From e75d6f4eac31422b705196f72f7937edf2c1bcb8 Mon Sep 17 00:00:00 2001 From: lybell Date: Wed, 27 Mar 2024 00:06:18 +0900 Subject: [PATCH] [Chore] update dist --- dist/core/xnb-core.cjs | 3680 ++++++---------- dist/core/xnb-core.es5.js | 4229 +++++++------------ dist/core/xnb-core.es5.min.js | 4 +- dist/core/xnb-core.js | 3680 ++++++---------- dist/core/xnb-core.min.js | 4 +- dist/core/xnb-core.module.js | 3713 +++++++--------- dist/plugins/stardewvalley/index.es5.min.js | 9 - dist/readers/xnb-readers.cjs | 536 +-- dist/readers/xnb-readers.es5.js | 1343 +++--- dist/readers/xnb-readers.es5.min.js | 4 +- dist/readers/xnb-readers.js | 536 +-- dist/readers/xnb-readers.min.js | 4 +- dist/readers/xnb-readers.module.js | 537 +-- package.json | 2 +- 14 files changed, 6677 insertions(+), 11604 deletions(-) delete mode 100644 dist/plugins/stardewvalley/index.es5.min.js diff --git a/dist/core/xnb-core.cjs b/dist/core/xnb-core.cjs index ec515d4..021d146 100644 --- a/dist/core/xnb-core.cjs +++ b/dist/core/xnb-core.cjs @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -30,17 +30,14 @@ const __promise_allSettled = Promise.allSettled !== undefined ? Promise.allSettl function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } - return keys; } - function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; @@ -50,10 +47,8 @@ function _objectSpread2(target) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } - return target; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { @@ -65,7 +60,6 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } @@ -77,13 +71,63 @@ class XnbError extends Error { this.message = message; Error.captureStackTrace(this, XnbError); } +} +class ReflectiveSchemeReader { + static isTypeOf(type) { + return false; + } + static hasSubType() { + return false; + } + static type() { + return "ReflectiveScheme"; + } + constructor(name, readers) { + this.name = name; + this.readers = readers; + } + read(buffer, resolver) { + const result = {}; + for (let [key, reader] of this.readers.entries()) { + if (reader.isValueType()) result[key] = reader.read(buffer);else if (reader.constructor.type() === "Nullable") result[key] = reader.read(buffer, resolver);else result[key] = resolver.read(buffer); + } + return result; + } + write(buffer, content, resolver) { + buffer.alloc(163518); + this.writeIndex(buffer, resolver); + for (let [key, reader] of this.readers.entries()) { + reader.write(buffer, content[key], reader.isValueType() ? null : resolver); + } + } + writeIndex(buffer, resolver) { + if (resolver != null) buffer.write7BitNumber(Number.parseInt(resolver.getIndex(this)) + 1); + } + isValueType() { + return false; + } + get type() { + const reg = /\.([^\.]+)$/; + if (reg.test(this.name)) return this.name.match(reg)[1]; + return this.name; + } + parseTypeList() { + let types = [...this.readers.values()].map(reader => { + if (reader.isValueType()) return null; + return reader.parseTypeList(); + }).flat(); + types.unshift(this.type); + return types; + } + toString() { + return "ReflectiveScheme<".concat(this.name, ">"); + } } function removeExternBracket(str) { let bracketStack = []; let result = []; - for (let i = 0; i < str.length; i++) { let c = str[i]; if (c === "[") bracketStack.push(i);else if (c === "]") { @@ -92,50 +136,59 @@ function removeExternBracket(str) { if (bracketStack.length === 0) result.push(str.slice(startPoint + 1, i)); } } - return result; } - class TypeReader { static setReaders(readers) { TypeReader.readers = _objectSpread2({}, readers); } - static addReaders(readers) { TypeReader.readers = _objectSpread2(_objectSpread2({}, TypeReader.readers), readers); } - + static setSchemes(schemes) { + TypeReader.schemes = _objectSpread2({}, schemes); + } + static addSchemes(schemes) { + TypeReader.schemes = _objectSpread2(_objectSpread2({}, TypeReader.schemes), schemes); + } + static setEnum(enumList) { + TypeReader.enumList.clear(); + enumList.forEach(id => TypeReader.enumList.add(id)); + } + static addEnum(enumList) { + enumList.forEach(id => TypeReader.enumList.add(id)); + } static makeSimplied(type, reader) { let simple = type.split(/`|,/)[0]; - if (reader.isTypeOf(simple)) { if (reader.hasSubType()) { let subtypes = TypeReader.parseSubtypes(type).map(TypeReader.simplifyType.bind(TypeReader)); return "".concat(reader.type(), "<").concat(subtypes.join(","), ">"); } else return reader.type(); } - return null; } - + static simplifyReflectiveType(subType) { + let simple = subType.split(/`|,/)[0]; + for (let reader of Object.values(TypeReader.readers)) { + if (reader.isTypeOf(simple)) return reader.type(); + } + if (TypeReader.schemes.hasOwnProperty(simple)) return "ReflectiveScheme<".concat(simple, ">"); + throw new XnbError("Non-implemented scheme found, cannot resolve scheme \"".concat(simple, "\", \"").concat(subType, "\".")); + } static simplifyType(type) { let simple = type.split(/`|,/)[0]; let isArray = simple.endsWith('[]'); - if (isArray) return "Array<".concat(simplifyType(simple.slice(0, -2)), ">"); - - if (simple === 'Microsoft.Xna.Framework.Content.ReflectiveReader') { - let reflectiveType = TypeReader.parseSubtypes(type).map(TypeReader.simplifyType.bind(TypeReader)); - return "".concat(reflectiveType); - } - + if (isArray) return "Array<".concat(TypeReader.simplifyType(simple.slice(0, -2)), ">"); + if (simple === 'Microsoft.Xna.Framework.Content.ReflectiveReader') return TypeReader.simplifyReflectiveType(TypeReader.parseSubtypes(type)[0]); for (let reader of Object.values(TypeReader.readers)) { let result = TypeReader.makeSimplied(type, reader); if (result !== null) return result; } - + if (TypeReader.schemes.hasOwnProperty(simple)) return "ReflectiveScheme<".concat(simple, ">"); + if (TypeReader.enumList.has(simple)) return "Int32"; throw new XnbError("Non-implemented type found, cannot resolve type \"".concat(simple, "\", \"").concat(type, "\".")); } - static parseSubtypes(type) { let subtype = type.slice(type.search("`") + 1); subtype[0]; @@ -143,7 +196,6 @@ class TypeReader { let matches = removeExternBracket(subtype); return matches; } - static getTypeInfo(type) { let mainType = type.match(/[^<]+/)[0]; let subtypes = type.match(/<(.+)>/); @@ -153,86 +205,121 @@ class TypeReader { subtypes }; } - static getReaderTypeList(typeString) { let reader = TypeReader.getReader(typeString); return reader.parseTypeList(); } - static getReader(typeString) { let { type, subtypes } = TypeReader.getTypeInfo(typeString); + if (type === "ReflectiveScheme") return makeReflectiveReader(subtypes[0]); subtypes = subtypes.map(TypeReader.getReader.bind(TypeReader)); if (TypeReader.readers.hasOwnProperty("".concat(type, "Reader"))) return new TypeReader.readers["".concat(type, "Reader")](...subtypes); + if (TypeReader.schemes.hasOwnProperty(type)) return makeReflectiveReader(type); throw new XnbError("Invalid reader type \"".concat(typeString, "\" passed, unable to resolve!")); } - + static getReaderClass(typeString) { + if (TypeReader.readers.hasOwnProperty(typeString)) return TypeReader.readers[typeString]; + throw new XnbError("There is no \"".concat(typeString, "\" class in reader list!")); + } static getReaderFromRaw(typeString) { const simplified = TypeReader.simplifyType(typeString); return TypeReader.getReader(simplified); } - } - _defineProperty(TypeReader, "readers", {}); +_defineProperty(TypeReader, "schemes", {}); +_defineProperty(TypeReader, "enumList", new Set()); +function makeReflectiveReader(className) { + if (!TypeReader.schemes.hasOwnProperty(className)) throw new XnbError("Unsupported scheme : ".concat(className)); + let scheme = TypeReader.schemes[className]; + if (scheme instanceof Map === false) { + scheme = convertSchemeToReader(scheme); + TypeReader.schemes[className] = scheme; + } + return new ReflectiveSchemeReader(className, scheme); +} +function convertSchemeEntryToReader(scheme) { + if (typeof scheme === "string") return TypeReader.getReader(scheme); + if (Array.isArray(scheme)) { + const ListReader = TypeReader.getReaderClass("ListReader"); + return new ListReader(convertSchemeEntryToReader(scheme[0])); + } + if (typeof scheme === "object") { + const keyCount = Object.keys(scheme).length; + if (keyCount === 1) { + const DictionaryReader = TypeReader.getReaderClass("DictionaryReader"); + const [key, value] = Object.entries(scheme)[0]; + return new DictionaryReader(convertSchemeEntryToReader(key), convertSchemeEntryToReader(value)); + } else if (keyCount > 1) { + return convertSchemeToReader(scheme); + } + } + throw new XnbError("Invalid Scheme to convert! : ".concat(scheme)); +} +function convertSchemeToReader(scheme) { + const result = new Map(); + for (let [key, type] of Object.entries(scheme)) { + let reader = convertSchemeEntryToReader(type); + if (key.startsWith("$")) { + key = key.slice(1); + try { + reader = new TypeReader.readers.NullableReader(reader); + } catch (_unused) { + throw new XnbError("There is no NullableReader from reader list!"); + } + } + result.set(key, reader); + } + return result; +} const UTF8_FIRST_BITES = [0xC0, 0xE0, 0xF0]; const UTF8_SECOND_BITES = 0x80; const UTF8_MASK = 0b111111; const UTF16_BITES$1 = [0xD800, 0xDC00]; const UTF16_MASK$1 = 0b1111111111; - function UTF8Encode(code) { if (code < 0x80) return [code]; if (code < 0x800) return [UTF8_FIRST_BITES[0] | code >> 6, UTF8_SECOND_BITES | code & UTF8_MASK]; if (code < 0x10000) return [UTF8_FIRST_BITES[1] | code >> 12, UTF8_SECOND_BITES | code >> 6 & UTF8_MASK, UTF8_SECOND_BITES | code & UTF8_MASK]; return [UTF8_FIRST_BITES[2] | code >> 18, UTF8_SECOND_BITES | code >> 12 & UTF8_MASK, UTF8_SECOND_BITES | code >> 6 & UTF8_MASK, UTF8_SECOND_BITES | code & UTF8_MASK]; } - function UTF16Encode(code) { if (code < 0xFFFF) return [code]; code -= 0x10000; return [UTF16_BITES$1[0] | code >> 10 & UTF16_MASK$1, UTF16_BITES$1[1] | code & UTF16_MASK$1]; } - function UTF8Decode(codeSet) { var _codeSet; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet = codeSet) !== null && _codeSet !== void 0 && _codeSet.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; if (codeSetRange === 2) return ((codeSet[0] ^ UTF8_FIRST_BITES[0]) << 6) + (codeSet[1] ^ UTF8_SECOND_BITES); - if (codeSetRange === 3) { return ((codeSet[0] ^ UTF8_FIRST_BITES[1]) << 12) + ((codeSet[1] ^ UTF8_SECOND_BITES) << 6) + (codeSet[2] ^ UTF8_SECOND_BITES); } - return ((codeSet[0] ^ UTF8_FIRST_BITES[2]) << 18) + ((codeSet[1] ^ UTF8_SECOND_BITES) << 12) + ((codeSet[2] ^ UTF8_SECOND_BITES) << 6) + (codeSet[3] ^ UTF8_SECOND_BITES); } - function UTF16Decode$1(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; return ((codeSet[0] & UTF16_MASK$1) << 10) + (codeSet[1] & UTF16_MASK$1) + 0x10000; } - function stringToUnicode$1(str) { const utf16Map = Array.from({ length: str.length }, (_, i) => str.charCodeAt(i)); const result = []; let index = 0; - while (index < str.length) { let code = utf16Map[index]; - if ((UTF16_BITES$1[0] & code) !== UTF16_BITES$1[0]) { result.push(code); index++; @@ -241,18 +328,14 @@ function stringToUnicode$1(str) { index += 2; } } - return result; } - function UTF8ToUnicode(codes) { const dataArray = codes instanceof ArrayBuffer ? new Uint8Array(codes) : codes; const result = []; let index = 0; - while (index < dataArray.length) { let headerCode = dataArray[index]; - if ((headerCode & 0x80) === 0) { result.push(headerCode); index++; @@ -267,47 +350,35 @@ function UTF8ToUnicode(codes) { index += 4; } } - return result; } - function UnicodeToUTF8(unicodeArr) { const result = []; - for (let code of unicodeArr) { result.push(...UTF8Encode(code)); } - return result; } - function UnicodeToString(unicodeArr) { const result = []; - for (let code of unicodeArr) { result.push(...UTF16Encode(code)); } - const blockSize = 32768; let resultStr = ""; - for (let i = 0; i < result.length / blockSize; i++) { resultStr += String.fromCharCode(...result.slice(i * blockSize, (i + 1) * blockSize)); } - return resultStr; } - function stringToUTF8(str) { return UnicodeToUTF8(stringToUnicode$1(str)); } - function UTF8ToString(utf8Array) { return UnicodeToString(UTF8ToUnicode(utf8Array)); } const LITTLE_ENDIAN = true; - class BufferReader { constructor(buffer) { let endianus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LITTLE_ENDIAN; @@ -317,7 +388,6 @@ class BufferReader { this._offset = 0; this._bitOffset = 0; } - seek(index) { let origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._offset; const offset = this._offset; @@ -325,34 +395,27 @@ class BufferReader { if (this._offset < 0 || this._offset > this.buffer.length) throw new RangeError("Buffer seek out of bounds! ".concat(this._offset, " ").concat(this.buffer.length)); return this._offset - offset; } - get bytePosition() { return Number.parseInt(this._offset); } - set bytePosition(value) { this._offset = value; } - get bitPosition() { return Number.parseInt(this._bitOffset); } - set bitPosition(offset) { if (offset < 0) offset = 16 - offset; this._bitOffset = offset % 16; const byteSeek = (offset - Math.abs(offset) % 16) / 16 * 2; this.seek(byteSeek); } - get size() { return this.buffer.byteLength; } - get buffer() { return this._buffer; } - copyFrom(buffer) { let targetIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; let sourceIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; @@ -361,97 +424,73 @@ class BufferReader { const isOverflow = this.buffer.byteLength < length + targetIndex; let targetBuffer = this.buffer; let targetView = this._dataView; - if (isOverflow) { targetBuffer = new ArrayBuffer(this.buffer.byteLength + (length + targetIndex - this.buffer.byteLength)); targetView = new DataView(targetBuffer); - for (let i = 0; i < this.buffer.byteLength; i++) { targetView.setUint8(i, this._dataView.getUint8(i)); } } - for (let i = sourceIndex, j = targetIndex; i < length; i++, j++) { targetView.setUint8(j, sourceView[i]); } - if (isOverflow) { this._buffer = targetBuffer; this._dataView = targetView; } } - read(count) { const buffer = this.buffer.slice(this._offset, this._offset + count); this.seek(count); return buffer; } - readByte() { return this.readUInt(); } - readInt() { const value = this._dataView.getInt8(this._offset); - this.seek(1); return value; } - readUInt() { const value = this._dataView.getUint8(this._offset); - this.seek(1); return value; } - readUInt16() { const value = this._dataView.getUint16(this._offset, this._endianus); - this.seek(2); return value; } - readUInt32() { const value = this._dataView.getUint32(this._offset, this._endianus); - this.seek(4); return value; } - readInt16() { const value = this._dataView.getInt16(this._offset, this._endianus); - this.seek(2); return value; } - readInt32() { const value = this._dataView.getInt32(this._offset, this._endianus); - this.seek(4); return value; } - readSingle() { const value = this._dataView.getFloat32(this._offset, this._endianus); - this.seek(4); return value; } - readDouble() { - const value = this._dataView.getFloat32(this._offset, this._endianus); - + const value = this._dataView.getFloat64(this._offset, this._endianus); this.seek(8); return value; } - readString() { let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1; const chars = []; this._offset; - if (count === -1) { while (this.peekByte(1) != 0x0) chars.push(this.readByte()); } else { @@ -459,73 +498,52 @@ class BufferReader { chars.push(this.readByte()); } } - return UTF8ToString(chars); } - peek(count) { const buffer = this.read(count); this.seek(-count); return buffer; } - peekByte() { return this.peekUInt(); } - peekInt() { const value = this._dataView.getInt8(this._offset); - return value; } - peekUInt() { const value = this._dataView.getUint8(this._offset); - return value; } - peekUInt16() { const value = this._dataView.getUint16(this._offset, this._endianus); - return value; } - peekUInt32() { const value = this._dataView.getUint32(this._offset, this._endianus); - return value; } - peekInt16() { const value = this._dataView.getInt16(this._offset, this._endianus); - return value; } - peekInt32() { const value = this._dataView.getInt32(this._offset, this._endianus); - return value; } - peekSingle() { const value = this._dataView.getFloat32(this._offset, this._endianus); - return value; } - peekDouble() { const value = this._dataView.getFloat64(this._offset, this._endianus); - return value; } - peekString() { let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; const chars = []; const startOffset = this._offset; - if (count === 0) { while (this.peekByte(1) != 0x0) chars.push(this.readByte()); } else { @@ -533,32 +551,25 @@ class BufferReader { chars.push(this.readByte()); } } - this.bytePosition = startOffset; return UTF8ToString(chars); } - read7BitNumber() { let result = 0; let bitsRead = 0; let value; - do { value = this.readByte(); result |= (value & 0x7F) << bitsRead; bitsRead += 7; } while (value & 0x80); - return result; } - readLZXBits(bits) { let bitsLeft = bits; let read = 0; - while (bitsLeft > 0) { const peek = this._dataView.getUint16(this._offset, true); - const bitsInFrame = Math.min(Math.max(bitsLeft, 0), 16 - this.bitPosition); const offset = 16 - this.bitPosition - bitsInFrame; const value = (peek & 2 ** bitsInFrame - 1 << offset) >> offset; @@ -566,10 +577,8 @@ class BufferReader { this.bitPosition += bitsInFrame; read |= value << bitsLeft; } - return read; } - peekLZXBits(bits) { let bitPosition = this.bitPosition; let bytePosition = this.bytePosition; @@ -578,7 +587,6 @@ class BufferReader { this.bytePosition = bytePosition; return read; } - readLZXInt16() { let seek = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; const lsB = this.readByte(); @@ -586,11 +594,9 @@ class BufferReader { if (!seek) this.seek(-2); return lsB << 8 | msB; } - align() { if (this.bitPosition > 0) this.bitPosition += 16 - this.bitPosition; } - } class BufferWriter { @@ -600,135 +606,98 @@ class BufferWriter { this._dataView = new DataView(this._buffer); this.bytePosition = 0; } - get buffer() { return this._buffer; } - reconnectDataView() { this._dataView = new DataView(this._buffer); } - trim() { let pending = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; this._buffer = this.buffer.slice(0, this.bytePosition); if (!pending) this.reconnectDataView(); } - alloc(bytes) { if (this._buffer.byteLength <= this.bytePosition + bytes) { const tBuffer = new ArrayBuffer(this._buffer.byteLength + bytes); const tDataView = new DataView(tBuffer); - for (let i = 0; i < this.buffer.byteLength; i++) { tDataView.setUint8(i, this._dataView.getUint8(i)); } - this._buffer = tBuffer; this._dataView = tDataView; } - return this; } - concat(buffer) { const targetBufferView = new Uint8Array(buffer); const newPosition = this.bytePosition + targetBufferView.length; this.alloc(targetBufferView.length); - for (let i = this.bytePosition; i < newPosition; i++) { this._dataView.setUint8(i, targetBufferView[i - this.bytePosition]); } - this.bytePosition = newPosition; this.trim(); } - write(bytes) { const targetBufferView = new Uint8Array(bytes); const newPosition = this.bytePosition + targetBufferView.length; this.alloc(targetBufferView.length); - for (let i = this.bytePosition; i < newPosition; i++) { this._dataView.setUint8(i, targetBufferView[i - this.bytePosition]); } - this.bytePosition = newPosition; } - writeString(str) { let utf8Data = stringToUTF8(str); this.write(utf8Data); } - writeByte(byte) { this.alloc(1)._dataView.setUint8(this.bytePosition, byte); - this.bytePosition++; } - writeInt(number) { this.alloc(1)._dataView.setInt8(this.bytePosition, number); - this.bytePosition++; } - writeUInt(number) { this.alloc(1)._dataView.setUint8(this.bytePosition, number); - this.bytePosition++; } - writeInt16(number) { this.alloc(2)._dataView.setInt16(this.bytePosition, number, true); - this.bytePosition += 2; } - writeUInt16(number) { this.alloc(2)._dataView.setUint16(this.bytePosition, number, true); - this.bytePosition += 2; } - writeInt32(number) { this.alloc(4)._dataView.setInt32(this.bytePosition, number, true); - this.bytePosition += 4; } - writeUInt32(number) { this.alloc(4)._dataView.setUint32(this.bytePosition, number, true); - this.bytePosition += 4; } - writeSingle(number) { this.alloc(4)._dataView.setFloat32(this.bytePosition, number, true); - this.bytePosition += 4; } - writeDouble(number) { this.alloc(8)._dataView.setFloat64(this.bytePosition, number, true); - this.bytePosition += 8; } - write7BitNumber(number) { this.alloc(2); - do { let byte = number & 0x7F; number = number >> 7; if (number) byte |= 0x80; - this._dataView.setUint8(this.bytePosition, byte); - this.bytePosition++; } while (number); } - } /** @license @@ -788,26 +757,22 @@ const LENGTH_MAXSYMBOLS = NUM_SECONDARY_LENGTHS + 1; const LENGTH_TABLEBITS = 12; const ALIGNED_MAXSYMBOLS = ALIGNED_NUM_ELEMENTS; const ALIGNED_TABLEBITS = 7; - class Lzx { constructor(window_bits) { this.window_size = 1 << window_bits; if (window_bits < 15 || window_bits > 21) throw new XnbError('Window size out of range!'); - if (!Lzx.extra_bits.length) { for (let i = 0, j = 0; i <= 50; i += 2) { Lzx.extra_bits[i] = Lzx.extra_bits[i + 1] = j; if (i != 0 && j < 17) j++; } } - if (!Lzx.position_base.length) { for (let i = 0, j = 0; i <= 50; i++) { Lzx.position_base[i] = j; j += 1 << Lzx.extra_bits[i]; } } - const posn_slots = window_bits == 21 ? 50 : window_bits == 20 ? 42 : window_bits << 1; this.R0 = this.R1 = this.R2 = 1; this.main_elements = NUM_CHARS + (posn_slots << 3); @@ -823,36 +788,27 @@ class Lzx { this.length_len = []; this.maintree_table = []; this.maintree_len = []; - for (let i = 0; i < MAINTREE_MAXSYMBOLS; i++) this.maintree_len[i] = 0; - for (let i = 0; i < NUM_SECONDARY_LENGTHS; i++) this.length_len[i] = 0; - this.win = []; } - decompress(buffer, frame_size, block_size) { if (!this.header_read) { const intel = buffer.readLZXBits(1); if (intel != 0) throw new XnbError("Intel E8 Call found, invalid for XNB files."); this.header_read = true; } - let togo = frame_size; - while (togo > 0) { if (this.block_remaining == 0) { this.block_type = buffer.readLZXBits(3); const hi = buffer.readLZXBits(16); const lo = buffer.readLZXBits(8); this.block_remaining = hi << 8 | lo; - switch (this.block_type) { case BLOCKTYPE.ALIGNED: for (let i = 0; i < 8; i++) this.aligned_len[i] = buffer.readLZXBits(3); - this.aligned_table = this.decodeTable(ALIGNED_MAXSYMBOLS, ALIGNED_TABLEBITS, this.aligned_len); - case BLOCKTYPE.VERBATIM: this.readLengths(buffer, this.maintree_len, 0, 256); this.readLengths(buffer, this.maintree_len, 256, this.main_elements); @@ -860,55 +816,44 @@ class Lzx { this.readLengths(buffer, this.length_len, 0, NUM_SECONDARY_LENGTHS); this.length_table = this.decodeTable(LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS, this.length_len); break; - case BLOCKTYPE.UNCOMPRESSED: buffer.align(); this.R0 = buffer.readInt32(); this.R1 = buffer.readInt32(); this.R2 = buffer.readInt32(); break; - default: throw new XnbError("Invalid Blocktype Found: ".concat(this.block_type)); } } - let this_run = this.block_remaining; - while ((this_run = this.block_remaining) > 0 && togo > 0) { if (this_run > togo) this_run = togo; togo -= this_run; this.block_remaining -= this_run; this.window_posn &= this.window_size - 1; if (this.window_posn + this_run > this.window_size) throw new XnbError('Cannot run outside of window frame.'); - switch (this.block_type) { case BLOCKTYPE.ALIGNED: while (this_run > 0) { let main_element = this.readHuffSymbol(buffer, this.maintree_table, this.maintree_len, MAINTREE_MAXSYMBOLS, MAINTREE_TABLEBITS); - if (main_element < NUM_CHARS) { this.win[this.window_posn++] = main_element; this_run--; continue; } - main_element -= NUM_CHARS; let length_footer; let match_length = main_element & NUM_PRIMARY_LENGTHS; - if (match_length == NUM_PRIMARY_LENGTHS) { length_footer = this.readHuffSymbol(buffer, this.length_table, this.length_len, LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS); match_length += length_footer; } - match_length += MIN_MATCH; let match_offset = main_element >> 3; - if (match_offset > 2) { let extra = Lzx.extra_bits[match_offset]; match_offset = Lzx.position_base[match_offset] - 2; - if (extra > 3) { extra -= 3; let verbatim_bits = buffer.readLZXBits(extra); @@ -918,7 +863,6 @@ class Lzx { } else if (extra == 3) { match_offset += this.readHuffSymbol(buffer, this.aligned_table, this.aligned_len, ALIGNED_MAXSYMBOLS, ALIGNED_TABLEBITS); } else if (extra > 0) match_offset += buffer.readLZXBits(extra);else match_offset = 1; - this.R2 = this.R1; this.R1 = this.R0; this.R0 = match_offset; @@ -933,59 +877,46 @@ class Lzx { this.R2 = this.R0; this.R0 = match_offset; } - let rundest = this.window_posn; let runsrc; this_run -= match_length; if (this.window_posn >= match_offset) runsrc = rundest - match_offset;else { runsrc = rundest + (this.window_size - match_offset); let copy_length = match_offset - this.window_posn; - if (copy_length < match_length) { match_length -= copy_length; this.window_posn += copy_length; - while (copy_length-- > 0) this.win[rundest++] = this.win[runsrc++]; - runsrc = 0; } } this.window_posn += match_length; - while (match_length-- > 0) this.win[rundest++] = this.win[runsrc++]; } - break; - case BLOCKTYPE.VERBATIM: while (this_run > 0) { let main_element = this.readHuffSymbol(buffer, this.maintree_table, this.maintree_len, MAINTREE_MAXSYMBOLS, MAINTREE_TABLEBITS); - if (main_element < NUM_CHARS) { this.win[this.window_posn++] = main_element; this_run--; continue; } - main_element -= NUM_CHARS; let length_footer; let match_length = main_element & NUM_PRIMARY_LENGTHS; - if (match_length == NUM_PRIMARY_LENGTHS) { length_footer = this.readHuffSymbol(buffer, this.length_table, this.length_len, LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS); match_length += length_footer; } - match_length += MIN_MATCH; let match_offset = main_element >> 3; - if (match_offset > 2) { if (match_offset != 3) { let extra = Lzx.extra_bits[match_offset]; let verbatim_bits = buffer.readLZXBits(extra); match_offset = Lzx.position_base[match_offset] - 2 + verbatim_bits; } else match_offset = 1; - this.R2 = this.R1; this.R1 = this.R0; this.R0 = match_offset; @@ -1000,73 +931,55 @@ class Lzx { this.R2 = this.R0; this.R0 = match_offset; } - let rundest = this.window_posn; let runsrc; this_run -= match_length; if (this.window_posn >= match_offset) runsrc = rundest - match_offset;else { runsrc = rundest + (this.window_size - match_offset); let copy_length = match_offset - this.window_posn; - if (copy_length < match_length) { match_length -= copy_length; this.window_posn += copy_length; - while (copy_length-- > 0) this.win[rundest++] = this.win[runsrc++]; - runsrc = 0; } } this.window_posn += match_length; - while (match_length-- > 0) this.win[rundest++] = this.win[runsrc++]; } - break; - case BLOCKTYPE.UNCOMPRESSED: if (buffer.bytePosition + this_run > block_size) throw new XnbError('Overrun!' + block_size + ' ' + buffer.bytePosition + ' ' + this_run); - for (let i = 0; i < this_run; i++) this.win[window_posn + i] = buffer.buffer[buffer.bytePosition + i]; - buffer.bytePosition += this_run; this.window_posn += this_run; break; - default: throw new XnbError('Invalid blocktype specified!'); } } } - if (togo != 0) throw new XnbError('EOF reached with data left to go.'); buffer.align(); const start_window_pos = (this.window_posn == 0 ? this.window_size : this.window_posn) - frame_size; return this.win.slice(start_window_pos, start_window_pos + frame_size); } - readLengths(buffer, table, first, last) { for (let i = 0; i < 20; i++) this.pretree_len[i] = buffer.readLZXBits(4); - this.pretree_table = this.decodeTable(PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS, this.pretree_len); - for (let i = first; i < last;) { let symbol = this.readHuffSymbol(buffer, this.pretree_table, this.pretree_len, PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS); - if (symbol == 17) { let zeros = buffer.readLZXBits(4) + 4; - while (zeros-- != 0) table[i++] = 0; } else if (symbol == 18) { let zeros = buffer.readLZXBits(5) + 20; - while (zeros-- != 0) table[i++] = 0; } else if (symbol == 19) { let same = buffer.readLZXBits(1) + 4; symbol = this.readHuffSymbol(buffer, this.pretree_table, this.pretree_len, PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS); symbol = table[i] - symbol; if (symbol < 0) symbol += 17; - while (same-- != 0) table[i++] = symbol; } else { symbol = table[i] - symbol; @@ -1074,77 +987,58 @@ class Lzx { table[i++] = symbol; } } - return table; } - decodeTable(symbols, bits, length) { let table = []; let pos = 0; let table_mask = 1 << bits; let bit_mask = table_mask >> 1; - for (let bit_num = 1; bit_num <= bits; bit_num++) { for (let symbol = 0; symbol < symbols; symbol++) { if (length[symbol] == bit_num) { let leaf = pos; - if ((pos += bit_mask) > table_mask) { throw new XnbError('Overrun table!'); } - let fill = bit_mask; - while (fill-- > 0) table[leaf++] = symbol; } } - bit_mask >>= 1; } - if (pos == table_mask) return table; - for (let symbol = pos; symbol < table_mask; symbol++) table[symbol] = 0xFFFF; - let next_symbol = table_mask >> 1 < symbols ? symbols : table_mask >> 1; pos <<= 16; table_mask <<= 16; bit_mask = 1 << 15; - for (let bit_num = bits + 1; bit_num <= 16; bit_num++) { for (let symbol = 0; symbol < symbols; symbol++) { if (length[symbol] != bit_num) continue; let leaf = pos >> 16; - for (let fill = 0; fill < bit_num - bits; fill++) { if (table[leaf] == 0xFFFF) { table[next_symbol << 1] = 0xFFFF; table[(next_symbol << 1) + 1] = 0xFFFF; table[leaf] = next_symbol++; } - leaf = table[leaf] << 1; if (pos >> 15 - fill & 1) leaf++; } - table[leaf] = symbol; if ((pos += bit_mask) > table_mask) throw new XnbError('Overrun table during decoding.'); } - bit_mask >>= 1; } - if (pos == table_mask) return table; throw new XnbError('Decode table did not reach table mask.'); } - readHuffSymbol(buffer, table, length, symbols, bits) { let bit = buffer.peekLZXBits(32) >>> 0; let i = table[buffer.peekLZXBits(bits)]; - if (i >= symbols) { let j = 1 << 32 - bits; - do { j >>= 1; i <<= 1; @@ -1152,11 +1046,9 @@ class Lzx { if (j == 0) return 0; } while ((i = table[i]) >= symbols); } - buffer.bitPosition += length[i]; return i; } - set RRR(X) { if (this.R0 != X && this.R1 != X && this.R2 != X) { this.R2 = this.R1; @@ -1172,9 +1064,7 @@ class Lzx { this.R0 = R2; } } - } - Lzx.position_base = []; Lzx.extra_bits = []; @@ -1185,10 +1075,8 @@ class Presser { let frame_size; const lzx = new Lzx(16); let decompressed = new BufferWriter(decompressedTodo); - while (pos < compressedTodo) { const flag = buffer.readByte(); - if (flag == 0xFF) { frame_size = buffer.readLZXInt16(); block_size = buffer.readLZXInt16(); @@ -1199,18 +1087,15 @@ class Presser { frame_size = 0x8000; pos += 2; } - if (block_size == 0 || frame_size == 0) break; if (block_size > 0x10000 || frame_size > 0x10000) throw new XnbError('Invalid size read in compression content.'); decompressed.write(lzx.decompress(buffer, frame_size, block_size)); pos += block_size; } - console.log('File has been successfully decompressed!'); decompressed.trim(); return decompressed.buffer; } - } class LZ4Utils { @@ -1223,7 +1108,6 @@ class LZ4Utils { a = a + -42973499 + (a << 3) | 0; return a ^ -1252372727 ^ a >>> 16 | 0; } - static readU64(b, n) { var x = 0; x |= b[n++] << 0; @@ -1236,7 +1120,6 @@ class LZ4Utils { x |= b[n++] << 56; return x; } - static readU32(b, n) { var x = 0; x |= b[n++] << 0; @@ -1245,14 +1128,12 @@ class LZ4Utils { x |= b[n++] << 24; return x; } - static writeU32(b, n, x) { b[n++] = x >> 0 & 0xff; b[n++] = x >> 8 & 0xff; b[n++] = x >> 16 & 0xff; b[n++] = x >> 24 & 0xff; } - static imul(a, b) { var ah = a >>> 16; var al = a & 65535; @@ -1260,12 +1141,8 @@ class LZ4Utils { var bl = b & 65535; return al * bl + (ah * bl + al * bh << 16) | 0; } - } -/** @license - * Original Code by: https://github.com/Benzinga/lz4js/ - */ const minMatch = 4; const minLength = 13; const searchLimit = 5; @@ -1277,45 +1154,36 @@ const runBits = 4; const runMask = (1 << runBits) - 1; makeBuffer(5 << 20); const hashTable = makeHashTable(); - function makeHashTable() { try { return new Uint32Array(hashSize); } catch (error) { const hashTable = new Array(hashSize); - for (var i = 0; i < hashSize; i++) { hashTable[i] = 0; } - return hashTable; } } - function clearHashTable(table) { for (var i = 0; i < hashSize; i++) { hashTable[i] = 0; } } - function makeBuffer(size) { try { return new Uint8Array(size); } catch (error) { var buf = new Array(size); - for (var i = 0; i < size; i++) { buf[i] = 0; } - return buf; } } - function compressBound(n) { return n + n / 255 + 16 | 0; } - function decompressBlock(src, dst) { let sIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; let sLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : src.length - 2 * sIndex; @@ -1323,46 +1191,36 @@ function decompressBlock(src, dst) { var mLength, mOffset, sEnd, n, i; var hasCopyWithin = dst.copyWithin !== undefined && dst.fill !== undefined; sEnd = sIndex + sLength; - while (sIndex < sEnd) { var token = src[sIndex++]; var literalCount = token >> 4; - if (literalCount > 0) { if (literalCount === 0xf) { while (true) { literalCount += src[sIndex]; - if (src[sIndex++] !== 0xff) { break; } } } - for (n = sIndex + literalCount; sIndex < n;) { dst[dIndex++] = src[sIndex++]; } } - if (sIndex >= sEnd) { break; } - mLength = token & 0xf; mOffset = src[sIndex++] | src[sIndex++] << 8; - if (mLength === 0xf) { while (true) { mLength += src[sIndex]; - if (src[sIndex++] !== 0xff) { break; } } } - mLength += minMatch; - if (hasCopyWithin && mOffset === 1) { dst.fill(dst[dIndex - 1] | 0, dIndex, dIndex + mLength); dIndex += mLength; @@ -1375,106 +1233,81 @@ function decompressBlock(src, dst) { } } } - return dIndex; } - function compressBlock(src, dst, sIndex, sLength, hashTable) { var mIndex, mAnchor, mLength, mOffset, mStep; var literalCount, dIndex, sEnd, n; dIndex = 0; sEnd = sLength + sIndex; mAnchor = sIndex; - if (sLength >= minLength) { var searchMatchCount = (1 << skipTrigger) + 3; - while (sIndex + minMatch < sEnd - searchLimit) { var seq = LZ4Utils.readU32(src, sIndex); var hash = LZ4Utils.hashU32(seq) >>> 0; hash = (hash >> 16 ^ hash) >>> 0 & 0xffff; mIndex = hashTable[hash] - 1; hashTable[hash] = sIndex + 1; - if (mIndex < 0 || sIndex - mIndex >>> 16 > 0 || LZ4Utils.readU32(src, mIndex) !== seq) { mStep = searchMatchCount++ >> skipTrigger; sIndex += mStep; continue; } - searchMatchCount = (1 << skipTrigger) + 3; literalCount = sIndex - mAnchor; mOffset = sIndex - mIndex; sIndex += minMatch; mIndex += minMatch; mLength = sIndex; - while (sIndex < sEnd - searchLimit && src[sIndex] === src[mIndex]) { sIndex++; mIndex++; } - mLength = sIndex - mLength; var token = mLength < mlMask ? mLength : mlMask; - if (literalCount >= runMask) { dst[dIndex++] = (runMask << mlBits) + token; - for (n = literalCount - runMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } else { dst[dIndex++] = (literalCount << mlBits) + token; } - for (var i = 0; i < literalCount; i++) { dst[dIndex++] = src[mAnchor + i]; } - dst[dIndex++] = mOffset; dst[dIndex++] = mOffset >> 8; - if (mLength >= mlMask) { for (n = mLength - mlMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } - mAnchor = sIndex; } } - if (mAnchor === 0) { return 0; } - literalCount = sEnd - mAnchor; - if (literalCount >= runMask) { dst[dIndex++] = runMask << mlBits; - for (n = literalCount - runMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } else { dst[dIndex++] = literalCount << mlBits; } - sIndex = mAnchor; - while (sIndex < sEnd) { dst[dIndex++] = src[sIndex++]; } - return dIndex; } - function compressSingleBlock(src, dst) { clearHashTable(); return compressBlock(src, dst, 0, src.length, hashTable); @@ -1482,27 +1315,22 @@ function compressSingleBlock(src, dst) { const UTF16_BITES = [0xD800, 0xDC00]; const UTF16_MASK = 0b1111111111; - function UTF16Decode(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; return ((codeSet[0] & UTF16_MASK) << 10) + (codeSet[1] & UTF16_MASK) + 0x10000; } - function stringToUnicode(str) { const utf16Map = Array.from({ length: str.length }, (_, i) => str.charCodeAt(i)); const result = []; let index = 0; - while (index < str.length) { let code = utf16Map[index]; - if ((UTF16_BITES[0] & code) !== UTF16_BITES[0]) { result.push(code); index++; @@ -1511,10 +1339,8 @@ function stringToUnicode(str) { index += 2; } } - return result; } - function UTF8Length(str) { const codes = stringToUnicode(str); return codes.reduce((sum, unicode) => { @@ -1530,36 +1356,30 @@ class StringReaderCore { let length = buffer.read7BitNumber(); return buffer.readString(length); } - write(buffer, string) { const size = UTF8Length(string); buffer.write7BitNumber(size); buffer.writeString(string); } - } class ReaderResolver { constructor(readers) { this.readers = readers; } - read(buffer) { let index = buffer.read7BitNumber() - 1; - if (this.readers[index] == null) throw new XnbError("Invalid reader index ".concat(index)); + if (this.readers[index] == null) throw new XnbError("Invalid reader index ".concat(index, " | pos: ").concat(buffer.bytePosition.toString(16))); return this.readers[index].read(buffer, this); } - write(buffer, content) { this.readers[0].write(buffer, content, this); } - getIndex(reader) { for (let i = 0, len = this.readers.length; i < len; i++) { if (reader.toString() === this.readers[i].toString()) return i; } } - } class XnbData { @@ -1579,61 +1399,44 @@ class XnbData { this.readers = readers; this.content = content; } - get target() { var _this$header; - switch ((_this$header = this.header) === null || _this$header === void 0 ? void 0 : _this$header.target) { case 'w': return "Microsoft Windows"; - case 'm': return "Windows Phone 7"; - case 'x': return "Xbox 360"; - case 'a': return "Android"; - case 'i': return "iOS"; - default: return "Unknown"; } } - get formatVersion() { var _this$header2; - switch ((_this$header2 = this.header) === null || _this$header2 === void 0 ? void 0 : _this$header2.formatVersion) { case 0x3: return "XNA Game Studio 3.0"; - case 0x4: return "XNA Game Studio 3.1"; - case 0x5: return "XNA Game Studio 4.0"; - default: return "Unknown"; } } - get hidef() { var _this$header3; - return !!((_this$header3 = this.header) !== null && _this$header3 !== void 0 && _this$header3.hidef); } - get compressed() { var _this$header4; - return !!((_this$header4 = this.header) !== null && _this$header4 !== void 0 && _this$header4.compressed); } - get contentType() { let { export: raw @@ -1641,7 +1444,6 @@ class XnbData { if (raw !== undefined) return raw.type; return "JSON"; } - get rawContent() { let { export: raw @@ -1652,7 +1454,6 @@ class XnbData { return value; }, 4); } - stringify() { return JSON.stringify({ header: this.header, @@ -1660,50 +1461,38 @@ class XnbData { content: this.content }, null, 4); } - toString() { return this.stringify(); } - } - function extensionToDatatype(extension) { switch (extension) { case "json": return "JSON"; - case "yaml": return "yaml"; - case "png": return "Texture2D"; - case "cso": return "Effect"; - case 'tbin': return "TBin"; - case 'xml': return "BmFont"; } - return "Others"; } - class XnbContent { constructor(data, ext) { this.type = extensionToDatatype(ext); this.content = data; } - } const HIDEF_MASK = 0x1; const COMPRESSED_LZ4_MASK = 0x40; const COMPRESSED_LZX_MASK = 0x80; const XNB_COMPRESSED_PROLOGUE_SIZE = 14; - class XnbConverter { constructor() { this.target = ''; @@ -1716,19 +1505,14 @@ class XnbConverter { this.readers = []; this.sharedResources = []; } - load(arrayBuffer) { this.buffer = new BufferReader(arrayBuffer); - this._validateHeader(); - console.info('XNB file validated successfully!'); this.fileSize = this.buffer.readUInt32(); if (this.buffer.size != this.fileSize) throw new XnbError('XNB file has been truncated!'); - if (this.compressed) { const decompressedSize = this.buffer.readUInt32(); - if (this.compressionType == COMPRESSED_LZX_MASK) { const compressedTodo = this.fileSize - XNB_COMPRESSED_PROLOGUE_SIZE; const decompressed = Presser.decompress(this.buffer, compressedTodo, decompressedSize); @@ -1743,22 +1527,23 @@ class XnbConverter { this.buffer.bytePosition = XNB_COMPRESSED_PROLOGUE_SIZE; } } - let count = this.buffer.read7BitNumber(); const stringReader = new StringReaderCore(); const readers = []; - for (let i = 0; i < count; i++) { const type = stringReader.read(this.buffer); const version = this.buffer.readInt32(); - const reader = TypeReader.getReaderFromRaw(type); - this.readers.push(reader); readers.push({ type, version }); } - + this.readers = readers.map(_ref => { + let { + type + } = _ref; + return TypeReader.getReaderFromRaw(type); + }); const shared = this.buffer.read7BitNumber(); if (shared != 0) throw new XnbError("Unexpected (".concat(shared, ") shared resources.")); const content = new ReaderResolver(this.readers); @@ -1771,7 +1556,6 @@ class XnbConverter { compressed: this.compressed }, readers, result); } - convert(json) { const buffer = new BufferWriter(); const stringReader = new StringReaderCore(); @@ -1793,18 +1577,15 @@ class XnbConverter { buffer.writeUInt32(0); if (lz4Compression) buffer.writeUInt32(0); buffer.write7BitNumber(json.readers.length); - for (let reader of json.readers) { this.readers.push(TypeReader.getReaderFromRaw(reader.type)); stringReader.write(buffer, reader.type); buffer.writeUInt32(reader.version); } - buffer.write7BitNumber(0); const content = new ReaderResolver(this.readers); content.write(buffer, json.content); buffer.trim(); - if (lz4Compression) { const trimmed = buffer.buffer.slice(XNB_COMPRESSED_PROLOGUE_SIZE); const trimmedArray = new Uint8Array(trimmed); @@ -1819,13 +1600,11 @@ class XnbConverter { let returnBuffer = buffer.buffer.slice(0, XNB_COMPRESSED_PROLOGUE_SIZE + compressedSize); return returnBuffer; } - let fileSize = buffer.bytePosition; buffer.bytePosition = 6; buffer.writeUInt32(fileSize, 6); return buffer.buffer; } - _validateHeader() { if (this.buffer == null) throw new XnbError('Buffer is null'); const magic = this.buffer.readString(3); @@ -1837,7 +1616,6 @@ class XnbConverter { this.compressed = flags & COMPRESSED_LZX_MASK || (flags & COMPRESSED_LZ4_MASK) != 0; this.compressionType = (flags & COMPRESSED_LZX_MASK) != 0 ? COMPRESSED_LZX_MASK : flags & COMPRESSED_LZ4_MASK ? COMPRESSED_LZ4_MASK : 0; } - } function injectRGBA(data, i) { @@ -1853,23 +1631,18 @@ function injectRGBA(data, i) { data[4 * i + 3] = a; return [r, g, b, a]; } - function png16to8(data) { const megascale = new Uint16Array(data); const downscale = new Uint8Array(megascale.length); - for (let i = 0; i < megascale.length; i++) { downscale[i] = megascale[i] >> 8; } - return downscale; } - function addChannels(data, originChannel) { const size = data.length / originChannel; const rgbaData = new Uint8Array(size * 4); if (originChannel === 4) return data; - if (originChannel === 1) { for (let i = 0; i < size; i++) { injectRGBA(rgbaData, i, { @@ -1892,16 +1665,13 @@ function addChannels(data, originChannel) { }); } } - return rgbaData; } - function applyPalette(data, depth, palette) { const oldData = new Uint8Array(data); const length = oldData.length * 8 / depth; const newData = new Uint8Array(length * 4); let bitPosition = 0; - for (let i = 0; i < length; i++) { const bytePosition = Math.floor(bitPosition / 8); const bitOffset = 8 - bitPosition % 8 - depth; @@ -1910,10 +1680,8 @@ function applyPalette(data, depth, palette) { [newData[i * 4], newData[i * 4 + 1], newData[i * 4 + 2], newData[i * 4 + 3]] = palette[paletteIndex]; bitPosition += depth; } - return newData; } - function fixPNG(pngdata) { const { width, @@ -1931,104 +1699,92 @@ function fixPNG(pngdata) { } var t = { - 396: function _() { - !function (t) { - if (t.TextEncoder && t.TextDecoder) return !1; - - function e() { - let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; - if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t, "') is invalid.")); - } - - function i() { - let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; - let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - fatal: !1 - }; - if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t, "') is invalid.")); - if (e.fatal) throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported."); - } - - Object.defineProperty(e.prototype, "encoding", { - value: "utf-8" - }), e.prototype.encode = function (t) { - let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - stream: !1 - }; - if (e.stream) throw new Error("Failed to encode: the 'stream' option is unsupported."); - let i = 0; - const n = t.length; - let r = 0, + 396: function _() { + !function (t) { + if (t.TextEncoder && t.TextDecoder) return !1; + function e() { + let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; + if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t, "') is invalid.")); + } + function i() { + let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; + let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + fatal: !1 + }; + if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t, "') is invalid.")); + if (e.fatal) throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported."); + } + Object.defineProperty(e.prototype, "encoding", { + value: "utf-8" + }), e.prototype.encode = function (t) { + let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + stream: !1 + }; + if (e.stream) throw new Error("Failed to encode: the 'stream' option is unsupported."); + let i = 0; + const n = t.length; + let r = 0, s = Math.max(32, n + (n >> 1) + 7), a = new Uint8Array(s >> 3 << 3); - - for (; i < n;) { - let e = t.charCodeAt(i++); - - if (e >= 55296 && e <= 56319) { - if (i < n) { - const n = t.charCodeAt(i); - 56320 == (64512 & n) && (++i, e = ((1023 & e) << 10) + (1023 & n) + 65536); + for (; i < n;) { + let e = t.charCodeAt(i++); + if (e >= 55296 && e <= 56319) { + if (i < n) { + const n = t.charCodeAt(i); + 56320 == (64512 & n) && (++i, e = ((1023 & e) << 10) + (1023 & n) + 65536); + } + if (e >= 55296 && e <= 56319) continue; } - - if (e >= 55296 && e <= 56319) continue; - } - - if (r + 4 > a.length) { - s += 8, s *= 1 + i / t.length * 2, s = s >> 3 << 3; - const e = new Uint8Array(s); - e.set(a), a = e; + if (r + 4 > a.length) { + s += 8, s *= 1 + i / t.length * 2, s = s >> 3 << 3; + const e = new Uint8Array(s); + e.set(a), a = e; + } + if (0 != (4294967168 & e)) { + if (0 == (4294965248 & e)) a[r++] = e >> 6 & 31 | 192;else if (0 == (4294901760 & e)) a[r++] = e >> 12 & 15 | 224, a[r++] = e >> 6 & 63 | 128;else { + if (0 != (4292870144 & e)) continue; + a[r++] = e >> 18 & 7 | 240, a[r++] = e >> 12 & 63 | 128, a[r++] = e >> 6 & 63 | 128; + } + a[r++] = 63 & e | 128; + } else a[r++] = e; } - - if (0 != (4294967168 & e)) { - if (0 == (4294965248 & e)) a[r++] = e >> 6 & 31 | 192;else if (0 == (4294901760 & e)) a[r++] = e >> 12 & 15 | 224, a[r++] = e >> 6 & 63 | 128;else { - if (0 != (4292870144 & e)) continue; - a[r++] = e >> 18 & 7 | 240, a[r++] = e >> 12 & 63 | 128, a[r++] = e >> 6 & 63 | 128; + return a.slice(0, r); + }, Object.defineProperty(i.prototype, "encoding", { + value: "utf-8" + }), Object.defineProperty(i.prototype, "fatal", { + value: !1 + }), Object.defineProperty(i.prototype, "ignoreBOM", { + value: !1 + }), i.prototype.decode = function (t) { + let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + stream: !1 + }; + if (e.stream) throw new Error("Failed to decode: the 'stream' option is unsupported."); + const i = new Uint8Array(t); + let n = 0; + const r = i.length, + s = []; + for (; n < r;) { + const t = i[n++]; + if (0 === t) break; + if (0 == (128 & t)) s.push(t);else if (192 == (224 & t)) { + const e = 63 & i[n++]; + s.push((31 & t) << 6 | e); + } else if (224 == (240 & t)) { + const e = 63 & i[n++], + r = 63 & i[n++]; + s.push((31 & t) << 12 | e << 6 | r); + } else if (240 == (248 & t)) { + let e = (7 & t) << 18 | (63 & i[n++]) << 12 | (63 & i[n++]) << 6 | 63 & i[n++]; + e > 65535 && (e -= 65536, s.push(e >>> 10 & 1023 | 55296), e = 56320 | 1023 & e), s.push(e); } - a[r++] = 63 & e | 128; - } else a[r++] = e; - } - - return a.slice(0, r); - }, Object.defineProperty(i.prototype, "encoding", { - value: "utf-8" - }), Object.defineProperty(i.prototype, "fatal", { - value: !1 - }), Object.defineProperty(i.prototype, "ignoreBOM", { - value: !1 - }), i.prototype.decode = function (t) { - let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - stream: !1 - }; - if (e.stream) throw new Error("Failed to decode: the 'stream' option is unsupported."); - const i = new Uint8Array(t); - let n = 0; - const r = i.length, - s = []; - - for (; n < r;) { - const t = i[n++]; - if (0 === t) break; - if (0 == (128 & t)) s.push(t);else if (192 == (224 & t)) { - const e = 63 & i[n++]; - s.push((31 & t) << 6 | e); - } else if (224 == (240 & t)) { - const e = 63 & i[n++], - r = 63 & i[n++]; - s.push((31 & t) << 12 | e << 6 | r); - } else if (240 == (248 & t)) { - let e = (7 & t) << 18 | (63 & i[n++]) << 12 | (63 & i[n++]) << 6 | 63 & i[n++]; - e > 65535 && (e -= 65536, s.push(e >>> 10 & 1023 | 55296), e = 56320 | 1023 & e), s.push(e); } - } - - return String.fromCharCode.apply(null, s); - }, t.TextEncoder = e, t.TextDecoder = i; - }("undefined" != typeof window ? window : "undefined" != typeof self ? self : this); - } -}, - e = {}; - + return String.fromCharCode.apply(null, s); + }, t.TextEncoder = e, t.TextDecoder = i; + }("undefined" != typeof window ? window : "undefined" != typeof self ? self : this); + } + }, + e = {}; function i(n) { var r = e[n]; if (void 0 !== r) return r.exports; @@ -2037,7 +1793,6 @@ function i(n) { }; return t[n].call(s.exports, s, s.exports, i), s.exports; } - i.d = (t, e) => { for (var n in e) i.o(e, n) && !i.o(t, n) && Object.defineProperty(t, n, { enumerable: !0, @@ -2045,15 +1800,13 @@ i.d = (t, e) => { }); }, i.o = (t, e) => Object.prototype.hasOwnProperty.call(t, e); var n = {}; - (() => { i.d(n, { P: () => Mi, m: () => Fi }), i(396); const t = new TextDecoder("utf-8"), - e = new TextEncoder(); - + e = new TextEncoder(); class r { constructor() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8192; @@ -2061,265 +1814,194 @@ var n = {}; let i = !1; "number" == typeof t ? t = new ArrayBuffer(t) : (i = !0, this.lastWrittenByte = t.byteLength); const n = e.offset ? e.offset >>> 0 : 0, - s = t.byteLength - n; + s = t.byteLength - n; let a = n; (ArrayBuffer.isView(t) || t instanceof r) && (t.byteLength !== t.buffer.byteLength && (a = t.byteOffset + n), t = t.buffer), this.lastWrittenByte = i ? s : 0, this.buffer = t, this.length = s, this.byteLength = s, this.byteOffset = a, this.offset = 0, this.littleEndian = !0, this._data = new DataView(this.buffer, a, s), this._mark = 0, this._marks = []; } - available() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return this.offset + t <= this.length; } - isLittleEndian() { return this.littleEndian; } - setLittleEndian() { return this.littleEndian = !0, this; } - isBigEndian() { return !this.littleEndian; } - setBigEndian() { return this.littleEndian = !1, this; } - skip() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return this.offset += t, this; } - seek(t) { return this.offset = t, this; } - mark() { return this._mark = this.offset, this; } - reset() { return this.offset = this._mark, this; } - pushMark() { return this._marks.push(this.offset), this; } - popMark() { const t = this._marks.pop(); - if (void 0 === t) throw new Error("Mark stack empty"); return this.seek(t), this; } - rewind() { return this.offset = 0, this; } - ensureAvailable() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - if (!this.available(t)) { const e = 2 * (this.offset + t), - i = new Uint8Array(e); + i = new Uint8Array(e); i.set(new Uint8Array(this.buffer)), this.buffer = i.buffer, this.length = this.byteLength = e, this._data = new DataView(this.buffer); } - return this; } - readBoolean() { return 0 !== this.readUint8(); } - readInt8() { return this._data.getInt8(this.offset++); } - readUint8() { return this._data.getUint8(this.offset++); } - readByte() { return this.readUint8(); } - readBytes() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; const e = new Uint8Array(t); - for (let i = 0; i < t; i++) e[i] = this.readByte(); - return e; } - readInt16() { const t = this._data.getInt16(this.offset, this.littleEndian); - return this.offset += 2, t; } - readUint16() { const t = this._data.getUint16(this.offset, this.littleEndian); - return this.offset += 2, t; } - readInt32() { const t = this._data.getInt32(this.offset, this.littleEndian); - return this.offset += 4, t; } - readUint32() { const t = this._data.getUint32(this.offset, this.littleEndian); - return this.offset += 4, t; } - readFloat32() { const t = this._data.getFloat32(this.offset, this.littleEndian); - return this.offset += 4, t; } - readFloat64() { const t = this._data.getFloat64(this.offset, this.littleEndian); - return this.offset += 8, t; } - readBigInt64() { const t = this._data.getBigInt64(this.offset, this.littleEndian); - return this.offset += 8, t; } - readBigUint64() { const t = this._data.getBigUint64(this.offset, this.littleEndian); - return this.offset += 8, t; } - readChar() { return String.fromCharCode(this.readInt8()); } - readChars() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; let e = ""; - for (let i = 0; i < t; i++) e += this.readChar(); - return e; } - readUtf8() { let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return i = this.readBytes(e), t.decode(i); var i; } - writeBoolean(t) { return this.writeUint8(t ? 255 : 0), this; } - writeInt8(t) { return this.ensureAvailable(1), this._data.setInt8(this.offset++, t), this._updateLastWrittenByte(), this; } - writeUint8(t) { return this.ensureAvailable(1), this._data.setUint8(this.offset++, t), this._updateLastWrittenByte(), this; } - writeByte(t) { return this.writeUint8(t); } - writeBytes(t) { this.ensureAvailable(t.length); - for (let e = 0; e < t.length; e++) this._data.setUint8(this.offset++, t[e]); - return this._updateLastWrittenByte(), this; } - writeInt16(t) { return this.ensureAvailable(2), this._data.setInt16(this.offset, t, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this; } - writeUint16(t) { return this.ensureAvailable(2), this._data.setUint16(this.offset, t, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this; } - writeInt32(t) { return this.ensureAvailable(4), this._data.setInt32(this.offset, t, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this; } - writeUint32(t) { return this.ensureAvailable(4), this._data.setUint32(this.offset, t, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this; } - writeFloat32(t) { return this.ensureAvailable(4), this._data.setFloat32(this.offset, t, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this; } - writeFloat64(t) { return this.ensureAvailable(8), this._data.setFloat64(this.offset, t, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this; } - writeBigInt64(t) { return this.ensureAvailable(8), this._data.setBigInt64(this.offset, t, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this; } - writeBigUint64(t) { return this.ensureAvailable(8), this._data.setBigUint64(this.offset, t, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this; } - writeChar(t) { return this.writeUint8(t.charCodeAt(0)); } - writeChars(t) { for (let e = 0; e < t.length; e++) this.writeUint8(t.charCodeAt(e)); - return this; } - writeUtf8(t) { return this.writeBytes(function (t) { return e.encode(t); }(t)); } - toArray() { return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte); } - _updateLastWrittenByte() { this.offset > this.lastWrittenByte && (this.lastWrittenByte = this.offset); } - } - function s(t) { let e = t.length; - for (; --e >= 0;) t[e] = 0; } - const a = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0]), - o = new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]), - h = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]), - l = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), - d = new Array(576); + o = new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]), + h = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]), + l = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), + d = new Array(576); s(d); - const _ = new Array(60); - s(_); const f = new Array(512); s(f); @@ -2328,790 +2010,640 @@ var n = {}; const u = new Array(29); s(u); const w = new Array(30); - function p(t, e, i, n, r) { this.static_tree = t, this.extra_bits = e, this.extra_base = i, this.elems = n, this.max_length = r, this.has_stree = t && t.length; } - let g, b, m; - function k(t, e) { this.dyn_tree = t, this.max_code = 0, this.stat_desc = e; } - s(w); - const y = t => t < 256 ? f[t] : f[256 + (t >>> 7)], - v = (t, e) => { - t.pending_buf[t.pending++] = 255 & e, t.pending_buf[t.pending++] = e >>> 8 & 255; - }, - E = (t, e, i) => { - t.bi_valid > 16 - i ? (t.bi_buf |= e << t.bi_valid & 65535, v(t, t.bi_buf), t.bi_buf = e >> 16 - t.bi_valid, t.bi_valid += i - 16) : (t.bi_buf |= e << t.bi_valid & 65535, t.bi_valid += i); - }, - A = (t, e, i) => { - E(t, i[2 * e], i[2 * e + 1]); - }, - x = (t, e) => { - let i = 0; - - do { - i |= 1 & t, t >>>= 1, i <<= 1; - } while (--e > 0); - - return i >>> 1; - }, - U = (t, e, i) => { - const n = new Array(16); - let r, - s, - a = 0; - - for (r = 1; r <= 15; r++) n[r] = a = a + i[r - 1] << 1; - - for (s = 0; s <= e; s++) { - let e = t[2 * s + 1]; - 0 !== e && (t[2 * s] = x(n[e]++, e)); - } - }, - z = t => { - let e; - - for (e = 0; e < 286; e++) t.dyn_ltree[2 * e] = 0; - - for (e = 0; e < 30; e++) t.dyn_dtree[2 * e] = 0; - - for (e = 0; e < 19; e++) t.bl_tree[2 * e] = 0; - - t.dyn_ltree[512] = 1, t.opt_len = t.static_len = 0, t.last_lit = t.matches = 0; - }, - R = t => { - t.bi_valid > 8 ? v(t, t.bi_buf) : t.bi_valid > 0 && (t.pending_buf[t.pending++] = t.bi_buf), t.bi_buf = 0, t.bi_valid = 0; - }, - N = (t, e, i, n) => { - const r = 2 * e, - s = 2 * i; - return t[r] < t[s] || t[r] === t[s] && n[e] <= n[i]; - }, - T = (t, e, i) => { - const n = t.heap[i]; - let r = i << 1; - - for (; r <= t.heap_len && (r < t.heap_len && N(e, t.heap[r + 1], t.heap[r], t.depth) && r++, !N(e, n, t.heap[r], t.depth));) t.heap[i] = t.heap[r], i = r, r <<= 1; - - t.heap[i] = n; - }, - O = (t, e, i) => { - let n, + v = (t, e) => { + t.pending_buf[t.pending++] = 255 & e, t.pending_buf[t.pending++] = e >>> 8 & 255; + }, + E = (t, e, i) => { + t.bi_valid > 16 - i ? (t.bi_buf |= e << t.bi_valid & 65535, v(t, t.bi_buf), t.bi_buf = e >> 16 - t.bi_valid, t.bi_valid += i - 16) : (t.bi_buf |= e << t.bi_valid & 65535, t.bi_valid += i); + }, + A = (t, e, i) => { + E(t, i[2 * e], i[2 * e + 1]); + }, + x = (t, e) => { + let i = 0; + do { + i |= 1 & t, t >>>= 1, i <<= 1; + } while (--e > 0); + return i >>> 1; + }, + U = (t, e, i) => { + const n = new Array(16); + let r, + s, + a = 0; + for (r = 1; r <= 15; r++) n[r] = a = a + i[r - 1] << 1; + for (s = 0; s <= e; s++) { + let e = t[2 * s + 1]; + 0 !== e && (t[2 * s] = x(n[e]++, e)); + } + }, + z = t => { + let e; + for (e = 0; e < 286; e++) t.dyn_ltree[2 * e] = 0; + for (e = 0; e < 30; e++) t.dyn_dtree[2 * e] = 0; + for (e = 0; e < 19; e++) t.bl_tree[2 * e] = 0; + t.dyn_ltree[512] = 1, t.opt_len = t.static_len = 0, t.last_lit = t.matches = 0; + }, + R = t => { + t.bi_valid > 8 ? v(t, t.bi_buf) : t.bi_valid > 0 && (t.pending_buf[t.pending++] = t.bi_buf), t.bi_buf = 0, t.bi_valid = 0; + }, + N = (t, e, i, n) => { + const r = 2 * e, + s = 2 * i; + return t[r] < t[s] || t[r] === t[s] && n[e] <= n[i]; + }, + T = (t, e, i) => { + const n = t.heap[i]; + let r = i << 1; + for (; r <= t.heap_len && (r < t.heap_len && N(e, t.heap[r + 1], t.heap[r], t.depth) && r++, !N(e, n, t.heap[r], t.depth));) t.heap[i] = t.heap[r], i = r, r <<= 1; + t.heap[i] = n; + }, + O = (t, e, i) => { + let n, r, s, h, l = 0; - if (0 !== t.last_lit) do { - n = t.pending_buf[t.d_buf + 2 * l] << 8 | t.pending_buf[t.d_buf + 2 * l + 1], r = t.pending_buf[t.l_buf + l], l++, 0 === n ? A(t, r, e) : (s = c[r], A(t, s + 256 + 1, e), h = a[s], 0 !== h && (r -= u[s], E(t, r, h)), n--, s = y(n), A(t, s, i), h = o[s], 0 !== h && (n -= w[s], E(t, n, h))); - } while (l < t.last_lit); - A(t, 256, e); - }, - L = (t, e) => { - const i = e.dyn_tree, - n = e.stat_desc.static_tree, - r = e.stat_desc.has_stree, - s = e.stat_desc.elems; - let a, + if (0 !== t.last_lit) do { + n = t.pending_buf[t.d_buf + 2 * l] << 8 | t.pending_buf[t.d_buf + 2 * l + 1], r = t.pending_buf[t.l_buf + l], l++, 0 === n ? A(t, r, e) : (s = c[r], A(t, s + 256 + 1, e), h = a[s], 0 !== h && (r -= u[s], E(t, r, h)), n--, s = y(n), A(t, s, i), h = o[s], 0 !== h && (n -= w[s], E(t, n, h))); + } while (l < t.last_lit); + A(t, 256, e); + }, + L = (t, e) => { + const i = e.dyn_tree, + n = e.stat_desc.static_tree, + r = e.stat_desc.has_stree, + s = e.stat_desc.elems; + let a, o, h, l = -1; - - for (t.heap_len = 0, t.heap_max = 573, a = 0; a < s; a++) 0 !== i[2 * a] ? (t.heap[++t.heap_len] = l = a, t.depth[a] = 0) : i[2 * a + 1] = 0; - - for (; t.heap_len < 2;) h = t.heap[++t.heap_len] = l < 2 ? ++l : 0, i[2 * h] = 1, t.depth[h] = 0, t.opt_len--, r && (t.static_len -= n[2 * h + 1]); - - for (e.max_code = l, a = t.heap_len >> 1; a >= 1; a--) T(t, i, a); - - h = s; - - do { - a = t.heap[1], t.heap[1] = t.heap[t.heap_len--], T(t, i, 1), o = t.heap[1], t.heap[--t.heap_max] = a, t.heap[--t.heap_max] = o, i[2 * h] = i[2 * a] + i[2 * o], t.depth[h] = (t.depth[a] >= t.depth[o] ? t.depth[a] : t.depth[o]) + 1, i[2 * a + 1] = i[2 * o + 1] = h, t.heap[1] = h++, T(t, i, 1); - } while (t.heap_len >= 2); - - t.heap[--t.heap_max] = t.heap[1], ((t, e) => { - const i = e.dyn_tree, - n = e.max_code, - r = e.stat_desc.static_tree, - s = e.stat_desc.has_stree, - a = e.stat_desc.extra_bits, - o = e.stat_desc.extra_base, - h = e.stat_desc.max_length; - - let l, + for (t.heap_len = 0, t.heap_max = 573, a = 0; a < s; a++) 0 !== i[2 * a] ? (t.heap[++t.heap_len] = l = a, t.depth[a] = 0) : i[2 * a + 1] = 0; + for (; t.heap_len < 2;) h = t.heap[++t.heap_len] = l < 2 ? ++l : 0, i[2 * h] = 1, t.depth[h] = 0, t.opt_len--, r && (t.static_len -= n[2 * h + 1]); + for (e.max_code = l, a = t.heap_len >> 1; a >= 1; a--) T(t, i, a); + h = s; + do { + a = t.heap[1], t.heap[1] = t.heap[t.heap_len--], T(t, i, 1), o = t.heap[1], t.heap[--t.heap_max] = a, t.heap[--t.heap_max] = o, i[2 * h] = i[2 * a] + i[2 * o], t.depth[h] = (t.depth[a] >= t.depth[o] ? t.depth[a] : t.depth[o]) + 1, i[2 * a + 1] = i[2 * o + 1] = h, t.heap[1] = h++, T(t, i, 1); + } while (t.heap_len >= 2); + t.heap[--t.heap_max] = t.heap[1], ((t, e) => { + const i = e.dyn_tree, + n = e.max_code, + r = e.stat_desc.static_tree, + s = e.stat_desc.has_stree, + a = e.stat_desc.extra_bits, + o = e.stat_desc.extra_base, + h = e.stat_desc.max_length; + let l, d, _, f, c, u, w = 0; - - for (f = 0; f <= 15; f++) t.bl_count[f] = 0; - - for (i[2 * t.heap[t.heap_max] + 1] = 0, l = t.heap_max + 1; l < 573; l++) d = t.heap[l], f = i[2 * i[2 * d + 1] + 1] + 1, f > h && (f = h, w++), i[2 * d + 1] = f, d > n || (t.bl_count[f]++, c = 0, d >= o && (c = a[d - o]), u = i[2 * d], t.opt_len += u * (f + c), s && (t.static_len += u * (r[2 * d + 1] + c))); - - if (0 !== w) { - do { - for (f = h - 1; 0 === t.bl_count[f];) f--; - - t.bl_count[f]--, t.bl_count[f + 1] += 2, t.bl_count[h]--, w -= 2; - } while (w > 0); - - for (f = h; 0 !== f; f--) for (d = t.bl_count[f]; 0 !== d;) _ = t.heap[--l], _ > n || (i[2 * _ + 1] !== f && (t.opt_len += (f - i[2 * _ + 1]) * i[2 * _], i[2 * _ + 1] = f), d--); - } - })(t, e), U(i, l, t.bl_count); - }, - B = (t, e, i) => { - let n, + for (f = 0; f <= 15; f++) t.bl_count[f] = 0; + for (i[2 * t.heap[t.heap_max] + 1] = 0, l = t.heap_max + 1; l < 573; l++) d = t.heap[l], f = i[2 * i[2 * d + 1] + 1] + 1, f > h && (f = h, w++), i[2 * d + 1] = f, d > n || (t.bl_count[f]++, c = 0, d >= o && (c = a[d - o]), u = i[2 * d], t.opt_len += u * (f + c), s && (t.static_len += u * (r[2 * d + 1] + c))); + if (0 !== w) { + do { + for (f = h - 1; 0 === t.bl_count[f];) f--; + t.bl_count[f]--, t.bl_count[f + 1] += 2, t.bl_count[h]--, w -= 2; + } while (w > 0); + for (f = h; 0 !== f; f--) for (d = t.bl_count[f]; 0 !== d;) _ = t.heap[--l], _ > n || (i[2 * _ + 1] !== f && (t.opt_len += (f - i[2 * _ + 1]) * i[2 * _], i[2 * _ + 1] = f), d--); + } + })(t, e), U(i, l, t.bl_count); + }, + B = (t, e, i) => { + let n, r, s = -1, a = e[1], o = 0, h = 7, l = 4; - - for (0 === a && (h = 138, l = 3), e[2 * (i + 1) + 1] = 65535, n = 0; n <= i; n++) r = a, a = e[2 * (n + 1) + 1], ++o < h && r === a || (o < l ? t.bl_tree[2 * r] += o : 0 !== r ? (r !== s && t.bl_tree[2 * r]++, t.bl_tree[32]++) : o <= 10 ? t.bl_tree[34]++ : t.bl_tree[36]++, o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4)); - }, - C = (t, e, i) => { - let n, + for (0 === a && (h = 138, l = 3), e[2 * (i + 1) + 1] = 65535, n = 0; n <= i; n++) r = a, a = e[2 * (n + 1) + 1], ++o < h && r === a || (o < l ? t.bl_tree[2 * r] += o : 0 !== r ? (r !== s && t.bl_tree[2 * r]++, t.bl_tree[32]++) : o <= 10 ? t.bl_tree[34]++ : t.bl_tree[36]++, o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4)); + }, + C = (t, e, i) => { + let n, r, s = -1, a = e[1], o = 0, h = 7, l = 4; - - for (0 === a && (h = 138, l = 3), n = 0; n <= i; n++) if (r = a, a = e[2 * (n + 1) + 1], !(++o < h && r === a)) { - if (o < l) do { - A(t, r, t.bl_tree); - } while (0 != --o);else 0 !== r ? (r !== s && (A(t, r, t.bl_tree), o--), A(t, 16, t.bl_tree), E(t, o - 3, 2)) : o <= 10 ? (A(t, 17, t.bl_tree), E(t, o - 3, 3)) : (A(t, 18, t.bl_tree), E(t, o - 11, 7)); - o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4); - } - }; - + for (0 === a && (h = 138, l = 3), n = 0; n <= i; n++) if (r = a, a = e[2 * (n + 1) + 1], !(++o < h && r === a)) { + if (o < l) do { + A(t, r, t.bl_tree); + } while (0 != --o);else 0 !== r ? (r !== s && (A(t, r, t.bl_tree), o--), A(t, 16, t.bl_tree), E(t, o - 3, 2)) : o <= 10 ? (A(t, 17, t.bl_tree), E(t, o - 3, 3)) : (A(t, 18, t.bl_tree), E(t, o - 11, 7)); + o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4); + } + }; let D = !1; - const I = (t, e, i, n) => { E(t, 0 + (n ? 1 : 0), 3), ((t, e, i, n) => { R(t), v(t, i), v(t, ~i), t.pending_buf.set(t.window.subarray(e, e + i), t.pending), t.pending += i; })(t, e, i); }; - var S = { - _tr_init: t => { - D || ((() => { - let t, e, i, n, r; - const s = new Array(16); - - for (i = 0, n = 0; n < 28; n++) for (u[n] = i, t = 0; t < 1 << a[n]; t++) c[i++] = n; - - for (c[i - 1] = n, r = 0, n = 0; n < 16; n++) for (w[n] = r, t = 0; t < 1 << o[n]; t++) f[r++] = n; - - for (r >>= 7; n < 30; n++) for (w[n] = r << 7, t = 0; t < 1 << o[n] - 7; t++) f[256 + r++] = n; - - for (e = 0; e <= 15; e++) s[e] = 0; - - for (t = 0; t <= 143;) d[2 * t + 1] = 8, t++, s[8]++; - - for (; t <= 255;) d[2 * t + 1] = 9, t++, s[9]++; - - for (; t <= 279;) d[2 * t + 1] = 7, t++, s[7]++; - - for (; t <= 287;) d[2 * t + 1] = 8, t++, s[8]++; - - for (U(d, 287, s), t = 0; t < 30; t++) _[2 * t + 1] = 5, _[2 * t] = x(t, 5); - - g = new p(d, a, 257, 286, 15), b = new p(_, o, 0, 30, 15), m = new p(new Array(0), h, 0, 19, 7); - })(), D = !0), t.l_desc = new k(t.dyn_ltree, g), t.d_desc = new k(t.dyn_dtree, b), t.bl_desc = new k(t.bl_tree, m), t.bi_buf = 0, t.bi_valid = 0, z(t); - }, - _tr_stored_block: I, - _tr_flush_block: (t, e, i, n) => { - let r, + _tr_init: t => { + D || ((() => { + let t, e, i, n, r; + const s = new Array(16); + for (i = 0, n = 0; n < 28; n++) for (u[n] = i, t = 0; t < 1 << a[n]; t++) c[i++] = n; + for (c[i - 1] = n, r = 0, n = 0; n < 16; n++) for (w[n] = r, t = 0; t < 1 << o[n]; t++) f[r++] = n; + for (r >>= 7; n < 30; n++) for (w[n] = r << 7, t = 0; t < 1 << o[n] - 7; t++) f[256 + r++] = n; + for (e = 0; e <= 15; e++) s[e] = 0; + for (t = 0; t <= 143;) d[2 * t + 1] = 8, t++, s[8]++; + for (; t <= 255;) d[2 * t + 1] = 9, t++, s[9]++; + for (; t <= 279;) d[2 * t + 1] = 7, t++, s[7]++; + for (; t <= 287;) d[2 * t + 1] = 8, t++, s[8]++; + for (U(d, 287, s), t = 0; t < 30; t++) _[2 * t + 1] = 5, _[2 * t] = x(t, 5); + g = new p(d, a, 257, 286, 15), b = new p(_, o, 0, 30, 15), m = new p(new Array(0), h, 0, 19, 7); + })(), D = !0), t.l_desc = new k(t.dyn_ltree, g), t.d_desc = new k(t.dyn_dtree, b), t.bl_desc = new k(t.bl_tree, m), t.bi_buf = 0, t.bi_valid = 0, z(t); + }, + _tr_stored_block: I, + _tr_flush_block: (t, e, i, n) => { + let r, s, a = 0; - t.level > 0 ? (2 === t.strm.data_type && (t.strm.data_type = (t => { - let e, + t.level > 0 ? (2 === t.strm.data_type && (t.strm.data_type = (t => { + let e, i = 4093624447; - - for (e = 0; e <= 31; e++, i >>>= 1) if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; - - if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return 1; - - for (e = 32; e < 256; e++) if (0 !== t.dyn_ltree[2 * e]) return 1; - - return 0; - })(t)), L(t, t.l_desc), L(t, t.d_desc), a = (t => { - let e; - - for (B(t, t.dyn_ltree, t.l_desc.max_code), B(t, t.dyn_dtree, t.d_desc.max_code), L(t, t.bl_desc), e = 18; e >= 3 && 0 === t.bl_tree[2 * l[e] + 1]; e--); - - return t.opt_len += 3 * (e + 1) + 5 + 5 + 4, e; - })(t), r = t.opt_len + 3 + 7 >>> 3, s = t.static_len + 3 + 7 >>> 3, s <= r && (r = s)) : r = s = i + 5, i + 4 <= r && -1 !== e ? I(t, e, i, n) : 4 === t.strategy || s === r ? (E(t, 2 + (n ? 1 : 0), 3), O(t, d, _)) : (E(t, 4 + (n ? 1 : 0), 3), ((t, e, i, n) => { - let r; - - for (E(t, e - 257, 5), E(t, i - 1, 5), E(t, n - 4, 4), r = 0; r < n; r++) E(t, t.bl_tree[2 * l[r] + 1], 3); - - C(t, t.dyn_ltree, e - 1), C(t, t.dyn_dtree, i - 1); - })(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, a + 1), O(t, t.dyn_ltree, t.dyn_dtree)), z(t), n && R(t); + for (e = 0; e <= 31; e++, i >>>= 1) if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; + if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return 1; + for (e = 32; e < 256; e++) if (0 !== t.dyn_ltree[2 * e]) return 1; + return 0; + })(t)), L(t, t.l_desc), L(t, t.d_desc), a = (t => { + let e; + for (B(t, t.dyn_ltree, t.l_desc.max_code), B(t, t.dyn_dtree, t.d_desc.max_code), L(t, t.bl_desc), e = 18; e >= 3 && 0 === t.bl_tree[2 * l[e] + 1]; e--); + return t.opt_len += 3 * (e + 1) + 5 + 5 + 4, e; + })(t), r = t.opt_len + 3 + 7 >>> 3, s = t.static_len + 3 + 7 >>> 3, s <= r && (r = s)) : r = s = i + 5, i + 4 <= r && -1 !== e ? I(t, e, i, n) : 4 === t.strategy || s === r ? (E(t, 2 + (n ? 1 : 0), 3), O(t, d, _)) : (E(t, 4 + (n ? 1 : 0), 3), ((t, e, i, n) => { + let r; + for (E(t, e - 257, 5), E(t, i - 1, 5), E(t, n - 4, 4), r = 0; r < n; r++) E(t, t.bl_tree[2 * l[r] + 1], 3); + C(t, t.dyn_ltree, e - 1), C(t, t.dyn_dtree, i - 1); + })(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, a + 1), O(t, t.dyn_ltree, t.dyn_dtree)), z(t), n && R(t); + }, + _tr_tally: (t, e, i) => (t.pending_buf[t.d_buf + 2 * t.last_lit] = e >>> 8 & 255, t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e, t.pending_buf[t.l_buf + t.last_lit] = 255 & i, t.last_lit++, 0 === e ? t.dyn_ltree[2 * i]++ : (t.matches++, e--, t.dyn_ltree[2 * (c[i] + 256 + 1)]++, t.dyn_dtree[2 * y(e)]++), t.last_lit === t.lit_bufsize - 1), + _tr_align: t => { + E(t, 2, 3), A(t, 256, d), (t => { + 16 === t.bi_valid ? (v(t, t.bi_buf), t.bi_buf = 0, t.bi_valid = 0) : t.bi_valid >= 8 && (t.pending_buf[t.pending++] = 255 & t.bi_buf, t.bi_buf >>= 8, t.bi_valid -= 8); + })(t); + } }, - _tr_tally: (t, e, i) => (t.pending_buf[t.d_buf + 2 * t.last_lit] = e >>> 8 & 255, t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e, t.pending_buf[t.l_buf + t.last_lit] = 255 & i, t.last_lit++, 0 === e ? t.dyn_ltree[2 * i]++ : (t.matches++, e--, t.dyn_ltree[2 * (c[i] + 256 + 1)]++, t.dyn_dtree[2 * y(e)]++), t.last_lit === t.lit_bufsize - 1), - _tr_align: t => { - E(t, 2, 3), A(t, 256, d), (t => { - 16 === t.bi_valid ? (v(t, t.bi_buf), t.bi_buf = 0, t.bi_valid = 0) : t.bi_valid >= 8 && (t.pending_buf[t.pending++] = 255 & t.bi_buf, t.bi_buf >>= 8, t.bi_valid -= 8); - })(t); - } - }, - Z = (t, e, i, n) => { - let r = 65535 & t | 0, + Z = (t, e, i, n) => { + let r = 65535 & t | 0, s = t >>> 16 & 65535 | 0, a = 0; - - for (; 0 !== i;) { - a = i > 2e3 ? 2e3 : i, i -= a; - - do { - r = r + e[n++] | 0, s = s + r | 0; - } while (--a); - - r %= 65521, s %= 65521; - } - - return r | s << 16 | 0; - }; - + for (; 0 !== i;) { + a = i > 2e3 ? 2e3 : i, i -= a; + do { + r = r + e[n++] | 0, s = s + r | 0; + } while (--a); + r %= 65521, s %= 65521; + } + return r | s << 16 | 0; + }; const F = new Uint32Array((() => { let t, - e = []; - + e = []; for (var i = 0; i < 256; i++) { t = i; - for (var n = 0; n < 8; n++) t = 1 & t ? 3988292384 ^ t >>> 1 : t >>> 1; - e[i] = t; } - return e; })()); - var M = (t, e, i, n) => { - const r = F, - s = n + i; - t ^= -1; - - for (let i = n; i < s; i++) t = t >>> 8 ^ r[255 & (t ^ e[i])]; - - return -1 ^ t; - }, - P = { - 2: "need dictionary", - 1: "stream end", - 0: "", - "-1": "file error", - "-2": "stream error", - "-3": "data error", - "-4": "insufficient memory", - "-5": "buffer error", - "-6": "incompatible version" - }, - H = { - Z_NO_FLUSH: 0, - Z_PARTIAL_FLUSH: 1, - Z_SYNC_FLUSH: 2, - Z_FULL_FLUSH: 3, - Z_FINISH: 4, - Z_BLOCK: 5, - Z_TREES: 6, - Z_OK: 0, - Z_STREAM_END: 1, - Z_NEED_DICT: 2, - Z_ERRNO: -1, - Z_STREAM_ERROR: -2, - Z_DATA_ERROR: -3, - Z_MEM_ERROR: -4, - Z_BUF_ERROR: -5, - Z_NO_COMPRESSION: 0, - Z_BEST_SPEED: 1, - Z_BEST_COMPRESSION: 9, - Z_DEFAULT_COMPRESSION: -1, - Z_FILTERED: 1, - Z_HUFFMAN_ONLY: 2, - Z_RLE: 3, - Z_FIXED: 4, - Z_DEFAULT_STRATEGY: 0, - Z_BINARY: 0, - Z_TEXT: 1, - Z_UNKNOWN: 2, - Z_DEFLATED: 8 - }; - + const r = F, + s = n + i; + t ^= -1; + for (let i = n; i < s; i++) t = t >>> 8 ^ r[255 & (t ^ e[i])]; + return -1 ^ t; + }, + P = { + 2: "need dictionary", + 1: "stream end", + 0: "", + "-1": "file error", + "-2": "stream error", + "-3": "data error", + "-4": "insufficient memory", + "-5": "buffer error", + "-6": "incompatible version" + }, + H = { + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + Z_BINARY: 0, + Z_TEXT: 1, + Z_UNKNOWN: 2, + Z_DEFLATED: 8 + }; const { - _tr_init: W, - _tr_stored_block: K, - _tr_flush_block: $, - _tr_tally: Y, - _tr_align: j - } = S, - { - Z_NO_FLUSH: G, - Z_PARTIAL_FLUSH: X, - Z_FULL_FLUSH: V, - Z_FINISH: q, - Z_BLOCK: J, - Z_OK: Q, - Z_STREAM_END: tt, - Z_STREAM_ERROR: et, - Z_DATA_ERROR: it, - Z_BUF_ERROR: nt, - Z_DEFAULT_COMPRESSION: rt, - Z_FILTERED: st, - Z_HUFFMAN_ONLY: at, - Z_RLE: ot, - Z_FIXED: ht, - Z_DEFAULT_STRATEGY: lt, - Z_UNKNOWN: dt, - Z_DEFLATED: _t - } = H, - ft = 258, - ct = 262, - ut = 103, - wt = 113, - pt = 666, - gt = (t, e) => (t.msg = P[e], e), - bt = t => (t << 1) - (t > 4 ? 9 : 0), - mt = t => { - let e = t.length; - - for (; --e >= 0;) t[e] = 0; - }; - + _tr_init: W, + _tr_stored_block: K, + _tr_flush_block: $, + _tr_tally: Y, + _tr_align: j + } = S, + { + Z_NO_FLUSH: G, + Z_PARTIAL_FLUSH: X, + Z_FULL_FLUSH: V, + Z_FINISH: q, + Z_BLOCK: J, + Z_OK: Q, + Z_STREAM_END: tt, + Z_STREAM_ERROR: et, + Z_DATA_ERROR: it, + Z_BUF_ERROR: nt, + Z_DEFAULT_COMPRESSION: rt, + Z_FILTERED: st, + Z_HUFFMAN_ONLY: at, + Z_RLE: ot, + Z_FIXED: ht, + Z_DEFAULT_STRATEGY: lt, + Z_UNKNOWN: dt, + Z_DEFLATED: _t + } = H, + ft = 258, + ct = 262, + ut = 103, + wt = 113, + pt = 666, + gt = (t, e) => (t.msg = P[e], e), + bt = t => (t << 1) - (t > 4 ? 9 : 0), + mt = t => { + let e = t.length; + for (; --e >= 0;) t[e] = 0; + }; let kt = (t, e, i) => (e << t.hash_shift ^ i) & t.hash_mask; - const yt = t => { - const e = t.state; - let i = e.pending; - i > t.avail_out && (i = t.avail_out), 0 !== i && (t.output.set(e.pending_buf.subarray(e.pending_out, e.pending_out + i), t.next_out), t.next_out += i, e.pending_out += i, t.total_out += i, t.avail_out -= i, e.pending -= i, 0 === e.pending && (e.pending_out = 0)); - }, - vt = (t, e) => { - $(t, t.block_start >= 0 ? t.block_start : -1, t.strstart - t.block_start, e), t.block_start = t.strstart, yt(t.strm); - }, - Et = (t, e) => { - t.pending_buf[t.pending++] = e; - }, - At = (t, e) => { - t.pending_buf[t.pending++] = e >>> 8 & 255, t.pending_buf[t.pending++] = 255 & e; - }, - xt = (t, e, i, n) => { - let r = t.avail_in; - return r > n && (r = n), 0 === r ? 0 : (t.avail_in -= r, e.set(t.input.subarray(t.next_in, t.next_in + r), i), 1 === t.state.wrap ? t.adler = Z(t.adler, e, r, i) : 2 === t.state.wrap && (t.adler = M(t.adler, e, r, i)), t.next_in += r, t.total_in += r, r); - }, - Ut = (t, e) => { - let i, + const e = t.state; + let i = e.pending; + i > t.avail_out && (i = t.avail_out), 0 !== i && (t.output.set(e.pending_buf.subarray(e.pending_out, e.pending_out + i), t.next_out), t.next_out += i, e.pending_out += i, t.total_out += i, t.avail_out -= i, e.pending -= i, 0 === e.pending && (e.pending_out = 0)); + }, + vt = (t, e) => { + $(t, t.block_start >= 0 ? t.block_start : -1, t.strstart - t.block_start, e), t.block_start = t.strstart, yt(t.strm); + }, + Et = (t, e) => { + t.pending_buf[t.pending++] = e; + }, + At = (t, e) => { + t.pending_buf[t.pending++] = e >>> 8 & 255, t.pending_buf[t.pending++] = 255 & e; + }, + xt = (t, e, i, n) => { + let r = t.avail_in; + return r > n && (r = n), 0 === r ? 0 : (t.avail_in -= r, e.set(t.input.subarray(t.next_in, t.next_in + r), i), 1 === t.state.wrap ? t.adler = Z(t.adler, e, r, i) : 2 === t.state.wrap && (t.adler = M(t.adler, e, r, i)), t.next_in += r, t.total_in += r, r); + }, + Ut = (t, e) => { + let i, n, r = t.max_chain_length, s = t.strstart, a = t.prev_length, o = t.nice_match; - const h = t.strstart > t.w_size - ct ? t.strstart - (t.w_size - ct) : 0, - l = t.window, - d = t.w_mask, - _ = t.prev, - f = t.strstart + ft; - let c = l[s + a - 1], + const h = t.strstart > t.w_size - ct ? t.strstart - (t.w_size - ct) : 0, + l = t.window, + d = t.w_mask, + _ = t.prev, + f = t.strstart + ft; + let c = l[s + a - 1], u = l[s + a]; - t.prev_length >= t.good_match && (r >>= 2), o > t.lookahead && (o = t.lookahead); - - do { - if (i = e, l[i + a] === u && l[i + a - 1] === c && l[i] === l[s] && l[++i] === l[s + 1]) { - s += 2, i++; - - do {} while (l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && s < f); - - if (n = ft - (f - s), s = f - ft, n > a) { - if (t.match_start = e, a = n, n >= o) break; - c = l[s + a - 1], u = l[s + a]; + t.prev_length >= t.good_match && (r >>= 2), o > t.lookahead && (o = t.lookahead); + do { + if (i = e, l[i + a] === u && l[i + a - 1] === c && l[i] === l[s] && l[++i] === l[s + 1]) { + s += 2, i++; + do {} while (l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && s < f); + if (n = ft - (f - s), s = f - ft, n > a) { + if (t.match_start = e, a = n, n >= o) break; + c = l[s + a - 1], u = l[s + a]; + } } + } while ((e = _[e & d]) > h && 0 != --r); + return a <= t.lookahead ? a : t.lookahead; + }, + zt = t => { + const e = t.w_size; + let i, n, r, s, a; + do { + if (s = t.window_size - t.lookahead - t.strstart, t.strstart >= e + (e - ct)) { + t.window.set(t.window.subarray(e, e + e), 0), t.match_start -= e, t.strstart -= e, t.block_start -= e, n = t.hash_size, i = n; + do { + r = t.head[--i], t.head[i] = r >= e ? r - e : 0; + } while (--n); + n = e, i = n; + do { + r = t.prev[--i], t.prev[i] = r >= e ? r - e : 0; + } while (--n); + s += e; + } + if (0 === t.strm.avail_in) break; + if (n = xt(t.strm, t.window, t.strstart + t.lookahead, s), t.lookahead += n, t.lookahead + t.insert >= 3) for (a = t.strstart - t.insert, t.ins_h = t.window[a], t.ins_h = kt(t, t.ins_h, t.window[a + 1]); t.insert && (t.ins_h = kt(t, t.ins_h, t.window[a + 3 - 1]), t.prev[a & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = a, a++, t.insert--, !(t.lookahead + t.insert < 3));); + } while (t.lookahead < ct && 0 !== t.strm.avail_in); + }, + Rt = (t, e) => { + let i, n; + for (;;) { + if (t.lookahead < ct) { + if (zt(t), t.lookahead < ct && e === G) return 1; + if (0 === t.lookahead) break; + } + if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 !== i && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i)), t.match_length >= 3) { + if (n = Y(t, t.strstart - t.match_start, t.match_length - 3), t.lookahead -= t.match_length, t.match_length <= t.max_lazy_match && t.lookahead >= 3) { + t.match_length--; + do { + t.strstart++, t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart; + } while (0 != --t.match_length); + t.strstart++; + } else t.strstart += t.match_length, t.match_length = 0, t.ins_h = t.window[t.strstart], t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 1]); + } else n = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++; + if (n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - } while ((e = _[e & d]) > h && 0 != --r); - - return a <= t.lookahead ? a : t.lookahead; - }, - zt = t => { - const e = t.w_size; - let i, n, r, s, a; - - do { - if (s = t.window_size - t.lookahead - t.strstart, t.strstart >= e + (e - ct)) { - t.window.set(t.window.subarray(e, e + e), 0), t.match_start -= e, t.strstart -= e, t.block_start -= e, n = t.hash_size, i = n; - - do { - r = t.head[--i], t.head[i] = r >= e ? r - e : 0; - } while (--n); - - n = e, i = n; - - do { - r = t.prev[--i], t.prev[i] = r >= e ? r - e : 0; - } while (--n); - - s += e; - } - - if (0 === t.strm.avail_in) break; - if (n = xt(t.strm, t.window, t.strstart + t.lookahead, s), t.lookahead += n, t.lookahead + t.insert >= 3) for (a = t.strstart - t.insert, t.ins_h = t.window[a], t.ins_h = kt(t, t.ins_h, t.window[a + 1]); t.insert && (t.ins_h = kt(t, t.ins_h, t.window[a + 3 - 1]), t.prev[a & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = a, a++, t.insert--, !(t.lookahead + t.insert < 3));); - } while (t.lookahead < ct && 0 !== t.strm.avail_in); - }, - Rt = (t, e) => { - let i, n; - - for (;;) { - if (t.lookahead < ct) { - if (zt(t), t.lookahead < ct && e === G) return 1; - if (0 === t.lookahead) break; - } - - if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 !== i && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i)), t.match_length >= 3) { - if (n = Y(t, t.strstart - t.match_start, t.match_length - 3), t.lookahead -= t.match_length, t.match_length <= t.max_lazy_match && t.lookahead >= 3) { - t.match_length--; - + return t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + }, + Nt = (t, e) => { + let i, n, r; + for (;;) { + if (t.lookahead < ct) { + if (zt(t), t.lookahead < ct && e === G) return 1; + if (0 === t.lookahead) break; + } + if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), t.prev_length = t.match_length, t.prev_match = t.match_start, t.match_length = 2, 0 !== i && t.prev_length < t.max_lazy_match && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i), t.match_length <= 5 && (t.strategy === st || 3 === t.match_length && t.strstart - t.match_start > 4096) && (t.match_length = 2)), t.prev_length >= 3 && t.match_length <= t.prev_length) { + r = t.strstart + t.lookahead - 3, n = Y(t, t.strstart - 1 - t.prev_match, t.prev_length - 3), t.lookahead -= t.prev_length - 1, t.prev_length -= 2; do { - t.strstart++, t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart; - } while (0 != --t.match_length); - - t.strstart++; - } else t.strstart += t.match_length, t.match_length = 0, t.ins_h = t.window[t.strstart], t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 1]); - } else n = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++; - if (n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - }, - Nt = (t, e) => { - let i, n, r; - - for (;;) { - if (t.lookahead < ct) { - if (zt(t), t.lookahead < ct && e === G) return 1; - if (0 === t.lookahead) break; + ++t.strstart <= r && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart); + } while (0 != --t.prev_length); + if (t.match_available = 0, t.match_length = 2, t.strstart++, n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; + } else if (t.match_available) { + if (n = Y(t, 0, t.window[t.strstart - 1]), n && vt(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out) return 1; + } else t.match_available = 1, t.strstart++, t.lookahead--; } - - if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), t.prev_length = t.match_length, t.prev_match = t.match_start, t.match_length = 2, 0 !== i && t.prev_length < t.max_lazy_match && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i), t.match_length <= 5 && (t.strategy === st || 3 === t.match_length && t.strstart - t.match_start > 4096) && (t.match_length = 2)), t.prev_length >= 3 && t.match_length <= t.prev_length) { - r = t.strstart + t.lookahead - 3, n = Y(t, t.strstart - 1 - t.prev_match, t.prev_length - 3), t.lookahead -= t.prev_length - 1, t.prev_length -= 2; - - do { - ++t.strstart <= r && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart); - } while (0 != --t.prev_length); - - if (t.match_available = 0, t.match_length = 2, t.strstart++, n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } else if (t.match_available) { - if (n = Y(t, 0, t.window[t.strstart - 1]), n && vt(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out) return 1; - } else t.match_available = 1, t.strstart++, t.lookahead--; - } - - return t.match_available && (n = Y(t, 0, t.window[t.strstart - 1]), t.match_available = 0), t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - }; - + return t.match_available && (n = Y(t, 0, t.window[t.strstart - 1]), t.match_available = 0), t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + }; function Tt(t, e, i, n, r) { this.good_length = t, this.max_lazy = e, this.nice_length = i, this.max_chain = n, this.func = r; } - const Ot = [new Tt(0, 0, 0, 0, (t, e) => { let i = 65535; - for (i > t.pending_buf_size - 5 && (i = t.pending_buf_size - 5);;) { if (t.lookahead <= 1) { if (zt(t), 0 === t.lookahead && e === G) return 1; if (0 === t.lookahead) break; } - t.strstart += t.lookahead, t.lookahead = 0; const n = t.block_start + i; if ((0 === t.strstart || t.strstart >= n) && (t.lookahead = t.strstart - n, t.strstart = n, vt(t, !1), 0 === t.strm.avail_out)) return 1; if (t.strstart - t.block_start >= t.w_size - ct && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : (t.strstart > t.block_start && (vt(t, !1), t.strm.avail_out), 1); }), new Tt(4, 4, 8, 4, Rt), new Tt(4, 5, 16, 8, Rt), new Tt(4, 6, 32, 32, Rt), new Tt(4, 4, 16, 16, Nt), new Tt(8, 16, 32, 32, Nt), new Tt(8, 16, 128, 128, Nt), new Tt(8, 32, 128, 256, Nt), new Tt(32, 128, 258, 1024, Nt), new Tt(32, 258, 258, 4096, Nt)]; - function Lt() { this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = _t, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new Uint16Array(1146), this.dyn_dtree = new Uint16Array(122), this.bl_tree = new Uint16Array(78), mt(this.dyn_ltree), mt(this.dyn_dtree), mt(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new Uint16Array(16), this.heap = new Uint16Array(573), mt(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new Uint16Array(573), mt(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0; } - const Bt = t => { - if (!t || !t.state) return gt(t, et); - t.total_in = t.total_out = 0, t.data_type = dt; - const e = t.state; - return e.pending = 0, e.pending_out = 0, e.wrap < 0 && (e.wrap = -e.wrap), e.status = e.wrap ? 42 : wt, t.adler = 2 === e.wrap ? 0 : 1, e.last_flush = G, W(e), Q; - }, - Ct = t => { - const e = Bt(t); - var i; - return e === Q && ((i = t.state).window_size = 2 * i.w_size, mt(i.head), i.max_lazy_match = Ot[i.level].max_lazy, i.good_match = Ot[i.level].good_length, i.nice_match = Ot[i.level].nice_length, i.max_chain_length = Ot[i.level].max_chain, i.strstart = 0, i.block_start = 0, i.lookahead = 0, i.insert = 0, i.match_length = i.prev_length = 2, i.match_available = 0, i.ins_h = 0), e; - }, - Dt = (t, e, i, n, r, s) => { - if (!t) return et; - let a = 1; - if (e === rt && (e = 6), n < 0 ? (a = 0, n = -n) : n > 15 && (a = 2, n -= 16), r < 1 || r > 9 || i !== _t || n < 8 || n > 15 || e < 0 || e > 9 || s < 0 || s > ht) return gt(t, et); - 8 === n && (n = 9); - const o = new Lt(); - return t.state = o, o.strm = t, o.wrap = a, o.gzhead = null, o.w_bits = n, o.w_size = 1 << o.w_bits, o.w_mask = o.w_size - 1, o.hash_bits = r + 7, o.hash_size = 1 << o.hash_bits, o.hash_mask = o.hash_size - 1, o.hash_shift = ~~((o.hash_bits + 3 - 1) / 3), o.window = new Uint8Array(2 * o.w_size), o.head = new Uint16Array(o.hash_size), o.prev = new Uint16Array(o.w_size), o.lit_bufsize = 1 << r + 6, o.pending_buf_size = 4 * o.lit_bufsize, o.pending_buf = new Uint8Array(o.pending_buf_size), o.d_buf = 1 * o.lit_bufsize, o.l_buf = 3 * o.lit_bufsize, o.level = e, o.strategy = s, o.method = i, Ct(t); - }; - + if (!t || !t.state) return gt(t, et); + t.total_in = t.total_out = 0, t.data_type = dt; + const e = t.state; + return e.pending = 0, e.pending_out = 0, e.wrap < 0 && (e.wrap = -e.wrap), e.status = e.wrap ? 42 : wt, t.adler = 2 === e.wrap ? 0 : 1, e.last_flush = G, W(e), Q; + }, + Ct = t => { + const e = Bt(t); + var i; + return e === Q && ((i = t.state).window_size = 2 * i.w_size, mt(i.head), i.max_lazy_match = Ot[i.level].max_lazy, i.good_match = Ot[i.level].good_length, i.nice_match = Ot[i.level].nice_length, i.max_chain_length = Ot[i.level].max_chain, i.strstart = 0, i.block_start = 0, i.lookahead = 0, i.insert = 0, i.match_length = i.prev_length = 2, i.match_available = 0, i.ins_h = 0), e; + }, + Dt = (t, e, i, n, r, s) => { + if (!t) return et; + let a = 1; + if (e === rt && (e = 6), n < 0 ? (a = 0, n = -n) : n > 15 && (a = 2, n -= 16), r < 1 || r > 9 || i !== _t || n < 8 || n > 15 || e < 0 || e > 9 || s < 0 || s > ht) return gt(t, et); + 8 === n && (n = 9); + const o = new Lt(); + return t.state = o, o.strm = t, o.wrap = a, o.gzhead = null, o.w_bits = n, o.w_size = 1 << o.w_bits, o.w_mask = o.w_size - 1, o.hash_bits = r + 7, o.hash_size = 1 << o.hash_bits, o.hash_mask = o.hash_size - 1, o.hash_shift = ~~((o.hash_bits + 3 - 1) / 3), o.window = new Uint8Array(2 * o.w_size), o.head = new Uint16Array(o.hash_size), o.prev = new Uint16Array(o.w_size), o.lit_bufsize = 1 << r + 6, o.pending_buf_size = 4 * o.lit_bufsize, o.pending_buf = new Uint8Array(o.pending_buf_size), o.d_buf = 1 * o.lit_bufsize, o.l_buf = 3 * o.lit_bufsize, o.level = e, o.strategy = s, o.method = i, Ct(t); + }; var It = Dt, - St = (t, e) => t && t.state ? 2 !== t.state.wrap ? et : (t.state.gzhead = e, Q) : et, - Zt = (t, e) => { - let i, n; - if (!t || !t.state || e > J || e < 0) return t ? gt(t, et) : et; - const r = t.state; - if (!t.output || !t.input && 0 !== t.avail_in || r.status === pt && e !== q) return gt(t, 0 === t.avail_out ? nt : et); - r.strm = t; - const s = r.last_flush; - if (r.last_flush = e, 42 === r.status) if (2 === r.wrap) t.adler = 0, Et(r, 31), Et(r, 139), Et(r, 8), r.gzhead ? (Et(r, (r.gzhead.text ? 1 : 0) + (r.gzhead.hcrc ? 2 : 0) + (r.gzhead.extra ? 4 : 0) + (r.gzhead.name ? 8 : 0) + (r.gzhead.comment ? 16 : 0)), Et(r, 255 & r.gzhead.time), Et(r, r.gzhead.time >> 8 & 255), Et(r, r.gzhead.time >> 16 & 255), Et(r, r.gzhead.time >> 24 & 255), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 255 & r.gzhead.os), r.gzhead.extra && r.gzhead.extra.length && (Et(r, 255 & r.gzhead.extra.length), Et(r, r.gzhead.extra.length >> 8 & 255)), r.gzhead.hcrc && (t.adler = M(t.adler, r.pending_buf, r.pending, 0)), r.gzindex = 0, r.status = 69) : (Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 3), r.status = wt);else { - let e = _t + (r.w_bits - 8 << 4) << 8, + St = (t, e) => t && t.state ? 2 !== t.state.wrap ? et : (t.state.gzhead = e, Q) : et, + Zt = (t, e) => { + let i, n; + if (!t || !t.state || e > J || e < 0) return t ? gt(t, et) : et; + const r = t.state; + if (!t.output || !t.input && 0 !== t.avail_in || r.status === pt && e !== q) return gt(t, 0 === t.avail_out ? nt : et); + r.strm = t; + const s = r.last_flush; + if (r.last_flush = e, 42 === r.status) if (2 === r.wrap) t.adler = 0, Et(r, 31), Et(r, 139), Et(r, 8), r.gzhead ? (Et(r, (r.gzhead.text ? 1 : 0) + (r.gzhead.hcrc ? 2 : 0) + (r.gzhead.extra ? 4 : 0) + (r.gzhead.name ? 8 : 0) + (r.gzhead.comment ? 16 : 0)), Et(r, 255 & r.gzhead.time), Et(r, r.gzhead.time >> 8 & 255), Et(r, r.gzhead.time >> 16 & 255), Et(r, r.gzhead.time >> 24 & 255), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 255 & r.gzhead.os), r.gzhead.extra && r.gzhead.extra.length && (Et(r, 255 & r.gzhead.extra.length), Et(r, r.gzhead.extra.length >> 8 & 255)), r.gzhead.hcrc && (t.adler = M(t.adler, r.pending_buf, r.pending, 0)), r.gzindex = 0, r.status = 69) : (Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 3), r.status = wt);else { + let e = _t + (r.w_bits - 8 << 4) << 8, i = -1; - i = r.strategy >= at || r.level < 2 ? 0 : r.level < 6 ? 1 : 6 === r.level ? 2 : 3, e |= i << 6, 0 !== r.strstart && (e |= 32), e += 31 - e % 31, r.status = wt, At(r, e), 0 !== r.strstart && (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), t.adler = 1; - } - if (69 === r.status) if (r.gzhead.extra) { - for (i = r.pending; r.gzindex < (65535 & r.gzhead.extra.length) && (r.pending !== r.pending_buf_size || (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending !== r.pending_buf_size));) Et(r, 255 & r.gzhead.extra[r.gzindex]), r.gzindex++; - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), r.gzindex === r.gzhead.extra.length && (r.gzindex = 0, r.status = 73); - } else r.status = 73; - if (73 === r.status) if (r.gzhead.name) { - i = r.pending; - - do { - if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { - n = 1; - break; - } - - n = r.gzindex < r.gzhead.name.length ? 255 & r.gzhead.name.charCodeAt(r.gzindex++) : 0, Et(r, n); - } while (0 !== n); - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.gzindex = 0, r.status = 91); - } else r.status = 91; - if (91 === r.status) if (r.gzhead.comment) { - i = r.pending; - - do { - if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { - n = 1; - break; - } - - n = r.gzindex < r.gzhead.comment.length ? 255 & r.gzhead.comment.charCodeAt(r.gzindex++) : 0, Et(r, n); - } while (0 !== n); - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.status = ut); - } else r.status = ut; - - if (r.status === ut && (r.gzhead.hcrc ? (r.pending + 2 > r.pending_buf_size && yt(t), r.pending + 2 <= r.pending_buf_size && (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), t.adler = 0, r.status = wt)) : r.status = wt), 0 !== r.pending) { - if (yt(t), 0 === t.avail_out) return r.last_flush = -1, Q; - } else if (0 === t.avail_in && bt(e) <= bt(s) && e !== q) return gt(t, nt); - - if (r.status === pt && 0 !== t.avail_in) return gt(t, nt); - - if (0 !== t.avail_in || 0 !== r.lookahead || e !== G && r.status !== pt) { - let i = r.strategy === at ? ((t, e) => { - let i; - - for (;;) { - if (0 === t.lookahead && (zt(t), 0 === t.lookahead)) { - if (e === G) return 1; + i = r.strategy >= at || r.level < 2 ? 0 : r.level < 6 ? 1 : 6 === r.level ? 2 : 3, e |= i << 6, 0 !== r.strstart && (e |= 32), e += 31 - e % 31, r.status = wt, At(r, e), 0 !== r.strstart && (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), t.adler = 1; + } + if (69 === r.status) if (r.gzhead.extra) { + for (i = r.pending; r.gzindex < (65535 & r.gzhead.extra.length) && (r.pending !== r.pending_buf_size || (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending !== r.pending_buf_size));) Et(r, 255 & r.gzhead.extra[r.gzindex]), r.gzindex++; + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), r.gzindex === r.gzhead.extra.length && (r.gzindex = 0, r.status = 73); + } else r.status = 73; + if (73 === r.status) if (r.gzhead.name) { + i = r.pending; + do { + if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { + n = 1; break; } - - if (t.match_length = 0, i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++, i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - })(r, e) : r.strategy === ot ? ((t, e) => { - let i, n, r, s; - const a = t.window; - - for (;;) { - if (t.lookahead <= ft) { - if (zt(t), t.lookahead <= ft && e === G) return 1; - if (0 === t.lookahead) break; + n = r.gzindex < r.gzhead.name.length ? 255 & r.gzhead.name.charCodeAt(r.gzindex++) : 0, Et(r, n); + } while (0 !== n); + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.gzindex = 0, r.status = 91); + } else r.status = 91; + if (91 === r.status) if (r.gzhead.comment) { + i = r.pending; + do { + if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { + n = 1; + break; } - - if (t.match_length = 0, t.lookahead >= 3 && t.strstart > 0 && (r = t.strstart - 1, n = a[r], n === a[++r] && n === a[++r] && n === a[++r])) { - s = t.strstart + ft; - - do {} while (n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && r < s); - - t.match_length = ft - (s - r), t.match_length > t.lookahead && (t.match_length = t.lookahead); + n = r.gzindex < r.gzhead.comment.length ? 255 & r.gzhead.comment.charCodeAt(r.gzindex++) : 0, Et(r, n); + } while (0 !== n); + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.status = ut); + } else r.status = ut; + if (r.status === ut && (r.gzhead.hcrc ? (r.pending + 2 > r.pending_buf_size && yt(t), r.pending + 2 <= r.pending_buf_size && (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), t.adler = 0, r.status = wt)) : r.status = wt), 0 !== r.pending) { + if (yt(t), 0 === t.avail_out) return r.last_flush = -1, Q; + } else if (0 === t.avail_in && bt(e) <= bt(s) && e !== q) return gt(t, nt); + if (r.status === pt && 0 !== t.avail_in) return gt(t, nt); + if (0 !== t.avail_in || 0 !== r.lookahead || e !== G && r.status !== pt) { + let i = r.strategy === at ? ((t, e) => { + let i; + for (;;) { + if (0 === t.lookahead && (zt(t), 0 === t.lookahead)) { + if (e === G) return 1; + break; + } + if (t.match_length = 0, i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++, i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - - if (t.match_length >= 3 ? (i = Y(t, 1, t.match_length - 3), t.lookahead -= t.match_length, t.strstart += t.match_length, t.match_length = 0) : (i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++), i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - })(r, e) : Ot[r.level].func(r, e); - if (3 !== i && 4 !== i || (r.status = pt), 1 === i || 3 === i) return 0 === t.avail_out && (r.last_flush = -1), Q; - if (2 === i && (e === X ? j(r) : e !== J && (K(r, 0, 0, !1), e === V && (mt(r.head), 0 === r.lookahead && (r.strstart = 0, r.block_start = 0, r.insert = 0))), yt(t), 0 === t.avail_out)) return r.last_flush = -1, Q; - } - - return e !== q ? Q : r.wrap <= 0 ? tt : (2 === r.wrap ? (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), Et(r, t.adler >> 16 & 255), Et(r, t.adler >> 24 & 255), Et(r, 255 & t.total_in), Et(r, t.total_in >> 8 & 255), Et(r, t.total_in >> 16 & 255), Et(r, t.total_in >> 24 & 255)) : (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), yt(t), r.wrap > 0 && (r.wrap = -r.wrap), 0 !== r.pending ? Q : tt); - }, - Ft = t => { - if (!t || !t.state) return et; - const e = t.state.status; - return 42 !== e && 69 !== e && 73 !== e && 91 !== e && e !== ut && e !== wt && e !== pt ? gt(t, et) : (t.state = null, e === wt ? gt(t, it) : Q); - }, - Mt = (t, e) => { - let i = e.length; - if (!t || !t.state) return et; - const n = t.state, - r = n.wrap; - if (2 === r || 1 === r && 42 !== n.status || n.lookahead) return et; - - if (1 === r && (t.adler = Z(t.adler, e, i, 0)), n.wrap = 0, i >= n.w_size) { - 0 === r && (mt(n.head), n.strstart = 0, n.block_start = 0, n.insert = 0); - let t = new Uint8Array(n.w_size); - t.set(e.subarray(i - n.w_size, i), 0), e = t, i = n.w_size; - } - - const s = t.avail_in, - a = t.next_in, - o = t.input; - - for (t.avail_in = i, t.next_in = 0, t.input = e, zt(n); n.lookahead >= 3;) { - let t = n.strstart, + return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + })(r, e) : r.strategy === ot ? ((t, e) => { + let i, n, r, s; + const a = t.window; + for (;;) { + if (t.lookahead <= ft) { + if (zt(t), t.lookahead <= ft && e === G) return 1; + if (0 === t.lookahead) break; + } + if (t.match_length = 0, t.lookahead >= 3 && t.strstart > 0 && (r = t.strstart - 1, n = a[r], n === a[++r] && n === a[++r] && n === a[++r])) { + s = t.strstart + ft; + do {} while (n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && r < s); + t.match_length = ft - (s - r), t.match_length > t.lookahead && (t.match_length = t.lookahead); + } + if (t.match_length >= 3 ? (i = Y(t, 1, t.match_length - 3), t.lookahead -= t.match_length, t.strstart += t.match_length, t.match_length = 0) : (i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++), i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; + } + return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + })(r, e) : Ot[r.level].func(r, e); + if (3 !== i && 4 !== i || (r.status = pt), 1 === i || 3 === i) return 0 === t.avail_out && (r.last_flush = -1), Q; + if (2 === i && (e === X ? j(r) : e !== J && (K(r, 0, 0, !1), e === V && (mt(r.head), 0 === r.lookahead && (r.strstart = 0, r.block_start = 0, r.insert = 0))), yt(t), 0 === t.avail_out)) return r.last_flush = -1, Q; + } + return e !== q ? Q : r.wrap <= 0 ? tt : (2 === r.wrap ? (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), Et(r, t.adler >> 16 & 255), Et(r, t.adler >> 24 & 255), Et(r, 255 & t.total_in), Et(r, t.total_in >> 8 & 255), Et(r, t.total_in >> 16 & 255), Et(r, t.total_in >> 24 & 255)) : (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), yt(t), r.wrap > 0 && (r.wrap = -r.wrap), 0 !== r.pending ? Q : tt); + }, + Ft = t => { + if (!t || !t.state) return et; + const e = t.state.status; + return 42 !== e && 69 !== e && 73 !== e && 91 !== e && e !== ut && e !== wt && e !== pt ? gt(t, et) : (t.state = null, e === wt ? gt(t, it) : Q); + }, + Mt = (t, e) => { + let i = e.length; + if (!t || !t.state) return et; + const n = t.state, + r = n.wrap; + if (2 === r || 1 === r && 42 !== n.status || n.lookahead) return et; + if (1 === r && (t.adler = Z(t.adler, e, i, 0)), n.wrap = 0, i >= n.w_size) { + 0 === r && (mt(n.head), n.strstart = 0, n.block_start = 0, n.insert = 0); + let t = new Uint8Array(n.w_size); + t.set(e.subarray(i - n.w_size, i), 0), e = t, i = n.w_size; + } + const s = t.avail_in, + a = t.next_in, + o = t.input; + for (t.avail_in = i, t.next_in = 0, t.input = e, zt(n); n.lookahead >= 3;) { + let t = n.strstart, e = n.lookahead - 2; - - do { - n.ins_h = kt(n, n.ins_h, n.window[t + 3 - 1]), n.prev[t & n.w_mask] = n.head[n.ins_h], n.head[n.ins_h] = t, t++; - } while (--e); - - n.strstart = t, n.lookahead = 2, zt(n); - } - - return n.strstart += n.lookahead, n.block_start = n.strstart, n.insert = n.lookahead, n.lookahead = 0, n.match_length = n.prev_length = 2, n.match_available = 0, t.next_in = a, t.input = o, t.avail_in = s, n.wrap = r, Q; - }; - + do { + n.ins_h = kt(n, n.ins_h, n.window[t + 3 - 1]), n.prev[t & n.w_mask] = n.head[n.ins_h], n.head[n.ins_h] = t, t++; + } while (--e); + n.strstart = t, n.lookahead = 2, zt(n); + } + return n.strstart += n.lookahead, n.block_start = n.strstart, n.insert = n.lookahead, n.lookahead = 0, n.match_length = n.prev_length = 2, n.match_available = 0, t.next_in = a, t.input = o, t.avail_in = s, n.wrap = r, Q; + }; const Pt = (t, e) => Object.prototype.hasOwnProperty.call(t, e); - var Ht = function Ht(t) { - const e = Array.prototype.slice.call(arguments, 1); - - for (; e.length;) { - const i = e.shift(); - - if (i) { - if ("object" != typeof i) throw new TypeError(i + "must be non-object"); - - for (const e in i) Pt(i, e) && (t[e] = i[e]); + const e = Array.prototype.slice.call(arguments, 1); + for (; e.length;) { + const i = e.shift(); + if (i) { + if ("object" != typeof i) throw new TypeError(i + "must be non-object"); + for (const e in i) Pt(i, e) && (t[e] = i[e]); + } } - } - - return t; - }, - Wt = t => { - let e = 0; - - for (let i = 0, n = t.length; i < n; i++) e += t[i].length; - - const i = new Uint8Array(e); - - for (let e = 0, n = 0, r = t.length; e < r; e++) { - let r = t[e]; - i.set(r, n), n += r.length; - } - - return i; - }; - + return t; + }, + Wt = t => { + let e = 0; + for (let i = 0, n = t.length; i < n; i++) e += t[i].length; + const i = new Uint8Array(e); + for (let e = 0, n = 0, r = t.length; e < r; e++) { + let r = t[e]; + i.set(r, n), n += r.length; + } + return i; + }; let Kt = !0; - try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (t) { Kt = !1; } - const $t = new Uint8Array(256); - for (let t = 0; t < 256; t++) $t[t] = t >= 252 ? 6 : t >= 248 ? 5 : t >= 240 ? 4 : t >= 224 ? 3 : t >= 192 ? 2 : 1; - $t[254] = $t[254] = 1; - var Yt = t => { - if ("function" == typeof TextEncoder && TextEncoder.prototype.encode) return new TextEncoder().encode(t); - let e, + if ("function" == typeof TextEncoder && TextEncoder.prototype.encode) return new TextEncoder().encode(t); + let e, i, n, r, s, a = t.length, o = 0; - - for (r = 0; r < a; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), o += i < 128 ? 1 : i < 2048 ? 2 : i < 65536 ? 3 : 4; - - for (e = new Uint8Array(o), s = 0, r = 0; s < o; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), i < 128 ? e[s++] = i : i < 2048 ? (e[s++] = 192 | i >>> 6, e[s++] = 128 | 63 & i) : i < 65536 ? (e[s++] = 224 | i >>> 12, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i) : (e[s++] = 240 | i >>> 18, e[s++] = 128 | i >>> 12 & 63, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i); - - return e; - }, - jt = (t, e) => { - const i = e || t.length; - if ("function" == typeof TextDecoder && TextDecoder.prototype.decode) return new TextDecoder().decode(t.subarray(0, e)); - let n, r; - const s = new Array(2 * i); - - for (r = 0, n = 0; n < i;) { - let e = t[n++]; - - if (e < 128) { - s[r++] = e; - continue; - } - - let a = $t[e]; - if (a > 4) s[r++] = 65533, n += a - 1;else { - for (e &= 2 === a ? 31 : 3 === a ? 15 : 7; a > 1 && n < i;) e = e << 6 | 63 & t[n++], a--; - - a > 1 ? s[r++] = 65533 : e < 65536 ? s[r++] = e : (e -= 65536, s[r++] = 55296 | e >> 10 & 1023, s[r++] = 56320 | 1023 & e); + for (r = 0; r < a; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), o += i < 128 ? 1 : i < 2048 ? 2 : i < 65536 ? 3 : 4; + for (e = new Uint8Array(o), s = 0, r = 0; s < o; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), i < 128 ? e[s++] = i : i < 2048 ? (e[s++] = 192 | i >>> 6, e[s++] = 128 | 63 & i) : i < 65536 ? (e[s++] = 224 | i >>> 12, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i) : (e[s++] = 240 | i >>> 18, e[s++] = 128 | i >>> 12 & 63, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i); + return e; + }, + jt = (t, e) => { + const i = e || t.length; + if ("function" == typeof TextDecoder && TextDecoder.prototype.decode) return new TextDecoder().decode(t.subarray(0, e)); + let n, r; + const s = new Array(2 * i); + for (r = 0, n = 0; n < i;) { + let e = t[n++]; + if (e < 128) { + s[r++] = e; + continue; + } + let a = $t[e]; + if (a > 4) s[r++] = 65533, n += a - 1;else { + for (e &= 2 === a ? 31 : 3 === a ? 15 : 7; a > 1 && n < i;) e = e << 6 | 63 & t[n++], a--; + a > 1 ? s[r++] = 65533 : e < 65536 ? s[r++] = e : (e -= 65536, s[r++] = 55296 | e >> 10 & 1023, s[r++] = 56320 | 1023 & e); + } } - } - - return ((t, e) => { - if (e < 65534 && t.subarray && Kt) return String.fromCharCode.apply(null, t.length === e ? t : t.subarray(0, e)); - let i = ""; - - for (let n = 0; n < e; n++) i += String.fromCharCode(t[n]); - - return i; - })(s, r); - }, - Gt = (t, e) => { - (e = e || t.length) > t.length && (e = t.length); - let i = e - 1; - - for (; i >= 0 && 128 == (192 & t[i]);) i--; - - return i < 0 || 0 === i ? e : i + $t[t[i]] > e ? i : e; - }, - Xt = function Xt() { - this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; - }; - + return ((t, e) => { + if (e < 65534 && t.subarray && Kt) return String.fromCharCode.apply(null, t.length === e ? t : t.subarray(0, e)); + let i = ""; + for (let n = 0; n < e; n++) i += String.fromCharCode(t[n]); + return i; + })(s, r); + }, + Gt = (t, e) => { + (e = e || t.length) > t.length && (e = t.length); + let i = e - 1; + for (; i >= 0 && 128 == (192 & t[i]);) i--; + return i < 0 || 0 === i ? e : i + $t[t[i]] > e ? i : e; + }, + Xt = function Xt() { + this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; + }; const Vt = Object.prototype.toString, - { - Z_NO_FLUSH: qt, - Z_SYNC_FLUSH: Jt, - Z_FULL_FLUSH: Qt, - Z_FINISH: te, - Z_OK: ee, - Z_STREAM_END: ie, - Z_DEFAULT_COMPRESSION: ne, - Z_DEFAULT_STRATEGY: re, - Z_DEFLATED: se - } = H; - + { + Z_NO_FLUSH: qt, + Z_SYNC_FLUSH: Jt, + Z_FULL_FLUSH: Qt, + Z_FINISH: te, + Z_OK: ee, + Z_STREAM_END: ie, + Z_DEFAULT_COMPRESSION: ne, + Z_DEFAULT_STRATEGY: re, + Z_DEFLATED: se + } = H; function ae(t) { this.options = Ht({ level: ne, @@ -3125,326 +2657,260 @@ var n = {}; e.raw && e.windowBits > 0 ? e.windowBits = -e.windowBits : e.gzip && e.windowBits > 0 && e.windowBits < 16 && (e.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new Xt(), this.strm.avail_out = 0; let i = It(this.strm, e.level, e.method, e.windowBits, e.memLevel, e.strategy); if (i !== ee) throw new Error(P[i]); - if (e.header && St(this.strm, e.header), e.dictionary) { let t; if (t = "string" == typeof e.dictionary ? Yt(e.dictionary) : "[object ArrayBuffer]" === Vt.call(e.dictionary) ? new Uint8Array(e.dictionary) : e.dictionary, i = Mt(this.strm, t), i !== ee) throw new Error(P[i]); this._dict_set = !0; } } - function oe(t, e) { const i = new ae(e); if (i.push(t, !0), i.err) throw i.msg || P[i.err]; return i.result; } - ae.prototype.push = function (t, e) { const i = this.strm, - n = this.options.chunkSize; + n = this.options.chunkSize; let r, s; if (this.ended) return !1; - for (s = e === ~~e ? e : !0 === e ? te : qt, "string" == typeof t ? i.input = Yt(t) : "[object ArrayBuffer]" === Vt.call(t) ? i.input = new Uint8Array(t) : i.input = t, i.next_in = 0, i.avail_in = i.input.length;;) if (0 === i.avail_out && (i.output = new Uint8Array(n), i.next_out = 0, i.avail_out = n), (s === Jt || s === Qt) && i.avail_out <= 6) this.onData(i.output.subarray(0, i.next_out)), i.avail_out = 0;else { if (r = Zt(i, s), r === ie) return i.next_out > 0 && this.onData(i.output.subarray(0, i.next_out)), r = Ft(this.strm), this.onEnd(r), this.ended = !0, r === ee; - if (0 !== i.avail_out) { if (s > 0 && i.next_out > 0) this.onData(i.output.subarray(0, i.next_out)), i.avail_out = 0;else if (0 === i.avail_in) break; } else this.onData(i.output); } - return !0; }, ae.prototype.onData = function (t) { this.chunks.push(t); }, ae.prototype.onEnd = function (t) { t === ee && (this.result = Wt(this.chunks)), this.chunks = [], this.err = t, this.msg = this.strm.msg; }; - var he = { - Deflate: ae, - deflate: oe, - deflateRaw: function deflateRaw(t, e) { - return (e = e || {}).raw = !0, oe(t, e); - }, - gzip: function gzip(t, e) { - return (e = e || {}).gzip = !0, oe(t, e); + Deflate: ae, + deflate: oe, + deflateRaw: function deflateRaw(t, e) { + return (e = e || {}).raw = !0, oe(t, e); + }, + gzip: function gzip(t, e) { + return (e = e || {}).gzip = !0, oe(t, e); + }, + constants: H }, - constants: H - }, - le = function le(t, e) { - let i, n, r, s, a, o, h, l, d, _, f, c, u, w, p, g, b, m, k, y, v, E, A, x; - - const U = t.state; - i = t.next_in, A = t.input, n = i + (t.avail_in - 5), r = t.next_out, x = t.output, s = r - (e - t.avail_out), a = r + (t.avail_out - 257), o = U.dmax, h = U.wsize, l = U.whave, d = U.wnext, _ = U.window, f = U.hold, c = U.bits, u = U.lencode, w = U.distcode, p = (1 << U.lenbits) - 1, g = (1 << U.distbits) - 1; - - t: do { - c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = u[f & p]; - - e: for (;;) { - if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, 0 === m) x[r++] = 65535 & b;else { - if (!(16 & m)) { - if (0 == (64 & m)) { - b = u[(65535 & b) + (f & (1 << m) - 1)]; - continue e; - } - - if (32 & m) { - U.mode = 12; - break t; - } - - t.msg = "invalid literal/length code", U.mode = 30; - break t; - } - - k = 65535 & b, m &= 15, m && (c < m && (f += A[i++] << c, c += 8), k += f & (1 << m) - 1, f >>>= m, c -= m), c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = w[f & g]; - - i: for (;;) { - if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, !(16 & m)) { + le = function le(t, e) { + let i, n, r, s, a, o, h, l, d, _, f, c, u, w, p, g, b, m, k, y, v, E, A, x; + const U = t.state; + i = t.next_in, A = t.input, n = i + (t.avail_in - 5), r = t.next_out, x = t.output, s = r - (e - t.avail_out), a = r + (t.avail_out - 257), o = U.dmax, h = U.wsize, l = U.whave, d = U.wnext, _ = U.window, f = U.hold, c = U.bits, u = U.lencode, w = U.distcode, p = (1 << U.lenbits) - 1, g = (1 << U.distbits) - 1; + t: do { + c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = u[f & p]; + e: for (;;) { + if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, 0 === m) x[r++] = 65535 & b;else { + if (!(16 & m)) { if (0 == (64 & m)) { - b = w[(65535 & b) + (f & (1 << m) - 1)]; - continue i; + b = u[(65535 & b) + (f & (1 << m) - 1)]; + continue e; } - - t.msg = "invalid distance code", U.mode = 30; - break t; - } - - if (y = 65535 & b, m &= 15, c < m && (f += A[i++] << c, c += 8, c < m && (f += A[i++] << c, c += 8)), y += f & (1 << m) - 1, y > o) { - t.msg = "invalid distance too far back", U.mode = 30; + if (32 & m) { + U.mode = 12; + break t; + } + t.msg = "invalid literal/length code", U.mode = 30; break t; } - - if (f >>>= m, c -= m, m = r - s, y > m) { - if (m = y - m, m > l && U.sane) { + k = 65535 & b, m &= 15, m && (c < m && (f += A[i++] << c, c += 8), k += f & (1 << m) - 1, f >>>= m, c -= m), c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = w[f & g]; + i: for (;;) { + if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, !(16 & m)) { + if (0 == (64 & m)) { + b = w[(65535 & b) + (f & (1 << m) - 1)]; + continue i; + } + t.msg = "invalid distance code", U.mode = 30; + break t; + } + if (y = 65535 & b, m &= 15, c < m && (f += A[i++] << c, c += 8, c < m && (f += A[i++] << c, c += 8)), y += f & (1 << m) - 1, y > o) { t.msg = "invalid distance too far back", U.mode = 30; break t; } - - if (v = 0, E = _, 0 === d) { - if (v += h - m, m < k) { - k -= m; - - do { - x[r++] = _[v++]; - } while (--m); - - v = r - y, E = x; + if (f >>>= m, c -= m, m = r - s, y > m) { + if (m = y - m, m > l && U.sane) { + t.msg = "invalid distance too far back", U.mode = 30; + break t; } - } else if (d < m) { - if (v += h + d - m, m -= d, m < k) { - k -= m; - - do { - x[r++] = _[v++]; - } while (--m); - - if (v = 0, d < k) { - m = d, k -= m; - + if (v = 0, E = _, 0 === d) { + if (v += h - m, m < k) { + k -= m; do { x[r++] = _[v++]; } while (--m); - v = r - y, E = x; } + } else if (d < m) { + if (v += h + d - m, m -= d, m < k) { + k -= m; + do { + x[r++] = _[v++]; + } while (--m); + if (v = 0, d < k) { + m = d, k -= m; + do { + x[r++] = _[v++]; + } while (--m); + v = r - y, E = x; + } + } + } else if (v += d - m, m < k) { + k -= m; + do { + x[r++] = _[v++]; + } while (--m); + v = r - y, E = x; } - } else if (v += d - m, m < k) { - k -= m; - + for (; k > 2;) x[r++] = E[v++], x[r++] = E[v++], x[r++] = E[v++], k -= 3; + k && (x[r++] = E[v++], k > 1 && (x[r++] = E[v++])); + } else { + v = r - y; do { - x[r++] = _[v++]; - } while (--m); - - v = r - y, E = x; + x[r++] = x[v++], x[r++] = x[v++], x[r++] = x[v++], k -= 3; + } while (k > 2); + k && (x[r++] = x[v++], k > 1 && (x[r++] = x[v++])); } - - for (; k > 2;) x[r++] = E[v++], x[r++] = E[v++], x[r++] = E[v++], k -= 3; - - k && (x[r++] = E[v++], k > 1 && (x[r++] = E[v++])); - } else { - v = r - y; - - do { - x[r++] = x[v++], x[r++] = x[v++], x[r++] = x[v++], k -= 3; - } while (k > 2); - - k && (x[r++] = x[v++], k > 1 && (x[r++] = x[v++])); + break; } - - break; } + break; } - break; - } - } while (i < n && r < a); - - k = c >> 3, i -= k, c -= k << 3, f &= (1 << c) - 1, t.next_in = i, t.next_out = r, t.avail_in = i < n ? n - i + 5 : 5 - (i - n), t.avail_out = r < a ? a - r + 257 : 257 - (r - a), U.hold = f, U.bits = c; - }; - + } while (i < n && r < a); + k = c >> 3, i -= k, c -= k << 3, f &= (1 << c) - 1, t.next_in = i, t.next_out = r, t.avail_in = i < n ? n - i + 5 : 5 - (i - n), t.avail_out = r < a ? a - r + 257 : 257 - (r - a), U.hold = f, U.bits = c; + }; const de = new Uint16Array([3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0]), - _e = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78]), - fe = new Uint16Array([1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0]), - ce = new Uint8Array([16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]); - + _e = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78]), + fe = new Uint16Array([1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0]), + ce = new Uint8Array([16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]); var ue = (t, e, i, n, r, s, a, o) => { const h = o.bits; - let l, - d, - _, - f, - c, - u, - w = 0, - p = 0, - g = 0, - b = 0, - m = 0, - k = 0, - y = 0, - v = 0, - E = 0, - A = 0, - x = null, - U = 0; - + d, + _, + f, + c, + u, + w = 0, + p = 0, + g = 0, + b = 0, + m = 0, + k = 0, + y = 0, + v = 0, + E = 0, + A = 0, + x = null, + U = 0; const z = new Uint16Array(16), - R = new Uint16Array(16); + R = new Uint16Array(16); let N, - T, - O, - L = null, - B = 0; - + T, + O, + L = null, + B = 0; for (w = 0; w <= 15; w++) z[w] = 0; - for (p = 0; p < n; p++) z[e[i + p]]++; - for (m = h, b = 15; b >= 1 && 0 === z[b]; b--); - if (m > b && (m = b), 0 === b) return r[s++] = 20971520, r[s++] = 20971520, o.bits = 1, 0; - for (g = 1; g < b && 0 === z[g]; g++); - for (m < g && (m = g), v = 1, w = 1; w <= 15; w++) if (v <<= 1, v -= z[w], v < 0) return -1; - if (v > 0 && (0 === t || 1 !== b)) return -1; - for (R[1] = 0, w = 1; w < 15; w++) R[w + 1] = R[w] + z[w]; - for (p = 0; p < n; p++) 0 !== e[i + p] && (a[R[e[i + p]]++] = p); - if (0 === t ? (x = L = a, u = 19) : 1 === t ? (x = de, U -= 257, L = _e, B -= 257, u = 256) : (x = fe, L = ce, u = -1), A = 0, p = 0, w = g, c = s, k = m, y = 0, _ = -1, E = 1 << m, f = E - 1, 1 === t && E > 852 || 2 === t && E > 592) return 1; - for (;;) { N = w - y, a[p] < u ? (T = 0, O = a[p]) : a[p] > u ? (T = L[B + a[p]], O = x[U + a[p]]) : (T = 96, O = 0), l = 1 << w - y, d = 1 << k, g = d; - do { d -= l, r[c + (A >> y) + d] = N << 24 | T << 16 | O | 0; } while (0 !== d); - for (l = 1 << w - 1; A & l;) l >>= 1; - if (0 !== l ? (A &= l - 1, A += l) : A = 0, p++, 0 == --z[w]) { if (w === b) break; w = e[i + a[p]]; } - if (w > m && (A & f) !== _) { for (0 === y && (y = m), c += g, k = w - y, v = 1 << k; k + y < b && (v -= z[k + y], !(v <= 0));) k++, v <<= 1; - if (E += 1 << k, 1 === t && E > 852 || 2 === t && E > 592) return 1; _ = A & f, r[_] = m << 24 | k << 16 | c - s | 0; } } - return 0 !== A && (r[c + A] = w - y << 24 | 64 << 16 | 0), o.bits = m, 0; }; - const { - Z_FINISH: we, - Z_BLOCK: pe, - Z_TREES: ge, - Z_OK: be, - Z_STREAM_END: me, - Z_NEED_DICT: ke, - Z_STREAM_ERROR: ye, - Z_DATA_ERROR: ve, - Z_MEM_ERROR: Ee, - Z_BUF_ERROR: Ae, - Z_DEFLATED: xe - } = H, - Ue = 12, - ze = 30, - Re = t => (t >>> 24 & 255) + (t >>> 8 & 65280) + ((65280 & t) << 8) + ((255 & t) << 24); - + Z_FINISH: we, + Z_BLOCK: pe, + Z_TREES: ge, + Z_OK: be, + Z_STREAM_END: me, + Z_NEED_DICT: ke, + Z_STREAM_ERROR: ye, + Z_DATA_ERROR: ve, + Z_MEM_ERROR: Ee, + Z_BUF_ERROR: Ae, + Z_DEFLATED: xe + } = H, + Ue = 12, + ze = 30, + Re = t => (t >>> 24 & 255) + (t >>> 8 & 65280) + ((65280 & t) << 8) + ((255 & t) << 24); function Ne() { this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Uint16Array(320), this.work = new Uint16Array(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0; } - const Te = t => { - if (!t || !t.state) return ye; - const e = t.state; - return t.total_in = t.total_out = e.total = 0, t.msg = "", e.wrap && (t.adler = 1 & e.wrap), e.mode = 1, e.last = 0, e.havedict = 0, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(852), e.distcode = e.distdyn = new Int32Array(592), e.sane = 1, e.back = -1, be; - }, - Oe = t => { - if (!t || !t.state) return ye; - const e = t.state; - return e.wsize = 0, e.whave = 0, e.wnext = 0, Te(t); - }, - Le = (t, e) => { - let i; - if (!t || !t.state) return ye; - const n = t.state; - return e < 0 ? (i = 0, e = -e) : (i = 1 + (e >> 4), e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? ye : (null !== n.window && n.wbits !== e && (n.window = null), n.wrap = i, n.wbits = e, Oe(t)); - }, - Be = (t, e) => { - if (!t) return ye; - const i = new Ne(); - t.state = i, i.window = null; - const n = Le(t, e); - return n !== be && (t.state = null), n; - }; - + if (!t || !t.state) return ye; + const e = t.state; + return t.total_in = t.total_out = e.total = 0, t.msg = "", e.wrap && (t.adler = 1 & e.wrap), e.mode = 1, e.last = 0, e.havedict = 0, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(852), e.distcode = e.distdyn = new Int32Array(592), e.sane = 1, e.back = -1, be; + }, + Oe = t => { + if (!t || !t.state) return ye; + const e = t.state; + return e.wsize = 0, e.whave = 0, e.wnext = 0, Te(t); + }, + Le = (t, e) => { + let i; + if (!t || !t.state) return ye; + const n = t.state; + return e < 0 ? (i = 0, e = -e) : (i = 1 + (e >> 4), e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? ye : (null !== n.window && n.wbits !== e && (n.window = null), n.wrap = i, n.wbits = e, Oe(t)); + }, + Be = (t, e) => { + if (!t) return ye; + const i = new Ne(); + t.state = i, i.window = null; + const n = Le(t, e); + return n !== be && (t.state = null), n; + }; let Ce, - De, - Ie = !0; - + De, + Ie = !0; const Se = t => { - if (Ie) { - Ce = new Int32Array(512), De = new Int32Array(32); - let e = 0; - - for (; e < 144;) t.lens[e++] = 8; - - for (; e < 256;) t.lens[e++] = 9; - - for (; e < 280;) t.lens[e++] = 7; - - for (; e < 288;) t.lens[e++] = 8; - - for (ue(1, t.lens, 0, 288, Ce, 0, t.work, { - bits: 9 - }), e = 0; e < 32;) t.lens[e++] = 5; - - ue(2, t.lens, 0, 32, De, 0, t.work, { - bits: 5 - }), Ie = !1; - } - - t.lencode = Ce, t.lenbits = 9, t.distcode = De, t.distbits = 5; - }, - Ze = (t, e, i, n) => { - let r; - const s = t.state; - return null === s.window && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new Uint8Array(s.wsize)), n >= s.wsize ? (s.window.set(e.subarray(i - s.wsize, i), 0), s.wnext = 0, s.whave = s.wsize) : (r = s.wsize - s.wnext, r > n && (r = n), s.window.set(e.subarray(i - n, i - n + r), s.wnext), (n -= r) ? (s.window.set(e.subarray(i - n, i), 0), s.wnext = n, s.whave = s.wsize) : (s.wnext += r, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += r))), 0; - }; - + if (Ie) { + Ce = new Int32Array(512), De = new Int32Array(32); + let e = 0; + for (; e < 144;) t.lens[e++] = 8; + for (; e < 256;) t.lens[e++] = 9; + for (; e < 280;) t.lens[e++] = 7; + for (; e < 288;) t.lens[e++] = 8; + for (ue(1, t.lens, 0, 288, Ce, 0, t.work, { + bits: 9 + }), e = 0; e < 32;) t.lens[e++] = 5; + ue(2, t.lens, 0, 32, De, 0, t.work, { + bits: 5 + }), Ie = !1; + } + t.lencode = Ce, t.lenbits = 9, t.distcode = De, t.distbits = 5; + }, + Ze = (t, e, i, n) => { + let r; + const s = t.state; + return null === s.window && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new Uint8Array(s.wsize)), n >= s.wsize ? (s.window.set(e.subarray(i - s.wsize, i), 0), s.wnext = 0, s.whave = s.wsize) : (r = s.wsize - s.wnext, r > n && (r = n), s.window.set(e.subarray(i - n, i - n + r), s.wnext), (n -= r) ? (s.window.set(e.subarray(i - n, i), 0), s.wnext = n, s.whave = s.wsize) : (s.wnext += r, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += r))), 0; + }; var Fe = Oe, - Me = Be, - Pe = (t, e) => { - let i, + Me = Be, + Pe = (t, e) => { + let i, n, r, s, @@ -3463,524 +2929,411 @@ var n = {}; b, m, k, - y, - v, - E, - A = 0; - - const x = new Uint8Array(4); - let U, z; - const R = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); - if (!t || !t.state || !t.output || !t.input && 0 !== t.avail_in) return ye; - i = t.state, i.mode === Ue && (i.mode = 13), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, _ = o, f = h, E = be; - - t: for (;;) switch (i.mode) { - case 1: - if (0 === i.wrap) { - i.mode = 13; - break; - } - - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (2 & i.wrap && 35615 === l) { - i.check = 0, x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0), l = 0, d = 0, i.mode = 2; - break; - } - - if (i.flags = 0, i.head && (i.head.done = !1), !(1 & i.wrap) || (((255 & l) << 8) + (l >> 8)) % 31) { - t.msg = "incorrect header check", i.mode = ze; - break; - } - - if ((15 & l) !== xe) { - t.msg = "unknown compression method", i.mode = ze; - break; - } - - if (l >>>= 4, d -= 4, v = 8 + (15 & l), 0 === i.wbits) i.wbits = v;else if (v > i.wbits) { - t.msg = "invalid window size", i.mode = ze; - break; - } - i.dmax = 1 << i.wbits, t.adler = i.check = 1, i.mode = 512 & l ? 10 : Ue, l = 0, d = 0; - break; - - case 2: - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (i.flags = l, (255 & i.flags) !== xe) { - t.msg = "unknown compression method", i.mode = ze; - break; - } - - if (57344 & i.flags) { - t.msg = "unknown header flags set", i.mode = ze; - break; - } - - i.head && (i.head.text = l >> 8 & 1), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 3; - - case 3: - for (; d < 32;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - i.head && (i.head.time = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, x[2] = l >>> 16 & 255, x[3] = l >>> 24 & 255, i.check = M(i.check, x, 4, 0)), l = 0, d = 0, i.mode = 4; - - case 4: - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - i.head && (i.head.xflags = 255 & l, i.head.os = l >> 8), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 5; - - case 5: - if (1024 & i.flags) { - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - i.length = l, i.head && (i.head.extra_len = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0; - } else i.head && (i.head.extra = null); - - i.mode = 6; - - case 6: - if (1024 & i.flags && (c = i.length, c > o && (c = o), c && (i.head && (v = i.head.extra_len - i.length, i.head.extra || (i.head.extra = new Uint8Array(i.head.extra_len)), i.head.extra.set(n.subarray(s, s + c), v)), 512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, i.length -= c), i.length)) break t; - i.length = 0, i.mode = 7; - - case 7: - if (2048 & i.flags) { - if (0 === o) break t; - c = 0; - - do { - v = n[s + c++], i.head && v && i.length < 65536 && (i.head.name += String.fromCharCode(v)); - } while (v && c < o); - - if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; - } else i.head && (i.head.name = null); - - i.length = 0, i.mode = 8; - - case 8: - if (4096 & i.flags) { - if (0 === o) break t; - c = 0; - - do { - v = n[s + c++], i.head && v && i.length < 65536 && (i.head.comment += String.fromCharCode(v)); - } while (v && c < o); - - if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; - } else i.head && (i.head.comment = null); - - i.mode = 9; - - case 9: - if (512 & i.flags) { - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (l !== (65535 & i.check)) { - t.msg = "header crc mismatch", i.mode = ze; - break; - } - - l = 0, d = 0; - } - - i.head && (i.head.hcrc = i.flags >> 9 & 1, i.head.done = !0), t.adler = i.check = 0, i.mode = Ue; - break; - - case 10: - for (; d < 32;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - t.adler = i.check = Re(l), l = 0, d = 0, i.mode = 11; - - case 11: - if (0 === i.havedict) return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, ke; - t.adler = i.check = 1, i.mode = Ue; - - case Ue: - if (e === pe || e === ge) break t; - - case 13: - if (i.last) { - l >>>= 7 & d, d -= 7 & d, i.mode = 27; - break; - } - - for (; d < 3;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - switch (i.last = 1 & l, l >>>= 1, d -= 1, 3 & l) { - case 0: - i.mode = 14; - break; - - case 1: - if (Se(i), i.mode = 20, e === ge) { - l >>>= 2, d -= 2; - break t; - } - - break; - - case 2: - i.mode = 17; - break; - - case 3: - t.msg = "invalid block type", i.mode = ze; - } - - l >>>= 2, d -= 2; - break; - - case 14: - for (l >>>= 7 & d, d -= 7 & d; d < 32;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if ((65535 & l) != (l >>> 16 ^ 65535)) { - t.msg = "invalid stored block lengths", i.mode = ze; - break; - } - - if (i.length = 65535 & l, l = 0, d = 0, i.mode = 15, e === ge) break t; - - case 15: - i.mode = 16; - - case 16: - if (c = i.length, c) { - if (c > o && (c = o), c > h && (c = h), 0 === c) break t; - r.set(n.subarray(s, s + c), a), o -= c, s += c, h -= c, a += c, i.length -= c; - break; - } - - i.mode = Ue; - break; - - case 17: - for (; d < 14;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (i.nlen = 257 + (31 & l), l >>>= 5, d -= 5, i.ndist = 1 + (31 & l), l >>>= 5, d -= 5, i.ncode = 4 + (15 & l), l >>>= 4, d -= 4, i.nlen > 286 || i.ndist > 30) { - t.msg = "too many length or distance symbols", i.mode = ze; - break; - } - - i.have = 0, i.mode = 18; - - case 18: - for (; i.have < i.ncode;) { - for (; d < 3;) { + y, + v, + E, + A = 0; + const x = new Uint8Array(4); + let U, z; + const R = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); + if (!t || !t.state || !t.output || !t.input && 0 !== t.avail_in) return ye; + i = t.state, i.mode === Ue && (i.mode = 13), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, _ = o, f = h, E = be; + t: for (;;) switch (i.mode) { + case 1: + if (0 === i.wrap) { + i.mode = 13; + break; + } + for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - i.lens[R[i.have++]] = 7 & l, l >>>= 3, d -= 3; - } - - for (; i.have < 19;) i.lens[R[i.have++]] = 0; - - if (i.lencode = i.lendyn, i.lenbits = 7, U = { - bits: i.lenbits - }, E = ue(0, i.lens, 0, 19, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { - t.msg = "invalid code lengths set", i.mode = ze; + if (2 & i.wrap && 35615 === l) { + i.check = 0, x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0), l = 0, d = 0, i.mode = 2; + break; + } + if (i.flags = 0, i.head && (i.head.done = !1), !(1 & i.wrap) || (((255 & l) << 8) + (l >> 8)) % 31) { + t.msg = "incorrect header check", i.mode = ze; + break; + } + if ((15 & l) !== xe) { + t.msg = "unknown compression method", i.mode = ze; + break; + } + if (l >>>= 4, d -= 4, v = 8 + (15 & l), 0 === i.wbits) i.wbits = v;else if (v > i.wbits) { + t.msg = "invalid window size", i.mode = ze; + break; + } + i.dmax = 1 << i.wbits, t.adler = i.check = 1, i.mode = 512 & l ? 10 : Ue, l = 0, d = 0; break; - } - - i.have = 0, i.mode = 19; - - case 19: - for (; i.have < i.nlen + i.ndist;) { - for (; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { + case 2: + for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - if (b < 16) l >>>= p, d -= p, i.lens[i.have++] = b;else { - if (16 === b) { - for (z = p + 2; d < z;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (l >>>= p, d -= p, 0 === i.have) { - t.msg = "invalid bit length repeat", i.mode = ze; - break; - } - - v = i.lens[i.have - 1], c = 3 + (3 & l), l >>>= 2, d -= 2; - } else if (17 === b) { - for (z = p + 3; d < z;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - l >>>= p, d -= p, v = 0, c = 3 + (7 & l), l >>>= 3, d -= 3; - } else { - for (z = p + 7; d < z;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - l >>>= p, d -= p, v = 0, c = 11 + (127 & l), l >>>= 7, d -= 7; + if (i.flags = l, (255 & i.flags) !== xe) { + t.msg = "unknown compression method", i.mode = ze; + break; + } + if (57344 & i.flags) { + t.msg = "unknown header flags set", i.mode = ze; + break; + } + i.head && (i.head.text = l >> 8 & 1), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 3; + case 3: + for (; d < 32;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.head && (i.head.time = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, x[2] = l >>> 16 & 255, x[3] = l >>> 24 & 255, i.check = M(i.check, x, 4, 0)), l = 0, d = 0, i.mode = 4; + case 4: + for (; d < 16;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.head && (i.head.xflags = 255 & l, i.head.os = l >> 8), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 5; + case 5: + if (1024 & i.flags) { + for (; d < 16;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; } - - if (i.have + c > i.nlen + i.ndist) { - t.msg = "invalid bit length repeat", i.mode = ze; + i.length = l, i.head && (i.head.extra_len = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0; + } else i.head && (i.head.extra = null); + i.mode = 6; + case 6: + if (1024 & i.flags && (c = i.length, c > o && (c = o), c && (i.head && (v = i.head.extra_len - i.length, i.head.extra || (i.head.extra = new Uint8Array(i.head.extra_len)), i.head.extra.set(n.subarray(s, s + c), v)), 512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, i.length -= c), i.length)) break t; + i.length = 0, i.mode = 7; + case 7: + if (2048 & i.flags) { + if (0 === o) break t; + c = 0; + do { + v = n[s + c++], i.head && v && i.length < 65536 && (i.head.name += String.fromCharCode(v)); + } while (v && c < o); + if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; + } else i.head && (i.head.name = null); + i.length = 0, i.mode = 8; + case 8: + if (4096 & i.flags) { + if (0 === o) break t; + c = 0; + do { + v = n[s + c++], i.head && v && i.length < 65536 && (i.head.comment += String.fromCharCode(v)); + } while (v && c < o); + if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; + } else i.head && (i.head.comment = null); + i.mode = 9; + case 9: + if (512 & i.flags) { + for (; d < 16;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (l !== (65535 & i.check)) { + t.msg = "header crc mismatch", i.mode = ze; break; } - - for (; c--;) i.lens[i.have++] = v; + l = 0, d = 0; } - } - - if (i.mode === ze) break; - - if (0 === i.lens[256]) { - t.msg = "invalid code -- missing end-of-block", i.mode = ze; - break; - } - - if (i.lenbits = 9, U = { - bits: i.lenbits - }, E = ue(1, i.lens, 0, i.nlen, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { - t.msg = "invalid literal/lengths set", i.mode = ze; - break; - } - - if (i.distbits = 6, i.distcode = i.distdyn, U = { - bits: i.distbits - }, E = ue(2, i.lens, i.nlen, i.ndist, i.distcode, 0, i.work, U), i.distbits = U.bits, E) { - t.msg = "invalid distances set", i.mode = ze; - break; - } - - if (i.mode = 20, e === ge) break t; - - case 20: - i.mode = 21; - - case 21: - if (o >= 6 && h >= 258) { - t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, le(t, f), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, i.mode === Ue && (i.back = -1); + i.head && (i.head.hcrc = i.flags >> 9 & 1, i.head.done = !0), t.adler = i.check = 0, i.mode = Ue; break; - } - - for (i.back = 0; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (g && 0 == (240 & g)) { - for (m = p, k = g, y = b; A = i.lencode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + case 10: + for (; d < 32;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - l >>>= m, d -= m, i.back += m; - } - - if (l >>>= p, d -= p, i.back += p, i.length = b, 0 === g) { - i.mode = 26; - break; - } - - if (32 & g) { - i.back = -1, i.mode = Ue; - break; - } - - if (64 & g) { - t.msg = "invalid literal/length code", i.mode = ze; - break; - } - - i.extra = 15 & g, i.mode = 22; - - case 22: - if (i.extra) { - for (z = i.extra; d < z;) { + t.adler = i.check = Re(l), l = 0, d = 0, i.mode = 11; + case 11: + if (0 === i.havedict) return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, ke; + t.adler = i.check = 1, i.mode = Ue; + case Ue: + if (e === pe || e === ge) break t; + case 13: + if (i.last) { + l >>>= 7 & d, d -= 7 & d, i.mode = 27; + break; + } + for (; d < 3;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - i.length += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; - } - - i.was = i.length, i.mode = 23; - - case 23: - for (; A = i.distcode[l & (1 << i.distbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (0 == (240 & g)) { - for (m = p, k = g, y = b; A = i.distcode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + switch (i.last = 1 & l, l >>>= 1, d -= 1, 3 & l) { + case 0: + i.mode = 14; + break; + case 1: + if (Se(i), i.mode = 20, e === ge) { + l >>>= 2, d -= 2; + break t; + } + break; + case 2: + i.mode = 17; + break; + case 3: + t.msg = "invalid block type", i.mode = ze; + } + l >>>= 2, d -= 2; + break; + case 14: + for (l >>>= 7 & d, d -= 7 & d; d < 32;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - l >>>= m, d -= m, i.back += m; - } - - if (l >>>= p, d -= p, i.back += p, 64 & g) { - t.msg = "invalid distance code", i.mode = ze; + if ((65535 & l) != (l >>> 16 ^ 65535)) { + t.msg = "invalid stored block lengths", i.mode = ze; + break; + } + if (i.length = 65535 & l, l = 0, d = 0, i.mode = 15, e === ge) break t; + case 15: + i.mode = 16; + case 16: + if (c = i.length, c) { + if (c > o && (c = o), c > h && (c = h), 0 === c) break t; + r.set(n.subarray(s, s + c), a), o -= c, s += c, h -= c, a += c, i.length -= c; + break; + } + i.mode = Ue; break; - } - - i.offset = b, i.extra = 15 & g, i.mode = 24; - - case 24: - if (i.extra) { - for (z = i.extra; d < z;) { + case 17: + for (; d < 14;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - i.offset += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; - } - - if (i.offset > i.dmax) { - t.msg = "invalid distance too far back", i.mode = ze; - break; - } - - i.mode = 25; - - case 25: - if (0 === h) break t; - - if (c = f - h, i.offset > c) { - if (c = i.offset - c, c > i.whave && i.sane) { - t.msg = "invalid distance too far back", i.mode = ze; + if (i.nlen = 257 + (31 & l), l >>>= 5, d -= 5, i.ndist = 1 + (31 & l), l >>>= 5, d -= 5, i.ncode = 4 + (15 & l), l >>>= 4, d -= 4, i.nlen > 286 || i.ndist > 30) { + t.msg = "too many length or distance symbols", i.mode = ze; break; } - - c > i.wnext ? (c -= i.wnext, u = i.wsize - c) : u = i.wnext - c, c > i.length && (c = i.length), w = i.window; - } else w = r, u = a - i.offset, c = i.length; - - c > h && (c = h), h -= c, i.length -= c; - - do { - r[a++] = w[u++]; - } while (--c); - - 0 === i.length && (i.mode = 21); - break; - - case 26: - if (0 === h) break t; - r[a++] = i.length, h--, i.mode = 21; - break; - - case 27: - if (i.wrap) { - for (; d < 32;) { + i.have = 0, i.mode = 18; + case 18: + for (; i.have < i.ncode;) { + for (; d < 3;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.lens[R[i.have++]] = 7 & l, l >>>= 3, d -= 3; + } + for (; i.have < 19;) i.lens[R[i.have++]] = 0; + if (i.lencode = i.lendyn, i.lenbits = 7, U = { + bits: i.lenbits + }, E = ue(0, i.lens, 0, 19, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { + t.msg = "invalid code lengths set", i.mode = ze; + break; + } + i.have = 0, i.mode = 19; + case 19: + for (; i.have < i.nlen + i.ndist;) { + for (; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (b < 16) l >>>= p, d -= p, i.lens[i.have++] = b;else { + if (16 === b) { + for (z = p + 2; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (l >>>= p, d -= p, 0 === i.have) { + t.msg = "invalid bit length repeat", i.mode = ze; + break; + } + v = i.lens[i.have - 1], c = 3 + (3 & l), l >>>= 2, d -= 2; + } else if (17 === b) { + for (z = p + 3; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= p, d -= p, v = 0, c = 3 + (7 & l), l >>>= 3, d -= 3; + } else { + for (z = p + 7; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= p, d -= p, v = 0, c = 11 + (127 & l), l >>>= 7, d -= 7; + } + if (i.have + c > i.nlen + i.ndist) { + t.msg = "invalid bit length repeat", i.mode = ze; + break; + } + for (; c--;) i.lens[i.have++] = v; + } + } + if (i.mode === ze) break; + if (0 === i.lens[256]) { + t.msg = "invalid code -- missing end-of-block", i.mode = ze; + break; + } + if (i.lenbits = 9, U = { + bits: i.lenbits + }, E = ue(1, i.lens, 0, i.nlen, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { + t.msg = "invalid literal/lengths set", i.mode = ze; + break; + } + if (i.distbits = 6, i.distcode = i.distdyn, U = { + bits: i.distbits + }, E = ue(2, i.lens, i.nlen, i.ndist, i.distcode, 0, i.work, U), i.distbits = U.bits, E) { + t.msg = "invalid distances set", i.mode = ze; + break; + } + if (i.mode = 20, e === ge) break t; + case 20: + i.mode = 21; + case 21: + if (o >= 6 && h >= 258) { + t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, le(t, f), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, i.mode === Ue && (i.back = -1); + break; + } + for (i.back = 0; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { if (0 === o) break t; - o--, l |= n[s++] << d, d += 8; + o--, l += n[s++] << d, d += 8; } - - if (f -= h, t.total_out += f, i.total += f, f && (t.adler = i.check = i.flags ? M(i.check, r, f, a - f) : Z(i.check, r, f, a - f)), f = h, (i.flags ? l : Re(l)) !== i.check) { - t.msg = "incorrect data check", i.mode = ze; + if (g && 0 == (240 & g)) { + for (m = p, k = g, y = b; A = i.lencode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= m, d -= m, i.back += m; + } + if (l >>>= p, d -= p, i.back += p, i.length = b, 0 === g) { + i.mode = 26; break; } - - l = 0, d = 0; - } - - i.mode = 28; - - case 28: - if (i.wrap && i.flags) { - for (; d < 32;) { + if (32 & g) { + i.back = -1, i.mode = Ue; + break; + } + if (64 & g) { + t.msg = "invalid literal/length code", i.mode = ze; + break; + } + i.extra = 15 & g, i.mode = 22; + case 22: + if (i.extra) { + for (z = i.extra; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.length += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; + } + i.was = i.length, i.mode = 23; + case 23: + for (; A = i.distcode[l & (1 << i.distbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - if (l !== (4294967295 & i.total)) { - t.msg = "incorrect length check", i.mode = ze; + if (0 == (240 & g)) { + for (m = p, k = g, y = b; A = i.distcode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= m, d -= m, i.back += m; + } + if (l >>>= p, d -= p, i.back += p, 64 & g) { + t.msg = "invalid distance code", i.mode = ze; break; } - - l = 0, d = 0; - } - - i.mode = 29; - - case 29: - E = me; - break t; - - case ze: - E = ve; - break t; - - case 31: - return Ee; - - default: - return ye; - } - - return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, (i.wsize || f !== t.avail_out && i.mode < ze && (i.mode < 27 || e !== we)) && Ze(t, t.output, t.next_out, f - t.avail_out), _ -= t.avail_in, f -= t.avail_out, t.total_in += _, t.total_out += f, i.total += f, i.wrap && f && (t.adler = i.check = i.flags ? M(i.check, r, f, t.next_out - f) : Z(i.check, r, f, t.next_out - f)), t.data_type = i.bits + (i.last ? 64 : 0) + (i.mode === Ue ? 128 : 0) + (20 === i.mode || 15 === i.mode ? 256 : 0), (0 === _ && 0 === f || e === we) && E === be && (E = Ae), E; - }, - He = t => { - if (!t || !t.state) return ye; - let e = t.state; - return e.window && (e.window = null), t.state = null, be; - }, - We = (t, e) => { - if (!t || !t.state) return ye; - const i = t.state; - return 0 == (2 & i.wrap) ? ye : (i.head = e, e.done = !1, be); - }, - Ke = (t, e) => { - const i = e.length; - let n, r, s; - return t && t.state ? (n = t.state, 0 !== n.wrap && 11 !== n.mode ? ye : 11 === n.mode && (r = 1, r = Z(r, e, i, 0), r !== n.check) ? ve : (s = Ze(t, e, i, i), s ? (n.mode = 31, Ee) : (n.havedict = 1, be))) : ye; - }, - $e = function $e() { - this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; - }; - + i.offset = b, i.extra = 15 & g, i.mode = 24; + case 24: + if (i.extra) { + for (z = i.extra; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.offset += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; + } + if (i.offset > i.dmax) { + t.msg = "invalid distance too far back", i.mode = ze; + break; + } + i.mode = 25; + case 25: + if (0 === h) break t; + if (c = f - h, i.offset > c) { + if (c = i.offset - c, c > i.whave && i.sane) { + t.msg = "invalid distance too far back", i.mode = ze; + break; + } + c > i.wnext ? (c -= i.wnext, u = i.wsize - c) : u = i.wnext - c, c > i.length && (c = i.length), w = i.window; + } else w = r, u = a - i.offset, c = i.length; + c > h && (c = h), h -= c, i.length -= c; + do { + r[a++] = w[u++]; + } while (--c); + 0 === i.length && (i.mode = 21); + break; + case 26: + if (0 === h) break t; + r[a++] = i.length, h--, i.mode = 21; + break; + case 27: + if (i.wrap) { + for (; d < 32;) { + if (0 === o) break t; + o--, l |= n[s++] << d, d += 8; + } + if (f -= h, t.total_out += f, i.total += f, f && (t.adler = i.check = i.flags ? M(i.check, r, f, a - f) : Z(i.check, r, f, a - f)), f = h, (i.flags ? l : Re(l)) !== i.check) { + t.msg = "incorrect data check", i.mode = ze; + break; + } + l = 0, d = 0; + } + i.mode = 28; + case 28: + if (i.wrap && i.flags) { + for (; d < 32;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (l !== (4294967295 & i.total)) { + t.msg = "incorrect length check", i.mode = ze; + break; + } + l = 0, d = 0; + } + i.mode = 29; + case 29: + E = me; + break t; + case ze: + E = ve; + break t; + case 31: + return Ee; + default: + return ye; + } + return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, (i.wsize || f !== t.avail_out && i.mode < ze && (i.mode < 27 || e !== we)) && Ze(t, t.output, t.next_out, f - t.avail_out), _ -= t.avail_in, f -= t.avail_out, t.total_in += _, t.total_out += f, i.total += f, i.wrap && f && (t.adler = i.check = i.flags ? M(i.check, r, f, t.next_out - f) : Z(i.check, r, f, t.next_out - f)), t.data_type = i.bits + (i.last ? 64 : 0) + (i.mode === Ue ? 128 : 0) + (20 === i.mode || 15 === i.mode ? 256 : 0), (0 === _ && 0 === f || e === we) && E === be && (E = Ae), E; + }, + He = t => { + if (!t || !t.state) return ye; + let e = t.state; + return e.window && (e.window = null), t.state = null, be; + }, + We = (t, e) => { + if (!t || !t.state) return ye; + const i = t.state; + return 0 == (2 & i.wrap) ? ye : (i.head = e, e.done = !1, be); + }, + Ke = (t, e) => { + const i = e.length; + let n, r, s; + return t && t.state ? (n = t.state, 0 !== n.wrap && 11 !== n.mode ? ye : 11 === n.mode && (r = 1, r = Z(r, e, i, 0), r !== n.check) ? ve : (s = Ze(t, e, i, i), s ? (n.mode = 31, Ee) : (n.havedict = 1, be))) : ye; + }, + $e = function $e() { + this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; + }; const Ye = Object.prototype.toString, - { - Z_NO_FLUSH: je, - Z_FINISH: Ge, - Z_OK: Xe, - Z_STREAM_END: Ve, - Z_NEED_DICT: qe, - Z_STREAM_ERROR: Je, - Z_DATA_ERROR: Qe, - Z_MEM_ERROR: ti - } = H; - + { + Z_NO_FLUSH: je, + Z_FINISH: Ge, + Z_OK: Xe, + Z_STREAM_END: Ve, + Z_NEED_DICT: qe, + Z_STREAM_ERROR: Je, + Z_DATA_ERROR: Qe, + Z_MEM_ERROR: ti + } = H; function ei(t) { this.options = Ht({ chunkSize: 65536, @@ -3993,23 +3346,19 @@ var n = {}; if (i !== Xe) throw new Error(P[i]); if (this.header = new $e(), We(this.strm, this.header), e.dictionary && ("string" == typeof e.dictionary ? e.dictionary = Yt(e.dictionary) : "[object ArrayBuffer]" === Ye.call(e.dictionary) && (e.dictionary = new Uint8Array(e.dictionary)), e.raw && (i = Ke(this.strm, e.dictionary), i !== Xe))) throw new Error(P[i]); } - function ii(t, e) { const i = new ei(e); if (i.push(t), i.err) throw i.msg || P[i.err]; return i.result; } - ei.prototype.push = function (t, e) { const i = this.strm, - n = this.options.chunkSize, - r = this.options.dictionary; + n = this.options.chunkSize, + r = this.options.dictionary; let s, a, o; if (this.ended) return !1; - for (a = e === ~~e ? e : !0 === e ? Ge : je, "[object ArrayBuffer]" === Ye.call(t) ? i.input = new Uint8Array(t) : i.input = t, i.next_in = 0, i.avail_in = i.input.length;;) { for (0 === i.avail_out && (i.output = new Uint8Array(n), i.next_out = 0, i.avail_out = n), s = Pe(i, a), s === qe && r && (s = Ke(i, r), s === Xe ? s = Pe(i, a) : s === Qe && (s = qe)); i.avail_in > 0 && s === Ve && i.state.wrap > 0 && 0 !== t[i.next_in];) Fe(i), s = Pe(i, a); - switch (s) { case Je: case Qe: @@ -4017,20 +3366,17 @@ var n = {}; case ti: return this.onEnd(s), this.ended = !0, !1; } - if (o = i.avail_out, i.next_out && (0 === i.avail_out || s === Ve)) if ("string" === this.options.to) { let t = Gt(i.output, i.next_out), - e = i.next_out - t, - r = jt(i.output, t); + e = i.next_out - t, + r = jt(i.output, t); i.next_out = e, i.avail_out = n - e, e && i.output.set(i.output.subarray(t, t + e), 0), this.onData(r); } else this.onData(i.output.length === i.next_out ? i.output : i.output.subarray(0, i.next_out)); - if (s !== Xe || 0 !== o) { if (s === Ve) return s = He(this.strm), this.onEnd(s), this.ended = !0, !0; if (0 === i.avail_in) break; } } - return !0; }, ei.prototype.onData = function (t) { this.chunks.push(t); @@ -4047,43 +3393,35 @@ var n = {}; constants: H }; const { - Deflate: ri, - deflate: si, - deflateRaw: ai, - gzip: oi - } = he, - { - Inflate: hi, - inflate: li, - inflateRaw: di, - ungzip: _i - } = ni; + Deflate: ri, + deflate: si, + deflateRaw: ai, + gzip: oi + } = he, + { + Inflate: hi, + inflate: li, + inflateRaw: di, + ungzip: _i + } = ni; var fi = si, - ci = hi, - ui = li; + ci = hi, + ui = li; const wi = [137, 80, 78, 71, 13, 10, 26, 10], - pi = []; - + pi = []; for (let t = 0; t < 256; t++) { let e = t; - for (let t = 0; t < 8; t++) 1 & e ? e = 3988292384 ^ e >>> 1 : e >>>= 1; - pi[t] = e; } - const gi = 4294967295; - function bi(t, e) { return (function (t, e, i) { let n = 4294967295; - for (let t = 0; t < i; t++) n = pi[255 & (n ^ e[t])] ^ n >>> 8; - return n; }(0, t, e) ^ gi) >>> 0; } - var mi, ki, yi, vi; !function (t) { t[t.UNKNOWN = -1] = "UNKNOWN", t[t.GREYSCALE = 0] = "GREYSCALE", t[t.TRUECOLOUR = 2] = "TRUECOLOUR", t[t.INDEXED_COLOUR = 3] = "INDEXED_COLOUR", t[t.GREYSCALE_ALPHA = 4] = "GREYSCALE_ALPHA", t[t.TRUECOLOUR_ALPHA = 6] = "TRUECOLOUR_ALPHA"; @@ -4095,9 +3433,8 @@ var n = {}; t[t.UNKNOWN = -1] = "UNKNOWN", t[t.NO_INTERLACE = 0] = "NO_INTERLACE", t[t.ADAM7 = 1] = "ADAM7"; }(vi || (vi = {})); const Ei = new Uint8Array(0), - Ai = new Uint16Array([255]), - xi = 255 === new Uint8Array(Ai.buffer)[0]; - + Ai = new Uint16Array([255]), + xi = 255 === new Uint8Array(Ai.buffer)[0]; class Ui extends r { constructor(t) { let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; @@ -4114,69 +3451,53 @@ var n = {}; text: {} }, this._end = !1, this._hasPalette = !1, this._palette = [], this._compressionMethod = ki.UNKNOWN, this._filterMethod = yi.UNKNOWN, this._interlaceMethod = vi.UNKNOWN, this._colorType = -1, this.setBigEndian(); } - decode() { for (this.decodeSignature(); !this._end;) this.decodeChunk(); - return this.decodeImage(), this._png; } - decodeSignature() { for (let t = 0; t < wi.length; t++) if (this.readUint8() !== wi[t]) throw new Error("wrong PNG signature. Byte at ".concat(t, " should be ").concat(wi[t], ".")); } - decodeChunk() { const t = this.readUint32(), - e = this.readChars(4), - i = this.offset; - + e = this.readChars(4), + i = this.offset; switch (e) { case "IHDR": this.decodeIHDR(); break; - case "PLTE": this.decodePLTE(t); break; - case "IDAT": this.decodeIDAT(t); break; - case "IEND": this._end = !0; break; - case "tRNS": this.decodetRNS(t); break; - case "iCCP": this.decodeiCCP(t); break; - case "tEXt": this.decodetEXt(t); break; - case "pHYs": this.decodepHYs(); break; - default: this.skip(t); } - if (this.offset - i !== t) throw new Error("Length mismatch while decoding chunk ".concat(e)); - if (this._checkCrc) { const i = this.readUint32(), - n = t + 4, - r = bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - n - 4, n), n); + n = t + 4, + r = bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - n - 4, n), n); if (r !== i) throw new Error("CRC mismatch for chunk ".concat(e, ". Expected ").concat(i, ", found ").concat(r)); } else this.skip(4); } - decodeIHDR() { const t = this._png; t.width = this.readUint32(), t.height = this.readUint32(), t.depth = function (t) { @@ -4185,71 +3506,54 @@ var n = {}; }(this.readUint8()); const e = this.readUint8(); let i; - switch (this._colorType = e, e) { case mi.GREYSCALE: i = 1; break; - case mi.TRUECOLOUR: i = 3; break; - case mi.INDEXED_COLOUR: i = 1; break; - case mi.GREYSCALE_ALPHA: i = 2; break; - case mi.TRUECOLOUR_ALPHA: i = 4; break; - default: throw new Error("Unknown color type: ".concat(e)); } - if (this._png.channels = i, this._compressionMethod = this.readUint8(), this._compressionMethod !== ki.DEFLATE) throw new Error("Unsupported compression method: ".concat(this._compressionMethod)); this._filterMethod = this.readUint8(), this._interlaceMethod = this.readUint8(); } - decodePLTE(t) { if (t % 3 != 0) throw new RangeError("PLTE field length must be a multiple of 3. Got ".concat(t)); const e = t / 3; this._hasPalette = !0; const i = []; this._palette = i; - for (let t = 0; t < e; t++) i.push([this.readUint8(), this.readUint8(), this.readUint8()]); } - decodeIDAT(t) { this._inflator.push(new Uint8Array(this.buffer, this.offset + this.byteOffset, t)), this.skip(t); } - decodetRNS(t) { if (3 === this._colorType) { if (t > this._palette.length) throw new Error("tRNS chunk contains more alpha values than there are palette colors (".concat(t, " vs ").concat(this._palette.length, ")")); let e = 0; - for (; e < t; e++) { const t = this.readByte(); - this._palette[e].push(t); } - for (; e < this._palette.length; e++) this._palette[e].push(255); } } - decodeiCCP(t) { let e, - i = ""; - + i = ""; for (; "\0" !== (e = this.readChar());) i += e; - const n = this.readUint8(); if (n !== ki.DEFLATE) throw new Error("Unsupported iCCP compression method: ".concat(n)); const r = this.readBytes(t - i.length - 2); @@ -4258,27 +3562,22 @@ var n = {}; profile: ui(r) }; } - decodetEXt(t) { let e, - i = ""; - + i = ""; for (; "\0" !== (e = this.readChar());) i += e; - this._png.text[i] = this.readChars(t - i.length - 1); } - decodepHYs() { const t = this.readUint32(), - e = this.readUint32(), - i = this.readByte(); + e = this.readUint32(), + i = this.readByte(); this._png.resolution = { x: t, y: e, unit: i }; } - decodeImage() { if (this._inflator.err) throw new Error("Error while decompressing the data: ".concat(this._inflator.err)); const t = this._inflator.result; @@ -4286,267 +3585,212 @@ var n = {}; if (this._interlaceMethod !== vi.NO_INTERLACE) throw new Error("Interlace method ".concat(this._interlaceMethod, " not supported")); this.decodeInterlaceNull(t); } - decodeInterlaceNull(t) { const e = this._png.height, - i = this._png.channels * this._png.depth / 8, - n = this._png.width * i, - r = new Uint8Array(this._png.height * n); + i = this._png.channels * this._png.depth / 8, + n = this._png.width * i, + r = new Uint8Array(this._png.height * n); let s, - a, - o = Ei, - h = 0; - + a, + o = Ei, + h = 0; for (let l = 0; l < e; l++) { switch (s = t.subarray(h + 1, h + 1 + n), a = r.subarray(l * n, (l + 1) * n), t[h]) { case 0: zi(s, a, n); break; - case 1: Ri(s, a, n, i); break; - case 2: Ni(s, a, o, n); break; - case 3: Ti(s, a, o, n, i); break; - case 4: Oi(s, a, o, n, i); break; - default: throw new Error("Unsupported filter: ".concat(t[h])); } - o = a, h += n + 1; } - if (this._hasPalette && (this._png.palette = this._palette), 16 === this._png.depth) { const t = new Uint16Array(r.buffer); if (xi) for (let e = 0; e < t.length; e++) t[e] = (255 & (l = t[e])) << 8 | l >> 8 & 255; this._png.data = t; } else this._png.data = r; - var l; } - } - function zi(t, e, i) { for (let n = 0; n < i; n++) e[n] = t[n]; } - function Ri(t, e, i, n) { let r = 0; - for (; r < n; r++) e[r] = t[r]; - for (; r < i; r++) e[r] = t[r] + e[r - n] & 255; } - function Ni(t, e, i, n) { let r = 0; if (0 === i.length) for (; r < n; r++) e[r] = t[r];else for (; r < n; r++) e[r] = t[r] + i[r] & 255; } - function Ti(t, e, i, n, r) { let s = 0; - if (0 === i.length) { for (; s < r; s++) e[s] = t[s]; - for (; s < n; s++) e[s] = t[s] + (e[s - r] >> 1) & 255; } else { for (; s < r; s++) e[s] = t[s] + (i[s] >> 1) & 255; - for (; s < n; s++) e[s] = t[s] + (e[s - r] + i[s] >> 1) & 255; } } - function Oi(t, e, i, n, r) { let s = 0; - if (0 === i.length) { for (; s < r; s++) e[s] = t[s]; - for (; s < n; s++) e[s] = t[s] + e[s - r] & 255; } else { for (; s < r; s++) e[s] = t[s] + i[s] & 255; - for (; s < n; s++) e[s] = t[s] + Li(e[s - r], i[s], i[s - r]) & 255; } } - function Li(t, e, i) { const n = t + e - i, - r = Math.abs(n - t), - s = Math.abs(n - e), - a = Math.abs(n - i); + r = Math.abs(n - t), + s = Math.abs(n - e), + a = Math.abs(n - i); return r <= s && r <= a ? t : s <= a ? e : i; } - const Bi = { level: 3 }; - class Ci extends r { constructor(t) { let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; super(), this._colorType = mi.UNKNOWN, this._zlibOptions = _objectSpread2(_objectSpread2({}, Bi), e.zlib), this._png = this._checkData(t), this.setBigEndian(); } - encode() { return this.encodeSignature(), this.encodeIHDR(), this.encodeData(), this.encodeIEND(), this.toArray(); } - encodeSignature() { this.writeBytes(wi); } - encodeIHDR() { this.writeUint32(13), this.writeChars("IHDR"), this.writeUint32(this._png.width), this.writeUint32(this._png.height), this.writeByte(this._png.depth), this.writeByte(this._colorType), this.writeByte(ki.DEFLATE), this.writeByte(yi.ADAPTIVE), this.writeByte(vi.NO_INTERLACE), this.writeCrc(17); } - encodeIEND() { this.writeUint32(0), this.writeChars("IEND"), this.writeCrc(4); } - encodeIDAT(t) { this.writeUint32(t.length), this.writeChars("IDAT"), this.writeBytes(t), this.writeCrc(t.length + 4); } - encodeData() { const { - width: t, - height: e, - channels: i, - depth: n, - data: s - } = this._png, - a = i * t, - o = new r().setBigEndian(); + width: t, + height: e, + channels: i, + depth: n, + data: s + } = this._png, + a = i * t, + o = new r().setBigEndian(); let h = 0; - for (let t = 0; t < e; t++) if (o.writeByte(0), 8 === n) h = Ii(s, o, a, h);else { if (16 !== n) throw new Error("unreachable"); h = Si(s, o, a, h); } - const l = o.toArray(), - d = fi(l, this._zlibOptions); + d = fi(l, this._zlibOptions); this.encodeIDAT(d); } - _checkData(t) { const { - colorType: e, - channels: i, - depth: n - } = function (t) { - const { - channels: e = 4, - depth: i = 8 - } = t; - if (4 !== e && 3 !== e && 2 !== e && 1 !== e) throw new RangeError("unsupported number of channels: ".concat(e)); - if (8 !== i && 16 !== i) throw new RangeError("unsupported bit depth: ".concat(i)); - const n = { - channels: e, - depth: i, - colorType: mi.UNKNOWN + colorType: e, + channels: i, + depth: n + } = function (t) { + const { + channels: e = 4, + depth: i = 8 + } = t; + if (4 !== e && 3 !== e && 2 !== e && 1 !== e) throw new RangeError("unsupported number of channels: ".concat(e)); + if (8 !== i && 16 !== i) throw new RangeError("unsupported bit depth: ".concat(i)); + const n = { + channels: e, + depth: i, + colorType: mi.UNKNOWN + }; + switch (e) { + case 4: + n.colorType = mi.TRUECOLOUR_ALPHA; + break; + case 3: + n.colorType = mi.TRUECOLOUR; + break; + case 1: + n.colorType = mi.GREYSCALE; + break; + case 2: + n.colorType = mi.GREYSCALE_ALPHA; + break; + default: + throw new Error("unsupported number of channels"); + } + return n; + }(t), + r = { + width: Di(t.width, "width"), + height: Di(t.height, "height"), + channels: i, + data: t.data, + depth: n, + text: {} }; - - switch (e) { - case 4: - n.colorType = mi.TRUECOLOUR_ALPHA; - break; - - case 3: - n.colorType = mi.TRUECOLOUR; - break; - - case 1: - n.colorType = mi.GREYSCALE; - break; - - case 2: - n.colorType = mi.GREYSCALE_ALPHA; - break; - - default: - throw new Error("unsupported number of channels"); - } - - return n; - }(t), - r = { - width: Di(t.width, "width"), - height: Di(t.height, "height"), - channels: i, - data: t.data, - depth: n, - text: {} - }; - this._colorType = e; const s = r.width * r.height * i; if (r.data.length !== s) throw new RangeError("wrong data size. Found ".concat(r.data.length, ", expected ").concat(s)); return r; } - writeCrc(t) { this.writeUint32(bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - t, t), t)); } - } - function Di(t, e) { if (Number.isInteger(t) && t > 0) return t; throw new TypeError("".concat(e, " must be a positive integer")); } - function Ii(t, e, i, n) { for (let r = 0; r < i; r++) e.writeByte(t[n++]); - return n; } - function Si(t, e, i, n) { for (let r = 0; r < i; r++) e.writeUint16(t[n++]); - return n; } - var Zi; !function (t) { t[t.UNKNOWN = 0] = "UNKNOWN", t[t.METRE = 1] = "METRE"; }(Zi || (Zi = {})); - const Fi = (t, e, i) => new Ci({ - width: t, - height: e, - data: i - }, undefined).encode(), - Mi = t => function (t, e) { - return new Ui(t, void 0).decode(); - }(t); + width: t, + height: e, + data: i + }, undefined).encode(), + Mi = t => function (t, e) { + return new Ui(t, void 0).decode(); + }(t); })(); - var r = n.P, - s = n.m; + s = n.m; function isTypeObject(object) { return object && object.hasOwnProperty('type') && object.hasOwnProperty('data'); } - function stringify(o, gap, indentation) { if (isTypeObject(o)) { let s = stringify(o.data, gap, indentation); - if (s.includes('\n')) { return ' #!' + o.type + s; } else { @@ -4554,17 +3798,13 @@ function stringify(o, gap, indentation) { } } else if (o && 'object' === typeof o) { let isArray = Array.isArray(o); - if (Object.keys(o).length == 0) { if (isArray) return '[]';else return '{}'; } - let s = '\n'; - for (let k in o) { if (Object.hasOwnProperty.call(o, k)) { s += gap.repeat(indentation + 1); - if (isArray) { s += '- ' + stringify(o[k], gap, indentation + 1); } else { @@ -4575,11 +3815,9 @@ function stringify(o, gap, indentation) { s += k + ': ' + stringify(o[k], gap, indentation + 1); } } - s += '\n'; } } - return s; } else if ('string' === typeof o) { return JSON.stringify(o); @@ -4591,118 +3829,92 @@ function stringify(o, gap, indentation) { throw new Error('Non-implemented parsing for ' + o); } } - function preStringify(object) { let space = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4; var gap = ''; - if (typeof space == 'number') { gap = ' '.repeat(Math.min(10, space)); } else if (typeof space == 'string') { gap = space.slice(0, 10); } - return stringify(object, gap, -1); } - class LineGenerator { constructor(lines, indentString, startingLine) { this.startingLine = startingLine || 0; this.lineIndex = -1; let filteredLines = []; - for (let i = 0; i < lines.length; i++) { let trimmedLine = lines[i].trim(); - if (trimmedLine !== '') { filteredLines.push([lines[i], i]); } } - this.lines = filteredLines; this.indentString = indentString || this.findIndentString(); } - getLineNumber() { return this.startingLine + this.lineIndex; } - nextGroup() { let lines = []; let baseIndent = this.indentLevel(this.lineIndex + 1); - while (!this.finished() && this.indentLevel(this.lineIndex + 1) >= baseIndent) { lines.push(this.next()); } - return new LineGenerator(lines, this.indentString, this.getLineNumber() - lines.length); } - next() { if (this.finished()) throw new Error('Trying to next finished generator'); this.lineIndex++; return this.getLine(); } - peek() { return this.getLine(this.lineIndex + 1); } - finished() { return this.lineIndex == this.lines.length - 1; } - getLine(index) { index = index !== undefined ? index : this.lineIndex; if (index >= this.lines.length) return null; return this.lines[index][0]; } - findIndentString() { for (let [line] of this.lines) { if (!line.trim() || line.replace(/^\s+/, "") == line) continue; return line.match(/^(\s+)/)[1]; } - return ''; } - indentLevel(index) { index = index !== undefined ? index : this.lineIndex; if (index < 0) index = 0; let indentLevel = 0; let line = this.getLine(index); - while (line.startsWith(this.indentString)) { line = line.slice(this.indentString.length); indentLevel++; } - return indentLevel; } - } - function getObject(lineGroup, type) { let object; lineGroup.indentLevel(); - while (!lineGroup.finished()) { let line = lineGroup.next(); let trimmedLine = line.trim(); let keyMatch = trimmedLine.match(/^(.*?):(?: |$)/); let typeMatch = trimmedLine.match(/#!([\w<,>]+)/); let key, value, type; - if (trimmedLine.startsWith('"')) { keyMatch = trimmedLine.match(/^"(.*?)":(?: |$)/); } - if (typeMatch) { type = typeMatch[1]; trimmedLine = trimmedLine.replace(typeMatch[0], ''); } - if (keyMatch) { if (!object) object = {}; key = keyMatch[1]; @@ -4711,43 +3923,35 @@ function getObject(lineGroup, type) { if (!object) object = []; value = trimmedLine.slice(1).trim(); } - if (value) { value = getValue(value, type); } else { value = getObject(lineGroup.nextGroup(), type); } - if (Array.isArray(object)) { object.push(value); } else { object[key] = value; } } - if (type) { object = { type: type, data: object }; } - return object; } - function getValue(value, type) { value = JSON.parse(value); - if (type) { value = { type: type, data: value }; } - return value; } - function parse(str) { let lines = str.replace(/\t/g, ' ').split('\n'); let lineGenerator = new LineGenerator(lines); @@ -4756,30 +3960,22 @@ function parse(str) { function deepCopy(obj) { let newObj; - if (Array.isArray(obj)) { newObj = []; - for (let item of obj) { newObj.push(deepCopy(item)); } - return newObj; } - if (!!obj && typeof obj === "object") { newObj = {}; - for (let [key, value] of Object.entries(obj)) { newObj[key] = deepCopy(value); } - return newObj; } - return obj; } - function isPrimitiveReaderType(reader) { switch (reader) { case 'Boolean': @@ -4795,13 +3991,12 @@ function isPrimitiveReaderType(reader) { case 'Vector4': case 'Rectangle': case 'Rect': + case 'Point': return true; - default: return false; } } - function isExportReaderType(reader) { switch (reader) { case 'Texture2D': @@ -4809,22 +4004,18 @@ function isExportReaderType(reader) { case 'Effect': case 'BmFont': return true; - default: return false; } } - function convertJsonContentsToXnbNode(raw, readers) { let extractedImages = []; let extractedMaps = []; - const { converted } = function recursiveConvert(obj, path) { let index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; const reader = readers[index]; - if (isPrimitiveReaderType(reader)) { return { converted: { @@ -4834,19 +4025,16 @@ function convertJsonContentsToXnbNode(raw, readers) { traversed: index }; } - if (reader === null) { return { converted: obj, traversed: index }; } - if (reader.startsWith('Nullable')) { let nullableData, trav; let [readerType, blockTraversed = 1] = reader.split(":"); blockTraversed = +blockTraversed; - if (obj === null) { nullableData = null; trav = index + blockTraversed; @@ -4864,7 +4052,6 @@ function convertJsonContentsToXnbNode(raw, readers) { nullableData = converted; trav = traversed; } - return { converted: { type: readerType, @@ -4875,7 +4062,6 @@ function convertJsonContentsToXnbNode(raw, readers) { traversed: trav }; } - if (isExportReaderType(reader)) { if (reader === 'Texture2D') { extractedImages.push({ @@ -4891,13 +4077,11 @@ function convertJsonContentsToXnbNode(raw, readers) { traversed: index }; } - if (reader === 'TBin') { extractedMaps.push({ path: path.join('.') }); } - return { converted: { type: reader, @@ -4906,16 +4090,24 @@ function convertJsonContentsToXnbNode(raw, readers) { traversed: index }; } - let data; if (Array.isArray(obj)) data = [];else data = {}; let traversed = index; let first = true; let isComplex = !reader.startsWith("Dictionary") && !reader.startsWith("Array") && !reader.startsWith("List"); - + let [readerType, complexBlockTraversed = 1] = reader.split(":"); + if (Object.keys(obj).length === 0) { + return { + converted: { + type: readerType, + data + }, + traversed: index + +complexBlockTraversed + }; + } for (let [key, value] of Object.entries(obj)) { let newIndex; - if (reader.startsWith("Dictionary")) newIndex = index + 2;else if (reader.startsWith("Array") || reader.startsWith("List")) newIndex = index + 1;else newIndex = traversed + 1; + if (readerType.startsWith("Dictionary")) newIndex = index + 2;else if (readerType.startsWith("Array") || readerType.startsWith("List")) newIndex = index + 1;else newIndex = traversed + 1; const { converted, traversed: nexter @@ -4926,72 +4118,56 @@ function convertJsonContentsToXnbNode(raw, readers) { first = false; } } - return { converted: { - type: reader, + type: readerType, data }, traversed }; }(raw, []); - return { converted, extractedImages, extractedMaps }; } - function convertJsonContentsFromXnbNode(obj) { if (!obj || typeof obj !== "object") return obj; - if (typeof obj === "object" && obj.hasOwnProperty("data")) { let { type, data } = obj; if (isPrimitiveReaderType(type)) return deepCopy(data); - if (isExportReaderType(type)) { data = deepCopy(data); if (type === "Texture2D") data.export = "Texture2D.png";else if (type === "Effect") data.export = "Effect.cso";else if (type === "TBin") data.export = "TBin.tbin";else if (type === "BmFont") data.export = "BmFont.xml"; return data; } - if (type.startsWith("Nullable")) { if (data === null || data.data === null) return null; return convertJsonContentsFromXnbNode(data.data); } - obj = deepCopy(data); } - let newObj; - if (Array.isArray(obj)) { newObj = []; - for (let item of obj) { newObj.push(convertJsonContentsFromXnbNode(item)); } - return newObj; } - if (!!obj && typeof obj === "object") { newObj = {}; - for (let [key, value] of Object.entries(obj)) { newObj[key] = convertJsonContentsFromXnbNode(value); } - return newObj; } - return null; } - function toXnbNodeData(json) { const toYamlJson = {}; const { @@ -5011,13 +4187,11 @@ function toXnbNodeData(json) { const rawContent = deepCopy(json.content); const mainReader = TypeReader.simplifyType(readerData[0].type); let readersTypeList = TypeReader.getReaderTypeList(mainReader); - if (readersTypeList[0] === 'SpriteFont') { readersTypeList = ['SpriteFont', 'Texture2D', 'List', 'Rectangle', 'List', 'Rectangle', 'List', 'Char', null, 'List', 'Vector3', 'Nullable', 'Char', null]; rawContent.verticalSpacing = rawContent.verticalLineSpacing; delete rawContent.verticalLineSpacing; } - const { converted, extractedImages, @@ -5028,7 +4202,6 @@ function toXnbNodeData(json) { if (extractedMaps.length > 0) toYamlJson.extractedMaps = extractedMaps; return toYamlJson; } - function fromXnbNodeData(json) { const result = {}; const { @@ -5045,86 +4218,66 @@ function fromXnbNodeData(json) { }; result.readers = deepCopy(readerData); result.content = convertJsonContentsFromXnbNode(json.content); - if (TypeReader.simplifyType(result.readers[0].type) === 'SpriteFont') { result.content.verticalLineSpacing = result.content.verticalSpacing; delete result.content.verticalSpacing; } - return result; } function searchElement(parent, element) { if (!parent || typeof parent != 'object') return; - if (parent.hasOwnProperty(element)) { return { parent, value: parent[element] }; } - for (let child of Object.values(parent)) { if (!!child || typeof child == 'object') { let found = searchElement(child, element); if (found) return found; } } - return null; } - function extractFileName(fullname) { let matcher = fullname.match(/(.*)\.([^\s.]+)$/); if (matcher === null) return [fullname, null]; return [matcher[1], matcher[2]]; } - function getExtension(dataType) { switch (dataType) { case "JSON": return "json"; - case "yaml": return "yaml"; - case "Texture2D": return "png"; - case "Effect": return "cso"; - case 'TBin': return "tbin"; - case 'BmFont': return "xml"; } - return "bin"; } - function getMimeType(dataType) { switch (dataType) { case "JSON": return "application/json"; - case "yaml": return "text/plain"; - case "Texture2D": return "image/png"; - case "Effect": return "application/x-cso"; - case 'BmFont': return "application/xml"; } - return "application/octet-stream"; } - function makeBlob(data, dataType) { if (typeof Blob === "function") return { data: new Blob([data], { @@ -5137,11 +4290,9 @@ function makeBlob(data, dataType) { extension: getExtension(dataType) }; } - function exportContent(content) { let jsonContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; let found = searchElement(content, "export"); - if (found) { const { value @@ -5150,21 +4301,18 @@ function exportContent(content) { type: dataType, data } = value; - if (dataType === "Texture2D") { data = s(value.width, value.height, new Uint8Array(data)); } - return makeBlob(data, dataType); } - if (jsonContent) { let contentJson = JSON.stringify(content, null, 4); return makeBlob(contentJson, "JSON"); } - return null; } + /** @api * decompressed xnb object to real file blobs. * @param {XnbData} decompressed xnb objects (returned by bufferToXnb() / Xnb.load()) @@ -5172,8 +4320,6 @@ function exportContent(content) { * contentOnly:export content file only, * fileName:exported files's name) (optional) */ - - function exportFiles(xnbObject) { let { yaml: isYaml = false, @@ -5194,10 +4340,8 @@ function exportFiles(xnbObject) { if (typeof fileName == "string" && fileName !== "") { return "".concat(fileName, ".").concat(getExtension(value.type)); } - return "".concat(value.type, ".").concat(getExtension(value.type)); } - return value; }, 4); let result = resultJSON; @@ -5205,22 +4349,18 @@ function exportFiles(xnbObject) { blobs.unshift(makeBlob(result, isYaml ? "yaml" : "JSON")); return blobs; } - function resolveCompression(compressionString) { let str = compressionString.toLowerCase(); if (str === "none") return 0; if (str === "lz4") return 0x40; return null; } - async function readBlobasText(blob) { if (typeof Blob === "function" && blob instanceof Blob) return blob.text();else if (typeof Buffer === "function" && blob instanceof Buffer) return blob.toString();else return blob; } - async function readBlobasArrayBuffer(blob) { if (typeof Blob === "function" && blob instanceof Blob) return blob.arrayBuffer();else if (typeof Buffer === "function" && blob instanceof Buffer) return blob.buffer; } - async function readExternFiles(extension, files) { if (extension === "png") { const rawPng = await readBlobasArrayBuffer(files.png); @@ -5233,7 +4373,6 @@ async function readExternFiles(extension, files) { height: png.height }; } - if (extension === "cso") { const data = await readBlobasArrayBuffer(files.cso); return { @@ -5241,7 +4380,6 @@ async function readExternFiles(extension, files) { data }; } - if (extension === "tbin") { const data = await readBlobasArrayBuffer(files.tbin); return { @@ -5249,7 +4387,6 @@ async function readExternFiles(extension, files) { data }; } - if (extension === "xml") { const data = await readBlobasText(files.xml); return { @@ -5258,7 +4395,6 @@ async function readExternFiles(extension, files) { }; } } - async function resolveImports(files) { let configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; const { @@ -5271,13 +4407,10 @@ async function resolveImports(files) { if (files.json) jsonData = JSON.parse(rawText);else jsonData = fromXnbNodeData(parse(rawText)); let compressBits = resolveCompression(compression); if (compressBits !== null) jsonData.header.compressed = compressBits; - if (!jsonData.hasOwnProperty('content')) { throw new XnbError("".concat(jsonFile.name, " does not have \"content\".")); } - const found = searchElement(jsonData.content, "export"); - if (found) { const { parent, @@ -5286,16 +4419,13 @@ async function resolveImports(files) { const [, extension] = extractFileName(value); parent.export = await readExternFiles(extension, files); } - return jsonData; } - function getReaderAssembly(extension) { if (extension === "png") return "Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553"; if (extension === "tbin") return "xTile.Pipeline.TideReader, xTile"; if (extension === "xml") return "BmFont.XmlSourceReader, BmFont, Version=2012.1.7.0, Culture=neutral, PublicKeyToken=null"; } - function makeHeader(fileName) { const [, extension] = extractFileName(fileName); const readerType = getReaderAssembly(extension); @@ -5325,32 +4455,28 @@ function makeHeader(fileName) { * @param {File / Buffer} file * @return {XnbData} JSON data with headers */ - async function unpackToXnbData(file) { if (typeof window !== "undefined") { const [, extension] = extractFileName(file.name); - if (extension !== "xnb") { return new Error("Invalid XNB File!"); } - const buffer = await file.arrayBuffer(); return bufferToXnb(buffer); } - return bufferToXnb(file.buffer); } + /** @api * Asynchronously reads the file into binary and then return content file. * XNB -> arrayBuffer -> XnbData -> Content * @param {File / Buffer} file * @return {XnbContent} exported Content Object */ - - function unpackToContent(file) { return unpackToXnbData(file).then(xnbDataToContent); } + /** @api * Asynchronously reads the file into binary and then unpacks the contents and remake to Blobs array. * XNB -> arrayBuffer -> XnbData -> Files @@ -5358,8 +4484,6 @@ function unpackToContent(file) { * @param {Object} config (yaml:export file as yaml, contentOnly:export content file only, fileName:file name(for node.js)) * @return {Array} exported Files Blobs */ - - function unpackToFiles(file) { let configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; let { @@ -5369,48 +4493,43 @@ function unpackToFiles(file) { } = configs; if (typeof window !== "undefined" && name === null) name = file.name; let [fileName] = extractFileName(name); - const exporter = xnbObject => exportFiles(xnbObject, { yaml, contentOnly, fileName }); - return unpackToXnbData(file).then(exporter); } + /** @api * reads the buffer and then unpacks. * arrayBuffer -> XnbData * @param {ArrayBuffer} buffer * @return {XnbData} the loaded XNB json */ - - function bufferToXnb(buffer) { const xnb = new XnbConverter(); return xnb.load(buffer); } + /** @api * reads the buffer and then unpacks the contents. * arrayBuffer -> XnbData -> Content * @param {ArrayBuffer} buffer * @return {XnbContent} exported Content Object */ - - function bufferToContents(buffer) { const xnb = new XnbConverter(); const xnbData = xnb.load(buffer); return xnbDataToContent(xnbData); } + /** @api * remove header from the loaded XNB Object * XnbData -> Content * @param {XnbData} the loaded XNB object include headers * @return {XnbContent} exported Content Object */ - - function xnbDataToContent(loadedXnb) { const { content @@ -5426,58 +4545,48 @@ function xnbDataToContent(loadedXnb) { * @param {FileList/Array} to pack json data * @return {Object/Object} packed XNB Array Buffer */ - - function fileMapper(files) { let returnMap = {}; let noHeaderMap = {}; - for (let i = 0; i < files.length; i++) { const file = files[i]; let [fileName, extension] = extractFileName(file.name); if (extension === null) continue; - if (returnMap[fileName] === undefined) { returnMap[fileName] = {}; if (extension !== "json" && extension !== "yaml") noHeaderMap[fileName] = file.name; } - const namedFileObj = returnMap[fileName]; if (typeof Blob === "function" && file instanceof Blob) namedFileObj[extension] = file;else namedFileObj[extension] = file.data; if (extension === "json" || extension === "yaml") delete noHeaderMap[fileName]; } - for (let fileName of Object.keys(noHeaderMap)) { returnMap[fileName].json = makeHeader(noHeaderMap[fileName]); } - return returnMap; } + /** @api * reads the json and then unpacks the contents. * @param {json} to pack json data * @return {ArrayBuffer} packed XNB Array Buffer */ - - function packJsonToBinary(json) { const xnb = new XnbConverter(); const buffer = xnb.convert(json); return buffer; } + /** @api * Asynchronously reads the file into binary and then pack xnb files. * @param {FlieList} files * @param {Object} configs(compression:default, none, LZ4, LZX / debug) * @return {Array(Blobs)} */ - - function pack(files) { let configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; const groupedFiles = fileMapper(files); let promises = []; - for (let [fileName, filePack] of Object.entries(groupedFiles)) { promises.push(resolveImports(filePack, configs).then(packJsonToBinary).then(buffer => { if (typeof Blob === "function") return { @@ -5492,7 +4601,6 @@ function pack(files) { }; })); } - return __promise_allSettled(promises).then(blobArray => { if (configs.debug === true) return blobArray; return blobArray.filter(_ref => { @@ -5509,22 +4617,36 @@ function pack(files) { }); }); } - function setReaders(readers) { return TypeReader.setReaders(readers); } - function addReaders(readers) { return TypeReader.addReaders(readers); } +function setSchemes(schemes) { + return TypeReader.setSchemes(schemes); +} +function addSchemes(schemes) { + return TypeReader.addSchemes(schemes); +} +function setEnum(enumList) { + return TypeReader.setEnum(enumList); +} +function addEnum(enumList) { + return TypeReader.addEnum(enumList); +} exports.XnbContent = XnbContent; exports.XnbData = XnbData; +exports.addEnum = addEnum; exports.addReaders = addReaders; +exports.addSchemes = addSchemes; exports.bufferToContents = bufferToContents; exports.bufferToXnb = bufferToXnb; exports.pack = pack; +exports.setEnum = setEnum; exports.setReaders = setReaders; +exports.setSchemes = setSchemes; exports.unpackToContent = unpackToContent; exports.unpackToFiles = unpackToFiles; exports.unpackToXnbData = unpackToXnbData; diff --git a/dist/core/xnb-core.es5.js b/dist/core/xnb-core.es5.js index 259e12d..c1f7128 100644 --- a/dist/core/xnb-core.es5.js +++ b/dist/core/xnb-core.es5.js @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -1980,17 +1980,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } - return keys; } - function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; @@ -2000,10 +1997,8 @@ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } - return target; } - function _typeof(obj) { "@babel/helpers - typeof"; @@ -2013,7 +2008,6 @@ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } - function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); @@ -2022,40 +2016,33 @@ reject(error); return; } - if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } - function _asyncToGenerator(fn) { return function () { var self = this, - args = arguments; + args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); - function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } - function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } - _next(undefined); }); }; } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; @@ -2065,7 +2052,6 @@ Object.defineProperty(target, descriptor.key, descriptor); } } - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); @@ -2074,7 +2060,6 @@ }); return Constructor; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { @@ -2086,15 +2071,12 @@ } else { obj[key] = value; } - return obj; } - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } - subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, @@ -2107,28 +2089,23 @@ }); if (superClass) _setPrototypeOf(subClass, superClass); } - function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } - function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; - return _setPrototypeOf(o, p); } - function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; - try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; @@ -2136,7 +2113,6 @@ return false; } } - function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; @@ -2150,34 +2126,25 @@ return instance; }; } - return _construct.apply(null, arguments); } - function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } - function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; - _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; - if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } - if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); - _cache.set(Class, Wrapper); } - function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } - Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, @@ -2188,104 +2155,66 @@ }); return _setPrototypeOf(Wrapper, Class); }; - return _wrapNativeSuper(Class); } - function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } - return self; } - function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } - return _assertThisInitialized(self); } - function _createSuper(Derived) { - var hasNativeReflectConstruct = _isNativeReflectConstruct(); - - return function _createSuperInternal() { - var Super = _getPrototypeOf(Derived), - result; - - if (hasNativeReflectConstruct) { - var NewTarget = _getPrototypeOf(this).constructor; - - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); - } - - return _possibleConstructorReturn(this, result); - }; - } - function __repeatConcat(str, num) { if (!!str && typeof str.repeat === "function") return str.repeat(num); - if (typeof str === "string") { var result = ""; - for (var i = 0; i < num; i++) { result += str; } - return result; } - if (str instanceof Array) { var result = []; - for (var i = 0; i < num; i++) { result.concat(str); } - return result; } - throw new Error("Invalid Data!"); } - function __includes(str, token) { if (!!str && typeof str.includes === "function") return str.includes(token); return str.indexOf(token) !== -1; } - function __startsWithString(str, token) { if (!!str && typeof str.startsWith === "function") return str.startsWith(token); if (typeof str !== "string" || typeof token !== "string") throw new Error("Invalid Data!"); var regexp = new RegExp("^" + token); return regexp.test(str); } - function __endsWithString(str, token) { if (typeof str.endsWith === "function") return str.endsWith(token); if (typeof str !== "string" || typeof token !== "string") throw new Error("Invalid Data!"); var regexp = new RegExp(token + "$"); return regexp.test(str); } - function __arrayMaker(obj, func) { if (!obj || _typeof(obj) !== "object") throw new Error("Invalid Data!"); var result = []; var length = obj.length; - for (var i = 0; i < length; i++) { result[i] = func(obj[i], i); } - return result; } - var __promise_allSettled = Promise.allSettled !== undefined ? Promise.allSettled.bind(Promise) : function (promises) { var mappedPromises = promises.map(function (p) { return p.then(function (value) { @@ -2497,6 +2426,7 @@ var Op = Object.prototype; var hasOwn = Op.hasOwnProperty; + var defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }; var undefined$1; // More compressible than void 0. var $Symbol = typeof Symbol === "function" ? Symbol : {}; var iteratorSymbol = $Symbol.iterator || "@@iterator"; @@ -2529,7 +2459,7 @@ // The ._invoke method unifies the implementations of the .next, // .throw, and .return methods. - generator._invoke = makeInvokeMethod(innerFn, self, context); + defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }); return generator; } @@ -2590,8 +2520,12 @@ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); GeneratorFunction.prototype = GeneratorFunctionPrototype; - define(Gp, "constructor", GeneratorFunctionPrototype); - define(GeneratorFunctionPrototype, "constructor", GeneratorFunction); + defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true }); + defineProperty( + GeneratorFunctionPrototype, + "constructor", + { value: GeneratorFunction, configurable: true } + ); GeneratorFunction.displayName = define( GeneratorFunctionPrototype, toStringTagSymbol, @@ -2701,7 +2635,7 @@ // Define the unified helper method that is used to implement .next, // .throw, and .return (see defineIteratorMethods). - this._invoke = enqueue; + defineProperty(this, "_invoke", { value: enqueue }); } defineIteratorMethods(AsyncIterator.prototype); @@ -2741,8 +2675,9 @@ throw arg; } - // Be forgiving, per 25.3.3.3.3 of the spec: - // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume + // Be forgiving, per GeneratorResume behavior specified since ES2015: + // ES2015 spec, step 3: https://262.ecma-international.org/6.0/#sec-generatorresume + // Latest spec, step 2: https://tc39.es/ecma262/#sec-generatorresume return doneResult(); } @@ -2811,31 +2746,32 @@ // delegate iterator, or by modifying context.method and context.arg, // setting context.delegate to null, and returning the ContinueSentinel. function maybeInvokeDelegate(delegate, context) { - var method = delegate.iterator[context.method]; + var methodName = context.method; + var method = delegate.iterator[methodName]; if (method === undefined$1) { // A .throw or .return when the delegate iterator has no .throw - // method always terminates the yield* loop. + // method, or a missing .next method, always terminate the + // yield* loop. context.delegate = null; - if (context.method === "throw") { - // Note: ["return"] must be used for ES3 parsing compatibility. - if (delegate.iterator["return"]) { - // If the delegate iterator has a return method, give it a - // chance to clean up. - context.method = "return"; - context.arg = undefined$1; - maybeInvokeDelegate(delegate, context); + // Note: ["return"] must be used for ES3 parsing compatibility. + if (methodName === "throw" && delegate.iterator["return"]) { + // If the delegate iterator has a return method, give it a + // chance to clean up. + context.method = "return"; + context.arg = undefined$1; + maybeInvokeDelegate(delegate, context); - if (context.method === "throw") { - // If maybeInvokeDelegate(context) changed context.method from - // "return" to "throw", let that override the TypeError below. - return ContinueSentinel; - } + if (context.method === "throw") { + // If maybeInvokeDelegate(context) changed context.method from + // "return" to "throw", let that override the TypeError below. + return ContinueSentinel; } - + } + if (methodName !== "return") { context.method = "throw"; context.arg = new TypeError( - "The iterator does not provide a 'throw' method"); + "The iterator does not provide a '" + methodName + "' method"); } return ContinueSentinel; @@ -2939,7 +2875,8 @@ this.reset(true); } - exports.keys = function(object) { + exports.keys = function(val) { + var object = Object(val); var keys = []; for (var key in object) { keys.push(key); @@ -2967,7 +2904,7 @@ }; function values(iterable) { - if (iterable) { + if (iterable != null) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) { return iteratorMethod.call(iterable); @@ -2997,8 +2934,7 @@ } } - // Return an iterator with no values. - return { next: doneResult }; + throw new TypeError(typeof iterable + " is not iterable"); } exports.values = values; @@ -3241,32 +3177,118 @@ } } (runtime)); + function _callSuper$1(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var XnbError = function (_Error) { - _inherits(XnbError, _Error); - - var _super = _createSuper(XnbError); - function XnbError() { - var _this; - + var _this2; var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - _classCallCheck(this, XnbError); - - _this = _super.call(this, message); - _this.name = "XnbError"; - _this.message = message; - Error.captureStackTrace(_assertThisInitialized(_this), XnbError); - return _this; + _this2 = _callSuper$1(this, XnbError, [message]); + _this2.name = "XnbError"; + _this2.message = message; + Error.captureStackTrace(_this2, XnbError); + return _this2; } - + _inherits(XnbError, _Error); return _createClass(XnbError); }(_wrapNativeSuper(Error)); + var ReflectiveSchemeReader = function () { + function ReflectiveSchemeReader(name, readers) { + _classCallCheck(this, ReflectiveSchemeReader); + this.name = name; + this.readers = readers; + } + return _createClass(ReflectiveSchemeReader, [{ + key: "read", + value: function read(buffer, resolver) { + var result = {}; + for (var _i2 = 0, _this$readers$entries2 = this.readers.entries(); _i2 < _this$readers$entries2.length; _i2++) { + var _this$readers$entries3 = _this$readers$entries2[_i2], + key = _this$readers$entries3[0], + reader = _this$readers$entries3[1]; + if (reader.isValueType()) result[key] = reader.read(buffer);else if (reader.constructor.type() === "Nullable") result[key] = reader.read(buffer, resolver);else result[key] = resolver.read(buffer); + } + return result; + } + }, { + key: "write", + value: function write(buffer, content, resolver) { + buffer.alloc(163518); + this.writeIndex(buffer, resolver); + for (var _i4 = 0, _this$readers$entries5 = this.readers.entries(); _i4 < _this$readers$entries5.length; _i4++) { + var _this$readers$entries6 = _this$readers$entries5[_i4], + key = _this$readers$entries6[0], + reader = _this$readers$entries6[1]; + reader.write(buffer, content[key], reader.isValueType() ? null : resolver); + } + } + }, { + key: "writeIndex", + value: function writeIndex(buffer, resolver) { + if (resolver != null) buffer.write7BitNumber(parseInt(resolver.getIndex(this)) + 1); + } + }, { + key: "isValueType", + value: function isValueType() { + return false; + } + }, { + key: "type", + get: function get() { + var reg = /\.([^\.]+)$/; + if (reg.test(this.name)) return this.name.match(reg)[1]; + return this.name; + } + }, { + key: "parseTypeList", + value: function parseTypeList() { + var types = [].concat(this.readers.values()).map(function (reader) { + if (reader.isValueType()) return null; + return reader.parseTypeList(); + }).flat(); + types.unshift(this.type); + return types; + } + }, { + key: "toString", + value: function toString() { + return "ReflectiveScheme<".concat(this.name, ">"); + } + }], [{ + key: "isTypeOf", + value: function isTypeOf(type) { + return false; + } + }, { + key: "hasSubType", + value: function hasSubType() { + return false; + } + }, { + key: "type", + value: function type() { + return "ReflectiveScheme"; + } + }]); + }(); + function removeExternBracket(str) { var bracketStack = []; var result = []; - for (var i = 0; i < str.length; i++) { var c = str[i]; if (c === "[") bracketStack.push(i);else if (c === "]") { @@ -3275,16 +3297,13 @@ if (bracketStack.length === 0) result.push(str.slice(startPoint + 1, i)); } } - return result; } - var TypeReader = function () { function TypeReader() { _classCallCheck(this, TypeReader); } - - _createClass(TypeReader, null, [{ + return _createClass(TypeReader, null, [{ key: "setReaders", value: function setReaders(readers) { TypeReader.readers = _objectSpread2({}, readers); @@ -3294,52 +3313,70 @@ value: function addReaders(readers) { TypeReader.readers = _objectSpread2(_objectSpread2({}, TypeReader.readers), readers); } + }, { + key: "setSchemes", + value: function setSchemes(schemes) { + TypeReader.schemes = _objectSpread2({}, schemes); + } + }, { + key: "addSchemes", + value: function addSchemes(schemes) { + TypeReader.schemes = _objectSpread2(_objectSpread2({}, TypeReader.schemes), schemes); + } + }, { + key: "setEnum", + value: function setEnum(enumList) { + TypeReader.enumList.clear(); + enumList.forEach(function (id) { + return TypeReader.enumList.add(id); + }); + } + }, { + key: "addEnum", + value: function addEnum(enumList) { + enumList.forEach(function (id) { + return TypeReader.enumList.add(id); + }); + } }, { key: "makeSimplied", value: function makeSimplied(type, reader) { var simple = type.split(/`|,/)[0]; - if (reader.isTypeOf(simple)) { if (reader.hasSubType()) { var subtypes = TypeReader.parseSubtypes(type).map(TypeReader.simplifyType.bind(TypeReader)); return "".concat(reader.type(), "<").concat(subtypes.join(","), ">"); } else return reader.type(); } - return null; } }, { - key: "simplifyType", - value: function (_simplifyType) { - function simplifyType(_x) { - return _simplifyType.apply(this, arguments); + key: "simplifyReflectiveType", + value: function simplifyReflectiveType(subType) { + var simple = subType.split(/`|,/)[0]; + for (var _i2 = 0, _Object$values2 = Object.values(TypeReader.readers); _i2 < _Object$values2.length; _i2++) { + var reader = _Object$values2[_i2]; + if (reader.isTypeOf(simple)) return reader.type(); } - - simplifyType.toString = function () { - return _simplifyType.toString(); - }; - - return simplifyType; - }(function (type) { + if (TypeReader.schemes.hasOwnProperty(simple)) return "ReflectiveScheme<".concat(simple, ">"); + throw new XnbError("Non-implemented scheme found, cannot resolve scheme \"".concat(simple, "\", \"").concat(subType, "\".")); + } + }, { + key: "simplifyType", + value: function simplifyType(type) { var simple = type.split(/`|,/)[0]; - var isArray = __endsWithString(simple, '[]'); - - if (isArray) return "Array<".concat(simplifyType(simple.slice(0, -2)), ">"); - - if (simple === 'Microsoft.Xna.Framework.Content.ReflectiveReader') { - var reflectiveType = TypeReader.parseSubtypes(type).map(TypeReader.simplifyType.bind(TypeReader)); - return "".concat(reflectiveType); - } - - for (var _i2 = 0, _Object$values2 = Object.values(TypeReader.readers); _i2 < _Object$values2.length; _i2++) { - var reader = _Object$values2[_i2]; + if (isArray) return "Array<".concat(TypeReader.simplifyType(simple.slice(0, -2)), ">"); + if (simple === 'Microsoft.Xna.Framework.Content.ReflectiveReader') return TypeReader.simplifyReflectiveType(TypeReader.parseSubtypes(type)[0]); + for (var _i4 = 0, _Object$values4 = Object.values(TypeReader.readers); _i4 < _Object$values4.length; _i4++) { + var reader = _Object$values4[_i4]; var result = TypeReader.makeSimplied(type, reader); if (result !== null) return result; } - + if (TypeReader.schemes.hasOwnProperty(simple)) return "ReflectiveScheme<".concat(simple, ">"); + if (TypeReader.enumList.has(simple)) return "Int32"; throw new XnbError("Non-implemented type found, cannot resolve type \"".concat(simple, "\", \"").concat(type, "\".")); - }) + } }, { key: "parseSubtypes", value: function parseSubtypes(type) { @@ -3372,13 +3409,20 @@ key: "getReader", value: function getReader(typeString) { var _TypeReader$getTypeIn = TypeReader.getTypeInfo(typeString), - type = _TypeReader$getTypeIn.type, - subtypes = _TypeReader$getTypeIn.subtypes; - + type = _TypeReader$getTypeIn.type, + subtypes = _TypeReader$getTypeIn.subtypes; + if (type === "ReflectiveScheme") return makeReflectiveReader(subtypes[0]); subtypes = subtypes.map(TypeReader.getReader.bind(TypeReader)); if (TypeReader.readers.hasOwnProperty("".concat(type, "Reader"))) return _construct(TypeReader.readers["".concat(type, "Reader")], subtypes); + if (TypeReader.schemes.hasOwnProperty(type)) return makeReflectiveReader(type); throw new XnbError("Invalid reader type \"".concat(typeString, "\" passed, unable to resolve!")); } + }, { + key: "getReaderClass", + value: function getReaderClass(typeString) { + if (TypeReader.readers.hasOwnProperty(typeString)) return TypeReader.readers[typeString]; + throw new XnbError("There is no \"".concat(typeString, "\" class in reader list!")); + } }, { key: "getReaderFromRaw", value: function getReaderFromRaw(typeString) { @@ -3386,70 +3430,105 @@ return TypeReader.getReader(simplified); } }]); - - return TypeReader; }(); - _defineProperty(TypeReader, "readers", {}); + _defineProperty(TypeReader, "schemes", {}); + _defineProperty(TypeReader, "enumList", new Set()); + function makeReflectiveReader(className) { + if (!TypeReader.schemes.hasOwnProperty(className)) throw new XnbError("Unsupported scheme : ".concat(className)); + var scheme = TypeReader.schemes[className]; + if (scheme instanceof Map === false) { + scheme = convertSchemeToReader(scheme); + TypeReader.schemes[className] = scheme; + } + return new ReflectiveSchemeReader(className, scheme); + } + function convertSchemeEntryToReader(scheme) { + if (typeof scheme === "string") return TypeReader.getReader(scheme); + if (Array.isArray(scheme)) { + var ListReader = TypeReader.getReaderClass("ListReader"); + return new ListReader(convertSchemeEntryToReader(scheme[0])); + } + if (_typeof(scheme) === "object") { + var keyCount = Object.keys(scheme).length; + if (keyCount === 1) { + var DictionaryReader = TypeReader.getReaderClass("DictionaryReader"); + var _Object$entries$ = Object.entries(scheme)[0], + key = _Object$entries$[0], + value = _Object$entries$[1]; + return new DictionaryReader(convertSchemeEntryToReader(key), convertSchemeEntryToReader(value)); + } else if (keyCount > 1) { + return convertSchemeToReader(scheme); + } + } + throw new XnbError("Invalid Scheme to convert! : ".concat(scheme)); + } + function convertSchemeToReader(scheme) { + var result = new Map(); + var __keys = Object.keys(scheme); + for (var __i = 0; __i < __keys.length; __i++) { + var key = __keys[__i], + type = scheme[key]; + var reader = convertSchemeEntryToReader(type); + if (__startsWithString(key, "$")) { + key = key.slice(1); + try { + reader = new TypeReader.readers.NullableReader(reader); + } catch (_unused) { + throw new XnbError("There is no NullableReader from reader list!"); + } + } + result.set(key, reader); + } + return result; + } var UTF8_FIRST_BITES = [0xC0, 0xE0, 0xF0]; var UTF8_SECOND_BITES = 0x80; var UTF8_MASK = 63; var UTF16_BITES$1 = [0xD800, 0xDC00]; var UTF16_MASK$1 = 1023; - function UTF8Encode(code) { if (code < 0x80) return [code]; if (code < 0x800) return [UTF8_FIRST_BITES[0] | code >> 6, UTF8_SECOND_BITES | code & UTF8_MASK]; if (code < 0x10000) return [UTF8_FIRST_BITES[1] | code >> 12, UTF8_SECOND_BITES | code >> 6 & UTF8_MASK, UTF8_SECOND_BITES | code & UTF8_MASK]; return [UTF8_FIRST_BITES[2] | code >> 18, UTF8_SECOND_BITES | code >> 12 & UTF8_MASK, UTF8_SECOND_BITES | code >> 6 & UTF8_MASK, UTF8_SECOND_BITES | code & UTF8_MASK]; } - function UTF16Encode(code) { if (code < 0xFFFF) return [code]; code -= 0x10000; return [UTF16_BITES$1[0] | code >> 10 & UTF16_MASK$1, UTF16_BITES$1[1] | code & UTF16_MASK$1]; } - function UTF8Decode(codeSet) { var _codeSet; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet = codeSet) !== null && _codeSet !== void 0 && _codeSet.length)) throw new Error("Invalid codeset!"); var codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; if (codeSetRange === 2) return ((codeSet[0] ^ UTF8_FIRST_BITES[0]) << 6) + (codeSet[1] ^ UTF8_SECOND_BITES); - if (codeSetRange === 3) { return ((codeSet[0] ^ UTF8_FIRST_BITES[1]) << 12) + ((codeSet[1] ^ UTF8_SECOND_BITES) << 6) + (codeSet[2] ^ UTF8_SECOND_BITES); } - return ((codeSet[0] ^ UTF8_FIRST_BITES[2]) << 18) + ((codeSet[1] ^ UTF8_SECOND_BITES) << 12) + ((codeSet[2] ^ UTF8_SECOND_BITES) << 6) + (codeSet[3] ^ UTF8_SECOND_BITES); } - function UTF16Decode$1(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); var codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; return ((codeSet[0] & UTF16_MASK$1) << 10) + (codeSet[1] & UTF16_MASK$1) + 0x10000; } - function stringToUnicode$1(str) { var utf16Map = __arrayMaker({ length: str.length }, function (_, i) { return str.charCodeAt(i); }); - var result = []; var index = 0; - while (index < str.length) { var code = utf16Map[index]; - if ((UTF16_BITES$1[0] & code) !== UTF16_BITES$1[0]) { result.push(code); index++; @@ -3458,18 +3537,14 @@ index += 2; } } - return result; } - function UTF8ToUnicode(codes) { var dataArray = codes instanceof ArrayBuffer ? new Uint8Array(codes) : codes; var result = []; var index = 0; - while (index < dataArray.length) { var headerCode = dataArray[index]; - if ((headerCode & 0x80) === 0) { result.push(headerCode); index++; @@ -3484,63 +3559,48 @@ index += 4; } } - return result; } - function UnicodeToUTF8(unicodeArr) { var result = []; - for (var _i2 = 0; _i2 < unicodeArr.length; _i2++) { var code = unicodeArr[_i2]; result.push.apply(result, UTF8Encode(code)); } - return result; } - function UnicodeToString(unicodeArr) { var result = []; - for (var _i4 = 0; _i4 < unicodeArr.length; _i4++) { var code = unicodeArr[_i4]; result.push.apply(result, UTF16Encode(code)); } - var blockSize = 32768; var resultStr = ""; - for (var i = 0; i < result.length / blockSize; i++) { resultStr += String.fromCharCode.apply(String, result.slice(i * blockSize, (i + 1) * blockSize)); } - return resultStr; } - function stringToUTF8(str) { return UnicodeToUTF8(stringToUnicode$1(str)); } - function UTF8ToString(utf8Array) { return UnicodeToString(UTF8ToUnicode(utf8Array)); } var LITTLE_ENDIAN = true; - var BufferReader = function () { function BufferReader(buffer) { var endianus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LITTLE_ENDIAN; - _classCallCheck(this, BufferReader); - this._endianus = endianus; this._buffer = buffer.slice(); this._dataView = new DataView(this._buffer); this._offset = 0; this._bitOffset = 0; } - - _createClass(BufferReader, [{ + return _createClass(BufferReader, [{ key: "seek", value: function seek(index) { var origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._offset; @@ -3588,20 +3648,16 @@ var isOverflow = this.buffer.byteLength < length + targetIndex; var targetBuffer = this.buffer; var targetView = this._dataView; - if (isOverflow) { targetBuffer = new ArrayBuffer(this.buffer.byteLength + (length + targetIndex - this.buffer.byteLength)); targetView = new DataView(targetBuffer); - for (var i = 0; i < this.buffer.byteLength; i++) { targetView.setUint8(i, this._dataView.getUint8(i)); } } - for (var _i = sourceIndex, j = targetIndex; _i < length; _i++, j++) { targetView.setUint8(j, sourceView[_i]); } - if (isOverflow) { this._buffer = targetBuffer; this._dataView = targetView; @@ -3623,7 +3679,6 @@ key: "readInt", value: function readInt() { var value = this._dataView.getInt8(this._offset); - this.seek(1); return value; } @@ -3631,7 +3686,6 @@ key: "readUInt", value: function readUInt() { var value = this._dataView.getUint8(this._offset); - this.seek(1); return value; } @@ -3639,7 +3693,6 @@ key: "readUInt16", value: function readUInt16() { var value = this._dataView.getUint16(this._offset, this._endianus); - this.seek(2); return value; } @@ -3647,7 +3700,6 @@ key: "readUInt32", value: function readUInt32() { var value = this._dataView.getUint32(this._offset, this._endianus); - this.seek(4); return value; } @@ -3655,7 +3707,6 @@ key: "readInt16", value: function readInt16() { var value = this._dataView.getInt16(this._offset, this._endianus); - this.seek(2); return value; } @@ -3663,7 +3714,6 @@ key: "readInt32", value: function readInt32() { var value = this._dataView.getInt32(this._offset, this._endianus); - this.seek(4); return value; } @@ -3671,15 +3721,13 @@ key: "readSingle", value: function readSingle() { var value = this._dataView.getFloat32(this._offset, this._endianus); - this.seek(4); return value; } }, { key: "readDouble", value: function readDouble() { - var value = this._dataView.getFloat32(this._offset, this._endianus); - + var value = this._dataView.getFloat64(this._offset, this._endianus); this.seek(8); return value; } @@ -3689,17 +3737,13 @@ var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1; var chars = []; this._offset; - if (count === -1) { - while (this.peekByte(1) != 0x0) { - chars.push(this.readByte()); - } + while (this.peekByte(1) != 0x0) chars.push(this.readByte()); } else { for (var i = 0; i < count; i++) { chars.push(this.readByte()); } } - return UTF8ToString(chars); } }, { @@ -3718,56 +3762,48 @@ key: "peekInt", value: function peekInt() { var value = this._dataView.getInt8(this._offset); - return value; } }, { key: "peekUInt", value: function peekUInt() { var value = this._dataView.getUint8(this._offset); - return value; } }, { key: "peekUInt16", value: function peekUInt16() { var value = this._dataView.getUint16(this._offset, this._endianus); - return value; } }, { key: "peekUInt32", value: function peekUInt32() { var value = this._dataView.getUint32(this._offset, this._endianus); - return value; } }, { key: "peekInt16", value: function peekInt16() { var value = this._dataView.getInt16(this._offset, this._endianus); - return value; } }, { key: "peekInt32", value: function peekInt32() { var value = this._dataView.getInt32(this._offset, this._endianus); - return value; } }, { key: "peekSingle", value: function peekSingle() { var value = this._dataView.getFloat32(this._offset, this._endianus); - return value; } }, { key: "peekDouble", value: function peekDouble() { var value = this._dataView.getFloat64(this._offset, this._endianus); - return value; } }, { @@ -3776,17 +3812,13 @@ var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; var chars = []; var startOffset = this._offset; - if (count === 0) { - while (this.peekByte(1) != 0x0) { - chars.push(this.readByte()); - } + while (this.peekByte(1) != 0x0) chars.push(this.readByte()); } else { for (var i = 0; i < count; i++) { chars.push(this.readByte()); } } - this.bytePosition = startOffset; return UTF8ToString(chars); } @@ -3796,13 +3828,11 @@ var result = 0; var bitsRead = 0; var value; - do { value = this.readByte(); result |= (value & 0x7F) << bitsRead; bitsRead += 7; } while (value & 0x80); - return result; } }, { @@ -3810,10 +3840,8 @@ value: function readLZXBits(bits) { var bitsLeft = bits; var read = 0; - while (bitsLeft > 0) { var peek = this._dataView.getUint16(this._offset, true); - var bitsInFrame = Math.min(Math.max(bitsLeft, 0), 16 - this.bitPosition); var offset = 16 - this.bitPosition - bitsInFrame; var value = (peek & Math.pow(2, bitsInFrame) - 1 << offset) >> offset; @@ -3821,7 +3849,6 @@ this.bitPosition += bitsInFrame; read |= value << bitsLeft; } - return read; } }, { @@ -3849,22 +3876,17 @@ if (this.bitPosition > 0) this.bitPosition += 16 - this.bitPosition; } }]); - - return BufferReader; }(); var BufferWriter = function () { function BufferWriter() { var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2048; - _classCallCheck(this, BufferWriter); - this._buffer = new ArrayBuffer(size); this._dataView = new DataView(this._buffer); this.bytePosition = 0; } - - _createClass(BufferWriter, [{ + return _createClass(BufferWriter, [{ key: "buffer", get: function get() { return this._buffer; @@ -3887,15 +3909,12 @@ if (this._buffer.byteLength <= this.bytePosition + bytes) { var tBuffer = new ArrayBuffer(this._buffer.byteLength + bytes); var tDataView = new DataView(tBuffer); - for (var i = 0; i < this.buffer.byteLength; i++) { tDataView.setUint8(i, this._dataView.getUint8(i)); } - this._buffer = tBuffer; this._dataView = tDataView; } - return this; } }, { @@ -3904,11 +3923,9 @@ var targetBufferView = new Uint8Array(buffer); var newPosition = this.bytePosition + targetBufferView.length; this.alloc(targetBufferView.length); - for (var i = this.bytePosition; i < newPosition; i++) { this._dataView.setUint8(i, targetBufferView[i - this.bytePosition]); } - this.bytePosition = newPosition; this.trim(); } @@ -3918,11 +3935,9 @@ var targetBufferView = new Uint8Array(bytes); var newPosition = this.bytePosition + targetBufferView.length; this.alloc(targetBufferView.length); - for (var i = this.bytePosition; i < newPosition; i++) { this._dataView.setUint8(i, targetBufferView[i - this.bytePosition]); } - this.bytePosition = newPosition; } }, { @@ -3935,83 +3950,69 @@ key: "writeByte", value: function writeByte(byte) { this.alloc(1)._dataView.setUint8(this.bytePosition, byte); - this.bytePosition++; } }, { key: "writeInt", value: function writeInt(number) { this.alloc(1)._dataView.setInt8(this.bytePosition, number); - this.bytePosition++; } }, { key: "writeUInt", value: function writeUInt(number) { this.alloc(1)._dataView.setUint8(this.bytePosition, number); - this.bytePosition++; } }, { key: "writeInt16", value: function writeInt16(number) { this.alloc(2)._dataView.setInt16(this.bytePosition, number, true); - this.bytePosition += 2; } }, { key: "writeUInt16", value: function writeUInt16(number) { this.alloc(2)._dataView.setUint16(this.bytePosition, number, true); - this.bytePosition += 2; } }, { key: "writeInt32", value: function writeInt32(number) { this.alloc(4)._dataView.setInt32(this.bytePosition, number, true); - this.bytePosition += 4; } }, { key: "writeUInt32", value: function writeUInt32(number) { this.alloc(4)._dataView.setUint32(this.bytePosition, number, true); - this.bytePosition += 4; } }, { key: "writeSingle", value: function writeSingle(number) { this.alloc(4)._dataView.setFloat32(this.bytePosition, number, true); - this.bytePosition += 4; } }, { key: "writeDouble", value: function writeDouble(number) { this.alloc(8)._dataView.setFloat64(this.bytePosition, number, true); - this.bytePosition += 8; } }, { key: "write7BitNumber", value: function write7BitNumber(number) { this.alloc(2); - do { var byte = number & 0x7F; number = number >> 7; if (number) byte |= 0x80; - this._dataView.setUint8(this.bytePosition, byte); - this.bytePosition++; } while (number); } }]); - - return BufferWriter; }(); var MIN_MATCH = 2; @@ -4034,28 +4035,23 @@ var LENGTH_TABLEBITS = 12; var ALIGNED_MAXSYMBOLS = ALIGNED_NUM_ELEMENTS; var ALIGNED_TABLEBITS = 7; - var Lzx = function () { function Lzx(window_bits) { _classCallCheck(this, Lzx); - this.window_size = 1 << window_bits; if (window_bits < 15 || window_bits > 21) throw new XnbError('Window size out of range!'); - if (!Lzx.extra_bits.length) { for (var i = 0, j = 0; i <= 50; i += 2) { Lzx.extra_bits[i] = Lzx.extra_bits[i + 1] = j; if (i != 0 && j < 17) j++; } } - if (!Lzx.position_base.length) { for (var _i = 0, _j = 0; _i <= 50; _i++) { Lzx.position_base[_i] = _j; _j += 1 << Lzx.extra_bits[_i]; } } - var posn_slots = window_bits == 21 ? 50 : window_bits == 20 ? 42 : window_bits << 1; this.R0 = this.R1 = this.R2 = 1; this.main_elements = NUM_CHARS + (posn_slots << 3); @@ -4071,19 +4067,11 @@ this.length_len = []; this.maintree_table = []; this.maintree_len = []; - - for (var _i2 = 0; _i2 < MAINTREE_MAXSYMBOLS; _i2++) { - this.maintree_len[_i2] = 0; - } - - for (var _i3 = 0; _i3 < NUM_SECONDARY_LENGTHS; _i3++) { - this.length_len[_i3] = 0; - } - + for (var _i2 = 0; _i2 < MAINTREE_MAXSYMBOLS; _i2++) this.maintree_len[_i2] = 0; + for (var _i3 = 0; _i3 < NUM_SECONDARY_LENGTHS; _i3++) this.length_len[_i3] = 0; this.win = []; } - - _createClass(Lzx, [{ + return _createClass(Lzx, [{ key: "decompress", value: function decompress(buffer, frame_size, block_size) { if (!this.header_read) { @@ -4091,24 +4079,17 @@ if (intel != 0) throw new XnbError("Intel E8 Call found, invalid for XNB files."); this.header_read = true; } - var togo = frame_size; - while (togo > 0) { if (this.block_remaining == 0) { this.block_type = buffer.readLZXBits(3); var hi = buffer.readLZXBits(16); var lo = buffer.readLZXBits(8); this.block_remaining = hi << 8 | lo; - switch (this.block_type) { case BLOCKTYPE.ALIGNED: - for (var i = 0; i < 8; i++) { - this.aligned_len[i] = buffer.readLZXBits(3); - } - + for (var i = 0; i < 8; i++) this.aligned_len[i] = buffer.readLZXBits(3); this.aligned_table = this.decodeTable(ALIGNED_MAXSYMBOLS, ALIGNED_TABLEBITS, this.aligned_len); - case BLOCKTYPE.VERBATIM: this.readLengths(buffer, this.maintree_len, 0, 256); this.readLengths(buffer, this.maintree_len, 256, this.main_elements); @@ -4116,55 +4097,44 @@ this.readLengths(buffer, this.length_len, 0, NUM_SECONDARY_LENGTHS); this.length_table = this.decodeTable(LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS, this.length_len); break; - case BLOCKTYPE.UNCOMPRESSED: buffer.align(); this.R0 = buffer.readInt32(); this.R1 = buffer.readInt32(); this.R2 = buffer.readInt32(); break; - default: throw new XnbError("Invalid Blocktype Found: ".concat(this.block_type)); } } - var this_run = this.block_remaining; - while ((this_run = this.block_remaining) > 0 && togo > 0) { if (this_run > togo) this_run = togo; togo -= this_run; this.block_remaining -= this_run; this.window_posn &= this.window_size - 1; if (this.window_posn + this_run > this.window_size) throw new XnbError('Cannot run outside of window frame.'); - switch (this.block_type) { case BLOCKTYPE.ALIGNED: while (this_run > 0) { var main_element = this.readHuffSymbol(buffer, this.maintree_table, this.maintree_len, MAINTREE_MAXSYMBOLS, MAINTREE_TABLEBITS); - if (main_element < NUM_CHARS) { this.win[this.window_posn++] = main_element; this_run--; continue; } - main_element -= NUM_CHARS; var length_footer = void 0; var match_length = main_element & NUM_PRIMARY_LENGTHS; - if (match_length == NUM_PRIMARY_LENGTHS) { length_footer = this.readHuffSymbol(buffer, this.length_table, this.length_len, LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS); match_length += length_footer; } - match_length += MIN_MATCH; var match_offset = main_element >> 3; - if (match_offset > 2) { var extra = Lzx.extra_bits[match_offset]; match_offset = Lzx.position_base[match_offset] - 2; - if (extra > 3) { extra -= 3; var verbatim_bits = buffer.readLZXBits(extra); @@ -4174,7 +4144,6 @@ } else if (extra == 3) { match_offset += this.readHuffSymbol(buffer, this.aligned_table, this.aligned_len, ALIGNED_MAXSYMBOLS, ALIGNED_TABLEBITS); } else if (extra > 0) match_offset += buffer.readLZXBits(extra);else match_offset = 1; - this.R2 = this.R1; this.R1 = this.R0; this.R0 = match_offset; @@ -4189,68 +4158,46 @@ this.R2 = this.R0; this.R0 = match_offset; } - var rundest = this.window_posn; var runsrc = void 0; this_run -= match_length; if (this.window_posn >= match_offset) runsrc = rundest - match_offset;else { runsrc = rundest + (this.window_size - match_offset); var copy_length = match_offset - this.window_posn; - if (copy_length < match_length) { match_length -= copy_length; this.window_posn += copy_length; - - while (copy_length-- > 0) { - this.win[rundest++] = this.win[runsrc++]; - } - + while (copy_length-- > 0) this.win[rundest++] = this.win[runsrc++]; runsrc = 0; } } this.window_posn += match_length; - - while (match_length-- > 0) { - this.win[rundest++] = this.win[runsrc++]; - } + while (match_length-- > 0) this.win[rundest++] = this.win[runsrc++]; } - break; - case BLOCKTYPE.VERBATIM: while (this_run > 0) { var _main_element = this.readHuffSymbol(buffer, this.maintree_table, this.maintree_len, MAINTREE_MAXSYMBOLS, MAINTREE_TABLEBITS); - if (_main_element < NUM_CHARS) { this.win[this.window_posn++] = _main_element; this_run--; continue; } - _main_element -= NUM_CHARS; - var _length_footer = void 0; - var _match_length = _main_element & NUM_PRIMARY_LENGTHS; - if (_match_length == NUM_PRIMARY_LENGTHS) { _length_footer = this.readHuffSymbol(buffer, this.length_table, this.length_len, LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS); _match_length += _length_footer; } - _match_length += MIN_MATCH; - var _match_offset = _main_element >> 3; - if (_match_offset > 2) { if (_match_offset != 3) { var _extra = Lzx.extra_bits[_match_offset]; - var _verbatim_bits = buffer.readLZXBits(_extra); - _match_offset = Lzx.position_base[_match_offset] - 2 + _verbatim_bits; } else _match_offset = 1; - this.R2 = this.R1; this.R1 = this.R0; this.R0 = _match_offset; @@ -4265,54 +4212,34 @@ this.R2 = this.R0; this.R0 = _match_offset; } - var _rundest = this.window_posn; - var _runsrc = void 0; - this_run -= _match_length; if (this.window_posn >= _match_offset) _runsrc = _rundest - _match_offset;else { _runsrc = _rundest + (this.window_size - _match_offset); - var _copy_length = _match_offset - this.window_posn; - if (_copy_length < _match_length) { _match_length -= _copy_length; this.window_posn += _copy_length; - - while (_copy_length-- > 0) { - this.win[_rundest++] = this.win[_runsrc++]; - } - + while (_copy_length-- > 0) this.win[_rundest++] = this.win[_runsrc++]; _runsrc = 0; } } this.window_posn += _match_length; - - while (_match_length-- > 0) { - this.win[_rundest++] = this.win[_runsrc++]; - } + while (_match_length-- > 0) this.win[_rundest++] = this.win[_runsrc++]; } - break; - case BLOCKTYPE.UNCOMPRESSED: if (buffer.bytePosition + this_run > block_size) throw new XnbError('Overrun!' + block_size + ' ' + buffer.bytePosition + ' ' + this_run); - - for (var _i4 = 0; _i4 < this_run; _i4++) { - this.win[window_posn + _i4] = buffer.buffer[buffer.bytePosition + _i4]; - } - + for (var _i4 = 0; _i4 < this_run; _i4++) this.win[window_posn + _i4] = buffer.buffer[buffer.bytePosition + _i4]; buffer.bytePosition += this_run; this.window_posn += this_run; break; - default: throw new XnbError('Invalid blocktype specified!'); } } } - if (togo != 0) throw new XnbError('EOF reached with data left to go.'); buffer.align(); var start_window_pos = (this.window_posn == 0 ? this.window_size : this.window_posn) - frame_size; @@ -4321,43 +4248,28 @@ }, { key: "readLengths", value: function readLengths(buffer, table, first, last) { - for (var i = 0; i < 20; i++) { - this.pretree_len[i] = buffer.readLZXBits(4); - } - + for (var i = 0; i < 20; i++) this.pretree_len[i] = buffer.readLZXBits(4); this.pretree_table = this.decodeTable(PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS, this.pretree_len); - for (var _i5 = first; _i5 < last;) { var symbol = this.readHuffSymbol(buffer, this.pretree_table, this.pretree_len, PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS); - if (symbol == 17) { var zeros = buffer.readLZXBits(4) + 4; - - while (zeros-- != 0) { - table[_i5++] = 0; - } + while (zeros-- != 0) table[_i5++] = 0; } else if (symbol == 18) { var _zeros = buffer.readLZXBits(5) + 20; - - while (_zeros-- != 0) { - table[_i5++] = 0; - } + while (_zeros-- != 0) table[_i5++] = 0; } else if (symbol == 19) { var same = buffer.readLZXBits(1) + 4; symbol = this.readHuffSymbol(buffer, this.pretree_table, this.pretree_len, PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS); symbol = table[_i5] - symbol; if (symbol < 0) symbol += 17; - - while (same-- != 0) { - table[_i5++] = symbol; - } + while (same-- != 0) table[_i5++] = symbol; } else { symbol = table[_i5] - symbol; if (symbol < 0) symbol += 17; table[_i5++] = symbol; } } - return table; } }, { @@ -4367,62 +4279,43 @@ var pos = 0; var table_mask = 1 << bits; var bit_mask = table_mask >> 1; - for (var bit_num = 1; bit_num <= bits; bit_num++) { for (var symbol = 0; symbol < symbols; symbol++) { if (length[symbol] == bit_num) { var leaf = pos; - if ((pos += bit_mask) > table_mask) { throw new XnbError('Overrun table!'); } - var fill = bit_mask; - - while (fill-- > 0) { - table[leaf++] = symbol; - } + while (fill-- > 0) table[leaf++] = symbol; } } - bit_mask >>= 1; } - if (pos == table_mask) return table; - - for (var _symbol = pos; _symbol < table_mask; _symbol++) { - table[_symbol] = 0xFFFF; - } - + for (var _symbol = pos; _symbol < table_mask; _symbol++) table[_symbol] = 0xFFFF; var next_symbol = table_mask >> 1 < symbols ? symbols : table_mask >> 1; pos <<= 16; table_mask <<= 16; bit_mask = 1 << 15; - for (var _bit_num = bits + 1; _bit_num <= 16; _bit_num++) { for (var _symbol2 = 0; _symbol2 < symbols; _symbol2++) { if (length[_symbol2] != _bit_num) continue; - var _leaf = pos >> 16; - for (var _fill = 0; _fill < _bit_num - bits; _fill++) { if (table[_leaf] == 0xFFFF) { table[next_symbol << 1] = 0xFFFF; table[(next_symbol << 1) + 1] = 0xFFFF; table[_leaf] = next_symbol++; } - _leaf = table[_leaf] << 1; if (pos >> 15 - _fill & 1) _leaf++; } - table[_leaf] = _symbol2; if ((pos += bit_mask) > table_mask) throw new XnbError('Overrun table during decoding.'); } - bit_mask >>= 1; } - if (pos == table_mask) return table; throw new XnbError('Decode table did not reach table mask.'); } @@ -4431,10 +4324,8 @@ value: function readHuffSymbol(buffer, table, length, symbols, bits) { var bit = buffer.peekLZXBits(32) >>> 0; var i = table[buffer.peekLZXBits(bits)]; - if (i >= symbols) { var j = 1 << 32 - bits; - do { j >>= 1; i <<= 1; @@ -4442,7 +4333,6 @@ if (j == 0) return 0; } while ((i = table[i]) >= symbols); } - buffer.bitPosition += length[i]; return i; } @@ -4464,10 +4354,7 @@ } } }]); - - return Lzx; }(); - Lzx.position_base = []; Lzx.extra_bits = []; @@ -4475,8 +4362,7 @@ function Presser() { _classCallCheck(this, Presser); } - - _createClass(Presser, null, [{ + return _createClass(Presser, null, [{ key: "decompress", value: function decompress(buffer, compressedTodo, decompressedTodo) { var pos = 0; @@ -4484,10 +4370,8 @@ var frame_size; var lzx = new Lzx(16); var decompressed = new BufferWriter(decompressedTodo); - while (pos < compressedTodo) { var flag = buffer.readByte(); - if (flag == 0xFF) { frame_size = buffer.readLZXInt16(); block_size = buffer.readLZXInt16(); @@ -4498,28 +4382,23 @@ frame_size = 0x8000; pos += 2; } - if (block_size == 0 || frame_size == 0) break; if (block_size > 0x10000 || frame_size > 0x10000) throw new XnbError('Invalid size read in compression content.'); decompressed.write(lzx.decompress(buffer, frame_size, block_size)); pos += block_size; } - console.log('File has been successfully decompressed!'); decompressed.trim(); return decompressed.buffer; } }]); - - return Presser; }(); var LZ4Utils = function () { function LZ4Utils() { _classCallCheck(this, LZ4Utils); } - - _createClass(LZ4Utils, null, [{ + return _createClass(LZ4Utils, null, [{ key: "hashU32", value: function hashU32(a) { a = a | 0; @@ -4572,8 +4451,6 @@ return al * bl + (ah * bl + al * bh << 16) | 0; } }]); - - return LZ4Utils; }(); var minMatch = 4; @@ -4587,45 +4464,36 @@ var runMask = (1 << runBits) - 1; makeBuffer(5 << 20); var hashTable = makeHashTable(); - function makeHashTable() { try { return new Uint32Array(hashSize); } catch (error) { var _hashTable = new Array(hashSize); - for (var i = 0; i < hashSize; i++) { _hashTable[i] = 0; } - return _hashTable; } } - function clearHashTable(table) { for (var i = 0; i < hashSize; i++) { hashTable[i] = 0; } } - function makeBuffer(size) { try { return new Uint8Array(size); } catch (error) { var buf = new Array(size); - for (var i = 0; i < size; i++) { buf[i] = 0; } - return buf; } } - function compressBound(n) { return n + n / 255 + 16 | 0; } - function decompressBlock(src, dst) { var sIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var sLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : src.length - 2 * sIndex; @@ -4633,46 +4501,36 @@ var mLength, mOffset, sEnd, n, i; var hasCopyWithin = dst.copyWithin !== undefined && dst.fill !== undefined; sEnd = sIndex + sLength; - while (sIndex < sEnd) { var token = src[sIndex++]; var literalCount = token >> 4; - if (literalCount > 0) { if (literalCount === 0xf) { while (true) { literalCount += src[sIndex]; - if (src[sIndex++] !== 0xff) { break; } } } - for (n = sIndex + literalCount; sIndex < n;) { dst[dIndex++] = src[sIndex++]; } } - if (sIndex >= sEnd) { break; } - mLength = token & 0xf; mOffset = src[sIndex++] | src[sIndex++] << 8; - if (mLength === 0xf) { while (true) { mLength += src[sIndex]; - if (src[sIndex++] !== 0xff) { break; } } } - mLength += minMatch; - if (hasCopyWithin && mOffset === 1) { dst.fill(dst[dIndex - 1] | 0, dIndex, dIndex + mLength); dIndex += mLength; @@ -4685,106 +4543,81 @@ } } } - return dIndex; } - function compressBlock(src, dst, sIndex, sLength, hashTable) { var mIndex, mAnchor, mLength, mOffset, mStep; var literalCount, dIndex, sEnd, n; dIndex = 0; sEnd = sLength + sIndex; mAnchor = sIndex; - if (sLength >= minLength) { var searchMatchCount = (1 << skipTrigger) + 3; - while (sIndex + minMatch < sEnd - searchLimit) { var seq = LZ4Utils.readU32(src, sIndex); var hash = LZ4Utils.hashU32(seq) >>> 0; hash = (hash >> 16 ^ hash) >>> 0 & 0xffff; mIndex = hashTable[hash] - 1; hashTable[hash] = sIndex + 1; - if (mIndex < 0 || sIndex - mIndex >>> 16 > 0 || LZ4Utils.readU32(src, mIndex) !== seq) { mStep = searchMatchCount++ >> skipTrigger; sIndex += mStep; continue; } - searchMatchCount = (1 << skipTrigger) + 3; literalCount = sIndex - mAnchor; mOffset = sIndex - mIndex; sIndex += minMatch; mIndex += minMatch; mLength = sIndex; - while (sIndex < sEnd - searchLimit && src[sIndex] === src[mIndex]) { sIndex++; mIndex++; } - mLength = sIndex - mLength; var token = mLength < mlMask ? mLength : mlMask; - if (literalCount >= runMask) { dst[dIndex++] = (runMask << mlBits) + token; - for (n = literalCount - runMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } else { dst[dIndex++] = (literalCount << mlBits) + token; } - for (var i = 0; i < literalCount; i++) { dst[dIndex++] = src[mAnchor + i]; } - dst[dIndex++] = mOffset; dst[dIndex++] = mOffset >> 8; - if (mLength >= mlMask) { for (n = mLength - mlMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } - mAnchor = sIndex; } } - if (mAnchor === 0) { return 0; } - literalCount = sEnd - mAnchor; - if (literalCount >= runMask) { dst[dIndex++] = runMask << mlBits; - for (n = literalCount - runMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } else { dst[dIndex++] = literalCount << mlBits; } - sIndex = mAnchor; - while (sIndex < sEnd) { dst[dIndex++] = src[sIndex++]; } - return dIndex; } - function compressSingleBlock(src, dst) { clearHashTable(); return compressBlock(src, dst, 0, src.length, hashTable); @@ -4792,30 +4625,24 @@ var UTF16_BITES = [0xD800, 0xDC00]; var UTF16_MASK = 1023; - function UTF16Decode(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); var codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; return ((codeSet[0] & UTF16_MASK) << 10) + (codeSet[1] & UTF16_MASK) + 0x10000; } - function stringToUnicode(str) { var utf16Map = __arrayMaker({ length: str.length }, function (_, i) { return str.charCodeAt(i); }); - var result = []; var index = 0; - while (index < str.length) { var code = utf16Map[index]; - if ((UTF16_BITES[0] & code) !== UTF16_BITES[0]) { result.push(code); index++; @@ -4824,10 +4651,8 @@ index += 2; } } - return result; } - function UTF8Length(str) { var codes = stringToUnicode(str); return codes.reduce(function (sum, unicode) { @@ -4842,8 +4667,7 @@ function StringReaderCore() { _classCallCheck(this, StringReaderCore); } - - _createClass(StringReaderCore, [{ + return _createClass(StringReaderCore, [{ key: "read", value: function read(buffer) { var length = buffer.read7BitNumber(); @@ -4857,22 +4681,18 @@ buffer.writeString(string); } }]); - - return StringReaderCore; }(); var ReaderResolver = function () { function ReaderResolver(readers) { _classCallCheck(this, ReaderResolver); - this.readers = readers; } - - _createClass(ReaderResolver, [{ + return _createClass(ReaderResolver, [{ key: "read", value: function read(buffer) { var index = buffer.read7BitNumber() - 1; - if (this.readers[index] == null) throw new XnbError("Invalid reader index ".concat(index)); + if (this.readers[index] == null) throw new XnbError("Invalid reader index ".concat(index, " | pos: ").concat(buffer.bytePosition.toString(16))); return this.readers[index].read(buffer, this); } }, { @@ -4888,18 +4708,15 @@ } } }]); - - return ReaderResolver; }(); var XnbData = function () { function XnbData(header, readers, content) { _classCallCheck(this, XnbData); - var target = header.target, - formatVersion = header.formatVersion, - hidef = header.hidef, - compressed = header.compressed; + formatVersion = header.formatVersion, + hidef = header.hidef, + compressed = header.compressed; this.header = { target: target, formatVersion: formatVersion, @@ -4909,28 +4726,21 @@ this.readers = readers; this.content = content; } - - _createClass(XnbData, [{ + return _createClass(XnbData, [{ key: "target", get: function get() { var _this$header; - switch ((_this$header = this.header) === null || _this$header === void 0 ? void 0 : _this$header.target) { case 'w': return "Microsoft Windows"; - case 'm': return "Windows Phone 7"; - case 'x': return "Xbox 360"; - case 'a': return "Android"; - case 'i': return "iOS"; - default: return "Unknown"; } @@ -4939,17 +4749,13 @@ key: "formatVersion", get: function get() { var _this$header2; - switch ((_this$header2 = this.header) === null || _this$header2 === void 0 ? void 0 : _this$header2.formatVersion) { case 0x3: return "XNA Game Studio 3.0"; - case 0x4: return "XNA Game Studio 3.1"; - case 0x5: return "XNA Game Studio 4.0"; - default: return "Unknown"; } @@ -4958,14 +4764,12 @@ key: "hidef", get: function get() { var _this$header3; - return !!((_this$header3 = this.header) !== null && _this$header3 !== void 0 && _this$header3.hidef); } }, { key: "compressed", get: function get() { var _this$header4; - return !!((_this$header4 = this.header) !== null && _this$header4 !== void 0 && _this$header4.compressed); } }, { @@ -5000,37 +4804,26 @@ return this.stringify(); } }]); - - return XnbData; }(); - function extensionToDatatype(extension) { switch (extension) { case "json": return "JSON"; - case "yaml": return "yaml"; - case "png": return "Texture2D"; - case "cso": return "Effect"; - case 'tbin': return "TBin"; - case 'xml': return "BmFont"; } - return "Others"; } - var XnbContent = _createClass(function XnbContent(data, ext) { _classCallCheck(this, XnbContent); - this.type = extensionToDatatype(ext); this.content = data; }); @@ -5039,11 +4832,9 @@ var COMPRESSED_LZ4_MASK = 0x40; var COMPRESSED_LZX_MASK = 0x80; var XNB_COMPRESSED_PROLOGUE_SIZE = 14; - var XnbConverter = function () { function XnbConverter() { _classCallCheck(this, XnbConverter); - this.target = ''; this.formatVersion = 0; this.hidef = false; @@ -5054,21 +4845,16 @@ this.readers = []; this.sharedResources = []; } - - _createClass(XnbConverter, [{ + return _createClass(XnbConverter, [{ key: "load", value: function load(arrayBuffer) { this.buffer = new BufferReader(arrayBuffer); - this._validateHeader(); - console.info('XNB file validated successfully!'); this.fileSize = this.buffer.readUInt32(); if (this.buffer.size != this.fileSize) throw new XnbError('XNB file has been truncated!'); - if (this.compressed) { var decompressedSize = this.buffer.readUInt32(); - if (this.compressionType == COMPRESSED_LZX_MASK) { var compressedTodo = this.fileSize - XNB_COMPRESSED_PROLOGUE_SIZE; var decompressed = Presser.decompress(this.buffer, compressedTodo, decompressedSize); @@ -5077,30 +4863,27 @@ } else if (this.compressionType == COMPRESSED_LZ4_MASK) { var trimmed = this.buffer.buffer.slice(XNB_COMPRESSED_PROLOGUE_SIZE); var trimmedArray = new Uint8Array(trimmed); - var _decompressed = new Uint8Array(decompressedSize); - decompressBlock(trimmedArray, _decompressed); this.buffer.copyFrom(_decompressed, XNB_COMPRESSED_PROLOGUE_SIZE, 0, decompressedSize); this.buffer.bytePosition = XNB_COMPRESSED_PROLOGUE_SIZE; } } - var count = this.buffer.read7BitNumber(); var stringReader = new StringReaderCore(); var readers = []; - for (var i = 0; i < count; i++) { var type = stringReader.read(this.buffer); var version = this.buffer.readInt32(); - var reader = TypeReader.getReaderFromRaw(type); - this.readers.push(reader); readers.push({ type: type, version: version }); } - + this.readers = readers.map(function (_ref) { + var type = _ref.type; + return TypeReader.getReaderFromRaw(type); + }); var shared = this.buffer.read7BitNumber(); if (shared != 0) throw new XnbError("Unexpected (".concat(shared, ") shared resources.")); var content = new ReaderResolver(this.readers); @@ -5119,10 +4902,10 @@ var buffer = new BufferWriter(); var stringReader = new StringReaderCore(); var _json$header = json.header, - target = _json$header.target, - formatVersion = _json$header.formatVersion, - hidef = _json$header.hidef, - compressed = _json$header.compressed; + target = _json$header.target, + formatVersion = _json$header.formatVersion, + hidef = _json$header.hidef, + compressed = _json$header.compressed; this.target = target; this.formatVersion = formatVersion; this.hidef = hidef; @@ -5135,26 +4918,21 @@ buffer.writeUInt32(0); if (lz4Compression) buffer.writeUInt32(0); buffer.write7BitNumber(json.readers.length); - for (var _i2 = 0, _json$readers2 = json.readers; _i2 < _json$readers2.length; _i2++) { var reader = _json$readers2[_i2]; this.readers.push(TypeReader.getReaderFromRaw(reader.type)); stringReader.write(buffer, reader.type); buffer.writeUInt32(reader.version); } - buffer.write7BitNumber(0); var content = new ReaderResolver(this.readers); content.write(buffer, json.content); buffer.trim(); - if (lz4Compression) { var trimmed = buffer.buffer.slice(XNB_COMPRESSED_PROLOGUE_SIZE); var trimmedArray = new Uint8Array(trimmed); var compressedSize = compressBound(trimmedArray.length); - var _compressed = new Uint8Array(compressedSize); - compressedSize = compressSingleBlock(trimmedArray, _compressed); _compressed = _compressed.slice(0, compressedSize); buffer.bytePosition = 6; @@ -5164,7 +4942,6 @@ var returnBuffer = buffer.buffer.slice(0, XNB_COMPRESSED_PROLOGUE_SIZE + compressedSize); return returnBuffer; } - var fileSize = buffer.bytePosition; buffer.bytePosition = 6; buffer.writeUInt32(fileSize, 6); @@ -5184,43 +4961,35 @@ this.compressionType = (flags & COMPRESSED_LZX_MASK) != 0 ? COMPRESSED_LZX_MASK : flags & COMPRESSED_LZ4_MASK ? COMPRESSED_LZ4_MASK : 0; } }]); - - return XnbConverter; }(); function injectRGBA(data, i) { var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, - r = _ref.r, - _ref$g = _ref.g, - g = _ref$g === void 0 ? r : _ref$g, - _ref$b = _ref.b, - b = _ref$b === void 0 ? r : _ref$b, - _ref$a = _ref.a, - a = _ref$a === void 0 ? 255 : _ref$a; - + r = _ref.r, + _ref$g = _ref.g, + g = _ref$g === void 0 ? r : _ref$g, + _ref$b = _ref.b, + b = _ref$b === void 0 ? r : _ref$b, + _ref$a = _ref.a, + a = _ref$a === void 0 ? 255 : _ref$a; data[4 * i + 0] = r; data[4 * i + 1] = g; data[4 * i + 2] = b; data[4 * i + 3] = a; return [r, g, b, a]; } - function png16to8(data) { var megascale = new Uint16Array(data); var downscale = new Uint8Array(megascale.length); - for (var i = 0; i < megascale.length; i++) { downscale[i] = megascale[i] >> 8; } - return downscale; } - function addChannels(data, originChannel) { var size = data.length / originChannel; var rgbaData = new Uint8Array(size * 4); if (originChannel === 4) return data; - if (originChannel === 1) { for (var i = 0; i < size; i++) { injectRGBA(rgbaData, i, { @@ -5243,16 +5012,13 @@ }); } } - return rgbaData; } - function applyPalette(data, depth, palette) { var oldData = new Uint8Array(data); var length = oldData.length * 8 / depth; var newData = new Uint8Array(length * 4); var bitPosition = 0; - for (var i = 0; i < length; i++) { var bytePosition = Math.floor(bitPosition / 8); var bitOffset = 8 - bitPosition % 8 - depth; @@ -5265,15 +5031,13 @@ newData[i * 4 + 3] = _palette$paletteIndex[3]; bitPosition += depth; } - return newData; } - function fixPNG(pngdata) { pngdata.width; - pngdata.height; - var channels = pngdata.channels, - depth = pngdata.depth; + pngdata.height; + var channels = pngdata.channels, + depth = pngdata.depth; var data = pngdata.data; if (pngdata.palette) return applyPalette(data, depth, pngdata.palette); if (depth === 16) data = png16to8(data); @@ -5281,111 +5045,107 @@ return data; } + function _callSuper(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var t = { - 396: function _() { - !function (t) { - if (t.TextEncoder && t.TextDecoder) return !1; - - function e() { - var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; - if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t, "') is invalid.")); - } - - function i() { - var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; - var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - fatal: !1 - }; - if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t, "') is invalid.")); - if (e.fatal) throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported."); - } - - Object.defineProperty(e.prototype, "encoding", { - value: "utf-8" - }), e.prototype.encode = function (t) { - var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - stream: !1 - }; - if (e.stream) throw new Error("Failed to encode: the 'stream' option is unsupported."); - var i = 0; - var n = t.length; - var r = 0, + 396: function _() { + !function (t) { + if (t.TextEncoder && t.TextDecoder) return !1; + function e() { + var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; + if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t, "') is invalid.")); + } + function i() { + var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; + var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + fatal: !1 + }; + if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t, "') is invalid.")); + if (e.fatal) throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported."); + } + Object.defineProperty(e.prototype, "encoding", { + value: "utf-8" + }), e.prototype.encode = function (t) { + var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + stream: !1 + }; + if (e.stream) throw new Error("Failed to encode: the 'stream' option is unsupported."); + var i = 0; + var n = t.length; + var r = 0, s = Math.max(32, n + (n >> 1) + 7), a = new Uint8Array(s >> 3 << 3); - - for (; i < n;) { - var _e2 = t.charCodeAt(i++); - - if (_e2 >= 55296 && _e2 <= 56319) { - if (i < n) { - var _n = t.charCodeAt(i); - - 56320 == (64512 & _n) && (++i, _e2 = ((1023 & _e2) << 10) + (1023 & _n) + 65536); + for (; i < n;) { + var _e2 = t.charCodeAt(i++); + if (_e2 >= 55296 && _e2 <= 56319) { + if (i < n) { + var _n = t.charCodeAt(i); + 56320 == (64512 & _n) && (++i, _e2 = ((1023 & _e2) << 10) + (1023 & _n) + 65536); + } + if (_e2 >= 55296 && _e2 <= 56319) continue; } - - if (_e2 >= 55296 && _e2 <= 56319) continue; - } - - if (r + 4 > a.length) { - s += 8, s *= 1 + i / t.length * 2, s = s >> 3 << 3; - - var _e3 = new Uint8Array(s); - - _e3.set(a), a = _e3; - } - - if (0 != (4294967168 & _e2)) { - if (0 == (4294965248 & _e2)) a[r++] = _e2 >> 6 & 31 | 192;else if (0 == (4294901760 & _e2)) a[r++] = _e2 >> 12 & 15 | 224, a[r++] = _e2 >> 6 & 63 | 128;else { - if (0 != (4292870144 & _e2)) continue; - a[r++] = _e2 >> 18 & 7 | 240, a[r++] = _e2 >> 12 & 63 | 128, a[r++] = _e2 >> 6 & 63 | 128; + if (r + 4 > a.length) { + s += 8, s *= 1 + i / t.length * 2, s = s >> 3 << 3; + var _e3 = new Uint8Array(s); + _e3.set(a), a = _e3; } - a[r++] = 63 & _e2 | 128; - } else a[r++] = _e2; - } - - return a.slice(0, r); - }, Object.defineProperty(i.prototype, "encoding", { - value: "utf-8" - }), Object.defineProperty(i.prototype, "fatal", { - value: !1 - }), Object.defineProperty(i.prototype, "ignoreBOM", { - value: !1 - }), i.prototype.decode = function (t) { - var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - stream: !1 - }; - if (e.stream) throw new Error("Failed to decode: the 'stream' option is unsupported."); - var i = new Uint8Array(t); - var n = 0; - var r = i.length, + if (0 != (4294967168 & _e2)) { + if (0 == (4294965248 & _e2)) a[r++] = _e2 >> 6 & 31 | 192;else if (0 == (4294901760 & _e2)) a[r++] = _e2 >> 12 & 15 | 224, a[r++] = _e2 >> 6 & 63 | 128;else { + if (0 != (4292870144 & _e2)) continue; + a[r++] = _e2 >> 18 & 7 | 240, a[r++] = _e2 >> 12 & 63 | 128, a[r++] = _e2 >> 6 & 63 | 128; + } + a[r++] = 63 & _e2 | 128; + } else a[r++] = _e2; + } + return a.slice(0, r); + }, Object.defineProperty(i.prototype, "encoding", { + value: "utf-8" + }), Object.defineProperty(i.prototype, "fatal", { + value: !1 + }), Object.defineProperty(i.prototype, "ignoreBOM", { + value: !1 + }), i.prototype.decode = function (t) { + var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + stream: !1 + }; + if (e.stream) throw new Error("Failed to decode: the 'stream' option is unsupported."); + var i = new Uint8Array(t); + var n = 0; + var r = i.length, s = []; - - for (; n < r;) { - var _t2 = i[n++]; - if (0 === _t2) break; - if (0 == (128 & _t2)) s.push(_t2);else if (192 == (224 & _t2)) { - var _e4 = 63 & i[n++]; - - s.push((31 & _t2) << 6 | _e4); - } else if (224 == (240 & _t2)) { - var _e5 = 63 & i[n++], + for (; n < r;) { + var _t2 = i[n++]; + if (0 === _t2) break; + if (0 == (128 & _t2)) s.push(_t2);else if (192 == (224 & _t2)) { + var _e4 = 63 & i[n++]; + s.push((31 & _t2) << 6 | _e4); + } else if (224 == (240 & _t2)) { + var _e5 = 63 & i[n++], _r = 63 & i[n++]; - - s.push((31 & _t2) << 12 | _e5 << 6 | _r); - } else if (240 == (248 & _t2)) { - var _e6 = (7 & _t2) << 18 | (63 & i[n++]) << 12 | (63 & i[n++]) << 6 | 63 & i[n++]; - - _e6 > 65535 && (_e6 -= 65536, s.push(_e6 >>> 10 & 1023 | 55296), _e6 = 56320 | 1023 & _e6), s.push(_e6); + s.push((31 & _t2) << 12 | _e5 << 6 | _r); + } else if (240 == (248 & _t2)) { + var _e6 = (7 & _t2) << 18 | (63 & i[n++]) << 12 | (63 & i[n++]) << 6 | 63 & i[n++]; + _e6 > 65535 && (_e6 -= 65536, s.push(_e6 >>> 10 & 1023 | 55296), _e6 = 56320 | 1023 & _e6), s.push(_e6); + } } - } - - return String.fromCharCode.apply(null, s); - }, t.TextEncoder = e, t.TextDecoder = i; - }("undefined" != typeof window ? window : "undefined" != typeof self ? self : this); - } - }, - e = {}; - + return String.fromCharCode.apply(null, s); + }, t.TextEncoder = e, t.TextDecoder = i; + }("undefined" != typeof window ? window : "undefined" != typeof self ? self : this); + } + }, + e = {}; function i(n) { var r = e[n]; if (void 0 !== r) return r.exports; @@ -5394,19 +5154,15 @@ }; return t[n].call(s.exports, s, s.exports, i), s.exports; } - i.d = function (t, e) { - for (var n in e) { - i.o(e, n) && !i.o(t, n) && Object.defineProperty(t, n, { - enumerable: !0, - get: e[n] - }); - } + for (var n in e) i.o(e, n) && !i.o(t, n) && Object.defineProperty(t, n, { + enumerable: !0, + get: e[n] + }); }, i.o = function (t, e) { return Object.prototype.hasOwnProperty.call(t, e); }; var n = {}; - (function () { i.d(n, { P: function P() { @@ -5417,24 +5173,20 @@ } }), i(396); var t = new TextDecoder("utf-8"), - e = new TextEncoder(); - + e = new TextEncoder(); var r = function () { function r() { var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8192; var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - _classCallCheck(this, r); - var i = !1; "number" == typeof t ? t = new ArrayBuffer(t) : (i = !0, this.lastWrittenByte = t.byteLength); var n = e.offset ? e.offset >>> 0 : 0, - s = t.byteLength - n; + s = t.byteLength - n; var a = n; (ArrayBuffer.isView(t) || t instanceof r) && (t.byteLength !== t.buffer.byteLength && (a = t.byteOffset + n), t = t.buffer), this.lastWrittenByte = i ? s : 0, this.buffer = t, this.length = s, this.byteLength = s, this.byteOffset = a, this.offset = 0, this.littleEndian = !0, this._data = new DataView(this.buffer, a, s), this._mark = 0, this._marks = []; } - - _createClass(r, [{ + return _createClass(r, [{ key: "available", value: function available() { var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; @@ -5490,7 +5242,6 @@ key: "popMark", value: function popMark() { var t = this._marks.pop(); - if (void 0 === t) throw new Error("Mark stack empty"); return this.seek(t), this; } @@ -5503,14 +5254,11 @@ key: "ensureAvailable", value: function ensureAvailable() { var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - if (!this.available(t)) { var _e7 = 2 * (this.offset + t), - _i2 = new Uint8Array(_e7); - + _i2 = new Uint8Array(_e7); _i2.set(new Uint8Array(this.buffer)), this.buffer = _i2.buffer, this.length = this.byteLength = _e7, this._data = new DataView(this.buffer); } - return this; } }, { @@ -5538,67 +5286,55 @@ value: function readBytes() { var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; var e = new Uint8Array(t); - - for (var _i3 = 0; _i3 < t; _i3++) { - e[_i3] = this.readByte(); - } - + for (var _i3 = 0; _i3 < t; _i3++) e[_i3] = this.readByte(); return e; } }, { key: "readInt16", value: function readInt16() { var t = this._data.getInt16(this.offset, this.littleEndian); - return this.offset += 2, t; } }, { key: "readUint16", value: function readUint16() { var t = this._data.getUint16(this.offset, this.littleEndian); - return this.offset += 2, t; } }, { key: "readInt32", value: function readInt32() { var t = this._data.getInt32(this.offset, this.littleEndian); - return this.offset += 4, t; } }, { key: "readUint32", value: function readUint32() { var t = this._data.getUint32(this.offset, this.littleEndian); - return this.offset += 4, t; } }, { key: "readFloat32", value: function readFloat32() { var t = this._data.getFloat32(this.offset, this.littleEndian); - return this.offset += 4, t; } }, { key: "readFloat64", value: function readFloat64() { var t = this._data.getFloat64(this.offset, this.littleEndian); - return this.offset += 8, t; } }, { key: "readBigInt64", value: function readBigInt64() { var t = this._data.getBigInt64(this.offset, this.littleEndian); - return this.offset += 8, t; } }, { key: "readBigUint64", value: function readBigUint64() { var t = this._data.getBigUint64(this.offset, this.littleEndian); - return this.offset += 8, t; } }, { @@ -5611,11 +5347,7 @@ value: function readChars() { var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; var e = ""; - - for (var _i4 = 0; _i4 < t; _i4++) { - e += this.readChar(); - } - + for (var _i4 = 0; _i4 < t; _i4++) e += this.readChar(); return e; } }, { @@ -5649,11 +5381,7 @@ key: "writeBytes", value: function writeBytes(t) { this.ensureAvailable(t.length); - - for (var _e8 = 0; _e8 < t.length; _e8++) { - this._data.setUint8(this.offset++, t[_e8]); - } - + for (var _e8 = 0; _e8 < t.length; _e8++) this._data.setUint8(this.offset++, t[_e8]); return this._updateLastWrittenByte(), this; } }, { @@ -5704,10 +5432,7 @@ }, { key: "writeChars", value: function writeChars(t) { - for (var _e9 = 0; _e9 < t.length; _e9++) { - this.writeUint8(t.charCodeAt(_e9)); - } - + for (var _e9 = 0; _e9 < t.length; _e9++) this.writeUint8(t.charCodeAt(_e9)); return this; } }, { @@ -5728,27 +5453,18 @@ this.offset > this.lastWrittenByte && (this.lastWrittenByte = this.offset); } }]); - - return r; }(); - function s(t) { var e = t.length; - - for (; --e >= 0;) { - t[e] = 0; - } + for (; --e >= 0;) t[e] = 0; } - var a = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0]), - o = new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]), - h = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]), - l = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), - d = new Array(576); + o = new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]), + h = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]), + l = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), + d = new Array(576); s(d); - var _ = new Array(60); - s(_); var f = new Array(512); s(f); @@ -5757,889 +5473,647 @@ var u = new Array(29); s(u); var w = new Array(30); - function p(t, e, i, n, r) { this.static_tree = t, this.extra_bits = e, this.extra_base = i, this.elems = n, this.max_length = r, this.has_stree = t && t.length; } - var g, b, m; - function k(t, e) { this.dyn_tree = t, this.max_code = 0, this.stat_desc = e; } - s(w); - var y = function y(t) { - return t < 256 ? f[t] : f[256 + (t >>> 7)]; - }, - v = function v(t, e) { - t.pending_buf[t.pending++] = 255 & e, t.pending_buf[t.pending++] = e >>> 8 & 255; - }, - E = function E(t, e, i) { - t.bi_valid > 16 - i ? (t.bi_buf |= e << t.bi_valid & 65535, v(t, t.bi_buf), t.bi_buf = e >> 16 - t.bi_valid, t.bi_valid += i - 16) : (t.bi_buf |= e << t.bi_valid & 65535, t.bi_valid += i); - }, - A = function A(t, e, i) { - E(t, i[2 * e], i[2 * e + 1]); - }, - x = function x(t, e) { - var i = 0; - - do { - i |= 1 & t, t >>>= 1, i <<= 1; - } while (--e > 0); - - return i >>> 1; - }, - U = function U(t, e, i) { - var n = new Array(16); - var r, + return t < 256 ? f[t] : f[256 + (t >>> 7)]; + }, + v = function v(t, e) { + t.pending_buf[t.pending++] = 255 & e, t.pending_buf[t.pending++] = e >>> 8 & 255; + }, + E = function E(t, e, i) { + t.bi_valid > 16 - i ? (t.bi_buf |= e << t.bi_valid & 65535, v(t, t.bi_buf), t.bi_buf = e >> 16 - t.bi_valid, t.bi_valid += i - 16) : (t.bi_buf |= e << t.bi_valid & 65535, t.bi_valid += i); + }, + A = function A(t, e, i) { + E(t, i[2 * e], i[2 * e + 1]); + }, + x = function x(t, e) { + var i = 0; + do { + i |= 1 & t, t >>>= 1, i <<= 1; + } while (--e > 0); + return i >>> 1; + }, + U = function U(t, e, i) { + var n = new Array(16); + var r, s, a = 0; - - for (r = 1; r <= 15; r++) { - n[r] = a = a + i[r - 1] << 1; - } - - for (s = 0; s <= e; s++) { - var _e10 = t[2 * s + 1]; - 0 !== _e10 && (t[2 * s] = x(n[_e10]++, _e10)); - } - }, - z = function z(t) { - var e; - - for (e = 0; e < 286; e++) { - t.dyn_ltree[2 * e] = 0; - } - - for (e = 0; e < 30; e++) { - t.dyn_dtree[2 * e] = 0; - } - - for (e = 0; e < 19; e++) { - t.bl_tree[2 * e] = 0; - } - - t.dyn_ltree[512] = 1, t.opt_len = t.static_len = 0, t.last_lit = t.matches = 0; - }, - R = function R(t) { - t.bi_valid > 8 ? v(t, t.bi_buf) : t.bi_valid > 0 && (t.pending_buf[t.pending++] = t.bi_buf), t.bi_buf = 0, t.bi_valid = 0; - }, - N = function N(t, e, i, n) { - var r = 2 * e, + for (r = 1; r <= 15; r++) n[r] = a = a + i[r - 1] << 1; + for (s = 0; s <= e; s++) { + var _e10 = t[2 * s + 1]; + 0 !== _e10 && (t[2 * s] = x(n[_e10]++, _e10)); + } + }, + z = function z(t) { + var e; + for (e = 0; e < 286; e++) t.dyn_ltree[2 * e] = 0; + for (e = 0; e < 30; e++) t.dyn_dtree[2 * e] = 0; + for (e = 0; e < 19; e++) t.bl_tree[2 * e] = 0; + t.dyn_ltree[512] = 1, t.opt_len = t.static_len = 0, t.last_lit = t.matches = 0; + }, + R = function R(t) { + t.bi_valid > 8 ? v(t, t.bi_buf) : t.bi_valid > 0 && (t.pending_buf[t.pending++] = t.bi_buf), t.bi_buf = 0, t.bi_valid = 0; + }, + N = function N(t, e, i, n) { + var r = 2 * e, s = 2 * i; - return t[r] < t[s] || t[r] === t[s] && n[e] <= n[i]; - }, - T = function T(t, e, i) { - var n = t.heap[i]; - var r = i << 1; - - for (; r <= t.heap_len && (r < t.heap_len && N(e, t.heap[r + 1], t.heap[r], t.depth) && r++, !N(e, n, t.heap[r], t.depth));) { - t.heap[i] = t.heap[r], i = r, r <<= 1; - } - - t.heap[i] = n; - }, - O = function O(t, e, i) { - var n, + return t[r] < t[s] || t[r] === t[s] && n[e] <= n[i]; + }, + T = function T(t, e, i) { + var n = t.heap[i]; + var r = i << 1; + for (; r <= t.heap_len && (r < t.heap_len && N(e, t.heap[r + 1], t.heap[r], t.depth) && r++, !N(e, n, t.heap[r], t.depth));) t.heap[i] = t.heap[r], i = r, r <<= 1; + t.heap[i] = n; + }, + O = function O(t, e, i) { + var n, r, s, h, l = 0; - if (0 !== t.last_lit) do { - n = t.pending_buf[t.d_buf + 2 * l] << 8 | t.pending_buf[t.d_buf + 2 * l + 1], r = t.pending_buf[t.l_buf + l], l++, 0 === n ? A(t, r, e) : (s = c[r], A(t, s + 256 + 1, e), h = a[s], 0 !== h && (r -= u[s], E(t, r, h)), n--, s = y(n), A(t, s, i), h = o[s], 0 !== h && (n -= w[s], E(t, n, h))); - } while (l < t.last_lit); - A(t, 256, e); - }, - L = function L(t, e) { - var i = e.dyn_tree, + if (0 !== t.last_lit) do { + n = t.pending_buf[t.d_buf + 2 * l] << 8 | t.pending_buf[t.d_buf + 2 * l + 1], r = t.pending_buf[t.l_buf + l], l++, 0 === n ? A(t, r, e) : (s = c[r], A(t, s + 256 + 1, e), h = a[s], 0 !== h && (r -= u[s], E(t, r, h)), n--, s = y(n), A(t, s, i), h = o[s], 0 !== h && (n -= w[s], E(t, n, h))); + } while (l < t.last_lit); + A(t, 256, e); + }, + L = function L(t, e) { + var i = e.dyn_tree, n = e.stat_desc.static_tree, r = e.stat_desc.has_stree, s = e.stat_desc.elems; - var a, + var a, o, h, l = -1; - - for (t.heap_len = 0, t.heap_max = 573, a = 0; a < s; a++) { - 0 !== i[2 * a] ? (t.heap[++t.heap_len] = l = a, t.depth[a] = 0) : i[2 * a + 1] = 0; - } - - for (; t.heap_len < 2;) { - h = t.heap[++t.heap_len] = l < 2 ? ++l : 0, i[2 * h] = 1, t.depth[h] = 0, t.opt_len--, r && (t.static_len -= n[2 * h + 1]); - } - - for (e.max_code = l, a = t.heap_len >> 1; a >= 1; a--) { - T(t, i, a); - } - - h = s; - - do { - a = t.heap[1], t.heap[1] = t.heap[t.heap_len--], T(t, i, 1), o = t.heap[1], t.heap[--t.heap_max] = a, t.heap[--t.heap_max] = o, i[2 * h] = i[2 * a] + i[2 * o], t.depth[h] = (t.depth[a] >= t.depth[o] ? t.depth[a] : t.depth[o]) + 1, i[2 * a + 1] = i[2 * o + 1] = h, t.heap[1] = h++, T(t, i, 1); - } while (t.heap_len >= 2); - - t.heap[--t.heap_max] = t.heap[1], function (t, e) { - var i = e.dyn_tree, + for (t.heap_len = 0, t.heap_max = 573, a = 0; a < s; a++) 0 !== i[2 * a] ? (t.heap[++t.heap_len] = l = a, t.depth[a] = 0) : i[2 * a + 1] = 0; + for (; t.heap_len < 2;) h = t.heap[++t.heap_len] = l < 2 ? ++l : 0, i[2 * h] = 1, t.depth[h] = 0, t.opt_len--, r && (t.static_len -= n[2 * h + 1]); + for (e.max_code = l, a = t.heap_len >> 1; a >= 1; a--) T(t, i, a); + h = s; + do { + a = t.heap[1], t.heap[1] = t.heap[t.heap_len--], T(t, i, 1), o = t.heap[1], t.heap[--t.heap_max] = a, t.heap[--t.heap_max] = o, i[2 * h] = i[2 * a] + i[2 * o], t.depth[h] = (t.depth[a] >= t.depth[o] ? t.depth[a] : t.depth[o]) + 1, i[2 * a + 1] = i[2 * o + 1] = h, t.heap[1] = h++, T(t, i, 1); + } while (t.heap_len >= 2); + t.heap[--t.heap_max] = t.heap[1], function (t, e) { + var i = e.dyn_tree, n = e.max_code, r = e.stat_desc.static_tree, s = e.stat_desc.has_stree, a = e.stat_desc.extra_bits, o = e.stat_desc.extra_base, h = e.stat_desc.max_length; - - var l, + var l, d, _, f, c, u, w = 0; - - for (f = 0; f <= 15; f++) { - t.bl_count[f] = 0; - } - - for (i[2 * t.heap[t.heap_max] + 1] = 0, l = t.heap_max + 1; l < 573; l++) { - d = t.heap[l], f = i[2 * i[2 * d + 1] + 1] + 1, f > h && (f = h, w++), i[2 * d + 1] = f, d > n || (t.bl_count[f]++, c = 0, d >= o && (c = a[d - o]), u = i[2 * d], t.opt_len += u * (f + c), s && (t.static_len += u * (r[2 * d + 1] + c))); - } - - if (0 !== w) { - do { - for (f = h - 1; 0 === t.bl_count[f];) { - f--; - } - - t.bl_count[f]--, t.bl_count[f + 1] += 2, t.bl_count[h]--, w -= 2; - } while (w > 0); - - for (f = h; 0 !== f; f--) { - for (d = t.bl_count[f]; 0 !== d;) { - _ = t.heap[--l], _ > n || (i[2 * _ + 1] !== f && (t.opt_len += (f - i[2 * _ + 1]) * i[2 * _], i[2 * _ + 1] = f), d--); - } + for (f = 0; f <= 15; f++) t.bl_count[f] = 0; + for (i[2 * t.heap[t.heap_max] + 1] = 0, l = t.heap_max + 1; l < 573; l++) d = t.heap[l], f = i[2 * i[2 * d + 1] + 1] + 1, f > h && (f = h, w++), i[2 * d + 1] = f, d > n || (t.bl_count[f]++, c = 0, d >= o && (c = a[d - o]), u = i[2 * d], t.opt_len += u * (f + c), s && (t.static_len += u * (r[2 * d + 1] + c))); + if (0 !== w) { + do { + for (f = h - 1; 0 === t.bl_count[f];) f--; + t.bl_count[f]--, t.bl_count[f + 1] += 2, t.bl_count[h]--, w -= 2; + } while (w > 0); + for (f = h; 0 !== f; f--) for (d = t.bl_count[f]; 0 !== d;) _ = t.heap[--l], _ > n || (i[2 * _ + 1] !== f && (t.opt_len += (f - i[2 * _ + 1]) * i[2 * _], i[2 * _ + 1] = f), d--); } - } - }(t, e), U(i, l, t.bl_count); - }, - B = function B(t, e, i) { - var n, + }(t, e), U(i, l, t.bl_count); + }, + B = function B(t, e, i) { + var n, r, s = -1, a = e[1], o = 0, h = 7, l = 4; - - for (0 === a && (h = 138, l = 3), e[2 * (i + 1) + 1] = 65535, n = 0; n <= i; n++) { - r = a, a = e[2 * (n + 1) + 1], ++o < h && r === a || (o < l ? t.bl_tree[2 * r] += o : 0 !== r ? (r !== s && t.bl_tree[2 * r]++, t.bl_tree[32]++) : o <= 10 ? t.bl_tree[34]++ : t.bl_tree[36]++, o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4)); - } - }, - C = function C(t, e, i) { - var n, + for (0 === a && (h = 138, l = 3), e[2 * (i + 1) + 1] = 65535, n = 0; n <= i; n++) r = a, a = e[2 * (n + 1) + 1], ++o < h && r === a || (o < l ? t.bl_tree[2 * r] += o : 0 !== r ? (r !== s && t.bl_tree[2 * r]++, t.bl_tree[32]++) : o <= 10 ? t.bl_tree[34]++ : t.bl_tree[36]++, o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4)); + }, + C = function C(t, e, i) { + var n, r, s = -1, a = e[1], o = 0, h = 7, l = 4; - - for (0 === a && (h = 138, l = 3), n = 0; n <= i; n++) { - if (r = a, a = e[2 * (n + 1) + 1], !(++o < h && r === a)) { + for (0 === a && (h = 138, l = 3), n = 0; n <= i; n++) if (r = a, a = e[2 * (n + 1) + 1], !(++o < h && r === a)) { if (o < l) do { A(t, r, t.bl_tree); } while (0 != --o);else 0 !== r ? (r !== s && (A(t, r, t.bl_tree), o--), A(t, 16, t.bl_tree), E(t, o - 3, 2)) : o <= 10 ? (A(t, 17, t.bl_tree), E(t, o - 3, 3)) : (A(t, 18, t.bl_tree), E(t, o - 11, 7)); o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4); } - } - }; - + }; var D = !1; - var I = function I(t, e, i, n) { E(t, 0 + (n ? 1 : 0), 3), function (t, e, i, n) { R(t), v(t, i), v(t, ~i), t.pending_buf.set(t.window.subarray(e, e + i), t.pending), t.pending += i; }(t, e, i); }; - var S = { - _tr_init: function _tr_init(t) { - D || (function () { - var t, e, i, n, r; - var s = new Array(16); - - for (i = 0, n = 0; n < 28; n++) { - for (u[n] = i, t = 0; t < 1 << a[n]; t++) { - c[i++] = n; - } - } - - for (c[i - 1] = n, r = 0, n = 0; n < 16; n++) { - for (w[n] = r, t = 0; t < 1 << o[n]; t++) { - f[r++] = n; - } - } - - for (r >>= 7; n < 30; n++) { - for (w[n] = r << 7, t = 0; t < 1 << o[n] - 7; t++) { - f[256 + r++] = n; - } - } - - for (e = 0; e <= 15; e++) { - s[e] = 0; - } - - for (t = 0; t <= 143;) { - d[2 * t + 1] = 8, t++, s[8]++; - } - - for (; t <= 255;) { - d[2 * t + 1] = 9, t++, s[9]++; - } - - for (; t <= 279;) { - d[2 * t + 1] = 7, t++, s[7]++; - } - - for (; t <= 287;) { - d[2 * t + 1] = 8, t++, s[8]++; - } - - for (U(d, 287, s), t = 0; t < 30; t++) { - _[2 * t + 1] = 5, _[2 * t] = x(t, 5); - } - - g = new p(d, a, 257, 286, 15), b = new p(_, o, 0, 30, 15), m = new p(new Array(0), h, 0, 19, 7); - }(), D = !0), t.l_desc = new k(t.dyn_ltree, g), t.d_desc = new k(t.dyn_dtree, b), t.bl_desc = new k(t.bl_tree, m), t.bi_buf = 0, t.bi_valid = 0, z(t); - }, - _tr_stored_block: I, - _tr_flush_block: function _tr_flush_block(t, e, i, n) { - var r, + _tr_init: function _tr_init(t) { + D || (function () { + var t, e, i, n, r; + var s = new Array(16); + for (i = 0, n = 0; n < 28; n++) for (u[n] = i, t = 0; t < 1 << a[n]; t++) c[i++] = n; + for (c[i - 1] = n, r = 0, n = 0; n < 16; n++) for (w[n] = r, t = 0; t < 1 << o[n]; t++) f[r++] = n; + for (r >>= 7; n < 30; n++) for (w[n] = r << 7, t = 0; t < 1 << o[n] - 7; t++) f[256 + r++] = n; + for (e = 0; e <= 15; e++) s[e] = 0; + for (t = 0; t <= 143;) d[2 * t + 1] = 8, t++, s[8]++; + for (; t <= 255;) d[2 * t + 1] = 9, t++, s[9]++; + for (; t <= 279;) d[2 * t + 1] = 7, t++, s[7]++; + for (; t <= 287;) d[2 * t + 1] = 8, t++, s[8]++; + for (U(d, 287, s), t = 0; t < 30; t++) _[2 * t + 1] = 5, _[2 * t] = x(t, 5); + g = new p(d, a, 257, 286, 15), b = new p(_, o, 0, 30, 15), m = new p(new Array(0), h, 0, 19, 7); + }(), D = !0), t.l_desc = new k(t.dyn_ltree, g), t.d_desc = new k(t.dyn_dtree, b), t.bl_desc = new k(t.bl_tree, m), t.bi_buf = 0, t.bi_valid = 0, z(t); + }, + _tr_stored_block: I, + _tr_flush_block: function _tr_flush_block(t, e, i, n) { + var r, s, a = 0; - t.level > 0 ? (2 === t.strm.data_type && (t.strm.data_type = function (t) { - var e, + t.level > 0 ? (2 === t.strm.data_type && (t.strm.data_type = function (t) { + var e, i = 4093624447; - - for (e = 0; e <= 31; e++, i >>>= 1) { - if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; - } - - if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return 1; - - for (e = 32; e < 256; e++) { - if (0 !== t.dyn_ltree[2 * e]) return 1; - } - - return 0; - }(t)), L(t, t.l_desc), L(t, t.d_desc), a = function (t) { - var e; - - for (B(t, t.dyn_ltree, t.l_desc.max_code), B(t, t.dyn_dtree, t.d_desc.max_code), L(t, t.bl_desc), e = 18; e >= 3 && 0 === t.bl_tree[2 * l[e] + 1]; e--) { - } - - return t.opt_len += 3 * (e + 1) + 5 + 5 + 4, e; - }(t), r = t.opt_len + 3 + 7 >>> 3, s = t.static_len + 3 + 7 >>> 3, s <= r && (r = s)) : r = s = i + 5, i + 4 <= r && -1 !== e ? I(t, e, i, n) : 4 === t.strategy || s === r ? (E(t, 2 + (n ? 1 : 0), 3), O(t, d, _)) : (E(t, 4 + (n ? 1 : 0), 3), function (t, e, i, n) { - var r; - - for (E(t, e - 257, 5), E(t, i - 1, 5), E(t, n - 4, 4), r = 0; r < n; r++) { - E(t, t.bl_tree[2 * l[r] + 1], 3); - } - - C(t, t.dyn_ltree, e - 1), C(t, t.dyn_dtree, i - 1); - }(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, a + 1), O(t, t.dyn_ltree, t.dyn_dtree)), z(t), n && R(t); - }, - _tr_tally: function _tr_tally(t, e, i) { - return t.pending_buf[t.d_buf + 2 * t.last_lit] = e >>> 8 & 255, t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e, t.pending_buf[t.l_buf + t.last_lit] = 255 & i, t.last_lit++, 0 === e ? t.dyn_ltree[2 * i]++ : (t.matches++, e--, t.dyn_ltree[2 * (c[i] + 256 + 1)]++, t.dyn_dtree[2 * y(e)]++), t.last_lit === t.lit_bufsize - 1; + for (e = 0; e <= 31; e++, i >>>= 1) if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; + if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return 1; + for (e = 32; e < 256; e++) if (0 !== t.dyn_ltree[2 * e]) return 1; + return 0; + }(t)), L(t, t.l_desc), L(t, t.d_desc), a = function (t) { + var e; + for (B(t, t.dyn_ltree, t.l_desc.max_code), B(t, t.dyn_dtree, t.d_desc.max_code), L(t, t.bl_desc), e = 18; e >= 3 && 0 === t.bl_tree[2 * l[e] + 1]; e--); + return t.opt_len += 3 * (e + 1) + 5 + 5 + 4, e; + }(t), r = t.opt_len + 3 + 7 >>> 3, s = t.static_len + 3 + 7 >>> 3, s <= r && (r = s)) : r = s = i + 5, i + 4 <= r && -1 !== e ? I(t, e, i, n) : 4 === t.strategy || s === r ? (E(t, 2 + (n ? 1 : 0), 3), O(t, d, _)) : (E(t, 4 + (n ? 1 : 0), 3), function (t, e, i, n) { + var r; + for (E(t, e - 257, 5), E(t, i - 1, 5), E(t, n - 4, 4), r = 0; r < n; r++) E(t, t.bl_tree[2 * l[r] + 1], 3); + C(t, t.dyn_ltree, e - 1), C(t, t.dyn_dtree, i - 1); + }(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, a + 1), O(t, t.dyn_ltree, t.dyn_dtree)), z(t), n && R(t); + }, + _tr_tally: function _tr_tally(t, e, i) { + return t.pending_buf[t.d_buf + 2 * t.last_lit] = e >>> 8 & 255, t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e, t.pending_buf[t.l_buf + t.last_lit] = 255 & i, t.last_lit++, 0 === e ? t.dyn_ltree[2 * i]++ : (t.matches++, e--, t.dyn_ltree[2 * (c[i] + 256 + 1)]++, t.dyn_dtree[2 * y(e)]++), t.last_lit === t.lit_bufsize - 1; + }, + _tr_align: function _tr_align(t) { + E(t, 2, 3), A(t, 256, d), function (t) { + 16 === t.bi_valid ? (v(t, t.bi_buf), t.bi_buf = 0, t.bi_valid = 0) : t.bi_valid >= 8 && (t.pending_buf[t.pending++] = 255 & t.bi_buf, t.bi_buf >>= 8, t.bi_valid -= 8); + }(t); + } }, - _tr_align: function _tr_align(t) { - E(t, 2, 3), A(t, 256, d), function (t) { - 16 === t.bi_valid ? (v(t, t.bi_buf), t.bi_buf = 0, t.bi_valid = 0) : t.bi_valid >= 8 && (t.pending_buf[t.pending++] = 255 & t.bi_buf, t.bi_buf >>= 8, t.bi_valid -= 8); - }(t); - } - }, - Z = function Z(t, e, i, n) { - var r = 65535 & t | 0, + Z = function Z(t, e, i, n) { + var r = 65535 & t | 0, s = t >>> 16 & 65535 | 0, a = 0; - - for (; 0 !== i;) { - a = i > 2e3 ? 2e3 : i, i -= a; - - do { - r = r + e[n++] | 0, s = s + r | 0; - } while (--a); - - r %= 65521, s %= 65521; - } - - return r | s << 16 | 0; - }; - + for (; 0 !== i;) { + a = i > 2e3 ? 2e3 : i, i -= a; + do { + r = r + e[n++] | 0, s = s + r | 0; + } while (--a); + r %= 65521, s %= 65521; + } + return r | s << 16 | 0; + }; var F = new Uint32Array(function () { var t, - e = []; - + e = []; for (var i = 0; i < 256; i++) { t = i; - - for (var n = 0; n < 8; n++) { - t = 1 & t ? 3988292384 ^ t >>> 1 : t >>> 1; - } - + for (var n = 0; n < 8; n++) t = 1 & t ? 3988292384 ^ t >>> 1 : t >>> 1; e[i] = t; } - return e; }()); - var M = function M(t, e, i, n) { - var r = F, + var r = F, s = n + i; - t ^= -1; - - for (var _i5 = n; _i5 < s; _i5++) { - t = t >>> 8 ^ r[255 & (t ^ e[_i5])]; - } - - return -1 ^ t; - }, - P = { - 2: "need dictionary", - 1: "stream end", - 0: "", - "-1": "file error", - "-2": "stream error", - "-3": "data error", - "-4": "insufficient memory", - "-5": "buffer error", - "-6": "incompatible version" - }, - H = { - Z_NO_FLUSH: 0, - Z_PARTIAL_FLUSH: 1, - Z_SYNC_FLUSH: 2, - Z_FULL_FLUSH: 3, - Z_FINISH: 4, - Z_BLOCK: 5, - Z_TREES: 6, - Z_OK: 0, - Z_STREAM_END: 1, - Z_NEED_DICT: 2, - Z_ERRNO: -1, - Z_STREAM_ERROR: -2, - Z_DATA_ERROR: -3, - Z_MEM_ERROR: -4, - Z_BUF_ERROR: -5, - Z_NO_COMPRESSION: 0, - Z_BEST_SPEED: 1, - Z_BEST_COMPRESSION: 9, - Z_DEFAULT_COMPRESSION: -1, - Z_FILTERED: 1, - Z_HUFFMAN_ONLY: 2, - Z_RLE: 3, - Z_FIXED: 4, - Z_DEFAULT_STRATEGY: 0, - Z_BINARY: 0, - Z_TEXT: 1, - Z_UNKNOWN: 2, - Z_DEFLATED: 8 - }; - + t ^= -1; + for (var _i5 = n; _i5 < s; _i5++) t = t >>> 8 ^ r[255 & (t ^ e[_i5])]; + return -1 ^ t; + }, + P = { + 2: "need dictionary", + 1: "stream end", + 0: "", + "-1": "file error", + "-2": "stream error", + "-3": "data error", + "-4": "insufficient memory", + "-5": "buffer error", + "-6": "incompatible version" + }, + H = { + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + Z_BINARY: 0, + Z_TEXT: 1, + Z_UNKNOWN: 2, + Z_DEFLATED: 8 + }; var W = S._tr_init, - K = S._tr_stored_block, - $ = S._tr_flush_block, - Y = S._tr_tally, - j = S._tr_align, - G = H.Z_NO_FLUSH, - X = H.Z_PARTIAL_FLUSH, - V = H.Z_FULL_FLUSH, - q = H.Z_FINISH, - J = H.Z_BLOCK, - Q = H.Z_OK, - tt = H.Z_STREAM_END, - et = H.Z_STREAM_ERROR, - it = H.Z_DATA_ERROR, - nt = H.Z_BUF_ERROR, - rt = H.Z_DEFAULT_COMPRESSION, - st = H.Z_FILTERED, - at = H.Z_HUFFMAN_ONLY, - ot = H.Z_RLE, - ht = H.Z_FIXED, - dt = H.Z_UNKNOWN, - _t = H.Z_DEFLATED, - ft = 258, - ct = 262, - ut = 103, - wt = 113, - pt = 666, - gt = function gt(t, e) { - return t.msg = P[e], e; - }, - bt = function bt(t) { - return (t << 1) - (t > 4 ? 9 : 0); - }, - mt = function mt(t) { - var e = t.length; - - for (; --e >= 0;) { - t[e] = 0; - } - }; - + K = S._tr_stored_block, + $ = S._tr_flush_block, + Y = S._tr_tally, + j = S._tr_align, + G = H.Z_NO_FLUSH, + X = H.Z_PARTIAL_FLUSH, + V = H.Z_FULL_FLUSH, + q = H.Z_FINISH, + J = H.Z_BLOCK, + Q = H.Z_OK, + tt = H.Z_STREAM_END, + et = H.Z_STREAM_ERROR, + it = H.Z_DATA_ERROR, + nt = H.Z_BUF_ERROR, + rt = H.Z_DEFAULT_COMPRESSION, + st = H.Z_FILTERED, + at = H.Z_HUFFMAN_ONLY, + ot = H.Z_RLE, + ht = H.Z_FIXED, + dt = H.Z_UNKNOWN, + _t = H.Z_DEFLATED, + ft = 258, + ct = 262, + ut = 103, + wt = 113, + pt = 666, + gt = function gt(t, e) { + return t.msg = P[e], e; + }, + bt = function bt(t) { + return (t << 1) - (t > 4 ? 9 : 0); + }, + mt = function mt(t) { + var e = t.length; + for (; --e >= 0;) t[e] = 0; + }; var kt = function kt(t, e, i) { return (e << t.hash_shift ^ i) & t.hash_mask; }; - var yt = function yt(t) { - var e = t.state; - var i = e.pending; - i > t.avail_out && (i = t.avail_out), 0 !== i && (t.output.set(e.pending_buf.subarray(e.pending_out, e.pending_out + i), t.next_out), t.next_out += i, e.pending_out += i, t.total_out += i, t.avail_out -= i, e.pending -= i, 0 === e.pending && (e.pending_out = 0)); - }, - vt = function vt(t, e) { - $(t, t.block_start >= 0 ? t.block_start : -1, t.strstart - t.block_start, e), t.block_start = t.strstart, yt(t.strm); - }, - Et = function Et(t, e) { - t.pending_buf[t.pending++] = e; - }, - At = function At(t, e) { - t.pending_buf[t.pending++] = e >>> 8 & 255, t.pending_buf[t.pending++] = 255 & e; - }, - xt = function xt(t, e, i, n) { - var r = t.avail_in; - return r > n && (r = n), 0 === r ? 0 : (t.avail_in -= r, e.set(t.input.subarray(t.next_in, t.next_in + r), i), 1 === t.state.wrap ? t.adler = Z(t.adler, e, r, i) : 2 === t.state.wrap && (t.adler = M(t.adler, e, r, i)), t.next_in += r, t.total_in += r, r); - }, - Ut = function Ut(t, e) { - var i, + var e = t.state; + var i = e.pending; + i > t.avail_out && (i = t.avail_out), 0 !== i && (t.output.set(e.pending_buf.subarray(e.pending_out, e.pending_out + i), t.next_out), t.next_out += i, e.pending_out += i, t.total_out += i, t.avail_out -= i, e.pending -= i, 0 === e.pending && (e.pending_out = 0)); + }, + vt = function vt(t, e) { + $(t, t.block_start >= 0 ? t.block_start : -1, t.strstart - t.block_start, e), t.block_start = t.strstart, yt(t.strm); + }, + Et = function Et(t, e) { + t.pending_buf[t.pending++] = e; + }, + At = function At(t, e) { + t.pending_buf[t.pending++] = e >>> 8 & 255, t.pending_buf[t.pending++] = 255 & e; + }, + xt = function xt(t, e, i, n) { + var r = t.avail_in; + return r > n && (r = n), 0 === r ? 0 : (t.avail_in -= r, e.set(t.input.subarray(t.next_in, t.next_in + r), i), 1 === t.state.wrap ? t.adler = Z(t.adler, e, r, i) : 2 === t.state.wrap && (t.adler = M(t.adler, e, r, i)), t.next_in += r, t.total_in += r, r); + }, + Ut = function Ut(t, e) { + var i, n, r = t.max_chain_length, s = t.strstart, a = t.prev_length, o = t.nice_match; - var h = t.strstart > t.w_size - ct ? t.strstart - (t.w_size - ct) : 0, + var h = t.strstart > t.w_size - ct ? t.strstart - (t.w_size - ct) : 0, l = t.window, d = t.w_mask, _ = t.prev, f = t.strstart + ft; - var c = l[s + a - 1], + var c = l[s + a - 1], u = l[s + a]; - t.prev_length >= t.good_match && (r >>= 2), o > t.lookahead && (o = t.lookahead); - - do { - if (i = e, l[i + a] === u && l[i + a - 1] === c && l[i] === l[s] && l[++i] === l[s + 1]) { - s += 2, i++; - - do {} while (l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && s < f); - - if (n = ft - (f - s), s = f - ft, n > a) { - if (t.match_start = e, a = n, n >= o) break; - c = l[s + a - 1], u = l[s + a]; + t.prev_length >= t.good_match && (r >>= 2), o > t.lookahead && (o = t.lookahead); + do { + if (i = e, l[i + a] === u && l[i + a - 1] === c && l[i] === l[s] && l[++i] === l[s + 1]) { + s += 2, i++; + do {} while (l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && s < f); + if (n = ft - (f - s), s = f - ft, n > a) { + if (t.match_start = e, a = n, n >= o) break; + c = l[s + a - 1], u = l[s + a]; + } } - } - } while ((e = _[e & d]) > h && 0 != --r); - - return a <= t.lookahead ? a : t.lookahead; - }, - zt = function zt(t) { - var e = t.w_size; - var i, n, r, s, a; - - do { - if (s = t.window_size - t.lookahead - t.strstart, t.strstart >= e + (e - ct)) { - t.window.set(t.window.subarray(e, e + e), 0), t.match_start -= e, t.strstart -= e, t.block_start -= e, n = t.hash_size, i = n; - - do { - r = t.head[--i], t.head[i] = r >= e ? r - e : 0; - } while (--n); - - n = e, i = n; - - do { - r = t.prev[--i], t.prev[i] = r >= e ? r - e : 0; - } while (--n); - - s += e; - } - - if (0 === t.strm.avail_in) break; - if (n = xt(t.strm, t.window, t.strstart + t.lookahead, s), t.lookahead += n, t.lookahead + t.insert >= 3) for (a = t.strstart - t.insert, t.ins_h = t.window[a], t.ins_h = kt(t, t.ins_h, t.window[a + 1]); t.insert && (t.ins_h = kt(t, t.ins_h, t.window[a + 3 - 1]), t.prev[a & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = a, a++, t.insert--, !(t.lookahead + t.insert < 3));) { - } - } while (t.lookahead < ct && 0 !== t.strm.avail_in); - }, - Rt = function Rt(t, e) { - var i, n; - - for (;;) { - if (t.lookahead < ct) { - if (zt(t), t.lookahead < ct && e === G) return 1; - if (0 === t.lookahead) break; - } - - if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 !== i && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i)), t.match_length >= 3) { - if (n = Y(t, t.strstart - t.match_start, t.match_length - 3), t.lookahead -= t.match_length, t.match_length <= t.max_lazy_match && t.lookahead >= 3) { - t.match_length--; - + } while ((e = _[e & d]) > h && 0 != --r); + return a <= t.lookahead ? a : t.lookahead; + }, + zt = function zt(t) { + var e = t.w_size; + var i, n, r, s, a; + do { + if (s = t.window_size - t.lookahead - t.strstart, t.strstart >= e + (e - ct)) { + t.window.set(t.window.subarray(e, e + e), 0), t.match_start -= e, t.strstart -= e, t.block_start -= e, n = t.hash_size, i = n; do { - t.strstart++, t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart; - } while (0 != --t.match_length); - - t.strstart++; - } else t.strstart += t.match_length, t.match_length = 0, t.ins_h = t.window[t.strstart], t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 1]); - } else n = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++; - if (n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - }, - Nt = function Nt(t, e) { - var i, n, r; - - for (;;) { - if (t.lookahead < ct) { - if (zt(t), t.lookahead < ct && e === G) return 1; - if (0 === t.lookahead) break; - } - - if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), t.prev_length = t.match_length, t.prev_match = t.match_start, t.match_length = 2, 0 !== i && t.prev_length < t.max_lazy_match && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i), t.match_length <= 5 && (t.strategy === st || 3 === t.match_length && t.strstart - t.match_start > 4096) && (t.match_length = 2)), t.prev_length >= 3 && t.match_length <= t.prev_length) { - r = t.strstart + t.lookahead - 3, n = Y(t, t.strstart - 1 - t.prev_match, t.prev_length - 3), t.lookahead -= t.prev_length - 1, t.prev_length -= 2; - - do { - ++t.strstart <= r && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart); - } while (0 != --t.prev_length); - - if (t.match_available = 0, t.match_length = 2, t.strstart++, n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } else if (t.match_available) { - if (n = Y(t, 0, t.window[t.strstart - 1]), n && vt(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out) return 1; - } else t.match_available = 1, t.strstart++, t.lookahead--; - } - - return t.match_available && (n = Y(t, 0, t.window[t.strstart - 1]), t.match_available = 0), t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - }; - + r = t.head[--i], t.head[i] = r >= e ? r - e : 0; + } while (--n); + n = e, i = n; + do { + r = t.prev[--i], t.prev[i] = r >= e ? r - e : 0; + } while (--n); + s += e; + } + if (0 === t.strm.avail_in) break; + if (n = xt(t.strm, t.window, t.strstart + t.lookahead, s), t.lookahead += n, t.lookahead + t.insert >= 3) for (a = t.strstart - t.insert, t.ins_h = t.window[a], t.ins_h = kt(t, t.ins_h, t.window[a + 1]); t.insert && (t.ins_h = kt(t, t.ins_h, t.window[a + 3 - 1]), t.prev[a & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = a, a++, t.insert--, !(t.lookahead + t.insert < 3));); + } while (t.lookahead < ct && 0 !== t.strm.avail_in); + }, + Rt = function Rt(t, e) { + var i, n; + for (;;) { + if (t.lookahead < ct) { + if (zt(t), t.lookahead < ct && e === G) return 1; + if (0 === t.lookahead) break; + } + if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 !== i && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i)), t.match_length >= 3) { + if (n = Y(t, t.strstart - t.match_start, t.match_length - 3), t.lookahead -= t.match_length, t.match_length <= t.max_lazy_match && t.lookahead >= 3) { + t.match_length--; + do { + t.strstart++, t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart; + } while (0 != --t.match_length); + t.strstart++; + } else t.strstart += t.match_length, t.match_length = 0, t.ins_h = t.window[t.strstart], t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 1]); + } else n = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++; + if (n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; + } + return t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + }, + Nt = function Nt(t, e) { + var i, n, r; + for (;;) { + if (t.lookahead < ct) { + if (zt(t), t.lookahead < ct && e === G) return 1; + if (0 === t.lookahead) break; + } + if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), t.prev_length = t.match_length, t.prev_match = t.match_start, t.match_length = 2, 0 !== i && t.prev_length < t.max_lazy_match && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i), t.match_length <= 5 && (t.strategy === st || 3 === t.match_length && t.strstart - t.match_start > 4096) && (t.match_length = 2)), t.prev_length >= 3 && t.match_length <= t.prev_length) { + r = t.strstart + t.lookahead - 3, n = Y(t, t.strstart - 1 - t.prev_match, t.prev_length - 3), t.lookahead -= t.prev_length - 1, t.prev_length -= 2; + do { + ++t.strstart <= r && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart); + } while (0 != --t.prev_length); + if (t.match_available = 0, t.match_length = 2, t.strstart++, n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; + } else if (t.match_available) { + if (n = Y(t, 0, t.window[t.strstart - 1]), n && vt(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out) return 1; + } else t.match_available = 1, t.strstart++, t.lookahead--; + } + return t.match_available && (n = Y(t, 0, t.window[t.strstart - 1]), t.match_available = 0), t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + }; function Tt(t, e, i, n, r) { this.good_length = t, this.max_lazy = e, this.nice_length = i, this.max_chain = n, this.func = r; } - var Ot = [new Tt(0, 0, 0, 0, function (t, e) { var i = 65535; - for (i > t.pending_buf_size - 5 && (i = t.pending_buf_size - 5);;) { if (t.lookahead <= 1) { if (zt(t), 0 === t.lookahead && e === G) return 1; if (0 === t.lookahead) break; } - t.strstart += t.lookahead, t.lookahead = 0; - var _n2 = t.block_start + i; - if ((0 === t.strstart || t.strstart >= _n2) && (t.lookahead = t.strstart - _n2, t.strstart = _n2, vt(t, !1), 0 === t.strm.avail_out)) return 1; if (t.strstart - t.block_start >= t.w_size - ct && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : (t.strstart > t.block_start && (vt(t, !1), t.strm.avail_out), 1); }), new Tt(4, 4, 8, 4, Rt), new Tt(4, 5, 16, 8, Rt), new Tt(4, 6, 32, 32, Rt), new Tt(4, 4, 16, 16, Nt), new Tt(8, 16, 32, 32, Nt), new Tt(8, 16, 128, 128, Nt), new Tt(8, 32, 128, 256, Nt), new Tt(32, 128, 258, 1024, Nt), new Tt(32, 258, 258, 4096, Nt)]; - function Lt() { this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = _t, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new Uint16Array(1146), this.dyn_dtree = new Uint16Array(122), this.bl_tree = new Uint16Array(78), mt(this.dyn_ltree), mt(this.dyn_dtree), mt(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new Uint16Array(16), this.heap = new Uint16Array(573), mt(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new Uint16Array(573), mt(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0; } - var Bt = function Bt(t) { - if (!t || !t.state) return gt(t, et); - t.total_in = t.total_out = 0, t.data_type = dt; - var e = t.state; - return e.pending = 0, e.pending_out = 0, e.wrap < 0 && (e.wrap = -e.wrap), e.status = e.wrap ? 42 : wt, t.adler = 2 === e.wrap ? 0 : 1, e.last_flush = G, W(e), Q; - }, - Ct = function Ct(t) { - var e = Bt(t); - var i; - return e === Q && ((i = t.state).window_size = 2 * i.w_size, mt(i.head), i.max_lazy_match = Ot[i.level].max_lazy, i.good_match = Ot[i.level].good_length, i.nice_match = Ot[i.level].nice_length, i.max_chain_length = Ot[i.level].max_chain, i.strstart = 0, i.block_start = 0, i.lookahead = 0, i.insert = 0, i.match_length = i.prev_length = 2, i.match_available = 0, i.ins_h = 0), e; - }, - Dt = function Dt(t, e, i, n, r, s) { - if (!t) return et; - var a = 1; - if (e === rt && (e = 6), n < 0 ? (a = 0, n = -n) : n > 15 && (a = 2, n -= 16), r < 1 || r > 9 || i !== _t || n < 8 || n > 15 || e < 0 || e > 9 || s < 0 || s > ht) return gt(t, et); - 8 === n && (n = 9); - var o = new Lt(); - return t.state = o, o.strm = t, o.wrap = a, o.gzhead = null, o.w_bits = n, o.w_size = 1 << o.w_bits, o.w_mask = o.w_size - 1, o.hash_bits = r + 7, o.hash_size = 1 << o.hash_bits, o.hash_mask = o.hash_size - 1, o.hash_shift = ~~((o.hash_bits + 3 - 1) / 3), o.window = new Uint8Array(2 * o.w_size), o.head = new Uint16Array(o.hash_size), o.prev = new Uint16Array(o.w_size), o.lit_bufsize = 1 << r + 6, o.pending_buf_size = 4 * o.lit_bufsize, o.pending_buf = new Uint8Array(o.pending_buf_size), o.d_buf = 1 * o.lit_bufsize, o.l_buf = 3 * o.lit_bufsize, o.level = e, o.strategy = s, o.method = i, Ct(t); - }; - + if (!t || !t.state) return gt(t, et); + t.total_in = t.total_out = 0, t.data_type = dt; + var e = t.state; + return e.pending = 0, e.pending_out = 0, e.wrap < 0 && (e.wrap = -e.wrap), e.status = e.wrap ? 42 : wt, t.adler = 2 === e.wrap ? 0 : 1, e.last_flush = G, W(e), Q; + }, + Ct = function Ct(t) { + var e = Bt(t); + var i; + return e === Q && ((i = t.state).window_size = 2 * i.w_size, mt(i.head), i.max_lazy_match = Ot[i.level].max_lazy, i.good_match = Ot[i.level].good_length, i.nice_match = Ot[i.level].nice_length, i.max_chain_length = Ot[i.level].max_chain, i.strstart = 0, i.block_start = 0, i.lookahead = 0, i.insert = 0, i.match_length = i.prev_length = 2, i.match_available = 0, i.ins_h = 0), e; + }, + Dt = function Dt(t, e, i, n, r, s) { + if (!t) return et; + var a = 1; + if (e === rt && (e = 6), n < 0 ? (a = 0, n = -n) : n > 15 && (a = 2, n -= 16), r < 1 || r > 9 || i !== _t || n < 8 || n > 15 || e < 0 || e > 9 || s < 0 || s > ht) return gt(t, et); + 8 === n && (n = 9); + var o = new Lt(); + return t.state = o, o.strm = t, o.wrap = a, o.gzhead = null, o.w_bits = n, o.w_size = 1 << o.w_bits, o.w_mask = o.w_size - 1, o.hash_bits = r + 7, o.hash_size = 1 << o.hash_bits, o.hash_mask = o.hash_size - 1, o.hash_shift = ~~((o.hash_bits + 3 - 1) / 3), o.window = new Uint8Array(2 * o.w_size), o.head = new Uint16Array(o.hash_size), o.prev = new Uint16Array(o.w_size), o.lit_bufsize = 1 << r + 6, o.pending_buf_size = 4 * o.lit_bufsize, o.pending_buf = new Uint8Array(o.pending_buf_size), o.d_buf = 1 * o.lit_bufsize, o.l_buf = 3 * o.lit_bufsize, o.level = e, o.strategy = s, o.method = i, Ct(t); + }; var It = Dt, - St = function St(t, e) { - return t && t.state ? 2 !== t.state.wrap ? et : (t.state.gzhead = e, Q) : et; - }, - Zt = function Zt(t, e) { - var i, n; - if (!t || !t.state || e > J || e < 0) return t ? gt(t, et) : et; - var r = t.state; - if (!t.output || !t.input && 0 !== t.avail_in || r.status === pt && e !== q) return gt(t, 0 === t.avail_out ? nt : et); - r.strm = t; - var s = r.last_flush; - if (r.last_flush = e, 42 === r.status) if (2 === r.wrap) t.adler = 0, Et(r, 31), Et(r, 139), Et(r, 8), r.gzhead ? (Et(r, (r.gzhead.text ? 1 : 0) + (r.gzhead.hcrc ? 2 : 0) + (r.gzhead.extra ? 4 : 0) + (r.gzhead.name ? 8 : 0) + (r.gzhead.comment ? 16 : 0)), Et(r, 255 & r.gzhead.time), Et(r, r.gzhead.time >> 8 & 255), Et(r, r.gzhead.time >> 16 & 255), Et(r, r.gzhead.time >> 24 & 255), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 255 & r.gzhead.os), r.gzhead.extra && r.gzhead.extra.length && (Et(r, 255 & r.gzhead.extra.length), Et(r, r.gzhead.extra.length >> 8 & 255)), r.gzhead.hcrc && (t.adler = M(t.adler, r.pending_buf, r.pending, 0)), r.gzindex = 0, r.status = 69) : (Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 3), r.status = wt);else { - var _e11 = _t + (r.w_bits - 8 << 4) << 8, + St = function St(t, e) { + return t && t.state ? 2 !== t.state.wrap ? et : (t.state.gzhead = e, Q) : et; + }, + Zt = function Zt(t, e) { + var i, n; + if (!t || !t.state || e > J || e < 0) return t ? gt(t, et) : et; + var r = t.state; + if (!t.output || !t.input && 0 !== t.avail_in || r.status === pt && e !== q) return gt(t, 0 === t.avail_out ? nt : et); + r.strm = t; + var s = r.last_flush; + if (r.last_flush = e, 42 === r.status) if (2 === r.wrap) t.adler = 0, Et(r, 31), Et(r, 139), Et(r, 8), r.gzhead ? (Et(r, (r.gzhead.text ? 1 : 0) + (r.gzhead.hcrc ? 2 : 0) + (r.gzhead.extra ? 4 : 0) + (r.gzhead.name ? 8 : 0) + (r.gzhead.comment ? 16 : 0)), Et(r, 255 & r.gzhead.time), Et(r, r.gzhead.time >> 8 & 255), Et(r, r.gzhead.time >> 16 & 255), Et(r, r.gzhead.time >> 24 & 255), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 255 & r.gzhead.os), r.gzhead.extra && r.gzhead.extra.length && (Et(r, 255 & r.gzhead.extra.length), Et(r, r.gzhead.extra.length >> 8 & 255)), r.gzhead.hcrc && (t.adler = M(t.adler, r.pending_buf, r.pending, 0)), r.gzindex = 0, r.status = 69) : (Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 3), r.status = wt);else { + var _e11 = _t + (r.w_bits - 8 << 4) << 8, _i6 = -1; - - _i6 = r.strategy >= at || r.level < 2 ? 0 : r.level < 6 ? 1 : 6 === r.level ? 2 : 3, _e11 |= _i6 << 6, 0 !== r.strstart && (_e11 |= 32), _e11 += 31 - _e11 % 31, r.status = wt, At(r, _e11), 0 !== r.strstart && (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), t.adler = 1; - } - if (69 === r.status) if (r.gzhead.extra) { - for (i = r.pending; r.gzindex < (65535 & r.gzhead.extra.length) && (r.pending !== r.pending_buf_size || (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending !== r.pending_buf_size));) { - Et(r, 255 & r.gzhead.extra[r.gzindex]), r.gzindex++; - } - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), r.gzindex === r.gzhead.extra.length && (r.gzindex = 0, r.status = 73); - } else r.status = 73; - if (73 === r.status) if (r.gzhead.name) { - i = r.pending; - - do { - if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { - n = 1; - break; - } - - n = r.gzindex < r.gzhead.name.length ? 255 & r.gzhead.name.charCodeAt(r.gzindex++) : 0, Et(r, n); - } while (0 !== n); - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.gzindex = 0, r.status = 91); - } else r.status = 91; - if (91 === r.status) if (r.gzhead.comment) { - i = r.pending; - - do { - if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { - n = 1; - break; - } - - n = r.gzindex < r.gzhead.comment.length ? 255 & r.gzhead.comment.charCodeAt(r.gzindex++) : 0, Et(r, n); - } while (0 !== n); - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.status = ut); - } else r.status = ut; - - if (r.status === ut && (r.gzhead.hcrc ? (r.pending + 2 > r.pending_buf_size && yt(t), r.pending + 2 <= r.pending_buf_size && (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), t.adler = 0, r.status = wt)) : r.status = wt), 0 !== r.pending) { - if (yt(t), 0 === t.avail_out) return r.last_flush = -1, Q; - } else if (0 === t.avail_in && bt(e) <= bt(s) && e !== q) return gt(t, nt); - - if (r.status === pt && 0 !== t.avail_in) return gt(t, nt); - - if (0 !== t.avail_in || 0 !== r.lookahead || e !== G && r.status !== pt) { - var _i7 = r.strategy === at ? function (t, e) { - var i; - - for (;;) { - if (0 === t.lookahead && (zt(t), 0 === t.lookahead)) { - if (e === G) return 1; + _i6 = r.strategy >= at || r.level < 2 ? 0 : r.level < 6 ? 1 : 6 === r.level ? 2 : 3, _e11 |= _i6 << 6, 0 !== r.strstart && (_e11 |= 32), _e11 += 31 - _e11 % 31, r.status = wt, At(r, _e11), 0 !== r.strstart && (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), t.adler = 1; + } + if (69 === r.status) if (r.gzhead.extra) { + for (i = r.pending; r.gzindex < (65535 & r.gzhead.extra.length) && (r.pending !== r.pending_buf_size || (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending !== r.pending_buf_size));) Et(r, 255 & r.gzhead.extra[r.gzindex]), r.gzindex++; + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), r.gzindex === r.gzhead.extra.length && (r.gzindex = 0, r.status = 73); + } else r.status = 73; + if (73 === r.status) if (r.gzhead.name) { + i = r.pending; + do { + if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { + n = 1; break; } - - if (t.match_length = 0, i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++, i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - }(r, e) : r.strategy === ot ? function (t, e) { - var i, n, r, s; - var a = t.window; - - for (;;) { - if (t.lookahead <= ft) { - if (zt(t), t.lookahead <= ft && e === G) return 1; - if (0 === t.lookahead) break; + n = r.gzindex < r.gzhead.name.length ? 255 & r.gzhead.name.charCodeAt(r.gzindex++) : 0, Et(r, n); + } while (0 !== n); + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.gzindex = 0, r.status = 91); + } else r.status = 91; + if (91 === r.status) if (r.gzhead.comment) { + i = r.pending; + do { + if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { + n = 1; + break; } - - if (t.match_length = 0, t.lookahead >= 3 && t.strstart > 0 && (r = t.strstart - 1, n = a[r], n === a[++r] && n === a[++r] && n === a[++r])) { - s = t.strstart + ft; - - do {} while (n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && r < s); - - t.match_length = ft - (s - r), t.match_length > t.lookahead && (t.match_length = t.lookahead); + n = r.gzindex < r.gzhead.comment.length ? 255 & r.gzhead.comment.charCodeAt(r.gzindex++) : 0, Et(r, n); + } while (0 !== n); + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.status = ut); + } else r.status = ut; + if (r.status === ut && (r.gzhead.hcrc ? (r.pending + 2 > r.pending_buf_size && yt(t), r.pending + 2 <= r.pending_buf_size && (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), t.adler = 0, r.status = wt)) : r.status = wt), 0 !== r.pending) { + if (yt(t), 0 === t.avail_out) return r.last_flush = -1, Q; + } else if (0 === t.avail_in && bt(e) <= bt(s) && e !== q) return gt(t, nt); + if (r.status === pt && 0 !== t.avail_in) return gt(t, nt); + if (0 !== t.avail_in || 0 !== r.lookahead || e !== G && r.status !== pt) { + var _i7 = r.strategy === at ? function (t, e) { + var i; + for (;;) { + if (0 === t.lookahead && (zt(t), 0 === t.lookahead)) { + if (e === G) return 1; + break; + } + if (t.match_length = 0, i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++, i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - - if (t.match_length >= 3 ? (i = Y(t, 1, t.match_length - 3), t.lookahead -= t.match_length, t.strstart += t.match_length, t.match_length = 0) : (i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++), i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - }(r, e) : Ot[r.level].func(r, e); - - if (3 !== _i7 && 4 !== _i7 || (r.status = pt), 1 === _i7 || 3 === _i7) return 0 === t.avail_out && (r.last_flush = -1), Q; - if (2 === _i7 && (e === X ? j(r) : e !== J && (K(r, 0, 0, !1), e === V && (mt(r.head), 0 === r.lookahead && (r.strstart = 0, r.block_start = 0, r.insert = 0))), yt(t), 0 === t.avail_out)) return r.last_flush = -1, Q; - } - - return e !== q ? Q : r.wrap <= 0 ? tt : (2 === r.wrap ? (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), Et(r, t.adler >> 16 & 255), Et(r, t.adler >> 24 & 255), Et(r, 255 & t.total_in), Et(r, t.total_in >> 8 & 255), Et(r, t.total_in >> 16 & 255), Et(r, t.total_in >> 24 & 255)) : (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), yt(t), r.wrap > 0 && (r.wrap = -r.wrap), 0 !== r.pending ? Q : tt); - }, - Ft = function Ft(t) { - if (!t || !t.state) return et; - var e = t.state.status; - return 42 !== e && 69 !== e && 73 !== e && 91 !== e && e !== ut && e !== wt && e !== pt ? gt(t, et) : (t.state = null, e === wt ? gt(t, it) : Q); - }, - Mt = function Mt(t, e) { - var i = e.length; - if (!t || !t.state) return et; - var n = t.state, + return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + }(r, e) : r.strategy === ot ? function (t, e) { + var i, n, r, s; + var a = t.window; + for (;;) { + if (t.lookahead <= ft) { + if (zt(t), t.lookahead <= ft && e === G) return 1; + if (0 === t.lookahead) break; + } + if (t.match_length = 0, t.lookahead >= 3 && t.strstart > 0 && (r = t.strstart - 1, n = a[r], n === a[++r] && n === a[++r] && n === a[++r])) { + s = t.strstart + ft; + do {} while (n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && r < s); + t.match_length = ft - (s - r), t.match_length > t.lookahead && (t.match_length = t.lookahead); + } + if (t.match_length >= 3 ? (i = Y(t, 1, t.match_length - 3), t.lookahead -= t.match_length, t.strstart += t.match_length, t.match_length = 0) : (i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++), i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; + } + return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + }(r, e) : Ot[r.level].func(r, e); + if (3 !== _i7 && 4 !== _i7 || (r.status = pt), 1 === _i7 || 3 === _i7) return 0 === t.avail_out && (r.last_flush = -1), Q; + if (2 === _i7 && (e === X ? j(r) : e !== J && (K(r, 0, 0, !1), e === V && (mt(r.head), 0 === r.lookahead && (r.strstart = 0, r.block_start = 0, r.insert = 0))), yt(t), 0 === t.avail_out)) return r.last_flush = -1, Q; + } + return e !== q ? Q : r.wrap <= 0 ? tt : (2 === r.wrap ? (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), Et(r, t.adler >> 16 & 255), Et(r, t.adler >> 24 & 255), Et(r, 255 & t.total_in), Et(r, t.total_in >> 8 & 255), Et(r, t.total_in >> 16 & 255), Et(r, t.total_in >> 24 & 255)) : (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), yt(t), r.wrap > 0 && (r.wrap = -r.wrap), 0 !== r.pending ? Q : tt); + }, + Ft = function Ft(t) { + if (!t || !t.state) return et; + var e = t.state.status; + return 42 !== e && 69 !== e && 73 !== e && 91 !== e && e !== ut && e !== wt && e !== pt ? gt(t, et) : (t.state = null, e === wt ? gt(t, it) : Q); + }, + Mt = function Mt(t, e) { + var i = e.length; + if (!t || !t.state) return et; + var n = t.state, r = n.wrap; - if (2 === r || 1 === r && 42 !== n.status || n.lookahead) return et; - - if (1 === r && (t.adler = Z(t.adler, e, i, 0)), n.wrap = 0, i >= n.w_size) { - 0 === r && (mt(n.head), n.strstart = 0, n.block_start = 0, n.insert = 0); - - var _t3 = new Uint8Array(n.w_size); - - _t3.set(e.subarray(i - n.w_size, i), 0), e = _t3, i = n.w_size; - } - - var s = t.avail_in, + if (2 === r || 1 === r && 42 !== n.status || n.lookahead) return et; + if (1 === r && (t.adler = Z(t.adler, e, i, 0)), n.wrap = 0, i >= n.w_size) { + 0 === r && (mt(n.head), n.strstart = 0, n.block_start = 0, n.insert = 0); + var _t3 = new Uint8Array(n.w_size); + _t3.set(e.subarray(i - n.w_size, i), 0), e = _t3, i = n.w_size; + } + var s = t.avail_in, a = t.next_in, o = t.input; - - for (t.avail_in = i, t.next_in = 0, t.input = e, zt(n); n.lookahead >= 3;) { - var _t4 = n.strstart, + for (t.avail_in = i, t.next_in = 0, t.input = e, zt(n); n.lookahead >= 3;) { + var _t4 = n.strstart, _e12 = n.lookahead - 2; - - do { - n.ins_h = kt(n, n.ins_h, n.window[_t4 + 3 - 1]), n.prev[_t4 & n.w_mask] = n.head[n.ins_h], n.head[n.ins_h] = _t4, _t4++; - } while (--_e12); - - n.strstart = _t4, n.lookahead = 2, zt(n); - } - - return n.strstart += n.lookahead, n.block_start = n.strstart, n.insert = n.lookahead, n.lookahead = 0, n.match_length = n.prev_length = 2, n.match_available = 0, t.next_in = a, t.input = o, t.avail_in = s, n.wrap = r, Q; - }; - + do { + n.ins_h = kt(n, n.ins_h, n.window[_t4 + 3 - 1]), n.prev[_t4 & n.w_mask] = n.head[n.ins_h], n.head[n.ins_h] = _t4, _t4++; + } while (--_e12); + n.strstart = _t4, n.lookahead = 2, zt(n); + } + return n.strstart += n.lookahead, n.block_start = n.strstart, n.insert = n.lookahead, n.lookahead = 0, n.match_length = n.prev_length = 2, n.match_available = 0, t.next_in = a, t.input = o, t.avail_in = s, n.wrap = r, Q; + }; var Pt = function Pt(t, e) { return Object.prototype.hasOwnProperty.call(t, e); }; - var Ht = function Ht(t) { - var e = Array.prototype.slice.call(arguments, 1); - - for (; e.length;) { - var _i8 = e.shift(); - - if (_i8) { - if ("object" != _typeof(_i8)) throw new TypeError(_i8 + "must be non-object"); - - for (var _e13 in _i8) { - Pt(_i8, _e13) && (t[_e13] = _i8[_e13]); + var e = Array.prototype.slice.call(arguments, 1); + for (; e.length;) { + var _i8 = e.shift(); + if (_i8) { + if ("object" != _typeof(_i8)) throw new TypeError(_i8 + "must be non-object"); + for (var _e13 in _i8) Pt(_i8, _e13) && (t[_e13] = _i8[_e13]); } } - } - - return t; - }, - Wt = function Wt(t) { - var e = 0; - - for (var _i9 = 0, _n3 = t.length; _i9 < _n3; _i9++) { - e += t[_i9].length; - } - - var i = new Uint8Array(e); - - for (var _e14 = 0, _n4 = 0, _r2 = t.length; _e14 < _r2; _e14++) { - var _r3 = t[_e14]; - i.set(_r3, _n4), _n4 += _r3.length; - } - - return i; - }; - + return t; + }, + Wt = function Wt(t) { + var e = 0; + for (var _i9 = 0, _n3 = t.length; _i9 < _n3; _i9++) e += t[_i9].length; + var i = new Uint8Array(e); + for (var _e14 = 0, _n4 = 0, _r2 = t.length; _e14 < _r2; _e14++) { + var _r3 = t[_e14]; + i.set(_r3, _n4), _n4 += _r3.length; + } + return i; + }; var Kt = !0; - try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (t) { Kt = !1; } - var $t = new Uint8Array(256); - - for (var _t5 = 0; _t5 < 256; _t5++) { - $t[_t5] = _t5 >= 252 ? 6 : _t5 >= 248 ? 5 : _t5 >= 240 ? 4 : _t5 >= 224 ? 3 : _t5 >= 192 ? 2 : 1; - } - + for (var _t5 = 0; _t5 < 256; _t5++) $t[_t5] = _t5 >= 252 ? 6 : _t5 >= 248 ? 5 : _t5 >= 240 ? 4 : _t5 >= 224 ? 3 : _t5 >= 192 ? 2 : 1; $t[254] = $t[254] = 1; - var Yt = function Yt(t) { - if ("function" == typeof TextEncoder && TextEncoder.prototype.encode) return new TextEncoder().encode(t); - var e, + if ("function" == typeof TextEncoder && TextEncoder.prototype.encode) return new TextEncoder().encode(t); + var e, i, n, r, s, a = t.length, o = 0; - - for (r = 0; r < a; r++) { - i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), o += i < 128 ? 1 : i < 2048 ? 2 : i < 65536 ? 3 : 4; - } - - for (e = new Uint8Array(o), s = 0, r = 0; s < o; r++) { - i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), i < 128 ? e[s++] = i : i < 2048 ? (e[s++] = 192 | i >>> 6, e[s++] = 128 | 63 & i) : i < 65536 ? (e[s++] = 224 | i >>> 12, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i) : (e[s++] = 240 | i >>> 18, e[s++] = 128 | i >>> 12 & 63, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i); - } - - return e; - }, - jt = function jt(t, e) { - var i = e || t.length; - if ("function" == typeof TextDecoder && TextDecoder.prototype.decode) return new TextDecoder().decode(t.subarray(0, e)); - var n, r; - var s = new Array(2 * i); - - for (r = 0, n = 0; n < i;) { - var _e15 = t[n++]; - - if (_e15 < 128) { - s[r++] = _e15; - continue; - } - - var _a = $t[_e15]; - if (_a > 4) s[r++] = 65533, n += _a - 1;else { - for (_e15 &= 2 === _a ? 31 : 3 === _a ? 15 : 7; _a > 1 && n < i;) { - _e15 = _e15 << 6 | 63 & t[n++], _a--; + for (r = 0; r < a; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), o += i < 128 ? 1 : i < 2048 ? 2 : i < 65536 ? 3 : 4; + for (e = new Uint8Array(o), s = 0, r = 0; s < o; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), i < 128 ? e[s++] = i : i < 2048 ? (e[s++] = 192 | i >>> 6, e[s++] = 128 | 63 & i) : i < 65536 ? (e[s++] = 224 | i >>> 12, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i) : (e[s++] = 240 | i >>> 18, e[s++] = 128 | i >>> 12 & 63, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i); + return e; + }, + jt = function jt(t, e) { + var i = e || t.length; + if ("function" == typeof TextDecoder && TextDecoder.prototype.decode) return new TextDecoder().decode(t.subarray(0, e)); + var n, r; + var s = new Array(2 * i); + for (r = 0, n = 0; n < i;) { + var _e15 = t[n++]; + if (_e15 < 128) { + s[r++] = _e15; + continue; + } + var _a = $t[_e15]; + if (_a > 4) s[r++] = 65533, n += _a - 1;else { + for (_e15 &= 2 === _a ? 31 : 3 === _a ? 15 : 7; _a > 1 && n < i;) _e15 = _e15 << 6 | 63 & t[n++], _a--; + _a > 1 ? s[r++] = 65533 : _e15 < 65536 ? s[r++] = _e15 : (_e15 -= 65536, s[r++] = 55296 | _e15 >> 10 & 1023, s[r++] = 56320 | 1023 & _e15); } - - _a > 1 ? s[r++] = 65533 : _e15 < 65536 ? s[r++] = _e15 : (_e15 -= 65536, s[r++] = 55296 | _e15 >> 10 & 1023, s[r++] = 56320 | 1023 & _e15); - } - } - - return function (t, e) { - if (e < 65534 && t.subarray && Kt) return String.fromCharCode.apply(null, t.length === e ? t : t.subarray(0, e)); - var i = ""; - - for (var _n5 = 0; _n5 < e; _n5++) { - i += String.fromCharCode(t[_n5]); } - - return i; - }(s, r); - }, - Gt = function Gt(t, e) { - (e = e || t.length) > t.length && (e = t.length); - var i = e - 1; - - for (; i >= 0 && 128 == (192 & t[i]);) { - i--; - } - - return i < 0 || 0 === i ? e : i + $t[t[i]] > e ? i : e; - }, - Xt = function Xt() { - this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; - }; - + return function (t, e) { + if (e < 65534 && t.subarray && Kt) return String.fromCharCode.apply(null, t.length === e ? t : t.subarray(0, e)); + var i = ""; + for (var _n5 = 0; _n5 < e; _n5++) i += String.fromCharCode(t[_n5]); + return i; + }(s, r); + }, + Gt = function Gt(t, e) { + (e = e || t.length) > t.length && (e = t.length); + var i = e - 1; + for (; i >= 0 && 128 == (192 & t[i]);) i--; + return i < 0 || 0 === i ? e : i + $t[t[i]] > e ? i : e; + }, + Xt = function Xt() { + this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; + }; var Vt = Object.prototype.toString, - qt = H.Z_NO_FLUSH, - Jt = H.Z_SYNC_FLUSH, - Qt = H.Z_FULL_FLUSH, - te = H.Z_FINISH, - ee = H.Z_OK, - ie = H.Z_STREAM_END, - ne = H.Z_DEFAULT_COMPRESSION, - re = H.Z_DEFAULT_STRATEGY, - se = H.Z_DEFLATED; - + qt = H.Z_NO_FLUSH, + Jt = H.Z_SYNC_FLUSH, + Qt = H.Z_FULL_FLUSH, + te = H.Z_FINISH, + ee = H.Z_OK, + ie = H.Z_STREAM_END, + ne = H.Z_DEFAULT_COMPRESSION, + re = H.Z_DEFAULT_STRATEGY, + se = H.Z_DEFLATED; function ae(t) { this.options = Ht({ level: ne, @@ -6653,357 +6127,260 @@ e.raw && e.windowBits > 0 ? e.windowBits = -e.windowBits : e.gzip && e.windowBits > 0 && e.windowBits < 16 && (e.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new Xt(), this.strm.avail_out = 0; var i = It(this.strm, e.level, e.method, e.windowBits, e.memLevel, e.strategy); if (i !== ee) throw new Error(P[i]); - if (e.header && St(this.strm, e.header), e.dictionary) { var _t6; - if (_t6 = "string" == typeof e.dictionary ? Yt(e.dictionary) : "[object ArrayBuffer]" === Vt.call(e.dictionary) ? new Uint8Array(e.dictionary) : e.dictionary, i = Mt(this.strm, _t6), i !== ee) throw new Error(P[i]); this._dict_set = !0; } } - function oe(t, e) { var i = new ae(e); if (i.push(t, !0), i.err) throw i.msg || P[i.err]; return i.result; } - ae.prototype.push = function (t, e) { var i = this.strm, - n = this.options.chunkSize; + n = this.options.chunkSize; var r, s; if (this.ended) return !1; - - for (s = e === ~~e ? e : !0 === e ? te : qt, "string" == typeof t ? i.input = Yt(t) : "[object ArrayBuffer]" === Vt.call(t) ? i.input = new Uint8Array(t) : i.input = t, i.next_in = 0, i.avail_in = i.input.length;;) { - if (0 === i.avail_out && (i.output = new Uint8Array(n), i.next_out = 0, i.avail_out = n), (s === Jt || s === Qt) && i.avail_out <= 6) this.onData(i.output.subarray(0, i.next_out)), i.avail_out = 0;else { - if (r = Zt(i, s), r === ie) return i.next_out > 0 && this.onData(i.output.subarray(0, i.next_out)), r = Ft(this.strm), this.onEnd(r), this.ended = !0, r === ee; - - if (0 !== i.avail_out) { - if (s > 0 && i.next_out > 0) this.onData(i.output.subarray(0, i.next_out)), i.avail_out = 0;else if (0 === i.avail_in) break; - } else this.onData(i.output); - } + for (s = e === ~~e ? e : !0 === e ? te : qt, "string" == typeof t ? i.input = Yt(t) : "[object ArrayBuffer]" === Vt.call(t) ? i.input = new Uint8Array(t) : i.input = t, i.next_in = 0, i.avail_in = i.input.length;;) if (0 === i.avail_out && (i.output = new Uint8Array(n), i.next_out = 0, i.avail_out = n), (s === Jt || s === Qt) && i.avail_out <= 6) this.onData(i.output.subarray(0, i.next_out)), i.avail_out = 0;else { + if (r = Zt(i, s), r === ie) return i.next_out > 0 && this.onData(i.output.subarray(0, i.next_out)), r = Ft(this.strm), this.onEnd(r), this.ended = !0, r === ee; + if (0 !== i.avail_out) { + if (s > 0 && i.next_out > 0) this.onData(i.output.subarray(0, i.next_out)), i.avail_out = 0;else if (0 === i.avail_in) break; + } else this.onData(i.output); } - return !0; }, ae.prototype.onData = function (t) { this.chunks.push(t); }, ae.prototype.onEnd = function (t) { t === ee && (this.result = Wt(this.chunks)), this.chunks = [], this.err = t, this.msg = this.strm.msg; }; - var he = { - Deflate: ae, - deflate: oe, - deflateRaw: function deflateRaw(t, e) { - return (e = e || {}).raw = !0, oe(t, e); - }, - gzip: function gzip(t, e) { - return (e = e || {}).gzip = !0, oe(t, e); + Deflate: ae, + deflate: oe, + deflateRaw: function deflateRaw(t, e) { + return (e = e || {}).raw = !0, oe(t, e); + }, + gzip: function gzip(t, e) { + return (e = e || {}).gzip = !0, oe(t, e); + }, + constants: H }, - constants: H - }, - le = function le(t, e) { - var i, n, r, s, a, o, h, l, d, _, f, c, u, w, p, g, b, m, k, y, v, E, A, x; - - var U = t.state; - i = t.next_in, A = t.input, n = i + (t.avail_in - 5), r = t.next_out, x = t.output, s = r - (e - t.avail_out), a = r + (t.avail_out - 257), o = U.dmax, h = U.wsize, l = U.whave, d = U.wnext, _ = U.window, f = U.hold, c = U.bits, u = U.lencode, w = U.distcode, p = (1 << U.lenbits) - 1, g = (1 << U.distbits) - 1; - - t: do { - c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = u[f & p]; - - e: for (;;) { - if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, 0 === m) x[r++] = 65535 & b;else { - if (!(16 & m)) { - if (0 == (64 & m)) { - b = u[(65535 & b) + (f & (1 << m) - 1)]; - continue e; - } - - if (32 & m) { - U.mode = 12; - break t; - } - - t.msg = "invalid literal/length code", U.mode = 30; - break t; - } - - k = 65535 & b, m &= 15, m && (c < m && (f += A[i++] << c, c += 8), k += f & (1 << m) - 1, f >>>= m, c -= m), c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = w[f & g]; - - i: for (;;) { - if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, !(16 & m)) { + le = function le(t, e) { + var i, n, r, s, a, o, h, l, d, _, f, c, u, w, p, g, b, m, k, y, v, E, A, x; + var U = t.state; + i = t.next_in, A = t.input, n = i + (t.avail_in - 5), r = t.next_out, x = t.output, s = r - (e - t.avail_out), a = r + (t.avail_out - 257), o = U.dmax, h = U.wsize, l = U.whave, d = U.wnext, _ = U.window, f = U.hold, c = U.bits, u = U.lencode, w = U.distcode, p = (1 << U.lenbits) - 1, g = (1 << U.distbits) - 1; + t: do { + c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = u[f & p]; + e: for (;;) { + if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, 0 === m) x[r++] = 65535 & b;else { + if (!(16 & m)) { if (0 == (64 & m)) { - b = w[(65535 & b) + (f & (1 << m) - 1)]; - continue i; + b = u[(65535 & b) + (f & (1 << m) - 1)]; + continue e; } - - t.msg = "invalid distance code", U.mode = 30; - break t; - } - - if (y = 65535 & b, m &= 15, c < m && (f += A[i++] << c, c += 8, c < m && (f += A[i++] << c, c += 8)), y += f & (1 << m) - 1, y > o) { - t.msg = "invalid distance too far back", U.mode = 30; + if (32 & m) { + U.mode = 12; + break t; + } + t.msg = "invalid literal/length code", U.mode = 30; break t; } - - if (f >>>= m, c -= m, m = r - s, y > m) { - if (m = y - m, m > l && U.sane) { - t.msg = "invalid distance too far back", U.mode = 30; + k = 65535 & b, m &= 15, m && (c < m && (f += A[i++] << c, c += 8), k += f & (1 << m) - 1, f >>>= m, c -= m), c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = w[f & g]; + i: for (;;) { + if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, !(16 & m)) { + if (0 == (64 & m)) { + b = w[(65535 & b) + (f & (1 << m) - 1)]; + continue i; + } + t.msg = "invalid distance code", U.mode = 30; break t; } - - if (v = 0, E = _, 0 === d) { - if (v += h - m, m < k) { - k -= m; - - do { - x[r++] = _[v++]; - } while (--m); - - v = r - y, E = x; + if (y = 65535 & b, m &= 15, c < m && (f += A[i++] << c, c += 8, c < m && (f += A[i++] << c, c += 8)), y += f & (1 << m) - 1, y > o) { + t.msg = "invalid distance too far back", U.mode = 30; + break t; + } + if (f >>>= m, c -= m, m = r - s, y > m) { + if (m = y - m, m > l && U.sane) { + t.msg = "invalid distance too far back", U.mode = 30; + break t; } - } else if (d < m) { - if (v += h + d - m, m -= d, m < k) { - k -= m; - - do { - x[r++] = _[v++]; - } while (--m); - - if (v = 0, d < k) { - m = d, k -= m; - + if (v = 0, E = _, 0 === d) { + if (v += h - m, m < k) { + k -= m; do { x[r++] = _[v++]; } while (--m); - v = r - y, E = x; } + } else if (d < m) { + if (v += h + d - m, m -= d, m < k) { + k -= m; + do { + x[r++] = _[v++]; + } while (--m); + if (v = 0, d < k) { + m = d, k -= m; + do { + x[r++] = _[v++]; + } while (--m); + v = r - y, E = x; + } + } + } else if (v += d - m, m < k) { + k -= m; + do { + x[r++] = _[v++]; + } while (--m); + v = r - y, E = x; } - } else if (v += d - m, m < k) { - k -= m; - + for (; k > 2;) x[r++] = E[v++], x[r++] = E[v++], x[r++] = E[v++], k -= 3; + k && (x[r++] = E[v++], k > 1 && (x[r++] = E[v++])); + } else { + v = r - y; do { - x[r++] = _[v++]; - } while (--m); - - v = r - y, E = x; + x[r++] = x[v++], x[r++] = x[v++], x[r++] = x[v++], k -= 3; + } while (k > 2); + k && (x[r++] = x[v++], k > 1 && (x[r++] = x[v++])); } - - for (; k > 2;) { - x[r++] = E[v++], x[r++] = E[v++], x[r++] = E[v++], k -= 3; - } - - k && (x[r++] = E[v++], k > 1 && (x[r++] = E[v++])); - } else { - v = r - y; - - do { - x[r++] = x[v++], x[r++] = x[v++], x[r++] = x[v++], k -= 3; - } while (k > 2); - - k && (x[r++] = x[v++], k > 1 && (x[r++] = x[v++])); + break; } - - break; } + break; } - break; - } - } while (i < n && r < a); - - k = c >> 3, i -= k, c -= k << 3, f &= (1 << c) - 1, t.next_in = i, t.next_out = r, t.avail_in = i < n ? n - i + 5 : 5 - (i - n), t.avail_out = r < a ? a - r + 257 : 257 - (r - a), U.hold = f, U.bits = c; - }; - + } while (i < n && r < a); + k = c >> 3, i -= k, c -= k << 3, f &= (1 << c) - 1, t.next_in = i, t.next_out = r, t.avail_in = i < n ? n - i + 5 : 5 - (i - n), t.avail_out = r < a ? a - r + 257 : 257 - (r - a), U.hold = f, U.bits = c; + }; var de = new Uint16Array([3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0]), - _e = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78]), - fe = new Uint16Array([1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0]), - ce = new Uint8Array([16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]); - + _e = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78]), + fe = new Uint16Array([1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0]), + ce = new Uint8Array([16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]); var ue = function ue(t, e, i, n, r, s, a, o) { var h = o.bits; - var l, - d, - _, - f, - c, - u, - w = 0, - p = 0, - g = 0, - b = 0, - m = 0, - k = 0, - y = 0, - v = 0, - E = 0, - A = 0, - x = null, - U = 0; - + d, + _, + f, + c, + u, + w = 0, + p = 0, + g = 0, + b = 0, + m = 0, + k = 0, + y = 0, + v = 0, + E = 0, + A = 0, + x = null, + U = 0; var z = new Uint16Array(16), - R = new Uint16Array(16); + R = new Uint16Array(16); var N, - T, - O, - L = null, - B = 0; - - for (w = 0; w <= 15; w++) { - z[w] = 0; - } - - for (p = 0; p < n; p++) { - z[e[i + p]]++; - } - - for (m = h, b = 15; b >= 1 && 0 === z[b]; b--) { - } - + T, + O, + L = null, + B = 0; + for (w = 0; w <= 15; w++) z[w] = 0; + for (p = 0; p < n; p++) z[e[i + p]]++; + for (m = h, b = 15; b >= 1 && 0 === z[b]; b--); if (m > b && (m = b), 0 === b) return r[s++] = 20971520, r[s++] = 20971520, o.bits = 1, 0; - - for (g = 1; g < b && 0 === z[g]; g++) { - } - - for (m < g && (m = g), v = 1, w = 1; w <= 15; w++) { - if (v <<= 1, v -= z[w], v < 0) return -1; - } - + for (g = 1; g < b && 0 === z[g]; g++); + for (m < g && (m = g), v = 1, w = 1; w <= 15; w++) if (v <<= 1, v -= z[w], v < 0) return -1; if (v > 0 && (0 === t || 1 !== b)) return -1; - - for (R[1] = 0, w = 1; w < 15; w++) { - R[w + 1] = R[w] + z[w]; - } - - for (p = 0; p < n; p++) { - 0 !== e[i + p] && (a[R[e[i + p]]++] = p); - } - + for (R[1] = 0, w = 1; w < 15; w++) R[w + 1] = R[w] + z[w]; + for (p = 0; p < n; p++) 0 !== e[i + p] && (a[R[e[i + p]]++] = p); if (0 === t ? (x = L = a, u = 19) : 1 === t ? (x = de, U -= 257, L = _e, B -= 257, u = 256) : (x = fe, L = ce, u = -1), A = 0, p = 0, w = g, c = s, k = m, y = 0, _ = -1, E = 1 << m, f = E - 1, 1 === t && E > 852 || 2 === t && E > 592) return 1; - for (;;) { N = w - y, a[p] < u ? (T = 0, O = a[p]) : a[p] > u ? (T = L[B + a[p]], O = x[U + a[p]]) : (T = 96, O = 0), l = 1 << w - y, d = 1 << k, g = d; - do { d -= l, r[c + (A >> y) + d] = N << 24 | T << 16 | O | 0; } while (0 !== d); - - for (l = 1 << w - 1; A & l;) { - l >>= 1; - } - + for (l = 1 << w - 1; A & l;) l >>= 1; if (0 !== l ? (A &= l - 1, A += l) : A = 0, p++, 0 == --z[w]) { if (w === b) break; w = e[i + a[p]]; } - if (w > m && (A & f) !== _) { - for (0 === y && (y = m), c += g, k = w - y, v = 1 << k; k + y < b && (v -= z[k + y], !(v <= 0));) { - k++, v <<= 1; - } - + for (0 === y && (y = m), c += g, k = w - y, v = 1 << k; k + y < b && (v -= z[k + y], !(v <= 0));) k++, v <<= 1; if (E += 1 << k, 1 === t && E > 852 || 2 === t && E > 592) return 1; _ = A & f, r[_] = m << 24 | k << 16 | c - s | 0; } } - return 0 !== A && (r[c + A] = w - y << 24 | 64 << 16 | 0), o.bits = m, 0; }; - var we = H.Z_FINISH, - pe = H.Z_BLOCK, - ge = H.Z_TREES, - be = H.Z_OK, - me = H.Z_STREAM_END, - ke = H.Z_NEED_DICT, - ye = H.Z_STREAM_ERROR, - ve = H.Z_DATA_ERROR, - Ee = H.Z_MEM_ERROR, - Ae = H.Z_BUF_ERROR, - xe = H.Z_DEFLATED, - Ue = 12, - ze = 30, - Re = function Re(t) { - return (t >>> 24 & 255) + (t >>> 8 & 65280) + ((65280 & t) << 8) + ((255 & t) << 24); - }; - + pe = H.Z_BLOCK, + ge = H.Z_TREES, + be = H.Z_OK, + me = H.Z_STREAM_END, + ke = H.Z_NEED_DICT, + ye = H.Z_STREAM_ERROR, + ve = H.Z_DATA_ERROR, + Ee = H.Z_MEM_ERROR, + Ae = H.Z_BUF_ERROR, + xe = H.Z_DEFLATED, + Ue = 12, + ze = 30, + Re = function Re(t) { + return (t >>> 24 & 255) + (t >>> 8 & 65280) + ((65280 & t) << 8) + ((255 & t) << 24); + }; function Ne() { this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Uint16Array(320), this.work = new Uint16Array(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0; } - var Te = function Te(t) { - if (!t || !t.state) return ye; - var e = t.state; - return t.total_in = t.total_out = e.total = 0, t.msg = "", e.wrap && (t.adler = 1 & e.wrap), e.mode = 1, e.last = 0, e.havedict = 0, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(852), e.distcode = e.distdyn = new Int32Array(592), e.sane = 1, e.back = -1, be; - }, - Oe = function Oe(t) { - if (!t || !t.state) return ye; - var e = t.state; - return e.wsize = 0, e.whave = 0, e.wnext = 0, Te(t); - }, - Le = function Le(t, e) { - var i; - if (!t || !t.state) return ye; - var n = t.state; - return e < 0 ? (i = 0, e = -e) : (i = 1 + (e >> 4), e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? ye : (null !== n.window && n.wbits !== e && (n.window = null), n.wrap = i, n.wbits = e, Oe(t)); - }, - Be = function Be(t, e) { - if (!t) return ye; - var i = new Ne(); - t.state = i, i.window = null; - var n = Le(t, e); - return n !== be && (t.state = null), n; - }; - + if (!t || !t.state) return ye; + var e = t.state; + return t.total_in = t.total_out = e.total = 0, t.msg = "", e.wrap && (t.adler = 1 & e.wrap), e.mode = 1, e.last = 0, e.havedict = 0, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(852), e.distcode = e.distdyn = new Int32Array(592), e.sane = 1, e.back = -1, be; + }, + Oe = function Oe(t) { + if (!t || !t.state) return ye; + var e = t.state; + return e.wsize = 0, e.whave = 0, e.wnext = 0, Te(t); + }, + Le = function Le(t, e) { + var i; + if (!t || !t.state) return ye; + var n = t.state; + return e < 0 ? (i = 0, e = -e) : (i = 1 + (e >> 4), e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? ye : (null !== n.window && n.wbits !== e && (n.window = null), n.wrap = i, n.wbits = e, Oe(t)); + }, + Be = function Be(t, e) { + if (!t) return ye; + var i = new Ne(); + t.state = i, i.window = null; + var n = Le(t, e); + return n !== be && (t.state = null), n; + }; var Ce, - De, - Ie = !0; - + De, + Ie = !0; var Se = function Se(t) { - if (Ie) { - Ce = new Int32Array(512), De = new Int32Array(32); - var _e16 = 0; - - for (; _e16 < 144;) { - t.lens[_e16++] = 8; - } - - for (; _e16 < 256;) { - t.lens[_e16++] = 9; - } - - for (; _e16 < 280;) { - t.lens[_e16++] = 7; - } - - for (; _e16 < 288;) { - t.lens[_e16++] = 8; - } - - for (ue(1, t.lens, 0, 288, Ce, 0, t.work, { - bits: 9 - }), _e16 = 0; _e16 < 32;) { - t.lens[_e16++] = 5; - } - - ue(2, t.lens, 0, 32, De, 0, t.work, { - bits: 5 - }), Ie = !1; - } - - t.lencode = Ce, t.lenbits = 9, t.distcode = De, t.distbits = 5; - }, - Ze = function Ze(t, e, i, n) { - var r; - var s = t.state; - return null === s.window && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new Uint8Array(s.wsize)), n >= s.wsize ? (s.window.set(e.subarray(i - s.wsize, i), 0), s.wnext = 0, s.whave = s.wsize) : (r = s.wsize - s.wnext, r > n && (r = n), s.window.set(e.subarray(i - n, i - n + r), s.wnext), (n -= r) ? (s.window.set(e.subarray(i - n, i), 0), s.wnext = n, s.whave = s.wsize) : (s.wnext += r, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += r))), 0; - }; - + if (Ie) { + Ce = new Int32Array(512), De = new Int32Array(32); + var _e16 = 0; + for (; _e16 < 144;) t.lens[_e16++] = 8; + for (; _e16 < 256;) t.lens[_e16++] = 9; + for (; _e16 < 280;) t.lens[_e16++] = 7; + for (; _e16 < 288;) t.lens[_e16++] = 8; + for (ue(1, t.lens, 0, 288, Ce, 0, t.work, { + bits: 9 + }), _e16 = 0; _e16 < 32;) t.lens[_e16++] = 5; + ue(2, t.lens, 0, 32, De, 0, t.work, { + bits: 5 + }), Ie = !1; + } + t.lencode = Ce, t.lenbits = 9, t.distcode = De, t.distbits = 5; + }, + Ze = function Ze(t, e, i, n) { + var r; + var s = t.state; + return null === s.window && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new Uint8Array(s.wsize)), n >= s.wsize ? (s.window.set(e.subarray(i - s.wsize, i), 0), s.wnext = 0, s.whave = s.wsize) : (r = s.wsize - s.wnext, r > n && (r = n), s.window.set(e.subarray(i - n, i - n + r), s.wnext), (n -= r) ? (s.window.set(e.subarray(i - n, i), 0), s.wnext = n, s.whave = s.wsize) : (s.wnext += r, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += r))), 0; + }; var Fe = Oe, - Me = Be, - Pe = function Pe(t, e) { - var i, + Me = Be, + Pe = function Pe(t, e) { + var i, n, r, s, @@ -7026,524 +6403,405 @@ v, E, A = 0; - - var x = new Uint8Array(4); - var U, z; - var R = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); - if (!t || !t.state || !t.output || !t.input && 0 !== t.avail_in) return ye; - i = t.state, i.mode === Ue && (i.mode = 13), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, _ = o, f = h, E = be; - - t: for (;;) { - switch (i.mode) { + var x = new Uint8Array(4); + var U, z; + var R = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); + if (!t || !t.state || !t.output || !t.input && 0 !== t.avail_in) return ye; + i = t.state, i.mode === Ue && (i.mode = 13), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, _ = o, f = h, E = be; + t: for (;;) switch (i.mode) { case 1: if (0 === i.wrap) { i.mode = 13; break; } - for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - if (2 & i.wrap && 35615 === l) { i.check = 0, x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0), l = 0, d = 0, i.mode = 2; break; } - if (i.flags = 0, i.head && (i.head.done = !1), !(1 & i.wrap) || (((255 & l) << 8) + (l >> 8)) % 31) { t.msg = "incorrect header check", i.mode = ze; break; } - if ((15 & l) !== xe) { t.msg = "unknown compression method", i.mode = ze; break; } - if (l >>>= 4, d -= 4, v = 8 + (15 & l), 0 === i.wbits) i.wbits = v;else if (v > i.wbits) { t.msg = "invalid window size", i.mode = ze; break; } i.dmax = 1 << i.wbits, t.adler = i.check = 1, i.mode = 512 & l ? 10 : Ue, l = 0, d = 0; break; - case 2: for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - if (i.flags = l, (255 & i.flags) !== xe) { t.msg = "unknown compression method", i.mode = ze; break; } - if (57344 & i.flags) { t.msg = "unknown header flags set", i.mode = ze; break; } - i.head && (i.head.text = l >> 8 & 1), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 3; - case 3: for (; d < 32;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - i.head && (i.head.time = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, x[2] = l >>> 16 & 255, x[3] = l >>> 24 & 255, i.check = M(i.check, x, 4, 0)), l = 0, d = 0, i.mode = 4; - case 4: for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - i.head && (i.head.xflags = 255 & l, i.head.os = l >> 8), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 5; - case 5: if (1024 & i.flags) { for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - i.length = l, i.head && (i.head.extra_len = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0; } else i.head && (i.head.extra = null); - i.mode = 6; - case 6: if (1024 & i.flags && (c = i.length, c > o && (c = o), c && (i.head && (v = i.head.extra_len - i.length, i.head.extra || (i.head.extra = new Uint8Array(i.head.extra_len)), i.head.extra.set(n.subarray(s, s + c), v)), 512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, i.length -= c), i.length)) break t; i.length = 0, i.mode = 7; - case 7: if (2048 & i.flags) { if (0 === o) break t; c = 0; - do { v = n[s + c++], i.head && v && i.length < 65536 && (i.head.name += String.fromCharCode(v)); } while (v && c < o); - if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; } else i.head && (i.head.name = null); - i.length = 0, i.mode = 8; - case 8: if (4096 & i.flags) { if (0 === o) break t; c = 0; - do { v = n[s + c++], i.head && v && i.length < 65536 && (i.head.comment += String.fromCharCode(v)); } while (v && c < o); - if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; } else i.head && (i.head.comment = null); - i.mode = 9; - case 9: if (512 & i.flags) { for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - if (l !== (65535 & i.check)) { t.msg = "header crc mismatch", i.mode = ze; break; } - l = 0, d = 0; } - i.head && (i.head.hcrc = i.flags >> 9 & 1, i.head.done = !0), t.adler = i.check = 0, i.mode = Ue; break; - case 10: for (; d < 32;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - t.adler = i.check = Re(l), l = 0, d = 0, i.mode = 11; - case 11: if (0 === i.havedict) return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, ke; t.adler = i.check = 1, i.mode = Ue; - case Ue: if (e === pe || e === ge) break t; - case 13: if (i.last) { l >>>= 7 & d, d -= 7 & d, i.mode = 27; break; } - for (; d < 3;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - switch (i.last = 1 & l, l >>>= 1, d -= 1, 3 & l) { case 0: i.mode = 14; break; - case 1: if (Se(i), i.mode = 20, e === ge) { l >>>= 2, d -= 2; break t; } - break; - case 2: i.mode = 17; break; - case 3: t.msg = "invalid block type", i.mode = ze; } - l >>>= 2, d -= 2; break; - case 14: for (l >>>= 7 & d, d -= 7 & d; d < 32;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - if ((65535 & l) != (l >>> 16 ^ 65535)) { t.msg = "invalid stored block lengths", i.mode = ze; break; } - if (i.length = 65535 & l, l = 0, d = 0, i.mode = 15, e === ge) break t; - case 15: i.mode = 16; - case 16: if (c = i.length, c) { if (c > o && (c = o), c > h && (c = h), 0 === c) break t; r.set(n.subarray(s, s + c), a), o -= c, s += c, h -= c, a += c, i.length -= c; break; } - i.mode = Ue; break; - case 17: for (; d < 14;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - if (i.nlen = 257 + (31 & l), l >>>= 5, d -= 5, i.ndist = 1 + (31 & l), l >>>= 5, d -= 5, i.ncode = 4 + (15 & l), l >>>= 4, d -= 4, i.nlen > 286 || i.ndist > 30) { t.msg = "too many length or distance symbols", i.mode = ze; break; } - i.have = 0, i.mode = 18; - case 18: for (; i.have < i.ncode;) { for (; d < 3;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - i.lens[R[i.have++]] = 7 & l, l >>>= 3, d -= 3; } - - for (; i.have < 19;) { - i.lens[R[i.have++]] = 0; - } - + for (; i.have < 19;) i.lens[R[i.have++]] = 0; if (i.lencode = i.lendyn, i.lenbits = 7, U = { bits: i.lenbits }, E = ue(0, i.lens, 0, 19, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { t.msg = "invalid code lengths set", i.mode = ze; break; } - i.have = 0, i.mode = 19; - case 19: for (; i.have < i.nlen + i.ndist;) { for (; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - if (b < 16) l >>>= p, d -= p, i.lens[i.have++] = b;else { if (16 === b) { for (z = p + 2; d < z;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - if (l >>>= p, d -= p, 0 === i.have) { t.msg = "invalid bit length repeat", i.mode = ze; break; } - v = i.lens[i.have - 1], c = 3 + (3 & l), l >>>= 2, d -= 2; } else if (17 === b) { for (z = p + 3; d < z;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - l >>>= p, d -= p, v = 0, c = 3 + (7 & l), l >>>= 3, d -= 3; } else { for (z = p + 7; d < z;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - l >>>= p, d -= p, v = 0, c = 11 + (127 & l), l >>>= 7, d -= 7; } - if (i.have + c > i.nlen + i.ndist) { t.msg = "invalid bit length repeat", i.mode = ze; break; } - - for (; c--;) { - i.lens[i.have++] = v; - } + for (; c--;) i.lens[i.have++] = v; } } - if (i.mode === ze) break; - if (0 === i.lens[256]) { t.msg = "invalid code -- missing end-of-block", i.mode = ze; break; } - if (i.lenbits = 9, U = { bits: i.lenbits }, E = ue(1, i.lens, 0, i.nlen, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { t.msg = "invalid literal/lengths set", i.mode = ze; break; } - if (i.distbits = 6, i.distcode = i.distdyn, U = { bits: i.distbits }, E = ue(2, i.lens, i.nlen, i.ndist, i.distcode, 0, i.work, U), i.distbits = U.bits, E) { t.msg = "invalid distances set", i.mode = ze; break; } - if (i.mode = 20, e === ge) break t; - case 20: i.mode = 21; - case 21: if (o >= 6 && h >= 258) { t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, le(t, f), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, i.mode === Ue && (i.back = -1); break; } - for (i.back = 0; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - if (g && 0 == (240 & g)) { for (m = p, k = g, y = b; A = i.lencode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - l >>>= m, d -= m, i.back += m; } - if (l >>>= p, d -= p, i.back += p, i.length = b, 0 === g) { i.mode = 26; break; } - if (32 & g) { i.back = -1, i.mode = Ue; break; } - if (64 & g) { t.msg = "invalid literal/length code", i.mode = ze; break; } - i.extra = 15 & g, i.mode = 22; - case 22: if (i.extra) { for (z = i.extra; d < z;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - i.length += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; } - i.was = i.length, i.mode = 23; - case 23: for (; A = i.distcode[l & (1 << i.distbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - if (0 == (240 & g)) { for (m = p, k = g, y = b; A = i.distcode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - l >>>= m, d -= m, i.back += m; } - if (l >>>= p, d -= p, i.back += p, 64 & g) { t.msg = "invalid distance code", i.mode = ze; break; } - i.offset = b, i.extra = 15 & g, i.mode = 24; - case 24: if (i.extra) { for (z = i.extra; d < z;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - i.offset += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; } - if (i.offset > i.dmax) { t.msg = "invalid distance too far back", i.mode = ze; break; } - i.mode = 25; - case 25: if (0 === h) break t; - if (c = f - h, i.offset > c) { if (c = i.offset - c, c > i.whave && i.sane) { t.msg = "invalid distance too far back", i.mode = ze; break; } - c > i.wnext ? (c -= i.wnext, u = i.wsize - c) : u = i.wnext - c, c > i.length && (c = i.length), w = i.window; } else w = r, u = a - i.offset, c = i.length; - c > h && (c = h), h -= c, i.length -= c; - do { r[a++] = w[u++]; } while (--c); - 0 === i.length && (i.mode = 21); break; - case 26: if (0 === h) break t; r[a++] = i.length, h--, i.mode = 21; break; - case 27: if (i.wrap) { for (; d < 32;) { if (0 === o) break t; o--, l |= n[s++] << d, d += 8; } - if (f -= h, t.total_out += f, i.total += f, f && (t.adler = i.check = i.flags ? M(i.check, r, f, a - f) : Z(i.check, r, f, a - f)), f = h, (i.flags ? l : Re(l)) !== i.check) { t.msg = "incorrect data check", i.mode = ze; break; } - l = 0, d = 0; } - i.mode = 28; - case 28: if (i.wrap && i.flags) { for (; d < 32;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - if (l !== (4294967295 & i.total)) { t.msg = "incorrect length check", i.mode = ze; break; } - l = 0, d = 0; } - i.mode = 29; - case 29: E = me; break t; - case ze: E = ve; break t; - case 31: return Ee; - default: return ye; } - } - - return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, (i.wsize || f !== t.avail_out && i.mode < ze && (i.mode < 27 || e !== we)) && Ze(t, t.output, t.next_out, f - t.avail_out), _ -= t.avail_in, f -= t.avail_out, t.total_in += _, t.total_out += f, i.total += f, i.wrap && f && (t.adler = i.check = i.flags ? M(i.check, r, f, t.next_out - f) : Z(i.check, r, f, t.next_out - f)), t.data_type = i.bits + (i.last ? 64 : 0) + (i.mode === Ue ? 128 : 0) + (20 === i.mode || 15 === i.mode ? 256 : 0), (0 === _ && 0 === f || e === we) && E === be && (E = Ae), E; - }, - He = function He(t) { - if (!t || !t.state) return ye; - var e = t.state; - return e.window && (e.window = null), t.state = null, be; - }, - We = function We(t, e) { - if (!t || !t.state) return ye; - var i = t.state; - return 0 == (2 & i.wrap) ? ye : (i.head = e, e.done = !1, be); - }, - Ke = function Ke(t, e) { - var i = e.length; - var n, r, s; - return t && t.state ? (n = t.state, 0 !== n.wrap && 11 !== n.mode ? ye : 11 === n.mode && (r = 1, r = Z(r, e, i, 0), r !== n.check) ? ve : (s = Ze(t, e, i, i), s ? (n.mode = 31, Ee) : (n.havedict = 1, be))) : ye; - }, - $e = function $e() { - this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; - }; - + return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, (i.wsize || f !== t.avail_out && i.mode < ze && (i.mode < 27 || e !== we)) && Ze(t, t.output, t.next_out, f - t.avail_out), _ -= t.avail_in, f -= t.avail_out, t.total_in += _, t.total_out += f, i.total += f, i.wrap && f && (t.adler = i.check = i.flags ? M(i.check, r, f, t.next_out - f) : Z(i.check, r, f, t.next_out - f)), t.data_type = i.bits + (i.last ? 64 : 0) + (i.mode === Ue ? 128 : 0) + (20 === i.mode || 15 === i.mode ? 256 : 0), (0 === _ && 0 === f || e === we) && E === be && (E = Ae), E; + }, + He = function He(t) { + if (!t || !t.state) return ye; + var e = t.state; + return e.window && (e.window = null), t.state = null, be; + }, + We = function We(t, e) { + if (!t || !t.state) return ye; + var i = t.state; + return 0 == (2 & i.wrap) ? ye : (i.head = e, e.done = !1, be); + }, + Ke = function Ke(t, e) { + var i = e.length; + var n, r, s; + return t && t.state ? (n = t.state, 0 !== n.wrap && 11 !== n.mode ? ye : 11 === n.mode && (r = 1, r = Z(r, e, i, 0), r !== n.check) ? ve : (s = Ze(t, e, i, i), s ? (n.mode = 31, Ee) : (n.havedict = 1, be))) : ye; + }, + $e = function $e() { + this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; + }; var Ye = Object.prototype.toString, - je = H.Z_NO_FLUSH, - Ge = H.Z_FINISH, - Xe = H.Z_OK, - Ve = H.Z_STREAM_END, - qe = H.Z_NEED_DICT, - Je = H.Z_STREAM_ERROR, - Qe = H.Z_DATA_ERROR, - ti = H.Z_MEM_ERROR; - + je = H.Z_NO_FLUSH, + Ge = H.Z_FINISH, + Xe = H.Z_OK, + Ve = H.Z_STREAM_END, + qe = H.Z_NEED_DICT, + Je = H.Z_STREAM_ERROR, + Qe = H.Z_DATA_ERROR, + ti = H.Z_MEM_ERROR; function ei(t) { this.options = Ht({ chunkSize: 65536, @@ -7556,25 +6814,19 @@ if (i !== Xe) throw new Error(P[i]); if (this.header = new $e(), We(this.strm, this.header), e.dictionary && ("string" == typeof e.dictionary ? e.dictionary = Yt(e.dictionary) : "[object ArrayBuffer]" === Ye.call(e.dictionary) && (e.dictionary = new Uint8Array(e.dictionary)), e.raw && (i = Ke(this.strm, e.dictionary), i !== Xe))) throw new Error(P[i]); } - function ii(t, e) { var i = new ei(e); if (i.push(t), i.err) throw i.msg || P[i.err]; return i.result; } - ei.prototype.push = function (t, e) { var i = this.strm, - n = this.options.chunkSize, - r = this.options.dictionary; + n = this.options.chunkSize, + r = this.options.dictionary; var s, a, o; if (this.ended) return !1; - for (a = e === ~~e ? e : !0 === e ? Ge : je, "[object ArrayBuffer]" === Ye.call(t) ? i.input = new Uint8Array(t) : i.input = t, i.next_in = 0, i.avail_in = i.input.length;;) { - for (0 === i.avail_out && (i.output = new Uint8Array(n), i.next_out = 0, i.avail_out = n), s = Pe(i, a), s === qe && r && (s = Ke(i, r), s === Xe ? s = Pe(i, a) : s === Qe && (s = qe)); i.avail_in > 0 && s === Ve && i.state.wrap > 0 && 0 !== t[i.next_in];) { - Fe(i), s = Pe(i, a); - } - + for (0 === i.avail_out && (i.output = new Uint8Array(n), i.next_out = 0, i.avail_out = n), s = Pe(i, a), s === qe && r && (s = Ke(i, r), s === Xe ? s = Pe(i, a) : s === Qe && (s = qe)); i.avail_in > 0 && s === Ve && i.state.wrap > 0 && 0 !== t[i.next_in];) Fe(i), s = Pe(i, a); switch (s) { case Je: case Qe: @@ -7582,21 +6834,17 @@ case ti: return this.onEnd(s), this.ended = !0, !1; } - if (o = i.avail_out, i.next_out && (0 === i.avail_out || s === Ve)) if ("string" === this.options.to) { var _t7 = Gt(i.output, i.next_out), - _e17 = i.next_out - _t7, - _r4 = jt(i.output, _t7); - + _e17 = i.next_out - _t7, + _r4 = jt(i.output, _t7); i.next_out = _e17, i.avail_out = n - _e17, _e17 && i.output.set(i.output.subarray(_t7, _t7 + _e17), 0), this.onData(_r4); } else this.onData(i.output.length === i.next_out ? i.output : i.output.subarray(0, i.next_out)); - if (s !== Xe || 0 !== o) { if (s === Ve) return s = He(this.strm), this.onEnd(s), this.ended = !0, !0; if (0 === i.avail_in) break; } } - return !0; }, ei.prototype.onData = function (t) { this.chunks.push(t); @@ -7613,38 +6861,26 @@ constants: H }; var si = he.deflate, - hi = ni.Inflate, - li = ni.inflate; + hi = ni.Inflate, + li = ni.inflate; var fi = si, - ci = hi, - ui = li; + ci = hi, + ui = li; var wi = [137, 80, 78, 71, 13, 10, 26, 10], - pi = []; - + pi = []; for (var _t8 = 0; _t8 < 256; _t8++) { var _e18 = _t8; - - for (var _t9 = 0; _t9 < 8; _t9++) { - 1 & _e18 ? _e18 = 3988292384 ^ _e18 >>> 1 : _e18 >>>= 1; - } - + for (var _t9 = 0; _t9 < 8; _t9++) 1 & _e18 ? _e18 = 3988292384 ^ _e18 >>> 1 : _e18 >>>= 1; pi[_t8] = _e18; } - var gi = 4294967295; - function bi(t, e) { return (function (t, e, i) { var n = 4294967295; - - for (var _t10 = 0; _t10 < i; _t10++) { - n = pi[255 & (n ^ e[_t10])] ^ n >>> 8; - } - + for (var _t10 = 0; _t10 < i; _t10++) n = pi[255 & (n ^ e[_t10])] ^ n >>> 8; return n; }(0, t, e) ^ gi) >>> 0; } - var mi, ki, yi, vi; !function (t) { t[t.UNKNOWN = -1] = "UNKNOWN", t[t.GREYSCALE = 0] = "GREYSCALE", t[t.TRUECOLOUR = 2] = "TRUECOLOUR", t[t.INDEXED_COLOUR = 3] = "INDEXED_COLOUR", t[t.GREYSCALE_ALPHA = 4] = "GREYSCALE_ALPHA", t[t.TRUECOLOUR_ALPHA = 6] = "TRUECOLOUR_ALPHA"; @@ -7656,102 +6892,77 @@ t[t.UNKNOWN = -1] = "UNKNOWN", t[t.NO_INTERLACE = 0] = "NO_INTERLACE", t[t.ADAM7 = 1] = "ADAM7"; }(vi || (vi = {})); var Ei = new Uint8Array(0), - Ai = new Uint16Array([255]), - xi = 255 === new Uint8Array(Ai.buffer)[0]; - - var Ui = function (_r5) { - _inherits(Ui, _r5); - - var _super = _createSuper(Ui); - + Ai = new Uint16Array([255]), + xi = 255 === new Uint8Array(Ai.buffer)[0]; + var Ui = function (_r5) { function Ui(t) { - var _this; - + var _this2; var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - _classCallCheck(this, Ui); - - _this = _super.call(this, t); + _this2 = _callSuper(this, Ui, [t]); var _e$checkCrc = e.checkCrc, - i = _e$checkCrc === void 0 ? !1 : _e$checkCrc; - _this._checkCrc = i, _this._inflator = new ci(), _this._png = { + i = _e$checkCrc === void 0 ? !1 : _e$checkCrc; + _this2._checkCrc = i, _this2._inflator = new ci(), _this2._png = { width: -1, height: -1, channels: -1, data: new Uint8Array(0), depth: 1, text: {} - }, _this._end = !1, _this._hasPalette = !1, _this._palette = [], _this._compressionMethod = ki.UNKNOWN, _this._filterMethod = yi.UNKNOWN, _this._interlaceMethod = vi.UNKNOWN, _this._colorType = -1, _this.setBigEndian(); - return _this; + }, _this2._end = !1, _this2._hasPalette = !1, _this2._palette = [], _this2._compressionMethod = ki.UNKNOWN, _this2._filterMethod = yi.UNKNOWN, _this2._interlaceMethod = vi.UNKNOWN, _this2._colorType = -1, _this2.setBigEndian(); + return _this2; } - - _createClass(Ui, [{ + _inherits(Ui, _r5); + return _createClass(Ui, [{ key: "decode", value: function decode() { - for (this.decodeSignature(); !this._end;) { - this.decodeChunk(); - } - + for (this.decodeSignature(); !this._end;) this.decodeChunk(); return this.decodeImage(), this._png; } }, { key: "decodeSignature", value: function decodeSignature() { - for (var _t11 = 0; _t11 < wi.length; _t11++) { - if (this.readUint8() !== wi[_t11]) throw new Error("wrong PNG signature. Byte at ".concat(_t11, " should be ").concat(wi[_t11], ".")); - } + for (var _t11 = 0; _t11 < wi.length; _t11++) if (this.readUint8() !== wi[_t11]) throw new Error("wrong PNG signature. Byte at ".concat(_t11, " should be ").concat(wi[_t11], ".")); } }, { key: "decodeChunk", value: function decodeChunk() { var t = this.readUint32(), - e = this.readChars(4), - i = this.offset; - + e = this.readChars(4), + i = this.offset; switch (e) { case "IHDR": this.decodeIHDR(); break; - case "PLTE": this.decodePLTE(t); break; - case "IDAT": this.decodeIDAT(t); break; - case "IEND": this._end = !0; break; - case "tRNS": this.decodetRNS(t); break; - case "iCCP": this.decodeiCCP(t); break; - case "tEXt": this.decodetEXt(t); break; - case "pHYs": this.decodepHYs(); break; - default: this.skip(t); } - if (this.offset - i !== t) throw new Error("Length mismatch while decoding chunk ".concat(e)); - if (this._checkCrc) { var _i10 = this.readUint32(), - _n6 = t + 4, - _r6 = bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - _n6 - 4, _n6), _n6); - + _n6 = t + 4, + _r6 = bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - _n6 - 4, _n6), _n6); if (_r6 !== _i10) throw new Error("CRC mismatch for chunk ".concat(e, ". Expected ").concat(_i10, ", found ").concat(_r6)); } else this.skip(4); } @@ -7765,32 +6976,25 @@ }(this.readUint8()); var e = this.readUint8(); var i; - switch (this._colorType = e, e) { case mi.GREYSCALE: i = 1; break; - case mi.TRUECOLOUR: i = 3; break; - case mi.INDEXED_COLOUR: i = 1; break; - case mi.GREYSCALE_ALPHA: i = 2; break; - case mi.TRUECOLOUR_ALPHA: i = 4; break; - default: throw new Error("Unknown color type: ".concat(e)); } - if (this._png.channels = i, this._compressionMethod = this.readUint8(), this._compressionMethod !== ki.DEFLATE) throw new Error("Unsupported compression method: ".concat(this._compressionMethod)); this._filterMethod = this.readUint8(), this._interlaceMethod = this.readUint8(); } @@ -7802,10 +7006,7 @@ this._hasPalette = !0; var i = []; this._palette = i; - - for (var _t12 = 0; _t12 < e; _t12++) { - i.push([this.readUint8(), this.readUint8(), this.readUint8()]); - } + for (var _t12 = 0; _t12 < e; _t12++) i.push([this.readUint8(), this.readUint8(), this.readUint8()]); } }, { key: "decodeIDAT", @@ -7818,28 +7019,19 @@ if (3 === this._colorType) { if (t > this._palette.length) throw new Error("tRNS chunk contains more alpha values than there are palette colors (".concat(t, " vs ").concat(this._palette.length, ")")); var _e19 = 0; - for (; _e19 < t; _e19++) { var _t13 = this.readByte(); - this._palette[_e19].push(_t13); } - - for (; _e19 < this._palette.length; _e19++) { - this._palette[_e19].push(255); - } + for (; _e19 < this._palette.length; _e19++) this._palette[_e19].push(255); } } }, { key: "decodeiCCP", value: function decodeiCCP(t) { var e, - i = ""; - - for (; "\0" !== (e = this.readChar());) { - i += e; - } - + i = ""; + for (; "\0" !== (e = this.readChar());) i += e; var n = this.readUint8(); if (n !== ki.DEFLATE) throw new Error("Unsupported iCCP compression method: ".concat(n)); var r = this.readBytes(t - i.length - 2); @@ -7852,20 +7044,16 @@ key: "decodetEXt", value: function decodetEXt(t) { var e, - i = ""; - - for (; "\0" !== (e = this.readChar());) { - i += e; - } - + i = ""; + for (; "\0" !== (e = this.readChar());) i += e; this._png.text[i] = this.readChars(t - i.length - 1); } }, { key: "decodepHYs", value: function decodepHYs() { var t = this.readUint32(), - e = this.readUint32(), - i = this.readByte(); + e = this.readUint32(), + i = this.readByte(); this._png.resolution = { x: t, y: e, @@ -7885,159 +7073,96 @@ key: "decodeInterlaceNull", value: function decodeInterlaceNull(t) { var e = this._png.height, - i = this._png.channels * this._png.depth / 8, - n = this._png.width * i, - r = new Uint8Array(this._png.height * n); + i = this._png.channels * this._png.depth / 8, + n = this._png.width * i, + r = new Uint8Array(this._png.height * n); var s, - a, - o = Ei, - h = 0; - + a, + o = Ei, + h = 0; for (var _l = 0; _l < e; _l++) { switch (s = t.subarray(h + 1, h + 1 + n), a = r.subarray(_l * n, (_l + 1) * n), t[h]) { case 0: zi(s, a, n); break; - case 1: Ri(s, a, n, i); break; - case 2: Ni(s, a, o, n); break; - case 3: Ti(s, a, o, n, i); break; - case 4: Oi(s, a, o, n, i); break; - default: throw new Error("Unsupported filter: ".concat(t[h])); } - o = a, h += n + 1; } - if (this._hasPalette && (this._png.palette = this._palette), 16 === this._png.depth) { var _t14 = new Uint16Array(r.buffer); - - if (xi) for (var _e20 = 0; _e20 < _t14.length; _e20++) { - _t14[_e20] = (255 & (l = _t14[_e20])) << 8 | l >> 8 & 255; - } + if (xi) for (var _e20 = 0; _e20 < _t14.length; _e20++) _t14[_e20] = (255 & (l = _t14[_e20])) << 8 | l >> 8 & 255; this._png.data = _t14; } else this._png.data = r; - var l; } }]); - - return Ui; }(r); - function zi(t, e, i) { - for (var _n7 = 0; _n7 < i; _n7++) { - e[_n7] = t[_n7]; - } + for (var _n7 = 0; _n7 < i; _n7++) e[_n7] = t[_n7]; } - function Ri(t, e, i, n) { var r = 0; - - for (; r < n; r++) { - e[r] = t[r]; - } - - for (; r < i; r++) { - e[r] = t[r] + e[r - n] & 255; - } + for (; r < n; r++) e[r] = t[r]; + for (; r < i; r++) e[r] = t[r] + e[r - n] & 255; } - function Ni(t, e, i, n) { var r = 0; - if (0 === i.length) for (; r < n; r++) { - e[r] = t[r]; - } else for (; r < n; r++) { - e[r] = t[r] + i[r] & 255; - } + if (0 === i.length) for (; r < n; r++) e[r] = t[r];else for (; r < n; r++) e[r] = t[r] + i[r] & 255; } - function Ti(t, e, i, n, r) { var s = 0; - if (0 === i.length) { - for (; s < r; s++) { - e[s] = t[s]; - } - - for (; s < n; s++) { - e[s] = t[s] + (e[s - r] >> 1) & 255; - } + for (; s < r; s++) e[s] = t[s]; + for (; s < n; s++) e[s] = t[s] + (e[s - r] >> 1) & 255; } else { - for (; s < r; s++) { - e[s] = t[s] + (i[s] >> 1) & 255; - } - - for (; s < n; s++) { - e[s] = t[s] + (e[s - r] + i[s] >> 1) & 255; - } + for (; s < r; s++) e[s] = t[s] + (i[s] >> 1) & 255; + for (; s < n; s++) e[s] = t[s] + (e[s - r] + i[s] >> 1) & 255; } } - function Oi(t, e, i, n, r) { var s = 0; - if (0 === i.length) { - for (; s < r; s++) { - e[s] = t[s]; - } - - for (; s < n; s++) { - e[s] = t[s] + e[s - r] & 255; - } + for (; s < r; s++) e[s] = t[s]; + for (; s < n; s++) e[s] = t[s] + e[s - r] & 255; } else { - for (; s < r; s++) { - e[s] = t[s] + i[s] & 255; - } - - for (; s < n; s++) { - e[s] = t[s] + Li(e[s - r], i[s], i[s - r]) & 255; - } + for (; s < r; s++) e[s] = t[s] + i[s] & 255; + for (; s < n; s++) e[s] = t[s] + Li(e[s - r], i[s], i[s - r]) & 255; } } - function Li(t, e, i) { var n = t + e - i, - r = Math.abs(n - t), - s = Math.abs(n - e), - a = Math.abs(n - i); + r = Math.abs(n - t), + s = Math.abs(n - e), + a = Math.abs(n - i); return r <= s && r <= a ? t : s <= a ? e : i; } - var Bi = { level: 3 }; - var Ci = function (_r7) { - _inherits(Ci, _r7); - - var _super2 = _createSuper(Ci); - function Ci(t) { - var _this2; - + var _this3; var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - _classCallCheck(this, Ci); - - _this2 = _super2.call(this), _this2._colorType = mi.UNKNOWN, _this2._zlibOptions = _objectSpread2(_objectSpread2({}, Bi), e.zlib), _this2._png = _this2._checkData(t), _this2.setBigEndian(); - return _this2; + _this3 = _callSuper(this, Ci), _this3._colorType = mi.UNKNOWN, _this3._zlibOptions = _objectSpread2(_objectSpread2({}, Bi), e.zlib), _this3._png = _this3._checkData(t), _this3.setBigEndian(); + return _this3; } - - _createClass(Ci, [{ + _inherits(Ci, _r7); + return _createClass(Ci, [{ key: "encode", value: function encode() { return this.encodeSignature(), this.encodeIHDR(), this.encodeData(), this.encodeIEND(), this.toArray(); @@ -8066,77 +7191,66 @@ key: "encodeData", value: function encodeData() { var _this$_png = this._png, - t = _this$_png.width, - e = _this$_png.height, - i = _this$_png.channels, - n = _this$_png.depth, - s = _this$_png.data, - a = i * t, - o = new r().setBigEndian(); + t = _this$_png.width, + e = _this$_png.height, + i = _this$_png.channels, + n = _this$_png.depth, + s = _this$_png.data, + a = i * t, + o = new r().setBigEndian(); var h = 0; - - for (var _t15 = 0; _t15 < e; _t15++) { - if (o.writeByte(0), 8 === n) h = Ii(s, o, a, h);else { - if (16 !== n) throw new Error("unreachable"); - h = Si(s, o, a, h); - } + for (var _t15 = 0; _t15 < e; _t15++) if (o.writeByte(0), 8 === n) h = Ii(s, o, a, h);else { + if (16 !== n) throw new Error("unreachable"); + h = Si(s, o, a, h); } - var l = o.toArray(), - d = fi(l, this._zlibOptions); + d = fi(l, this._zlibOptions); this.encodeIDAT(d); } }, { key: "_checkData", value: function _checkData(t) { var _ref = function (t) { - var _t$channels = t.channels, + var _t$channels = t.channels, e = _t$channels === void 0 ? 4 : _t$channels, _t$depth = t.depth, i = _t$depth === void 0 ? 8 : _t$depth; - if (4 !== e && 3 !== e && 2 !== e && 1 !== e) throw new RangeError("unsupported number of channels: ".concat(e)); - if (8 !== i && 16 !== i) throw new RangeError("unsupported bit depth: ".concat(i)); - var n = { - channels: e, - depth: i, - colorType: mi.UNKNOWN + if (4 !== e && 3 !== e && 2 !== e && 1 !== e) throw new RangeError("unsupported number of channels: ".concat(e)); + if (8 !== i && 16 !== i) throw new RangeError("unsupported bit depth: ".concat(i)); + var n = { + channels: e, + depth: i, + colorType: mi.UNKNOWN + }; + switch (e) { + case 4: + n.colorType = mi.TRUECOLOUR_ALPHA; + break; + case 3: + n.colorType = mi.TRUECOLOUR; + break; + case 1: + n.colorType = mi.GREYSCALE; + break; + case 2: + n.colorType = mi.GREYSCALE_ALPHA; + break; + default: + throw new Error("unsupported number of channels"); + } + return n; + }(t), + e = _ref.colorType, + i = _ref.channels, + n = _ref.depth, + r = { + width: Di(t.width, "width"), + height: Di(t.height, "height"), + channels: i, + data: t.data, + depth: n, + text: {} }; - - switch (e) { - case 4: - n.colorType = mi.TRUECOLOUR_ALPHA; - break; - - case 3: - n.colorType = mi.TRUECOLOUR; - break; - - case 1: - n.colorType = mi.GREYSCALE; - break; - - case 2: - n.colorType = mi.GREYSCALE_ALPHA; - break; - - default: - throw new Error("unsupported number of channels"); - } - - return n; - }(t), - e = _ref.colorType, - i = _ref.channels, - n = _ref.depth, - r = { - width: Di(t.width, "width"), - height: Di(t.height, "height"), - channels: i, - data: t.data, - depth: n, - text: {} - }; - this._colorType = e; var s = r.width * r.height * i; if (r.data.length !== s) throw new RangeError("wrong data size. Found ".concat(r.data.length, ", expected ").concat(s)); @@ -8148,61 +7262,45 @@ this.writeUint32(bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - t, t), t)); } }]); - - return Ci; }(r); - function Di(t, e) { if (Number.isInteger(t) && t > 0) return t; throw new TypeError("".concat(e, " must be a positive integer")); } - function Ii(t, e, i, n) { - for (var _r8 = 0; _r8 < i; _r8++) { - e.writeByte(t[n++]); - } - + for (var _r8 = 0; _r8 < i; _r8++) e.writeByte(t[n++]); return n; } - function Si(t, e, i, n) { - for (var _r9 = 0; _r9 < i; _r9++) { - e.writeUint16(t[n++]); - } - + for (var _r9 = 0; _r9 < i; _r9++) e.writeUint16(t[n++]); return n; } - var Zi; !function (t) { t[t.UNKNOWN = 0] = "UNKNOWN", t[t.METRE = 1] = "METRE"; }(Zi || (Zi = {})); - var Fi = function Fi(t, e, i) { - return new Ci({ - width: t, - height: e, - data: i - }, undefined).encode(); - }, - Mi = function Mi(t) { - return function (t, e) { - return new Ui(t, void 0).decode(); - }(t); - }; + return new Ci({ + width: t, + height: e, + data: i + }, undefined).encode(); + }, + Mi = function Mi(t) { + return function (t, e) { + return new Ui(t, void 0).decode(); + }(t); + }; })(); - var r = n.P, - s = n.m; + s = n.m; function isTypeObject(object) { return object && object.hasOwnProperty('type') && object.hasOwnProperty('data'); } - function stringify(o, gap, indentation) { if (isTypeObject(o)) { var s = stringify(o.data, gap, indentation); - if (__includes(s, '\n')) { return ' #!' + o.type + s; } else { @@ -8210,17 +7308,13 @@ } } else if (o && 'object' === _typeof(o)) { var isArray = Array.isArray(o); - if (Object.keys(o).length == 0) { if (isArray) return '[]';else return '{}'; } - var _s = '\n'; - for (var k in o) { if (Object.hasOwnProperty.call(o, k)) { _s += __repeatConcat(gap, indentation + 1); - if (isArray) { _s += '- ' + stringify(o[k], gap, indentation + 1); } else { @@ -8231,11 +7325,9 @@ _s += k + ': ' + stringify(o[k], gap, indentation + 1); } } - _s += '\n'; } } - return _s; } else if ('string' === typeof o) { return JSON.stringify(o); @@ -8247,41 +7339,32 @@ throw new Error('Non-implemented parsing for ' + o); } } - function preStringify(object) { var space = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4; var gap = ''; - if (typeof space == 'number') { gap = __repeatConcat(' ', Math.min(10, space)); } else if (typeof space == 'string') { gap = space.slice(0, 10); } - return stringify(object, gap, -1); } - var LineGenerator = function () { function LineGenerator(lines, indentString, startingLine) { _classCallCheck(this, LineGenerator); - this.startingLine = startingLine || 0; this.lineIndex = -1; var filteredLines = []; - for (var i = 0; i < lines.length; i++) { var trimmedLine = lines[i].trim(); - if (trimmedLine !== '') { filteredLines.push([lines[i], i]); } } - this.lines = filteredLines; this.indentString = indentString || this.findIndentString(); } - - _createClass(LineGenerator, [{ + return _createClass(LineGenerator, [{ key: "getLineNumber", value: function getLineNumber() { return this.startingLine + this.lineIndex; @@ -8291,11 +7374,9 @@ value: function nextGroup() { var lines = []; var baseIndent = this.indentLevel(this.lineIndex + 1); - while (!this.finished() && this.indentLevel(this.lineIndex + 1) >= baseIndent) { lines.push(this.next()); } - return new LineGenerator(lines, this.indentString, this.getLineNumber() - lines.length); } }, { @@ -8327,11 +7408,10 @@ value: function findIndentString() { for (var _i2 = 0, _this$lines2 = this.lines; _i2 < _this$lines2.length; _i2++) { var _this$lines2$_i = _this$lines2[_i2], - line = _this$lines2$_i[0]; + line = _this$lines2$_i[0]; if (!line.trim() || line.replace(/^\s+/, "") == line) continue; return line.match(/^(\s+)/)[1]; } - return ''; } }, { @@ -8341,42 +7421,32 @@ if (index < 0) index = 0; var indentLevel = 0; var line = this.getLine(index); - while (__startsWithString(line, this.indentString)) { line = line.slice(this.indentString.length); indentLevel++; } - return indentLevel; } }]); - - return LineGenerator; }(); - function getObject(lineGroup, type) { var object; lineGroup.indentLevel(); - while (!lineGroup.finished()) { var line = lineGroup.next(); var trimmedLine = line.trim(); var keyMatch = trimmedLine.match(/^(.*?):(?: |$)/); var typeMatch = trimmedLine.match(/#!([\w<,>]+)/); - var key = void 0, - value = void 0, - _type = void 0; - + value = void 0, + _type = void 0; if (__startsWithString(trimmedLine, '"')) { keyMatch = trimmedLine.match(/^"(.*?)":(?: |$)/); } - if (typeMatch) { _type = typeMatch[1]; trimmedLine = trimmedLine.replace(typeMatch[0], ''); } - if (keyMatch) { if (!object) object = {}; key = keyMatch[1]; @@ -8385,43 +7455,35 @@ if (!object) object = []; value = trimmedLine.slice(1).trim(); } - if (value) { value = getValue(value, _type); } else { value = getObject(lineGroup.nextGroup(), _type); } - if (Array.isArray(object)) { object.push(value); } else { object[key] = value; } } - if (type) { object = { type: type, data: object }; } - return object; } - function getValue(value, type) { value = JSON.parse(value); - if (type) { value = { type: type, data: value }; } - return value; } - function parse(str) { var lines = str.replace(/\t/g, ' ').split('\n'); var lineGenerator = new LineGenerator(lines); @@ -8430,35 +7492,26 @@ function deepCopy(obj) { var newObj; - if (Array.isArray(obj)) { newObj = []; - for (var _i2 = 0; _i2 < obj.length; _i2++) { var item = obj[_i2]; newObj.push(deepCopy(item)); } - return newObj; } - if (!!obj && _typeof(obj) === "object") { newObj = {}; - var __keys = Object.keys(obj); - for (var __i = 0; __i < __keys.length; __i++) { var key = __keys[__i], - value = obj[key]; + value = obj[key]; newObj[key] = deepCopy(value); } - return newObj; } - return obj; } - function isPrimitiveReaderType(reader) { switch (reader) { case 'Boolean': @@ -8474,13 +7527,12 @@ case 'Vector4': case 'Rectangle': case 'Rect': + case 'Point': return true; - default: return false; } } - function isExportReaderType(reader) { switch (reader) { case 'Texture2D': @@ -8488,209 +7540,186 @@ case 'Effect': case 'BmFont': return true; - default: return false; } } - function convertJsonContentsToXnbNode(raw, readers) { var extractedImages = []; var extractedMaps = []; - var _recursiveConvert = function recursiveConvert(obj, path) { - var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var reader = readers[index]; - - if (isPrimitiveReaderType(reader)) { - return { - converted: { - type: reader, - data: obj - }, - traversed: index - }; - } - - if (reader === null) { - return { - converted: obj, - traversed: index - }; - } - - if (__startsWithString(reader, 'Nullable')) { - var nullableData, trav; - - var _reader$split = reader.split(":"), - readerType = _reader$split[0], + var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; + var reader = readers[index]; + if (isPrimitiveReaderType(reader)) { + return { + converted: { + type: reader, + data: obj + }, + traversed: index + }; + } + if (reader === null) { + return { + converted: obj, + traversed: index + }; + } + if (__startsWithString(reader, 'Nullable')) { + var nullableData, trav; + var _reader$split = reader.split(":"), + _readerType = _reader$split[0], _reader$split$ = _reader$split[1], blockTraversed = _reader$split$ === void 0 ? 1 : _reader$split$; - - blockTraversed = +blockTraversed; - - if (obj === null) { - nullableData = null; - trav = index + blockTraversed; - } else if (_typeof(obj) === "object" && (!obj || Object.keys(obj).length === 0)) { - nullableData = { - type: readers[index + 1], - data: deepCopy(obj) - }; - trav = index + blockTraversed; - } else { - var _recursiveConvert2 = recursiveConvert(obj, [].concat(path), index + 1), + blockTraversed = +blockTraversed; + if (obj === null) { + nullableData = null; + trav = index + blockTraversed; + } else if (_typeof(obj) === "object" && (!obj || Object.keys(obj).length === 0)) { + nullableData = { + type: readers[index + 1], + data: deepCopy(obj) + }; + trav = index + blockTraversed; + } else { + var _recursiveConvert2 = recursiveConvert(obj, [].concat(path), index + 1), _converted = _recursiveConvert2.converted, _traversed = _recursiveConvert2.traversed; - - nullableData = _converted; - trav = _traversed; - } - - return { - converted: { - type: readerType, - data: { - data: nullableData - } - }, - traversed: trav - }; - } - - if (isExportReaderType(reader)) { - if (reader === 'Texture2D') { - extractedImages.push({ - path: path.join('.') - }); + nullableData = _converted; + trav = _traversed; + } return { converted: { - type: reader, + type: _readerType, data: { - format: obj.format + data: nullableData } }, - traversed: index + traversed: trav }; } - - if (reader === 'TBin') { - extractedMaps.push({ - path: path.join('.') - }); + if (isExportReaderType(reader)) { + if (reader === 'Texture2D') { + extractedImages.push({ + path: path.join('.') + }); + return { + converted: { + type: reader, + data: { + format: obj.format + } + }, + traversed: index + }; + } + if (reader === 'TBin') { + extractedMaps.push({ + path: path.join('.') + }); + } + return { + converted: { + type: reader, + data: {} + }, + traversed: index + }; } - - return { - converted: { - type: reader, - data: {} - }, - traversed: index - }; - } - - var data; - if (Array.isArray(obj)) data = [];else data = {}; - var traversed = index; - var first = true; - var isComplex = !__startsWithString(reader, "Dictionary") && !__startsWithString(reader, "Array") && !__startsWithString(reader, "List"); - - var __keys = Object.keys(obj); - - for (var __i = 0; __i < __keys.length; __i++) { - var key = __keys[__i]; + var data; + if (Array.isArray(obj)) data = [];else data = {}; + var traversed = index; + var first = true; + var isComplex = !__startsWithString(reader, "Dictionary") && !__startsWithString(reader, "Array") && !__startsWithString(reader, "List"); + var _reader$split2 = reader.split(":"), + readerType = _reader$split2[0], + _reader$split2$ = _reader$split2[1], + complexBlockTraversed = _reader$split2$ === void 0 ? 1 : _reader$split2$; + if (Object.keys(obj).length === 0) { + return { + converted: { + type: readerType, + data: data + }, + traversed: index + +complexBlockTraversed + }; + } + var __keys = Object.keys(obj); + for (var __i = 0; __i < __keys.length; __i++) { + var key = __keys[__i]; obj[key]; - var newIndex = void 0; - if (__startsWithString(reader, "Dictionary")) newIndex = index + 2;else if (__startsWithString(reader, "Array") || __startsWithString(reader, "List")) newIndex = index + 1;else newIndex = traversed + 1; - - var _recursiveConvert3 = recursiveConvert(obj[key], [].concat(path, [key]), newIndex), + var newIndex = void 0; + if (__startsWithString(readerType, "Dictionary")) newIndex = index + 2;else if (__startsWithString(readerType, "Array") || __startsWithString(readerType, "List")) newIndex = index + 1;else newIndex = traversed + 1; + var _recursiveConvert3 = recursiveConvert(obj[key], [].concat(path, [key]), newIndex), _converted2 = _recursiveConvert3.converted, nexter = _recursiveConvert3.traversed; - - data[key] = _converted2; - if (isComplex) traversed = nexter;else if (first) { - traversed = nexter; - first = false; + data[key] = _converted2; + if (isComplex) traversed = nexter;else if (first) { + traversed = nexter; + first = false; + } } - } - - return { - converted: { - type: reader, - data: data - }, - traversed: traversed - }; - }(raw, []), - converted = _recursiveConvert.converted; - + return { + converted: { + type: readerType, + data: data + }, + traversed: traversed + }; + }(raw, []), + converted = _recursiveConvert.converted; return { converted: converted, extractedImages: extractedImages, extractedMaps: extractedMaps }; } - function convertJsonContentsFromXnbNode(obj) { if (!obj || _typeof(obj) !== "object") return obj; - if (_typeof(obj) === "object" && obj.hasOwnProperty("data")) { var _obj = obj, - type = _obj.type, - data = _obj.data; + type = _obj.type, + data = _obj.data; if (isPrimitiveReaderType(type)) return deepCopy(data); - if (isExportReaderType(type)) { data = deepCopy(data); if (type === "Texture2D") data.export = "Texture2D.png";else if (type === "Effect") data.export = "Effect.cso";else if (type === "TBin") data.export = "TBin.tbin";else if (type === "BmFont") data.export = "BmFont.xml"; return data; } - if (__startsWithString(type, "Nullable")) { if (data === null || data.data === null) return null; return convertJsonContentsFromXnbNode(data.data); } - obj = deepCopy(data); } - var newObj; - if (Array.isArray(obj)) { newObj = []; - for (var _i4 = 0, _obj3 = obj; _i4 < _obj3.length; _i4++) { var item = _obj3[_i4]; newObj.push(convertJsonContentsFromXnbNode(item)); } - return newObj; } - if (!!obj && _typeof(obj) === "object") { newObj = {}; - var __keys = Object.keys(obj); - for (var __i = 0; __i < __keys.length; __i++) { var key = __keys[__i], - value = obj[key]; + value = obj[key]; newObj[key] = convertJsonContentsFromXnbNode(value); } - return newObj; } - return null; } - function toXnbNodeData(json) { var toYamlJson = {}; var _json$header = json.header, - compressed = _json$header.compressed; - _json$header.formatVersion; - var hiDef = _json$header.hidef, - target = _json$header.target; + compressed = _json$header.compressed; + _json$header.formatVersion; + var hiDef = _json$header.hidef, + target = _json$header.target; var readerData = deepCopy(json.readers); toYamlJson.xnbData = { target: target, @@ -8702,31 +7731,27 @@ var rawContent = deepCopy(json.content); var mainReader = TypeReader.simplifyType(readerData[0].type); var readersTypeList = TypeReader.getReaderTypeList(mainReader); - if (readersTypeList[0] === 'SpriteFont') { readersTypeList = ['SpriteFont', 'Texture2D', 'List', 'Rectangle', 'List', 'Rectangle', 'List', 'Char', null, 'List', 'Vector3', 'Nullable', 'Char', null]; rawContent.verticalSpacing = rawContent.verticalLineSpacing; delete rawContent.verticalLineSpacing; } - var _convertJsonContentsT = convertJsonContentsToXnbNode(rawContent, readersTypeList), - converted = _convertJsonContentsT.converted, - extractedImages = _convertJsonContentsT.extractedImages, - extractedMaps = _convertJsonContentsT.extractedMaps; - + converted = _convertJsonContentsT.converted, + extractedImages = _convertJsonContentsT.extractedImages, + extractedMaps = _convertJsonContentsT.extractedMaps; toYamlJson.content = converted; if (extractedImages.length > 0) toYamlJson.extractedImages = extractedImages; if (extractedMaps.length > 0) toYamlJson.extractedMaps = extractedMaps; return toYamlJson; } - function fromXnbNodeData(json) { var result = {}; var _json$xnbData = json.xnbData, - compressed = _json$xnbData.compressed, - readerData = _json$xnbData.readerData, - hidef = _json$xnbData.hiDef, - target = _json$xnbData.target; + compressed = _json$xnbData.compressed, + readerData = _json$xnbData.readerData, + hidef = _json$xnbData.hiDef, + target = _json$xnbData.target; result.header = { target: target, formatVersion: 5, @@ -8735,91 +7760,69 @@ }; result.readers = deepCopy(readerData); result.content = convertJsonContentsFromXnbNode(json.content); - if (TypeReader.simplifyType(result.readers[0].type) === 'SpriteFont') { result.content.verticalLineSpacing = result.content.verticalSpacing; delete result.content.verticalSpacing; } - return result; } function searchElement(parent, element) { if (!parent || _typeof(parent) != 'object') return; - if (parent.hasOwnProperty(element)) { return { parent: parent, value: parent[element] }; } - var __keys = Object.keys(parent); - for (var __i = 0; __i < __keys.length; __i++) { var __key = __keys[__i], - child = parent[__key]; - + child = parent[__key]; if (!!child || _typeof(child) == 'object') { var found = searchElement(child, element); if (found) return found; } } - return null; } - function extractFileName(fullname) { var matcher = fullname.match(/(.*)\.([^\s.]+)$/); if (matcher === null) return [fullname, null]; return [matcher[1], matcher[2]]; } - function getExtension(dataType) { switch (dataType) { case "JSON": return "json"; - case "yaml": return "yaml"; - case "Texture2D": return "png"; - case "Effect": return "cso"; - case 'TBin': return "tbin"; - case 'BmFont': return "xml"; } - return "bin"; } - function getMimeType(dataType) { switch (dataType) { case "JSON": return "application/json"; - case "yaml": return "text/plain"; - case "Texture2D": return "image/png"; - case "Effect": return "application/x-cso"; - case 'BmFont': return "application/xml"; } - return "application/octet-stream"; } - function makeBlob(data, dataType) { if (typeof Blob === "function") return { data: new Blob([data], { @@ -8832,30 +7835,25 @@ extension: getExtension(dataType) }; } - function exportContent(content) { var jsonContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var found = searchElement(content, "export"); - if (found) { var value = found.value; var dataType = value.type, - data = value.data; - + data = value.data; if (dataType === "Texture2D") { data = s(value.width, value.height, new Uint8Array(data)); } - return makeBlob(data, dataType); } - if (jsonContent) { var contentJson = JSON.stringify(content, null, 4); return makeBlob(contentJson, "JSON"); } - return null; } + /** @api * decompressed xnb object to real file blobs. * @param {XnbData} decompressed xnb objects (returned by bufferToXnb() / Xnb.load()) @@ -8863,17 +7861,14 @@ * contentOnly:export content file only, * fileName:exported files's name) (optional) */ - - function exportFiles(xnbObject) { var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref$yaml = _ref.yaml, - isYaml = _ref$yaml === void 0 ? false : _ref$yaml, - _ref$contentOnly = _ref.contentOnly, - contentOnly = _ref$contentOnly === void 0 ? false : _ref$contentOnly, - _ref$fileName = _ref.fileName, - fileName = _ref$fileName === void 0 ? null : _ref$fileName; - + _ref$yaml = _ref.yaml, + isYaml = _ref$yaml === void 0 ? false : _ref$yaml, + _ref$contentOnly = _ref.contentOnly, + contentOnly = _ref$contentOnly === void 0 ? false : _ref$contentOnly, + _ref$fileName = _ref.fileName, + fileName = _ref$fileName === void 0 ? null : _ref$fileName; if (isYaml && contentOnly) isYaml = false; if (!xnbObject.hasOwnProperty('content')) throw new XnbError('Invalid object!'); var blobs = []; @@ -8886,10 +7881,8 @@ if (typeof fileName == "string" && fileName !== "") { return "".concat(fileName, ".").concat(getExtension(value.type)); } - return "".concat(value.type, ".").concat(getExtension(value.type)); } - return value; }, 4); var result = resultJSON; @@ -8897,268 +7890,213 @@ blobs.unshift(makeBlob(result, isYaml ? "yaml" : "JSON")); return blobs; } - function resolveCompression(compressionString) { var str = compressionString.toLowerCase(); if (str === "none") return 0; if (str === "lz4") return 0x40; return null; } - function readBlobasText(_x) { return _readBlobasText.apply(this, arguments); } - function _readBlobasText() { _readBlobasText = _asyncToGenerator(regeneratorRuntime.mark(function _callee(blob) { return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - if (!(typeof Blob === "function" && blob instanceof Blob)) { - _context.next = 4; - break; - } - - return _context.abrupt("return", blob.text()); - - case 4: - if (!(typeof Buffer === "function" && blob instanceof Buffer)) { - _context.next = 8; - break; - } - - return _context.abrupt("return", blob.toString()); - - case 8: - return _context.abrupt("return", blob); - - case 9: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + if (!(typeof Blob === "function" && blob instanceof Blob)) { + _context.next = 4; + break; + } + return _context.abrupt("return", blob.text()); + case 4: + if (!(typeof Buffer === "function" && blob instanceof Buffer)) { + _context.next = 8; + break; + } + return _context.abrupt("return", blob.toString()); + case 8: + return _context.abrupt("return", blob); + case 9: + case "end": + return _context.stop(); } }, _callee); })); return _readBlobasText.apply(this, arguments); } - function readBlobasArrayBuffer(_x2) { return _readBlobasArrayBuffer.apply(this, arguments); } - function _readBlobasArrayBuffer() { _readBlobasArrayBuffer = _asyncToGenerator(regeneratorRuntime.mark(function _callee2(blob) { return regeneratorRuntime.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - if (!(typeof Blob === "function" && blob instanceof Blob)) { - _context2.next = 4; - break; - } - - return _context2.abrupt("return", blob.arrayBuffer()); - - case 4: - if (!(typeof Buffer === "function" && blob instanceof Buffer)) { - _context2.next = 6; - break; - } - - return _context2.abrupt("return", blob.buffer); - - case 6: - case "end": - return _context2.stop(); - } + while (1) switch (_context2.prev = _context2.next) { + case 0: + if (!(typeof Blob === "function" && blob instanceof Blob)) { + _context2.next = 4; + break; + } + return _context2.abrupt("return", blob.arrayBuffer()); + case 4: + if (!(typeof Buffer === "function" && blob instanceof Buffer)) { + _context2.next = 6; + break; + } + return _context2.abrupt("return", blob.buffer); + case 6: + case "end": + return _context2.stop(); } }, _callee2); })); return _readBlobasArrayBuffer.apply(this, arguments); } - function readExternFiles(_x3, _x4) { return _readExternFiles.apply(this, arguments); } - function _readExternFiles() { _readExternFiles = _asyncToGenerator(regeneratorRuntime.mark(function _callee3(extension, files) { var rawPng, png, data, _data, _data2; - return regeneratorRuntime.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - if (!(extension === "png")) { - _context3.next = 7; - break; - } - - _context3.next = 3; - return readBlobasArrayBuffer(files.png); - - case 3: - rawPng = _context3.sent; - png = r(new Uint8Array(rawPng)); - if (png.channel !== 4 || png.depth !== 8 || png.palette !== undefined) png.data = fixPNG(png); - return _context3.abrupt("return", { - type: "Texture2D", - data: png.data, - width: png.width, - height: png.height - }); - - case 7: - if (!(extension === "cso")) { - _context3.next = 12; - break; - } - - _context3.next = 10; - return readBlobasArrayBuffer(files.cso); - - case 10: - data = _context3.sent; - return _context3.abrupt("return", { - type: "Effect", - data: data - }); - - case 12: - if (!(extension === "tbin")) { - _context3.next = 17; - break; - } - - _context3.next = 15; - return readBlobasArrayBuffer(files.tbin); - - case 15: - _data = _context3.sent; - return _context3.abrupt("return", { - type: "TBin", - data: _data - }); - - case 17: - if (!(extension === "xml")) { - _context3.next = 22; - break; - } - - _context3.next = 20; - return readBlobasText(files.xml); - - case 20: - _data2 = _context3.sent; - return _context3.abrupt("return", { - type: "BmFont", - data: _data2 - }); - - case 22: - case "end": - return _context3.stop(); - } + while (1) switch (_context3.prev = _context3.next) { + case 0: + if (!(extension === "png")) { + _context3.next = 7; + break; + } + _context3.next = 3; + return readBlobasArrayBuffer(files.png); + case 3: + rawPng = _context3.sent; + png = r(new Uint8Array(rawPng)); + if (png.channel !== 4 || png.depth !== 8 || png.palette !== undefined) png.data = fixPNG(png); + return _context3.abrupt("return", { + type: "Texture2D", + data: png.data, + width: png.width, + height: png.height + }); + case 7: + if (!(extension === "cso")) { + _context3.next = 12; + break; + } + _context3.next = 10; + return readBlobasArrayBuffer(files.cso); + case 10: + data = _context3.sent; + return _context3.abrupt("return", { + type: "Effect", + data: data + }); + case 12: + if (!(extension === "tbin")) { + _context3.next = 17; + break; + } + _context3.next = 15; + return readBlobasArrayBuffer(files.tbin); + case 15: + _data = _context3.sent; + return _context3.abrupt("return", { + type: "TBin", + data: _data + }); + case 17: + if (!(extension === "xml")) { + _context3.next = 22; + break; + } + _context3.next = 20; + return readBlobasText(files.xml); + case 20: + _data2 = _context3.sent; + return _context3.abrupt("return", { + type: "BmFont", + data: _data2 + }); + case 22: + case "end": + return _context3.stop(); } }, _callee3); })); return _readExternFiles.apply(this, arguments); } - function resolveImports(_x5) { return _resolveImports.apply(this, arguments); } - function _resolveImports() { _resolveImports = _asyncToGenerator(regeneratorRuntime.mark(function _callee4(files) { var configs, - _configs$compression, - compression, - jsonFile, - rawText, - jsonData, - compressBits, - found, - parent, - value, - _extractFileName2, - extension, - _args4 = arguments; - + _configs$compression, + compression, + jsonFile, + rawText, + jsonData, + compressBits, + found, + parent, + value, + _extractFileName2, + extension, + _args4 = arguments; return regeneratorRuntime.wrap(function _callee4$(_context4) { - while (1) { - switch (_context4.prev = _context4.next) { - case 0: - configs = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {}; - _configs$compression = configs.compression, compression = _configs$compression === void 0 ? "default" : _configs$compression; - jsonFile = files.json || files.yaml; - - if (jsonFile) { - _context4.next = 5; - break; - } - - throw new XnbError("There is no JSON or YAML file to pack!"); - - case 5: - _context4.next = 7; - return readBlobasText(jsonFile); - - case 7: - rawText = _context4.sent; - jsonData = null; - if (files.json) jsonData = JSON.parse(rawText);else jsonData = fromXnbNodeData(parse(rawText)); - compressBits = resolveCompression(compression); - if (compressBits !== null) jsonData.header.compressed = compressBits; - - if (jsonData.hasOwnProperty('content')) { - _context4.next = 14; - break; - } - - throw new XnbError("".concat(jsonFile.name, " does not have \"content\".")); - - case 14: - found = searchElement(jsonData.content, "export"); - - if (!found) { - _context4.next = 21; - break; - } - - parent = found.parent, value = found.value; - _extractFileName2 = extractFileName(value), extension = _extractFileName2[1]; - _context4.next = 20; - return readExternFiles(extension, files); - - case 20: - parent.export = _context4.sent; - - case 21: - return _context4.abrupt("return", jsonData); - - case 22: - case "end": - return _context4.stop(); - } + while (1) switch (_context4.prev = _context4.next) { + case 0: + configs = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {}; + _configs$compression = configs.compression, compression = _configs$compression === void 0 ? "default" : _configs$compression; + jsonFile = files.json || files.yaml; + if (jsonFile) { + _context4.next = 5; + break; + } + throw new XnbError("There is no JSON or YAML file to pack!"); + case 5: + _context4.next = 7; + return readBlobasText(jsonFile); + case 7: + rawText = _context4.sent; + jsonData = null; + if (files.json) jsonData = JSON.parse(rawText);else jsonData = fromXnbNodeData(parse(rawText)); + compressBits = resolveCompression(compression); + if (compressBits !== null) jsonData.header.compressed = compressBits; + if (jsonData.hasOwnProperty('content')) { + _context4.next = 14; + break; + } + throw new XnbError("".concat(jsonFile.name, " does not have \"content\".")); + case 14: + found = searchElement(jsonData.content, "export"); + if (!found) { + _context4.next = 21; + break; + } + parent = found.parent, value = found.value; + _extractFileName2 = extractFileName(value), extension = _extractFileName2[1]; + _context4.next = 20; + return readExternFiles(extension, files); + case 20: + parent.export = _context4.sent; + case 21: + return _context4.abrupt("return", jsonData); + case 22: + case "end": + return _context4.stop(); } }, _callee4); })); return _resolveImports.apply(this, arguments); } - function getReaderAssembly(extension) { if (extension === "png") return "Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553"; if (extension === "tbin") return "xTile.Pipeline.TideReader, xTile"; if (extension === "xml") return "BmFont.XmlSourceReader, BmFont, Version=2012.1.7.0, Culture=neutral, PublicKeyToken=null"; } - function makeHeader(fileName) { var _extractFileName = extractFileName(fileName), - extension = _extractFileName[1]; - + extension = _extractFileName[1]; var readerType = getReaderAssembly(extension); var content = { export: fileName @@ -9186,7 +8124,6 @@ * @param {File / Buffer} file * @return {XnbData} JSON data with headers */ - function unpackToXnbData(_x) { return _unpackToXnbData.apply(this, arguments); } @@ -9196,54 +8133,42 @@ * @param {File / Buffer} file * @return {XnbContent} exported Content Object */ - - function _unpackToXnbData() { _unpackToXnbData = _asyncToGenerator(regeneratorRuntime.mark(function _callee(file) { var _extractFileName3, extension, buffer; - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - if (!(typeof window !== "undefined")) { - _context.next = 8; - break; - } - - _extractFileName3 = extractFileName(file.name), extension = _extractFileName3[1]; - - if (!(extension !== "xnb")) { - _context.next = 4; - break; - } - - return _context.abrupt("return", new Error("Invalid XNB File!")); - - case 4: - _context.next = 6; - return file.arrayBuffer(); - - case 6: - buffer = _context.sent; - return _context.abrupt("return", bufferToXnb(buffer)); - - case 8: - return _context.abrupt("return", bufferToXnb(file.buffer)); - - case 9: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + if (!(typeof window !== "undefined")) { + _context.next = 8; + break; + } + _extractFileName3 = extractFileName(file.name), extension = _extractFileName3[1]; + if (!(extension !== "xnb")) { + _context.next = 4; + break; + } + return _context.abrupt("return", new Error("Invalid XNB File!")); + case 4: + _context.next = 6; + return file.arrayBuffer(); + case 6: + buffer = _context.sent; + return _context.abrupt("return", bufferToXnb(buffer)); + case 8: + return _context.abrupt("return", bufferToXnb(file.buffer)); + case 9: + case "end": + return _context.stop(); } }, _callee); })); return _unpackToXnbData.apply(this, arguments); } - function unpackToContent(file) { return unpackToXnbData(file).then(xnbDataToContent); } + /** @api * Asynchronously reads the file into binary and then unpacks the contents and remake to Blobs array. * XNB -> arrayBuffer -> XnbData -> Files @@ -9251,21 +8176,17 @@ * @param {Object} config (yaml:export file as yaml, contentOnly:export content file only, fileName:file name(for node.js)) * @return {Array} exported Files Blobs */ - - function unpackToFiles(file) { var configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var _configs$yaml = configs.yaml, - yaml = _configs$yaml === void 0 ? false : _configs$yaml, - _configs$contentOnly = configs.contentOnly, - contentOnly = _configs$contentOnly === void 0 ? false : _configs$contentOnly, - _configs$fileName = configs.fileName, - name = _configs$fileName === void 0 ? null : _configs$fileName; + yaml = _configs$yaml === void 0 ? false : _configs$yaml, + _configs$contentOnly = configs.contentOnly, + contentOnly = _configs$contentOnly === void 0 ? false : _configs$contentOnly, + _configs$fileName = configs.fileName, + name = _configs$fileName === void 0 ? null : _configs$fileName; if (typeof window !== "undefined" && name === null) name = file.name; - var _extractFileName = extractFileName(name), - fileName = _extractFileName[0]; - + fileName = _extractFileName[0]; var exporter = function exporter(xnbObject) { return exportFiles(xnbObject, { yaml: yaml, @@ -9273,49 +8194,43 @@ fileName: fileName }); }; - return unpackToXnbData(file).then(exporter); } + /** @api * reads the buffer and then unpacks. * arrayBuffer -> XnbData * @param {ArrayBuffer} buffer * @return {XnbData} the loaded XNB json */ - - function bufferToXnb(buffer) { var xnb = new XnbConverter(); return xnb.load(buffer); } + /** @api * reads the buffer and then unpacks the contents. * arrayBuffer -> XnbData -> Content * @param {ArrayBuffer} buffer * @return {XnbContent} exported Content Object */ - - function bufferToContents(buffer) { var xnb = new XnbConverter(); var xnbData = xnb.load(buffer); return xnbDataToContent(xnbData); } + /** @api * remove header from the loaded XNB Object * XnbData -> Content * @param {XnbData} the loaded XNB object include headers * @return {XnbContent} exported Content Object */ - - function xnbDataToContent(loadedXnb) { var content = loadedXnb.content; - var _exportContent = exportContent(content, true), - data = _exportContent.data, - extension = _exportContent.extension; - + data = _exportContent.data, + extension = _exportContent.extension; return new XnbContent(data, extension); } /** @api @@ -9323,68 +8238,55 @@ * @param {FileList/Array} to pack json data * @return {Object/Object} packed XNB Array Buffer */ - - function fileMapper(files) { var returnMap = {}; var noHeaderMap = {}; - for (var i = 0; i < files.length; i++) { var file = files[i]; - var _extractFileName2 = extractFileName(file.name), - fileName = _extractFileName2[0], - extension = _extractFileName2[1]; - + fileName = _extractFileName2[0], + extension = _extractFileName2[1]; if (extension === null) continue; - if (returnMap[fileName] === undefined) { returnMap[fileName] = {}; if (extension !== "json" && extension !== "yaml") noHeaderMap[fileName] = file.name; } - var namedFileObj = returnMap[fileName]; if (typeof Blob === "function" && file instanceof Blob) namedFileObj[extension] = file;else namedFileObj[extension] = file.data; if (extension === "json" || extension === "yaml") delete noHeaderMap[fileName]; } - for (var _i2 = 0, _Object$keys2 = Object.keys(noHeaderMap); _i2 < _Object$keys2.length; _i2++) { var _fileName = _Object$keys2[_i2]; returnMap[_fileName].json = makeHeader(noHeaderMap[_fileName]); } - return returnMap; } + /** @api * reads the json and then unpacks the contents. * @param {json} to pack json data * @return {ArrayBuffer} packed XNB Array Buffer */ - - function packJsonToBinary(json) { var xnb = new XnbConverter(); var buffer = xnb.convert(json); return buffer; } + /** @api * Asynchronously reads the file into binary and then pack xnb files. * @param {FlieList} files * @param {Object} configs(compression:default, none, LZ4, LZX / debug) * @return {Array(Blobs)} */ - - function pack(files) { var configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var groupedFiles = fileMapper(files); var promises = []; - var __keys = Object.keys(groupedFiles); - for (var __i = 0; __i < __keys.length; __i++) { var fileName = __keys[__i], - filePack = groupedFiles[fileName]; + filePack = groupedFiles[fileName]; promises.push(resolveImports(filePack, configs).then(packJsonToBinary).then(function (buffer) { if (typeof Blob === "function") return { name: fileName, @@ -9398,12 +8300,11 @@ }; })); } - return __promise_allSettled(promises).then(function (blobArray) { if (configs.debug === true) return blobArray; return blobArray.filter(function (_ref) { var status = _ref.status; - _ref.value; + _ref.value; return status === "fulfilled"; }).map(function (_ref2) { var value = _ref2.value; @@ -9411,22 +8312,36 @@ }); }); } - function setReaders(readers) { return TypeReader.setReaders(readers); } - function addReaders(readers) { return TypeReader.addReaders(readers); } + function setSchemes(schemes) { + return TypeReader.setSchemes(schemes); + } + function addSchemes(schemes) { + return TypeReader.addSchemes(schemes); + } + function setEnum(enumList) { + return TypeReader.setEnum(enumList); + } + function addEnum(enumList) { + return TypeReader.addEnum(enumList); + } exports.XnbContent = XnbContent; exports.XnbData = XnbData; + exports.addEnum = addEnum; exports.addReaders = addReaders; + exports.addSchemes = addSchemes; exports.bufferToContents = bufferToContents; exports.bufferToXnb = bufferToXnb; exports.pack = pack; + exports.setEnum = setEnum; exports.setReaders = setReaders; + exports.setSchemes = setSchemes; exports.unpackToContent = unpackToContent; exports.unpackToFiles = unpackToFiles; exports.unpackToXnbData = unpackToXnbData; diff --git a/dist/core/xnb-core.es5.min.js b/dist/core/xnb-core.es5.min.js index c2b7cd4..de37aff 100644 --- a/dist/core/xnb-core.es5.min.js +++ b/dist/core/xnb-core.es5.min.js @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -45,4 +45,4 @@ * ----------------------------------------------------------------------------- */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XNB={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=function(t){return t&&t.Math==Math&&t},r=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e&&e)||function(){return this}()||Function("return this")(),i={},a=function(t){try{return!!t()}catch(t){return!0}},o=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),s=!a((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),u=s,h=Function.prototype.call,f=u?h.bind(h):function(){return h.apply(h,arguments)},c={},l={}.propertyIsEnumerable,d=Object.getOwnPropertyDescriptor,p=d&&!l.call({1:2},1);c.f=p?function(t){var e=d(this,t);return!!e&&e.enumerable}:l;var v,_,y=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},w=s,g=Function.prototype,b=g.bind,m=g.call,k=w&&b.bind(m,m),x=w?function(t){return t&&k(t)}:function(t){return t&&function(){return m.apply(t,arguments)}},E=x,O=E({}.toString),R=E("".slice),A=function(t){return R(O(t),8,-1)},U=x,S=a,T=A,L=r.Object,B=U("".split),I=S((function(){return!L("z").propertyIsEnumerable(0)}))?function(t){return"String"==T(t)?B(t,""):L(t)}:L,N=r.TypeError,P=function(t){if(null==t)throw N("Can't call method on "+t);return t},j=I,z=P,D=function(t){return j(z(t))},C=function(t){return"function"==typeof t},F=C,Z=function(t){return"object"==typeof t?null!==t:F(t)},M=r,V=C,X=function(t){return V(t)?t:void 0},H=function(t,e){return arguments.length<2?X(M[t]):M[t]&&M[t][e]},W=x({}.isPrototypeOf),G=H("navigator","userAgent")||"",K=r,Y=G,J=K.process,$=K.Deno,q=J&&J.versions||$&&$.version,Q=q&&q.v8;Q&&(_=(v=Q.split("."))[0]>0&&v[0]<4?1:+(v[0]+v[1])),!_&&Y&&(!(v=Y.match(/Edge\/(\d+)/))||v[1]>=74)&&(v=Y.match(/Chrome\/(\d+)/))&&(_=+v[1]);var tt=_,et=tt,nt=a,rt=!!Object.getOwnPropertySymbols&&!nt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&et&&et<41})),it=rt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,at=H,ot=C,st=W,ut=it,ht=r.Object,ft=ut?function(t){return"symbol"==typeof t}:function(t){var e=at("Symbol");return ot(e)&&st(e.prototype,ht(t))},ct=r.String,lt=function(t){try{return ct(t)}catch(t){return"Object"}},dt=C,pt=lt,vt=r.TypeError,_t=function(t){if(dt(t))return t;throw vt(pt(t)+" is not a function")},yt=_t,wt=function(t,e){var n=t[e];return null==n?void 0:yt(n)},gt=f,bt=C,mt=Z,kt=r.TypeError,xt={exports:{}},Et=r,Ot=Object.defineProperty,Rt=function(t,e){try{Ot(Et,t,{value:e,configurable:!0,writable:!0})}catch(n){Et[t]=e}return e},At=Rt,Ut="__core-js_shared__",St=r[Ut]||At(Ut,{}),Tt=St;(xt.exports=function(t,e){return Tt[t]||(Tt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.22.4",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.22.4/LICENSE",source:"https://github.com/zloirock/core-js"});var Lt=P,Bt=r.Object,It=function(t){return Bt(Lt(t))},Nt=x({}.hasOwnProperty),Pt=Object.hasOwn||function(t,e){return Nt(It(t),e)},jt=x,zt=0,Dt=Math.random(),Ct=jt(1..toString),Ft=function(t){return"Symbol("+(void 0===t?"":t)+")_"+Ct(++zt+Dt,36)},Zt=r,Mt=xt.exports,Vt=Pt,Xt=Ft,Ht=rt,Wt=it,Gt=Mt("wks"),Kt=Zt.Symbol,Yt=Kt&&Kt.for,Jt=Wt?Kt:Kt&&Kt.withoutSetter||Xt,$t=function(t){if(!Vt(Gt,t)||!Ht&&"string"!=typeof Gt[t]){var e="Symbol."+t;Ht&&Vt(Kt,t)?Gt[t]=Kt[t]:Gt[t]=Wt&&Yt?Yt(e):Jt(e)}return Gt[t]},qt=f,Qt=Z,te=ft,ee=wt,ne=function(t,e){var n,r;if("string"===e&&bt(n=t.toString)&&!mt(r=gt(n,t)))return r;if(bt(n=t.valueOf)&&!mt(r=gt(n,t)))return r;if("string"!==e&&bt(n=t.toString)&&!mt(r=gt(n,t)))return r;throw kt("Can't convert object to primitive value")},re=$t,ie=r.TypeError,ae=re("toPrimitive"),oe=function(t,e){if(!Qt(t)||te(t))return t;var n,r=ee(t,ae);if(r){if(void 0===e&&(e="default"),n=qt(r,t,e),!Qt(n)||te(n))return n;throw ie("Can't convert object to primitive value")}return void 0===e&&(e="number"),ne(t,e)},se=ft,ue=function(t){var e=oe(t,"string");return se(e)?e:e+""},he=Z,fe=r.document,ce=he(fe)&&he(fe.createElement),le=function(t){return ce?fe.createElement(t):{}},de=le,pe=!o&&!a((function(){return 7!=Object.defineProperty(de("div"),"a",{get:function(){return 7}}).a})),ve=o,_e=f,ye=c,we=y,ge=D,be=ue,me=Pt,ke=pe,xe=Object.getOwnPropertyDescriptor;i.f=ve?xe:function(t,e){if(t=ge(t),e=be(e),ke)try{return xe(t,e)}catch(t){}if(me(t,e))return we(!_e(ye.f,t,e),t[e])};var Ee={},Oe=o&&a((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Re=r,Ae=Z,Ue=Re.String,Se=Re.TypeError,Te=function(t){if(Ae(t))return t;throw Se(Ue(t)+" is not an object")},Le=o,Be=pe,Ie=Oe,Ne=Te,Pe=ue,je=r.TypeError,ze=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ce="enumerable",Fe="configurable",Ze="writable";Ee.f=Le?Ie?function(t,e,n){if(Ne(t),e=Pe(e),Ne(n),"function"==typeof t&&"prototype"===e&&"value"in n&&Ze in n&&!n.writable){var r=De(t,e);r&&r.writable&&(t[e]=n.value,n={configurable:Fe in n?n.configurable:r.configurable,enumerable:Ce in n?n.enumerable:r.enumerable,writable:!1})}return ze(t,e,n)}:ze:function(t,e,n){if(Ne(t),e=Pe(e),Ne(n),Be)try{return ze(t,e,n)}catch(t){}if("get"in n||"set"in n)throw je("Accessors not supported");return"value"in n&&(t[e]=n.value),t};var Me=Ee,Ve=y,Xe=o?function(t,e,n){return Me.f(t,e,Ve(1,n))}:function(t,e,n){return t[e]=n,t},He={exports:{}},We=o,Ge=Pt,Ke=Function.prototype,Ye=We&&Object.getOwnPropertyDescriptor,Je=Ge(Ke,"name"),$e={EXISTS:Je,PROPER:Je&&"something"===function(){}.name,CONFIGURABLE:Je&&(!We||We&&Ye(Ke,"name").configurable)},qe=C,Qe=St,tn=x(Function.toString);qe(Qe.inspectSource)||(Qe.inspectSource=function(t){return tn(t)});var en,nn,rn,an=Qe.inspectSource,on=C,sn=an,un=r.WeakMap,hn=on(un)&&/native code/.test(sn(un)),fn=xt.exports,cn=Ft,ln=fn("keys"),dn={},pn=hn,vn=r,_n=x,yn=Z,wn=Xe,gn=Pt,bn=St,mn=function(t){return ln[t]||(ln[t]=cn(t))},kn=dn,xn="Object already initialized",En=vn.TypeError,On=vn.WeakMap;if(pn||bn.state){var Rn=bn.state||(bn.state=new On),An=_n(Rn.get),Un=_n(Rn.has),Sn=_n(Rn.set);en=function(t,e){if(Un(Rn,t))throw new En(xn);return e.facade=t,Sn(Rn,t,e),e},nn=function(t){return An(Rn,t)||{}},rn=function(t){return Un(Rn,t)}}else{var Tn=mn("state");kn[Tn]=!0,en=function(t,e){if(gn(t,Tn))throw new En(xn);return e.facade=t,wn(t,Tn,e),e},nn=function(t){return gn(t,Tn)?t[Tn]:{}},rn=function(t){return gn(t,Tn)}}var Ln={set:en,get:nn,has:rn,enforce:function(t){return rn(t)?nn(t):en(t,{})},getterFor:function(t){return function(e){var n;if(!yn(e)||(n=nn(e)).type!==t)throw En("Incompatible receiver, "+t+" required");return n}}},Bn=a,In=C,Nn=Pt,Pn=Ee.f,jn=$e.CONFIGURABLE,zn=an,Dn=Ln.enforce,Cn=Ln.get,Fn=!Bn((function(){return 8!==Pn((function(){}),"length",{value:8}).length})),Zn=String(String).split("String"),Mn=He.exports=function(t,e,n){"Symbol("===String(e).slice(0,7)&&(e="["+String(e).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(e="get "+e),n&&n.setter&&(e="set "+e),(!Nn(t,"name")||jn&&t.name!==e)&&Pn(t,"name",{value:e,configurable:!0}),Fn&&n&&Nn(n,"arity")&&t.length!==n.arity&&Pn(t,"length",{value:n.arity});var r=Dn(t);return Nn(r,"source")||(r.source=Zn.join("string"==typeof e?e:"")),t};Function.prototype.toString=Mn((function(){return In(this)&&Cn(this).source||zn(this)}),"toString");var Vn=r,Xn=C,Hn=Xe,Wn=He.exports,Gn=Rt,Kn=function(t,e,n,r){var i=!!r&&!!r.unsafe,a=!!r&&!!r.enumerable,o=!!r&&!!r.noTargetGet,s=r&&void 0!==r.name?r.name:e;return Xn(n)&&Wn(n,s,r),t===Vn?(a?t[e]=n:Gn(e,n),t):(i?!o&&t[e]&&(a=!0):delete t[e],a?t[e]=n:Hn(t,e,n),t)},Yn={},Jn=Math.ceil,$n=Math.floor,qn=function(t){var e=+t;return e!=e||0===e?0:(e>0?$n:Jn)(e)},Qn=qn,tr=Math.max,er=Math.min,nr=qn,rr=Math.min,ir=function(t){return t>0?rr(nr(t),9007199254740991):0},ar=function(t){return ir(t.length)},or=D,sr=function(t,e){var n=Qn(t);return n<0?tr(n+e,0):er(n,e)},ur=ar,hr=function(t){return function(e,n,r){var i,a=or(e),o=ur(a),s=sr(r,o);if(t&&n!=n){for(;o>s;)if((i=a[s++])!=i)return!0}else for(;o>s;s++)if((t||s in a)&&a[s]===n)return t||s||0;return!t&&-1}},fr={includes:hr(!0),indexOf:hr(!1)},cr=Pt,lr=D,dr=fr.indexOf,pr=dn,vr=x([].push),_r=function(t,e){var n,r=lr(t),i=0,a=[];for(n in r)!cr(pr,n)&&cr(r,n)&&vr(a,n);for(;e.length>i;)cr(r,n=e[i++])&&(~dr(a,n)||vr(a,n));return a},yr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype");Yn.f=Object.getOwnPropertyNames||function(t){return _r(t,yr)};var wr={};wr.f=Object.getOwnPropertySymbols;var gr=H,br=Yn,mr=wr,kr=Te,xr=x([].concat),Er=gr("Reflect","ownKeys")||function(t){var e=br.f(kr(t)),n=mr.f;return n?xr(e,n(t)):e},Or=Pt,Rr=Er,Ar=i,Ur=Ee,Sr=a,Tr=C,Lr=/#|\.prototype\./,Br=function(t,e){var n=Nr[Ir(t)];return n==jr||n!=Pr&&(Tr(e)?Sr(e):!!e)},Ir=Br.normalize=function(t){return String(t).replace(Lr,".").toLowerCase()},Nr=Br.data={},Pr=Br.NATIVE="N",jr=Br.POLYFILL="P",zr=Br,Dr=r,Cr=i.f,Fr=Xe,Zr=Kn,Mr=Rt,Vr=function(t,e,n){for(var r=Rr(e),i=Ur.f,a=Ar.f,o=0;o=51&&/native code/.test(t))return!1;var n=new uo((function(t){t(1)})),r=function(t){t((function(){}),(function(){}))};return(n.constructor={})[_o]=r,!(yo=n.then((function(){}))instanceof r)||!e&&po&&!wo})),bo={CONSTRUCTOR:go,REJECTION_EVENT:wo,SUBCLASSING:yo},mo={},ko=_t,xo=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=ko(e),this.reject=ko(n)};mo.f=function(t){return new xo(t)};var Eo,Oo,Ro,Ao=Hr,Uo=Wr,So=r,To=f,Lo=Kn,Bo=ti,Io=function(t,e,n){t&&!n&&(t=t.prototype),t&&!ni(t,ri)&&ei(t,ri,{configurable:!0,value:e})},No=function(t){var e=ii(t),n=ai.f;oi&&e&&!e[si]&&n(e,si,{configurable:!0,get:function(){return this}})},Po=_t,jo=C,zo=Z,Do=function(t,e){if(ui(e,t))return t;throw hi("Incorrect invocation")},Co=function(t,e){var n,r=Fi(t).constructor;return void 0===r||null==(n=Fi(r)[Mi])?e:Zi(n)},Fo=ja.set,Zo=to,Mo=function(t,e){var n=eo.console;n&&n.error&&(1==arguments.length?n.error(t):n.error(t,e))},Vo=no,Xo=io,Ho=Ln,Wo=ao,Go=mo,Ko="Promise",Yo=bo.CONSTRUCTOR,Jo=bo.REJECTION_EVENT,$o=bo.SUBCLASSING,qo=Ho.getterFor(Ko),Qo=Ho.set,ts=Wo&&Wo.prototype,es=Wo,ns=ts,rs=So.TypeError,is=So.document,as=So.process,os=Go.f,ss=os,us=!!(is&&is.createEvent&&So.dispatchEvent),hs="unhandledrejection",fs=function(t){var e;return!(!zo(t)||!jo(e=t.then))&&e},cs=function(t,e){var n,r,i,a=e.value,o=1==e.state,s=o?t.ok:t.fail,u=t.resolve,h=t.reject,f=t.domain;try{s?(o||(2===e.rejection&&_s(e),e.rejection=1),!0===s?n=a:(f&&f.enter(),n=s(a),f&&(f.exit(),i=!0)),n===t.promise?h(rs("Promise-chain cycle")):(r=fs(n))?To(r,n,u,h):u(n)):h(a)}catch(t){f&&!i&&f.exit(),h(t)}},ls=function(t,e){t.notified||(t.notified=!0,Zo((function(){for(var n,r=t.reactions;n=r.get();)cs(n,t);t.notified=!1,e&&!t.rejection&&ps(t)})))},ds=function(t,e,n){var r,i;us?((r=is.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),So.dispatchEvent(r)):r={promise:e,reason:n},!Jo&&(i=So["on"+t])?i(r):t===hs&&Mo("Unhandled promise rejection",n)},ps=function(t){To(Fo,So,(function(){var e,n=t.facade,r=t.value;if(vs(t)&&(e=Vo((function(){Uo?as.emit("unhandledRejection",r,n):ds(hs,n,r)})),t.rejection=Uo||vs(t)?2:1,e.error))throw e.value}))},vs=function(t){return 1!==t.rejection&&!t.parent},_s=function(t){To(Fo,So,(function(){var e=t.facade;Uo?as.emit("rejectionHandled",e):ds("rejectionhandled",e,t.value)}))},ys=function(t,e,n){return function(r){t(e,r,n)}},ws=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,ls(t,!0))},gs=function(t,e,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===e)throw rs("Promise can't be resolved itself");var r=fs(e);r?Zo((function(){var n={done:!1};try{To(r,e,ys(gs,n,t),ys(ws,n,t))}catch(e){ws(n,e,t)}})):(t.value=e,t.state=1,ls(t,!1))}catch(e){ws({done:!1},e,t)}}};if(Yo&&(ns=(es=function(t){Do(this,ns),Po(t),To(Eo,this);var e=qo(this);try{t(ys(gs,e),ys(ws,e))}catch(t){ws(e,t)}}).prototype,(Eo=function(t){Qo(this,{type:Ko,done:!1,notified:!1,parent:!1,reactions:new Xo,rejection:!1,state:0,value:void 0})}).prototype=Lo(ns,"then",(function(t,e){var n=qo(this),r=os(Co(this,es));return n.parent=!0,r.ok=!jo(t)||t,r.fail=jo(e)&&e,r.domain=Uo?as.domain:void 0,0==n.state?n.reactions.add(r):Zo((function(){cs(r,n)})),r.promise})),Oo=function(){var t=new Eo,e=qo(t);this.promise=t,this.resolve=ys(gs,e),this.reject=ys(ws,e)},Go.f=os=function(t){return t===es||undefined===t?new Oo(t):ss(t)},jo(Wo)&&ts!==Object.prototype)){Ro=ts.then,$o||Lo(ts,"then",(function(t,e){var n=this;return new es((function(t,e){To(Ro,n,t,e)})).then(t,e)}),{unsafe:!0});try{delete ts.constructor}catch(t){}Bo&&Bo(ts,ns)}Ao({global:!0,wrap:!0,forced:Yo},{Promise:es}),Io(es,Ko,!1),No(Ko);var bs={},ms=bs,ks=$t("iterator"),xs=Array.prototype,Es=wi,Os=wt,Rs=bs,As=$t("iterator"),Us=function(t){if(null!=t)return Os(t,As)||Os(t,"@@iterator")||Rs[Es(t)]},Ss=f,Ts=_t,Ls=Te,Bs=lt,Is=Us,Ns=r.TypeError,Ps=f,js=Te,zs=wt,Ds=$i,Cs=f,Fs=Te,Zs=lt,Ms=function(t){return void 0!==t&&(ms.Array===t||xs[ks]===t)},Vs=ar,Xs=W,Hs=function(t,e){var n=arguments.length<2?Is(t):e;if(Ts(n))return Ls(Ss(n,t));throw Ns(Bs(t)+" is not iterable")},Ws=Us,Gs=function(t,e,n){var r,i;js(t);try{if(!(r=zs(t,"return"))){if("throw"===e)throw n;return n}r=Ps(r,t)}catch(t){i=!0,r=t}if("throw"===e)throw n;if(i)throw r;return js(r),n},Ks=r.TypeError,Ys=function(t,e){this.stopped=t,this.result=e},Js=Ys.prototype,$s=function(t,e,n){var r,i,a,o,s,u,h,f=n&&n.that,c=!(!n||!n.AS_ENTRIES),l=!(!n||!n.IS_ITERATOR),d=!(!n||!n.INTERRUPTED),p=Ds(e,f),v=function(t){return r&&Gs(r,"normal",t),new Ys(!0,t)},_=function(t){return c?(Fs(t),d?p(t[0],t[1],v):p(t[0],t[1])):d?p(t,v):p(t)};if(l)r=t;else{if(!(i=Ws(t)))throw Ks(Zs(t)+" is not iterable");if(Ms(i)){for(a=0,o=Vs(t);o>a;a++)if((s=_(t[a]))&&Xs(Js,s))return s;return new Ys(!1)}r=Hs(t,i)}for(u=r.next;!(h=Cs(u,r)).done;){try{s=_(h.value)}catch(t){Gs(r,"throw",t)}if("object"==typeof s&&s&&Xs(Js,s))return s}return new Ys(!1)};function qs(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Qs(t){for(var e=1;e=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),h=r.call(o,"finallyLoc");if(u&&h){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;A(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:S(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}({exports:{}});var th=function(t){su(n,t);var e=vu(n);function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return ru(this,n),(t=e.call(this,r)).name="XnbError",t.message=r,Error.captureStackTrace(du(t),n),t}return au(n)}(lu(Error));function eh(t){for(var e=[],n=[],r=0;r")}return n.type()}return null}},{key:"simplifyType",value:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(e){var n=e.split(/`|,/)[0];if(function(t,e){if("function"==typeof t.endsWith)return t.endsWith(e);if("string"!=typeof t||"string"!=typeof e)throw new Error("Invalid Data!");return new RegExp(e+"$").test(t)}(n,"[]"))return"Array<".concat(simplifyType(n.slice(0,-2)),">");if("Microsoft.Xna.Framework.Content.ReflectiveReader"===n){var r=t.parseSubtypes(e).map(t.simplifyType.bind(t));return"".concat(r)}for(var i=0,a=Object.values(t.readers);i/);return n=n?n[1].split(",").map((function(t){return t.trim()})):[],{type:e,subtypes:n}}},{key:"getReaderTypeList",value:function(e){return t.getReader(e).parseTypeList()}},{key:"getReader",value:function(e){var n=t.getTypeInfo(e),r=n.type,i=n.subtypes;if(i=i.map(t.getReader.bind(t)),t.readers.hasOwnProperty("".concat(r,"Reader")))return cu(t.readers["".concat(r,"Reader")],i);throw new th('Invalid reader type "'.concat(e,'" passed, unable to resolve!'))}},{key:"getReaderFromRaw",value:function(e){var n=t.simplifyType(e);return t.getReader(n)}}]),t}();ou(nh,"readers",{});var rh=[192,224,240],ih=128,ah=63,oh=[55296,56320],sh=1023;function uh(t){return t<128?[t]:t<2048?[rh[0]|t>>6,ih|t&ah]:t<65536?[rh[1]|t>>12,ih|t>>6&ah,ih|t&ah]:[rh[2]|t>>18,ih|t>>12&ah,ih|t>>6&ah,ih|t&ah]}function hh(t){return t<65535?[t]:[oh[0]|(t-=65536)>>10&sh,oh[1]|t&sh]}function fh(t){var e;if("number"==typeof t&&(t=[t]),null===(e=t)||void 0===e||!e.length)throw new Error("Invalid codeset!");var n=t.length;return 1===n?t[0]:2===n?((t[0]^rh[0])<<6)+(t[1]^ih):3===n?((t[0]^rh[1])<<12)+((t[1]^ih)<<6)+(t[2]^ih):((t[0]^rh[2])<<18)+((t[1]^ih)<<12)+((t[2]^ih)<<6)+(t[3]^ih)}function ch(t){var e;if("number"==typeof t&&(t=[t]),null===(e=t)||void 0===e||!e.length)throw new Error("Invalid codeset!");return 1===t.length?t[0]:((t[0]&sh)<<10)+(t[1]&sh)+65536}function lh(t){return function(t){for(var e=[],n=0;n1&&void 0!==arguments[1])||arguments[1];ru(this,t),this._endianus=n,this._buffer=e.slice(),this._dataView=new DataView(this._buffer),this._offset=0,this._bitOffset=0}return au(t,[{key:"seek",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._offset,n=this._offset;if(this._offset=Math.max(e+parseInt(t),0),this._offset<0||this._offset>this.buffer.length)throw new RangeError("Buffer seek out of bounds! ".concat(this._offset," ").concat(this.buffer.length));return this._offset-n}},{key:"bytePosition",get:function(){return parseInt(this._offset)},set:function(t){this._offset=t}},{key:"bitPosition",get:function(){return parseInt(this._bitOffset)},set:function(t){t<0&&(t=16-t),this._bitOffset=t%16;var e=(t-Math.abs(t)%16)/16*2;this.seek(e)}},{key:"size",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._buffer}},{key:"copyFrom",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.byteLength,i=new Uint8Array(t),a=this.buffer.byteLength0&&void 0!==arguments[0]?arguments[0]:-1,e=[];if(this._offset,-1===t)for(;0!=this.peekByte(1);)e.push(this.readByte());else for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:0,e=[],n=this._offset;if(0===t)for(;0!=this.peekByte(1);)e.push(this.readByte());else for(var r=0;r0;){var r=this._dataView.getUint16(this._offset,!0),i=Math.min(Math.max(e,0),16-this.bitPosition),a=16-this.bitPosition-i,o=(r&Math.pow(2,i)-1<>a;e-=i,this.bitPosition+=i,n|=o<0&&void 0!==arguments[0])||arguments[0],e=this.readByte(),n=this.readByte();return t||this.seek(-2),e<<8|n}},{key:"align",value:function(){this.bitPosition>0&&(this.bitPosition+=16-this.bitPosition)}}]),t}(),vh=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2048;ru(this,t),this._buffer=new ArrayBuffer(e),this._dataView=new DataView(this._buffer),this.bytePosition=0}return au(t,[{key:"buffer",get:function(){return this._buffer}},{key:"reconnectDataView",value:function(){this._dataView=new DataView(this._buffer)}},{key:"trim",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._buffer=this.buffer.slice(0,this.bytePosition),t||this.reconnectDataView()}},{key:"alloc",value:function(t){if(this._buffer.byteLength<=this.bytePosition+t){for(var e=new ArrayBuffer(this._buffer.byteLength+t),n=new DataView(e),r=0;r>=7)&&(e|=128),this._dataView.setUint8(this.bytePosition,e),this.bytePosition++}while(t)}}]),t}(),_h=256,yh=0,wh=1,gh=2,bh=3,mh=656,kh=function(){function t(e){if(ru(this,t),this.window_size=1<21)throw new th("Window size out of range!");if(!t.extra_bits.length)for(var n=0,r=0;n<=50;n+=2)t.extra_bits[n]=t.extra_bits[n+1]=r,0!=n&&r<17&&r++;if(!t.position_base.length)for(var i=0,a=0;i<=50;i++)t.position_base[i]=a,a+=1<0;){if(0==this.block_remaining){this.block_type=e.readLZXBits(3);var a=e.readLZXBits(16),o=e.readLZXBits(8);switch(this.block_remaining=a<<8|o,this.block_type){case gh:for(var s=0;s<8;s++)this.aligned_len[s]=e.readLZXBits(3);this.aligned_table=this.decodeTable(8,7,this.aligned_len);case wh:this.readLengths(e,this.maintree_len,0,256),this.readLengths(e,this.maintree_len,256,this.main_elements),this.maintree_table=this.decodeTable(mh,12,this.maintree_len),this.readLengths(e,this.length_len,0,249),this.length_table=this.decodeTable(250,12,this.length_len);break;case bh:e.align(),this.R0=e.readInt32(),this.R1=e.readInt32(),this.R2=e.readInt32();break;default:throw new th("Invalid Blocktype Found: ".concat(this.block_type))}}for(var u=this.block_remaining;(u=this.block_remaining)>0&&i>0;){if(u>i&&(u=i),i-=u,this.block_remaining-=u,this.window_posn&=this.window_size-1,this.window_posn+u>this.window_size)throw new th("Cannot run outside of window frame.");switch(this.block_type){case gh:for(;u>0;){var h=this.readHuffSymbol(e,this.maintree_table,this.maintree_len,mh,12);if(h<_h)this.win[this.window_posn++]=h,u--;else{var f=7&(h-=_h);7==f&&(f+=this.readHuffSymbol(e,this.length_table,this.length_len,250,12)),f+=2;var c=h>>3;if(c>2){var l=t.extra_bits[c];if(c=t.position_base[c]-2,l>3)l-=3,c+=e.readLZXBits(l)<<3,c+=this.readHuffSymbol(e,this.aligned_table,this.aligned_len,8,7);else 3==l?c+=this.readHuffSymbol(e,this.aligned_table,this.aligned_len,8,7):l>0?c+=e.readLZXBits(l):c=1;this.R2=this.R1,this.R1=this.R0,this.R0=c}else 0===c?c=this.R0:1==c?(c=this.R1,this.R1=this.R0,this.R0=c):(c=this.R2,this.R2=this.R0,this.R0=c);var d=this.window_posn,p=void 0;if(u-=f,this.window_posn>=c)p=d-c;else{p=d+(this.window_size-c);var v=c-this.window_posn;if(v0;)this.win[d++]=this.win[p++];p=0}}for(this.window_posn+=f;f-- >0;)this.win[d++]=this.win[p++]}}break;case wh:for(;u>0;){var _=this.readHuffSymbol(e,this.maintree_table,this.maintree_len,mh,12);if(_<_h)this.win[this.window_posn++]=_,u--;else{var y=7&(_-=_h);7==y&&(y+=this.readHuffSymbol(e,this.length_table,this.length_len,250,12)),y+=2;var w=_>>3;if(w>2){if(3!=w){var g=t.extra_bits[w],b=e.readLZXBits(g);w=t.position_base[w]-2+b}else w=1;this.R2=this.R1,this.R1=this.R0,this.R0=w}else 0===w?w=this.R0:1==w?(w=this.R1,this.R1=this.R0,this.R0=w):(w=this.R2,this.R2=this.R0,this.R0=w);var m=this.window_posn,k=void 0;if(u-=y,this.window_posn>=w)k=m-w;else{k=m+(this.window_size-w);var x=w-this.window_posn;if(x0;)this.win[m++]=this.win[k++];k=0}}for(this.window_posn+=y;y-- >0;)this.win[m++]=this.win[k++]}}break;case bh:if(e.bytePosition+u>r)throw new th("Overrun!"+r+" "+e.bytePosition+" "+u);for(var E=0;E>1,s=1;s<=e;s++){for(var u=0;ua)throw new th("Overrun table!");for(var f=o;f-- >0;)r[h++]=u}o>>=1}if(i==a)return r;for(var c=i;c>1>1;i<<=16,a<<=16,o=32768;for(var d=e+1;d<=16;d++){for(var p=0;p>16,_=0;_>15-_&1&&v++;if(r[v]=p,(i+=o)>a)throw new th("Overrun table during decoding.")}o>>=1}if(i==a)return r;throw new th("Decode table did not reach table mask.")}},{key:"readHuffSymbol",value:function(t,e,n,r,i){var a=t.peekLZXBits(32)>>>0,o=e[t.peekLZXBits(i)];if(o>=r){var s=1<<32-i;do{if(o<<=1,o|=0!=(a&(s>>=1))?1:0,0==s)return 0}while((o=e[o])>=r)}return t.bitPosition+=n[o],o}},{key:"RRR",set:function(t){if(this.R0!=t&&this.R1!=t&&this.R2!=t)this.R2=this.R1,this.R1=this.R0,this.R0=t;else if(this.R1==t){var e=this.R1;this.R1=this.R0,this.R0=e}else if(this.R2==t){var n=this.R2;this.R2=this.R0,this.R0=n}}}]),t}();kh.position_base=[],kh.extra_bits=[];var xh=function(){function t(){ru(this,t)}return au(t,null,[{key:"decompress",value:function(t,e,n){for(var r,i,a=0,o=new kh(16),s=new vh(n);a65536||i>65536)throw new th("Invalid size read in compression content.");s.write(o.decompress(t,i,r)),a+=r}return console.log("File has been successfully decompressed!"),s.trim(),s.buffer}}]),t}(),Eh=function(){function t(){ru(this,t)}return au(t,null,[{key:"hashU32",value:function(t){return-1252372727^(t=(t=(t=(t=-949894596^(t=(t|=0)+2127912214+(t<<12)|0)^t>>>19)+374761393+(t<<5)|0)+-744332180^t<<9)+-42973499+(t<<3)|0)^t>>>16|0}},{key:"readU64",value:function(t,e){var n=0;return n|=t[e++]<<0,n|=t[e++]<<8,n|=t[e++]<<16,n|=t[e++]<<24,n|=t[e++]<<32,n|=t[e++]<<40,n|=t[e++]<<48,n|=t[e++]<<56}},{key:"readU32",value:function(t,e){var n=0;return n|=t[e++]<<0,n|=t[e++]<<8,n|=t[e++]<<16,n|=t[e++]<<24}},{key:"writeU32",value:function(t,e,n){t[e++]=n>>0&255,t[e++]=n>>8&255,t[e++]=n>>16&255,t[e++]=n>>24&255}},{key:"imul",value:function(t,e){var n=65535&t,r=65535&e;return n*r+((t>>>16)*r+n*(e>>>16)<<16)|0}}]),t}(),Oh=65536,Rh=15;!function(t){try{new Uint8Array(t)}catch(r){for(var e=new Array(t),n=0;n=13)for(var d=67;n+4>>0;if(a=i[v=(v>>16^v)>>>0&65535]-1,i[v]=n+1,a<0||n-a>>>16>0||Eh.readU32(t,a)!==p)n+=d++>>6;else{for(d=67,h=n-o,u=n-a,a+=4,s=n+=4;n=Rh){for(e[f++]=240+_,l=h-Rh;l>=255;l-=255)e[f++]=255;e[f++]=l}else e[f++]=(h<<4)+_;for(var y=0;y>8,s>=15){for(l=s-15;l>=255;l-=255)e[f++]=255;e[f++]=l}o=n}}if(0===o)return 0;if((h=c-o)>=Rh){for(e[f++]=240,l=h-Rh;l>=255;l-=255)e[f++]=255;e[f++]=l}else e[f++]=h<<4;for(n=o;n2&&void 0!==arguments[2]?arguments[2]:0,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.length-2*s,h=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,f=void 0!==e.copyWithin&&void 0!==e.fill;for(i=s+u;s>4;if(l>0){if(15===l)for(;l+=t[s],255===t[s++];);for(a=s+l;s=i)break;if(n=15&c,r=t[s++]|t[s++]<<8,15===n)for(;n+=t[s],255===t[s++];);if(n+=4,f&&1===r)e.fill(0|e[h-1],h,h+n),h+=n;else if(f&&r>n&&n>31)e.copyWithin(h,h-r,h-r+n),h+=n;else for(a=(o=h-r)+n;o2&&void 0!==arguments[2]?arguments[2]:{},r=n.r,i=n.g,a=void 0===i?r:i,o=n.b,s=void 0===o?r:o,u=n.a,h=void 0===u?255:u;return t[4*e+0]=r,t[4*e+1]=a,t[4*e+2]=s,t[4*e+3]=h,[r,a,s,h]}function Zh(t){t.width,t.height;var e=t.channels,n=t.depth,r=t.data;return t.palette?function(t,e,n){for(var r=new Uint8Array(t),i=8*r.length/e,a=new Uint8Array(4*i),o=0,s=0;s>h&Math.pow(2,e)-1];a[4*s]=f[0],a[4*s+1]=f[1],a[4*s+2]=f[2],a[4*s+3]=f[3],o+=e}return a}(r,n,t.palette):(16===n&&(r=function(t){for(var e=new Uint16Array(t),n=new Uint8Array(e.length),r=0;r>8;return n}(r)),e<4&&(r=function(t,e){var n=t.length/e,r=new Uint8Array(4*n);if(4===e)return t;if(1===e)for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:"utf-8";if("utf-8"!==t)throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t,"') is invalid."))}function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"utf-8",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fatal:!1};if("utf-8"!==t)throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t,"') is invalid."));if(e.fatal)throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}Object.defineProperty(e.prototype,"encoding",{value:"utf-8"}),e.prototype.encode=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{stream:!1};if(e.stream)throw new Error("Failed to encode: the 'stream' option is unsupported.");for(var n=0,r=t.length,i=0,a=Math.max(32,r+(r>>1)+7),o=new Uint8Array(a>>3<<3);n=55296&&s<=56319){if(n=55296&&s<=56319)continue}if(i+4>o.length){a+=8,a=(a*=1+n/t.length*2)>>3<<3;var h=new Uint8Array(a);h.set(o),o=h}if(0!=(4294967168&s)){if(0==(4294965248&s))o[i++]=s>>6&31|192;else if(0==(4294901760&s))o[i++]=s>>12&15|224,o[i++]=s>>6&63|128;else{if(0!=(4292870144&s))continue;o[i++]=s>>18&7|240,o[i++]=s>>12&63|128,o[i++]=s>>6&63|128}o[i++]=63&s|128}else o[i++]=s}return o.slice(0,i)},Object.defineProperty(n.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(n.prototype,"fatal",{value:!1}),Object.defineProperty(n.prototype,"ignoreBOM",{value:!1}),n.prototype.decode=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{stream:!1};if(e.stream)throw new Error("Failed to decode: the 'stream' option is unsupported.");for(var n=new Uint8Array(t),r=0,i=n.length,a=[];r65535&&(f-=65536,a.push(f>>>10&1023|55296),f=56320|1023&f),a.push(f)}}return String.fromCharCode.apply(null,a)},t.TextEncoder=e,t.TextDecoder=n}("undefined"!=typeof window?window:"undefined"!=typeof self?self:this)}},Vh={};function Xh(t){var e=Vh[t];if(void 0!==e)return e.exports;var n=Vh[t]={exports:{}};return Mh[t].call(n.exports,n,n.exports,Xh),n.exports}Xh.d=function(t,e){for(var n in e)Xh.o(e,n)&&!Xh.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},Xh.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var Hh={};!function(){Xh.d(Hh,{P:function(){return Un},m:function(){return An}}),Xh(396);var t=new TextDecoder("utf-8"),e=new TextEncoder,n=function(){function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8192,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ru(this,n);var r=!1;"number"==typeof t?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);var i=e.offset?e.offset>>>0:0,a=t.byteLength-i,o=i;(ArrayBuffer.isView(t)||t instanceof n)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+i),t=t.buffer),this.lastWrittenByte=r?a:0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}return au(n,[{key:"available",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.offset+t<=this.length}},{key:"isLittleEndian",value:function(){return this.littleEndian}},{key:"setLittleEndian",value:function(){return this.littleEndian=!0,this}},{key:"isBigEndian",value:function(){return!this.littleEndian}},{key:"setBigEndian",value:function(){return this.littleEndian=!1,this}},{key:"skip",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.offset+=t,this}},{key:"seek",value:function(t){return this.offset=t,this}},{key:"mark",value:function(){return this._mark=this.offset,this}},{key:"reset",value:function(){return this.offset=this._mark,this}},{key:"pushMark",value:function(){return this._marks.push(this.offset),this}},{key:"popMark",value:function(){var t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}},{key:"rewind",value:function(){return this.offset=0,this}},{key:"ensureAvailable",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(!this.available(t)){var e=2*(this.offset+t),n=new Uint8Array(e);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=this.byteLength=e,this._data=new DataView(this.buffer)}return this}},{key:"readBoolean",value:function(){return 0!==this.readUint8()}},{key:"readInt8",value:function(){return this._data.getInt8(this.offset++)}},{key:"readUint8",value:function(){return this._data.getUint8(this.offset++)}},{key:"readByte",value:function(){return this.readUint8()}},{key:"readBytes",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=new Uint8Array(t),n=0;n0&&void 0!==arguments[0]?arguments[0]:1,e="",n=0;n0&&void 0!==arguments[0]?arguments[0]:1;return e=this.readBytes(n),t.decode(e)}},{key:"writeBoolean",value:function(t){return this.writeUint8(t?255:0),this}},{key:"writeInt8",value:function(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}},{key:"writeUint8",value:function(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}},{key:"writeByte",value:function(t){return this.writeUint8(t)}},{key:"writeBytes",value:function(t){this.ensureAvailable(t.length);for(var e=0;ethis.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}]),n}();function r(t){for(var e=t.length;--e>=0;)t[e]=0}var i=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),a=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),o=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),s=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=new Array(576);r(u);var h=new Array(60);r(h);var f=new Array(512);r(f);var c=new Array(256);r(c);var l=new Array(29);r(l);var d,p,v,_=new Array(30);function y(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}function w(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}r(_);var g=function(t){return t<256?f[t]:f[256+(t>>>7)]},b=function(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},m=function(t,e,n){t.bi_valid>16-n?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<>>=1,n<<=1}while(--e>0);return n>>>1},E=function(t,e,n){var r,i,a=new Array(16),o=0;for(r=1;r<=15;r++)a[r]=o=o+n[r-1]<<1;for(i=0;i<=e;i++){var s=t[2*i+1];0!==s&&(t[2*i]=x(a[s]++,s))}},O=function(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},R=function(t){t.bi_valid>8?b(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},A=function(t,e,n,r){var i=2*e,a=2*n;return t[i]>1;n>=1;n--)U(t,a,n);i=u;do{n=t.heap[1],t.heap[1]=t.heap[t.heap_len--],U(t,a,1),r=t.heap[1],t.heap[--t.heap_max]=n,t.heap[--t.heap_max]=r,a[2*i]=a[2*n]+a[2*r],t.depth[i]=(t.depth[n]>=t.depth[r]?t.depth[n]:t.depth[r])+1,a[2*n+1]=a[2*r+1]=i,t.heap[1]=i++,U(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var n,r,i,a,o,s,u=e.dyn_tree,h=e.max_code,f=e.stat_desc.static_tree,c=e.stat_desc.has_stree,l=e.stat_desc.extra_bits,d=e.stat_desc.extra_base,p=e.stat_desc.max_length,v=0;for(a=0;a<=15;a++)t.bl_count[a]=0;for(u[2*t.heap[t.heap_max]+1]=0,n=t.heap_max+1;n<573;n++)(a=u[2*u[2*(r=t.heap[n])+1]+1]+1)>p&&(a=p,v++),u[2*r+1]=a,r>h||(t.bl_count[a]++,o=0,r>=d&&(o=l[r-d]),s=u[2*r],t.opt_len+=s*(a+o),c&&(t.static_len+=s*(f[2*r+1]+o)));if(0!==v){do{for(a=p-1;0===t.bl_count[a];)a--;t.bl_count[a]--,t.bl_count[a+1]+=2,t.bl_count[p]--,v-=2}while(v>0);for(a=p;0!==a;a--)for(r=t.bl_count[a];0!==r;)(i=t.heap[--n])>h||(u[2*i+1]!==a&&(t.opt_len+=(a-u[2*i+1])*u[2*i],u[2*i+1]=a),r--)}}(t,e),E(a,h,t.bl_count)},L=function(t,e,n){var r,i,a=-1,o=e[1],s=0,u=7,h=4;for(0===o&&(u=138,h=3),e[2*(n+1)+1]=65535,r=0;r<=n;r++)i=o,o=e[2*(r+1)+1],++s>=7;r<30;r++)for(_[r]=s<<7,t=0;t<1<0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),T(t,t.l_desc),T(t,t.d_desc),o=function(t){var e;for(L(t,t.dyn_ltree,t.l_desc.max_code),L(t,t.dyn_dtree,t.d_desc.max_code),T(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*s[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),i=t.opt_len+3+7>>>3,(a=t.static_len+3+7>>>3)<=i&&(i=a)):i=a=n+5,n+4<=i&&-1!==e?N(t,e,n,r):4===t.strategy||a===i?(m(t,2+(r?1:0),3),S(t,u,h)):(m(t,4+(r?1:0),3),function(t,e,n,r){var i;for(m(t,e-257,5),m(t,n-1,5),m(t,r-4,4),i=0;i>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(c[n]+256+1)]++,t.dyn_dtree[2*g(e)]++),t.last_lit===t.lit_bufsize-1},C=function(t){m(t,2,3),k(t,256,u),function(t){16===t.bi_valid?(b(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)},F=function(t,e,n,r){for(var i=65535&t|0,a=t>>>16&65535|0,o=0;0!==n;){n-=o=n>2e3?2e3:n;do{a=a+(i=i+e[r++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0},Z=new Uint32Array(function(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e}()),M=function(t,e,n,r){var i=Z,a=r+n;t^=-1;for(var o=r;o>>8^i[255&(t^e[o])];return-1^t},V={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},X={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},H=P,W=j,G=z,K=D,Y=C,J=X.Z_NO_FLUSH,$=X.Z_PARTIAL_FLUSH,q=X.Z_FULL_FLUSH,Q=X.Z_FINISH,tt=X.Z_BLOCK,et=X.Z_OK,nt=X.Z_STREAM_END,rt=X.Z_STREAM_ERROR,it=X.Z_DATA_ERROR,at=X.Z_BUF_ERROR,ot=X.Z_DEFAULT_COMPRESSION,st=X.Z_FILTERED,ut=X.Z_HUFFMAN_ONLY,ht=X.Z_RLE,ft=X.Z_FIXED,ct=X.Z_UNKNOWN,lt=X.Z_DEFLATED,dt=258,pt=262,vt=103,_t=113,yt=666,wt=function(t,e){return t.msg=V[e],e},gt=function(t){return(t<<1)-(t>4?9:0)},bt=function(t){for(var e=t.length;--e>=0;)t[e]=0},mt=function(t,e,n){return(e<t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},xt=function(t,e){G(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,kt(t.strm)},Et=function(t,e){t.pending_buf[t.pending++]=e},Ot=function(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Rt=function(t,e,n,r){var i=t.avail_in;return i>r&&(i=r),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),n),1===t.state.wrap?t.adler=F(t.adler,e,i,n):2===t.state.wrap&&(t.adler=M(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)},At=function(t,e){var n,r,i=t.max_chain_length,a=t.strstart,o=t.prev_length,s=t.nice_match,u=t.strstart>t.w_size-pt?t.strstart-(t.w_size-pt):0,h=t.window,f=t.w_mask,c=t.prev,l=t.strstart+dt,d=h[a+o-1],p=h[a+o];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(h[(n=e)+o]===p&&h[n+o-1]===d&&h[n]===h[a]&&h[++n]===h[a+1]){a+=2,n++;do{}while(h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&ao){if(t.match_start=e,o=r,r>=s)break;d=h[a+o-1],p=h[a+o]}}}while((e=c[e&f])>u&&0!=--i);return o<=t.lookahead?o:t.lookahead},Ut=function(t){var e,n,r,i,a,o=t.w_size;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=o+(o-pt)){t.window.set(t.window.subarray(o,o+o),0),t.match_start-=o,t.strstart-=o,t.block_start-=o,e=n=t.hash_size;do{r=t.head[--e],t.head[e]=r>=o?r-o:0}while(--n);e=n=o;do{r=t.prev[--e],t.prev[e]=r>=o?r-o:0}while(--n);i+=o}if(0===t.strm.avail_in)break;if(n=Rt(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=3)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=mt(t,t.ins_h,t.window[a+1]);t.insert&&(t.ins_h=mt(t,t.ins_h,t.window[a+3-1]),t.prev[a&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=a,a++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead=3&&(t.ins_h=mt(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n<=t.w_size-pt&&(t.match_length=At(t,n)),t.match_length>=3)if(r=K(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=mt(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=mt(t,t.ins_h,t.window[t.strstart+1]);else r=K(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2},Tt=function(t,e){for(var n,r,i;;){if(t.lookahead=3&&(t.ins_h=mt(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,r=K(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=mt(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,r&&(xt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((r=K(t,0,t.window[t.strstart-1]))&&xt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=K(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2};function Lt(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}var Bt=[new Lt(0,0,0,0,(function(t,e){var n=65535;for(n>t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Ut(t),0===t.lookahead&&e===J)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+n;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,xt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-pt&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Q?(xt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(xt(t,!1),t.strm.avail_out),1)})),new Lt(4,4,8,4,St),new Lt(4,5,16,8,St),new Lt(4,6,32,32,St),new Lt(4,4,16,16,Tt),new Lt(8,16,32,32,Tt),new Lt(8,16,128,128,Tt),new Lt(8,32,128,256,Tt),new Lt(32,128,258,1024,Tt),new Lt(32,258,258,4096,Tt)];function It(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=lt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),bt(this.dyn_ltree),bt(this.dyn_dtree),bt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),bt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),bt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Nt=function(t){var e,n=function(t){if(!t||!t.state)return wt(t,rt);t.total_in=t.total_out=0,t.data_type=ct;var e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:_t,t.adler=2===e.wrap?0:1,e.last_flush=J,H(e),et}(t);return n===et&&((e=t.state).window_size=2*e.w_size,bt(e.head),e.max_lazy_match=Bt[e.level].max_lazy,e.good_match=Bt[e.level].good_length,e.nice_match=Bt[e.level].nice_length,e.max_chain_length=Bt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0),n},Pt=function(t,e,n,r,i,a){if(!t)return rt;var o=1;if(e===ot&&(e=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>9||n!==lt||r<8||r>15||e<0||e>9||a<0||a>ft)return wt(t,rt);8===r&&(r=9);var s=new It;return t.state=s,s.strm=t,s.wrap=o,s.gzhead=null,s.w_bits=r,s.w_size=1<tt||e<0)return t?wt(t,rt):rt;var i=t.state;if(!t.output||!t.input&&0!==t.avail_in||i.status===yt&&e!==Q)return wt(t,0===t.avail_out?at:rt);i.strm=t;var a=i.last_flush;if(i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,Et(i,31),Et(i,139),Et(i,8),i.gzhead?(Et(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),Et(i,255&i.gzhead.time),Et(i,i.gzhead.time>>8&255),Et(i,i.gzhead.time>>16&255),Et(i,i.gzhead.time>>24&255),Et(i,9===i.level?2:i.strategy>=ut||i.level<2?4:0),Et(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(Et(i,255&i.gzhead.extra.length),Et(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=M(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(Et(i,0),Et(i,0),Et(i,0),Et(i,0),Et(i,0),Et(i,9===i.level?2:i.strategy>=ut||i.level<2?4:0),Et(i,3),i.status=_t);else{var o=lt+(i.w_bits-8<<4)<<8;o|=(i.strategy>=ut||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(o|=32),o+=31-o%31,i.status=_t,Ot(i,o),0!==i.strstart&&(Ot(i,t.adler>>>16),Ot(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>n&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),kt(t),n=i.pending,i.pending!==i.pending_buf_size));)Et(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),kt(t),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindexn&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),0===r&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),kt(t),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindexn&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),0===r&&(i.status=vt)}else i.status=vt;if(i.status===vt&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&kt(t),i.pending+2<=i.pending_buf_size&&(Et(i,255&t.adler),Et(i,t.adler>>8&255),t.adler=0,i.status=_t)):i.status=_t),0!==i.pending){if(kt(t),0===t.avail_out)return i.last_flush=-1,et}else if(0===t.avail_in&>(e)<=gt(a)&&e!==Q)return wt(t,at);if(i.status===yt&&0!==t.avail_in)return wt(t,at);if(0!==t.avail_in||0!==i.lookahead||e!==J&&i.status!==yt){var s=i.strategy===ut?function(t,e){for(var n;;){if(0===t.lookahead&&(Ut(t),0===t.lookahead)){if(e===J)return 1;break}if(t.match_length=0,n=K(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}(i,e):i.strategy===ht?function(t,e){for(var n,r,i,a,o=t.window;;){if(t.lookahead<=dt){if(Ut(t),t.lookahead<=dt&&e===J)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&((r=o[i=t.strstart-1])===o[++i]&&r===o[++i]&&r===o[++i])){a=t.strstart+dt;do{}while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=K(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=K(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}(i,e):Bt[i.level].func(i,e);if(3!==s&&4!==s||(i.status=yt),1===s||3===s)return 0===t.avail_out&&(i.last_flush=-1),et;if(2===s&&(e===$?Y(i):e!==tt&&(W(i,0,0,!1),e===q&&(bt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),kt(t),0===t.avail_out))return i.last_flush=-1,et}return e!==Q?et:i.wrap<=0?nt:(2===i.wrap?(Et(i,255&t.adler),Et(i,t.adler>>8&255),Et(i,t.adler>>16&255),Et(i,t.adler>>24&255),Et(i,255&t.total_in),Et(i,t.total_in>>8&255),Et(i,t.total_in>>16&255),Et(i,t.total_in>>24&255)):(Ot(i,t.adler>>>16),Ot(i,65535&t.adler)),kt(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?et:nt)},zt=function(t){if(!t||!t.state)return rt;var e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==vt&&e!==_t&&e!==yt?wt(t,rt):(t.state=null,e===_t?wt(t,it):et)},Dt=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},Ct=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var n=e.shift();if(n){if("object"!=tu(n))throw new TypeError(n+"must be non-object");for(var r in n)Dt(n,r)&&(t[r]=n[r])}}return t},Ft=function(t){for(var e=0,n=0,r=t.length;n=252?6:Vt>=248?5:Vt>=240?4:Vt>=224?3:Vt>=192?2:1;Mt[254]=Mt[254]=1;var Xt=function(t){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);var e,n,r,i,a,o=t.length,s=0;for(i=0;i>>6,e[a++]=128|63&n):n<65536?(e[a++]=224|n>>>12,e[a++]=128|n>>>6&63,e[a++]=128|63&n):(e[a++]=240|n>>>18,e[a++]=128|n>>>12&63,e[a++]=128|n>>>6&63,e[a++]=128|63&n);return e},Ht=function(t,e){var n,r,i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));var a=new Array(2*i);for(r=0,n=0;n4)a[r++]=65533,n+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&n1?a[r++]=65533:o<65536?a[r++]=o:(o-=65536,a[r++]=55296|o>>10&1023,a[r++]=56320|1023&o)}}}return function(t,e){if(e<65534&&t.subarray&&Zt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));for(var n="",r=0;rt.length&&(e=t.length);for(var n=e-1;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+Mt[t[n]]>e?n:e},Gt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Kt=Object.prototype.toString,Yt=X.Z_NO_FLUSH,Jt=X.Z_SYNC_FLUSH,$t=X.Z_FULL_FLUSH,qt=X.Z_FINISH,Qt=X.Z_OK,te=X.Z_STREAM_END,ee=X.Z_DEFAULT_COMPRESSION,ne=X.Z_DEFAULT_STRATEGY,re=X.Z_DEFLATED;function ie(t){this.options=Ct({level:ee,method:re,chunkSize:16384,windowBits:15,memLevel:8,strategy:ne},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gt,this.strm.avail_out=0;var n=Pt(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==Qt)throw new Error(V[n]);if(e.header&&function(t,e){t&&t.state&&(2!==t.state.wrap||(t.state.gzhead=e))}(this.strm,e.header),e.dictionary){var r;if(r="string"==typeof e.dictionary?Xt(e.dictionary):"[object ArrayBuffer]"===Kt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=function(t,e){var n=e.length;if(!t||!t.state)return rt;var r=t.state,i=r.wrap;if(2===i||1===i&&42!==r.status||r.lookahead)return rt;if(1===i&&(t.adler=F(t.adler,e,n,0)),r.wrap=0,n>=r.w_size){0===i&&(bt(r.head),r.strstart=0,r.block_start=0,r.insert=0);var a=new Uint8Array(r.w_size);a.set(e.subarray(n-r.w_size,n),0),e=a,n=r.w_size}var o=t.avail_in,s=t.next_in,u=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,Ut(r);r.lookahead>=3;){var h=r.strstart,f=r.lookahead-2;do{r.ins_h=mt(r,r.ins_h,r.window[h+3-1]),r.prev[h&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=h,h++}while(--f);r.strstart=h,r.lookahead=2,Ut(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=s,t.input=u,t.avail_in=o,r.wrap=i,et}(this.strm,r),n!==Qt)throw new Error(V[n]);this._dict_set=!0}}function ae(t,e){var n=new ie(e);if(n.push(t,!0),n.err)throw n.msg||V[n.err];return n.result}ie.prototype.push=function(t,e){var n,r,i=this.strm,a=this.options.chunkSize;if(this.ended)return!1;for(r=e===~~e?e:!0===e?qt:Yt,"string"==typeof t?i.input=Xt(t):"[object ArrayBuffer]"===Kt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),(r===Jt||r===$t)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if((n=jt(i,r))===te)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),n=zt(this.strm),this.onEnd(n),this.ended=!0,n===Qt;if(0!==i.avail_out){if(r>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},ie.prototype.onData=function(t){this.chunks.push(t)},ie.prototype.onEnd=function(t){t===Qt&&(this.result=Ft(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var oe=ae,se=function(t,e){var n,r,i,a,o,s,u,h,f,c,l,d,p,v,_,y,w,g,b,m,k,x,E,O,R=t.state;n=t.next_in,E=t.input,r=n+(t.avail_in-5),i=t.next_out,O=t.output,a=i-(e-t.avail_out),o=i+(t.avail_out-257),s=R.dmax,u=R.wsize,h=R.whave,f=R.wnext,c=R.window,l=R.hold,d=R.bits,p=R.lencode,v=R.distcode,_=(1<>>=g=w>>>24,d-=g,0===(g=w>>>16&255))O[i++]=65535&w;else{if(!(16&g)){if(0==(64&g)){w=p[(65535&w)+(l&(1<>>=g,d-=g),d<15&&(l+=E[n++]<>>=g=w>>>24,d-=g,!(16&(g=w>>>16&255))){if(0==(64&g)){w=v[(65535&w)+(l&(1<s){t.msg="invalid distance too far back",R.mode=30;break t}if(l>>>=g,d-=g,m>(g=i-a)){if((g=m-g)>h&&R.sane){t.msg="invalid distance too far back",R.mode=30;break t}if(k=0,x=c,0===f){if(k+=u-g,g2;)O[i++]=x[k++],O[i++]=x[k++],O[i++]=x[k++],b-=3;b&&(O[i++]=x[k++],b>1&&(O[i++]=x[k++]))}else{k=i-m;do{O[i++]=O[k++],O[i++]=O[k++],O[i++]=O[k++],b-=3}while(b>2);b&&(O[i++]=O[k++],b>1&&(O[i++]=O[k++]))}break}}break}}while(n>3,l&=(1<<(d-=b<<3))-1,t.next_in=n,t.next_out=i,t.avail_in=n=1&&0===T[m];m--);if(k>m&&(k=m),0===m)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(b=1;b0&&(0===t||1!==m))return-1;for(L[1]=0,w=1;w<15;w++)L[w+1]=L[w]+T[w];for(g=0;g852||2===t&&R>592)return 1;for(;;){p=w-E,o[g]d?(v=B[I+o[g]],_=U[S+o[g]]):(v=96,_=0),u=1<>E)+(h-=u)]=p<<24|v<<16|_|0}while(0!==h);for(u=1<>=1;if(0!==u?(A&=u-1,A+=u):A=0,g++,0==--T[w]){if(w===m)break;w=e[n+o[g]]}if(w>k&&(A&c)!==f){for(0===E&&(E=k),l+=b,O=1<<(x=w-E);x+E852||2===t&&R>592)return 1;i[f=A&c]=k<<24|x<<16|l-a|0}}return 0!==A&&(i[l+A]=w-E<<24|64<<16|0),s.bits=k,0},de=X.Z_FINISH,pe=X.Z_BLOCK,ve=X.Z_TREES,_e=X.Z_OK,ye=X.Z_STREAM_END,we=X.Z_NEED_DICT,ge=X.Z_STREAM_ERROR,be=X.Z_DATA_ERROR,me=X.Z_MEM_ERROR,ke=X.Z_BUF_ERROR,xe=X.Z_DEFLATED,Ee=12,Oe=30,Re=function(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)};function Ae(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Ue,Se,Te=function(t){if(!t||!t.state)return ge;var e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,function(t){if(!t||!t.state)return ge;var e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,_e}(t)},Le=!0,Be=function(t){if(Le){Ue=new Int32Array(512),Se=new Int32Array(32);for(var e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(le(1,t.lens,0,288,Ue,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;le(2,t.lens,0,32,Se,0,t.work,{bits:5}),Le=!1}t.lencode=Ue,t.lenbits=9,t.distcode=Se,t.distbits=5},Ie=function(t,e,n,r){var i,a=t.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(e.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>r&&(i=r),a.window.set(e.subarray(n-r,n-r+i),a.wnext),(r-=i)?(a.window.set(e.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave>4),e<48&&(e&=15)),e&&(e<8||e>15)?ge:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,Te(t))}(t,e);return r!==_e&&(t.state=null),r},je=function(t,e){var n,r,i,a,o,s,u,h,f,c,l,d,p,v,_,y,w,g,b,m,k,x,E,O,R=0,A=new Uint8Array(4),U=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return ge;(n=t.state).mode===Ee&&(n.mode=13),o=t.next_out,i=t.output,u=t.avail_out,a=t.next_in,r=t.input,s=t.avail_in,h=n.hold,f=n.bits,c=s,l=u,x=_e;t:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;f<16;){if(0===s)break t;s--,h+=r[a++]<>>8&255,n.check=M(n.check,A,2,0),h=0,f=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",n.mode=Oe;break}if((15&h)!==xe){t.msg="unknown compression method",n.mode=Oe;break}if(f-=4,k=8+(15&(h>>>=4)),0===n.wbits)n.wbits=k;else if(k>n.wbits){t.msg="invalid window size",n.mode=Oe;break}n.dmax=1<>8&1),512&n.flags&&(A[0]=255&h,A[1]=h>>>8&255,n.check=M(n.check,A,2,0)),h=0,f=0,n.mode=3;case 3:for(;f<32;){if(0===s)break t;s--,h+=r[a++]<>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,n.check=M(n.check,A,4,0)),h=0,f=0,n.mode=4;case 4:for(;f<16;){if(0===s)break t;s--,h+=r[a++]<>8),512&n.flags&&(A[0]=255&h,A[1]=h>>>8&255,n.check=M(n.check,A,2,0)),h=0,f=0,n.mode=5;case 5:if(1024&n.flags){for(;f<16;){if(0===s)break t;s--,h+=r[a++]<>>8&255,n.check=M(n.check,A,2,0)),h=0,f=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((d=n.length)>s&&(d=s),d&&(n.head&&(k=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(a,a+d),k)),512&n.flags&&(n.check=M(n.check,r,d,a)),s-=d,a+=d,n.length-=d),n.length))break t;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===s)break t;d=0;do{k=r[a+d++],n.head&&k&&n.length<65536&&(n.head.name+=String.fromCharCode(k))}while(k&&d>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=Ee;break;case 10:for(;f<32;){if(0===s)break t;s--,h+=r[a++]<>>=7&f,f-=7&f,n.mode=27;break}for(;f<3;){if(0===s)break t;s--,h+=r[a++]<>>=1)){case 0:n.mode=14;break;case 1:if(Be(n),n.mode=20,e===ve){h>>>=2,f-=2;break t}break;case 2:n.mode=17;break;case 3:t.msg="invalid block type",n.mode=Oe}h>>>=2,f-=2;break;case 14:for(h>>>=7&f,f-=7&f;f<32;){if(0===s)break t;s--,h+=r[a++]<>>16^65535)){t.msg="invalid stored block lengths",n.mode=Oe;break}if(n.length=65535&h,h=0,f=0,n.mode=15,e===ve)break t;case 15:n.mode=16;case 16:if(d=n.length){if(d>s&&(d=s),d>u&&(d=u),0===d)break t;i.set(r.subarray(a,a+d),o),s-=d,a+=d,u-=d,o+=d,n.length-=d;break}n.mode=Ee;break;case 17:for(;f<14;){if(0===s)break t;s--,h+=r[a++]<>>=5,f-=5,n.ndist=1+(31&h),h>>>=5,f-=5,n.ncode=4+(15&h),h>>>=4,f-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=Oe;break}n.have=0,n.mode=18;case 18:for(;n.have>>=3,f-=3}for(;n.have<19;)n.lens[U[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},x=le(0,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,x){t.msg="invalid code lengths set",n.mode=Oe;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,w=65535&R,!((_=R>>>24)<=f);){if(0===s)break t;s--,h+=r[a++]<>>=_,f-=_,n.lens[n.have++]=w;else{if(16===w){for(O=_+2;f>>=_,f-=_,0===n.have){t.msg="invalid bit length repeat",n.mode=Oe;break}k=n.lens[n.have-1],d=3+(3&h),h>>>=2,f-=2}else if(17===w){for(O=_+3;f>>=_)),h>>>=3,f-=3}else{for(O=_+7;f>>=_)),h>>>=7,f-=7}if(n.have+d>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=Oe;break}for(;d--;)n.lens[n.have++]=k}}if(n.mode===Oe)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=Oe;break}if(n.lenbits=9,E={bits:n.lenbits},x=le(1,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,x){t.msg="invalid literal/lengths set",n.mode=Oe;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},x=le(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,x){t.msg="invalid distances set",n.mode=Oe;break}if(n.mode=20,e===ve)break t;case 20:n.mode=21;case 21:if(s>=6&&u>=258){t.next_out=o,t.avail_out=u,t.next_in=a,t.avail_in=s,n.hold=h,n.bits=f,se(t,l),o=t.next_out,i=t.output,u=t.avail_out,a=t.next_in,r=t.input,s=t.avail_in,h=n.hold,f=n.bits,n.mode===Ee&&(n.back=-1);break}for(n.back=0;y=(R=n.lencode[h&(1<>>16&255,w=65535&R,!((_=R>>>24)<=f);){if(0===s)break t;s--,h+=r[a++]<>g)])>>>16&255,w=65535&R,!(g+(_=R>>>24)<=f);){if(0===s)break t;s--,h+=r[a++]<>>=g,f-=g,n.back+=g}if(h>>>=_,f-=_,n.back+=_,n.length=w,0===y){n.mode=26;break}if(32&y){n.back=-1,n.mode=Ee;break}if(64&y){t.msg="invalid literal/length code",n.mode=Oe;break}n.extra=15&y,n.mode=22;case 22:if(n.extra){for(O=n.extra;f>>=n.extra,f-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;y=(R=n.distcode[h&(1<>>16&255,w=65535&R,!((_=R>>>24)<=f);){if(0===s)break t;s--,h+=r[a++]<>g)])>>>16&255,w=65535&R,!(g+(_=R>>>24)<=f);){if(0===s)break t;s--,h+=r[a++]<>>=g,f-=g,n.back+=g}if(h>>>=_,f-=_,n.back+=_,64&y){t.msg="invalid distance code",n.mode=Oe;break}n.offset=w,n.extra=15&y,n.mode=24;case 24:if(n.extra){for(O=n.extra;f>>=n.extra,f-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=Oe;break}n.mode=25;case 25:if(0===u)break t;if(d=l-u,n.offset>d){if((d=n.offset-d)>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=Oe;break}d>n.wnext?(d-=n.wnext,p=n.wsize-d):p=n.wnext-d,d>n.length&&(d=n.length),v=n.window}else v=i,p=o-n.offset,d=n.length;d>u&&(d=u),u-=d,n.length-=d;do{i[o++]=v[p++]}while(--d);0===n.length&&(n.mode=21);break;case 26:if(0===u)break t;i[o++]=n.length,u--,n.mode=21;break;case 27:if(n.wrap){for(;f<32;){if(0===s)break t;s--,h|=r[a++]<=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gt,this.strm.avail_out=0;var n=Pe(this.strm,e.windowBits);if(n!==Ve)throw new Error(V[n]);if(this.header=new Ce,function(t,e){if(!t||!t.state)return ge;var n=t.state;0==(2&n.wrap)||(n.head=e,e.done=!1)}(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Xt(e.dictionary):"[object ArrayBuffer]"===Fe.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=De(this.strm,e.dictionary))!==Ve))throw new Error(V[n])}function Je(t,e){var n=new Ye(e);if(n.push(t),n.err)throw n.msg||V[n.err];return n.result}Ye.prototype.push=function(t,e){var n,r,i,a=this.strm,o=this.options.chunkSize,s=this.options.dictionary;if(this.ended)return!1;for(r=e===~~e?e:!0===e?Me:Ze,"[object ArrayBuffer]"===Fe.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(o),a.next_out=0,a.avail_out=o),(n=je(a,r))===He&&s&&((n=De(a,s))===Ve?n=je(a,r):n===Ge&&(n=He));a.avail_in>0&&n===Xe&&a.state.wrap>0&&0!==t[a.next_in];)Ne(a),n=je(a,r);switch(n){case We:case Ge:case He:case Ke:return this.onEnd(n),this.ended=!0,!1}if(i=a.avail_out,a.next_out&&(0===a.avail_out||n===Xe))if("string"===this.options.to){var u=Wt(a.output,a.next_out),h=a.next_out-u,f=Ht(a.output,u);a.next_out=h,a.avail_out=o-h,h&&a.output.set(a.output.subarray(u,u+h),0),this.onData(f)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(n!==Ve||0!==i){if(n===Xe)return n=ze(this.strm),this.onEnd(n),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},Ye.prototype.onData=function(t){this.chunks.push(t)},Ye.prototype.onEnd=function(t){t===Ve&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ft(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};for(var $e=oe,qe=Ye,Qe=Je,tn=[137,80,78,71,13,10,26,10],en=[],nn=0;nn<256;nn++){for(var rn=nn,an=0;an<8;an++)1&rn?rn=3988292384^rn>>>1:rn>>>=1;en[nn]=rn}var on,sn,un,hn;function fn(t,e){return(4294967295^function(t,e,n){for(var r=4294967295,i=0;i>>8;return r}(0,t,e))>>>0}!function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.GREYSCALE=0]="GREYSCALE",t[t.TRUECOLOUR=2]="TRUECOLOUR",t[t.INDEXED_COLOUR=3]="INDEXED_COLOUR",t[t.GREYSCALE_ALPHA=4]="GREYSCALE_ALPHA",t[t.TRUECOLOUR_ALPHA=6]="TRUECOLOUR_ALPHA"}(on||(on={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.DEFLATE=0]="DEFLATE"}(sn||(sn={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.ADAPTIVE=0]="ADAPTIVE"}(un||(un={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.NO_INTERLACE=0]="NO_INTERLACE",t[t.ADAM7=1]="ADAM7"}(hn||(hn={}));var cn=new Uint8Array(0),ln=new Uint16Array([255]),dn=255===new Uint8Array(ln.buffer)[0],pn=function(t){su(n,t);var e=vu(n);function n(t){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ru(this,n),r=e.call(this,t);var a=i.checkCrc,o=void 0!==a&&a;return r._checkCrc=o,r._inflator=new qe,r._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},r._end=!1,r._hasPalette=!1,r._palette=[],r._compressionMethod=sn.UNKNOWN,r._filterMethod=un.UNKNOWN,r._interlaceMethod=hn.UNKNOWN,r._colorType=-1,r.setBigEndian(),r}return au(n,[{key:"decode",value:function(){for(this.decodeSignature();!this._end;)this.decodeChunk();return this.decodeImage(),this._png}},{key:"decodeSignature",value:function(){for(var t=0;tthis._palette.length)throw new Error("tRNS chunk contains more alpha values than there are palette colors (".concat(t," vs ").concat(this._palette.length,")"));for(var e=0;e>8&255;this._png.data=c}else this._png.data=s}}]),n}(n);function vn(t,e,n){for(var r=0;r>1)&255}else{for(;a>1)&255;for(;a>1)&255}}function gn(t,e,n,r,i){var a=0;if(0===n.length){for(;a1&&void 0!==arguments[1]?arguments[1]:{};return ru(this,r),(n=e.call(this))._colorType=on.UNKNOWN,n._zlibOptions=Qs(Qs({},kn),i.zlib),n._png=n._checkData(t),n.setBigEndian(),n}return au(r,[{key:"encode",value:function(){return this.encodeSignature(),this.encodeIHDR(),this.encodeData(),this.encodeIEND(),this.toArray()}},{key:"encodeSignature",value:function(){this.writeBytes(tn)}},{key:"encodeIHDR",value:function(){this.writeUint32(13),this.writeChars("IHDR"),this.writeUint32(this._png.width),this.writeUint32(this._png.height),this.writeByte(this._png.depth),this.writeByte(this._colorType),this.writeByte(sn.DEFLATE),this.writeByte(un.ADAPTIVE),this.writeByte(hn.NO_INTERLACE),this.writeCrc(17)}},{key:"encodeIEND",value:function(){this.writeUint32(0),this.writeChars("IEND"),this.writeCrc(4)}},{key:"encodeIDAT",value:function(t){this.writeUint32(t.length),this.writeChars("IDAT"),this.writeBytes(t),this.writeCrc(t.length+4)}},{key:"encodeData",value:function(){for(var t=this._png,e=t.width,r=t.height,i=t.channels,a=t.depth,o=t.data,s=i*e,u=(new n).setBigEndian(),h=0,f=0;f0)return t;throw new TypeError("".concat(e," must be a positive integer"))}function On(t,e,n,r){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:4,n="";return"number"==typeof e?n=_u(" ",Math.min(10,e)):"string"==typeof e&&(n=e.slice(0,10)),Kh(t,n,-1)}var Jh=function(){function t(e,n,r){ru(this,t),this.startingLine=r||0,this.lineIndex=-1;for(var i=[],a=0;a=n;)e.push(this.next());return new t(e,this.indentString,this.getLineNumber()-e.length)}},{key:"next",value:function(){if(this.finished())throw new Error("Trying to next finished generator");return this.lineIndex++,this.getLine()}},{key:"peek",value:function(){return this.getLine(this.lineIndex+1)}},{key:"finished",value:function(){return this.lineIndex==this.lines.length-1}},{key:"getLine",value:function(t){return(t=void 0!==t?t:this.lineIndex)>=this.lines.length?null:this.lines[t][0]}},{key:"findIndentString",value:function(){for(var t=0,e=this.lines;t]+)/),o=void 0,s=void 0,u=void 0;wu(r,'"')&&(i=r.match(/^"(.*?)":(?: |$)/)),a&&(u=a[1],r=r.replace(a[0],"")),i?(n||(n={}),o=i[1],s=r.replace(i[0],"").trim()):wu(r,"-")&&(n||(n=[]),s=r.slice(1).trim()),s=s?qh(s,u):$h(t.nextGroup(),u),Array.isArray(n)?n.push(s):n[o]=s}return e&&(n={type:e,data:n}),n}function qh(t,e){return t=JSON.parse(t),e&&(t={type:e,data:t}),t}function Qh(t){var e=t.replace(/\t/g,"\t").split("\n");return $h(new Jh(e))}function tf(t){var e;if(Array.isArray(t)){e=[];for(var n=0;n","Rectangle","List","Rectangle","List","Char",null,"List","Vector3","Nullable","Char",null],s.verticalSpacing=s.verticalLineSpacing,delete s.verticalLineSpacing);var f=function(t,e){var n=[],r=[],i=function t(i,a){var o,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,u=e[s];if(ef(u))return{converted:{type:u,data:i},traversed:s};if(null===u)return{converted:i,traversed:s};if(wu(u,"Nullable")){var h,f,c=u.split(":"),l=c[0],d=c[1],p=void 0===d?1:d;if(p=+p,null===i)h=null,f=s+p;else if("object"!==tu(i)||i&&0!==Object.keys(i).length){var v=t(i,[].concat(a),s+1);h=v.converted,f=v.traversed}else h={type:e[s+1],data:tf(i)},f=s+p;return{converted:{type:l,data:{data:h}},traversed:f}}if(nf(u))return"Texture2D"===u?(n.push({path:a.join(".")}),{converted:{type:u,data:{format:i.format}},traversed:s}):("TBin"===u&&r.push({path:a.join(".")}),{converted:{type:u,data:{}},traversed:s});o=Array.isArray(i)?[]:{};for(var _=s,y=!0,w=!wu(u,"Dictionary")&&!wu(u,"Array")&&!wu(u,"List"),g=Object.keys(i),b=0;b0&&(e.extractedImages=l),d.length>0&&(e.extractedMaps=d),e}function of(t){var e={},n=t.xnbData,r=n.compressed,i=n.readerData,a=n.hiDef,o=n.target;return e.header={target:o,formatVersion:5,compressed:r?"a"===o||"i"===o?64:128:0,hidef:a},e.readers=tf(i),e.content=rf(t.content),"SpriteFont"===nh.simplifyType(e.readers[0].type)&&(e.content.verticalLineSpacing=e.content.verticalSpacing,delete e.content.verticalSpacing),e}function sf(t,e){if(t&&"object"==tu(t)){if(t.hasOwnProperty(e))return{parent:t,value:t[e]};for(var n=Object.keys(t),r=0;r1&&void 0!==arguments[1]&&arguments[1],n=sf(t,"export");if(n){var r=n.value,i=r.type,a=r.data;return"Texture2D"===i&&(a=Gh(r.width,r.height,new Uint8Array(a))),cf(a,i)}if(e){var o=JSON.stringify(t,null,4);return cf(o,"JSON")}return null}function df(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.yaml,r=void 0!==n&&n,i=e.contentOnly,a=void 0!==i&&i,o=e.fileName,s=void 0===o?null:o;if(r&&a&&(r=!1),!t.hasOwnProperty("content"))throw new th("Invalid object!");var u=[],h=t.content,f=lf(h,a);if(null!==f&&u.push(f),a)return u;var c=JSON.stringify(t,(function(t,e){return"export"===t?"string"==typeof s&&""!==s?"".concat(s,".").concat(hf(e.type)):"".concat(e.type,".").concat(hf(e.type)):e}),4),l=c;return r&&(l=Yh(af(t))),u.unshift(cf(l,r?"yaml":"JSON")),u}function pf(t){var e=t.toLowerCase();return"none"===e?0:"lz4"===e?64:null}function vf(t){return _f.apply(this,arguments)}function _f(){return(_f=nu(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("function"==typeof Blob&&e instanceof Blob)){t.next=4;break}return t.abrupt("return",e.text());case 4:if(!("function"==typeof Buffer&&e instanceof Buffer)){t.next=8;break}return t.abrupt("return",e.toString());case 8:return t.abrupt("return",e);case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function yf(t){return wf.apply(this,arguments)}function wf(){return(wf=nu(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("function"==typeof Blob&&e instanceof Blob)){t.next=4;break}return t.abrupt("return",e.arrayBuffer());case 4:if(!("function"==typeof Buffer&&e instanceof Buffer)){t.next=6;break}return t.abrupt("return",e.buffer);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function gf(t,e){return bf.apply(this,arguments)}function bf(){return bf=nu(regeneratorRuntime.mark((function t(e,n){var r,i,a,o,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("png"!==e){t.next=7;break}return t.next=3,yf(n.png);case 3:return r=t.sent,4===(i=Wh(new Uint8Array(r))).channel&&8===i.depth&&void 0===i.palette||(i.data=Zh(i)),t.abrupt("return",{type:"Texture2D",data:i.data,width:i.width,height:i.height});case 7:if("cso"!==e){t.next=12;break}return t.next=10,yf(n.cso);case 10:return a=t.sent,t.abrupt("return",{type:"Effect",data:a});case 12:if("tbin"!==e){t.next=17;break}return t.next=15,yf(n.tbin);case 15:return o=t.sent,t.abrupt("return",{type:"TBin",data:o});case 17:if("xml"!==e){t.next=22;break}return t.next=20,vf(n.xml);case 20:return s=t.sent,t.abrupt("return",{type:"BmFont",data:s});case 22:case"end":return t.stop()}}),t)}))),bf.apply(this,arguments)}function mf(t){return kf.apply(this,arguments)}function kf(){return kf=nu(regeneratorRuntime.mark((function t(e){var n,r,i,a,o,s,u,h,f,c,l,d,p=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=p.length>1&&void 0!==p[1]?p[1]:{},r=n.compression,i=void 0===r?"default":r,a=e.json||e.yaml){t.next=5;break}throw new th("There is no JSON or YAML file to pack!");case 5:return t.next=7,vf(a);case 7:if(o=t.sent,s=null,s=e.json?JSON.parse(o):of(Qh(o)),null!==(u=pf(i))&&(s.header.compressed=u),s.hasOwnProperty("content")){t.next=14;break}throw new th("".concat(a.name,' does not have "content".'));case 14:if(!(h=sf(s.content,"export"))){t.next=21;break}return f=h.parent,c=h.value,l=uf(c),d=l[1],t.next=20,gf(d,e);case 20:f.export=t.sent;case 21:return t.abrupt("return",s);case 22:case"end":return t.stop()}}),t)}))),kf.apply(this,arguments)}function xf(t){var e=uf(t)[1],n=function(t){return"png"===t?"Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553":"tbin"===t?"xTile.Pipeline.TideReader, xTile":"xml"===t?"BmFont.XmlSourceReader, BmFont, Version=2012.1.7.0, Culture=neutral, PublicKeyToken=null":void 0}(e),r={export:t};"png"===e&&(r.format=0);var i={header:{target:"w",formatVersion:5,hidef:!0,compressed:!0},readers:[{type:n,version:0}],content:r};return JSON.stringify(i)}function Ef(t){return Of.apply(this,arguments)}function Of(){return(Of=nu(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("undefined"==typeof window){t.next=8;break}if(n=uf(e.name),"xnb"===n[1]){t.next=4;break}return t.abrupt("return",new Error("Invalid XNB File!"));case 4:return t.next=6,e.arrayBuffer();case 6:return r=t.sent,t.abrupt("return",Rf(r));case 8:return t.abrupt("return",Rf(e.buffer));case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Rf(t){return(new Ch).load(t)}function Af(t){var e=lf(t.content,!0),n=e.data,r=e.extension;return new Ph(n,r)}function Uf(t){for(var e={},n={},r=0;r1&&void 0!==arguments[1]?arguments[1]:{},n=Uf(t),r=[],i=Object.keys(n),a=0;a1&&void 0!==arguments[1]?arguments[1]:{},n=e.yaml,r=void 0!==n&&n,i=e.contentOnly,a=void 0!==i&&i,o=e.fileName,s=void 0===o?null:o;"undefined"!=typeof window&&null===s&&(s=t.name);var u=uf(s),h=u[0],f=function(t){return df(t,{yaml:r,contentOnly:a,fileName:h})};return Ef(t).then(f)},t.unpackToXnbData=Ef,t.xnbDataToContent=Af,t.xnbDataToFiles=df,Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XNB={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=function(t){return t&&t.Math==Math&&t},r=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e&&e)||function(){return this}()||Function("return this")(),i={},a=function(t){try{return!!t()}catch(t){return!0}},o=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),s=!a((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),u=s,h=Function.prototype.call,f=u?h.bind(h):function(){return h.apply(h,arguments)},c={},l={}.propertyIsEnumerable,d=Object.getOwnPropertyDescriptor,p=d&&!l.call({1:2},1);c.f=p?function(t){var e=d(this,t);return!!e&&e.enumerable}:l;var v,y,_=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},w=s,g=Function.prototype,b=g.bind,m=g.call,k=w&&b.bind(m,m),x=w?function(t){return t&&k(t)}:function(t){return t&&function(){return m.apply(t,arguments)}},E=x,R=E({}.toString),O=E("".slice),A=function(t){return O(R(t),8,-1)},S=x,U=a,T=A,L=r.Object,B=S("".split),I=U((function(){return!L("z").propertyIsEnumerable(0)}))?function(t){return"String"==T(t)?B(t,""):L(t)}:L,P=r.TypeError,N=function(t){if(null==t)throw P("Can't call method on "+t);return t},j=I,C=N,z=function(t){return j(C(t))},D=function(t){return"function"==typeof t},F=D,Z=function(t){return"object"==typeof t?null!==t:F(t)},M=r,V=D,X=function(t){return V(t)?t:void 0},H=function(t,e){return arguments.length<2?X(M[t]):M[t]&&M[t][e]},W=x({}.isPrototypeOf),G=H("navigator","userAgent")||"",K=r,Y=G,J=K.process,$=K.Deno,q=J&&J.versions||$&&$.version,Q=q&&q.v8;Q&&(y=(v=Q.split("."))[0]>0&&v[0]<4?1:+(v[0]+v[1])),!y&&Y&&(!(v=Y.match(/Edge\/(\d+)/))||v[1]>=74)&&(v=Y.match(/Chrome\/(\d+)/))&&(y=+v[1]);var tt=y,et=tt,nt=a,rt=!!Object.getOwnPropertySymbols&&!nt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&et&&et<41})),it=rt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,at=H,ot=D,st=W,ut=it,ht=r.Object,ft=ut?function(t){return"symbol"==typeof t}:function(t){var e=at("Symbol");return ot(e)&&st(e.prototype,ht(t))},ct=r.String,lt=function(t){try{return ct(t)}catch(t){return"Object"}},dt=D,pt=lt,vt=r.TypeError,yt=function(t){if(dt(t))return t;throw vt(pt(t)+" is not a function")},_t=yt,wt=function(t,e){var n=t[e];return null==n?void 0:_t(n)},gt=f,bt=D,mt=Z,kt=r.TypeError,xt={exports:{}},Et=r,Rt=Object.defineProperty,Ot=function(t,e){try{Rt(Et,t,{value:e,configurable:!0,writable:!0})}catch(n){Et[t]=e}return e},At=Ot,St="__core-js_shared__",Ut=r[St]||At(St,{}),Tt=Ut;(xt.exports=function(t,e){return Tt[t]||(Tt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.22.4",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.22.4/LICENSE",source:"https://github.com/zloirock/core-js"});var Lt=N,Bt=r.Object,It=function(t){return Bt(Lt(t))},Pt=x({}.hasOwnProperty),Nt=Object.hasOwn||function(t,e){return Pt(It(t),e)},jt=x,Ct=0,zt=Math.random(),Dt=jt(1..toString),Ft=function(t){return"Symbol("+(void 0===t?"":t)+")_"+Dt(++Ct+zt,36)},Zt=r,Mt=xt.exports,Vt=Nt,Xt=Ft,Ht=rt,Wt=it,Gt=Mt("wks"),Kt=Zt.Symbol,Yt=Kt&&Kt.for,Jt=Wt?Kt:Kt&&Kt.withoutSetter||Xt,$t=function(t){if(!Vt(Gt,t)||!Ht&&"string"!=typeof Gt[t]){var e="Symbol."+t;Ht&&Vt(Kt,t)?Gt[t]=Kt[t]:Gt[t]=Wt&&Yt?Yt(e):Jt(e)}return Gt[t]},qt=f,Qt=Z,te=ft,ee=wt,ne=function(t,e){var n,r;if("string"===e&&bt(n=t.toString)&&!mt(r=gt(n,t)))return r;if(bt(n=t.valueOf)&&!mt(r=gt(n,t)))return r;if("string"!==e&&bt(n=t.toString)&&!mt(r=gt(n,t)))return r;throw kt("Can't convert object to primitive value")},re=$t,ie=r.TypeError,ae=re("toPrimitive"),oe=function(t,e){if(!Qt(t)||te(t))return t;var n,r=ee(t,ae);if(r){if(void 0===e&&(e="default"),n=qt(r,t,e),!Qt(n)||te(n))return n;throw ie("Can't convert object to primitive value")}return void 0===e&&(e="number"),ne(t,e)},se=ft,ue=function(t){var e=oe(t,"string");return se(e)?e:e+""},he=Z,fe=r.document,ce=he(fe)&&he(fe.createElement),le=function(t){return ce?fe.createElement(t):{}},de=le,pe=!o&&!a((function(){return 7!=Object.defineProperty(de("div"),"a",{get:function(){return 7}}).a})),ve=o,ye=f,_e=c,we=_,ge=z,be=ue,me=Nt,ke=pe,xe=Object.getOwnPropertyDescriptor;i.f=ve?xe:function(t,e){if(t=ge(t),e=be(e),ke)try{return xe(t,e)}catch(t){}if(me(t,e))return we(!ye(_e.f,t,e),t[e])};var Ee={},Re=o&&a((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Oe=r,Ae=Z,Se=Oe.String,Ue=Oe.TypeError,Te=function(t){if(Ae(t))return t;throw Ue(Se(t)+" is not an object")},Le=o,Be=pe,Ie=Re,Pe=Te,Ne=ue,je=r.TypeError,Ce=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,De="enumerable",Fe="configurable",Ze="writable";Ee.f=Le?Ie?function(t,e,n){if(Pe(t),e=Ne(e),Pe(n),"function"==typeof t&&"prototype"===e&&"value"in n&&Ze in n&&!n.writable){var r=ze(t,e);r&&r.writable&&(t[e]=n.value,n={configurable:Fe in n?n.configurable:r.configurable,enumerable:De in n?n.enumerable:r.enumerable,writable:!1})}return Ce(t,e,n)}:Ce:function(t,e,n){if(Pe(t),e=Ne(e),Pe(n),Be)try{return Ce(t,e,n)}catch(t){}if("get"in n||"set"in n)throw je("Accessors not supported");return"value"in n&&(t[e]=n.value),t};var Me=Ee,Ve=_,Xe=o?function(t,e,n){return Me.f(t,e,Ve(1,n))}:function(t,e,n){return t[e]=n,t},He={exports:{}},We=o,Ge=Nt,Ke=Function.prototype,Ye=We&&Object.getOwnPropertyDescriptor,Je=Ge(Ke,"name"),$e={EXISTS:Je,PROPER:Je&&"something"===function(){}.name,CONFIGURABLE:Je&&(!We||We&&Ye(Ke,"name").configurable)},qe=D,Qe=Ut,tn=x(Function.toString);qe(Qe.inspectSource)||(Qe.inspectSource=function(t){return tn(t)});var en,nn,rn,an=Qe.inspectSource,on=D,sn=an,un=r.WeakMap,hn=on(un)&&/native code/.test(sn(un)),fn=xt.exports,cn=Ft,ln=fn("keys"),dn={},pn=hn,vn=r,yn=x,_n=Z,wn=Xe,gn=Nt,bn=Ut,mn=function(t){return ln[t]||(ln[t]=cn(t))},kn=dn,xn="Object already initialized",En=vn.TypeError,Rn=vn.WeakMap;if(pn||bn.state){var On=bn.state||(bn.state=new Rn),An=yn(On.get),Sn=yn(On.has),Un=yn(On.set);en=function(t,e){if(Sn(On,t))throw new En(xn);return e.facade=t,Un(On,t,e),e},nn=function(t){return An(On,t)||{}},rn=function(t){return Sn(On,t)}}else{var Tn=mn("state");kn[Tn]=!0,en=function(t,e){if(gn(t,Tn))throw new En(xn);return e.facade=t,wn(t,Tn,e),e},nn=function(t){return gn(t,Tn)?t[Tn]:{}},rn=function(t){return gn(t,Tn)}}var Ln={set:en,get:nn,has:rn,enforce:function(t){return rn(t)?nn(t):en(t,{})},getterFor:function(t){return function(e){var n;if(!_n(e)||(n=nn(e)).type!==t)throw En("Incompatible receiver, "+t+" required");return n}}},Bn=a,In=D,Pn=Nt,Nn=Ee.f,jn=$e.CONFIGURABLE,Cn=an,zn=Ln.enforce,Dn=Ln.get,Fn=!Bn((function(){return 8!==Nn((function(){}),"length",{value:8}).length})),Zn=String(String).split("String"),Mn=He.exports=function(t,e,n){"Symbol("===String(e).slice(0,7)&&(e="["+String(e).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(e="get "+e),n&&n.setter&&(e="set "+e),(!Pn(t,"name")||jn&&t.name!==e)&&Nn(t,"name",{value:e,configurable:!0}),Fn&&n&&Pn(n,"arity")&&t.length!==n.arity&&Nn(t,"length",{value:n.arity});var r=zn(t);return Pn(r,"source")||(r.source=Zn.join("string"==typeof e?e:"")),t};Function.prototype.toString=Mn((function(){return In(this)&&Dn(this).source||Cn(this)}),"toString");var Vn=r,Xn=D,Hn=Xe,Wn=He.exports,Gn=Ot,Kn=function(t,e,n,r){var i=!!r&&!!r.unsafe,a=!!r&&!!r.enumerable,o=!!r&&!!r.noTargetGet,s=r&&void 0!==r.name?r.name:e;return Xn(n)&&Wn(n,s,r),t===Vn?(a?t[e]=n:Gn(e,n),t):(i?!o&&t[e]&&(a=!0):delete t[e],a?t[e]=n:Hn(t,e,n),t)},Yn={},Jn=Math.ceil,$n=Math.floor,qn=function(t){var e=+t;return e!=e||0===e?0:(e>0?$n:Jn)(e)},Qn=qn,tr=Math.max,er=Math.min,nr=qn,rr=Math.min,ir=function(t){return t>0?rr(nr(t),9007199254740991):0},ar=function(t){return ir(t.length)},or=z,sr=function(t,e){var n=Qn(t);return n<0?tr(n+e,0):er(n,e)},ur=ar,hr=function(t){return function(e,n,r){var i,a=or(e),o=ur(a),s=sr(r,o);if(t&&n!=n){for(;o>s;)if((i=a[s++])!=i)return!0}else for(;o>s;s++)if((t||s in a)&&a[s]===n)return t||s||0;return!t&&-1}},fr={includes:hr(!0),indexOf:hr(!1)},cr=Nt,lr=z,dr=fr.indexOf,pr=dn,vr=x([].push),yr=function(t,e){var n,r=lr(t),i=0,a=[];for(n in r)!cr(pr,n)&&cr(r,n)&&vr(a,n);for(;e.length>i;)cr(r,n=e[i++])&&(~dr(a,n)||vr(a,n));return a},_r=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype");Yn.f=Object.getOwnPropertyNames||function(t){return yr(t,_r)};var wr={};wr.f=Object.getOwnPropertySymbols;var gr=H,br=Yn,mr=wr,kr=Te,xr=x([].concat),Er=gr("Reflect","ownKeys")||function(t){var e=br.f(kr(t)),n=mr.f;return n?xr(e,n(t)):e},Rr=Nt,Or=Er,Ar=i,Sr=Ee,Ur=a,Tr=D,Lr=/#|\.prototype\./,Br=function(t,e){var n=Pr[Ir(t)];return n==jr||n!=Nr&&(Tr(e)?Ur(e):!!e)},Ir=Br.normalize=function(t){return String(t).replace(Lr,".").toLowerCase()},Pr=Br.data={},Nr=Br.NATIVE="N",jr=Br.POLYFILL="P",Cr=Br,zr=r,Dr=i.f,Fr=Xe,Zr=Kn,Mr=Ot,Vr=function(t,e,n){for(var r=Or(e),i=Sr.f,a=Ar.f,o=0;o=51&&/native code/.test(t))return!1;var n=new uo((function(t){t(1)})),r=function(t){t((function(){}),(function(){}))};return(n.constructor={})[yo]=r,!(_o=n.then((function(){}))instanceof r)||!e&&po&&!wo})),bo={CONSTRUCTOR:go,REJECTION_EVENT:wo,SUBCLASSING:_o},mo={},ko=yt,xo=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=ko(e),this.reject=ko(n)};mo.f=function(t){return new xo(t)};var Eo,Ro,Oo,Ao=Hr,So=Wr,Uo=r,To=f,Lo=Kn,Bo=ti,Io=function(t,e,n){t&&!n&&(t=t.prototype),t&&!ni(t,ri)&&ei(t,ri,{configurable:!0,value:e})},Po=function(t){var e=ii(t),n=ai.f;oi&&e&&!e[si]&&n(e,si,{configurable:!0,get:function(){return this}})},No=yt,jo=D,Co=Z,zo=function(t,e){if(ui(e,t))return t;throw hi("Incorrect invocation")},Do=function(t,e){var n,r=Fi(t).constructor;return void 0===r||null==(n=Fi(r)[Mi])?e:Zi(n)},Fo=ja.set,Zo=to,Mo=function(t,e){var n=eo.console;n&&n.error&&(1==arguments.length?n.error(t):n.error(t,e))},Vo=no,Xo=io,Ho=Ln,Wo=ao,Go=mo,Ko="Promise",Yo=bo.CONSTRUCTOR,Jo=bo.REJECTION_EVENT,$o=bo.SUBCLASSING,qo=Ho.getterFor(Ko),Qo=Ho.set,ts=Wo&&Wo.prototype,es=Wo,ns=ts,rs=Uo.TypeError,is=Uo.document,as=Uo.process,os=Go.f,ss=os,us=!!(is&&is.createEvent&&Uo.dispatchEvent),hs="unhandledrejection",fs=function(t){var e;return!(!Co(t)||!jo(e=t.then))&&e},cs=function(t,e){var n,r,i,a=e.value,o=1==e.state,s=o?t.ok:t.fail,u=t.resolve,h=t.reject,f=t.domain;try{s?(o||(2===e.rejection&&ys(e),e.rejection=1),!0===s?n=a:(f&&f.enter(),n=s(a),f&&(f.exit(),i=!0)),n===t.promise?h(rs("Promise-chain cycle")):(r=fs(n))?To(r,n,u,h):u(n)):h(a)}catch(t){f&&!i&&f.exit(),h(t)}},ls=function(t,e){t.notified||(t.notified=!0,Zo((function(){for(var n,r=t.reactions;n=r.get();)cs(n,t);t.notified=!1,e&&!t.rejection&&ps(t)})))},ds=function(t,e,n){var r,i;us?((r=is.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),Uo.dispatchEvent(r)):r={promise:e,reason:n},!Jo&&(i=Uo["on"+t])?i(r):t===hs&&Mo("Unhandled promise rejection",n)},ps=function(t){To(Fo,Uo,(function(){var e,n=t.facade,r=t.value;if(vs(t)&&(e=Vo((function(){So?as.emit("unhandledRejection",r,n):ds(hs,n,r)})),t.rejection=So||vs(t)?2:1,e.error))throw e.value}))},vs=function(t){return 1!==t.rejection&&!t.parent},ys=function(t){To(Fo,Uo,(function(){var e=t.facade;So?as.emit("rejectionHandled",e):ds("rejectionhandled",e,t.value)}))},_s=function(t,e,n){return function(r){t(e,r,n)}},ws=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,ls(t,!0))},gs=function(t,e,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===e)throw rs("Promise can't be resolved itself");var r=fs(e);r?Zo((function(){var n={done:!1};try{To(r,e,_s(gs,n,t),_s(ws,n,t))}catch(e){ws(n,e,t)}})):(t.value=e,t.state=1,ls(t,!1))}catch(e){ws({done:!1},e,t)}}};if(Yo&&(ns=(es=function(t){zo(this,ns),No(t),To(Eo,this);var e=qo(this);try{t(_s(gs,e),_s(ws,e))}catch(t){ws(e,t)}}).prototype,(Eo=function(t){Qo(this,{type:Ko,done:!1,notified:!1,parent:!1,reactions:new Xo,rejection:!1,state:0,value:void 0})}).prototype=Lo(ns,"then",(function(t,e){var n=qo(this),r=os(Do(this,es));return n.parent=!0,r.ok=!jo(t)||t,r.fail=jo(e)&&e,r.domain=So?as.domain:void 0,0==n.state?n.reactions.add(r):Zo((function(){cs(r,n)})),r.promise})),Ro=function(){var t=new Eo,e=qo(t);this.promise=t,this.resolve=_s(gs,e),this.reject=_s(ws,e)},Go.f=os=function(t){return t===es||undefined===t?new Ro(t):ss(t)},jo(Wo)&&ts!==Object.prototype)){Oo=ts.then,$o||Lo(ts,"then",(function(t,e){var n=this;return new es((function(t,e){To(Oo,n,t,e)})).then(t,e)}),{unsafe:!0});try{delete ts.constructor}catch(t){}Bo&&Bo(ts,ns)}Ao({global:!0,wrap:!0,forced:Yo},{Promise:es}),Io(es,Ko,!1),Po(Ko);var bs={},ms=bs,ks=$t("iterator"),xs=Array.prototype,Es=wi,Rs=wt,Os=bs,As=$t("iterator"),Ss=function(t){if(null!=t)return Rs(t,As)||Rs(t,"@@iterator")||Os[Es(t)]},Us=f,Ts=yt,Ls=Te,Bs=lt,Is=Ss,Ps=r.TypeError,Ns=f,js=Te,Cs=wt,zs=$i,Ds=f,Fs=Te,Zs=lt,Ms=function(t){return void 0!==t&&(ms.Array===t||xs[ks]===t)},Vs=ar,Xs=W,Hs=function(t,e){var n=arguments.length<2?Is(t):e;if(Ts(n))return Ls(Us(n,t));throw Ps(Bs(t)+" is not iterable")},Ws=Ss,Gs=function(t,e,n){var r,i;js(t);try{if(!(r=Cs(t,"return"))){if("throw"===e)throw n;return n}r=Ns(r,t)}catch(t){i=!0,r=t}if("throw"===e)throw n;if(i)throw r;return js(r),n},Ks=r.TypeError,Ys=function(t,e){this.stopped=t,this.result=e},Js=Ys.prototype,$s=function(t,e,n){var r,i,a,o,s,u,h,f=n&&n.that,c=!(!n||!n.AS_ENTRIES),l=!(!n||!n.IS_ITERATOR),d=!(!n||!n.INTERRUPTED),p=zs(e,f),v=function(t){return r&&Gs(r,"normal",t),new Ys(!0,t)},y=function(t){return c?(Fs(t),d?p(t[0],t[1],v):p(t[0],t[1])):d?p(t,v):p(t)};if(l)r=t;else{if(!(i=Ws(t)))throw Ks(Zs(t)+" is not iterable");if(Ms(i)){for(a=0,o=Vs(t);o>a;a++)if((s=y(t[a]))&&Xs(Js,s))return s;return new Ys(!1)}r=Hs(t,i)}for(u=r.next;!(h=Ds(u,r)).done;){try{s=y(h.value)}catch(t){Gs(r,"throw",t)}if("object"==typeof s&&s&&Xs(Js,s))return s}return new Ys(!1)};function qs(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Qs(t){for(var e=1;e=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),h=r.call(o,"finallyLoc");if(u&&h){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}({exports:{}});var Qu=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return ru(this,e),(t=qu(this,e,[n])).name="XnbError",t.message=n,Error.captureStackTrace(t,e),t}return su(e,t),au(e)}(lu(Error)),th=au((function t(e,n){ru(this,t),this.name=e,this.readers=n}),[{key:"read",value:function(t,e){for(var n={},r=0,i=this.readers.entries();r")}}],[{key:"isTypeOf",value:function(t){return!1}},{key:"hasSubType",value:function(){return!1}},{key:"type",value:function(){return"ReflectiveScheme"}}]);function eh(t){for(var e=[],n=[],r=0;r")}return n.type()}return null}},{key:"simplifyReflectiveType",value:function(e){for(var n=e.split(/`|,/)[0],r=0,i=Object.values(t.readers);r");throw new Qu('Non-implemented scheme found, cannot resolve scheme "'.concat(n,'", "').concat(e,'".'))}},{key:"simplifyType",value:function(e){var n=e.split(/`|,/)[0];if(function(t,e){if("function"==typeof t.endsWith)return t.endsWith(e);if("string"!=typeof t||"string"!=typeof e)throw new Error("Invalid Data!");return new RegExp(e+"$").test(t)}(n,"[]"))return"Array<".concat(t.simplifyType(n.slice(0,-2)),">");if("Microsoft.Xna.Framework.Content.ReflectiveReader"===n)return t.simplifyReflectiveType(t.parseSubtypes(e)[0]);for(var r=0,i=Object.values(t.readers);r");if(t.enumList.has(n))return"Int32";throw new Qu('Non-implemented type found, cannot resolve type "'.concat(n,'", "').concat(e,'".'))}},{key:"parseSubtypes",value:function(t){var e=t.slice(t.search("`")+1);return e[0],e=eh(e)[0],eh(e)}},{key:"getTypeInfo",value:function(t){var e=t.match(/[^<]+/)[0],n=t.match(/<(.+)>/);return n=n?n[1].split(",").map((function(t){return t.trim()})):[],{type:e,subtypes:n}}},{key:"getReaderTypeList",value:function(e){return t.getReader(e).parseTypeList()}},{key:"getReader",value:function(e){var n=t.getTypeInfo(e),r=n.type,i=n.subtypes;if("ReflectiveScheme"===r)return rh(i[0]);if(i=i.map(t.getReader.bind(t)),t.readers.hasOwnProperty("".concat(r,"Reader")))return cu(t.readers["".concat(r,"Reader")],i);if(t.schemes.hasOwnProperty(r))return rh(r);throw new Qu('Invalid reader type "'.concat(e,'" passed, unable to resolve!'))}},{key:"getReaderClass",value:function(e){if(t.readers.hasOwnProperty(e))return t.readers[e];throw new Qu('There is no "'.concat(e,'" class in reader list!'))}},{key:"getReaderFromRaw",value:function(e){var n=t.simplifyType(e);return t.getReader(n)}}])}();function rh(t){if(!nh.schemes.hasOwnProperty(t))throw new Qu("Unsupported scheme : ".concat(t));var e=nh.schemes[t];return e instanceof Map==!1&&(e=ah(e),nh.schemes[t]=e),new th(t,e)}function ih(t){if("string"==typeof t)return nh.getReader(t);if(Array.isArray(t))return new(nh.getReaderClass("ListReader"))(ih(t[0]));if("object"===tu(t)){var e=Object.keys(t).length;if(1===e){var n=nh.getReaderClass("DictionaryReader"),r=Object.entries(t)[0],i=r[0],a=r[1];return new n(ih(i),ih(a))}if(e>1)return ah(t)}throw new Qu("Invalid Scheme to convert! : ".concat(t))}function ah(t){for(var e=new Map,n=Object.keys(t),r=0;r>6,sh|t&uh]:t<65536?[oh[1]|t>>12,sh|t>>6&uh,sh|t&uh]:[oh[2]|t>>18,sh|t>>12&uh,sh|t>>6&uh,sh|t&uh]}function lh(t){return t<65535?[t]:[hh[0]|(t-=65536)>>10&fh,hh[1]|t&fh]}function dh(t){var e;if("number"==typeof t&&(t=[t]),null===(e=t)||void 0===e||!e.length)throw new Error("Invalid codeset!");var n=t.length;return 1===n?t[0]:2===n?((t[0]^oh[0])<<6)+(t[1]^sh):3===n?((t[0]^oh[1])<<12)+((t[1]^sh)<<6)+(t[2]^sh):((t[0]^oh[2])<<18)+((t[1]^sh)<<12)+((t[2]^sh)<<6)+(t[3]^sh)}function ph(t){var e;if("number"==typeof t&&(t=[t]),null===(e=t)||void 0===e||!e.length)throw new Error("Invalid codeset!");return 1===t.length?t[0]:((t[0]&fh)<<10)+(t[1]&fh)+65536}function vh(t){return function(t){for(var e=[],n=0;n1&&void 0!==arguments[1])||arguments[1];ru(this,t),this._endianus=n,this._buffer=e.slice(),this._dataView=new DataView(this._buffer),this._offset=0,this._bitOffset=0}),[{key:"seek",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._offset,n=this._offset;if(this._offset=Math.max(e+parseInt(t),0),this._offset<0||this._offset>this.buffer.length)throw new RangeError("Buffer seek out of bounds! ".concat(this._offset," ").concat(this.buffer.length));return this._offset-n}},{key:"bytePosition",get:function(){return parseInt(this._offset)},set:function(t){this._offset=t}},{key:"bitPosition",get:function(){return parseInt(this._bitOffset)},set:function(t){t<0&&(t=16-t),this._bitOffset=t%16;var e=(t-Math.abs(t)%16)/16*2;this.seek(e)}},{key:"size",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._buffer}},{key:"copyFrom",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.byteLength,i=new Uint8Array(t),a=this.buffer.byteLength0&&void 0!==arguments[0]?arguments[0]:-1,e=[];if(this._offset,-1===t)for(;0!=this.peekByte(1);)e.push(this.readByte());else for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:0,e=[],n=this._offset;if(0===t)for(;0!=this.peekByte(1);)e.push(this.readByte());else for(var r=0;r0;){var r=this._dataView.getUint16(this._offset,!0),i=Math.min(Math.max(e,0),16-this.bitPosition),a=16-this.bitPosition-i,o=(r&Math.pow(2,i)-1<>a;e-=i,this.bitPosition+=i,n|=o<0&&void 0!==arguments[0])||arguments[0],e=this.readByte(),n=this.readByte();return t||this.seek(-2),e<<8|n}},{key:"align",value:function(){this.bitPosition>0&&(this.bitPosition+=16-this.bitPosition)}}]),wh=au((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2048;ru(this,t),this._buffer=new ArrayBuffer(e),this._dataView=new DataView(this._buffer),this.bytePosition=0}),[{key:"buffer",get:function(){return this._buffer}},{key:"reconnectDataView",value:function(){this._dataView=new DataView(this._buffer)}},{key:"trim",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._buffer=this.buffer.slice(0,this.bytePosition),t||this.reconnectDataView()}},{key:"alloc",value:function(t){if(this._buffer.byteLength<=this.bytePosition+t){for(var e=new ArrayBuffer(this._buffer.byteLength+t),n=new DataView(e),r=0;r>=7)&&(e|=128),this._dataView.setUint8(this.bytePosition,e),this.bytePosition++}while(t)}}]),gh=256,bh=0,mh=1,kh=2,xh=3,Eh=656,Rh=function(){function t(e){if(ru(this,t),this.window_size=1<21)throw new Qu("Window size out of range!");if(!t.extra_bits.length)for(var n=0,r=0;n<=50;n+=2)t.extra_bits[n]=t.extra_bits[n+1]=r,0!=n&&r<17&&r++;if(!t.position_base.length)for(var i=0,a=0;i<=50;i++)t.position_base[i]=a,a+=1<0;){if(0==this.block_remaining){this.block_type=e.readLZXBits(3);var a=e.readLZXBits(16),o=e.readLZXBits(8);switch(this.block_remaining=a<<8|o,this.block_type){case kh:for(var s=0;s<8;s++)this.aligned_len[s]=e.readLZXBits(3);this.aligned_table=this.decodeTable(8,7,this.aligned_len);case mh:this.readLengths(e,this.maintree_len,0,256),this.readLengths(e,this.maintree_len,256,this.main_elements),this.maintree_table=this.decodeTable(Eh,12,this.maintree_len),this.readLengths(e,this.length_len,0,249),this.length_table=this.decodeTable(250,12,this.length_len);break;case xh:e.align(),this.R0=e.readInt32(),this.R1=e.readInt32(),this.R2=e.readInt32();break;default:throw new Qu("Invalid Blocktype Found: ".concat(this.block_type))}}for(var u=this.block_remaining;(u=this.block_remaining)>0&&i>0;){if(u>i&&(u=i),i-=u,this.block_remaining-=u,this.window_posn&=this.window_size-1,this.window_posn+u>this.window_size)throw new Qu("Cannot run outside of window frame.");switch(this.block_type){case kh:for(;u>0;){var h=this.readHuffSymbol(e,this.maintree_table,this.maintree_len,Eh,12);if(h>3;if(c>2){var l=t.extra_bits[c];if(c=t.position_base[c]-2,l>3)l-=3,c+=e.readLZXBits(l)<<3,c+=this.readHuffSymbol(e,this.aligned_table,this.aligned_len,8,7);else 3==l?c+=this.readHuffSymbol(e,this.aligned_table,this.aligned_len,8,7):l>0?c+=e.readLZXBits(l):c=1;this.R2=this.R1,this.R1=this.R0,this.R0=c}else 0===c?c=this.R0:1==c?(c=this.R1,this.R1=this.R0,this.R0=c):(c=this.R2,this.R2=this.R0,this.R0=c);var d=this.window_posn,p=void 0;if(u-=f,this.window_posn>=c)p=d-c;else{p=d+(this.window_size-c);var v=c-this.window_posn;if(v0;)this.win[d++]=this.win[p++];p=0}}for(this.window_posn+=f;f-- >0;)this.win[d++]=this.win[p++]}}break;case mh:for(;u>0;){var y=this.readHuffSymbol(e,this.maintree_table,this.maintree_len,Eh,12);if(y>3;if(w>2){if(3!=w){var g=t.extra_bits[w],b=e.readLZXBits(g);w=t.position_base[w]-2+b}else w=1;this.R2=this.R1,this.R1=this.R0,this.R0=w}else 0===w?w=this.R0:1==w?(w=this.R1,this.R1=this.R0,this.R0=w):(w=this.R2,this.R2=this.R0,this.R0=w);var m=this.window_posn,k=void 0;if(u-=_,this.window_posn>=w)k=m-w;else{k=m+(this.window_size-w);var x=w-this.window_posn;if(x<_){for(_-=x,this.window_posn+=x;x-- >0;)this.win[m++]=this.win[k++];k=0}}for(this.window_posn+=_;_-- >0;)this.win[m++]=this.win[k++]}}break;case xh:if(e.bytePosition+u>r)throw new Qu("Overrun!"+r+" "+e.bytePosition+" "+u);for(var E=0;E>1,s=1;s<=e;s++){for(var u=0;ua)throw new Qu("Overrun table!");for(var f=o;f-- >0;)r[h++]=u}o>>=1}if(i==a)return r;for(var c=i;c>1>1;i<<=16,a<<=16,o=32768;for(var d=e+1;d<=16;d++){for(var p=0;p>16,y=0;y>15-y&1&&v++;if(r[v]=p,(i+=o)>a)throw new Qu("Overrun table during decoding.")}o>>=1}if(i==a)return r;throw new Qu("Decode table did not reach table mask.")}},{key:"readHuffSymbol",value:function(t,e,n,r,i){var a=t.peekLZXBits(32)>>>0,o=e[t.peekLZXBits(i)];if(o>=r){var s=1<<32-i;do{if(o<<=1,o|=0!=(a&(s>>=1))?1:0,0==s)return 0}while((o=e[o])>=r)}return t.bitPosition+=n[o],o}},{key:"RRR",set:function(t){if(this.R0!=t&&this.R1!=t&&this.R2!=t)this.R2=this.R1,this.R1=this.R0,this.R0=t;else if(this.R1==t){var e=this.R1;this.R1=this.R0,this.R0=e}else if(this.R2==t){var n=this.R2;this.R2=this.R0,this.R0=n}}}])}();Rh.position_base=[],Rh.extra_bits=[];var Oh=au((function t(){ru(this,t)}),null,[{key:"decompress",value:function(t,e,n){for(var r,i,a=0,o=new Rh(16),s=new wh(n);a65536||i>65536)throw new Qu("Invalid size read in compression content.");s.write(o.decompress(t,i,r)),a+=r}return console.log("File has been successfully decompressed!"),s.trim(),s.buffer}}]),Ah=au((function t(){ru(this,t)}),null,[{key:"hashU32",value:function(t){return-1252372727^(t=(t=(t=374761393+(t=-949894596^(t=2127912214+(t|=0)+(t<<12)|0)^t>>>19)+(t<<5)|0)-744332180^t<<9)-42973499+(t<<3)|0)^t>>>16|0}},{key:"readU64",value:function(t,e){var n=0;return n|=t[e++]<<0,n|=t[e++]<<8,n|=t[e++]<<16,n|=t[e++]<<24,n|=t[e++]<<32,n|=t[e++]<<40,n|=t[e++]<<48,n|=t[e++]<<56}},{key:"readU32",value:function(t,e){var n=0;return n|=t[e++]<<0,n|=t[e++]<<8,n|=t[e++]<<16,n|=t[e++]<<24}},{key:"writeU32",value:function(t,e,n){t[e++]=n>>0&255,t[e++]=n>>8&255,t[e++]=n>>16&255,t[e++]=n>>24&255}},{key:"imul",value:function(t,e){var n=65535&t,r=65535&e;return n*r+((t>>>16)*r+n*(e>>>16)<<16)|0}}]),Sh=65536,Uh=15;!function(t){try{new Uint8Array(t)}catch(r){for(var e=new Array(t),n=0;n=13)for(var d=67;n+4>>0;if(a=i[v=(v>>16^v)>>>0&65535]-1,i[v]=n+1,a<0||n-a>>>16>0||Ah.readU32(t,a)!==p)n+=d++>>6;else{for(d=67,h=n-o,u=n-a,a+=4,s=n+=4;n=Uh){for(e[f++]=240+y,l=h-Uh;l>=255;l-=255)e[f++]=255;e[f++]=l}else e[f++]=(h<<4)+y;for(var _=0;_>8,s>=15){for(l=s-15;l>=255;l-=255)e[f++]=255;e[f++]=l}o=n}}if(0===o)return 0;if((h=c-o)>=Uh){for(e[f++]=240,l=h-Uh;l>=255;l-=255)e[f++]=255;e[f++]=l}else e[f++]=h<<4;for(n=o;n2&&void 0!==arguments[2]?arguments[2]:0,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.length-2*s,h=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,f=void 0!==e.copyWithin&&void 0!==e.fill;for(i=s+u;s>4;if(l>0){if(15===l)for(;l+=t[s],255===t[s++];);for(a=s+l;s=i)break;if(n=15&c,r=t[s++]|t[s++]<<8,15===n)for(;n+=t[s],255===t[s++];);if(n+=4,f&&1===r)e.fill(0|e[h-1],h,h+n),h+=n;else if(f&&r>n&&n>31)e.copyWithin(h,h-r,h-r+n),h+=n;else for(a=(o=h-r)+n;o2&&void 0!==arguments[2]?arguments[2]:{},r=n.r,i=n.g,a=void 0===i?r:i,o=n.b,s=void 0===o?r:o,u=n.a,h=void 0===u?255:u;return t[4*e+0]=r,t[4*e+1]=a,t[4*e+2]=s,t[4*e+3]=h,[r,a,s,h]}function Xh(t){t.width,t.height;var e=t.channels,n=t.depth,r=t.data;return t.palette?function(t,e,n){for(var r=new Uint8Array(t),i=8*r.length/e,a=new Uint8Array(4*i),o=0,s=0;s>h&Math.pow(2,e)-1];a[4*s]=f[0],a[4*s+1]=f[1],a[4*s+2]=f[2],a[4*s+3]=f[3],o+=e}return a}(r,n,t.palette):(16===n&&(r=function(t){for(var e=new Uint16Array(t),n=new Uint8Array(e.length),r=0;r>8;return n}(r)),e<4&&(r=function(t,e){var n=t.length/e,r=new Uint8Array(4*n);if(4===e)return t;if(1===e)for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:"utf-8";if("utf-8"!==t)throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t,"') is invalid."))}function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"utf-8",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fatal:!1};if("utf-8"!==t)throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t,"') is invalid."));if(e.fatal)throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}Object.defineProperty(e.prototype,"encoding",{value:"utf-8"}),e.prototype.encode=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{stream:!1};if(e.stream)throw new Error("Failed to encode: the 'stream' option is unsupported.");for(var n=0,r=t.length,i=0,a=Math.max(32,r+(r>>1)+7),o=new Uint8Array(a>>3<<3);n=55296&&s<=56319){if(n=55296&&s<=56319)continue}if(i+4>o.length){a+=8,a=(a*=1+n/t.length*2)>>3<<3;var h=new Uint8Array(a);h.set(o),o=h}if(0!=(4294967168&s)){if(0==(4294965248&s))o[i++]=s>>6&31|192;else if(0==(4294901760&s))o[i++]=s>>12&15|224,o[i++]=s>>6&63|128;else{if(0!=(4292870144&s))continue;o[i++]=s>>18&7|240,o[i++]=s>>12&63|128,o[i++]=s>>6&63|128}o[i++]=63&s|128}else o[i++]=s}return o.slice(0,i)},Object.defineProperty(n.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(n.prototype,"fatal",{value:!1}),Object.defineProperty(n.prototype,"ignoreBOM",{value:!1}),n.prototype.decode=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{stream:!1};if(e.stream)throw new Error("Failed to decode: the 'stream' option is unsupported.");for(var n=new Uint8Array(t),r=0,i=n.length,a=[];r65535&&(f-=65536,a.push(f>>>10&1023|55296),f=56320|1023&f),a.push(f)}}return String.fromCharCode.apply(null,a)},t.TextEncoder=e,t.TextDecoder=n}("undefined"!=typeof window?window:"undefined"!=typeof self?self:this)}},Gh={};function Kh(t){var e=Gh[t];if(void 0!==e)return e.exports;var n=Gh[t]={exports:{}};return Wh[t].call(n.exports,n,n.exports,Kh),n.exports}Kh.d=function(t,e){for(var n in e)Kh.o(e,n)&&!Kh.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},Kh.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var Yh={};!function(){Kh.d(Yh,{P:function(){return Sn},m:function(){return An}}),Kh(396);var t=new TextDecoder("utf-8"),e=new TextEncoder,n=au((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8192,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ru(this,t);var r=!1;"number"==typeof e?e=new ArrayBuffer(e):(r=!0,this.lastWrittenByte=e.byteLength);var i=n.offset?n.offset>>>0:0,a=e.byteLength-i,o=i;(ArrayBuffer.isView(e)||e instanceof t)&&(e.byteLength!==e.buffer.byteLength&&(o=e.byteOffset+i),e=e.buffer),this.lastWrittenByte=r?a:0,this.buffer=e,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}),[{key:"available",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.offset+t<=this.length}},{key:"isLittleEndian",value:function(){return this.littleEndian}},{key:"setLittleEndian",value:function(){return this.littleEndian=!0,this}},{key:"isBigEndian",value:function(){return!this.littleEndian}},{key:"setBigEndian",value:function(){return this.littleEndian=!1,this}},{key:"skip",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.offset+=t,this}},{key:"seek",value:function(t){return this.offset=t,this}},{key:"mark",value:function(){return this._mark=this.offset,this}},{key:"reset",value:function(){return this.offset=this._mark,this}},{key:"pushMark",value:function(){return this._marks.push(this.offset),this}},{key:"popMark",value:function(){var t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}},{key:"rewind",value:function(){return this.offset=0,this}},{key:"ensureAvailable",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(!this.available(t)){var e=2*(this.offset+t),n=new Uint8Array(e);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=this.byteLength=e,this._data=new DataView(this.buffer)}return this}},{key:"readBoolean",value:function(){return 0!==this.readUint8()}},{key:"readInt8",value:function(){return this._data.getInt8(this.offset++)}},{key:"readUint8",value:function(){return this._data.getUint8(this.offset++)}},{key:"readByte",value:function(){return this.readUint8()}},{key:"readBytes",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=new Uint8Array(t),n=0;n0&&void 0!==arguments[0]?arguments[0]:1,e="",n=0;n0&&void 0!==arguments[0]?arguments[0]:1;return e=this.readBytes(n),t.decode(e)}},{key:"writeBoolean",value:function(t){return this.writeUint8(t?255:0),this}},{key:"writeInt8",value:function(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}},{key:"writeUint8",value:function(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}},{key:"writeByte",value:function(t){return this.writeUint8(t)}},{key:"writeBytes",value:function(t){this.ensureAvailable(t.length);for(var e=0;ethis.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}]);function r(t){for(var e=t.length;--e>=0;)t[e]=0}var i=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),a=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),o=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),s=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=new Array(576);r(u);var h=new Array(60);r(h);var f=new Array(512);r(f);var c=new Array(256);r(c);var l=new Array(29);r(l);var d,p,v,y=new Array(30);function _(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}function w(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}r(y);var g=function(t){return t<256?f[t]:f[256+(t>>>7)]},b=function(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},m=function(t,e,n){t.bi_valid>16-n?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<>>=1,n<<=1}while(--e>0);return n>>>1},E=function(t,e,n){var r,i,a=new Array(16),o=0;for(r=1;r<=15;r++)a[r]=o=o+n[r-1]<<1;for(i=0;i<=e;i++){var s=t[2*i+1];0!==s&&(t[2*i]=x(a[s]++,s))}},R=function(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},O=function(t){t.bi_valid>8?b(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},A=function(t,e,n,r){var i=2*e,a=2*n;return t[i]>1;n>=1;n--)S(t,a,n);i=u;do{n=t.heap[1],t.heap[1]=t.heap[t.heap_len--],S(t,a,1),r=t.heap[1],t.heap[--t.heap_max]=n,t.heap[--t.heap_max]=r,a[2*i]=a[2*n]+a[2*r],t.depth[i]=(t.depth[n]>=t.depth[r]?t.depth[n]:t.depth[r])+1,a[2*n+1]=a[2*r+1]=i,t.heap[1]=i++,S(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var n,r,i,a,o,s,u=e.dyn_tree,h=e.max_code,f=e.stat_desc.static_tree,c=e.stat_desc.has_stree,l=e.stat_desc.extra_bits,d=e.stat_desc.extra_base,p=e.stat_desc.max_length,v=0;for(a=0;a<=15;a++)t.bl_count[a]=0;for(u[2*t.heap[t.heap_max]+1]=0,n=t.heap_max+1;n<573;n++)(a=u[2*u[2*(r=t.heap[n])+1]+1]+1)>p&&(a=p,v++),u[2*r+1]=a,r>h||(t.bl_count[a]++,o=0,r>=d&&(o=l[r-d]),s=u[2*r],t.opt_len+=s*(a+o),c&&(t.static_len+=s*(f[2*r+1]+o)));if(0!==v){do{for(a=p-1;0===t.bl_count[a];)a--;t.bl_count[a]--,t.bl_count[a+1]+=2,t.bl_count[p]--,v-=2}while(v>0);for(a=p;0!==a;a--)for(r=t.bl_count[a];0!==r;)(i=t.heap[--n])>h||(u[2*i+1]!==a&&(t.opt_len+=(a-u[2*i+1])*u[2*i],u[2*i+1]=a),r--)}}(t,e),E(a,h,t.bl_count)},L=function(t,e,n){var r,i,a=-1,o=e[1],s=0,u=7,h=4;for(0===o&&(u=138,h=3),e[2*(n+1)+1]=65535,r=0;r<=n;r++)i=o,o=e[2*(r+1)+1],++s>=7;r<30;r++)for(y[r]=s<<7,t=0;t<1<0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),T(t,t.l_desc),T(t,t.d_desc),o=function(t){var e;for(L(t,t.dyn_ltree,t.l_desc.max_code),L(t,t.dyn_dtree,t.d_desc.max_code),T(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*s[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),i=t.opt_len+3+7>>>3,(a=t.static_len+3+7>>>3)<=i&&(i=a)):i=a=n+5,n+4<=i&&-1!==e?P(t,e,n,r):4===t.strategy||a===i?(m(t,2+(r?1:0),3),U(t,u,h)):(m(t,4+(r?1:0),3),function(t,e,n,r){var i;for(m(t,e-257,5),m(t,n-1,5),m(t,r-4,4),i=0;i>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(c[n]+256+1)]++,t.dyn_dtree[2*g(e)]++),t.last_lit===t.lit_bufsize-1},D=function(t){m(t,2,3),k(t,256,u),function(t){16===t.bi_valid?(b(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)},F=function(t,e,n,r){for(var i=65535&t|0,a=t>>>16&65535|0,o=0;0!==n;){n-=o=n>2e3?2e3:n;do{a=a+(i=i+e[r++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0},Z=new Uint32Array(function(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e}()),M=function(t,e,n,r){var i=Z,a=r+n;t^=-1;for(var o=r;o>>8^i[255&(t^e[o])];return-1^t},V={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},X={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},H=N,W=j,G=C,K=z,Y=D,J=X.Z_NO_FLUSH,$=X.Z_PARTIAL_FLUSH,q=X.Z_FULL_FLUSH,Q=X.Z_FINISH,tt=X.Z_BLOCK,et=X.Z_OK,nt=X.Z_STREAM_END,rt=X.Z_STREAM_ERROR,it=X.Z_DATA_ERROR,at=X.Z_BUF_ERROR,ot=X.Z_DEFAULT_COMPRESSION,st=X.Z_FILTERED,ut=X.Z_HUFFMAN_ONLY,ht=X.Z_RLE,ft=X.Z_FIXED,ct=X.Z_UNKNOWN,lt=X.Z_DEFLATED,dt=258,pt=262,vt=103,yt=113,_t=666,wt=function(t,e){return t.msg=V[e],e},gt=function(t){return(t<<1)-(t>4?9:0)},bt=function(t){for(var e=t.length;--e>=0;)t[e]=0},mt=function(t,e,n){return(e<t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},xt=function(t,e){G(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,kt(t.strm)},Et=function(t,e){t.pending_buf[t.pending++]=e},Rt=function(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Ot=function(t,e,n,r){var i=t.avail_in;return i>r&&(i=r),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),n),1===t.state.wrap?t.adler=F(t.adler,e,i,n):2===t.state.wrap&&(t.adler=M(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)},At=function(t,e){var n,r,i=t.max_chain_length,a=t.strstart,o=t.prev_length,s=t.nice_match,u=t.strstart>t.w_size-pt?t.strstart-(t.w_size-pt):0,h=t.window,f=t.w_mask,c=t.prev,l=t.strstart+dt,d=h[a+o-1],p=h[a+o];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(h[(n=e)+o]===p&&h[n+o-1]===d&&h[n]===h[a]&&h[++n]===h[a+1]){a+=2,n++;do{}while(h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&h[++a]===h[++n]&&ao){if(t.match_start=e,o=r,r>=s)break;d=h[a+o-1],p=h[a+o]}}}while((e=c[e&f])>u&&0!=--i);return o<=t.lookahead?o:t.lookahead},St=function(t){var e,n,r,i,a,o=t.w_size;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=o+(o-pt)){t.window.set(t.window.subarray(o,o+o),0),t.match_start-=o,t.strstart-=o,t.block_start-=o,e=n=t.hash_size;do{r=t.head[--e],t.head[e]=r>=o?r-o:0}while(--n);e=n=o;do{r=t.prev[--e],t.prev[e]=r>=o?r-o:0}while(--n);i+=o}if(0===t.strm.avail_in)break;if(n=Ot(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=3)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=mt(t,t.ins_h,t.window[a+1]);t.insert&&(t.ins_h=mt(t,t.ins_h,t.window[a+3-1]),t.prev[a&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=a,a++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead=3&&(t.ins_h=mt(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n<=t.w_size-pt&&(t.match_length=At(t,n)),t.match_length>=3)if(r=K(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=mt(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=mt(t,t.ins_h,t.window[t.strstart+1]);else r=K(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2},Tt=function(t,e){for(var n,r,i;;){if(t.lookahead=3&&(t.ins_h=mt(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,r=K(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=mt(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,r&&(xt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((r=K(t,0,t.window[t.strstart-1]))&&xt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=K(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2};function Lt(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}var Bt=[new Lt(0,0,0,0,(function(t,e){var n=65535;for(n>t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(St(t),0===t.lookahead&&e===J)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+n;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,xt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-pt&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Q?(xt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(xt(t,!1),t.strm.avail_out),1)})),new Lt(4,4,8,4,Ut),new Lt(4,5,16,8,Ut),new Lt(4,6,32,32,Ut),new Lt(4,4,16,16,Tt),new Lt(8,16,32,32,Tt),new Lt(8,16,128,128,Tt),new Lt(8,32,128,256,Tt),new Lt(32,128,258,1024,Tt),new Lt(32,258,258,4096,Tt)];function It(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=lt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),bt(this.dyn_ltree),bt(this.dyn_dtree),bt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),bt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),bt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Pt=function(t){var e,n=function(t){if(!t||!t.state)return wt(t,rt);t.total_in=t.total_out=0,t.data_type=ct;var e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:yt,t.adler=2===e.wrap?0:1,e.last_flush=J,H(e),et}(t);return n===et&&((e=t.state).window_size=2*e.w_size,bt(e.head),e.max_lazy_match=Bt[e.level].max_lazy,e.good_match=Bt[e.level].good_length,e.nice_match=Bt[e.level].nice_length,e.max_chain_length=Bt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0),n},Nt=function(t,e,n,r,i,a){if(!t)return rt;var o=1;if(e===ot&&(e=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>9||n!==lt||r<8||r>15||e<0||e>9||a<0||a>ft)return wt(t,rt);8===r&&(r=9);var s=new It;return t.state=s,s.strm=t,s.wrap=o,s.gzhead=null,s.w_bits=r,s.w_size=1<tt||e<0)return t?wt(t,rt):rt;var i=t.state;if(!t.output||!t.input&&0!==t.avail_in||i.status===_t&&e!==Q)return wt(t,0===t.avail_out?at:rt);i.strm=t;var a=i.last_flush;if(i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,Et(i,31),Et(i,139),Et(i,8),i.gzhead?(Et(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),Et(i,255&i.gzhead.time),Et(i,i.gzhead.time>>8&255),Et(i,i.gzhead.time>>16&255),Et(i,i.gzhead.time>>24&255),Et(i,9===i.level?2:i.strategy>=ut||i.level<2?4:0),Et(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(Et(i,255&i.gzhead.extra.length),Et(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=M(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(Et(i,0),Et(i,0),Et(i,0),Et(i,0),Et(i,0),Et(i,9===i.level?2:i.strategy>=ut||i.level<2?4:0),Et(i,3),i.status=yt);else{var o=lt+(i.w_bits-8<<4)<<8;o|=(i.strategy>=ut||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(o|=32),o+=31-o%31,i.status=yt,Rt(i,o),0!==i.strstart&&(Rt(i,t.adler>>>16),Rt(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>n&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),kt(t),n=i.pending,i.pending!==i.pending_buf_size));)Et(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),kt(t),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindexn&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),0===r&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),kt(t),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindexn&&(t.adler=M(t.adler,i.pending_buf,i.pending-n,n)),0===r&&(i.status=vt)}else i.status=vt;if(i.status===vt&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&kt(t),i.pending+2<=i.pending_buf_size&&(Et(i,255&t.adler),Et(i,t.adler>>8&255),t.adler=0,i.status=yt)):i.status=yt),0!==i.pending){if(kt(t),0===t.avail_out)return i.last_flush=-1,et}else if(0===t.avail_in&>(e)<=gt(a)&&e!==Q)return wt(t,at);if(i.status===_t&&0!==t.avail_in)return wt(t,at);if(0!==t.avail_in||0!==i.lookahead||e!==J&&i.status!==_t){var s=i.strategy===ut?function(t,e){for(var n;;){if(0===t.lookahead&&(St(t),0===t.lookahead)){if(e===J)return 1;break}if(t.match_length=0,n=K(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}(i,e):i.strategy===ht?function(t,e){for(var n,r,i,a,o=t.window;;){if(t.lookahead<=dt){if(St(t),t.lookahead<=dt&&e===J)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&((r=o[i=t.strstart-1])===o[++i]&&r===o[++i]&&r===o[++i])){a=t.strstart+dt;do{}while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=K(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=K(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2}(i,e):Bt[i.level].func(i,e);if(3!==s&&4!==s||(i.status=_t),1===s||3===s)return 0===t.avail_out&&(i.last_flush=-1),et;if(2===s&&(e===$?Y(i):e!==tt&&(W(i,0,0,!1),e===q&&(bt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),kt(t),0===t.avail_out))return i.last_flush=-1,et}return e!==Q?et:i.wrap<=0?nt:(2===i.wrap?(Et(i,255&t.adler),Et(i,t.adler>>8&255),Et(i,t.adler>>16&255),Et(i,t.adler>>24&255),Et(i,255&t.total_in),Et(i,t.total_in>>8&255),Et(i,t.total_in>>16&255),Et(i,t.total_in>>24&255)):(Rt(i,t.adler>>>16),Rt(i,65535&t.adler)),kt(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?et:nt)},Ct=function(t){if(!t||!t.state)return rt;var e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==vt&&e!==yt&&e!==_t?wt(t,rt):(t.state=null,e===yt?wt(t,it):et)},zt=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},Dt=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var n=e.shift();if(n){if("object"!=tu(n))throw new TypeError(n+"must be non-object");for(var r in n)zt(n,r)&&(t[r]=n[r])}}return t},Ft=function(t){for(var e=0,n=0,r=t.length;n=252?6:Vt>=248?5:Vt>=240?4:Vt>=224?3:Vt>=192?2:1;Mt[254]=Mt[254]=1;var Xt=function(t){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);var e,n,r,i,a,o=t.length,s=0;for(i=0;i>>6,e[a++]=128|63&n):n<65536?(e[a++]=224|n>>>12,e[a++]=128|n>>>6&63,e[a++]=128|63&n):(e[a++]=240|n>>>18,e[a++]=128|n>>>12&63,e[a++]=128|n>>>6&63,e[a++]=128|63&n);return e},Ht=function(t,e){var n,r,i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));var a=new Array(2*i);for(r=0,n=0;n4)a[r++]=65533,n+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&n1?a[r++]=65533:o<65536?a[r++]=o:(o-=65536,a[r++]=55296|o>>10&1023,a[r++]=56320|1023&o)}}}return function(t,e){if(e<65534&&t.subarray&&Zt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));for(var n="",r=0;rt.length&&(e=t.length);for(var n=e-1;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+Mt[t[n]]>e?n:e},Gt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Kt=Object.prototype.toString,Yt=X.Z_NO_FLUSH,Jt=X.Z_SYNC_FLUSH,$t=X.Z_FULL_FLUSH,qt=X.Z_FINISH,Qt=X.Z_OK,te=X.Z_STREAM_END,ee=X.Z_DEFAULT_COMPRESSION,ne=X.Z_DEFAULT_STRATEGY,re=X.Z_DEFLATED;function ie(t){this.options=Dt({level:ee,method:re,chunkSize:16384,windowBits:15,memLevel:8,strategy:ne},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gt,this.strm.avail_out=0;var n=Nt(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==Qt)throw new Error(V[n]);if(e.header&&function(t,e){t&&t.state&&(2!==t.state.wrap||(t.state.gzhead=e))}(this.strm,e.header),e.dictionary){var r;if(r="string"==typeof e.dictionary?Xt(e.dictionary):"[object ArrayBuffer]"===Kt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=function(t,e){var n=e.length;if(!t||!t.state)return rt;var r=t.state,i=r.wrap;if(2===i||1===i&&42!==r.status||r.lookahead)return rt;if(1===i&&(t.adler=F(t.adler,e,n,0)),r.wrap=0,n>=r.w_size){0===i&&(bt(r.head),r.strstart=0,r.block_start=0,r.insert=0);var a=new Uint8Array(r.w_size);a.set(e.subarray(n-r.w_size,n),0),e=a,n=r.w_size}var o=t.avail_in,s=t.next_in,u=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,St(r);r.lookahead>=3;){var h=r.strstart,f=r.lookahead-2;do{r.ins_h=mt(r,r.ins_h,r.window[h+3-1]),r.prev[h&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=h,h++}while(--f);r.strstart=h,r.lookahead=2,St(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=s,t.input=u,t.avail_in=o,r.wrap=i,et}(this.strm,r),n!==Qt)throw new Error(V[n]);this._dict_set=!0}}function ae(t,e){var n=new ie(e);if(n.push(t,!0),n.err)throw n.msg||V[n.err];return n.result}ie.prototype.push=function(t,e){var n,r,i=this.strm,a=this.options.chunkSize;if(this.ended)return!1;for(r=e===~~e?e:!0===e?qt:Yt,"string"==typeof t?i.input=Xt(t):"[object ArrayBuffer]"===Kt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),(r===Jt||r===$t)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if((n=jt(i,r))===te)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),n=Ct(this.strm),this.onEnd(n),this.ended=!0,n===Qt;if(0!==i.avail_out){if(r>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},ie.prototype.onData=function(t){this.chunks.push(t)},ie.prototype.onEnd=function(t){t===Qt&&(this.result=Ft(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var oe=ae,se=function(t,e){var n,r,i,a,o,s,u,h,f,c,l,d,p,v,y,_,w,g,b,m,k,x,E,R,O=t.state;n=t.next_in,E=t.input,r=n+(t.avail_in-5),i=t.next_out,R=t.output,a=i-(e-t.avail_out),o=i+(t.avail_out-257),s=O.dmax,u=O.wsize,h=O.whave,f=O.wnext,c=O.window,l=O.hold,d=O.bits,p=O.lencode,v=O.distcode,y=(1<>>=g=w>>>24,d-=g,0===(g=w>>>16&255))R[i++]=65535&w;else{if(!(16&g)){if(0==(64&g)){w=p[(65535&w)+(l&(1<>>=g,d-=g),d<15&&(l+=E[n++]<>>=g=w>>>24,d-=g,!(16&(g=w>>>16&255))){if(0==(64&g)){w=v[(65535&w)+(l&(1<s){t.msg="invalid distance too far back",O.mode=30;break t}if(l>>>=g,d-=g,m>(g=i-a)){if((g=m-g)>h&&O.sane){t.msg="invalid distance too far back",O.mode=30;break t}if(k=0,x=c,0===f){if(k+=u-g,g2;)R[i++]=x[k++],R[i++]=x[k++],R[i++]=x[k++],b-=3;b&&(R[i++]=x[k++],b>1&&(R[i++]=x[k++]))}else{k=i-m;do{R[i++]=R[k++],R[i++]=R[k++],R[i++]=R[k++],b-=3}while(b>2);b&&(R[i++]=R[k++],b>1&&(R[i++]=R[k++]))}break}}break}}while(n>3,l&=(1<<(d-=b<<3))-1,t.next_in=n,t.next_out=i,t.avail_in=n=1&&0===T[m];m--);if(k>m&&(k=m),0===m)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(b=1;b0&&(0===t||1!==m))return-1;for(L[1]=0,w=1;w<15;w++)L[w+1]=L[w]+T[w];for(g=0;g852||2===t&&O>592)return 1;for(;;){p=w-E,o[g]d?(v=B[I+o[g]],y=S[U+o[g]]):(v=96,y=0),u=1<>E)+(h-=u)]=p<<24|v<<16|y|0}while(0!==h);for(u=1<>=1;if(0!==u?(A&=u-1,A+=u):A=0,g++,0==--T[w]){if(w===m)break;w=e[n+o[g]]}if(w>k&&(A&c)!==f){for(0===E&&(E=k),l+=b,R=1<<(x=w-E);x+E852||2===t&&O>592)return 1;i[f=A&c]=k<<24|x<<16|l-a|0}}return 0!==A&&(i[l+A]=w-E<<24|64<<16|0),s.bits=k,0},de=X.Z_FINISH,pe=X.Z_BLOCK,ve=X.Z_TREES,ye=X.Z_OK,_e=X.Z_STREAM_END,we=X.Z_NEED_DICT,ge=X.Z_STREAM_ERROR,be=X.Z_DATA_ERROR,me=X.Z_MEM_ERROR,ke=X.Z_BUF_ERROR,xe=X.Z_DEFLATED,Ee=12,Re=30,Oe=function(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)};function Ae(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Se,Ue,Te=function(t){if(!t||!t.state)return ge;var e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,function(t){if(!t||!t.state)return ge;var e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,ye}(t)},Le=!0,Be=function(t){if(Le){Se=new Int32Array(512),Ue=new Int32Array(32);for(var e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(le(1,t.lens,0,288,Se,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;le(2,t.lens,0,32,Ue,0,t.work,{bits:5}),Le=!1}t.lencode=Se,t.lenbits=9,t.distcode=Ue,t.distbits=5},Ie=function(t,e,n,r){var i,a=t.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(e.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>r&&(i=r),a.window.set(e.subarray(n-r,n-r+i),a.wnext),(r-=i)?(a.window.set(e.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave>4),e<48&&(e&=15)),e&&(e<8||e>15)?ge:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,Te(t))}(t,e);return r!==ye&&(t.state=null),r},je=function(t,e){var n,r,i,a,o,s,u,h,f,c,l,d,p,v,y,_,w,g,b,m,k,x,E,R,O=0,A=new Uint8Array(4),S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return ge;(n=t.state).mode===Ee&&(n.mode=13),o=t.next_out,i=t.output,u=t.avail_out,a=t.next_in,r=t.input,s=t.avail_in,h=n.hold,f=n.bits,c=s,l=u,x=ye;t:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;f<16;){if(0===s)break t;s--,h+=r[a++]<>>8&255,n.check=M(n.check,A,2,0),h=0,f=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",n.mode=Re;break}if((15&h)!==xe){t.msg="unknown compression method",n.mode=Re;break}if(f-=4,k=8+(15&(h>>>=4)),0===n.wbits)n.wbits=k;else if(k>n.wbits){t.msg="invalid window size",n.mode=Re;break}n.dmax=1<>8&1),512&n.flags&&(A[0]=255&h,A[1]=h>>>8&255,n.check=M(n.check,A,2,0)),h=0,f=0,n.mode=3;case 3:for(;f<32;){if(0===s)break t;s--,h+=r[a++]<>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,n.check=M(n.check,A,4,0)),h=0,f=0,n.mode=4;case 4:for(;f<16;){if(0===s)break t;s--,h+=r[a++]<>8),512&n.flags&&(A[0]=255&h,A[1]=h>>>8&255,n.check=M(n.check,A,2,0)),h=0,f=0,n.mode=5;case 5:if(1024&n.flags){for(;f<16;){if(0===s)break t;s--,h+=r[a++]<>>8&255,n.check=M(n.check,A,2,0)),h=0,f=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((d=n.length)>s&&(d=s),d&&(n.head&&(k=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(a,a+d),k)),512&n.flags&&(n.check=M(n.check,r,d,a)),s-=d,a+=d,n.length-=d),n.length))break t;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===s)break t;d=0;do{k=r[a+d++],n.head&&k&&n.length<65536&&(n.head.name+=String.fromCharCode(k))}while(k&&d>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=Ee;break;case 10:for(;f<32;){if(0===s)break t;s--,h+=r[a++]<>>=7&f,f-=7&f,n.mode=27;break}for(;f<3;){if(0===s)break t;s--,h+=r[a++]<>>=1)){case 0:n.mode=14;break;case 1:if(Be(n),n.mode=20,e===ve){h>>>=2,f-=2;break t}break;case 2:n.mode=17;break;case 3:t.msg="invalid block type",n.mode=Re}h>>>=2,f-=2;break;case 14:for(h>>>=7&f,f-=7&f;f<32;){if(0===s)break t;s--,h+=r[a++]<>>16^65535)){t.msg="invalid stored block lengths",n.mode=Re;break}if(n.length=65535&h,h=0,f=0,n.mode=15,e===ve)break t;case 15:n.mode=16;case 16:if(d=n.length){if(d>s&&(d=s),d>u&&(d=u),0===d)break t;i.set(r.subarray(a,a+d),o),s-=d,a+=d,u-=d,o+=d,n.length-=d;break}n.mode=Ee;break;case 17:for(;f<14;){if(0===s)break t;s--,h+=r[a++]<>>=5,f-=5,n.ndist=1+(31&h),h>>>=5,f-=5,n.ncode=4+(15&h),h>>>=4,f-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=Re;break}n.have=0,n.mode=18;case 18:for(;n.have>>=3,f-=3}for(;n.have<19;)n.lens[S[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},x=le(0,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,x){t.msg="invalid code lengths set",n.mode=Re;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,w=65535&O,!((y=O>>>24)<=f);){if(0===s)break t;s--,h+=r[a++]<>>=y,f-=y,n.lens[n.have++]=w;else{if(16===w){for(R=y+2;f>>=y,f-=y,0===n.have){t.msg="invalid bit length repeat",n.mode=Re;break}k=n.lens[n.have-1],d=3+(3&h),h>>>=2,f-=2}else if(17===w){for(R=y+3;f>>=y)),h>>>=3,f-=3}else{for(R=y+7;f>>=y)),h>>>=7,f-=7}if(n.have+d>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=Re;break}for(;d--;)n.lens[n.have++]=k}}if(n.mode===Re)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=Re;break}if(n.lenbits=9,E={bits:n.lenbits},x=le(1,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,x){t.msg="invalid literal/lengths set",n.mode=Re;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},x=le(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,x){t.msg="invalid distances set",n.mode=Re;break}if(n.mode=20,e===ve)break t;case 20:n.mode=21;case 21:if(s>=6&&u>=258){t.next_out=o,t.avail_out=u,t.next_in=a,t.avail_in=s,n.hold=h,n.bits=f,se(t,l),o=t.next_out,i=t.output,u=t.avail_out,a=t.next_in,r=t.input,s=t.avail_in,h=n.hold,f=n.bits,n.mode===Ee&&(n.back=-1);break}for(n.back=0;_=(O=n.lencode[h&(1<>>16&255,w=65535&O,!((y=O>>>24)<=f);){if(0===s)break t;s--,h+=r[a++]<>g)])>>>16&255,w=65535&O,!(g+(y=O>>>24)<=f);){if(0===s)break t;s--,h+=r[a++]<>>=g,f-=g,n.back+=g}if(h>>>=y,f-=y,n.back+=y,n.length=w,0===_){n.mode=26;break}if(32&_){n.back=-1,n.mode=Ee;break}if(64&_){t.msg="invalid literal/length code",n.mode=Re;break}n.extra=15&_,n.mode=22;case 22:if(n.extra){for(R=n.extra;f>>=n.extra,f-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;_=(O=n.distcode[h&(1<>>16&255,w=65535&O,!((y=O>>>24)<=f);){if(0===s)break t;s--,h+=r[a++]<>g)])>>>16&255,w=65535&O,!(g+(y=O>>>24)<=f);){if(0===s)break t;s--,h+=r[a++]<>>=g,f-=g,n.back+=g}if(h>>>=y,f-=y,n.back+=y,64&_){t.msg="invalid distance code",n.mode=Re;break}n.offset=w,n.extra=15&_,n.mode=24;case 24:if(n.extra){for(R=n.extra;f>>=n.extra,f-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=Re;break}n.mode=25;case 25:if(0===u)break t;if(d=l-u,n.offset>d){if((d=n.offset-d)>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=Re;break}d>n.wnext?(d-=n.wnext,p=n.wsize-d):p=n.wnext-d,d>n.length&&(d=n.length),v=n.window}else v=i,p=o-n.offset,d=n.length;d>u&&(d=u),u-=d,n.length-=d;do{i[o++]=v[p++]}while(--d);0===n.length&&(n.mode=21);break;case 26:if(0===u)break t;i[o++]=n.length,u--,n.mode=21;break;case 27:if(n.wrap){for(;f<32;){if(0===s)break t;s--,h|=r[a++]<=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gt,this.strm.avail_out=0;var n=Ne(this.strm,e.windowBits);if(n!==Ve)throw new Error(V[n]);if(this.header=new De,function(t,e){if(!t||!t.state)return ge;var n=t.state;0==(2&n.wrap)||(n.head=e,e.done=!1)}(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Xt(e.dictionary):"[object ArrayBuffer]"===Fe.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=ze(this.strm,e.dictionary))!==Ve))throw new Error(V[n])}function Je(t,e){var n=new Ye(e);if(n.push(t),n.err)throw n.msg||V[n.err];return n.result}Ye.prototype.push=function(t,e){var n,r,i,a=this.strm,o=this.options.chunkSize,s=this.options.dictionary;if(this.ended)return!1;for(r=e===~~e?e:!0===e?Me:Ze,"[object ArrayBuffer]"===Fe.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(o),a.next_out=0,a.avail_out=o),(n=je(a,r))===He&&s&&((n=ze(a,s))===Ve?n=je(a,r):n===Ge&&(n=He));a.avail_in>0&&n===Xe&&a.state.wrap>0&&0!==t[a.next_in];)Pe(a),n=je(a,r);switch(n){case We:case Ge:case He:case Ke:return this.onEnd(n),this.ended=!0,!1}if(i=a.avail_out,a.next_out&&(0===a.avail_out||n===Xe))if("string"===this.options.to){var u=Wt(a.output,a.next_out),h=a.next_out-u,f=Ht(a.output,u);a.next_out=h,a.avail_out=o-h,h&&a.output.set(a.output.subarray(u,u+h),0),this.onData(f)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(n!==Ve||0!==i){if(n===Xe)return n=Ce(this.strm),this.onEnd(n),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},Ye.prototype.onData=function(t){this.chunks.push(t)},Ye.prototype.onEnd=function(t){t===Ve&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ft(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};for(var $e=oe,qe=Ye,Qe=Je,tn=[137,80,78,71,13,10,26,10],en=[],nn=0;nn<256;nn++){for(var rn=nn,an=0;an<8;an++)1&rn?rn=3988292384^rn>>>1:rn>>>=1;en[nn]=rn}var on,sn,un,hn;function fn(t,e){return(4294967295^function(t,e,n){for(var r=4294967295,i=0;i>>8;return r}(0,t,e))>>>0}!function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.GREYSCALE=0]="GREYSCALE",t[t.TRUECOLOUR=2]="TRUECOLOUR",t[t.INDEXED_COLOUR=3]="INDEXED_COLOUR",t[t.GREYSCALE_ALPHA=4]="GREYSCALE_ALPHA",t[t.TRUECOLOUR_ALPHA=6]="TRUECOLOUR_ALPHA"}(on||(on={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.DEFLATE=0]="DEFLATE"}(sn||(sn={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.ADAPTIVE=0]="ADAPTIVE"}(un||(un={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.NO_INTERLACE=0]="NO_INTERLACE",t[t.ADAM7=1]="ADAM7"}(hn||(hn={}));var cn=new Uint8Array(0),ln=new Uint16Array([255]),dn=255===new Uint8Array(ln.buffer)[0],pn=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ru(this,e),n=Hh(this,e,[t]);var i=r.checkCrc,a=void 0!==i&&i;return n._checkCrc=a,n._inflator=new qe,n._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},n._end=!1,n._hasPalette=!1,n._palette=[],n._compressionMethod=sn.UNKNOWN,n._filterMethod=un.UNKNOWN,n._interlaceMethod=hn.UNKNOWN,n._colorType=-1,n.setBigEndian(),n}return su(e,t),au(e,[{key:"decode",value:function(){for(this.decodeSignature();!this._end;)this.decodeChunk();return this.decodeImage(),this._png}},{key:"decodeSignature",value:function(){for(var t=0;tthis._palette.length)throw new Error("tRNS chunk contains more alpha values than there are palette colors (".concat(t," vs ").concat(this._palette.length,")"));for(var e=0;e>8&255;this._png.data=c}else this._png.data=s}}])}(n);function vn(t,e,n){for(var r=0;r>1)&255}else{for(;a>1)&255;for(;a>1)&255}}function gn(t,e,n,r,i){var a=0;if(0===n.length){for(;a1&&void 0!==arguments[1]?arguments[1]:{};return ru(this,e),(n=Hh(this,e))._colorType=on.UNKNOWN,n._zlibOptions=Qs(Qs({},kn),r.zlib),n._png=n._checkData(t),n.setBigEndian(),n}return su(e,t),au(e,[{key:"encode",value:function(){return this.encodeSignature(),this.encodeIHDR(),this.encodeData(),this.encodeIEND(),this.toArray()}},{key:"encodeSignature",value:function(){this.writeBytes(tn)}},{key:"encodeIHDR",value:function(){this.writeUint32(13),this.writeChars("IHDR"),this.writeUint32(this._png.width),this.writeUint32(this._png.height),this.writeByte(this._png.depth),this.writeByte(this._colorType),this.writeByte(sn.DEFLATE),this.writeByte(un.ADAPTIVE),this.writeByte(hn.NO_INTERLACE),this.writeCrc(17)}},{key:"encodeIEND",value:function(){this.writeUint32(0),this.writeChars("IEND"),this.writeCrc(4)}},{key:"encodeIDAT",value:function(t){this.writeUint32(t.length),this.writeChars("IDAT"),this.writeBytes(t),this.writeCrc(t.length+4)}},{key:"encodeData",value:function(){for(var t=this._png,e=t.width,r=t.height,i=t.channels,a=t.depth,o=t.data,s=i*e,u=(new n).setBigEndian(),h=0,f=0;f0)return t;throw new TypeError("".concat(e," must be a positive integer"))}function Rn(t,e,n,r){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:4,n="";return"number"==typeof e?n=pu(" ",Math.min(10,e)):"string"==typeof e&&(n=e.slice(0,10)),qh(t,n,-1)}var tf=function(){function t(e,n,r){ru(this,t),this.startingLine=r||0,this.lineIndex=-1;for(var i=[],a=0;a=n;)e.push(this.next());return new t(e,this.indentString,this.getLineNumber()-e.length)}},{key:"next",value:function(){if(this.finished())throw new Error("Trying to next finished generator");return this.lineIndex++,this.getLine()}},{key:"peek",value:function(){return this.getLine(this.lineIndex+1)}},{key:"finished",value:function(){return this.lineIndex==this.lines.length-1}},{key:"getLine",value:function(t){return(t=void 0!==t?t:this.lineIndex)>=this.lines.length?null:this.lines[t][0]}},{key:"findIndentString",value:function(){for(var t=0,e=this.lines;t]+)/),o=void 0,s=void 0,u=void 0;yu(r,'"')&&(i=r.match(/^"(.*?)":(?: |$)/)),a&&(u=a[1],r=r.replace(a[0],"")),i?(n||(n={}),o=i[1],s=r.replace(i[0],"").trim()):yu(r,"-")&&(n||(n=[]),s=r.slice(1).trim()),s=s?nf(s,u):ef(t.nextGroup(),u),Array.isArray(n)?n.push(s):n[o]=s}return e&&(n={type:e,data:n}),n}function nf(t,e){return t=JSON.parse(t),e&&(t={type:e,data:t}),t}function rf(t){var e=t.replace(/\t/g,"\t").split("\n");return ef(new tf(e))}function af(t){var e;if(Array.isArray(t)){e=[];for(var n=0;n","Rectangle","List","Rectangle","List","Char",null,"List","Vector3","Nullable","Char",null],s.verticalSpacing=s.verticalLineSpacing,delete s.verticalLineSpacing);var f=function(t,e){var n=[],r=[],i=function t(i,a){var o,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,u=e[s];if(of(u))return{converted:{type:u,data:i},traversed:s};if(null===u)return{converted:i,traversed:s};if(yu(u,"Nullable")){var h,f,c=u.split(":"),l=c[0],d=c[1],p=void 0===d?1:d;if(p=+p,null===i)h=null,f=s+p;else if("object"!==tu(i)||i&&0!==Object.keys(i).length){var v=t(i,[].concat(a),s+1);h=v.converted,f=v.traversed}else h={type:e[s+1],data:af(i)},f=s+p;return{converted:{type:l,data:{data:h}},traversed:f}}if(sf(u))return"Texture2D"===u?(n.push({path:a.join(".")}),{converted:{type:u,data:{format:i.format}},traversed:s}):("TBin"===u&&r.push({path:a.join(".")}),{converted:{type:u,data:{}},traversed:s});o=Array.isArray(i)?[]:{};var y=s,_=!0,w=!yu(u,"Dictionary")&&!yu(u,"Array")&&!yu(u,"List"),g=u.split(":"),b=g[0],m=g[1],k=void 0===m?1:m;if(0===Object.keys(i).length)return{converted:{type:b,data:o},traversed:s+ +k};for(var x=Object.keys(i),E=0;E0&&(e.extractedImages=l),d.length>0&&(e.extractedMaps=d),e}function ff(t){var e={},n=t.xnbData,r=n.compressed,i=n.readerData,a=n.hiDef,o=n.target;return e.header={target:o,formatVersion:5,compressed:r?"a"===o||"i"===o?64:128:0,hidef:a},e.readers=af(i),e.content=uf(t.content),"SpriteFont"===nh.simplifyType(e.readers[0].type)&&(e.content.verticalLineSpacing=e.content.verticalSpacing,delete e.content.verticalSpacing),e}function cf(t,e){if(t&&"object"==tu(t)){if(t.hasOwnProperty(e))return{parent:t,value:t[e]};for(var n=Object.keys(t),r=0;r1&&void 0!==arguments[1]&&arguments[1],n=cf(t,"export");if(n){var r=n.value,i=r.type,a=r.data;return"Texture2D"===i&&(a=$h(r.width,r.height,new Uint8Array(a))),vf(a,i)}if(e){var o=JSON.stringify(t,null,4);return vf(o,"JSON")}return null}function _f(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.yaml,r=void 0!==n&&n,i=e.contentOnly,a=void 0!==i&&i,o=e.fileName,s=void 0===o?null:o;if(r&&a&&(r=!1),!t.hasOwnProperty("content"))throw new Qu("Invalid object!");var u=[],h=t.content,f=yf(h,a);if(null!==f&&u.push(f),a)return u;var c=JSON.stringify(t,(function(t,e){return"export"===t?"string"==typeof s&&""!==s?"".concat(s,".").concat(df(e.type)):"".concat(e.type,".").concat(df(e.type)):e}),4),l=c;return r&&(l=Qh(hf(t))),u.unshift(vf(l,r?"yaml":"JSON")),u}function wf(t){var e=t.toLowerCase();return"none"===e?0:"lz4"===e?64:null}function gf(t){return bf.apply(this,arguments)}function bf(){return(bf=nu(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("function"==typeof Blob&&e instanceof Blob)){t.next=4;break}return t.abrupt("return",e.text());case 4:if(!("function"==typeof Buffer&&e instanceof Buffer)){t.next=8;break}return t.abrupt("return",e.toString());case 8:return t.abrupt("return",e);case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function mf(t){return kf.apply(this,arguments)}function kf(){return(kf=nu(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("function"==typeof Blob&&e instanceof Blob)){t.next=4;break}return t.abrupt("return",e.arrayBuffer());case 4:if(!("function"==typeof Buffer&&e instanceof Buffer)){t.next=6;break}return t.abrupt("return",e.buffer);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function xf(t,e){return Ef.apply(this,arguments)}function Ef(){return Ef=nu(regeneratorRuntime.mark((function t(e,n){var r,i,a,o,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("png"!==e){t.next=7;break}return t.next=3,mf(n.png);case 3:return r=t.sent,4===(i=Jh(new Uint8Array(r))).channel&&8===i.depth&&void 0===i.palette||(i.data=Xh(i)),t.abrupt("return",{type:"Texture2D",data:i.data,width:i.width,height:i.height});case 7:if("cso"!==e){t.next=12;break}return t.next=10,mf(n.cso);case 10:return a=t.sent,t.abrupt("return",{type:"Effect",data:a});case 12:if("tbin"!==e){t.next=17;break}return t.next=15,mf(n.tbin);case 15:return o=t.sent,t.abrupt("return",{type:"TBin",data:o});case 17:if("xml"!==e){t.next=22;break}return t.next=20,gf(n.xml);case 20:return s=t.sent,t.abrupt("return",{type:"BmFont",data:s});case 22:case"end":return t.stop()}}),t)}))),Ef.apply(this,arguments)}function Rf(t){return Of.apply(this,arguments)}function Of(){return Of=nu(regeneratorRuntime.mark((function t(e){var n,r,i,a,o,s,u,h,f,c,l,d,p=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=p.length>1&&void 0!==p[1]?p[1]:{},r=n.compression,i=void 0===r?"default":r,a=e.json||e.yaml){t.next=5;break}throw new Qu("There is no JSON or YAML file to pack!");case 5:return t.next=7,gf(a);case 7:if(o=t.sent,s=null,s=e.json?JSON.parse(o):ff(rf(o)),null!==(u=wf(i))&&(s.header.compressed=u),s.hasOwnProperty("content")){t.next=14;break}throw new Qu("".concat(a.name,' does not have "content".'));case 14:if(!(h=cf(s.content,"export"))){t.next=21;break}return f=h.parent,c=h.value,l=lf(c),d=l[1],t.next=20,xf(d,e);case 20:f.export=t.sent;case 21:return t.abrupt("return",s);case 22:case"end":return t.stop()}}),t)}))),Of.apply(this,arguments)}function Af(t){var e=lf(t)[1],n=function(t){return"png"===t?"Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553":"tbin"===t?"xTile.Pipeline.TideReader, xTile":"xml"===t?"BmFont.XmlSourceReader, BmFont, Version=2012.1.7.0, Culture=neutral, PublicKeyToken=null":void 0}(e),r={export:t};"png"===e&&(r.format=0);var i={header:{target:"w",formatVersion:5,hidef:!0,compressed:!0},readers:[{type:n,version:0}],content:r};return JSON.stringify(i)}function Sf(t){return Uf.apply(this,arguments)}function Uf(){return(Uf=nu(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("undefined"==typeof window){t.next=8;break}if(n=lf(e.name),"xnb"===n[1]){t.next=4;break}return t.abrupt("return",new Error("Invalid XNB File!"));case 4:return t.next=6,e.arrayBuffer();case 6:return r=t.sent,t.abrupt("return",Tf(r));case 8:return t.abrupt("return",Tf(e.buffer));case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Tf(t){return(new Mh).load(t)}function Lf(t){var e=yf(t.content,!0),n=e.data,r=e.extension;return new zh(n,r)}function Bf(t){for(var e={},n={},r=0;r1&&void 0!==arguments[1]?arguments[1]:{},n=Bf(t),r=[],i=Object.keys(n),a=0;a1&&void 0!==arguments[1]?arguments[1]:{},n=e.yaml,r=void 0!==n&&n,i=e.contentOnly,a=void 0!==i&&i,o=e.fileName,s=void 0===o?null:o;"undefined"!=typeof window&&null===s&&(s=t.name);var u=lf(s),h=u[0],f=function(t){return _f(t,{yaml:r,contentOnly:a,fileName:h})};return Sf(t).then(f)},t.unpackToXnbData=Sf,t.xnbDataToContent=Lf,t.xnbDataToFiles=_f,Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/dist/core/xnb-core.js b/dist/core/xnb-core.js index ee72292..011a9f3 100644 --- a/dist/core/xnb-core.js +++ b/dist/core/xnb-core.js @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -32,17 +32,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } - return keys; } - function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; @@ -52,10 +49,8 @@ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } - return target; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { @@ -67,7 +62,6 @@ } else { obj[key] = value; } - return obj; } @@ -79,13 +73,63 @@ this.message = message; Error.captureStackTrace(this, XnbError); } + } + class ReflectiveSchemeReader { + static isTypeOf(type) { + return false; + } + static hasSubType() { + return false; + } + static type() { + return "ReflectiveScheme"; + } + constructor(name, readers) { + this.name = name; + this.readers = readers; + } + read(buffer, resolver) { + const result = {}; + for (let [key, reader] of this.readers.entries()) { + if (reader.isValueType()) result[key] = reader.read(buffer);else if (reader.constructor.type() === "Nullable") result[key] = reader.read(buffer, resolver);else result[key] = resolver.read(buffer); + } + return result; + } + write(buffer, content, resolver) { + buffer.alloc(163518); + this.writeIndex(buffer, resolver); + for (let [key, reader] of this.readers.entries()) { + reader.write(buffer, content[key], reader.isValueType() ? null : resolver); + } + } + writeIndex(buffer, resolver) { + if (resolver != null) buffer.write7BitNumber(Number.parseInt(resolver.getIndex(this)) + 1); + } + isValueType() { + return false; + } + get type() { + const reg = /\.([^\.]+)$/; + if (reg.test(this.name)) return this.name.match(reg)[1]; + return this.name; + } + parseTypeList() { + let types = [...this.readers.values()].map(reader => { + if (reader.isValueType()) return null; + return reader.parseTypeList(); + }).flat(); + types.unshift(this.type); + return types; + } + toString() { + return "ReflectiveScheme<".concat(this.name, ">"); + } } function removeExternBracket(str) { let bracketStack = []; let result = []; - for (let i = 0; i < str.length; i++) { let c = str[i]; if (c === "[") bracketStack.push(i);else if (c === "]") { @@ -94,50 +138,59 @@ if (bracketStack.length === 0) result.push(str.slice(startPoint + 1, i)); } } - return result; } - class TypeReader { static setReaders(readers) { TypeReader.readers = _objectSpread2({}, readers); } - static addReaders(readers) { TypeReader.readers = _objectSpread2(_objectSpread2({}, TypeReader.readers), readers); } - + static setSchemes(schemes) { + TypeReader.schemes = _objectSpread2({}, schemes); + } + static addSchemes(schemes) { + TypeReader.schemes = _objectSpread2(_objectSpread2({}, TypeReader.schemes), schemes); + } + static setEnum(enumList) { + TypeReader.enumList.clear(); + enumList.forEach(id => TypeReader.enumList.add(id)); + } + static addEnum(enumList) { + enumList.forEach(id => TypeReader.enumList.add(id)); + } static makeSimplied(type, reader) { let simple = type.split(/`|,/)[0]; - if (reader.isTypeOf(simple)) { if (reader.hasSubType()) { let subtypes = TypeReader.parseSubtypes(type).map(TypeReader.simplifyType.bind(TypeReader)); return "".concat(reader.type(), "<").concat(subtypes.join(","), ">"); } else return reader.type(); } - return null; } - + static simplifyReflectiveType(subType) { + let simple = subType.split(/`|,/)[0]; + for (let reader of Object.values(TypeReader.readers)) { + if (reader.isTypeOf(simple)) return reader.type(); + } + if (TypeReader.schemes.hasOwnProperty(simple)) return "ReflectiveScheme<".concat(simple, ">"); + throw new XnbError("Non-implemented scheme found, cannot resolve scheme \"".concat(simple, "\", \"").concat(subType, "\".")); + } static simplifyType(type) { let simple = type.split(/`|,/)[0]; let isArray = simple.endsWith('[]'); - if (isArray) return "Array<".concat(simplifyType(simple.slice(0, -2)), ">"); - - if (simple === 'Microsoft.Xna.Framework.Content.ReflectiveReader') { - let reflectiveType = TypeReader.parseSubtypes(type).map(TypeReader.simplifyType.bind(TypeReader)); - return "".concat(reflectiveType); - } - + if (isArray) return "Array<".concat(TypeReader.simplifyType(simple.slice(0, -2)), ">"); + if (simple === 'Microsoft.Xna.Framework.Content.ReflectiveReader') return TypeReader.simplifyReflectiveType(TypeReader.parseSubtypes(type)[0]); for (let reader of Object.values(TypeReader.readers)) { let result = TypeReader.makeSimplied(type, reader); if (result !== null) return result; } - + if (TypeReader.schemes.hasOwnProperty(simple)) return "ReflectiveScheme<".concat(simple, ">"); + if (TypeReader.enumList.has(simple)) return "Int32"; throw new XnbError("Non-implemented type found, cannot resolve type \"".concat(simple, "\", \"").concat(type, "\".")); } - static parseSubtypes(type) { let subtype = type.slice(type.search("`") + 1); subtype[0]; @@ -145,7 +198,6 @@ let matches = removeExternBracket(subtype); return matches; } - static getTypeInfo(type) { let mainType = type.match(/[^<]+/)[0]; let subtypes = type.match(/<(.+)>/); @@ -155,86 +207,121 @@ subtypes }; } - static getReaderTypeList(typeString) { let reader = TypeReader.getReader(typeString); return reader.parseTypeList(); } - static getReader(typeString) { let { type, subtypes } = TypeReader.getTypeInfo(typeString); + if (type === "ReflectiveScheme") return makeReflectiveReader(subtypes[0]); subtypes = subtypes.map(TypeReader.getReader.bind(TypeReader)); if (TypeReader.readers.hasOwnProperty("".concat(type, "Reader"))) return new TypeReader.readers["".concat(type, "Reader")](...subtypes); + if (TypeReader.schemes.hasOwnProperty(type)) return makeReflectiveReader(type); throw new XnbError("Invalid reader type \"".concat(typeString, "\" passed, unable to resolve!")); } - + static getReaderClass(typeString) { + if (TypeReader.readers.hasOwnProperty(typeString)) return TypeReader.readers[typeString]; + throw new XnbError("There is no \"".concat(typeString, "\" class in reader list!")); + } static getReaderFromRaw(typeString) { const simplified = TypeReader.simplifyType(typeString); return TypeReader.getReader(simplified); } - } - _defineProperty(TypeReader, "readers", {}); + _defineProperty(TypeReader, "schemes", {}); + _defineProperty(TypeReader, "enumList", new Set()); + function makeReflectiveReader(className) { + if (!TypeReader.schemes.hasOwnProperty(className)) throw new XnbError("Unsupported scheme : ".concat(className)); + let scheme = TypeReader.schemes[className]; + if (scheme instanceof Map === false) { + scheme = convertSchemeToReader(scheme); + TypeReader.schemes[className] = scheme; + } + return new ReflectiveSchemeReader(className, scheme); + } + function convertSchemeEntryToReader(scheme) { + if (typeof scheme === "string") return TypeReader.getReader(scheme); + if (Array.isArray(scheme)) { + const ListReader = TypeReader.getReaderClass("ListReader"); + return new ListReader(convertSchemeEntryToReader(scheme[0])); + } + if (typeof scheme === "object") { + const keyCount = Object.keys(scheme).length; + if (keyCount === 1) { + const DictionaryReader = TypeReader.getReaderClass("DictionaryReader"); + const [key, value] = Object.entries(scheme)[0]; + return new DictionaryReader(convertSchemeEntryToReader(key), convertSchemeEntryToReader(value)); + } else if (keyCount > 1) { + return convertSchemeToReader(scheme); + } + } + throw new XnbError("Invalid Scheme to convert! : ".concat(scheme)); + } + function convertSchemeToReader(scheme) { + const result = new Map(); + for (let [key, type] of Object.entries(scheme)) { + let reader = convertSchemeEntryToReader(type); + if (key.startsWith("$")) { + key = key.slice(1); + try { + reader = new TypeReader.readers.NullableReader(reader); + } catch (_unused) { + throw new XnbError("There is no NullableReader from reader list!"); + } + } + result.set(key, reader); + } + return result; + } const UTF8_FIRST_BITES = [0xC0, 0xE0, 0xF0]; const UTF8_SECOND_BITES = 0x80; const UTF8_MASK = 0b111111; const UTF16_BITES$1 = [0xD800, 0xDC00]; const UTF16_MASK$1 = 0b1111111111; - function UTF8Encode(code) { if (code < 0x80) return [code]; if (code < 0x800) return [UTF8_FIRST_BITES[0] | code >> 6, UTF8_SECOND_BITES | code & UTF8_MASK]; if (code < 0x10000) return [UTF8_FIRST_BITES[1] | code >> 12, UTF8_SECOND_BITES | code >> 6 & UTF8_MASK, UTF8_SECOND_BITES | code & UTF8_MASK]; return [UTF8_FIRST_BITES[2] | code >> 18, UTF8_SECOND_BITES | code >> 12 & UTF8_MASK, UTF8_SECOND_BITES | code >> 6 & UTF8_MASK, UTF8_SECOND_BITES | code & UTF8_MASK]; } - function UTF16Encode(code) { if (code < 0xFFFF) return [code]; code -= 0x10000; return [UTF16_BITES$1[0] | code >> 10 & UTF16_MASK$1, UTF16_BITES$1[1] | code & UTF16_MASK$1]; } - function UTF8Decode(codeSet) { var _codeSet; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet = codeSet) !== null && _codeSet !== void 0 && _codeSet.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; if (codeSetRange === 2) return ((codeSet[0] ^ UTF8_FIRST_BITES[0]) << 6) + (codeSet[1] ^ UTF8_SECOND_BITES); - if (codeSetRange === 3) { return ((codeSet[0] ^ UTF8_FIRST_BITES[1]) << 12) + ((codeSet[1] ^ UTF8_SECOND_BITES) << 6) + (codeSet[2] ^ UTF8_SECOND_BITES); } - return ((codeSet[0] ^ UTF8_FIRST_BITES[2]) << 18) + ((codeSet[1] ^ UTF8_SECOND_BITES) << 12) + ((codeSet[2] ^ UTF8_SECOND_BITES) << 6) + (codeSet[3] ^ UTF8_SECOND_BITES); } - function UTF16Decode$1(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; return ((codeSet[0] & UTF16_MASK$1) << 10) + (codeSet[1] & UTF16_MASK$1) + 0x10000; } - function stringToUnicode$1(str) { const utf16Map = Array.from({ length: str.length }, (_, i) => str.charCodeAt(i)); const result = []; let index = 0; - while (index < str.length) { let code = utf16Map[index]; - if ((UTF16_BITES$1[0] & code) !== UTF16_BITES$1[0]) { result.push(code); index++; @@ -243,18 +330,14 @@ index += 2; } } - return result; } - function UTF8ToUnicode(codes) { const dataArray = codes instanceof ArrayBuffer ? new Uint8Array(codes) : codes; const result = []; let index = 0; - while (index < dataArray.length) { let headerCode = dataArray[index]; - if ((headerCode & 0x80) === 0) { result.push(headerCode); index++; @@ -269,47 +352,35 @@ index += 4; } } - return result; } - function UnicodeToUTF8(unicodeArr) { const result = []; - for (let code of unicodeArr) { result.push(...UTF8Encode(code)); } - return result; } - function UnicodeToString(unicodeArr) { const result = []; - for (let code of unicodeArr) { result.push(...UTF16Encode(code)); } - const blockSize = 32768; let resultStr = ""; - for (let i = 0; i < result.length / blockSize; i++) { resultStr += String.fromCharCode(...result.slice(i * blockSize, (i + 1) * blockSize)); } - return resultStr; } - function stringToUTF8(str) { return UnicodeToUTF8(stringToUnicode$1(str)); } - function UTF8ToString(utf8Array) { return UnicodeToString(UTF8ToUnicode(utf8Array)); } const LITTLE_ENDIAN = true; - class BufferReader { constructor(buffer) { let endianus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LITTLE_ENDIAN; @@ -319,7 +390,6 @@ this._offset = 0; this._bitOffset = 0; } - seek(index) { let origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._offset; const offset = this._offset; @@ -327,34 +397,27 @@ if (this._offset < 0 || this._offset > this.buffer.length) throw new RangeError("Buffer seek out of bounds! ".concat(this._offset, " ").concat(this.buffer.length)); return this._offset - offset; } - get bytePosition() { return Number.parseInt(this._offset); } - set bytePosition(value) { this._offset = value; } - get bitPosition() { return Number.parseInt(this._bitOffset); } - set bitPosition(offset) { if (offset < 0) offset = 16 - offset; this._bitOffset = offset % 16; const byteSeek = (offset - Math.abs(offset) % 16) / 16 * 2; this.seek(byteSeek); } - get size() { return this.buffer.byteLength; } - get buffer() { return this._buffer; } - copyFrom(buffer) { let targetIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; let sourceIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; @@ -363,97 +426,73 @@ const isOverflow = this.buffer.byteLength < length + targetIndex; let targetBuffer = this.buffer; let targetView = this._dataView; - if (isOverflow) { targetBuffer = new ArrayBuffer(this.buffer.byteLength + (length + targetIndex - this.buffer.byteLength)); targetView = new DataView(targetBuffer); - for (let i = 0; i < this.buffer.byteLength; i++) { targetView.setUint8(i, this._dataView.getUint8(i)); } } - for (let i = sourceIndex, j = targetIndex; i < length; i++, j++) { targetView.setUint8(j, sourceView[i]); } - if (isOverflow) { this._buffer = targetBuffer; this._dataView = targetView; } } - read(count) { const buffer = this.buffer.slice(this._offset, this._offset + count); this.seek(count); return buffer; } - readByte() { return this.readUInt(); } - readInt() { const value = this._dataView.getInt8(this._offset); - this.seek(1); return value; } - readUInt() { const value = this._dataView.getUint8(this._offset); - this.seek(1); return value; } - readUInt16() { const value = this._dataView.getUint16(this._offset, this._endianus); - this.seek(2); return value; } - readUInt32() { const value = this._dataView.getUint32(this._offset, this._endianus); - this.seek(4); return value; } - readInt16() { const value = this._dataView.getInt16(this._offset, this._endianus); - this.seek(2); return value; } - readInt32() { const value = this._dataView.getInt32(this._offset, this._endianus); - this.seek(4); return value; } - readSingle() { const value = this._dataView.getFloat32(this._offset, this._endianus); - this.seek(4); return value; } - readDouble() { - const value = this._dataView.getFloat32(this._offset, this._endianus); - + const value = this._dataView.getFloat64(this._offset, this._endianus); this.seek(8); return value; } - readString() { let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1; const chars = []; this._offset; - if (count === -1) { while (this.peekByte(1) != 0x0) chars.push(this.readByte()); } else { @@ -461,73 +500,52 @@ chars.push(this.readByte()); } } - return UTF8ToString(chars); } - peek(count) { const buffer = this.read(count); this.seek(-count); return buffer; } - peekByte() { return this.peekUInt(); } - peekInt() { const value = this._dataView.getInt8(this._offset); - return value; } - peekUInt() { const value = this._dataView.getUint8(this._offset); - return value; } - peekUInt16() { const value = this._dataView.getUint16(this._offset, this._endianus); - return value; } - peekUInt32() { const value = this._dataView.getUint32(this._offset, this._endianus); - return value; } - peekInt16() { const value = this._dataView.getInt16(this._offset, this._endianus); - return value; } - peekInt32() { const value = this._dataView.getInt32(this._offset, this._endianus); - return value; } - peekSingle() { const value = this._dataView.getFloat32(this._offset, this._endianus); - return value; } - peekDouble() { const value = this._dataView.getFloat64(this._offset, this._endianus); - return value; } - peekString() { let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; const chars = []; const startOffset = this._offset; - if (count === 0) { while (this.peekByte(1) != 0x0) chars.push(this.readByte()); } else { @@ -535,32 +553,25 @@ chars.push(this.readByte()); } } - this.bytePosition = startOffset; return UTF8ToString(chars); } - read7BitNumber() { let result = 0; let bitsRead = 0; let value; - do { value = this.readByte(); result |= (value & 0x7F) << bitsRead; bitsRead += 7; } while (value & 0x80); - return result; } - readLZXBits(bits) { let bitsLeft = bits; let read = 0; - while (bitsLeft > 0) { const peek = this._dataView.getUint16(this._offset, true); - const bitsInFrame = Math.min(Math.max(bitsLeft, 0), 16 - this.bitPosition); const offset = 16 - this.bitPosition - bitsInFrame; const value = (peek & 2 ** bitsInFrame - 1 << offset) >> offset; @@ -568,10 +579,8 @@ this.bitPosition += bitsInFrame; read |= value << bitsLeft; } - return read; } - peekLZXBits(bits) { let bitPosition = this.bitPosition; let bytePosition = this.bytePosition; @@ -580,7 +589,6 @@ this.bytePosition = bytePosition; return read; } - readLZXInt16() { let seek = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; const lsB = this.readByte(); @@ -588,11 +596,9 @@ if (!seek) this.seek(-2); return lsB << 8 | msB; } - align() { if (this.bitPosition > 0) this.bitPosition += 16 - this.bitPosition; } - } class BufferWriter { @@ -602,135 +608,98 @@ this._dataView = new DataView(this._buffer); this.bytePosition = 0; } - get buffer() { return this._buffer; } - reconnectDataView() { this._dataView = new DataView(this._buffer); } - trim() { let pending = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; this._buffer = this.buffer.slice(0, this.bytePosition); if (!pending) this.reconnectDataView(); } - alloc(bytes) { if (this._buffer.byteLength <= this.bytePosition + bytes) { const tBuffer = new ArrayBuffer(this._buffer.byteLength + bytes); const tDataView = new DataView(tBuffer); - for (let i = 0; i < this.buffer.byteLength; i++) { tDataView.setUint8(i, this._dataView.getUint8(i)); } - this._buffer = tBuffer; this._dataView = tDataView; } - return this; } - concat(buffer) { const targetBufferView = new Uint8Array(buffer); const newPosition = this.bytePosition + targetBufferView.length; this.alloc(targetBufferView.length); - for (let i = this.bytePosition; i < newPosition; i++) { this._dataView.setUint8(i, targetBufferView[i - this.bytePosition]); } - this.bytePosition = newPosition; this.trim(); } - write(bytes) { const targetBufferView = new Uint8Array(bytes); const newPosition = this.bytePosition + targetBufferView.length; this.alloc(targetBufferView.length); - for (let i = this.bytePosition; i < newPosition; i++) { this._dataView.setUint8(i, targetBufferView[i - this.bytePosition]); } - this.bytePosition = newPosition; } - writeString(str) { let utf8Data = stringToUTF8(str); this.write(utf8Data); } - writeByte(byte) { this.alloc(1)._dataView.setUint8(this.bytePosition, byte); - this.bytePosition++; } - writeInt(number) { this.alloc(1)._dataView.setInt8(this.bytePosition, number); - this.bytePosition++; } - writeUInt(number) { this.alloc(1)._dataView.setUint8(this.bytePosition, number); - this.bytePosition++; } - writeInt16(number) { this.alloc(2)._dataView.setInt16(this.bytePosition, number, true); - this.bytePosition += 2; } - writeUInt16(number) { this.alloc(2)._dataView.setUint16(this.bytePosition, number, true); - this.bytePosition += 2; } - writeInt32(number) { this.alloc(4)._dataView.setInt32(this.bytePosition, number, true); - this.bytePosition += 4; } - writeUInt32(number) { this.alloc(4)._dataView.setUint32(this.bytePosition, number, true); - this.bytePosition += 4; } - writeSingle(number) { this.alloc(4)._dataView.setFloat32(this.bytePosition, number, true); - this.bytePosition += 4; } - writeDouble(number) { this.alloc(8)._dataView.setFloat64(this.bytePosition, number, true); - this.bytePosition += 8; } - write7BitNumber(number) { this.alloc(2); - do { let byte = number & 0x7F; number = number >> 7; if (number) byte |= 0x80; - this._dataView.setUint8(this.bytePosition, byte); - this.bytePosition++; } while (number); } - } /** @license @@ -790,26 +759,22 @@ const LENGTH_TABLEBITS = 12; const ALIGNED_MAXSYMBOLS = ALIGNED_NUM_ELEMENTS; const ALIGNED_TABLEBITS = 7; - class Lzx { constructor(window_bits) { this.window_size = 1 << window_bits; if (window_bits < 15 || window_bits > 21) throw new XnbError('Window size out of range!'); - if (!Lzx.extra_bits.length) { for (let i = 0, j = 0; i <= 50; i += 2) { Lzx.extra_bits[i] = Lzx.extra_bits[i + 1] = j; if (i != 0 && j < 17) j++; } } - if (!Lzx.position_base.length) { for (let i = 0, j = 0; i <= 50; i++) { Lzx.position_base[i] = j; j += 1 << Lzx.extra_bits[i]; } } - const posn_slots = window_bits == 21 ? 50 : window_bits == 20 ? 42 : window_bits << 1; this.R0 = this.R1 = this.R2 = 1; this.main_elements = NUM_CHARS + (posn_slots << 3); @@ -825,36 +790,27 @@ this.length_len = []; this.maintree_table = []; this.maintree_len = []; - for (let i = 0; i < MAINTREE_MAXSYMBOLS; i++) this.maintree_len[i] = 0; - for (let i = 0; i < NUM_SECONDARY_LENGTHS; i++) this.length_len[i] = 0; - this.win = []; } - decompress(buffer, frame_size, block_size) { if (!this.header_read) { const intel = buffer.readLZXBits(1); if (intel != 0) throw new XnbError("Intel E8 Call found, invalid for XNB files."); this.header_read = true; } - let togo = frame_size; - while (togo > 0) { if (this.block_remaining == 0) { this.block_type = buffer.readLZXBits(3); const hi = buffer.readLZXBits(16); const lo = buffer.readLZXBits(8); this.block_remaining = hi << 8 | lo; - switch (this.block_type) { case BLOCKTYPE.ALIGNED: for (let i = 0; i < 8; i++) this.aligned_len[i] = buffer.readLZXBits(3); - this.aligned_table = this.decodeTable(ALIGNED_MAXSYMBOLS, ALIGNED_TABLEBITS, this.aligned_len); - case BLOCKTYPE.VERBATIM: this.readLengths(buffer, this.maintree_len, 0, 256); this.readLengths(buffer, this.maintree_len, 256, this.main_elements); @@ -862,55 +818,44 @@ this.readLengths(buffer, this.length_len, 0, NUM_SECONDARY_LENGTHS); this.length_table = this.decodeTable(LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS, this.length_len); break; - case BLOCKTYPE.UNCOMPRESSED: buffer.align(); this.R0 = buffer.readInt32(); this.R1 = buffer.readInt32(); this.R2 = buffer.readInt32(); break; - default: throw new XnbError("Invalid Blocktype Found: ".concat(this.block_type)); } } - let this_run = this.block_remaining; - while ((this_run = this.block_remaining) > 0 && togo > 0) { if (this_run > togo) this_run = togo; togo -= this_run; this.block_remaining -= this_run; this.window_posn &= this.window_size - 1; if (this.window_posn + this_run > this.window_size) throw new XnbError('Cannot run outside of window frame.'); - switch (this.block_type) { case BLOCKTYPE.ALIGNED: while (this_run > 0) { let main_element = this.readHuffSymbol(buffer, this.maintree_table, this.maintree_len, MAINTREE_MAXSYMBOLS, MAINTREE_TABLEBITS); - if (main_element < NUM_CHARS) { this.win[this.window_posn++] = main_element; this_run--; continue; } - main_element -= NUM_CHARS; let length_footer; let match_length = main_element & NUM_PRIMARY_LENGTHS; - if (match_length == NUM_PRIMARY_LENGTHS) { length_footer = this.readHuffSymbol(buffer, this.length_table, this.length_len, LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS); match_length += length_footer; } - match_length += MIN_MATCH; let match_offset = main_element >> 3; - if (match_offset > 2) { let extra = Lzx.extra_bits[match_offset]; match_offset = Lzx.position_base[match_offset] - 2; - if (extra > 3) { extra -= 3; let verbatim_bits = buffer.readLZXBits(extra); @@ -920,7 +865,6 @@ } else if (extra == 3) { match_offset += this.readHuffSymbol(buffer, this.aligned_table, this.aligned_len, ALIGNED_MAXSYMBOLS, ALIGNED_TABLEBITS); } else if (extra > 0) match_offset += buffer.readLZXBits(extra);else match_offset = 1; - this.R2 = this.R1; this.R1 = this.R0; this.R0 = match_offset; @@ -935,59 +879,46 @@ this.R2 = this.R0; this.R0 = match_offset; } - let rundest = this.window_posn; let runsrc; this_run -= match_length; if (this.window_posn >= match_offset) runsrc = rundest - match_offset;else { runsrc = rundest + (this.window_size - match_offset); let copy_length = match_offset - this.window_posn; - if (copy_length < match_length) { match_length -= copy_length; this.window_posn += copy_length; - while (copy_length-- > 0) this.win[rundest++] = this.win[runsrc++]; - runsrc = 0; } } this.window_posn += match_length; - while (match_length-- > 0) this.win[rundest++] = this.win[runsrc++]; } - break; - case BLOCKTYPE.VERBATIM: while (this_run > 0) { let main_element = this.readHuffSymbol(buffer, this.maintree_table, this.maintree_len, MAINTREE_MAXSYMBOLS, MAINTREE_TABLEBITS); - if (main_element < NUM_CHARS) { this.win[this.window_posn++] = main_element; this_run--; continue; } - main_element -= NUM_CHARS; let length_footer; let match_length = main_element & NUM_PRIMARY_LENGTHS; - if (match_length == NUM_PRIMARY_LENGTHS) { length_footer = this.readHuffSymbol(buffer, this.length_table, this.length_len, LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS); match_length += length_footer; } - match_length += MIN_MATCH; let match_offset = main_element >> 3; - if (match_offset > 2) { if (match_offset != 3) { let extra = Lzx.extra_bits[match_offset]; let verbatim_bits = buffer.readLZXBits(extra); match_offset = Lzx.position_base[match_offset] - 2 + verbatim_bits; } else match_offset = 1; - this.R2 = this.R1; this.R1 = this.R0; this.R0 = match_offset; @@ -1002,73 +933,55 @@ this.R2 = this.R0; this.R0 = match_offset; } - let rundest = this.window_posn; let runsrc; this_run -= match_length; if (this.window_posn >= match_offset) runsrc = rundest - match_offset;else { runsrc = rundest + (this.window_size - match_offset); let copy_length = match_offset - this.window_posn; - if (copy_length < match_length) { match_length -= copy_length; this.window_posn += copy_length; - while (copy_length-- > 0) this.win[rundest++] = this.win[runsrc++]; - runsrc = 0; } } this.window_posn += match_length; - while (match_length-- > 0) this.win[rundest++] = this.win[runsrc++]; } - break; - case BLOCKTYPE.UNCOMPRESSED: if (buffer.bytePosition + this_run > block_size) throw new XnbError('Overrun!' + block_size + ' ' + buffer.bytePosition + ' ' + this_run); - for (let i = 0; i < this_run; i++) this.win[window_posn + i] = buffer.buffer[buffer.bytePosition + i]; - buffer.bytePosition += this_run; this.window_posn += this_run; break; - default: throw new XnbError('Invalid blocktype specified!'); } } } - if (togo != 0) throw new XnbError('EOF reached with data left to go.'); buffer.align(); const start_window_pos = (this.window_posn == 0 ? this.window_size : this.window_posn) - frame_size; return this.win.slice(start_window_pos, start_window_pos + frame_size); } - readLengths(buffer, table, first, last) { for (let i = 0; i < 20; i++) this.pretree_len[i] = buffer.readLZXBits(4); - this.pretree_table = this.decodeTable(PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS, this.pretree_len); - for (let i = first; i < last;) { let symbol = this.readHuffSymbol(buffer, this.pretree_table, this.pretree_len, PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS); - if (symbol == 17) { let zeros = buffer.readLZXBits(4) + 4; - while (zeros-- != 0) table[i++] = 0; } else if (symbol == 18) { let zeros = buffer.readLZXBits(5) + 20; - while (zeros-- != 0) table[i++] = 0; } else if (symbol == 19) { let same = buffer.readLZXBits(1) + 4; symbol = this.readHuffSymbol(buffer, this.pretree_table, this.pretree_len, PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS); symbol = table[i] - symbol; if (symbol < 0) symbol += 17; - while (same-- != 0) table[i++] = symbol; } else { symbol = table[i] - symbol; @@ -1076,77 +989,58 @@ table[i++] = symbol; } } - return table; } - decodeTable(symbols, bits, length) { let table = []; let pos = 0; let table_mask = 1 << bits; let bit_mask = table_mask >> 1; - for (let bit_num = 1; bit_num <= bits; bit_num++) { for (let symbol = 0; symbol < symbols; symbol++) { if (length[symbol] == bit_num) { let leaf = pos; - if ((pos += bit_mask) > table_mask) { throw new XnbError('Overrun table!'); } - let fill = bit_mask; - while (fill-- > 0) table[leaf++] = symbol; } } - bit_mask >>= 1; } - if (pos == table_mask) return table; - for (let symbol = pos; symbol < table_mask; symbol++) table[symbol] = 0xFFFF; - let next_symbol = table_mask >> 1 < symbols ? symbols : table_mask >> 1; pos <<= 16; table_mask <<= 16; bit_mask = 1 << 15; - for (let bit_num = bits + 1; bit_num <= 16; bit_num++) { for (let symbol = 0; symbol < symbols; symbol++) { if (length[symbol] != bit_num) continue; let leaf = pos >> 16; - for (let fill = 0; fill < bit_num - bits; fill++) { if (table[leaf] == 0xFFFF) { table[next_symbol << 1] = 0xFFFF; table[(next_symbol << 1) + 1] = 0xFFFF; table[leaf] = next_symbol++; } - leaf = table[leaf] << 1; if (pos >> 15 - fill & 1) leaf++; } - table[leaf] = symbol; if ((pos += bit_mask) > table_mask) throw new XnbError('Overrun table during decoding.'); } - bit_mask >>= 1; } - if (pos == table_mask) return table; throw new XnbError('Decode table did not reach table mask.'); } - readHuffSymbol(buffer, table, length, symbols, bits) { let bit = buffer.peekLZXBits(32) >>> 0; let i = table[buffer.peekLZXBits(bits)]; - if (i >= symbols) { let j = 1 << 32 - bits; - do { j >>= 1; i <<= 1; @@ -1154,11 +1048,9 @@ if (j == 0) return 0; } while ((i = table[i]) >= symbols); } - buffer.bitPosition += length[i]; return i; } - set RRR(X) { if (this.R0 != X && this.R1 != X && this.R2 != X) { this.R2 = this.R1; @@ -1174,9 +1066,7 @@ this.R0 = R2; } } - } - Lzx.position_base = []; Lzx.extra_bits = []; @@ -1187,10 +1077,8 @@ let frame_size; const lzx = new Lzx(16); let decompressed = new BufferWriter(decompressedTodo); - while (pos < compressedTodo) { const flag = buffer.readByte(); - if (flag == 0xFF) { frame_size = buffer.readLZXInt16(); block_size = buffer.readLZXInt16(); @@ -1201,18 +1089,15 @@ frame_size = 0x8000; pos += 2; } - if (block_size == 0 || frame_size == 0) break; if (block_size > 0x10000 || frame_size > 0x10000) throw new XnbError('Invalid size read in compression content.'); decompressed.write(lzx.decompress(buffer, frame_size, block_size)); pos += block_size; } - console.log('File has been successfully decompressed!'); decompressed.trim(); return decompressed.buffer; } - } class LZ4Utils { @@ -1225,7 +1110,6 @@ a = a + -42973499 + (a << 3) | 0; return a ^ -1252372727 ^ a >>> 16 | 0; } - static readU64(b, n) { var x = 0; x |= b[n++] << 0; @@ -1238,7 +1122,6 @@ x |= b[n++] << 56; return x; } - static readU32(b, n) { var x = 0; x |= b[n++] << 0; @@ -1247,14 +1130,12 @@ x |= b[n++] << 24; return x; } - static writeU32(b, n, x) { b[n++] = x >> 0 & 0xff; b[n++] = x >> 8 & 0xff; b[n++] = x >> 16 & 0xff; b[n++] = x >> 24 & 0xff; } - static imul(a, b) { var ah = a >>> 16; var al = a & 65535; @@ -1262,12 +1143,8 @@ var bl = b & 65535; return al * bl + (ah * bl + al * bh << 16) | 0; } - } - /** @license - * Original Code by: https://github.com/Benzinga/lz4js/ - */ const minMatch = 4; const minLength = 13; const searchLimit = 5; @@ -1279,45 +1156,36 @@ const runMask = (1 << runBits) - 1; makeBuffer(5 << 20); const hashTable = makeHashTable(); - function makeHashTable() { try { return new Uint32Array(hashSize); } catch (error) { const hashTable = new Array(hashSize); - for (var i = 0; i < hashSize; i++) { hashTable[i] = 0; } - return hashTable; } } - function clearHashTable(table) { for (var i = 0; i < hashSize; i++) { hashTable[i] = 0; } } - function makeBuffer(size) { try { return new Uint8Array(size); } catch (error) { var buf = new Array(size); - for (var i = 0; i < size; i++) { buf[i] = 0; } - return buf; } } - function compressBound(n) { return n + n / 255 + 16 | 0; } - function decompressBlock(src, dst) { let sIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; let sLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : src.length - 2 * sIndex; @@ -1325,46 +1193,36 @@ var mLength, mOffset, sEnd, n, i; var hasCopyWithin = dst.copyWithin !== undefined && dst.fill !== undefined; sEnd = sIndex + sLength; - while (sIndex < sEnd) { var token = src[sIndex++]; var literalCount = token >> 4; - if (literalCount > 0) { if (literalCount === 0xf) { while (true) { literalCount += src[sIndex]; - if (src[sIndex++] !== 0xff) { break; } } } - for (n = sIndex + literalCount; sIndex < n;) { dst[dIndex++] = src[sIndex++]; } } - if (sIndex >= sEnd) { break; } - mLength = token & 0xf; mOffset = src[sIndex++] | src[sIndex++] << 8; - if (mLength === 0xf) { while (true) { mLength += src[sIndex]; - if (src[sIndex++] !== 0xff) { break; } } } - mLength += minMatch; - if (hasCopyWithin && mOffset === 1) { dst.fill(dst[dIndex - 1] | 0, dIndex, dIndex + mLength); dIndex += mLength; @@ -1377,106 +1235,81 @@ } } } - return dIndex; } - function compressBlock(src, dst, sIndex, sLength, hashTable) { var mIndex, mAnchor, mLength, mOffset, mStep; var literalCount, dIndex, sEnd, n; dIndex = 0; sEnd = sLength + sIndex; mAnchor = sIndex; - if (sLength >= minLength) { var searchMatchCount = (1 << skipTrigger) + 3; - while (sIndex + minMatch < sEnd - searchLimit) { var seq = LZ4Utils.readU32(src, sIndex); var hash = LZ4Utils.hashU32(seq) >>> 0; hash = (hash >> 16 ^ hash) >>> 0 & 0xffff; mIndex = hashTable[hash] - 1; hashTable[hash] = sIndex + 1; - if (mIndex < 0 || sIndex - mIndex >>> 16 > 0 || LZ4Utils.readU32(src, mIndex) !== seq) { mStep = searchMatchCount++ >> skipTrigger; sIndex += mStep; continue; } - searchMatchCount = (1 << skipTrigger) + 3; literalCount = sIndex - mAnchor; mOffset = sIndex - mIndex; sIndex += minMatch; mIndex += minMatch; mLength = sIndex; - while (sIndex < sEnd - searchLimit && src[sIndex] === src[mIndex]) { sIndex++; mIndex++; } - mLength = sIndex - mLength; var token = mLength < mlMask ? mLength : mlMask; - if (literalCount >= runMask) { dst[dIndex++] = (runMask << mlBits) + token; - for (n = literalCount - runMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } else { dst[dIndex++] = (literalCount << mlBits) + token; } - for (var i = 0; i < literalCount; i++) { dst[dIndex++] = src[mAnchor + i]; } - dst[dIndex++] = mOffset; dst[dIndex++] = mOffset >> 8; - if (mLength >= mlMask) { for (n = mLength - mlMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } - mAnchor = sIndex; } } - if (mAnchor === 0) { return 0; } - literalCount = sEnd - mAnchor; - if (literalCount >= runMask) { dst[dIndex++] = runMask << mlBits; - for (n = literalCount - runMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } else { dst[dIndex++] = literalCount << mlBits; } - sIndex = mAnchor; - while (sIndex < sEnd) { dst[dIndex++] = src[sIndex++]; } - return dIndex; } - function compressSingleBlock(src, dst) { clearHashTable(); return compressBlock(src, dst, 0, src.length, hashTable); @@ -1484,27 +1317,22 @@ const UTF16_BITES = [0xD800, 0xDC00]; const UTF16_MASK = 0b1111111111; - function UTF16Decode(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; return ((codeSet[0] & UTF16_MASK) << 10) + (codeSet[1] & UTF16_MASK) + 0x10000; } - function stringToUnicode(str) { const utf16Map = Array.from({ length: str.length }, (_, i) => str.charCodeAt(i)); const result = []; let index = 0; - while (index < str.length) { let code = utf16Map[index]; - if ((UTF16_BITES[0] & code) !== UTF16_BITES[0]) { result.push(code); index++; @@ -1513,10 +1341,8 @@ index += 2; } } - return result; } - function UTF8Length(str) { const codes = stringToUnicode(str); return codes.reduce((sum, unicode) => { @@ -1532,36 +1358,30 @@ let length = buffer.read7BitNumber(); return buffer.readString(length); } - write(buffer, string) { const size = UTF8Length(string); buffer.write7BitNumber(size); buffer.writeString(string); } - } class ReaderResolver { constructor(readers) { this.readers = readers; } - read(buffer) { let index = buffer.read7BitNumber() - 1; - if (this.readers[index] == null) throw new XnbError("Invalid reader index ".concat(index)); + if (this.readers[index] == null) throw new XnbError("Invalid reader index ".concat(index, " | pos: ").concat(buffer.bytePosition.toString(16))); return this.readers[index].read(buffer, this); } - write(buffer, content) { this.readers[0].write(buffer, content, this); } - getIndex(reader) { for (let i = 0, len = this.readers.length; i < len; i++) { if (reader.toString() === this.readers[i].toString()) return i; } } - } class XnbData { @@ -1581,61 +1401,44 @@ this.readers = readers; this.content = content; } - get target() { var _this$header; - switch ((_this$header = this.header) === null || _this$header === void 0 ? void 0 : _this$header.target) { case 'w': return "Microsoft Windows"; - case 'm': return "Windows Phone 7"; - case 'x': return "Xbox 360"; - case 'a': return "Android"; - case 'i': return "iOS"; - default: return "Unknown"; } } - get formatVersion() { var _this$header2; - switch ((_this$header2 = this.header) === null || _this$header2 === void 0 ? void 0 : _this$header2.formatVersion) { case 0x3: return "XNA Game Studio 3.0"; - case 0x4: return "XNA Game Studio 3.1"; - case 0x5: return "XNA Game Studio 4.0"; - default: return "Unknown"; } } - get hidef() { var _this$header3; - return !!((_this$header3 = this.header) !== null && _this$header3 !== void 0 && _this$header3.hidef); } - get compressed() { var _this$header4; - return !!((_this$header4 = this.header) !== null && _this$header4 !== void 0 && _this$header4.compressed); } - get contentType() { let { export: raw @@ -1643,7 +1446,6 @@ if (raw !== undefined) return raw.type; return "JSON"; } - get rawContent() { let { export: raw @@ -1654,7 +1456,6 @@ return value; }, 4); } - stringify() { return JSON.stringify({ header: this.header, @@ -1662,50 +1463,38 @@ content: this.content }, null, 4); } - toString() { return this.stringify(); } - } - function extensionToDatatype(extension) { switch (extension) { case "json": return "JSON"; - case "yaml": return "yaml"; - case "png": return "Texture2D"; - case "cso": return "Effect"; - case 'tbin': return "TBin"; - case 'xml': return "BmFont"; } - return "Others"; } - class XnbContent { constructor(data, ext) { this.type = extensionToDatatype(ext); this.content = data; } - } const HIDEF_MASK = 0x1; const COMPRESSED_LZ4_MASK = 0x40; const COMPRESSED_LZX_MASK = 0x80; const XNB_COMPRESSED_PROLOGUE_SIZE = 14; - class XnbConverter { constructor() { this.target = ''; @@ -1718,19 +1507,14 @@ this.readers = []; this.sharedResources = []; } - load(arrayBuffer) { this.buffer = new BufferReader(arrayBuffer); - this._validateHeader(); - console.info('XNB file validated successfully!'); this.fileSize = this.buffer.readUInt32(); if (this.buffer.size != this.fileSize) throw new XnbError('XNB file has been truncated!'); - if (this.compressed) { const decompressedSize = this.buffer.readUInt32(); - if (this.compressionType == COMPRESSED_LZX_MASK) { const compressedTodo = this.fileSize - XNB_COMPRESSED_PROLOGUE_SIZE; const decompressed = Presser.decompress(this.buffer, compressedTodo, decompressedSize); @@ -1745,22 +1529,23 @@ this.buffer.bytePosition = XNB_COMPRESSED_PROLOGUE_SIZE; } } - let count = this.buffer.read7BitNumber(); const stringReader = new StringReaderCore(); const readers = []; - for (let i = 0; i < count; i++) { const type = stringReader.read(this.buffer); const version = this.buffer.readInt32(); - const reader = TypeReader.getReaderFromRaw(type); - this.readers.push(reader); readers.push({ type, version }); } - + this.readers = readers.map(_ref => { + let { + type + } = _ref; + return TypeReader.getReaderFromRaw(type); + }); const shared = this.buffer.read7BitNumber(); if (shared != 0) throw new XnbError("Unexpected (".concat(shared, ") shared resources.")); const content = new ReaderResolver(this.readers); @@ -1773,7 +1558,6 @@ compressed: this.compressed }, readers, result); } - convert(json) { const buffer = new BufferWriter(); const stringReader = new StringReaderCore(); @@ -1795,18 +1579,15 @@ buffer.writeUInt32(0); if (lz4Compression) buffer.writeUInt32(0); buffer.write7BitNumber(json.readers.length); - for (let reader of json.readers) { this.readers.push(TypeReader.getReaderFromRaw(reader.type)); stringReader.write(buffer, reader.type); buffer.writeUInt32(reader.version); } - buffer.write7BitNumber(0); const content = new ReaderResolver(this.readers); content.write(buffer, json.content); buffer.trim(); - if (lz4Compression) { const trimmed = buffer.buffer.slice(XNB_COMPRESSED_PROLOGUE_SIZE); const trimmedArray = new Uint8Array(trimmed); @@ -1821,13 +1602,11 @@ let returnBuffer = buffer.buffer.slice(0, XNB_COMPRESSED_PROLOGUE_SIZE + compressedSize); return returnBuffer; } - let fileSize = buffer.bytePosition; buffer.bytePosition = 6; buffer.writeUInt32(fileSize, 6); return buffer.buffer; } - _validateHeader() { if (this.buffer == null) throw new XnbError('Buffer is null'); const magic = this.buffer.readString(3); @@ -1839,7 +1618,6 @@ this.compressed = flags & COMPRESSED_LZX_MASK || (flags & COMPRESSED_LZ4_MASK) != 0; this.compressionType = (flags & COMPRESSED_LZX_MASK) != 0 ? COMPRESSED_LZX_MASK : flags & COMPRESSED_LZ4_MASK ? COMPRESSED_LZ4_MASK : 0; } - } function injectRGBA(data, i) { @@ -1855,23 +1633,18 @@ data[4 * i + 3] = a; return [r, g, b, a]; } - function png16to8(data) { const megascale = new Uint16Array(data); const downscale = new Uint8Array(megascale.length); - for (let i = 0; i < megascale.length; i++) { downscale[i] = megascale[i] >> 8; } - return downscale; } - function addChannels(data, originChannel) { const size = data.length / originChannel; const rgbaData = new Uint8Array(size * 4); if (originChannel === 4) return data; - if (originChannel === 1) { for (let i = 0; i < size; i++) { injectRGBA(rgbaData, i, { @@ -1894,16 +1667,13 @@ }); } } - return rgbaData; } - function applyPalette(data, depth, palette) { const oldData = new Uint8Array(data); const length = oldData.length * 8 / depth; const newData = new Uint8Array(length * 4); let bitPosition = 0; - for (let i = 0; i < length; i++) { const bytePosition = Math.floor(bitPosition / 8); const bitOffset = 8 - bitPosition % 8 - depth; @@ -1912,10 +1682,8 @@ [newData[i * 4], newData[i * 4 + 1], newData[i * 4 + 2], newData[i * 4 + 3]] = palette[paletteIndex]; bitPosition += depth; } - return newData; } - function fixPNG(pngdata) { const { width, @@ -1933,104 +1701,92 @@ } var t = { - 396: function _() { - !function (t) { - if (t.TextEncoder && t.TextDecoder) return !1; - - function e() { - let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; - if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t, "') is invalid.")); - } - - function i() { - let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; - let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - fatal: !1 - }; - if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t, "') is invalid.")); - if (e.fatal) throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported."); - } - - Object.defineProperty(e.prototype, "encoding", { - value: "utf-8" - }), e.prototype.encode = function (t) { - let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - stream: !1 - }; - if (e.stream) throw new Error("Failed to encode: the 'stream' option is unsupported."); - let i = 0; - const n = t.length; - let r = 0, + 396: function _() { + !function (t) { + if (t.TextEncoder && t.TextDecoder) return !1; + function e() { + let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; + if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t, "') is invalid.")); + } + function i() { + let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; + let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + fatal: !1 + }; + if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t, "') is invalid.")); + if (e.fatal) throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported."); + } + Object.defineProperty(e.prototype, "encoding", { + value: "utf-8" + }), e.prototype.encode = function (t) { + let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + stream: !1 + }; + if (e.stream) throw new Error("Failed to encode: the 'stream' option is unsupported."); + let i = 0; + const n = t.length; + let r = 0, s = Math.max(32, n + (n >> 1) + 7), a = new Uint8Array(s >> 3 << 3); - - for (; i < n;) { - let e = t.charCodeAt(i++); - - if (e >= 55296 && e <= 56319) { - if (i < n) { - const n = t.charCodeAt(i); - 56320 == (64512 & n) && (++i, e = ((1023 & e) << 10) + (1023 & n) + 65536); + for (; i < n;) { + let e = t.charCodeAt(i++); + if (e >= 55296 && e <= 56319) { + if (i < n) { + const n = t.charCodeAt(i); + 56320 == (64512 & n) && (++i, e = ((1023 & e) << 10) + (1023 & n) + 65536); + } + if (e >= 55296 && e <= 56319) continue; } - - if (e >= 55296 && e <= 56319) continue; - } - - if (r + 4 > a.length) { - s += 8, s *= 1 + i / t.length * 2, s = s >> 3 << 3; - const e = new Uint8Array(s); - e.set(a), a = e; + if (r + 4 > a.length) { + s += 8, s *= 1 + i / t.length * 2, s = s >> 3 << 3; + const e = new Uint8Array(s); + e.set(a), a = e; + } + if (0 != (4294967168 & e)) { + if (0 == (4294965248 & e)) a[r++] = e >> 6 & 31 | 192;else if (0 == (4294901760 & e)) a[r++] = e >> 12 & 15 | 224, a[r++] = e >> 6 & 63 | 128;else { + if (0 != (4292870144 & e)) continue; + a[r++] = e >> 18 & 7 | 240, a[r++] = e >> 12 & 63 | 128, a[r++] = e >> 6 & 63 | 128; + } + a[r++] = 63 & e | 128; + } else a[r++] = e; } - - if (0 != (4294967168 & e)) { - if (0 == (4294965248 & e)) a[r++] = e >> 6 & 31 | 192;else if (0 == (4294901760 & e)) a[r++] = e >> 12 & 15 | 224, a[r++] = e >> 6 & 63 | 128;else { - if (0 != (4292870144 & e)) continue; - a[r++] = e >> 18 & 7 | 240, a[r++] = e >> 12 & 63 | 128, a[r++] = e >> 6 & 63 | 128; + return a.slice(0, r); + }, Object.defineProperty(i.prototype, "encoding", { + value: "utf-8" + }), Object.defineProperty(i.prototype, "fatal", { + value: !1 + }), Object.defineProperty(i.prototype, "ignoreBOM", { + value: !1 + }), i.prototype.decode = function (t) { + let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + stream: !1 + }; + if (e.stream) throw new Error("Failed to decode: the 'stream' option is unsupported."); + const i = new Uint8Array(t); + let n = 0; + const r = i.length, + s = []; + for (; n < r;) { + const t = i[n++]; + if (0 === t) break; + if (0 == (128 & t)) s.push(t);else if (192 == (224 & t)) { + const e = 63 & i[n++]; + s.push((31 & t) << 6 | e); + } else if (224 == (240 & t)) { + const e = 63 & i[n++], + r = 63 & i[n++]; + s.push((31 & t) << 12 | e << 6 | r); + } else if (240 == (248 & t)) { + let e = (7 & t) << 18 | (63 & i[n++]) << 12 | (63 & i[n++]) << 6 | 63 & i[n++]; + e > 65535 && (e -= 65536, s.push(e >>> 10 & 1023 | 55296), e = 56320 | 1023 & e), s.push(e); } - a[r++] = 63 & e | 128; - } else a[r++] = e; - } - - return a.slice(0, r); - }, Object.defineProperty(i.prototype, "encoding", { - value: "utf-8" - }), Object.defineProperty(i.prototype, "fatal", { - value: !1 - }), Object.defineProperty(i.prototype, "ignoreBOM", { - value: !1 - }), i.prototype.decode = function (t) { - let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - stream: !1 - }; - if (e.stream) throw new Error("Failed to decode: the 'stream' option is unsupported."); - const i = new Uint8Array(t); - let n = 0; - const r = i.length, - s = []; - - for (; n < r;) { - const t = i[n++]; - if (0 === t) break; - if (0 == (128 & t)) s.push(t);else if (192 == (224 & t)) { - const e = 63 & i[n++]; - s.push((31 & t) << 6 | e); - } else if (224 == (240 & t)) { - const e = 63 & i[n++], - r = 63 & i[n++]; - s.push((31 & t) << 12 | e << 6 | r); - } else if (240 == (248 & t)) { - let e = (7 & t) << 18 | (63 & i[n++]) << 12 | (63 & i[n++]) << 6 | 63 & i[n++]; - e > 65535 && (e -= 65536, s.push(e >>> 10 & 1023 | 55296), e = 56320 | 1023 & e), s.push(e); } - } - - return String.fromCharCode.apply(null, s); - }, t.TextEncoder = e, t.TextDecoder = i; - }("undefined" != typeof window ? window : "undefined" != typeof self ? self : this); - } - }, - e = {}; - + return String.fromCharCode.apply(null, s); + }, t.TextEncoder = e, t.TextDecoder = i; + }("undefined" != typeof window ? window : "undefined" != typeof self ? self : this); + } + }, + e = {}; function i(n) { var r = e[n]; if (void 0 !== r) return r.exports; @@ -2039,7 +1795,6 @@ }; return t[n].call(s.exports, s, s.exports, i), s.exports; } - i.d = (t, e) => { for (var n in e) i.o(e, n) && !i.o(t, n) && Object.defineProperty(t, n, { enumerable: !0, @@ -2047,15 +1802,13 @@ }); }, i.o = (t, e) => Object.prototype.hasOwnProperty.call(t, e); var n = {}; - (() => { i.d(n, { P: () => Mi, m: () => Fi }), i(396); const t = new TextDecoder("utf-8"), - e = new TextEncoder(); - + e = new TextEncoder(); class r { constructor() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8192; @@ -2063,265 +1816,194 @@ let i = !1; "number" == typeof t ? t = new ArrayBuffer(t) : (i = !0, this.lastWrittenByte = t.byteLength); const n = e.offset ? e.offset >>> 0 : 0, - s = t.byteLength - n; + s = t.byteLength - n; let a = n; (ArrayBuffer.isView(t) || t instanceof r) && (t.byteLength !== t.buffer.byteLength && (a = t.byteOffset + n), t = t.buffer), this.lastWrittenByte = i ? s : 0, this.buffer = t, this.length = s, this.byteLength = s, this.byteOffset = a, this.offset = 0, this.littleEndian = !0, this._data = new DataView(this.buffer, a, s), this._mark = 0, this._marks = []; } - available() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return this.offset + t <= this.length; } - isLittleEndian() { return this.littleEndian; } - setLittleEndian() { return this.littleEndian = !0, this; } - isBigEndian() { return !this.littleEndian; } - setBigEndian() { return this.littleEndian = !1, this; } - skip() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return this.offset += t, this; } - seek(t) { return this.offset = t, this; } - mark() { return this._mark = this.offset, this; } - reset() { return this.offset = this._mark, this; } - pushMark() { return this._marks.push(this.offset), this; } - popMark() { const t = this._marks.pop(); - if (void 0 === t) throw new Error("Mark stack empty"); return this.seek(t), this; } - rewind() { return this.offset = 0, this; } - ensureAvailable() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - if (!this.available(t)) { const e = 2 * (this.offset + t), - i = new Uint8Array(e); + i = new Uint8Array(e); i.set(new Uint8Array(this.buffer)), this.buffer = i.buffer, this.length = this.byteLength = e, this._data = new DataView(this.buffer); } - return this; } - readBoolean() { return 0 !== this.readUint8(); } - readInt8() { return this._data.getInt8(this.offset++); } - readUint8() { return this._data.getUint8(this.offset++); } - readByte() { return this.readUint8(); } - readBytes() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; const e = new Uint8Array(t); - for (let i = 0; i < t; i++) e[i] = this.readByte(); - return e; } - readInt16() { const t = this._data.getInt16(this.offset, this.littleEndian); - return this.offset += 2, t; } - readUint16() { const t = this._data.getUint16(this.offset, this.littleEndian); - return this.offset += 2, t; } - readInt32() { const t = this._data.getInt32(this.offset, this.littleEndian); - return this.offset += 4, t; } - readUint32() { const t = this._data.getUint32(this.offset, this.littleEndian); - return this.offset += 4, t; } - readFloat32() { const t = this._data.getFloat32(this.offset, this.littleEndian); - return this.offset += 4, t; } - readFloat64() { const t = this._data.getFloat64(this.offset, this.littleEndian); - return this.offset += 8, t; } - readBigInt64() { const t = this._data.getBigInt64(this.offset, this.littleEndian); - return this.offset += 8, t; } - readBigUint64() { const t = this._data.getBigUint64(this.offset, this.littleEndian); - return this.offset += 8, t; } - readChar() { return String.fromCharCode(this.readInt8()); } - readChars() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; let e = ""; - for (let i = 0; i < t; i++) e += this.readChar(); - return e; } - readUtf8() { let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return i = this.readBytes(e), t.decode(i); var i; } - writeBoolean(t) { return this.writeUint8(t ? 255 : 0), this; } - writeInt8(t) { return this.ensureAvailable(1), this._data.setInt8(this.offset++, t), this._updateLastWrittenByte(), this; } - writeUint8(t) { return this.ensureAvailable(1), this._data.setUint8(this.offset++, t), this._updateLastWrittenByte(), this; } - writeByte(t) { return this.writeUint8(t); } - writeBytes(t) { this.ensureAvailable(t.length); - for (let e = 0; e < t.length; e++) this._data.setUint8(this.offset++, t[e]); - return this._updateLastWrittenByte(), this; } - writeInt16(t) { return this.ensureAvailable(2), this._data.setInt16(this.offset, t, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this; } - writeUint16(t) { return this.ensureAvailable(2), this._data.setUint16(this.offset, t, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this; } - writeInt32(t) { return this.ensureAvailable(4), this._data.setInt32(this.offset, t, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this; } - writeUint32(t) { return this.ensureAvailable(4), this._data.setUint32(this.offset, t, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this; } - writeFloat32(t) { return this.ensureAvailable(4), this._data.setFloat32(this.offset, t, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this; } - writeFloat64(t) { return this.ensureAvailable(8), this._data.setFloat64(this.offset, t, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this; } - writeBigInt64(t) { return this.ensureAvailable(8), this._data.setBigInt64(this.offset, t, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this; } - writeBigUint64(t) { return this.ensureAvailable(8), this._data.setBigUint64(this.offset, t, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this; } - writeChar(t) { return this.writeUint8(t.charCodeAt(0)); } - writeChars(t) { for (let e = 0; e < t.length; e++) this.writeUint8(t.charCodeAt(e)); - return this; } - writeUtf8(t) { return this.writeBytes(function (t) { return e.encode(t); }(t)); } - toArray() { return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte); } - _updateLastWrittenByte() { this.offset > this.lastWrittenByte && (this.lastWrittenByte = this.offset); } - } - function s(t) { let e = t.length; - for (; --e >= 0;) t[e] = 0; } - const a = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0]), - o = new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]), - h = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]), - l = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), - d = new Array(576); + o = new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]), + h = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]), + l = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), + d = new Array(576); s(d); - const _ = new Array(60); - s(_); const f = new Array(512); s(f); @@ -2330,790 +2012,640 @@ const u = new Array(29); s(u); const w = new Array(30); - function p(t, e, i, n, r) { this.static_tree = t, this.extra_bits = e, this.extra_base = i, this.elems = n, this.max_length = r, this.has_stree = t && t.length; } - let g, b, m; - function k(t, e) { this.dyn_tree = t, this.max_code = 0, this.stat_desc = e; } - s(w); - const y = t => t < 256 ? f[t] : f[256 + (t >>> 7)], - v = (t, e) => { - t.pending_buf[t.pending++] = 255 & e, t.pending_buf[t.pending++] = e >>> 8 & 255; - }, - E = (t, e, i) => { - t.bi_valid > 16 - i ? (t.bi_buf |= e << t.bi_valid & 65535, v(t, t.bi_buf), t.bi_buf = e >> 16 - t.bi_valid, t.bi_valid += i - 16) : (t.bi_buf |= e << t.bi_valid & 65535, t.bi_valid += i); - }, - A = (t, e, i) => { - E(t, i[2 * e], i[2 * e + 1]); - }, - x = (t, e) => { - let i = 0; - - do { - i |= 1 & t, t >>>= 1, i <<= 1; - } while (--e > 0); - - return i >>> 1; - }, - U = (t, e, i) => { - const n = new Array(16); - let r, - s, - a = 0; - - for (r = 1; r <= 15; r++) n[r] = a = a + i[r - 1] << 1; - - for (s = 0; s <= e; s++) { - let e = t[2 * s + 1]; - 0 !== e && (t[2 * s] = x(n[e]++, e)); - } - }, - z = t => { - let e; - - for (e = 0; e < 286; e++) t.dyn_ltree[2 * e] = 0; - - for (e = 0; e < 30; e++) t.dyn_dtree[2 * e] = 0; - - for (e = 0; e < 19; e++) t.bl_tree[2 * e] = 0; - - t.dyn_ltree[512] = 1, t.opt_len = t.static_len = 0, t.last_lit = t.matches = 0; - }, - R = t => { - t.bi_valid > 8 ? v(t, t.bi_buf) : t.bi_valid > 0 && (t.pending_buf[t.pending++] = t.bi_buf), t.bi_buf = 0, t.bi_valid = 0; - }, - N = (t, e, i, n) => { - const r = 2 * e, - s = 2 * i; - return t[r] < t[s] || t[r] === t[s] && n[e] <= n[i]; - }, - T = (t, e, i) => { - const n = t.heap[i]; - let r = i << 1; - - for (; r <= t.heap_len && (r < t.heap_len && N(e, t.heap[r + 1], t.heap[r], t.depth) && r++, !N(e, n, t.heap[r], t.depth));) t.heap[i] = t.heap[r], i = r, r <<= 1; - - t.heap[i] = n; - }, - O = (t, e, i) => { - let n, + v = (t, e) => { + t.pending_buf[t.pending++] = 255 & e, t.pending_buf[t.pending++] = e >>> 8 & 255; + }, + E = (t, e, i) => { + t.bi_valid > 16 - i ? (t.bi_buf |= e << t.bi_valid & 65535, v(t, t.bi_buf), t.bi_buf = e >> 16 - t.bi_valid, t.bi_valid += i - 16) : (t.bi_buf |= e << t.bi_valid & 65535, t.bi_valid += i); + }, + A = (t, e, i) => { + E(t, i[2 * e], i[2 * e + 1]); + }, + x = (t, e) => { + let i = 0; + do { + i |= 1 & t, t >>>= 1, i <<= 1; + } while (--e > 0); + return i >>> 1; + }, + U = (t, e, i) => { + const n = new Array(16); + let r, + s, + a = 0; + for (r = 1; r <= 15; r++) n[r] = a = a + i[r - 1] << 1; + for (s = 0; s <= e; s++) { + let e = t[2 * s + 1]; + 0 !== e && (t[2 * s] = x(n[e]++, e)); + } + }, + z = t => { + let e; + for (e = 0; e < 286; e++) t.dyn_ltree[2 * e] = 0; + for (e = 0; e < 30; e++) t.dyn_dtree[2 * e] = 0; + for (e = 0; e < 19; e++) t.bl_tree[2 * e] = 0; + t.dyn_ltree[512] = 1, t.opt_len = t.static_len = 0, t.last_lit = t.matches = 0; + }, + R = t => { + t.bi_valid > 8 ? v(t, t.bi_buf) : t.bi_valid > 0 && (t.pending_buf[t.pending++] = t.bi_buf), t.bi_buf = 0, t.bi_valid = 0; + }, + N = (t, e, i, n) => { + const r = 2 * e, + s = 2 * i; + return t[r] < t[s] || t[r] === t[s] && n[e] <= n[i]; + }, + T = (t, e, i) => { + const n = t.heap[i]; + let r = i << 1; + for (; r <= t.heap_len && (r < t.heap_len && N(e, t.heap[r + 1], t.heap[r], t.depth) && r++, !N(e, n, t.heap[r], t.depth));) t.heap[i] = t.heap[r], i = r, r <<= 1; + t.heap[i] = n; + }, + O = (t, e, i) => { + let n, r, s, h, l = 0; - if (0 !== t.last_lit) do { - n = t.pending_buf[t.d_buf + 2 * l] << 8 | t.pending_buf[t.d_buf + 2 * l + 1], r = t.pending_buf[t.l_buf + l], l++, 0 === n ? A(t, r, e) : (s = c[r], A(t, s + 256 + 1, e), h = a[s], 0 !== h && (r -= u[s], E(t, r, h)), n--, s = y(n), A(t, s, i), h = o[s], 0 !== h && (n -= w[s], E(t, n, h))); - } while (l < t.last_lit); - A(t, 256, e); - }, - L = (t, e) => { - const i = e.dyn_tree, - n = e.stat_desc.static_tree, - r = e.stat_desc.has_stree, - s = e.stat_desc.elems; - let a, + if (0 !== t.last_lit) do { + n = t.pending_buf[t.d_buf + 2 * l] << 8 | t.pending_buf[t.d_buf + 2 * l + 1], r = t.pending_buf[t.l_buf + l], l++, 0 === n ? A(t, r, e) : (s = c[r], A(t, s + 256 + 1, e), h = a[s], 0 !== h && (r -= u[s], E(t, r, h)), n--, s = y(n), A(t, s, i), h = o[s], 0 !== h && (n -= w[s], E(t, n, h))); + } while (l < t.last_lit); + A(t, 256, e); + }, + L = (t, e) => { + const i = e.dyn_tree, + n = e.stat_desc.static_tree, + r = e.stat_desc.has_stree, + s = e.stat_desc.elems; + let a, o, h, l = -1; - - for (t.heap_len = 0, t.heap_max = 573, a = 0; a < s; a++) 0 !== i[2 * a] ? (t.heap[++t.heap_len] = l = a, t.depth[a] = 0) : i[2 * a + 1] = 0; - - for (; t.heap_len < 2;) h = t.heap[++t.heap_len] = l < 2 ? ++l : 0, i[2 * h] = 1, t.depth[h] = 0, t.opt_len--, r && (t.static_len -= n[2 * h + 1]); - - for (e.max_code = l, a = t.heap_len >> 1; a >= 1; a--) T(t, i, a); - - h = s; - - do { - a = t.heap[1], t.heap[1] = t.heap[t.heap_len--], T(t, i, 1), o = t.heap[1], t.heap[--t.heap_max] = a, t.heap[--t.heap_max] = o, i[2 * h] = i[2 * a] + i[2 * o], t.depth[h] = (t.depth[a] >= t.depth[o] ? t.depth[a] : t.depth[o]) + 1, i[2 * a + 1] = i[2 * o + 1] = h, t.heap[1] = h++, T(t, i, 1); - } while (t.heap_len >= 2); - - t.heap[--t.heap_max] = t.heap[1], ((t, e) => { - const i = e.dyn_tree, - n = e.max_code, - r = e.stat_desc.static_tree, - s = e.stat_desc.has_stree, - a = e.stat_desc.extra_bits, - o = e.stat_desc.extra_base, - h = e.stat_desc.max_length; - - let l, + for (t.heap_len = 0, t.heap_max = 573, a = 0; a < s; a++) 0 !== i[2 * a] ? (t.heap[++t.heap_len] = l = a, t.depth[a] = 0) : i[2 * a + 1] = 0; + for (; t.heap_len < 2;) h = t.heap[++t.heap_len] = l < 2 ? ++l : 0, i[2 * h] = 1, t.depth[h] = 0, t.opt_len--, r && (t.static_len -= n[2 * h + 1]); + for (e.max_code = l, a = t.heap_len >> 1; a >= 1; a--) T(t, i, a); + h = s; + do { + a = t.heap[1], t.heap[1] = t.heap[t.heap_len--], T(t, i, 1), o = t.heap[1], t.heap[--t.heap_max] = a, t.heap[--t.heap_max] = o, i[2 * h] = i[2 * a] + i[2 * o], t.depth[h] = (t.depth[a] >= t.depth[o] ? t.depth[a] : t.depth[o]) + 1, i[2 * a + 1] = i[2 * o + 1] = h, t.heap[1] = h++, T(t, i, 1); + } while (t.heap_len >= 2); + t.heap[--t.heap_max] = t.heap[1], ((t, e) => { + const i = e.dyn_tree, + n = e.max_code, + r = e.stat_desc.static_tree, + s = e.stat_desc.has_stree, + a = e.stat_desc.extra_bits, + o = e.stat_desc.extra_base, + h = e.stat_desc.max_length; + let l, d, _, f, c, u, w = 0; - - for (f = 0; f <= 15; f++) t.bl_count[f] = 0; - - for (i[2 * t.heap[t.heap_max] + 1] = 0, l = t.heap_max + 1; l < 573; l++) d = t.heap[l], f = i[2 * i[2 * d + 1] + 1] + 1, f > h && (f = h, w++), i[2 * d + 1] = f, d > n || (t.bl_count[f]++, c = 0, d >= o && (c = a[d - o]), u = i[2 * d], t.opt_len += u * (f + c), s && (t.static_len += u * (r[2 * d + 1] + c))); - - if (0 !== w) { - do { - for (f = h - 1; 0 === t.bl_count[f];) f--; - - t.bl_count[f]--, t.bl_count[f + 1] += 2, t.bl_count[h]--, w -= 2; - } while (w > 0); - - for (f = h; 0 !== f; f--) for (d = t.bl_count[f]; 0 !== d;) _ = t.heap[--l], _ > n || (i[2 * _ + 1] !== f && (t.opt_len += (f - i[2 * _ + 1]) * i[2 * _], i[2 * _ + 1] = f), d--); - } - })(t, e), U(i, l, t.bl_count); - }, - B = (t, e, i) => { - let n, + for (f = 0; f <= 15; f++) t.bl_count[f] = 0; + for (i[2 * t.heap[t.heap_max] + 1] = 0, l = t.heap_max + 1; l < 573; l++) d = t.heap[l], f = i[2 * i[2 * d + 1] + 1] + 1, f > h && (f = h, w++), i[2 * d + 1] = f, d > n || (t.bl_count[f]++, c = 0, d >= o && (c = a[d - o]), u = i[2 * d], t.opt_len += u * (f + c), s && (t.static_len += u * (r[2 * d + 1] + c))); + if (0 !== w) { + do { + for (f = h - 1; 0 === t.bl_count[f];) f--; + t.bl_count[f]--, t.bl_count[f + 1] += 2, t.bl_count[h]--, w -= 2; + } while (w > 0); + for (f = h; 0 !== f; f--) for (d = t.bl_count[f]; 0 !== d;) _ = t.heap[--l], _ > n || (i[2 * _ + 1] !== f && (t.opt_len += (f - i[2 * _ + 1]) * i[2 * _], i[2 * _ + 1] = f), d--); + } + })(t, e), U(i, l, t.bl_count); + }, + B = (t, e, i) => { + let n, r, s = -1, a = e[1], o = 0, h = 7, l = 4; - - for (0 === a && (h = 138, l = 3), e[2 * (i + 1) + 1] = 65535, n = 0; n <= i; n++) r = a, a = e[2 * (n + 1) + 1], ++o < h && r === a || (o < l ? t.bl_tree[2 * r] += o : 0 !== r ? (r !== s && t.bl_tree[2 * r]++, t.bl_tree[32]++) : o <= 10 ? t.bl_tree[34]++ : t.bl_tree[36]++, o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4)); - }, - C = (t, e, i) => { - let n, + for (0 === a && (h = 138, l = 3), e[2 * (i + 1) + 1] = 65535, n = 0; n <= i; n++) r = a, a = e[2 * (n + 1) + 1], ++o < h && r === a || (o < l ? t.bl_tree[2 * r] += o : 0 !== r ? (r !== s && t.bl_tree[2 * r]++, t.bl_tree[32]++) : o <= 10 ? t.bl_tree[34]++ : t.bl_tree[36]++, o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4)); + }, + C = (t, e, i) => { + let n, r, s = -1, a = e[1], o = 0, h = 7, l = 4; - - for (0 === a && (h = 138, l = 3), n = 0; n <= i; n++) if (r = a, a = e[2 * (n + 1) + 1], !(++o < h && r === a)) { - if (o < l) do { - A(t, r, t.bl_tree); - } while (0 != --o);else 0 !== r ? (r !== s && (A(t, r, t.bl_tree), o--), A(t, 16, t.bl_tree), E(t, o - 3, 2)) : o <= 10 ? (A(t, 17, t.bl_tree), E(t, o - 3, 3)) : (A(t, 18, t.bl_tree), E(t, o - 11, 7)); - o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4); - } - }; - + for (0 === a && (h = 138, l = 3), n = 0; n <= i; n++) if (r = a, a = e[2 * (n + 1) + 1], !(++o < h && r === a)) { + if (o < l) do { + A(t, r, t.bl_tree); + } while (0 != --o);else 0 !== r ? (r !== s && (A(t, r, t.bl_tree), o--), A(t, 16, t.bl_tree), E(t, o - 3, 2)) : o <= 10 ? (A(t, 17, t.bl_tree), E(t, o - 3, 3)) : (A(t, 18, t.bl_tree), E(t, o - 11, 7)); + o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4); + } + }; let D = !1; - const I = (t, e, i, n) => { E(t, 0 + (n ? 1 : 0), 3), ((t, e, i, n) => { R(t), v(t, i), v(t, ~i), t.pending_buf.set(t.window.subarray(e, e + i), t.pending), t.pending += i; })(t, e, i); }; - var S = { - _tr_init: t => { - D || ((() => { - let t, e, i, n, r; - const s = new Array(16); - - for (i = 0, n = 0; n < 28; n++) for (u[n] = i, t = 0; t < 1 << a[n]; t++) c[i++] = n; - - for (c[i - 1] = n, r = 0, n = 0; n < 16; n++) for (w[n] = r, t = 0; t < 1 << o[n]; t++) f[r++] = n; - - for (r >>= 7; n < 30; n++) for (w[n] = r << 7, t = 0; t < 1 << o[n] - 7; t++) f[256 + r++] = n; - - for (e = 0; e <= 15; e++) s[e] = 0; - - for (t = 0; t <= 143;) d[2 * t + 1] = 8, t++, s[8]++; - - for (; t <= 255;) d[2 * t + 1] = 9, t++, s[9]++; - - for (; t <= 279;) d[2 * t + 1] = 7, t++, s[7]++; - - for (; t <= 287;) d[2 * t + 1] = 8, t++, s[8]++; - - for (U(d, 287, s), t = 0; t < 30; t++) _[2 * t + 1] = 5, _[2 * t] = x(t, 5); - - g = new p(d, a, 257, 286, 15), b = new p(_, o, 0, 30, 15), m = new p(new Array(0), h, 0, 19, 7); - })(), D = !0), t.l_desc = new k(t.dyn_ltree, g), t.d_desc = new k(t.dyn_dtree, b), t.bl_desc = new k(t.bl_tree, m), t.bi_buf = 0, t.bi_valid = 0, z(t); - }, - _tr_stored_block: I, - _tr_flush_block: (t, e, i, n) => { - let r, + _tr_init: t => { + D || ((() => { + let t, e, i, n, r; + const s = new Array(16); + for (i = 0, n = 0; n < 28; n++) for (u[n] = i, t = 0; t < 1 << a[n]; t++) c[i++] = n; + for (c[i - 1] = n, r = 0, n = 0; n < 16; n++) for (w[n] = r, t = 0; t < 1 << o[n]; t++) f[r++] = n; + for (r >>= 7; n < 30; n++) for (w[n] = r << 7, t = 0; t < 1 << o[n] - 7; t++) f[256 + r++] = n; + for (e = 0; e <= 15; e++) s[e] = 0; + for (t = 0; t <= 143;) d[2 * t + 1] = 8, t++, s[8]++; + for (; t <= 255;) d[2 * t + 1] = 9, t++, s[9]++; + for (; t <= 279;) d[2 * t + 1] = 7, t++, s[7]++; + for (; t <= 287;) d[2 * t + 1] = 8, t++, s[8]++; + for (U(d, 287, s), t = 0; t < 30; t++) _[2 * t + 1] = 5, _[2 * t] = x(t, 5); + g = new p(d, a, 257, 286, 15), b = new p(_, o, 0, 30, 15), m = new p(new Array(0), h, 0, 19, 7); + })(), D = !0), t.l_desc = new k(t.dyn_ltree, g), t.d_desc = new k(t.dyn_dtree, b), t.bl_desc = new k(t.bl_tree, m), t.bi_buf = 0, t.bi_valid = 0, z(t); + }, + _tr_stored_block: I, + _tr_flush_block: (t, e, i, n) => { + let r, s, a = 0; - t.level > 0 ? (2 === t.strm.data_type && (t.strm.data_type = (t => { - let e, + t.level > 0 ? (2 === t.strm.data_type && (t.strm.data_type = (t => { + let e, i = 4093624447; - - for (e = 0; e <= 31; e++, i >>>= 1) if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; - - if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return 1; - - for (e = 32; e < 256; e++) if (0 !== t.dyn_ltree[2 * e]) return 1; - - return 0; - })(t)), L(t, t.l_desc), L(t, t.d_desc), a = (t => { - let e; - - for (B(t, t.dyn_ltree, t.l_desc.max_code), B(t, t.dyn_dtree, t.d_desc.max_code), L(t, t.bl_desc), e = 18; e >= 3 && 0 === t.bl_tree[2 * l[e] + 1]; e--); - - return t.opt_len += 3 * (e + 1) + 5 + 5 + 4, e; - })(t), r = t.opt_len + 3 + 7 >>> 3, s = t.static_len + 3 + 7 >>> 3, s <= r && (r = s)) : r = s = i + 5, i + 4 <= r && -1 !== e ? I(t, e, i, n) : 4 === t.strategy || s === r ? (E(t, 2 + (n ? 1 : 0), 3), O(t, d, _)) : (E(t, 4 + (n ? 1 : 0), 3), ((t, e, i, n) => { - let r; - - for (E(t, e - 257, 5), E(t, i - 1, 5), E(t, n - 4, 4), r = 0; r < n; r++) E(t, t.bl_tree[2 * l[r] + 1], 3); - - C(t, t.dyn_ltree, e - 1), C(t, t.dyn_dtree, i - 1); - })(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, a + 1), O(t, t.dyn_ltree, t.dyn_dtree)), z(t), n && R(t); + for (e = 0; e <= 31; e++, i >>>= 1) if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; + if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return 1; + for (e = 32; e < 256; e++) if (0 !== t.dyn_ltree[2 * e]) return 1; + return 0; + })(t)), L(t, t.l_desc), L(t, t.d_desc), a = (t => { + let e; + for (B(t, t.dyn_ltree, t.l_desc.max_code), B(t, t.dyn_dtree, t.d_desc.max_code), L(t, t.bl_desc), e = 18; e >= 3 && 0 === t.bl_tree[2 * l[e] + 1]; e--); + return t.opt_len += 3 * (e + 1) + 5 + 5 + 4, e; + })(t), r = t.opt_len + 3 + 7 >>> 3, s = t.static_len + 3 + 7 >>> 3, s <= r && (r = s)) : r = s = i + 5, i + 4 <= r && -1 !== e ? I(t, e, i, n) : 4 === t.strategy || s === r ? (E(t, 2 + (n ? 1 : 0), 3), O(t, d, _)) : (E(t, 4 + (n ? 1 : 0), 3), ((t, e, i, n) => { + let r; + for (E(t, e - 257, 5), E(t, i - 1, 5), E(t, n - 4, 4), r = 0; r < n; r++) E(t, t.bl_tree[2 * l[r] + 1], 3); + C(t, t.dyn_ltree, e - 1), C(t, t.dyn_dtree, i - 1); + })(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, a + 1), O(t, t.dyn_ltree, t.dyn_dtree)), z(t), n && R(t); + }, + _tr_tally: (t, e, i) => (t.pending_buf[t.d_buf + 2 * t.last_lit] = e >>> 8 & 255, t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e, t.pending_buf[t.l_buf + t.last_lit] = 255 & i, t.last_lit++, 0 === e ? t.dyn_ltree[2 * i]++ : (t.matches++, e--, t.dyn_ltree[2 * (c[i] + 256 + 1)]++, t.dyn_dtree[2 * y(e)]++), t.last_lit === t.lit_bufsize - 1), + _tr_align: t => { + E(t, 2, 3), A(t, 256, d), (t => { + 16 === t.bi_valid ? (v(t, t.bi_buf), t.bi_buf = 0, t.bi_valid = 0) : t.bi_valid >= 8 && (t.pending_buf[t.pending++] = 255 & t.bi_buf, t.bi_buf >>= 8, t.bi_valid -= 8); + })(t); + } }, - _tr_tally: (t, e, i) => (t.pending_buf[t.d_buf + 2 * t.last_lit] = e >>> 8 & 255, t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e, t.pending_buf[t.l_buf + t.last_lit] = 255 & i, t.last_lit++, 0 === e ? t.dyn_ltree[2 * i]++ : (t.matches++, e--, t.dyn_ltree[2 * (c[i] + 256 + 1)]++, t.dyn_dtree[2 * y(e)]++), t.last_lit === t.lit_bufsize - 1), - _tr_align: t => { - E(t, 2, 3), A(t, 256, d), (t => { - 16 === t.bi_valid ? (v(t, t.bi_buf), t.bi_buf = 0, t.bi_valid = 0) : t.bi_valid >= 8 && (t.pending_buf[t.pending++] = 255 & t.bi_buf, t.bi_buf >>= 8, t.bi_valid -= 8); - })(t); - } - }, - Z = (t, e, i, n) => { - let r = 65535 & t | 0, + Z = (t, e, i, n) => { + let r = 65535 & t | 0, s = t >>> 16 & 65535 | 0, a = 0; - - for (; 0 !== i;) { - a = i > 2e3 ? 2e3 : i, i -= a; - - do { - r = r + e[n++] | 0, s = s + r | 0; - } while (--a); - - r %= 65521, s %= 65521; - } - - return r | s << 16 | 0; - }; - + for (; 0 !== i;) { + a = i > 2e3 ? 2e3 : i, i -= a; + do { + r = r + e[n++] | 0, s = s + r | 0; + } while (--a); + r %= 65521, s %= 65521; + } + return r | s << 16 | 0; + }; const F = new Uint32Array((() => { let t, - e = []; - + e = []; for (var i = 0; i < 256; i++) { t = i; - for (var n = 0; n < 8; n++) t = 1 & t ? 3988292384 ^ t >>> 1 : t >>> 1; - e[i] = t; } - return e; })()); - var M = (t, e, i, n) => { - const r = F, - s = n + i; - t ^= -1; - - for (let i = n; i < s; i++) t = t >>> 8 ^ r[255 & (t ^ e[i])]; - - return -1 ^ t; - }, - P = { - 2: "need dictionary", - 1: "stream end", - 0: "", - "-1": "file error", - "-2": "stream error", - "-3": "data error", - "-4": "insufficient memory", - "-5": "buffer error", - "-6": "incompatible version" - }, - H = { - Z_NO_FLUSH: 0, - Z_PARTIAL_FLUSH: 1, - Z_SYNC_FLUSH: 2, - Z_FULL_FLUSH: 3, - Z_FINISH: 4, - Z_BLOCK: 5, - Z_TREES: 6, - Z_OK: 0, - Z_STREAM_END: 1, - Z_NEED_DICT: 2, - Z_ERRNO: -1, - Z_STREAM_ERROR: -2, - Z_DATA_ERROR: -3, - Z_MEM_ERROR: -4, - Z_BUF_ERROR: -5, - Z_NO_COMPRESSION: 0, - Z_BEST_SPEED: 1, - Z_BEST_COMPRESSION: 9, - Z_DEFAULT_COMPRESSION: -1, - Z_FILTERED: 1, - Z_HUFFMAN_ONLY: 2, - Z_RLE: 3, - Z_FIXED: 4, - Z_DEFAULT_STRATEGY: 0, - Z_BINARY: 0, - Z_TEXT: 1, - Z_UNKNOWN: 2, - Z_DEFLATED: 8 - }; - + const r = F, + s = n + i; + t ^= -1; + for (let i = n; i < s; i++) t = t >>> 8 ^ r[255 & (t ^ e[i])]; + return -1 ^ t; + }, + P = { + 2: "need dictionary", + 1: "stream end", + 0: "", + "-1": "file error", + "-2": "stream error", + "-3": "data error", + "-4": "insufficient memory", + "-5": "buffer error", + "-6": "incompatible version" + }, + H = { + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + Z_BINARY: 0, + Z_TEXT: 1, + Z_UNKNOWN: 2, + Z_DEFLATED: 8 + }; const { - _tr_init: W, - _tr_stored_block: K, - _tr_flush_block: $, - _tr_tally: Y, - _tr_align: j - } = S, - { - Z_NO_FLUSH: G, - Z_PARTIAL_FLUSH: X, - Z_FULL_FLUSH: V, - Z_FINISH: q, - Z_BLOCK: J, - Z_OK: Q, - Z_STREAM_END: tt, - Z_STREAM_ERROR: et, - Z_DATA_ERROR: it, - Z_BUF_ERROR: nt, - Z_DEFAULT_COMPRESSION: rt, - Z_FILTERED: st, - Z_HUFFMAN_ONLY: at, - Z_RLE: ot, - Z_FIXED: ht, - Z_DEFAULT_STRATEGY: lt, - Z_UNKNOWN: dt, - Z_DEFLATED: _t - } = H, - ft = 258, - ct = 262, - ut = 103, - wt = 113, - pt = 666, - gt = (t, e) => (t.msg = P[e], e), - bt = t => (t << 1) - (t > 4 ? 9 : 0), - mt = t => { - let e = t.length; - - for (; --e >= 0;) t[e] = 0; - }; - + _tr_init: W, + _tr_stored_block: K, + _tr_flush_block: $, + _tr_tally: Y, + _tr_align: j + } = S, + { + Z_NO_FLUSH: G, + Z_PARTIAL_FLUSH: X, + Z_FULL_FLUSH: V, + Z_FINISH: q, + Z_BLOCK: J, + Z_OK: Q, + Z_STREAM_END: tt, + Z_STREAM_ERROR: et, + Z_DATA_ERROR: it, + Z_BUF_ERROR: nt, + Z_DEFAULT_COMPRESSION: rt, + Z_FILTERED: st, + Z_HUFFMAN_ONLY: at, + Z_RLE: ot, + Z_FIXED: ht, + Z_DEFAULT_STRATEGY: lt, + Z_UNKNOWN: dt, + Z_DEFLATED: _t + } = H, + ft = 258, + ct = 262, + ut = 103, + wt = 113, + pt = 666, + gt = (t, e) => (t.msg = P[e], e), + bt = t => (t << 1) - (t > 4 ? 9 : 0), + mt = t => { + let e = t.length; + for (; --e >= 0;) t[e] = 0; + }; let kt = (t, e, i) => (e << t.hash_shift ^ i) & t.hash_mask; - const yt = t => { - const e = t.state; - let i = e.pending; - i > t.avail_out && (i = t.avail_out), 0 !== i && (t.output.set(e.pending_buf.subarray(e.pending_out, e.pending_out + i), t.next_out), t.next_out += i, e.pending_out += i, t.total_out += i, t.avail_out -= i, e.pending -= i, 0 === e.pending && (e.pending_out = 0)); - }, - vt = (t, e) => { - $(t, t.block_start >= 0 ? t.block_start : -1, t.strstart - t.block_start, e), t.block_start = t.strstart, yt(t.strm); - }, - Et = (t, e) => { - t.pending_buf[t.pending++] = e; - }, - At = (t, e) => { - t.pending_buf[t.pending++] = e >>> 8 & 255, t.pending_buf[t.pending++] = 255 & e; - }, - xt = (t, e, i, n) => { - let r = t.avail_in; - return r > n && (r = n), 0 === r ? 0 : (t.avail_in -= r, e.set(t.input.subarray(t.next_in, t.next_in + r), i), 1 === t.state.wrap ? t.adler = Z(t.adler, e, r, i) : 2 === t.state.wrap && (t.adler = M(t.adler, e, r, i)), t.next_in += r, t.total_in += r, r); - }, - Ut = (t, e) => { - let i, + const e = t.state; + let i = e.pending; + i > t.avail_out && (i = t.avail_out), 0 !== i && (t.output.set(e.pending_buf.subarray(e.pending_out, e.pending_out + i), t.next_out), t.next_out += i, e.pending_out += i, t.total_out += i, t.avail_out -= i, e.pending -= i, 0 === e.pending && (e.pending_out = 0)); + }, + vt = (t, e) => { + $(t, t.block_start >= 0 ? t.block_start : -1, t.strstart - t.block_start, e), t.block_start = t.strstart, yt(t.strm); + }, + Et = (t, e) => { + t.pending_buf[t.pending++] = e; + }, + At = (t, e) => { + t.pending_buf[t.pending++] = e >>> 8 & 255, t.pending_buf[t.pending++] = 255 & e; + }, + xt = (t, e, i, n) => { + let r = t.avail_in; + return r > n && (r = n), 0 === r ? 0 : (t.avail_in -= r, e.set(t.input.subarray(t.next_in, t.next_in + r), i), 1 === t.state.wrap ? t.adler = Z(t.adler, e, r, i) : 2 === t.state.wrap && (t.adler = M(t.adler, e, r, i)), t.next_in += r, t.total_in += r, r); + }, + Ut = (t, e) => { + let i, n, r = t.max_chain_length, s = t.strstart, a = t.prev_length, o = t.nice_match; - const h = t.strstart > t.w_size - ct ? t.strstart - (t.w_size - ct) : 0, - l = t.window, - d = t.w_mask, - _ = t.prev, - f = t.strstart + ft; - let c = l[s + a - 1], + const h = t.strstart > t.w_size - ct ? t.strstart - (t.w_size - ct) : 0, + l = t.window, + d = t.w_mask, + _ = t.prev, + f = t.strstart + ft; + let c = l[s + a - 1], u = l[s + a]; - t.prev_length >= t.good_match && (r >>= 2), o > t.lookahead && (o = t.lookahead); - - do { - if (i = e, l[i + a] === u && l[i + a - 1] === c && l[i] === l[s] && l[++i] === l[s + 1]) { - s += 2, i++; - - do {} while (l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && s < f); - - if (n = ft - (f - s), s = f - ft, n > a) { - if (t.match_start = e, a = n, n >= o) break; - c = l[s + a - 1], u = l[s + a]; + t.prev_length >= t.good_match && (r >>= 2), o > t.lookahead && (o = t.lookahead); + do { + if (i = e, l[i + a] === u && l[i + a - 1] === c && l[i] === l[s] && l[++i] === l[s + 1]) { + s += 2, i++; + do {} while (l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && s < f); + if (n = ft - (f - s), s = f - ft, n > a) { + if (t.match_start = e, a = n, n >= o) break; + c = l[s + a - 1], u = l[s + a]; + } } + } while ((e = _[e & d]) > h && 0 != --r); + return a <= t.lookahead ? a : t.lookahead; + }, + zt = t => { + const e = t.w_size; + let i, n, r, s, a; + do { + if (s = t.window_size - t.lookahead - t.strstart, t.strstart >= e + (e - ct)) { + t.window.set(t.window.subarray(e, e + e), 0), t.match_start -= e, t.strstart -= e, t.block_start -= e, n = t.hash_size, i = n; + do { + r = t.head[--i], t.head[i] = r >= e ? r - e : 0; + } while (--n); + n = e, i = n; + do { + r = t.prev[--i], t.prev[i] = r >= e ? r - e : 0; + } while (--n); + s += e; + } + if (0 === t.strm.avail_in) break; + if (n = xt(t.strm, t.window, t.strstart + t.lookahead, s), t.lookahead += n, t.lookahead + t.insert >= 3) for (a = t.strstart - t.insert, t.ins_h = t.window[a], t.ins_h = kt(t, t.ins_h, t.window[a + 1]); t.insert && (t.ins_h = kt(t, t.ins_h, t.window[a + 3 - 1]), t.prev[a & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = a, a++, t.insert--, !(t.lookahead + t.insert < 3));); + } while (t.lookahead < ct && 0 !== t.strm.avail_in); + }, + Rt = (t, e) => { + let i, n; + for (;;) { + if (t.lookahead < ct) { + if (zt(t), t.lookahead < ct && e === G) return 1; + if (0 === t.lookahead) break; + } + if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 !== i && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i)), t.match_length >= 3) { + if (n = Y(t, t.strstart - t.match_start, t.match_length - 3), t.lookahead -= t.match_length, t.match_length <= t.max_lazy_match && t.lookahead >= 3) { + t.match_length--; + do { + t.strstart++, t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart; + } while (0 != --t.match_length); + t.strstart++; + } else t.strstart += t.match_length, t.match_length = 0, t.ins_h = t.window[t.strstart], t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 1]); + } else n = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++; + if (n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - } while ((e = _[e & d]) > h && 0 != --r); - - return a <= t.lookahead ? a : t.lookahead; - }, - zt = t => { - const e = t.w_size; - let i, n, r, s, a; - - do { - if (s = t.window_size - t.lookahead - t.strstart, t.strstart >= e + (e - ct)) { - t.window.set(t.window.subarray(e, e + e), 0), t.match_start -= e, t.strstart -= e, t.block_start -= e, n = t.hash_size, i = n; - - do { - r = t.head[--i], t.head[i] = r >= e ? r - e : 0; - } while (--n); - - n = e, i = n; - - do { - r = t.prev[--i], t.prev[i] = r >= e ? r - e : 0; - } while (--n); - - s += e; - } - - if (0 === t.strm.avail_in) break; - if (n = xt(t.strm, t.window, t.strstart + t.lookahead, s), t.lookahead += n, t.lookahead + t.insert >= 3) for (a = t.strstart - t.insert, t.ins_h = t.window[a], t.ins_h = kt(t, t.ins_h, t.window[a + 1]); t.insert && (t.ins_h = kt(t, t.ins_h, t.window[a + 3 - 1]), t.prev[a & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = a, a++, t.insert--, !(t.lookahead + t.insert < 3));); - } while (t.lookahead < ct && 0 !== t.strm.avail_in); - }, - Rt = (t, e) => { - let i, n; - - for (;;) { - if (t.lookahead < ct) { - if (zt(t), t.lookahead < ct && e === G) return 1; - if (0 === t.lookahead) break; - } - - if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 !== i && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i)), t.match_length >= 3) { - if (n = Y(t, t.strstart - t.match_start, t.match_length - 3), t.lookahead -= t.match_length, t.match_length <= t.max_lazy_match && t.lookahead >= 3) { - t.match_length--; - + return t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + }, + Nt = (t, e) => { + let i, n, r; + for (;;) { + if (t.lookahead < ct) { + if (zt(t), t.lookahead < ct && e === G) return 1; + if (0 === t.lookahead) break; + } + if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), t.prev_length = t.match_length, t.prev_match = t.match_start, t.match_length = 2, 0 !== i && t.prev_length < t.max_lazy_match && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i), t.match_length <= 5 && (t.strategy === st || 3 === t.match_length && t.strstart - t.match_start > 4096) && (t.match_length = 2)), t.prev_length >= 3 && t.match_length <= t.prev_length) { + r = t.strstart + t.lookahead - 3, n = Y(t, t.strstart - 1 - t.prev_match, t.prev_length - 3), t.lookahead -= t.prev_length - 1, t.prev_length -= 2; do { - t.strstart++, t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart; - } while (0 != --t.match_length); - - t.strstart++; - } else t.strstart += t.match_length, t.match_length = 0, t.ins_h = t.window[t.strstart], t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 1]); - } else n = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++; - if (n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - }, - Nt = (t, e) => { - let i, n, r; - - for (;;) { - if (t.lookahead < ct) { - if (zt(t), t.lookahead < ct && e === G) return 1; - if (0 === t.lookahead) break; + ++t.strstart <= r && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart); + } while (0 != --t.prev_length); + if (t.match_available = 0, t.match_length = 2, t.strstart++, n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; + } else if (t.match_available) { + if (n = Y(t, 0, t.window[t.strstart - 1]), n && vt(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out) return 1; + } else t.match_available = 1, t.strstart++, t.lookahead--; } - - if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), t.prev_length = t.match_length, t.prev_match = t.match_start, t.match_length = 2, 0 !== i && t.prev_length < t.max_lazy_match && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i), t.match_length <= 5 && (t.strategy === st || 3 === t.match_length && t.strstart - t.match_start > 4096) && (t.match_length = 2)), t.prev_length >= 3 && t.match_length <= t.prev_length) { - r = t.strstart + t.lookahead - 3, n = Y(t, t.strstart - 1 - t.prev_match, t.prev_length - 3), t.lookahead -= t.prev_length - 1, t.prev_length -= 2; - - do { - ++t.strstart <= r && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart); - } while (0 != --t.prev_length); - - if (t.match_available = 0, t.match_length = 2, t.strstart++, n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } else if (t.match_available) { - if (n = Y(t, 0, t.window[t.strstart - 1]), n && vt(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out) return 1; - } else t.match_available = 1, t.strstart++, t.lookahead--; - } - - return t.match_available && (n = Y(t, 0, t.window[t.strstart - 1]), t.match_available = 0), t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - }; - + return t.match_available && (n = Y(t, 0, t.window[t.strstart - 1]), t.match_available = 0), t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + }; function Tt(t, e, i, n, r) { this.good_length = t, this.max_lazy = e, this.nice_length = i, this.max_chain = n, this.func = r; } - const Ot = [new Tt(0, 0, 0, 0, (t, e) => { let i = 65535; - for (i > t.pending_buf_size - 5 && (i = t.pending_buf_size - 5);;) { if (t.lookahead <= 1) { if (zt(t), 0 === t.lookahead && e === G) return 1; if (0 === t.lookahead) break; } - t.strstart += t.lookahead, t.lookahead = 0; const n = t.block_start + i; if ((0 === t.strstart || t.strstart >= n) && (t.lookahead = t.strstart - n, t.strstart = n, vt(t, !1), 0 === t.strm.avail_out)) return 1; if (t.strstart - t.block_start >= t.w_size - ct && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : (t.strstart > t.block_start && (vt(t, !1), t.strm.avail_out), 1); }), new Tt(4, 4, 8, 4, Rt), new Tt(4, 5, 16, 8, Rt), new Tt(4, 6, 32, 32, Rt), new Tt(4, 4, 16, 16, Nt), new Tt(8, 16, 32, 32, Nt), new Tt(8, 16, 128, 128, Nt), new Tt(8, 32, 128, 256, Nt), new Tt(32, 128, 258, 1024, Nt), new Tt(32, 258, 258, 4096, Nt)]; - function Lt() { this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = _t, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new Uint16Array(1146), this.dyn_dtree = new Uint16Array(122), this.bl_tree = new Uint16Array(78), mt(this.dyn_ltree), mt(this.dyn_dtree), mt(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new Uint16Array(16), this.heap = new Uint16Array(573), mt(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new Uint16Array(573), mt(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0; } - const Bt = t => { - if (!t || !t.state) return gt(t, et); - t.total_in = t.total_out = 0, t.data_type = dt; - const e = t.state; - return e.pending = 0, e.pending_out = 0, e.wrap < 0 && (e.wrap = -e.wrap), e.status = e.wrap ? 42 : wt, t.adler = 2 === e.wrap ? 0 : 1, e.last_flush = G, W(e), Q; - }, - Ct = t => { - const e = Bt(t); - var i; - return e === Q && ((i = t.state).window_size = 2 * i.w_size, mt(i.head), i.max_lazy_match = Ot[i.level].max_lazy, i.good_match = Ot[i.level].good_length, i.nice_match = Ot[i.level].nice_length, i.max_chain_length = Ot[i.level].max_chain, i.strstart = 0, i.block_start = 0, i.lookahead = 0, i.insert = 0, i.match_length = i.prev_length = 2, i.match_available = 0, i.ins_h = 0), e; - }, - Dt = (t, e, i, n, r, s) => { - if (!t) return et; - let a = 1; - if (e === rt && (e = 6), n < 0 ? (a = 0, n = -n) : n > 15 && (a = 2, n -= 16), r < 1 || r > 9 || i !== _t || n < 8 || n > 15 || e < 0 || e > 9 || s < 0 || s > ht) return gt(t, et); - 8 === n && (n = 9); - const o = new Lt(); - return t.state = o, o.strm = t, o.wrap = a, o.gzhead = null, o.w_bits = n, o.w_size = 1 << o.w_bits, o.w_mask = o.w_size - 1, o.hash_bits = r + 7, o.hash_size = 1 << o.hash_bits, o.hash_mask = o.hash_size - 1, o.hash_shift = ~~((o.hash_bits + 3 - 1) / 3), o.window = new Uint8Array(2 * o.w_size), o.head = new Uint16Array(o.hash_size), o.prev = new Uint16Array(o.w_size), o.lit_bufsize = 1 << r + 6, o.pending_buf_size = 4 * o.lit_bufsize, o.pending_buf = new Uint8Array(o.pending_buf_size), o.d_buf = 1 * o.lit_bufsize, o.l_buf = 3 * o.lit_bufsize, o.level = e, o.strategy = s, o.method = i, Ct(t); - }; - + if (!t || !t.state) return gt(t, et); + t.total_in = t.total_out = 0, t.data_type = dt; + const e = t.state; + return e.pending = 0, e.pending_out = 0, e.wrap < 0 && (e.wrap = -e.wrap), e.status = e.wrap ? 42 : wt, t.adler = 2 === e.wrap ? 0 : 1, e.last_flush = G, W(e), Q; + }, + Ct = t => { + const e = Bt(t); + var i; + return e === Q && ((i = t.state).window_size = 2 * i.w_size, mt(i.head), i.max_lazy_match = Ot[i.level].max_lazy, i.good_match = Ot[i.level].good_length, i.nice_match = Ot[i.level].nice_length, i.max_chain_length = Ot[i.level].max_chain, i.strstart = 0, i.block_start = 0, i.lookahead = 0, i.insert = 0, i.match_length = i.prev_length = 2, i.match_available = 0, i.ins_h = 0), e; + }, + Dt = (t, e, i, n, r, s) => { + if (!t) return et; + let a = 1; + if (e === rt && (e = 6), n < 0 ? (a = 0, n = -n) : n > 15 && (a = 2, n -= 16), r < 1 || r > 9 || i !== _t || n < 8 || n > 15 || e < 0 || e > 9 || s < 0 || s > ht) return gt(t, et); + 8 === n && (n = 9); + const o = new Lt(); + return t.state = o, o.strm = t, o.wrap = a, o.gzhead = null, o.w_bits = n, o.w_size = 1 << o.w_bits, o.w_mask = o.w_size - 1, o.hash_bits = r + 7, o.hash_size = 1 << o.hash_bits, o.hash_mask = o.hash_size - 1, o.hash_shift = ~~((o.hash_bits + 3 - 1) / 3), o.window = new Uint8Array(2 * o.w_size), o.head = new Uint16Array(o.hash_size), o.prev = new Uint16Array(o.w_size), o.lit_bufsize = 1 << r + 6, o.pending_buf_size = 4 * o.lit_bufsize, o.pending_buf = new Uint8Array(o.pending_buf_size), o.d_buf = 1 * o.lit_bufsize, o.l_buf = 3 * o.lit_bufsize, o.level = e, o.strategy = s, o.method = i, Ct(t); + }; var It = Dt, - St = (t, e) => t && t.state ? 2 !== t.state.wrap ? et : (t.state.gzhead = e, Q) : et, - Zt = (t, e) => { - let i, n; - if (!t || !t.state || e > J || e < 0) return t ? gt(t, et) : et; - const r = t.state; - if (!t.output || !t.input && 0 !== t.avail_in || r.status === pt && e !== q) return gt(t, 0 === t.avail_out ? nt : et); - r.strm = t; - const s = r.last_flush; - if (r.last_flush = e, 42 === r.status) if (2 === r.wrap) t.adler = 0, Et(r, 31), Et(r, 139), Et(r, 8), r.gzhead ? (Et(r, (r.gzhead.text ? 1 : 0) + (r.gzhead.hcrc ? 2 : 0) + (r.gzhead.extra ? 4 : 0) + (r.gzhead.name ? 8 : 0) + (r.gzhead.comment ? 16 : 0)), Et(r, 255 & r.gzhead.time), Et(r, r.gzhead.time >> 8 & 255), Et(r, r.gzhead.time >> 16 & 255), Et(r, r.gzhead.time >> 24 & 255), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 255 & r.gzhead.os), r.gzhead.extra && r.gzhead.extra.length && (Et(r, 255 & r.gzhead.extra.length), Et(r, r.gzhead.extra.length >> 8 & 255)), r.gzhead.hcrc && (t.adler = M(t.adler, r.pending_buf, r.pending, 0)), r.gzindex = 0, r.status = 69) : (Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 3), r.status = wt);else { - let e = _t + (r.w_bits - 8 << 4) << 8, + St = (t, e) => t && t.state ? 2 !== t.state.wrap ? et : (t.state.gzhead = e, Q) : et, + Zt = (t, e) => { + let i, n; + if (!t || !t.state || e > J || e < 0) return t ? gt(t, et) : et; + const r = t.state; + if (!t.output || !t.input && 0 !== t.avail_in || r.status === pt && e !== q) return gt(t, 0 === t.avail_out ? nt : et); + r.strm = t; + const s = r.last_flush; + if (r.last_flush = e, 42 === r.status) if (2 === r.wrap) t.adler = 0, Et(r, 31), Et(r, 139), Et(r, 8), r.gzhead ? (Et(r, (r.gzhead.text ? 1 : 0) + (r.gzhead.hcrc ? 2 : 0) + (r.gzhead.extra ? 4 : 0) + (r.gzhead.name ? 8 : 0) + (r.gzhead.comment ? 16 : 0)), Et(r, 255 & r.gzhead.time), Et(r, r.gzhead.time >> 8 & 255), Et(r, r.gzhead.time >> 16 & 255), Et(r, r.gzhead.time >> 24 & 255), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 255 & r.gzhead.os), r.gzhead.extra && r.gzhead.extra.length && (Et(r, 255 & r.gzhead.extra.length), Et(r, r.gzhead.extra.length >> 8 & 255)), r.gzhead.hcrc && (t.adler = M(t.adler, r.pending_buf, r.pending, 0)), r.gzindex = 0, r.status = 69) : (Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 3), r.status = wt);else { + let e = _t + (r.w_bits - 8 << 4) << 8, i = -1; - i = r.strategy >= at || r.level < 2 ? 0 : r.level < 6 ? 1 : 6 === r.level ? 2 : 3, e |= i << 6, 0 !== r.strstart && (e |= 32), e += 31 - e % 31, r.status = wt, At(r, e), 0 !== r.strstart && (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), t.adler = 1; - } - if (69 === r.status) if (r.gzhead.extra) { - for (i = r.pending; r.gzindex < (65535 & r.gzhead.extra.length) && (r.pending !== r.pending_buf_size || (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending !== r.pending_buf_size));) Et(r, 255 & r.gzhead.extra[r.gzindex]), r.gzindex++; - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), r.gzindex === r.gzhead.extra.length && (r.gzindex = 0, r.status = 73); - } else r.status = 73; - if (73 === r.status) if (r.gzhead.name) { - i = r.pending; - - do { - if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { - n = 1; - break; - } - - n = r.gzindex < r.gzhead.name.length ? 255 & r.gzhead.name.charCodeAt(r.gzindex++) : 0, Et(r, n); - } while (0 !== n); - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.gzindex = 0, r.status = 91); - } else r.status = 91; - if (91 === r.status) if (r.gzhead.comment) { - i = r.pending; - - do { - if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { - n = 1; - break; - } - - n = r.gzindex < r.gzhead.comment.length ? 255 & r.gzhead.comment.charCodeAt(r.gzindex++) : 0, Et(r, n); - } while (0 !== n); - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.status = ut); - } else r.status = ut; - - if (r.status === ut && (r.gzhead.hcrc ? (r.pending + 2 > r.pending_buf_size && yt(t), r.pending + 2 <= r.pending_buf_size && (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), t.adler = 0, r.status = wt)) : r.status = wt), 0 !== r.pending) { - if (yt(t), 0 === t.avail_out) return r.last_flush = -1, Q; - } else if (0 === t.avail_in && bt(e) <= bt(s) && e !== q) return gt(t, nt); - - if (r.status === pt && 0 !== t.avail_in) return gt(t, nt); - - if (0 !== t.avail_in || 0 !== r.lookahead || e !== G && r.status !== pt) { - let i = r.strategy === at ? ((t, e) => { - let i; - - for (;;) { - if (0 === t.lookahead && (zt(t), 0 === t.lookahead)) { - if (e === G) return 1; + i = r.strategy >= at || r.level < 2 ? 0 : r.level < 6 ? 1 : 6 === r.level ? 2 : 3, e |= i << 6, 0 !== r.strstart && (e |= 32), e += 31 - e % 31, r.status = wt, At(r, e), 0 !== r.strstart && (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), t.adler = 1; + } + if (69 === r.status) if (r.gzhead.extra) { + for (i = r.pending; r.gzindex < (65535 & r.gzhead.extra.length) && (r.pending !== r.pending_buf_size || (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending !== r.pending_buf_size));) Et(r, 255 & r.gzhead.extra[r.gzindex]), r.gzindex++; + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), r.gzindex === r.gzhead.extra.length && (r.gzindex = 0, r.status = 73); + } else r.status = 73; + if (73 === r.status) if (r.gzhead.name) { + i = r.pending; + do { + if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { + n = 1; break; } - - if (t.match_length = 0, i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++, i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - })(r, e) : r.strategy === ot ? ((t, e) => { - let i, n, r, s; - const a = t.window; - - for (;;) { - if (t.lookahead <= ft) { - if (zt(t), t.lookahead <= ft && e === G) return 1; - if (0 === t.lookahead) break; + n = r.gzindex < r.gzhead.name.length ? 255 & r.gzhead.name.charCodeAt(r.gzindex++) : 0, Et(r, n); + } while (0 !== n); + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.gzindex = 0, r.status = 91); + } else r.status = 91; + if (91 === r.status) if (r.gzhead.comment) { + i = r.pending; + do { + if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { + n = 1; + break; } - - if (t.match_length = 0, t.lookahead >= 3 && t.strstart > 0 && (r = t.strstart - 1, n = a[r], n === a[++r] && n === a[++r] && n === a[++r])) { - s = t.strstart + ft; - - do {} while (n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && r < s); - - t.match_length = ft - (s - r), t.match_length > t.lookahead && (t.match_length = t.lookahead); + n = r.gzindex < r.gzhead.comment.length ? 255 & r.gzhead.comment.charCodeAt(r.gzindex++) : 0, Et(r, n); + } while (0 !== n); + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.status = ut); + } else r.status = ut; + if (r.status === ut && (r.gzhead.hcrc ? (r.pending + 2 > r.pending_buf_size && yt(t), r.pending + 2 <= r.pending_buf_size && (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), t.adler = 0, r.status = wt)) : r.status = wt), 0 !== r.pending) { + if (yt(t), 0 === t.avail_out) return r.last_flush = -1, Q; + } else if (0 === t.avail_in && bt(e) <= bt(s) && e !== q) return gt(t, nt); + if (r.status === pt && 0 !== t.avail_in) return gt(t, nt); + if (0 !== t.avail_in || 0 !== r.lookahead || e !== G && r.status !== pt) { + let i = r.strategy === at ? ((t, e) => { + let i; + for (;;) { + if (0 === t.lookahead && (zt(t), 0 === t.lookahead)) { + if (e === G) return 1; + break; + } + if (t.match_length = 0, i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++, i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - - if (t.match_length >= 3 ? (i = Y(t, 1, t.match_length - 3), t.lookahead -= t.match_length, t.strstart += t.match_length, t.match_length = 0) : (i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++), i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - })(r, e) : Ot[r.level].func(r, e); - if (3 !== i && 4 !== i || (r.status = pt), 1 === i || 3 === i) return 0 === t.avail_out && (r.last_flush = -1), Q; - if (2 === i && (e === X ? j(r) : e !== J && (K(r, 0, 0, !1), e === V && (mt(r.head), 0 === r.lookahead && (r.strstart = 0, r.block_start = 0, r.insert = 0))), yt(t), 0 === t.avail_out)) return r.last_flush = -1, Q; - } - - return e !== q ? Q : r.wrap <= 0 ? tt : (2 === r.wrap ? (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), Et(r, t.adler >> 16 & 255), Et(r, t.adler >> 24 & 255), Et(r, 255 & t.total_in), Et(r, t.total_in >> 8 & 255), Et(r, t.total_in >> 16 & 255), Et(r, t.total_in >> 24 & 255)) : (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), yt(t), r.wrap > 0 && (r.wrap = -r.wrap), 0 !== r.pending ? Q : tt); - }, - Ft = t => { - if (!t || !t.state) return et; - const e = t.state.status; - return 42 !== e && 69 !== e && 73 !== e && 91 !== e && e !== ut && e !== wt && e !== pt ? gt(t, et) : (t.state = null, e === wt ? gt(t, it) : Q); - }, - Mt = (t, e) => { - let i = e.length; - if (!t || !t.state) return et; - const n = t.state, - r = n.wrap; - if (2 === r || 1 === r && 42 !== n.status || n.lookahead) return et; - - if (1 === r && (t.adler = Z(t.adler, e, i, 0)), n.wrap = 0, i >= n.w_size) { - 0 === r && (mt(n.head), n.strstart = 0, n.block_start = 0, n.insert = 0); - let t = new Uint8Array(n.w_size); - t.set(e.subarray(i - n.w_size, i), 0), e = t, i = n.w_size; - } - - const s = t.avail_in, - a = t.next_in, - o = t.input; - - for (t.avail_in = i, t.next_in = 0, t.input = e, zt(n); n.lookahead >= 3;) { - let t = n.strstart, + return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + })(r, e) : r.strategy === ot ? ((t, e) => { + let i, n, r, s; + const a = t.window; + for (;;) { + if (t.lookahead <= ft) { + if (zt(t), t.lookahead <= ft && e === G) return 1; + if (0 === t.lookahead) break; + } + if (t.match_length = 0, t.lookahead >= 3 && t.strstart > 0 && (r = t.strstart - 1, n = a[r], n === a[++r] && n === a[++r] && n === a[++r])) { + s = t.strstart + ft; + do {} while (n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && r < s); + t.match_length = ft - (s - r), t.match_length > t.lookahead && (t.match_length = t.lookahead); + } + if (t.match_length >= 3 ? (i = Y(t, 1, t.match_length - 3), t.lookahead -= t.match_length, t.strstart += t.match_length, t.match_length = 0) : (i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++), i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; + } + return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + })(r, e) : Ot[r.level].func(r, e); + if (3 !== i && 4 !== i || (r.status = pt), 1 === i || 3 === i) return 0 === t.avail_out && (r.last_flush = -1), Q; + if (2 === i && (e === X ? j(r) : e !== J && (K(r, 0, 0, !1), e === V && (mt(r.head), 0 === r.lookahead && (r.strstart = 0, r.block_start = 0, r.insert = 0))), yt(t), 0 === t.avail_out)) return r.last_flush = -1, Q; + } + return e !== q ? Q : r.wrap <= 0 ? tt : (2 === r.wrap ? (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), Et(r, t.adler >> 16 & 255), Et(r, t.adler >> 24 & 255), Et(r, 255 & t.total_in), Et(r, t.total_in >> 8 & 255), Et(r, t.total_in >> 16 & 255), Et(r, t.total_in >> 24 & 255)) : (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), yt(t), r.wrap > 0 && (r.wrap = -r.wrap), 0 !== r.pending ? Q : tt); + }, + Ft = t => { + if (!t || !t.state) return et; + const e = t.state.status; + return 42 !== e && 69 !== e && 73 !== e && 91 !== e && e !== ut && e !== wt && e !== pt ? gt(t, et) : (t.state = null, e === wt ? gt(t, it) : Q); + }, + Mt = (t, e) => { + let i = e.length; + if (!t || !t.state) return et; + const n = t.state, + r = n.wrap; + if (2 === r || 1 === r && 42 !== n.status || n.lookahead) return et; + if (1 === r && (t.adler = Z(t.adler, e, i, 0)), n.wrap = 0, i >= n.w_size) { + 0 === r && (mt(n.head), n.strstart = 0, n.block_start = 0, n.insert = 0); + let t = new Uint8Array(n.w_size); + t.set(e.subarray(i - n.w_size, i), 0), e = t, i = n.w_size; + } + const s = t.avail_in, + a = t.next_in, + o = t.input; + for (t.avail_in = i, t.next_in = 0, t.input = e, zt(n); n.lookahead >= 3;) { + let t = n.strstart, e = n.lookahead - 2; - - do { - n.ins_h = kt(n, n.ins_h, n.window[t + 3 - 1]), n.prev[t & n.w_mask] = n.head[n.ins_h], n.head[n.ins_h] = t, t++; - } while (--e); - - n.strstart = t, n.lookahead = 2, zt(n); - } - - return n.strstart += n.lookahead, n.block_start = n.strstart, n.insert = n.lookahead, n.lookahead = 0, n.match_length = n.prev_length = 2, n.match_available = 0, t.next_in = a, t.input = o, t.avail_in = s, n.wrap = r, Q; - }; - + do { + n.ins_h = kt(n, n.ins_h, n.window[t + 3 - 1]), n.prev[t & n.w_mask] = n.head[n.ins_h], n.head[n.ins_h] = t, t++; + } while (--e); + n.strstart = t, n.lookahead = 2, zt(n); + } + return n.strstart += n.lookahead, n.block_start = n.strstart, n.insert = n.lookahead, n.lookahead = 0, n.match_length = n.prev_length = 2, n.match_available = 0, t.next_in = a, t.input = o, t.avail_in = s, n.wrap = r, Q; + }; const Pt = (t, e) => Object.prototype.hasOwnProperty.call(t, e); - var Ht = function Ht(t) { - const e = Array.prototype.slice.call(arguments, 1); - - for (; e.length;) { - const i = e.shift(); - - if (i) { - if ("object" != typeof i) throw new TypeError(i + "must be non-object"); - - for (const e in i) Pt(i, e) && (t[e] = i[e]); + const e = Array.prototype.slice.call(arguments, 1); + for (; e.length;) { + const i = e.shift(); + if (i) { + if ("object" != typeof i) throw new TypeError(i + "must be non-object"); + for (const e in i) Pt(i, e) && (t[e] = i[e]); + } } - } - - return t; - }, - Wt = t => { - let e = 0; - - for (let i = 0, n = t.length; i < n; i++) e += t[i].length; - - const i = new Uint8Array(e); - - for (let e = 0, n = 0, r = t.length; e < r; e++) { - let r = t[e]; - i.set(r, n), n += r.length; - } - - return i; - }; - + return t; + }, + Wt = t => { + let e = 0; + for (let i = 0, n = t.length; i < n; i++) e += t[i].length; + const i = new Uint8Array(e); + for (let e = 0, n = 0, r = t.length; e < r; e++) { + let r = t[e]; + i.set(r, n), n += r.length; + } + return i; + }; let Kt = !0; - try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (t) { Kt = !1; } - const $t = new Uint8Array(256); - for (let t = 0; t < 256; t++) $t[t] = t >= 252 ? 6 : t >= 248 ? 5 : t >= 240 ? 4 : t >= 224 ? 3 : t >= 192 ? 2 : 1; - $t[254] = $t[254] = 1; - var Yt = t => { - if ("function" == typeof TextEncoder && TextEncoder.prototype.encode) return new TextEncoder().encode(t); - let e, + if ("function" == typeof TextEncoder && TextEncoder.prototype.encode) return new TextEncoder().encode(t); + let e, i, n, r, s, a = t.length, o = 0; - - for (r = 0; r < a; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), o += i < 128 ? 1 : i < 2048 ? 2 : i < 65536 ? 3 : 4; - - for (e = new Uint8Array(o), s = 0, r = 0; s < o; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), i < 128 ? e[s++] = i : i < 2048 ? (e[s++] = 192 | i >>> 6, e[s++] = 128 | 63 & i) : i < 65536 ? (e[s++] = 224 | i >>> 12, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i) : (e[s++] = 240 | i >>> 18, e[s++] = 128 | i >>> 12 & 63, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i); - - return e; - }, - jt = (t, e) => { - const i = e || t.length; - if ("function" == typeof TextDecoder && TextDecoder.prototype.decode) return new TextDecoder().decode(t.subarray(0, e)); - let n, r; - const s = new Array(2 * i); - - for (r = 0, n = 0; n < i;) { - let e = t[n++]; - - if (e < 128) { - s[r++] = e; - continue; - } - - let a = $t[e]; - if (a > 4) s[r++] = 65533, n += a - 1;else { - for (e &= 2 === a ? 31 : 3 === a ? 15 : 7; a > 1 && n < i;) e = e << 6 | 63 & t[n++], a--; - - a > 1 ? s[r++] = 65533 : e < 65536 ? s[r++] = e : (e -= 65536, s[r++] = 55296 | e >> 10 & 1023, s[r++] = 56320 | 1023 & e); + for (r = 0; r < a; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), o += i < 128 ? 1 : i < 2048 ? 2 : i < 65536 ? 3 : 4; + for (e = new Uint8Array(o), s = 0, r = 0; s < o; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), i < 128 ? e[s++] = i : i < 2048 ? (e[s++] = 192 | i >>> 6, e[s++] = 128 | 63 & i) : i < 65536 ? (e[s++] = 224 | i >>> 12, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i) : (e[s++] = 240 | i >>> 18, e[s++] = 128 | i >>> 12 & 63, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i); + return e; + }, + jt = (t, e) => { + const i = e || t.length; + if ("function" == typeof TextDecoder && TextDecoder.prototype.decode) return new TextDecoder().decode(t.subarray(0, e)); + let n, r; + const s = new Array(2 * i); + for (r = 0, n = 0; n < i;) { + let e = t[n++]; + if (e < 128) { + s[r++] = e; + continue; + } + let a = $t[e]; + if (a > 4) s[r++] = 65533, n += a - 1;else { + for (e &= 2 === a ? 31 : 3 === a ? 15 : 7; a > 1 && n < i;) e = e << 6 | 63 & t[n++], a--; + a > 1 ? s[r++] = 65533 : e < 65536 ? s[r++] = e : (e -= 65536, s[r++] = 55296 | e >> 10 & 1023, s[r++] = 56320 | 1023 & e); + } } - } - - return ((t, e) => { - if (e < 65534 && t.subarray && Kt) return String.fromCharCode.apply(null, t.length === e ? t : t.subarray(0, e)); - let i = ""; - - for (let n = 0; n < e; n++) i += String.fromCharCode(t[n]); - - return i; - })(s, r); - }, - Gt = (t, e) => { - (e = e || t.length) > t.length && (e = t.length); - let i = e - 1; - - for (; i >= 0 && 128 == (192 & t[i]);) i--; - - return i < 0 || 0 === i ? e : i + $t[t[i]] > e ? i : e; - }, - Xt = function Xt() { - this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; - }; - + return ((t, e) => { + if (e < 65534 && t.subarray && Kt) return String.fromCharCode.apply(null, t.length === e ? t : t.subarray(0, e)); + let i = ""; + for (let n = 0; n < e; n++) i += String.fromCharCode(t[n]); + return i; + })(s, r); + }, + Gt = (t, e) => { + (e = e || t.length) > t.length && (e = t.length); + let i = e - 1; + for (; i >= 0 && 128 == (192 & t[i]);) i--; + return i < 0 || 0 === i ? e : i + $t[t[i]] > e ? i : e; + }, + Xt = function Xt() { + this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; + }; const Vt = Object.prototype.toString, - { - Z_NO_FLUSH: qt, - Z_SYNC_FLUSH: Jt, - Z_FULL_FLUSH: Qt, - Z_FINISH: te, - Z_OK: ee, - Z_STREAM_END: ie, - Z_DEFAULT_COMPRESSION: ne, - Z_DEFAULT_STRATEGY: re, - Z_DEFLATED: se - } = H; - + { + Z_NO_FLUSH: qt, + Z_SYNC_FLUSH: Jt, + Z_FULL_FLUSH: Qt, + Z_FINISH: te, + Z_OK: ee, + Z_STREAM_END: ie, + Z_DEFAULT_COMPRESSION: ne, + Z_DEFAULT_STRATEGY: re, + Z_DEFLATED: se + } = H; function ae(t) { this.options = Ht({ level: ne, @@ -3127,326 +2659,260 @@ e.raw && e.windowBits > 0 ? e.windowBits = -e.windowBits : e.gzip && e.windowBits > 0 && e.windowBits < 16 && (e.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new Xt(), this.strm.avail_out = 0; let i = It(this.strm, e.level, e.method, e.windowBits, e.memLevel, e.strategy); if (i !== ee) throw new Error(P[i]); - if (e.header && St(this.strm, e.header), e.dictionary) { let t; if (t = "string" == typeof e.dictionary ? Yt(e.dictionary) : "[object ArrayBuffer]" === Vt.call(e.dictionary) ? new Uint8Array(e.dictionary) : e.dictionary, i = Mt(this.strm, t), i !== ee) throw new Error(P[i]); this._dict_set = !0; } } - function oe(t, e) { const i = new ae(e); if (i.push(t, !0), i.err) throw i.msg || P[i.err]; return i.result; } - ae.prototype.push = function (t, e) { const i = this.strm, - n = this.options.chunkSize; + n = this.options.chunkSize; let r, s; if (this.ended) return !1; - for (s = e === ~~e ? e : !0 === e ? te : qt, "string" == typeof t ? i.input = Yt(t) : "[object ArrayBuffer]" === Vt.call(t) ? i.input = new Uint8Array(t) : i.input = t, i.next_in = 0, i.avail_in = i.input.length;;) if (0 === i.avail_out && (i.output = new Uint8Array(n), i.next_out = 0, i.avail_out = n), (s === Jt || s === Qt) && i.avail_out <= 6) this.onData(i.output.subarray(0, i.next_out)), i.avail_out = 0;else { if (r = Zt(i, s), r === ie) return i.next_out > 0 && this.onData(i.output.subarray(0, i.next_out)), r = Ft(this.strm), this.onEnd(r), this.ended = !0, r === ee; - if (0 !== i.avail_out) { if (s > 0 && i.next_out > 0) this.onData(i.output.subarray(0, i.next_out)), i.avail_out = 0;else if (0 === i.avail_in) break; } else this.onData(i.output); } - return !0; }, ae.prototype.onData = function (t) { this.chunks.push(t); }, ae.prototype.onEnd = function (t) { t === ee && (this.result = Wt(this.chunks)), this.chunks = [], this.err = t, this.msg = this.strm.msg; }; - var he = { - Deflate: ae, - deflate: oe, - deflateRaw: function deflateRaw(t, e) { - return (e = e || {}).raw = !0, oe(t, e); - }, - gzip: function gzip(t, e) { - return (e = e || {}).gzip = !0, oe(t, e); + Deflate: ae, + deflate: oe, + deflateRaw: function deflateRaw(t, e) { + return (e = e || {}).raw = !0, oe(t, e); + }, + gzip: function gzip(t, e) { + return (e = e || {}).gzip = !0, oe(t, e); + }, + constants: H }, - constants: H - }, - le = function le(t, e) { - let i, n, r, s, a, o, h, l, d, _, f, c, u, w, p, g, b, m, k, y, v, E, A, x; - - const U = t.state; - i = t.next_in, A = t.input, n = i + (t.avail_in - 5), r = t.next_out, x = t.output, s = r - (e - t.avail_out), a = r + (t.avail_out - 257), o = U.dmax, h = U.wsize, l = U.whave, d = U.wnext, _ = U.window, f = U.hold, c = U.bits, u = U.lencode, w = U.distcode, p = (1 << U.lenbits) - 1, g = (1 << U.distbits) - 1; - - t: do { - c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = u[f & p]; - - e: for (;;) { - if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, 0 === m) x[r++] = 65535 & b;else { - if (!(16 & m)) { - if (0 == (64 & m)) { - b = u[(65535 & b) + (f & (1 << m) - 1)]; - continue e; - } - - if (32 & m) { - U.mode = 12; - break t; - } - - t.msg = "invalid literal/length code", U.mode = 30; - break t; - } - - k = 65535 & b, m &= 15, m && (c < m && (f += A[i++] << c, c += 8), k += f & (1 << m) - 1, f >>>= m, c -= m), c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = w[f & g]; - - i: for (;;) { - if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, !(16 & m)) { + le = function le(t, e) { + let i, n, r, s, a, o, h, l, d, _, f, c, u, w, p, g, b, m, k, y, v, E, A, x; + const U = t.state; + i = t.next_in, A = t.input, n = i + (t.avail_in - 5), r = t.next_out, x = t.output, s = r - (e - t.avail_out), a = r + (t.avail_out - 257), o = U.dmax, h = U.wsize, l = U.whave, d = U.wnext, _ = U.window, f = U.hold, c = U.bits, u = U.lencode, w = U.distcode, p = (1 << U.lenbits) - 1, g = (1 << U.distbits) - 1; + t: do { + c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = u[f & p]; + e: for (;;) { + if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, 0 === m) x[r++] = 65535 & b;else { + if (!(16 & m)) { if (0 == (64 & m)) { - b = w[(65535 & b) + (f & (1 << m) - 1)]; - continue i; + b = u[(65535 & b) + (f & (1 << m) - 1)]; + continue e; } - - t.msg = "invalid distance code", U.mode = 30; - break t; - } - - if (y = 65535 & b, m &= 15, c < m && (f += A[i++] << c, c += 8, c < m && (f += A[i++] << c, c += 8)), y += f & (1 << m) - 1, y > o) { - t.msg = "invalid distance too far back", U.mode = 30; + if (32 & m) { + U.mode = 12; + break t; + } + t.msg = "invalid literal/length code", U.mode = 30; break t; } - - if (f >>>= m, c -= m, m = r - s, y > m) { - if (m = y - m, m > l && U.sane) { + k = 65535 & b, m &= 15, m && (c < m && (f += A[i++] << c, c += 8), k += f & (1 << m) - 1, f >>>= m, c -= m), c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = w[f & g]; + i: for (;;) { + if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, !(16 & m)) { + if (0 == (64 & m)) { + b = w[(65535 & b) + (f & (1 << m) - 1)]; + continue i; + } + t.msg = "invalid distance code", U.mode = 30; + break t; + } + if (y = 65535 & b, m &= 15, c < m && (f += A[i++] << c, c += 8, c < m && (f += A[i++] << c, c += 8)), y += f & (1 << m) - 1, y > o) { t.msg = "invalid distance too far back", U.mode = 30; break t; } - - if (v = 0, E = _, 0 === d) { - if (v += h - m, m < k) { - k -= m; - - do { - x[r++] = _[v++]; - } while (--m); - - v = r - y, E = x; + if (f >>>= m, c -= m, m = r - s, y > m) { + if (m = y - m, m > l && U.sane) { + t.msg = "invalid distance too far back", U.mode = 30; + break t; } - } else if (d < m) { - if (v += h + d - m, m -= d, m < k) { - k -= m; - - do { - x[r++] = _[v++]; - } while (--m); - - if (v = 0, d < k) { - m = d, k -= m; - + if (v = 0, E = _, 0 === d) { + if (v += h - m, m < k) { + k -= m; do { x[r++] = _[v++]; } while (--m); - v = r - y, E = x; } + } else if (d < m) { + if (v += h + d - m, m -= d, m < k) { + k -= m; + do { + x[r++] = _[v++]; + } while (--m); + if (v = 0, d < k) { + m = d, k -= m; + do { + x[r++] = _[v++]; + } while (--m); + v = r - y, E = x; + } + } + } else if (v += d - m, m < k) { + k -= m; + do { + x[r++] = _[v++]; + } while (--m); + v = r - y, E = x; } - } else if (v += d - m, m < k) { - k -= m; - + for (; k > 2;) x[r++] = E[v++], x[r++] = E[v++], x[r++] = E[v++], k -= 3; + k && (x[r++] = E[v++], k > 1 && (x[r++] = E[v++])); + } else { + v = r - y; do { - x[r++] = _[v++]; - } while (--m); - - v = r - y, E = x; + x[r++] = x[v++], x[r++] = x[v++], x[r++] = x[v++], k -= 3; + } while (k > 2); + k && (x[r++] = x[v++], k > 1 && (x[r++] = x[v++])); } - - for (; k > 2;) x[r++] = E[v++], x[r++] = E[v++], x[r++] = E[v++], k -= 3; - - k && (x[r++] = E[v++], k > 1 && (x[r++] = E[v++])); - } else { - v = r - y; - - do { - x[r++] = x[v++], x[r++] = x[v++], x[r++] = x[v++], k -= 3; - } while (k > 2); - - k && (x[r++] = x[v++], k > 1 && (x[r++] = x[v++])); + break; } - - break; } + break; } - break; - } - } while (i < n && r < a); - - k = c >> 3, i -= k, c -= k << 3, f &= (1 << c) - 1, t.next_in = i, t.next_out = r, t.avail_in = i < n ? n - i + 5 : 5 - (i - n), t.avail_out = r < a ? a - r + 257 : 257 - (r - a), U.hold = f, U.bits = c; - }; - + } while (i < n && r < a); + k = c >> 3, i -= k, c -= k << 3, f &= (1 << c) - 1, t.next_in = i, t.next_out = r, t.avail_in = i < n ? n - i + 5 : 5 - (i - n), t.avail_out = r < a ? a - r + 257 : 257 - (r - a), U.hold = f, U.bits = c; + }; const de = new Uint16Array([3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0]), - _e = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78]), - fe = new Uint16Array([1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0]), - ce = new Uint8Array([16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]); - + _e = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78]), + fe = new Uint16Array([1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0]), + ce = new Uint8Array([16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]); var ue = (t, e, i, n, r, s, a, o) => { const h = o.bits; - let l, - d, - _, - f, - c, - u, - w = 0, - p = 0, - g = 0, - b = 0, - m = 0, - k = 0, - y = 0, - v = 0, - E = 0, - A = 0, - x = null, - U = 0; - + d, + _, + f, + c, + u, + w = 0, + p = 0, + g = 0, + b = 0, + m = 0, + k = 0, + y = 0, + v = 0, + E = 0, + A = 0, + x = null, + U = 0; const z = new Uint16Array(16), - R = new Uint16Array(16); + R = new Uint16Array(16); let N, - T, - O, - L = null, - B = 0; - + T, + O, + L = null, + B = 0; for (w = 0; w <= 15; w++) z[w] = 0; - for (p = 0; p < n; p++) z[e[i + p]]++; - for (m = h, b = 15; b >= 1 && 0 === z[b]; b--); - if (m > b && (m = b), 0 === b) return r[s++] = 20971520, r[s++] = 20971520, o.bits = 1, 0; - for (g = 1; g < b && 0 === z[g]; g++); - for (m < g && (m = g), v = 1, w = 1; w <= 15; w++) if (v <<= 1, v -= z[w], v < 0) return -1; - if (v > 0 && (0 === t || 1 !== b)) return -1; - for (R[1] = 0, w = 1; w < 15; w++) R[w + 1] = R[w] + z[w]; - for (p = 0; p < n; p++) 0 !== e[i + p] && (a[R[e[i + p]]++] = p); - if (0 === t ? (x = L = a, u = 19) : 1 === t ? (x = de, U -= 257, L = _e, B -= 257, u = 256) : (x = fe, L = ce, u = -1), A = 0, p = 0, w = g, c = s, k = m, y = 0, _ = -1, E = 1 << m, f = E - 1, 1 === t && E > 852 || 2 === t && E > 592) return 1; - for (;;) { N = w - y, a[p] < u ? (T = 0, O = a[p]) : a[p] > u ? (T = L[B + a[p]], O = x[U + a[p]]) : (T = 96, O = 0), l = 1 << w - y, d = 1 << k, g = d; - do { d -= l, r[c + (A >> y) + d] = N << 24 | T << 16 | O | 0; } while (0 !== d); - for (l = 1 << w - 1; A & l;) l >>= 1; - if (0 !== l ? (A &= l - 1, A += l) : A = 0, p++, 0 == --z[w]) { if (w === b) break; w = e[i + a[p]]; } - if (w > m && (A & f) !== _) { for (0 === y && (y = m), c += g, k = w - y, v = 1 << k; k + y < b && (v -= z[k + y], !(v <= 0));) k++, v <<= 1; - if (E += 1 << k, 1 === t && E > 852 || 2 === t && E > 592) return 1; _ = A & f, r[_] = m << 24 | k << 16 | c - s | 0; } } - return 0 !== A && (r[c + A] = w - y << 24 | 64 << 16 | 0), o.bits = m, 0; }; - const { - Z_FINISH: we, - Z_BLOCK: pe, - Z_TREES: ge, - Z_OK: be, - Z_STREAM_END: me, - Z_NEED_DICT: ke, - Z_STREAM_ERROR: ye, - Z_DATA_ERROR: ve, - Z_MEM_ERROR: Ee, - Z_BUF_ERROR: Ae, - Z_DEFLATED: xe - } = H, - Ue = 12, - ze = 30, - Re = t => (t >>> 24 & 255) + (t >>> 8 & 65280) + ((65280 & t) << 8) + ((255 & t) << 24); - + Z_FINISH: we, + Z_BLOCK: pe, + Z_TREES: ge, + Z_OK: be, + Z_STREAM_END: me, + Z_NEED_DICT: ke, + Z_STREAM_ERROR: ye, + Z_DATA_ERROR: ve, + Z_MEM_ERROR: Ee, + Z_BUF_ERROR: Ae, + Z_DEFLATED: xe + } = H, + Ue = 12, + ze = 30, + Re = t => (t >>> 24 & 255) + (t >>> 8 & 65280) + ((65280 & t) << 8) + ((255 & t) << 24); function Ne() { this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Uint16Array(320), this.work = new Uint16Array(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0; } - const Te = t => { - if (!t || !t.state) return ye; - const e = t.state; - return t.total_in = t.total_out = e.total = 0, t.msg = "", e.wrap && (t.adler = 1 & e.wrap), e.mode = 1, e.last = 0, e.havedict = 0, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(852), e.distcode = e.distdyn = new Int32Array(592), e.sane = 1, e.back = -1, be; - }, - Oe = t => { - if (!t || !t.state) return ye; - const e = t.state; - return e.wsize = 0, e.whave = 0, e.wnext = 0, Te(t); - }, - Le = (t, e) => { - let i; - if (!t || !t.state) return ye; - const n = t.state; - return e < 0 ? (i = 0, e = -e) : (i = 1 + (e >> 4), e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? ye : (null !== n.window && n.wbits !== e && (n.window = null), n.wrap = i, n.wbits = e, Oe(t)); - }, - Be = (t, e) => { - if (!t) return ye; - const i = new Ne(); - t.state = i, i.window = null; - const n = Le(t, e); - return n !== be && (t.state = null), n; - }; - + if (!t || !t.state) return ye; + const e = t.state; + return t.total_in = t.total_out = e.total = 0, t.msg = "", e.wrap && (t.adler = 1 & e.wrap), e.mode = 1, e.last = 0, e.havedict = 0, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(852), e.distcode = e.distdyn = new Int32Array(592), e.sane = 1, e.back = -1, be; + }, + Oe = t => { + if (!t || !t.state) return ye; + const e = t.state; + return e.wsize = 0, e.whave = 0, e.wnext = 0, Te(t); + }, + Le = (t, e) => { + let i; + if (!t || !t.state) return ye; + const n = t.state; + return e < 0 ? (i = 0, e = -e) : (i = 1 + (e >> 4), e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? ye : (null !== n.window && n.wbits !== e && (n.window = null), n.wrap = i, n.wbits = e, Oe(t)); + }, + Be = (t, e) => { + if (!t) return ye; + const i = new Ne(); + t.state = i, i.window = null; + const n = Le(t, e); + return n !== be && (t.state = null), n; + }; let Ce, - De, - Ie = !0; - + De, + Ie = !0; const Se = t => { - if (Ie) { - Ce = new Int32Array(512), De = new Int32Array(32); - let e = 0; - - for (; e < 144;) t.lens[e++] = 8; - - for (; e < 256;) t.lens[e++] = 9; - - for (; e < 280;) t.lens[e++] = 7; - - for (; e < 288;) t.lens[e++] = 8; - - for (ue(1, t.lens, 0, 288, Ce, 0, t.work, { - bits: 9 - }), e = 0; e < 32;) t.lens[e++] = 5; - - ue(2, t.lens, 0, 32, De, 0, t.work, { - bits: 5 - }), Ie = !1; - } - - t.lencode = Ce, t.lenbits = 9, t.distcode = De, t.distbits = 5; - }, - Ze = (t, e, i, n) => { - let r; - const s = t.state; - return null === s.window && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new Uint8Array(s.wsize)), n >= s.wsize ? (s.window.set(e.subarray(i - s.wsize, i), 0), s.wnext = 0, s.whave = s.wsize) : (r = s.wsize - s.wnext, r > n && (r = n), s.window.set(e.subarray(i - n, i - n + r), s.wnext), (n -= r) ? (s.window.set(e.subarray(i - n, i), 0), s.wnext = n, s.whave = s.wsize) : (s.wnext += r, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += r))), 0; - }; - + if (Ie) { + Ce = new Int32Array(512), De = new Int32Array(32); + let e = 0; + for (; e < 144;) t.lens[e++] = 8; + for (; e < 256;) t.lens[e++] = 9; + for (; e < 280;) t.lens[e++] = 7; + for (; e < 288;) t.lens[e++] = 8; + for (ue(1, t.lens, 0, 288, Ce, 0, t.work, { + bits: 9 + }), e = 0; e < 32;) t.lens[e++] = 5; + ue(2, t.lens, 0, 32, De, 0, t.work, { + bits: 5 + }), Ie = !1; + } + t.lencode = Ce, t.lenbits = 9, t.distcode = De, t.distbits = 5; + }, + Ze = (t, e, i, n) => { + let r; + const s = t.state; + return null === s.window && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new Uint8Array(s.wsize)), n >= s.wsize ? (s.window.set(e.subarray(i - s.wsize, i), 0), s.wnext = 0, s.whave = s.wsize) : (r = s.wsize - s.wnext, r > n && (r = n), s.window.set(e.subarray(i - n, i - n + r), s.wnext), (n -= r) ? (s.window.set(e.subarray(i - n, i), 0), s.wnext = n, s.whave = s.wsize) : (s.wnext += r, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += r))), 0; + }; var Fe = Oe, - Me = Be, - Pe = (t, e) => { - let i, + Me = Be, + Pe = (t, e) => { + let i, n, r, s, @@ -3465,524 +2931,411 @@ b, m, k, - y, - v, - E, - A = 0; - - const x = new Uint8Array(4); - let U, z; - const R = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); - if (!t || !t.state || !t.output || !t.input && 0 !== t.avail_in) return ye; - i = t.state, i.mode === Ue && (i.mode = 13), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, _ = o, f = h, E = be; - - t: for (;;) switch (i.mode) { - case 1: - if (0 === i.wrap) { - i.mode = 13; - break; - } - - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (2 & i.wrap && 35615 === l) { - i.check = 0, x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0), l = 0, d = 0, i.mode = 2; - break; - } - - if (i.flags = 0, i.head && (i.head.done = !1), !(1 & i.wrap) || (((255 & l) << 8) + (l >> 8)) % 31) { - t.msg = "incorrect header check", i.mode = ze; - break; - } - - if ((15 & l) !== xe) { - t.msg = "unknown compression method", i.mode = ze; - break; - } - - if (l >>>= 4, d -= 4, v = 8 + (15 & l), 0 === i.wbits) i.wbits = v;else if (v > i.wbits) { - t.msg = "invalid window size", i.mode = ze; - break; - } - i.dmax = 1 << i.wbits, t.adler = i.check = 1, i.mode = 512 & l ? 10 : Ue, l = 0, d = 0; - break; - - case 2: - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (i.flags = l, (255 & i.flags) !== xe) { - t.msg = "unknown compression method", i.mode = ze; - break; - } - - if (57344 & i.flags) { - t.msg = "unknown header flags set", i.mode = ze; - break; - } - - i.head && (i.head.text = l >> 8 & 1), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 3; - - case 3: - for (; d < 32;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - i.head && (i.head.time = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, x[2] = l >>> 16 & 255, x[3] = l >>> 24 & 255, i.check = M(i.check, x, 4, 0)), l = 0, d = 0, i.mode = 4; - - case 4: - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - i.head && (i.head.xflags = 255 & l, i.head.os = l >> 8), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 5; - - case 5: - if (1024 & i.flags) { - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - i.length = l, i.head && (i.head.extra_len = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0; - } else i.head && (i.head.extra = null); - - i.mode = 6; - - case 6: - if (1024 & i.flags && (c = i.length, c > o && (c = o), c && (i.head && (v = i.head.extra_len - i.length, i.head.extra || (i.head.extra = new Uint8Array(i.head.extra_len)), i.head.extra.set(n.subarray(s, s + c), v)), 512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, i.length -= c), i.length)) break t; - i.length = 0, i.mode = 7; - - case 7: - if (2048 & i.flags) { - if (0 === o) break t; - c = 0; - - do { - v = n[s + c++], i.head && v && i.length < 65536 && (i.head.name += String.fromCharCode(v)); - } while (v && c < o); - - if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; - } else i.head && (i.head.name = null); - - i.length = 0, i.mode = 8; - - case 8: - if (4096 & i.flags) { - if (0 === o) break t; - c = 0; - - do { - v = n[s + c++], i.head && v && i.length < 65536 && (i.head.comment += String.fromCharCode(v)); - } while (v && c < o); - - if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; - } else i.head && (i.head.comment = null); - - i.mode = 9; - - case 9: - if (512 & i.flags) { - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (l !== (65535 & i.check)) { - t.msg = "header crc mismatch", i.mode = ze; - break; - } - - l = 0, d = 0; - } - - i.head && (i.head.hcrc = i.flags >> 9 & 1, i.head.done = !0), t.adler = i.check = 0, i.mode = Ue; - break; - - case 10: - for (; d < 32;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - t.adler = i.check = Re(l), l = 0, d = 0, i.mode = 11; - - case 11: - if (0 === i.havedict) return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, ke; - t.adler = i.check = 1, i.mode = Ue; - - case Ue: - if (e === pe || e === ge) break t; - - case 13: - if (i.last) { - l >>>= 7 & d, d -= 7 & d, i.mode = 27; - break; - } - - for (; d < 3;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - switch (i.last = 1 & l, l >>>= 1, d -= 1, 3 & l) { - case 0: - i.mode = 14; - break; - - case 1: - if (Se(i), i.mode = 20, e === ge) { - l >>>= 2, d -= 2; - break t; - } - - break; - - case 2: - i.mode = 17; - break; - - case 3: - t.msg = "invalid block type", i.mode = ze; - } - - l >>>= 2, d -= 2; - break; - - case 14: - for (l >>>= 7 & d, d -= 7 & d; d < 32;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if ((65535 & l) != (l >>> 16 ^ 65535)) { - t.msg = "invalid stored block lengths", i.mode = ze; - break; - } - - if (i.length = 65535 & l, l = 0, d = 0, i.mode = 15, e === ge) break t; - - case 15: - i.mode = 16; - - case 16: - if (c = i.length, c) { - if (c > o && (c = o), c > h && (c = h), 0 === c) break t; - r.set(n.subarray(s, s + c), a), o -= c, s += c, h -= c, a += c, i.length -= c; - break; - } - - i.mode = Ue; - break; - - case 17: - for (; d < 14;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (i.nlen = 257 + (31 & l), l >>>= 5, d -= 5, i.ndist = 1 + (31 & l), l >>>= 5, d -= 5, i.ncode = 4 + (15 & l), l >>>= 4, d -= 4, i.nlen > 286 || i.ndist > 30) { - t.msg = "too many length or distance symbols", i.mode = ze; - break; - } - - i.have = 0, i.mode = 18; - - case 18: - for (; i.have < i.ncode;) { - for (; d < 3;) { + y, + v, + E, + A = 0; + const x = new Uint8Array(4); + let U, z; + const R = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); + if (!t || !t.state || !t.output || !t.input && 0 !== t.avail_in) return ye; + i = t.state, i.mode === Ue && (i.mode = 13), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, _ = o, f = h, E = be; + t: for (;;) switch (i.mode) { + case 1: + if (0 === i.wrap) { + i.mode = 13; + break; + } + for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - i.lens[R[i.have++]] = 7 & l, l >>>= 3, d -= 3; - } - - for (; i.have < 19;) i.lens[R[i.have++]] = 0; - - if (i.lencode = i.lendyn, i.lenbits = 7, U = { - bits: i.lenbits - }, E = ue(0, i.lens, 0, 19, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { - t.msg = "invalid code lengths set", i.mode = ze; + if (2 & i.wrap && 35615 === l) { + i.check = 0, x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0), l = 0, d = 0, i.mode = 2; + break; + } + if (i.flags = 0, i.head && (i.head.done = !1), !(1 & i.wrap) || (((255 & l) << 8) + (l >> 8)) % 31) { + t.msg = "incorrect header check", i.mode = ze; + break; + } + if ((15 & l) !== xe) { + t.msg = "unknown compression method", i.mode = ze; + break; + } + if (l >>>= 4, d -= 4, v = 8 + (15 & l), 0 === i.wbits) i.wbits = v;else if (v > i.wbits) { + t.msg = "invalid window size", i.mode = ze; + break; + } + i.dmax = 1 << i.wbits, t.adler = i.check = 1, i.mode = 512 & l ? 10 : Ue, l = 0, d = 0; break; - } - - i.have = 0, i.mode = 19; - - case 19: - for (; i.have < i.nlen + i.ndist;) { - for (; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { + case 2: + for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - if (b < 16) l >>>= p, d -= p, i.lens[i.have++] = b;else { - if (16 === b) { - for (z = p + 2; d < z;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (l >>>= p, d -= p, 0 === i.have) { - t.msg = "invalid bit length repeat", i.mode = ze; - break; - } - - v = i.lens[i.have - 1], c = 3 + (3 & l), l >>>= 2, d -= 2; - } else if (17 === b) { - for (z = p + 3; d < z;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - l >>>= p, d -= p, v = 0, c = 3 + (7 & l), l >>>= 3, d -= 3; - } else { - for (z = p + 7; d < z;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - l >>>= p, d -= p, v = 0, c = 11 + (127 & l), l >>>= 7, d -= 7; + if (i.flags = l, (255 & i.flags) !== xe) { + t.msg = "unknown compression method", i.mode = ze; + break; + } + if (57344 & i.flags) { + t.msg = "unknown header flags set", i.mode = ze; + break; + } + i.head && (i.head.text = l >> 8 & 1), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 3; + case 3: + for (; d < 32;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.head && (i.head.time = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, x[2] = l >>> 16 & 255, x[3] = l >>> 24 & 255, i.check = M(i.check, x, 4, 0)), l = 0, d = 0, i.mode = 4; + case 4: + for (; d < 16;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.head && (i.head.xflags = 255 & l, i.head.os = l >> 8), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 5; + case 5: + if (1024 & i.flags) { + for (; d < 16;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; } - - if (i.have + c > i.nlen + i.ndist) { - t.msg = "invalid bit length repeat", i.mode = ze; + i.length = l, i.head && (i.head.extra_len = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0; + } else i.head && (i.head.extra = null); + i.mode = 6; + case 6: + if (1024 & i.flags && (c = i.length, c > o && (c = o), c && (i.head && (v = i.head.extra_len - i.length, i.head.extra || (i.head.extra = new Uint8Array(i.head.extra_len)), i.head.extra.set(n.subarray(s, s + c), v)), 512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, i.length -= c), i.length)) break t; + i.length = 0, i.mode = 7; + case 7: + if (2048 & i.flags) { + if (0 === o) break t; + c = 0; + do { + v = n[s + c++], i.head && v && i.length < 65536 && (i.head.name += String.fromCharCode(v)); + } while (v && c < o); + if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; + } else i.head && (i.head.name = null); + i.length = 0, i.mode = 8; + case 8: + if (4096 & i.flags) { + if (0 === o) break t; + c = 0; + do { + v = n[s + c++], i.head && v && i.length < 65536 && (i.head.comment += String.fromCharCode(v)); + } while (v && c < o); + if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; + } else i.head && (i.head.comment = null); + i.mode = 9; + case 9: + if (512 & i.flags) { + for (; d < 16;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (l !== (65535 & i.check)) { + t.msg = "header crc mismatch", i.mode = ze; break; } - - for (; c--;) i.lens[i.have++] = v; + l = 0, d = 0; } - } - - if (i.mode === ze) break; - - if (0 === i.lens[256]) { - t.msg = "invalid code -- missing end-of-block", i.mode = ze; - break; - } - - if (i.lenbits = 9, U = { - bits: i.lenbits - }, E = ue(1, i.lens, 0, i.nlen, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { - t.msg = "invalid literal/lengths set", i.mode = ze; - break; - } - - if (i.distbits = 6, i.distcode = i.distdyn, U = { - bits: i.distbits - }, E = ue(2, i.lens, i.nlen, i.ndist, i.distcode, 0, i.work, U), i.distbits = U.bits, E) { - t.msg = "invalid distances set", i.mode = ze; - break; - } - - if (i.mode = 20, e === ge) break t; - - case 20: - i.mode = 21; - - case 21: - if (o >= 6 && h >= 258) { - t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, le(t, f), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, i.mode === Ue && (i.back = -1); + i.head && (i.head.hcrc = i.flags >> 9 & 1, i.head.done = !0), t.adler = i.check = 0, i.mode = Ue; break; - } - - for (i.back = 0; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (g && 0 == (240 & g)) { - for (m = p, k = g, y = b; A = i.lencode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + case 10: + for (; d < 32;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - l >>>= m, d -= m, i.back += m; - } - - if (l >>>= p, d -= p, i.back += p, i.length = b, 0 === g) { - i.mode = 26; - break; - } - - if (32 & g) { - i.back = -1, i.mode = Ue; - break; - } - - if (64 & g) { - t.msg = "invalid literal/length code", i.mode = ze; - break; - } - - i.extra = 15 & g, i.mode = 22; - - case 22: - if (i.extra) { - for (z = i.extra; d < z;) { + t.adler = i.check = Re(l), l = 0, d = 0, i.mode = 11; + case 11: + if (0 === i.havedict) return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, ke; + t.adler = i.check = 1, i.mode = Ue; + case Ue: + if (e === pe || e === ge) break t; + case 13: + if (i.last) { + l >>>= 7 & d, d -= 7 & d, i.mode = 27; + break; + } + for (; d < 3;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - i.length += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; - } - - i.was = i.length, i.mode = 23; - - case 23: - for (; A = i.distcode[l & (1 << i.distbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (0 == (240 & g)) { - for (m = p, k = g, y = b; A = i.distcode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + switch (i.last = 1 & l, l >>>= 1, d -= 1, 3 & l) { + case 0: + i.mode = 14; + break; + case 1: + if (Se(i), i.mode = 20, e === ge) { + l >>>= 2, d -= 2; + break t; + } + break; + case 2: + i.mode = 17; + break; + case 3: + t.msg = "invalid block type", i.mode = ze; + } + l >>>= 2, d -= 2; + break; + case 14: + for (l >>>= 7 & d, d -= 7 & d; d < 32;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - l >>>= m, d -= m, i.back += m; - } - - if (l >>>= p, d -= p, i.back += p, 64 & g) { - t.msg = "invalid distance code", i.mode = ze; + if ((65535 & l) != (l >>> 16 ^ 65535)) { + t.msg = "invalid stored block lengths", i.mode = ze; + break; + } + if (i.length = 65535 & l, l = 0, d = 0, i.mode = 15, e === ge) break t; + case 15: + i.mode = 16; + case 16: + if (c = i.length, c) { + if (c > o && (c = o), c > h && (c = h), 0 === c) break t; + r.set(n.subarray(s, s + c), a), o -= c, s += c, h -= c, a += c, i.length -= c; + break; + } + i.mode = Ue; break; - } - - i.offset = b, i.extra = 15 & g, i.mode = 24; - - case 24: - if (i.extra) { - for (z = i.extra; d < z;) { + case 17: + for (; d < 14;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - i.offset += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; - } - - if (i.offset > i.dmax) { - t.msg = "invalid distance too far back", i.mode = ze; - break; - } - - i.mode = 25; - - case 25: - if (0 === h) break t; - - if (c = f - h, i.offset > c) { - if (c = i.offset - c, c > i.whave && i.sane) { - t.msg = "invalid distance too far back", i.mode = ze; + if (i.nlen = 257 + (31 & l), l >>>= 5, d -= 5, i.ndist = 1 + (31 & l), l >>>= 5, d -= 5, i.ncode = 4 + (15 & l), l >>>= 4, d -= 4, i.nlen > 286 || i.ndist > 30) { + t.msg = "too many length or distance symbols", i.mode = ze; break; } - - c > i.wnext ? (c -= i.wnext, u = i.wsize - c) : u = i.wnext - c, c > i.length && (c = i.length), w = i.window; - } else w = r, u = a - i.offset, c = i.length; - - c > h && (c = h), h -= c, i.length -= c; - - do { - r[a++] = w[u++]; - } while (--c); - - 0 === i.length && (i.mode = 21); - break; - - case 26: - if (0 === h) break t; - r[a++] = i.length, h--, i.mode = 21; - break; - - case 27: - if (i.wrap) { - for (; d < 32;) { + i.have = 0, i.mode = 18; + case 18: + for (; i.have < i.ncode;) { + for (; d < 3;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.lens[R[i.have++]] = 7 & l, l >>>= 3, d -= 3; + } + for (; i.have < 19;) i.lens[R[i.have++]] = 0; + if (i.lencode = i.lendyn, i.lenbits = 7, U = { + bits: i.lenbits + }, E = ue(0, i.lens, 0, 19, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { + t.msg = "invalid code lengths set", i.mode = ze; + break; + } + i.have = 0, i.mode = 19; + case 19: + for (; i.have < i.nlen + i.ndist;) { + for (; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (b < 16) l >>>= p, d -= p, i.lens[i.have++] = b;else { + if (16 === b) { + for (z = p + 2; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (l >>>= p, d -= p, 0 === i.have) { + t.msg = "invalid bit length repeat", i.mode = ze; + break; + } + v = i.lens[i.have - 1], c = 3 + (3 & l), l >>>= 2, d -= 2; + } else if (17 === b) { + for (z = p + 3; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= p, d -= p, v = 0, c = 3 + (7 & l), l >>>= 3, d -= 3; + } else { + for (z = p + 7; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= p, d -= p, v = 0, c = 11 + (127 & l), l >>>= 7, d -= 7; + } + if (i.have + c > i.nlen + i.ndist) { + t.msg = "invalid bit length repeat", i.mode = ze; + break; + } + for (; c--;) i.lens[i.have++] = v; + } + } + if (i.mode === ze) break; + if (0 === i.lens[256]) { + t.msg = "invalid code -- missing end-of-block", i.mode = ze; + break; + } + if (i.lenbits = 9, U = { + bits: i.lenbits + }, E = ue(1, i.lens, 0, i.nlen, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { + t.msg = "invalid literal/lengths set", i.mode = ze; + break; + } + if (i.distbits = 6, i.distcode = i.distdyn, U = { + bits: i.distbits + }, E = ue(2, i.lens, i.nlen, i.ndist, i.distcode, 0, i.work, U), i.distbits = U.bits, E) { + t.msg = "invalid distances set", i.mode = ze; + break; + } + if (i.mode = 20, e === ge) break t; + case 20: + i.mode = 21; + case 21: + if (o >= 6 && h >= 258) { + t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, le(t, f), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, i.mode === Ue && (i.back = -1); + break; + } + for (i.back = 0; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { if (0 === o) break t; - o--, l |= n[s++] << d, d += 8; + o--, l += n[s++] << d, d += 8; } - - if (f -= h, t.total_out += f, i.total += f, f && (t.adler = i.check = i.flags ? M(i.check, r, f, a - f) : Z(i.check, r, f, a - f)), f = h, (i.flags ? l : Re(l)) !== i.check) { - t.msg = "incorrect data check", i.mode = ze; + if (g && 0 == (240 & g)) { + for (m = p, k = g, y = b; A = i.lencode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= m, d -= m, i.back += m; + } + if (l >>>= p, d -= p, i.back += p, i.length = b, 0 === g) { + i.mode = 26; break; } - - l = 0, d = 0; - } - - i.mode = 28; - - case 28: - if (i.wrap && i.flags) { - for (; d < 32;) { + if (32 & g) { + i.back = -1, i.mode = Ue; + break; + } + if (64 & g) { + t.msg = "invalid literal/length code", i.mode = ze; + break; + } + i.extra = 15 & g, i.mode = 22; + case 22: + if (i.extra) { + for (z = i.extra; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.length += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; + } + i.was = i.length, i.mode = 23; + case 23: + for (; A = i.distcode[l & (1 << i.distbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - if (l !== (4294967295 & i.total)) { - t.msg = "incorrect length check", i.mode = ze; + if (0 == (240 & g)) { + for (m = p, k = g, y = b; A = i.distcode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= m, d -= m, i.back += m; + } + if (l >>>= p, d -= p, i.back += p, 64 & g) { + t.msg = "invalid distance code", i.mode = ze; break; } - - l = 0, d = 0; - } - - i.mode = 29; - - case 29: - E = me; - break t; - - case ze: - E = ve; - break t; - - case 31: - return Ee; - - default: - return ye; - } - - return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, (i.wsize || f !== t.avail_out && i.mode < ze && (i.mode < 27 || e !== we)) && Ze(t, t.output, t.next_out, f - t.avail_out), _ -= t.avail_in, f -= t.avail_out, t.total_in += _, t.total_out += f, i.total += f, i.wrap && f && (t.adler = i.check = i.flags ? M(i.check, r, f, t.next_out - f) : Z(i.check, r, f, t.next_out - f)), t.data_type = i.bits + (i.last ? 64 : 0) + (i.mode === Ue ? 128 : 0) + (20 === i.mode || 15 === i.mode ? 256 : 0), (0 === _ && 0 === f || e === we) && E === be && (E = Ae), E; - }, - He = t => { - if (!t || !t.state) return ye; - let e = t.state; - return e.window && (e.window = null), t.state = null, be; - }, - We = (t, e) => { - if (!t || !t.state) return ye; - const i = t.state; - return 0 == (2 & i.wrap) ? ye : (i.head = e, e.done = !1, be); - }, - Ke = (t, e) => { - const i = e.length; - let n, r, s; - return t && t.state ? (n = t.state, 0 !== n.wrap && 11 !== n.mode ? ye : 11 === n.mode && (r = 1, r = Z(r, e, i, 0), r !== n.check) ? ve : (s = Ze(t, e, i, i), s ? (n.mode = 31, Ee) : (n.havedict = 1, be))) : ye; - }, - $e = function $e() { - this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; - }; - + i.offset = b, i.extra = 15 & g, i.mode = 24; + case 24: + if (i.extra) { + for (z = i.extra; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.offset += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; + } + if (i.offset > i.dmax) { + t.msg = "invalid distance too far back", i.mode = ze; + break; + } + i.mode = 25; + case 25: + if (0 === h) break t; + if (c = f - h, i.offset > c) { + if (c = i.offset - c, c > i.whave && i.sane) { + t.msg = "invalid distance too far back", i.mode = ze; + break; + } + c > i.wnext ? (c -= i.wnext, u = i.wsize - c) : u = i.wnext - c, c > i.length && (c = i.length), w = i.window; + } else w = r, u = a - i.offset, c = i.length; + c > h && (c = h), h -= c, i.length -= c; + do { + r[a++] = w[u++]; + } while (--c); + 0 === i.length && (i.mode = 21); + break; + case 26: + if (0 === h) break t; + r[a++] = i.length, h--, i.mode = 21; + break; + case 27: + if (i.wrap) { + for (; d < 32;) { + if (0 === o) break t; + o--, l |= n[s++] << d, d += 8; + } + if (f -= h, t.total_out += f, i.total += f, f && (t.adler = i.check = i.flags ? M(i.check, r, f, a - f) : Z(i.check, r, f, a - f)), f = h, (i.flags ? l : Re(l)) !== i.check) { + t.msg = "incorrect data check", i.mode = ze; + break; + } + l = 0, d = 0; + } + i.mode = 28; + case 28: + if (i.wrap && i.flags) { + for (; d < 32;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (l !== (4294967295 & i.total)) { + t.msg = "incorrect length check", i.mode = ze; + break; + } + l = 0, d = 0; + } + i.mode = 29; + case 29: + E = me; + break t; + case ze: + E = ve; + break t; + case 31: + return Ee; + default: + return ye; + } + return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, (i.wsize || f !== t.avail_out && i.mode < ze && (i.mode < 27 || e !== we)) && Ze(t, t.output, t.next_out, f - t.avail_out), _ -= t.avail_in, f -= t.avail_out, t.total_in += _, t.total_out += f, i.total += f, i.wrap && f && (t.adler = i.check = i.flags ? M(i.check, r, f, t.next_out - f) : Z(i.check, r, f, t.next_out - f)), t.data_type = i.bits + (i.last ? 64 : 0) + (i.mode === Ue ? 128 : 0) + (20 === i.mode || 15 === i.mode ? 256 : 0), (0 === _ && 0 === f || e === we) && E === be && (E = Ae), E; + }, + He = t => { + if (!t || !t.state) return ye; + let e = t.state; + return e.window && (e.window = null), t.state = null, be; + }, + We = (t, e) => { + if (!t || !t.state) return ye; + const i = t.state; + return 0 == (2 & i.wrap) ? ye : (i.head = e, e.done = !1, be); + }, + Ke = (t, e) => { + const i = e.length; + let n, r, s; + return t && t.state ? (n = t.state, 0 !== n.wrap && 11 !== n.mode ? ye : 11 === n.mode && (r = 1, r = Z(r, e, i, 0), r !== n.check) ? ve : (s = Ze(t, e, i, i), s ? (n.mode = 31, Ee) : (n.havedict = 1, be))) : ye; + }, + $e = function $e() { + this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; + }; const Ye = Object.prototype.toString, - { - Z_NO_FLUSH: je, - Z_FINISH: Ge, - Z_OK: Xe, - Z_STREAM_END: Ve, - Z_NEED_DICT: qe, - Z_STREAM_ERROR: Je, - Z_DATA_ERROR: Qe, - Z_MEM_ERROR: ti - } = H; - + { + Z_NO_FLUSH: je, + Z_FINISH: Ge, + Z_OK: Xe, + Z_STREAM_END: Ve, + Z_NEED_DICT: qe, + Z_STREAM_ERROR: Je, + Z_DATA_ERROR: Qe, + Z_MEM_ERROR: ti + } = H; function ei(t) { this.options = Ht({ chunkSize: 65536, @@ -3995,23 +3348,19 @@ if (i !== Xe) throw new Error(P[i]); if (this.header = new $e(), We(this.strm, this.header), e.dictionary && ("string" == typeof e.dictionary ? e.dictionary = Yt(e.dictionary) : "[object ArrayBuffer]" === Ye.call(e.dictionary) && (e.dictionary = new Uint8Array(e.dictionary)), e.raw && (i = Ke(this.strm, e.dictionary), i !== Xe))) throw new Error(P[i]); } - function ii(t, e) { const i = new ei(e); if (i.push(t), i.err) throw i.msg || P[i.err]; return i.result; } - ei.prototype.push = function (t, e) { const i = this.strm, - n = this.options.chunkSize, - r = this.options.dictionary; + n = this.options.chunkSize, + r = this.options.dictionary; let s, a, o; if (this.ended) return !1; - for (a = e === ~~e ? e : !0 === e ? Ge : je, "[object ArrayBuffer]" === Ye.call(t) ? i.input = new Uint8Array(t) : i.input = t, i.next_in = 0, i.avail_in = i.input.length;;) { for (0 === i.avail_out && (i.output = new Uint8Array(n), i.next_out = 0, i.avail_out = n), s = Pe(i, a), s === qe && r && (s = Ke(i, r), s === Xe ? s = Pe(i, a) : s === Qe && (s = qe)); i.avail_in > 0 && s === Ve && i.state.wrap > 0 && 0 !== t[i.next_in];) Fe(i), s = Pe(i, a); - switch (s) { case Je: case Qe: @@ -4019,20 +3368,17 @@ case ti: return this.onEnd(s), this.ended = !0, !1; } - if (o = i.avail_out, i.next_out && (0 === i.avail_out || s === Ve)) if ("string" === this.options.to) { let t = Gt(i.output, i.next_out), - e = i.next_out - t, - r = jt(i.output, t); + e = i.next_out - t, + r = jt(i.output, t); i.next_out = e, i.avail_out = n - e, e && i.output.set(i.output.subarray(t, t + e), 0), this.onData(r); } else this.onData(i.output.length === i.next_out ? i.output : i.output.subarray(0, i.next_out)); - if (s !== Xe || 0 !== o) { if (s === Ve) return s = He(this.strm), this.onEnd(s), this.ended = !0, !0; if (0 === i.avail_in) break; } } - return !0; }, ei.prototype.onData = function (t) { this.chunks.push(t); @@ -4049,43 +3395,35 @@ constants: H }; const { - Deflate: ri, - deflate: si, - deflateRaw: ai, - gzip: oi - } = he, - { - Inflate: hi, - inflate: li, - inflateRaw: di, - ungzip: _i - } = ni; + Deflate: ri, + deflate: si, + deflateRaw: ai, + gzip: oi + } = he, + { + Inflate: hi, + inflate: li, + inflateRaw: di, + ungzip: _i + } = ni; var fi = si, - ci = hi, - ui = li; + ci = hi, + ui = li; const wi = [137, 80, 78, 71, 13, 10, 26, 10], - pi = []; - + pi = []; for (let t = 0; t < 256; t++) { let e = t; - for (let t = 0; t < 8; t++) 1 & e ? e = 3988292384 ^ e >>> 1 : e >>>= 1; - pi[t] = e; } - const gi = 4294967295; - function bi(t, e) { return (function (t, e, i) { let n = 4294967295; - for (let t = 0; t < i; t++) n = pi[255 & (n ^ e[t])] ^ n >>> 8; - return n; }(0, t, e) ^ gi) >>> 0; } - var mi, ki, yi, vi; !function (t) { t[t.UNKNOWN = -1] = "UNKNOWN", t[t.GREYSCALE = 0] = "GREYSCALE", t[t.TRUECOLOUR = 2] = "TRUECOLOUR", t[t.INDEXED_COLOUR = 3] = "INDEXED_COLOUR", t[t.GREYSCALE_ALPHA = 4] = "GREYSCALE_ALPHA", t[t.TRUECOLOUR_ALPHA = 6] = "TRUECOLOUR_ALPHA"; @@ -4097,9 +3435,8 @@ t[t.UNKNOWN = -1] = "UNKNOWN", t[t.NO_INTERLACE = 0] = "NO_INTERLACE", t[t.ADAM7 = 1] = "ADAM7"; }(vi || (vi = {})); const Ei = new Uint8Array(0), - Ai = new Uint16Array([255]), - xi = 255 === new Uint8Array(Ai.buffer)[0]; - + Ai = new Uint16Array([255]), + xi = 255 === new Uint8Array(Ai.buffer)[0]; class Ui extends r { constructor(t) { let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; @@ -4116,69 +3453,53 @@ text: {} }, this._end = !1, this._hasPalette = !1, this._palette = [], this._compressionMethod = ki.UNKNOWN, this._filterMethod = yi.UNKNOWN, this._interlaceMethod = vi.UNKNOWN, this._colorType = -1, this.setBigEndian(); } - decode() { for (this.decodeSignature(); !this._end;) this.decodeChunk(); - return this.decodeImage(), this._png; } - decodeSignature() { for (let t = 0; t < wi.length; t++) if (this.readUint8() !== wi[t]) throw new Error("wrong PNG signature. Byte at ".concat(t, " should be ").concat(wi[t], ".")); } - decodeChunk() { const t = this.readUint32(), - e = this.readChars(4), - i = this.offset; - + e = this.readChars(4), + i = this.offset; switch (e) { case "IHDR": this.decodeIHDR(); break; - case "PLTE": this.decodePLTE(t); break; - case "IDAT": this.decodeIDAT(t); break; - case "IEND": this._end = !0; break; - case "tRNS": this.decodetRNS(t); break; - case "iCCP": this.decodeiCCP(t); break; - case "tEXt": this.decodetEXt(t); break; - case "pHYs": this.decodepHYs(); break; - default: this.skip(t); } - if (this.offset - i !== t) throw new Error("Length mismatch while decoding chunk ".concat(e)); - if (this._checkCrc) { const i = this.readUint32(), - n = t + 4, - r = bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - n - 4, n), n); + n = t + 4, + r = bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - n - 4, n), n); if (r !== i) throw new Error("CRC mismatch for chunk ".concat(e, ". Expected ").concat(i, ", found ").concat(r)); } else this.skip(4); } - decodeIHDR() { const t = this._png; t.width = this.readUint32(), t.height = this.readUint32(), t.depth = function (t) { @@ -4187,71 +3508,54 @@ }(this.readUint8()); const e = this.readUint8(); let i; - switch (this._colorType = e, e) { case mi.GREYSCALE: i = 1; break; - case mi.TRUECOLOUR: i = 3; break; - case mi.INDEXED_COLOUR: i = 1; break; - case mi.GREYSCALE_ALPHA: i = 2; break; - case mi.TRUECOLOUR_ALPHA: i = 4; break; - default: throw new Error("Unknown color type: ".concat(e)); } - if (this._png.channels = i, this._compressionMethod = this.readUint8(), this._compressionMethod !== ki.DEFLATE) throw new Error("Unsupported compression method: ".concat(this._compressionMethod)); this._filterMethod = this.readUint8(), this._interlaceMethod = this.readUint8(); } - decodePLTE(t) { if (t % 3 != 0) throw new RangeError("PLTE field length must be a multiple of 3. Got ".concat(t)); const e = t / 3; this._hasPalette = !0; const i = []; this._palette = i; - for (let t = 0; t < e; t++) i.push([this.readUint8(), this.readUint8(), this.readUint8()]); } - decodeIDAT(t) { this._inflator.push(new Uint8Array(this.buffer, this.offset + this.byteOffset, t)), this.skip(t); } - decodetRNS(t) { if (3 === this._colorType) { if (t > this._palette.length) throw new Error("tRNS chunk contains more alpha values than there are palette colors (".concat(t, " vs ").concat(this._palette.length, ")")); let e = 0; - for (; e < t; e++) { const t = this.readByte(); - this._palette[e].push(t); } - for (; e < this._palette.length; e++) this._palette[e].push(255); } } - decodeiCCP(t) { let e, - i = ""; - + i = ""; for (; "\0" !== (e = this.readChar());) i += e; - const n = this.readUint8(); if (n !== ki.DEFLATE) throw new Error("Unsupported iCCP compression method: ".concat(n)); const r = this.readBytes(t - i.length - 2); @@ -4260,27 +3564,22 @@ profile: ui(r) }; } - decodetEXt(t) { let e, - i = ""; - + i = ""; for (; "\0" !== (e = this.readChar());) i += e; - this._png.text[i] = this.readChars(t - i.length - 1); } - decodepHYs() { const t = this.readUint32(), - e = this.readUint32(), - i = this.readByte(); + e = this.readUint32(), + i = this.readByte(); this._png.resolution = { x: t, y: e, unit: i }; } - decodeImage() { if (this._inflator.err) throw new Error("Error while decompressing the data: ".concat(this._inflator.err)); const t = this._inflator.result; @@ -4288,267 +3587,212 @@ if (this._interlaceMethod !== vi.NO_INTERLACE) throw new Error("Interlace method ".concat(this._interlaceMethod, " not supported")); this.decodeInterlaceNull(t); } - decodeInterlaceNull(t) { const e = this._png.height, - i = this._png.channels * this._png.depth / 8, - n = this._png.width * i, - r = new Uint8Array(this._png.height * n); + i = this._png.channels * this._png.depth / 8, + n = this._png.width * i, + r = new Uint8Array(this._png.height * n); let s, - a, - o = Ei, - h = 0; - + a, + o = Ei, + h = 0; for (let l = 0; l < e; l++) { switch (s = t.subarray(h + 1, h + 1 + n), a = r.subarray(l * n, (l + 1) * n), t[h]) { case 0: zi(s, a, n); break; - case 1: Ri(s, a, n, i); break; - case 2: Ni(s, a, o, n); break; - case 3: Ti(s, a, o, n, i); break; - case 4: Oi(s, a, o, n, i); break; - default: throw new Error("Unsupported filter: ".concat(t[h])); } - o = a, h += n + 1; } - if (this._hasPalette && (this._png.palette = this._palette), 16 === this._png.depth) { const t = new Uint16Array(r.buffer); if (xi) for (let e = 0; e < t.length; e++) t[e] = (255 & (l = t[e])) << 8 | l >> 8 & 255; this._png.data = t; } else this._png.data = r; - var l; } - } - function zi(t, e, i) { for (let n = 0; n < i; n++) e[n] = t[n]; } - function Ri(t, e, i, n) { let r = 0; - for (; r < n; r++) e[r] = t[r]; - for (; r < i; r++) e[r] = t[r] + e[r - n] & 255; } - function Ni(t, e, i, n) { let r = 0; if (0 === i.length) for (; r < n; r++) e[r] = t[r];else for (; r < n; r++) e[r] = t[r] + i[r] & 255; } - function Ti(t, e, i, n, r) { let s = 0; - if (0 === i.length) { for (; s < r; s++) e[s] = t[s]; - for (; s < n; s++) e[s] = t[s] + (e[s - r] >> 1) & 255; } else { for (; s < r; s++) e[s] = t[s] + (i[s] >> 1) & 255; - for (; s < n; s++) e[s] = t[s] + (e[s - r] + i[s] >> 1) & 255; } } - function Oi(t, e, i, n, r) { let s = 0; - if (0 === i.length) { for (; s < r; s++) e[s] = t[s]; - for (; s < n; s++) e[s] = t[s] + e[s - r] & 255; } else { for (; s < r; s++) e[s] = t[s] + i[s] & 255; - for (; s < n; s++) e[s] = t[s] + Li(e[s - r], i[s], i[s - r]) & 255; } } - function Li(t, e, i) { const n = t + e - i, - r = Math.abs(n - t), - s = Math.abs(n - e), - a = Math.abs(n - i); + r = Math.abs(n - t), + s = Math.abs(n - e), + a = Math.abs(n - i); return r <= s && r <= a ? t : s <= a ? e : i; } - const Bi = { level: 3 }; - class Ci extends r { constructor(t) { let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; super(), this._colorType = mi.UNKNOWN, this._zlibOptions = _objectSpread2(_objectSpread2({}, Bi), e.zlib), this._png = this._checkData(t), this.setBigEndian(); } - encode() { return this.encodeSignature(), this.encodeIHDR(), this.encodeData(), this.encodeIEND(), this.toArray(); } - encodeSignature() { this.writeBytes(wi); } - encodeIHDR() { this.writeUint32(13), this.writeChars("IHDR"), this.writeUint32(this._png.width), this.writeUint32(this._png.height), this.writeByte(this._png.depth), this.writeByte(this._colorType), this.writeByte(ki.DEFLATE), this.writeByte(yi.ADAPTIVE), this.writeByte(vi.NO_INTERLACE), this.writeCrc(17); } - encodeIEND() { this.writeUint32(0), this.writeChars("IEND"), this.writeCrc(4); } - encodeIDAT(t) { this.writeUint32(t.length), this.writeChars("IDAT"), this.writeBytes(t), this.writeCrc(t.length + 4); } - encodeData() { const { - width: t, - height: e, - channels: i, - depth: n, - data: s - } = this._png, - a = i * t, - o = new r().setBigEndian(); + width: t, + height: e, + channels: i, + depth: n, + data: s + } = this._png, + a = i * t, + o = new r().setBigEndian(); let h = 0; - for (let t = 0; t < e; t++) if (o.writeByte(0), 8 === n) h = Ii(s, o, a, h);else { if (16 !== n) throw new Error("unreachable"); h = Si(s, o, a, h); } - const l = o.toArray(), - d = fi(l, this._zlibOptions); + d = fi(l, this._zlibOptions); this.encodeIDAT(d); } - _checkData(t) { const { - colorType: e, - channels: i, - depth: n - } = function (t) { - const { - channels: e = 4, - depth: i = 8 - } = t; - if (4 !== e && 3 !== e && 2 !== e && 1 !== e) throw new RangeError("unsupported number of channels: ".concat(e)); - if (8 !== i && 16 !== i) throw new RangeError("unsupported bit depth: ".concat(i)); - const n = { - channels: e, - depth: i, - colorType: mi.UNKNOWN + colorType: e, + channels: i, + depth: n + } = function (t) { + const { + channels: e = 4, + depth: i = 8 + } = t; + if (4 !== e && 3 !== e && 2 !== e && 1 !== e) throw new RangeError("unsupported number of channels: ".concat(e)); + if (8 !== i && 16 !== i) throw new RangeError("unsupported bit depth: ".concat(i)); + const n = { + channels: e, + depth: i, + colorType: mi.UNKNOWN + }; + switch (e) { + case 4: + n.colorType = mi.TRUECOLOUR_ALPHA; + break; + case 3: + n.colorType = mi.TRUECOLOUR; + break; + case 1: + n.colorType = mi.GREYSCALE; + break; + case 2: + n.colorType = mi.GREYSCALE_ALPHA; + break; + default: + throw new Error("unsupported number of channels"); + } + return n; + }(t), + r = { + width: Di(t.width, "width"), + height: Di(t.height, "height"), + channels: i, + data: t.data, + depth: n, + text: {} }; - - switch (e) { - case 4: - n.colorType = mi.TRUECOLOUR_ALPHA; - break; - - case 3: - n.colorType = mi.TRUECOLOUR; - break; - - case 1: - n.colorType = mi.GREYSCALE; - break; - - case 2: - n.colorType = mi.GREYSCALE_ALPHA; - break; - - default: - throw new Error("unsupported number of channels"); - } - - return n; - }(t), - r = { - width: Di(t.width, "width"), - height: Di(t.height, "height"), - channels: i, - data: t.data, - depth: n, - text: {} - }; - this._colorType = e; const s = r.width * r.height * i; if (r.data.length !== s) throw new RangeError("wrong data size. Found ".concat(r.data.length, ", expected ").concat(s)); return r; } - writeCrc(t) { this.writeUint32(bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - t, t), t)); } - } - function Di(t, e) { if (Number.isInteger(t) && t > 0) return t; throw new TypeError("".concat(e, " must be a positive integer")); } - function Ii(t, e, i, n) { for (let r = 0; r < i; r++) e.writeByte(t[n++]); - return n; } - function Si(t, e, i, n) { for (let r = 0; r < i; r++) e.writeUint16(t[n++]); - return n; } - var Zi; !function (t) { t[t.UNKNOWN = 0] = "UNKNOWN", t[t.METRE = 1] = "METRE"; }(Zi || (Zi = {})); - const Fi = (t, e, i) => new Ci({ - width: t, - height: e, - data: i - }, undefined).encode(), - Mi = t => function (t, e) { - return new Ui(t, void 0).decode(); - }(t); + width: t, + height: e, + data: i + }, undefined).encode(), + Mi = t => function (t, e) { + return new Ui(t, void 0).decode(); + }(t); })(); - var r = n.P, - s = n.m; + s = n.m; function isTypeObject(object) { return object && object.hasOwnProperty('type') && object.hasOwnProperty('data'); } - function stringify(o, gap, indentation) { if (isTypeObject(o)) { let s = stringify(o.data, gap, indentation); - if (s.includes('\n')) { return ' #!' + o.type + s; } else { @@ -4556,17 +3800,13 @@ } } else if (o && 'object' === typeof o) { let isArray = Array.isArray(o); - if (Object.keys(o).length == 0) { if (isArray) return '[]';else return '{}'; } - let s = '\n'; - for (let k in o) { if (Object.hasOwnProperty.call(o, k)) { s += gap.repeat(indentation + 1); - if (isArray) { s += '- ' + stringify(o[k], gap, indentation + 1); } else { @@ -4577,11 +3817,9 @@ s += k + ': ' + stringify(o[k], gap, indentation + 1); } } - s += '\n'; } } - return s; } else if ('string' === typeof o) { return JSON.stringify(o); @@ -4593,118 +3831,92 @@ throw new Error('Non-implemented parsing for ' + o); } } - function preStringify(object) { let space = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4; var gap = ''; - if (typeof space == 'number') { gap = ' '.repeat(Math.min(10, space)); } else if (typeof space == 'string') { gap = space.slice(0, 10); } - return stringify(object, gap, -1); } - class LineGenerator { constructor(lines, indentString, startingLine) { this.startingLine = startingLine || 0; this.lineIndex = -1; let filteredLines = []; - for (let i = 0; i < lines.length; i++) { let trimmedLine = lines[i].trim(); - if (trimmedLine !== '') { filteredLines.push([lines[i], i]); } } - this.lines = filteredLines; this.indentString = indentString || this.findIndentString(); } - getLineNumber() { return this.startingLine + this.lineIndex; } - nextGroup() { let lines = []; let baseIndent = this.indentLevel(this.lineIndex + 1); - while (!this.finished() && this.indentLevel(this.lineIndex + 1) >= baseIndent) { lines.push(this.next()); } - return new LineGenerator(lines, this.indentString, this.getLineNumber() - lines.length); } - next() { if (this.finished()) throw new Error('Trying to next finished generator'); this.lineIndex++; return this.getLine(); } - peek() { return this.getLine(this.lineIndex + 1); } - finished() { return this.lineIndex == this.lines.length - 1; } - getLine(index) { index = index !== undefined ? index : this.lineIndex; if (index >= this.lines.length) return null; return this.lines[index][0]; } - findIndentString() { for (let [line] of this.lines) { if (!line.trim() || line.replace(/^\s+/, "") == line) continue; return line.match(/^(\s+)/)[1]; } - return ''; } - indentLevel(index) { index = index !== undefined ? index : this.lineIndex; if (index < 0) index = 0; let indentLevel = 0; let line = this.getLine(index); - while (line.startsWith(this.indentString)) { line = line.slice(this.indentString.length); indentLevel++; } - return indentLevel; } - } - function getObject(lineGroup, type) { let object; lineGroup.indentLevel(); - while (!lineGroup.finished()) { let line = lineGroup.next(); let trimmedLine = line.trim(); let keyMatch = trimmedLine.match(/^(.*?):(?: |$)/); let typeMatch = trimmedLine.match(/#!([\w<,>]+)/); let key, value, type; - if (trimmedLine.startsWith('"')) { keyMatch = trimmedLine.match(/^"(.*?)":(?: |$)/); } - if (typeMatch) { type = typeMatch[1]; trimmedLine = trimmedLine.replace(typeMatch[0], ''); } - if (keyMatch) { if (!object) object = {}; key = keyMatch[1]; @@ -4713,43 +3925,35 @@ if (!object) object = []; value = trimmedLine.slice(1).trim(); } - if (value) { value = getValue(value, type); } else { value = getObject(lineGroup.nextGroup(), type); } - if (Array.isArray(object)) { object.push(value); } else { object[key] = value; } } - if (type) { object = { type: type, data: object }; } - return object; } - function getValue(value, type) { value = JSON.parse(value); - if (type) { value = { type: type, data: value }; } - return value; } - function parse(str) { let lines = str.replace(/\t/g, ' ').split('\n'); let lineGenerator = new LineGenerator(lines); @@ -4758,30 +3962,22 @@ function deepCopy(obj) { let newObj; - if (Array.isArray(obj)) { newObj = []; - for (let item of obj) { newObj.push(deepCopy(item)); } - return newObj; } - if (!!obj && typeof obj === "object") { newObj = {}; - for (let [key, value] of Object.entries(obj)) { newObj[key] = deepCopy(value); } - return newObj; } - return obj; } - function isPrimitiveReaderType(reader) { switch (reader) { case 'Boolean': @@ -4797,13 +3993,12 @@ case 'Vector4': case 'Rectangle': case 'Rect': + case 'Point': return true; - default: return false; } } - function isExportReaderType(reader) { switch (reader) { case 'Texture2D': @@ -4811,22 +4006,18 @@ case 'Effect': case 'BmFont': return true; - default: return false; } } - function convertJsonContentsToXnbNode(raw, readers) { let extractedImages = []; let extractedMaps = []; - const { converted } = function recursiveConvert(obj, path) { let index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; const reader = readers[index]; - if (isPrimitiveReaderType(reader)) { return { converted: { @@ -4836,19 +4027,16 @@ traversed: index }; } - if (reader === null) { return { converted: obj, traversed: index }; } - if (reader.startsWith('Nullable')) { let nullableData, trav; let [readerType, blockTraversed = 1] = reader.split(":"); blockTraversed = +blockTraversed; - if (obj === null) { nullableData = null; trav = index + blockTraversed; @@ -4866,7 +4054,6 @@ nullableData = converted; trav = traversed; } - return { converted: { type: readerType, @@ -4877,7 +4064,6 @@ traversed: trav }; } - if (isExportReaderType(reader)) { if (reader === 'Texture2D') { extractedImages.push({ @@ -4893,13 +4079,11 @@ traversed: index }; } - if (reader === 'TBin') { extractedMaps.push({ path: path.join('.') }); } - return { converted: { type: reader, @@ -4908,16 +4092,24 @@ traversed: index }; } - let data; if (Array.isArray(obj)) data = [];else data = {}; let traversed = index; let first = true; let isComplex = !reader.startsWith("Dictionary") && !reader.startsWith("Array") && !reader.startsWith("List"); - + let [readerType, complexBlockTraversed = 1] = reader.split(":"); + if (Object.keys(obj).length === 0) { + return { + converted: { + type: readerType, + data + }, + traversed: index + +complexBlockTraversed + }; + } for (let [key, value] of Object.entries(obj)) { let newIndex; - if (reader.startsWith("Dictionary")) newIndex = index + 2;else if (reader.startsWith("Array") || reader.startsWith("List")) newIndex = index + 1;else newIndex = traversed + 1; + if (readerType.startsWith("Dictionary")) newIndex = index + 2;else if (readerType.startsWith("Array") || readerType.startsWith("List")) newIndex = index + 1;else newIndex = traversed + 1; const { converted, traversed: nexter @@ -4928,72 +4120,56 @@ first = false; } } - return { converted: { - type: reader, + type: readerType, data }, traversed }; }(raw, []); - return { converted, extractedImages, extractedMaps }; } - function convertJsonContentsFromXnbNode(obj) { if (!obj || typeof obj !== "object") return obj; - if (typeof obj === "object" && obj.hasOwnProperty("data")) { let { type, data } = obj; if (isPrimitiveReaderType(type)) return deepCopy(data); - if (isExportReaderType(type)) { data = deepCopy(data); if (type === "Texture2D") data.export = "Texture2D.png";else if (type === "Effect") data.export = "Effect.cso";else if (type === "TBin") data.export = "TBin.tbin";else if (type === "BmFont") data.export = "BmFont.xml"; return data; } - if (type.startsWith("Nullable")) { if (data === null || data.data === null) return null; return convertJsonContentsFromXnbNode(data.data); } - obj = deepCopy(data); } - let newObj; - if (Array.isArray(obj)) { newObj = []; - for (let item of obj) { newObj.push(convertJsonContentsFromXnbNode(item)); } - return newObj; } - if (!!obj && typeof obj === "object") { newObj = {}; - for (let [key, value] of Object.entries(obj)) { newObj[key] = convertJsonContentsFromXnbNode(value); } - return newObj; } - return null; } - function toXnbNodeData(json) { const toYamlJson = {}; const { @@ -5013,13 +4189,11 @@ const rawContent = deepCopy(json.content); const mainReader = TypeReader.simplifyType(readerData[0].type); let readersTypeList = TypeReader.getReaderTypeList(mainReader); - if (readersTypeList[0] === 'SpriteFont') { readersTypeList = ['SpriteFont', 'Texture2D', 'List', 'Rectangle', 'List', 'Rectangle', 'List', 'Char', null, 'List', 'Vector3', 'Nullable', 'Char', null]; rawContent.verticalSpacing = rawContent.verticalLineSpacing; delete rawContent.verticalLineSpacing; } - const { converted, extractedImages, @@ -5030,7 +4204,6 @@ if (extractedMaps.length > 0) toYamlJson.extractedMaps = extractedMaps; return toYamlJson; } - function fromXnbNodeData(json) { const result = {}; const { @@ -5047,86 +4220,66 @@ }; result.readers = deepCopy(readerData); result.content = convertJsonContentsFromXnbNode(json.content); - if (TypeReader.simplifyType(result.readers[0].type) === 'SpriteFont') { result.content.verticalLineSpacing = result.content.verticalSpacing; delete result.content.verticalSpacing; } - return result; } function searchElement(parent, element) { if (!parent || typeof parent != 'object') return; - if (parent.hasOwnProperty(element)) { return { parent, value: parent[element] }; } - for (let child of Object.values(parent)) { if (!!child || typeof child == 'object') { let found = searchElement(child, element); if (found) return found; } } - return null; } - function extractFileName(fullname) { let matcher = fullname.match(/(.*)\.([^\s.]+)$/); if (matcher === null) return [fullname, null]; return [matcher[1], matcher[2]]; } - function getExtension(dataType) { switch (dataType) { case "JSON": return "json"; - case "yaml": return "yaml"; - case "Texture2D": return "png"; - case "Effect": return "cso"; - case 'TBin': return "tbin"; - case 'BmFont': return "xml"; } - return "bin"; } - function getMimeType(dataType) { switch (dataType) { case "JSON": return "application/json"; - case "yaml": return "text/plain"; - case "Texture2D": return "image/png"; - case "Effect": return "application/x-cso"; - case 'BmFont': return "application/xml"; } - return "application/octet-stream"; } - function makeBlob(data, dataType) { if (typeof Blob === "function") return { data: new Blob([data], { @@ -5139,11 +4292,9 @@ extension: getExtension(dataType) }; } - function exportContent(content) { let jsonContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; let found = searchElement(content, "export"); - if (found) { const { value @@ -5152,21 +4303,18 @@ type: dataType, data } = value; - if (dataType === "Texture2D") { data = s(value.width, value.height, new Uint8Array(data)); } - return makeBlob(data, dataType); } - if (jsonContent) { let contentJson = JSON.stringify(content, null, 4); return makeBlob(contentJson, "JSON"); } - return null; } + /** @api * decompressed xnb object to real file blobs. * @param {XnbData} decompressed xnb objects (returned by bufferToXnb() / Xnb.load()) @@ -5174,8 +4322,6 @@ * contentOnly:export content file only, * fileName:exported files's name) (optional) */ - - function exportFiles(xnbObject) { let { yaml: isYaml = false, @@ -5196,10 +4342,8 @@ if (typeof fileName == "string" && fileName !== "") { return "".concat(fileName, ".").concat(getExtension(value.type)); } - return "".concat(value.type, ".").concat(getExtension(value.type)); } - return value; }, 4); let result = resultJSON; @@ -5207,22 +4351,18 @@ blobs.unshift(makeBlob(result, isYaml ? "yaml" : "JSON")); return blobs; } - function resolveCompression(compressionString) { let str = compressionString.toLowerCase(); if (str === "none") return 0; if (str === "lz4") return 0x40; return null; } - async function readBlobasText(blob) { if (typeof Blob === "function" && blob instanceof Blob) return blob.text();else if (typeof Buffer === "function" && blob instanceof Buffer) return blob.toString();else return blob; } - async function readBlobasArrayBuffer(blob) { if (typeof Blob === "function" && blob instanceof Blob) return blob.arrayBuffer();else if (typeof Buffer === "function" && blob instanceof Buffer) return blob.buffer; } - async function readExternFiles(extension, files) { if (extension === "png") { const rawPng = await readBlobasArrayBuffer(files.png); @@ -5235,7 +4375,6 @@ height: png.height }; } - if (extension === "cso") { const data = await readBlobasArrayBuffer(files.cso); return { @@ -5243,7 +4382,6 @@ data }; } - if (extension === "tbin") { const data = await readBlobasArrayBuffer(files.tbin); return { @@ -5251,7 +4389,6 @@ data }; } - if (extension === "xml") { const data = await readBlobasText(files.xml); return { @@ -5260,7 +4397,6 @@ }; } } - async function resolveImports(files) { let configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; const { @@ -5273,13 +4409,10 @@ if (files.json) jsonData = JSON.parse(rawText);else jsonData = fromXnbNodeData(parse(rawText)); let compressBits = resolveCompression(compression); if (compressBits !== null) jsonData.header.compressed = compressBits; - if (!jsonData.hasOwnProperty('content')) { throw new XnbError("".concat(jsonFile.name, " does not have \"content\".")); } - const found = searchElement(jsonData.content, "export"); - if (found) { const { parent, @@ -5288,16 +4421,13 @@ const [, extension] = extractFileName(value); parent.export = await readExternFiles(extension, files); } - return jsonData; } - function getReaderAssembly(extension) { if (extension === "png") return "Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553"; if (extension === "tbin") return "xTile.Pipeline.TideReader, xTile"; if (extension === "xml") return "BmFont.XmlSourceReader, BmFont, Version=2012.1.7.0, Culture=neutral, PublicKeyToken=null"; } - function makeHeader(fileName) { const [, extension] = extractFileName(fileName); const readerType = getReaderAssembly(extension); @@ -5327,32 +4457,28 @@ * @param {File / Buffer} file * @return {XnbData} JSON data with headers */ - async function unpackToXnbData(file) { if (typeof window !== "undefined") { const [, extension] = extractFileName(file.name); - if (extension !== "xnb") { return new Error("Invalid XNB File!"); } - const buffer = await file.arrayBuffer(); return bufferToXnb(buffer); } - return bufferToXnb(file.buffer); } + /** @api * Asynchronously reads the file into binary and then return content file. * XNB -> arrayBuffer -> XnbData -> Content * @param {File / Buffer} file * @return {XnbContent} exported Content Object */ - - function unpackToContent(file) { return unpackToXnbData(file).then(xnbDataToContent); } + /** @api * Asynchronously reads the file into binary and then unpacks the contents and remake to Blobs array. * XNB -> arrayBuffer -> XnbData -> Files @@ -5360,8 +4486,6 @@ * @param {Object} config (yaml:export file as yaml, contentOnly:export content file only, fileName:file name(for node.js)) * @return {Array} exported Files Blobs */ - - function unpackToFiles(file) { let configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; let { @@ -5371,48 +4495,43 @@ } = configs; if (typeof window !== "undefined" && name === null) name = file.name; let [fileName] = extractFileName(name); - const exporter = xnbObject => exportFiles(xnbObject, { yaml, contentOnly, fileName }); - return unpackToXnbData(file).then(exporter); } + /** @api * reads the buffer and then unpacks. * arrayBuffer -> XnbData * @param {ArrayBuffer} buffer * @return {XnbData} the loaded XNB json */ - - function bufferToXnb(buffer) { const xnb = new XnbConverter(); return xnb.load(buffer); } + /** @api * reads the buffer and then unpacks the contents. * arrayBuffer -> XnbData -> Content * @param {ArrayBuffer} buffer * @return {XnbContent} exported Content Object */ - - function bufferToContents(buffer) { const xnb = new XnbConverter(); const xnbData = xnb.load(buffer); return xnbDataToContent(xnbData); } + /** @api * remove header from the loaded XNB Object * XnbData -> Content * @param {XnbData} the loaded XNB object include headers * @return {XnbContent} exported Content Object */ - - function xnbDataToContent(loadedXnb) { const { content @@ -5428,58 +4547,48 @@ * @param {FileList/Array} to pack json data * @return {Object/Object} packed XNB Array Buffer */ - - function fileMapper(files) { let returnMap = {}; let noHeaderMap = {}; - for (let i = 0; i < files.length; i++) { const file = files[i]; let [fileName, extension] = extractFileName(file.name); if (extension === null) continue; - if (returnMap[fileName] === undefined) { returnMap[fileName] = {}; if (extension !== "json" && extension !== "yaml") noHeaderMap[fileName] = file.name; } - const namedFileObj = returnMap[fileName]; if (typeof Blob === "function" && file instanceof Blob) namedFileObj[extension] = file;else namedFileObj[extension] = file.data; if (extension === "json" || extension === "yaml") delete noHeaderMap[fileName]; } - for (let fileName of Object.keys(noHeaderMap)) { returnMap[fileName].json = makeHeader(noHeaderMap[fileName]); } - return returnMap; } + /** @api * reads the json and then unpacks the contents. * @param {json} to pack json data * @return {ArrayBuffer} packed XNB Array Buffer */ - - function packJsonToBinary(json) { const xnb = new XnbConverter(); const buffer = xnb.convert(json); return buffer; } + /** @api * Asynchronously reads the file into binary and then pack xnb files. * @param {FlieList} files * @param {Object} configs(compression:default, none, LZ4, LZX / debug) * @return {Array(Blobs)} */ - - function pack(files) { let configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; const groupedFiles = fileMapper(files); let promises = []; - for (let [fileName, filePack] of Object.entries(groupedFiles)) { promises.push(resolveImports(filePack, configs).then(packJsonToBinary).then(buffer => { if (typeof Blob === "function") return { @@ -5494,7 +4603,6 @@ }; })); } - return __promise_allSettled(promises).then(blobArray => { if (configs.debug === true) return blobArray; return blobArray.filter(_ref => { @@ -5511,22 +4619,36 @@ }); }); } - function setReaders(readers) { return TypeReader.setReaders(readers); } - function addReaders(readers) { return TypeReader.addReaders(readers); } + function setSchemes(schemes) { + return TypeReader.setSchemes(schemes); + } + function addSchemes(schemes) { + return TypeReader.addSchemes(schemes); + } + function setEnum(enumList) { + return TypeReader.setEnum(enumList); + } + function addEnum(enumList) { + return TypeReader.addEnum(enumList); + } exports.XnbContent = XnbContent; exports.XnbData = XnbData; + exports.addEnum = addEnum; exports.addReaders = addReaders; + exports.addSchemes = addSchemes; exports.bufferToContents = bufferToContents; exports.bufferToXnb = bufferToXnb; exports.pack = pack; + exports.setEnum = setEnum; exports.setReaders = setReaders; + exports.setSchemes = setSchemes; exports.unpackToContent = unpackToContent; exports.unpackToFiles = unpackToFiles; exports.unpackToXnbData = unpackToXnbData; diff --git a/dist/core/xnb-core.min.js b/dist/core/xnb-core.min.js index c08cdf0..6f3cf0b 100644 --- a/dist/core/xnb-core.min.js +++ b/dist/core/xnb-core.min.js @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -45,4 +45,4 @@ * ----------------------------------------------------------------------------- */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XNB={})}(this,(function(t){"use strict";const e=void 0!==Promise.allSettled?Promise.allSettled.bind(Promise):function(t){let e=t.map((t=>t.then((t=>({status:"fulfilled",value:t}))).catch((t=>({status:"rejected",reason:t})))));return Promise.all(e)};function i(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function n(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:"";super(t),this.name="XnbError",this.message=t,Error.captureStackTrace(this,s)}}function a(t){let e=[],i=[];for(let n=0;n")}return e.type()}return null}static simplifyType(t){let e=t.split(/`|,/)[0];if(e.endsWith("[]"))return"Array<".concat(simplifyType(e.slice(0,-2)),">");if("Microsoft.Xna.Framework.Content.ReflectiveReader"===e){let e=o.parseSubtypes(t).map(o.simplifyType.bind(o));return"".concat(e)}for(let e of Object.values(o.readers)){let i=o.makeSimplied(t,e);if(null!==i)return i}throw new s('Non-implemented type found, cannot resolve type "'.concat(e,'", "').concat(t,'".'))}static parseSubtypes(t){let e=t.slice(t.search("`")+1);return e[0],e=a(e)[0],a(e)}static getTypeInfo(t){let e=t.match(/[^<]+/)[0],i=t.match(/<(.+)>/);return i=i?i[1].split(",").map((t=>t.trim())):[],{type:e,subtypes:i}}static getReaderTypeList(t){return o.getReader(t).parseTypeList()}static getReader(t){let{type:e,subtypes:i}=o.getTypeInfo(t);if(i=i.map(o.getReader.bind(o)),o.readers.hasOwnProperty("".concat(e,"Reader")))return new(o.readers["".concat(e,"Reader")])(...i);throw new s('Invalid reader type "'.concat(t,'" passed, unable to resolve!'))}static getReaderFromRaw(t){const e=o.simplifyType(t);return o.getReader(e)}}r(o,"readers",{});const h=[192,224,240],l=128,d=63,f=[55296,56320],c=1023;function u(t){return t<128?[t]:t<2048?[h[0]|t>>6,l|t&d]:t<65536?[h[1]|t>>12,l|t>>6&d,l|t&d]:[h[2]|t>>18,l|t>>12&d,l|t>>6&d,l|t&d]}function _(t){return t<65535?[t]:[f[0]|(t-=65536)>>10&c,f[1]|t&c]}function w(t){var e;if("number"==typeof t&&(t=[t]),null===(e=t)||void 0===e||!e.length)throw new Error("Invalid codeset!");const i=t.length;return 1===i?t[0]:2===i?((t[0]^h[0])<<6)+(t[1]^l):3===i?((t[0]^h[1])<<12)+((t[1]^l)<<6)+(t[2]^l):((t[0]^h[2])<<18)+((t[1]^l)<<12)+((t[2]^l)<<6)+(t[3]^l)}function p(t){var e;if("number"==typeof t&&(t=[t]),null===(e=t)||void 0===e||!e.length)throw new Error("Invalid codeset!");return 1===t.length?t[0]:((t[0]&c)<<10)+(t[1]&c)+65536}function b(t){return function(t){const e=[];for(let i of t)e.push(...u(i));return e}(function(t){const e=Array.from({length:t.length},((e,i)=>t.charCodeAt(i))),i=[];let n=0;for(;n1&&void 0!==arguments[1])||arguments[1];this._endianus=e,this._buffer=t.slice(),this._dataView=new DataView(this._buffer),this._offset=0,this._bitOffset=0}seek(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._offset;const i=this._offset;if(this._offset=Math.max(e+Number.parseInt(t),0),this._offset<0||this._offset>this.buffer.length)throw new RangeError("Buffer seek out of bounds! ".concat(this._offset," ").concat(this.buffer.length));return this._offset-i}get bytePosition(){return Number.parseInt(this._offset)}set bytePosition(t){this._offset=t}get bitPosition(){return Number.parseInt(this._bitOffset)}set bitPosition(t){t<0&&(t=16-t),this._bitOffset=t%16;const e=(t-Math.abs(t)%16)/16*2;this.seek(e)}get size(){return this.buffer.byteLength}get buffer(){return this._buffer}copyFrom(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.byteLength;const r=new Uint8Array(t),s=this.buffer.byteLength0&&void 0!==arguments[0]?arguments[0]:-1;const e=[];if(this._offset,-1===t)for(;0!=this.peekByte(1);)e.push(this.readByte());else for(let i=0;i0&&void 0!==arguments[0]?arguments[0]:0;const e=[],i=this._offset;if(0===t)for(;0!=this.peekByte(1);)e.push(this.readByte());else for(let i=0;i0;){const t=this._dataView.getUint16(this._offset,!0),n=Math.min(Math.max(e,0),16-this.bitPosition),r=16-this.bitPosition-n,s=(t&2**n-1<>r;e-=n,this.bitPosition+=n,i|=s<0&&void 0!==arguments[0])||arguments[0];const e=this.readByte(),i=this.readByte();return t||this.seek(-2),e<<8|i}align(){this.bitPosition>0&&(this.bitPosition+=16-this.bitPosition)}}class y{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2048;this._buffer=new ArrayBuffer(t),this._dataView=new DataView(this._buffer),this.bytePosition=0}get buffer(){return this._buffer}reconnectDataView(){this._dataView=new DataView(this._buffer)}trim(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._buffer=this.buffer.slice(0,this.bytePosition),t||this.reconnectDataView()}alloc(t){if(this._buffer.byteLength<=this.bytePosition+t){const e=new ArrayBuffer(this._buffer.byteLength+t),i=new DataView(e);for(let t=0;t>=7)&&(e|=128),this._dataView.setUint8(this.bytePosition,e),this.bytePosition++}while(t)}}const v=256,k=0,x=1,E=2,A=3,U=656;class R{constructor(t){if(this.window_size=1<21)throw new s("Window size out of range!");if(!R.extra_bits.length)for(let t=0,e=0;t<=50;t+=2)R.extra_bits[t]=R.extra_bits[t+1]=e,0!=t&&e<17&&e++;if(!R.position_base.length)for(let t=0,e=0;t<=50;t++)R.position_base[t]=e,e+=1<0;){if(0==this.block_remaining){this.block_type=t.readLZXBits(3);const e=t.readLZXBits(16),i=t.readLZXBits(8);switch(this.block_remaining=e<<8|i,this.block_type){case E:for(let e=0;e<8;e++)this.aligned_len[e]=t.readLZXBits(3);this.aligned_table=this.decodeTable(8,7,this.aligned_len);case x:this.readLengths(t,this.maintree_len,0,256),this.readLengths(t,this.maintree_len,256,this.main_elements),this.maintree_table=this.decodeTable(U,12,this.maintree_len),this.readLengths(t,this.length_len,0,249),this.length_table=this.decodeTable(250,12,this.length_len);break;case A:t.align(),this.R0=t.readInt32(),this.R1=t.readInt32(),this.R2=t.readInt32();break;default:throw new s("Invalid Blocktype Found: ".concat(this.block_type))}}let e=this.block_remaining;for(;(e=this.block_remaining)>0&&n>0;){if(e>n&&(e=n),n-=e,this.block_remaining-=e,this.window_posn&=this.window_size-1,this.window_posn+e>this.window_size)throw new s("Cannot run outside of window frame.");switch(this.block_type){case E:for(;e>0;){let i,n=this.readHuffSymbol(t,this.maintree_table,this.maintree_len,U,12);if(n>3;if(s>2){let e=R.extra_bits[s];if(s=R.position_base[s]-2,e>3){e-=3,s+=t.readLZXBits(e)<<3,s+=this.readHuffSymbol(t,this.aligned_table,this.aligned_len,8,7)}else 3==e?s+=this.readHuffSymbol(t,this.aligned_table,this.aligned_len,8,7):e>0?s+=t.readLZXBits(e):s=1;this.R2=this.R1,this.R1=this.R0,this.R0=s}else 0===s?s=this.R0:1==s?(s=this.R1,this.R1=this.R0,this.R0=s):(s=this.R2,this.R2=this.R0,this.R0=s);let a,o=this.window_posn;if(e-=r,this.window_posn>=s)a=o-s;else{a=o+(this.window_size-s);let t=s-this.window_posn;if(t0;)this.win[o++]=this.win[a++];a=0}}for(this.window_posn+=r;r-- >0;)this.win[o++]=this.win[a++]}break;case x:for(;e>0;){let i,n=this.readHuffSymbol(t,this.maintree_table,this.maintree_len,U,12);if(n>3;if(s>2){if(3!=s){let e=R.extra_bits[s],i=t.readLZXBits(e);s=R.position_base[s]-2+i}else s=1;this.R2=this.R1,this.R1=this.R0,this.R0=s}else 0===s?s=this.R0:1==s?(s=this.R1,this.R1=this.R0,this.R0=s):(s=this.R2,this.R2=this.R0,this.R0=s);let a,o=this.window_posn;if(e-=r,this.window_posn>=s)a=o-s;else{a=o+(this.window_size-s);let t=s-this.window_posn;if(t0;)this.win[o++]=this.win[a++];a=0}}for(this.window_posn+=r;r-- >0;)this.win[o++]=this.win[a++]}break;case A:if(t.bytePosition+e>i)throw new s("Overrun!"+i+" "+t.bytePosition+" "+e);for(let i=0;i>1;for(let h=1;h<=e;h++){for(let e=0;ea)throw new s("Overrun table!");let i=o;for(;i-- >0;)n[t++]=e}o>>=1}if(r==a)return n;for(let t=r;t>1>1;r<<=16,a<<=16,o=32768;for(let l=e+1;l<=16;l++){for(let d=0;d>16;for(let i=0;i>15-i&1&&t++;if(n[t]=d,(r+=o)>a)throw new s("Overrun table during decoding.")}o>>=1}if(r==a)return n;throw new s("Decode table did not reach table mask.")}readHuffSymbol(t,e,i,n,r){let s=t.peekLZXBits(32)>>>0,a=e[t.peekLZXBits(r)];if(a>=n){let t=1<<32-r;do{if(t>>=1,a<<=1,a|=0!=(s&t)?1:0,0==t)return 0}while((a=e[a])>=n)}return t.bitPosition+=i[a],a}set RRR(t){if(this.R0!=t&&this.R1!=t&&this.R2!=t)this.R2=this.R1,this.R1=this.R0,this.R0=t;else if(this.R1==t){let t=this.R1;this.R1=this.R0,this.R0=t}else if(this.R2==t){let t=this.R2;this.R2=this.R0,this.R0=t}}}R.position_base=[],R.extra_bits=[];class B{static hashU32(t){return-1252372727^(t=(t=(t=(t=-949894596^(t=(t|=0)+2127912214+(t<<12)|0)^t>>>19)+374761393+(t<<5)|0)+-744332180^t<<9)+-42973499+(t<<3)|0)^t>>>16|0}static readU64(t,e){var i=0;return i|=t[e++]<<0,i|=t[e++]<<8,i|=t[e++]<<16,i|=t[e++]<<24,i|=t[e++]<<32,i|=t[e++]<<40,i|=t[e++]<<48,i|=t[e++]<<56}static readU32(t,e){var i=0;return i|=t[e++]<<0,i|=t[e++]<<8,i|=t[e++]<<16,i|=t[e++]<<24}static writeU32(t,e,i){t[e++]=i>>0&255,t[e++]=i>>8&255,t[e++]=i>>16&255,t[e++]=i>>24&255}static imul(t,e){var i=65535&t,n=65535&e;return i*n+((t>>>16)*n+i*(e>>>16)<<16)|0}}const O=65536,T=15;!function(t){try{new Uint8Array(t)}catch(n){for(var e=new Array(t),i=0;i=13)for(var u=67;i+4>>0;if(s=r[w=(w>>16^w)>>>0&65535]-1,r[w]=i+1,s<0||i-s>>>16>0||B.readU32(t,s)!==_)i+=u++>>6;else{for(u=67,l=i-a,h=i-s,s+=4,o=i+=4;i=T){for(e[d++]=240+p,c=l-T;c>=255;c-=255)e[d++]=255;e[d++]=c}else e[d++]=(l<<4)+p;for(var b=0;b>8,o>=15){for(c=o-15;c>=255;c-=255)e[d++]=255;e[d++]=c}a=i}}if(0===a)return 0;if((l=f-a)>=T){for(e[d++]=240,c=l-T;c>=255;c-=255)e[d++]=255;e[d++]=c}else e[d++]=l<<4;for(i=a;it.charCodeAt(i))),i=[];let n=0;for(;ne<128?t+1:e<2048?t+2:e<65536?t+3:t+4),0)}class D{read(t){let e=t.read7BitNumber();return t.readString(e)}write(t,e){const i=z(e);t.write7BitNumber(i),t.writeString(e)}}class P{constructor(t){this.readers=t}read(t){let e=t.read7BitNumber()-1;if(null==this.readers[e])throw new s("Invalid reader index ".concat(e));return this.readers[e].read(t,this)}write(t,e){this.readers[0].write(t,e,this)}getIndex(t){for(let e=0,i=this.readers.length;e"export"===t?e.type:e),4)}stringify(){return JSON.stringify({header:this.header,readers:this.readers,content:this.content},null,4)}toString(){return this.stringify()}}class Z{constructor(t,e){this.type=function(t){switch(t){case"json":return"JSON";case"yaml":return"yaml";case"png":return"Texture2D";case"cso":return"Effect";case"tbin":return"TBin";case"xml":return"BmFont"}return"Others"}(e),this.content=t}}const F=64,V=128,j=14;class M{constructor(){this.target="",this.formatVersion=0,this.hidef=!1,this.compressed=!1,this.compressionType=0,this.buffer=null,this.fileSize=0,this.readers=[],this.sharedResources=[]}load(t){if(this.buffer=new m(t),this._validateHeader(),console.info("XNB file validated successfully!"),this.fileSize=this.buffer.readUInt32(),this.buffer.size!=this.fileSize)throw new s("XNB file has been truncated!");if(this.compressed){const t=this.buffer.readUInt32();if(this.compressionType==V){const e=this.fileSize-j,i=class{static decompress(t,e,i){let n,r,a=0;const o=new R(16);let h=new y(i);for(;a65536||r>65536)throw new s("Invalid size read in compression content.");h.write(o.decompress(t,r,n)),a+=n}return console.log("File has been successfully decompressed!"),h.trim(),h.buffer}}.decompress(this.buffer,e,t);this.buffer.copyFrom(i,j,0,t),this.buffer.bytePosition=j}else if(this.compressionType==F){const e=this.buffer.buffer.slice(j),i=new Uint8Array(e),n=new Uint8Array(t);!function(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.length-2*i,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;var s,a,o,h,l,d=void 0!==e.copyWithin&&void 0!==e.fill;for(o=i+n;i>4;if(c>0){if(15===c)for(;c+=t[i],255===t[i++];);for(h=i+c;i=o)break;if(s=15&f,a=t[i++]|t[i++]<<8,15===s)for(;s+=t[i],255===t[i++];);if(s+=4,d&&1===a)e.fill(0|e[r-1],r,r+s),r+=s;else if(d&&a>s&&s>31)e.copyWithin(r,r-a,r-a+s),r+=s;else for(h=(l=r-a)+s;l2&&void 0!==arguments[2]?arguments[2]:{};return t[4*e+0]=i,t[4*e+1]=n,t[4*e+2]=r,t[4*e+3]=s,[i,n,r,s]}function W(t){const{width:e,height:i,channels:n,depth:r}=t;let{data:s}=t;return t.palette?function(t,e,i){const n=new Uint8Array(t),r=8*n.length/e,s=new Uint8Array(4*r);let a=0;for(let t=0;t>o&2**e-1,[s[4*t],s[4*t+1],s[4*t+2],s[4*t+3]]=i[h],a+=e}return s}(s,r,t.palette):(16===r&&(s=function(t){const e=new Uint16Array(t),i=new Uint8Array(e.length);for(let t=0;t>8;return i}(s)),n<4&&(s=function(t,e){const i=t.length/e,n=new Uint8Array(4*i);if(4===e)return t;if(1===e)for(let e=0;e0&&void 0!==arguments[0]?arguments[0]:"utf-8";if("utf-8"!==t)throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t,"') is invalid."))}function i(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"utf-8",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fatal:!1};if("utf-8"!==t)throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t,"') is invalid."));if(e.fatal)throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}Object.defineProperty(e.prototype,"encoding",{value:"utf-8"}),e.prototype.encode=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{stream:!1};if(e.stream)throw new Error("Failed to encode: the 'stream' option is unsupported.");let i=0;const n=t.length;let r=0,s=Math.max(32,n+(n>>1)+7),a=new Uint8Array(s>>3<<3);for(;i=55296&&e<=56319){if(i=55296&&e<=56319)continue}if(r+4>a.length){s+=8,s*=1+i/t.length*2,s=s>>3<<3;const e=new Uint8Array(s);e.set(a),a=e}if(0!=(4294967168&e)){if(0==(4294965248&e))a[r++]=e>>6&31|192;else if(0==(4294901760&e))a[r++]=e>>12&15|224,a[r++]=e>>6&63|128;else{if(0!=(4292870144&e))continue;a[r++]=e>>18&7|240,a[r++]=e>>12&63|128,a[r++]=e>>6&63|128}a[r++]=63&e|128}else a[r++]=e}return a.slice(0,r)},Object.defineProperty(i.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(i.prototype,"fatal",{value:!1}),Object.defineProperty(i.prototype,"ignoreBOM",{value:!1}),i.prototype.decode=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{stream:!1};if(e.stream)throw new Error("Failed to decode: the 'stream' option is unsupported.");const i=new Uint8Array(t);let n=0;const r=i.length,s=[];for(;n65535&&(e-=65536,s.push(e>>>10&1023|55296),e=56320|1023&e),s.push(e)}}return String.fromCharCode.apply(null,s)},t.TextEncoder=e,t.TextDecoder=i}("undefined"!=typeof window?window:"undefined"!=typeof self?self:this)}},K={};function Y(t){var e=K[t];if(void 0!==e)return e.exports;var i=K[t]={exports:{}};return H[t].call(i.exports,i,i.exports,Y),i.exports}Y.d=(t,e)=>{for(var i in e)Y.o(e,i)&&!Y.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},Y.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var G={};(()=>{Y.d(G,{P:()=>Ii,m:()=>Li}),Y(396);const t=new TextDecoder("utf-8"),e=new TextEncoder;class i{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8192,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!1;"number"==typeof t?t=new ArrayBuffer(t):(n=!0,this.lastWrittenByte=t.byteLength);const r=e.offset?e.offset>>>0:0,s=t.byteLength-r;let a=r;(ArrayBuffer.isView(t)||t instanceof i)&&(t.byteLength!==t.buffer.byteLength&&(a=t.byteOffset+r),t=t.buffer),this.lastWrittenByte=n?s:0,this.buffer=t,this.length=s,this.byteLength=s,this.byteOffset=a,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,a,s),this._mark=0,this._marks=[]}available(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.offset+=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(!this.available(t)){const e=2*(this.offset+t),i=new Uint8Array(e);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=e,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;const e=new Uint8Array(t);for(let i=0;i0&&void 0!==arguments[0]?arguments[0]:1,e="";for(let i=0;i0&&void 0!==arguments[0]?arguments[0]:1;return i=this.readBytes(e),t.decode(i);var i}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let e=0;ethis.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function r(t){let e=t.length;for(;--e>=0;)t[e]=0}const s=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),a=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),o=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),l=new Array(576);r(l);const d=new Array(60);r(d);const f=new Array(512);r(f);const c=new Array(256);r(c);const u=new Array(29);r(u);const _=new Array(30);function w(t,e,i,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}let p,b,g;function m(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}r(_);const y=t=>t<256?f[t]:f[256+(t>>>7)],v=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},k=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<{k(t,i[2*e],i[2*e+1])},E=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},A=(t,e,i)=>{const n=new Array(16);let r,s,a=0;for(r=1;r<=15;r++)n[r]=a=a+i[r-1]<<1;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=E(n[e]++,e))}},U=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},R=t=>{t.bi_valid>8?v(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},B=(t,e,i,n)=>{const r=2*e,s=2*i;return t[r]{const n=t.heap[i];let r=i<<1;for(;r<=t.heap_len&&(r{let n,r,o,h,l=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*l]<<8|t.pending_buf[t.d_buf+2*l+1],r=t.pending_buf[t.l_buf+l],l++,0===n?x(t,r,e):(o=c[r],x(t,o+256+1,e),h=s[o],0!==h&&(r-=u[o],k(t,r,h)),n--,o=y(n),x(t,o,i),h=a[o],0!==h&&(n-=_[o],k(t,n,h)))}while(l{const i=e.dyn_tree,n=e.stat_desc.static_tree,r=e.stat_desc.has_stree,s=e.stat_desc.elems;let a,o,h,l=-1;for(t.heap_len=0,t.heap_max=573,a=0;a>1;a>=1;a--)O(t,i,a);h=s;do{a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],O(t,i,1),o=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=o,i[2*h]=i[2*a]+i[2*o],t.depth[h]=(t.depth[a]>=t.depth[o]?t.depth[a]:t.depth[o])+1,i[2*a+1]=i[2*o+1]=h,t.heap[1]=h++,O(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,n=e.max_code,r=e.stat_desc.static_tree,s=e.stat_desc.has_stree,a=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,h=e.stat_desc.max_length;let l,d,f,c,u,_,w=0;for(c=0;c<=15;c++)t.bl_count[c]=0;for(i[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)d=t.heap[l],c=i[2*i[2*d+1]+1]+1,c>h&&(c=h,w++),i[2*d+1]=c,d>n||(t.bl_count[c]++,u=0,d>=o&&(u=a[d-o]),_=i[2*d],t.opt_len+=_*(c+u),s&&(t.static_len+=_*(r[2*d+1]+u)));if(0!==w){do{for(c=h-1;0===t.bl_count[c];)c--;t.bl_count[c]--,t.bl_count[c+1]+=2,t.bl_count[h]--,w-=2}while(w>0);for(c=h;0!==c;c--)for(d=t.bl_count[c];0!==d;)f=t.heap[--l],f>n||(i[2*f+1]!==c&&(t.opt_len+=(c-i[2*f+1])*i[2*f],i[2*f+1]=c),d--)}})(t,e),A(i,l,t.bl_count)},I=(t,e,i)=>{let n,r,s=-1,a=e[1],o=0,h=7,l=4;for(0===a&&(h=138,l=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)r=a,a=e[2*(n+1)+1],++o{let n,r,s=-1,a=e[1],o=0,h=7,l=4;for(0===a&&(h=138,l=3),n=0;n<=i;n++)if(r=a,a=e[2*(n+1)+1],!(++o{k(t,0+(n?1:0),3),((t,e,i,n)=>{R(t),v(t,i),v(t,~i),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i})(t,e,i)};var D={_tr_init:t=>{S||((()=>{let t,e,i,n,r;const h=new Array(16);for(i=0,n=0;n<28;n++)for(u[n]=i,t=0;t<1<>=7;n<30;n++)for(_[n]=r<<7,t=0;t<1<{let r,s,a=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),L(t,t.l_desc),L(t,t.d_desc),a=(t=>{let e;for(I(t,t.dyn_ltree,t.l_desc.max_code),I(t,t.dyn_dtree,t.d_desc.max_code),L(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*h[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),r=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==e?z(t,e,i,n):4===t.strategy||s===r?(k(t,2+(n?1:0),3),T(t,l,d)):(k(t,4+(n?1:0),3),((t,e,i,n)=>{let r;for(k(t,e-257,5),k(t,i-1,5),k(t,n-4,4),r=0;r(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(c[i]+256+1)]++,t.dyn_dtree[2*y(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{k(t,2,3),x(t,256,l),(t=>{16===t.bi_valid?(v(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},P=(t,e,i,n)=>{let r=65535&t|0,s=t>>>16&65535|0,a=0;for(;0!==i;){a=i>2e3?2e3:i,i-=a;do{r=r+e[n++]|0,s=s+r|0}while(--a);r%=65521,s%=65521}return r|s<<16|0};const C=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var Z=(t,e,i,n)=>{const r=C,s=n+i;t^=-1;for(let i=n;i>>8^r[255&(t^e[i])];return-1^t},F={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},V={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:j,_tr_stored_block:M,_tr_flush_block:X,_tr_tally:W,_tr_align:H}=D,{Z_NO_FLUSH:K,Z_PARTIAL_FLUSH:J,Z_FULL_FLUSH:$,Z_FINISH:q,Z_BLOCK:Q,Z_OK:tt,Z_STREAM_END:et,Z_STREAM_ERROR:it,Z_DATA_ERROR:nt,Z_BUF_ERROR:rt,Z_DEFAULT_COMPRESSION:st,Z_FILTERED:at,Z_HUFFMAN_ONLY:ot,Z_RLE:ht,Z_FIXED:lt,Z_DEFAULT_STRATEGY:dt,Z_UNKNOWN:ft,Z_DEFLATED:ct}=V,ut=258,_t=262,wt=103,pt=113,bt=666,gt=(t,e)=>(t.msg=F[e],e),mt=t=>(t<<1)-(t>4?9:0),yt=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let vt=(t,e,i)=>(e<{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},xt=(t,e)=>{X(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,kt(t.strm)},Et=(t,e)=>{t.pending_buf[t.pending++]=e},At=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Ut=(t,e,i,n)=>{let r=t.avail_in;return r>n&&(r=n),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),i),1===t.state.wrap?t.adler=P(t.adler,e,r,i):2===t.state.wrap&&(t.adler=Z(t.adler,e,r,i)),t.next_in+=r,t.total_in+=r,r)},Rt=(t,e)=>{let i,n,r=t.max_chain_length,s=t.strstart,a=t.prev_length,o=t.nice_match;const h=t.strstart>t.w_size-_t?t.strstart-(t.w_size-_t):0,l=t.window,d=t.w_mask,f=t.prev,c=t.strstart+ut;let u=l[s+a-1],_=l[s+a];t.prev_length>=t.good_match&&(r>>=2),o>t.lookahead&&(o=t.lookahead);do{if(i=e,l[i+a]===_&&l[i+a-1]===u&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&sa){if(t.match_start=e,a=n,n>=o)break;u=l[s+a-1],_=l[s+a]}}}while((e=f[e&d])>h&&0!=--r);return a<=t.lookahead?a:t.lookahead},Bt=t=>{const e=t.w_size;let i,n,r,s,a;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-_t)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,i=n;do{r=t.head[--i],t.head[i]=r>=e?r-e:0}while(--n);n=e,i=n;do{r=t.prev[--i],t.prev[i]=r>=e?r-e:0}while(--n);s+=e}if(0===t.strm.avail_in)break;if(n=Ut(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=n,t.lookahead+t.insert>=3)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=vt(t,t.ins_h,t.window[a+1]);t.insert&&(t.ins_h=vt(t,t.ins_h,t.window[a+3-1]),t.prev[a&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=a,a++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<_t&&0!==t.strm.avail_in)},Ot=(t,e)=>{let i,n;for(;;){if(t.lookahead<_t){if(Bt(t),t.lookahead<_t&&e===K)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=vt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-_t&&(t.match_length=Rt(t,i)),t.match_length>=3)if(n=W(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=vt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=vt(t,t.ins_h,t.window[t.strstart+1]);else n=W(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2},Tt=(t,e)=>{let i,n,r;for(;;){if(t.lookahead<_t){if(Bt(t),t.lookahead<_t&&e===K)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=vt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,n=W(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=vt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(xt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=W(t,0,t.window[t.strstart-1]),n&&xt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=W(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2};function Lt(t,e,i,n,r){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=n,this.func=r}const It=[new Lt(0,0,0,0,((t,e)=>{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Bt(t),0===t.lookahead&&e===K)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,xt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-_t&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===q?(xt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(xt(t,!1),t.strm.avail_out),1)})),new Lt(4,4,8,4,Ot),new Lt(4,5,16,8,Ot),new Lt(4,6,32,32,Ot),new Lt(4,4,16,16,Tt),new Lt(8,16,32,32,Tt),new Lt(8,16,128,128,Tt),new Lt(8,32,128,256,Tt),new Lt(32,128,258,1024,Tt),new Lt(32,258,258,4096,Tt)];function Nt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ct,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),yt(this.dyn_ltree),yt(this.dyn_dtree),yt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),yt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),yt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const St=t=>{const e=(t=>{if(!t||!t.state)return gt(t,it);t.total_in=t.total_out=0,t.data_type=ft;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:pt,t.adler=2===e.wrap?0:1,e.last_flush=K,j(e),tt})(t);var i;return e===tt&&((i=t.state).window_size=2*i.w_size,yt(i.head),i.max_lazy_match=It[i.level].max_lazy,i.good_match=It[i.level].good_length,i.nice_match=It[i.level].nice_length,i.max_chain_length=It[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e};var zt=(t,e,i,n,r,s)=>{if(!t)return it;let a=1;if(e===st&&(e=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),r<1||r>9||i!==ct||n<8||n>15||e<0||e>9||s<0||s>lt)return gt(t,it);8===n&&(n=9);const o=new Nt;return t.state=o,o.strm=t,o.wrap=a,o.gzhead=null,o.w_bits=n,o.w_size=1<{let i,n;if(!t||!t.state||e>Q||e<0)return t?gt(t,it):it;const r=t.state;if(!t.output||!t.input&&0!==t.avail_in||r.status===bt&&e!==q)return gt(t,0===t.avail_out?rt:it);r.strm=t;const s=r.last_flush;if(r.last_flush=e,42===r.status)if(2===r.wrap)t.adler=0,Et(r,31),Et(r,139),Et(r,8),r.gzhead?(Et(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Et(r,255&r.gzhead.time),Et(r,r.gzhead.time>>8&255),Et(r,r.gzhead.time>>16&255),Et(r,r.gzhead.time>>24&255),Et(r,9===r.level?2:r.strategy>=ot||r.level<2?4:0),Et(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Et(r,255&r.gzhead.extra.length),Et(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=Z(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(Et(r,0),Et(r,0),Et(r,0),Et(r,0),Et(r,0),Et(r,9===r.level?2:r.strategy>=ot||r.level<2?4:0),Et(r,3),r.status=pt);else{let e=ct+(r.w_bits-8<<4)<<8,i=-1;i=r.strategy>=ot||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=i<<6,0!==r.strstart&&(e|=32),e+=31-e%31,r.status=pt,At(r,e),0!==r.strstart&&(At(r,t.adler>>>16),At(r,65535&t.adler)),t.adler=1}if(69===r.status)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>i&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),kt(t),i=r.pending,r.pending!==r.pending_buf_size));)Et(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),kt(t),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindexi&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),kt(t),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindexi&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.status=wt)}else r.status=wt;if(r.status===wt&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&kt(t),r.pending+2<=r.pending_buf_size&&(Et(r,255&t.adler),Et(r,t.adler>>8&255),t.adler=0,r.status=pt)):r.status=pt),0!==r.pending){if(kt(t),0===t.avail_out)return r.last_flush=-1,tt}else if(0===t.avail_in&&mt(e)<=mt(s)&&e!==q)return gt(t,rt);if(r.status===bt&&0!==t.avail_in)return gt(t,rt);if(0!==t.avail_in||0!==r.lookahead||e!==K&&r.status!==bt){let i=r.strategy===ot?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(Bt(t),0===t.lookahead)){if(e===K)return 1;break}if(t.match_length=0,i=W(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===ht?((t,e)=>{let i,n,r,s;const a=t.window;for(;;){if(t.lookahead<=ut){if(Bt(t),t.lookahead<=ut&&e===K)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,n=a[r],n===a[++r]&&n===a[++r]&&n===a[++r])){s=t.strstart+ut;do{}while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&rt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=W(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=W(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===q?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2})(r,e):It[r.level].func(r,e);if(3!==i&&4!==i||(r.status=bt),1===i||3===i)return 0===t.avail_out&&(r.last_flush=-1),tt;if(2===i&&(e===J?H(r):e!==Q&&(M(r,0,0,!1),e===$&&(yt(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),kt(t),0===t.avail_out))return r.last_flush=-1,tt}return e!==q?tt:r.wrap<=0?et:(2===r.wrap?(Et(r,255&t.adler),Et(r,t.adler>>8&255),Et(r,t.adler>>16&255),Et(r,t.adler>>24&255),Et(r,255&t.total_in),Et(r,t.total_in>>8&255),Et(r,t.total_in>>16&255),Et(r,t.total_in>>24&255)):(At(r,t.adler>>>16),At(r,65535&t.adler)),kt(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?tt:et)},Pt=t=>{if(!t||!t.state)return it;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==wt&&e!==pt&&e!==bt?gt(t,it):(t.state=null,e===pt?gt(t,nt):tt)};const Ct=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Zt=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Ct(i,e)&&(t[e]=i[e])}}return t},Ft=t=>{let e=0;for(let i=0,n=t.length;i=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;jt[254]=jt[254]=1;var Mt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,i,n,r,s,a=t.length,o=0;for(r=0;r>>6,e[s++]=128|63&i):i<65536?(e[s++]=224|i>>>12,e[s++]=128|i>>>6&63,e[s++]=128|63&i):(e[s++]=240|i>>>18,e[s++]=128|i>>>12&63,e[s++]=128|i>>>6&63,e[s++]=128|63&i);return e},Xt=(t,e)=>{const i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=a-1;else{for(e&=2===a?31:3===a?15:7;a>1&&n1?s[r++]=65533:e<65536?s[r++]=e:(e-=65536,s[r++]=55296|e>>10&1023,s[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Vt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+jt[t[i]]>e?i:e},Ht=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Kt=Object.prototype.toString,{Z_NO_FLUSH:Yt,Z_SYNC_FLUSH:Gt,Z_FULL_FLUSH:Jt,Z_FINISH:$t,Z_OK:qt,Z_STREAM_END:Qt,Z_DEFAULT_COMPRESSION:te,Z_DEFAULT_STRATEGY:ee,Z_DEFLATED:ie}=V;function ne(t){this.options=Zt({level:te,method:ie,chunkSize:16384,windowBits:15,memLevel:8,strategy:ee},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ht,this.strm.avail_out=0;let i=zt(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==qt)throw new Error(F[i]);if(e.header&&((t,e)=>{t&&t.state&&(2!==t.state.wrap||(t.state.gzhead=e))})(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Mt(e.dictionary):"[object ArrayBuffer]"===Kt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=((t,e)=>{let i=e.length;if(!t||!t.state)return it;const n=t.state,r=n.wrap;if(2===r||1===r&&42!==n.status||n.lookahead)return it;if(1===r&&(t.adler=P(t.adler,e,i,0)),n.wrap=0,i>=n.w_size){0===r&&(yt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(i-n.w_size,i),0),e=t,i=n.w_size}const s=t.avail_in,a=t.next_in,o=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,Bt(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=vt(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,Bt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=a,t.input=o,t.avail_in=s,n.wrap=r,tt})(this.strm,t),i!==qt)throw new Error(F[i]);this._dict_set=!0}}function re(t,e){const i=new ne(e);if(i.push(t,!0),i.err)throw i.msg||F[i.err];return i.result}ne.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?$t:Yt,"string"==typeof t?i.input=Mt(t):"[object ArrayBuffer]"===Kt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(s===Gt||s===Jt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Dt(i,s),r===Qt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Pt(this.strm),this.onEnd(r),this.ended=!0,r===qt;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},ne.prototype.onData=function(t){this.chunks.push(t)},ne.prototype.onEnd=function(t){t===qt&&(this.result=Ft(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var se={Deflate:ne,deflate:re,deflateRaw:function(t,e){return(e=e||{}).raw=!0,re(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,re(t,e)},constants:V},ae=function(t,e){let i,n,r,s,a,o,h,l,d,f,c,u,_,w,p,b,g,m,y,v,k,x,E,A;const U=t.state;i=t.next_in,E=t.input,n=i+(t.avail_in-5),r=t.next_out,A=t.output,s=r-(e-t.avail_out),a=r+(t.avail_out-257),o=U.dmax,h=U.wsize,l=U.whave,d=U.wnext,f=U.window,c=U.hold,u=U.bits,_=U.lencode,w=U.distcode,p=(1<>>24,c>>>=m,u-=m,m=g>>>16&255,0===m)A[r++]=65535&g;else{if(!(16&m)){if(0==(64&m)){g=_[(65535&g)+(c&(1<>>=m,u-=m),u<15&&(c+=E[i++]<>>24,c>>>=m,u-=m,m=g>>>16&255,!(16&m)){if(0==(64&m)){g=w[(65535&g)+(c&(1<o){t.msg="invalid distance too far back",U.mode=30;break t}if(c>>>=m,u-=m,m=r-s,v>m){if(m=v-m,m>l&&U.sane){t.msg="invalid distance too far back",U.mode=30;break t}if(k=0,x=f,0===d){if(k+=h-m,m2;)A[r++]=x[k++],A[r++]=x[k++],A[r++]=x[k++],y-=3;y&&(A[r++]=x[k++],y>1&&(A[r++]=x[k++]))}else{k=r-v;do{A[r++]=A[k++],A[r++]=A[k++],A[r++]=A[k++],y-=3}while(y>2);y&&(A[r++]=A[k++],y>1&&(A[r++]=A[k++]))}break}}break}}while(i>3,i-=y,u-=y<<3,c&=(1<{const h=o.bits;let l,d,f,c,u,_,w=0,p=0,b=0,g=0,m=0,y=0,v=0,k=0,x=0,E=0,A=null,U=0;const R=new Uint16Array(16),B=new Uint16Array(16);let O,T,L,I=null,N=0;for(w=0;w<=15;w++)R[w]=0;for(p=0;p=1&&0===R[g];g--);if(m>g&&(m=g),0===g)return r[s++]=20971520,r[s++]=20971520,o.bits=1,0;for(b=1;b0&&(0===t||1!==g))return-1;for(B[1]=0,w=1;w<15;w++)B[w+1]=B[w]+R[w];for(p=0;p852||2===t&&x>592)return 1;for(;;){O=w-v,a[p]<_?(T=0,L=a[p]):a[p]>_?(T=I[N+a[p]],L=A[U+a[p]]):(T=96,L=0),l=1<>v)+d]=O<<24|T<<16|L|0}while(0!==d);for(l=1<>=1;if(0!==l?(E&=l-1,E+=l):E=0,p++,0==--R[w]){if(w===g)break;w=e[i+a[p]]}if(w>m&&(E&c)!==f){for(0===v&&(v=m),u+=b,y=w-v,k=1<852||2===t&&x>592)return 1;f=E&c,r[f]=m<<24|y<<16|u-s|0}}return 0!==E&&(r[u+E]=w-v<<24|64<<16|0),o.bits=m,0};const{Z_FINISH:ce,Z_BLOCK:ue,Z_TREES:_e,Z_OK:we,Z_STREAM_END:pe,Z_NEED_DICT:be,Z_STREAM_ERROR:ge,Z_DATA_ERROR:me,Z_MEM_ERROR:ye,Z_BUF_ERROR:ve,Z_DEFLATED:ke}=V,xe=12,Ee=30,Ae=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Ue(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Re=t=>{if(!t||!t.state)return ge;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,(t=>{if(!t||!t.state)return ge;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,we})(t)};let Be,Oe,Te=!0;const Le=t=>{if(Te){Be=new Int32Array(512),Oe=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(fe(1,t.lens,0,288,Be,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;fe(2,t.lens,0,32,Oe,0,t.work,{bits:5}),Te=!1}t.lencode=Be,t.lenbits=9,t.distcode=Oe,t.distbits=5},Ie=(t,e,i,n)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(e.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(e.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(e.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave{if(!t)return ge;const i=new Ue;t.state=i,i.window=null;const n=((t,e)=>{let i;if(!t||!t.state)return ge;const n=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?ge:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,Re(t))})(t,e);return n!==we&&(t.state=null),n},ze=(t,e)=>{let i,n,r,s,a,o,h,l,d,f,c,u,_,w,p,b,g,m,y,v,k,x,E=0;const A=new Uint8Array(4);let U,R;const B=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return ge;i=t.state,i.mode===xe&&(i.mode=13),a=t.next_out,r=t.output,h=t.avail_out,s=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,f=o,c=h,x=we;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===o)break t;o--,l+=n[s++]<>>8&255,i.check=Z(i.check,A,2,0),l=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",i.mode=Ee;break}if((15&l)!==ke){t.msg="unknown compression method",i.mode=Ee;break}if(l>>>=4,d-=4,k=8+(15&l),0===i.wbits)i.wbits=k;else if(k>i.wbits){t.msg="invalid window size",i.mode=Ee;break}i.dmax=1<>8&1),512&i.flags&&(A[0]=255&l,A[1]=l>>>8&255,i.check=Z(i.check,A,2,0)),l=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,l+=n[s++]<>>8&255,A[2]=l>>>16&255,A[3]=l>>>24&255,i.check=Z(i.check,A,4,0)),l=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,l+=n[s++]<>8),512&i.flags&&(A[0]=255&l,A[1]=l>>>8&255,i.check=Z(i.check,A,2,0)),l=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===o)break t;o--,l+=n[s++]<>>8&255,i.check=Z(i.check,A,2,0)),l=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(u=i.length,u>o&&(u=o),u&&(i.head&&(k=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+u),k)),512&i.flags&&(i.check=Z(i.check,n,u,s)),o-=u,s+=u,i.length-=u),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===o)break t;u=0;do{k=n[s+u++],i.head&&k&&i.length<65536&&(i.head.name+=String.fromCharCode(k))}while(k&&u>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=xe;break;case 10:for(;d<32;){if(0===o)break t;o--,l+=n[s++]<>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===o)break t;o--,l+=n[s++]<>>=1,d-=1,3&l){case 0:i.mode=14;break;case 1:if(Le(i),i.mode=20,e===_e){l>>>=2,d-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=Ee}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,l+=n[s++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=Ee;break}if(i.length=65535&l,l=0,d=0,i.mode=15,e===_e)break t;case 15:i.mode=16;case 16:if(u=i.length,u){if(u>o&&(u=o),u>h&&(u=h),0===u)break t;r.set(n.subarray(s,s+u),a),o-=u,s+=u,h-=u,a+=u,i.length-=u;break}i.mode=xe;break;case 17:for(;d<14;){if(0===o)break t;o--,l+=n[s++]<>>=5,d-=5,i.ndist=1+(31&l),l>>>=5,d-=5,i.ncode=4+(15&l),l>>>=4,d-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=Ee;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,d-=3}for(;i.have<19;)i.lens[B[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,U={bits:i.lenbits},x=fe(0,i.lens,0,19,i.lencode,0,i.work,U),i.lenbits=U.bits,x){t.msg="invalid code lengths set",i.mode=Ee;break}i.have=0,i.mode=19;case 19:for(;i.have>>24,b=E>>>16&255,g=65535&E,!(p<=d);){if(0===o)break t;o--,l+=n[s++]<>>=p,d-=p,i.lens[i.have++]=g;else{if(16===g){for(R=p+2;d>>=p,d-=p,0===i.have){t.msg="invalid bit length repeat",i.mode=Ee;break}k=i.lens[i.have-1],u=3+(3&l),l>>>=2,d-=2}else if(17===g){for(R=p+3;d>>=p,d-=p,k=0,u=3+(7&l),l>>>=3,d-=3}else{for(R=p+7;d>>=p,d-=p,k=0,u=11+(127&l),l>>>=7,d-=7}if(i.have+u>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=Ee;break}for(;u--;)i.lens[i.have++]=k}}if(i.mode===Ee)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=Ee;break}if(i.lenbits=9,U={bits:i.lenbits},x=fe(1,i.lens,0,i.nlen,i.lencode,0,i.work,U),i.lenbits=U.bits,x){t.msg="invalid literal/lengths set",i.mode=Ee;break}if(i.distbits=6,i.distcode=i.distdyn,U={bits:i.distbits},x=fe(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,U),i.distbits=U.bits,x){t.msg="invalid distances set",i.mode=Ee;break}if(i.mode=20,e===_e)break t;case 20:i.mode=21;case 21:if(o>=6&&h>=258){t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,i.hold=l,i.bits=d,ae(t,c),a=t.next_out,r=t.output,h=t.avail_out,s=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,i.mode===xe&&(i.back=-1);break}for(i.back=0;E=i.lencode[l&(1<>>24,b=E>>>16&255,g=65535&E,!(p<=d);){if(0===o)break t;o--,l+=n[s++]<>m)],p=E>>>24,b=E>>>16&255,g=65535&E,!(m+p<=d);){if(0===o)break t;o--,l+=n[s++]<>>=m,d-=m,i.back+=m}if(l>>>=p,d-=p,i.back+=p,i.length=g,0===b){i.mode=26;break}if(32&b){i.back=-1,i.mode=xe;break}if(64&b){t.msg="invalid literal/length code",i.mode=Ee;break}i.extra=15&b,i.mode=22;case 22:if(i.extra){for(R=i.extra;d>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;E=i.distcode[l&(1<>>24,b=E>>>16&255,g=65535&E,!(p<=d);){if(0===o)break t;o--,l+=n[s++]<>m)],p=E>>>24,b=E>>>16&255,g=65535&E,!(m+p<=d);){if(0===o)break t;o--,l+=n[s++]<>>=m,d-=m,i.back+=m}if(l>>>=p,d-=p,i.back+=p,64&b){t.msg="invalid distance code",i.mode=Ee;break}i.offset=g,i.extra=15&b,i.mode=24;case 24:if(i.extra){for(R=i.extra;d>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=Ee;break}i.mode=25;case 25:if(0===h)break t;if(u=c-h,i.offset>u){if(u=i.offset-u,u>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=Ee;break}u>i.wnext?(u-=i.wnext,_=i.wsize-u):_=i.wnext-u,u>i.length&&(u=i.length),w=i.window}else w=r,_=a-i.offset,u=i.length;u>h&&(u=h),h-=u,i.length-=u;do{r[a++]=w[_++]}while(--u);0===i.length&&(i.mode=21);break;case 26:if(0===h)break t;r[a++]=i.length,h--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===o)break t;o--,l|=n[s++]<{if(!t||!t.state)return ge;let e=t.state;return e.window&&(e.window=null),t.state=null,we},Pe=(t,e)=>{const i=e.length;let n,r,s;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?ge:11===n.mode&&(r=1,r=P(r,e,i,0),r!==n.check)?me:(s=Ie(t,e,i,i),s?(n.mode=31,ye):(n.havedict=1,we))):ge},Ce=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Ze=Object.prototype.toString,{Z_NO_FLUSH:Fe,Z_FINISH:Ve,Z_OK:je,Z_STREAM_END:Me,Z_NEED_DICT:Xe,Z_STREAM_ERROR:We,Z_DATA_ERROR:He,Z_MEM_ERROR:Ke}=V;function Ye(t){this.options=Zt({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ht,this.strm.avail_out=0;let i=Se(this.strm,e.windowBits);if(i!==je)throw new Error(F[i]);if(this.header=new Ce,((t,e)=>{if(!t||!t.state)return ge;const i=t.state;0==(2&i.wrap)||(i.head=e,e.done=!1)})(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Mt(e.dictionary):"[object ArrayBuffer]"===Ze.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=Pe(this.strm,e.dictionary),i!==je)))throw new Error(F[i])}function Ge(t,e){const i=new Ye(e);if(i.push(t),i.err)throw i.msg||F[i.err];return i.result}Ye.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(a=e===~~e?e:!0===e?Ve:Fe,"[object ArrayBuffer]"===Ze.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=ze(i,a),s===Xe&&r&&(s=Pe(i,r),s===je?s=ze(i,a):s===He&&(s=Xe));i.avail_in>0&&s===Me&&i.state.wrap>0&&0!==t[i.next_in];)Ne(i),s=ze(i,a);switch(s){case We:case He:case Xe:case Ke:return this.onEnd(s),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||s===Me))if("string"===this.options.to){let t=Wt(i.output,i.next_out),e=i.next_out-t,r=Xt(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==je||0!==o){if(s===Me)return s=De(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Ye.prototype.onData=function(t){this.chunks.push(t)},Ye.prototype.onEnd=function(t){t===je&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ft(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Je={Inflate:Ye,inflate:Ge,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Ge(t,e)},ungzip:Ge,constants:V};const{Deflate:$e,deflate:qe,deflateRaw:Qe,gzip:ti}=se,{Inflate:ei,inflate:ii,inflateRaw:ni,ungzip:ri}=Je;var si=qe,ai=ei,oi=ii;const hi=[137,80,78,71,13,10,26,10],li=[];for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)1&e?e=3988292384^e>>>1:e>>>=1;li[t]=e}function di(t,e){return(4294967295^function(t,e,i){let n=4294967295;for(let t=0;t>>8;return n}(0,t,e))>>>0}var fi,ci,ui,_i;!function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.GREYSCALE=0]="GREYSCALE",t[t.TRUECOLOUR=2]="TRUECOLOUR",t[t.INDEXED_COLOUR=3]="INDEXED_COLOUR",t[t.GREYSCALE_ALPHA=4]="GREYSCALE_ALPHA",t[t.TRUECOLOUR_ALPHA=6]="TRUECOLOUR_ALPHA"}(fi||(fi={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.DEFLATE=0]="DEFLATE"}(ci||(ci={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.ADAPTIVE=0]="ADAPTIVE"}(ui||(ui={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.NO_INTERLACE=0]="NO_INTERLACE",t[t.ADAM7=1]="ADAM7"}(_i||(_i={}));const wi=new Uint8Array(0),pi=new Uint16Array([255]),bi=255===new Uint8Array(pi.buffer)[0];class gi extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t);const{checkCrc:i=!1}=e;this._checkCrc=i,this._inflator=new ai,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._end=!1,this._hasPalette=!1,this._palette=[],this._compressionMethod=ci.UNKNOWN,this._filterMethod=ui.UNKNOWN,this._interlaceMethod=_i.UNKNOWN,this._colorType=-1,this.setBigEndian()}decode(){for(this.decodeSignature();!this._end;)this.decodeChunk();return this.decodeImage(),this._png}decodeSignature(){for(let t=0;tthis._palette.length)throw new Error("tRNS chunk contains more alpha values than there are palette colors (".concat(t," vs ").concat(this._palette.length,")"));let e=0;for(;e>8&255;this._png.data=t}else this._png.data=r;var l}}function mi(t,e,i){for(let n=0;n>1)&255}else{for(;s>1)&255;for(;s>1)&255}}function xi(t,e,i,n,r){let s=0;if(0===i.length){for(;s1&&void 0!==arguments[1]?arguments[1]:{};super(),this._colorType=fi.UNKNOWN,this._zlibOptions=n(n({},Ai),e.zlib),this._png=this._checkData(t),this.setBigEndian()}encode(){return this.encodeSignature(),this.encodeIHDR(),this.encodeData(),this.encodeIEND(),this.toArray()}encodeSignature(){this.writeBytes(hi)}encodeIHDR(){this.writeUint32(13),this.writeChars("IHDR"),this.writeUint32(this._png.width),this.writeUint32(this._png.height),this.writeByte(this._png.depth),this.writeByte(this._colorType),this.writeByte(ci.DEFLATE),this.writeByte(ui.ADAPTIVE),this.writeByte(_i.NO_INTERLACE),this.writeCrc(17)}encodeIEND(){this.writeUint32(0),this.writeChars("IEND"),this.writeCrc(4)}encodeIDAT(t){this.writeUint32(t.length),this.writeChars("IDAT"),this.writeBytes(t),this.writeCrc(t.length+4)}encodeData(){const{width:t,height:e,channels:n,depth:r,data:s}=this._png,a=n*t,o=(new i).setBigEndian();let h=0;for(let t=0;t0)return t;throw new TypeError("".concat(e," must be a positive integer"))}function Bi(t,e,i,n){for(let r=0;rnew Ui({width:t,height:e,data:i},void 0).encode(),Ii=t=>function(t,e){return new gi(t,void 0).decode()}(t)})();var J=G.P,$=G.m;function q(t,e,i){if((n=t)&&n.hasOwnProperty("type")&&n.hasOwnProperty("data")){let n=q(t.data,e,i);return n.includes("\n")?" #!"+t.type+n:n+" #!"+t.type}if(t&&"object"==typeof t){let n=Array.isArray(t);if(0==Object.keys(t).length)return n?"[]":"{}";let r="\n";for(let s in t)Object.hasOwnProperty.call(t,s)&&(r+=e.repeat(i+1),n?r+="- "+q(t[s],e,i+1):s.includes(": ")?(r+=q(s,e,i+1),r+=": "+q(t[s],e,i+1)):r+=s+": "+q(t[s],e,i+1),r+="\n");return r}if("string"==typeof t)return JSON.stringify(t);if(null==t)return"null";if(!!t==t||+t==t)return JSON.stringify(t);throw new Error("Non-implemented parsing for "+t);var n}function Q(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;var i="";return"number"==typeof e?i=" ".repeat(Math.min(10,e)):"string"==typeof e&&(i=e.slice(0,10)),q(t,i,-1)}class tt{constructor(t,e,i){this.startingLine=i||0,this.lineIndex=-1;let n=[];for(let e=0;e=e;)t.push(this.next());return new tt(t,this.indentString,this.getLineNumber()-t.length)}next(){if(this.finished())throw new Error("Trying to next finished generator");return this.lineIndex++,this.getLine()}peek(){return this.getLine(this.lineIndex+1)}finished(){return this.lineIndex==this.lines.length-1}getLine(t){return(t=void 0!==t?t:this.lineIndex)>=this.lines.length?null:this.lines[t][0]}findIndentString(){for(let[t]of this.lines)if(t.trim()&&t.replace(/^\s+/,"")!=t)return t.match(/^(\s+)/)[1];return""}indentLevel(t){(t=void 0!==t?t:this.lineIndex)<0&&(t=0);let e=0,i=this.getLine(t);for(;i.startsWith(this.indentString);)i=i.slice(this.indentString.length),e++;return e}}function et(t,e){let i;for(t.indentLevel();!t.finished();){let e,n,r,s=t.next().trim(),a=s.match(/^(.*?):(?: |$)/),o=s.match(/#!([\w<,>]+)/);s.startsWith('"')&&(a=s.match(/^"(.*?)":(?: |$)/)),o&&(r=o[1],s=s.replace(o[0],"")),a?(i||(i={}),e=a[1],n=s.replace(a[0],"").trim()):s.startsWith("-")&&(i||(i=[]),n=s.slice(1).trim()),n=n?it(n,r):et(t.nextGroup(),r),Array.isArray(i)?i.push(n):i[e]=n}return e&&(i={type:e,data:i}),i}function it(t,e){return t=JSON.parse(t),e&&(t={type:e,data:t}),t}function nt(t){let e=t.replace(/\t/g,"\t").split("\n");return et(new tt(e))}function rt(t){let e;if(Array.isArray(t)){e=[];for(let i of t)e.push(rt(i));return e}if(t&&"object"==typeof t){e={};for(let[i,n]of Object.entries(t))e[i]=rt(n);return e}return t}function st(t){switch(t){case"Boolean":case"Int32":case"UInt32":case"Single":case"Double":case"Char":case"String":case"":case"Vector2":case"Vector3":case"Vector4":case"Rectangle":case"Rect":return!0;default:return!1}}function at(t){switch(t){case"Texture2D":case"TBin":case"Effect":case"BmFont":return!0;default:return!1}}function ot(t){if(!t||"object"!=typeof t)return t;if("object"==typeof t&&t.hasOwnProperty("data")){let{type:e,data:i}=t;if(st(e))return rt(i);if(at(e))return i=rt(i),"Texture2D"===e?i.export="Texture2D.png":"Effect"===e?i.export="Effect.cso":"TBin"===e?i.export="TBin.tbin":"BmFont"===e&&(i.export="BmFont.xml"),i;if(e.startsWith("Nullable"))return null===i||null===i.data?null:ot(i.data);t=rt(i)}let e;if(Array.isArray(t)){e=[];for(let i of t)e.push(ot(i));return e}if(t&&"object"==typeof t){e={};for(let[i,n]of Object.entries(t))e[i]=ot(n);return e}return null}function ht(t){const e={},{compressed:i,formatVersion:n,hidef:r,target:s}=t.header;let a=rt(t.readers);e.xnbData={target:s,compressed:!!i,hiDef:r,readerData:a,numSharedResources:0};const h=rt(t.content),l=o.simplifyType(a[0].type);let d=o.getReaderTypeList(l);"SpriteFont"===d[0]&&(d=["SpriteFont","Texture2D","List","Rectangle","List","Rectangle","List","Char",null,"List","Vector3","Nullable","Char",null],h.verticalSpacing=h.verticalLineSpacing,delete h.verticalLineSpacing);const{converted:f,extractedImages:c,extractedMaps:u}=function(t,e){let i=[],n=[];const{converted:r}=function t(r,s){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const o=e[a];if(st(o))return{converted:{type:o,data:r},traversed:a};if(null===o)return{converted:r,traversed:a};if(o.startsWith("Nullable")){let i,n,[h,l=1]=o.split(":");if(l=+l,null===r)i=null,n=a+l;else if("object"!=typeof r||r&&0!==Object.keys(r).length){let{converted:e,traversed:o}=t(r,[...s],a+1);i=e,n=o}else i={type:e[a+1],data:rt(r)},n=a+l;return{converted:{type:h,data:{data:i}},traversed:n}}if(at(o))return"Texture2D"===o?(i.push({path:s.join(".")}),{converted:{type:o,data:{format:r.format}},traversed:a}):("TBin"===o&&n.push({path:s.join(".")}),{converted:{type:o,data:{}},traversed:a});let h;h=Array.isArray(r)?[]:{};let l=a,d=!0,f=!o.startsWith("Dictionary")&&!o.startsWith("Array")&&!o.startsWith("List");for(let[e,i]of Object.entries(r)){let i;i=o.startsWith("Dictionary")?a+2:o.startsWith("Array")||o.startsWith("List")?a+1:l+1;const{converted:n,traversed:c}=t(r[e],[...s,e],i);h[e]=n,f?l=c:d&&(l=c,d=!1)}return{converted:{type:o,data:h},traversed:l}}(t,[]);return{converted:r,extractedImages:i,extractedMaps:n}}(h,d);return e.content=f,c.length>0&&(e.extractedImages=c),u.length>0&&(e.extractedMaps=u),e}function lt(t){const e={},{compressed:i,readerData:n,hiDef:r,target:s}=t.xnbData;return e.header={target:s,formatVersion:5,compressed:i?"a"===s||"i"===s?64:128:0,hidef:r},e.readers=rt(n),e.content=ot(t.content),"SpriteFont"===o.simplifyType(e.readers[0].type)&&(e.content.verticalLineSpacing=e.content.verticalSpacing,delete e.content.verticalSpacing),e}function dt(t,e){if(t&&"object"==typeof t){if(t.hasOwnProperty(e))return{parent:t,value:t[e]};for(let i of Object.values(t))if(i||"object"==typeof i){let t=dt(i,e);if(t)return t}return null}}function ft(t){let e=t.match(/(.*)\.([^\s.]+)$/);return null===e?[t,null]:[e[1],e[2]]}function ct(t){switch(t){case"JSON":return"json";case"yaml":return"yaml";case"Texture2D":return"png";case"Effect":return"cso";case"TBin":return"tbin";case"BmFont":return"xml"}return"bin"}function ut(t){switch(t){case"JSON":return"application/json";case"yaml":return"text/plain";case"Texture2D":return"image/png";case"Effect":return"application/x-cso";case"BmFont":return"application/xml"}return"application/octet-stream"}function _t(t,e){return"function"==typeof Blob?{data:new Blob([t],{type:ut(e)}),extension:ct(e)}:{data:t,extension:ct(e)}}function wt(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=dt(t,"export");if(i){const{value:t}=i;let{type:e,data:n}=t;return"Texture2D"===e&&(n=$(t.width,t.height,new Uint8Array(n))),_t(n,e)}if(e){return _t(JSON.stringify(t,null,4),"JSON")}return null}function pt(t){let{yaml:e=!1,contentOnly:i=!1,fileName:n=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&i&&(e=!1),!t.hasOwnProperty("content"))throw new s("Invalid object!");const r=[],{content:a}=t,o=wt(a,i);if(null!==o&&r.push(o),i)return r;const h=JSON.stringify(t,((t,e)=>"export"===t?"string"==typeof n&&""!==n?"".concat(n,".").concat(ct(e.type)):"".concat(e.type,".").concat(ct(e.type)):e),4);let l=h;return e&&(l=Q(ht(t))),r.unshift(_t(l,e?"yaml":"JSON")),r}function bt(t){let e=t.toLowerCase();return"none"===e?0:"lz4"===e?64:null}async function gt(t){return"function"==typeof Blob&&t instanceof Blob?t.text():"function"==typeof Buffer&&t instanceof Buffer?t.toString():t}async function mt(t){return"function"==typeof Blob&&t instanceof Blob?t.arrayBuffer():"function"==typeof Buffer&&t instanceof Buffer?t.buffer:void 0}async function yt(t,e){if("png"===t){const t=await mt(e.png);let i=J(new Uint8Array(t));return 4===i.channel&&8===i.depth&&void 0===i.palette||(i.data=W(i)),{type:"Texture2D",data:i.data,width:i.width,height:i.height}}if("cso"===t){return{type:"Effect",data:await mt(e.cso)}}if("tbin"===t){return{type:"TBin",data:await mt(e.tbin)}}if("xml"===t){return{type:"BmFont",data:await gt(e.xml)}}}async function vt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{compression:i="default"}=e,n=t.json||t.yaml;if(!n)throw new s("There is no JSON or YAML file to pack!");const r=await gt(n);let a=null;a=t.json?JSON.parse(r):lt(nt(r));let o=bt(i);if(null!==o&&(a.header.compressed=o),!a.hasOwnProperty("content"))throw new s("".concat(n.name,' does not have "content".'));const h=dt(a.content,"export");if(h){const{parent:e,value:i}=h,[,n]=ft(i);e.export=await yt(n,t)}return a}function kt(t){const[,e]=ft(t),i=function(t){return"png"===t?"Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553":"tbin"===t?"xTile.Pipeline.TideReader, xTile":"xml"===t?"BmFont.XmlSourceReader, BmFont, Version=2012.1.7.0, Culture=neutral, PublicKeyToken=null":void 0}(e);let n={export:t};"png"===e&&(n.format=0);const r={header:{target:"w",formatVersion:5,hidef:!0,compressed:!0},readers:[{type:i,version:0}],content:n};return JSON.stringify(r)}async function xt(t){if("undefined"!=typeof window){const[,e]=ft(t.name);if("xnb"!==e)return new Error("Invalid XNB File!");return Et(await t.arrayBuffer())}return Et(t.buffer)}function Et(t){return(new M).load(t)}function At(t){const{content:e}=t,{data:i,extension:n}=wt(e,!0);return new Z(i,n)}function Ut(t){let e={},i={};for(let n=0;n1&&void 0!==arguments[1]?arguments[1]:{};const n=Ut(t);let r=[];for(let[t,e]of Object.entries(n))r.push(vt(e,i).then(Rt).then((e=>"function"==typeof Blob?{name:t,data:new Blob([e],{type:"application/octet-stream"})}:{name:t,data:new Uint8Array(e)})));return e(r).then((t=>!0===i.debug?t:t.filter((t=>{let{status:e,value:i}=t;return"fulfilled"===e})).map((t=>{let{value:e}=t;return e}))))},t.setReaders=function(t){return o.setReaders(t)},t.unpackToContent=function(t){return xt(t).then(At)},t.unpackToFiles=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{yaml:i=!1,contentOnly:n=!1,fileName:r=null}=e;"undefined"!=typeof window&&null===r&&(r=t.name);let[s]=ft(r);const a=t=>pt(t,{yaml:i,contentOnly:n,fileName:s});return xt(t).then(a)},t.unpackToXnbData=xt,t.xnbDataToContent=At,t.xnbDataToFiles=pt,Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XNB={})}(this,(function(t){"use strict";const e=void 0!==Promise.allSettled?Promise.allSettled.bind(Promise):function(t){let e=t.map((t=>t.then((t=>({status:"fulfilled",value:t}))).catch((t=>({status:"rejected",reason:t})))));return Promise.all(e)};function i(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function n(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:"";super(t),this.name="XnbError",this.message=t,Error.captureStackTrace(this,s)}}class a{static isTypeOf(t){return!1}static hasSubType(){return!1}static type(){return"ReflectiveScheme"}constructor(t,e){this.name=t,this.readers=e}read(t,e){const i={};for(let[n,r]of this.readers.entries())r.isValueType()?i[n]=r.read(t):"Nullable"===r.constructor.type()?i[n]=r.read(t,e):i[n]=e.read(t);return i}write(t,e,i){t.alloc(163518),this.writeIndex(t,i);for(let[n,r]of this.readers.entries())r.write(t,e[n],r.isValueType()?null:i)}writeIndex(t,e){null!=e&&t.write7BitNumber(Number.parseInt(e.getIndex(this))+1)}isValueType(){return!1}get type(){const t=/\.([^\.]+)$/;return t.test(this.name)?this.name.match(t)[1]:this.name}parseTypeList(){let t=[...this.readers.values()].map((t=>t.isValueType()?null:t.parseTypeList())).flat();return t.unshift(this.type),t}toString(){return"ReflectiveScheme<".concat(this.name,">")}}function o(t){let e=[],i=[];for(let n=0;nh.enumList.add(t)))}static addEnum(t){t.forEach((t=>h.enumList.add(t)))}static makeSimplied(t,e){let i=t.split(/`|,/)[0];if(e.isTypeOf(i)){if(e.hasSubType()){let i=h.parseSubtypes(t).map(h.simplifyType.bind(h));return"".concat(e.type(),"<").concat(i.join(","),">")}return e.type()}return null}static simplifyReflectiveType(t){let e=t.split(/`|,/)[0];for(let t of Object.values(h.readers))if(t.isTypeOf(e))return t.type();if(h.schemes.hasOwnProperty(e))return"ReflectiveScheme<".concat(e,">");throw new s('Non-implemented scheme found, cannot resolve scheme "'.concat(e,'", "').concat(t,'".'))}static simplifyType(t){let e=t.split(/`|,/)[0];if(e.endsWith("[]"))return"Array<".concat(h.simplifyType(e.slice(0,-2)),">");if("Microsoft.Xna.Framework.Content.ReflectiveReader"===e)return h.simplifyReflectiveType(h.parseSubtypes(t)[0]);for(let e of Object.values(h.readers)){let i=h.makeSimplied(t,e);if(null!==i)return i}if(h.schemes.hasOwnProperty(e))return"ReflectiveScheme<".concat(e,">");if(h.enumList.has(e))return"Int32";throw new s('Non-implemented type found, cannot resolve type "'.concat(e,'", "').concat(t,'".'))}static parseSubtypes(t){let e=t.slice(t.search("`")+1);return e[0],e=o(e)[0],o(e)}static getTypeInfo(t){let e=t.match(/[^<]+/)[0],i=t.match(/<(.+)>/);return i=i?i[1].split(",").map((t=>t.trim())):[],{type:e,subtypes:i}}static getReaderTypeList(t){return h.getReader(t).parseTypeList()}static getReader(t){let{type:e,subtypes:i}=h.getTypeInfo(t);if("ReflectiveScheme"===e)return l(i[0]);if(i=i.map(h.getReader.bind(h)),h.readers.hasOwnProperty("".concat(e,"Reader")))return new(h.readers["".concat(e,"Reader")])(...i);if(h.schemes.hasOwnProperty(e))return l(e);throw new s('Invalid reader type "'.concat(t,'" passed, unable to resolve!'))}static getReaderClass(t){if(h.readers.hasOwnProperty(t))return h.readers[t];throw new s('There is no "'.concat(t,'" class in reader list!'))}static getReaderFromRaw(t){const e=h.simplifyType(t);return h.getReader(e)}}function l(t){if(!h.schemes.hasOwnProperty(t))throw new s("Unsupported scheme : ".concat(t));let e=h.schemes[t];return e instanceof Map==!1&&(e=f(e),h.schemes[t]=e),new a(t,e)}function d(t){if("string"==typeof t)return h.getReader(t);if(Array.isArray(t)){return new(h.getReaderClass("ListReader"))(d(t[0]))}if("object"==typeof t){const e=Object.keys(t).length;if(1===e){const e=h.getReaderClass("DictionaryReader"),[i,n]=Object.entries(t)[0];return new e(d(i),d(n))}if(e>1)return f(t)}throw new s("Invalid Scheme to convert! : ".concat(t))}function f(t){const e=new Map;for(let[i,n]of Object.entries(t)){let t=d(n);if(i.startsWith("$")){i=i.slice(1);try{t=new h.readers.NullableReader(t)}catch(t){throw new s("There is no NullableReader from reader list!")}}e.set(i,t)}return e}r(h,"readers",{}),r(h,"schemes",{}),r(h,"enumList",new Set);const c=[192,224,240],u=128,_=63,p=[55296,56320],w=1023;function b(t){return t<128?[t]:t<2048?[c[0]|t>>6,u|t&_]:t<65536?[c[1]|t>>12,u|t>>6&_,u|t&_]:[c[2]|t>>18,u|t>>12&_,u|t>>6&_,u|t&_]}function g(t){return t<65535?[t]:[p[0]|(t-=65536)>>10&w,p[1]|t&w]}function m(t){var e;if("number"==typeof t&&(t=[t]),null===(e=t)||void 0===e||!e.length)throw new Error("Invalid codeset!");const i=t.length;return 1===i?t[0]:2===i?((t[0]^c[0])<<6)+(t[1]^u):3===i?((t[0]^c[1])<<12)+((t[1]^u)<<6)+(t[2]^u):((t[0]^c[2])<<18)+((t[1]^u)<<12)+((t[2]^u)<<6)+(t[3]^u)}function y(t){var e;if("number"==typeof t&&(t=[t]),null===(e=t)||void 0===e||!e.length)throw new Error("Invalid codeset!");return 1===t.length?t[0]:((t[0]&w)<<10)+(t[1]&w)+65536}function v(t){return function(t){const e=[];for(let i of t)e.push(...b(i));return e}(function(t){const e=Array.from({length:t.length},((e,i)=>t.charCodeAt(i))),i=[];let n=0;for(;n1&&void 0!==arguments[1])||arguments[1];this._endianus=e,this._buffer=t.slice(),this._dataView=new DataView(this._buffer),this._offset=0,this._bitOffset=0}seek(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._offset;const i=this._offset;if(this._offset=Math.max(e+Number.parseInt(t),0),this._offset<0||this._offset>this.buffer.length)throw new RangeError("Buffer seek out of bounds! ".concat(this._offset," ").concat(this.buffer.length));return this._offset-i}get bytePosition(){return Number.parseInt(this._offset)}set bytePosition(t){this._offset=t}get bitPosition(){return Number.parseInt(this._bitOffset)}set bitPosition(t){t<0&&(t=16-t),this._bitOffset=t%16;const e=(t-Math.abs(t)%16)/16*2;this.seek(e)}get size(){return this.buffer.byteLength}get buffer(){return this._buffer}copyFrom(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.byteLength;const r=new Uint8Array(t),s=this.buffer.byteLength0&&void 0!==arguments[0]?arguments[0]:-1;const e=[];if(this._offset,-1===t)for(;0!=this.peekByte(1);)e.push(this.readByte());else for(let i=0;i0&&void 0!==arguments[0]?arguments[0]:0;const e=[],i=this._offset;if(0===t)for(;0!=this.peekByte(1);)e.push(this.readByte());else for(let i=0;i0;){const t=this._dataView.getUint16(this._offset,!0),n=Math.min(Math.max(e,0),16-this.bitPosition),r=16-this.bitPosition-n,s=(t&2**n-1<>r;e-=n,this.bitPosition+=n,i|=s<0&&void 0!==arguments[0])||arguments[0];const e=this.readByte(),i=this.readByte();return t||this.seek(-2),e<<8|i}align(){this.bitPosition>0&&(this.bitPosition+=16-this.bitPosition)}}class E{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2048;this._buffer=new ArrayBuffer(t),this._dataView=new DataView(this._buffer),this.bytePosition=0}get buffer(){return this._buffer}reconnectDataView(){this._dataView=new DataView(this._buffer)}trim(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._buffer=this.buffer.slice(0,this.bytePosition),t||this.reconnectDataView()}alloc(t){if(this._buffer.byteLength<=this.bytePosition+t){const e=new ArrayBuffer(this._buffer.byteLength+t),i=new DataView(e);for(let t=0;t>=7)&&(e|=128),this._dataView.setUint8(this.bytePosition,e),this.bytePosition++}while(t)}}const A=256,U=0,R=1,B=2,O=3,T=656;class S{constructor(t){if(this.window_size=1<21)throw new s("Window size out of range!");if(!S.extra_bits.length)for(let t=0,e=0;t<=50;t+=2)S.extra_bits[t]=S.extra_bits[t+1]=e,0!=t&&e<17&&e++;if(!S.position_base.length)for(let t=0,e=0;t<=50;t++)S.position_base[t]=e,e+=1<0;){if(0==this.block_remaining){this.block_type=t.readLZXBits(3);const e=t.readLZXBits(16),i=t.readLZXBits(8);switch(this.block_remaining=e<<8|i,this.block_type){case B:for(let e=0;e<8;e++)this.aligned_len[e]=t.readLZXBits(3);this.aligned_table=this.decodeTable(8,7,this.aligned_len);case R:this.readLengths(t,this.maintree_len,0,256),this.readLengths(t,this.maintree_len,256,this.main_elements),this.maintree_table=this.decodeTable(T,12,this.maintree_len),this.readLengths(t,this.length_len,0,249),this.length_table=this.decodeTable(250,12,this.length_len);break;case O:t.align(),this.R0=t.readInt32(),this.R1=t.readInt32(),this.R2=t.readInt32();break;default:throw new s("Invalid Blocktype Found: ".concat(this.block_type))}}let e=this.block_remaining;for(;(e=this.block_remaining)>0&&n>0;){if(e>n&&(e=n),n-=e,this.block_remaining-=e,this.window_posn&=this.window_size-1,this.window_posn+e>this.window_size)throw new s("Cannot run outside of window frame.");switch(this.block_type){case B:for(;e>0;){let i,n=this.readHuffSymbol(t,this.maintree_table,this.maintree_len,T,12);if(n>3;if(s>2){let e=S.extra_bits[s];if(s=S.position_base[s]-2,e>3){e-=3,s+=t.readLZXBits(e)<<3,s+=this.readHuffSymbol(t,this.aligned_table,this.aligned_len,8,7)}else 3==e?s+=this.readHuffSymbol(t,this.aligned_table,this.aligned_len,8,7):e>0?s+=t.readLZXBits(e):s=1;this.R2=this.R1,this.R1=this.R0,this.R0=s}else 0===s?s=this.R0:1==s?(s=this.R1,this.R1=this.R0,this.R0=s):(s=this.R2,this.R2=this.R0,this.R0=s);let a,o=this.window_posn;if(e-=r,this.window_posn>=s)a=o-s;else{a=o+(this.window_size-s);let t=s-this.window_posn;if(t0;)this.win[o++]=this.win[a++];a=0}}for(this.window_posn+=r;r-- >0;)this.win[o++]=this.win[a++]}break;case R:for(;e>0;){let i,n=this.readHuffSymbol(t,this.maintree_table,this.maintree_len,T,12);if(n>3;if(s>2){if(3!=s){let e=S.extra_bits[s],i=t.readLZXBits(e);s=S.position_base[s]-2+i}else s=1;this.R2=this.R1,this.R1=this.R0,this.R0=s}else 0===s?s=this.R0:1==s?(s=this.R1,this.R1=this.R0,this.R0=s):(s=this.R2,this.R2=this.R0,this.R0=s);let a,o=this.window_posn;if(e-=r,this.window_posn>=s)a=o-s;else{a=o+(this.window_size-s);let t=s-this.window_posn;if(t0;)this.win[o++]=this.win[a++];a=0}}for(this.window_posn+=r;r-- >0;)this.win[o++]=this.win[a++]}break;case O:if(t.bytePosition+e>i)throw new s("Overrun!"+i+" "+t.bytePosition+" "+e);for(let i=0;i>1;for(let h=1;h<=e;h++){for(let e=0;ea)throw new s("Overrun table!");let i=o;for(;i-- >0;)n[t++]=e}o>>=1}if(r==a)return n;for(let t=r;t>1>1;r<<=16,a<<=16,o=32768;for(let l=e+1;l<=16;l++){for(let d=0;d>16;for(let i=0;i>15-i&1&&t++;if(n[t]=d,(r+=o)>a)throw new s("Overrun table during decoding.")}o>>=1}if(r==a)return n;throw new s("Decode table did not reach table mask.")}readHuffSymbol(t,e,i,n,r){let s=t.peekLZXBits(32)>>>0,a=e[t.peekLZXBits(r)];if(a>=n){let t=1<<32-r;do{if(t>>=1,a<<=1,a|=0!=(s&t)?1:0,0==t)return 0}while((a=e[a])>=n)}return t.bitPosition+=i[a],a}set RRR(t){if(this.R0!=t&&this.R1!=t&&this.R2!=t)this.R2=this.R1,this.R1=this.R0,this.R0=t;else if(this.R1==t){let t=this.R1;this.R1=this.R0,this.R0=t}else if(this.R2==t){let t=this.R2;this.R2=this.R0,this.R0=t}}}S.position_base=[],S.extra_bits=[];class L{static hashU32(t){return-1252372727^(t=(t=(t=(t=-949894596^(t=(t|=0)+2127912214+(t<<12)|0)^t>>>19)+374761393+(t<<5)|0)+-744332180^t<<9)+-42973499+(t<<3)|0)^t>>>16|0}static readU64(t,e){var i=0;return i|=t[e++]<<0,i|=t[e++]<<8,i|=t[e++]<<16,i|=t[e++]<<24,i|=t[e++]<<32,i|=t[e++]<<40,i|=t[e++]<<48,i|=t[e++]<<56}static readU32(t,e){var i=0;return i|=t[e++]<<0,i|=t[e++]<<8,i|=t[e++]<<16,i|=t[e++]<<24}static writeU32(t,e,i){t[e++]=i>>0&255,t[e++]=i>>8&255,t[e++]=i>>16&255,t[e++]=i>>24&255}static imul(t,e){var i=65535&t,n=65535&e;return i*n+((t>>>16)*n+i*(e>>>16)<<16)|0}}const I=65536,N=15;!function(t){try{new Uint8Array(t)}catch(n){for(var e=new Array(t),i=0;i=13)for(var u=67;i+4>>0;if(s=r[p=(p>>16^p)>>>0&65535]-1,r[p]=i+1,s<0||i-s>>>16>0||L.readU32(t,s)!==_)i+=u++>>6;else{for(u=67,l=i-a,h=i-s,s+=4,o=i+=4;i=N){for(e[d++]=240+w,c=l-N;c>=255;c-=255)e[d++]=255;e[d++]=c}else e[d++]=(l<<4)+w;for(var b=0;b>8,o>=15){for(c=o-15;c>=255;c-=255)e[d++]=255;e[d++]=c}a=i}}if(0===a)return 0;if((l=f-a)>=N){for(e[d++]=240,c=l-N;c>=255;c-=255)e[d++]=255;e[d++]=c}else e[d++]=l<<4;for(i=a;it.charCodeAt(i))),i=[];let n=0;for(;ne<128?t+1:e<2048?t+2:e<65536?t+3:t+4),0)}class F{read(t){let e=t.read7BitNumber();return t.readString(e)}write(t,e){const i=Z(e);t.write7BitNumber(i),t.writeString(e)}}class V{constructor(t){this.readers=t}read(t){let e=t.read7BitNumber()-1;if(null==this.readers[e])throw new s("Invalid reader index ".concat(e," | pos: ").concat(t.bytePosition.toString(16)));return this.readers[e].read(t,this)}write(t,e){this.readers[0].write(t,e,this)}getIndex(t){for(let e=0,i=this.readers.length;e"export"===t?e.type:e),4)}stringify(){return JSON.stringify({header:this.header,readers:this.readers,content:this.content},null,4)}toString(){return this.stringify()}}class M{constructor(t,e){this.type=function(t){switch(t){case"json":return"JSON";case"yaml":return"yaml";case"png":return"Texture2D";case"cso":return"Effect";case"tbin":return"TBin";case"xml":return"BmFont"}return"Others"}(e),this.content=t}}const W=64,X=128,H=14;class K{constructor(){this.target="",this.formatVersion=0,this.hidef=!1,this.compressed=!1,this.compressionType=0,this.buffer=null,this.fileSize=0,this.readers=[],this.sharedResources=[]}load(t){if(this.buffer=new x(t),this._validateHeader(),console.info("XNB file validated successfully!"),this.fileSize=this.buffer.readUInt32(),this.buffer.size!=this.fileSize)throw new s("XNB file has been truncated!");if(this.compressed){const t=this.buffer.readUInt32();if(this.compressionType==X){const e=this.fileSize-H,i=class{static decompress(t,e,i){let n,r,a=0;const o=new S(16);let h=new E(i);for(;a65536||r>65536)throw new s("Invalid size read in compression content.");h.write(o.decompress(t,r,n)),a+=n}return console.log("File has been successfully decompressed!"),h.trim(),h.buffer}}.decompress(this.buffer,e,t);this.buffer.copyFrom(i,H,0,t),this.buffer.bytePosition=H}else if(this.compressionType==W){const e=this.buffer.buffer.slice(H),i=new Uint8Array(e),n=new Uint8Array(t);!function(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.length-2*i,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;var s,a,o,h,l,d=void 0!==e.copyWithin&&void 0!==e.fill;for(o=i+n;i>4;if(c>0){if(15===c)for(;c+=t[i],255===t[i++];);for(h=i+c;i=o)break;if(s=15&f,a=t[i++]|t[i++]<<8,15===s)for(;s+=t[i],255===t[i++];);if(s+=4,d&&1===a)e.fill(0|e[r-1],r,r+s),r+=s;else if(d&&a>s&&s>31)e.copyWithin(r,r-a,r-a+s),r+=s;else for(h=(l=r-a)+s;l{let{type:e}=t;return h.getReaderFromRaw(e)}));const r=this.buffer.read7BitNumber();if(0!=r)throw new s("Unexpected (".concat(r,") shared resources."));const a=new V(this.readers).read(this.buffer);return console.log("Successfuly read XNB file!"),new j({target:this.target,formatVersion:this.formatVersion,hidef:this.hidef,compressed:this.compressed},n,a)}convert(t){const e=new E,i=new F;let{target:n,formatVersion:r,hidef:s,compressed:a}=t.header;this.target=n,this.formatVersion=r,this.hidef=s;const o="a"==this.target||"i"==this.target||0!=(a&W);this.compressed=!!o,e.writeString("XNB"),e.writeString(this.target),e.writeByte(this.formatVersion),e.writeByte(this.hidef|(this.compressed&&o?W:0)),e.writeUInt32(0),o&&e.writeUInt32(0),e.write7BitNumber(t.readers.length);for(let n of t.readers)this.readers.push(h.getReaderFromRaw(n.type)),i.write(e,n.type),e.writeUInt32(n.version);e.write7BitNumber(0);if(new V(this.readers).write(e,t.content),e.trim(),o){const t=e.buffer.slice(H),i=new Uint8Array(t);let n=function(t){return t+t/255+16|0}(i.length),r=new Uint8Array(n);return n=D(i,r),r=r.slice(0,n),e.bytePosition=6,e.writeUInt32(H+n),e.writeUInt32(i.length),e.concat(r),e.buffer.slice(0,H+n)}let l=e.bytePosition;return e.bytePosition=6,e.writeUInt32(l,6),e.buffer}_validateHeader(){if(null==this.buffer)throw new s("Buffer is null");const t=this.buffer.readString(3);if("XNB"!=t)throw new s('Invalid file magic found, expecting "XNB", found "'.concat(t,'"'));this.target=this.buffer.readString(1).toLowerCase(),this.formatVersion=this.buffer.readByte();const e=this.buffer.readByte(1);this.hidef=0!=(1&e),this.compressed=e&X||0!=(e&W),this.compressionType=0!=(e&X)?X:e&W?W:0}}function Y(t,e){let{r:i,g:n=i,b:r=i,a:s=255}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t[4*e+0]=i,t[4*e+1]=n,t[4*e+2]=r,t[4*e+3]=s,[i,n,r,s]}function G(t){const{width:e,height:i,channels:n,depth:r}=t;let{data:s}=t;return t.palette?function(t,e,i){const n=new Uint8Array(t),r=8*n.length/e,s=new Uint8Array(4*r);let a=0;for(let t=0;t>o&2**e-1,[s[4*t],s[4*t+1],s[4*t+2],s[4*t+3]]=i[h],a+=e}return s}(s,r,t.palette):(16===r&&(s=function(t){const e=new Uint16Array(t),i=new Uint8Array(e.length);for(let t=0;t>8;return i}(s)),n<4&&(s=function(t,e){const i=t.length/e,n=new Uint8Array(4*i);if(4===e)return t;if(1===e)for(let e=0;e0&&void 0!==arguments[0]?arguments[0]:"utf-8";if("utf-8"!==t)throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t,"') is invalid."))}function i(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"utf-8",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fatal:!1};if("utf-8"!==t)throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t,"') is invalid."));if(e.fatal)throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}Object.defineProperty(e.prototype,"encoding",{value:"utf-8"}),e.prototype.encode=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{stream:!1};if(e.stream)throw new Error("Failed to encode: the 'stream' option is unsupported.");let i=0;const n=t.length;let r=0,s=Math.max(32,n+(n>>1)+7),a=new Uint8Array(s>>3<<3);for(;i=55296&&e<=56319){if(i=55296&&e<=56319)continue}if(r+4>a.length){s+=8,s*=1+i/t.length*2,s=s>>3<<3;const e=new Uint8Array(s);e.set(a),a=e}if(0!=(4294967168&e)){if(0==(4294965248&e))a[r++]=e>>6&31|192;else if(0==(4294901760&e))a[r++]=e>>12&15|224,a[r++]=e>>6&63|128;else{if(0!=(4292870144&e))continue;a[r++]=e>>18&7|240,a[r++]=e>>12&63|128,a[r++]=e>>6&63|128}a[r++]=63&e|128}else a[r++]=e}return a.slice(0,r)},Object.defineProperty(i.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(i.prototype,"fatal",{value:!1}),Object.defineProperty(i.prototype,"ignoreBOM",{value:!1}),i.prototype.decode=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{stream:!1};if(e.stream)throw new Error("Failed to decode: the 'stream' option is unsupported.");const i=new Uint8Array(t);let n=0;const r=i.length,s=[];for(;n65535&&(e-=65536,s.push(e>>>10&1023|55296),e=56320|1023&e),s.push(e)}}return String.fromCharCode.apply(null,s)},t.TextEncoder=e,t.TextDecoder=i}("undefined"!=typeof window?window:"undefined"!=typeof self?self:this)}},$={};function q(t){var e=$[t];if(void 0!==e)return e.exports;var i=$[t]={exports:{}};return J[t].call(i.exports,i,i.exports,q),i.exports}q.d=(t,e)=>{for(var i in e)q.o(e,i)&&!q.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},q.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Q={};(()=>{q.d(Q,{P:()=>Li,m:()=>Si}),q(396);const t=new TextDecoder("utf-8"),e=new TextEncoder;class i{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8192,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!1;"number"==typeof t?t=new ArrayBuffer(t):(n=!0,this.lastWrittenByte=t.byteLength);const r=e.offset?e.offset>>>0:0,s=t.byteLength-r;let a=r;(ArrayBuffer.isView(t)||t instanceof i)&&(t.byteLength!==t.buffer.byteLength&&(a=t.byteOffset+r),t=t.buffer),this.lastWrittenByte=n?s:0,this.buffer=t,this.length=s,this.byteLength=s,this.byteOffset=a,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,a,s),this._mark=0,this._marks=[]}available(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.offset+=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(!this.available(t)){const e=2*(this.offset+t),i=new Uint8Array(e);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=e,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;const e=new Uint8Array(t);for(let i=0;i0&&void 0!==arguments[0]?arguments[0]:1,e="";for(let i=0;i0&&void 0!==arguments[0]?arguments[0]:1;return i=this.readBytes(e),t.decode(i);var i}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let e=0;ethis.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function r(t){let e=t.length;for(;--e>=0;)t[e]=0}const s=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),a=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),o=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),l=new Array(576);r(l);const d=new Array(60);r(d);const f=new Array(512);r(f);const c=new Array(256);r(c);const u=new Array(29);r(u);const _=new Array(30);function p(t,e,i,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}let w,b,g;function m(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}r(_);const y=t=>t<256?f[t]:f[256+(t>>>7)],v=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},k=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<{k(t,i[2*e],i[2*e+1])},E=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},A=(t,e,i)=>{const n=new Array(16);let r,s,a=0;for(r=1;r<=15;r++)n[r]=a=a+i[r-1]<<1;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=E(n[e]++,e))}},U=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},R=t=>{t.bi_valid>8?v(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},B=(t,e,i,n)=>{const r=2*e,s=2*i;return t[r]{const n=t.heap[i];let r=i<<1;for(;r<=t.heap_len&&(r{let n,r,o,h,l=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*l]<<8|t.pending_buf[t.d_buf+2*l+1],r=t.pending_buf[t.l_buf+l],l++,0===n?x(t,r,e):(o=c[r],x(t,o+256+1,e),h=s[o],0!==h&&(r-=u[o],k(t,r,h)),n--,o=y(n),x(t,o,i),h=a[o],0!==h&&(n-=_[o],k(t,n,h)))}while(l{const i=e.dyn_tree,n=e.stat_desc.static_tree,r=e.stat_desc.has_stree,s=e.stat_desc.elems;let a,o,h,l=-1;for(t.heap_len=0,t.heap_max=573,a=0;a>1;a>=1;a--)O(t,i,a);h=s;do{a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],O(t,i,1),o=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=o,i[2*h]=i[2*a]+i[2*o],t.depth[h]=(t.depth[a]>=t.depth[o]?t.depth[a]:t.depth[o])+1,i[2*a+1]=i[2*o+1]=h,t.heap[1]=h++,O(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,n=e.max_code,r=e.stat_desc.static_tree,s=e.stat_desc.has_stree,a=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,h=e.stat_desc.max_length;let l,d,f,c,u,_,p=0;for(c=0;c<=15;c++)t.bl_count[c]=0;for(i[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)d=t.heap[l],c=i[2*i[2*d+1]+1]+1,c>h&&(c=h,p++),i[2*d+1]=c,d>n||(t.bl_count[c]++,u=0,d>=o&&(u=a[d-o]),_=i[2*d],t.opt_len+=_*(c+u),s&&(t.static_len+=_*(r[2*d+1]+u)));if(0!==p){do{for(c=h-1;0===t.bl_count[c];)c--;t.bl_count[c]--,t.bl_count[c+1]+=2,t.bl_count[h]--,p-=2}while(p>0);for(c=h;0!==c;c--)for(d=t.bl_count[c];0!==d;)f=t.heap[--l],f>n||(i[2*f+1]!==c&&(t.opt_len+=(c-i[2*f+1])*i[2*f],i[2*f+1]=c),d--)}})(t,e),A(i,l,t.bl_count)},L=(t,e,i)=>{let n,r,s=-1,a=e[1],o=0,h=7,l=4;for(0===a&&(h=138,l=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)r=a,a=e[2*(n+1)+1],++o{let n,r,s=-1,a=e[1],o=0,h=7,l=4;for(0===a&&(h=138,l=3),n=0;n<=i;n++)if(r=a,a=e[2*(n+1)+1],!(++o{k(t,0+(n?1:0),3),((t,e,i,n)=>{R(t),v(t,i),v(t,~i),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i})(t,e,i)};var D={_tr_init:t=>{N||((()=>{let t,e,i,n,r;const h=new Array(16);for(i=0,n=0;n<28;n++)for(u[n]=i,t=0;t<1<>=7;n<30;n++)for(_[n]=r<<7,t=0;t<1<{let r,s,a=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),S(t,t.l_desc),S(t,t.d_desc),a=(t=>{let e;for(L(t,t.dyn_ltree,t.l_desc.max_code),L(t,t.dyn_dtree,t.d_desc.max_code),S(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*h[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),r=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==e?z(t,e,i,n):4===t.strategy||s===r?(k(t,2+(n?1:0),3),T(t,l,d)):(k(t,4+(n?1:0),3),((t,e,i,n)=>{let r;for(k(t,e-257,5),k(t,i-1,5),k(t,n-4,4),r=0;r(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(c[i]+256+1)]++,t.dyn_dtree[2*y(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{k(t,2,3),x(t,256,l),(t=>{16===t.bi_valid?(v(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},P=(t,e,i,n)=>{let r=65535&t|0,s=t>>>16&65535|0,a=0;for(;0!==i;){a=i>2e3?2e3:i,i-=a;do{r=r+e[n++]|0,s=s+r|0}while(--a);r%=65521,s%=65521}return r|s<<16|0};const C=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var Z=(t,e,i,n)=>{const r=C,s=n+i;t^=-1;for(let i=n;i>>8^r[255&(t^e[i])];return-1^t},F={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},V={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:j,_tr_stored_block:M,_tr_flush_block:W,_tr_tally:X,_tr_align:H}=D,{Z_NO_FLUSH:K,Z_PARTIAL_FLUSH:Y,Z_FULL_FLUSH:G,Z_FINISH:J,Z_BLOCK:$,Z_OK:tt,Z_STREAM_END:et,Z_STREAM_ERROR:it,Z_DATA_ERROR:nt,Z_BUF_ERROR:rt,Z_DEFAULT_COMPRESSION:st,Z_FILTERED:at,Z_HUFFMAN_ONLY:ot,Z_RLE:ht,Z_FIXED:lt,Z_DEFAULT_STRATEGY:dt,Z_UNKNOWN:ft,Z_DEFLATED:ct}=V,ut=258,_t=262,pt=103,wt=113,bt=666,gt=(t,e)=>(t.msg=F[e],e),mt=t=>(t<<1)-(t>4?9:0),yt=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let vt=(t,e,i)=>(e<{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},xt=(t,e)=>{W(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,kt(t.strm)},Et=(t,e)=>{t.pending_buf[t.pending++]=e},At=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Ut=(t,e,i,n)=>{let r=t.avail_in;return r>n&&(r=n),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),i),1===t.state.wrap?t.adler=P(t.adler,e,r,i):2===t.state.wrap&&(t.adler=Z(t.adler,e,r,i)),t.next_in+=r,t.total_in+=r,r)},Rt=(t,e)=>{let i,n,r=t.max_chain_length,s=t.strstart,a=t.prev_length,o=t.nice_match;const h=t.strstart>t.w_size-_t?t.strstart-(t.w_size-_t):0,l=t.window,d=t.w_mask,f=t.prev,c=t.strstart+ut;let u=l[s+a-1],_=l[s+a];t.prev_length>=t.good_match&&(r>>=2),o>t.lookahead&&(o=t.lookahead);do{if(i=e,l[i+a]===_&&l[i+a-1]===u&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&sa){if(t.match_start=e,a=n,n>=o)break;u=l[s+a-1],_=l[s+a]}}}while((e=f[e&d])>h&&0!=--r);return a<=t.lookahead?a:t.lookahead},Bt=t=>{const e=t.w_size;let i,n,r,s,a;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-_t)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,i=n;do{r=t.head[--i],t.head[i]=r>=e?r-e:0}while(--n);n=e,i=n;do{r=t.prev[--i],t.prev[i]=r>=e?r-e:0}while(--n);s+=e}if(0===t.strm.avail_in)break;if(n=Ut(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=n,t.lookahead+t.insert>=3)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=vt(t,t.ins_h,t.window[a+1]);t.insert&&(t.ins_h=vt(t,t.ins_h,t.window[a+3-1]),t.prev[a&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=a,a++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<_t&&0!==t.strm.avail_in)},Ot=(t,e)=>{let i,n;for(;;){if(t.lookahead<_t){if(Bt(t),t.lookahead<_t&&e===K)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=vt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-_t&&(t.match_length=Rt(t,i)),t.match_length>=3)if(n=X(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=vt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=vt(t,t.ins_h,t.window[t.strstart+1]);else n=X(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===J?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2},Tt=(t,e)=>{let i,n,r;for(;;){if(t.lookahead<_t){if(Bt(t),t.lookahead<_t&&e===K)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=vt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,n=X(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=vt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(xt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=X(t,0,t.window[t.strstart-1]),n&&xt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=X(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===J?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2};function St(t,e,i,n,r){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=n,this.func=r}const Lt=[new St(0,0,0,0,((t,e)=>{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Bt(t),0===t.lookahead&&e===K)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,xt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-_t&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===J?(xt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(xt(t,!1),t.strm.avail_out),1)})),new St(4,4,8,4,Ot),new St(4,5,16,8,Ot),new St(4,6,32,32,Ot),new St(4,4,16,16,Tt),new St(8,16,32,32,Tt),new St(8,16,128,128,Tt),new St(8,32,128,256,Tt),new St(32,128,258,1024,Tt),new St(32,258,258,4096,Tt)];function It(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ct,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),yt(this.dyn_ltree),yt(this.dyn_dtree),yt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),yt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),yt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Nt=t=>{const e=(t=>{if(!t||!t.state)return gt(t,it);t.total_in=t.total_out=0,t.data_type=ft;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:wt,t.adler=2===e.wrap?0:1,e.last_flush=K,j(e),tt})(t);var i;return e===tt&&((i=t.state).window_size=2*i.w_size,yt(i.head),i.max_lazy_match=Lt[i.level].max_lazy,i.good_match=Lt[i.level].good_length,i.nice_match=Lt[i.level].nice_length,i.max_chain_length=Lt[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e};var zt=(t,e,i,n,r,s)=>{if(!t)return it;let a=1;if(e===st&&(e=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),r<1||r>9||i!==ct||n<8||n>15||e<0||e>9||s<0||s>lt)return gt(t,it);8===n&&(n=9);const o=new It;return t.state=o,o.strm=t,o.wrap=a,o.gzhead=null,o.w_bits=n,o.w_size=1<{let i,n;if(!t||!t.state||e>$||e<0)return t?gt(t,it):it;const r=t.state;if(!t.output||!t.input&&0!==t.avail_in||r.status===bt&&e!==J)return gt(t,0===t.avail_out?rt:it);r.strm=t;const s=r.last_flush;if(r.last_flush=e,42===r.status)if(2===r.wrap)t.adler=0,Et(r,31),Et(r,139),Et(r,8),r.gzhead?(Et(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Et(r,255&r.gzhead.time),Et(r,r.gzhead.time>>8&255),Et(r,r.gzhead.time>>16&255),Et(r,r.gzhead.time>>24&255),Et(r,9===r.level?2:r.strategy>=ot||r.level<2?4:0),Et(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Et(r,255&r.gzhead.extra.length),Et(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=Z(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(Et(r,0),Et(r,0),Et(r,0),Et(r,0),Et(r,0),Et(r,9===r.level?2:r.strategy>=ot||r.level<2?4:0),Et(r,3),r.status=wt);else{let e=ct+(r.w_bits-8<<4)<<8,i=-1;i=r.strategy>=ot||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=i<<6,0!==r.strstart&&(e|=32),e+=31-e%31,r.status=wt,At(r,e),0!==r.strstart&&(At(r,t.adler>>>16),At(r,65535&t.adler)),t.adler=1}if(69===r.status)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>i&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),kt(t),i=r.pending,r.pending!==r.pending_buf_size));)Et(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),kt(t),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindexi&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),kt(t),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindexi&&(t.adler=Z(t.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.status=pt)}else r.status=pt;if(r.status===pt&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&kt(t),r.pending+2<=r.pending_buf_size&&(Et(r,255&t.adler),Et(r,t.adler>>8&255),t.adler=0,r.status=wt)):r.status=wt),0!==r.pending){if(kt(t),0===t.avail_out)return r.last_flush=-1,tt}else if(0===t.avail_in&&mt(e)<=mt(s)&&e!==J)return gt(t,rt);if(r.status===bt&&0!==t.avail_in)return gt(t,rt);if(0!==t.avail_in||0!==r.lookahead||e!==K&&r.status!==bt){let i=r.strategy===ot?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(Bt(t),0===t.lookahead)){if(e===K)return 1;break}if(t.match_length=0,i=X(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===J?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===ht?((t,e)=>{let i,n,r,s;const a=t.window;for(;;){if(t.lookahead<=ut){if(Bt(t),t.lookahead<=ut&&e===K)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,n=a[r],n===a[++r]&&n===a[++r]&&n===a[++r])){s=t.strstart+ut;do{}while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&rt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=X(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=X(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(xt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===J?(xt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(xt(t,!1),0===t.strm.avail_out)?1:2})(r,e):Lt[r.level].func(r,e);if(3!==i&&4!==i||(r.status=bt),1===i||3===i)return 0===t.avail_out&&(r.last_flush=-1),tt;if(2===i&&(e===Y?H(r):e!==$&&(M(r,0,0,!1),e===G&&(yt(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),kt(t),0===t.avail_out))return r.last_flush=-1,tt}return e!==J?tt:r.wrap<=0?et:(2===r.wrap?(Et(r,255&t.adler),Et(r,t.adler>>8&255),Et(r,t.adler>>16&255),Et(r,t.adler>>24&255),Et(r,255&t.total_in),Et(r,t.total_in>>8&255),Et(r,t.total_in>>16&255),Et(r,t.total_in>>24&255)):(At(r,t.adler>>>16),At(r,65535&t.adler)),kt(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?tt:et)},Pt=t=>{if(!t||!t.state)return it;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==pt&&e!==wt&&e!==bt?gt(t,it):(t.state=null,e===wt?gt(t,nt):tt)};const Ct=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Zt=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Ct(i,e)&&(t[e]=i[e])}}return t},Ft=t=>{let e=0;for(let i=0,n=t.length;i=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;jt[254]=jt[254]=1;var Mt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,i,n,r,s,a=t.length,o=0;for(r=0;r>>6,e[s++]=128|63&i):i<65536?(e[s++]=224|i>>>12,e[s++]=128|i>>>6&63,e[s++]=128|63&i):(e[s++]=240|i>>>18,e[s++]=128|i>>>12&63,e[s++]=128|i>>>6&63,e[s++]=128|63&i);return e},Wt=(t,e)=>{const i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=a-1;else{for(e&=2===a?31:3===a?15:7;a>1&&n1?s[r++]=65533:e<65536?s[r++]=e:(e-=65536,s[r++]=55296|e>>10&1023,s[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Vt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+jt[t[i]]>e?i:e},Ht=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Kt=Object.prototype.toString,{Z_NO_FLUSH:Yt,Z_SYNC_FLUSH:Gt,Z_FULL_FLUSH:Jt,Z_FINISH:$t,Z_OK:qt,Z_STREAM_END:Qt,Z_DEFAULT_COMPRESSION:te,Z_DEFAULT_STRATEGY:ee,Z_DEFLATED:ie}=V;function ne(t){this.options=Zt({level:te,method:ie,chunkSize:16384,windowBits:15,memLevel:8,strategy:ee},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ht,this.strm.avail_out=0;let i=zt(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==qt)throw new Error(F[i]);if(e.header&&((t,e)=>{t&&t.state&&(2!==t.state.wrap||(t.state.gzhead=e))})(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Mt(e.dictionary):"[object ArrayBuffer]"===Kt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=((t,e)=>{let i=e.length;if(!t||!t.state)return it;const n=t.state,r=n.wrap;if(2===r||1===r&&42!==n.status||n.lookahead)return it;if(1===r&&(t.adler=P(t.adler,e,i,0)),n.wrap=0,i>=n.w_size){0===r&&(yt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(i-n.w_size,i),0),e=t,i=n.w_size}const s=t.avail_in,a=t.next_in,o=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,Bt(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=vt(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,Bt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=a,t.input=o,t.avail_in=s,n.wrap=r,tt})(this.strm,t),i!==qt)throw new Error(F[i]);this._dict_set=!0}}function re(t,e){const i=new ne(e);if(i.push(t,!0),i.err)throw i.msg||F[i.err];return i.result}ne.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?$t:Yt,"string"==typeof t?i.input=Mt(t):"[object ArrayBuffer]"===Kt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(s===Gt||s===Jt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Dt(i,s),r===Qt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Pt(this.strm),this.onEnd(r),this.ended=!0,r===qt;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},ne.prototype.onData=function(t){this.chunks.push(t)},ne.prototype.onEnd=function(t){t===qt&&(this.result=Ft(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var se={Deflate:ne,deflate:re,deflateRaw:function(t,e){return(e=e||{}).raw=!0,re(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,re(t,e)},constants:V},ae=function(t,e){let i,n,r,s,a,o,h,l,d,f,c,u,_,p,w,b,g,m,y,v,k,x,E,A;const U=t.state;i=t.next_in,E=t.input,n=i+(t.avail_in-5),r=t.next_out,A=t.output,s=r-(e-t.avail_out),a=r+(t.avail_out-257),o=U.dmax,h=U.wsize,l=U.whave,d=U.wnext,f=U.window,c=U.hold,u=U.bits,_=U.lencode,p=U.distcode,w=(1<>>24,c>>>=m,u-=m,m=g>>>16&255,0===m)A[r++]=65535&g;else{if(!(16&m)){if(0==(64&m)){g=_[(65535&g)+(c&(1<>>=m,u-=m),u<15&&(c+=E[i++]<>>24,c>>>=m,u-=m,m=g>>>16&255,!(16&m)){if(0==(64&m)){g=p[(65535&g)+(c&(1<o){t.msg="invalid distance too far back",U.mode=30;break t}if(c>>>=m,u-=m,m=r-s,v>m){if(m=v-m,m>l&&U.sane){t.msg="invalid distance too far back",U.mode=30;break t}if(k=0,x=f,0===d){if(k+=h-m,m2;)A[r++]=x[k++],A[r++]=x[k++],A[r++]=x[k++],y-=3;y&&(A[r++]=x[k++],y>1&&(A[r++]=x[k++]))}else{k=r-v;do{A[r++]=A[k++],A[r++]=A[k++],A[r++]=A[k++],y-=3}while(y>2);y&&(A[r++]=A[k++],y>1&&(A[r++]=A[k++]))}break}}break}}while(i>3,i-=y,u-=y<<3,c&=(1<{const h=o.bits;let l,d,f,c,u,_,p=0,w=0,b=0,g=0,m=0,y=0,v=0,k=0,x=0,E=0,A=null,U=0;const R=new Uint16Array(16),B=new Uint16Array(16);let O,T,S,L=null,I=0;for(p=0;p<=15;p++)R[p]=0;for(w=0;w=1&&0===R[g];g--);if(m>g&&(m=g),0===g)return r[s++]=20971520,r[s++]=20971520,o.bits=1,0;for(b=1;b0&&(0===t||1!==g))return-1;for(B[1]=0,p=1;p<15;p++)B[p+1]=B[p]+R[p];for(w=0;w852||2===t&&x>592)return 1;for(;;){O=p-v,a[w]<_?(T=0,S=a[w]):a[w]>_?(T=L[I+a[w]],S=A[U+a[w]]):(T=96,S=0),l=1<>v)+d]=O<<24|T<<16|S|0}while(0!==d);for(l=1<>=1;if(0!==l?(E&=l-1,E+=l):E=0,w++,0==--R[p]){if(p===g)break;p=e[i+a[w]]}if(p>m&&(E&c)!==f){for(0===v&&(v=m),u+=b,y=p-v,k=1<852||2===t&&x>592)return 1;f=E&c,r[f]=m<<24|y<<16|u-s|0}}return 0!==E&&(r[u+E]=p-v<<24|64<<16|0),o.bits=m,0};const{Z_FINISH:ce,Z_BLOCK:ue,Z_TREES:_e,Z_OK:pe,Z_STREAM_END:we,Z_NEED_DICT:be,Z_STREAM_ERROR:ge,Z_DATA_ERROR:me,Z_MEM_ERROR:ye,Z_BUF_ERROR:ve,Z_DEFLATED:ke}=V,xe=12,Ee=30,Ae=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Ue(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Re=t=>{if(!t||!t.state)return ge;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,(t=>{if(!t||!t.state)return ge;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,pe})(t)};let Be,Oe,Te=!0;const Se=t=>{if(Te){Be=new Int32Array(512),Oe=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(fe(1,t.lens,0,288,Be,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;fe(2,t.lens,0,32,Oe,0,t.work,{bits:5}),Te=!1}t.lencode=Be,t.lenbits=9,t.distcode=Oe,t.distbits=5},Le=(t,e,i,n)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(e.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(e.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(e.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave{if(!t)return ge;const i=new Ue;t.state=i,i.window=null;const n=((t,e)=>{let i;if(!t||!t.state)return ge;const n=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?ge:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,Re(t))})(t,e);return n!==pe&&(t.state=null),n},ze=(t,e)=>{let i,n,r,s,a,o,h,l,d,f,c,u,_,p,w,b,g,m,y,v,k,x,E=0;const A=new Uint8Array(4);let U,R;const B=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return ge;i=t.state,i.mode===xe&&(i.mode=13),a=t.next_out,r=t.output,h=t.avail_out,s=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,f=o,c=h,x=pe;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===o)break t;o--,l+=n[s++]<>>8&255,i.check=Z(i.check,A,2,0),l=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",i.mode=Ee;break}if((15&l)!==ke){t.msg="unknown compression method",i.mode=Ee;break}if(l>>>=4,d-=4,k=8+(15&l),0===i.wbits)i.wbits=k;else if(k>i.wbits){t.msg="invalid window size",i.mode=Ee;break}i.dmax=1<>8&1),512&i.flags&&(A[0]=255&l,A[1]=l>>>8&255,i.check=Z(i.check,A,2,0)),l=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,l+=n[s++]<>>8&255,A[2]=l>>>16&255,A[3]=l>>>24&255,i.check=Z(i.check,A,4,0)),l=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,l+=n[s++]<>8),512&i.flags&&(A[0]=255&l,A[1]=l>>>8&255,i.check=Z(i.check,A,2,0)),l=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===o)break t;o--,l+=n[s++]<>>8&255,i.check=Z(i.check,A,2,0)),l=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(u=i.length,u>o&&(u=o),u&&(i.head&&(k=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+u),k)),512&i.flags&&(i.check=Z(i.check,n,u,s)),o-=u,s+=u,i.length-=u),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===o)break t;u=0;do{k=n[s+u++],i.head&&k&&i.length<65536&&(i.head.name+=String.fromCharCode(k))}while(k&&u>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=xe;break;case 10:for(;d<32;){if(0===o)break t;o--,l+=n[s++]<>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===o)break t;o--,l+=n[s++]<>>=1,d-=1,3&l){case 0:i.mode=14;break;case 1:if(Se(i),i.mode=20,e===_e){l>>>=2,d-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=Ee}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,l+=n[s++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=Ee;break}if(i.length=65535&l,l=0,d=0,i.mode=15,e===_e)break t;case 15:i.mode=16;case 16:if(u=i.length,u){if(u>o&&(u=o),u>h&&(u=h),0===u)break t;r.set(n.subarray(s,s+u),a),o-=u,s+=u,h-=u,a+=u,i.length-=u;break}i.mode=xe;break;case 17:for(;d<14;){if(0===o)break t;o--,l+=n[s++]<>>=5,d-=5,i.ndist=1+(31&l),l>>>=5,d-=5,i.ncode=4+(15&l),l>>>=4,d-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=Ee;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,d-=3}for(;i.have<19;)i.lens[B[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,U={bits:i.lenbits},x=fe(0,i.lens,0,19,i.lencode,0,i.work,U),i.lenbits=U.bits,x){t.msg="invalid code lengths set",i.mode=Ee;break}i.have=0,i.mode=19;case 19:for(;i.have>>24,b=E>>>16&255,g=65535&E,!(w<=d);){if(0===o)break t;o--,l+=n[s++]<>>=w,d-=w,i.lens[i.have++]=g;else{if(16===g){for(R=w+2;d>>=w,d-=w,0===i.have){t.msg="invalid bit length repeat",i.mode=Ee;break}k=i.lens[i.have-1],u=3+(3&l),l>>>=2,d-=2}else if(17===g){for(R=w+3;d>>=w,d-=w,k=0,u=3+(7&l),l>>>=3,d-=3}else{for(R=w+7;d>>=w,d-=w,k=0,u=11+(127&l),l>>>=7,d-=7}if(i.have+u>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=Ee;break}for(;u--;)i.lens[i.have++]=k}}if(i.mode===Ee)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=Ee;break}if(i.lenbits=9,U={bits:i.lenbits},x=fe(1,i.lens,0,i.nlen,i.lencode,0,i.work,U),i.lenbits=U.bits,x){t.msg="invalid literal/lengths set",i.mode=Ee;break}if(i.distbits=6,i.distcode=i.distdyn,U={bits:i.distbits},x=fe(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,U),i.distbits=U.bits,x){t.msg="invalid distances set",i.mode=Ee;break}if(i.mode=20,e===_e)break t;case 20:i.mode=21;case 21:if(o>=6&&h>=258){t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,i.hold=l,i.bits=d,ae(t,c),a=t.next_out,r=t.output,h=t.avail_out,s=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,i.mode===xe&&(i.back=-1);break}for(i.back=0;E=i.lencode[l&(1<>>24,b=E>>>16&255,g=65535&E,!(w<=d);){if(0===o)break t;o--,l+=n[s++]<>m)],w=E>>>24,b=E>>>16&255,g=65535&E,!(m+w<=d);){if(0===o)break t;o--,l+=n[s++]<>>=m,d-=m,i.back+=m}if(l>>>=w,d-=w,i.back+=w,i.length=g,0===b){i.mode=26;break}if(32&b){i.back=-1,i.mode=xe;break}if(64&b){t.msg="invalid literal/length code",i.mode=Ee;break}i.extra=15&b,i.mode=22;case 22:if(i.extra){for(R=i.extra;d>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;E=i.distcode[l&(1<>>24,b=E>>>16&255,g=65535&E,!(w<=d);){if(0===o)break t;o--,l+=n[s++]<>m)],w=E>>>24,b=E>>>16&255,g=65535&E,!(m+w<=d);){if(0===o)break t;o--,l+=n[s++]<>>=m,d-=m,i.back+=m}if(l>>>=w,d-=w,i.back+=w,64&b){t.msg="invalid distance code",i.mode=Ee;break}i.offset=g,i.extra=15&b,i.mode=24;case 24:if(i.extra){for(R=i.extra;d>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=Ee;break}i.mode=25;case 25:if(0===h)break t;if(u=c-h,i.offset>u){if(u=i.offset-u,u>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=Ee;break}u>i.wnext?(u-=i.wnext,_=i.wsize-u):_=i.wnext-u,u>i.length&&(u=i.length),p=i.window}else p=r,_=a-i.offset,u=i.length;u>h&&(u=h),h-=u,i.length-=u;do{r[a++]=p[_++]}while(--u);0===i.length&&(i.mode=21);break;case 26:if(0===h)break t;r[a++]=i.length,h--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===o)break t;o--,l|=n[s++]<{if(!t||!t.state)return ge;let e=t.state;return e.window&&(e.window=null),t.state=null,pe},Pe=(t,e)=>{const i=e.length;let n,r,s;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?ge:11===n.mode&&(r=1,r=P(r,e,i,0),r!==n.check)?me:(s=Le(t,e,i,i),s?(n.mode=31,ye):(n.havedict=1,pe))):ge},Ce=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Ze=Object.prototype.toString,{Z_NO_FLUSH:Fe,Z_FINISH:Ve,Z_OK:je,Z_STREAM_END:Me,Z_NEED_DICT:We,Z_STREAM_ERROR:Xe,Z_DATA_ERROR:He,Z_MEM_ERROR:Ke}=V;function Ye(t){this.options=Zt({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ht,this.strm.avail_out=0;let i=Ne(this.strm,e.windowBits);if(i!==je)throw new Error(F[i]);if(this.header=new Ce,((t,e)=>{if(!t||!t.state)return ge;const i=t.state;0==(2&i.wrap)||(i.head=e,e.done=!1)})(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Mt(e.dictionary):"[object ArrayBuffer]"===Ze.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=Pe(this.strm,e.dictionary),i!==je)))throw new Error(F[i])}function Ge(t,e){const i=new Ye(e);if(i.push(t),i.err)throw i.msg||F[i.err];return i.result}Ye.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(a=e===~~e?e:!0===e?Ve:Fe,"[object ArrayBuffer]"===Ze.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=ze(i,a),s===We&&r&&(s=Pe(i,r),s===je?s=ze(i,a):s===He&&(s=We));i.avail_in>0&&s===Me&&i.state.wrap>0&&0!==t[i.next_in];)Ie(i),s=ze(i,a);switch(s){case Xe:case He:case We:case Ke:return this.onEnd(s),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||s===Me))if("string"===this.options.to){let t=Xt(i.output,i.next_out),e=i.next_out-t,r=Wt(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==je||0!==o){if(s===Me)return s=De(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Ye.prototype.onData=function(t){this.chunks.push(t)},Ye.prototype.onEnd=function(t){t===je&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ft(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Je={Inflate:Ye,inflate:Ge,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Ge(t,e)},ungzip:Ge,constants:V};const{Deflate:$e,deflate:qe,deflateRaw:Qe,gzip:ti}=se,{Inflate:ei,inflate:ii,inflateRaw:ni,ungzip:ri}=Je;var si=qe,ai=ei,oi=ii;const hi=[137,80,78,71,13,10,26,10],li=[];for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)1&e?e=3988292384^e>>>1:e>>>=1;li[t]=e}function di(t,e){return(4294967295^function(t,e,i){let n=4294967295;for(let t=0;t>>8;return n}(0,t,e))>>>0}var fi,ci,ui,_i;!function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.GREYSCALE=0]="GREYSCALE",t[t.TRUECOLOUR=2]="TRUECOLOUR",t[t.INDEXED_COLOUR=3]="INDEXED_COLOUR",t[t.GREYSCALE_ALPHA=4]="GREYSCALE_ALPHA",t[t.TRUECOLOUR_ALPHA=6]="TRUECOLOUR_ALPHA"}(fi||(fi={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.DEFLATE=0]="DEFLATE"}(ci||(ci={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.ADAPTIVE=0]="ADAPTIVE"}(ui||(ui={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.NO_INTERLACE=0]="NO_INTERLACE",t[t.ADAM7=1]="ADAM7"}(_i||(_i={}));const pi=new Uint8Array(0),wi=new Uint16Array([255]),bi=255===new Uint8Array(wi.buffer)[0];class gi extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t);const{checkCrc:i=!1}=e;this._checkCrc=i,this._inflator=new ai,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._end=!1,this._hasPalette=!1,this._palette=[],this._compressionMethod=ci.UNKNOWN,this._filterMethod=ui.UNKNOWN,this._interlaceMethod=_i.UNKNOWN,this._colorType=-1,this.setBigEndian()}decode(){for(this.decodeSignature();!this._end;)this.decodeChunk();return this.decodeImage(),this._png}decodeSignature(){for(let t=0;tthis._palette.length)throw new Error("tRNS chunk contains more alpha values than there are palette colors (".concat(t," vs ").concat(this._palette.length,")"));let e=0;for(;e>8&255;this._png.data=t}else this._png.data=r;var l}}function mi(t,e,i){for(let n=0;n>1)&255}else{for(;s>1)&255;for(;s>1)&255}}function xi(t,e,i,n,r){let s=0;if(0===i.length){for(;s1&&void 0!==arguments[1]?arguments[1]:{};super(),this._colorType=fi.UNKNOWN,this._zlibOptions=n(n({},Ai),e.zlib),this._png=this._checkData(t),this.setBigEndian()}encode(){return this.encodeSignature(),this.encodeIHDR(),this.encodeData(),this.encodeIEND(),this.toArray()}encodeSignature(){this.writeBytes(hi)}encodeIHDR(){this.writeUint32(13),this.writeChars("IHDR"),this.writeUint32(this._png.width),this.writeUint32(this._png.height),this.writeByte(this._png.depth),this.writeByte(this._colorType),this.writeByte(ci.DEFLATE),this.writeByte(ui.ADAPTIVE),this.writeByte(_i.NO_INTERLACE),this.writeCrc(17)}encodeIEND(){this.writeUint32(0),this.writeChars("IEND"),this.writeCrc(4)}encodeIDAT(t){this.writeUint32(t.length),this.writeChars("IDAT"),this.writeBytes(t),this.writeCrc(t.length+4)}encodeData(){const{width:t,height:e,channels:n,depth:r,data:s}=this._png,a=n*t,o=(new i).setBigEndian();let h=0;for(let t=0;t0)return t;throw new TypeError("".concat(e," must be a positive integer"))}function Bi(t,e,i,n){for(let r=0;rnew Ui({width:t,height:e,data:i},void 0).encode(),Li=t=>function(t,e){return new gi(t,void 0).decode()}(t)})();var tt=Q.P,et=Q.m;function it(t,e,i){if((n=t)&&n.hasOwnProperty("type")&&n.hasOwnProperty("data")){let n=it(t.data,e,i);return n.includes("\n")?" #!"+t.type+n:n+" #!"+t.type}if(t&&"object"==typeof t){let n=Array.isArray(t);if(0==Object.keys(t).length)return n?"[]":"{}";let r="\n";for(let s in t)Object.hasOwnProperty.call(t,s)&&(r+=e.repeat(i+1),n?r+="- "+it(t[s],e,i+1):s.includes(": ")?(r+=it(s,e,i+1),r+=": "+it(t[s],e,i+1)):r+=s+": "+it(t[s],e,i+1),r+="\n");return r}if("string"==typeof t)return JSON.stringify(t);if(null==t)return"null";if(!!t==t||+t==t)return JSON.stringify(t);throw new Error("Non-implemented parsing for "+t);var n}function nt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;var i="";return"number"==typeof e?i=" ".repeat(Math.min(10,e)):"string"==typeof e&&(i=e.slice(0,10)),it(t,i,-1)}class rt{constructor(t,e,i){this.startingLine=i||0,this.lineIndex=-1;let n=[];for(let e=0;e=e;)t.push(this.next());return new rt(t,this.indentString,this.getLineNumber()-t.length)}next(){if(this.finished())throw new Error("Trying to next finished generator");return this.lineIndex++,this.getLine()}peek(){return this.getLine(this.lineIndex+1)}finished(){return this.lineIndex==this.lines.length-1}getLine(t){return(t=void 0!==t?t:this.lineIndex)>=this.lines.length?null:this.lines[t][0]}findIndentString(){for(let[t]of this.lines)if(t.trim()&&t.replace(/^\s+/,"")!=t)return t.match(/^(\s+)/)[1];return""}indentLevel(t){(t=void 0!==t?t:this.lineIndex)<0&&(t=0);let e=0,i=this.getLine(t);for(;i.startsWith(this.indentString);)i=i.slice(this.indentString.length),e++;return e}}function st(t,e){let i;for(t.indentLevel();!t.finished();){let e,n,r,s=t.next().trim(),a=s.match(/^(.*?):(?: |$)/),o=s.match(/#!([\w<,>]+)/);s.startsWith('"')&&(a=s.match(/^"(.*?)":(?: |$)/)),o&&(r=o[1],s=s.replace(o[0],"")),a?(i||(i={}),e=a[1],n=s.replace(a[0],"").trim()):s.startsWith("-")&&(i||(i=[]),n=s.slice(1).trim()),n=n?at(n,r):st(t.nextGroup(),r),Array.isArray(i)?i.push(n):i[e]=n}return e&&(i={type:e,data:i}),i}function at(t,e){return t=JSON.parse(t),e&&(t={type:e,data:t}),t}function ot(t){let e=t.replace(/\t/g,"\t").split("\n");return st(new rt(e))}function ht(t){let e;if(Array.isArray(t)){e=[];for(let i of t)e.push(ht(i));return e}if(t&&"object"==typeof t){e={};for(let[i,n]of Object.entries(t))e[i]=ht(n);return e}return t}function lt(t){switch(t){case"Boolean":case"Int32":case"UInt32":case"Single":case"Double":case"Char":case"String":case"":case"Vector2":case"Vector3":case"Vector4":case"Rectangle":case"Rect":case"Point":return!0;default:return!1}}function dt(t){switch(t){case"Texture2D":case"TBin":case"Effect":case"BmFont":return!0;default:return!1}}function ft(t){if(!t||"object"!=typeof t)return t;if("object"==typeof t&&t.hasOwnProperty("data")){let{type:e,data:i}=t;if(lt(e))return ht(i);if(dt(e))return i=ht(i),"Texture2D"===e?i.export="Texture2D.png":"Effect"===e?i.export="Effect.cso":"TBin"===e?i.export="TBin.tbin":"BmFont"===e&&(i.export="BmFont.xml"),i;if(e.startsWith("Nullable"))return null===i||null===i.data?null:ft(i.data);t=ht(i)}let e;if(Array.isArray(t)){e=[];for(let i of t)e.push(ft(i));return e}if(t&&"object"==typeof t){e={};for(let[i,n]of Object.entries(t))e[i]=ft(n);return e}return null}function ct(t){const e={},{compressed:i,formatVersion:n,hidef:r,target:s}=t.header;let a=ht(t.readers);e.xnbData={target:s,compressed:!!i,hiDef:r,readerData:a,numSharedResources:0};const o=ht(t.content),l=h.simplifyType(a[0].type);let d=h.getReaderTypeList(l);"SpriteFont"===d[0]&&(d=["SpriteFont","Texture2D","List","Rectangle","List","Rectangle","List","Char",null,"List","Vector3","Nullable","Char",null],o.verticalSpacing=o.verticalLineSpacing,delete o.verticalLineSpacing);const{converted:f,extractedImages:c,extractedMaps:u}=function(t,e){let i=[],n=[];const{converted:r}=function t(r,s){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const o=e[a];if(lt(o))return{converted:{type:o,data:r},traversed:a};if(null===o)return{converted:r,traversed:a};if(o.startsWith("Nullable")){let i,n,[h,l=1]=o.split(":");if(l=+l,null===r)i=null,n=a+l;else if("object"!=typeof r||r&&0!==Object.keys(r).length){let{converted:e,traversed:o}=t(r,[...s],a+1);i=e,n=o}else i={type:e[a+1],data:ht(r)},n=a+l;return{converted:{type:h,data:{data:i}},traversed:n}}if(dt(o))return"Texture2D"===o?(i.push({path:s.join(".")}),{converted:{type:o,data:{format:r.format}},traversed:a}):("TBin"===o&&n.push({path:s.join(".")}),{converted:{type:o,data:{}},traversed:a});let h;h=Array.isArray(r)?[]:{};let l=a,d=!0,f=!o.startsWith("Dictionary")&&!o.startsWith("Array")&&!o.startsWith("List"),[c,u=1]=o.split(":");if(0===Object.keys(r).length)return{converted:{type:c,data:h},traversed:a+ +u};for(let[e,i]of Object.entries(r)){let i;i=c.startsWith("Dictionary")?a+2:c.startsWith("Array")||c.startsWith("List")?a+1:l+1;const{converted:n,traversed:o}=t(r[e],[...s,e],i);h[e]=n,f?l=o:d&&(l=o,d=!1)}return{converted:{type:c,data:h},traversed:l}}(t,[]);return{converted:r,extractedImages:i,extractedMaps:n}}(o,d);return e.content=f,c.length>0&&(e.extractedImages=c),u.length>0&&(e.extractedMaps=u),e}function ut(t){const e={},{compressed:i,readerData:n,hiDef:r,target:s}=t.xnbData;return e.header={target:s,formatVersion:5,compressed:i?"a"===s||"i"===s?64:128:0,hidef:r},e.readers=ht(n),e.content=ft(t.content),"SpriteFont"===h.simplifyType(e.readers[0].type)&&(e.content.verticalLineSpacing=e.content.verticalSpacing,delete e.content.verticalSpacing),e}function _t(t,e){if(t&&"object"==typeof t){if(t.hasOwnProperty(e))return{parent:t,value:t[e]};for(let i of Object.values(t))if(i||"object"==typeof i){let t=_t(i,e);if(t)return t}return null}}function pt(t){let e=t.match(/(.*)\.([^\s.]+)$/);return null===e?[t,null]:[e[1],e[2]]}function wt(t){switch(t){case"JSON":return"json";case"yaml":return"yaml";case"Texture2D":return"png";case"Effect":return"cso";case"TBin":return"tbin";case"BmFont":return"xml"}return"bin"}function bt(t){switch(t){case"JSON":return"application/json";case"yaml":return"text/plain";case"Texture2D":return"image/png";case"Effect":return"application/x-cso";case"BmFont":return"application/xml"}return"application/octet-stream"}function gt(t,e){return"function"==typeof Blob?{data:new Blob([t],{type:bt(e)}),extension:wt(e)}:{data:t,extension:wt(e)}}function mt(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=_t(t,"export");if(i){const{value:t}=i;let{type:e,data:n}=t;return"Texture2D"===e&&(n=et(t.width,t.height,new Uint8Array(n))),gt(n,e)}if(e){return gt(JSON.stringify(t,null,4),"JSON")}return null}function yt(t){let{yaml:e=!1,contentOnly:i=!1,fileName:n=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&i&&(e=!1),!t.hasOwnProperty("content"))throw new s("Invalid object!");const r=[],{content:a}=t,o=mt(a,i);if(null!==o&&r.push(o),i)return r;const h=JSON.stringify(t,((t,e)=>"export"===t?"string"==typeof n&&""!==n?"".concat(n,".").concat(wt(e.type)):"".concat(e.type,".").concat(wt(e.type)):e),4);let l=h;return e&&(l=nt(ct(t))),r.unshift(gt(l,e?"yaml":"JSON")),r}function vt(t){let e=t.toLowerCase();return"none"===e?0:"lz4"===e?64:null}async function kt(t){return"function"==typeof Blob&&t instanceof Blob?t.text():"function"==typeof Buffer&&t instanceof Buffer?t.toString():t}async function xt(t){return"function"==typeof Blob&&t instanceof Blob?t.arrayBuffer():"function"==typeof Buffer&&t instanceof Buffer?t.buffer:void 0}async function Et(t,e){if("png"===t){const t=await xt(e.png);let i=tt(new Uint8Array(t));return 4===i.channel&&8===i.depth&&void 0===i.palette||(i.data=G(i)),{type:"Texture2D",data:i.data,width:i.width,height:i.height}}if("cso"===t){return{type:"Effect",data:await xt(e.cso)}}if("tbin"===t){return{type:"TBin",data:await xt(e.tbin)}}if("xml"===t){return{type:"BmFont",data:await kt(e.xml)}}}async function At(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{compression:i="default"}=e,n=t.json||t.yaml;if(!n)throw new s("There is no JSON or YAML file to pack!");const r=await kt(n);let a=null;a=t.json?JSON.parse(r):ut(ot(r));let o=vt(i);if(null!==o&&(a.header.compressed=o),!a.hasOwnProperty("content"))throw new s("".concat(n.name,' does not have "content".'));const h=_t(a.content,"export");if(h){const{parent:e,value:i}=h,[,n]=pt(i);e.export=await Et(n,t)}return a}function Ut(t){const[,e]=pt(t),i=function(t){return"png"===t?"Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553":"tbin"===t?"xTile.Pipeline.TideReader, xTile":"xml"===t?"BmFont.XmlSourceReader, BmFont, Version=2012.1.7.0, Culture=neutral, PublicKeyToken=null":void 0}(e);let n={export:t};"png"===e&&(n.format=0);const r={header:{target:"w",formatVersion:5,hidef:!0,compressed:!0},readers:[{type:i,version:0}],content:n};return JSON.stringify(r)}async function Rt(t){if("undefined"!=typeof window){const[,e]=pt(t.name);if("xnb"!==e)return new Error("Invalid XNB File!");return Bt(await t.arrayBuffer())}return Bt(t.buffer)}function Bt(t){return(new K).load(t)}function Ot(t){const{content:e}=t,{data:i,extension:n}=mt(e,!0);return new M(i,n)}function Tt(t){let e={},i={};for(let n=0;n1&&void 0!==arguments[1]?arguments[1]:{};const n=Tt(t);let r=[];for(let[t,e]of Object.entries(n))r.push(At(e,i).then(St).then((e=>"function"==typeof Blob?{name:t,data:new Blob([e],{type:"application/octet-stream"})}:{name:t,data:new Uint8Array(e)})));return e(r).then((t=>!0===i.debug?t:t.filter((t=>{let{status:e,value:i}=t;return"fulfilled"===e})).map((t=>{let{value:e}=t;return e}))))},t.setEnum=function(t){return h.setEnum(t)},t.setReaders=function(t){return h.setReaders(t)},t.setSchemes=function(t){return h.setSchemes(t)},t.unpackToContent=function(t){return Rt(t).then(Ot)},t.unpackToFiles=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{yaml:i=!1,contentOnly:n=!1,fileName:r=null}=e;"undefined"!=typeof window&&null===r&&(r=t.name);let[s]=pt(r);const a=t=>yt(t,{yaml:i,contentOnly:n,fileName:s});return Rt(t).then(a)},t.unpackToXnbData=Rt,t.xnbDataToContent=Ot,t.xnbDataToFiles=yt,Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/dist/core/xnb-core.module.js b/dist/core/xnb-core.module.js index eccf2b8..cdee3a0 100644 --- a/dist/core/xnb-core.module.js +++ b/dist/core/xnb-core.module.js @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -26,17 +26,14 @@ const __promise_allSettled = Promise.allSettled !== undefined ? Promise.allSettl function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } - return keys; } - function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; @@ -46,10 +43,8 @@ function _objectSpread2(target) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } - return target; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { @@ -61,7 +56,6 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } @@ -73,13 +67,63 @@ class XnbError extends Error { this.message = message; Error.captureStackTrace(this, XnbError); } +} +class ReflectiveSchemeReader { + static isTypeOf(type) { + return false; + } + static hasSubType() { + return false; + } + static type() { + return "ReflectiveScheme"; + } + constructor(name, readers) { + this.name = name; + this.readers = readers; + } + read(buffer, resolver) { + const result = {}; + for (let [key, reader] of this.readers.entries()) { + if (reader.isValueType()) result[key] = reader.read(buffer);else if (reader.constructor.type() === "Nullable") result[key] = reader.read(buffer, resolver);else result[key] = resolver.read(buffer); + } + return result; + } + write(buffer, content, resolver) { + buffer.alloc(163518); + this.writeIndex(buffer, resolver); + for (let [key, reader] of this.readers.entries()) { + reader.write(buffer, content[key], reader.isValueType() ? null : resolver); + } + } + writeIndex(buffer, resolver) { + if (resolver != null) buffer.write7BitNumber(Number.parseInt(resolver.getIndex(this)) + 1); + } + isValueType() { + return false; + } + get type() { + const reg = /\.([^\.]+)$/; + if (reg.test(this.name)) return this.name.match(reg)[1]; + return this.name; + } + parseTypeList() { + let types = [...this.readers.values()].map(reader => { + if (reader.isValueType()) return null; + return reader.parseTypeList(); + }).flat(); + types.unshift(this.type); + return types; + } + toString() { + return "ReflectiveScheme<".concat(this.name, ">"); + } } function removeExternBracket(str) { let bracketStack = []; let result = []; - for (let i = 0; i < str.length; i++) { let c = str[i]; if (c === "[") bracketStack.push(i);else if (c === "]") { @@ -88,50 +132,59 @@ function removeExternBracket(str) { if (bracketStack.length === 0) result.push(str.slice(startPoint + 1, i)); } } - return result; } - class TypeReader { static setReaders(readers) { TypeReader.readers = _objectSpread2({}, readers); } - static addReaders(readers) { TypeReader.readers = _objectSpread2(_objectSpread2({}, TypeReader.readers), readers); } - + static setSchemes(schemes) { + TypeReader.schemes = _objectSpread2({}, schemes); + } + static addSchemes(schemes) { + TypeReader.schemes = _objectSpread2(_objectSpread2({}, TypeReader.schemes), schemes); + } + static setEnum(enumList) { + TypeReader.enumList.clear(); + enumList.forEach(id => TypeReader.enumList.add(id)); + } + static addEnum(enumList) { + enumList.forEach(id => TypeReader.enumList.add(id)); + } static makeSimplied(type, reader) { let simple = type.split(/`|,/)[0]; - if (reader.isTypeOf(simple)) { if (reader.hasSubType()) { let subtypes = TypeReader.parseSubtypes(type).map(TypeReader.simplifyType.bind(TypeReader)); return "".concat(reader.type(), "<").concat(subtypes.join(","), ">"); } else return reader.type(); } - return null; } - + static simplifyReflectiveType(subType) { + let simple = subType.split(/`|,/)[0]; + for (let reader of Object.values(TypeReader.readers)) { + if (reader.isTypeOf(simple)) return reader.type(); + } + if (TypeReader.schemes.hasOwnProperty(simple)) return "ReflectiveScheme<".concat(simple, ">"); + throw new XnbError("Non-implemented scheme found, cannot resolve scheme \"".concat(simple, "\", \"").concat(subType, "\".")); + } static simplifyType(type) { let simple = type.split(/`|,/)[0]; let isArray = simple.endsWith('[]'); - if (isArray) return "Array<".concat(simplifyType(simple.slice(0, -2)), ">"); - - if (simple === 'Microsoft.Xna.Framework.Content.ReflectiveReader') { - let reflectiveType = TypeReader.parseSubtypes(type).map(TypeReader.simplifyType.bind(TypeReader)); - return "".concat(reflectiveType); - } - + if (isArray) return "Array<".concat(TypeReader.simplifyType(simple.slice(0, -2)), ">"); + if (simple === 'Microsoft.Xna.Framework.Content.ReflectiveReader') return TypeReader.simplifyReflectiveType(TypeReader.parseSubtypes(type)[0]); for (let reader of Object.values(TypeReader.readers)) { let result = TypeReader.makeSimplied(type, reader); if (result !== null) return result; } - + if (TypeReader.schemes.hasOwnProperty(simple)) return "ReflectiveScheme<".concat(simple, ">"); + if (TypeReader.enumList.has(simple)) return "Int32"; throw new XnbError("Non-implemented type found, cannot resolve type \"".concat(simple, "\", \"").concat(type, "\".")); } - static parseSubtypes(type) { let subtype = type.slice(type.search("`") + 1); subtype[0]; @@ -139,7 +192,6 @@ class TypeReader { let matches = removeExternBracket(subtype); return matches; } - static getTypeInfo(type) { let mainType = type.match(/[^<]+/)[0]; let subtypes = type.match(/<(.+)>/); @@ -149,106 +201,137 @@ class TypeReader { subtypes }; } - static getReaderTypeList(typeString) { let reader = TypeReader.getReader(typeString); return reader.parseTypeList(); } - static getReader(typeString) { let { type, subtypes } = TypeReader.getTypeInfo(typeString); + if (type === "ReflectiveScheme") return makeReflectiveReader(subtypes[0]); subtypes = subtypes.map(TypeReader.getReader.bind(TypeReader)); if (TypeReader.readers.hasOwnProperty("".concat(type, "Reader"))) return new TypeReader.readers["".concat(type, "Reader")](...subtypes); + if (TypeReader.schemes.hasOwnProperty(type)) return makeReflectiveReader(type); throw new XnbError("Invalid reader type \"".concat(typeString, "\" passed, unable to resolve!")); } - + static getReaderClass(typeString) { + if (TypeReader.readers.hasOwnProperty(typeString)) return TypeReader.readers[typeString]; + throw new XnbError("There is no \"".concat(typeString, "\" class in reader list!")); + } static getReaderFromRaw(typeString) { const simplified = TypeReader.simplifyType(typeString); return TypeReader.getReader(simplified); } - } - _defineProperty(TypeReader, "readers", {}); +_defineProperty(TypeReader, "schemes", {}); +_defineProperty(TypeReader, "enumList", new Set()); +function makeReflectiveReader(className) { + if (!TypeReader.schemes.hasOwnProperty(className)) throw new XnbError("Unsupported scheme : ".concat(className)); + let scheme = TypeReader.schemes[className]; + if (scheme instanceof Map === false) { + scheme = convertSchemeToReader(scheme); + TypeReader.schemes[className] = scheme; + } + return new ReflectiveSchemeReader(className, scheme); +} +function convertSchemeEntryToReader(scheme) { + if (typeof scheme === "string") return TypeReader.getReader(scheme); + if (Array.isArray(scheme)) { + const ListReader = TypeReader.getReaderClass("ListReader"); + return new ListReader(convertSchemeEntryToReader(scheme[0])); + } + if (typeof scheme === "object") { + const keyCount = Object.keys(scheme).length; + if (keyCount === 1) { + const DictionaryReader = TypeReader.getReaderClass("DictionaryReader"); + const [key, value] = Object.entries(scheme)[0]; + return new DictionaryReader(convertSchemeEntryToReader(key), convertSchemeEntryToReader(value)); + } else if (keyCount > 1) { + return convertSchemeToReader(scheme); + } + } + throw new XnbError("Invalid Scheme to convert! : ".concat(scheme)); +} +function convertSchemeToReader(scheme) { + const result = new Map(); + for (let [key, type] of Object.entries(scheme)) { + let reader = convertSchemeEntryToReader(type); + if (key.startsWith("$")) { + key = key.slice(1); + try { + reader = new TypeReader.readers.NullableReader(reader); + } catch (_unused) { + throw new XnbError("There is no NullableReader from reader list!"); + } + } + result.set(key, reader); + } + return result; +} const UTF8_FIRST_BITES = [0xC0, 0xE0, 0xF0]; const UTF8_SECOND_BITES = 0x80; const UTF8_MASK = 0b111111; -const UTF16_BITES = [0xD800, 0xDC00]; -const UTF16_MASK = 0b1111111111; - +const UTF16_BITES$1 = [0xD800, 0xDC00]; +const UTF16_MASK$1 = 0b1111111111; function UTF8Encode(code) { if (code < 0x80) return [code]; if (code < 0x800) return [UTF8_FIRST_BITES[0] | code >> 6, UTF8_SECOND_BITES | code & UTF8_MASK]; if (code < 0x10000) return [UTF8_FIRST_BITES[1] | code >> 12, UTF8_SECOND_BITES | code >> 6 & UTF8_MASK, UTF8_SECOND_BITES | code & UTF8_MASK]; return [UTF8_FIRST_BITES[2] | code >> 18, UTF8_SECOND_BITES | code >> 12 & UTF8_MASK, UTF8_SECOND_BITES | code >> 6 & UTF8_MASK, UTF8_SECOND_BITES | code & UTF8_MASK]; } - function UTF16Encode(code) { if (code < 0xFFFF) return [code]; code -= 0x10000; - return [UTF16_BITES[0] | code >> 10 & UTF16_MASK, UTF16_BITES[1] | code & UTF16_MASK]; + return [UTF16_BITES$1[0] | code >> 10 & UTF16_MASK$1, UTF16_BITES$1[1] | code & UTF16_MASK$1]; } - function UTF8Decode(codeSet) { var _codeSet; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet = codeSet) !== null && _codeSet !== void 0 && _codeSet.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; if (codeSetRange === 2) return ((codeSet[0] ^ UTF8_FIRST_BITES[0]) << 6) + (codeSet[1] ^ UTF8_SECOND_BITES); - if (codeSetRange === 3) { return ((codeSet[0] ^ UTF8_FIRST_BITES[1]) << 12) + ((codeSet[1] ^ UTF8_SECOND_BITES) << 6) + (codeSet[2] ^ UTF8_SECOND_BITES); } - return ((codeSet[0] ^ UTF8_FIRST_BITES[2]) << 18) + ((codeSet[1] ^ UTF8_SECOND_BITES) << 12) + ((codeSet[2] ^ UTF8_SECOND_BITES) << 6) + (codeSet[3] ^ UTF8_SECOND_BITES); } - -function UTF16Decode(codeSet) { +function UTF16Decode$1(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; - return ((codeSet[0] & UTF16_MASK) << 10) + (codeSet[1] & UTF16_MASK) + 0x10000; + return ((codeSet[0] & UTF16_MASK$1) << 10) + (codeSet[1] & UTF16_MASK$1) + 0x10000; } - -function stringToUnicode(str) { +function stringToUnicode$1(str) { const utf16Map = Array.from({ length: str.length }, (_, i) => str.charCodeAt(i)); const result = []; let index = 0; - while (index < str.length) { let code = utf16Map[index]; - - if ((UTF16_BITES[0] & code) !== UTF16_BITES[0]) { + if ((UTF16_BITES$1[0] & code) !== UTF16_BITES$1[0]) { result.push(code); index++; } else { - result.push(UTF16Decode(utf16Map.slice(index, index + 2))); + result.push(UTF16Decode$1(utf16Map.slice(index, index + 2))); index += 2; } } - return result; } - function UTF8ToUnicode(codes) { const dataArray = codes instanceof ArrayBuffer ? new Uint8Array(codes) : codes; const result = []; let index = 0; - while (index < dataArray.length) { let headerCode = dataArray[index]; - if ((headerCode & 0x80) === 0) { result.push(headerCode); index++; @@ -263,47 +346,35 @@ function UTF8ToUnicode(codes) { index += 4; } } - return result; } - function UnicodeToUTF8(unicodeArr) { const result = []; - for (let code of unicodeArr) { result.push(...UTF8Encode(code)); } - return result; } - function UnicodeToString(unicodeArr) { const result = []; - for (let code of unicodeArr) { result.push(...UTF16Encode(code)); } - const blockSize = 32768; let resultStr = ""; - for (let i = 0; i < result.length / blockSize; i++) { resultStr += String.fromCharCode(...result.slice(i * blockSize, (i + 1) * blockSize)); } - return resultStr; } - function stringToUTF8(str) { - return UnicodeToUTF8(stringToUnicode(str)); + return UnicodeToUTF8(stringToUnicode$1(str)); } - function UTF8ToString(utf8Array) { return UnicodeToString(UTF8ToUnicode(utf8Array)); } const LITTLE_ENDIAN = true; - class BufferReader { constructor(buffer) { let endianus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LITTLE_ENDIAN; @@ -313,7 +384,6 @@ class BufferReader { this._offset = 0; this._bitOffset = 0; } - seek(index) { let origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._offset; const offset = this._offset; @@ -321,34 +391,27 @@ class BufferReader { if (this._offset < 0 || this._offset > this.buffer.length) throw new RangeError("Buffer seek out of bounds! ".concat(this._offset, " ").concat(this.buffer.length)); return this._offset - offset; } - get bytePosition() { return Number.parseInt(this._offset); } - set bytePosition(value) { this._offset = value; } - get bitPosition() { return Number.parseInt(this._bitOffset); } - set bitPosition(offset) { if (offset < 0) offset = 16 - offset; this._bitOffset = offset % 16; const byteSeek = (offset - Math.abs(offset) % 16) / 16 * 2; this.seek(byteSeek); } - get size() { return this.buffer.byteLength; } - get buffer() { return this._buffer; } - copyFrom(buffer) { let targetIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; let sourceIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; @@ -357,97 +420,73 @@ class BufferReader { const isOverflow = this.buffer.byteLength < length + targetIndex; let targetBuffer = this.buffer; let targetView = this._dataView; - if (isOverflow) { targetBuffer = new ArrayBuffer(this.buffer.byteLength + (length + targetIndex - this.buffer.byteLength)); targetView = new DataView(targetBuffer); - for (let i = 0; i < this.buffer.byteLength; i++) { targetView.setUint8(i, this._dataView.getUint8(i)); } } - for (let i = sourceIndex, j = targetIndex; i < length; i++, j++) { targetView.setUint8(j, sourceView[i]); } - if (isOverflow) { this._buffer = targetBuffer; this._dataView = targetView; } } - read(count) { const buffer = this.buffer.slice(this._offset, this._offset + count); this.seek(count); return buffer; } - readByte() { return this.readUInt(); } - readInt() { const value = this._dataView.getInt8(this._offset); - this.seek(1); return value; } - readUInt() { const value = this._dataView.getUint8(this._offset); - this.seek(1); return value; } - readUInt16() { const value = this._dataView.getUint16(this._offset, this._endianus); - this.seek(2); return value; } - readUInt32() { const value = this._dataView.getUint32(this._offset, this._endianus); - this.seek(4); return value; } - readInt16() { const value = this._dataView.getInt16(this._offset, this._endianus); - this.seek(2); return value; } - readInt32() { const value = this._dataView.getInt32(this._offset, this._endianus); - this.seek(4); return value; } - readSingle() { const value = this._dataView.getFloat32(this._offset, this._endianus); - this.seek(4); return value; } - readDouble() { - const value = this._dataView.getFloat32(this._offset, this._endianus); - + const value = this._dataView.getFloat64(this._offset, this._endianus); this.seek(8); return value; } - readString() { let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1; const chars = []; this._offset; - if (count === -1) { while (this.peekByte(1) != 0x0) chars.push(this.readByte()); } else { @@ -455,73 +494,52 @@ class BufferReader { chars.push(this.readByte()); } } - return UTF8ToString(chars); } - peek(count) { const buffer = this.read(count); this.seek(-count); return buffer; } - peekByte() { return this.peekUInt(); } - peekInt() { const value = this._dataView.getInt8(this._offset); - return value; } - peekUInt() { const value = this._dataView.getUint8(this._offset); - return value; } - peekUInt16() { const value = this._dataView.getUint16(this._offset, this._endianus); - return value; } - peekUInt32() { const value = this._dataView.getUint32(this._offset, this._endianus); - return value; } - peekInt16() { const value = this._dataView.getInt16(this._offset, this._endianus); - return value; } - peekInt32() { const value = this._dataView.getInt32(this._offset, this._endianus); - return value; } - peekSingle() { const value = this._dataView.getFloat32(this._offset, this._endianus); - return value; } - peekDouble() { const value = this._dataView.getFloat64(this._offset, this._endianus); - return value; } - peekString() { let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; const chars = []; const startOffset = this._offset; - if (count === 0) { while (this.peekByte(1) != 0x0) chars.push(this.readByte()); } else { @@ -529,32 +547,25 @@ class BufferReader { chars.push(this.readByte()); } } - this.bytePosition = startOffset; return UTF8ToString(chars); } - read7BitNumber() { let result = 0; let bitsRead = 0; let value; - do { value = this.readByte(); result |= (value & 0x7F) << bitsRead; bitsRead += 7; } while (value & 0x80); - return result; } - readLZXBits(bits) { let bitsLeft = bits; let read = 0; - while (bitsLeft > 0) { const peek = this._dataView.getUint16(this._offset, true); - const bitsInFrame = Math.min(Math.max(bitsLeft, 0), 16 - this.bitPosition); const offset = 16 - this.bitPosition - bitsInFrame; const value = (peek & 2 ** bitsInFrame - 1 << offset) >> offset; @@ -562,10 +573,8 @@ class BufferReader { this.bitPosition += bitsInFrame; read |= value << bitsLeft; } - return read; } - peekLZXBits(bits) { let bitPosition = this.bitPosition; let bytePosition = this.bytePosition; @@ -574,7 +583,6 @@ class BufferReader { this.bytePosition = bytePosition; return read; } - readLZXInt16() { let seek = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; const lsB = this.readByte(); @@ -582,11 +590,9 @@ class BufferReader { if (!seek) this.seek(-2); return lsB << 8 | msB; } - align() { if (this.bitPosition > 0) this.bitPosition += 16 - this.bitPosition; } - } class BufferWriter { @@ -596,135 +602,98 @@ class BufferWriter { this._dataView = new DataView(this._buffer); this.bytePosition = 0; } - get buffer() { return this._buffer; } - reconnectDataView() { this._dataView = new DataView(this._buffer); } - trim() { let pending = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; this._buffer = this.buffer.slice(0, this.bytePosition); if (!pending) this.reconnectDataView(); } - alloc(bytes) { if (this._buffer.byteLength <= this.bytePosition + bytes) { const tBuffer = new ArrayBuffer(this._buffer.byteLength + bytes); const tDataView = new DataView(tBuffer); - for (let i = 0; i < this.buffer.byteLength; i++) { tDataView.setUint8(i, this._dataView.getUint8(i)); } - this._buffer = tBuffer; this._dataView = tDataView; } - return this; } - concat(buffer) { const targetBufferView = new Uint8Array(buffer); const newPosition = this.bytePosition + targetBufferView.length; this.alloc(targetBufferView.length); - for (let i = this.bytePosition; i < newPosition; i++) { this._dataView.setUint8(i, targetBufferView[i - this.bytePosition]); } - this.bytePosition = newPosition; this.trim(); } - write(bytes) { const targetBufferView = new Uint8Array(bytes); const newPosition = this.bytePosition + targetBufferView.length; this.alloc(targetBufferView.length); - for (let i = this.bytePosition; i < newPosition; i++) { this._dataView.setUint8(i, targetBufferView[i - this.bytePosition]); } - this.bytePosition = newPosition; } - writeString(str) { let utf8Data = stringToUTF8(str); this.write(utf8Data); } - writeByte(byte) { this.alloc(1)._dataView.setUint8(this.bytePosition, byte); - this.bytePosition++; } - writeInt(number) { this.alloc(1)._dataView.setInt8(this.bytePosition, number); - this.bytePosition++; } - writeUInt(number) { this.alloc(1)._dataView.setUint8(this.bytePosition, number); - this.bytePosition++; } - writeInt16(number) { this.alloc(2)._dataView.setInt16(this.bytePosition, number, true); - this.bytePosition += 2; } - writeUInt16(number) { this.alloc(2)._dataView.setUint16(this.bytePosition, number, true); - this.bytePosition += 2; } - writeInt32(number) { this.alloc(4)._dataView.setInt32(this.bytePosition, number, true); - this.bytePosition += 4; } - writeUInt32(number) { this.alloc(4)._dataView.setUint32(this.bytePosition, number, true); - this.bytePosition += 4; } - writeSingle(number) { this.alloc(4)._dataView.setFloat32(this.bytePosition, number, true); - this.bytePosition += 4; } - writeDouble(number) { this.alloc(8)._dataView.setFloat64(this.bytePosition, number, true); - this.bytePosition += 8; } - write7BitNumber(number) { this.alloc(2); - do { let byte = number & 0x7F; number = number >> 7; if (number) byte |= 0x80; - this._dataView.setUint8(this.bytePosition, byte); - this.bytePosition++; } while (number); } - } /** @license @@ -784,26 +753,22 @@ const LENGTH_MAXSYMBOLS = NUM_SECONDARY_LENGTHS + 1; const LENGTH_TABLEBITS = 12; const ALIGNED_MAXSYMBOLS = ALIGNED_NUM_ELEMENTS; const ALIGNED_TABLEBITS = 7; - class Lzx { constructor(window_bits) { this.window_size = 1 << window_bits; if (window_bits < 15 || window_bits > 21) throw new XnbError('Window size out of range!'); - if (!Lzx.extra_bits.length) { for (let i = 0, j = 0; i <= 50; i += 2) { Lzx.extra_bits[i] = Lzx.extra_bits[i + 1] = j; if (i != 0 && j < 17) j++; } } - if (!Lzx.position_base.length) { for (let i = 0, j = 0; i <= 50; i++) { Lzx.position_base[i] = j; j += 1 << Lzx.extra_bits[i]; } } - const posn_slots = window_bits == 21 ? 50 : window_bits == 20 ? 42 : window_bits << 1; this.R0 = this.R1 = this.R2 = 1; this.main_elements = NUM_CHARS + (posn_slots << 3); @@ -819,36 +784,27 @@ class Lzx { this.length_len = []; this.maintree_table = []; this.maintree_len = []; - for (let i = 0; i < MAINTREE_MAXSYMBOLS; i++) this.maintree_len[i] = 0; - for (let i = 0; i < NUM_SECONDARY_LENGTHS; i++) this.length_len[i] = 0; - this.win = []; } - decompress(buffer, frame_size, block_size) { if (!this.header_read) { const intel = buffer.readLZXBits(1); if (intel != 0) throw new XnbError("Intel E8 Call found, invalid for XNB files."); this.header_read = true; } - let togo = frame_size; - while (togo > 0) { if (this.block_remaining == 0) { this.block_type = buffer.readLZXBits(3); const hi = buffer.readLZXBits(16); const lo = buffer.readLZXBits(8); this.block_remaining = hi << 8 | lo; - switch (this.block_type) { case BLOCKTYPE.ALIGNED: for (let i = 0; i < 8; i++) this.aligned_len[i] = buffer.readLZXBits(3); - this.aligned_table = this.decodeTable(ALIGNED_MAXSYMBOLS, ALIGNED_TABLEBITS, this.aligned_len); - case BLOCKTYPE.VERBATIM: this.readLengths(buffer, this.maintree_len, 0, 256); this.readLengths(buffer, this.maintree_len, 256, this.main_elements); @@ -856,55 +812,44 @@ class Lzx { this.readLengths(buffer, this.length_len, 0, NUM_SECONDARY_LENGTHS); this.length_table = this.decodeTable(LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS, this.length_len); break; - case BLOCKTYPE.UNCOMPRESSED: buffer.align(); this.R0 = buffer.readInt32(); this.R1 = buffer.readInt32(); this.R2 = buffer.readInt32(); break; - default: throw new XnbError("Invalid Blocktype Found: ".concat(this.block_type)); } } - let this_run = this.block_remaining; - while ((this_run = this.block_remaining) > 0 && togo > 0) { if (this_run > togo) this_run = togo; togo -= this_run; this.block_remaining -= this_run; this.window_posn &= this.window_size - 1; if (this.window_posn + this_run > this.window_size) throw new XnbError('Cannot run outside of window frame.'); - switch (this.block_type) { case BLOCKTYPE.ALIGNED: while (this_run > 0) { let main_element = this.readHuffSymbol(buffer, this.maintree_table, this.maintree_len, MAINTREE_MAXSYMBOLS, MAINTREE_TABLEBITS); - if (main_element < NUM_CHARS) { this.win[this.window_posn++] = main_element; this_run--; continue; } - main_element -= NUM_CHARS; let length_footer; let match_length = main_element & NUM_PRIMARY_LENGTHS; - if (match_length == NUM_PRIMARY_LENGTHS) { length_footer = this.readHuffSymbol(buffer, this.length_table, this.length_len, LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS); match_length += length_footer; } - match_length += MIN_MATCH; let match_offset = main_element >> 3; - if (match_offset > 2) { let extra = Lzx.extra_bits[match_offset]; match_offset = Lzx.position_base[match_offset] - 2; - if (extra > 3) { extra -= 3; let verbatim_bits = buffer.readLZXBits(extra); @@ -914,7 +859,6 @@ class Lzx { } else if (extra == 3) { match_offset += this.readHuffSymbol(buffer, this.aligned_table, this.aligned_len, ALIGNED_MAXSYMBOLS, ALIGNED_TABLEBITS); } else if (extra > 0) match_offset += buffer.readLZXBits(extra);else match_offset = 1; - this.R2 = this.R1; this.R1 = this.R0; this.R0 = match_offset; @@ -929,59 +873,46 @@ class Lzx { this.R2 = this.R0; this.R0 = match_offset; } - let rundest = this.window_posn; let runsrc; this_run -= match_length; if (this.window_posn >= match_offset) runsrc = rundest - match_offset;else { runsrc = rundest + (this.window_size - match_offset); let copy_length = match_offset - this.window_posn; - if (copy_length < match_length) { match_length -= copy_length; this.window_posn += copy_length; - while (copy_length-- > 0) this.win[rundest++] = this.win[runsrc++]; - runsrc = 0; } } this.window_posn += match_length; - while (match_length-- > 0) this.win[rundest++] = this.win[runsrc++]; } - break; - case BLOCKTYPE.VERBATIM: while (this_run > 0) { let main_element = this.readHuffSymbol(buffer, this.maintree_table, this.maintree_len, MAINTREE_MAXSYMBOLS, MAINTREE_TABLEBITS); - if (main_element < NUM_CHARS) { this.win[this.window_posn++] = main_element; this_run--; continue; } - main_element -= NUM_CHARS; let length_footer; let match_length = main_element & NUM_PRIMARY_LENGTHS; - if (match_length == NUM_PRIMARY_LENGTHS) { length_footer = this.readHuffSymbol(buffer, this.length_table, this.length_len, LENGTH_MAXSYMBOLS, LENGTH_TABLEBITS); match_length += length_footer; } - match_length += MIN_MATCH; let match_offset = main_element >> 3; - if (match_offset > 2) { if (match_offset != 3) { let extra = Lzx.extra_bits[match_offset]; let verbatim_bits = buffer.readLZXBits(extra); match_offset = Lzx.position_base[match_offset] - 2 + verbatim_bits; } else match_offset = 1; - this.R2 = this.R1; this.R1 = this.R0; this.R0 = match_offset; @@ -996,73 +927,55 @@ class Lzx { this.R2 = this.R0; this.R0 = match_offset; } - let rundest = this.window_posn; let runsrc; this_run -= match_length; if (this.window_posn >= match_offset) runsrc = rundest - match_offset;else { runsrc = rundest + (this.window_size - match_offset); let copy_length = match_offset - this.window_posn; - if (copy_length < match_length) { match_length -= copy_length; this.window_posn += copy_length; - while (copy_length-- > 0) this.win[rundest++] = this.win[runsrc++]; - runsrc = 0; } } this.window_posn += match_length; - while (match_length-- > 0) this.win[rundest++] = this.win[runsrc++]; } - break; - case BLOCKTYPE.UNCOMPRESSED: if (buffer.bytePosition + this_run > block_size) throw new XnbError('Overrun!' + block_size + ' ' + buffer.bytePosition + ' ' + this_run); - for (let i = 0; i < this_run; i++) this.win[window_posn + i] = buffer.buffer[buffer.bytePosition + i]; - buffer.bytePosition += this_run; this.window_posn += this_run; break; - default: throw new XnbError('Invalid blocktype specified!'); } } } - if (togo != 0) throw new XnbError('EOF reached with data left to go.'); buffer.align(); const start_window_pos = (this.window_posn == 0 ? this.window_size : this.window_posn) - frame_size; return this.win.slice(start_window_pos, start_window_pos + frame_size); } - readLengths(buffer, table, first, last) { for (let i = 0; i < 20; i++) this.pretree_len[i] = buffer.readLZXBits(4); - this.pretree_table = this.decodeTable(PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS, this.pretree_len); - for (let i = first; i < last;) { let symbol = this.readHuffSymbol(buffer, this.pretree_table, this.pretree_len, PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS); - if (symbol == 17) { let zeros = buffer.readLZXBits(4) + 4; - while (zeros-- != 0) table[i++] = 0; } else if (symbol == 18) { let zeros = buffer.readLZXBits(5) + 20; - while (zeros-- != 0) table[i++] = 0; } else if (symbol == 19) { let same = buffer.readLZXBits(1) + 4; symbol = this.readHuffSymbol(buffer, this.pretree_table, this.pretree_len, PRETREE_MAXSYMBOLS, PRETREE_TABLEBITS); symbol = table[i] - symbol; if (symbol < 0) symbol += 17; - while (same-- != 0) table[i++] = symbol; } else { symbol = table[i] - symbol; @@ -1070,77 +983,58 @@ class Lzx { table[i++] = symbol; } } - return table; } - decodeTable(symbols, bits, length) { let table = []; let pos = 0; let table_mask = 1 << bits; let bit_mask = table_mask >> 1; - for (let bit_num = 1; bit_num <= bits; bit_num++) { for (let symbol = 0; symbol < symbols; symbol++) { if (length[symbol] == bit_num) { let leaf = pos; - if ((pos += bit_mask) > table_mask) { throw new XnbError('Overrun table!'); } - let fill = bit_mask; - while (fill-- > 0) table[leaf++] = symbol; } } - bit_mask >>= 1; } - if (pos == table_mask) return table; - for (let symbol = pos; symbol < table_mask; symbol++) table[symbol] = 0xFFFF; - let next_symbol = table_mask >> 1 < symbols ? symbols : table_mask >> 1; pos <<= 16; table_mask <<= 16; bit_mask = 1 << 15; - for (let bit_num = bits + 1; bit_num <= 16; bit_num++) { for (let symbol = 0; symbol < symbols; symbol++) { if (length[symbol] != bit_num) continue; let leaf = pos >> 16; - for (let fill = 0; fill < bit_num - bits; fill++) { if (table[leaf] == 0xFFFF) { table[next_symbol << 1] = 0xFFFF; table[(next_symbol << 1) + 1] = 0xFFFF; table[leaf] = next_symbol++; } - leaf = table[leaf] << 1; if (pos >> 15 - fill & 1) leaf++; } - table[leaf] = symbol; if ((pos += bit_mask) > table_mask) throw new XnbError('Overrun table during decoding.'); } - bit_mask >>= 1; } - if (pos == table_mask) return table; throw new XnbError('Decode table did not reach table mask.'); } - readHuffSymbol(buffer, table, length, symbols, bits) { let bit = buffer.peekLZXBits(32) >>> 0; let i = table[buffer.peekLZXBits(bits)]; - if (i >= symbols) { let j = 1 << 32 - bits; - do { j >>= 1; i <<= 1; @@ -1148,11 +1042,9 @@ class Lzx { if (j == 0) return 0; } while ((i = table[i]) >= symbols); } - buffer.bitPosition += length[i]; return i; } - set RRR(X) { if (this.R0 != X && this.R1 != X && this.R2 != X) { this.R2 = this.R1; @@ -1168,9 +1060,7 @@ class Lzx { this.R0 = R2; } } - } - Lzx.position_base = []; Lzx.extra_bits = []; @@ -1181,10 +1071,8 @@ class Presser { let frame_size; const lzx = new Lzx(16); let decompressed = new BufferWriter(decompressedTodo); - while (pos < compressedTodo) { const flag = buffer.readByte(); - if (flag == 0xFF) { frame_size = buffer.readLZXInt16(); block_size = buffer.readLZXInt16(); @@ -1195,18 +1083,15 @@ class Presser { frame_size = 0x8000; pos += 2; } - if (block_size == 0 || frame_size == 0) break; if (block_size > 0x10000 || frame_size > 0x10000) throw new XnbError('Invalid size read in compression content.'); decompressed.write(lzx.decompress(buffer, frame_size, block_size)); pos += block_size; } - console.log('File has been successfully decompressed!'); decompressed.trim(); return decompressed.buffer; } - } class LZ4Utils { @@ -1219,7 +1104,6 @@ class LZ4Utils { a = a + -42973499 + (a << 3) | 0; return a ^ -1252372727 ^ a >>> 16 | 0; } - static readU64(b, n) { var x = 0; x |= b[n++] << 0; @@ -1232,7 +1116,6 @@ class LZ4Utils { x |= b[n++] << 56; return x; } - static readU32(b, n) { var x = 0; x |= b[n++] << 0; @@ -1241,14 +1124,12 @@ class LZ4Utils { x |= b[n++] << 24; return x; } - static writeU32(b, n, x) { b[n++] = x >> 0 & 0xff; b[n++] = x >> 8 & 0xff; b[n++] = x >> 16 & 0xff; b[n++] = x >> 24 & 0xff; } - static imul(a, b) { var ah = a >>> 16; var al = a & 65535; @@ -1256,12 +1137,8 @@ class LZ4Utils { var bl = b & 65535; return al * bl + (ah * bl + al * bh << 16) | 0; } - } -/** @license - * Original Code by: https://github.com/Benzinga/lz4js/ - */ const minMatch = 4; const minLength = 13; const searchLimit = 5; @@ -1273,45 +1150,36 @@ const runBits = 4; const runMask = (1 << runBits) - 1; makeBuffer(5 << 20); const hashTable = makeHashTable(); - function makeHashTable() { try { return new Uint32Array(hashSize); } catch (error) { const hashTable = new Array(hashSize); - for (var i = 0; i < hashSize; i++) { hashTable[i] = 0; } - return hashTable; } } - function clearHashTable(table) { for (var i = 0; i < hashSize; i++) { hashTable[i] = 0; } } - function makeBuffer(size) { try { return new Uint8Array(size); } catch (error) { var buf = new Array(size); - for (var i = 0; i < size; i++) { buf[i] = 0; } - return buf; } } - function compressBound(n) { return n + n / 255 + 16 | 0; } - function decompressBlock(src, dst) { let sIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; let sLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : src.length - 2 * sIndex; @@ -1319,46 +1187,36 @@ function decompressBlock(src, dst) { var mLength, mOffset, sEnd, n, i; var hasCopyWithin = dst.copyWithin !== undefined && dst.fill !== undefined; sEnd = sIndex + sLength; - while (sIndex < sEnd) { var token = src[sIndex++]; var literalCount = token >> 4; - if (literalCount > 0) { if (literalCount === 0xf) { while (true) { literalCount += src[sIndex]; - if (src[sIndex++] !== 0xff) { break; } } } - for (n = sIndex + literalCount; sIndex < n;) { dst[dIndex++] = src[sIndex++]; } } - if (sIndex >= sEnd) { break; } - mLength = token & 0xf; mOffset = src[sIndex++] | src[sIndex++] << 8; - if (mLength === 0xf) { while (true) { mLength += src[sIndex]; - if (src[sIndex++] !== 0xff) { break; } } } - mLength += minMatch; - if (hasCopyWithin && mOffset === 1) { dst.fill(dst[dIndex - 1] | 0, dIndex, dIndex + mLength); dIndex += mLength; @@ -1371,111 +1229,114 @@ function decompressBlock(src, dst) { } } } - return dIndex; } - function compressBlock(src, dst, sIndex, sLength, hashTable) { var mIndex, mAnchor, mLength, mOffset, mStep; var literalCount, dIndex, sEnd, n; dIndex = 0; sEnd = sLength + sIndex; mAnchor = sIndex; - if (sLength >= minLength) { var searchMatchCount = (1 << skipTrigger) + 3; - while (sIndex + minMatch < sEnd - searchLimit) { var seq = LZ4Utils.readU32(src, sIndex); var hash = LZ4Utils.hashU32(seq) >>> 0; hash = (hash >> 16 ^ hash) >>> 0 & 0xffff; mIndex = hashTable[hash] - 1; hashTable[hash] = sIndex + 1; - if (mIndex < 0 || sIndex - mIndex >>> 16 > 0 || LZ4Utils.readU32(src, mIndex) !== seq) { mStep = searchMatchCount++ >> skipTrigger; sIndex += mStep; continue; } - searchMatchCount = (1 << skipTrigger) + 3; literalCount = sIndex - mAnchor; mOffset = sIndex - mIndex; sIndex += minMatch; mIndex += minMatch; mLength = sIndex; - while (sIndex < sEnd - searchLimit && src[sIndex] === src[mIndex]) { sIndex++; mIndex++; } - mLength = sIndex - mLength; var token = mLength < mlMask ? mLength : mlMask; - if (literalCount >= runMask) { dst[dIndex++] = (runMask << mlBits) + token; - for (n = literalCount - runMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } else { dst[dIndex++] = (literalCount << mlBits) + token; } - for (var i = 0; i < literalCount; i++) { dst[dIndex++] = src[mAnchor + i]; } - dst[dIndex++] = mOffset; dst[dIndex++] = mOffset >> 8; - if (mLength >= mlMask) { for (n = mLength - mlMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } - mAnchor = sIndex; } } - if (mAnchor === 0) { return 0; } - literalCount = sEnd - mAnchor; - if (literalCount >= runMask) { dst[dIndex++] = runMask << mlBits; - for (n = literalCount - runMask; n >= 0xff; n -= 0xff) { dst[dIndex++] = 0xff; } - dst[dIndex++] = n; } else { dst[dIndex++] = literalCount << mlBits; } - sIndex = mAnchor; - while (sIndex < sEnd) { dst[dIndex++] = src[sIndex++]; } - return dIndex; } - function compressSingleBlock(src, dst) { clearHashTable(); return compressBlock(src, dst, 0, src.length, hashTable); } +const UTF16_BITES = [0xD800, 0xDC00]; +const UTF16_MASK = 0b1111111111; +function UTF16Decode(codeSet) { + var _codeSet2; + if (typeof codeSet === "number") codeSet = [codeSet]; + if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); + const codeSetRange = codeSet.length; + if (codeSetRange === 1) return codeSet[0]; + return ((codeSet[0] & UTF16_MASK) << 10) + (codeSet[1] & UTF16_MASK) + 0x10000; +} +function stringToUnicode(str) { + const utf16Map = Array.from({ + length: str.length + }, (_, i) => str.charCodeAt(i)); + const result = []; + let index = 0; + while (index < str.length) { + let code = utf16Map[index]; + if ((UTF16_BITES[0] & code) !== UTF16_BITES[0]) { + result.push(code); + index++; + } else { + result.push(UTF16Decode(utf16Map.slice(index, index + 2))); + index += 2; + } + } + return result; +} function UTF8Length(str) { const codes = stringToUnicode(str); return codes.reduce((sum, unicode) => { @@ -1491,36 +1352,30 @@ class StringReaderCore { let length = buffer.read7BitNumber(); return buffer.readString(length); } - write(buffer, string) { const size = UTF8Length(string); buffer.write7BitNumber(size); buffer.writeString(string); } - } class ReaderResolver { constructor(readers) { this.readers = readers; } - read(buffer) { let index = buffer.read7BitNumber() - 1; - if (this.readers[index] == null) throw new XnbError("Invalid reader index ".concat(index)); + if (this.readers[index] == null) throw new XnbError("Invalid reader index ".concat(index, " | pos: ").concat(buffer.bytePosition.toString(16))); return this.readers[index].read(buffer, this); } - write(buffer, content) { this.readers[0].write(buffer, content, this); } - getIndex(reader) { for (let i = 0, len = this.readers.length; i < len; i++) { if (reader.toString() === this.readers[i].toString()) return i; } } - } class XnbData { @@ -1540,61 +1395,44 @@ class XnbData { this.readers = readers; this.content = content; } - get target() { var _this$header; - switch ((_this$header = this.header) === null || _this$header === void 0 ? void 0 : _this$header.target) { case 'w': return "Microsoft Windows"; - case 'm': return "Windows Phone 7"; - case 'x': return "Xbox 360"; - case 'a': return "Android"; - case 'i': return "iOS"; - default: return "Unknown"; } } - get formatVersion() { var _this$header2; - switch ((_this$header2 = this.header) === null || _this$header2 === void 0 ? void 0 : _this$header2.formatVersion) { case 0x3: return "XNA Game Studio 3.0"; - case 0x4: return "XNA Game Studio 3.1"; - case 0x5: return "XNA Game Studio 4.0"; - default: return "Unknown"; } } - get hidef() { var _this$header3; - return !!((_this$header3 = this.header) !== null && _this$header3 !== void 0 && _this$header3.hidef); } - get compressed() { var _this$header4; - return !!((_this$header4 = this.header) !== null && _this$header4 !== void 0 && _this$header4.compressed); } - get contentType() { let { export: raw @@ -1602,7 +1440,6 @@ class XnbData { if (raw !== undefined) return raw.type; return "JSON"; } - get rawContent() { let { export: raw @@ -1613,7 +1450,6 @@ class XnbData { return value; }, 4); } - stringify() { return JSON.stringify({ header: this.header, @@ -1621,50 +1457,38 @@ class XnbData { content: this.content }, null, 4); } - toString() { return this.stringify(); } - } - function extensionToDatatype(extension) { switch (extension) { case "json": return "JSON"; - case "yaml": return "yaml"; - case "png": return "Texture2D"; - case "cso": return "Effect"; - case 'tbin': return "TBin"; - case 'xml': return "BmFont"; } - return "Others"; } - class XnbContent { constructor(data, ext) { this.type = extensionToDatatype(ext); this.content = data; } - } const HIDEF_MASK = 0x1; const COMPRESSED_LZ4_MASK = 0x40; const COMPRESSED_LZX_MASK = 0x80; const XNB_COMPRESSED_PROLOGUE_SIZE = 14; - class XnbConverter { constructor() { this.target = ''; @@ -1677,19 +1501,14 @@ class XnbConverter { this.readers = []; this.sharedResources = []; } - load(arrayBuffer) { this.buffer = new BufferReader(arrayBuffer); - this._validateHeader(); - console.info('XNB file validated successfully!'); this.fileSize = this.buffer.readUInt32(); if (this.buffer.size != this.fileSize) throw new XnbError('XNB file has been truncated!'); - if (this.compressed) { const decompressedSize = this.buffer.readUInt32(); - if (this.compressionType == COMPRESSED_LZX_MASK) { const compressedTodo = this.fileSize - XNB_COMPRESSED_PROLOGUE_SIZE; const decompressed = Presser.decompress(this.buffer, compressedTodo, decompressedSize); @@ -1704,22 +1523,23 @@ class XnbConverter { this.buffer.bytePosition = XNB_COMPRESSED_PROLOGUE_SIZE; } } - let count = this.buffer.read7BitNumber(); const stringReader = new StringReaderCore(); const readers = []; - for (let i = 0; i < count; i++) { const type = stringReader.read(this.buffer); const version = this.buffer.readInt32(); - const reader = TypeReader.getReaderFromRaw(type); - this.readers.push(reader); readers.push({ type, version }); } - + this.readers = readers.map(_ref => { + let { + type + } = _ref; + return TypeReader.getReaderFromRaw(type); + }); const shared = this.buffer.read7BitNumber(); if (shared != 0) throw new XnbError("Unexpected (".concat(shared, ") shared resources.")); const content = new ReaderResolver(this.readers); @@ -1732,7 +1552,6 @@ class XnbConverter { compressed: this.compressed }, readers, result); } - convert(json) { const buffer = new BufferWriter(); const stringReader = new StringReaderCore(); @@ -1754,18 +1573,15 @@ class XnbConverter { buffer.writeUInt32(0); if (lz4Compression) buffer.writeUInt32(0); buffer.write7BitNumber(json.readers.length); - for (let reader of json.readers) { this.readers.push(TypeReader.getReaderFromRaw(reader.type)); stringReader.write(buffer, reader.type); buffer.writeUInt32(reader.version); } - buffer.write7BitNumber(0); const content = new ReaderResolver(this.readers); content.write(buffer, json.content); buffer.trim(); - if (lz4Compression) { const trimmed = buffer.buffer.slice(XNB_COMPRESSED_PROLOGUE_SIZE); const trimmedArray = new Uint8Array(trimmed); @@ -1780,13 +1596,11 @@ class XnbConverter { let returnBuffer = buffer.buffer.slice(0, XNB_COMPRESSED_PROLOGUE_SIZE + compressedSize); return returnBuffer; } - let fileSize = buffer.bytePosition; buffer.bytePosition = 6; buffer.writeUInt32(fileSize, 6); return buffer.buffer; } - _validateHeader() { if (this.buffer == null) throw new XnbError('Buffer is null'); const magic = this.buffer.readString(3); @@ -1798,7 +1612,6 @@ class XnbConverter { this.compressed = flags & COMPRESSED_LZX_MASK || (flags & COMPRESSED_LZ4_MASK) != 0; this.compressionType = (flags & COMPRESSED_LZX_MASK) != 0 ? COMPRESSED_LZX_MASK : flags & COMPRESSED_LZ4_MASK ? COMPRESSED_LZ4_MASK : 0; } - } function injectRGBA(data, i) { @@ -1814,23 +1627,18 @@ function injectRGBA(data, i) { data[4 * i + 3] = a; return [r, g, b, a]; } - function png16to8(data) { const megascale = new Uint16Array(data); const downscale = new Uint8Array(megascale.length); - for (let i = 0; i < megascale.length; i++) { downscale[i] = megascale[i] >> 8; } - return downscale; } - function addChannels(data, originChannel) { const size = data.length / originChannel; const rgbaData = new Uint8Array(size * 4); if (originChannel === 4) return data; - if (originChannel === 1) { for (let i = 0; i < size; i++) { injectRGBA(rgbaData, i, { @@ -1853,16 +1661,13 @@ function addChannels(data, originChannel) { }); } } - return rgbaData; } - function applyPalette(data, depth, palette) { const oldData = new Uint8Array(data); const length = oldData.length * 8 / depth; const newData = new Uint8Array(length * 4); let bitPosition = 0; - for (let i = 0; i < length; i++) { const bytePosition = Math.floor(bitPosition / 8); const bitOffset = 8 - bitPosition % 8 - depth; @@ -1871,10 +1676,8 @@ function applyPalette(data, depth, palette) { [newData[i * 4], newData[i * 4 + 1], newData[i * 4 + 2], newData[i * 4 + 3]] = palette[paletteIndex]; bitPosition += depth; } - return newData; } - function fixPNG(pngdata) { const { width, @@ -1892,104 +1695,92 @@ function fixPNG(pngdata) { } var t = { - 396: function _() { - !function (t) { - if (t.TextEncoder && t.TextDecoder) return !1; - - function e() { - let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; - if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t, "') is invalid.")); - } - - function i() { - let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; - let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - fatal: !1 - }; - if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t, "') is invalid.")); - if (e.fatal) throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported."); - } - - Object.defineProperty(e.prototype, "encoding", { - value: "utf-8" - }), e.prototype.encode = function (t) { - let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - stream: !1 - }; - if (e.stream) throw new Error("Failed to encode: the 'stream' option is unsupported."); - let i = 0; - const n = t.length; - let r = 0, + 396: function _() { + !function (t) { + if (t.TextEncoder && t.TextDecoder) return !1; + function e() { + let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; + if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('".concat(t, "') is invalid.")); + } + function i() { + let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "utf-8"; + let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + fatal: !1 + }; + if ("utf-8" !== t) throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('".concat(t, "') is invalid.")); + if (e.fatal) throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported."); + } + Object.defineProperty(e.prototype, "encoding", { + value: "utf-8" + }), e.prototype.encode = function (t) { + let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + stream: !1 + }; + if (e.stream) throw new Error("Failed to encode: the 'stream' option is unsupported."); + let i = 0; + const n = t.length; + let r = 0, s = Math.max(32, n + (n >> 1) + 7), a = new Uint8Array(s >> 3 << 3); - - for (; i < n;) { - let e = t.charCodeAt(i++); - - if (e >= 55296 && e <= 56319) { - if (i < n) { - const n = t.charCodeAt(i); - 56320 == (64512 & n) && (++i, e = ((1023 & e) << 10) + (1023 & n) + 65536); + for (; i < n;) { + let e = t.charCodeAt(i++); + if (e >= 55296 && e <= 56319) { + if (i < n) { + const n = t.charCodeAt(i); + 56320 == (64512 & n) && (++i, e = ((1023 & e) << 10) + (1023 & n) + 65536); + } + if (e >= 55296 && e <= 56319) continue; } - - if (e >= 55296 && e <= 56319) continue; - } - - if (r + 4 > a.length) { - s += 8, s *= 1 + i / t.length * 2, s = s >> 3 << 3; - const e = new Uint8Array(s); - e.set(a), a = e; + if (r + 4 > a.length) { + s += 8, s *= 1 + i / t.length * 2, s = s >> 3 << 3; + const e = new Uint8Array(s); + e.set(a), a = e; + } + if (0 != (4294967168 & e)) { + if (0 == (4294965248 & e)) a[r++] = e >> 6 & 31 | 192;else if (0 == (4294901760 & e)) a[r++] = e >> 12 & 15 | 224, a[r++] = e >> 6 & 63 | 128;else { + if (0 != (4292870144 & e)) continue; + a[r++] = e >> 18 & 7 | 240, a[r++] = e >> 12 & 63 | 128, a[r++] = e >> 6 & 63 | 128; + } + a[r++] = 63 & e | 128; + } else a[r++] = e; } - - if (0 != (4294967168 & e)) { - if (0 == (4294965248 & e)) a[r++] = e >> 6 & 31 | 192;else if (0 == (4294901760 & e)) a[r++] = e >> 12 & 15 | 224, a[r++] = e >> 6 & 63 | 128;else { - if (0 != (4292870144 & e)) continue; - a[r++] = e >> 18 & 7 | 240, a[r++] = e >> 12 & 63 | 128, a[r++] = e >> 6 & 63 | 128; + return a.slice(0, r); + }, Object.defineProperty(i.prototype, "encoding", { + value: "utf-8" + }), Object.defineProperty(i.prototype, "fatal", { + value: !1 + }), Object.defineProperty(i.prototype, "ignoreBOM", { + value: !1 + }), i.prototype.decode = function (t) { + let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + stream: !1 + }; + if (e.stream) throw new Error("Failed to decode: the 'stream' option is unsupported."); + const i = new Uint8Array(t); + let n = 0; + const r = i.length, + s = []; + for (; n < r;) { + const t = i[n++]; + if (0 === t) break; + if (0 == (128 & t)) s.push(t);else if (192 == (224 & t)) { + const e = 63 & i[n++]; + s.push((31 & t) << 6 | e); + } else if (224 == (240 & t)) { + const e = 63 & i[n++], + r = 63 & i[n++]; + s.push((31 & t) << 12 | e << 6 | r); + } else if (240 == (248 & t)) { + let e = (7 & t) << 18 | (63 & i[n++]) << 12 | (63 & i[n++]) << 6 | 63 & i[n++]; + e > 65535 && (e -= 65536, s.push(e >>> 10 & 1023 | 55296), e = 56320 | 1023 & e), s.push(e); } - a[r++] = 63 & e | 128; - } else a[r++] = e; - } - - return a.slice(0, r); - }, Object.defineProperty(i.prototype, "encoding", { - value: "utf-8" - }), Object.defineProperty(i.prototype, "fatal", { - value: !1 - }), Object.defineProperty(i.prototype, "ignoreBOM", { - value: !1 - }), i.prototype.decode = function (t) { - let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - stream: !1 - }; - if (e.stream) throw new Error("Failed to decode: the 'stream' option is unsupported."); - const i = new Uint8Array(t); - let n = 0; - const r = i.length, - s = []; - - for (; n < r;) { - const t = i[n++]; - if (0 === t) break; - if (0 == (128 & t)) s.push(t);else if (192 == (224 & t)) { - const e = 63 & i[n++]; - s.push((31 & t) << 6 | e); - } else if (224 == (240 & t)) { - const e = 63 & i[n++], - r = 63 & i[n++]; - s.push((31 & t) << 12 | e << 6 | r); - } else if (240 == (248 & t)) { - let e = (7 & t) << 18 | (63 & i[n++]) << 12 | (63 & i[n++]) << 6 | 63 & i[n++]; - e > 65535 && (e -= 65536, s.push(e >>> 10 & 1023 | 55296), e = 56320 | 1023 & e), s.push(e); } - } - - return String.fromCharCode.apply(null, s); - }, t.TextEncoder = e, t.TextDecoder = i; - }("undefined" != typeof window ? window : "undefined" != typeof self ? self : this); - } -}, - e = {}; - + return String.fromCharCode.apply(null, s); + }, t.TextEncoder = e, t.TextDecoder = i; + }("undefined" != typeof window ? window : "undefined" != typeof self ? self : this); + } + }, + e = {}; function i(n) { var r = e[n]; if (void 0 !== r) return r.exports; @@ -1998,7 +1789,6 @@ function i(n) { }; return t[n].call(s.exports, s, s.exports, i), s.exports; } - i.d = (t, e) => { for (var n in e) i.o(e, n) && !i.o(t, n) && Object.defineProperty(t, n, { enumerable: !0, @@ -2006,15 +1796,13 @@ i.d = (t, e) => { }); }, i.o = (t, e) => Object.prototype.hasOwnProperty.call(t, e); var n = {}; - (() => { i.d(n, { P: () => Mi, m: () => Fi }), i(396); const t = new TextDecoder("utf-8"), - e = new TextEncoder(); - + e = new TextEncoder(); class r { constructor() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8192; @@ -2022,265 +1810,194 @@ var n = {}; let i = !1; "number" == typeof t ? t = new ArrayBuffer(t) : (i = !0, this.lastWrittenByte = t.byteLength); const n = e.offset ? e.offset >>> 0 : 0, - s = t.byteLength - n; + s = t.byteLength - n; let a = n; (ArrayBuffer.isView(t) || t instanceof r) && (t.byteLength !== t.buffer.byteLength && (a = t.byteOffset + n), t = t.buffer), this.lastWrittenByte = i ? s : 0, this.buffer = t, this.length = s, this.byteLength = s, this.byteOffset = a, this.offset = 0, this.littleEndian = !0, this._data = new DataView(this.buffer, a, s), this._mark = 0, this._marks = []; } - available() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return this.offset + t <= this.length; } - isLittleEndian() { return this.littleEndian; } - setLittleEndian() { return this.littleEndian = !0, this; } - isBigEndian() { return !this.littleEndian; } - setBigEndian() { return this.littleEndian = !1, this; } - skip() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return this.offset += t, this; } - seek(t) { return this.offset = t, this; } - mark() { return this._mark = this.offset, this; } - reset() { return this.offset = this._mark, this; } - pushMark() { return this._marks.push(this.offset), this; } - popMark() { const t = this._marks.pop(); - if (void 0 === t) throw new Error("Mark stack empty"); return this.seek(t), this; } - rewind() { return this.offset = 0, this; } - ensureAvailable() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - if (!this.available(t)) { const e = 2 * (this.offset + t), - i = new Uint8Array(e); + i = new Uint8Array(e); i.set(new Uint8Array(this.buffer)), this.buffer = i.buffer, this.length = this.byteLength = e, this._data = new DataView(this.buffer); } - return this; } - readBoolean() { return 0 !== this.readUint8(); } - readInt8() { return this._data.getInt8(this.offset++); } - readUint8() { return this._data.getUint8(this.offset++); } - readByte() { return this.readUint8(); } - readBytes() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; const e = new Uint8Array(t); - for (let i = 0; i < t; i++) e[i] = this.readByte(); - return e; } - readInt16() { const t = this._data.getInt16(this.offset, this.littleEndian); - return this.offset += 2, t; } - readUint16() { const t = this._data.getUint16(this.offset, this.littleEndian); - return this.offset += 2, t; } - readInt32() { const t = this._data.getInt32(this.offset, this.littleEndian); - return this.offset += 4, t; } - readUint32() { const t = this._data.getUint32(this.offset, this.littleEndian); - return this.offset += 4, t; } - readFloat32() { const t = this._data.getFloat32(this.offset, this.littleEndian); - return this.offset += 4, t; } - readFloat64() { const t = this._data.getFloat64(this.offset, this.littleEndian); - return this.offset += 8, t; } - readBigInt64() { const t = this._data.getBigInt64(this.offset, this.littleEndian); - return this.offset += 8, t; } - readBigUint64() { const t = this._data.getBigUint64(this.offset, this.littleEndian); - return this.offset += 8, t; } - readChar() { return String.fromCharCode(this.readInt8()); } - readChars() { let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; let e = ""; - for (let i = 0; i < t; i++) e += this.readChar(); - return e; } - readUtf8() { let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return i = this.readBytes(e), t.decode(i); var i; } - writeBoolean(t) { return this.writeUint8(t ? 255 : 0), this; } - writeInt8(t) { return this.ensureAvailable(1), this._data.setInt8(this.offset++, t), this._updateLastWrittenByte(), this; } - writeUint8(t) { return this.ensureAvailable(1), this._data.setUint8(this.offset++, t), this._updateLastWrittenByte(), this; } - writeByte(t) { return this.writeUint8(t); } - writeBytes(t) { this.ensureAvailable(t.length); - for (let e = 0; e < t.length; e++) this._data.setUint8(this.offset++, t[e]); - return this._updateLastWrittenByte(), this; } - writeInt16(t) { return this.ensureAvailable(2), this._data.setInt16(this.offset, t, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this; } - writeUint16(t) { return this.ensureAvailable(2), this._data.setUint16(this.offset, t, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this; } - writeInt32(t) { return this.ensureAvailable(4), this._data.setInt32(this.offset, t, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this; } - writeUint32(t) { return this.ensureAvailable(4), this._data.setUint32(this.offset, t, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this; } - writeFloat32(t) { return this.ensureAvailable(4), this._data.setFloat32(this.offset, t, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this; } - writeFloat64(t) { return this.ensureAvailable(8), this._data.setFloat64(this.offset, t, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this; } - writeBigInt64(t) { return this.ensureAvailable(8), this._data.setBigInt64(this.offset, t, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this; } - writeBigUint64(t) { return this.ensureAvailable(8), this._data.setBigUint64(this.offset, t, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this; } - writeChar(t) { return this.writeUint8(t.charCodeAt(0)); } - writeChars(t) { for (let e = 0; e < t.length; e++) this.writeUint8(t.charCodeAt(e)); - return this; } - writeUtf8(t) { return this.writeBytes(function (t) { return e.encode(t); }(t)); } - toArray() { return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte); } - _updateLastWrittenByte() { this.offset > this.lastWrittenByte && (this.lastWrittenByte = this.offset); } - } - function s(t) { let e = t.length; - for (; --e >= 0;) t[e] = 0; } - const a = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0]), - o = new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]), - h = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]), - l = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), - d = new Array(576); + o = new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]), + h = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]), + l = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), + d = new Array(576); s(d); - const _ = new Array(60); - s(_); const f = new Array(512); s(f); @@ -2289,790 +2006,640 @@ var n = {}; const u = new Array(29); s(u); const w = new Array(30); - function p(t, e, i, n, r) { this.static_tree = t, this.extra_bits = e, this.extra_base = i, this.elems = n, this.max_length = r, this.has_stree = t && t.length; } - let g, b, m; - function k(t, e) { this.dyn_tree = t, this.max_code = 0, this.stat_desc = e; } - s(w); - const y = t => t < 256 ? f[t] : f[256 + (t >>> 7)], - v = (t, e) => { - t.pending_buf[t.pending++] = 255 & e, t.pending_buf[t.pending++] = e >>> 8 & 255; - }, - E = (t, e, i) => { - t.bi_valid > 16 - i ? (t.bi_buf |= e << t.bi_valid & 65535, v(t, t.bi_buf), t.bi_buf = e >> 16 - t.bi_valid, t.bi_valid += i - 16) : (t.bi_buf |= e << t.bi_valid & 65535, t.bi_valid += i); - }, - A = (t, e, i) => { - E(t, i[2 * e], i[2 * e + 1]); - }, - x = (t, e) => { - let i = 0; - - do { - i |= 1 & t, t >>>= 1, i <<= 1; - } while (--e > 0); - - return i >>> 1; - }, - U = (t, e, i) => { - const n = new Array(16); - let r, + v = (t, e) => { + t.pending_buf[t.pending++] = 255 & e, t.pending_buf[t.pending++] = e >>> 8 & 255; + }, + E = (t, e, i) => { + t.bi_valid > 16 - i ? (t.bi_buf |= e << t.bi_valid & 65535, v(t, t.bi_buf), t.bi_buf = e >> 16 - t.bi_valid, t.bi_valid += i - 16) : (t.bi_buf |= e << t.bi_valid & 65535, t.bi_valid += i); + }, + A = (t, e, i) => { + E(t, i[2 * e], i[2 * e + 1]); + }, + x = (t, e) => { + let i = 0; + do { + i |= 1 & t, t >>>= 1, i <<= 1; + } while (--e > 0); + return i >>> 1; + }, + U = (t, e, i) => { + const n = new Array(16); + let r, s, a = 0; - - for (r = 1; r <= 15; r++) n[r] = a = a + i[r - 1] << 1; - - for (s = 0; s <= e; s++) { - let e = t[2 * s + 1]; - 0 !== e && (t[2 * s] = x(n[e]++, e)); - } - }, - z = t => { - let e; - - for (e = 0; e < 286; e++) t.dyn_ltree[2 * e] = 0; - - for (e = 0; e < 30; e++) t.dyn_dtree[2 * e] = 0; - - for (e = 0; e < 19; e++) t.bl_tree[2 * e] = 0; - - t.dyn_ltree[512] = 1, t.opt_len = t.static_len = 0, t.last_lit = t.matches = 0; - }, - R = t => { - t.bi_valid > 8 ? v(t, t.bi_buf) : t.bi_valid > 0 && (t.pending_buf[t.pending++] = t.bi_buf), t.bi_buf = 0, t.bi_valid = 0; - }, - N = (t, e, i, n) => { - const r = 2 * e, - s = 2 * i; - return t[r] < t[s] || t[r] === t[s] && n[e] <= n[i]; - }, - T = (t, e, i) => { - const n = t.heap[i]; - let r = i << 1; - - for (; r <= t.heap_len && (r < t.heap_len && N(e, t.heap[r + 1], t.heap[r], t.depth) && r++, !N(e, n, t.heap[r], t.depth));) t.heap[i] = t.heap[r], i = r, r <<= 1; - - t.heap[i] = n; - }, - O = (t, e, i) => { - let n, + for (r = 1; r <= 15; r++) n[r] = a = a + i[r - 1] << 1; + for (s = 0; s <= e; s++) { + let e = t[2 * s + 1]; + 0 !== e && (t[2 * s] = x(n[e]++, e)); + } + }, + z = t => { + let e; + for (e = 0; e < 286; e++) t.dyn_ltree[2 * e] = 0; + for (e = 0; e < 30; e++) t.dyn_dtree[2 * e] = 0; + for (e = 0; e < 19; e++) t.bl_tree[2 * e] = 0; + t.dyn_ltree[512] = 1, t.opt_len = t.static_len = 0, t.last_lit = t.matches = 0; + }, + R = t => { + t.bi_valid > 8 ? v(t, t.bi_buf) : t.bi_valid > 0 && (t.pending_buf[t.pending++] = t.bi_buf), t.bi_buf = 0, t.bi_valid = 0; + }, + N = (t, e, i, n) => { + const r = 2 * e, + s = 2 * i; + return t[r] < t[s] || t[r] === t[s] && n[e] <= n[i]; + }, + T = (t, e, i) => { + const n = t.heap[i]; + let r = i << 1; + for (; r <= t.heap_len && (r < t.heap_len && N(e, t.heap[r + 1], t.heap[r], t.depth) && r++, !N(e, n, t.heap[r], t.depth));) t.heap[i] = t.heap[r], i = r, r <<= 1; + t.heap[i] = n; + }, + O = (t, e, i) => { + let n, r, s, h, l = 0; - if (0 !== t.last_lit) do { - n = t.pending_buf[t.d_buf + 2 * l] << 8 | t.pending_buf[t.d_buf + 2 * l + 1], r = t.pending_buf[t.l_buf + l], l++, 0 === n ? A(t, r, e) : (s = c[r], A(t, s + 256 + 1, e), h = a[s], 0 !== h && (r -= u[s], E(t, r, h)), n--, s = y(n), A(t, s, i), h = o[s], 0 !== h && (n -= w[s], E(t, n, h))); - } while (l < t.last_lit); - A(t, 256, e); - }, - L = (t, e) => { - const i = e.dyn_tree, - n = e.stat_desc.static_tree, - r = e.stat_desc.has_stree, - s = e.stat_desc.elems; - let a, + if (0 !== t.last_lit) do { + n = t.pending_buf[t.d_buf + 2 * l] << 8 | t.pending_buf[t.d_buf + 2 * l + 1], r = t.pending_buf[t.l_buf + l], l++, 0 === n ? A(t, r, e) : (s = c[r], A(t, s + 256 + 1, e), h = a[s], 0 !== h && (r -= u[s], E(t, r, h)), n--, s = y(n), A(t, s, i), h = o[s], 0 !== h && (n -= w[s], E(t, n, h))); + } while (l < t.last_lit); + A(t, 256, e); + }, + L = (t, e) => { + const i = e.dyn_tree, + n = e.stat_desc.static_tree, + r = e.stat_desc.has_stree, + s = e.stat_desc.elems; + let a, o, h, l = -1; - - for (t.heap_len = 0, t.heap_max = 573, a = 0; a < s; a++) 0 !== i[2 * a] ? (t.heap[++t.heap_len] = l = a, t.depth[a] = 0) : i[2 * a + 1] = 0; - - for (; t.heap_len < 2;) h = t.heap[++t.heap_len] = l < 2 ? ++l : 0, i[2 * h] = 1, t.depth[h] = 0, t.opt_len--, r && (t.static_len -= n[2 * h + 1]); - - for (e.max_code = l, a = t.heap_len >> 1; a >= 1; a--) T(t, i, a); - - h = s; - - do { - a = t.heap[1], t.heap[1] = t.heap[t.heap_len--], T(t, i, 1), o = t.heap[1], t.heap[--t.heap_max] = a, t.heap[--t.heap_max] = o, i[2 * h] = i[2 * a] + i[2 * o], t.depth[h] = (t.depth[a] >= t.depth[o] ? t.depth[a] : t.depth[o]) + 1, i[2 * a + 1] = i[2 * o + 1] = h, t.heap[1] = h++, T(t, i, 1); - } while (t.heap_len >= 2); - - t.heap[--t.heap_max] = t.heap[1], ((t, e) => { - const i = e.dyn_tree, - n = e.max_code, - r = e.stat_desc.static_tree, - s = e.stat_desc.has_stree, - a = e.stat_desc.extra_bits, - o = e.stat_desc.extra_base, - h = e.stat_desc.max_length; - - let l, + for (t.heap_len = 0, t.heap_max = 573, a = 0; a < s; a++) 0 !== i[2 * a] ? (t.heap[++t.heap_len] = l = a, t.depth[a] = 0) : i[2 * a + 1] = 0; + for (; t.heap_len < 2;) h = t.heap[++t.heap_len] = l < 2 ? ++l : 0, i[2 * h] = 1, t.depth[h] = 0, t.opt_len--, r && (t.static_len -= n[2 * h + 1]); + for (e.max_code = l, a = t.heap_len >> 1; a >= 1; a--) T(t, i, a); + h = s; + do { + a = t.heap[1], t.heap[1] = t.heap[t.heap_len--], T(t, i, 1), o = t.heap[1], t.heap[--t.heap_max] = a, t.heap[--t.heap_max] = o, i[2 * h] = i[2 * a] + i[2 * o], t.depth[h] = (t.depth[a] >= t.depth[o] ? t.depth[a] : t.depth[o]) + 1, i[2 * a + 1] = i[2 * o + 1] = h, t.heap[1] = h++, T(t, i, 1); + } while (t.heap_len >= 2); + t.heap[--t.heap_max] = t.heap[1], ((t, e) => { + const i = e.dyn_tree, + n = e.max_code, + r = e.stat_desc.static_tree, + s = e.stat_desc.has_stree, + a = e.stat_desc.extra_bits, + o = e.stat_desc.extra_base, + h = e.stat_desc.max_length; + let l, d, _, f, c, u, w = 0; - - for (f = 0; f <= 15; f++) t.bl_count[f] = 0; - - for (i[2 * t.heap[t.heap_max] + 1] = 0, l = t.heap_max + 1; l < 573; l++) d = t.heap[l], f = i[2 * i[2 * d + 1] + 1] + 1, f > h && (f = h, w++), i[2 * d + 1] = f, d > n || (t.bl_count[f]++, c = 0, d >= o && (c = a[d - o]), u = i[2 * d], t.opt_len += u * (f + c), s && (t.static_len += u * (r[2 * d + 1] + c))); - - if (0 !== w) { - do { - for (f = h - 1; 0 === t.bl_count[f];) f--; - - t.bl_count[f]--, t.bl_count[f + 1] += 2, t.bl_count[h]--, w -= 2; - } while (w > 0); - - for (f = h; 0 !== f; f--) for (d = t.bl_count[f]; 0 !== d;) _ = t.heap[--l], _ > n || (i[2 * _ + 1] !== f && (t.opt_len += (f - i[2 * _ + 1]) * i[2 * _], i[2 * _ + 1] = f), d--); - } - })(t, e), U(i, l, t.bl_count); - }, - B = (t, e, i) => { - let n, + for (f = 0; f <= 15; f++) t.bl_count[f] = 0; + for (i[2 * t.heap[t.heap_max] + 1] = 0, l = t.heap_max + 1; l < 573; l++) d = t.heap[l], f = i[2 * i[2 * d + 1] + 1] + 1, f > h && (f = h, w++), i[2 * d + 1] = f, d > n || (t.bl_count[f]++, c = 0, d >= o && (c = a[d - o]), u = i[2 * d], t.opt_len += u * (f + c), s && (t.static_len += u * (r[2 * d + 1] + c))); + if (0 !== w) { + do { + for (f = h - 1; 0 === t.bl_count[f];) f--; + t.bl_count[f]--, t.bl_count[f + 1] += 2, t.bl_count[h]--, w -= 2; + } while (w > 0); + for (f = h; 0 !== f; f--) for (d = t.bl_count[f]; 0 !== d;) _ = t.heap[--l], _ > n || (i[2 * _ + 1] !== f && (t.opt_len += (f - i[2 * _ + 1]) * i[2 * _], i[2 * _ + 1] = f), d--); + } + })(t, e), U(i, l, t.bl_count); + }, + B = (t, e, i) => { + let n, r, s = -1, a = e[1], o = 0, h = 7, l = 4; - - for (0 === a && (h = 138, l = 3), e[2 * (i + 1) + 1] = 65535, n = 0; n <= i; n++) r = a, a = e[2 * (n + 1) + 1], ++o < h && r === a || (o < l ? t.bl_tree[2 * r] += o : 0 !== r ? (r !== s && t.bl_tree[2 * r]++, t.bl_tree[32]++) : o <= 10 ? t.bl_tree[34]++ : t.bl_tree[36]++, o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4)); - }, - C = (t, e, i) => { - let n, + for (0 === a && (h = 138, l = 3), e[2 * (i + 1) + 1] = 65535, n = 0; n <= i; n++) r = a, a = e[2 * (n + 1) + 1], ++o < h && r === a || (o < l ? t.bl_tree[2 * r] += o : 0 !== r ? (r !== s && t.bl_tree[2 * r]++, t.bl_tree[32]++) : o <= 10 ? t.bl_tree[34]++ : t.bl_tree[36]++, o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4)); + }, + C = (t, e, i) => { + let n, r, s = -1, a = e[1], o = 0, h = 7, l = 4; - - for (0 === a && (h = 138, l = 3), n = 0; n <= i; n++) if (r = a, a = e[2 * (n + 1) + 1], !(++o < h && r === a)) { - if (o < l) do { - A(t, r, t.bl_tree); - } while (0 != --o);else 0 !== r ? (r !== s && (A(t, r, t.bl_tree), o--), A(t, 16, t.bl_tree), E(t, o - 3, 2)) : o <= 10 ? (A(t, 17, t.bl_tree), E(t, o - 3, 3)) : (A(t, 18, t.bl_tree), E(t, o - 11, 7)); - o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4); - } - }; - + for (0 === a && (h = 138, l = 3), n = 0; n <= i; n++) if (r = a, a = e[2 * (n + 1) + 1], !(++o < h && r === a)) { + if (o < l) do { + A(t, r, t.bl_tree); + } while (0 != --o);else 0 !== r ? (r !== s && (A(t, r, t.bl_tree), o--), A(t, 16, t.bl_tree), E(t, o - 3, 2)) : o <= 10 ? (A(t, 17, t.bl_tree), E(t, o - 3, 3)) : (A(t, 18, t.bl_tree), E(t, o - 11, 7)); + o = 0, s = r, 0 === a ? (h = 138, l = 3) : r === a ? (h = 6, l = 3) : (h = 7, l = 4); + } + }; let D = !1; - const I = (t, e, i, n) => { E(t, 0 + (n ? 1 : 0), 3), ((t, e, i, n) => { R(t), v(t, i), v(t, ~i), t.pending_buf.set(t.window.subarray(e, e + i), t.pending), t.pending += i; })(t, e, i); }; - var S = { - _tr_init: t => { - D || ((() => { - let t, e, i, n, r; - const s = new Array(16); - - for (i = 0, n = 0; n < 28; n++) for (u[n] = i, t = 0; t < 1 << a[n]; t++) c[i++] = n; - - for (c[i - 1] = n, r = 0, n = 0; n < 16; n++) for (w[n] = r, t = 0; t < 1 << o[n]; t++) f[r++] = n; - - for (r >>= 7; n < 30; n++) for (w[n] = r << 7, t = 0; t < 1 << o[n] - 7; t++) f[256 + r++] = n; - - for (e = 0; e <= 15; e++) s[e] = 0; - - for (t = 0; t <= 143;) d[2 * t + 1] = 8, t++, s[8]++; - - for (; t <= 255;) d[2 * t + 1] = 9, t++, s[9]++; - - for (; t <= 279;) d[2 * t + 1] = 7, t++, s[7]++; - - for (; t <= 287;) d[2 * t + 1] = 8, t++, s[8]++; - - for (U(d, 287, s), t = 0; t < 30; t++) _[2 * t + 1] = 5, _[2 * t] = x(t, 5); - - g = new p(d, a, 257, 286, 15), b = new p(_, o, 0, 30, 15), m = new p(new Array(0), h, 0, 19, 7); - })(), D = !0), t.l_desc = new k(t.dyn_ltree, g), t.d_desc = new k(t.dyn_dtree, b), t.bl_desc = new k(t.bl_tree, m), t.bi_buf = 0, t.bi_valid = 0, z(t); - }, - _tr_stored_block: I, - _tr_flush_block: (t, e, i, n) => { - let r, + _tr_init: t => { + D || ((() => { + let t, e, i, n, r; + const s = new Array(16); + for (i = 0, n = 0; n < 28; n++) for (u[n] = i, t = 0; t < 1 << a[n]; t++) c[i++] = n; + for (c[i - 1] = n, r = 0, n = 0; n < 16; n++) for (w[n] = r, t = 0; t < 1 << o[n]; t++) f[r++] = n; + for (r >>= 7; n < 30; n++) for (w[n] = r << 7, t = 0; t < 1 << o[n] - 7; t++) f[256 + r++] = n; + for (e = 0; e <= 15; e++) s[e] = 0; + for (t = 0; t <= 143;) d[2 * t + 1] = 8, t++, s[8]++; + for (; t <= 255;) d[2 * t + 1] = 9, t++, s[9]++; + for (; t <= 279;) d[2 * t + 1] = 7, t++, s[7]++; + for (; t <= 287;) d[2 * t + 1] = 8, t++, s[8]++; + for (U(d, 287, s), t = 0; t < 30; t++) _[2 * t + 1] = 5, _[2 * t] = x(t, 5); + g = new p(d, a, 257, 286, 15), b = new p(_, o, 0, 30, 15), m = new p(new Array(0), h, 0, 19, 7); + })(), D = !0), t.l_desc = new k(t.dyn_ltree, g), t.d_desc = new k(t.dyn_dtree, b), t.bl_desc = new k(t.bl_tree, m), t.bi_buf = 0, t.bi_valid = 0, z(t); + }, + _tr_stored_block: I, + _tr_flush_block: (t, e, i, n) => { + let r, s, a = 0; - t.level > 0 ? (2 === t.strm.data_type && (t.strm.data_type = (t => { - let e, + t.level > 0 ? (2 === t.strm.data_type && (t.strm.data_type = (t => { + let e, i = 4093624447; - - for (e = 0; e <= 31; e++, i >>>= 1) if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; - - if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return 1; - - for (e = 32; e < 256; e++) if (0 !== t.dyn_ltree[2 * e]) return 1; - - return 0; - })(t)), L(t, t.l_desc), L(t, t.d_desc), a = (t => { - let e; - - for (B(t, t.dyn_ltree, t.l_desc.max_code), B(t, t.dyn_dtree, t.d_desc.max_code), L(t, t.bl_desc), e = 18; e >= 3 && 0 === t.bl_tree[2 * l[e] + 1]; e--); - - return t.opt_len += 3 * (e + 1) + 5 + 5 + 4, e; - })(t), r = t.opt_len + 3 + 7 >>> 3, s = t.static_len + 3 + 7 >>> 3, s <= r && (r = s)) : r = s = i + 5, i + 4 <= r && -1 !== e ? I(t, e, i, n) : 4 === t.strategy || s === r ? (E(t, 2 + (n ? 1 : 0), 3), O(t, d, _)) : (E(t, 4 + (n ? 1 : 0), 3), ((t, e, i, n) => { - let r; - - for (E(t, e - 257, 5), E(t, i - 1, 5), E(t, n - 4, 4), r = 0; r < n; r++) E(t, t.bl_tree[2 * l[r] + 1], 3); - - C(t, t.dyn_ltree, e - 1), C(t, t.dyn_dtree, i - 1); - })(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, a + 1), O(t, t.dyn_ltree, t.dyn_dtree)), z(t), n && R(t); + for (e = 0; e <= 31; e++, i >>>= 1) if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; + if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return 1; + for (e = 32; e < 256; e++) if (0 !== t.dyn_ltree[2 * e]) return 1; + return 0; + })(t)), L(t, t.l_desc), L(t, t.d_desc), a = (t => { + let e; + for (B(t, t.dyn_ltree, t.l_desc.max_code), B(t, t.dyn_dtree, t.d_desc.max_code), L(t, t.bl_desc), e = 18; e >= 3 && 0 === t.bl_tree[2 * l[e] + 1]; e--); + return t.opt_len += 3 * (e + 1) + 5 + 5 + 4, e; + })(t), r = t.opt_len + 3 + 7 >>> 3, s = t.static_len + 3 + 7 >>> 3, s <= r && (r = s)) : r = s = i + 5, i + 4 <= r && -1 !== e ? I(t, e, i, n) : 4 === t.strategy || s === r ? (E(t, 2 + (n ? 1 : 0), 3), O(t, d, _)) : (E(t, 4 + (n ? 1 : 0), 3), ((t, e, i, n) => { + let r; + for (E(t, e - 257, 5), E(t, i - 1, 5), E(t, n - 4, 4), r = 0; r < n; r++) E(t, t.bl_tree[2 * l[r] + 1], 3); + C(t, t.dyn_ltree, e - 1), C(t, t.dyn_dtree, i - 1); + })(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, a + 1), O(t, t.dyn_ltree, t.dyn_dtree)), z(t), n && R(t); + }, + _tr_tally: (t, e, i) => (t.pending_buf[t.d_buf + 2 * t.last_lit] = e >>> 8 & 255, t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e, t.pending_buf[t.l_buf + t.last_lit] = 255 & i, t.last_lit++, 0 === e ? t.dyn_ltree[2 * i]++ : (t.matches++, e--, t.dyn_ltree[2 * (c[i] + 256 + 1)]++, t.dyn_dtree[2 * y(e)]++), t.last_lit === t.lit_bufsize - 1), + _tr_align: t => { + E(t, 2, 3), A(t, 256, d), (t => { + 16 === t.bi_valid ? (v(t, t.bi_buf), t.bi_buf = 0, t.bi_valid = 0) : t.bi_valid >= 8 && (t.pending_buf[t.pending++] = 255 & t.bi_buf, t.bi_buf >>= 8, t.bi_valid -= 8); + })(t); + } }, - _tr_tally: (t, e, i) => (t.pending_buf[t.d_buf + 2 * t.last_lit] = e >>> 8 & 255, t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e, t.pending_buf[t.l_buf + t.last_lit] = 255 & i, t.last_lit++, 0 === e ? t.dyn_ltree[2 * i]++ : (t.matches++, e--, t.dyn_ltree[2 * (c[i] + 256 + 1)]++, t.dyn_dtree[2 * y(e)]++), t.last_lit === t.lit_bufsize - 1), - _tr_align: t => { - E(t, 2, 3), A(t, 256, d), (t => { - 16 === t.bi_valid ? (v(t, t.bi_buf), t.bi_buf = 0, t.bi_valid = 0) : t.bi_valid >= 8 && (t.pending_buf[t.pending++] = 255 & t.bi_buf, t.bi_buf >>= 8, t.bi_valid -= 8); - })(t); - } - }, - Z = (t, e, i, n) => { - let r = 65535 & t | 0, + Z = (t, e, i, n) => { + let r = 65535 & t | 0, s = t >>> 16 & 65535 | 0, a = 0; - - for (; 0 !== i;) { - a = i > 2e3 ? 2e3 : i, i -= a; - - do { - r = r + e[n++] | 0, s = s + r | 0; - } while (--a); - - r %= 65521, s %= 65521; - } - - return r | s << 16 | 0; - }; - + for (; 0 !== i;) { + a = i > 2e3 ? 2e3 : i, i -= a; + do { + r = r + e[n++] | 0, s = s + r | 0; + } while (--a); + r %= 65521, s %= 65521; + } + return r | s << 16 | 0; + }; const F = new Uint32Array((() => { let t, - e = []; - + e = []; for (var i = 0; i < 256; i++) { t = i; - for (var n = 0; n < 8; n++) t = 1 & t ? 3988292384 ^ t >>> 1 : t >>> 1; - e[i] = t; } - return e; })()); - var M = (t, e, i, n) => { - const r = F, - s = n + i; - t ^= -1; - - for (let i = n; i < s; i++) t = t >>> 8 ^ r[255 & (t ^ e[i])]; - - return -1 ^ t; - }, - P = { - 2: "need dictionary", - 1: "stream end", - 0: "", - "-1": "file error", - "-2": "stream error", - "-3": "data error", - "-4": "insufficient memory", - "-5": "buffer error", - "-6": "incompatible version" - }, - H = { - Z_NO_FLUSH: 0, - Z_PARTIAL_FLUSH: 1, - Z_SYNC_FLUSH: 2, - Z_FULL_FLUSH: 3, - Z_FINISH: 4, - Z_BLOCK: 5, - Z_TREES: 6, - Z_OK: 0, - Z_STREAM_END: 1, - Z_NEED_DICT: 2, - Z_ERRNO: -1, - Z_STREAM_ERROR: -2, - Z_DATA_ERROR: -3, - Z_MEM_ERROR: -4, - Z_BUF_ERROR: -5, - Z_NO_COMPRESSION: 0, - Z_BEST_SPEED: 1, - Z_BEST_COMPRESSION: 9, - Z_DEFAULT_COMPRESSION: -1, - Z_FILTERED: 1, - Z_HUFFMAN_ONLY: 2, - Z_RLE: 3, - Z_FIXED: 4, - Z_DEFAULT_STRATEGY: 0, - Z_BINARY: 0, - Z_TEXT: 1, - Z_UNKNOWN: 2, - Z_DEFLATED: 8 - }; - + const r = F, + s = n + i; + t ^= -1; + for (let i = n; i < s; i++) t = t >>> 8 ^ r[255 & (t ^ e[i])]; + return -1 ^ t; + }, + P = { + 2: "need dictionary", + 1: "stream end", + 0: "", + "-1": "file error", + "-2": "stream error", + "-3": "data error", + "-4": "insufficient memory", + "-5": "buffer error", + "-6": "incompatible version" + }, + H = { + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + Z_BINARY: 0, + Z_TEXT: 1, + Z_UNKNOWN: 2, + Z_DEFLATED: 8 + }; const { - _tr_init: W, - _tr_stored_block: K, - _tr_flush_block: $, - _tr_tally: Y, - _tr_align: j - } = S, - { - Z_NO_FLUSH: G, - Z_PARTIAL_FLUSH: X, - Z_FULL_FLUSH: V, - Z_FINISH: q, - Z_BLOCK: J, - Z_OK: Q, - Z_STREAM_END: tt, - Z_STREAM_ERROR: et, - Z_DATA_ERROR: it, - Z_BUF_ERROR: nt, - Z_DEFAULT_COMPRESSION: rt, - Z_FILTERED: st, - Z_HUFFMAN_ONLY: at, - Z_RLE: ot, - Z_FIXED: ht, - Z_DEFAULT_STRATEGY: lt, - Z_UNKNOWN: dt, - Z_DEFLATED: _t - } = H, - ft = 258, - ct = 262, - ut = 103, - wt = 113, - pt = 666, - gt = (t, e) => (t.msg = P[e], e), - bt = t => (t << 1) - (t > 4 ? 9 : 0), - mt = t => { - let e = t.length; - - for (; --e >= 0;) t[e] = 0; - }; - + _tr_init: W, + _tr_stored_block: K, + _tr_flush_block: $, + _tr_tally: Y, + _tr_align: j + } = S, + { + Z_NO_FLUSH: G, + Z_PARTIAL_FLUSH: X, + Z_FULL_FLUSH: V, + Z_FINISH: q, + Z_BLOCK: J, + Z_OK: Q, + Z_STREAM_END: tt, + Z_STREAM_ERROR: et, + Z_DATA_ERROR: it, + Z_BUF_ERROR: nt, + Z_DEFAULT_COMPRESSION: rt, + Z_FILTERED: st, + Z_HUFFMAN_ONLY: at, + Z_RLE: ot, + Z_FIXED: ht, + Z_DEFAULT_STRATEGY: lt, + Z_UNKNOWN: dt, + Z_DEFLATED: _t + } = H, + ft = 258, + ct = 262, + ut = 103, + wt = 113, + pt = 666, + gt = (t, e) => (t.msg = P[e], e), + bt = t => (t << 1) - (t > 4 ? 9 : 0), + mt = t => { + let e = t.length; + for (; --e >= 0;) t[e] = 0; + }; let kt = (t, e, i) => (e << t.hash_shift ^ i) & t.hash_mask; - const yt = t => { - const e = t.state; - let i = e.pending; - i > t.avail_out && (i = t.avail_out), 0 !== i && (t.output.set(e.pending_buf.subarray(e.pending_out, e.pending_out + i), t.next_out), t.next_out += i, e.pending_out += i, t.total_out += i, t.avail_out -= i, e.pending -= i, 0 === e.pending && (e.pending_out = 0)); - }, - vt = (t, e) => { - $(t, t.block_start >= 0 ? t.block_start : -1, t.strstart - t.block_start, e), t.block_start = t.strstart, yt(t.strm); - }, - Et = (t, e) => { - t.pending_buf[t.pending++] = e; - }, - At = (t, e) => { - t.pending_buf[t.pending++] = e >>> 8 & 255, t.pending_buf[t.pending++] = 255 & e; - }, - xt = (t, e, i, n) => { - let r = t.avail_in; - return r > n && (r = n), 0 === r ? 0 : (t.avail_in -= r, e.set(t.input.subarray(t.next_in, t.next_in + r), i), 1 === t.state.wrap ? t.adler = Z(t.adler, e, r, i) : 2 === t.state.wrap && (t.adler = M(t.adler, e, r, i)), t.next_in += r, t.total_in += r, r); - }, - Ut = (t, e) => { - let i, + const e = t.state; + let i = e.pending; + i > t.avail_out && (i = t.avail_out), 0 !== i && (t.output.set(e.pending_buf.subarray(e.pending_out, e.pending_out + i), t.next_out), t.next_out += i, e.pending_out += i, t.total_out += i, t.avail_out -= i, e.pending -= i, 0 === e.pending && (e.pending_out = 0)); + }, + vt = (t, e) => { + $(t, t.block_start >= 0 ? t.block_start : -1, t.strstart - t.block_start, e), t.block_start = t.strstart, yt(t.strm); + }, + Et = (t, e) => { + t.pending_buf[t.pending++] = e; + }, + At = (t, e) => { + t.pending_buf[t.pending++] = e >>> 8 & 255, t.pending_buf[t.pending++] = 255 & e; + }, + xt = (t, e, i, n) => { + let r = t.avail_in; + return r > n && (r = n), 0 === r ? 0 : (t.avail_in -= r, e.set(t.input.subarray(t.next_in, t.next_in + r), i), 1 === t.state.wrap ? t.adler = Z(t.adler, e, r, i) : 2 === t.state.wrap && (t.adler = M(t.adler, e, r, i)), t.next_in += r, t.total_in += r, r); + }, + Ut = (t, e) => { + let i, n, r = t.max_chain_length, s = t.strstart, a = t.prev_length, o = t.nice_match; - const h = t.strstart > t.w_size - ct ? t.strstart - (t.w_size - ct) : 0, - l = t.window, - d = t.w_mask, - _ = t.prev, - f = t.strstart + ft; - let c = l[s + a - 1], + const h = t.strstart > t.w_size - ct ? t.strstart - (t.w_size - ct) : 0, + l = t.window, + d = t.w_mask, + _ = t.prev, + f = t.strstart + ft; + let c = l[s + a - 1], u = l[s + a]; - t.prev_length >= t.good_match && (r >>= 2), o > t.lookahead && (o = t.lookahead); - - do { - if (i = e, l[i + a] === u && l[i + a - 1] === c && l[i] === l[s] && l[++i] === l[s + 1]) { - s += 2, i++; - - do {} while (l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && s < f); - - if (n = ft - (f - s), s = f - ft, n > a) { - if (t.match_start = e, a = n, n >= o) break; - c = l[s + a - 1], u = l[s + a]; + t.prev_length >= t.good_match && (r >>= 2), o > t.lookahead && (o = t.lookahead); + do { + if (i = e, l[i + a] === u && l[i + a - 1] === c && l[i] === l[s] && l[++i] === l[s + 1]) { + s += 2, i++; + do {} while (l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && l[++s] === l[++i] && s < f); + if (n = ft - (f - s), s = f - ft, n > a) { + if (t.match_start = e, a = n, n >= o) break; + c = l[s + a - 1], u = l[s + a]; + } } + } while ((e = _[e & d]) > h && 0 != --r); + return a <= t.lookahead ? a : t.lookahead; + }, + zt = t => { + const e = t.w_size; + let i, n, r, s, a; + do { + if (s = t.window_size - t.lookahead - t.strstart, t.strstart >= e + (e - ct)) { + t.window.set(t.window.subarray(e, e + e), 0), t.match_start -= e, t.strstart -= e, t.block_start -= e, n = t.hash_size, i = n; + do { + r = t.head[--i], t.head[i] = r >= e ? r - e : 0; + } while (--n); + n = e, i = n; + do { + r = t.prev[--i], t.prev[i] = r >= e ? r - e : 0; + } while (--n); + s += e; + } + if (0 === t.strm.avail_in) break; + if (n = xt(t.strm, t.window, t.strstart + t.lookahead, s), t.lookahead += n, t.lookahead + t.insert >= 3) for (a = t.strstart - t.insert, t.ins_h = t.window[a], t.ins_h = kt(t, t.ins_h, t.window[a + 1]); t.insert && (t.ins_h = kt(t, t.ins_h, t.window[a + 3 - 1]), t.prev[a & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = a, a++, t.insert--, !(t.lookahead + t.insert < 3));); + } while (t.lookahead < ct && 0 !== t.strm.avail_in); + }, + Rt = (t, e) => { + let i, n; + for (;;) { + if (t.lookahead < ct) { + if (zt(t), t.lookahead < ct && e === G) return 1; + if (0 === t.lookahead) break; + } + if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 !== i && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i)), t.match_length >= 3) { + if (n = Y(t, t.strstart - t.match_start, t.match_length - 3), t.lookahead -= t.match_length, t.match_length <= t.max_lazy_match && t.lookahead >= 3) { + t.match_length--; + do { + t.strstart++, t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart; + } while (0 != --t.match_length); + t.strstart++; + } else t.strstart += t.match_length, t.match_length = 0, t.ins_h = t.window[t.strstart], t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 1]); + } else n = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++; + if (n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - } while ((e = _[e & d]) > h && 0 != --r); - - return a <= t.lookahead ? a : t.lookahead; - }, - zt = t => { - const e = t.w_size; - let i, n, r, s, a; - - do { - if (s = t.window_size - t.lookahead - t.strstart, t.strstart >= e + (e - ct)) { - t.window.set(t.window.subarray(e, e + e), 0), t.match_start -= e, t.strstart -= e, t.block_start -= e, n = t.hash_size, i = n; - - do { - r = t.head[--i], t.head[i] = r >= e ? r - e : 0; - } while (--n); - - n = e, i = n; - - do { - r = t.prev[--i], t.prev[i] = r >= e ? r - e : 0; - } while (--n); - - s += e; - } - - if (0 === t.strm.avail_in) break; - if (n = xt(t.strm, t.window, t.strstart + t.lookahead, s), t.lookahead += n, t.lookahead + t.insert >= 3) for (a = t.strstart - t.insert, t.ins_h = t.window[a], t.ins_h = kt(t, t.ins_h, t.window[a + 1]); t.insert && (t.ins_h = kt(t, t.ins_h, t.window[a + 3 - 1]), t.prev[a & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = a, a++, t.insert--, !(t.lookahead + t.insert < 3));); - } while (t.lookahead < ct && 0 !== t.strm.avail_in); - }, - Rt = (t, e) => { - let i, n; - - for (;;) { - if (t.lookahead < ct) { - if (zt(t), t.lookahead < ct && e === G) return 1; - if (0 === t.lookahead) break; - } - - if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 !== i && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i)), t.match_length >= 3) { - if (n = Y(t, t.strstart - t.match_start, t.match_length - 3), t.lookahead -= t.match_length, t.match_length <= t.max_lazy_match && t.lookahead >= 3) { - t.match_length--; - + return t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + }, + Nt = (t, e) => { + let i, n, r; + for (;;) { + if (t.lookahead < ct) { + if (zt(t), t.lookahead < ct && e === G) return 1; + if (0 === t.lookahead) break; + } + if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), t.prev_length = t.match_length, t.prev_match = t.match_start, t.match_length = 2, 0 !== i && t.prev_length < t.max_lazy_match && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i), t.match_length <= 5 && (t.strategy === st || 3 === t.match_length && t.strstart - t.match_start > 4096) && (t.match_length = 2)), t.prev_length >= 3 && t.match_length <= t.prev_length) { + r = t.strstart + t.lookahead - 3, n = Y(t, t.strstart - 1 - t.prev_match, t.prev_length - 3), t.lookahead -= t.prev_length - 1, t.prev_length -= 2; do { - t.strstart++, t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart; - } while (0 != --t.match_length); - - t.strstart++; - } else t.strstart += t.match_length, t.match_length = 0, t.ins_h = t.window[t.strstart], t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 1]); - } else n = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++; - if (n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - }, - Nt = (t, e) => { - let i, n, r; - - for (;;) { - if (t.lookahead < ct) { - if (zt(t), t.lookahead < ct && e === G) return 1; - if (0 === t.lookahead) break; + ++t.strstart <= r && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart); + } while (0 != --t.prev_length); + if (t.match_available = 0, t.match_length = 2, t.strstart++, n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; + } else if (t.match_available) { + if (n = Y(t, 0, t.window[t.strstart - 1]), n && vt(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out) return 1; + } else t.match_available = 1, t.strstart++, t.lookahead--; } - - if (i = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), t.prev_length = t.match_length, t.prev_match = t.match_start, t.match_length = 2, 0 !== i && t.prev_length < t.max_lazy_match && t.strstart - i <= t.w_size - ct && (t.match_length = Ut(t, i), t.match_length <= 5 && (t.strategy === st || 3 === t.match_length && t.strstart - t.match_start > 4096) && (t.match_length = 2)), t.prev_length >= 3 && t.match_length <= t.prev_length) { - r = t.strstart + t.lookahead - 3, n = Y(t, t.strstart - 1 - t.prev_match, t.prev_length - 3), t.lookahead -= t.prev_length - 1, t.prev_length -= 2; - - do { - ++t.strstart <= r && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart); - } while (0 != --t.prev_length); - - if (t.match_available = 0, t.match_length = 2, t.strstart++, n && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } else if (t.match_available) { - if (n = Y(t, 0, t.window[t.strstart - 1]), n && vt(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out) return 1; - } else t.match_available = 1, t.strstart++, t.lookahead--; - } - - return t.match_available && (n = Y(t, 0, t.window[t.strstart - 1]), t.match_available = 0), t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - }; - + return t.match_available && (n = Y(t, 0, t.window[t.strstart - 1]), t.match_available = 0), t.insert = t.strstart < 2 ? t.strstart : 2, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + }; function Tt(t, e, i, n, r) { this.good_length = t, this.max_lazy = e, this.nice_length = i, this.max_chain = n, this.func = r; } - const Ot = [new Tt(0, 0, 0, 0, (t, e) => { let i = 65535; - for (i > t.pending_buf_size - 5 && (i = t.pending_buf_size - 5);;) { if (t.lookahead <= 1) { if (zt(t), 0 === t.lookahead && e === G) return 1; if (0 === t.lookahead) break; } - t.strstart += t.lookahead, t.lookahead = 0; const n = t.block_start + i; if ((0 === t.strstart || t.strstart >= n) && (t.lookahead = t.strstart - n, t.strstart = n, vt(t, !1), 0 === t.strm.avail_out)) return 1; if (t.strstart - t.block_start >= t.w_size - ct && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : (t.strstart > t.block_start && (vt(t, !1), t.strm.avail_out), 1); }), new Tt(4, 4, 8, 4, Rt), new Tt(4, 5, 16, 8, Rt), new Tt(4, 6, 32, 32, Rt), new Tt(4, 4, 16, 16, Nt), new Tt(8, 16, 32, 32, Nt), new Tt(8, 16, 128, 128, Nt), new Tt(8, 32, 128, 256, Nt), new Tt(32, 128, 258, 1024, Nt), new Tt(32, 258, 258, 4096, Nt)]; - function Lt() { this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = _t, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new Uint16Array(1146), this.dyn_dtree = new Uint16Array(122), this.bl_tree = new Uint16Array(78), mt(this.dyn_ltree), mt(this.dyn_dtree), mt(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new Uint16Array(16), this.heap = new Uint16Array(573), mt(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new Uint16Array(573), mt(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0; } - const Bt = t => { - if (!t || !t.state) return gt(t, et); - t.total_in = t.total_out = 0, t.data_type = dt; - const e = t.state; - return e.pending = 0, e.pending_out = 0, e.wrap < 0 && (e.wrap = -e.wrap), e.status = e.wrap ? 42 : wt, t.adler = 2 === e.wrap ? 0 : 1, e.last_flush = G, W(e), Q; - }, - Ct = t => { - const e = Bt(t); - var i; - return e === Q && ((i = t.state).window_size = 2 * i.w_size, mt(i.head), i.max_lazy_match = Ot[i.level].max_lazy, i.good_match = Ot[i.level].good_length, i.nice_match = Ot[i.level].nice_length, i.max_chain_length = Ot[i.level].max_chain, i.strstart = 0, i.block_start = 0, i.lookahead = 0, i.insert = 0, i.match_length = i.prev_length = 2, i.match_available = 0, i.ins_h = 0), e; - }, - Dt = (t, e, i, n, r, s) => { - if (!t) return et; - let a = 1; - if (e === rt && (e = 6), n < 0 ? (a = 0, n = -n) : n > 15 && (a = 2, n -= 16), r < 1 || r > 9 || i !== _t || n < 8 || n > 15 || e < 0 || e > 9 || s < 0 || s > ht) return gt(t, et); - 8 === n && (n = 9); - const o = new Lt(); - return t.state = o, o.strm = t, o.wrap = a, o.gzhead = null, o.w_bits = n, o.w_size = 1 << o.w_bits, o.w_mask = o.w_size - 1, o.hash_bits = r + 7, o.hash_size = 1 << o.hash_bits, o.hash_mask = o.hash_size - 1, o.hash_shift = ~~((o.hash_bits + 3 - 1) / 3), o.window = new Uint8Array(2 * o.w_size), o.head = new Uint16Array(o.hash_size), o.prev = new Uint16Array(o.w_size), o.lit_bufsize = 1 << r + 6, o.pending_buf_size = 4 * o.lit_bufsize, o.pending_buf = new Uint8Array(o.pending_buf_size), o.d_buf = 1 * o.lit_bufsize, o.l_buf = 3 * o.lit_bufsize, o.level = e, o.strategy = s, o.method = i, Ct(t); - }; - + if (!t || !t.state) return gt(t, et); + t.total_in = t.total_out = 0, t.data_type = dt; + const e = t.state; + return e.pending = 0, e.pending_out = 0, e.wrap < 0 && (e.wrap = -e.wrap), e.status = e.wrap ? 42 : wt, t.adler = 2 === e.wrap ? 0 : 1, e.last_flush = G, W(e), Q; + }, + Ct = t => { + const e = Bt(t); + var i; + return e === Q && ((i = t.state).window_size = 2 * i.w_size, mt(i.head), i.max_lazy_match = Ot[i.level].max_lazy, i.good_match = Ot[i.level].good_length, i.nice_match = Ot[i.level].nice_length, i.max_chain_length = Ot[i.level].max_chain, i.strstart = 0, i.block_start = 0, i.lookahead = 0, i.insert = 0, i.match_length = i.prev_length = 2, i.match_available = 0, i.ins_h = 0), e; + }, + Dt = (t, e, i, n, r, s) => { + if (!t) return et; + let a = 1; + if (e === rt && (e = 6), n < 0 ? (a = 0, n = -n) : n > 15 && (a = 2, n -= 16), r < 1 || r > 9 || i !== _t || n < 8 || n > 15 || e < 0 || e > 9 || s < 0 || s > ht) return gt(t, et); + 8 === n && (n = 9); + const o = new Lt(); + return t.state = o, o.strm = t, o.wrap = a, o.gzhead = null, o.w_bits = n, o.w_size = 1 << o.w_bits, o.w_mask = o.w_size - 1, o.hash_bits = r + 7, o.hash_size = 1 << o.hash_bits, o.hash_mask = o.hash_size - 1, o.hash_shift = ~~((o.hash_bits + 3 - 1) / 3), o.window = new Uint8Array(2 * o.w_size), o.head = new Uint16Array(o.hash_size), o.prev = new Uint16Array(o.w_size), o.lit_bufsize = 1 << r + 6, o.pending_buf_size = 4 * o.lit_bufsize, o.pending_buf = new Uint8Array(o.pending_buf_size), o.d_buf = 1 * o.lit_bufsize, o.l_buf = 3 * o.lit_bufsize, o.level = e, o.strategy = s, o.method = i, Ct(t); + }; var It = Dt, - St = (t, e) => t && t.state ? 2 !== t.state.wrap ? et : (t.state.gzhead = e, Q) : et, - Zt = (t, e) => { - let i, n; - if (!t || !t.state || e > J || e < 0) return t ? gt(t, et) : et; - const r = t.state; - if (!t.output || !t.input && 0 !== t.avail_in || r.status === pt && e !== q) return gt(t, 0 === t.avail_out ? nt : et); - r.strm = t; - const s = r.last_flush; - if (r.last_flush = e, 42 === r.status) if (2 === r.wrap) t.adler = 0, Et(r, 31), Et(r, 139), Et(r, 8), r.gzhead ? (Et(r, (r.gzhead.text ? 1 : 0) + (r.gzhead.hcrc ? 2 : 0) + (r.gzhead.extra ? 4 : 0) + (r.gzhead.name ? 8 : 0) + (r.gzhead.comment ? 16 : 0)), Et(r, 255 & r.gzhead.time), Et(r, r.gzhead.time >> 8 & 255), Et(r, r.gzhead.time >> 16 & 255), Et(r, r.gzhead.time >> 24 & 255), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 255 & r.gzhead.os), r.gzhead.extra && r.gzhead.extra.length && (Et(r, 255 & r.gzhead.extra.length), Et(r, r.gzhead.extra.length >> 8 & 255)), r.gzhead.hcrc && (t.adler = M(t.adler, r.pending_buf, r.pending, 0)), r.gzindex = 0, r.status = 69) : (Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 3), r.status = wt);else { - let e = _t + (r.w_bits - 8 << 4) << 8, + St = (t, e) => t && t.state ? 2 !== t.state.wrap ? et : (t.state.gzhead = e, Q) : et, + Zt = (t, e) => { + let i, n; + if (!t || !t.state || e > J || e < 0) return t ? gt(t, et) : et; + const r = t.state; + if (!t.output || !t.input && 0 !== t.avail_in || r.status === pt && e !== q) return gt(t, 0 === t.avail_out ? nt : et); + r.strm = t; + const s = r.last_flush; + if (r.last_flush = e, 42 === r.status) if (2 === r.wrap) t.adler = 0, Et(r, 31), Et(r, 139), Et(r, 8), r.gzhead ? (Et(r, (r.gzhead.text ? 1 : 0) + (r.gzhead.hcrc ? 2 : 0) + (r.gzhead.extra ? 4 : 0) + (r.gzhead.name ? 8 : 0) + (r.gzhead.comment ? 16 : 0)), Et(r, 255 & r.gzhead.time), Et(r, r.gzhead.time >> 8 & 255), Et(r, r.gzhead.time >> 16 & 255), Et(r, r.gzhead.time >> 24 & 255), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 255 & r.gzhead.os), r.gzhead.extra && r.gzhead.extra.length && (Et(r, 255 & r.gzhead.extra.length), Et(r, r.gzhead.extra.length >> 8 & 255)), r.gzhead.hcrc && (t.adler = M(t.adler, r.pending_buf, r.pending, 0)), r.gzindex = 0, r.status = 69) : (Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 0), Et(r, 9 === r.level ? 2 : r.strategy >= at || r.level < 2 ? 4 : 0), Et(r, 3), r.status = wt);else { + let e = _t + (r.w_bits - 8 << 4) << 8, i = -1; - i = r.strategy >= at || r.level < 2 ? 0 : r.level < 6 ? 1 : 6 === r.level ? 2 : 3, e |= i << 6, 0 !== r.strstart && (e |= 32), e += 31 - e % 31, r.status = wt, At(r, e), 0 !== r.strstart && (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), t.adler = 1; - } - if (69 === r.status) if (r.gzhead.extra) { - for (i = r.pending; r.gzindex < (65535 & r.gzhead.extra.length) && (r.pending !== r.pending_buf_size || (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending !== r.pending_buf_size));) Et(r, 255 & r.gzhead.extra[r.gzindex]), r.gzindex++; - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), r.gzindex === r.gzhead.extra.length && (r.gzindex = 0, r.status = 73); - } else r.status = 73; - if (73 === r.status) if (r.gzhead.name) { - i = r.pending; - - do { - if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { - n = 1; - break; - } - - n = r.gzindex < r.gzhead.name.length ? 255 & r.gzhead.name.charCodeAt(r.gzindex++) : 0, Et(r, n); - } while (0 !== n); - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.gzindex = 0, r.status = 91); - } else r.status = 91; - if (91 === r.status) if (r.gzhead.comment) { - i = r.pending; - - do { - if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { - n = 1; - break; - } - - n = r.gzindex < r.gzhead.comment.length ? 255 & r.gzhead.comment.charCodeAt(r.gzindex++) : 0, Et(r, n); - } while (0 !== n); - - r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.status = ut); - } else r.status = ut; - - if (r.status === ut && (r.gzhead.hcrc ? (r.pending + 2 > r.pending_buf_size && yt(t), r.pending + 2 <= r.pending_buf_size && (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), t.adler = 0, r.status = wt)) : r.status = wt), 0 !== r.pending) { - if (yt(t), 0 === t.avail_out) return r.last_flush = -1, Q; - } else if (0 === t.avail_in && bt(e) <= bt(s) && e !== q) return gt(t, nt); - - if (r.status === pt && 0 !== t.avail_in) return gt(t, nt); - - if (0 !== t.avail_in || 0 !== r.lookahead || e !== G && r.status !== pt) { - let i = r.strategy === at ? ((t, e) => { - let i; - - for (;;) { - if (0 === t.lookahead && (zt(t), 0 === t.lookahead)) { - if (e === G) return 1; + i = r.strategy >= at || r.level < 2 ? 0 : r.level < 6 ? 1 : 6 === r.level ? 2 : 3, e |= i << 6, 0 !== r.strstart && (e |= 32), e += 31 - e % 31, r.status = wt, At(r, e), 0 !== r.strstart && (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), t.adler = 1; + } + if (69 === r.status) if (r.gzhead.extra) { + for (i = r.pending; r.gzindex < (65535 & r.gzhead.extra.length) && (r.pending !== r.pending_buf_size || (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending !== r.pending_buf_size));) Et(r, 255 & r.gzhead.extra[r.gzindex]), r.gzindex++; + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), r.gzindex === r.gzhead.extra.length && (r.gzindex = 0, r.status = 73); + } else r.status = 73; + if (73 === r.status) if (r.gzhead.name) { + i = r.pending; + do { + if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { + n = 1; break; } - - if (t.match_length = 0, i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++, i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - })(r, e) : r.strategy === ot ? ((t, e) => { - let i, n, r, s; - const a = t.window; - - for (;;) { - if (t.lookahead <= ft) { - if (zt(t), t.lookahead <= ft && e === G) return 1; - if (0 === t.lookahead) break; + n = r.gzindex < r.gzhead.name.length ? 255 & r.gzhead.name.charCodeAt(r.gzindex++) : 0, Et(r, n); + } while (0 !== n); + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.gzindex = 0, r.status = 91); + } else r.status = 91; + if (91 === r.status) if (r.gzhead.comment) { + i = r.pending; + do { + if (r.pending === r.pending_buf_size && (r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), yt(t), i = r.pending, r.pending === r.pending_buf_size)) { + n = 1; + break; } - - if (t.match_length = 0, t.lookahead >= 3 && t.strstart > 0 && (r = t.strstart - 1, n = a[r], n === a[++r] && n === a[++r] && n === a[++r])) { - s = t.strstart + ft; - - do {} while (n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && r < s); - - t.match_length = ft - (s - r), t.match_length > t.lookahead && (t.match_length = t.lookahead); + n = r.gzindex < r.gzhead.comment.length ? 255 & r.gzhead.comment.charCodeAt(r.gzindex++) : 0, Et(r, n); + } while (0 !== n); + r.gzhead.hcrc && r.pending > i && (t.adler = M(t.adler, r.pending_buf, r.pending - i, i)), 0 === n && (r.status = ut); + } else r.status = ut; + if (r.status === ut && (r.gzhead.hcrc ? (r.pending + 2 > r.pending_buf_size && yt(t), r.pending + 2 <= r.pending_buf_size && (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), t.adler = 0, r.status = wt)) : r.status = wt), 0 !== r.pending) { + if (yt(t), 0 === t.avail_out) return r.last_flush = -1, Q; + } else if (0 === t.avail_in && bt(e) <= bt(s) && e !== q) return gt(t, nt); + if (r.status === pt && 0 !== t.avail_in) return gt(t, nt); + if (0 !== t.avail_in || 0 !== r.lookahead || e !== G && r.status !== pt) { + let i = r.strategy === at ? ((t, e) => { + let i; + for (;;) { + if (0 === t.lookahead && (zt(t), 0 === t.lookahead)) { + if (e === G) return 1; + break; + } + if (t.match_length = 0, i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++, i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; } - - if (t.match_length >= 3 ? (i = Y(t, 1, t.match_length - 3), t.lookahead -= t.match_length, t.strstart += t.match_length, t.match_length = 0) : (i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++), i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; - } - - return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; - })(r, e) : Ot[r.level].func(r, e); - if (3 !== i && 4 !== i || (r.status = pt), 1 === i || 3 === i) return 0 === t.avail_out && (r.last_flush = -1), Q; - if (2 === i && (e === X ? j(r) : e !== J && (K(r, 0, 0, !1), e === V && (mt(r.head), 0 === r.lookahead && (r.strstart = 0, r.block_start = 0, r.insert = 0))), yt(t), 0 === t.avail_out)) return r.last_flush = -1, Q; - } - - return e !== q ? Q : r.wrap <= 0 ? tt : (2 === r.wrap ? (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), Et(r, t.adler >> 16 & 255), Et(r, t.adler >> 24 & 255), Et(r, 255 & t.total_in), Et(r, t.total_in >> 8 & 255), Et(r, t.total_in >> 16 & 255), Et(r, t.total_in >> 24 & 255)) : (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), yt(t), r.wrap > 0 && (r.wrap = -r.wrap), 0 !== r.pending ? Q : tt); - }, - Ft = t => { - if (!t || !t.state) return et; - const e = t.state.status; - return 42 !== e && 69 !== e && 73 !== e && 91 !== e && e !== ut && e !== wt && e !== pt ? gt(t, et) : (t.state = null, e === wt ? gt(t, it) : Q); - }, - Mt = (t, e) => { - let i = e.length; - if (!t || !t.state) return et; - const n = t.state, - r = n.wrap; - if (2 === r || 1 === r && 42 !== n.status || n.lookahead) return et; - - if (1 === r && (t.adler = Z(t.adler, e, i, 0)), n.wrap = 0, i >= n.w_size) { - 0 === r && (mt(n.head), n.strstart = 0, n.block_start = 0, n.insert = 0); - let t = new Uint8Array(n.w_size); - t.set(e.subarray(i - n.w_size, i), 0), e = t, i = n.w_size; - } - - const s = t.avail_in, - a = t.next_in, - o = t.input; - - for (t.avail_in = i, t.next_in = 0, t.input = e, zt(n); n.lookahead >= 3;) { - let t = n.strstart, + return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + })(r, e) : r.strategy === ot ? ((t, e) => { + let i, n, r, s; + const a = t.window; + for (;;) { + if (t.lookahead <= ft) { + if (zt(t), t.lookahead <= ft && e === G) return 1; + if (0 === t.lookahead) break; + } + if (t.match_length = 0, t.lookahead >= 3 && t.strstart > 0 && (r = t.strstart - 1, n = a[r], n === a[++r] && n === a[++r] && n === a[++r])) { + s = t.strstart + ft; + do {} while (n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && n === a[++r] && r < s); + t.match_length = ft - (s - r), t.match_length > t.lookahead && (t.match_length = t.lookahead); + } + if (t.match_length >= 3 ? (i = Y(t, 1, t.match_length - 3), t.lookahead -= t.match_length, t.strstart += t.match_length, t.match_length = 0) : (i = Y(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++), i && (vt(t, !1), 0 === t.strm.avail_out)) return 1; + } + return t.insert = 0, e === q ? (vt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (vt(t, !1), 0 === t.strm.avail_out) ? 1 : 2; + })(r, e) : Ot[r.level].func(r, e); + if (3 !== i && 4 !== i || (r.status = pt), 1 === i || 3 === i) return 0 === t.avail_out && (r.last_flush = -1), Q; + if (2 === i && (e === X ? j(r) : e !== J && (K(r, 0, 0, !1), e === V && (mt(r.head), 0 === r.lookahead && (r.strstart = 0, r.block_start = 0, r.insert = 0))), yt(t), 0 === t.avail_out)) return r.last_flush = -1, Q; + } + return e !== q ? Q : r.wrap <= 0 ? tt : (2 === r.wrap ? (Et(r, 255 & t.adler), Et(r, t.adler >> 8 & 255), Et(r, t.adler >> 16 & 255), Et(r, t.adler >> 24 & 255), Et(r, 255 & t.total_in), Et(r, t.total_in >> 8 & 255), Et(r, t.total_in >> 16 & 255), Et(r, t.total_in >> 24 & 255)) : (At(r, t.adler >>> 16), At(r, 65535 & t.adler)), yt(t), r.wrap > 0 && (r.wrap = -r.wrap), 0 !== r.pending ? Q : tt); + }, + Ft = t => { + if (!t || !t.state) return et; + const e = t.state.status; + return 42 !== e && 69 !== e && 73 !== e && 91 !== e && e !== ut && e !== wt && e !== pt ? gt(t, et) : (t.state = null, e === wt ? gt(t, it) : Q); + }, + Mt = (t, e) => { + let i = e.length; + if (!t || !t.state) return et; + const n = t.state, + r = n.wrap; + if (2 === r || 1 === r && 42 !== n.status || n.lookahead) return et; + if (1 === r && (t.adler = Z(t.adler, e, i, 0)), n.wrap = 0, i >= n.w_size) { + 0 === r && (mt(n.head), n.strstart = 0, n.block_start = 0, n.insert = 0); + let t = new Uint8Array(n.w_size); + t.set(e.subarray(i - n.w_size, i), 0), e = t, i = n.w_size; + } + const s = t.avail_in, + a = t.next_in, + o = t.input; + for (t.avail_in = i, t.next_in = 0, t.input = e, zt(n); n.lookahead >= 3;) { + let t = n.strstart, e = n.lookahead - 2; - - do { - n.ins_h = kt(n, n.ins_h, n.window[t + 3 - 1]), n.prev[t & n.w_mask] = n.head[n.ins_h], n.head[n.ins_h] = t, t++; - } while (--e); - - n.strstart = t, n.lookahead = 2, zt(n); - } - - return n.strstart += n.lookahead, n.block_start = n.strstart, n.insert = n.lookahead, n.lookahead = 0, n.match_length = n.prev_length = 2, n.match_available = 0, t.next_in = a, t.input = o, t.avail_in = s, n.wrap = r, Q; - }; - + do { + n.ins_h = kt(n, n.ins_h, n.window[t + 3 - 1]), n.prev[t & n.w_mask] = n.head[n.ins_h], n.head[n.ins_h] = t, t++; + } while (--e); + n.strstart = t, n.lookahead = 2, zt(n); + } + return n.strstart += n.lookahead, n.block_start = n.strstart, n.insert = n.lookahead, n.lookahead = 0, n.match_length = n.prev_length = 2, n.match_available = 0, t.next_in = a, t.input = o, t.avail_in = s, n.wrap = r, Q; + }; const Pt = (t, e) => Object.prototype.hasOwnProperty.call(t, e); - var Ht = function Ht(t) { - const e = Array.prototype.slice.call(arguments, 1); - - for (; e.length;) { - const i = e.shift(); - - if (i) { - if ("object" != typeof i) throw new TypeError(i + "must be non-object"); - - for (const e in i) Pt(i, e) && (t[e] = i[e]); + const e = Array.prototype.slice.call(arguments, 1); + for (; e.length;) { + const i = e.shift(); + if (i) { + if ("object" != typeof i) throw new TypeError(i + "must be non-object"); + for (const e in i) Pt(i, e) && (t[e] = i[e]); + } } - } - - return t; - }, - Wt = t => { - let e = 0; - - for (let i = 0, n = t.length; i < n; i++) e += t[i].length; - - const i = new Uint8Array(e); - - for (let e = 0, n = 0, r = t.length; e < r; e++) { - let r = t[e]; - i.set(r, n), n += r.length; - } - - return i; - }; - + return t; + }, + Wt = t => { + let e = 0; + for (let i = 0, n = t.length; i < n; i++) e += t[i].length; + const i = new Uint8Array(e); + for (let e = 0, n = 0, r = t.length; e < r; e++) { + let r = t[e]; + i.set(r, n), n += r.length; + } + return i; + }; let Kt = !0; - try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (t) { Kt = !1; } - const $t = new Uint8Array(256); - for (let t = 0; t < 256; t++) $t[t] = t >= 252 ? 6 : t >= 248 ? 5 : t >= 240 ? 4 : t >= 224 ? 3 : t >= 192 ? 2 : 1; - $t[254] = $t[254] = 1; - var Yt = t => { - if ("function" == typeof TextEncoder && TextEncoder.prototype.encode) return new TextEncoder().encode(t); - let e, + if ("function" == typeof TextEncoder && TextEncoder.prototype.encode) return new TextEncoder().encode(t); + let e, i, n, r, s, a = t.length, o = 0; - - for (r = 0; r < a; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), o += i < 128 ? 1 : i < 2048 ? 2 : i < 65536 ? 3 : 4; - - for (e = new Uint8Array(o), s = 0, r = 0; s < o; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), i < 128 ? e[s++] = i : i < 2048 ? (e[s++] = 192 | i >>> 6, e[s++] = 128 | 63 & i) : i < 65536 ? (e[s++] = 224 | i >>> 12, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i) : (e[s++] = 240 | i >>> 18, e[s++] = 128 | i >>> 12 & 63, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i); - - return e; - }, - jt = (t, e) => { - const i = e || t.length; - if ("function" == typeof TextDecoder && TextDecoder.prototype.decode) return new TextDecoder().decode(t.subarray(0, e)); - let n, r; - const s = new Array(2 * i); - - for (r = 0, n = 0; n < i;) { - let e = t[n++]; - - if (e < 128) { - s[r++] = e; - continue; - } - - let a = $t[e]; - if (a > 4) s[r++] = 65533, n += a - 1;else { - for (e &= 2 === a ? 31 : 3 === a ? 15 : 7; a > 1 && n < i;) e = e << 6 | 63 & t[n++], a--; - - a > 1 ? s[r++] = 65533 : e < 65536 ? s[r++] = e : (e -= 65536, s[r++] = 55296 | e >> 10 & 1023, s[r++] = 56320 | 1023 & e); + for (r = 0; r < a; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), o += i < 128 ? 1 : i < 2048 ? 2 : i < 65536 ? 3 : 4; + for (e = new Uint8Array(o), s = 0, r = 0; s < o; r++) i = t.charCodeAt(r), 55296 == (64512 & i) && r + 1 < a && (n = t.charCodeAt(r + 1), 56320 == (64512 & n) && (i = 65536 + (i - 55296 << 10) + (n - 56320), r++)), i < 128 ? e[s++] = i : i < 2048 ? (e[s++] = 192 | i >>> 6, e[s++] = 128 | 63 & i) : i < 65536 ? (e[s++] = 224 | i >>> 12, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i) : (e[s++] = 240 | i >>> 18, e[s++] = 128 | i >>> 12 & 63, e[s++] = 128 | i >>> 6 & 63, e[s++] = 128 | 63 & i); + return e; + }, + jt = (t, e) => { + const i = e || t.length; + if ("function" == typeof TextDecoder && TextDecoder.prototype.decode) return new TextDecoder().decode(t.subarray(0, e)); + let n, r; + const s = new Array(2 * i); + for (r = 0, n = 0; n < i;) { + let e = t[n++]; + if (e < 128) { + s[r++] = e; + continue; + } + let a = $t[e]; + if (a > 4) s[r++] = 65533, n += a - 1;else { + for (e &= 2 === a ? 31 : 3 === a ? 15 : 7; a > 1 && n < i;) e = e << 6 | 63 & t[n++], a--; + a > 1 ? s[r++] = 65533 : e < 65536 ? s[r++] = e : (e -= 65536, s[r++] = 55296 | e >> 10 & 1023, s[r++] = 56320 | 1023 & e); + } } - } - - return ((t, e) => { - if (e < 65534 && t.subarray && Kt) return String.fromCharCode.apply(null, t.length === e ? t : t.subarray(0, e)); - let i = ""; - - for (let n = 0; n < e; n++) i += String.fromCharCode(t[n]); - - return i; - })(s, r); - }, - Gt = (t, e) => { - (e = e || t.length) > t.length && (e = t.length); - let i = e - 1; - - for (; i >= 0 && 128 == (192 & t[i]);) i--; - - return i < 0 || 0 === i ? e : i + $t[t[i]] > e ? i : e; - }, - Xt = function Xt() { - this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; - }; - + return ((t, e) => { + if (e < 65534 && t.subarray && Kt) return String.fromCharCode.apply(null, t.length === e ? t : t.subarray(0, e)); + let i = ""; + for (let n = 0; n < e; n++) i += String.fromCharCode(t[n]); + return i; + })(s, r); + }, + Gt = (t, e) => { + (e = e || t.length) > t.length && (e = t.length); + let i = e - 1; + for (; i >= 0 && 128 == (192 & t[i]);) i--; + return i < 0 || 0 === i ? e : i + $t[t[i]] > e ? i : e; + }, + Xt = function Xt() { + this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; + }; const Vt = Object.prototype.toString, - { - Z_NO_FLUSH: qt, - Z_SYNC_FLUSH: Jt, - Z_FULL_FLUSH: Qt, - Z_FINISH: te, - Z_OK: ee, - Z_STREAM_END: ie, - Z_DEFAULT_COMPRESSION: ne, - Z_DEFAULT_STRATEGY: re, - Z_DEFLATED: se - } = H; - + { + Z_NO_FLUSH: qt, + Z_SYNC_FLUSH: Jt, + Z_FULL_FLUSH: Qt, + Z_FINISH: te, + Z_OK: ee, + Z_STREAM_END: ie, + Z_DEFAULT_COMPRESSION: ne, + Z_DEFAULT_STRATEGY: re, + Z_DEFLATED: se + } = H; function ae(t) { this.options = Ht({ level: ne, @@ -3086,326 +2653,260 @@ var n = {}; e.raw && e.windowBits > 0 ? e.windowBits = -e.windowBits : e.gzip && e.windowBits > 0 && e.windowBits < 16 && (e.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new Xt(), this.strm.avail_out = 0; let i = It(this.strm, e.level, e.method, e.windowBits, e.memLevel, e.strategy); if (i !== ee) throw new Error(P[i]); - if (e.header && St(this.strm, e.header), e.dictionary) { let t; if (t = "string" == typeof e.dictionary ? Yt(e.dictionary) : "[object ArrayBuffer]" === Vt.call(e.dictionary) ? new Uint8Array(e.dictionary) : e.dictionary, i = Mt(this.strm, t), i !== ee) throw new Error(P[i]); this._dict_set = !0; } } - function oe(t, e) { const i = new ae(e); if (i.push(t, !0), i.err) throw i.msg || P[i.err]; return i.result; } - ae.prototype.push = function (t, e) { const i = this.strm, - n = this.options.chunkSize; + n = this.options.chunkSize; let r, s; if (this.ended) return !1; - for (s = e === ~~e ? e : !0 === e ? te : qt, "string" == typeof t ? i.input = Yt(t) : "[object ArrayBuffer]" === Vt.call(t) ? i.input = new Uint8Array(t) : i.input = t, i.next_in = 0, i.avail_in = i.input.length;;) if (0 === i.avail_out && (i.output = new Uint8Array(n), i.next_out = 0, i.avail_out = n), (s === Jt || s === Qt) && i.avail_out <= 6) this.onData(i.output.subarray(0, i.next_out)), i.avail_out = 0;else { if (r = Zt(i, s), r === ie) return i.next_out > 0 && this.onData(i.output.subarray(0, i.next_out)), r = Ft(this.strm), this.onEnd(r), this.ended = !0, r === ee; - if (0 !== i.avail_out) { if (s > 0 && i.next_out > 0) this.onData(i.output.subarray(0, i.next_out)), i.avail_out = 0;else if (0 === i.avail_in) break; } else this.onData(i.output); } - return !0; }, ae.prototype.onData = function (t) { this.chunks.push(t); }, ae.prototype.onEnd = function (t) { t === ee && (this.result = Wt(this.chunks)), this.chunks = [], this.err = t, this.msg = this.strm.msg; }; - var he = { - Deflate: ae, - deflate: oe, - deflateRaw: function deflateRaw(t, e) { - return (e = e || {}).raw = !0, oe(t, e); - }, - gzip: function gzip(t, e) { - return (e = e || {}).gzip = !0, oe(t, e); + Deflate: ae, + deflate: oe, + deflateRaw: function deflateRaw(t, e) { + return (e = e || {}).raw = !0, oe(t, e); + }, + gzip: function gzip(t, e) { + return (e = e || {}).gzip = !0, oe(t, e); + }, + constants: H }, - constants: H - }, - le = function le(t, e) { - let i, n, r, s, a, o, h, l, d, _, f, c, u, w, p, g, b, m, k, y, v, E, A, x; - - const U = t.state; - i = t.next_in, A = t.input, n = i + (t.avail_in - 5), r = t.next_out, x = t.output, s = r - (e - t.avail_out), a = r + (t.avail_out - 257), o = U.dmax, h = U.wsize, l = U.whave, d = U.wnext, _ = U.window, f = U.hold, c = U.bits, u = U.lencode, w = U.distcode, p = (1 << U.lenbits) - 1, g = (1 << U.distbits) - 1; - - t: do { - c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = u[f & p]; - - e: for (;;) { - if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, 0 === m) x[r++] = 65535 & b;else { - if (!(16 & m)) { - if (0 == (64 & m)) { - b = u[(65535 & b) + (f & (1 << m) - 1)]; - continue e; - } - - if (32 & m) { - U.mode = 12; - break t; - } - - t.msg = "invalid literal/length code", U.mode = 30; - break t; - } - - k = 65535 & b, m &= 15, m && (c < m && (f += A[i++] << c, c += 8), k += f & (1 << m) - 1, f >>>= m, c -= m), c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = w[f & g]; - - i: for (;;) { - if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, !(16 & m)) { + le = function le(t, e) { + let i, n, r, s, a, o, h, l, d, _, f, c, u, w, p, g, b, m, k, y, v, E, A, x; + const U = t.state; + i = t.next_in, A = t.input, n = i + (t.avail_in - 5), r = t.next_out, x = t.output, s = r - (e - t.avail_out), a = r + (t.avail_out - 257), o = U.dmax, h = U.wsize, l = U.whave, d = U.wnext, _ = U.window, f = U.hold, c = U.bits, u = U.lencode, w = U.distcode, p = (1 << U.lenbits) - 1, g = (1 << U.distbits) - 1; + t: do { + c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = u[f & p]; + e: for (;;) { + if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, 0 === m) x[r++] = 65535 & b;else { + if (!(16 & m)) { if (0 == (64 & m)) { - b = w[(65535 & b) + (f & (1 << m) - 1)]; - continue i; + b = u[(65535 & b) + (f & (1 << m) - 1)]; + continue e; } - - t.msg = "invalid distance code", U.mode = 30; - break t; - } - - if (y = 65535 & b, m &= 15, c < m && (f += A[i++] << c, c += 8, c < m && (f += A[i++] << c, c += 8)), y += f & (1 << m) - 1, y > o) { - t.msg = "invalid distance too far back", U.mode = 30; + if (32 & m) { + U.mode = 12; + break t; + } + t.msg = "invalid literal/length code", U.mode = 30; break t; } - - if (f >>>= m, c -= m, m = r - s, y > m) { - if (m = y - m, m > l && U.sane) { + k = 65535 & b, m &= 15, m && (c < m && (f += A[i++] << c, c += 8), k += f & (1 << m) - 1, f >>>= m, c -= m), c < 15 && (f += A[i++] << c, c += 8, f += A[i++] << c, c += 8), b = w[f & g]; + i: for (;;) { + if (m = b >>> 24, f >>>= m, c -= m, m = b >>> 16 & 255, !(16 & m)) { + if (0 == (64 & m)) { + b = w[(65535 & b) + (f & (1 << m) - 1)]; + continue i; + } + t.msg = "invalid distance code", U.mode = 30; + break t; + } + if (y = 65535 & b, m &= 15, c < m && (f += A[i++] << c, c += 8, c < m && (f += A[i++] << c, c += 8)), y += f & (1 << m) - 1, y > o) { t.msg = "invalid distance too far back", U.mode = 30; break t; } - - if (v = 0, E = _, 0 === d) { - if (v += h - m, m < k) { - k -= m; - - do { - x[r++] = _[v++]; - } while (--m); - - v = r - y, E = x; + if (f >>>= m, c -= m, m = r - s, y > m) { + if (m = y - m, m > l && U.sane) { + t.msg = "invalid distance too far back", U.mode = 30; + break t; } - } else if (d < m) { - if (v += h + d - m, m -= d, m < k) { - k -= m; - - do { - x[r++] = _[v++]; - } while (--m); - - if (v = 0, d < k) { - m = d, k -= m; - + if (v = 0, E = _, 0 === d) { + if (v += h - m, m < k) { + k -= m; do { x[r++] = _[v++]; } while (--m); - v = r - y, E = x; } + } else if (d < m) { + if (v += h + d - m, m -= d, m < k) { + k -= m; + do { + x[r++] = _[v++]; + } while (--m); + if (v = 0, d < k) { + m = d, k -= m; + do { + x[r++] = _[v++]; + } while (--m); + v = r - y, E = x; + } + } + } else if (v += d - m, m < k) { + k -= m; + do { + x[r++] = _[v++]; + } while (--m); + v = r - y, E = x; } - } else if (v += d - m, m < k) { - k -= m; - + for (; k > 2;) x[r++] = E[v++], x[r++] = E[v++], x[r++] = E[v++], k -= 3; + k && (x[r++] = E[v++], k > 1 && (x[r++] = E[v++])); + } else { + v = r - y; do { - x[r++] = _[v++]; - } while (--m); - - v = r - y, E = x; + x[r++] = x[v++], x[r++] = x[v++], x[r++] = x[v++], k -= 3; + } while (k > 2); + k && (x[r++] = x[v++], k > 1 && (x[r++] = x[v++])); } - - for (; k > 2;) x[r++] = E[v++], x[r++] = E[v++], x[r++] = E[v++], k -= 3; - - k && (x[r++] = E[v++], k > 1 && (x[r++] = E[v++])); - } else { - v = r - y; - - do { - x[r++] = x[v++], x[r++] = x[v++], x[r++] = x[v++], k -= 3; - } while (k > 2); - - k && (x[r++] = x[v++], k > 1 && (x[r++] = x[v++])); + break; } - - break; } + break; } - break; - } - } while (i < n && r < a); - - k = c >> 3, i -= k, c -= k << 3, f &= (1 << c) - 1, t.next_in = i, t.next_out = r, t.avail_in = i < n ? n - i + 5 : 5 - (i - n), t.avail_out = r < a ? a - r + 257 : 257 - (r - a), U.hold = f, U.bits = c; - }; - + } while (i < n && r < a); + k = c >> 3, i -= k, c -= k << 3, f &= (1 << c) - 1, t.next_in = i, t.next_out = r, t.avail_in = i < n ? n - i + 5 : 5 - (i - n), t.avail_out = r < a ? a - r + 257 : 257 - (r - a), U.hold = f, U.bits = c; + }; const de = new Uint16Array([3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0]), - _e = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78]), - fe = new Uint16Array([1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0]), - ce = new Uint8Array([16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]); - + _e = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78]), + fe = new Uint16Array([1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0]), + ce = new Uint8Array([16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]); var ue = (t, e, i, n, r, s, a, o) => { const h = o.bits; - let l, - d, - _, - f, - c, - u, - w = 0, - p = 0, - g = 0, - b = 0, - m = 0, - k = 0, - y = 0, - v = 0, - E = 0, - A = 0, - x = null, - U = 0; - + d, + _, + f, + c, + u, + w = 0, + p = 0, + g = 0, + b = 0, + m = 0, + k = 0, + y = 0, + v = 0, + E = 0, + A = 0, + x = null, + U = 0; const z = new Uint16Array(16), - R = new Uint16Array(16); + R = new Uint16Array(16); let N, - T, - O, - L = null, - B = 0; - + T, + O, + L = null, + B = 0; for (w = 0; w <= 15; w++) z[w] = 0; - for (p = 0; p < n; p++) z[e[i + p]]++; - for (m = h, b = 15; b >= 1 && 0 === z[b]; b--); - if (m > b && (m = b), 0 === b) return r[s++] = 20971520, r[s++] = 20971520, o.bits = 1, 0; - for (g = 1; g < b && 0 === z[g]; g++); - for (m < g && (m = g), v = 1, w = 1; w <= 15; w++) if (v <<= 1, v -= z[w], v < 0) return -1; - if (v > 0 && (0 === t || 1 !== b)) return -1; - for (R[1] = 0, w = 1; w < 15; w++) R[w + 1] = R[w] + z[w]; - for (p = 0; p < n; p++) 0 !== e[i + p] && (a[R[e[i + p]]++] = p); - if (0 === t ? (x = L = a, u = 19) : 1 === t ? (x = de, U -= 257, L = _e, B -= 257, u = 256) : (x = fe, L = ce, u = -1), A = 0, p = 0, w = g, c = s, k = m, y = 0, _ = -1, E = 1 << m, f = E - 1, 1 === t && E > 852 || 2 === t && E > 592) return 1; - for (;;) { N = w - y, a[p] < u ? (T = 0, O = a[p]) : a[p] > u ? (T = L[B + a[p]], O = x[U + a[p]]) : (T = 96, O = 0), l = 1 << w - y, d = 1 << k, g = d; - do { d -= l, r[c + (A >> y) + d] = N << 24 | T << 16 | O | 0; } while (0 !== d); - for (l = 1 << w - 1; A & l;) l >>= 1; - if (0 !== l ? (A &= l - 1, A += l) : A = 0, p++, 0 == --z[w]) { if (w === b) break; w = e[i + a[p]]; } - if (w > m && (A & f) !== _) { for (0 === y && (y = m), c += g, k = w - y, v = 1 << k; k + y < b && (v -= z[k + y], !(v <= 0));) k++, v <<= 1; - if (E += 1 << k, 1 === t && E > 852 || 2 === t && E > 592) return 1; _ = A & f, r[_] = m << 24 | k << 16 | c - s | 0; } } - return 0 !== A && (r[c + A] = w - y << 24 | 64 << 16 | 0), o.bits = m, 0; }; - const { - Z_FINISH: we, - Z_BLOCK: pe, - Z_TREES: ge, - Z_OK: be, - Z_STREAM_END: me, - Z_NEED_DICT: ke, - Z_STREAM_ERROR: ye, - Z_DATA_ERROR: ve, - Z_MEM_ERROR: Ee, - Z_BUF_ERROR: Ae, - Z_DEFLATED: xe - } = H, - Ue = 12, - ze = 30, - Re = t => (t >>> 24 & 255) + (t >>> 8 & 65280) + ((65280 & t) << 8) + ((255 & t) << 24); - + Z_FINISH: we, + Z_BLOCK: pe, + Z_TREES: ge, + Z_OK: be, + Z_STREAM_END: me, + Z_NEED_DICT: ke, + Z_STREAM_ERROR: ye, + Z_DATA_ERROR: ve, + Z_MEM_ERROR: Ee, + Z_BUF_ERROR: Ae, + Z_DEFLATED: xe + } = H, + Ue = 12, + ze = 30, + Re = t => (t >>> 24 & 255) + (t >>> 8 & 65280) + ((65280 & t) << 8) + ((255 & t) << 24); function Ne() { this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Uint16Array(320), this.work = new Uint16Array(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0; } - const Te = t => { - if (!t || !t.state) return ye; - const e = t.state; - return t.total_in = t.total_out = e.total = 0, t.msg = "", e.wrap && (t.adler = 1 & e.wrap), e.mode = 1, e.last = 0, e.havedict = 0, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(852), e.distcode = e.distdyn = new Int32Array(592), e.sane = 1, e.back = -1, be; - }, - Oe = t => { - if (!t || !t.state) return ye; - const e = t.state; - return e.wsize = 0, e.whave = 0, e.wnext = 0, Te(t); - }, - Le = (t, e) => { - let i; - if (!t || !t.state) return ye; - const n = t.state; - return e < 0 ? (i = 0, e = -e) : (i = 1 + (e >> 4), e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? ye : (null !== n.window && n.wbits !== e && (n.window = null), n.wrap = i, n.wbits = e, Oe(t)); - }, - Be = (t, e) => { - if (!t) return ye; - const i = new Ne(); - t.state = i, i.window = null; - const n = Le(t, e); - return n !== be && (t.state = null), n; - }; - + if (!t || !t.state) return ye; + const e = t.state; + return t.total_in = t.total_out = e.total = 0, t.msg = "", e.wrap && (t.adler = 1 & e.wrap), e.mode = 1, e.last = 0, e.havedict = 0, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(852), e.distcode = e.distdyn = new Int32Array(592), e.sane = 1, e.back = -1, be; + }, + Oe = t => { + if (!t || !t.state) return ye; + const e = t.state; + return e.wsize = 0, e.whave = 0, e.wnext = 0, Te(t); + }, + Le = (t, e) => { + let i; + if (!t || !t.state) return ye; + const n = t.state; + return e < 0 ? (i = 0, e = -e) : (i = 1 + (e >> 4), e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? ye : (null !== n.window && n.wbits !== e && (n.window = null), n.wrap = i, n.wbits = e, Oe(t)); + }, + Be = (t, e) => { + if (!t) return ye; + const i = new Ne(); + t.state = i, i.window = null; + const n = Le(t, e); + return n !== be && (t.state = null), n; + }; let Ce, - De, - Ie = !0; - + De, + Ie = !0; const Se = t => { - if (Ie) { - Ce = new Int32Array(512), De = new Int32Array(32); - let e = 0; - - for (; e < 144;) t.lens[e++] = 8; - - for (; e < 256;) t.lens[e++] = 9; - - for (; e < 280;) t.lens[e++] = 7; - - for (; e < 288;) t.lens[e++] = 8; - - for (ue(1, t.lens, 0, 288, Ce, 0, t.work, { - bits: 9 - }), e = 0; e < 32;) t.lens[e++] = 5; - - ue(2, t.lens, 0, 32, De, 0, t.work, { - bits: 5 - }), Ie = !1; - } - - t.lencode = Ce, t.lenbits = 9, t.distcode = De, t.distbits = 5; - }, - Ze = (t, e, i, n) => { - let r; - const s = t.state; - return null === s.window && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new Uint8Array(s.wsize)), n >= s.wsize ? (s.window.set(e.subarray(i - s.wsize, i), 0), s.wnext = 0, s.whave = s.wsize) : (r = s.wsize - s.wnext, r > n && (r = n), s.window.set(e.subarray(i - n, i - n + r), s.wnext), (n -= r) ? (s.window.set(e.subarray(i - n, i), 0), s.wnext = n, s.whave = s.wsize) : (s.wnext += r, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += r))), 0; - }; - + if (Ie) { + Ce = new Int32Array(512), De = new Int32Array(32); + let e = 0; + for (; e < 144;) t.lens[e++] = 8; + for (; e < 256;) t.lens[e++] = 9; + for (; e < 280;) t.lens[e++] = 7; + for (; e < 288;) t.lens[e++] = 8; + for (ue(1, t.lens, 0, 288, Ce, 0, t.work, { + bits: 9 + }), e = 0; e < 32;) t.lens[e++] = 5; + ue(2, t.lens, 0, 32, De, 0, t.work, { + bits: 5 + }), Ie = !1; + } + t.lencode = Ce, t.lenbits = 9, t.distcode = De, t.distbits = 5; + }, + Ze = (t, e, i, n) => { + let r; + const s = t.state; + return null === s.window && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new Uint8Array(s.wsize)), n >= s.wsize ? (s.window.set(e.subarray(i - s.wsize, i), 0), s.wnext = 0, s.whave = s.wsize) : (r = s.wsize - s.wnext, r > n && (r = n), s.window.set(e.subarray(i - n, i - n + r), s.wnext), (n -= r) ? (s.window.set(e.subarray(i - n, i), 0), s.wnext = n, s.whave = s.wsize) : (s.wnext += r, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += r))), 0; + }; var Fe = Oe, - Me = Be, - Pe = (t, e) => { - let i, + Me = Be, + Pe = (t, e) => { + let i, n, r, s, @@ -3424,524 +2925,411 @@ var n = {}; b, m, k, - y, - v, - E, - A = 0; - - const x = new Uint8Array(4); - let U, z; - const R = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); - if (!t || !t.state || !t.output || !t.input && 0 !== t.avail_in) return ye; - i = t.state, i.mode === Ue && (i.mode = 13), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, _ = o, f = h, E = be; - - t: for (;;) switch (i.mode) { - case 1: - if (0 === i.wrap) { - i.mode = 13; - break; - } - - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (2 & i.wrap && 35615 === l) { - i.check = 0, x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0), l = 0, d = 0, i.mode = 2; - break; - } - - if (i.flags = 0, i.head && (i.head.done = !1), !(1 & i.wrap) || (((255 & l) << 8) + (l >> 8)) % 31) { - t.msg = "incorrect header check", i.mode = ze; - break; - } - - if ((15 & l) !== xe) { - t.msg = "unknown compression method", i.mode = ze; - break; - } - - if (l >>>= 4, d -= 4, v = 8 + (15 & l), 0 === i.wbits) i.wbits = v;else if (v > i.wbits) { - t.msg = "invalid window size", i.mode = ze; - break; - } - i.dmax = 1 << i.wbits, t.adler = i.check = 1, i.mode = 512 & l ? 10 : Ue, l = 0, d = 0; - break; - - case 2: - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (i.flags = l, (255 & i.flags) !== xe) { - t.msg = "unknown compression method", i.mode = ze; - break; - } - - if (57344 & i.flags) { - t.msg = "unknown header flags set", i.mode = ze; - break; - } - - i.head && (i.head.text = l >> 8 & 1), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 3; - - case 3: - for (; d < 32;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - i.head && (i.head.time = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, x[2] = l >>> 16 & 255, x[3] = l >>> 24 & 255, i.check = M(i.check, x, 4, 0)), l = 0, d = 0, i.mode = 4; - - case 4: - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - i.head && (i.head.xflags = 255 & l, i.head.os = l >> 8), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 5; - - case 5: - if (1024 & i.flags) { - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - i.length = l, i.head && (i.head.extra_len = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0; - } else i.head && (i.head.extra = null); - - i.mode = 6; - - case 6: - if (1024 & i.flags && (c = i.length, c > o && (c = o), c && (i.head && (v = i.head.extra_len - i.length, i.head.extra || (i.head.extra = new Uint8Array(i.head.extra_len)), i.head.extra.set(n.subarray(s, s + c), v)), 512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, i.length -= c), i.length)) break t; - i.length = 0, i.mode = 7; - - case 7: - if (2048 & i.flags) { - if (0 === o) break t; - c = 0; - - do { - v = n[s + c++], i.head && v && i.length < 65536 && (i.head.name += String.fromCharCode(v)); - } while (v && c < o); - - if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; - } else i.head && (i.head.name = null); - - i.length = 0, i.mode = 8; - - case 8: - if (4096 & i.flags) { - if (0 === o) break t; - c = 0; - - do { - v = n[s + c++], i.head && v && i.length < 65536 && (i.head.comment += String.fromCharCode(v)); - } while (v && c < o); - - if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; - } else i.head && (i.head.comment = null); - - i.mode = 9; - - case 9: - if (512 & i.flags) { - for (; d < 16;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (l !== (65535 & i.check)) { - t.msg = "header crc mismatch", i.mode = ze; - break; - } - - l = 0, d = 0; - } - - i.head && (i.head.hcrc = i.flags >> 9 & 1, i.head.done = !0), t.adler = i.check = 0, i.mode = Ue; - break; - - case 10: - for (; d < 32;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - t.adler = i.check = Re(l), l = 0, d = 0, i.mode = 11; - - case 11: - if (0 === i.havedict) return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, ke; - t.adler = i.check = 1, i.mode = Ue; - - case Ue: - if (e === pe || e === ge) break t; - - case 13: - if (i.last) { - l >>>= 7 & d, d -= 7 & d, i.mode = 27; - break; - } - - for (; d < 3;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - switch (i.last = 1 & l, l >>>= 1, d -= 1, 3 & l) { - case 0: - i.mode = 14; - break; - - case 1: - if (Se(i), i.mode = 20, e === ge) { - l >>>= 2, d -= 2; - break t; - } - - break; - - case 2: - i.mode = 17; - break; - - case 3: - t.msg = "invalid block type", i.mode = ze; - } - - l >>>= 2, d -= 2; - break; - - case 14: - for (l >>>= 7 & d, d -= 7 & d; d < 32;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if ((65535 & l) != (l >>> 16 ^ 65535)) { - t.msg = "invalid stored block lengths", i.mode = ze; - break; - } - - if (i.length = 65535 & l, l = 0, d = 0, i.mode = 15, e === ge) break t; - - case 15: - i.mode = 16; - - case 16: - if (c = i.length, c) { - if (c > o && (c = o), c > h && (c = h), 0 === c) break t; - r.set(n.subarray(s, s + c), a), o -= c, s += c, h -= c, a += c, i.length -= c; - break; - } - - i.mode = Ue; - break; - - case 17: - for (; d < 14;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (i.nlen = 257 + (31 & l), l >>>= 5, d -= 5, i.ndist = 1 + (31 & l), l >>>= 5, d -= 5, i.ncode = 4 + (15 & l), l >>>= 4, d -= 4, i.nlen > 286 || i.ndist > 30) { - t.msg = "too many length or distance symbols", i.mode = ze; - break; - } - - i.have = 0, i.mode = 18; - - case 18: - for (; i.have < i.ncode;) { - for (; d < 3;) { + y, + v, + E, + A = 0; + const x = new Uint8Array(4); + let U, z; + const R = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); + if (!t || !t.state || !t.output || !t.input && 0 !== t.avail_in) return ye; + i = t.state, i.mode === Ue && (i.mode = 13), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, _ = o, f = h, E = be; + t: for (;;) switch (i.mode) { + case 1: + if (0 === i.wrap) { + i.mode = 13; + break; + } + for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - i.lens[R[i.have++]] = 7 & l, l >>>= 3, d -= 3; - } - - for (; i.have < 19;) i.lens[R[i.have++]] = 0; - - if (i.lencode = i.lendyn, i.lenbits = 7, U = { - bits: i.lenbits - }, E = ue(0, i.lens, 0, 19, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { - t.msg = "invalid code lengths set", i.mode = ze; + if (2 & i.wrap && 35615 === l) { + i.check = 0, x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0), l = 0, d = 0, i.mode = 2; + break; + } + if (i.flags = 0, i.head && (i.head.done = !1), !(1 & i.wrap) || (((255 & l) << 8) + (l >> 8)) % 31) { + t.msg = "incorrect header check", i.mode = ze; + break; + } + if ((15 & l) !== xe) { + t.msg = "unknown compression method", i.mode = ze; + break; + } + if (l >>>= 4, d -= 4, v = 8 + (15 & l), 0 === i.wbits) i.wbits = v;else if (v > i.wbits) { + t.msg = "invalid window size", i.mode = ze; + break; + } + i.dmax = 1 << i.wbits, t.adler = i.check = 1, i.mode = 512 & l ? 10 : Ue, l = 0, d = 0; break; - } - - i.have = 0, i.mode = 19; - - case 19: - for (; i.have < i.nlen + i.ndist;) { - for (; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { + case 2: + for (; d < 16;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - if (b < 16) l >>>= p, d -= p, i.lens[i.have++] = b;else { - if (16 === b) { - for (z = p + 2; d < z;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (l >>>= p, d -= p, 0 === i.have) { - t.msg = "invalid bit length repeat", i.mode = ze; - break; - } - - v = i.lens[i.have - 1], c = 3 + (3 & l), l >>>= 2, d -= 2; - } else if (17 === b) { - for (z = p + 3; d < z;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - l >>>= p, d -= p, v = 0, c = 3 + (7 & l), l >>>= 3, d -= 3; - } else { - for (z = p + 7; d < z;) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - l >>>= p, d -= p, v = 0, c = 11 + (127 & l), l >>>= 7, d -= 7; + if (i.flags = l, (255 & i.flags) !== xe) { + t.msg = "unknown compression method", i.mode = ze; + break; + } + if (57344 & i.flags) { + t.msg = "unknown header flags set", i.mode = ze; + break; + } + i.head && (i.head.text = l >> 8 & 1), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 3; + case 3: + for (; d < 32;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.head && (i.head.time = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, x[2] = l >>> 16 & 255, x[3] = l >>> 24 & 255, i.check = M(i.check, x, 4, 0)), l = 0, d = 0, i.mode = 4; + case 4: + for (; d < 16;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.head && (i.head.xflags = 255 & l, i.head.os = l >> 8), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0, i.mode = 5; + case 5: + if (1024 & i.flags) { + for (; d < 16;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; } - - if (i.have + c > i.nlen + i.ndist) { - t.msg = "invalid bit length repeat", i.mode = ze; + i.length = l, i.head && (i.head.extra_len = l), 512 & i.flags && (x[0] = 255 & l, x[1] = l >>> 8 & 255, i.check = M(i.check, x, 2, 0)), l = 0, d = 0; + } else i.head && (i.head.extra = null); + i.mode = 6; + case 6: + if (1024 & i.flags && (c = i.length, c > o && (c = o), c && (i.head && (v = i.head.extra_len - i.length, i.head.extra || (i.head.extra = new Uint8Array(i.head.extra_len)), i.head.extra.set(n.subarray(s, s + c), v)), 512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, i.length -= c), i.length)) break t; + i.length = 0, i.mode = 7; + case 7: + if (2048 & i.flags) { + if (0 === o) break t; + c = 0; + do { + v = n[s + c++], i.head && v && i.length < 65536 && (i.head.name += String.fromCharCode(v)); + } while (v && c < o); + if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; + } else i.head && (i.head.name = null); + i.length = 0, i.mode = 8; + case 8: + if (4096 & i.flags) { + if (0 === o) break t; + c = 0; + do { + v = n[s + c++], i.head && v && i.length < 65536 && (i.head.comment += String.fromCharCode(v)); + } while (v && c < o); + if (512 & i.flags && (i.check = M(i.check, n, c, s)), o -= c, s += c, v) break t; + } else i.head && (i.head.comment = null); + i.mode = 9; + case 9: + if (512 & i.flags) { + for (; d < 16;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (l !== (65535 & i.check)) { + t.msg = "header crc mismatch", i.mode = ze; break; } - - for (; c--;) i.lens[i.have++] = v; + l = 0, d = 0; } - } - - if (i.mode === ze) break; - - if (0 === i.lens[256]) { - t.msg = "invalid code -- missing end-of-block", i.mode = ze; - break; - } - - if (i.lenbits = 9, U = { - bits: i.lenbits - }, E = ue(1, i.lens, 0, i.nlen, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { - t.msg = "invalid literal/lengths set", i.mode = ze; - break; - } - - if (i.distbits = 6, i.distcode = i.distdyn, U = { - bits: i.distbits - }, E = ue(2, i.lens, i.nlen, i.ndist, i.distcode, 0, i.work, U), i.distbits = U.bits, E) { - t.msg = "invalid distances set", i.mode = ze; - break; - } - - if (i.mode = 20, e === ge) break t; - - case 20: - i.mode = 21; - - case 21: - if (o >= 6 && h >= 258) { - t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, le(t, f), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, i.mode === Ue && (i.back = -1); + i.head && (i.head.hcrc = i.flags >> 9 & 1, i.head.done = !0), t.adler = i.check = 0, i.mode = Ue; break; - } - - for (i.back = 0; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (g && 0 == (240 & g)) { - for (m = p, k = g, y = b; A = i.lencode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + case 10: + for (; d < 32;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - l >>>= m, d -= m, i.back += m; - } - - if (l >>>= p, d -= p, i.back += p, i.length = b, 0 === g) { - i.mode = 26; - break; - } - - if (32 & g) { - i.back = -1, i.mode = Ue; - break; - } - - if (64 & g) { - t.msg = "invalid literal/length code", i.mode = ze; - break; - } - - i.extra = 15 & g, i.mode = 22; - - case 22: - if (i.extra) { - for (z = i.extra; d < z;) { + t.adler = i.check = Re(l), l = 0, d = 0, i.mode = 11; + case 11: + if (0 === i.havedict) return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, ke; + t.adler = i.check = 1, i.mode = Ue; + case Ue: + if (e === pe || e === ge) break t; + case 13: + if (i.last) { + l >>>= 7 & d, d -= 7 & d, i.mode = 27; + break; + } + for (; d < 3;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - i.length += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; - } - - i.was = i.length, i.mode = 23; - - case 23: - for (; A = i.distcode[l & (1 << i.distbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { - if (0 === o) break t; - o--, l += n[s++] << d, d += 8; - } - - if (0 == (240 & g)) { - for (m = p, k = g, y = b; A = i.distcode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + switch (i.last = 1 & l, l >>>= 1, d -= 1, 3 & l) { + case 0: + i.mode = 14; + break; + case 1: + if (Se(i), i.mode = 20, e === ge) { + l >>>= 2, d -= 2; + break t; + } + break; + case 2: + i.mode = 17; + break; + case 3: + t.msg = "invalid block type", i.mode = ze; + } + l >>>= 2, d -= 2; + break; + case 14: + for (l >>>= 7 & d, d -= 7 & d; d < 32;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - l >>>= m, d -= m, i.back += m; - } - - if (l >>>= p, d -= p, i.back += p, 64 & g) { - t.msg = "invalid distance code", i.mode = ze; + if ((65535 & l) != (l >>> 16 ^ 65535)) { + t.msg = "invalid stored block lengths", i.mode = ze; + break; + } + if (i.length = 65535 & l, l = 0, d = 0, i.mode = 15, e === ge) break t; + case 15: + i.mode = 16; + case 16: + if (c = i.length, c) { + if (c > o && (c = o), c > h && (c = h), 0 === c) break t; + r.set(n.subarray(s, s + c), a), o -= c, s += c, h -= c, a += c, i.length -= c; + break; + } + i.mode = Ue; break; - } - - i.offset = b, i.extra = 15 & g, i.mode = 24; - - case 24: - if (i.extra) { - for (z = i.extra; d < z;) { + case 17: + for (; d < 14;) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - i.offset += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; - } - - if (i.offset > i.dmax) { - t.msg = "invalid distance too far back", i.mode = ze; - break; - } - - i.mode = 25; - - case 25: - if (0 === h) break t; - - if (c = f - h, i.offset > c) { - if (c = i.offset - c, c > i.whave && i.sane) { - t.msg = "invalid distance too far back", i.mode = ze; + if (i.nlen = 257 + (31 & l), l >>>= 5, d -= 5, i.ndist = 1 + (31 & l), l >>>= 5, d -= 5, i.ncode = 4 + (15 & l), l >>>= 4, d -= 4, i.nlen > 286 || i.ndist > 30) { + t.msg = "too many length or distance symbols", i.mode = ze; break; } - - c > i.wnext ? (c -= i.wnext, u = i.wsize - c) : u = i.wnext - c, c > i.length && (c = i.length), w = i.window; - } else w = r, u = a - i.offset, c = i.length; - - c > h && (c = h), h -= c, i.length -= c; - - do { - r[a++] = w[u++]; - } while (--c); - - 0 === i.length && (i.mode = 21); - break; - - case 26: - if (0 === h) break t; - r[a++] = i.length, h--, i.mode = 21; - break; - - case 27: - if (i.wrap) { - for (; d < 32;) { + i.have = 0, i.mode = 18; + case 18: + for (; i.have < i.ncode;) { + for (; d < 3;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.lens[R[i.have++]] = 7 & l, l >>>= 3, d -= 3; + } + for (; i.have < 19;) i.lens[R[i.have++]] = 0; + if (i.lencode = i.lendyn, i.lenbits = 7, U = { + bits: i.lenbits + }, E = ue(0, i.lens, 0, 19, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { + t.msg = "invalid code lengths set", i.mode = ze; + break; + } + i.have = 0, i.mode = 19; + case 19: + for (; i.have < i.nlen + i.ndist;) { + for (; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (b < 16) l >>>= p, d -= p, i.lens[i.have++] = b;else { + if (16 === b) { + for (z = p + 2; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (l >>>= p, d -= p, 0 === i.have) { + t.msg = "invalid bit length repeat", i.mode = ze; + break; + } + v = i.lens[i.have - 1], c = 3 + (3 & l), l >>>= 2, d -= 2; + } else if (17 === b) { + for (z = p + 3; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= p, d -= p, v = 0, c = 3 + (7 & l), l >>>= 3, d -= 3; + } else { + for (z = p + 7; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= p, d -= p, v = 0, c = 11 + (127 & l), l >>>= 7, d -= 7; + } + if (i.have + c > i.nlen + i.ndist) { + t.msg = "invalid bit length repeat", i.mode = ze; + break; + } + for (; c--;) i.lens[i.have++] = v; + } + } + if (i.mode === ze) break; + if (0 === i.lens[256]) { + t.msg = "invalid code -- missing end-of-block", i.mode = ze; + break; + } + if (i.lenbits = 9, U = { + bits: i.lenbits + }, E = ue(1, i.lens, 0, i.nlen, i.lencode, 0, i.work, U), i.lenbits = U.bits, E) { + t.msg = "invalid literal/lengths set", i.mode = ze; + break; + } + if (i.distbits = 6, i.distcode = i.distdyn, U = { + bits: i.distbits + }, E = ue(2, i.lens, i.nlen, i.ndist, i.distcode, 0, i.work, U), i.distbits = U.bits, E) { + t.msg = "invalid distances set", i.mode = ze; + break; + } + if (i.mode = 20, e === ge) break t; + case 20: + i.mode = 21; + case 21: + if (o >= 6 && h >= 258) { + t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, le(t, f), a = t.next_out, r = t.output, h = t.avail_out, s = t.next_in, n = t.input, o = t.avail_in, l = i.hold, d = i.bits, i.mode === Ue && (i.back = -1); + break; + } + for (i.back = 0; A = i.lencode[l & (1 << i.lenbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { if (0 === o) break t; - o--, l |= n[s++] << d, d += 8; + o--, l += n[s++] << d, d += 8; } - - if (f -= h, t.total_out += f, i.total += f, f && (t.adler = i.check = i.flags ? M(i.check, r, f, a - f) : Z(i.check, r, f, a - f)), f = h, (i.flags ? l : Re(l)) !== i.check) { - t.msg = "incorrect data check", i.mode = ze; + if (g && 0 == (240 & g)) { + for (m = p, k = g, y = b; A = i.lencode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= m, d -= m, i.back += m; + } + if (l >>>= p, d -= p, i.back += p, i.length = b, 0 === g) { + i.mode = 26; break; } - - l = 0, d = 0; - } - - i.mode = 28; - - case 28: - if (i.wrap && i.flags) { - for (; d < 32;) { + if (32 & g) { + i.back = -1, i.mode = Ue; + break; + } + if (64 & g) { + t.msg = "invalid literal/length code", i.mode = ze; + break; + } + i.extra = 15 & g, i.mode = 22; + case 22: + if (i.extra) { + for (z = i.extra; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.length += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; + } + i.was = i.length, i.mode = 23; + case 23: + for (; A = i.distcode[l & (1 << i.distbits) - 1], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(p <= d);) { if (0 === o) break t; o--, l += n[s++] << d, d += 8; } - - if (l !== (4294967295 & i.total)) { - t.msg = "incorrect length check", i.mode = ze; + if (0 == (240 & g)) { + for (m = p, k = g, y = b; A = i.distcode[y + ((l & (1 << m + k) - 1) >> m)], p = A >>> 24, g = A >>> 16 & 255, b = 65535 & A, !(m + p <= d);) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + l >>>= m, d -= m, i.back += m; + } + if (l >>>= p, d -= p, i.back += p, 64 & g) { + t.msg = "invalid distance code", i.mode = ze; break; } - - l = 0, d = 0; - } - - i.mode = 29; - - case 29: - E = me; - break t; - - case ze: - E = ve; - break t; - - case 31: - return Ee; - - default: - return ye; - } - - return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, (i.wsize || f !== t.avail_out && i.mode < ze && (i.mode < 27 || e !== we)) && Ze(t, t.output, t.next_out, f - t.avail_out), _ -= t.avail_in, f -= t.avail_out, t.total_in += _, t.total_out += f, i.total += f, i.wrap && f && (t.adler = i.check = i.flags ? M(i.check, r, f, t.next_out - f) : Z(i.check, r, f, t.next_out - f)), t.data_type = i.bits + (i.last ? 64 : 0) + (i.mode === Ue ? 128 : 0) + (20 === i.mode || 15 === i.mode ? 256 : 0), (0 === _ && 0 === f || e === we) && E === be && (E = Ae), E; - }, - He = t => { - if (!t || !t.state) return ye; - let e = t.state; - return e.window && (e.window = null), t.state = null, be; - }, - We = (t, e) => { - if (!t || !t.state) return ye; - const i = t.state; - return 0 == (2 & i.wrap) ? ye : (i.head = e, e.done = !1, be); - }, - Ke = (t, e) => { - const i = e.length; - let n, r, s; - return t && t.state ? (n = t.state, 0 !== n.wrap && 11 !== n.mode ? ye : 11 === n.mode && (r = 1, r = Z(r, e, i, 0), r !== n.check) ? ve : (s = Ze(t, e, i, i), s ? (n.mode = 31, Ee) : (n.havedict = 1, be))) : ye; - }, - $e = function $e() { - this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; - }; - + i.offset = b, i.extra = 15 & g, i.mode = 24; + case 24: + if (i.extra) { + for (z = i.extra; d < z;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + i.offset += l & (1 << i.extra) - 1, l >>>= i.extra, d -= i.extra, i.back += i.extra; + } + if (i.offset > i.dmax) { + t.msg = "invalid distance too far back", i.mode = ze; + break; + } + i.mode = 25; + case 25: + if (0 === h) break t; + if (c = f - h, i.offset > c) { + if (c = i.offset - c, c > i.whave && i.sane) { + t.msg = "invalid distance too far back", i.mode = ze; + break; + } + c > i.wnext ? (c -= i.wnext, u = i.wsize - c) : u = i.wnext - c, c > i.length && (c = i.length), w = i.window; + } else w = r, u = a - i.offset, c = i.length; + c > h && (c = h), h -= c, i.length -= c; + do { + r[a++] = w[u++]; + } while (--c); + 0 === i.length && (i.mode = 21); + break; + case 26: + if (0 === h) break t; + r[a++] = i.length, h--, i.mode = 21; + break; + case 27: + if (i.wrap) { + for (; d < 32;) { + if (0 === o) break t; + o--, l |= n[s++] << d, d += 8; + } + if (f -= h, t.total_out += f, i.total += f, f && (t.adler = i.check = i.flags ? M(i.check, r, f, a - f) : Z(i.check, r, f, a - f)), f = h, (i.flags ? l : Re(l)) !== i.check) { + t.msg = "incorrect data check", i.mode = ze; + break; + } + l = 0, d = 0; + } + i.mode = 28; + case 28: + if (i.wrap && i.flags) { + for (; d < 32;) { + if (0 === o) break t; + o--, l += n[s++] << d, d += 8; + } + if (l !== (4294967295 & i.total)) { + t.msg = "incorrect length check", i.mode = ze; + break; + } + l = 0, d = 0; + } + i.mode = 29; + case 29: + E = me; + break t; + case ze: + E = ve; + break t; + case 31: + return Ee; + default: + return ye; + } + return t.next_out = a, t.avail_out = h, t.next_in = s, t.avail_in = o, i.hold = l, i.bits = d, (i.wsize || f !== t.avail_out && i.mode < ze && (i.mode < 27 || e !== we)) && Ze(t, t.output, t.next_out, f - t.avail_out), _ -= t.avail_in, f -= t.avail_out, t.total_in += _, t.total_out += f, i.total += f, i.wrap && f && (t.adler = i.check = i.flags ? M(i.check, r, f, t.next_out - f) : Z(i.check, r, f, t.next_out - f)), t.data_type = i.bits + (i.last ? 64 : 0) + (i.mode === Ue ? 128 : 0) + (20 === i.mode || 15 === i.mode ? 256 : 0), (0 === _ && 0 === f || e === we) && E === be && (E = Ae), E; + }, + He = t => { + if (!t || !t.state) return ye; + let e = t.state; + return e.window && (e.window = null), t.state = null, be; + }, + We = (t, e) => { + if (!t || !t.state) return ye; + const i = t.state; + return 0 == (2 & i.wrap) ? ye : (i.head = e, e.done = !1, be); + }, + Ke = (t, e) => { + const i = e.length; + let n, r, s; + return t && t.state ? (n = t.state, 0 !== n.wrap && 11 !== n.mode ? ye : 11 === n.mode && (r = 1, r = Z(r, e, i, 0), r !== n.check) ? ve : (s = Ze(t, e, i, i), s ? (n.mode = 31, Ee) : (n.havedict = 1, be))) : ye; + }, + $e = function $e() { + this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; + }; const Ye = Object.prototype.toString, - { - Z_NO_FLUSH: je, - Z_FINISH: Ge, - Z_OK: Xe, - Z_STREAM_END: Ve, - Z_NEED_DICT: qe, - Z_STREAM_ERROR: Je, - Z_DATA_ERROR: Qe, - Z_MEM_ERROR: ti - } = H; - + { + Z_NO_FLUSH: je, + Z_FINISH: Ge, + Z_OK: Xe, + Z_STREAM_END: Ve, + Z_NEED_DICT: qe, + Z_STREAM_ERROR: Je, + Z_DATA_ERROR: Qe, + Z_MEM_ERROR: ti + } = H; function ei(t) { this.options = Ht({ chunkSize: 65536, @@ -3954,23 +3342,19 @@ var n = {}; if (i !== Xe) throw new Error(P[i]); if (this.header = new $e(), We(this.strm, this.header), e.dictionary && ("string" == typeof e.dictionary ? e.dictionary = Yt(e.dictionary) : "[object ArrayBuffer]" === Ye.call(e.dictionary) && (e.dictionary = new Uint8Array(e.dictionary)), e.raw && (i = Ke(this.strm, e.dictionary), i !== Xe))) throw new Error(P[i]); } - function ii(t, e) { const i = new ei(e); if (i.push(t), i.err) throw i.msg || P[i.err]; return i.result; } - ei.prototype.push = function (t, e) { const i = this.strm, - n = this.options.chunkSize, - r = this.options.dictionary; + n = this.options.chunkSize, + r = this.options.dictionary; let s, a, o; if (this.ended) return !1; - for (a = e === ~~e ? e : !0 === e ? Ge : je, "[object ArrayBuffer]" === Ye.call(t) ? i.input = new Uint8Array(t) : i.input = t, i.next_in = 0, i.avail_in = i.input.length;;) { for (0 === i.avail_out && (i.output = new Uint8Array(n), i.next_out = 0, i.avail_out = n), s = Pe(i, a), s === qe && r && (s = Ke(i, r), s === Xe ? s = Pe(i, a) : s === Qe && (s = qe)); i.avail_in > 0 && s === Ve && i.state.wrap > 0 && 0 !== t[i.next_in];) Fe(i), s = Pe(i, a); - switch (s) { case Je: case Qe: @@ -3978,20 +3362,17 @@ var n = {}; case ti: return this.onEnd(s), this.ended = !0, !1; } - if (o = i.avail_out, i.next_out && (0 === i.avail_out || s === Ve)) if ("string" === this.options.to) { let t = Gt(i.output, i.next_out), - e = i.next_out - t, - r = jt(i.output, t); + e = i.next_out - t, + r = jt(i.output, t); i.next_out = e, i.avail_out = n - e, e && i.output.set(i.output.subarray(t, t + e), 0), this.onData(r); } else this.onData(i.output.length === i.next_out ? i.output : i.output.subarray(0, i.next_out)); - if (s !== Xe || 0 !== o) { if (s === Ve) return s = He(this.strm), this.onEnd(s), this.ended = !0, !0; if (0 === i.avail_in) break; } } - return !0; }, ei.prototype.onData = function (t) { this.chunks.push(t); @@ -4008,43 +3389,35 @@ var n = {}; constants: H }; const { - Deflate: ri, - deflate: si, - deflateRaw: ai, - gzip: oi - } = he, - { - Inflate: hi, - inflate: li, - inflateRaw: di, - ungzip: _i - } = ni; + Deflate: ri, + deflate: si, + deflateRaw: ai, + gzip: oi + } = he, + { + Inflate: hi, + inflate: li, + inflateRaw: di, + ungzip: _i + } = ni; var fi = si, - ci = hi, - ui = li; + ci = hi, + ui = li; const wi = [137, 80, 78, 71, 13, 10, 26, 10], - pi = []; - + pi = []; for (let t = 0; t < 256; t++) { let e = t; - for (let t = 0; t < 8; t++) 1 & e ? e = 3988292384 ^ e >>> 1 : e >>>= 1; - pi[t] = e; } - const gi = 4294967295; - function bi(t, e) { return (function (t, e, i) { let n = 4294967295; - for (let t = 0; t < i; t++) n = pi[255 & (n ^ e[t])] ^ n >>> 8; - return n; }(0, t, e) ^ gi) >>> 0; } - var mi, ki, yi, vi; !function (t) { t[t.UNKNOWN = -1] = "UNKNOWN", t[t.GREYSCALE = 0] = "GREYSCALE", t[t.TRUECOLOUR = 2] = "TRUECOLOUR", t[t.INDEXED_COLOUR = 3] = "INDEXED_COLOUR", t[t.GREYSCALE_ALPHA = 4] = "GREYSCALE_ALPHA", t[t.TRUECOLOUR_ALPHA = 6] = "TRUECOLOUR_ALPHA"; @@ -4056,9 +3429,8 @@ var n = {}; t[t.UNKNOWN = -1] = "UNKNOWN", t[t.NO_INTERLACE = 0] = "NO_INTERLACE", t[t.ADAM7 = 1] = "ADAM7"; }(vi || (vi = {})); const Ei = new Uint8Array(0), - Ai = new Uint16Array([255]), - xi = 255 === new Uint8Array(Ai.buffer)[0]; - + Ai = new Uint16Array([255]), + xi = 255 === new Uint8Array(Ai.buffer)[0]; class Ui extends r { constructor(t) { let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; @@ -4075,69 +3447,53 @@ var n = {}; text: {} }, this._end = !1, this._hasPalette = !1, this._palette = [], this._compressionMethod = ki.UNKNOWN, this._filterMethod = yi.UNKNOWN, this._interlaceMethod = vi.UNKNOWN, this._colorType = -1, this.setBigEndian(); } - decode() { for (this.decodeSignature(); !this._end;) this.decodeChunk(); - return this.decodeImage(), this._png; } - decodeSignature() { for (let t = 0; t < wi.length; t++) if (this.readUint8() !== wi[t]) throw new Error("wrong PNG signature. Byte at ".concat(t, " should be ").concat(wi[t], ".")); } - decodeChunk() { const t = this.readUint32(), - e = this.readChars(4), - i = this.offset; - + e = this.readChars(4), + i = this.offset; switch (e) { case "IHDR": this.decodeIHDR(); break; - case "PLTE": this.decodePLTE(t); break; - case "IDAT": this.decodeIDAT(t); break; - case "IEND": this._end = !0; break; - case "tRNS": this.decodetRNS(t); break; - case "iCCP": this.decodeiCCP(t); break; - case "tEXt": this.decodetEXt(t); break; - case "pHYs": this.decodepHYs(); break; - default: this.skip(t); } - if (this.offset - i !== t) throw new Error("Length mismatch while decoding chunk ".concat(e)); - if (this._checkCrc) { const i = this.readUint32(), - n = t + 4, - r = bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - n - 4, n), n); + n = t + 4, + r = bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - n - 4, n), n); if (r !== i) throw new Error("CRC mismatch for chunk ".concat(e, ". Expected ").concat(i, ", found ").concat(r)); } else this.skip(4); } - decodeIHDR() { const t = this._png; t.width = this.readUint32(), t.height = this.readUint32(), t.depth = function (t) { @@ -4146,71 +3502,54 @@ var n = {}; }(this.readUint8()); const e = this.readUint8(); let i; - switch (this._colorType = e, e) { case mi.GREYSCALE: i = 1; break; - case mi.TRUECOLOUR: i = 3; break; - case mi.INDEXED_COLOUR: i = 1; break; - case mi.GREYSCALE_ALPHA: i = 2; break; - case mi.TRUECOLOUR_ALPHA: i = 4; break; - default: throw new Error("Unknown color type: ".concat(e)); } - if (this._png.channels = i, this._compressionMethod = this.readUint8(), this._compressionMethod !== ki.DEFLATE) throw new Error("Unsupported compression method: ".concat(this._compressionMethod)); this._filterMethod = this.readUint8(), this._interlaceMethod = this.readUint8(); } - decodePLTE(t) { if (t % 3 != 0) throw new RangeError("PLTE field length must be a multiple of 3. Got ".concat(t)); const e = t / 3; this._hasPalette = !0; const i = []; this._palette = i; - for (let t = 0; t < e; t++) i.push([this.readUint8(), this.readUint8(), this.readUint8()]); } - decodeIDAT(t) { this._inflator.push(new Uint8Array(this.buffer, this.offset + this.byteOffset, t)), this.skip(t); } - decodetRNS(t) { if (3 === this._colorType) { if (t > this._palette.length) throw new Error("tRNS chunk contains more alpha values than there are palette colors (".concat(t, " vs ").concat(this._palette.length, ")")); let e = 0; - for (; e < t; e++) { const t = this.readByte(); - this._palette[e].push(t); } - for (; e < this._palette.length; e++) this._palette[e].push(255); } } - decodeiCCP(t) { let e, - i = ""; - + i = ""; for (; "\0" !== (e = this.readChar());) i += e; - const n = this.readUint8(); if (n !== ki.DEFLATE) throw new Error("Unsupported iCCP compression method: ".concat(n)); const r = this.readBytes(t - i.length - 2); @@ -4219,27 +3558,22 @@ var n = {}; profile: ui(r) }; } - decodetEXt(t) { let e, - i = ""; - + i = ""; for (; "\0" !== (e = this.readChar());) i += e; - this._png.text[i] = this.readChars(t - i.length - 1); } - decodepHYs() { const t = this.readUint32(), - e = this.readUint32(), - i = this.readByte(); + e = this.readUint32(), + i = this.readByte(); this._png.resolution = { x: t, y: e, unit: i }; } - decodeImage() { if (this._inflator.err) throw new Error("Error while decompressing the data: ".concat(this._inflator.err)); const t = this._inflator.result; @@ -4247,267 +3581,212 @@ var n = {}; if (this._interlaceMethod !== vi.NO_INTERLACE) throw new Error("Interlace method ".concat(this._interlaceMethod, " not supported")); this.decodeInterlaceNull(t); } - decodeInterlaceNull(t) { const e = this._png.height, - i = this._png.channels * this._png.depth / 8, - n = this._png.width * i, - r = new Uint8Array(this._png.height * n); + i = this._png.channels * this._png.depth / 8, + n = this._png.width * i, + r = new Uint8Array(this._png.height * n); let s, - a, - o = Ei, - h = 0; - + a, + o = Ei, + h = 0; for (let l = 0; l < e; l++) { switch (s = t.subarray(h + 1, h + 1 + n), a = r.subarray(l * n, (l + 1) * n), t[h]) { case 0: zi(s, a, n); break; - case 1: Ri(s, a, n, i); break; - case 2: Ni(s, a, o, n); break; - case 3: Ti(s, a, o, n, i); break; - case 4: Oi(s, a, o, n, i); break; - default: throw new Error("Unsupported filter: ".concat(t[h])); } - o = a, h += n + 1; } - if (this._hasPalette && (this._png.palette = this._palette), 16 === this._png.depth) { const t = new Uint16Array(r.buffer); if (xi) for (let e = 0; e < t.length; e++) t[e] = (255 & (l = t[e])) << 8 | l >> 8 & 255; this._png.data = t; } else this._png.data = r; - var l; } - } - function zi(t, e, i) { for (let n = 0; n < i; n++) e[n] = t[n]; } - function Ri(t, e, i, n) { let r = 0; - for (; r < n; r++) e[r] = t[r]; - for (; r < i; r++) e[r] = t[r] + e[r - n] & 255; } - function Ni(t, e, i, n) { let r = 0; if (0 === i.length) for (; r < n; r++) e[r] = t[r];else for (; r < n; r++) e[r] = t[r] + i[r] & 255; } - function Ti(t, e, i, n, r) { let s = 0; - if (0 === i.length) { for (; s < r; s++) e[s] = t[s]; - for (; s < n; s++) e[s] = t[s] + (e[s - r] >> 1) & 255; } else { for (; s < r; s++) e[s] = t[s] + (i[s] >> 1) & 255; - for (; s < n; s++) e[s] = t[s] + (e[s - r] + i[s] >> 1) & 255; } } - function Oi(t, e, i, n, r) { let s = 0; - if (0 === i.length) { for (; s < r; s++) e[s] = t[s]; - for (; s < n; s++) e[s] = t[s] + e[s - r] & 255; } else { for (; s < r; s++) e[s] = t[s] + i[s] & 255; - for (; s < n; s++) e[s] = t[s] + Li(e[s - r], i[s], i[s - r]) & 255; } } - function Li(t, e, i) { const n = t + e - i, - r = Math.abs(n - t), - s = Math.abs(n - e), - a = Math.abs(n - i); + r = Math.abs(n - t), + s = Math.abs(n - e), + a = Math.abs(n - i); return r <= s && r <= a ? t : s <= a ? e : i; } - const Bi = { level: 3 }; - class Ci extends r { constructor(t) { let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; super(), this._colorType = mi.UNKNOWN, this._zlibOptions = _objectSpread2(_objectSpread2({}, Bi), e.zlib), this._png = this._checkData(t), this.setBigEndian(); } - encode() { return this.encodeSignature(), this.encodeIHDR(), this.encodeData(), this.encodeIEND(), this.toArray(); } - encodeSignature() { this.writeBytes(wi); } - encodeIHDR() { this.writeUint32(13), this.writeChars("IHDR"), this.writeUint32(this._png.width), this.writeUint32(this._png.height), this.writeByte(this._png.depth), this.writeByte(this._colorType), this.writeByte(ki.DEFLATE), this.writeByte(yi.ADAPTIVE), this.writeByte(vi.NO_INTERLACE), this.writeCrc(17); } - encodeIEND() { this.writeUint32(0), this.writeChars("IEND"), this.writeCrc(4); } - encodeIDAT(t) { this.writeUint32(t.length), this.writeChars("IDAT"), this.writeBytes(t), this.writeCrc(t.length + 4); } - encodeData() { const { - width: t, - height: e, - channels: i, - depth: n, - data: s - } = this._png, - a = i * t, - o = new r().setBigEndian(); + width: t, + height: e, + channels: i, + depth: n, + data: s + } = this._png, + a = i * t, + o = new r().setBigEndian(); let h = 0; - for (let t = 0; t < e; t++) if (o.writeByte(0), 8 === n) h = Ii(s, o, a, h);else { if (16 !== n) throw new Error("unreachable"); h = Si(s, o, a, h); } - const l = o.toArray(), - d = fi(l, this._zlibOptions); + d = fi(l, this._zlibOptions); this.encodeIDAT(d); } - _checkData(t) { const { - colorType: e, - channels: i, - depth: n - } = function (t) { - const { - channels: e = 4, - depth: i = 8 - } = t; - if (4 !== e && 3 !== e && 2 !== e && 1 !== e) throw new RangeError("unsupported number of channels: ".concat(e)); - if (8 !== i && 16 !== i) throw new RangeError("unsupported bit depth: ".concat(i)); - const n = { - channels: e, - depth: i, - colorType: mi.UNKNOWN + colorType: e, + channels: i, + depth: n + } = function (t) { + const { + channels: e = 4, + depth: i = 8 + } = t; + if (4 !== e && 3 !== e && 2 !== e && 1 !== e) throw new RangeError("unsupported number of channels: ".concat(e)); + if (8 !== i && 16 !== i) throw new RangeError("unsupported bit depth: ".concat(i)); + const n = { + channels: e, + depth: i, + colorType: mi.UNKNOWN + }; + switch (e) { + case 4: + n.colorType = mi.TRUECOLOUR_ALPHA; + break; + case 3: + n.colorType = mi.TRUECOLOUR; + break; + case 1: + n.colorType = mi.GREYSCALE; + break; + case 2: + n.colorType = mi.GREYSCALE_ALPHA; + break; + default: + throw new Error("unsupported number of channels"); + } + return n; + }(t), + r = { + width: Di(t.width, "width"), + height: Di(t.height, "height"), + channels: i, + data: t.data, + depth: n, + text: {} }; - - switch (e) { - case 4: - n.colorType = mi.TRUECOLOUR_ALPHA; - break; - - case 3: - n.colorType = mi.TRUECOLOUR; - break; - - case 1: - n.colorType = mi.GREYSCALE; - break; - - case 2: - n.colorType = mi.GREYSCALE_ALPHA; - break; - - default: - throw new Error("unsupported number of channels"); - } - - return n; - }(t), - r = { - width: Di(t.width, "width"), - height: Di(t.height, "height"), - channels: i, - data: t.data, - depth: n, - text: {} - }; - this._colorType = e; const s = r.width * r.height * i; if (r.data.length !== s) throw new RangeError("wrong data size. Found ".concat(r.data.length, ", expected ").concat(s)); return r; } - writeCrc(t) { this.writeUint32(bi(new Uint8Array(this.buffer, this.byteOffset + this.offset - t, t), t)); } - } - function Di(t, e) { if (Number.isInteger(t) && t > 0) return t; throw new TypeError("".concat(e, " must be a positive integer")); } - function Ii(t, e, i, n) { for (let r = 0; r < i; r++) e.writeByte(t[n++]); - return n; } - function Si(t, e, i, n) { for (let r = 0; r < i; r++) e.writeUint16(t[n++]); - return n; } - var Zi; !function (t) { t[t.UNKNOWN = 0] = "UNKNOWN", t[t.METRE = 1] = "METRE"; }(Zi || (Zi = {})); - const Fi = (t, e, i) => new Ci({ - width: t, - height: e, - data: i - }, undefined).encode(), - Mi = t => function (t, e) { - return new Ui(t, void 0).decode(); - }(t); + width: t, + height: e, + data: i + }, undefined).encode(), + Mi = t => function (t, e) { + return new Ui(t, void 0).decode(); + }(t); })(); - var r = n.P, - s = n.m; + s = n.m; function isTypeObject(object) { return object && object.hasOwnProperty('type') && object.hasOwnProperty('data'); } - function stringify(o, gap, indentation) { if (isTypeObject(o)) { let s = stringify(o.data, gap, indentation); - if (s.includes('\n')) { return ' #!' + o.type + s; } else { @@ -4515,17 +3794,13 @@ function stringify(o, gap, indentation) { } } else if (o && 'object' === typeof o) { let isArray = Array.isArray(o); - if (Object.keys(o).length == 0) { if (isArray) return '[]';else return '{}'; } - let s = '\n'; - for (let k in o) { if (Object.hasOwnProperty.call(o, k)) { s += gap.repeat(indentation + 1); - if (isArray) { s += '- ' + stringify(o[k], gap, indentation + 1); } else { @@ -4536,11 +3811,9 @@ function stringify(o, gap, indentation) { s += k + ': ' + stringify(o[k], gap, indentation + 1); } } - s += '\n'; } } - return s; } else if ('string' === typeof o) { return JSON.stringify(o); @@ -4552,118 +3825,92 @@ function stringify(o, gap, indentation) { throw new Error('Non-implemented parsing for ' + o); } } - function preStringify(object) { let space = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4; var gap = ''; - if (typeof space == 'number') { gap = ' '.repeat(Math.min(10, space)); } else if (typeof space == 'string') { gap = space.slice(0, 10); } - return stringify(object, gap, -1); } - class LineGenerator { constructor(lines, indentString, startingLine) { this.startingLine = startingLine || 0; this.lineIndex = -1; let filteredLines = []; - for (let i = 0; i < lines.length; i++) { let trimmedLine = lines[i].trim(); - if (trimmedLine !== '') { filteredLines.push([lines[i], i]); } } - this.lines = filteredLines; this.indentString = indentString || this.findIndentString(); } - getLineNumber() { return this.startingLine + this.lineIndex; } - nextGroup() { let lines = []; let baseIndent = this.indentLevel(this.lineIndex + 1); - while (!this.finished() && this.indentLevel(this.lineIndex + 1) >= baseIndent) { lines.push(this.next()); } - return new LineGenerator(lines, this.indentString, this.getLineNumber() - lines.length); } - next() { if (this.finished()) throw new Error('Trying to next finished generator'); this.lineIndex++; return this.getLine(); } - peek() { return this.getLine(this.lineIndex + 1); } - finished() { return this.lineIndex == this.lines.length - 1; } - getLine(index) { index = index !== undefined ? index : this.lineIndex; if (index >= this.lines.length) return null; return this.lines[index][0]; } - findIndentString() { for (let [line] of this.lines) { if (!line.trim() || line.replace(/^\s+/, "") == line) continue; return line.match(/^(\s+)/)[1]; } - return ''; } - indentLevel(index) { index = index !== undefined ? index : this.lineIndex; if (index < 0) index = 0; let indentLevel = 0; let line = this.getLine(index); - while (line.startsWith(this.indentString)) { line = line.slice(this.indentString.length); indentLevel++; } - return indentLevel; } - } - function getObject(lineGroup, type) { let object; lineGroup.indentLevel(); - while (!lineGroup.finished()) { let line = lineGroup.next(); let trimmedLine = line.trim(); let keyMatch = trimmedLine.match(/^(.*?):(?: |$)/); let typeMatch = trimmedLine.match(/#!([\w<,>]+)/); let key, value, type; - if (trimmedLine.startsWith('"')) { keyMatch = trimmedLine.match(/^"(.*?)":(?: |$)/); } - if (typeMatch) { type = typeMatch[1]; trimmedLine = trimmedLine.replace(typeMatch[0], ''); } - if (keyMatch) { if (!object) object = {}; key = keyMatch[1]; @@ -4672,43 +3919,35 @@ function getObject(lineGroup, type) { if (!object) object = []; value = trimmedLine.slice(1).trim(); } - if (value) { value = getValue(value, type); } else { value = getObject(lineGroup.nextGroup(), type); } - if (Array.isArray(object)) { object.push(value); } else { object[key] = value; } } - if (type) { object = { type: type, data: object }; } - return object; } - function getValue(value, type) { value = JSON.parse(value); - if (type) { value = { type: type, data: value }; } - return value; } - function parse(str) { let lines = str.replace(/\t/g, ' ').split('\n'); let lineGenerator = new LineGenerator(lines); @@ -4717,30 +3956,22 @@ function parse(str) { function deepCopy(obj) { let newObj; - if (Array.isArray(obj)) { newObj = []; - for (let item of obj) { newObj.push(deepCopy(item)); } - return newObj; } - if (!!obj && typeof obj === "object") { newObj = {}; - for (let [key, value] of Object.entries(obj)) { newObj[key] = deepCopy(value); } - return newObj; } - return obj; } - function isPrimitiveReaderType(reader) { switch (reader) { case 'Boolean': @@ -4756,13 +3987,12 @@ function isPrimitiveReaderType(reader) { case 'Vector4': case 'Rectangle': case 'Rect': + case 'Point': return true; - default: return false; } } - function isExportReaderType(reader) { switch (reader) { case 'Texture2D': @@ -4770,22 +4000,18 @@ function isExportReaderType(reader) { case 'Effect': case 'BmFont': return true; - default: return false; } } - function convertJsonContentsToXnbNode(raw, readers) { let extractedImages = []; let extractedMaps = []; - const { converted } = function recursiveConvert(obj, path) { let index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; const reader = readers[index]; - if (isPrimitiveReaderType(reader)) { return { converted: { @@ -4795,19 +4021,16 @@ function convertJsonContentsToXnbNode(raw, readers) { traversed: index }; } - if (reader === null) { return { converted: obj, traversed: index }; } - if (reader.startsWith('Nullable')) { let nullableData, trav; let [readerType, blockTraversed = 1] = reader.split(":"); blockTraversed = +blockTraversed; - if (obj === null) { nullableData = null; trav = index + blockTraversed; @@ -4825,7 +4048,6 @@ function convertJsonContentsToXnbNode(raw, readers) { nullableData = converted; trav = traversed; } - return { converted: { type: readerType, @@ -4836,7 +4058,6 @@ function convertJsonContentsToXnbNode(raw, readers) { traversed: trav }; } - if (isExportReaderType(reader)) { if (reader === 'Texture2D') { extractedImages.push({ @@ -4852,13 +4073,11 @@ function convertJsonContentsToXnbNode(raw, readers) { traversed: index }; } - if (reader === 'TBin') { extractedMaps.push({ path: path.join('.') }); } - return { converted: { type: reader, @@ -4867,16 +4086,24 @@ function convertJsonContentsToXnbNode(raw, readers) { traversed: index }; } - let data; if (Array.isArray(obj)) data = [];else data = {}; let traversed = index; let first = true; let isComplex = !reader.startsWith("Dictionary") && !reader.startsWith("Array") && !reader.startsWith("List"); - + let [readerType, complexBlockTraversed = 1] = reader.split(":"); + if (Object.keys(obj).length === 0) { + return { + converted: { + type: readerType, + data + }, + traversed: index + +complexBlockTraversed + }; + } for (let [key, value] of Object.entries(obj)) { let newIndex; - if (reader.startsWith("Dictionary")) newIndex = index + 2;else if (reader.startsWith("Array") || reader.startsWith("List")) newIndex = index + 1;else newIndex = traversed + 1; + if (readerType.startsWith("Dictionary")) newIndex = index + 2;else if (readerType.startsWith("Array") || readerType.startsWith("List")) newIndex = index + 1;else newIndex = traversed + 1; const { converted, traversed: nexter @@ -4887,72 +4114,56 @@ function convertJsonContentsToXnbNode(raw, readers) { first = false; } } - return { converted: { - type: reader, + type: readerType, data }, traversed }; }(raw, []); - return { converted, extractedImages, extractedMaps }; } - function convertJsonContentsFromXnbNode(obj) { if (!obj || typeof obj !== "object") return obj; - if (typeof obj === "object" && obj.hasOwnProperty("data")) { let { type, data } = obj; if (isPrimitiveReaderType(type)) return deepCopy(data); - if (isExportReaderType(type)) { data = deepCopy(data); if (type === "Texture2D") data.export = "Texture2D.png";else if (type === "Effect") data.export = "Effect.cso";else if (type === "TBin") data.export = "TBin.tbin";else if (type === "BmFont") data.export = "BmFont.xml"; return data; } - if (type.startsWith("Nullable")) { if (data === null || data.data === null) return null; return convertJsonContentsFromXnbNode(data.data); } - obj = deepCopy(data); } - let newObj; - if (Array.isArray(obj)) { newObj = []; - for (let item of obj) { newObj.push(convertJsonContentsFromXnbNode(item)); } - return newObj; } - if (!!obj && typeof obj === "object") { newObj = {}; - for (let [key, value] of Object.entries(obj)) { newObj[key] = convertJsonContentsFromXnbNode(value); } - return newObj; } - return null; } - function toXnbNodeData(json) { const toYamlJson = {}; const { @@ -4972,13 +4183,11 @@ function toXnbNodeData(json) { const rawContent = deepCopy(json.content); const mainReader = TypeReader.simplifyType(readerData[0].type); let readersTypeList = TypeReader.getReaderTypeList(mainReader); - if (readersTypeList[0] === 'SpriteFont') { readersTypeList = ['SpriteFont', 'Texture2D', 'List', 'Rectangle', 'List', 'Rectangle', 'List', 'Char', null, 'List', 'Vector3', 'Nullable', 'Char', null]; rawContent.verticalSpacing = rawContent.verticalLineSpacing; delete rawContent.verticalLineSpacing; } - const { converted, extractedImages, @@ -4989,7 +4198,6 @@ function toXnbNodeData(json) { if (extractedMaps.length > 0) toYamlJson.extractedMaps = extractedMaps; return toYamlJson; } - function fromXnbNodeData(json) { const result = {}; const { @@ -5006,86 +4214,66 @@ function fromXnbNodeData(json) { }; result.readers = deepCopy(readerData); result.content = convertJsonContentsFromXnbNode(json.content); - if (TypeReader.simplifyType(result.readers[0].type) === 'SpriteFont') { result.content.verticalLineSpacing = result.content.verticalSpacing; delete result.content.verticalSpacing; } - return result; } function searchElement(parent, element) { if (!parent || typeof parent != 'object') return; - if (parent.hasOwnProperty(element)) { return { parent, value: parent[element] }; } - for (let child of Object.values(parent)) { if (!!child || typeof child == 'object') { let found = searchElement(child, element); if (found) return found; } } - return null; } - function extractFileName(fullname) { let matcher = fullname.match(/(.*)\.([^\s.]+)$/); if (matcher === null) return [fullname, null]; return [matcher[1], matcher[2]]; } - function getExtension(dataType) { switch (dataType) { case "JSON": return "json"; - case "yaml": return "yaml"; - case "Texture2D": return "png"; - case "Effect": return "cso"; - case 'TBin': return "tbin"; - case 'BmFont': return "xml"; } - return "bin"; } - function getMimeType(dataType) { switch (dataType) { case "JSON": return "application/json"; - case "yaml": return "text/plain"; - case "Texture2D": return "image/png"; - case "Effect": return "application/x-cso"; - case 'BmFont': return "application/xml"; } - return "application/octet-stream"; } - function makeBlob(data, dataType) { if (typeof Blob === "function") return { data: new Blob([data], { @@ -5098,11 +4286,9 @@ function makeBlob(data, dataType) { extension: getExtension(dataType) }; } - function exportContent(content) { let jsonContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; let found = searchElement(content, "export"); - if (found) { const { value @@ -5111,21 +4297,18 @@ function exportContent(content) { type: dataType, data } = value; - if (dataType === "Texture2D") { data = s(value.width, value.height, new Uint8Array(data)); } - return makeBlob(data, dataType); } - if (jsonContent) { let contentJson = JSON.stringify(content, null, 4); return makeBlob(contentJson, "JSON"); } - return null; } + /** @api * decompressed xnb object to real file blobs. * @param {XnbData} decompressed xnb objects (returned by bufferToXnb() / Xnb.load()) @@ -5133,8 +4316,6 @@ function exportContent(content) { * contentOnly:export content file only, * fileName:exported files's name) (optional) */ - - function exportFiles(xnbObject) { let { yaml: isYaml = false, @@ -5155,10 +4336,8 @@ function exportFiles(xnbObject) { if (typeof fileName == "string" && fileName !== "") { return "".concat(fileName, ".").concat(getExtension(value.type)); } - return "".concat(value.type, ".").concat(getExtension(value.type)); } - return value; }, 4); let result = resultJSON; @@ -5166,22 +4345,18 @@ function exportFiles(xnbObject) { blobs.unshift(makeBlob(result, isYaml ? "yaml" : "JSON")); return blobs; } - function resolveCompression(compressionString) { let str = compressionString.toLowerCase(); if (str === "none") return 0; if (str === "lz4") return 0x40; return null; } - async function readBlobasText(blob) { if (typeof Blob === "function" && blob instanceof Blob) return blob.text();else if (typeof Buffer === "function" && blob instanceof Buffer) return blob.toString();else return blob; } - async function readBlobasArrayBuffer(blob) { if (typeof Blob === "function" && blob instanceof Blob) return blob.arrayBuffer();else if (typeof Buffer === "function" && blob instanceof Buffer) return blob.buffer; } - async function readExternFiles(extension, files) { if (extension === "png") { const rawPng = await readBlobasArrayBuffer(files.png); @@ -5194,7 +4369,6 @@ async function readExternFiles(extension, files) { height: png.height }; } - if (extension === "cso") { const data = await readBlobasArrayBuffer(files.cso); return { @@ -5202,7 +4376,6 @@ async function readExternFiles(extension, files) { data }; } - if (extension === "tbin") { const data = await readBlobasArrayBuffer(files.tbin); return { @@ -5210,7 +4383,6 @@ async function readExternFiles(extension, files) { data }; } - if (extension === "xml") { const data = await readBlobasText(files.xml); return { @@ -5219,7 +4391,6 @@ async function readExternFiles(extension, files) { }; } } - async function resolveImports(files) { let configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; const { @@ -5232,13 +4403,10 @@ async function resolveImports(files) { if (files.json) jsonData = JSON.parse(rawText);else jsonData = fromXnbNodeData(parse(rawText)); let compressBits = resolveCompression(compression); if (compressBits !== null) jsonData.header.compressed = compressBits; - if (!jsonData.hasOwnProperty('content')) { throw new XnbError("".concat(jsonFile.name, " does not have \"content\".")); } - const found = searchElement(jsonData.content, "export"); - if (found) { const { parent, @@ -5247,16 +4415,13 @@ async function resolveImports(files) { const [, extension] = extractFileName(value); parent.export = await readExternFiles(extension, files); } - return jsonData; } - function getReaderAssembly(extension) { if (extension === "png") return "Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553"; if (extension === "tbin") return "xTile.Pipeline.TideReader, xTile"; if (extension === "xml") return "BmFont.XmlSourceReader, BmFont, Version=2012.1.7.0, Culture=neutral, PublicKeyToken=null"; } - function makeHeader(fileName) { const [, extension] = extractFileName(fileName); const readerType = getReaderAssembly(extension); @@ -5286,32 +4451,28 @@ function makeHeader(fileName) { * @param {File / Buffer} file * @return {XnbData} JSON data with headers */ - async function unpackToXnbData(file) { if (typeof window !== "undefined") { const [, extension] = extractFileName(file.name); - if (extension !== "xnb") { return new Error("Invalid XNB File!"); } - const buffer = await file.arrayBuffer(); return bufferToXnb(buffer); } - return bufferToXnb(file.buffer); } + /** @api * Asynchronously reads the file into binary and then return content file. * XNB -> arrayBuffer -> XnbData -> Content * @param {File / Buffer} file * @return {XnbContent} exported Content Object */ - - function unpackToContent(file) { return unpackToXnbData(file).then(xnbDataToContent); } + /** @api * Asynchronously reads the file into binary and then unpacks the contents and remake to Blobs array. * XNB -> arrayBuffer -> XnbData -> Files @@ -5319,8 +4480,6 @@ function unpackToContent(file) { * @param {Object} config (yaml:export file as yaml, contentOnly:export content file only, fileName:file name(for node.js)) * @return {Array} exported Files Blobs */ - - function unpackToFiles(file) { let configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; let { @@ -5330,48 +4489,43 @@ function unpackToFiles(file) { } = configs; if (typeof window !== "undefined" && name === null) name = file.name; let [fileName] = extractFileName(name); - const exporter = xnbObject => exportFiles(xnbObject, { yaml, contentOnly, fileName }); - return unpackToXnbData(file).then(exporter); } + /** @api * reads the buffer and then unpacks. * arrayBuffer -> XnbData * @param {ArrayBuffer} buffer * @return {XnbData} the loaded XNB json */ - - function bufferToXnb(buffer) { const xnb = new XnbConverter(); return xnb.load(buffer); } + /** @api * reads the buffer and then unpacks the contents. * arrayBuffer -> XnbData -> Content * @param {ArrayBuffer} buffer * @return {XnbContent} exported Content Object */ - - function bufferToContents(buffer) { const xnb = new XnbConverter(); const xnbData = xnb.load(buffer); return xnbDataToContent(xnbData); } + /** @api * remove header from the loaded XNB Object * XnbData -> Content * @param {XnbData} the loaded XNB object include headers * @return {XnbContent} exported Content Object */ - - function xnbDataToContent(loadedXnb) { const { content @@ -5387,58 +4541,48 @@ function xnbDataToContent(loadedXnb) { * @param {FileList/Array} to pack json data * @return {Object/Object} packed XNB Array Buffer */ - - function fileMapper(files) { let returnMap = {}; let noHeaderMap = {}; - for (let i = 0; i < files.length; i++) { const file = files[i]; let [fileName, extension] = extractFileName(file.name); if (extension === null) continue; - if (returnMap[fileName] === undefined) { returnMap[fileName] = {}; if (extension !== "json" && extension !== "yaml") noHeaderMap[fileName] = file.name; } - const namedFileObj = returnMap[fileName]; if (typeof Blob === "function" && file instanceof Blob) namedFileObj[extension] = file;else namedFileObj[extension] = file.data; if (extension === "json" || extension === "yaml") delete noHeaderMap[fileName]; } - for (let fileName of Object.keys(noHeaderMap)) { returnMap[fileName].json = makeHeader(noHeaderMap[fileName]); } - return returnMap; } + /** @api * reads the json and then unpacks the contents. * @param {json} to pack json data * @return {ArrayBuffer} packed XNB Array Buffer */ - - function packJsonToBinary(json) { const xnb = new XnbConverter(); const buffer = xnb.convert(json); return buffer; } + /** @api * Asynchronously reads the file into binary and then pack xnb files. * @param {FlieList} files * @param {Object} configs(compression:default, none, LZ4, LZX / debug) * @return {Array(Blobs)} */ - - function pack(files) { let configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; const groupedFiles = fileMapper(files); let promises = []; - for (let [fileName, filePack] of Object.entries(groupedFiles)) { promises.push(resolveImports(filePack, configs).then(packJsonToBinary).then(buffer => { if (typeof Blob === "function") return { @@ -5453,7 +4597,6 @@ function pack(files) { }; })); } - return __promise_allSettled(promises).then(blobArray => { if (configs.debug === true) return blobArray; return blobArray.filter(_ref => { @@ -5470,13 +4613,23 @@ function pack(files) { }); }); } - function setReaders(readers) { return TypeReader.setReaders(readers); } - function addReaders(readers) { return TypeReader.addReaders(readers); } +function setSchemes(schemes) { + return TypeReader.setSchemes(schemes); +} +function addSchemes(schemes) { + return TypeReader.addSchemes(schemes); +} +function setEnum(enumList) { + return TypeReader.setEnum(enumList); +} +function addEnum(enumList) { + return TypeReader.addEnum(enumList); +} -export { XnbContent, XnbData, addReaders, bufferToContents, bufferToXnb, pack, setReaders, unpackToContent, unpackToFiles, unpackToXnbData, xnbDataToContent, exportFiles as xnbDataToFiles }; +export { XnbContent, XnbData, addEnum, addReaders, addSchemes, bufferToContents, bufferToXnb, pack, setEnum, setReaders, setSchemes, unpackToContent, unpackToFiles, unpackToXnbData, xnbDataToContent, exportFiles as xnbDataToFiles }; diff --git a/dist/plugins/stardewvalley/index.es5.min.js b/dist/plugins/stardewvalley/index.es5.min.js deleted file mode 100644 index a8a4c09..0000000 --- a/dist/plugins/stardewvalley/index.es5.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @xnb/stardewvalley 1.2.0 - * made by Lybell( https://github.com/lybell-art/ ) - * special thanks to Concernedape(Stardew Valley Producer), 진의(Unoffical XnbCli updater) - * - * xnb.js is licensed under the LGPL 3.0 License. - * -*/ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).XNB={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;n")}},{key:"parseTypeList",value:function(){var e=this.reader.parseTypeList();return["".concat(this.type,":").concat(e.length)].concat(e)}}],[{key:"isTypeOf",value:function(e){return"Microsoft.Xna.Framework.Content.ArrayReader"===e}},{key:"hasSubType",value:function(){return!0}}])}(w);function D(e,t){if(!e||"object"!==r(e))throw new Error("Invalid Data!");for(var n=[],a=e.length,i=0;i>(e>>3&30)&3)}}],[{key:"isTypeOf",value:function(e){switch(e){case"Microsoft.Xna.Framework.Content.CharReader":case"System.Char":return!0;default:return!1}}}])}(w);var b=function(e){function t(e,n){var r,a,i,u;if(o(this,t),null==e||null==n)throw new Error("Cannot create instance of DictionaryReader without Key and Value.");return a=this,i=f(i=t),(r=p(a,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(i,u||[],f(a).constructor):i.apply(a,u))).key=e,r.value=n,r}return s(t,e),l(t,[{key:"read",value:function(e,t){for(var n={},r=(new v).read(e),a=0;a")}},{key:"parseTypeList",value:function(){return[this.type].concat(this.key.parseTypeList(),this.value.parseTypeList())}}],[{key:"isTypeOf",value:function(e){return"Microsoft.Xna.Framework.Content.DictionaryReader"===e}},{key:"hasSubType",value:function(){return!0}}])}(w);function O(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}!function(e){function t(){return o(this,t),O(this,t,arguments)}s(t,e),l(t,[{key:"read",value:function(e){return e.readDouble()}},{key:"write",value:function(e,t,n){this.writeIndex(e,n),e.writeDouble(t)}}],[{key:"isTypeOf",value:function(e){switch(e){case"Microsoft.Xna.Framework.Content.DoubleReader":case"System.Double":return!0;default:return!1}}}])}(w);function F(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}!function(e){function t(){return o(this,t),F(this,t,arguments)}s(t,e),l(t,[{key:"read",value:function(e){var t=(new v).read(e),n=e.read(t);return{export:{type:this.type,data:n}}}},{key:"write",value:function(e,t,n){this.writeIndex(e,n);var r=t.export.data;(new v).write(e,r.byteLength,null),e.concat(r)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){switch(e){case"Microsoft.Xna.Framework.Content.EffectReader":case"Microsoft.Xna.Framework.Graphics.Effect":return!0;default:return!1}}}])}(w);function A(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var L=function(e){function t(){return o(this,t),A(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e){return e.readInt32()}},{key:"write",value:function(e,t,n){this.writeIndex(e,n),e.writeInt32(t)}}],[{key:"isTypeOf",value:function(e){switch(e){case"Microsoft.Xna.Framework.Content.Int32Reader":case"Microsoft.Xna.Framework.Content.EnumReader":case"System.Int32":return!0;default:return!1}}}])}(w);var _=function(e){function t(e){var n,r,a,i;return o(this,t),r=this,a=f(a=t),(n=p(r,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(a,i||[],f(r).constructor):a.apply(r,i))).reader=e,n}return s(t,e),l(t,[{key:"read",value:function(e,t){for(var n=(new v).read(e),r=[],a=0;a")}},{key:"parseTypeList",value:function(){var e=this.reader.parseTypeList();return["".concat(this.type,":").concat(e.length)].concat(e)}}],[{key:"isTypeOf",value:function(e){switch(e){case"Microsoft.Xna.Framework.Content.ListReader":case"System.Collections.Generic.List":return!0;default:return!1}}},{key:"hasSubType",value:function(){return!0}}])}(w);var N=function(e){function t(e){var n,r,a,i;return o(this,t),r=this,a=f(a=t),(n=p(r,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(a,i||[],f(r).constructor):a.apply(r,i))).reader=e,n}return s(t,e),l(t,[{key:"read",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=new V,r=e.peekByte(1);return r?null===t||this.reader.isValueType()?(n.read(e),this.reader.read(e)):t.read(e):(n.read(e),null)}},{key:"write",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;new V;null!==t?((null===n||this.reader.isValueType())&&e.writeByte(1),this.reader.write(e,t,this.reader.isValueType()?null:n)):e.writeByte(0)}},{key:"isValueType",value:function(){return!1}},{key:"type",get:function(){return"Nullable<".concat(this.reader.type,">")}},{key:"parseTypeList",value:function(){var e=this.reader.parseTypeList();return["".concat(this.type,":").concat(e.length)].concat(e)}}],[{key:"isTypeOf",value:function(e){return"Microsoft.Xna.Framework.Content.NullableReader"===e}},{key:"hasSubType",value:function(){return!0}}])}(w);function W(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}!function(e){function t(){return o(this,t),W(this,t,arguments)}s(t,e),l(t,[{key:"read",value:function(e){var t=new L;return{x:t.read(e),y:t.read(e)}}},{key:"write",value:function(e,t,n){this.writeIndex(e,n);var r=new L;r.write(e,t.x,null),r.write(e,t.y,null)}}],[{key:"isTypeOf",value:function(e){switch(e){case"Microsoft.Xna.Framework.Content.PointReader":case"Microsoft.Xna.Framework.Point":return!0;default:return!1}}}])}(w);!function(e){function t(e){var n,r,a,i;return o(this,t),r=this,a=f(a=t),(n=p(r,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(a,i||[],f(r).constructor):a.apply(r,i))).reader=e,n}s(t,e),l(t,[{key:"read",value:function(e,t){return this.reader.read(e,t)}},{key:"write",value:function(e,t,n){this.reader.write(e,t,this.reader.isValueType()?null:n)}},{key:"isValueType",value:function(){return!1}},{key:"type",get:function(){return"".concat(this.reader.type)}},{key:"parseTypeList",value:function(){return[].concat(this.reader.parseTypeList())}}],[{key:"isTypeOf",value:function(e){return"Microsoft.Xna.Framework.Content.ReflectiveReader"===e}},{key:"hasSubType",value:function(){return!0}}])}(w);function z(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var E=function(e){function t(){return o(this,t),z(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e){var t=new L;return{x:t.read(e),y:t.read(e),width:t.read(e),height:t.read(e)}}},{key:"write",value:function(e,t,n){this.writeIndex(e,n);var r=new L;r.write(e,t.x,null),r.write(e,t.y,null),r.write(e,t.width,null),r.write(e,t.height,null)}}],[{key:"isTypeOf",value:function(e){switch(e){case"Microsoft.Xna.Framework.Content.RectangleReader":case"Microsoft.Xna.Framework.Rectangle":return!0;default:return!1}}}])}(w);function H(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var U=function(e){function t(){return o(this,t),H(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e){return e.readSingle()}},{key:"write",value:function(e,t,n){this.writeIndex(e,n),e.writeSingle(t)}}],[{key:"isTypeOf",value:function(e){switch(e){case"Microsoft.Xna.Framework.Content.SingleReader":case"System.Single":return!0;default:return!1}}}])}(w),j=256;function q(e,t,n,r){for(var a=Array(r),i=0;i1&&void 0!==arguments[1]?arguments[1]:1e-7,n=e.length,r=Array(n),a=Math.abs(t/n),i=Array(n),o=0;o=Math.abs(a);){var s=c[0][0],f=c[0][1],d=q(s,f,X(e[s][s],e[f][f],e[s][f]),n);e=K(d,e),i=J(i,d),c=Q(e)}for(var y=0;y0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;o(this,e),this._values=[t,n,r]}return l(e,[{key:"x",get:function(){return this._values[0]},set:function(e){this._values[0]=e}},{key:"y",get:function(){return this._values[1]},set:function(e){this._values[1]=e}},{key:"z",get:function(){return this._values[2]},set:function(e){this._values[2]=e}},{key:"length",get:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}},{key:"lengthSq",get:function(){return this.x*this.x+this.y*this.y+this.z*this.z}},{key:"normalized",get:function(){return 0===this.length?null:e.multScalar(this,1/this.length)}},{key:"colorInt",get:function(){return this._values.map((function(e){var t=parseInt(255*e+.5);return Math.max(Math.min(t,255),0)}))}},{key:"clone",value:function(){return new e(this.x,this.y,this.z)}},{key:"set",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;return this._values[0]=e,this._values[1]=t,this._values[2]=n,this}},{key:"toVec4",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new te(this.x,this.y,this.z,e)}},{key:"addVector",value:function(e){return this._values[0]+=e.x,this._values[1]+=e.y,this._values[2]+=e.z,this}},{key:"addScaledVector",value:function(e,t){return this._values[0]+=e.x*t,this._values[1]+=e.y*t,this._values[2]+=e.z*t,this}},{key:"mult",value:function(e){return this._values[0]*=e,this._values[1]*=e,this._values[2]*=e,this}},{key:"multVector",value:function(e){return this._values[0]*=e.x,this._values[1]*=e.y,this._values[2]*=e.z,this}},{key:"clamp",value:function(e,t){var n=function(n){return e>n?e:t(n=e)?0:10&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t;o(this,e),this._values=[t,n,r,a]}return l(e,[{key:"x",get:function(){return this._values[0]},set:function(e){this._values[0]=e}},{key:"y",get:function(){return this._values[1]},set:function(e){this._values[1]=e}},{key:"z",get:function(){return this._values[2]},set:function(e){this._values[2]=e}},{key:"w",get:function(){return this._values[3]},set:function(e){this._values[3]=e}},{key:"length",get:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}},{key:"lengthSq",get:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}},{key:"normalized",get:function(){return 0===this.length?null:e.multScalar(this,1/this.length)}},{key:"xyz",get:function(){return new ee(this.x,this.y,this.z)}},{key:"splatX",get:function(){return new e(this.x)}},{key:"splatY",get:function(){return new e(this.y)}},{key:"splatZ",get:function(){return new e(this.z)}},{key:"splatW",get:function(){return new e(this.w)}},{key:"clone",value:function(){return new e(this.x,this.y,this.z,this.w)}},{key:"set",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e;return this._values[0]=e,this._values[1]=t,this._values[2]=n,this._values[3]=r,this}},{key:"toVec3",value:function(){return this.xyz}},{key:"addVector",value:function(e){return this._values[0]+=e.x,this._values[1]+=e.y,this._values[2]+=e.z,this._values[3]+=e.w,this}},{key:"addScaledVector",value:function(e,t){return this._values[0]+=e.x*t,this._values[1]+=e.y*t,this._values[2]+=e.z*t,this._values[3]+=e.w*t,this}},{key:"subVector",value:function(e){return this._values[0]-=e.x,this._values[1]-=e.y,this._values[2]-=e.z,this._values[3]-=e.w,this}},{key:"mult",value:function(e){return this._values[0]*=e,this._values[1]*=e,this._values[2]*=e,this._values[3]*=e,this}},{key:"multVector",value:function(e){return this._values[0]*=e.x,this._values[1]*=e.y,this._values[2]*=e.z,this._values[3]*=e.w,this}},{key:"reciprocal",value:function(){return this._values[0]=1/this._values[0],this._values[1]=1/this._values[1],this._values[2]=1/this._values[2],this._values[3]=1/this._values[3],this}},{key:"clamp",value:function(e,t){var n=function(n){return e>n?e:te?0:1>8,r[a+2]=255&t,r[a+3]=t>>8;for(var i=0;i<4;i++)r[a+4+i]=n[4*i+0]|n[4*i+1]<<2|n[4*i+2]<<4|n[4*i+3]<<6}function se(e,t,n,r,a){var i,o=le(e),u=le(t);if(o<=u)i=n.slice();else{var l=[u,o];o=l[0],u=l[1],i=n.map((function(e){return 0===e?1:1===e?0:e}))}ce(o,u,i,r,a)}function fe(e,t,n,r,a){var i,o=le(e),u=le(t);if(o=128||!a)){var y=this._remap[l],S=(t[4*u+3]+1)/256;this._weights[y]+=i?S:1,this._remap[u]=y;break}}else this._remap[u]=-1;for(var p=0;p=r?e:(r=o,i)}),0);return a+=r,i}));if(au&&(i=n[c],u=s)}this.start=a.clampGrid().clone(),this.end=i.clampGrid().clone()}}}])}(Se),ge=function(e){function t(e){var n;o(this,t);(n=de(this,t,[e])).iterationCount=e.flags&j?8:1,n.bestError=1/0,n.metric=new te(1),0!=(32&n.flags)&&n.metric.set(.2126,.7152,.0722,0);var r=n.colors,a=r.points,i=r.weights;return n.principle=ne(a,i),n.order=new Uint8Array(128),n.pointsWeights=[],n.xSum_wSum=new te(0),n}return s(t,e),l(t,[{key:"constructOrdering",value:function(e,t){var n=this.makeOrder(e);return this.copyOrderToThisOrder(n,t),!!this.checkOrderUnique(n,t)&&(this.copyOrderWeight(n),!0)}},{key:"compress3",value:function(e,t){this.compressBase((function(e){var t=e[0],n=e[2],r=e[3],a=new te(.5,.5,.5,1/4),i=te.multiplyAdd(n,a,t),o=i.splatW,u=te.multiplyAdd(n,a,r);return{ax:i,aa:o,bx:u,bb:u.splatW,ab:te.multVector(n,a).splatW}}),(function(n,r,a){return se(n,r,a,e,t)}),2)}},{key:"compress4",value:function(e,t){this.compressBase((function(e){var t=e[0],n=e[1],r=e[2],a=e[3],i=new te(1/3,1/3,1/3,1/9),o=new te(2/3,2/3,2/3,4/9),u=new te(2/9),l=te.multiplyAdd(r,i,te.multiplyAdd(n,o,t)),c=l.splatW,s=te.multiplyAdd(n,i,te.multiplyAdd(r,o,a));return{ax:l,aa:c,bx:s,bb:s.splatW,ab:te.multVector(u,te.add(n,r)).splatW}}),(function(n,r,a){return fe(n,r,a,e,t)}),3)}},{key:"compressBase",value:function(e,t){var r=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;this.constructOrdering(this.principle,0);var i={start:new te(0),end:new te(0),error:this.bestError,iteration:0,bestI:0,bestJ:0};3===a&&(i.bestK=0);for(var o=function(t,a){var o=e(t),u=r.computeOptimalPoints(o);return u.error2&&void 0!==arguments[2]?arguments[2]:2,r=this.colors.count,a=function(t,r,a){var i={bestI:t,bestJ:2===n?a:r,iteration:e};return 3===n&&(i.bestK=a),i},i=new te(0),o=0;o15?15:t}function me(e,t,n,r){var a=ve(e,t,5),i=ve(e,t,7);a.error<=i.error?function(e,t,n){var r=e.min,a=e.max,i=e.indices;if(r>a){Ie(a,r,i.map((function(e){return 0===e?1:1===e?0:e<=5?7-e:e})),t,n)}else Ie(r,a,i,t,n)}(a,n,r):function(e,t,n){var r=e.min,a=e.max,i=e.indices;if(r>a){Ie(a,r,i.map((function(e){return 0===e?1:1===e?0:9-e})),t,n)}else Ie(r,a,i,t,n)}(i,n,r)}function ve(e,t,n){var r=function(e,t,n){for(var r=255,a=0,i=0;i<16;i++){if(0!=(t&1<a&&(a=o)):(oa&&(a=o))}}r>a&&(r=a);a-r>8*s&255;r[o]=f,o++}}}function Re(e){var t=e>>11&31,n=e>>5&63,r=31&e;return[t<<3|t>>2,n<<2|n>>4,r<<3|r>>2,255]}function ke(e,t,n){var r=e.map((function(e,r){return Math.floor(e*(1-n)+t[r]*n)}));return r[3]=255,r}function Te(e,t,n,r){for(var a=function(e,t,n){var r=e[t]|e[t+1]<<8,a=e[t+2]|e[t+3]<<8,i=Re(r),o=Re(a);return[i,o,ke(i,o,n&&r<=a?.5:1/3),n&&r<=a?[0,0,0,0]:ke(i,o,2/3)]}(t,n,r),i=function(e,t){for(var n=t+4,r=new Uint8Array(16),a=0;a<4;a++){var i=e[n+a];r[4*a+0]=3&i,r[4*a+1]=i>>2&3,r[4*a+2]=i>>4&3,r[4*a+3]=i>>6&3}return r}(t,n),o=0;o<16;o++)for(var u=0;u<4;u++)e[4*o+u]=a[i[o]][u]}function Be(e){for(var t=0;t<4;t++)for(var n=0;n<4;n++)e(n,t)}function Ce(e){var t=7&e,n=280&e,r=96&e;return 2!=t&&4!=t&&(t=1),16!=n&&n!=j&&(n=8),64!=r&&(r=32),t|n|r|128&e}function Me(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.x,a=void 0===r?0:r,i=n.y,o=void 0===i?0:i,u=n.width,l=void 0===u?0:u,c=n.height,s=void 0===c?0:c,f=0;Be((function(n,r){var i=a+n,u=o+r;if(i>4}}(e,t,n):0!=(4&r)&&function(e,t,n){for(var r=t[n+0],a=t[n+1],i=De(r,a,r<=a?5:7),o=new Uint8Array(16),u=0,l=2,c=0;c<2;c++){for(var s=0,f=0;f<3;f++)s|=t[n+l]<<8*f,l++;for(var d=0;d<8;d++){var y=s>>3*d&7;o[u]=y,u++}}for(var S=0;S<16;++S)e[4*S+3]=i[o[S]]}(e,t,n)}function Ve(e,t,n,r,a){var i=0!=(1&(a=Ce(a)))?8:16,o=0;!function(e,t,n){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{},n=t.x,r=void 0===n?0:n,a=t.y,i=void 0===a?0:a,o=t.width,u=void 0===o?0:o,l=t.height,c=void 0===l?0:l,s=new Uint8Array(64),f=0,d=0;return Be((function(t,n){var a=r+t,o=i+n;if(a>n&Math.pow(2,t)-1}function Le(e,t,n,r){var a=Math.round(e/255*31),i=Math.round(t/255*31),o=Math.round(n/255*31);return Math.round(r/255)<<15|a<<10|i<<5|o}function _e(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Ne=function(e){function t(){return o(this,t),_e(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e){var t=new L,n=new v,r=t.read(e),a=n.read(e),i=n.read(e),o=n.read(e),u=null,l=null;o>1&&console.warn("Found mipcount of ".concat(o,", only the first will be used."));var c=n.read(e);a*i*4>c&&(u=a>>16&65535,l=i>>16&65535,(a&=65535)*(i&=65535)*4!==c&&console.warn("invalid width & height! ".concat(a," x ").concat(i)));var s=e.read(c);if(4==r)s=Fe(s,a,i,Pe);else if(5==r)s=Fe(s,a,i,Ge);else if(6==r)s=Fe(s,a,i,be);else if(2==r)s=function(e){for(var t,n,r,a=new Uint8Array(e),i=a.length/2,o=new Uint8Array(4*i),u=0;u>15&1,[(r=[Ae(t,5,10),Ae(t,5,5),Ae(t,5,0)].map((function(e){return e<<3|e>>2})))[0],r[1],r[2],255*n]);o[4*u]=l[0],o[4*u+1]=l[1],o[4*u+2]=l[2],o[4*u+3]=l[3]}return o}(s);else if(0!=r)throw new Error("Non-implemented Texture2D format type (".concat(r,") found."));s instanceof ArrayBuffer&&(s=new Uint8Array(s));for(var f=0;f>8}return r}(u)),a.write(e,u.length,null),e.concat(u)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"Microsoft.Xna.Framework.Content.Texture2DReader"===e}}])}(w);function We(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var ze=function(e){function t(){return o(this,t),We(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e){var t=new U;return{x:t.read(e),y:t.read(e),z:t.read(e)}}},{key:"write",value:function(e,t,n){this.writeIndex(e,n);var r=new U;r.write(e,t.x,null),r.write(e,t.y,null),r.write(e,t.z,null)}}],[{key:"isTypeOf",value:function(e){switch(e){case"Microsoft.Xna.Framework.Content.Vector3Reader":case"Microsoft.Xna.Framework.Vector3":return!0;default:return!1}}}])}(w);function Ee(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}!function(e){function t(){return o(this,t),Ee(this,t,arguments)}s(t,e),l(t,[{key:"read",value:function(e,t){var n=new L,r=new U,a=new N(new G);return{texture:t.read(e),glyphs:t.read(e),cropping:t.read(e),characterMap:t.read(e),verticalLineSpacing:n.read(e),horizontalSpacing:r.read(e),kerning:t.read(e),defaultCharacter:a.read(e)}}},{key:"write",value:function(e,t,n){var r=new L,a=new G,i=new U,o=new N(a),u=new Ne,l=new _(new E),c=new _(a),s=new _(new ze);this.writeIndex(e,n);try{u.write(e,t.texture,n),e.alloc(1e5),l.write(e,t.glyphs,n),l.write(e,t.cropping,n),c.write(e,t.characterMap,n),r.write(e,t.verticalLineSpacing,null),i.write(e,t.horizontalSpacing,null),s.write(e,t.kerning,n),o.write(e,t.defaultCharacter,null)}catch(e){throw e}}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"Microsoft.Xna.Framework.Content.SpriteFontReader"===e}},{key:"parseTypeList",value:function(){return["SpriteFont","Texture2D","List","Rectangle","List","Rectangle","List","Char",null,null,"List","Vector3","Nullable","Char"]}}])}(w);function He(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}!function(e){function t(){return o(this,t),He(this,t,arguments)}s(t,e),l(t,[{key:"read",value:function(e){var t=(new L).read(e),n=e.read(t);return{export:{type:this.type,data:n}}}},{key:"write",value:function(e,t,n){this.writeIndex(e,n);var r=t.export.data;(new L).write(e,r.byteLength,null),e.concat(r)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"xTile.Pipeline.TideReader"===e}}])}(w);function Ue(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}!function(e){function t(){return o(this,t),Ue(this,t,arguments)}s(t,e),l(t,[{key:"read",value:function(e){var t=new L,n=new v,r=t.read(e),a=n.read(e),i=n.read(e),o=n.read(e);o>1&&console.warn("Found mipcount of ".concat(o,", only the first will be used."));var u=n.read(e),l=e.read(u);if(l=new Uint8Array(l),0!=r)throw new Error("Compressed texture format is not supported!");for(var c=0;c","String","Nullable","String",null,"Nullable","String","Nullable","String",null,"Nullable","String","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function Ke(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Je=function(e){function t(){return o(this,t),Ke(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new N(new M);return{ResponsePoint:n.read(e,t),Script:n.read(e,t),Text:n.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new N(new M);this.writeIndex(e,n),r.write(e,t.ResponsePoint,n),r.write(e,t.Script,n),r.write(e,t.Text,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.Movies.CharacterResponse"===e}},{key:"parseTypeList",value:function(){return["CharacterResponse","Nullable:1","String","Nullable:1","String","Nullable:1","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function Ye(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Ze=function(e){function t(){return o(this,t),Ye(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new N(new Je);return{BeforeMovie:n.read(e,t),DuringMovie:n.read(e,t),AfterMovie:n.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new N(new Je);this.writeIndex(e,n),r.write(e,t.BeforeMovie,n),r.write(e,t.DuringMovie,n),r.write(e,t.AfterMovie,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.Movies.SpecialResponses"===e}},{key:"parseTypeList",value:function(){return["SpecialResponses","Nullable:7"].concat(Je.parseTypeList(),["Nullable:7"],Je.parseTypeList(),["Nullable:7"],Je.parseTypeList())}},{key:"type",value:function(){return"Reflective"}}])}(w);function et(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var tt=function(e){function t(){return o(this,t),et(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new N(new M),r=new N(new _(new M)),a=new N(new Ze);return{Tag:t.read(e),Response:n.read(e,t)||"like",Whitelist:r.read(e,t)||[],SpecialResponses:a.read(e,t),ID:t.read(e)}}},{key:"write",value:function(e,t,n){var r=new M,a=new N(new M),i=new N(new _(new M)),o=new N(new Ze);this.writeIndex(e,n),r.write(e,t.Tag,n),a.write(e,t.Response,n),i.write(e,t.Whitelist,n),o.write(e,t.SpecialResponses,n),r.write(e,t.ID,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.Movies.MovieReaction"===e}},{key:"parseTypeList",value:function(){return["MovieReaction","String","Nullable:1","String","Nullable>:2","List","String","Nullable:25"].concat(Ze.parseTypeList(),["String"])}},{key:"type",value:function(){return"Reflective"}}])}(w);function nt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var rt=function(e){function t(){return o(this,t),nt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new N(new _(new tt));return{NPCName:t.read(e),Reactions:n.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new M,a=new N(new _(new tt));this.writeIndex(e,n),r.write(e,t.NPCName,n),a.write(e,t.Reactions,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.Movies.MovieCharacterReaction"===e}},{key:"parseTypeList",value:function(){return["MovieCharacterReaction","String","Nullable>:34","List"].concat(tt.parseTypeList())}},{key:"type",value:function(){return"Reflective"}}])}(w);function at(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var it=function(e){function t(){return o(this,t),at(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new L,r=new N(new _(new M));return{ID:t.read(e),Name:t.read(e),DisplayName:t.read(e),Description:t.read(e),Price:n.read(e),Texture:t.read(e),SpriteIndex:n.read(e),ItemTags:r.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new L,a=new M,i=new N(new _(new M));this.writeIndex(e,n),a.write(e,t.ID,n),a.write(e,t.Name,n),a.write(e,t.DisplayName,n),a.write(e,t.Description,n),r.write(e,t.Price,null),a.write(e,t.Texture,n),r.write(e,t.SpriteIndex,null),i.write(e,t.ItemTags,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.Movies.ConcessionItemData"===e}},{key:"parseTypeList",value:function(){return["ConcessionItemData","String","String","String","String",null,"String",null,"Nullable>:2","List","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function ot(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var ut=function(e){function t(){return o(this,t),ot(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new N(new _(new M));return{Name:t.read(e),LovedTags:n.read(e,t),LikedTags:n.read(e,t),DislikedTags:n.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new M,a=new N(new _(new M));this.writeIndex(e,n),r.write(e,t.Name,n),a.write(e,t.LovedTags,n),a.write(e,t.LikedTags,n),a.write(e,t.DislikedTags,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.Movies.ConcessionTaste"===e}},{key:"parseTypeList",value:function(){return["ConcessionTaste","String","Nullable>:2","List","String","Nullable>:2","List","String","Nullable>:2","List","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function lt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var ct=function(e){function t(){return o(this,t),lt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new L,r=new U;return{RequiredPopulation:n.read(e),Chance:Math.round(1e5*r.read(e))/1e5,ItemId:t.read(e),MinQuantity:n.read(e),MaxQuantity:n.read(e)}}},{key:"write",value:function(e,t,n){var r=new L,a=new U,i=new M;this.writeIndex(e,n),r.write(e,t.RequiredPopulation,null),a.write(e,t.Chance,null),i.write(e,t.ItemId,n),r.write(e,t.MinQuantity,null),r.write(e,t.MaxQuantity,null)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.FishPonds.FishPondReward"===e}},{key:"parseTypeList",value:function(){return["FishPondReward",null,null,"String",null,null]}},{key:"type",value:function(){return"Reflective"}}])}(w);function st(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var ft=function(e){function t(){return o(this,t),st(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new L,r=new N(new b(new L,new _(new M))),a=new N(new b(new M,new M));return{Id:t.read(e),RequiredTags:t.read(e),Precedence:n.read(e),SpawnTime:n.read(e),ProducedItems:t.read(e),PopulationGates:r.read(e,t),CustomFields:a.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new M,a=new _(new M),i=new L,o=new _(new ct),u=new N(new b(new L,new _(new M))),l=new N(new b(new M,new M));this.writeIndex(e,n),r.write(e,t.Id,n),a.write(e,t.RequiredTags,n),i.write(e,t.Precedence,null),i.write(e,t.SpawnTime,null),o.write(e,t.ProducedItems,n),u.write(e,t.PopulationGates,n),l.write(e,t.CustomFields,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.FishPonds.FishPondData"===e}},{key:"parseTypeList",value:function(){return["FishPondData","String","List","String",null,null,"List:6"].concat(ct.parseTypeList(),["Nullable>>:4","Dictionary>","Int32","List","String","Nullable>:3","Dictionary","String","String"])}},{key:"type",value:function(){return"Reflective"}}])}(w);function dt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var yt=function(e){function t(){return o(this,t),dt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new N(new _(new M)),r=new N(new M),a=new V;return{Id:r.read(e),FirstItemTags:n.read(e,t),SecondItemTags:n.read(e,t),SpendingRightItem:a.read(e),CraftedItemID:r.read(e,t),CraftedItemIDs:n.read(e,t),CraftedItemIdFeminine:r.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new N(new _(new M)),a=new N(new M),i=new V;this.writeIndex(e,n),a.write(e,t.Id,n),r.write(e,t.FirstItemTags,n),r.write(e,t.SecondItemTags,n),i.write(e,t.SpendingRightItem,null),a.write(e,t.CraftedItemID,n),r.write(e,t.CraftedItemIDs,n),a.write(e,t.CraftedItemIdFeminine,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.Crafting.TailorItemRecipe"===e}},{key:"parseTypeList",value:function(){return["TailorItemRecipe","Nullable:1","String","Nullable>:2","List","String","Nullable>:2","List","String",null,"Nullable:1","String","Nullable>:2","List","String","Nullable:1","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function St(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var pt=function(e){function t(){return o(this,t),St(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){return{Type:t.read(e),Key:t.read(e),Value:t.read(e)}}},{key:"write",value:function(e,t,n){var r=new M;this.writeIndex(e,n),r.write(e,t.Type,n),r.write(e,t.Key,n),r.write(e,t.Value,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.HomeRenovations.RenovationValue"===e}},{key:"parseTypeList",value:function(){return["RenovationValue","String","String","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function ht(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var gt=function(e){function t(){return o(this,t),ht(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e){var n=g(f(t.prototype),"read",this).call(this,e);return{X:n.x,Y:n.y,Width:n.width,Height:n.height}}},{key:"write",value:function(e,n,r){var a=n.X,i=n.Y,o=n.Width,u=n.Height;g(f(t.prototype),"write",this).call(this,e,{x:a,y:i,width:o,height:u},r)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return!!g(f(t),"isTypeOf",this).call(this,e)||"StardewValley.GameData.HomeRenovations.Rect"===e}},{key:"parseTypeList",value:function(){return["Rect"]}},{key:"type",value:function(){return"Reflective"}}])}(E);function wt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var mt=function(e){function t(){return o(this,t),wt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){return{Rects:t.read(e)}}},{key:"write",value:function(e,t,n){var r=new _(new gt);this.writeIndex(e,n),r.write(e,t.Rects,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.HomeRenovations.RectGroup"===e}},{key:"parseTypeList",value:function(){return["RectGroup","List","Rect"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function vt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Dt=function(e){function t(){return o(this,t),vt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new V,r=new L,a=new N(new _(new mt)),i=new N(new M),o=new N(new b(new M,new M));return{TextStrings:t.read(e),AnimationType:t.read(e),CheckForObstructions:n.read(e),Price:r.read(e),RoomId:i.read(e,t),Requirements:t.read(e),RenovateActions:t.read(e),RectGroups:a.read(e,t),SpecialRect:i.read(e,t),CustomFields:o.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new V,a=new L,i=new M,o=new _(new pt),u=new N(new _(new mt)),l=new N(new M),c=new N(new b(new M,new M));this.writeIndex(e,n),i.write(e,t.TextStrings,n),i.write(e,t.AnimationType,n),r.write(e,t.CheckForObstructions,null),a.write(e,t.Price,null),l.write(e,t.RoomId,n),o.write(e,t.Requirements,n),o.write(e,t.RenovateActions,n),u.write(e,t.RectGroups,n),l.write(e,t.SpecialRect,n),c.write(e,t.CustomFields,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.HomeRenovations.HomeRenovation"===e}},{key:"parseTypeList",value:function(){return["HomeRenovation","String","String",null,null,"Nullable","String","List"].concat(pt.parseTypeList(),["List"],pt.parseTypeList(),["Nullable>:4","List"],mt.parseTypeList(),["Nullable","String","Nullable>:3","Dictionary","String","String"])}},{key:"type",value:function(){return"Reflective"}}])}(w);function It(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Rt=function(e){function t(){return o(this,t),It(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new L;return{Name:t.read(e),Index:n.read(e),Sprite:t.read(e),Color:t.read(e),Items:t.read(e),Pick:n.read(e),RequiredItems:n.read(e),Reward:t.read(e)}}},{key:"write",value:function(e,t,n){var r=new L,a=new M;this.writeIndex(e,n),a.write(e,t.Name,n),r.write(e,t.Index,null),a.write(e,t.Sprite,n),a.write(e,t.Color,n),a.write(e,t.Items,n),r.write(e,t.Pick,null),r.write(e,t.RequiredItems,null),a.write(e,t.Reward,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){switch(e){case"StardewValley.GameData.BundleData":case"StardewValley.GameData.Bundles.BundleData":return!0;default:return!1}}},{key:"parseTypeList",value:function(){return["BundleData","String",null,"String","String","String",null,null,"String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function kt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Tt=function(e){function t(){return o(this,t),kt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){return{Id:t.read(e),Bundles:t.read(e)}}},{key:"write",value:function(e,t,n){var r=new M,a=new _(new Rt);this.writeIndex(e,n),r.write(e,t.Id,n),a.write(e,t.Bundles,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.Bundles.BundleSetData"===e}},{key:"parseTypeList",value:function(){return["BundleSetData","String","List"].concat(Rt.parseTypeList())}},{key:"type",value:function(){return"Reflective"}}])}(w);function Bt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Ct=function(e){function t(){return o(this,t),Bt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new N(new _(new Tt)),r=new N(new _(new Rt));return{AreaName:t.read(e),Keys:t.read(e),BundleSets:n.read(e,t),Bundles:r.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new M,a=new N(new _(new Tt)),i=new N(new _(new Rt));this.writeIndex(e,n),r.write(e,t.AreaName,n),r.write(e,t.Keys,n),a.write(e,t.BundleSets,n),i.write(e,t.Bundles,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.Bundles.RandomBundleData"===e}},{key:"parseTypeList",value:function(){return["RandomBundleData","String","String","Nullable>:14","List"].concat(Tt.parseTypeList(),["Nullable>:11","List"],Rt.parseTypeList())}},{key:"type",value:function(){return"Reflective"}}])}(w);function Mt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var $t=function(e){function t(){return o(this,t),Mt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){return{RequiredTags:new N(new M).read(e,t)||"",Value:t.read(e)}}},{key:"write",value:function(e,t,n){var r=new M,a=new N(new M);this.writeIndex(e,n),a.write(e,t.RequiredTags,n),r.write(e,t.Value,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){switch(e){case"StardewValley.GameData.SpecialOrders.RandomizedElementItem":case"StardewValley.GameData.RandomizedElementItem":return!0;default:return!1}}},{key:"parseTypeList",value:function(){return["RandomizedElementItem","Nullable","String","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function xt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Vt=function(e){function t(){return o(this,t),xt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){return{Name:t.read(e),Values:t.read(e)}}},{key:"write",value:function(e,t,n){var r=new M,a=new _(new $t);this.writeIndex(e,n),r.write(e,t.Name,n),a.write(e,t.Values,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){switch(e){case"StardewValley.GameData.SpecialOrders.RandomizedElement":case"StardewValley.GameData.RandomizedElement":return!0;default:return!1}}},{key:"parseTypeList",value:function(){return["RandomizedElement","String","List"].concat($t.parseTypeList())}},{key:"type",value:function(){return"Reflective"}}])}(w);function Pt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Gt=function(e){function t(){return o(this,t),Pt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){return{Type:t.read(e),Text:t.read(e),RequiredCount:t.read(e),Data:t.read(e)}}},{key:"write",value:function(e,t,n){var r=new M,a=new b(new M,new M);this.writeIndex(e,n),r.write(e,t.Type,n),r.write(e,t.Text,n),r.write(e,t.RequiredCount,n),a.write(e,t.Data,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){switch(e){case"StardewValley.GameData.SpecialOrders.SpecialOrderObjectiveData":case"StardewValley.GameData.SpecialOrderObjectiveData":return!0;default:return!1}}},{key:"parseTypeList",value:function(){return["SpecialOrderObjectiveData","String","String","String","Dictionary","String","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function bt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Ot=function(e){function t(){return o(this,t),bt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){return{Type:t.read(e),Data:t.read(e)}}},{key:"write",value:function(e,t,n){var r=new M,a=new b(new M,new M);this.writeIndex(e,n),r.write(e,t.Type,n),a.write(e,t.Data,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){switch(e){case"StardewValley.GameData.SpecialOrders.SpecialOrderRewardData":case"StardewValley.GameData.SpecialOrderRewardData":return!0;default:return!1}}},{key:"parseTypeList",value:function(){return["SpecialOrderRewardData","String","Dictionary","String","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function Ft(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var At=function(e){function t(){return o(this,t),Ft(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new L,r=new V,a=new N(new M),i=new N(new _(new Vt)),o=new N(new b(new M,new M));return{Name:t.read(e),Requester:t.read(e),Duration:n.read(e),Repeatable:r.read(e),RequiredTags:a.read(e,t),Condition:a.read(e,t),OrderType:a.read(e,t),SpecialRule:a.read(e,t),Text:t.read(e),ItemToRemoveOnEnd:a.read(e,t),MailToRemoveOnEnd:a.read(e,t),RandomizedElements:i.read(e,t),Objectives:t.read(e),Rewards:t.read(e),CustomFields:o.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new L,a=new V,i=new M,o=new N(new M),u=new N(new _(new Vt)),l=new _(new Gt),c=new _(new Ot),s=new N(new b(new M,new M));this.writeIndex(e,n),i.write(e,t.Name,n),i.write(e,t.Requester,n),r.write(e,t.Duration,null),a.write(e,t.Repeatable,null),o.write(e,t.RequiredTags,n),o.write(e,t.Condition,n),o.write(e,t.OrderType,n),o.write(e,t.SpecialRule,n),i.write(e,t.Text,n),o.write(e,t.ItemToRemoveOnEnd,n),o.write(e,t.MailToRemoveOnEnd,n),u.write(e,t.RandomizedElements,n),l.write(e,t.Objectives,n),c.write(e,t.Rewards,n),s.write(e,t.CustomFields,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.SpecialOrders.SpecialOrderData"===e}},{key:"parseTypeList",value:function(){return["SpecialOrderData","String","String",null,null,"Nullable","String","Nullable","String","Nullable","String","Nullable","String","String","Nullable","String","Nullable","String","Nullable>:8","List"].concat(Vt.parseTypeList(),["List"],Gt.parseTypeList(),["List"],Ot.parseTypeList(),["Nullable>:3","Dictionary","String","String"])}},{key:"type",value:function(){return"Reflective"}}])}(w);function Lt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var _t=function(e){function t(){return o(this,t),Lt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new N(new M),r=new N(new b(new M,new M)),a=new V;return{ID:t.read(e),TooltipStringPath:t.read(e),MapName:t.read(e),IconTexture:n.read(e,t),WorldMapTexture:n.read(e,t),SpawnMonstersByDefault:a.read(e),ModData:r.read(e,t),CustomFields:r.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new M,a=new N(new M),i=new N(new b(new M)),o=new V;this.writeIndex(e,n),r.write(e,t.ID,n),r.write(e,t.TooltipStringPath,n),r.write(e,t.MapName,n),a.write(e,t.IconTexture,n),a.write(e,t.WorldMapTexture,n),o.write(e,t.SpawnMonstersByDefault,null),i.write(e,t.ModData,n),i.write(e,t.CustomFields,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.ModFarmType"===e}},{key:"parseTypeList",value:function(){return["ModFarmType","String","String","String","Nullable:1","String","Nullable:1","String",null,"Nullable>:3","Dictionary","String","String","Nullable>:3","Dictionary","String","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function Nt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Wt=function(e){function t(){return o(this,t),Nt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new L,r=new U,a=new V,i=new N(new M),o=new N(new b(new M,new M));return{ID:t.read(e),LanguageCode:t.read(e),ButtonTexture:t.read(e),UseLatinFont:a.read(e),FontFile:i.read(e,t),FontPixelZoom:r.read(e),FontApplyYOffset:a.read(e),SmallFontLineSpacing:n.read(e),UseGenderedCharacterTranslations:a.read(e),NumberComma:i.read(e,t),TimeFormat:t.read(e),ClockTimeFormat:t.read(e),ClockDateFormat:t.read(e),CustomFields:o.read(e,t)}}},{key:"write",value:function(e,t,n){var r=new M,a=new L,i=new U,o=new V,u=new N(new M),l=new N(new b(new M,new M));this.writeIndex(e,n),r.write(e,t.ID,n),r.write(e,t.LanguageCode,n),r.write(e,t.ButtonTexture,n),o.write(e,t.UseLatinFont,null),u.write(e,t.FontFile,n),i.write(e,t.FontPixelZoom,null),o.write(e,t.FontApplyYOffset,null),a.write(e,t.SmallFontLineSpacing,null),o.write(e,t.UseGenderedCharacterTranslations,null),u.write(e,t.NumberComma,n),r.write(e,t.TimeFormat,n),r.write(e,t.ClockTimeFormat,n),r.write(e,t.ClockDateFormat,n),l.write(e,t.CustomFields,n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.ModLanguage"===e}},{key:"parseTypeList",value:function(){return["ModLanguage","String","String","String",null,"Nullable:1","String",null,null,null,null,"Nullable:1","String","String","String","String","Nullable>:3","Dictionary","String","String"]}},{key:"type",value:function(){return"Reflective"}}])}(w);function zt(e,t,n){return t=f(t),p(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}var Et=function(e){function t(){return o(this,t),zt(this,t,arguments)}return s(t,e),l(t,[{key:"read",value:function(e,t){var n=new L,r=new V;return{ID:t.read(e),Texture:t.read(e),IsFlooring:r.read(e),Count:n.read(e)}}},{key:"write",value:function(e,t,n){var r=new L,a=new V,i=new M;this.writeIndex(e,n),i.write(e,t.ID,n),i.write(e,t.Texture,n),a.write(e,t.IsFlooring,null),r.write(e,t.Count,null)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(e){return"StardewValley.GameData.ModWallpaperOrFlooring"===e}},{key:"parseTypeList",value:function(){return["ModWallpaperOrFlooring","String","String",null,null]}},{key:"type",value:function(){return"Reflective"}}])}(w),Ht=Object.freeze({__proto__:null,MovieSceneReader:Qe,MovieCharacterReactionReader:rt,MovieReactionReader:tt,SpecialResponsesReader:Ze,CharacterResponseReader:Je,ConcessionItemDataReader:it,ConcessionTasteReader:ut,FishPondDataReader:ft,FishPondRewardReader:ct,TailorItemRecipeReader:yt,HomeRenovationReader:Dt,RenovationValueReader:pt,RectGroupReader:mt,RectReader:gt,RandomBundleDataReader:Ct,BundleSetDataReader:Tt,BundleDataReader:Rt,SpecialOrderDataReader:At,RandomizedElementReader:Vt,RandomizedElementItemReader:$t,SpecialOrderObjectiveDataReader:Gt,SpecialOrderRewardDataReader:Ot,ModFarmTypeReader:_t,ModLanguageReader:Wt,ModWallpaperOrFlooringReader:Et}),Ut={$Id:"String",$ItemId:"String",$RandomItemId:["String"],$MaxItems:"Int32",MinStack:"Int32",MaxStack:"Int32",Quality:"Int32",$ObjectInternalName:"String",$ObjectDisplayName:"String",ToolUpgradeLevel:"Int32",IsRecipe:"Boolean",$StackModifiers:["StardewValley.GameData.QuantityModifier"],StackModifierMode:"Int32",$QualityModifiers:["StardewValley.GameData.QuantityModifier"],QualityModifierMode:"Int32",$ModData:{String:"String"},$PerItemCondition:"String"},jt=n(n({},Ut),{},{$Condition:"String"}),qt=n(n({},jt),{},{$Season:"Int32",Chance:"Single"}),Xt=n(n({},Ut),{},{$Condition:"String",IgnoreBaseChance:"Boolean",IsMegaSuccess:"Boolean",IsDoubleMegaSuccess:"Boolean",AddToInventoryDirectly:"Boolean",CreateMultipleDebris:"Boolean"}),Qt=n(n({},jt),{},{Chance:"Single",$ForShavingEnchantment:"Boolean",$ScaledMinStackWhenShaving:"Int32",$ScaledMaxStackWhenShaving:"Int32"}),Kt=n(n({},jt),{},{Chance:"Double",ApplyGenerousEnchantment:"Boolean",OneDebrisPerDrop:"Boolean",Precedence:"Int32",ContinueOnDrop:"Boolean"}),Jt=n(n({},jt),{},{Chance:"Single",$Season:"Int32",$FishAreaId:"String",$BobberPosition:"Rectangle",$PlayerPosition:"Rectangle",MinFishingLevel:"Int32",MinDistanceFromShore:"Int32",MaxDistanceFromShore:"Int32",ApplyDailyLuck:"Boolean",CuriosityLureBuff:"Single",CatchLimit:"Int32",IsBossFish:"Boolean",$SetFlagOnCatch:"String",RequireMagicBait:"Boolean",Precedence:"Int32",IgnoreFishDataRequirements:"Boolean",CanBeInherited:"Boolean",$ChanceModifiers:["StardewValley.GameData.QuantityModifier"],ChanceModifierMode:"Int32",ChanceBoostPerLuckLevel:"Single",UseFishCaughtSeededRandom:"Boolean"}),Yt=n(n({},jt),{},{Chance:"Double",$Season:"Int32"}),Zt=n(n({},jt),{},{$OutputMethod:"String",CopyColor:"Boolean",CopyPrice:"Boolean",CopyQuality:"Boolean",$PreserveType:"String",$PreserveId:"String",IncrementMachineParentSheetIndex:"Int32",$PriceModifiers:["StardewValley.GameData.QuantityModifier"],PriceModifierMode:"Int32",$CustomData:{String:"String"}}),en=n(n({},jt),{},{Rarity:"Int32"}),tn=n(n({},jt),{},{Chance:"Double",$SetFlagOnPickup:"String",Precedence:"Int32"}),nn=n(n({},jt),{},{$TradeItemId:"String",TradeItemAmount:"Int32",Price:"Int32",$ApplyProfitMargins:"Boolean",AvailableStock:"Int32",AvailableStockLimit:"Int32",AvoidRepeat:"Boolean",UseObjectDataPrice:"Boolean",IgnoreShopPriceModifiers:"Boolean",$PriceModifiers:["StardewValley.GameData.QuantityModifier"],PriceModifierMode:"Int32",$AvailableStockModifiers:["StardewValley.GameData.QuantityModifier"],AvailableStockModifierMode:"Int32",$ActionsOnPurchase:["String"],$CustomFields:{String:"String"}}),rn=n(n({},jt),{},{$Season:"Int32",Chance:"Single"}),an={"StardewValley.GameData.GenericSpawnItemData":Ut,"StardewValley.GameData.GenericSpawnItemDataWithCondition":jt,"StardewValley.GameData.AudioCueData":{Id:"String",$FilePaths:["String"],$Category:"String",StreamedVoorbis:"Boolean",Looped:"Boolean",UseReverb:"Boolean",$CustomFields:{String:"String"}},"StardewValley.GameData.IncomingPhoneCallData":{$TriggerCondition:"String",$RingCondition:"String",$FromNpc:"String",$FromPortrait:"String",$FromDisplayName:"String",Dialogue:"String",IgnoreBaseChance:"Boolean",$SimpleDialogueSplitBy:"String",MaxCalls:"Int32",$CustomFields:{String:"String"}},"StardewValley.GameData.JukeboxTrackData":{Name:"String",$Available:"Boolean",$AlternativeTrackIds:["String"]},"StardewValley.GameData.MannequinData":{ID:"String",DisplayName:"String",Description:"String",Texture:"String",FarmerTexture:"String",SheetIndex:"Int32",DisplaysClothingAsMale:"Boolean",Cursed:"Boolean",$CustomFields:{String:"String"}},"StardewValley.GameData.MonsterSlayerQuestData":{DisplayName:"String",Targets:["String"],Count:"Int32",$RewardItmeId:"String",RewardItemPrice:"Int32",$RewardDialogue:"String",$RewardDialogueFlag:"String",$RewardFlag:"String",$RewardFlagAll:"String",$RewardMail:"String",$RewardMailAll:"String",$CustomFields:{String:"String"}},"StardewValley.GameData.PassiveFestivalData":{DisplayName:"String",Condition:"String",ShowOnCalendar:"Boolean",Season:"Int32",StartDay:"Int32",EndDay:"Int32",StartTime:"Int32",StartMessage:"String",OnlyShowMessageOnFirstDay:"Boolean",$MapReplacements:{String:"String"},$DailySetupMethod:"String",$CleanupMethod:"String",$CustomFields:{String:"String"}},"StardewValley.GameData.TriggerActionData":{Id:"String",Trigger:"String",Condition:"String",HostOnly:"Boolean",$Action:"String",$Actions:["String"],$CustomFields:{String:"String"},MarkActionApplied:"Boolean"},"StardewValley.GameData.TrinketData":{Id:"String",DisplayName:"String",Description:"String",Texture:"String",SheetIndex:"Int32",TrinketEffectClass:"String",DropsNaturally:"Boolean",CanBeReforged:"Boolean",$TrinketMetadata:{String:"String"}},"StardewValley.GameData.PlantableRule":{Id:"String",$Condition:"String",PlantedIn:"Int32",Result:"Int32",$DeniedMessage:"String"},"StardewValley.GameData.QuantityModifier":{Id:"String",$Condition:"String",Modification:"Int32",Amount:"Single",$RandomAmount:["Single"]},"StardewValley.GameData.StatIncrement":{$RequiredItemId:"String",$RequiredTags:["String"],StatName:"String"},"StardewValley.GameData.TemporaryAnimatedSpriteDefinition":{Id:"String",$Condition:"String",Texture:"String",SourceRect:"Rectangle",Interval:"Single",Frames:"Int32",Loops:"Int32",PositionOffset:"Vector2",Flicker:"Boolean",Flip:"Boolean",SortOffset:"Single",AlphaFade:"Single",Scale:"Single",ScaleChange:"Single",Rotation:"Single",RotationChange:"Single",$Color:"String"},"StardewValley.GameData.BigCraftables.BigCraftableData":{Name:"String",DisplayName:"String",Description:"String",Price:"Int32",Fragility:"Int32",CanBePlacedOutdoors:"Boolean",CanBePlacedIndoors:"Boolean",IsLamp:"Boolean",$Texture:"String",SpriteIndex:"Int32",$ContextTags:["String"],$CustomFields:{String:"String"}},"StardewValley.GameData.Buffs.BuffData":{DisplayName:"String",$Description:"String",IsDebuff:"Boolean",$GlowColor:"String",Duration:"Int32",MaxDuration:"Int32",IconTexture:"String",IconSpriteIndex:"Int32",$Effects:"StardewValley.GameData.Buffs.BuffAttributesData",$ActionsOnApply:["String"],$CustomFields:{String:"String"}},"StardewValley.GameData.Buffs.BuffAttributesData":{FarmingLevel:"Single",FishingLevel:"Single",MiningLevel:"Single",LuckLevel:"Single",ForagingLevel:"Single",MaxStamina:"Single",MagneticRadius:"Single",Speed:"Single",Defense:"Single",Attack:"Single"},"StardewValley.GameData.Buildings.BuildingData":{Name:"String",Description:"String",Texture:"String",$Skins:["StardewValley.GameData.Buildings.BuildingSkin"],DrawShadow:"Boolean",UpgradeSignTile:"Vector2",UpgradeSignHeight:"Single",Size:"Point",FadeWhenBehind:"Boolean",SourceRect:"Rectangle",SeasonOffset:"Point",DrawOffset:"Vector2",SortTileOffset:"Single",$CollisionMap:"String",$AdditionalPlacementTiles:["StardewValley.GameData.Buildings.BuildingPlacementTile"],$BuildingType:"String",$Builder:"String",$BuildCondition:"String",BuildDays:"Int32",BuildCost:"Int32",$BuildMaterials:["StardewValley.GameData.Buildings.BuildingMaterial"],$BuildingToUpgrade:"String",MagicalConstruction:"Boolean",BuildMenuDrawOffset:"Point",HumanDoor:"Point",AnimalDoor:"Rectangle",AnimalDoorOpenDuration:"Single",$AnimalDoorOpenSound:"String",AnimalDoorCloseDuration:"Single",$AnimalDoorCloseSound:"String",$NonInstancedIndoorLocation:"String",$IndoorMap:"String",$IndoorMapType:"String",MaxOccupants:"Int32",$ValidOccupantTypes:["String"],AllowAnimalPregnancy:"Boolean",$IndoorItemMoves:["StardewValley.GameData.Buildings.IndoorItemMove"],$IndoorItems:["StardewValley.GameData.Buildings.IndoorItemAdd"],$AddMailOnBuild:["String"],$MetaData:{String:"String"},$ModData:{String:"String"},HayCapacity:"Int32",$Chests:["StardewValley.GameData.Buildings.BuildingChest"],$DefaultAction:"String",AdditionalTilePropertyRadius:"Int32",AllowsFlooringUnderneath:"Boolean",$ActionTiles:["StardewValley.GameData.Buildings.BuildingActionTile"],$TileProperties:["StardewValley.GameData.Buildings.BuildingTileProperty"],$ItemConversions:["StardewValley.GameData.Buildings.BuildingItemConversion"],$DrawLayers:["StardewValley.GameData.Buildings.BuildingDrawLayer"],$CustomFields:{String:"String"}},"StardewValley.GameData.Buildings.BuildingActionTile":{Id:"String",Tile:"Point",Action:"String"},"StardewValley.GameData.Buildings.BuildingChest":{Id:"String",Type:"Int32",$Sound:"String",$InvalidItemMessage:"String",$InvalidItemMessageCondition:"String",$InvalidCountMessage:"String",$ChestFullMessage:"String",DisplayTile:"Vector2",DisplayHeight:"Single"},"StardewValley.GameData.Buildings.BuildingDrawLayer":{Id:"String",$Texture:"String",SourceRect:"Rectangle",DrawPosition:"Vector2",DrawInBackground:"Boolean",SortTileOffset:"Single",$OnlyDrawIfChestHasContents:"String",FrameDuration:"Int32",FrameCount:"Int32",FramesPerRow:"Int32",AnimalDoorOffset:"Point"},"StardewValley.GameData.Buildings.BuildingItemConversion":{Id:"String",RequiredTags:["String"],RequiredCount:"Int32",MaxDailyConversions:"Int32",SourceChest:"String",DestinationChest:"String",ProducedItems:["StardewValley.GameData.GenericSpawnItemDataWithCondition"]},"StardewValley.GameData.Buildings.BuildingMaterial":{ItemId:"String",Amount:"Int32"},"StardewValley.GameData.Buildings.BuildingPlacementTile":{TileArea:"Rectangle",OnlyNeedsToBePassable:"Boolean"},"StardewValley.GameData.Buildings.BuildingSkin":{Id:"String",$Name:"String",$Description:"String",Texture:"String",$Condition:"String",$BuildDays:"Int32",$BuildCost:"Int32",$BuildMaterials:["StardewValley.GameData.Buildings.BuildingMaterial"],ShowAsSeparateConstructionEntry:"Boolean",$Metadata:{String:"String"}},"StardewValley.GameData.Buildings.BuildingTileProperty":{Id:"String",Name:"String",$Value:"String",Layer:"String",TileArea:"Rectangle"},"StardewValley.GameData.Buildings.IndoorItemAdd":{Id:"String",ItemId:"String",Tile:"Point",Indestructible:"Boolean"},"StardewValley.GameData.Buildings.IndoorItemMove":{Id:"String",Source:"Point",Destination:"Point",Size:"Point",$UnlessItemId:"String"},"StardewValley.GameData.Characters.CharacterData":{DisplayName:"String",$BirthSeason:"Int32",BirthDay:"Int32",$HomeRegion:"String",Language:"Int32",Gender:"Int32",Age:"Int32",Manner:"Int32",SocialAnxiety:"Int32",Optimism:"Int32",IsDarkSkinned:"Boolean",CanBeRomanced:"Boolean",$LoveInterest:"String",Calendar:"Int32",SocialTab:"Int32",$CanSocialize:"String",CanReceiveGifts:"Boolean",CanGreetNearbyCharacters:"Boolean",$CanCommentOnPurchasedShopItems:"Boolean",$CanVisitIsland:"String",$IntroductionsQuest:"Boolean",$ItemDeliveryQuests:"String",PerfectionScore:"Boolean",EndSlideShow:"Int32",$SpouseAdopts:"String",$SpouseWantsChildren:"String",$SpouseGiftJealousy:"String",SpouseGiftJealousyFriendshipChange:"Int32",$SpouseRoom:"StardewValley.GameData.Characters.CharacterSpouseRoomData",$SpousePatio:"StardewValley.GameData.Characters.CharacterSpousePatioData",$SpouseFloors:["String"],$SpouseWallpapers:["String"],DumpsterDiveFriendshipEffect:"Int32",$DumpsterDiveEmote:"Int32",$FriendsAndFamily:{String:"String"},$FlowerDanceCanDance:"Boolean",$WinterStarGifts:["StardewValley.GameData.GenericSpawnItemDataWithCondition"],$WinterStarParticipant:"String",$UnlockConditions:"String",SpawnIfMissing:"Boolean",$Home:["StardewValley.GameData.Characters.CharacterHomeData"],$TextureName:"String",$Appearance:["StardewValley.GameData.Characters.CharacterAppearanceData"],$MugShotSourceRect:"Rectangle",Size:"Point",Breather:"Boolean",$BreathChestRect:"Rectangle",$BreathChestPosition:"Point",$Shadow:"StardewValley.GameData.Characters.CharacterShadowData",EmoteOffset:"Point",$ShakePortraits:["Int32"],KissSpriteIndex:"Int32",KissSpriteFacingRight:"Boolean",$HiddenProfileEmoteSound:"String",HiddenProfileEmoteDuration:"Int32",HiddenProfileEmoteStartFrame:"Int32",HiddenProfileEmoteFrameCount:"Int32",HiddenProfileEmoteFrameDuration:"Single",$FormerCharacterNames:["String"],FestivalVanillaActorIndex:"Int32",$CustomFields:{String:"String"}},"StardewValley.GameData.Characters.CharacterAppearanceData":{Id:"String",$Condition:"String",$Season:"Int32",Indoors:"Boolean",Outdoors:"Boolean",$Portrait:"String",$Sprite:"String",IsIslandAttire:"Boolean",Precedence:"Int32",Weight:"Int32"},"StardewValley.GameData.Characters.CharacterHomeData":{Id:"String",$Condition:"String",Location:"String",Tile:"Point",$Direction:"String"},"StardewValley.GameData.Characters.CharacterShadowData":{Visible:"Boolean",Offset:"Point",Scale:"Single"},"StardewValley.GameData.Characters.CharacterSpousePatioData":{$MapAsset:"String",MapSourceRect:"Rectangle",$SpriteAnimationFrames:["Array"],SpriteAnimationPixelOffset:"Point"},"StardewValley.GameData.Characters.CharacterSpouseRoomData":{$MapAsset:"String",MapSourceRect:"Rectangle"},"StardewValley.GameData.Crops.CropData":{Seasons:["Int32"],DaysInPhase:["Int32"],RegrowDays:"Int32",IsRaised:"Boolean",IsPaddyCrop:"Boolean",NeedsWatering:"Boolean",$PlantableLocationRules:["StardewValley.GameData.PlantableRule"],HarvestItemId:"String",HarvestMinStack:"Int32",HarvestMaxStack:"Int32",HarvestMaxIncreasePerFarmingLevel:"Single",ExtraHarvestChance:"Double",HarvestMethod:"Int32",HarvestMinQuality:"Int32",$HarvestMaxQuality:"Int32",$TintColors:["String"],Texture:"String",SpriteIndex:"Int32",CountForMonoculture:"Boolean",CountForPolyculture:"Boolean",$CustomFields:{String:"String"}},"StardewValley.GameData.FarmAnimals.FarmAnimalData":{$DisplayName:"String",$House:"String",Gender:"Int32",PurchasePrice:"Int32",SellPrice:"Int32",$ShopTexture:"String",ShopSourceRect:"Rectangle",$ShopDisplayName:"String",$ShopDescription:"String",$ShopMissingBuildingDescription:"String",$RequiredBuilding:"String",$UnlockCondition:"String",$AlternatePurchaseTypes:["StardewValley.GameData.FarmAnimals.AlternatePurchaseAnimals"],$EggItemIds:["String"],IncubationTime:"Int32",IncubatorParentSheetOffset:"Int32",$BirthText:"String",DaysToMature:"Int32",CanGetPregnant:"Boolean",DaysToProduce:"Int32",HarvestType:"Int32",$HarvestTool:"String",$ProduceItemIds:["StardewValley.GameData.FarmAnimals.FarmAnimalProduce"],$DeluxeProduceItemIds:["StardewValley.GameData.FarmAnimals.FarmAnimalProduce"],ProduceOnMature:"Boolean",FriendshipForFasterProduce:"Int32",DeluxeProduceMinimumFriendship:"Int32",DeluxeProduceCareDivisor:"Single",DeluxeProduceLuckMultiplier:"Single",ProfessionForHappinessBoost:"Int32",ProfessionForQualityBoost:"Int32",ProfessionForFasterProduce:"Int32",$Sound:"String",$BabySound:"String",Texture:"String",$HarvestedTexture:"String",$BabyTexture:"String",UseFlippedRightForLeft:"Boolean",SpriteWidth:"Int32",SpriteHeight:"Int32",EmoteOffset:"Point",SwimOffset:"Point",$Skins:["StardewValley.GameData.FarmAnimals.FarmAnimalSkin"],$ShadowWhenBabySwims:"StardewValley.GameData.FarmAnimals.FarmAnimalShadowData",$ShadowWhenBaby:"StardewValley.GameData.FarmAnimals.FarmAnimalShadowData",$ShadowWhenAdultSwims:"StardewValley.GameData.FarmAnimals.FarmAnimalShadowData",$ShadowWhenAdult:"StardewValley.GameData.FarmAnimals.FarmAnimalShadowData",CanSwim:"Boolean",BabiesFollowAdults:"Boolean",GrassEatAmount:"Int32",HappinessDrain:"Int32",UpDownPetHitboxTileSize:"Vector2",LeftRightPetHitboxTileSize:"Vector2",BabyUpDownPetHitboxTileSize:"Vector2",BabyLeftRightPetHitboxTileSize:"Vector2",$StatToIncrementOnProduce:["StardewValley.GameData.StatIncrement"],ShowInSummitCredits:"Boolean",$CustomFields:{String:"String"}},"StardewValley.GameData.FarmAnimals.AlternatePurchaseAnimals":{$Condition:"String",AnimalIds:["String"]},"StardewValley.GameData.FarmAnimals.FarmAnimalProduce":{$Id:"String",$Condition:"String",MinimumFriendship:"Int32",ItemId:"String"},"StardewValley.GameData.FarmAnimals.FarmAnimalShadowData":{Visible:"Boolean",$Offset:"Point",$Scale:"Single"},"StardewValley.GameData.FarmAnimals.FarmAnimalSkin":{Id:"String",Weight:"Single",$Texture:"String",$HarvestedTexture:"String",$BabyTexture:"String"},"StardewValley.GameData.Fences.FenceData":{Health:"Int32",RepairHealthAdjustmentMinimum:"Single",RepairHealthAdjustmentMaximum:"Single",Texture:"String",PlacementSound:"String",$RemovalSound:"String",$RemovalToolIds:["String"],$RemovalToolTypes:["String"],RemovalDebrisType:"Int32",$HeldObjectDrawOffset:"Vector2",LeftEndHeldObjectDrawX:"Single",RightEndHeldObjectDrawX:"Single"},"StardewValley.GameData.FloorsAndPaths.FloorPathData":{Id:"String",ItemId:"String",Texture:"String",Corner:"Point",WinterTexture:"String",WinterCorner:"Point",PlacementSound:"String",$RemovalSound:"String",RemovalDebrisType:"Int32",FootstepSound:"String",ConnectType:"Int32",ShadowType:"Int32",CornerSize:"Int32",FarmSpeedBuff:"Single"},"StardewValley.GameData.FruitTrees.FruitTreeData":{DisplayName:"String",Seasons:["Int32"],Fruit:["StardewValley.GameData.FruitTrees.FruitTreeFruitData"],Texture:"String",TextureSpriteRow:"Int32",$CustomFields:{String:"String"},$PlantableLocationRules:["StardewValley.GameData.PlantableRule"]},"StardewValley.GameData.FruitTrees.FruitTreeFruitData":qt,"StardewValley.GameData.GarbageCans.GarbageCanData":{DefaultBaseChance:"Single",BeforeAll:["StardewValley.GameData.GarbageCans.GarbageCanItemData"],AfterAll:["StardewValley.GameData.GarbageCans.GarbageCanItemData"],GarbageCans:{String:"StardewValley.GameData.GarbageCans.GarbageCanEntryData"}},"StardewValley.GameData.GarbageCans.GarbageCanEntryData":{BaseChance:"Single",Items:["StardewValley.GameData.GarbageCans.GarbageCanItemData"],$CustomFields:{String:"String"}},"StardewValley.GameData.GarbageCans.GarbageCanItemData":Xt,"StardewValley.GameData.GiantCrops.GiantCropData":{FromItemId:"String",HarvestItems:["StardewValley.GameData.GiantCrops.GiantCropHarvestItemData"],Texture:"String",TexturePosition:"Point",TileSize:"Point",Health:"Int32",Chance:"Single",$Condition:"String",$CustomFields:{String:"String"}},"StardewValley.GameData.GiantCrops.GiantCropHarvestItemData":Qt,"StardewValley.GameData.LocationContexts.LocationContextData":{$SeasonOverride:"Int32",$DefaultMusic:"String",$DefaultMusicCondition:"String",DefaultMusicDelayOneScreen:"Boolean",$Music:["StardewValley.GameData.Locations.LocationMusicData"],$DayAmbience:"String",$NightAmbience:"String",PlayRandomAmbientSounds:"Boolean",AllowRainTotem:"Boolean",$RainTotemAffectsContext:"String",$WeatherConditions:["StardewValley.GameData.LocationContexts.WeatherCondition"],$CopyWeatherFromLocation:"String",$ReviveLocations:["StardewValley.GameData.LocationContexts.ReviveLocation"],MaxPassOutCost:"Int32",$PassOutMail:["StardewValley.GameData.LocationContexts.PassOutMailData"],$PassOutLocations:["StardewValley.GameData.LocationContexts.ReviveLocation"],$CustomFields:{String:"String"}},"StardewValley.GameData.LocationContexts.PassOutMailData":{Id:"String",$Condition:"String",Mail:"String",MaxPassOutCost:"Int32",SkipRandomSelection:"Boolean"},"StardewValley.GameData.LocationContexts.ReviveLocation":{Id:"String",$Condition:"String",Location:"String",Position:"Point"},"StardewValley.GameData.LocationContexts.WeatherCondition":{Id:"String",$Condition:"String",Weather:"String"},"StardewValley.GameData.Locations.LocationData":{$DisplayName:"String",$DefaultArrivalTile:"Point",ExcludeFromNpcPathfinding:"Boolean",$CreateOnLoad:"StardewValley.GameData.Locations.CreateLocationData",$FormerLocationNames:["String"],$CanPlantHere:"Boolean",CanHaveGreenRainSpawns:"Boolean",$ArtifactSpots:["StardewValley.GameData.Locations.ArtifactSpotDropData"],$FishAreas:{String:"StardewValley.GameData.Locations.FishAreaData"},$Fish:["StardewValley.GameData.Locations.SpawnFishData"],$Forage:["StardewValley.GameData.Locations.SpawnForageData"],MinDailyWeeds:"Int32",MaxDailyWeeds:"Int32",FirstDayWeedMultiplier:"Int32",MinDailyForageSpawn:"Int32",MaxDailyForageSpawn:"Int32",MaxSpawnedForageAtOnce:"Int32",ChanceForClay:"Double",$Music:["StardewValley.GameData.Locations.LocationMusicData"],$MusicDefault:"String",MusicContext:"Int32",MusicIgnoredInRain:"Boolean",MusicIgnoredInSpring:"Boolean",MusicIgnoredInSummer:"Boolean",MusicIgnoredInFall:"Boolean",MusicIgnoredInFallDebris:"Boolean",MusicIgnoredInWinter:"Boolean",MusicIsTownTheme:"Boolean",$CustomFields:{String:"String"}},"StardewValley.GameData.Locations.ArtifactSpotDropData":Kt,"StardewValley.GameData.Locations.CreateLocationData":{MapPath:"String",$Type:"String",AlwaysActive:"Boolean"},"StardewValley.GameData.Locations.FishAreaData":{$DisplayName:"String",$Position:"Rectangle",$CrabPotFishTypes:["String"],CrabPotJunkChance:"Single"},"StardewValley.GameData.Locations.LocationMusicData":{$Id:"String",Track:"String",$Condition:"String"},"StardewValley.GameData.Locations.SpawnFishData":Jt,"StardewValley.GameData.Locations.SpawnForageData":Yt,"StardewValley.GameData.Machines.MachineData":{HasInput:"Boolean",HasOutput:"Boolean",$InteractMethod:"String",$OutputRules:["StardewValley.GameData.Machines.MachineOutputRule"],$AdditionalConsumedItems:["StardewValley.GameData.Machines.MachineItemAdditionalConsumedItems"],$PreventTimePass:["Int32"],$ReadyTimeModifiers:["StardewValley.GameData.QuantityModifier"],ReadyTimeModifierMode:"Int32",$InvalidItemMessage:"String",$InvalidItemMessageCondition:"String",$InvalidCountMessage:"String",$LoadEffects:["StardewValley.GameData.Machines.MachineEffects"],$WorkingEffects:["StardewValley.GameData.Machines.MachineEffects"],WorkingEffectChance:"Single",AllowLoadWhenFull:"Boolean",WobbleWhileWorking:"Boolean",$LightWhileWorking:"StardewValley.GameData.Machines.MachineLight",ShowNextIndexWhileWorking:"Boolean",ShowNextIndexWhenReady:"Boolean",AllowFairyDust:"Boolean",IsIncubator:"Boolean",$ClearContentsOvernightCondition:"String",$StatsToIncrementWhenLoaded:["StardewValley.GameData.StatIncrement"],$StatsToIncrementWhenHarvested:["StardewValley.GameData.StatIncrement"],$ExperienceGainOnHarvest:"String",$CustomFields:{String:"String"}},"StardewValley.GameData.Machines.MachineEffects":{Id:"String",$Condition:"String",$Sounds:["StardewValley.GameData.Machines.MachineSoundData"],Interval:"Int32",$Frames:["Int32"],ShakeDuration:"Int32",$TemporarySprites:["StardewValley.GameData.TemporaryAnimatedSpriteDefinition"]},"StardewValley.GameData.Machines.MachineItemAdditionalConsumedItems":{ItemId:"String",RequiredCount:"Int32",InvalidCountMessage:"String"},"StardewValley.GameData.Machines.MachineItemOutput":Zt,"StardewValley.GameData.Machines.MachineLight":{Radius:"Single",$Color:"String"},"StardewValley.GameData.Machines.MachineOutputRule":{Id:"String",Triggers:["StardewValley.GameData.Machines.MachineOutputTriggerRule"],UseFirstValidOutput:"Boolean",$OutputItem:["StardewValley.GameData.Machines.MachineItemOutput"],MinutesUntilReady:"Int32",DaysUntilReady:"Int32",$InvalidCountMessage:"String",RecalculateOnCollect:"Boolean"},"StardewValley.GameData.Machines.MachineOutputTriggerRule":{$Id:"String",Trigger:"Int32",$RequiredItemId:"String",$RequiredTags:["String"],RequiredCount:"Int32",$Condition:"String"},"StardewValley.GameData.Machines.MachineSoundData":{Id:"String",Delay:"Int32"},"StardewValley.GameData.MakeoverOutfits.MakeoverOutfit":{Id:"String",OutfitParts:["StardewValley.GameData.MakeoverOutfits.MakeoverItem"],$Gender:"String"},"StardewValley.GameData.MakeoverOutfits.MakeoverItem":{$Id:"String",$ItemId:"String",$Color:"String"},"StardewValley.GameData.Minecarts.MinecartNetworkData":{$UnlockCondition:"String",$LockedMessage:"String",$ChooseDestinationMessage:"String",$BuyTicketMessage:"String",Destinations:["StardewValley.GameData.Minecarts.MinecartDestinationData"]},"StardewValley.GameData.Minecarts.MinecartDestinationData":{Id:"String",DisplayName:"String",$Condition:"String",Price:"Int32",$BuyTicketMessage:"String",TargetLocation:"String",TargetTile:"Point",$TargetDirection:"String",$CustomFields:{String:"String"}},"StardewValley.GameData.Movies.MovieData":{$Id:"String",$Seasons:["Int32"],$YearModulus:"Int32",$YearRemainder:"Int32",$Texture:"String",SheetIndex:"Int32",Title:"String",Description:"String",$Tags:["String"],$CranePrizes:["StardewValley.GameData.Movies.MovieCranePrizeData"],$ClearDefaultCranePrizeGroups:["Int32"],Scenes:["MovieScene"],$CustomFields:{String:"String"}},"StardewValley.GameData.Movies.MovieCranePrizeData":en,"StardewValley.GameData.Museum.MuseumRewards":{TargetContextTags:["StardewValley.GameData.Museum.MuseumDonationRequirement"],$RewardItemId:"String",RewardItemCount:"Int32",RewardItemIsSpecial:"Boolean",RewardItemIsRecipe:"Boolean",$RewardActions:["String"],FlagOnCompletion:"Boolean",$CustomFields:{String:"String"}},"StardewValley.GameData.Museum.MuseumDonationRequirement":{Tag:"String",Count:"Int32"},"StardewValley.GameData.Objects.ObjectData":{Name:"String",DisplayName:"String",Description:"String",Type:"String",Category:"Int32",Price:"Int32",$Texture:"String",SpriteIndex:"Int32",Edibility:"Int32",IsDrink:"Boolean",$Buffs:["StardewValley.GameData.Objects.ObjectBuffData"],GeodeDropsDefaultItems:"Boolean",$GeodeDrops:["StardewValley.GameData.Objects.ObjectGeodeDropData"],$ArtifactSpotChances:{String:"Single"},ExcludeFromFishingCollection:"Boolean",ExcludeFromShippingCollection:"Boolean",ExcludeFromRandomSale:"Boolean",$ContextTags:["String"],$CustomFields:{String:"String"}},"StardewValley.GameData.Objects.ObjectBuffData":{$Id:"String",$BuffId:"String",$IconTexture:"String",IconSpriteIndex:"Int32",Duration:"Int32",IsDebuff:"Boolean",$GlowColor:"String",$CustomAttributes:"StardewValley.GameData.Buffs.BuffAttributesData",$CustomFields:{String:"String"}},"StardewValley.GameData.Objects.ObjectGeodeDropData":tn,"StardewValley.GameData.Shirts.ShirtData":{$Name:"String",$DisplayName:"String",$Description:"String",Price:"Int32",$Texture:"String",SpriteIndex:"Int32",$DefaultColor:"String",CanBeDyed:"Boolean",IsPrismatic:"Boolean",HasSleeves:"Boolean",CanChooseDuringCharacterCustomization:"Boolean",$CustomFields:{String:"String"}},"StardewValley.GameData.Pants.PantsData":{Name:"String",DisplayName:"String",Description:"String",Price:"Int32",$Texture:"String",SpriteIndex:"Int32",$DefaultColor:"String",CanBeDyed:"Boolean",IsPrismatic:"Boolean",CanChooseDuringCharacterCustomization:"Boolean",$CustomFields:{String:"String"}},"StardewValley.GameData.Pets.PetData":{DisplayName:"String",BarkSound:"String",ContentSound:"String",RepeatContentSoundAfter:"Int32",EmoteOffset:"Point",EventOffset:"Point",$AdoptionEventLocation:"String",$AdoptionEventId:"String",SummitPerfectionEvent:"StardewValley.GameData.Pets.PetSummitPerfectionEventData",MoveSpeed:"Int32",SleepOnBedChance:"Single",SleepNearBedChance:"Single",SleepOnRugChance:"Single",Behaviors:["StardewValley.GameData.Pets.PetBehavior"],GiftChance:"Single",$Gifts:["StardewValley.GameData.Pets.PetGift"],Breeds:["StardewValley.GameData.Pets.PetBreed"],$CustomFields:{String:"String"}},"StardewValley.GameData.Pets.PetAnimationFrame":{Frame:"Int32",Duration:"Int32",HitGround:"Boolean",Jump:"Boolean",$Sound:"String",SoundRangeFromBorder:"Int32",SoundRange:"Int32",SoundIsVoice:"Boolean"},"StardewValley.GameData.Pets.PetBehavior":{Name:"String",IsSideBehavior:"Boolean",RandomizeDirection:"Boolean",$Direction:"String",WalkInDirection:"Boolean",MoveSpeed:"Int32",$SoundOnStart:"String",SoundRangeFromBorder:"Int32",SoundRange:"Int32",SoundIsVoice:"Boolean",Shake:"Int32",$Animation:["StardewValley.GameData.Pets.PetAnimationFrame"],LoopMode:"Int32",AnimationMinimumLoops:"Int32",AnimationMaximumLoops:"Int32",$AnimationEndBehaviorChanges:["StardewValley.GameData.Pets.PetBehaviorChanges"],Duration:"Int32",MinimumDuration:"Int32",MaximumDuration:"Int32",$TimeoutBehaviorChanges:["StardewValley.GameData.Pets.PetBehaviorChanges"],$PlayerNearbyBehaviorChanges:["StardewValley.GameData.Pets.PetBehaviorChanges"],RandomBehaviorChangeChance:"Single",$RandomBehaviorChanges:["StardewValley.GameData.Pets.PetBehaviorChanges"],$JumpLandBehaviorChanges:["StardewValley.GameData.Pets.PetBehaviorChanges"]},"StardewValley.GameData.Pets.PetBehaviorChanges":{Weight:"Single",OutsideOnly:"Boolean",$UpBehavior:"String",$DownBehavior:"String",$LeftBehavior:"String",$RightBehavior:"String",$Behavior:"String"},"StardewValley.GameData.Pets.PetBreed":{Id:"String",Texture:"String",IconTexture:"String",IconSourceRect:"Rectangle",CanBeChosenAtStart:"Boolean",CanBeAdoptedFromMarnie:"Boolean",AdoptionPrice:"Int32",$BarkOverride:"String",VoicePitch:"Single"},"StardewValley.GameData.Pets.PetGift":{MinimumFriendshipThreshold:"Int32",Weight:"Single",QualifiedItemID:"String",Stack:"Int32"},"StardewValley.GameData.Pets.PetSummitPerfectionEventData":{SourceRect:"Rectangle",AnimationLength:"Int32",Flipped:"Boolean",Motion:"Vector2",PingPong:"Boolean"},"StardewValley.GameData.Powers.PowersData":{DisplayName:"String",$Description:"String",TexturePath:"String",TexturePosition:"Point",UnlockedCondition:"String"},"StardewValley.GameData.Shops.ShopData":{$ApplyProfitMargins:"Boolean",Currency:"Int32",$StackSizeVisibility:"Int32",$OpenSound:"String",$PurchaseSound:"String",$PurchaseRepeatSound:"String",$PriceModifiers:["StardewValley.GameData.QuantityModifier"],PriceModifierMode:"Int32",$Owners:["StardewValley.GameData.Shops.ShopOwnerData"],$VisualTheme:["StardewValley.GameData.Shops.ShopThemeData"],$SalableItemTags:["String"],Items:["StardewValley.GameData.Shops.ShopItemData"],$CustomFields:{String:"String"}},"StardewValley.GameData.Shops.ShopDialogueData":{Id:"String",$Condition:"String",$Dialogue:"String",$RandomDialogue:["String"]},"StardewValley.GameData.Shops.ShopItemData":nn,"StardewValley.GameData.Shops.ShopOwnerData":{$Id:"String",$Name:"String",$Condition:"String",$Portrait:"String",$Dialogues:["StardewValley.GameData.Shops.ShopDialogueData"],RandomizeDialogueOnOpen:"Boolean",$ClosedMessage:"String"},"StardewValley.GameData.Shops.ShopThemeData":{$Condition:"String",$WindowBorderTexture:"String",$WindowBorderSourceRect:"Rectangle",$PortraitBackgroundTexture:"String",$PortraitBackgroundSourceRect:"Rectangle",$DialogueBackgroundTexture:"String",$DialogueBackgroundSourceRect:"Rectangle",$DialogueColor:"String",$DialogueShadowColor:"String",$ItemRowBackgroundTexture:"String",$ItemRowBackgroundSourceRect:"Rectangle",$ItemRowBackgroundHoverColor:"String",$ItemRowTextColor:"String",$ItemIconBackgroundTexture:"String",$ItemIconBackgroundSourceRect:"Rectangle",$ScrollUpTexture:"String",$ScrollUpSourceRect:"Rectangle",$ScrollDownTexture:"String",$ScrollDownSourceRect:"Rectangle",$ScrollBarFrontTexture:"String",$ScrollBarFrontSourceRect:"Rectangle",$ScrollBarBackTexture:"String",$ScrollBarBackSourceRect:"Rectangle"},"StardewValley.GameData.Tools.ToolData":{ClassName:"String",Name:"String",AttachmentSlots:"Int32",SalePrice:"Int32",DisplayName:"String",Description:"String",Texture:"String",SpriteIndex:"Int32",MenuSpriteIndex:"Int32",UpgradeLevel:"Int32",ApplyUpgradeLevelToDisplayName:"Boolean",$ConventionalUpgradeFrom:"String",$UpgradeFrom:["StardewValley.GameData.Tools.ToolUpgradeData"],CanBeLostOnDeath:"Boolean",$SetProperties:{String:"String"},$ModData:{String:"String"},$CustomFields:{String:"String"}},"StardewValley.GameData.Tools.ToolUpgradeData":{$Condition:"String",Price:"Int32",$RequireToolId:"String",$TradeItemId:"String",TradeItemAmount:"Int32"},"StardewValley.GameData.Weapons.WeaponData":{Name:"String",DisplayName:"String",Description:"String",MinDamage:"Int32",MaxDamage:"Int32",Knockback:"Single",Speed:"Int32",Precision:"Int32",Defense:"Int32",Type:"Int32",MineBaseLevel:"Int32",MineMinLevel:"Int32",AreaOfEffect:"Int32",CritChance:"Single",CritMultiplier:"Single",CanBeLostOnDeath:"Boolean",Texture:"String",SpriteIndex:"Int32",$Projectiles:["StardewValley.GameData.Weapons.WeaponProjectile"],$CustomFields:{String:"String"}},"StardewValley.GameData.Weapons.WeaponProjectile":{Id:"String",Damage:"Int32",Explodes:"Boolean",Bounces:"Int32",MaxDistance:"Int32",Velocity:"Int32",RotationVelocity:"Int32",TailLength:"Int32",$FireSound:"String",$BounceSound:"String",$CollisionSound:"String",MinAngleOffset:"Single",MaxAngleOffset:"Single",SpriteIndex:"Int32",$Item:"StardewValley.GameData.GenericSpawnItemData"},"StardewValley.GameData.Weddings.WeddingData":{EventScript:{String:"String"},Attendees:{String:"StardewValley.GameData.Weddings.WeddingAttendeeData"}},"StardewValley.GameData.Weddings.WeddingAttendeeData":{Id:"String",$Condition:"String",Setup:"String",$Celebration:"String",IgnoreUnlockConditions:"Boolean"},"StardewValley.GameData.WildTrees.WildTreeData":{Textures:["StardewValley.GameData.WildTrees.WildTreeTextureData"],SeedItemId:"String",SeedPlantable:"Boolean",GrowthChance:"Single",FertilizedGrowthChance:"Single",SeedSpreadChance:"Single",SeedOnShakeChance:"Single",SeedOnChopChance:"Single",DropWoodOnChop:"Boolean",DropHardwoodOnLumberChop:"Boolean",IsLeafy:"Boolean",IsLeafyInWinter:"Boolean",IsLeafyInFall:"Boolean",$PlantableLocationRules:["StardewValley.GameData.PlantableRule"],GrowsInWinter:"Boolean",IsStumpDuringWinter:"Boolean",AllowWoodpeckers:"Boolean",UseAlternateSpriteWhenNotShaken:"Boolean",UseAlternateSpriteWhenSeedReady:"Boolean",$DebrisColor:"String",$SeedDropItems:["StardewValley.GameData.WildTrees.WildTreeSeedDropItemData"],$ChopItems:["StardewValley.GameData.WildTrees.WildTreeChopItemData"],$TapItems:["StardewValley.GameData.WildTrees.WildTreeTapItemData"],$ShakeItems:["StardewValley.GameData.WildTrees.WildTreeItemData"],$CustomFields:{String:"String"},GrowsMoss:"Boolean"},"StardewValley.GameData.WildTrees.WildTreeItemData":rn,"StardewValley.GameData.WildTrees.WildTreeChopItemData":n(n({},rn),{},{$MinSize:"Int32",$MaxSize:"Int32",$ForStump:"Boolean"}),"StardewValley.GameData.WildTrees.WildTreeSeedDropItemData":n(n({},rn),{},{ContinueOnDrop:"Boolean"}),"StardewValley.GameData.WildTrees.WildTreeTapItemData":n(n({},rn),{},{$PreviousItemId:["String"],DaysUntilReady:"Int32",$DaysUntilReadyModifiers:["StardewValley.GameData.QuantityModifier"],DaysUntilReadyModifierMode:"Int32"}),"StardewValley.GameData.WildTrees.WildTreeTextureData":{$Condition:"String",$Season:"Int32",Texture:"String"},"StardewValley.GameData.WorldMaps.WorldMapAreaData":{Id:"String",$Condition:"String",PixelArea:"Rectangle",$ScrollText:"String",$Textures:["StardewValley.GameData.WorldMaps.WorldMapTextureData"],$Tooltips:["StardewValley.GameData.WorldMaps.WorldMapTooltipData"],$WorldPositions:["StardewValley.GameData.WorldMaps.WorldMapAreaPositionData"],$CustomFields:{String:"String"}},"StardewValley.GameData.WorldMaps.WorldMapAreaPositionData":{Id:"String",$Condition:"String",$LocationContext:"String",$LocationName:"String",$LocationNames:["String"],TileArea:"Rectangle",$ExtendedTileArea:"Rectangle",MapPixelArea:"Rectangle",$ScrollText:"String",$ScrollTextZones:["StardewValley.GameData.WorldMaps.WorldMapAreaPositionScrollTextZoneData"]},"StardewValley.GameData.WorldMaps.WorldMapAreaPositionScrollTextZoneData":{Id:"String",TileArea:"Rectangle",$ScrollText:"String"},"StardewValley.GameData.WorldMaps.WorldMapRegionData":{BaseTexture:["StardewValley.GameData.WorldMaps.WorldMapTextureData"],$MapNeighborIdAliases:{String:"String"},MapAreas:["StardewValley.GameData.WorldMaps.WorldMapAreaData"]},"StardewValley.GameData.WorldMaps.WorldMapTextureData":{Id:"String",$Condition:"String",Texture:"String",SourceRect:"Rectangle",MapPixelArea:"Rectangle"},"StardewValley.GameData.WorldMaps.WorldMapTooltipData":{Id:"String",$Condition:"String",$KnownCondition:"String",PixelArea:"Rectangle",Text:"String",LeftNeighbor:"String",RightNeighbor:"String",UpNeighbor:"String",DownNeighbor:"String"}};e.enums=["StardewValley.GameData.QuantityModifier+ModificationType","StardewValley.GameData.QuantityModifier+QuantityModifierMode","StardewValley.GameData.MusicContext","StardewValley.GameData.PlantableResult","StardewValley.GameData.PlantableRuleContext","StardewValley.GameData.Buildings.BuildingChestType","StardewValley.Gender","StardewValley.GameData.Characters.CalendarBehavior","StardewValley.GameData.Characters.EndSlideShowBehavior","StardewValley.GameData.Characters.NpcAge","StardewValley.GameData.Characters.NpcLanguage","StardewValley.GameData.Characters.NpcManner","StardewValley.GameData.Characters.NpcOptimism","StardewValley.GameData.Characters.NpcSocialAnxiety","StardewValley.GameData.Characters.SocialTabBehavior","StardewValley.Season","StardewValley.GameData.Crops.HarvestMethod","StardewValley.GameData.FloorsAndPaths.FloorPathConnectType","StardewValley.GameData.FloorsAndPaths.FloorPathShadowType","StardewValley.GameData.Machines.MachineOutputTrigger","StardewValley.GameData.Machines.MachineTimeBlockers","StardewValley.GameData.Pets.PetAnimationLoopMode","StardewValley.GameData.Shops.LimitedStockMode","StardewValley.GameData.Shops.ShopOwnerType","StardewValley.GameData.Shops.StackSizeVisibility","StardewValley.GameData.SpecialOrders.QuestDuration","StardewValley.GameData.WildTrees.WildTreeGrowthStage"],e.readers=Ht,e.schemes=an,Object.defineProperty(e,"__esModule",{value:!0})})); diff --git a/dist/readers/xnb-readers.cjs b/dist/readers/xnb-readers.cjs index 92f9092..3c1a073 100644 --- a/dist/readers/xnb-readers.cjs +++ b/dist/readers/xnb-readers.cjs @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -15,47 +15,36 @@ class BaseReader { static isTypeOf(type) { return false; } - static hasSubType() { return false; } - static parseTypeList() { return [this.type()]; } - static type() { return this.name.slice(0, -6); } - isValueType() { return true; } - get type() { return this.constructor.type(); } - read(buffer, resolver) { throw new Error('Cannot invoke methods on abstract class.'); } - write(buffer, content, resolver) { throw new Error('Cannot invoke methods on abstract class.'); } - writeIndex(buffer, resolver) { if (resolver != null) buffer.write7BitNumber(Number.parseInt(resolver.getIndex(this)) + 1); } - toString() { return this.type; } - parseTypeList() { return this.constructor.parseTypeList(); } - } class UInt32Reader extends BaseReader { @@ -64,21 +53,17 @@ class UInt32Reader extends BaseReader { case 'Microsoft.Xna.Framework.Content.UInt32Reader': case 'System.UInt32': return true; - default: return false; } } - read(buffer) { return buffer.readUInt32(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeUInt32(content); } - } class ArrayReader extends BaseReader { @@ -86,79 +71,63 @@ class ArrayReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.ArrayReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer, resolver) { const uint32Reader = new UInt32Reader(); let size = uint32Reader.read(buffer); let array = []; - for (let i = 0; i < size; i++) { let value = this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); array.push(value); } - return array; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const uint32Reader = new UInt32Reader(); - uint32Reader.write(buffer, content.length, resolver); - + uint32Reader.write(buffer, content.length, null); for (let i = 0; i < content.length; i++) this.reader.write(buffer, content[i], this.reader.isValueType() ? null : resolver); } - isValueType() { return false; } - get type() { return "Array<".concat(this.reader.type, ">"); } - parseTypeList() { - return [this.type, ...this.reader.parseTypeList()]; + const inBlock = this.reader.parseTypeList(); + return ["".concat(this.type, ":").concat(inBlock.length), ...inBlock]; } - } const UTF16_BITES = [0xD800, 0xDC00]; const UTF16_MASK = 0b1111111111; - function UTF16Decode(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; return ((codeSet[0] & UTF16_MASK) << 10) + (codeSet[1] & UTF16_MASK) + 0x10000; } - function stringToUnicode(str) { const utf16Map = Array.from({ length: str.length }, (_, i) => str.charCodeAt(i)); const result = []; let index = 0; - while (index < str.length) { let code = utf16Map[index]; - if ((UTF16_BITES[0] & code) !== UTF16_BITES[0]) { result.push(code); index++; @@ -167,10 +136,8 @@ function stringToUnicode(str) { index += 2; } } - return result; } - function UTF8Length(str) { const codes = stringToUnicode(str); return codes.reduce((sum, unicode) => { @@ -187,28 +154,23 @@ class StringReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.StringReader': case 'System.String': return true; - default: return false; } } - read(buffer) { let length = buffer.read7BitNumber(); return buffer.readString(length); } - write(buffer, string, resolver) { this.writeIndex(buffer, resolver); const size = UTF8Length(string); buffer.write7BitNumber(size); buffer.writeString(string); } - isValueType() { return false; } - } class BmFontReader extends BaseReader { @@ -216,12 +178,10 @@ class BmFontReader extends BaseReader { switch (type) { case 'BmFont.XmlSourceReader': return true; - default: return false; } } - read(buffer) { const stringReader = new StringReader(); const xml = stringReader.read(buffer); @@ -232,17 +192,14 @@ class BmFontReader extends BaseReader { } }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const stringReader = new StringReader(); stringReader.write(buffer, content.export.data, null); } - isValueType() { return false; } - } class BooleanReader extends BaseReader { @@ -251,21 +208,17 @@ class BooleanReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.BooleanReader': case 'System.Boolean': return true; - default: return false; } } - read(buffer) { return Boolean(buffer.readInt()); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeByte(content); } - } class CharReader extends BaseReader { @@ -274,27 +227,21 @@ class CharReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.CharReader': case 'System.Char': return true; - default: return false; } } - read(buffer) { let charSize = this._getCharSize(buffer.peekInt()); - return buffer.readString(charSize); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeString(content); } - _getCharSize(byte) { return (0xE5000000 >> (byte >> 3 & 0x1e) & 3) + 1; } - } class DictionaryReader extends BaseReader { @@ -302,59 +249,47 @@ class DictionaryReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.DictionaryReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(key, value) { if (key == undefined || value == undefined) throw new Error('Cannot create instance of DictionaryReader without Key and Value.'); super(); this.key = key; this.value = value; } - read(buffer, resolver) { let dictionary = {}; const uint32Reader = new UInt32Reader(); const size = uint32Reader.read(buffer); - for (let i = 0; i < size; i++) { let key = this.key.isValueType() ? this.key.read(buffer) : resolver.read(buffer); let value = this.value.isValueType() ? this.value.read(buffer) : resolver.read(buffer); dictionary[key] = value; } - return dictionary; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeUInt32(Object.keys(content).length); - for (let key of Object.keys(content)) { this.key.write(buffer, key, this.key.isValueType() ? null : resolver); this.value.write(buffer, content[key], this.value.isValueType() ? null : resolver); } } - isValueType() { return false; } - get type() { return "Dictionary<".concat(this.key.type, ",").concat(this.value.type, ">"); } - parseTypeList() { return [this.type, ...this.key.parseTypeList(), ...this.value.parseTypeList()]; } - } class DoubleReader extends BaseReader { @@ -363,21 +298,17 @@ class DoubleReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.DoubleReader': case 'System.Double': return true; - default: return false; } } - read(buffer) { return buffer.readDouble(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeDouble(content); } - } class EffectReader extends BaseReader { @@ -386,12 +317,10 @@ class EffectReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.EffectReader': case 'Microsoft.Xna.Framework.Graphics.Effect': return true; - default: return false; } } - read(buffer) { const uint32Reader = new UInt32Reader(); const size = uint32Reader.read(buffer); @@ -403,7 +332,6 @@ class EffectReader extends BaseReader { } }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const data = content.export.data; @@ -411,34 +339,29 @@ class EffectReader extends BaseReader { uint32Reader.write(buffer, data.byteLength, null); buffer.concat(data); } - isValueType() { return false; } - } class Int32Reader extends BaseReader { static isTypeOf(type) { switch (type) { case 'Microsoft.Xna.Framework.Content.Int32Reader': + case 'Microsoft.Xna.Framework.Content.EnumReader': case 'System.Int32': return true; - default: return false; } } - read(buffer) { return buffer.readInt32(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeInt32(content); } - } class ListReader extends BaseReader { @@ -447,56 +370,45 @@ class ListReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.ListReader': case 'System.Collections.Generic.List': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer, resolver) { const uint32Reader = new UInt32Reader(); const size = uint32Reader.read(buffer); const list = []; - for (let i = 0; i < size; i++) { const value = this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); list.push(value); } - return list; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const uint32Reader = new UInt32Reader(); uint32Reader.write(buffer, content.length, null); - - for (let data of Object.values(content)) { + for (let data of content) { this.reader.write(buffer, data, this.reader.isValueType() ? null : resolver); } } - isValueType() { return false; } - get type() { return "List<".concat(this.reader.type, ">"); } - parseTypeList() { - return [this.type, ...this.reader.parseTypeList()]; + const inBlock = this.reader.parseTypeList(); + return ["".concat(this.type, ":").concat(inBlock.length), ...inBlock]; } - } class NullableReader extends BaseReader { @@ -504,65 +416,78 @@ class NullableReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.NullableReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer) { let resolver = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; const booleanReader = new BooleanReader(); const hasValue = buffer.peekByte(1); - if (!hasValue) { booleanReader.read(buffer); return null; } - - if (resolver === null) { + if (resolver === null || this.reader.isValueType()) { booleanReader.read(buffer); return this.reader.read(buffer); } - - return this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); + return resolver.read(buffer); } - write(buffer) { let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let resolver = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - if (content === null) { buffer.writeByte(0); return; } - - if (resolver === null) buffer.writeByte(1); + if (resolver === null || this.reader.isValueType()) buffer.writeByte(1); this.reader.write(buffer, content, this.reader.isValueType() ? null : resolver); } - isValueType() { return false; } - get type() { return "Nullable<".concat(this.reader.type, ">"); } - parseTypeList() { const inBlock = this.reader.parseTypeList(); return ["".concat(this.type, ":").concat(inBlock.length), ...inBlock]; } +} +class PointReader extends BaseReader { + static isTypeOf(type) { + switch (type) { + case 'Microsoft.Xna.Framework.Content.PointReader': + case 'Microsoft.Xna.Framework.Point': + return true; + default: + return false; + } + } + read(buffer) { + const int32Reader = new Int32Reader(); + const x = int32Reader.read(buffer); + const y = int32Reader.read(buffer); + return { + x, + y + }; + } + write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + const int32Reader = new Int32Reader(); + int32Reader.write(buffer, content.x, null); + int32Reader.write(buffer, content.y, null); + } } class ReflectiveReader extends BaseReader { @@ -570,42 +495,33 @@ class ReflectiveReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.ReflectiveReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer, resolver) { const reflective = this.reader.read(buffer, resolver); return reflective; } - write(buffer, content, resolver) { this.reader.write(buffer, content, this.reader.isValueType() ? null : resolver); } - isValueType() { return false; } - get type() { return "".concat(this.reader.type); } - parseTypeList() { return [...this.reader.parseTypeList()]; } - } class RectangleReader extends BaseReader { @@ -614,12 +530,10 @@ class RectangleReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.RectangleReader': case 'Microsoft.Xna.Framework.Rectangle': return true; - default: return false; } } - read(buffer) { const int32Reader = new Int32Reader(); const x = int32Reader.read(buffer); @@ -633,7 +547,6 @@ class RectangleReader extends BaseReader { height }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const int32Reader = new Int32Reader(); @@ -642,7 +555,6 @@ class RectangleReader extends BaseReader { int32Reader.write(buffer, content.width, null); int32Reader.write(buffer, content.height, null); } - } class SingleReader extends BaseReader { @@ -651,21 +563,17 @@ class SingleReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.SingleReader': case 'System.Single': return true; - default: return false; } } - read(buffer) { return buffer.readSingle(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeSingle(content); } - } const kDxt1 = 1 << 0; @@ -680,17 +588,14 @@ const kWeightColourByAlpha = 1 << 7; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } - return keys; } - function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; @@ -700,10 +605,8 @@ function _objectSpread2(target) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } - return target; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { @@ -715,7 +618,6 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } @@ -723,20 +625,16 @@ function Rot(theta) { let Mat = [[Math.cos(theta), Math.sin(theta)], [-Math.sin(theta), Math.cos(theta)]]; return Mat; } - function Rij(k, l, theta, N) { let Mat = Array(N); - for (let i = 0; i < N; i++) { Mat[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Mat[i][j] = (i === j) * 1.0; } } - let Rotij = Rot(theta); Mat[k][k] = Rotij[0][0]; Mat[l][l] = Rotij[1][1]; @@ -744,25 +642,20 @@ function Rij(k, l, theta, N) { Mat[l][k] = Rotij[1][0]; return Mat; } - function getTheta(aii, ajj, aij) { let th = 0.0; let denom = ajj - aii; - if (Math.abs(denom) <= 1E-12) { th = Math.PI / 4.0; } else { th = 0.5 * Math.atan(2.0 * aij / (ajj - aii)); } - return th; } - function getAij(Mij) { let N = Mij.length; let maxMij = 0.0; let maxIJ = [0, 1]; - for (let i = 0; i < N; i++) { for (let j = i + 1; j < N; j++) { if (Math.abs(maxMij) <= Math.abs(Mij[i][j])) { @@ -771,22 +664,17 @@ function getAij(Mij) { } } } - return [maxIJ, maxMij]; } - function unitary(U, H) { let N = U.length; let Mat = Array(N); - for (let i = 0; i < N; i++) { Mat[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Mat[i][j] = 0; - for (let k = 0; k < N; k++) { for (let l = 0; l < N; l++) { Mat[i][j] = Mat[i][j] + U[k][i] * H[k][l] * U[l][j]; @@ -794,50 +682,39 @@ function unitary(U, H) { } } } - return Mat; } - function AxB(A, B) { let N = A.length; let Mat = Array(N); - for (let i = 0; i < N; i++) { Mat[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Mat[i][j] = 0; - for (let k = 0; k < N; k++) { Mat[i][j] = Mat[i][j] + A[i][k] * B[k][j]; } } } - return Mat; } - function eigens(Hij) { let convergence = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1E-7; let N = Hij.length; let Ei = Array(N); let e0 = Math.abs(convergence / N); let Sij = Array(N); - for (let i = 0; i < N; i++) { Sij[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Sij[i][j] = (i === j) * 1.0; } } - let Vab = getAij(Hij); - while (Math.abs(Vab[1]) >= Math.abs(e0)) { let i = Vab[0][0]; let j = Vab[0][1]; @@ -847,14 +724,11 @@ function eigens(Hij) { Sij = AxB(Sij, Gij); Vab = getAij(Hij); } - for (let i = 0; i < N; i++) { Ei[i] = Hij[i][i]; } - return sorting(Ei, Sij); } - function sorting(values, vectors) { let eigsCount = values.length; vectors.length; @@ -882,7 +756,6 @@ function sorting(values, vectors) { }); return [sortedValues, sortedVectors]; } - function dominentPrincipalVector(matrix) { let [, [dominentVector]] = eigens(matrix); return dominentVector; @@ -895,57 +768,44 @@ class Vec3 { let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; this._values = [x, y, z]; } - get x() { return this._values[0]; } - get y() { return this._values[1]; } - get z() { return this._values[2]; } - set x(value) { this._values[0] = value; } - set y(value) { this._values[1] = value; } - set z(value) { this._values[2] = value; } - get length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } - get lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z; } - get normalized() { if (this.length === 0) return null; return Vec3.multScalar(this, 1 / this.length); } - get colorInt() { const floatToInt = value => { const result = parseInt(value * 255 + 0.5); return Math.max(Math.min(result, 255), 0); }; - return this._values.map(floatToInt); } - clone() { return new Vec3(this.x, this.y, this.z); } - set(x) { let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x; let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; @@ -954,99 +814,79 @@ class Vec3 { this._values[2] = z; return this; } - toVec4() { let w = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return new Vec4(this.x, this.y, this.z, w); } - addVector(v) { this._values[0] += v.x; this._values[1] += v.y; this._values[2] += v.z; return this; } - addScaledVector(v, scalar) { this._values[0] += v.x * scalar; this._values[1] += v.y * scalar; this._values[2] += v.z * scalar; return this; } - mult(scalar) { this._values[0] *= scalar; this._values[1] *= scalar; this._values[2] *= scalar; return this; } - multVector(vec) { this._values[0] *= vec.x; this._values[1] *= vec.y; this._values[2] *= vec.z; return this; } - clamp(min, max) { const clamper = v => min > v ? min : max < v ? max : v; - this._values[0] = clamper(this._values[0]); this._values[1] = clamper(this._values[1]); this._values[2] = clamper(this._values[2]); return this; } - clampGrid() { const clamper = v => 0 > v ? 0 : 1 < v ? 1 : v; - const gridClamper = (value, grid) => Math.trunc(clamper(value) * grid + 0.5) / grid; - this._values[0] = gridClamper(this._values[0], 31); this._values[1] = gridClamper(this._values[1], 63); this._values[2] = gridClamper(this._values[2], 31); return this; } - normalize() { this._values[0] /= this.length; this._values[1] /= this.length; this._values[2] /= this.length; return this; } - toString() { return "Vec3( ".concat(this._values.join(", "), " )"); } - static add(a, b) { return new Vec3(a.x + b.x, a.y + b.y, a.z + b.z); } - static sub(a, b) { return new Vec3(a.x - b.x, a.y - b.y, a.z - b.z); } - static dot(a, b) { return a.x * b.x + a.y * b.y + a.z * b.z; } - static multScalar(a, scalar) { return new Vec3(a.x * scalar, a.y * scalar, a.z * scalar); } - static multVector(a, b) { return new Vec3(a.x * b.x, a.y * b.y, a.z * b.z); } - static interpolate(a, b, p) { let a_ = Vec3.multScalar(a, 1 - p); let b_ = Vec3.multScalar(b, p); return Vec3.add(a_, b_); } - } - class Vec4 { constructor() { let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; @@ -1055,76 +895,58 @@ class Vec4 { let w = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : x; this._values = [x, y, z, w]; } - get x() { return this._values[0]; } - get y() { return this._values[1]; } - get z() { return this._values[2]; } - get w() { return this._values[3]; } - set x(value) { this._values[0] = value; } - set y(value) { this._values[1] = value; } - set z(value) { this._values[2] = value; } - set w(value) { this._values[3] = value; } - get length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); } - get lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; } - get normalized() { if (this.length === 0) return null; return Vec4.multScalar(this, 1 / this.length); } - get xyz() { return new Vec3(this.x, this.y, this.z); } - get splatX() { return new Vec4(this.x); } - get splatY() { return new Vec4(this.y); } - get splatZ() { return new Vec4(this.z); } - get splatW() { return new Vec4(this.w); } - clone() { return new Vec4(this.x, this.y, this.z, this.w); } - set(x) { let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x; let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; @@ -1135,11 +957,9 @@ class Vec4 { this._values[3] = w; return this; } - toVec3() { return this.xyz; } - addVector(v) { this._values[0] += v.x; this._values[1] += v.y; @@ -1147,7 +967,6 @@ class Vec4 { this._values[3] += v.w; return this; } - addScaledVector(v, scalar) { this._values[0] += v.x * scalar; this._values[1] += v.y * scalar; @@ -1155,7 +974,6 @@ class Vec4 { this._values[3] += v.w * scalar; return this; } - subVector(v) { this._values[0] -= v.x; this._values[1] -= v.y; @@ -1163,7 +981,6 @@ class Vec4 { this._values[3] -= v.w; return this; } - mult(scalar) { this._values[0] *= scalar; this._values[1] *= scalar; @@ -1171,7 +988,6 @@ class Vec4 { this._values[3] *= scalar; return this; } - multVector(vec) { this._values[0] *= vec.x; this._values[1] *= vec.y; @@ -1179,7 +995,6 @@ class Vec4 { this._values[3] *= vec.w; return this; } - reciprocal() { this._values[0] = 1 / this._values[0]; this._values[1] = 1 / this._values[1]; @@ -1187,29 +1002,23 @@ class Vec4 { this._values[3] = 1 / this._values[3]; return this; } - clamp(min, max) { const clamper = v => min > v ? min : max < v ? max : v; - this._values[0] = clamper(this._values[0]); this._values[1] = clamper(this._values[1]); this._values[2] = clamper(this._values[2]); this._values[3] = clamper(this._values[3]); return this; } - clampGrid() { const clamper = v => 0 > v ? 0 : 1 < v ? 1 : v; - const gridClamper = (value, grid) => Math.trunc(clamper(value) * grid + 0.5) / grid; - this._values[0] = gridClamper(this._values[0], 31); this._values[1] = gridClamper(this._values[1], 63); this._values[2] = gridClamper(this._values[2], 31); this._values[3] = clamper(this._values[3]); return this; } - truncate() { this._values[0] = Math.trunc(this._values[0]); this._values[1] = Math.trunc(this._values[1]); @@ -1217,7 +1026,6 @@ class Vec4 { this._values[3] = Math.trunc(this._values[3]); return this; } - normalize() { this._values[0] /= this.length; this._values[1] /= this.length; @@ -1225,51 +1033,39 @@ class Vec4 { this._values[3] /= this.length; return this; } - toString() { return "Vec4( ".concat(this._values.join(", "), " )"); } - static add(a, b) { return new Vec4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); } - static sub(a, b) { return new Vec4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); } - static dot(a, b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } - static multScalar(a, scalar) { return new Vec4(a.x * scalar, a.y * scalar, a.z * scalar, a.w * scalar); } - static multVector(a, b) { return new Vec4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); } - static interpolate(a, b, p) { let a_ = Vec4.multScalar(a, 1 - p); let b_ = Vec4.multScalar(b, p); return Vec4.add(a_, b_); } - static multiplyAdd(a, b, c) { return new Vec4(a.x * b.x + c.x, a.y * b.y + c.y, a.z * b.z + c.z, a.w * b.w + c.w); } - static negativeMultiplySubtract(a, b, c) { return new Vec4(c.x - a.x * b.x, c.y - a.y * b.y, c.z - a.z * b.z, c.w - a.w * b.w); } - static compareAnyLessThan(left, right) { return left.x < right.x || left.y < right.y || left.z < right.z || left.w < right.w; } - } - function computeWeightedCovariance(values, weights) { let total = 0; let mean = values.reduce((sum, value, i) => { @@ -1294,7 +1090,6 @@ function computeWeightedCovariance(values, weights) { covariance[2][1] = covariance[1][2]; return covariance; } - function computePCA(values, weights) { const covariance = computeWeightedCovariance(values, weights); return new Vec3(...dominentPrincipalVector(covariance)); @@ -1311,45 +1106,37 @@ function floatToInt(value, limit) { if (integer > limit) return integer; return integer; } - function floatTo565(color) { const r = floatToInt(31.0 * color.x, 31); const g = floatToInt(63.0 * color.y, 63); const b = floatToInt(31.0 * color.z, 31); return r << 11 | g << 5 | b; } - function writeColourBlock(firstColor, secondColor, indices, result, blockOffset) { result[blockOffset + 0] = firstColor & 0xff; result[blockOffset + 1] = firstColor >> 8; result[blockOffset + 2] = secondColor & 0xff; result[blockOffset + 3] = secondColor >> 8; - for (let y = 0; y < 4; y++) { result[blockOffset + 4 + y] = indices[4 * y + 0] | indices[4 * y + 1] << 2 | indices[4 * y + 2] << 4 | indices[4 * y + 3] << 6; } } - function writeColourBlock3(start, end, indices, result, blockOffset) { let firstColor = floatTo565(start); let secondColor = floatTo565(end); let remapped; - if (firstColor <= secondColor) { remapped = indices.slice(); } else { [firstColor, secondColor] = [secondColor, firstColor]; remapped = indices.map(index => index === 0 ? 1 : index === 1 ? 0 : index); } - writeColourBlock(firstColor, secondColor, remapped, result, blockOffset); } - function writeColourBlock4(start, end, indices, result, blockOffset) { let firstColor = floatTo565(start); let secondColor = floatTo565(end); let remapped; - if (firstColor < secondColor) { [firstColor, secondColor] = [secondColor, firstColor]; remapped = indices.map(index => (index ^ 0x1) & 0x3); @@ -1358,7 +1145,6 @@ function writeColourBlock4(start, end, indices, result, blockOffset) { } else { remapped = indices.slice(); } - writeColourBlock(firstColor, secondColor, remapped, result, blockOffset); } @@ -1372,21 +1158,17 @@ class ColorSet { this._points = []; const isDxt1 = (this.flags & kDxt1) != 0; const weightByAlpha = (this.flags & kWeightColourByAlpha) != 0; - for (let i = 0; i < 16; i++) { const bit = 1 << i; - if ((mask & bit) == 0) { this._remap[i] = -1; continue; } - if (isDxt1 && rgba[4 * i + 3] < 128) { this._remap[i] = -1; this._transparent = true; continue; } - for (let j = 0;; j++) { if (j == i) { const r = rgba[4 * i] / 255.0; @@ -1399,10 +1181,8 @@ class ColorSet { this._count++; break; } - const oldbit = 1 << j; const match = (mask & oldbit) != 0 && rgba[4 * i] == rgba[4 * j] && rgba[4 * i + 1] == rgba[4 * j + 1] && rgba[4 * i + 2] == rgba[4 * j + 2] && (rgba[4 * j + 3] >= 128 || !isDxt1); - if (match) { const index = this._remap[j]; const w = (rgba[4 * i + 3] + 1) / 256.0; @@ -1412,61 +1192,44 @@ class ColorSet { } } } - for (let i = 0; i < this._count; ++i) this._weights[i] = Math.sqrt(this._weights[i]); } - get transparent() { return this._transparent; } - get count() { return this._count; } - get points() { return Object.freeze(this._points.slice()); } - get weights() { return Object.freeze(this._weights.slice()); } - remapIndicesSingle(singleIndex, target) { const result = this._remap.map(index => index === -1 ? 3 : singleIndex); - target.forEach((_, i) => target[i] = result[i]); } - remapIndices(indexMap, target) { const result = this._remap.map(index => index === -1 ? 3 : indexMap[index]); - target.forEach((_, i) => target[i] = result[i]); } - } - class ColorFit { constructor(colorSet) { this.colors = colorSet; this.flags = colorSet.flags; } - compress(result, offset) { const isDxt1 = (this.flags & kDxt1) != 0; - if (isDxt1) { this.compress3(result, offset); if (!this.colors.transparent) this.compress4(result, offset); } else this.compress4(result, offset); } - compress3(result, offset) {} - compress4(result, offset) {} - } - class SingleColourFit extends ColorFit { constructor(colorSet) { super(colorSet); @@ -1478,10 +1241,8 @@ class SingleColourFit extends ColorFit { this.error = Infinity; this.bestError = Infinity; } - compressBase(lookups, saveFunc) { this.computeEndPoints(lookups); - if (this.error < this.bestError) { const indices = new Uint8Array(16); this.colors.remapIndicesSingle(this.index, indices); @@ -1489,30 +1250,21 @@ class SingleColourFit extends ColorFit { this.bestError = this.error; } } - compress3(result, offset) { const lookups = [lookup_5_3, lookup_6_3, lookup_5_3]; - const saveFunc = (start, end, indices) => writeColourBlock3(start, end, indices, result, offset); - this.compressBase(lookups, saveFunc); } - compress4(result, offset) { const lookups = [lookup_5_4, lookup_6_4, lookup_5_4]; - const saveFunc = (start, end, indices) => writeColourBlock4(start, end, indices, result, offset); - this.compressBase(lookups, saveFunc); } - computeEndPoints(lookups) { this.error = Infinity; - for (let index = 0; index < 2; index++) { const sources = []; let error = 0; - for (let channel = 0; channel < 3; channel++) { const lookup = lookups[channel]; const target = this.color[channel]; @@ -1520,7 +1272,6 @@ class SingleColourFit extends ColorFit { const diff = sources[channel][2]; error += diff * diff; } - if (error < this.error) { this.start = new Vec3(sources[0][0] / 31.0, sources[1][0] / 63.0, sources[2][0] / 31.0); this.end = new Vec3(sources[0][1] / 31.0, sources[1][1] / 63.0, sources[2][1] / 31.0); @@ -1529,24 +1280,19 @@ class SingleColourFit extends ColorFit { } } } - } - class RangeFit extends ColorFit { constructor(colorSet) { super(colorSet); this.metric = new Vec3(1); - if ((this.flags & kColourMetricPerceptual) !== 0) { this.metric.set(0.2126, 0.7152, 0.0722); } - this.start = new Vec3(0); this.end = new Vec3(0); this.bestError = Infinity; this.computePoints(); } - compressBase(codes, saveFunc) { const { points: values @@ -1563,7 +1309,6 @@ class RangeFit extends ColorFit { error += minDist; return packedIndex; }); - if (error < this.bestError) { let indices = new Uint8Array(16); this.colors.remapIndices(closest, indices); @@ -1571,23 +1316,16 @@ class RangeFit extends ColorFit { this.bestError = error; } } - compress3(result, offset) { const codes = [this.start.clone(), this.end.clone(), Vec3.interpolate(this.start, this.end, 0.5)]; - const saveFunc = (start, end, indices) => writeColourBlock3(start, end, indices, result, offset); - this.compressBase(codes, saveFunc); } - compress4(result, offset) { const codes = [this.start.clone(), this.end.clone(), Vec3.interpolate(this.start, this.end, 1 / 3), Vec3.interpolate(this.start, this.end, 2 / 3)]; - const saveFunc = (start, end, indices) => writeColourBlock4(start, end, indices, result, offset); - this.compressBase(codes, saveFunc); } - computePoints() { const { count, @@ -1599,10 +1337,8 @@ class RangeFit extends ColorFit { let start, end, min, max; start = end = values[0]; min = max = Vec3.dot(start, principle); - for (let i = 1; i < count; i++) { let value = Vec3.dot(values[i], principle); - if (value < min) { start = values[i]; min = value; @@ -1611,13 +1347,10 @@ class RangeFit extends ColorFit { max = value; } } - this.start = start.clampGrid().clone(); this.end = end.clampGrid().clone(); } - } - class ClusterFit extends ColorFit { constructor(colorSet) { super(colorSet); @@ -1625,11 +1358,9 @@ class ClusterFit extends ColorFit { this.iterationCount = colorSet.flags & kColourIterativeClusterFit ? kMaxIterations : 1; this.bestError = Infinity; this.metric = new Vec4(1); - if ((this.flags & kColourMetricPerceptual) !== 0) { this.metric.set(0.2126, 0.7152, 0.0722, 0); } - const { points: values, weights @@ -1639,7 +1370,6 @@ class ClusterFit extends ColorFit { this.pointsWeights = []; this.xSum_wSum = new Vec4(0); } - constructOrdering(axis, iteration) { const currentOrder = this.makeOrder(axis); this.copyOrderToThisOrder(currentOrder, iteration); @@ -1648,7 +1378,6 @@ class ClusterFit extends ColorFit { this.copyOrderWeight(currentOrder); return true; } - compress3(result, offset) { const aabbx = _ref => { let [part0,, part1, part2] = _ref; @@ -1666,12 +1395,9 @@ class ClusterFit extends ColorFit { ab: alphabeta_sum }; }; - const saveFunc = (start, end, indices) => writeColourBlock3(start, end, indices, result, offset); - this.compressBase(aabbx, saveFunc, 2); } - compress4(result, offset) { const aabbx = _ref2 => { let [part0, part1, part2, part3] = _ref2; @@ -1691,12 +1417,9 @@ class ClusterFit extends ColorFit { ab: alphabeta_sum }; }; - const saveFunc = (start, end, indices) => writeColourBlock4(start, end, indices, result, offset); - this.compressBase(aabbx, saveFunc, 3); } - compressBase(aabbFunc, saveFunc) { let repeater = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; this.constructOrdering(this.principle, 0); @@ -1709,19 +1432,15 @@ class ClusterFit extends ColorFit { bestJ: 0 }; if (repeater === 3) best.bestK = 0; - const leastSquares = (parts, internalIndices) => { const aabbx = aabbFunc(parts); const internalBest = this.computeOptimalPoints(aabbx); - if (internalBest.error < best.error) { best = _objectSpread2(_objectSpread2({}, internalBest), internalIndices); return true; } - return false; }; - for (let iterationIndex = 0;;) { this.clusterIterate(iterationIndex, leastSquares, repeater); if (best.iteration != iterationIndex) break; @@ -1730,10 +1449,8 @@ class ClusterFit extends ColorFit { const newAxis = Vec4.sub(best.end, best.start).xyz; if (!this.constructOrdering(newAxis, iterationIndex)) break; } - if (best.error < this.bestError) this.saveBlock(best, saveFunc); } - makeOrder(axis) { const { count, @@ -1747,36 +1464,29 @@ class ClusterFit extends ColorFit { return a - b; }); } - copyOrderToThisOrder(order, iteration) { const orderOffset = iteration * 16; order.forEach((ord, i) => { this.order[orderOffset + i] = ord; }); } - checkOrderUnique(order, iteration) { const { count } = this.colors; - for (let it = 0; it < iteration; it++) { let prevOffset = it * 16; let same = true; - for (let i = 0; i < count; i++) { if (order[i] !== this.order[prevOffset + i]) { same = false; break; } } - if (same) return false; } - return true; } - copyOrderWeight(order) { const { count, @@ -1784,7 +1494,6 @@ class ClusterFit extends ColorFit { weights } = this.colors; this.xSum_wSum.set(0); - for (let i = 0; i < count; i++) { const j = order[i]; const p = unweighted[j].toVec4(1); @@ -1794,7 +1503,6 @@ class ClusterFit extends ColorFit { this.xSum_wSum.addVector(x); } } - computeOptimalPoints(vectorPoint) { const { ax, @@ -1818,7 +1526,6 @@ class ClusterFit extends ColorFit { error }; } - computeError(_ref3) { let { a, @@ -1837,7 +1544,6 @@ class ClusterFit extends ColorFit { const e5 = Vec4.multVector(e4, this.metric); return e5.x + e5.y + e5.z; } - saveBlock(best, writeFunc) { const { count @@ -1853,30 +1559,25 @@ class ClusterFit extends ColorFit { } = best; const orderOffset = iteration * 16; const unordered = new Uint8Array(16); - const mapper = m => { if (m < bestI) return 0; if (m < bestJ) return 2; if (m < bestK) return 3; return 1; }; - for (let i = 0; i < count; i++) { unordered[this.order[orderOffset + i]] = mapper(i); } - const bestIndices = new Uint8Array(16); this.colors.remapIndices(unordered, bestIndices); writeFunc(start.xyz, end.xyz, bestIndices); this.bestError = error; } - clusterIterate(index, func) { let iterCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; const { count } = this.colors; - const indexMapper = (i, j, k) => { const mapper = { bestI: i, @@ -1886,16 +1587,12 @@ class ClusterFit extends ColorFit { if (iterCount === 3) mapper.bestK = k; return mapper; }; - let part0 = new Vec4(0.0); - for (let i = 0; i < count; i++) { let part1 = new Vec4(0.0); - for (let j = i;;) { let preLastPart = j == 0 ? this.pointsWeights[0].clone() : new Vec4(0.0); const kmin = j == 0 ? 1 : j; - for (let k = kmin;;) { const restPart = Vec4.sub(this.xSum_wSum, preLastPart).subVector(part1).subVector(part0); func([part0, part1, preLastPart, restPart], indexMapper(i, j, k)); @@ -1903,17 +1600,14 @@ class ClusterFit extends ColorFit { preLastPart.addVector(this.pointsWeights[k]); k++; } - if (iterCount === 2) break; if (j === count) break; part1.addVector(this.pointsWeights[j]); j++; } - part0.addVector(this.pointsWeights[i]); } } - } function quantise(alpha) { @@ -1923,7 +1617,6 @@ function quantise(alpha) { if (result > GRID) return GRID; return result; } - function compressAlphaDxt3(rgba, mask, result, offset) { for (let i = 0; i < 8; i++) { let quant1 = quantise(rgba[8 * i + 3]); @@ -1935,13 +1628,11 @@ function compressAlphaDxt3(rgba, mask, result, offset) { result[offset + i] = quant1 | quant2 << 4; } } - function compressAlphaDxt5(rgba, mask, result, offset) { let step5 = interpolateAlpha(rgba, mask, 5); let step7 = interpolateAlpha(rgba, mask, 7); if (step5.error <= step7.error) writeAlphaBlock5(step5, result, offset);else writeAlphaBlock7(step7, result, offset); } - function interpolateAlpha(rgba, mask, steps) { let { min, @@ -1957,16 +1648,13 @@ function interpolateAlpha(rgba, mask, steps) { error }; } - function setAlphaRange(rgba, mask, steps) { let min = 255; let max = 0; - for (let i = 0; i < 16; i++) { let bit = 1 << i; if ((mask & bit) == 0) continue; let value = rgba[4 * i + 3]; - if (steps === 5) { if (value !== 0 && value < min) min = value; if (value !== 255 && value > max) max = value; @@ -1975,7 +1663,6 @@ function setAlphaRange(rgba, mask, steps) { if (value > max) max = value; } } - if (min > max) min = max; if (max - min < steps) max = Math.min(min + steps, 255); if (max - min < steps) min = Math.max(max - steps, 0); @@ -1984,61 +1671,48 @@ function setAlphaRange(rgba, mask, steps) { max }; } - function setAlphaCodeBook(min, max, steps) { let codes = [min, max, ...Array.from({ length: steps - 1 }, (_, i) => { return Math.floor(((steps - (i + 1)) * min + (i + 1) * max) / steps); })]; - if (steps === 5) { codes[6] = 0; codes[7] = 255; } - return codes; } - function fitCodes(rgba, mask, codes, indices) { let err = 0; - for (let i = 0; i < 16; ++i) { let bit = 1 << i; - if ((mask & bit) == 0) { indices[i] = 0; continue; } - let value = rgba[4 * i + 3]; let least = Infinity; let index = 0; - for (let j = 0; j < 8; ++j) { let dist = value - codes[j]; dist *= dist; - if (dist < least) { least = dist; index = j; } } - indices[i] = index; err += least; } - return err; } - function writeAlphaBlock5(_ref, result, offset) { let { min: alpha0, max: alpha1, indices } = _ref; - if (alpha0 > alpha1) { const swapped = indices.map(index => { if (index === 0) return 1; @@ -2049,14 +1723,12 @@ function writeAlphaBlock5(_ref, result, offset) { writeAlphaBlock(alpha1, alpha0, swapped, result, offset); } else writeAlphaBlock(alpha0, alpha1, indices, result, offset); } - function writeAlphaBlock7(_ref2, result, offset) { let { min: alpha0, max: alpha1, indices } = _ref2; - if (alpha0 > alpha1) { const swapped = indices.map(index => { if (index === 0) return 1; @@ -2066,22 +1738,18 @@ function writeAlphaBlock7(_ref2, result, offset) { writeAlphaBlock(alpha1, alpha0, swapped, result, offset); } else writeAlphaBlock(alpha0, alpha1, indices, result, offset); } - function writeAlphaBlock(alpha0, alpha1, indices, result, offset) { result[offset] = alpha0; result[offset + 1] = alpha1; let indicesPointer = 0; let resultPointer = offset + 2; - for (let i = 0; i < 2; i++) { let value = 0; - for (let j = 0; j < 8; ++j) { let index = indices[indicesPointer]; value |= index << 3 * j; indicesPointer++; } - for (let j = 0; j < 3; ++j) { let byte = value >> 8 * j & 0xff; result[resultPointer] = byte; @@ -2096,13 +1764,11 @@ function unpack565(color16bit) { const blue = color16bit & 0x1f; return [red << 3 | red >> 2, green << 2 | green >> 4, blue << 3 | blue >> 2, 255]; } - function interpolateColorArray(a, b, amount) { const result = a.map((aColor, i) => Math.floor(aColor * (1 - amount) + b[i] * amount)); result[3] = 255; return result; } - function unpackColorCodes(block, offset, isDxt1) { const color1 = block[offset] | block[offset + 1] << 8; const color2 = block[offset + 2] | block[offset + 3] << 8; @@ -2110,11 +1776,9 @@ function unpackColorCodes(block, offset, isDxt1) { const unpackedColor2 = unpack565(color2); return [unpackedColor1, unpackedColor2, isDxt1 && color1 <= color2 ? interpolateColorArray(unpackedColor1, unpackedColor2, 1 / 2) : interpolateColorArray(unpackedColor1, unpackedColor2, 1 / 3), isDxt1 && color1 <= color2 ? [0, 0, 0, 0] : interpolateColorArray(unpackedColor1, unpackedColor2, 2 / 3)]; } - function unpackIndices(block, blockOffset) { let offset = blockOffset + 4; let result = new Uint8Array(16); - for (let i = 0; i < 4; i++) { let packedIndices = block[offset + i]; result[i * 4 + 0] = packedIndices & 0x3; @@ -2122,21 +1786,17 @@ function unpackIndices(block, blockOffset) { result[i * 4 + 2] = packedIndices >> 4 & 0x3; result[i * 4 + 3] = packedIndices >> 6 & 0x3; } - return result; } - function decompressColor(rgba, block, offset, isDxt1) { const colorCode = unpackColorCodes(block, offset, isDxt1); const indices = unpackIndices(block, offset); - for (let i = 0; i < 16; i++) { for (let j = 0; j < 4; j++) { rgba[4 * i + j] = colorCode[indices[i]][j]; } } } - function decompressAlphaDxt3(rgba, block, offset) { for (let i = 0; i < 8; ++i) { let quant = block[offset + i]; @@ -2146,7 +1806,6 @@ function decompressAlphaDxt3(rgba, block, offset) { rgba[8 * i + 7] = hi | hi >> 4; } } - function decompressAlphaDxt5(rgba, block, offset) { let alpha0 = block[offset + 0]; let alpha1 = block[offset + 1]; @@ -2154,23 +1813,19 @@ function decompressAlphaDxt5(rgba, block, offset) { let indices = new Uint8Array(16); let indicePointer = 0; let bytePointer = 2; - for (let i = 0; i < 2; i++) { let value = 0; - for (let j = 0; j < 3; j++) { let byte = block[offset + bytePointer]; value |= byte << 8 * j; bytePointer++; } - for (let j = 0; j < 8; j++) { let index = value >> 3 * j & 0x7; indices[indicePointer] = index; indicePointer++; } } - for (let i = 0; i < 16; ++i) { rgba[4 * i + 3] = codes[indices[i]]; } @@ -2201,7 +1856,6 @@ const DXT1_COMPRESSED_BYTES = 8; const DXT5_COMPRESSED_BYTES = 16; const COLORS = 4; const DECOMPRESSED_BLOCK_SIZE = 16; - function blockRepeat(width, height, func) { for (let y = 0; y < height; y += 4) { for (let x = 0; x < width; x += 4) { @@ -2209,7 +1863,6 @@ function blockRepeat(width, height, func) { } } } - function rectRepeat(func) { for (let y = 0; y < 4; y++) { for (let x = 0; x < 4; x++) { @@ -2217,7 +1870,6 @@ function rectRepeat(func) { } } } - function FixFlags(flags) { let method = flags & (kDxt1 | kDxt3 | kDxt5); let fit = flags & (kColourIterativeClusterFit | kColourClusterFit | kColourRangeFit); @@ -2228,14 +1880,12 @@ function FixFlags(flags) { if (metric != kColourMetricUniform) metric = kColourMetricPerceptual; return method | fit | metric | extra; } - function GetStorageRequirements(width, height, flags) { flags = FixFlags(flags); const blockcount = Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4); const blocksize = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; return blockcount * blocksize; } - function extractColorBlock(img) { let { x = 0, @@ -2249,14 +1899,11 @@ function extractColorBlock(img) { rectRepeat(function (px, py) { let sx = x + px; let sy = y + py; - if (sx < width && sy < height) { let sourceColorOffset = COLORS * (width * sy + sx); - for (let i = 0; i < COLORS; i++) { block[blockColorOffset++] = img[sourceColorOffset++]; } - mask |= 1 << 4 * py + px; } else blockColorOffset += COLORS; }); @@ -2265,7 +1912,6 @@ function extractColorBlock(img) { mask }; } - function copyBuffer(result, block) { let { x = 0, @@ -2277,23 +1923,19 @@ function copyBuffer(result, block) { rectRepeat(function (px, py) { let sx = x + px; let sy = y + py; - if (sx < width && sy < height) { let resultColorOffset = COLORS * (width * sy + sx); - for (let i = 0; i < COLORS; i++) { result[resultColorOffset + i] = block[blockColorOffset++]; } } else blockColorOffset += COLORS; }); } - function getCompressor(colorSet) { if (colorSet.count === 1) return new SingleColourFit(colorSet); if ((colorSet.flags & kColourRangeFit) != 0 || colorSet.count == 0) return new RangeFit(colorSet); return new ClusterFit(colorSet); } - function CompressMasked(rgba, mask, result, offset, flags) { flags = FixFlags(flags); let colorOffset = (flags & (kDxt3 | kDxt5)) !== 0 ? 8 : 0; @@ -2302,14 +1944,12 @@ function CompressMasked(rgba, mask, result, offset, flags) { compressor.compress(result, offset + colorOffset); if ((flags & kDxt3) !== 0) compressAlphaDxt3(rgba, mask, result, offset);else if ((flags & kDxt5) !== 0) compressAlphaDxt5(rgba, mask, result, offset); } - function decompressBlock(result, block, offset, flags) { flags = FixFlags(flags); let colorOffset = (flags & (kDxt3 | kDxt5)) !== 0 ? 8 : 0; decompressColor(result, block, offset + colorOffset, (flags & kDxt1) !== 0); if ((flags & kDxt3) !== 0) decompressAlphaDxt3(result, block, offset);else if ((flags & kDxt5) !== 0) decompressAlphaDxt5(result, block, offset); } - function compressImage(source, width, height, result, flags) { flags = FixFlags(flags); const bytesPerBlock = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; @@ -2328,12 +1968,10 @@ function compressImage(source, width, height, result, flags) { targetBlockPointer += bytesPerBlock; }); } - function decompressImage(result, width, height, source, flags) { flags = FixFlags(flags); const bytesPerBlock = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; let sourceBlockPointer = 0; - for (let y = 0; y < height; y += 4) { for (let x = 0; x < width; x += 4) { const targetRGBA = new Uint8Array(DECOMPRESSED_BLOCK_SIZE * COLORS); @@ -2348,7 +1986,6 @@ function decompressImage(result, width, height, source, flags) { } } } - const flags = { DXT1: kDxt1, DXT3: kDxt3, @@ -2360,7 +1997,6 @@ const flags = { ColourMetricUniform: kColourMetricUniform, WeightColourByAlpha: kWeightColourByAlpha }; - function compress(inputData, width, height, flags) { let source = inputData instanceof ArrayBuffer ? new Uint8Array(inputData) : inputData; const targetSize = GetStorageRequirements(width, height, flags); @@ -2368,7 +2004,6 @@ function compress(inputData, width, height, flags) { compressImage(source, width, height, result, flags); return result; } - function decompress(inputData, width, height, flags) { let source = inputData instanceof ArrayBuffer ? new Uint8Array(inputData) : inputData; const targetSize = width * height * 4; @@ -2380,7 +2015,6 @@ function decompress(inputData, width, height, flags) { function extractBits(bitData, amount, offset) { return bitData >> offset & 2 ** amount - 1; } - function colorToBgra5551(red, green, blue, alpha) { const r = Math.round(red / 255 * 31); const g = Math.round(green / 255 * 31); @@ -2388,24 +2022,19 @@ function colorToBgra5551(red, green, blue, alpha) { const a = Math.round(alpha / 255); return a << 15 | r << 10 | g << 5 | b; } - function bgra5551ToColor(bgra5551) { const r = extractBits(bgra5551, 5, 10); const g = extractBits(bgra5551, 5, 5); const b = extractBits(bgra5551, 5, 0); const a = bgra5551 >> 15 & 1; - const scaleUp = value => value << 3 | value >> 2; - const [red, green, blue] = [r, g, b].map(scaleUp); return [red, green, blue, a * 255]; } - function convertTo5551(colorBuffer) { const colorArray = new Uint8Array(colorBuffer); const length = colorArray.length / 4; const convertedArray = new Uint8Array(length * 2); - for (let i = 0; i < length; i++) { const red = colorArray[i * 4]; const green = colorArray[i * 4 + 1]; @@ -2415,20 +2044,16 @@ function convertTo5551(colorBuffer) { convertedArray[i * 2] = bgra5551 & 0xff; convertedArray[i * 2 + 1] = bgra5551 >> 8; } - return convertedArray; } - function convertFrom5551(colorBuffer) { const colorArray = new Uint8Array(colorBuffer); const length = colorArray.length / 2; const convertedArray = new Uint8Array(length * 4); - for (let i = 0; i < length; i++) { const colors = bgra5551ToColor(colorArray[i * 2] | colorArray[i * 2 + 1] << 8); [convertedArray[i * 4], convertedArray[i * 4 + 1], convertedArray[i * 4 + 2], convertedArray[i * 4 + 3]] = colors; } - return convertedArray; } @@ -2437,12 +2062,10 @@ class Texture2DReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.Texture2DReader': return true; - default: return false; } } - read(buffer) { const int32Reader = new Int32Reader(); const uint32Reader = new UInt32Reader(); @@ -2450,22 +2073,31 @@ class Texture2DReader extends BaseReader { let width = uint32Reader.read(buffer); let height = uint32Reader.read(buffer); let mipCount = uint32Reader.read(buffer); + let usedWidth = null; + let usedHeight = null; if (mipCount > 1) console.warn("Found mipcount of ".concat(mipCount, ", only the first will be used.")); let dataSize = uint32Reader.read(buffer); + if (width * height * 4 > dataSize) { + usedWidth = width >> 16 & 0xffff; + width = width & 0xffff; + usedHeight = height >> 16 & 0xffff; + height = height & 0xffff; + if (width * height * 4 !== dataSize) { + console.warn("invalid width & height! ".concat(width, " x ").concat(height)); + } + } let data = buffer.read(dataSize); if (format == 4) data = decompress(data, width, height, flags.DXT1);else if (format == 5) data = decompress(data, width, height, flags.DXT3);else if (format == 6) data = decompress(data, width, height, flags.DXT5);else if (format == 2) { data = convertFrom5551(data); } else if (format != 0) throw new Error("Non-implemented Texture2D format type (".concat(format, ") found.")); if (data instanceof ArrayBuffer) data = new Uint8Array(data); - for (let i = 0; i < data.length; i += 4) { let inverseAlpha = 255 / data[i + 3]; data[i] = Math.min(Math.ceil(data[i] * inverseAlpha), 255); data[i + 1] = Math.min(Math.ceil(data[i + 1] * inverseAlpha), 255); data[i + 2] = Math.min(Math.ceil(data[i + 2] * inverseAlpha), 255); } - - return { + const result = { format, export: { type: this.type, @@ -2474,36 +2106,40 @@ class Texture2DReader extends BaseReader { height } }; + if (usedWidth !== null) result.additional = { + usedWidth, + usedHeight + }; + return result; } - write(buffer, content, resolver) { const int32Reader = new Int32Reader(); const uint32Reader = new UInt32Reader(); this.writeIndex(buffer, resolver); - const width = content.export.width; - const height = content.export.height; + let width = content.export.width; + let height = content.export.height; + if (content.additional != null) { + width = width | content.additional.usedWidth << 16; + height = height | content.additional.usedHeight << 16; + } int32Reader.write(buffer, content.format, null); - uint32Reader.write(buffer, content.export.width, null); - uint32Reader.write(buffer, content.export.height, null); + uint32Reader.write(buffer, width, null); + uint32Reader.write(buffer, height, null); uint32Reader.write(buffer, 1, null); let data = content.export.data; - for (let i = 0; i < data.length; i += 4) { const alpha = data[i + 3] / 255; data[i] = Math.floor(data[i] * alpha); data[i + 1] = Math.floor(data[i + 1] * alpha); data[i + 2] = Math.floor(data[i + 2] * alpha); } - if (content.format === 4) data = compress(data, width, height, flags.DXT1);else if (content.format === 5) data = compress(data, width, height, flags.DXT3);else if (content.format === 6) data = compress(data, width, height, flags.DXT5);else if (content.format === 2) data = convertTo5551(data); uint32Reader.write(buffer, data.length, null); buffer.concat(data); } - isValueType() { return false; } - } class Vector3Reader extends BaseReader { @@ -2512,12 +2148,10 @@ class Vector3Reader extends BaseReader { case 'Microsoft.Xna.Framework.Content.Vector3Reader': case 'Microsoft.Xna.Framework.Vector3': return true; - default: return false; } } - read(buffer) { const singleReader = new SingleReader(); let x = singleReader.read(buffer); @@ -2529,7 +2163,6 @@ class Vector3Reader extends BaseReader { z }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const singleReader = new SingleReader(); @@ -2537,7 +2170,6 @@ class Vector3Reader extends BaseReader { singleReader.write(buffer, content.y, null); singleReader.write(buffer, content.z, null); } - } class SpriteFontReader extends BaseReader { @@ -2545,16 +2177,13 @@ class SpriteFontReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.SpriteFontReader': return true; - default: return false; } } - static parseTypeList() { return ["SpriteFont", "Texture2D", 'List', 'Rectangle', 'List', 'Rectangle', 'List', 'Char', null, null, 'List', 'Vector3', 'Nullable', 'Char']; } - read(buffer, resolver) { const int32Reader = new Int32Reader(); const singleReader = new SingleReader(); @@ -2578,7 +2207,6 @@ class SpriteFontReader extends BaseReader { defaultCharacter }; } - write(buffer, content, resolver) { const int32Reader = new Int32Reader(); const charReader = new CharReader(); @@ -2589,7 +2217,6 @@ class SpriteFontReader extends BaseReader { const charListReader = new ListReader(charReader); const vector3ListReader = new ListReader(new Vector3Reader()); this.writeIndex(buffer, resolver); - try { texture2DReader.write(buffer, content.texture, resolver); buffer.alloc(100000); @@ -2604,11 +2231,9 @@ class SpriteFontReader extends BaseReader { throw ex; } } - isValueType() { return false; } - } class TBinReader extends BaseReader { @@ -2616,12 +2241,10 @@ class TBinReader extends BaseReader { switch (type) { case 'xTile.Pipeline.TideReader': return true; - default: return false; } } - read(buffer) { const int32Reader = new Int32Reader(); let size = int32Reader.read(buffer); @@ -2633,7 +2256,6 @@ class TBinReader extends BaseReader { } }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const data = content.export.data; @@ -2641,11 +2263,9 @@ class TBinReader extends BaseReader { int32Reader.write(buffer, data.byteLength, null); buffer.concat(data); } - isValueType() { return false; } - } class LightweightTexture2DReader extends BaseReader { @@ -2653,16 +2273,13 @@ class LightweightTexture2DReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.Texture2DReader': return true; - default: return false; } } - static type() { return "Texture2D"; } - read(buffer) { const int32Reader = new Int32Reader(); const uint32Reader = new UInt32Reader(); @@ -2675,14 +2292,12 @@ class LightweightTexture2DReader extends BaseReader { let data = buffer.read(dataSize); data = new Uint8Array(data); if (format != 0) throw new Error("Compressed texture format is not supported!"); - for (let i = 0; i < data.length; i += 4) { let inverseAlpha = 255 / data[i + 3]; data[i] = Math.min(Math.ceil(data[i] * inverseAlpha), 255); data[i + 1] = Math.min(Math.ceil(data[i + 1] * inverseAlpha), 255); data[i + 2] = Math.min(Math.ceil(data[i + 2] * inverseAlpha), 255); } - return { format, export: { @@ -2693,7 +2308,6 @@ class LightweightTexture2DReader extends BaseReader { } }; } - write(buffer, content, resolver) { if (content.format != 0) throw new Error("Compressed texture format is not supported!"); const int32Reader = new Int32Reader(); @@ -2706,26 +2320,21 @@ class LightweightTexture2DReader extends BaseReader { uint32Reader.write(buffer, content.export.height, null); uint32Reader.write(buffer, 1, null); let data = content.export.data; - for (let i = 0; i < data.length; i += 4) { const alpha = data[i + 3] / 255; data[i] = Math.floor(data[i] * alpha); data[i + 1] = Math.floor(data[i + 1] * alpha); data[i + 2] = Math.floor(data[i + 2] * alpha); } - uint32Reader.write(buffer, data.length, null); buffer.concat(data); } - isValueType() { return false; } - get type() { return "Texture2D"; } - } class Vector2Reader extends BaseReader { @@ -2734,12 +2343,10 @@ class Vector2Reader extends BaseReader { case 'Microsoft.Xna.Framework.Content.Vector2Reader': case 'Microsoft.Xna.Framework.Vector2': return true; - default: return false; } } - read(buffer) { const singleReader = new SingleReader(); let x = singleReader.read(buffer); @@ -2749,7 +2356,12 @@ class Vector2Reader extends BaseReader { y }; } - + write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + const singleReader = new SingleReader(); + singleReader.write(buffer, content.x, null); + singleReader.write(buffer, content.y, null); + } } class Vector4Reader extends BaseReader { @@ -2758,12 +2370,10 @@ class Vector4Reader extends BaseReader { case 'Microsoft.Xna.Framework.Content.Vector4Reader': case 'Microsoft.Xna.Framework.Vector4': return true; - default: return false; } } - read(buffer) { const singleReader = new SingleReader(); let x = singleReader.read(buffer); @@ -2777,7 +2387,14 @@ class Vector4Reader extends BaseReader { w }; } - + write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + const singleReader = new SingleReader(); + singleReader.write(buffer, content.x, null); + singleReader.write(buffer, content.y, null); + singleReader.write(buffer, content.z, null); + singleReader.write(buffer, content.w, null); + } } exports.ArrayReader = ArrayReader; @@ -2792,6 +2409,7 @@ exports.Int32Reader = Int32Reader; exports.LightweightTexture2DReader = LightweightTexture2DReader; exports.ListReader = ListReader; exports.NullableReader = NullableReader; +exports.PointReader = PointReader; exports.RectangleReader = RectangleReader; exports.ReflectiveReader = ReflectiveReader; exports.SingleReader = SingleReader; diff --git a/dist/readers/xnb-readers.es5.js b/dist/readers/xnb-readers.es5.js index 8c849de..143ef40 100644 --- a/dist/readers/xnb-readers.es5.js +++ b/dist/readers/xnb-readers.es5.js @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -1284,17 +1284,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } - return keys; } - function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; @@ -1304,10 +1301,8 @@ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } - return target; } - function _typeof(obj) { "@babel/helpers - typeof"; @@ -1317,13 +1312,11 @@ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; @@ -1333,7 +1326,6 @@ Object.defineProperty(target, descriptor.key, descriptor); } } - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); @@ -1342,7 +1334,6 @@ }); return Constructor; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { @@ -1354,15 +1345,12 @@ } else { obj[key] = value; } - return obj; } - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } - subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, @@ -1375,28 +1363,23 @@ }); if (superClass) _setPrototypeOf(subClass, superClass); } - function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } - function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; - return _setPrototypeOf(o, p); } - function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; - try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; @@ -1404,7 +1387,6 @@ return false; } } - function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; @@ -1418,53 +1400,28 @@ return instance; }; } - return _construct.apply(null, arguments); } - function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } - return self; } - function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } - return _assertThisInitialized(self); } - function _createSuper(Derived) { - var hasNativeReflectConstruct = _isNativeReflectConstruct(); - - return function _createSuperInternal() { - var Super = _getPrototypeOf(Derived), - result; - - if (hasNativeReflectConstruct) { - var NewTarget = _getPrototypeOf(this).constructor; - - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); - } - - return _possibleConstructorReturn(this, result); - }; - } - var BaseReader = function () { function BaseReader() { _classCallCheck(this, BaseReader); } - - _createClass(BaseReader, [{ + return _createClass(BaseReader, [{ key: "isValueType", value: function isValueType() { return true; @@ -1520,22 +1477,29 @@ return this.name.slice(0, -6); } }]); - - return BaseReader; }(); + function _callSuper$n(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var UInt32Reader = function (_BaseReader) { - _inherits(UInt32Reader, _BaseReader); - - var _super = _createSuper(UInt32Reader); - function UInt32Reader() { _classCallCheck(this, UInt32Reader); - - return _super.apply(this, arguments); + return _callSuper$n(this, UInt32Reader, arguments); } - - _createClass(UInt32Reader, [{ + _inherits(UInt32Reader, _BaseReader); + return _createClass(UInt32Reader, [{ key: "read", value: function read(buffer) { return buffer.readUInt32(); @@ -1553,43 +1517,46 @@ case 'Microsoft.Xna.Framework.Content.UInt32Reader': case 'System.UInt32': return true; - default: return false; } } }]); - - return UInt32Reader; }(BaseReader); + function _callSuper$m(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var ArrayReader = function (_BaseReader) { - _inherits(ArrayReader, _BaseReader); - - var _super = _createSuper(ArrayReader); - function ArrayReader(reader) { - var _this; - + var _this2; _classCallCheck(this, ArrayReader); - - _this = _super.call(this); - _this.reader = reader; - return _this; + _this2 = _callSuper$m(this, ArrayReader); + _this2.reader = reader; + return _this2; } - - _createClass(ArrayReader, [{ + _inherits(ArrayReader, _BaseReader); + return _createClass(ArrayReader, [{ key: "read", value: function read(buffer, resolver) { var uint32Reader = new UInt32Reader(); var size = uint32Reader.read(buffer); var array = []; - for (var i = 0; i < size; i++) { var value = this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); array.push(value); } - return array; } }, { @@ -1597,11 +1564,8 @@ value: function write(buffer, content, resolver) { this.writeIndex(buffer, resolver); var uint32Reader = new UInt32Reader(); - uint32Reader.write(buffer, content.length, resolver); - - for (var i = 0; i < content.length; i++) { - this.reader.write(buffer, content[i], this.reader.isValueType() ? null : resolver); - } + uint32Reader.write(buffer, content.length, null); + for (var i = 0; i < content.length; i++) this.reader.write(buffer, content[i], this.reader.isValueType() ? null : resolver); } }, { key: "isValueType", @@ -1616,7 +1580,8 @@ }, { key: "parseTypeList", value: function parseTypeList() { - return [this.type].concat(this.reader.parseTypeList()); + var inBlock = this.reader.parseTypeList(); + return ["".concat(this.type, ":").concat(inBlock.length)].concat(inBlock); } }], [{ key: "isTypeOf", @@ -1624,7 +1589,6 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.ArrayReader': return true; - default: return false; } @@ -1635,27 +1599,21 @@ return true; } }]); - - return ArrayReader; }(BaseReader); function __arrayMaker(obj, func) { if (!obj || _typeof(obj) !== "object") throw new Error("Invalid Data!"); var result = []; var length = obj.length; - for (var i = 0; i < length; i++) { result[i] = func(obj[i], i); } - return result; } - function __trunc(number) { if (number < 0) return Math.ceil(number); return Math.floor(number); } - Promise.allSettled !== undefined ? Promise.allSettled.bind(Promise) : function (promises) { var mappedPromises = promises.map(function (p) { return p.then(function (value) { @@ -1675,30 +1633,24 @@ var UTF16_BITES = [0xD800, 0xDC00]; var UTF16_MASK = 1023; - function UTF16Decode(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); var codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; return ((codeSet[0] & UTF16_MASK) << 10) + (codeSet[1] & UTF16_MASK) + 0x10000; } - function stringToUnicode(str) { var utf16Map = __arrayMaker({ length: str.length }, function (_, i) { return str.charCodeAt(i); }); - var result = []; var index = 0; - while (index < str.length) { var code = utf16Map[index]; - if ((UTF16_BITES[0] & code) !== UTF16_BITES[0]) { result.push(code); index++; @@ -1707,10 +1659,8 @@ index += 2; } } - return result; } - function UTF8Length(str) { var codes = stringToUnicode(str); return codes.reduce(function (sum, unicode) { @@ -1721,18 +1671,27 @@ }, 0); } + function _callSuper$l(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var StringReader = function (_BaseReader) { - _inherits(StringReader, _BaseReader); - - var _super = _createSuper(StringReader); - function StringReader() { _classCallCheck(this, StringReader); - - return _super.apply(this, arguments); + return _callSuper$l(this, StringReader, arguments); } - - _createClass(StringReader, [{ + _inherits(StringReader, _BaseReader); + return _createClass(StringReader, [{ key: "read", value: function read(buffer) { var length = buffer.read7BitNumber(); @@ -1758,28 +1717,34 @@ case 'Microsoft.Xna.Framework.Content.StringReader': case 'System.String': return true; - default: return false; } } }]); - - return StringReader; }(BaseReader); + function _callSuper$k(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var BmFontReader = function (_BaseReader) { - _inherits(BmFontReader, _BaseReader); - - var _super = _createSuper(BmFontReader); - function BmFontReader() { _classCallCheck(this, BmFontReader); - - return _super.apply(this, arguments); + return _callSuper$k(this, BmFontReader, arguments); } - - _createClass(BmFontReader, [{ + _inherits(BmFontReader, _BaseReader); + return _createClass(BmFontReader, [{ key: "read", value: function read(buffer) { var stringReader = new StringReader(); @@ -1809,28 +1774,34 @@ switch (type) { case 'BmFont.XmlSourceReader': return true; - default: return false; } } }]); - - return BmFontReader; }(BaseReader); + function _callSuper$j(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var BooleanReader = function (_BaseReader) { - _inherits(BooleanReader, _BaseReader); - - var _super = _createSuper(BooleanReader); - function BooleanReader() { _classCallCheck(this, BooleanReader); - - return _super.apply(this, arguments); + return _callSuper$j(this, BooleanReader, arguments); } - - _createClass(BooleanReader, [{ + _inherits(BooleanReader, _BaseReader); + return _createClass(BooleanReader, [{ key: "read", value: function read(buffer) { return Boolean(buffer.readInt()); @@ -1848,32 +1819,37 @@ case 'Microsoft.Xna.Framework.Content.BooleanReader': case 'System.Boolean': return true; - default: return false; } } }]); - - return BooleanReader; }(BaseReader); + function _callSuper$i(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var CharReader = function (_BaseReader) { - _inherits(CharReader, _BaseReader); - - var _super = _createSuper(CharReader); - function CharReader() { _classCallCheck(this, CharReader); - - return _super.apply(this, arguments); + return _callSuper$i(this, CharReader, arguments); } - - _createClass(CharReader, [{ + _inherits(CharReader, _BaseReader); + return _createClass(CharReader, [{ key: "read", value: function read(buffer) { var charSize = this._getCharSize(buffer.peekInt()); - return buffer.readString(charSize); } }, { @@ -1894,46 +1870,49 @@ case 'Microsoft.Xna.Framework.Content.CharReader': case 'System.Char': return true; - default: return false; } } }]); - - return CharReader; }(BaseReader); + function _callSuper$h(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var DictionaryReader = function (_BaseReader) { - _inherits(DictionaryReader, _BaseReader); - - var _super = _createSuper(DictionaryReader); - function DictionaryReader(key, value) { - var _this; - + var _this2; _classCallCheck(this, DictionaryReader); - if (key == undefined || value == undefined) throw new Error('Cannot create instance of DictionaryReader without Key and Value.'); - _this = _super.call(this); - _this.key = key; - _this.value = value; - return _this; + _this2 = _callSuper$h(this, DictionaryReader); + _this2.key = key; + _this2.value = value; + return _this2; } - - _createClass(DictionaryReader, [{ + _inherits(DictionaryReader, _BaseReader); + return _createClass(DictionaryReader, [{ key: "read", value: function read(buffer, resolver) { var dictionary = {}; var uint32Reader = new UInt32Reader(); var size = uint32Reader.read(buffer); - for (var i = 0; i < size; i++) { var key = this.key.isValueType() ? this.key.read(buffer) : resolver.read(buffer); var value = this.value.isValueType() ? this.value.read(buffer) : resolver.read(buffer); dictionary[key] = value; } - return dictionary; } }, { @@ -1941,7 +1920,6 @@ value: function write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeUInt32(Object.keys(content).length); - for (var _i2 = 0, _Object$keys2 = Object.keys(content); _i2 < _Object$keys2.length; _i2++) { var key = _Object$keys2[_i2]; this.key.write(buffer, key, this.key.isValueType() ? null : resolver); @@ -1969,7 +1947,6 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.DictionaryReader': return true; - default: return false; } @@ -1980,22 +1957,29 @@ return true; } }]); - - return DictionaryReader; }(BaseReader); + function _callSuper$g(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var DoubleReader = function (_BaseReader) { - _inherits(DoubleReader, _BaseReader); - - var _super = _createSuper(DoubleReader); - function DoubleReader() { _classCallCheck(this, DoubleReader); - - return _super.apply(this, arguments); + return _callSuper$g(this, DoubleReader, arguments); } - - _createClass(DoubleReader, [{ + _inherits(DoubleReader, _BaseReader); + return _createClass(DoubleReader, [{ key: "read", value: function read(buffer) { return buffer.readDouble(); @@ -2013,28 +1997,34 @@ case 'Microsoft.Xna.Framework.Content.DoubleReader': case 'System.Double': return true; - default: return false; } } }]); - - return DoubleReader; }(BaseReader); + function _callSuper$f(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var EffectReader = function (_BaseReader) { - _inherits(EffectReader, _BaseReader); - - var _super = _createSuper(EffectReader); - function EffectReader() { _classCallCheck(this, EffectReader); - - return _super.apply(this, arguments); + return _callSuper$f(this, EffectReader, arguments); } - - _createClass(EffectReader, [{ + _inherits(EffectReader, _BaseReader); + return _createClass(EffectReader, [{ key: "read", value: function read(buffer) { var uint32Reader = new UInt32Reader(); @@ -2068,28 +2058,34 @@ case 'Microsoft.Xna.Framework.Content.EffectReader': case 'Microsoft.Xna.Framework.Graphics.Effect': return true; - default: return false; } } }]); - - return EffectReader; }(BaseReader); + function _callSuper$e(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var Int32Reader = function (_BaseReader) { - _inherits(Int32Reader, _BaseReader); - - var _super = _createSuper(Int32Reader); - function Int32Reader() { _classCallCheck(this, Int32Reader); - - return _super.apply(this, arguments); + return _callSuper$e(this, Int32Reader, arguments); } - - _createClass(Int32Reader, [{ + _inherits(Int32Reader, _BaseReader); + return _createClass(Int32Reader, [{ key: "read", value: function read(buffer) { return buffer.readInt32(); @@ -2105,45 +2101,49 @@ value: function isTypeOf(type) { switch (type) { case 'Microsoft.Xna.Framework.Content.Int32Reader': + case 'Microsoft.Xna.Framework.Content.EnumReader': case 'System.Int32': return true; - default: return false; } } }]); - - return Int32Reader; }(BaseReader); + function _callSuper$d(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var ListReader = function (_BaseReader) { - _inherits(ListReader, _BaseReader); - - var _super = _createSuper(ListReader); - function ListReader(reader) { - var _this; - + var _this2; _classCallCheck(this, ListReader); - - _this = _super.call(this); - _this.reader = reader; - return _this; + _this2 = _callSuper$d(this, ListReader); + _this2.reader = reader; + return _this2; } - - _createClass(ListReader, [{ + _inherits(ListReader, _BaseReader); + return _createClass(ListReader, [{ key: "read", value: function read(buffer, resolver) { var uint32Reader = new UInt32Reader(); var size = uint32Reader.read(buffer); var list = []; - for (var i = 0; i < size; i++) { var value = this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); list.push(value); } - return list; } }, { @@ -2152,12 +2152,8 @@ this.writeIndex(buffer, resolver); var uint32Reader = new UInt32Reader(); uint32Reader.write(buffer, content.length, null); - - var __keys = Object.keys(content); - - for (var __i = 0; __i < __keys.length; __i++) { - var __key = __keys[__i], - data = content[__key]; + for (var _i2 = 0; _i2 < content.length; _i2++) { + var data = content[_i2]; this.reader.write(buffer, data, this.reader.isValueType() ? null : resolver); } } @@ -2174,7 +2170,8 @@ }, { key: "parseTypeList", value: function parseTypeList() { - return [this.type].concat(this.reader.parseTypeList()); + var inBlock = this.reader.parseTypeList(); + return ["".concat(this.type, ":").concat(inBlock.length)].concat(inBlock); } }], [{ key: "isTypeOf", @@ -2183,7 +2180,6 @@ case 'Microsoft.Xna.Framework.Content.ListReader': case 'System.Collections.Generic.List': return true; - default: return false; } @@ -2194,43 +2190,46 @@ return true; } }]); - - return ListReader; }(BaseReader); + function _callSuper$c(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var NullableReader = function (_BaseReader) { - _inherits(NullableReader, _BaseReader); - - var _super = _createSuper(NullableReader); - function NullableReader(reader) { - var _this; - + var _this2; _classCallCheck(this, NullableReader); - - _this = _super.call(this); - _this.reader = reader; - return _this; + _this2 = _callSuper$c(this, NullableReader); + _this2.reader = reader; + return _this2; } - - _createClass(NullableReader, [{ + _inherits(NullableReader, _BaseReader); + return _createClass(NullableReader, [{ key: "read", value: function read(buffer) { var resolver = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var booleanReader = new BooleanReader(); var hasValue = buffer.peekByte(1); - if (!hasValue) { booleanReader.read(buffer); return null; } - - if (resolver === null) { + if (resolver === null || this.reader.isValueType()) { booleanReader.read(buffer); return this.reader.read(buffer); } - - return this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); + return resolver.read(buffer); } }, { key: "write", @@ -2238,13 +2237,11 @@ var content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var resolver = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; new BooleanReader(); - if (content === null) { buffer.writeByte(0); return; } - - if (resolver === null) buffer.writeByte(1); + if (resolver === null || this.reader.isValueType()) buffer.writeByte(1); this.reader.write(buffer, content, this.reader.isValueType() ? null : resolver); } }, { @@ -2269,7 +2266,6 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.NullableReader': return true; - default: return false; } @@ -2280,26 +2276,85 @@ return true; } }]); + }(BaseReader); - return NullableReader; + function _callSuper$b(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } + var PointReader = function (_BaseReader) { + function PointReader() { + _classCallCheck(this, PointReader); + return _callSuper$b(this, PointReader, arguments); + } + _inherits(PointReader, _BaseReader); + return _createClass(PointReader, [{ + key: "read", + value: function read(buffer) { + var int32Reader = new Int32Reader(); + var x = int32Reader.read(buffer); + var y = int32Reader.read(buffer); + return { + x: x, + y: y + }; + } + }, { + key: "write", + value: function write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + var int32Reader = new Int32Reader(); + int32Reader.write(buffer, content.x, null); + int32Reader.write(buffer, content.y, null); + } + }], [{ + key: "isTypeOf", + value: function isTypeOf(type) { + switch (type) { + case 'Microsoft.Xna.Framework.Content.PointReader': + case 'Microsoft.Xna.Framework.Point': + return true; + default: + return false; + } + } + }]); }(BaseReader); + function _callSuper$a(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var ReflectiveReader = function (_BaseReader) { - _inherits(ReflectiveReader, _BaseReader); - - var _super = _createSuper(ReflectiveReader); - function ReflectiveReader(reader) { - var _this; - + var _this2; _classCallCheck(this, ReflectiveReader); - - _this = _super.call(this); - _this.reader = reader; - return _this; + _this2 = _callSuper$a(this, ReflectiveReader); + _this2.reader = reader; + return _this2; } - - _createClass(ReflectiveReader, [{ + _inherits(ReflectiveReader, _BaseReader); + return _createClass(ReflectiveReader, [{ key: "read", value: function read(buffer, resolver) { var reflective = this.reader.read(buffer, resolver); @@ -2331,7 +2386,6 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.ReflectiveReader': return true; - default: return false; } @@ -2342,22 +2396,29 @@ return true; } }]); - - return ReflectiveReader; }(BaseReader); + function _callSuper$9(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var RectangleReader = function (_BaseReader) { - _inherits(RectangleReader, _BaseReader); - - var _super = _createSuper(RectangleReader); - function RectangleReader() { _classCallCheck(this, RectangleReader); - - return _super.apply(this, arguments); + return _callSuper$9(this, RectangleReader, arguments); } - - _createClass(RectangleReader, [{ + _inherits(RectangleReader, _BaseReader); + return _createClass(RectangleReader, [{ key: "read", value: function read(buffer) { var int32Reader = new Int32Reader(); @@ -2389,28 +2450,34 @@ case 'Microsoft.Xna.Framework.Content.RectangleReader': case 'Microsoft.Xna.Framework.Rectangle': return true; - default: return false; } } }]); - - return RectangleReader; }(BaseReader); + function _callSuper$8(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var SingleReader = function (_BaseReader) { - _inherits(SingleReader, _BaseReader); - - var _super = _createSuper(SingleReader); - function SingleReader() { _classCallCheck(this, SingleReader); - - return _super.apply(this, arguments); + return _callSuper$8(this, SingleReader, arguments); } - - _createClass(SingleReader, [{ + _inherits(SingleReader, _BaseReader); + return _createClass(SingleReader, [{ key: "read", value: function read(buffer) { return buffer.readSingle(); @@ -2428,14 +2495,11 @@ case 'Microsoft.Xna.Framework.Content.SingleReader': case 'System.Single': return true; - default: return false; } } }]); - - return SingleReader; }(BaseReader); var kDxt1 = 1 << 0; @@ -2452,20 +2516,16 @@ var Mat = [[Math.cos(theta), Math.sin(theta)], [-Math.sin(theta), Math.cos(theta)]]; return Mat; } - function Rij(k, l, theta, N) { var Mat = Array(N); - for (var i = 0; i < N; i++) { Mat[i] = Array(N); } - for (var _i = 0; _i < N; _i++) { for (var j = 0; j < N; j++) { Mat[_i][j] = (_i === j) * 1.0; } } - var Rotij = Rot(theta); Mat[k][k] = Rotij[0][0]; Mat[l][l] = Rotij[1][1]; @@ -2473,25 +2533,20 @@ Mat[l][k] = Rotij[1][0]; return Mat; } - function getTheta(aii, ajj, aij) { var th = 0.0; var denom = ajj - aii; - if (Math.abs(denom) <= 1E-12) { th = Math.PI / 4.0; } else { th = 0.5 * Math.atan(2.0 * aij / (ajj - aii)); } - return th; } - function getAij(Mij) { var N = Mij.length; var maxMij = 0.0; var maxIJ = [0, 1]; - for (var i = 0; i < N; i++) { for (var j = i + 1; j < N; j++) { if (Math.abs(maxMij) <= Math.abs(Mij[i][j])) { @@ -2500,22 +2555,17 @@ } } } - return [maxIJ, maxMij]; } - function unitary(U, H) { var N = U.length; var Mat = Array(N); - for (var i = 0; i < N; i++) { Mat[i] = Array(N); } - for (var _i2 = 0; _i2 < N; _i2++) { for (var j = 0; j < N; j++) { Mat[_i2][j] = 0; - for (var k = 0; k < N; k++) { for (var l = 0; l < N; l++) { Mat[_i2][j] = Mat[_i2][j] + U[k][_i2] * H[k][l] * U[l][j]; @@ -2523,50 +2573,39 @@ } } } - return Mat; } - function AxB(A, B) { var N = A.length; var Mat = Array(N); - for (var i = 0; i < N; i++) { Mat[i] = Array(N); } - for (var _i3 = 0; _i3 < N; _i3++) { for (var j = 0; j < N; j++) { Mat[_i3][j] = 0; - for (var k = 0; k < N; k++) { Mat[_i3][j] = Mat[_i3][j] + A[_i3][k] * B[k][j]; } } } - return Mat; } - function eigens(Hij) { var convergence = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1E-7; var N = Hij.length; var Ei = Array(N); var e0 = Math.abs(convergence / N); var Sij = Array(N); - for (var i = 0; i < N; i++) { Sij[i] = Array(N); } - for (var _i4 = 0; _i4 < N; _i4++) { for (var j = 0; j < N; j++) { Sij[_i4][j] = (_i4 === j) * 1.0; } } - var Vab = getAij(Hij); - while (Math.abs(Vab[1]) >= Math.abs(e0)) { var _i5 = Vab[0][0]; var _j = Vab[0][1]; @@ -2576,18 +2615,14 @@ Sij = AxB(Sij, Gij); Vab = getAij(Hij); } - for (var _i6 = 0; _i6 < N; _i6++) { Ei[_i6] = Hij[_i6][_i6]; } - return sorting(Ei, Sij); } - function sorting(values, vectors) { var eigsCount = values.length; vectors.length; - var pairs = __arrayMaker({ length: eigsCount }, function (_, i) { @@ -2599,7 +2634,6 @@ vec: vector }; }); - pairs.sort(function (a, b) { return b.value - a.value; }); @@ -2613,12 +2647,10 @@ }); return [sortedValues, sortedVectors]; } - function dominentPrincipalVector(matrix) { var _eigens = eigens(matrix), - _eigens$ = _eigens[1], - dominentVector = _eigens$[0]; - + _eigens$ = _eigens[1], + dominentVector = _eigens$[0]; return dominentVector; } @@ -2627,13 +2659,10 @@ var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x; var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; - _classCallCheck(this, Vec3); - this._values = [x, y, z]; } - - _createClass(Vec3, [{ + return _createClass(Vec3, [{ key: "x", get: function get() { return this._values[0]; @@ -2680,7 +2709,6 @@ var result = parseInt(value * 255 + 0.5); return Math.max(Math.min(result, 255), 0); }; - return this._values.map(floatToInt); } }, { @@ -2742,7 +2770,6 @@ var clamper = function clamper(v) { return min > v ? min : max < v ? max : v; }; - this._values[0] = clamper(this._values[0]); this._values[1] = clamper(this._values[1]); this._values[2] = clamper(this._values[2]); @@ -2754,11 +2781,9 @@ var clamper = function clamper(v) { return 0 > v ? 0 : 1 < v ? 1 : v; }; - var gridClamper = function gridClamper(value, grid) { return __trunc(clamper(value) * grid + 0.5) / grid; }; - this._values[0] = gridClamper(this._values[0], 31); this._values[1] = gridClamper(this._values[1], 63); this._values[2] = gridClamper(this._values[2], 31); @@ -2810,23 +2835,17 @@ return Vec3.add(a_, b_); } }]); - - return Vec3; }(); - var Vec4 = function () { function Vec4() { var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x; var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; var w = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : x; - _classCallCheck(this, Vec4); - this._values = [x, y, z, w]; } - - _createClass(Vec4, [{ + return _createClass(Vec4, [{ key: "x", get: function get() { return this._values[0]; @@ -2981,7 +3000,6 @@ var clamper = function clamper(v) { return min > v ? min : max < v ? max : v; }; - this._values[0] = clamper(this._values[0]); this._values[1] = clamper(this._values[1]); this._values[2] = clamper(this._values[2]); @@ -2994,11 +3012,9 @@ var clamper = function clamper(v) { return 0 > v ? 0 : 1 < v ? 1 : v; }; - var gridClamper = function gridClamper(value, grid) { return __trunc(clamper(value) * grid + 0.5) / grid; }; - this._values[0] = gridClamper(this._values[0], 31); this._values[1] = gridClamper(this._values[1], 63); this._values[2] = gridClamper(this._values[2], 31); @@ -3076,10 +3092,7 @@ return left.x < right.x || left.y < right.y || left.z < right.z || left.w < right.w; } }]); - - return Vec4; }(); - function computeWeightedCovariance(values, weights) { var total = 0; var mean = values.reduce(function (sum, value, i) { @@ -3104,7 +3117,6 @@ covariance[2][1] = covariance[1][2]; return covariance; } - function computePCA(values, weights) { var covariance = computeWeightedCovariance(values, weights); return _construct(Vec3, dominentPrincipalVector(covariance)); @@ -3121,30 +3133,25 @@ if (integer > limit) return integer; return integer; } - function floatTo565(color) { var r = floatToInt(31.0 * color.x, 31); var g = floatToInt(63.0 * color.y, 63); var b = floatToInt(31.0 * color.z, 31); return r << 11 | g << 5 | b; } - function writeColourBlock(firstColor, secondColor, indices, result, blockOffset) { result[blockOffset + 0] = firstColor & 0xff; result[blockOffset + 1] = firstColor >> 8; result[blockOffset + 2] = secondColor & 0xff; result[blockOffset + 3] = secondColor >> 8; - for (var y = 0; y < 4; y++) { result[blockOffset + 4 + y] = indices[4 * y + 0] | indices[4 * y + 1] << 2 | indices[4 * y + 2] << 4 | indices[4 * y + 3] << 6; } } - function writeColourBlock3(start, end, indices, result, blockOffset) { var firstColor = floatTo565(start); var secondColor = floatTo565(end); var remapped; - if (firstColor <= secondColor) { remapped = indices.slice(); } else { @@ -3155,15 +3162,12 @@ return index === 0 ? 1 : index === 1 ? 0 : index; }); } - writeColourBlock(firstColor, secondColor, remapped, result, blockOffset); } - function writeColourBlock4(start, end, indices, result, blockOffset) { var firstColor = floatTo565(start); var secondColor = floatTo565(end); var remapped; - if (firstColor < secondColor) { var _ref2 = [secondColor, firstColor]; firstColor = _ref2[0]; @@ -3176,14 +3180,26 @@ } else { remapped = indices.slice(); } - writeColourBlock(firstColor, secondColor, remapped, result, blockOffset); } + function _callSuper$7(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var ColorSet = function () { function ColorSet(rgba, mask, flags) { _classCallCheck(this, ColorSet); - this.flags = flags; this._count = 0; this._transparent = false; @@ -3192,21 +3208,17 @@ this._points = []; var isDxt1 = (this.flags & kDxt1) != 0; var weightByAlpha = (this.flags & kWeightColourByAlpha) != 0; - for (var i = 0; i < 16; i++) { var bit = 1 << i; - if ((mask & bit) == 0) { this._remap[i] = -1; continue; } - if (isDxt1 && rgba[4 * i + 3] < 128) { this._remap[i] = -1; this._transparent = true; continue; } - for (var j = 0;; j++) { if (j == i) { var r = rgba[4 * i] / 255.0; @@ -3219,10 +3231,8 @@ this._count++; break; } - var oldbit = 1 << j; var match = (mask & oldbit) != 0 && rgba[4 * i] == rgba[4 * j] && rgba[4 * i + 1] == rgba[4 * j + 1] && rgba[4 * i + 2] == rgba[4 * j + 2] && (rgba[4 * j + 3] >= 128 || !isDxt1); - if (match) { var index = this._remap[j]; var w = (rgba[4 * i + 3] + 1) / 256.0; @@ -3232,13 +3242,9 @@ } } } - - for (var _i = 0; _i < this._count; ++_i) { - this._weights[_i] = Math.sqrt(this._weights[_i]); - } + for (var _i = 0; _i < this._count; ++_i) this._weights[_i] = Math.sqrt(this._weights[_i]); } - - _createClass(ColorSet, [{ + return _createClass(ColorSet, [{ key: "transparent", get: function get() { return this._transparent; @@ -3264,7 +3270,6 @@ var result = this._remap.map(function (index) { return index === -1 ? 3 : singleIndex; }); - target.forEach(function (_, i) { return target[i] = result[i]; }); @@ -3275,29 +3280,22 @@ var result = this._remap.map(function (index) { return index === -1 ? 3 : indexMap[index]; }); - target.forEach(function (_, i) { return target[i] = result[i]; }); } }]); - - return ColorSet; }(); - var ColorFit = function () { function ColorFit(colorSet) { _classCallCheck(this, ColorFit); - this.colors = colorSet; this.flags = colorSet.flags; } - - _createClass(ColorFit, [{ + return _createClass(ColorFit, [{ key: "compress", value: function compress(result, offset) { var isDxt1 = (this.flags & kDxt1) != 0; - if (isDxt1) { this.compress3(result, offset); if (!this.colors.transparent) this.compress4(result, offset); @@ -3310,36 +3308,26 @@ key: "compress4", value: function compress4(result, offset) {} }]); - - return ColorFit; }(); - var SingleColourFit = function (_ColorFit) { - _inherits(SingleColourFit, _ColorFit); - - var _super = _createSuper(SingleColourFit); - function SingleColourFit(colorSet) { - var _this; - + var _this2; _classCallCheck(this, SingleColourFit); - - _this = _super.call(this, colorSet); + _this2 = _callSuper$7(this, SingleColourFit, [colorSet]); var singleColor = colorSet.points[0]; - _this.color = singleColor.colorInt; - _this.start = new Vec3(0); - _this.end = new Vec3(0); - _this.index = 0; - _this.error = Infinity; - _this.bestError = Infinity; - return _this; + _this2.color = singleColor.colorInt; + _this2.start = new Vec3(0); + _this2.end = new Vec3(0); + _this2.index = 0; + _this2.error = Infinity; + _this2.bestError = Infinity; + return _this2; } - - _createClass(SingleColourFit, [{ + _inherits(SingleColourFit, _ColorFit); + return _createClass(SingleColourFit, [{ key: "compressBase", value: function compressBase(lookups, saveFunc) { this.computeEndPoints(lookups); - if (this.error < this.bestError) { var indices = new Uint8Array(16); this.colors.remapIndicesSingle(this.index, indices); @@ -3351,33 +3339,27 @@ key: "compress3", value: function compress3(result, offset) { var lookups = [lookup_5_3, lookup_6_3, lookup_5_3]; - var saveFunc = function saveFunc(start, end, indices) { return writeColourBlock3(start, end, indices, result, offset); }; - this.compressBase(lookups, saveFunc); } }, { key: "compress4", value: function compress4(result, offset) { var lookups = [lookup_5_4, lookup_6_4, lookup_5_4]; - var saveFunc = function saveFunc(start, end, indices) { return writeColourBlock4(start, end, indices, result, offset); }; - this.compressBase(lookups, saveFunc); } }, { key: "computeEndPoints", value: function computeEndPoints(lookups) { this.error = Infinity; - for (var index = 0; index < 2; index++) { var sources = []; var error = 0; - for (var channel = 0; channel < 3; channel++) { var lookup = lookups[channel]; var target = this.color[channel]; @@ -3385,7 +3367,6 @@ var diff = sources[channel][2]; error += diff * diff; } - if (error < this.error) { this.start = new Vec3(sources[0][0] / 31.0, sources[1][0] / 63.0, sources[2][0] / 31.0); this.end = new Vec3(sources[0][1] / 31.0, sources[1][1] / 63.0, sources[2][1] / 31.0); @@ -3395,47 +3376,33 @@ } } }]); - - return SingleColourFit; }(ColorFit); - var RangeFit = function (_ColorFit2) { - _inherits(RangeFit, _ColorFit2); - - var _super2 = _createSuper(RangeFit); - - function RangeFit(colorSet) { - var _this2; - + function RangeFit(colorSet) { + var _this3; _classCallCheck(this, RangeFit); - - _this2 = _super2.call(this, colorSet); - _this2.metric = new Vec3(1); - - if ((_this2.flags & kColourMetricPerceptual) !== 0) { - _this2.metric.set(0.2126, 0.7152, 0.0722); - } - - _this2.start = new Vec3(0); - _this2.end = new Vec3(0); - _this2.bestError = Infinity; - - _this2.computePoints(); - - return _this2; + _this3 = _callSuper$7(this, RangeFit, [colorSet]); + _this3.metric = new Vec3(1); + if ((_this3.flags & kColourMetricPerceptual) !== 0) { + _this3.metric.set(0.2126, 0.7152, 0.0722); + } + _this3.start = new Vec3(0); + _this3.end = new Vec3(0); + _this3.bestError = Infinity; + _this3.computePoints(); + return _this3; } - - _createClass(RangeFit, [{ + _inherits(RangeFit, _ColorFit2); + return _createClass(RangeFit, [{ key: "compressBase", value: function compressBase(codes, saveFunc) { - var _this3 = this; - + var _this4 = this; var values = this.colors.points; var error = 0; var closest = values.map(function (color) { var minDist = Infinity; var packedIndex = codes.reduce(function (idx, code, j) { - var dist = Vec3.sub(color, code).multVector(_this3.metric).lengthSq; + var dist = Vec3.sub(color, code).multVector(_this4.metric).lengthSq; if (dist >= minDist) return idx; minDist = dist; return j; @@ -3443,7 +3410,6 @@ error += minDist; return packedIndex; }); - if (error < this.bestError) { var indices = new Uint8Array(16); this.colors.remapIndices(closest, indices); @@ -3455,40 +3421,34 @@ key: "compress3", value: function compress3(result, offset) { var codes = [this.start.clone(), this.end.clone(), Vec3.interpolate(this.start, this.end, 0.5)]; - var saveFunc = function saveFunc(start, end, indices) { return writeColourBlock3(start, end, indices, result, offset); }; - this.compressBase(codes, saveFunc); } }, { key: "compress4", value: function compress4(result, offset) { var codes = [this.start.clone(), this.end.clone(), Vec3.interpolate(this.start, this.end, 1 / 3), Vec3.interpolate(this.start, this.end, 2 / 3)]; - var saveFunc = function saveFunc(start, end, indices) { return writeColourBlock4(start, end, indices, result, offset); }; - this.compressBase(codes, saveFunc); } }, { key: "computePoints", value: function computePoints() { var _this$colors = this.colors, - count = _this$colors.count, - values = _this$colors.points, - weights = _this$colors.weights; + count = _this$colors.count, + values = _this$colors.points, + weights = _this$colors.weights; if (count <= 0) return; var principle = computePCA(values, weights); var start, end, min, max; start = end = values[0]; min = max = Vec3.dot(start, principle); - for (var i = 1; i < count; i++) { var value = Vec3.dot(values[i], principle); - if (value < min) { start = values[i]; min = value; @@ -3497,46 +3457,34 @@ max = value; } } - this.start = start.clampGrid().clone(); this.end = end.clampGrid().clone(); } }]); - - return RangeFit; }(ColorFit); - var ClusterFit = function (_ColorFit3) { - _inherits(ClusterFit, _ColorFit3); - - var _super3 = _createSuper(ClusterFit); - function ClusterFit(colorSet) { - var _this4; - + var _this5; _classCallCheck(this, ClusterFit); - - _this4 = _super3.call(this, colorSet); + _this5 = _callSuper$7(this, ClusterFit, [colorSet]); var kMaxIterations = 8; - _this4.iterationCount = colorSet.flags & kColourIterativeClusterFit ? kMaxIterations : 1; - _this4.bestError = Infinity; - _this4.metric = new Vec4(1); - - if ((_this4.flags & kColourMetricPerceptual) !== 0) { - _this4.metric.set(0.2126, 0.7152, 0.0722, 0); - } - - var _this4$colors = _this4.colors, - values = _this4$colors.points, - weights = _this4$colors.weights; - _this4.principle = computePCA(values, weights); - _this4.order = new Uint8Array(16 * kMaxIterations); - _this4.pointsWeights = []; - _this4.xSum_wSum = new Vec4(0); - return _this4; + _this5.iterationCount = colorSet.flags & kColourIterativeClusterFit ? kMaxIterations : 1; + _this5.bestError = Infinity; + _this5.metric = new Vec4(1); + if ((_this5.flags & kColourMetricPerceptual) !== 0) { + _this5.metric.set(0.2126, 0.7152, 0.0722, 0); + } + var _this5$colors = _this5.colors, + values = _this5$colors.points, + weights = _this5$colors.weights; + _this5.principle = computePCA(values, weights); + _this5.order = new Uint8Array(16 * kMaxIterations); + _this5.pointsWeights = []; + _this5.xSum_wSum = new Vec4(0); + return _this5; } - - _createClass(ClusterFit, [{ + _inherits(ClusterFit, _ColorFit3); + return _createClass(ClusterFit, [{ key: "constructOrdering", value: function constructOrdering(axis, iteration) { var currentOrder = this.makeOrder(axis); @@ -3551,8 +3499,8 @@ value: function compress3(result, offset) { var aabbx = function aabbx(_ref) { var part0 = _ref[0], - part1 = _ref[2], - part2 = _ref[3]; + part1 = _ref[2], + part2 = _ref[3]; var const1_2 = new Vec4(1 / 2, 1 / 2, 1 / 2, 1 / 4); var alphax_sum = Vec4.multiplyAdd(part1, const1_2, part0); var alpha2_sum = alphax_sum.splatW; @@ -3567,11 +3515,9 @@ ab: alphabeta_sum }; }; - var saveFunc = function saveFunc(start, end, indices) { return writeColourBlock3(start, end, indices, result, offset); }; - this.compressBase(aabbx, saveFunc, 2); } }, { @@ -3579,9 +3525,9 @@ value: function compress4(result, offset) { var aabbx = function aabbx(_ref2) { var part0 = _ref2[0], - part1 = _ref2[1], - part2 = _ref2[2], - part3 = _ref2[3]; + part1 = _ref2[1], + part2 = _ref2[2], + part3 = _ref2[3]; var const1_3 = new Vec4(1 / 3, 1 / 3, 1 / 3, 1 / 9); var const2_3 = new Vec4(2 / 3, 2 / 3, 2 / 3, 4 / 9); var const2_9 = new Vec4(2 / 9); @@ -3598,18 +3544,15 @@ ab: alphabeta_sum }; }; - var saveFunc = function saveFunc(start, end, indices) { return writeColourBlock4(start, end, indices, result, offset); }; - this.compressBase(aabbx, saveFunc, 3); } }, { key: "compressBase", value: function compressBase(aabbFunc, saveFunc) { - var _this5 = this; - + var _this6 = this; var repeater = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; this.constructOrdering(this.principle, 0); var best = { @@ -3621,20 +3564,15 @@ bestJ: 0 }; if (repeater === 3) best.bestK = 0; - var leastSquares = function leastSquares(parts, internalIndices) { var aabbx = aabbFunc(parts); - - var internalBest = _this5.computeOptimalPoints(aabbx); - + var internalBest = _this6.computeOptimalPoints(aabbx); if (internalBest.error < best.error) { best = _objectSpread2(_objectSpread2({}, internalBest), internalIndices); return true; } - return false; }; - for (var iterationIndex = 0;;) { this.clusterIterate(iterationIndex, leastSquares, repeater); if (best.iteration != iterationIndex) break; @@ -3643,15 +3581,14 @@ var newAxis = Vec4.sub(best.end, best.start).xyz; if (!this.constructOrdering(newAxis, iterationIndex)) break; } - if (best.error < this.bestError) this.saveBlock(best, saveFunc); } }, { key: "makeOrder", value: function makeOrder(axis) { var _this$colors2 = this.colors, - count = _this$colors2.count, - values = _this$colors2.points; + count = _this$colors2.count, + values = _this$colors2.points; var dotProducts = values.map(function (color, i) { return Vec3.dot(color, axis); }); @@ -3667,43 +3604,37 @@ }, { key: "copyOrderToThisOrder", value: function copyOrderToThisOrder(order, iteration) { - var _this6 = this; - + var _this7 = this; var orderOffset = iteration * 16; order.forEach(function (ord, i) { - _this6.order[orderOffset + i] = ord; + _this7.order[orderOffset + i] = ord; }); } }, { key: "checkOrderUnique", value: function checkOrderUnique(order, iteration) { var count = this.colors.count; - for (var it = 0; it < iteration; it++) { var prevOffset = it * 16; var same = true; - for (var i = 0; i < count; i++) { if (order[i] !== this.order[prevOffset + i]) { same = false; break; } } - if (same) return false; } - return true; } }, { key: "copyOrderWeight", value: function copyOrderWeight(order) { var _this$colors3 = this.colors, - count = _this$colors3.count, - unweighted = _this$colors3.points, - weights = _this$colors3.weights; + count = _this$colors3.count, + unweighted = _this$colors3.points, + weights = _this$colors3.weights; this.xSum_wSum.set(0); - for (var i = 0; i < count; i++) { var j = order[i]; var p = unweighted[j].toVec4(1); @@ -3717,10 +3648,10 @@ key: "computeOptimalPoints", value: function computeOptimalPoints(vectorPoint) { var ax = vectorPoint.ax, - bx = vectorPoint.bx, - aa = vectorPoint.aa, - bb = vectorPoint.bb, - ab = vectorPoint.ab; + bx = vectorPoint.bx, + aa = vectorPoint.aa, + bb = vectorPoint.bb, + ab = vectorPoint.ab; var factor = Vec4.negativeMultiplySubtract(ab, ab, Vec4.multVector(aa, bb)).reciprocal(); var a = Vec4.negativeMultiplySubtract(bx, ab, Vec4.multVector(ax, bb)).multVector(factor); var b = Vec4.negativeMultiplySubtract(ax, ab, Vec4.multVector(bx, aa)).multVector(factor); @@ -3740,12 +3671,12 @@ key: "computeError", value: function computeError(_ref3) { var a = _ref3.a, - b = _ref3.b, - ax = _ref3.ax, - bx = _ref3.bx, - aa = _ref3.aa, - bb = _ref3.bb, - ab = _ref3.ab; + b = _ref3.b, + ax = _ref3.ax, + bx = _ref3.bx, + aa = _ref3.aa, + bb = _ref3.bb, + ab = _ref3.ab; var two = new Vec4(2); var e1 = Vec4.multiplyAdd(Vec4.multVector(a, a), aa, Vec4.multVector(b, b).multVector(bb)); var e2 = Vec4.negativeMultiplySubtract(a, ax, Vec4.multVector(a, b).multVector(ab)); @@ -3759,27 +3690,24 @@ value: function saveBlock(best, writeFunc) { var count = this.colors.count; var start = best.start, - end = best.end, - iteration = best.iteration, - error = best.error, - bestI = best.bestI, - bestJ = best.bestJ, - _best$bestK = best.bestK, - bestK = _best$bestK === void 0 ? -1 : _best$bestK; + end = best.end, + iteration = best.iteration, + error = best.error, + bestI = best.bestI, + bestJ = best.bestJ, + _best$bestK = best.bestK, + bestK = _best$bestK === void 0 ? -1 : _best$bestK; var orderOffset = iteration * 16; var unordered = new Uint8Array(16); - var mapper = function mapper(m) { if (m < bestI) return 0; if (m < bestJ) return 2; if (m < bestK) return 3; return 1; }; - for (var i = 0; i < count; i++) { unordered[this.order[orderOffset + i]] = mapper(i); } - var bestIndices = new Uint8Array(16); this.colors.remapIndices(unordered, bestIndices); writeFunc(start.xyz, end.xyz, bestIndices); @@ -3790,7 +3718,6 @@ value: function clusterIterate(index, func) { var iterCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; var count = this.colors.count; - var indexMapper = function indexMapper(i, j, k) { var mapper = { bestI: i, @@ -3800,16 +3727,12 @@ if (iterCount === 3) mapper.bestK = k; return mapper; }; - var part0 = new Vec4(0.0); - for (var i = 0; i < count; i++) { var part1 = new Vec4(0.0); - for (var j = i;;) { var preLastPart = j == 0 ? this.pointsWeights[0].clone() : new Vec4(0.0); var kmin = j == 0 ? 1 : j; - for (var k = kmin;;) { var restPart = Vec4.sub(this.xSum_wSum, preLastPart).subVector(part1).subVector(part0); func([part0, part1, preLastPart, restPart], indexMapper(i, j, k)); @@ -3817,19 +3740,15 @@ preLastPart.addVector(this.pointsWeights[k]); k++; } - if (iterCount === 2) break; if (j === count) break; part1.addVector(this.pointsWeights[j]); j++; } - part0.addVector(this.pointsWeights[i]); } } }]); - - return ClusterFit; }(ColorFit); function quantise(alpha) { @@ -3839,7 +3758,6 @@ if (result > GRID) return GRID; return result; } - function compressAlphaDxt3(rgba, mask, result, offset) { for (var i = 0; i < 8; i++) { var quant1 = quantise(rgba[8 * i + 3]); @@ -3851,18 +3769,15 @@ result[offset + i] = quant1 | quant2 << 4; } } - function compressAlphaDxt5(rgba, mask, result, offset) { var step5 = interpolateAlpha(rgba, mask, 5); var step7 = interpolateAlpha(rgba, mask, 7); if (step5.error <= step7.error) writeAlphaBlock5(step5, result, offset);else writeAlphaBlock7(step7, result, offset); } - function interpolateAlpha(rgba, mask, steps) { var _setAlphaRange = setAlphaRange(rgba, mask, steps), - min = _setAlphaRange.min, - max = _setAlphaRange.max; - + min = _setAlphaRange.min, + max = _setAlphaRange.max; var code = setAlphaCodeBook(min, max, steps); var indices = new Uint8Array(16); var error = fitCodes(rgba, mask, code, indices); @@ -3873,16 +3788,13 @@ error: error }; } - function setAlphaRange(rgba, mask, steps) { var min = 255; var max = 0; - for (var i = 0; i < 16; i++) { var bit = 1 << i; if ((mask & bit) == 0) continue; var value = rgba[4 * i + 3]; - if (steps === 5) { if (value !== 0 && value < min) min = value; if (value !== 255 && value > max) max = value; @@ -3891,7 +3803,6 @@ if (value > max) max = value; } } - if (min > max) min = max; if (max - min < steps) max = Math.min(min + steps, 255); if (max - min < steps) min = Math.max(max - steps, 0); @@ -3900,59 +3811,46 @@ max: max }; } - function setAlphaCodeBook(min, max, steps) { var codes = [min, max].concat(__arrayMaker({ length: steps - 1 }, function (_, i) { return Math.floor(((steps - (i + 1)) * min + (i + 1) * max) / steps); })); - if (steps === 5) { codes[6] = 0; codes[7] = 255; } - return codes; } - function fitCodes(rgba, mask, codes, indices) { var err = 0; - for (var i = 0; i < 16; ++i) { var bit = 1 << i; - if ((mask & bit) == 0) { indices[i] = 0; continue; } - var value = rgba[4 * i + 3]; var least = Infinity; var index = 0; - for (var j = 0; j < 8; ++j) { var dist = value - codes[j]; dist *= dist; - if (dist < least) { least = dist; index = j; } } - indices[i] = index; err += least; } - return err; } - function writeAlphaBlock5(_ref, result, offset) { var alpha0 = _ref.min, - alpha1 = _ref.max, - indices = _ref.indices; - + alpha1 = _ref.max, + indices = _ref.indices; if (alpha0 > alpha1) { var swapped = indices.map(function (index) { if (index === 0) return 1; @@ -3963,12 +3861,10 @@ writeAlphaBlock(alpha1, alpha0, swapped, result, offset); } else writeAlphaBlock(alpha0, alpha1, indices, result, offset); } - function writeAlphaBlock7(_ref2, result, offset) { var alpha0 = _ref2.min, - alpha1 = _ref2.max, - indices = _ref2.indices; - + alpha1 = _ref2.max, + indices = _ref2.indices; if (alpha0 > alpha1) { var swapped = indices.map(function (index) { if (index === 0) return 1; @@ -3978,22 +3874,18 @@ writeAlphaBlock(alpha1, alpha0, swapped, result, offset); } else writeAlphaBlock(alpha0, alpha1, indices, result, offset); } - function writeAlphaBlock(alpha0, alpha1, indices, result, offset) { result[offset] = alpha0; result[offset + 1] = alpha1; var indicesPointer = 0; var resultPointer = offset + 2; - for (var i = 0; i < 2; i++) { var value = 0; - for (var j = 0; j < 8; ++j) { var index = indices[indicesPointer]; value |= index << 3 * j; indicesPointer++; } - for (var _j = 0; _j < 3; ++_j) { var byte = value >> 8 * _j & 0xff; result[resultPointer] = byte; @@ -4008,7 +3900,6 @@ var blue = color16bit & 0x1f; return [red << 3 | red >> 2, green << 2 | green >> 4, blue << 3 | blue >> 2, 255]; } - function interpolateColorArray(a, b, amount) { var result = a.map(function (aColor, i) { return Math.floor(aColor * (1 - amount) + b[i] * amount); @@ -4016,7 +3907,6 @@ result[3] = 255; return result; } - function unpackColorCodes(block, offset, isDxt1) { var color1 = block[offset] | block[offset + 1] << 8; var color2 = block[offset + 2] | block[offset + 3] << 8; @@ -4024,11 +3914,9 @@ var unpackedColor2 = unpack565(color2); return [unpackedColor1, unpackedColor2, isDxt1 && color1 <= color2 ? interpolateColorArray(unpackedColor1, unpackedColor2, 1 / 2) : interpolateColorArray(unpackedColor1, unpackedColor2, 1 / 3), isDxt1 && color1 <= color2 ? [0, 0, 0, 0] : interpolateColorArray(unpackedColor1, unpackedColor2, 2 / 3)]; } - function unpackIndices(block, blockOffset) { var offset = blockOffset + 4; var result = new Uint8Array(16); - for (var i = 0; i < 4; i++) { var packedIndices = block[offset + i]; result[i * 4 + 0] = packedIndices & 0x3; @@ -4036,21 +3924,17 @@ result[i * 4 + 2] = packedIndices >> 4 & 0x3; result[i * 4 + 3] = packedIndices >> 6 & 0x3; } - return result; } - function decompressColor(rgba, block, offset, isDxt1) { var colorCode = unpackColorCodes(block, offset, isDxt1); var indices = unpackIndices(block, offset); - for (var i = 0; i < 16; i++) { for (var j = 0; j < 4; j++) { rgba[4 * i + j] = colorCode[indices[i]][j]; } } } - function decompressAlphaDxt3(rgba, block, offset) { for (var i = 0; i < 8; ++i) { var quant = block[offset + i]; @@ -4060,7 +3944,6 @@ rgba[8 * i + 7] = hi | hi >> 4; } } - function decompressAlphaDxt5(rgba, block, offset) { var alpha0 = block[offset + 0]; var alpha1 = block[offset + 1]; @@ -4068,23 +3951,19 @@ var indices = new Uint8Array(16); var indicePointer = 0; var bytePointer = 2; - for (var i = 0; i < 2; i++) { var value = 0; - for (var j = 0; j < 3; j++) { var byte = block[offset + bytePointer]; value |= byte << 8 * j; bytePointer++; } - for (var _j = 0; _j < 8; _j++) { var index = value >> 3 * _j & 0x7; indices[indicePointer] = index; indicePointer++; } } - for (var _i = 0; _i < 16; ++_i) { rgba[4 * _i + 3] = codes[indices[_i]]; } @@ -4115,7 +3994,6 @@ var DXT5_COMPRESSED_BYTES = 16; var COLORS = 4; var DECOMPRESSED_BLOCK_SIZE = 16; - function blockRepeat(width, height, func) { for (var y = 0; y < height; y += 4) { for (var x = 0; x < width; x += 4) { @@ -4123,7 +4001,6 @@ } } } - function rectRepeat(func) { for (var y = 0; y < 4; y++) { for (var x = 0; x < 4; x++) { @@ -4131,7 +4008,6 @@ } } } - function FixFlags(flags) { var method = flags & (kDxt1 | kDxt3 | kDxt5); var fit = flags & (kColourIterativeClusterFit | kColourClusterFit | kColourRangeFit); @@ -4142,39 +4018,33 @@ if (metric != kColourMetricUniform) metric = kColourMetricPerceptual; return method | fit | metric | extra; } - function GetStorageRequirements(width, height, flags) { flags = FixFlags(flags); var blockcount = Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4); var blocksize = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; return blockcount * blocksize; } - function extractColorBlock(img) { var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref$x = _ref.x, - x = _ref$x === void 0 ? 0 : _ref$x, - _ref$y = _ref.y, - y = _ref$y === void 0 ? 0 : _ref$y, - _ref$width = _ref.width, - width = _ref$width === void 0 ? 0 : _ref$width, - _ref$height = _ref.height, - height = _ref$height === void 0 ? 0 : _ref$height; - + _ref$x = _ref.x, + x = _ref$x === void 0 ? 0 : _ref$x, + _ref$y = _ref.y, + y = _ref$y === void 0 ? 0 : _ref$y, + _ref$width = _ref.width, + width = _ref$width === void 0 ? 0 : _ref$width, + _ref$height = _ref.height, + height = _ref$height === void 0 ? 0 : _ref$height; var block = new Uint8Array(DECOMPRESSED_BLOCK_SIZE * COLORS); var mask = 0; var blockColorOffset = 0; rectRepeat(function (px, py) { var sx = x + px; var sy = y + py; - if (sx < width && sy < height) { var sourceColorOffset = COLORS * (width * sy + sx); - for (var i = 0; i < COLORS; i++) { block[blockColorOffset++] = img[sourceColorOffset++]; } - mask |= 1 << 4 * py + px; } else blockColorOffset += COLORS; }); @@ -4183,39 +4053,33 @@ mask: mask }; } - function copyBuffer(result, block) { var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, - _ref2$x = _ref2.x, - x = _ref2$x === void 0 ? 0 : _ref2$x, - _ref2$y = _ref2.y, - y = _ref2$y === void 0 ? 0 : _ref2$y, - _ref2$width = _ref2.width, - width = _ref2$width === void 0 ? 0 : _ref2$width, - _ref2$height = _ref2.height, - height = _ref2$height === void 0 ? 0 : _ref2$height; - + _ref2$x = _ref2.x, + x = _ref2$x === void 0 ? 0 : _ref2$x, + _ref2$y = _ref2.y, + y = _ref2$y === void 0 ? 0 : _ref2$y, + _ref2$width = _ref2.width, + width = _ref2$width === void 0 ? 0 : _ref2$width, + _ref2$height = _ref2.height, + height = _ref2$height === void 0 ? 0 : _ref2$height; var blockColorOffset = 0; rectRepeat(function (px, py) { var sx = x + px; var sy = y + py; - if (sx < width && sy < height) { var resultColorOffset = COLORS * (width * sy + sx); - for (var i = 0; i < COLORS; i++) { result[resultColorOffset + i] = block[blockColorOffset++]; } } else blockColorOffset += COLORS; }); } - function getCompressor(colorSet) { if (colorSet.count === 1) return new SingleColourFit(colorSet); if ((colorSet.flags & kColourRangeFit) != 0 || colorSet.count == 0) return new RangeFit(colorSet); return new ClusterFit(colorSet); } - function CompressMasked(rgba, mask, result, offset, flags) { flags = FixFlags(flags); var colorOffset = (flags & (kDxt3 | kDxt5)) !== 0 ? 8 : 0; @@ -4224,38 +4088,33 @@ compressor.compress(result, offset + colorOffset); if ((flags & kDxt3) !== 0) compressAlphaDxt3(rgba, mask, result, offset);else if ((flags & kDxt5) !== 0) compressAlphaDxt5(rgba, mask, result, offset); } - function decompressBlock(result, block, offset, flags) { flags = FixFlags(flags); var colorOffset = (flags & (kDxt3 | kDxt5)) !== 0 ? 8 : 0; decompressColor(result, block, offset + colorOffset, (flags & kDxt1) !== 0); if ((flags & kDxt3) !== 0) decompressAlphaDxt3(result, block, offset);else if ((flags & kDxt5) !== 0) decompressAlphaDxt5(result, block, offset); } - function compressImage(source, width, height, result, flags) { flags = FixFlags(flags); var bytesPerBlock = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; var targetBlockPointer = 0; blockRepeat(width, height, function (x, y) { var _extractColorBlock = extractColorBlock(source, { - x: x, - y: y, - width: width, - height: height - }), - sourceRGBA = _extractColorBlock.block, - mask = _extractColorBlock.mask; - + x: x, + y: y, + width: width, + height: height + }), + sourceRGBA = _extractColorBlock.block, + mask = _extractColorBlock.mask; CompressMasked(sourceRGBA, mask, result, targetBlockPointer, flags); targetBlockPointer += bytesPerBlock; }); } - function decompressImage(result, width, height, source, flags) { flags = FixFlags(flags); var bytesPerBlock = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; var sourceBlockPointer = 0; - for (var y = 0; y < height; y += 4) { for (var x = 0; x < width; x += 4) { var targetRGBA = new Uint8Array(DECOMPRESSED_BLOCK_SIZE * COLORS); @@ -4270,7 +4129,6 @@ } } } - var flags = { DXT1: kDxt1, DXT3: kDxt3, @@ -4282,7 +4140,6 @@ ColourMetricUniform: kColourMetricUniform, WeightColourByAlpha: kWeightColourByAlpha }; - function compress(inputData, width, height, flags) { var source = inputData instanceof ArrayBuffer ? new Uint8Array(inputData) : inputData; var targetSize = GetStorageRequirements(width, height, flags); @@ -4290,7 +4147,6 @@ compressImage(source, width, height, result, flags); return result; } - function decompress(inputData, width, height, flags) { var source = inputData instanceof ArrayBuffer ? new Uint8Array(inputData) : inputData; var targetSize = width * height * 4; @@ -4302,7 +4158,6 @@ function extractBits(bitData, amount, offset) { return bitData >> offset & Math.pow(2, amount) - 1; } - function colorToBgra5551(red, green, blue, alpha) { var r = Math.round(red / 255 * 31); var g = Math.round(green / 255 * 31); @@ -4310,30 +4165,24 @@ var a = Math.round(alpha / 255); return a << 15 | r << 10 | g << 5 | b; } - function bgra5551ToColor(bgra5551) { var r = extractBits(bgra5551, 5, 10); var g = extractBits(bgra5551, 5, 5); var b = extractBits(bgra5551, 5, 0); var a = bgra5551 >> 15 & 1; - var scaleUp = function scaleUp(value) { return value << 3 | value >> 2; }; - var _map = [r, g, b].map(scaleUp), - red = _map[0], - green = _map[1], - blue = _map[2]; - + red = _map[0], + green = _map[1], + blue = _map[2]; return [red, green, blue, a * 255]; } - function convertTo5551(colorBuffer) { var colorArray = new Uint8Array(colorBuffer); var length = colorArray.length / 4; var convertedArray = new Uint8Array(length * 2); - for (var i = 0; i < length; i++) { var red = colorArray[i * 4]; var green = colorArray[i * 4 + 1]; @@ -4343,15 +4192,12 @@ convertedArray[i * 2] = bgra5551 & 0xff; convertedArray[i * 2 + 1] = bgra5551 >> 8; } - return convertedArray; } - function convertFrom5551(colorBuffer) { var colorArray = new Uint8Array(colorBuffer); var length = colorArray.length / 2; var convertedArray = new Uint8Array(length * 4); - for (var i = 0; i < length; i++) { var colors = bgra5551ToColor(colorArray[i * 2] | colorArray[i * 2 + 1] << 8); convertedArray[i * 4] = colors[0]; @@ -4359,22 +4205,30 @@ convertedArray[i * 4 + 2] = colors[2]; convertedArray[i * 4 + 3] = colors[3]; } - return convertedArray; } + function _callSuper$6(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var Texture2DReader = function (_BaseReader) { - _inherits(Texture2DReader, _BaseReader); - - var _super = _createSuper(Texture2DReader); - function Texture2DReader() { _classCallCheck(this, Texture2DReader); - - return _super.apply(this, arguments); + return _callSuper$6(this, Texture2DReader, arguments); } - - _createClass(Texture2DReader, [{ + _inherits(Texture2DReader, _BaseReader); + return _createClass(Texture2DReader, [{ key: "read", value: function read(buffer) { var int32Reader = new Int32Reader(); @@ -4383,22 +4237,31 @@ var width = uint32Reader.read(buffer); var height = uint32Reader.read(buffer); var mipCount = uint32Reader.read(buffer); + var usedWidth = null; + var usedHeight = null; if (mipCount > 1) console.warn("Found mipcount of ".concat(mipCount, ", only the first will be used.")); var dataSize = uint32Reader.read(buffer); + if (width * height * 4 > dataSize) { + usedWidth = width >> 16 & 0xffff; + width = width & 0xffff; + usedHeight = height >> 16 & 0xffff; + height = height & 0xffff; + if (width * height * 4 !== dataSize) { + console.warn("invalid width & height! ".concat(width, " x ").concat(height)); + } + } var data = buffer.read(dataSize); if (format == 4) data = decompress(data, width, height, flags.DXT1);else if (format == 5) data = decompress(data, width, height, flags.DXT3);else if (format == 6) data = decompress(data, width, height, flags.DXT5);else if (format == 2) { data = convertFrom5551(data); } else if (format != 0) throw new Error("Non-implemented Texture2D format type (".concat(format, ") found.")); if (data instanceof ArrayBuffer) data = new Uint8Array(data); - for (var i = 0; i < data.length; i += 4) { var inverseAlpha = 255 / data[i + 3]; data[i] = Math.min(Math.ceil(data[i] * inverseAlpha), 255); data[i + 1] = Math.min(Math.ceil(data[i + 1] * inverseAlpha), 255); data[i + 2] = Math.min(Math.ceil(data[i + 2] * inverseAlpha), 255); } - - return { + var result = { format: format, export: { type: this.type, @@ -4407,6 +4270,11 @@ height: height } }; + if (usedWidth !== null) result.additional = { + usedWidth: usedWidth, + usedHeight: usedHeight + }; + return result; } }, { key: "write", @@ -4416,19 +4284,21 @@ this.writeIndex(buffer, resolver); var width = content.export.width; var height = content.export.height; + if (content.additional != null) { + width = width | content.additional.usedWidth << 16; + height = height | content.additional.usedHeight << 16; + } int32Reader.write(buffer, content.format, null); - uint32Reader.write(buffer, content.export.width, null); - uint32Reader.write(buffer, content.export.height, null); + uint32Reader.write(buffer, width, null); + uint32Reader.write(buffer, height, null); uint32Reader.write(buffer, 1, null); var data = content.export.data; - for (var i = 0; i < data.length; i += 4) { var alpha = data[i + 3] / 255; data[i] = Math.floor(data[i] * alpha); data[i + 1] = Math.floor(data[i + 1] * alpha); data[i + 2] = Math.floor(data[i + 2] * alpha); } - if (content.format === 4) data = compress(data, width, height, flags.DXT1);else if (content.format === 5) data = compress(data, width, height, flags.DXT3);else if (content.format === 6) data = compress(data, width, height, flags.DXT5);else if (content.format === 2) data = convertTo5551(data); uint32Reader.write(buffer, data.length, null); buffer.concat(data); @@ -4444,28 +4314,34 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.Texture2DReader': return true; - default: return false; } } }]); - - return Texture2DReader; }(BaseReader); + function _callSuper$5(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var Vector3Reader = function (_BaseReader) { - _inherits(Vector3Reader, _BaseReader); - - var _super = _createSuper(Vector3Reader); - function Vector3Reader() { _classCallCheck(this, Vector3Reader); - - return _super.apply(this, arguments); + return _callSuper$5(this, Vector3Reader, arguments); } - - _createClass(Vector3Reader, [{ + _inherits(Vector3Reader, _BaseReader); + return _createClass(Vector3Reader, [{ key: "read", value: function read(buffer) { var singleReader = new SingleReader(); @@ -4494,28 +4370,34 @@ case 'Microsoft.Xna.Framework.Content.Vector3Reader': case 'Microsoft.Xna.Framework.Vector3': return true; - default: return false; } } }]); - - return Vector3Reader; }(BaseReader); + function _callSuper$4(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var SpriteFontReader = function (_BaseReader) { - _inherits(SpriteFontReader, _BaseReader); - - var _super = _createSuper(SpriteFontReader); - function SpriteFontReader() { _classCallCheck(this, SpriteFontReader); - - return _super.apply(this, arguments); + return _callSuper$4(this, SpriteFontReader, arguments); } - - _createClass(SpriteFontReader, [{ + _inherits(SpriteFontReader, _BaseReader); + return _createClass(SpriteFontReader, [{ key: "read", value: function read(buffer, resolver) { var int32Reader = new Int32Reader(); @@ -4552,7 +4434,6 @@ var charListReader = new ListReader(charReader); var vector3ListReader = new ListReader(new Vector3Reader()); this.writeIndex(buffer, resolver); - try { texture2DReader.write(buffer, content.texture, resolver); buffer.alloc(100000); @@ -4578,7 +4459,6 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.SpriteFontReader': return true; - default: return false; } @@ -4589,22 +4469,29 @@ return ["SpriteFont", "Texture2D", 'List', 'Rectangle', 'List', 'Rectangle', 'List', 'Char', null, null, 'List', 'Vector3', 'Nullable', 'Char']; } }]); - - return SpriteFontReader; }(BaseReader); + function _callSuper$3(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var TBinReader = function (_BaseReader) { - _inherits(TBinReader, _BaseReader); - - var _super = _createSuper(TBinReader); - function TBinReader() { _classCallCheck(this, TBinReader); - - return _super.apply(this, arguments); + return _callSuper$3(this, TBinReader, arguments); } - - _createClass(TBinReader, [{ + _inherits(TBinReader, _BaseReader); + return _createClass(TBinReader, [{ key: "read", value: function read(buffer) { var int32Reader = new Int32Reader(); @@ -4637,28 +4524,34 @@ switch (type) { case 'xTile.Pipeline.TideReader': return true; - default: return false; } } }]); - - return TBinReader; }(BaseReader); + function _callSuper$2(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var LightweightTexture2DReader = function (_BaseReader) { - _inherits(LightweightTexture2DReader, _BaseReader); - - var _super = _createSuper(LightweightTexture2DReader); - function LightweightTexture2DReader() { _classCallCheck(this, LightweightTexture2DReader); - - return _super.apply(this, arguments); + return _callSuper$2(this, LightweightTexture2DReader, arguments); } - - _createClass(LightweightTexture2DReader, [{ + _inherits(LightweightTexture2DReader, _BaseReader); + return _createClass(LightweightTexture2DReader, [{ key: "read", value: function read(buffer) { var int32Reader = new Int32Reader(); @@ -4672,14 +4565,12 @@ var data = buffer.read(dataSize); data = new Uint8Array(data); if (format != 0) throw new Error("Compressed texture format is not supported!"); - for (var i = 0; i < data.length; i += 4) { var inverseAlpha = 255 / data[i + 3]; data[i] = Math.min(Math.ceil(data[i] * inverseAlpha), 255); data[i + 1] = Math.min(Math.ceil(data[i + 1] * inverseAlpha), 255); data[i + 2] = Math.min(Math.ceil(data[i + 2] * inverseAlpha), 255); } - return { format: format, export: { @@ -4704,14 +4595,12 @@ uint32Reader.write(buffer, content.export.height, null); uint32Reader.write(buffer, 1, null); var data = content.export.data; - for (var i = 0; i < data.length; i += 4) { var alpha = data[i + 3] / 255; data[i] = Math.floor(data[i] * alpha); data[i + 1] = Math.floor(data[i + 1] * alpha); data[i + 2] = Math.floor(data[i + 2] * alpha); } - uint32Reader.write(buffer, data.length, null); buffer.concat(data); } @@ -4731,7 +4620,6 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.Texture2DReader': return true; - default: return false; } @@ -4742,22 +4630,29 @@ return "Texture2D"; } }]); - - return LightweightTexture2DReader; }(BaseReader); + function _callSuper$1(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var Vector2Reader = function (_BaseReader) { - _inherits(Vector2Reader, _BaseReader); - - var _super = _createSuper(Vector2Reader); - function Vector2Reader() { _classCallCheck(this, Vector2Reader); - - return _super.apply(this, arguments); + return _callSuper$1(this, Vector2Reader, arguments); } - - _createClass(Vector2Reader, [{ + _inherits(Vector2Reader, _BaseReader); + return _createClass(Vector2Reader, [{ key: "read", value: function read(buffer) { var singleReader = new SingleReader(); @@ -4768,6 +4663,14 @@ y: y }; } + }, { + key: "write", + value: function write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + var singleReader = new SingleReader(); + singleReader.write(buffer, content.x, null); + singleReader.write(buffer, content.y, null); + } }], [{ key: "isTypeOf", value: function isTypeOf(type) { @@ -4775,28 +4678,34 @@ case 'Microsoft.Xna.Framework.Content.Vector2Reader': case 'Microsoft.Xna.Framework.Vector2': return true; - default: return false; } } }]); - - return Vector2Reader; }(BaseReader); + function _callSuper(_this, derived, args) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + } + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); + } var Vector4Reader = function (_BaseReader) { - _inherits(Vector4Reader, _BaseReader); - - var _super = _createSuper(Vector4Reader); - function Vector4Reader() { _classCallCheck(this, Vector4Reader); - - return _super.apply(this, arguments); + return _callSuper(this, Vector4Reader, arguments); } - - _createClass(Vector4Reader, [{ + _inherits(Vector4Reader, _BaseReader); + return _createClass(Vector4Reader, [{ key: "read", value: function read(buffer) { var singleReader = new SingleReader(); @@ -4811,6 +4720,16 @@ w: w }; } + }, { + key: "write", + value: function write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + var singleReader = new SingleReader(); + singleReader.write(buffer, content.x, null); + singleReader.write(buffer, content.y, null); + singleReader.write(buffer, content.z, null); + singleReader.write(buffer, content.w, null); + } }], [{ key: "isTypeOf", value: function isTypeOf(type) { @@ -4818,14 +4737,11 @@ case 'Microsoft.Xna.Framework.Content.Vector4Reader': case 'Microsoft.Xna.Framework.Vector4': return true; - default: return false; } } }]); - - return Vector4Reader; }(BaseReader); exports.ArrayReader = ArrayReader; @@ -4840,6 +4756,7 @@ exports.LightweightTexture2DReader = LightweightTexture2DReader; exports.ListReader = ListReader; exports.NullableReader = NullableReader; + exports.PointReader = PointReader; exports.RectangleReader = RectangleReader; exports.ReflectiveReader = ReflectiveReader; exports.SingleReader = SingleReader; diff --git a/dist/readers/xnb-readers.es5.min.js b/dist/readers/xnb-readers.es5.min.js index 84e39f6..936b568 100644 --- a/dist/readers/xnb-readers.es5.min.js +++ b/dist/readers/xnb-readers.es5.min.js @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -28,4 +28,4 @@ * -------------------------------------------------------------------------- */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XNB={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,n=function(t){try{return!!t()}catch(t){return!0}},i=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),u=function(t){return t&&t.Math==Math&&t},a=u("object"==typeof globalThis&&globalThis)||u("object"==typeof window&&window)||u("object"==typeof self&&self)||u("object"==typeof e&&e)||function(){return this}()||Function("return this")(),o=function(t){return"function"==typeof t},s=o,c=function(t){return"object"==typeof t?null!==t:s(t)},l=!n((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),f=l,h=Function.prototype,y=h.bind,v=h.call,p=f&&y.bind(v,v),d=f?function(t){return t&&p(t)}:function(t){return t&&function(){return v.apply(t,arguments)}},w=a.TypeError,m=function(t){if(null==t)throw w("Can't call method on "+t);return t},g=a.Object,k=function(t){return g(m(t))},b=k,_=d({}.hasOwnProperty),x=Object.hasOwn||function(t,e){return _(b(t),e)},T={exports:{}},S=a,O=Object.defineProperty,A=function(t,e){try{O(S,t,{value:e,configurable:!0,writable:!0})}catch(r){S[t]=e}return e},M=A,R="__core-js_shared__",z=a[R]||M(R,{}),V=z;(T.exports=function(t,e){return V[t]||(V[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.22.4",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.22.4/LICENSE",source:"https://github.com/zloirock/core-js"});var j,I,E=d,C=0,P=Math.random(),F=E(1..toString),U=function(t){return"Symbol("+(void 0===t?"":t)+")_"+F(++C+P,36)},B=a,D=o,L=function(t){return D(t)?t:void 0},X=function(t,e){return arguments.length<2?L(B[t]):B[t]&&B[t][e]},W=a,N=X("navigator","userAgent")||"",G=W.process,Y=W.Deno,q=G&&G.versions||Y&&Y.version,K=q&&q.v8;K&&(I=(j=K.split("."))[0]>0&&j[0]<4?1:+(j[0]+j[1])),!I&&N&&(!(j=N.match(/Edge\/(\d+)/))||j[1]>=74)&&(j=N.match(/Chrome\/(\d+)/))&&(I=+j[1]);var J=I,Z=n,$=!!Object.getOwnPropertySymbols&&!Z((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&J&&J<41})),H=$&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Q=a,tt=T.exports,et=x,rt=U,nt=$,it=H,ut=tt("wks"),at=Q.Symbol,ot=at&&at.for,st=it?at:at&&at.withoutSetter||rt,ct=function(t){if(!et(ut,t)||!nt&&"string"!=typeof ut[t]){var e="Symbol."+t;nt&&et(at,t)?ut[t]=at[t]:ut[t]=it&&ot?ot(e):st(e)}return ut[t]},lt={};lt[ct("toStringTag")]="z";var ft="[object z]"===String(lt),ht=d,yt=ht({}.toString),vt=ht("".slice),pt=function(t){return vt(yt(t),8,-1)},dt=a,wt=ft,mt=o,gt=pt,kt=ct("toStringTag"),bt=dt.Object,_t="Arguments"==gt(function(){return arguments}()),xt=wt?gt:function(t){var e,r,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=bt(t),kt))?r:_t?gt(e):"Object"==(n=gt(e))&&mt(e.callee)?"Arguments":n},Tt=a.String,St=function(t){try{return Tt(t)}catch(t){return"Object"}},Ot={},At=c,Mt=a.document,Rt=At(Mt)&&At(Mt.createElement),zt=function(t){return Rt?Mt.createElement(t):{}},Vt=!i&&!n((function(){return 7!=Object.defineProperty(zt("div"),"a",{get:function(){return 7}}).a})),jt=i&&n((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),It=a,Et=c,Ct=It.String,Pt=It.TypeError,Ft=function(t){if(Et(t))return t;throw Pt(Ct(t)+" is not an object")},Ut=l,Bt=Function.prototype.call,Dt=Ut?Bt.bind(Bt):function(){return Bt.apply(Bt,arguments)},Lt=d({}.isPrototypeOf),Xt=X,Wt=o,Nt=Lt,Gt=H,Yt=a.Object,qt=Gt?function(t){return"symbol"==typeof t}:function(t){var e=Xt("Symbol");return Wt(e)&&Nt(e.prototype,Yt(t))},Kt=o,Jt=St,Zt=a.TypeError,$t=function(t){if(Kt(t))return t;throw Zt(Jt(t)+" is not a function")},Ht=$t,Qt=Dt,te=o,ee=c,re=a.TypeError,ne=Dt,ie=c,ue=qt,ae=function(t,e){var r=t[e];return null==r?void 0:Ht(r)},oe=function(t,e){var r,n;if("string"===e&&te(r=t.toString)&&!ee(n=Qt(r,t)))return n;if(te(r=t.valueOf)&&!ee(n=Qt(r,t)))return n;if("string"!==e&&te(r=t.toString)&&!ee(n=Qt(r,t)))return n;throw re("Can't convert object to primitive value")},se=ct,ce=a.TypeError,le=se("toPrimitive"),fe=function(t,e){if(!ie(t)||ue(t))return t;var r,n=ae(t,le);if(n){if(void 0===e&&(e="default"),r=ne(n,t,e),!ie(r)||ue(r))return r;throw ce("Can't convert object to primitive value")}return void 0===e&&(e="number"),oe(t,e)},he=qt,ye=i,ve=Vt,pe=jt,de=Ft,we=function(t){var e=fe(t,"string");return he(e)?e:e+""},me=a.TypeError,ge=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,be="enumerable",_e="configurable",xe="writable";Ot.f=ye?pe?function(t,e,r){if(de(t),e=we(e),de(r),"function"==typeof t&&"prototype"===e&&"value"in r&&xe in r&&!r.writable){var n=ke(t,e);n&&n.writable&&(t[e]=r.value,r={configurable:_e in r?r.configurable:n.configurable,enumerable:be in r?r.enumerable:n.enumerable,writable:!1})}return ge(t,e,r)}:ge:function(t,e,r){if(de(t),e=we(e),de(r),ve)try{return ge(t,e,r)}catch(t){}if("get"in r||"set"in r)throw me("Accessors not supported");return"value"in r&&(t[e]=r.value),t};var Te=Ot,Se=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Oe=i?function(t,e,r){return Te.f(t,e,Se(1,r))}:function(t,e,r){return t[e]=r,t},Ae={exports:{}},Me=i,Re=x,ze=Function.prototype,Ve=Me&&Object.getOwnPropertyDescriptor,je=Re(ze,"name"),Ie={EXISTS:je,PROPER:je&&"something"===function(){}.name,CONFIGURABLE:je&&(!Me||Me&&Ve(ze,"name").configurable)},Ee=o,Ce=z,Pe=d(Function.toString);Ee(Ce.inspectSource)||(Ce.inspectSource=function(t){return Pe(t)});var Fe,Ue,Be,De=Ce.inspectSource,Le=o,Xe=De,We=a.WeakMap,Ne=Le(We)&&/native code/.test(Xe(We)),Ge=T.exports,Ye=U,qe=Ge("keys"),Ke=function(t){return qe[t]||(qe[t]=Ye(t))},Je=Ne,Ze=a,$e=d,He=c,Qe=Oe,tr=x,er=z,rr=Ke,nr={},ir="Object already initialized",ur=Ze.TypeError,ar=Ze.WeakMap;if(Je||er.state){var or=er.state||(er.state=new ar),sr=$e(or.get),cr=$e(or.has),lr=$e(or.set);Fe=function(t,e){if(cr(or,t))throw new ur(ir);return e.facade=t,lr(or,t,e),e},Ue=function(t){return sr(or,t)||{}},Be=function(t){return cr(or,t)}}else{var fr=rr("state");nr[fr]=!0,Fe=function(t,e){if(tr(t,fr))throw new ur(ir);return e.facade=t,Qe(t,fr,e),e},Ue=function(t){return tr(t,fr)?t[fr]:{}},Be=function(t){return tr(t,fr)}}var hr={set:Fe,get:Ue,has:Be,enforce:function(t){return Be(t)?Ue(t):Fe(t,{})},getterFor:function(t){return function(e){var r;if(!He(e)||(r=Ue(e)).type!==t)throw ur("Incompatible receiver, "+t+" required");return r}}},yr=n,vr=o,pr=x,dr=Ot.f,wr=Ie.CONFIGURABLE,mr=De,gr=hr.enforce,kr=hr.get,br=!yr((function(){return 8!==dr((function(){}),"length",{value:8}).length})),_r=String(String).split("String"),xr=Ae.exports=function(t,e,r){"Symbol("===String(e).slice(0,7)&&(e="["+String(e).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(e="get "+e),r&&r.setter&&(e="set "+e),(!pr(t,"name")||wr&&t.name!==e)&&dr(t,"name",{value:e,configurable:!0}),br&&r&&pr(r,"arity")&&t.length!==r.arity&&dr(t,"length",{value:r.arity});var n=gr(t);return pr(n,"source")||(n.source=_r.join("string"==typeof e?e:"")),t};Function.prototype.toString=xr((function(){return vr(this)&&kr(this).source||mr(this)}),"toString");var Tr,Sr,Or,Ar=a,Mr=o,Rr=Oe,zr=Ae.exports,Vr=A,jr=!n((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),Ir=a,Er=x,Cr=o,Pr=k,Fr=jr,Ur=Ke("IE_PROTO"),Br=Ir.Object,Dr=Br.prototype,Lr=Fr?Br.getPrototypeOf:function(t){var e=Pr(t);if(Er(e,Ur))return e[Ur];var r=e.constructor;return Cr(r)&&e instanceof r?r.prototype:e instanceof Br?Dr:null},Xr=a,Wr=o,Nr=Xr.String,Gr=Xr.TypeError,Yr=d,qr=Ft,Kr=function(t){if("object"==typeof t||Wr(t))return t;throw Gr("Can't set "+Nr(t)+" as a prototype")},Jr=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,r={};try{(t=Yr(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),e=r instanceof Array}catch(t){}return function(r,n){return qr(r),Kr(n),e?t(r,n):r.__proto__=n,r}}():void 0),Zr=r,$r=i,Hr=a,Qr=o,tn=c,en=x,rn=xt,nn=St,un=Oe,an=function(t,e,r,n){var i=!!n&&!!n.unsafe,u=!!n&&!!n.enumerable,a=!!n&&!!n.noTargetGet,o=n&&void 0!==n.name?n.name:e;return Mr(r)&&zr(r,o,n),t===Ar?(u?t[e]=r:Vr(e,r),t):(i?!a&&t[e]&&(u=!0):delete t[e],u?t[e]=r:Rr(t,e,r),t)},on=Ot.f,sn=Lt,cn=Lr,ln=Jr,fn=ct,hn=U,yn=Hr.Int8Array,vn=yn&&yn.prototype,pn=Hr.Uint8ClampedArray,dn=pn&&pn.prototype,wn=yn&&cn(yn),mn=vn&&cn(vn),gn=Object.prototype,kn=Hr.TypeError,bn=fn("toStringTag"),_n=hn("TYPED_ARRAY_TAG"),xn=hn("TYPED_ARRAY_CONSTRUCTOR"),Tn=Zr&&!!ln&&"Opera"!==rn(Hr.opera),Sn=!1,On={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},An={BigInt64Array:8,BigUint64Array:8},Mn=function(t){if(!tn(t))return!1;var e=rn(t);return en(On,e)||en(An,e)};for(Tr in On)(Or=(Sr=Hr[Tr])&&Sr.prototype)?un(Or,xn,Sr):Tn=!1;for(Tr in An)(Or=(Sr=Hr[Tr])&&Sr.prototype)&&un(Or,xn,Sr);if((!Tn||!Qr(wn)||wn===Function.prototype)&&(wn=function(){throw kn("Incorrect invocation")},Tn))for(Tr in On)Hr[Tr]&&ln(Hr[Tr],wn);if((!Tn||!mn||mn===gn)&&(mn=wn.prototype,Tn))for(Tr in On)Hr[Tr]&&ln(Hr[Tr].prototype,mn);if(Tn&&cn(dn)!==mn&&ln(dn,mn),$r&&!en(mn,bn))for(Tr in Sn=!0,on(mn,bn,{get:function(){return tn(this)?this[_n]:void 0}}),On)Hr[Tr]&&un(Hr[Tr],_n,Tr);var Rn={NATIVE_ARRAY_BUFFER_VIEWS:Tn,TYPED_ARRAY_CONSTRUCTOR:xn,TYPED_ARRAY_TAG:Sn&&_n,aTypedArray:function(t){if(Mn(t))return t;throw kn("Target is not a typed array")},aTypedArrayConstructor:function(t){if(Qr(t)&&(!ln||sn(wn,t)))return t;throw kn(nn(t)+" is not a typed array constructor")},exportTypedArrayMethod:function(t,e,r,n){if($r){if(r)for(var i in On){var u=Hr[i];if(u&&en(u.prototype,t))try{delete u.prototype[t]}catch(r){try{u.prototype[t]=e}catch(t){}}}mn[t]&&!r||an(mn,t,r?e:Tn&&vn[t]||e,n)}},exportTypedArrayStaticMethod:function(t,e,r){var n,i;if($r){if(ln){if(r)for(n in On)if((i=Hr[n])&&en(i,t))try{delete i[t]}catch(t){}if(wn[t]&&!r)return;try{return an(wn,t,r?e:Tn&&wn[t]||e)}catch(t){}}for(n in On)!(i=Hr[n])||i[t]&&!r||an(i,t,e)}},isView:function(t){if(!tn(t))return!1;var e=rn(t);return"DataView"===e||en(On,e)||en(An,e)},isTypedArray:Mn,TypedArray:wn,TypedArrayPrototype:mn},zn=$t,Vn=l,jn=d(d.bind),In=d,En=n,Cn=pt,Pn=a.Object,Fn=In("".split),Un=En((function(){return!Pn("z").propertyIsEnumerable(0)}))?function(t){return"String"==Cn(t)?Fn(t,""):Pn(t)}:Pn,Bn=Math.ceil,Dn=Math.floor,Ln=function(t){var e=+t;return e!=e||0===e?0:(e>0?Dn:Bn)(e)},Xn=Math.min,Wn=function(t){return t>0?Xn(Ln(t),9007199254740991):0},Nn=pt,Gn=Array.isArray||function(t){return"Array"==Nn(t)},Yn=d,qn=n,Kn=o,Jn=xt,Zn=De,$n=function(){},Hn=[],Qn=X("Reflect","construct"),ti=/^\s*(?:class|function)\b/,ei=Yn(ti.exec),ri=!ti.exec($n),ni=function(t){if(!Kn(t))return!1;try{return Qn($n,Hn,t),!0}catch(t){return!1}},ii=function(t){if(!Kn(t))return!1;switch(Jn(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ri||!!ei(ti,Zn(t))}catch(t){return!0}};ii.sham=!0;var ui=!Qn||qn((function(){var t;return ni(ni.call)||!ni(Object)||!ni((function(){t=!0}))||t}))?ii:ni,ai=a,oi=Gn,si=ui,ci=c,li=ct("species"),fi=ai.Array,hi=function(t){var e;return oi(t)&&(e=t.constructor,(si(e)&&(e===fi||oi(e.prototype))||ci(e)&&null===(e=e[li]))&&(e=void 0)),void 0===e?fi:e},yi=function(t,e){return zn(t),void 0===e?t:Vn?jn(t,e):function(){return t.apply(e,arguments)}},vi=Un,pi=k,di=function(t){return Wn(t.length)},wi=function(t,e){return new(hi(t))(0===e?0:e)},mi=d([].push),gi=function(t){var e=1==t,r=2==t,n=3==t,i=4==t,u=6==t,a=7==t,o=5==t||u;return function(s,c,l,f){for(var h,y,v=pi(s),p=vi(v),d=yi(c,l),w=di(p),m=0,g=f||wi,k=e?g(s,w):r||a?g(s,0):void 0;w>m;m++)if((o||m in p)&&(y=d(h=p[m],m,v),t))if(e)k[m]=y;else if(y)switch(t){case 3:return!0;case 5:return h;case 6:return m;case 2:mi(k,h)}else switch(t){case 4:return!1;case 7:mi(k,h)}return u?-1:n||i?i:k}},ki={forEach:gi(0),map:gi(1),filter:gi(2),some:gi(3),every:gi(4),find:gi(5),findIndex:gi(6),filterReject:gi(7)},bi=ui,_i=St,xi=a.TypeError,Ti=Ft,Si=function(t){if(bi(t))return t;throw xi(_i(t)+" is not a constructor")},Oi=ct("species"),Ai=function(t,e){var r,n=Ti(t).constructor;return void 0===n||null==(r=Ti(n)[Oi])?e:Si(r)},Mi=Rn.TYPED_ARRAY_CONSTRUCTOR,Ri=Rn.aTypedArrayConstructor,zi=ki.map,Vi=function(t){return Ri(Ai(t,t[Mi]))},ji=Rn.aTypedArray;(0,Rn.exportTypedArrayMethod)("map",(function(t){return zi(ji(this),t,arguments.length>1?arguments[1]:void 0,(function(t,e){return new(Vi(t))(e)}))}));var Ii=i,Ei=Ie.EXISTS,Ci=d,Pi=Ot.f,Fi=Function.prototype,Ui=Ci(Fi.toString),Bi=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Di=Ci(Bi.exec);function Li(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Xi(t){for(var e=1;e")}},{key:"parseTypeList",value:function(){return[this.type].concat(this.reader.parseTypeList())}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.ArrayReader"===t}},{key:"hasSubType",value:function(){return!0}}]),r}(eu);function iu(t,e){if(!t||"object"!==Wi(t))throw new Error("Invalid Data!");for(var r=[],n=t.length,i=0;i>(t>>3&30)&3)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.CharReader":case"System.Char":return!0;default:return!1}}}]),r}(eu),yu=function(t){Ki(r,t);var e=tu(r);function r(t,n){var i;if(Ni(this,r),null==t||null==n)throw new Error("Cannot create instance of DictionaryReader without Key and Value.");return(i=e.call(this)).key=t,i.value=n,i}return Yi(r,[{key:"read",value:function(t,e){for(var r={},n=(new ru).read(t),i=0;i")}},{key:"parseTypeList",value:function(){return[this.type].concat(this.key.parseTypeList(),this.value.parseTypeList())}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.DictionaryReader"===t}},{key:"hasSubType",value:function(){return!0}}]),r}(eu),vu=function(t){Ki(r,t);var e=tu(r);function r(){return Ni(this,r),e.apply(this,arguments)}return Yi(r,[{key:"read",value:function(t){return t.readDouble()}},{key:"write",value:function(t,e,r){this.writeIndex(t,r),t.writeDouble(e)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.DoubleReader":case"System.Double":return!0;default:return!1}}}]),r}(eu),pu=function(t){Ki(r,t);var e=tu(r);function r(){return Ni(this,r),e.apply(this,arguments)}return Yi(r,[{key:"read",value:function(t){var e=(new ru).read(t),r=t.read(e);return{export:{type:this.type,data:r}}}},{key:"write",value:function(t,e,r){this.writeIndex(t,r);var n=e.export.data;(new ru).write(t,n.byteLength,null),t.concat(n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.EffectReader":case"Microsoft.Xna.Framework.Graphics.Effect":return!0;default:return!1}}}]),r}(eu),du=function(t){Ki(r,t);var e=tu(r);function r(){return Ni(this,r),e.apply(this,arguments)}return Yi(r,[{key:"read",value:function(t){return t.readInt32()}},{key:"write",value:function(t,e,r){this.writeIndex(t,r),t.writeInt32(e)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.Int32Reader":case"System.Int32":return!0;default:return!1}}}]),r}(eu),wu=function(t){Ki(r,t);var e=tu(r);function r(t){var n;return Ni(this,r),(n=e.call(this)).reader=t,n}return Yi(r,[{key:"read",value:function(t,e){for(var r=(new ru).read(t),n=[],i=0;i")}},{key:"parseTypeList",value:function(){return[this.type].concat(this.reader.parseTypeList())}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.ListReader":case"System.Collections.Generic.List":return!0;default:return!1}}},{key:"hasSubType",value:function(){return!0}}]),r}(eu),mu=function(t){Ki(r,t);var e=tu(r);function r(t){var n;return Ni(this,r),(n=e.call(this)).reader=t,n}return Yi(r,[{key:"read",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=new fu,n=t.peekByte(1);return n?null===e?(r.read(t),this.reader.read(t)):this.reader.isValueType()?this.reader.read(t):e.read(t):(r.read(t),null)}},{key:"write",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;new fu,null!==e?(null===r&&t.writeByte(1),this.reader.write(t,e,this.reader.isValueType()?null:r)):t.writeByte(0)}},{key:"isValueType",value:function(){return!1}},{key:"type",get:function(){return"Nullable<".concat(this.reader.type,">")}},{key:"parseTypeList",value:function(){var t=this.reader.parseTypeList();return["".concat(this.type,":").concat(t.length)].concat(t)}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.NullableReader"===t}},{key:"hasSubType",value:function(){return!0}}]),r}(eu),gu=function(t){Ki(r,t);var e=tu(r);function r(t){var n;return Ni(this,r),(n=e.call(this)).reader=t,n}return Yi(r,[{key:"read",value:function(t,e){return this.reader.read(t,e)}},{key:"write",value:function(t,e,r){this.reader.write(t,e,this.reader.isValueType()?null:r)}},{key:"isValueType",value:function(){return!1}},{key:"type",get:function(){return"".concat(this.reader.type)}},{key:"parseTypeList",value:function(){return[].concat(this.reader.parseTypeList())}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.ReflectiveReader"===t}},{key:"hasSubType",value:function(){return!0}}]),r}(eu),ku=function(t){Ki(r,t);var e=tu(r);function r(){return Ni(this,r),e.apply(this,arguments)}return Yi(r,[{key:"read",value:function(t){var e=new du;return{x:e.read(t),y:e.read(t),width:e.read(t),height:e.read(t)}}},{key:"write",value:function(t,e,r){this.writeIndex(t,r);var n=new du;n.write(t,e.x,null),n.write(t,e.y,null),n.write(t,e.width,null),n.write(t,e.height,null)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.RectangleReader":case"Microsoft.Xna.Framework.Rectangle":return!0;default:return!1}}}]),r}(eu),bu=function(t){Ki(r,t);var e=tu(r);function r(){return Ni(this,r),e.apply(this,arguments)}return Yi(r,[{key:"read",value:function(t){return t.readSingle()}},{key:"write",value:function(t,e,r){this.writeIndex(t,r),t.writeSingle(e)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.SingleReader":case"System.Single":return!0;default:return!1}}}]),r}(eu),_u=256;function xu(t,e,r,n){for(var i=Array(n),u=0;u1&&void 0!==arguments[1]?arguments[1]:1e-7,r=t.length,n=Array(r),i=Math.abs(e/r),u=Array(r),a=0;a=Math.abs(i);){var l=c[0][0],f=c[0][1],h=xu(l,f,Tu(t[l][l],t[f][f],t[l][f]),r);t=Ou(h,t),u=Au(u,h),c=Su(t)}for(var y=0;y0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;Ni(this,t),this._values=[e,r,n]}return Yi(t,[{key:"x",get:function(){return this._values[0]},set:function(t){this._values[0]=t}},{key:"y",get:function(){return this._values[1]},set:function(t){this._values[1]=t}},{key:"z",get:function(){return this._values[2]},set:function(t){this._values[2]=t}},{key:"length",get:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}},{key:"lengthSq",get:function(){return this.x*this.x+this.y*this.y+this.z*this.z}},{key:"normalized",get:function(){return 0===this.length?null:t.multScalar(this,1/this.length)}},{key:"colorInt",get:function(){return this._values.map((function(t){var e=parseInt(255*t+.5);return Math.max(Math.min(e,255),0)}))}},{key:"clone",value:function(){return new t(this.x,this.y,this.z)}},{key:"set",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;return this._values[0]=t,this._values[1]=e,this._values[2]=r,this}},{key:"toVec4",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Vu(this.x,this.y,this.z,t)}},{key:"addVector",value:function(t){return this._values[0]+=t.x,this._values[1]+=t.y,this._values[2]+=t.z,this}},{key:"addScaledVector",value:function(t,e){return this._values[0]+=t.x*e,this._values[1]+=t.y*e,this._values[2]+=t.z*e,this}},{key:"mult",value:function(t){return this._values[0]*=t,this._values[1]*=t,this._values[2]*=t,this}},{key:"multVector",value:function(t){return this._values[0]*=t.x,this._values[1]*=t.y,this._values[2]*=t.z,this}},{key:"clamp",value:function(t,e){var r=function(r){return t>r?t:e(r=t)?0:10&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e;Ni(this,t),this._values=[e,r,n,i]}return Yi(t,[{key:"x",get:function(){return this._values[0]},set:function(t){this._values[0]=t}},{key:"y",get:function(){return this._values[1]},set:function(t){this._values[1]=t}},{key:"z",get:function(){return this._values[2]},set:function(t){this._values[2]=t}},{key:"w",get:function(){return this._values[3]},set:function(t){this._values[3]=t}},{key:"length",get:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}},{key:"lengthSq",get:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}},{key:"normalized",get:function(){return 0===this.length?null:t.multScalar(this,1/this.length)}},{key:"xyz",get:function(){return new zu(this.x,this.y,this.z)}},{key:"splatX",get:function(){return new t(this.x)}},{key:"splatY",get:function(){return new t(this.y)}},{key:"splatZ",get:function(){return new t(this.z)}},{key:"splatW",get:function(){return new t(this.w)}},{key:"clone",value:function(){return new t(this.x,this.y,this.z,this.w)}},{key:"set",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t;return this._values[0]=t,this._values[1]=e,this._values[2]=r,this._values[3]=n,this}},{key:"toVec3",value:function(){return this.xyz}},{key:"addVector",value:function(t){return this._values[0]+=t.x,this._values[1]+=t.y,this._values[2]+=t.z,this._values[3]+=t.w,this}},{key:"addScaledVector",value:function(t,e){return this._values[0]+=t.x*e,this._values[1]+=t.y*e,this._values[2]+=t.z*e,this._values[3]+=t.w*e,this}},{key:"subVector",value:function(t){return this._values[0]-=t.x,this._values[1]-=t.y,this._values[2]-=t.z,this._values[3]-=t.w,this}},{key:"mult",value:function(t){return this._values[0]*=t,this._values[1]*=t,this._values[2]*=t,this._values[3]*=t,this}},{key:"multVector",value:function(t){return this._values[0]*=t.x,this._values[1]*=t.y,this._values[2]*=t.z,this._values[3]*=t.w,this}},{key:"reciprocal",value:function(){return this._values[0]=1/this._values[0],this._values[1]=1/this._values[1],this._values[2]=1/this._values[2],this._values[3]=1/this._values[3],this}},{key:"clamp",value:function(t,e){var r=function(r){return t>r?t:et?0:1>8,n[i+2]=255&e,n[i+3]=e>>8;for(var u=0;u<4;u++)n[i+4+u]=r[4*u+0]|r[4*u+1]<<2|r[4*u+2]<<4|r[4*u+3]<<6}function Du(t,e,r,n,i){var u,a=Uu(t),o=Uu(e);if(a<=o)u=r.slice();else{var s=[o,a];a=s[0],o=s[1],u=r.map((function(t){return 0===t?1:1===t?0:t}))}Bu(a,o,u,n,i)}function Lu(t,e,r,n,i){var u,a=Uu(t),o=Uu(e);if(a=128||!i)){var h=this._remap[o],y=(e[4*a+3]+1)/256;this._weights[h]+=u?y:1,this._remap[a]=h;break}}else this._remap[a]=-1}for(var v=0;v=n?t:(n=a,u)}),0);return i+=n,u}));if(io&&(u=r[c],o=l)}this.start=i.clampGrid().clone(),this.end=u.clampGrid().clone()}}}]),r}(Wu),Yu=function(t){Ki(r,t);var e=tu(r);function r(t){var n;Ni(this,r);(n=e.call(this,t)).iterationCount=t.flags&_u?8:1,n.bestError=1/0,n.metric=new Vu(1),0!=(32&n.flags)&&n.metric.set(.2126,.7152,.0722,0);var i=n.colors,u=i.points,a=i.weights;return n.principle=ju(u,a),n.order=new Uint8Array(128),n.pointsWeights=[],n.xSum_wSum=new Vu(0),n}return Yi(r,[{key:"constructOrdering",value:function(t,e){var r=this.makeOrder(t);return this.copyOrderToThisOrder(r,e),!!this.checkOrderUnique(r,e)&&(this.copyOrderWeight(r),!0)}},{key:"compress3",value:function(t,e){this.compressBase((function(t){var e=t[0],r=t[2],n=t[3],i=new Vu(.5,.5,.5,1/4),u=Vu.multiplyAdd(r,i,e),a=u.splatW,o=Vu.multiplyAdd(r,i,n);return{ax:u,aa:a,bx:o,bb:o.splatW,ab:Vu.multVector(r,i).splatW}}),(function(r,n,i){return Du(r,n,i,t,e)}),2)}},{key:"compress4",value:function(t,e){this.compressBase((function(t){var e=t[0],r=t[1],n=t[2],i=t[3],u=new Vu(1/3,1/3,1/3,1/9),a=new Vu(2/3,2/3,2/3,4/9),o=new Vu(2/9),s=Vu.multiplyAdd(n,u,Vu.multiplyAdd(r,a,e)),c=s.splatW,l=Vu.multiplyAdd(r,u,Vu.multiplyAdd(n,a,i));return{ax:s,aa:c,bx:l,bb:l.splatW,ab:Vu.multVector(o,Vu.add(r,n)).splatW}}),(function(r,n,i){return Lu(r,n,i,t,e)}),3)}},{key:"compressBase",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;this.constructOrdering(this.principle,0);var i={start:new Vu(0),end:new Vu(0),error:this.bestError,iteration:0,bestI:0,bestJ:0};3===n&&(i.bestK=0);for(var u=function(e,n){var u=t(e),a=r.computeOptimalPoints(u);return a.error2&&void 0!==arguments[2]?arguments[2]:2,n=this.colors.count,i=function(e,n,i){var u={bestI:e,bestJ:2===r?i:n,iteration:t};return 3===r&&(u.bestK=i),u},u=new Vu(0),a=0;a15?15:e}function Ku(t,e,r,n){var i=Ju(t,e,5),u=Ju(t,e,7);i.error<=u.error?function(t,e,r){var n=t.min,i=t.max,u=t.indices;if(n>i){$u(i,n,u.map((function(t){return 0===t?1:1===t?0:t<=5?7-t:t})),e,r)}else $u(n,i,u,e,r)}(i,r,n):function(t,e,r){var n=t.min,i=t.max,u=t.indices;if(n>i){$u(i,n,u.map((function(t){return 0===t?1:1===t?0:9-t})),e,r)}else $u(n,i,u,e,r)}(u,r,n)}function Ju(t,e,r){var n=function(t,e,r){for(var n=255,i=0,u=0;u<16;u++){if(0!=(e&1<i&&(i=a)):(ai&&(i=a))}}n>i&&(n=i);i-n>8*l&255;n[a]=f,a++}}}function Hu(t){var e=t>>11&31,r=t>>5&63,n=31&t;return[e<<3|e>>2,r<<2|r>>4,n<<3|n>>2,255]}function Qu(t,e,r){var n=t.map((function(t,n){return Math.floor(t*(1-r)+e[n]*r)}));return n[3]=255,n}function ta(t,e,r,n){for(var i=function(t,e,r){var n=t[e]|t[e+1]<<8,i=t[e+2]|t[e+3]<<8,u=Hu(n),a=Hu(i);return[u,a,Qu(u,a,r&&n<=i?.5:1/3),r&&n<=i?[0,0,0,0]:Qu(u,a,2/3)]}(e,r,n),u=function(t,e){for(var r=e+4,n=new Uint8Array(16),i=0;i<4;i++){var u=t[r+i];n[4*i+0]=3&u,n[4*i+1]=u>>2&3,n[4*i+2]=u>>4&3,n[4*i+3]=u>>6&3}return n}(e,r),a=0;a<16;a++)for(var o=0;o<4;o++)t[4*a+o]=i[u[a]][o]}function ea(t){for(var e=0;e<4;e++)for(var r=0;r<4;r++)t(r,e)}function ra(t){var e=7&t,r=280&t,n=96&t;return 2!=e&&4!=e&&(e=1),16!=r&&r!=_u&&(r=8),64!=n&&(n=32),e|r|n|128&t}function na(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.x,i=void 0===n?0:n,u=r.y,a=void 0===u?0:u,o=r.width,s=void 0===o?0:o,c=r.height,l=void 0===c?0:c,f=0;ea((function(r,n){var u=i+r,o=a+n;if(u>4}}(t,e,r):0!=(4&n)&&function(t,e,r){for(var n=e[r+0],i=e[r+1],u=Zu(n,i,n<=i?5:7),a=new Uint8Array(16),o=0,s=2,c=0;c<2;c++){for(var l=0,f=0;f<3;f++)l|=e[r+s]<<8*f,s++;for(var h=0;h<8;h++){var y=l>>3*h&7;a[o]=y,o++}}for(var v=0;v<16;++v)t[4*v+3]=u[a[v]]}(t,e,r)}function aa(t,e,r,n,i){var u=0!=(1&(i=ra(i)))?8:16,a=0;!function(t,e,r){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},r=e.x,n=void 0===r?0:r,i=e.y,u=void 0===i?0:i,a=e.width,o=void 0===a?0:a,s=e.height,c=void 0===s?0:s,l=new Uint8Array(64),f=0,h=0;return ea((function(e,r){var i=n+e,a=u+r;if(i>r&Math.pow(2,e)-1}function ya(t,e,r,n){var i=Math.round(t/255*31),u=Math.round(e/255*31),a=Math.round(r/255*31);return Math.round(n/255)<<15|i<<10|u<<5|a}var va=function(t){Ki(r,t);var e=tu(r);function r(){return Ni(this,r),e.apply(this,arguments)}return Yi(r,[{key:"read",value:function(t){var e=new du,r=new ru,n=e.read(t),i=r.read(t),u=r.read(t),a=r.read(t);a>1&&console.warn("Found mipcount of ".concat(a,", only the first will be used."));var o=r.read(t),s=t.read(o);if(4==n)s=fa(s,i,u,oa);else if(5==n)s=fa(s,i,u,sa);else if(6==n)s=fa(s,i,u,ca);else if(2==n)s=function(t){for(var e,r,n,i=new Uint8Array(t),u=i.length/2,a=new Uint8Array(4*u),o=0;o>15&1,[(n=[ha(e,5,10),ha(e,5,5),ha(e,5,0)].map((function(t){return t<<3|t>>2})))[0],n[1],n[2],255*r]);a[4*o]=s[0],a[4*o+1]=s[1],a[4*o+2]=s[2],a[4*o+3]=s[3]}return a}(s);else if(0!=n)throw new Error("Non-implemented Texture2D format type (".concat(n,") found."));s instanceof ArrayBuffer&&(s=new Uint8Array(s));for(var c=0;c>8}return n}(o)),i.write(t,o.length,null),t.concat(o)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.Texture2DReader"===t}}]),r}(eu),pa=function(t){Ki(r,t);var e=tu(r);function r(){return Ni(this,r),e.apply(this,arguments)}return Yi(r,[{key:"read",value:function(t){var e=new bu;return{x:e.read(t),y:e.read(t),z:e.read(t)}}},{key:"write",value:function(t,e,r){this.writeIndex(t,r);var n=new bu;n.write(t,e.x,null),n.write(t,e.y,null),n.write(t,e.z,null)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.Vector3Reader":case"Microsoft.Xna.Framework.Vector3":return!0;default:return!1}}}]),r}(eu),da=function(t){Ki(r,t);var e=tu(r);function r(){return Ni(this,r),e.apply(this,arguments)}return Yi(r,[{key:"read",value:function(t,e){var r=new du,n=new bu,i=new mu(new hu);return{texture:e.read(t),glyphs:e.read(t),cropping:e.read(t),characterMap:e.read(t),verticalLineSpacing:r.read(t),horizontalSpacing:n.read(t),kerning:e.read(t),defaultCharacter:i.read(t)}}},{key:"write",value:function(t,e,r){var n=new du,i=new hu,u=new bu,a=new mu(i),o=new va,s=new wu(new ku),c=new wu(i),l=new wu(new pa);this.writeIndex(t,r);try{o.write(t,e.texture,r),t.alloc(1e5),s.write(t,e.glyphs,r),s.write(t,e.cropping,r),c.write(t,e.characterMap,r),n.write(t,e.verticalLineSpacing,null),u.write(t,e.horizontalSpacing,null),l.write(t,e.kerning,r),a.write(t,e.defaultCharacter,null)}catch(t){throw t}}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.SpriteFontReader"===t}},{key:"parseTypeList",value:function(){return["SpriteFont","Texture2D","List","Rectangle","List","Rectangle","List","Char",null,null,"List","Vector3","Nullable","Char"]}}]),r}(eu),wa=function(t){Ki(r,t);var e=tu(r);function r(){return Ni(this,r),e.apply(this,arguments)}return Yi(r,[{key:"read",value:function(t){var e=(new du).read(t),r=t.read(e);return{export:{type:this.type,data:r}}}},{key:"write",value:function(t,e,r){this.writeIndex(t,r);var n=e.export.data;(new du).write(t,n.byteLength,null),t.concat(n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(t){return"xTile.Pipeline.TideReader"===t}}]),r}(eu),ma=function(t){Ki(r,t);var e=tu(r);function r(){return Ni(this,r),e.apply(this,arguments)}return Yi(r,[{key:"read",value:function(t){var e=new du,r=new ru,n=e.read(t),i=r.read(t),u=r.read(t),a=r.read(t);a>1&&console.warn("Found mipcount of ".concat(a,", only the first will be used."));var o=r.read(t),s=t.read(o);if(s=new Uint8Array(s),0!=n)throw new Error("Compressed texture format is not supported!");for(var c=0;c0&&z[0]<4?1:+(z[0]+z[1])),!V&&N&&(!(z=N.match(/Edge\/(\d+)/))||z[1]>=74)&&(z=N.match(/Chrome\/(\d+)/))&&(V=+z[1]);var J=V,H=n,Z=!!Object.getOwnPropertySymbols&&!H((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&J&&J<41})),$=Z&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Q=i,tt=_.exports,et=x,rt=F,nt=Z,ot=$,ut=tt("wks"),it=Q.Symbol,at=it&&it.for,ct=ot?it:it&&it.withoutSetter||rt,st=function(t){if(!et(ut,t)||!nt&&"string"!=typeof ut[t]){var e="Symbol."+t;nt&&et(it,t)?ut[t]=it[t]:ut[t]=ot&&at?at(e):ct(e)}return ut[t]},ft={};ft[st("toStringTag")]="z";var lt="[object z]"===String(ft),yt=d,ht=yt({}.toString),vt=yt("".slice),pt=function(t){return vt(ht(t),8,-1)},dt=i,wt=lt,mt=a,gt=pt,kt=st("toStringTag"),bt=dt.Object,Rt="Arguments"==gt(function(){return arguments}()),xt=wt?gt:function(t){var e,r,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=bt(t),kt))?r:Rt?gt(e):"Object"==(n=gt(e))&&mt(e.callee)?"Arguments":n},_t=i.String,Ot=function(t){try{return _t(t)}catch(t){return"Object"}},Tt={},St=s,At=i.document,Mt=St(At)&&St(At.createElement),Bt=function(t){return Mt?At.createElement(t):{}},Pt=!o&&!n((function(){return 7!=Object.defineProperty(Bt("div"),"a",{get:function(){return 7}}).a})),zt=o&&n((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Vt=i,It=s,jt=Vt.String,Et=Vt.TypeError,Ct=function(t){if(It(t))return t;throw Et(jt(t)+" is not an object")},Ft=f,Ut=Function.prototype.call,Dt=Ft?Ut.bind(Ut):function(){return Ut.apply(Ut,arguments)},Xt=d({}.isPrototypeOf),Lt=L,Wt=a,Nt=Xt,Gt=$,Yt=i.Object,qt=Gt?function(t){return"symbol"==typeof t}:function(t){var e=Lt("Symbol");return Wt(e)&&Nt(e.prototype,Yt(t))},Kt=a,Jt=Ot,Ht=i.TypeError,Zt=function(t){if(Kt(t))return t;throw Ht(Jt(t)+" is not a function")},$t=Zt,Qt=Dt,te=a,ee=s,re=i.TypeError,ne=Dt,oe=s,ue=qt,ie=function(t,e){var r=t[e];return null==r?void 0:$t(r)},ae=function(t,e){var r,n;if("string"===e&&te(r=t.toString)&&!ee(n=Qt(r,t)))return n;if(te(r=t.valueOf)&&!ee(n=Qt(r,t)))return n;if("string"!==e&&te(r=t.toString)&&!ee(n=Qt(r,t)))return n;throw re("Can't convert object to primitive value")},ce=st,se=i.TypeError,fe=ce("toPrimitive"),le=function(t,e){if(!oe(t)||ue(t))return t;var r,n=ie(t,fe);if(n){if(void 0===e&&(e="default"),r=ne(n,t,e),!oe(r)||ue(r))return r;throw se("Can't convert object to primitive value")}return void 0===e&&(e="number"),ae(t,e)},ye=qt,he=o,ve=Pt,pe=zt,de=Ct,we=function(t){var e=le(t,"string");return ye(e)?e:e+""},me=i.TypeError,ge=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,be="enumerable",Re="configurable",xe="writable";Tt.f=he?pe?function(t,e,r){if(de(t),e=we(e),de(r),"function"==typeof t&&"prototype"===e&&"value"in r&&xe in r&&!r.writable){var n=ke(t,e);n&&n.writable&&(t[e]=r.value,r={configurable:Re in r?r.configurable:n.configurable,enumerable:be in r?r.enumerable:n.enumerable,writable:!1})}return ge(t,e,r)}:ge:function(t,e,r){if(de(t),e=we(e),de(r),ve)try{return ge(t,e,r)}catch(t){}if("get"in r||"set"in r)throw me("Accessors not supported");return"value"in r&&(t[e]=r.value),t};var _e=Tt,Oe=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Te=o?function(t,e,r){return _e.f(t,e,Oe(1,r))}:function(t,e,r){return t[e]=r,t},Se={exports:{}},Ae=o,Me=x,Be=Function.prototype,Pe=Ae&&Object.getOwnPropertyDescriptor,ze=Me(Be,"name"),Ve={EXISTS:ze,PROPER:ze&&"something"===function(){}.name,CONFIGURABLE:ze&&(!Ae||Ae&&Pe(Be,"name").configurable)},Ie=a,je=B,Ee=d(Function.toString);Ie(je.inspectSource)||(je.inspectSource=function(t){return Ee(t)});var Ce,Fe,Ue,De=je.inspectSource,Xe=a,Le=De,We=i.WeakMap,Ne=Xe(We)&&/native code/.test(Le(We)),Ge=_.exports,Ye=F,qe=Ge("keys"),Ke=function(t){return qe[t]||(qe[t]=Ye(t))},Je=Ne,He=i,Ze=d,$e=s,Qe=Te,tr=x,er=B,rr=Ke,nr={},or="Object already initialized",ur=He.TypeError,ir=He.WeakMap;if(Je||er.state){var ar=er.state||(er.state=new ir),cr=Ze(ar.get),sr=Ze(ar.has),fr=Ze(ar.set);Ce=function(t,e){if(sr(ar,t))throw new ur(or);return e.facade=t,fr(ar,t,e),e},Fe=function(t){return cr(ar,t)||{}},Ue=function(t){return sr(ar,t)}}else{var lr=rr("state");nr[lr]=!0,Ce=function(t,e){if(tr(t,lr))throw new ur(or);return e.facade=t,Qe(t,lr,e),e},Fe=function(t){return tr(t,lr)?t[lr]:{}},Ue=function(t){return tr(t,lr)}}var yr={set:Ce,get:Fe,has:Ue,enforce:function(t){return Ue(t)?Fe(t):Ce(t,{})},getterFor:function(t){return function(e){var r;if(!$e(e)||(r=Fe(e)).type!==t)throw ur("Incompatible receiver, "+t+" required");return r}}},hr=n,vr=a,pr=x,dr=Tt.f,wr=Ve.CONFIGURABLE,mr=De,gr=yr.enforce,kr=yr.get,br=!hr((function(){return 8!==dr((function(){}),"length",{value:8}).length})),Rr=String(String).split("String"),xr=Se.exports=function(t,e,r){"Symbol("===String(e).slice(0,7)&&(e="["+String(e).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(e="get "+e),r&&r.setter&&(e="set "+e),(!pr(t,"name")||wr&&t.name!==e)&&dr(t,"name",{value:e,configurable:!0}),br&&r&&pr(r,"arity")&&t.length!==r.arity&&dr(t,"length",{value:r.arity});var n=gr(t);return pr(n,"source")||(n.source=Rr.join("string"==typeof e?e:"")),t};Function.prototype.toString=xr((function(){return vr(this)&&kr(this).source||mr(this)}),"toString");var _r,Or,Tr,Sr=i,Ar=a,Mr=Te,Br=Se.exports,Pr=S,zr=!n((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),Vr=i,Ir=x,jr=a,Er=k,Cr=zr,Fr=Ke("IE_PROTO"),Ur=Vr.Object,Dr=Ur.prototype,Xr=Cr?Ur.getPrototypeOf:function(t){var e=Er(t);if(Ir(e,Fr))return e[Fr];var r=e.constructor;return jr(r)&&e instanceof r?r.prototype:e instanceof Ur?Dr:null},Lr=i,Wr=a,Nr=Lr.String,Gr=Lr.TypeError,Yr=d,qr=Ct,Kr=function(t){if("object"==typeof t||Wr(t))return t;throw Gr("Can't set "+Nr(t)+" as a prototype")},Jr=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,r={};try{(t=Yr(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),e=r instanceof Array}catch(t){}return function(r,n){return qr(r),Kr(n),e?t(r,n):r.__proto__=n,r}}():void 0),Hr=r,Zr=o,$r=i,Qr=a,tn=s,en=x,rn=xt,nn=Ot,on=Te,un=function(t,e,r,n){var o=!!n&&!!n.unsafe,u=!!n&&!!n.enumerable,i=!!n&&!!n.noTargetGet,a=n&&void 0!==n.name?n.name:e;return Ar(r)&&Br(r,a,n),t===Sr?(u?t[e]=r:Pr(e,r),t):(o?!i&&t[e]&&(u=!0):delete t[e],u?t[e]=r:Mr(t,e,r),t)},an=Tt.f,cn=Xt,sn=Xr,fn=Jr,ln=st,yn=F,hn=$r.Int8Array,vn=hn&&hn.prototype,pn=$r.Uint8ClampedArray,dn=pn&&pn.prototype,wn=hn&&sn(hn),mn=vn&&sn(vn),gn=Object.prototype,kn=$r.TypeError,bn=ln("toStringTag"),Rn=yn("TYPED_ARRAY_TAG"),xn=yn("TYPED_ARRAY_CONSTRUCTOR"),_n=Hr&&!!fn&&"Opera"!==rn($r.opera),On=!1,Tn={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Sn={BigInt64Array:8,BigUint64Array:8},An=function(t){if(!tn(t))return!1;var e=rn(t);return en(Tn,e)||en(Sn,e)};for(_r in Tn)(Tr=(Or=$r[_r])&&Or.prototype)?on(Tr,xn,Or):_n=!1;for(_r in Sn)(Tr=(Or=$r[_r])&&Or.prototype)&&on(Tr,xn,Or);if((!_n||!Qr(wn)||wn===Function.prototype)&&(wn=function(){throw kn("Incorrect invocation")},_n))for(_r in Tn)$r[_r]&&fn($r[_r],wn);if((!_n||!mn||mn===gn)&&(mn=wn.prototype,_n))for(_r in Tn)$r[_r]&&fn($r[_r].prototype,mn);if(_n&&sn(dn)!==mn&&fn(dn,mn),Zr&&!en(mn,bn))for(_r in On=!0,an(mn,bn,{get:function(){return tn(this)?this[Rn]:void 0}}),Tn)$r[_r]&&on($r[_r],Rn,_r);var Mn={NATIVE_ARRAY_BUFFER_VIEWS:_n,TYPED_ARRAY_CONSTRUCTOR:xn,TYPED_ARRAY_TAG:On&&Rn,aTypedArray:function(t){if(An(t))return t;throw kn("Target is not a typed array")},aTypedArrayConstructor:function(t){if(Qr(t)&&(!fn||cn(wn,t)))return t;throw kn(nn(t)+" is not a typed array constructor")},exportTypedArrayMethod:function(t,e,r,n){if(Zr){if(r)for(var o in Tn){var u=$r[o];if(u&&en(u.prototype,t))try{delete u.prototype[t]}catch(r){try{u.prototype[t]=e}catch(t){}}}mn[t]&&!r||un(mn,t,r?e:_n&&vn[t]||e,n)}},exportTypedArrayStaticMethod:function(t,e,r){var n,o;if(Zr){if(fn){if(r)for(n in Tn)if((o=$r[n])&&en(o,t))try{delete o[t]}catch(t){}if(wn[t]&&!r)return;try{return un(wn,t,r?e:_n&&wn[t]||e)}catch(t){}}for(n in Tn)!(o=$r[n])||o[t]&&!r||un(o,t,e)}},isView:function(t){if(!tn(t))return!1;var e=rn(t);return"DataView"===e||en(Tn,e)||en(Sn,e)},isTypedArray:An,TypedArray:wn,TypedArrayPrototype:mn},Bn=Zt,Pn=f,zn=d(d.bind),Vn=d,In=n,jn=pt,En=i.Object,Cn=Vn("".split),Fn=In((function(){return!En("z").propertyIsEnumerable(0)}))?function(t){return"String"==jn(t)?Cn(t,""):En(t)}:En,Un=Math.ceil,Dn=Math.floor,Xn=function(t){var e=+t;return e!=e||0===e?0:(e>0?Dn:Un)(e)},Ln=Math.min,Wn=function(t){return t>0?Ln(Xn(t),9007199254740991):0},Nn=pt,Gn=Array.isArray||function(t){return"Array"==Nn(t)},Yn=d,qn=n,Kn=a,Jn=xt,Hn=De,Zn=function(){},$n=[],Qn=L("Reflect","construct"),to=/^\s*(?:class|function)\b/,eo=Yn(to.exec),ro=!to.exec(Zn),no=function(t){if(!Kn(t))return!1;try{return Qn(Zn,$n,t),!0}catch(t){return!1}},oo=function(t){if(!Kn(t))return!1;switch(Jn(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ro||!!eo(to,Hn(t))}catch(t){return!0}};oo.sham=!0;var uo=!Qn||qn((function(){var t;return no(no.call)||!no(Object)||!no((function(){t=!0}))||t}))?oo:no,io=i,ao=Gn,co=uo,so=s,fo=st("species"),lo=io.Array,yo=function(t){var e;return ao(t)&&(e=t.constructor,(co(e)&&(e===lo||ao(e.prototype))||so(e)&&null===(e=e[fo]))&&(e=void 0)),void 0===e?lo:e},ho=function(t,e){return Bn(t),void 0===e?t:Pn?zn(t,e):function(){return t.apply(e,arguments)}},vo=Fn,po=k,wo=function(t){return Wn(t.length)},mo=function(t,e){return new(yo(t))(0===e?0:e)},go=d([].push),ko=function(t){var e=1==t,r=2==t,n=3==t,o=4==t,u=6==t,i=7==t,a=5==t||u;return function(c,s,f,l){for(var y,h,v=po(c),p=vo(v),d=ho(s,f),w=wo(p),m=0,g=l||mo,k=e?g(c,w):r||i?g(c,0):void 0;w>m;m++)if((a||m in p)&&(h=d(y=p[m],m,v),t))if(e)k[m]=h;else if(h)switch(t){case 3:return!0;case 5:return y;case 6:return m;case 2:go(k,y)}else switch(t){case 4:return!1;case 7:go(k,y)}return u?-1:n||o?o:k}},bo={forEach:ko(0),map:ko(1),filter:ko(2),some:ko(3),every:ko(4),find:ko(5),findIndex:ko(6),filterReject:ko(7)},Ro=uo,xo=Ot,_o=i.TypeError,Oo=Ct,To=function(t){if(Ro(t))return t;throw _o(xo(t)+" is not a constructor")},So=st("species"),Ao=function(t,e){var r,n=Oo(t).constructor;return void 0===n||null==(r=Oo(n)[So])?e:To(r)},Mo=Mn.TYPED_ARRAY_CONSTRUCTOR,Bo=Mn.aTypedArrayConstructor,Po=bo.map,zo=function(t){return Bo(Ao(t,t[Mo]))},Vo=Mn.aTypedArray;(0,Mn.exportTypedArrayMethod)("map",(function(t){return Po(Vo(this),t,arguments.length>1?arguments[1]:void 0,(function(t,e){return new(zo(t))(e)}))}));var Io=o,jo=Ve.EXISTS,Eo=d,Co=Tt.f,Fo=Function.prototype,Uo=Eo(Fo.toString),Do=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Xo=Eo(Do.exec);function Lo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Wo(t){for(var e=1;e")}},{key:"parseTypeList",value:function(){var t=this.reader.parseTypeList();return["".concat(this.type,":").concat(t.length)].concat(t)}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.ArrayReader"===t}},{key:"hasSubType",value:function(){return!0}}])}(eu);function uu(t,e){if(!t||"object"!==No(t))throw new Error("Invalid Data!");for(var r=[],n=t.length,o=0;o>(t>>3&30)&3)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.CharReader":case"System.Char":return!0;default:return!1}}}])}(eu);var mu=function(t){function e(t,r){var n,o,u,i;if(Go(this,e),null==t||null==r)throw new Error("Cannot create instance of DictionaryReader without Key and Value.");return o=this,u=Ho(u=e),(n=tu(o,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(u,i||[],Ho(o).constructor):u.apply(o,i))).key=t,n.value=r,n}return Jo(e,t),qo(e,[{key:"read",value:function(t,e){for(var r={},n=(new nu).read(t),o=0;o")}},{key:"parseTypeList",value:function(){return[this.type].concat(this.key.parseTypeList(),this.value.parseTypeList())}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.DictionaryReader"===t}},{key:"hasSubType",value:function(){return!0}}])}(eu);function gu(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var ku=function(t){function e(){return Go(this,e),gu(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t){return t.readDouble()}},{key:"write",value:function(t,e,r){this.writeIndex(t,r),t.writeDouble(e)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.DoubleReader":case"System.Double":return!0;default:return!1}}}])}(eu);function bu(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var Ru=function(t){function e(){return Go(this,e),bu(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t){var e=(new nu).read(t),r=t.read(e);return{export:{type:this.type,data:r}}}},{key:"write",value:function(t,e,r){this.writeIndex(t,r);var n=e.export.data;(new nu).write(t,n.byteLength,null),t.concat(n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.EffectReader":case"Microsoft.Xna.Framework.Graphics.Effect":return!0;default:return!1}}}])}(eu);function xu(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var _u=function(t){function e(){return Go(this,e),xu(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t){return t.readInt32()}},{key:"write",value:function(t,e,r){this.writeIndex(t,r),t.writeInt32(e)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.Int32Reader":case"Microsoft.Xna.Framework.Content.EnumReader":case"System.Int32":return!0;default:return!1}}}])}(eu);var Ou=function(t){function e(t){var r,n,o,u;return Go(this,e),n=this,o=Ho(o=e),(r=tu(n,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(o,u||[],Ho(n).constructor):o.apply(n,u))).reader=t,r}return Jo(e,t),qo(e,[{key:"read",value:function(t,e){for(var r=(new nu).read(t),n=[],o=0;o")}},{key:"parseTypeList",value:function(){var t=this.reader.parseTypeList();return["".concat(this.type,":").concat(t.length)].concat(t)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.ListReader":case"System.Collections.Generic.List":return!0;default:return!1}}},{key:"hasSubType",value:function(){return!0}}])}(eu);var Tu=function(t){function e(t){var r,n,o,u;return Go(this,e),n=this,o=Ho(o=e),(r=tu(n,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(o,u||[],Ho(n).constructor):o.apply(n,u))).reader=t,r}return Jo(e,t),qo(e,[{key:"read",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=new pu,n=t.peekByte(1);return n?null===e||this.reader.isValueType()?(r.read(t),this.reader.read(t)):e.read(t):(r.read(t),null)}},{key:"write",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;new pu,null!==e?((null===r||this.reader.isValueType())&&t.writeByte(1),this.reader.write(t,e,this.reader.isValueType()?null:r)):t.writeByte(0)}},{key:"isValueType",value:function(){return!1}},{key:"type",get:function(){return"Nullable<".concat(this.reader.type,">")}},{key:"parseTypeList",value:function(){var t=this.reader.parseTypeList();return["".concat(this.type,":").concat(t.length)].concat(t)}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.NullableReader"===t}},{key:"hasSubType",value:function(){return!0}}])}(eu);function Su(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var Au=function(t){function e(){return Go(this,e),Su(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t){var e=new _u;return{x:e.read(t),y:e.read(t)}}},{key:"write",value:function(t,e,r){this.writeIndex(t,r);var n=new _u;n.write(t,e.x,null),n.write(t,e.y,null)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.PointReader":case"Microsoft.Xna.Framework.Point":return!0;default:return!1}}}])}(eu);var Mu=function(t){function e(t){var r,n,o,u;return Go(this,e),n=this,o=Ho(o=e),(r=tu(n,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(o,u||[],Ho(n).constructor):o.apply(n,u))).reader=t,r}return Jo(e,t),qo(e,[{key:"read",value:function(t,e){return this.reader.read(t,e)}},{key:"write",value:function(t,e,r){this.reader.write(t,e,this.reader.isValueType()?null:r)}},{key:"isValueType",value:function(){return!1}},{key:"type",get:function(){return"".concat(this.reader.type)}},{key:"parseTypeList",value:function(){return[].concat(this.reader.parseTypeList())}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.ReflectiveReader"===t}},{key:"hasSubType",value:function(){return!0}}])}(eu);function Bu(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var Pu=function(t){function e(){return Go(this,e),Bu(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t){var e=new _u;return{x:e.read(t),y:e.read(t),width:e.read(t),height:e.read(t)}}},{key:"write",value:function(t,e,r){this.writeIndex(t,r);var n=new _u;n.write(t,e.x,null),n.write(t,e.y,null),n.write(t,e.width,null),n.write(t,e.height,null)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.RectangleReader":case"Microsoft.Xna.Framework.Rectangle":return!0;default:return!1}}}])}(eu);function zu(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var Vu=function(t){function e(){return Go(this,e),zu(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t){return t.readSingle()}},{key:"write",value:function(t,e,r){this.writeIndex(t,r),t.writeSingle(e)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.SingleReader":case"System.Single":return!0;default:return!1}}}])}(eu),Iu=256;function ju(t,e,r,n){for(var o=Array(n),u=0;u1&&void 0!==arguments[1]?arguments[1]:1e-7,r=t.length,n=Array(r),o=Math.abs(e/r),u=Array(r),i=0;i=Math.abs(o);){var f=s[0][0],l=s[0][1],y=ju(f,l,Eu(t[f][f],t[l][l],t[f][l]),r);t=Fu(y,t),u=Uu(u,y),s=Cu(t)}for(var h=0;h0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;Go(this,t),this._values=[e,r,n]}return qo(t,[{key:"x",get:function(){return this._values[0]},set:function(t){this._values[0]=t}},{key:"y",get:function(){return this._values[1]},set:function(t){this._values[1]=t}},{key:"z",get:function(){return this._values[2]},set:function(t){this._values[2]=t}},{key:"length",get:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}},{key:"lengthSq",get:function(){return this.x*this.x+this.y*this.y+this.z*this.z}},{key:"normalized",get:function(){return 0===this.length?null:t.multScalar(this,1/this.length)}},{key:"colorInt",get:function(){return this._values.map((function(t){var e=parseInt(255*t+.5);return Math.max(Math.min(e,255),0)}))}},{key:"clone",value:function(){return new t(this.x,this.y,this.z)}},{key:"set",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;return this._values[0]=t,this._values[1]=e,this._values[2]=r,this}},{key:"toVec4",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Wu(this.x,this.y,this.z,t)}},{key:"addVector",value:function(t){return this._values[0]+=t.x,this._values[1]+=t.y,this._values[2]+=t.z,this}},{key:"addScaledVector",value:function(t,e){return this._values[0]+=t.x*e,this._values[1]+=t.y*e,this._values[2]+=t.z*e,this}},{key:"mult",value:function(t){return this._values[0]*=t,this._values[1]*=t,this._values[2]*=t,this}},{key:"multVector",value:function(t){return this._values[0]*=t.x,this._values[1]*=t.y,this._values[2]*=t.z,this}},{key:"clamp",value:function(t,e){var r=function(r){return t>r?t:e(r=t)?0:10&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e;Go(this,t),this._values=[e,r,n,o]}return qo(t,[{key:"x",get:function(){return this._values[0]},set:function(t){this._values[0]=t}},{key:"y",get:function(){return this._values[1]},set:function(t){this._values[1]=t}},{key:"z",get:function(){return this._values[2]},set:function(t){this._values[2]=t}},{key:"w",get:function(){return this._values[3]},set:function(t){this._values[3]=t}},{key:"length",get:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}},{key:"lengthSq",get:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}},{key:"normalized",get:function(){return 0===this.length?null:t.multScalar(this,1/this.length)}},{key:"xyz",get:function(){return new Lu(this.x,this.y,this.z)}},{key:"splatX",get:function(){return new t(this.x)}},{key:"splatY",get:function(){return new t(this.y)}},{key:"splatZ",get:function(){return new t(this.z)}},{key:"splatW",get:function(){return new t(this.w)}},{key:"clone",value:function(){return new t(this.x,this.y,this.z,this.w)}},{key:"set",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t;return this._values[0]=t,this._values[1]=e,this._values[2]=r,this._values[3]=n,this}},{key:"toVec3",value:function(){return this.xyz}},{key:"addVector",value:function(t){return this._values[0]+=t.x,this._values[1]+=t.y,this._values[2]+=t.z,this._values[3]+=t.w,this}},{key:"addScaledVector",value:function(t,e){return this._values[0]+=t.x*e,this._values[1]+=t.y*e,this._values[2]+=t.z*e,this._values[3]+=t.w*e,this}},{key:"subVector",value:function(t){return this._values[0]-=t.x,this._values[1]-=t.y,this._values[2]-=t.z,this._values[3]-=t.w,this}},{key:"mult",value:function(t){return this._values[0]*=t,this._values[1]*=t,this._values[2]*=t,this._values[3]*=t,this}},{key:"multVector",value:function(t){return this._values[0]*=t.x,this._values[1]*=t.y,this._values[2]*=t.z,this._values[3]*=t.w,this}},{key:"reciprocal",value:function(){return this._values[0]=1/this._values[0],this._values[1]=1/this._values[1],this._values[2]=1/this._values[2],this._values[3]=1/this._values[3],this}},{key:"clamp",value:function(t,e){var r=function(r){return t>r?t:et?0:1>8,n[o+2]=255&e,n[o+3]=e>>8;for(var u=0;u<4;u++)n[o+4+u]=r[4*u+0]|r[4*u+1]<<2|r[4*u+2]<<4|r[4*u+3]<<6}function $u(t,e,r,n,o){var u,i=Hu(t),a=Hu(e);if(i<=a)u=r.slice();else{var c=[a,i];i=c[0],a=c[1],u=r.map((function(t){return 0===t?1:1===t?0:t}))}Zu(i,a,u,n,o)}function Qu(t,e,r,n,o){var u,i=Hu(t),a=Hu(e);if(i=128||!o)){var y=this._remap[a],h=(e[4*i+3]+1)/256;this._weights[y]+=u?h:1,this._remap[i]=y;break}}else this._remap[i]=-1;for(var v=0;v=n?t:(n=i,u)}),0);return o+=n,u}));if(oa&&(u=r[s],a=f)}this.start=o.clampGrid().clone(),this.end=u.clampGrid().clone()}}}])}(ri),ui=function(t){function e(t){var r;Go(this,e);(r=ti(this,e,[t])).iterationCount=t.flags&Iu?8:1,r.bestError=1/0,r.metric=new Wu(1),0!=(32&r.flags)&&r.metric.set(.2126,.7152,.0722,0);var n=r.colors,o=n.points,u=n.weights;return r.principle=Nu(o,u),r.order=new Uint8Array(128),r.pointsWeights=[],r.xSum_wSum=new Wu(0),r}return Jo(e,t),qo(e,[{key:"constructOrdering",value:function(t,e){var r=this.makeOrder(t);return this.copyOrderToThisOrder(r,e),!!this.checkOrderUnique(r,e)&&(this.copyOrderWeight(r),!0)}},{key:"compress3",value:function(t,e){this.compressBase((function(t){var e=t[0],r=t[2],n=t[3],o=new Wu(.5,.5,.5,1/4),u=Wu.multiplyAdd(r,o,e),i=u.splatW,a=Wu.multiplyAdd(r,o,n);return{ax:u,aa:i,bx:a,bb:a.splatW,ab:Wu.multVector(r,o).splatW}}),(function(r,n,o){return $u(r,n,o,t,e)}),2)}},{key:"compress4",value:function(t,e){this.compressBase((function(t){var e=t[0],r=t[1],n=t[2],o=t[3],u=new Wu(1/3,1/3,1/3,1/9),i=new Wu(2/3,2/3,2/3,4/9),a=new Wu(2/9),c=Wu.multiplyAdd(n,u,Wu.multiplyAdd(r,i,e)),s=c.splatW,f=Wu.multiplyAdd(r,u,Wu.multiplyAdd(n,i,o));return{ax:c,aa:s,bx:f,bb:f.splatW,ab:Wu.multVector(a,Wu.add(r,n)).splatW}}),(function(r,n,o){return Qu(r,n,o,t,e)}),3)}},{key:"compressBase",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;this.constructOrdering(this.principle,0);var o={start:new Wu(0),end:new Wu(0),error:this.bestError,iteration:0,bestI:0,bestJ:0};3===n&&(o.bestK=0);for(var u=function(e,n){var u=t(e),i=r.computeOptimalPoints(u);return i.error2&&void 0!==arguments[2]?arguments[2]:2,n=this.colors.count,o=function(e,n,o){var u={bestI:e,bestJ:2===r?o:n,iteration:t};return 3===r&&(u.bestK=o),u},u=new Wu(0),i=0;i15?15:e}function ai(t,e,r,n){var o=ci(t,e,5),u=ci(t,e,7);o.error<=u.error?function(t,e,r){var n=t.min,o=t.max,u=t.indices;if(n>o){fi(o,n,u.map((function(t){return 0===t?1:1===t?0:t<=5?7-t:t})),e,r)}else fi(n,o,u,e,r)}(o,r,n):function(t,e,r){var n=t.min,o=t.max,u=t.indices;if(n>o){fi(o,n,u.map((function(t){return 0===t?1:1===t?0:9-t})),e,r)}else fi(n,o,u,e,r)}(u,r,n)}function ci(t,e,r){var n=function(t,e,r){for(var n=255,o=0,u=0;u<16;u++){if(0!=(e&1<o&&(o=i)):(io&&(o=i))}}n>o&&(n=o);o-n>8*f&255;n[i]=l,i++}}}function li(t){var e=t>>11&31,r=t>>5&63,n=31&t;return[e<<3|e>>2,r<<2|r>>4,n<<3|n>>2,255]}function yi(t,e,r){var n=t.map((function(t,n){return Math.floor(t*(1-r)+e[n]*r)}));return n[3]=255,n}function hi(t,e,r,n){for(var o=function(t,e,r){var n=t[e]|t[e+1]<<8,o=t[e+2]|t[e+3]<<8,u=li(n),i=li(o);return[u,i,yi(u,i,r&&n<=o?.5:1/3),r&&n<=o?[0,0,0,0]:yi(u,i,2/3)]}(e,r,n),u=function(t,e){for(var r=e+4,n=new Uint8Array(16),o=0;o<4;o++){var u=t[r+o];n[4*o+0]=3&u,n[4*o+1]=u>>2&3,n[4*o+2]=u>>4&3,n[4*o+3]=u>>6&3}return n}(e,r),i=0;i<16;i++)for(var a=0;a<4;a++)t[4*i+a]=o[u[i]][a]}function vi(t){for(var e=0;e<4;e++)for(var r=0;r<4;r++)t(r,e)}function pi(t){var e=7&t,r=280&t,n=96&t;return 2!=e&&4!=e&&(e=1),16!=r&&r!=Iu&&(r=8),64!=n&&(n=32),e|r|n|128&t}function di(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.x,o=void 0===n?0:n,u=r.y,i=void 0===u?0:u,a=r.width,c=void 0===a?0:a,s=r.height,f=void 0===s?0:s,l=0;vi((function(r,n){var u=o+r,a=i+n;if(u>4}}(t,e,r):0!=(4&n)&&function(t,e,r){for(var n=e[r+0],o=e[r+1],u=si(n,o,n<=o?5:7),i=new Uint8Array(16),a=0,c=2,s=0;s<2;s++){for(var f=0,l=0;l<3;l++)f|=e[r+c]<<8*l,c++;for(var y=0;y<8;y++){var h=f>>3*y&7;i[a]=h,a++}}for(var v=0;v<16;++v)t[4*v+3]=u[i[v]]}(t,e,r)}function gi(t,e,r,n,o){var u=0!=(1&(o=pi(o)))?8:16,i=0;!function(t,e,r){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},r=e.x,n=void 0===r?0:r,o=e.y,u=void 0===o?0:o,i=e.width,a=void 0===i?0:i,c=e.height,s=void 0===c?0:c,f=new Uint8Array(64),l=0,y=0;return vi((function(e,r){var o=n+e,i=u+r;if(o>r&Math.pow(2,e)-1}function Ti(t,e,r,n){var o=Math.round(t/255*31),u=Math.round(e/255*31),i=Math.round(r/255*31);return Math.round(n/255)<<15|o<<10|u<<5|i}function Si(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var Ai=function(t){function e(){return Go(this,e),Si(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t){var e=new _u,r=new nu,n=e.read(t),o=r.read(t),u=r.read(t),i=r.read(t),a=null,c=null;i>1&&console.warn("Found mipcount of ".concat(i,", only the first will be used."));var s=r.read(t);o*u*4>s&&(a=o>>16&65535,c=u>>16&65535,(o&=65535)*(u&=65535)*4!==s&&console.warn("invalid width & height! ".concat(o," x ").concat(u)));var f=t.read(s);if(4==n)f=_i(f,o,u,ki);else if(5==n)f=_i(f,o,u,bi);else if(6==n)f=_i(f,o,u,Ri);else if(2==n)f=function(t){for(var e,r,n,o=new Uint8Array(t),u=o.length/2,i=new Uint8Array(4*u),a=0;a>15&1,[(n=[Oi(e,5,10),Oi(e,5,5),Oi(e,5,0)].map((function(t){return t<<3|t>>2})))[0],n[1],n[2],255*r]);i[4*a]=c[0],i[4*a+1]=c[1],i[4*a+2]=c[2],i[4*a+3]=c[3]}return i}(f);else if(0!=n)throw new Error("Non-implemented Texture2D format type (".concat(n,") found."));f instanceof ArrayBuffer&&(f=new Uint8Array(f));for(var l=0;l>8}return n}(a)),o.write(t,a.length,null),t.concat(a)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.Texture2DReader"===t}}])}(eu);function Mi(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var Bi=function(t){function e(){return Go(this,e),Mi(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t){var e=new Vu;return{x:e.read(t),y:e.read(t),z:e.read(t)}}},{key:"write",value:function(t,e,r){this.writeIndex(t,r);var n=new Vu;n.write(t,e.x,null),n.write(t,e.y,null),n.write(t,e.z,null)}}],[{key:"isTypeOf",value:function(t){switch(t){case"Microsoft.Xna.Framework.Content.Vector3Reader":case"Microsoft.Xna.Framework.Vector3":return!0;default:return!1}}}])}(eu);function Pi(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var zi=function(t){function e(){return Go(this,e),Pi(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t,e){var r=new _u,n=new Vu,o=new Tu(new wu);return{texture:e.read(t),glyphs:e.read(t),cropping:e.read(t),characterMap:e.read(t),verticalLineSpacing:r.read(t),horizontalSpacing:n.read(t),kerning:e.read(t),defaultCharacter:o.read(t)}}},{key:"write",value:function(t,e,r){var n=new _u,o=new wu,u=new Vu,i=new Tu(o),a=new Ai,c=new Ou(new Pu),s=new Ou(o),f=new Ou(new Bi);this.writeIndex(t,r);try{a.write(t,e.texture,r),t.alloc(1e5),c.write(t,e.glyphs,r),c.write(t,e.cropping,r),s.write(t,e.characterMap,r),n.write(t,e.verticalLineSpacing,null),u.write(t,e.horizontalSpacing,null),f.write(t,e.kerning,r),i.write(t,e.defaultCharacter,null)}catch(t){throw t}}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(t){return"Microsoft.Xna.Framework.Content.SpriteFontReader"===t}},{key:"parseTypeList",value:function(){return["SpriteFont","Texture2D","List","Rectangle","List","Rectangle","List","Char",null,null,"List","Vector3","Nullable","Char"]}}])}(eu);function Vi(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var Ii=function(t){function e(){return Go(this,e),Vi(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t){var e=(new _u).read(t),r=t.read(e);return{export:{type:this.type,data:r}}}},{key:"write",value:function(t,e,r){this.writeIndex(t,r);var n=e.export.data;(new _u).write(t,n.byteLength,null),t.concat(n)}},{key:"isValueType",value:function(){return!1}}],[{key:"isTypeOf",value:function(t){return"xTile.Pipeline.TideReader"===t}}])}(eu);function ji(t,e,r){return e=Ho(e),tu(t,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){return!1}}()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}var Ei=function(t){function e(){return Go(this,e),ji(this,e,arguments)}return Jo(e,t),qo(e,[{key:"read",value:function(t){var e=new _u,r=new nu,n=e.read(t),o=r.read(t),u=r.read(t),i=r.read(t);i>1&&console.warn("Found mipcount of ".concat(i,", only the first will be used."));var a=r.read(t),c=t.read(a);if(c=new Uint8Array(c),0!=n)throw new Error("Compressed texture format is not supported!");for(var s=0;s"); } - parseTypeList() { - return [this.type, ...this.reader.parseTypeList()]; + const inBlock = this.reader.parseTypeList(); + return ["".concat(this.type, ":").concat(inBlock.length), ...inBlock]; } - } const UTF16_BITES = [0xD800, 0xDC00]; const UTF16_MASK = 0b1111111111; - function UTF16Decode(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; return ((codeSet[0] & UTF16_MASK) << 10) + (codeSet[1] & UTF16_MASK) + 0x10000; } - function stringToUnicode(str) { const utf16Map = Array.from({ length: str.length }, (_, i) => str.charCodeAt(i)); const result = []; let index = 0; - while (index < str.length) { let code = utf16Map[index]; - if ((UTF16_BITES[0] & code) !== UTF16_BITES[0]) { result.push(code); index++; @@ -169,10 +138,8 @@ index += 2; } } - return result; } - function UTF8Length(str) { const codes = stringToUnicode(str); return codes.reduce((sum, unicode) => { @@ -189,28 +156,23 @@ case 'Microsoft.Xna.Framework.Content.StringReader': case 'System.String': return true; - default: return false; } } - read(buffer) { let length = buffer.read7BitNumber(); return buffer.readString(length); } - write(buffer, string, resolver) { this.writeIndex(buffer, resolver); const size = UTF8Length(string); buffer.write7BitNumber(size); buffer.writeString(string); } - isValueType() { return false; } - } class BmFontReader extends BaseReader { @@ -218,12 +180,10 @@ switch (type) { case 'BmFont.XmlSourceReader': return true; - default: return false; } } - read(buffer) { const stringReader = new StringReader(); const xml = stringReader.read(buffer); @@ -234,17 +194,14 @@ } }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const stringReader = new StringReader(); stringReader.write(buffer, content.export.data, null); } - isValueType() { return false; } - } class BooleanReader extends BaseReader { @@ -253,21 +210,17 @@ case 'Microsoft.Xna.Framework.Content.BooleanReader': case 'System.Boolean': return true; - default: return false; } } - read(buffer) { return Boolean(buffer.readInt()); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeByte(content); } - } class CharReader extends BaseReader { @@ -276,27 +229,21 @@ case 'Microsoft.Xna.Framework.Content.CharReader': case 'System.Char': return true; - default: return false; } } - read(buffer) { let charSize = this._getCharSize(buffer.peekInt()); - return buffer.readString(charSize); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeString(content); } - _getCharSize(byte) { return (0xE5000000 >> (byte >> 3 & 0x1e) & 3) + 1; } - } class DictionaryReader extends BaseReader { @@ -304,59 +251,47 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.DictionaryReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(key, value) { if (key == undefined || value == undefined) throw new Error('Cannot create instance of DictionaryReader without Key and Value.'); super(); this.key = key; this.value = value; } - read(buffer, resolver) { let dictionary = {}; const uint32Reader = new UInt32Reader(); const size = uint32Reader.read(buffer); - for (let i = 0; i < size; i++) { let key = this.key.isValueType() ? this.key.read(buffer) : resolver.read(buffer); let value = this.value.isValueType() ? this.value.read(buffer) : resolver.read(buffer); dictionary[key] = value; } - return dictionary; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeUInt32(Object.keys(content).length); - for (let key of Object.keys(content)) { this.key.write(buffer, key, this.key.isValueType() ? null : resolver); this.value.write(buffer, content[key], this.value.isValueType() ? null : resolver); } } - isValueType() { return false; } - get type() { return "Dictionary<".concat(this.key.type, ",").concat(this.value.type, ">"); } - parseTypeList() { return [this.type, ...this.key.parseTypeList(), ...this.value.parseTypeList()]; } - } class DoubleReader extends BaseReader { @@ -365,21 +300,17 @@ case 'Microsoft.Xna.Framework.Content.DoubleReader': case 'System.Double': return true; - default: return false; } } - read(buffer) { return buffer.readDouble(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeDouble(content); } - } class EffectReader extends BaseReader { @@ -388,12 +319,10 @@ case 'Microsoft.Xna.Framework.Content.EffectReader': case 'Microsoft.Xna.Framework.Graphics.Effect': return true; - default: return false; } } - read(buffer) { const uint32Reader = new UInt32Reader(); const size = uint32Reader.read(buffer); @@ -405,7 +334,6 @@ } }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const data = content.export.data; @@ -413,34 +341,29 @@ uint32Reader.write(buffer, data.byteLength, null); buffer.concat(data); } - isValueType() { return false; } - } class Int32Reader extends BaseReader { static isTypeOf(type) { switch (type) { case 'Microsoft.Xna.Framework.Content.Int32Reader': + case 'Microsoft.Xna.Framework.Content.EnumReader': case 'System.Int32': return true; - default: return false; } } - read(buffer) { return buffer.readInt32(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeInt32(content); } - } class ListReader extends BaseReader { @@ -449,56 +372,45 @@ case 'Microsoft.Xna.Framework.Content.ListReader': case 'System.Collections.Generic.List': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer, resolver) { const uint32Reader = new UInt32Reader(); const size = uint32Reader.read(buffer); const list = []; - for (let i = 0; i < size; i++) { const value = this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); list.push(value); } - return list; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const uint32Reader = new UInt32Reader(); uint32Reader.write(buffer, content.length, null); - - for (let data of Object.values(content)) { + for (let data of content) { this.reader.write(buffer, data, this.reader.isValueType() ? null : resolver); } } - isValueType() { return false; } - get type() { return "List<".concat(this.reader.type, ">"); } - parseTypeList() { - return [this.type, ...this.reader.parseTypeList()]; + const inBlock = this.reader.parseTypeList(); + return ["".concat(this.type, ":").concat(inBlock.length), ...inBlock]; } - } class NullableReader extends BaseReader { @@ -506,65 +418,78 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.NullableReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer) { let resolver = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; const booleanReader = new BooleanReader(); const hasValue = buffer.peekByte(1); - if (!hasValue) { booleanReader.read(buffer); return null; } - - if (resolver === null) { + if (resolver === null || this.reader.isValueType()) { booleanReader.read(buffer); return this.reader.read(buffer); } - - return this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); + return resolver.read(buffer); } - write(buffer) { let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let resolver = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - if (content === null) { buffer.writeByte(0); return; } - - if (resolver === null) buffer.writeByte(1); + if (resolver === null || this.reader.isValueType()) buffer.writeByte(1); this.reader.write(buffer, content, this.reader.isValueType() ? null : resolver); } - isValueType() { return false; } - get type() { return "Nullable<".concat(this.reader.type, ">"); } - parseTypeList() { const inBlock = this.reader.parseTypeList(); return ["".concat(this.type, ":").concat(inBlock.length), ...inBlock]; } + } + class PointReader extends BaseReader { + static isTypeOf(type) { + switch (type) { + case 'Microsoft.Xna.Framework.Content.PointReader': + case 'Microsoft.Xna.Framework.Point': + return true; + default: + return false; + } + } + read(buffer) { + const int32Reader = new Int32Reader(); + const x = int32Reader.read(buffer); + const y = int32Reader.read(buffer); + return { + x, + y + }; + } + write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + const int32Reader = new Int32Reader(); + int32Reader.write(buffer, content.x, null); + int32Reader.write(buffer, content.y, null); + } } class ReflectiveReader extends BaseReader { @@ -572,42 +497,33 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.ReflectiveReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer, resolver) { const reflective = this.reader.read(buffer, resolver); return reflective; } - write(buffer, content, resolver) { this.reader.write(buffer, content, this.reader.isValueType() ? null : resolver); } - isValueType() { return false; } - get type() { return "".concat(this.reader.type); } - parseTypeList() { return [...this.reader.parseTypeList()]; } - } class RectangleReader extends BaseReader { @@ -616,12 +532,10 @@ case 'Microsoft.Xna.Framework.Content.RectangleReader': case 'Microsoft.Xna.Framework.Rectangle': return true; - default: return false; } } - read(buffer) { const int32Reader = new Int32Reader(); const x = int32Reader.read(buffer); @@ -635,7 +549,6 @@ height }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const int32Reader = new Int32Reader(); @@ -644,7 +557,6 @@ int32Reader.write(buffer, content.width, null); int32Reader.write(buffer, content.height, null); } - } class SingleReader extends BaseReader { @@ -653,21 +565,17 @@ case 'Microsoft.Xna.Framework.Content.SingleReader': case 'System.Single': return true; - default: return false; } } - read(buffer) { return buffer.readSingle(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeSingle(content); } - } const kDxt1 = 1 << 0; @@ -682,17 +590,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } - return keys; } - function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; @@ -702,10 +607,8 @@ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } - return target; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { @@ -717,7 +620,6 @@ } else { obj[key] = value; } - return obj; } @@ -725,20 +627,16 @@ let Mat = [[Math.cos(theta), Math.sin(theta)], [-Math.sin(theta), Math.cos(theta)]]; return Mat; } - function Rij(k, l, theta, N) { let Mat = Array(N); - for (let i = 0; i < N; i++) { Mat[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Mat[i][j] = (i === j) * 1.0; } } - let Rotij = Rot(theta); Mat[k][k] = Rotij[0][0]; Mat[l][l] = Rotij[1][1]; @@ -746,25 +644,20 @@ Mat[l][k] = Rotij[1][0]; return Mat; } - function getTheta(aii, ajj, aij) { let th = 0.0; let denom = ajj - aii; - if (Math.abs(denom) <= 1E-12) { th = Math.PI / 4.0; } else { th = 0.5 * Math.atan(2.0 * aij / (ajj - aii)); } - return th; } - function getAij(Mij) { let N = Mij.length; let maxMij = 0.0; let maxIJ = [0, 1]; - for (let i = 0; i < N; i++) { for (let j = i + 1; j < N; j++) { if (Math.abs(maxMij) <= Math.abs(Mij[i][j])) { @@ -773,22 +666,17 @@ } } } - return [maxIJ, maxMij]; } - function unitary(U, H) { let N = U.length; let Mat = Array(N); - for (let i = 0; i < N; i++) { Mat[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Mat[i][j] = 0; - for (let k = 0; k < N; k++) { for (let l = 0; l < N; l++) { Mat[i][j] = Mat[i][j] + U[k][i] * H[k][l] * U[l][j]; @@ -796,50 +684,39 @@ } } } - return Mat; } - function AxB(A, B) { let N = A.length; let Mat = Array(N); - for (let i = 0; i < N; i++) { Mat[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Mat[i][j] = 0; - for (let k = 0; k < N; k++) { Mat[i][j] = Mat[i][j] + A[i][k] * B[k][j]; } } } - return Mat; } - function eigens(Hij) { let convergence = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1E-7; let N = Hij.length; let Ei = Array(N); let e0 = Math.abs(convergence / N); let Sij = Array(N); - for (let i = 0; i < N; i++) { Sij[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Sij[i][j] = (i === j) * 1.0; } } - let Vab = getAij(Hij); - while (Math.abs(Vab[1]) >= Math.abs(e0)) { let i = Vab[0][0]; let j = Vab[0][1]; @@ -849,14 +726,11 @@ Sij = AxB(Sij, Gij); Vab = getAij(Hij); } - for (let i = 0; i < N; i++) { Ei[i] = Hij[i][i]; } - return sorting(Ei, Sij); } - function sorting(values, vectors) { let eigsCount = values.length; vectors.length; @@ -884,7 +758,6 @@ }); return [sortedValues, sortedVectors]; } - function dominentPrincipalVector(matrix) { let [, [dominentVector]] = eigens(matrix); return dominentVector; @@ -897,57 +770,44 @@ let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; this._values = [x, y, z]; } - get x() { return this._values[0]; } - get y() { return this._values[1]; } - get z() { return this._values[2]; } - set x(value) { this._values[0] = value; } - set y(value) { this._values[1] = value; } - set z(value) { this._values[2] = value; } - get length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } - get lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z; } - get normalized() { if (this.length === 0) return null; return Vec3.multScalar(this, 1 / this.length); } - get colorInt() { const floatToInt = value => { const result = parseInt(value * 255 + 0.5); return Math.max(Math.min(result, 255), 0); }; - return this._values.map(floatToInt); } - clone() { return new Vec3(this.x, this.y, this.z); } - set(x) { let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x; let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; @@ -956,99 +816,79 @@ this._values[2] = z; return this; } - toVec4() { let w = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return new Vec4(this.x, this.y, this.z, w); } - addVector(v) { this._values[0] += v.x; this._values[1] += v.y; this._values[2] += v.z; return this; } - addScaledVector(v, scalar) { this._values[0] += v.x * scalar; this._values[1] += v.y * scalar; this._values[2] += v.z * scalar; return this; } - mult(scalar) { this._values[0] *= scalar; this._values[1] *= scalar; this._values[2] *= scalar; return this; } - multVector(vec) { this._values[0] *= vec.x; this._values[1] *= vec.y; this._values[2] *= vec.z; return this; } - clamp(min, max) { const clamper = v => min > v ? min : max < v ? max : v; - this._values[0] = clamper(this._values[0]); this._values[1] = clamper(this._values[1]); this._values[2] = clamper(this._values[2]); return this; } - clampGrid() { const clamper = v => 0 > v ? 0 : 1 < v ? 1 : v; - const gridClamper = (value, grid) => Math.trunc(clamper(value) * grid + 0.5) / grid; - this._values[0] = gridClamper(this._values[0], 31); this._values[1] = gridClamper(this._values[1], 63); this._values[2] = gridClamper(this._values[2], 31); return this; } - normalize() { this._values[0] /= this.length; this._values[1] /= this.length; this._values[2] /= this.length; return this; } - toString() { return "Vec3( ".concat(this._values.join(", "), " )"); } - static add(a, b) { return new Vec3(a.x + b.x, a.y + b.y, a.z + b.z); } - static sub(a, b) { return new Vec3(a.x - b.x, a.y - b.y, a.z - b.z); } - static dot(a, b) { return a.x * b.x + a.y * b.y + a.z * b.z; } - static multScalar(a, scalar) { return new Vec3(a.x * scalar, a.y * scalar, a.z * scalar); } - static multVector(a, b) { return new Vec3(a.x * b.x, a.y * b.y, a.z * b.z); } - static interpolate(a, b, p) { let a_ = Vec3.multScalar(a, 1 - p); let b_ = Vec3.multScalar(b, p); return Vec3.add(a_, b_); } - } - class Vec4 { constructor() { let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; @@ -1057,76 +897,58 @@ let w = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : x; this._values = [x, y, z, w]; } - get x() { return this._values[0]; } - get y() { return this._values[1]; } - get z() { return this._values[2]; } - get w() { return this._values[3]; } - set x(value) { this._values[0] = value; } - set y(value) { this._values[1] = value; } - set z(value) { this._values[2] = value; } - set w(value) { this._values[3] = value; } - get length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); } - get lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; } - get normalized() { if (this.length === 0) return null; return Vec4.multScalar(this, 1 / this.length); } - get xyz() { return new Vec3(this.x, this.y, this.z); } - get splatX() { return new Vec4(this.x); } - get splatY() { return new Vec4(this.y); } - get splatZ() { return new Vec4(this.z); } - get splatW() { return new Vec4(this.w); } - clone() { return new Vec4(this.x, this.y, this.z, this.w); } - set(x) { let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x; let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; @@ -1137,11 +959,9 @@ this._values[3] = w; return this; } - toVec3() { return this.xyz; } - addVector(v) { this._values[0] += v.x; this._values[1] += v.y; @@ -1149,7 +969,6 @@ this._values[3] += v.w; return this; } - addScaledVector(v, scalar) { this._values[0] += v.x * scalar; this._values[1] += v.y * scalar; @@ -1157,7 +976,6 @@ this._values[3] += v.w * scalar; return this; } - subVector(v) { this._values[0] -= v.x; this._values[1] -= v.y; @@ -1165,7 +983,6 @@ this._values[3] -= v.w; return this; } - mult(scalar) { this._values[0] *= scalar; this._values[1] *= scalar; @@ -1173,7 +990,6 @@ this._values[3] *= scalar; return this; } - multVector(vec) { this._values[0] *= vec.x; this._values[1] *= vec.y; @@ -1181,7 +997,6 @@ this._values[3] *= vec.w; return this; } - reciprocal() { this._values[0] = 1 / this._values[0]; this._values[1] = 1 / this._values[1]; @@ -1189,29 +1004,23 @@ this._values[3] = 1 / this._values[3]; return this; } - clamp(min, max) { const clamper = v => min > v ? min : max < v ? max : v; - this._values[0] = clamper(this._values[0]); this._values[1] = clamper(this._values[1]); this._values[2] = clamper(this._values[2]); this._values[3] = clamper(this._values[3]); return this; } - clampGrid() { const clamper = v => 0 > v ? 0 : 1 < v ? 1 : v; - const gridClamper = (value, grid) => Math.trunc(clamper(value) * grid + 0.5) / grid; - this._values[0] = gridClamper(this._values[0], 31); this._values[1] = gridClamper(this._values[1], 63); this._values[2] = gridClamper(this._values[2], 31); this._values[3] = clamper(this._values[3]); return this; } - truncate() { this._values[0] = Math.trunc(this._values[0]); this._values[1] = Math.trunc(this._values[1]); @@ -1219,7 +1028,6 @@ this._values[3] = Math.trunc(this._values[3]); return this; } - normalize() { this._values[0] /= this.length; this._values[1] /= this.length; @@ -1227,51 +1035,39 @@ this._values[3] /= this.length; return this; } - toString() { return "Vec4( ".concat(this._values.join(", "), " )"); } - static add(a, b) { return new Vec4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); } - static sub(a, b) { return new Vec4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); } - static dot(a, b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } - static multScalar(a, scalar) { return new Vec4(a.x * scalar, a.y * scalar, a.z * scalar, a.w * scalar); } - static multVector(a, b) { return new Vec4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); } - static interpolate(a, b, p) { let a_ = Vec4.multScalar(a, 1 - p); let b_ = Vec4.multScalar(b, p); return Vec4.add(a_, b_); } - static multiplyAdd(a, b, c) { return new Vec4(a.x * b.x + c.x, a.y * b.y + c.y, a.z * b.z + c.z, a.w * b.w + c.w); } - static negativeMultiplySubtract(a, b, c) { return new Vec4(c.x - a.x * b.x, c.y - a.y * b.y, c.z - a.z * b.z, c.w - a.w * b.w); } - static compareAnyLessThan(left, right) { return left.x < right.x || left.y < right.y || left.z < right.z || left.w < right.w; } - } - function computeWeightedCovariance(values, weights) { let total = 0; let mean = values.reduce((sum, value, i) => { @@ -1296,7 +1092,6 @@ covariance[2][1] = covariance[1][2]; return covariance; } - function computePCA(values, weights) { const covariance = computeWeightedCovariance(values, weights); return new Vec3(...dominentPrincipalVector(covariance)); @@ -1313,45 +1108,37 @@ if (integer > limit) return integer; return integer; } - function floatTo565(color) { const r = floatToInt(31.0 * color.x, 31); const g = floatToInt(63.0 * color.y, 63); const b = floatToInt(31.0 * color.z, 31); return r << 11 | g << 5 | b; } - function writeColourBlock(firstColor, secondColor, indices, result, blockOffset) { result[blockOffset + 0] = firstColor & 0xff; result[blockOffset + 1] = firstColor >> 8; result[blockOffset + 2] = secondColor & 0xff; result[blockOffset + 3] = secondColor >> 8; - for (let y = 0; y < 4; y++) { result[blockOffset + 4 + y] = indices[4 * y + 0] | indices[4 * y + 1] << 2 | indices[4 * y + 2] << 4 | indices[4 * y + 3] << 6; } } - function writeColourBlock3(start, end, indices, result, blockOffset) { let firstColor = floatTo565(start); let secondColor = floatTo565(end); let remapped; - if (firstColor <= secondColor) { remapped = indices.slice(); } else { [firstColor, secondColor] = [secondColor, firstColor]; remapped = indices.map(index => index === 0 ? 1 : index === 1 ? 0 : index); } - writeColourBlock(firstColor, secondColor, remapped, result, blockOffset); } - function writeColourBlock4(start, end, indices, result, blockOffset) { let firstColor = floatTo565(start); let secondColor = floatTo565(end); let remapped; - if (firstColor < secondColor) { [firstColor, secondColor] = [secondColor, firstColor]; remapped = indices.map(index => (index ^ 0x1) & 0x3); @@ -1360,7 +1147,6 @@ } else { remapped = indices.slice(); } - writeColourBlock(firstColor, secondColor, remapped, result, blockOffset); } @@ -1374,21 +1160,17 @@ this._points = []; const isDxt1 = (this.flags & kDxt1) != 0; const weightByAlpha = (this.flags & kWeightColourByAlpha) != 0; - for (let i = 0; i < 16; i++) { const bit = 1 << i; - if ((mask & bit) == 0) { this._remap[i] = -1; continue; } - if (isDxt1 && rgba[4 * i + 3] < 128) { this._remap[i] = -1; this._transparent = true; continue; } - for (let j = 0;; j++) { if (j == i) { const r = rgba[4 * i] / 255.0; @@ -1401,10 +1183,8 @@ this._count++; break; } - const oldbit = 1 << j; const match = (mask & oldbit) != 0 && rgba[4 * i] == rgba[4 * j] && rgba[4 * i + 1] == rgba[4 * j + 1] && rgba[4 * i + 2] == rgba[4 * j + 2] && (rgba[4 * j + 3] >= 128 || !isDxt1); - if (match) { const index = this._remap[j]; const w = (rgba[4 * i + 3] + 1) / 256.0; @@ -1414,61 +1194,44 @@ } } } - for (let i = 0; i < this._count; ++i) this._weights[i] = Math.sqrt(this._weights[i]); } - get transparent() { return this._transparent; } - get count() { return this._count; } - get points() { return Object.freeze(this._points.slice()); } - get weights() { return Object.freeze(this._weights.slice()); } - remapIndicesSingle(singleIndex, target) { const result = this._remap.map(index => index === -1 ? 3 : singleIndex); - target.forEach((_, i) => target[i] = result[i]); } - remapIndices(indexMap, target) { const result = this._remap.map(index => index === -1 ? 3 : indexMap[index]); - target.forEach((_, i) => target[i] = result[i]); } - } - class ColorFit { constructor(colorSet) { this.colors = colorSet; this.flags = colorSet.flags; } - compress(result, offset) { const isDxt1 = (this.flags & kDxt1) != 0; - if (isDxt1) { this.compress3(result, offset); if (!this.colors.transparent) this.compress4(result, offset); } else this.compress4(result, offset); } - compress3(result, offset) {} - compress4(result, offset) {} - } - class SingleColourFit extends ColorFit { constructor(colorSet) { super(colorSet); @@ -1480,10 +1243,8 @@ this.error = Infinity; this.bestError = Infinity; } - compressBase(lookups, saveFunc) { this.computeEndPoints(lookups); - if (this.error < this.bestError) { const indices = new Uint8Array(16); this.colors.remapIndicesSingle(this.index, indices); @@ -1491,30 +1252,21 @@ this.bestError = this.error; } } - compress3(result, offset) { const lookups = [lookup_5_3, lookup_6_3, lookup_5_3]; - const saveFunc = (start, end, indices) => writeColourBlock3(start, end, indices, result, offset); - this.compressBase(lookups, saveFunc); } - compress4(result, offset) { const lookups = [lookup_5_4, lookup_6_4, lookup_5_4]; - const saveFunc = (start, end, indices) => writeColourBlock4(start, end, indices, result, offset); - this.compressBase(lookups, saveFunc); } - computeEndPoints(lookups) { this.error = Infinity; - for (let index = 0; index < 2; index++) { const sources = []; let error = 0; - for (let channel = 0; channel < 3; channel++) { const lookup = lookups[channel]; const target = this.color[channel]; @@ -1522,7 +1274,6 @@ const diff = sources[channel][2]; error += diff * diff; } - if (error < this.error) { this.start = new Vec3(sources[0][0] / 31.0, sources[1][0] / 63.0, sources[2][0] / 31.0); this.end = new Vec3(sources[0][1] / 31.0, sources[1][1] / 63.0, sources[2][1] / 31.0); @@ -1531,24 +1282,19 @@ } } } - } - class RangeFit extends ColorFit { constructor(colorSet) { super(colorSet); this.metric = new Vec3(1); - if ((this.flags & kColourMetricPerceptual) !== 0) { this.metric.set(0.2126, 0.7152, 0.0722); } - this.start = new Vec3(0); this.end = new Vec3(0); this.bestError = Infinity; this.computePoints(); } - compressBase(codes, saveFunc) { const { points: values @@ -1565,7 +1311,6 @@ error += minDist; return packedIndex; }); - if (error < this.bestError) { let indices = new Uint8Array(16); this.colors.remapIndices(closest, indices); @@ -1573,23 +1318,16 @@ this.bestError = error; } } - compress3(result, offset) { const codes = [this.start.clone(), this.end.clone(), Vec3.interpolate(this.start, this.end, 0.5)]; - const saveFunc = (start, end, indices) => writeColourBlock3(start, end, indices, result, offset); - this.compressBase(codes, saveFunc); } - compress4(result, offset) { const codes = [this.start.clone(), this.end.clone(), Vec3.interpolate(this.start, this.end, 1 / 3), Vec3.interpolate(this.start, this.end, 2 / 3)]; - const saveFunc = (start, end, indices) => writeColourBlock4(start, end, indices, result, offset); - this.compressBase(codes, saveFunc); } - computePoints() { const { count, @@ -1601,10 +1339,8 @@ let start, end, min, max; start = end = values[0]; min = max = Vec3.dot(start, principle); - for (let i = 1; i < count; i++) { let value = Vec3.dot(values[i], principle); - if (value < min) { start = values[i]; min = value; @@ -1613,13 +1349,10 @@ max = value; } } - this.start = start.clampGrid().clone(); this.end = end.clampGrid().clone(); } - } - class ClusterFit extends ColorFit { constructor(colorSet) { super(colorSet); @@ -1627,11 +1360,9 @@ this.iterationCount = colorSet.flags & kColourIterativeClusterFit ? kMaxIterations : 1; this.bestError = Infinity; this.metric = new Vec4(1); - if ((this.flags & kColourMetricPerceptual) !== 0) { this.metric.set(0.2126, 0.7152, 0.0722, 0); } - const { points: values, weights @@ -1641,7 +1372,6 @@ this.pointsWeights = []; this.xSum_wSum = new Vec4(0); } - constructOrdering(axis, iteration) { const currentOrder = this.makeOrder(axis); this.copyOrderToThisOrder(currentOrder, iteration); @@ -1650,7 +1380,6 @@ this.copyOrderWeight(currentOrder); return true; } - compress3(result, offset) { const aabbx = _ref => { let [part0,, part1, part2] = _ref; @@ -1668,12 +1397,9 @@ ab: alphabeta_sum }; }; - const saveFunc = (start, end, indices) => writeColourBlock3(start, end, indices, result, offset); - this.compressBase(aabbx, saveFunc, 2); } - compress4(result, offset) { const aabbx = _ref2 => { let [part0, part1, part2, part3] = _ref2; @@ -1693,12 +1419,9 @@ ab: alphabeta_sum }; }; - const saveFunc = (start, end, indices) => writeColourBlock4(start, end, indices, result, offset); - this.compressBase(aabbx, saveFunc, 3); } - compressBase(aabbFunc, saveFunc) { let repeater = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; this.constructOrdering(this.principle, 0); @@ -1711,19 +1434,15 @@ bestJ: 0 }; if (repeater === 3) best.bestK = 0; - const leastSquares = (parts, internalIndices) => { const aabbx = aabbFunc(parts); const internalBest = this.computeOptimalPoints(aabbx); - if (internalBest.error < best.error) { best = _objectSpread2(_objectSpread2({}, internalBest), internalIndices); return true; } - return false; }; - for (let iterationIndex = 0;;) { this.clusterIterate(iterationIndex, leastSquares, repeater); if (best.iteration != iterationIndex) break; @@ -1732,10 +1451,8 @@ const newAxis = Vec4.sub(best.end, best.start).xyz; if (!this.constructOrdering(newAxis, iterationIndex)) break; } - if (best.error < this.bestError) this.saveBlock(best, saveFunc); } - makeOrder(axis) { const { count, @@ -1749,36 +1466,29 @@ return a - b; }); } - copyOrderToThisOrder(order, iteration) { const orderOffset = iteration * 16; order.forEach((ord, i) => { this.order[orderOffset + i] = ord; }); } - checkOrderUnique(order, iteration) { const { count } = this.colors; - for (let it = 0; it < iteration; it++) { let prevOffset = it * 16; let same = true; - for (let i = 0; i < count; i++) { if (order[i] !== this.order[prevOffset + i]) { same = false; break; } } - if (same) return false; } - return true; } - copyOrderWeight(order) { const { count, @@ -1786,7 +1496,6 @@ weights } = this.colors; this.xSum_wSum.set(0); - for (let i = 0; i < count; i++) { const j = order[i]; const p = unweighted[j].toVec4(1); @@ -1796,7 +1505,6 @@ this.xSum_wSum.addVector(x); } } - computeOptimalPoints(vectorPoint) { const { ax, @@ -1820,7 +1528,6 @@ error }; } - computeError(_ref3) { let { a, @@ -1839,7 +1546,6 @@ const e5 = Vec4.multVector(e4, this.metric); return e5.x + e5.y + e5.z; } - saveBlock(best, writeFunc) { const { count @@ -1855,30 +1561,25 @@ } = best; const orderOffset = iteration * 16; const unordered = new Uint8Array(16); - const mapper = m => { if (m < bestI) return 0; if (m < bestJ) return 2; if (m < bestK) return 3; return 1; }; - for (let i = 0; i < count; i++) { unordered[this.order[orderOffset + i]] = mapper(i); } - const bestIndices = new Uint8Array(16); this.colors.remapIndices(unordered, bestIndices); writeFunc(start.xyz, end.xyz, bestIndices); this.bestError = error; } - clusterIterate(index, func) { let iterCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; const { count } = this.colors; - const indexMapper = (i, j, k) => { const mapper = { bestI: i, @@ -1888,16 +1589,12 @@ if (iterCount === 3) mapper.bestK = k; return mapper; }; - let part0 = new Vec4(0.0); - for (let i = 0; i < count; i++) { let part1 = new Vec4(0.0); - for (let j = i;;) { let preLastPart = j == 0 ? this.pointsWeights[0].clone() : new Vec4(0.0); const kmin = j == 0 ? 1 : j; - for (let k = kmin;;) { const restPart = Vec4.sub(this.xSum_wSum, preLastPart).subVector(part1).subVector(part0); func([part0, part1, preLastPart, restPart], indexMapper(i, j, k)); @@ -1905,17 +1602,14 @@ preLastPart.addVector(this.pointsWeights[k]); k++; } - if (iterCount === 2) break; if (j === count) break; part1.addVector(this.pointsWeights[j]); j++; } - part0.addVector(this.pointsWeights[i]); } } - } function quantise(alpha) { @@ -1925,7 +1619,6 @@ if (result > GRID) return GRID; return result; } - function compressAlphaDxt3(rgba, mask, result, offset) { for (let i = 0; i < 8; i++) { let quant1 = quantise(rgba[8 * i + 3]); @@ -1937,13 +1630,11 @@ result[offset + i] = quant1 | quant2 << 4; } } - function compressAlphaDxt5(rgba, mask, result, offset) { let step5 = interpolateAlpha(rgba, mask, 5); let step7 = interpolateAlpha(rgba, mask, 7); if (step5.error <= step7.error) writeAlphaBlock5(step5, result, offset);else writeAlphaBlock7(step7, result, offset); } - function interpolateAlpha(rgba, mask, steps) { let { min, @@ -1959,16 +1650,13 @@ error }; } - function setAlphaRange(rgba, mask, steps) { let min = 255; let max = 0; - for (let i = 0; i < 16; i++) { let bit = 1 << i; if ((mask & bit) == 0) continue; let value = rgba[4 * i + 3]; - if (steps === 5) { if (value !== 0 && value < min) min = value; if (value !== 255 && value > max) max = value; @@ -1977,7 +1665,6 @@ if (value > max) max = value; } } - if (min > max) min = max; if (max - min < steps) max = Math.min(min + steps, 255); if (max - min < steps) min = Math.max(max - steps, 0); @@ -1986,61 +1673,48 @@ max }; } - function setAlphaCodeBook(min, max, steps) { let codes = [min, max, ...Array.from({ length: steps - 1 }, (_, i) => { return Math.floor(((steps - (i + 1)) * min + (i + 1) * max) / steps); })]; - if (steps === 5) { codes[6] = 0; codes[7] = 255; } - return codes; } - function fitCodes(rgba, mask, codes, indices) { let err = 0; - for (let i = 0; i < 16; ++i) { let bit = 1 << i; - if ((mask & bit) == 0) { indices[i] = 0; continue; } - let value = rgba[4 * i + 3]; let least = Infinity; let index = 0; - for (let j = 0; j < 8; ++j) { let dist = value - codes[j]; dist *= dist; - if (dist < least) { least = dist; index = j; } } - indices[i] = index; err += least; } - return err; } - function writeAlphaBlock5(_ref, result, offset) { let { min: alpha0, max: alpha1, indices } = _ref; - if (alpha0 > alpha1) { const swapped = indices.map(index => { if (index === 0) return 1; @@ -2051,14 +1725,12 @@ writeAlphaBlock(alpha1, alpha0, swapped, result, offset); } else writeAlphaBlock(alpha0, alpha1, indices, result, offset); } - function writeAlphaBlock7(_ref2, result, offset) { let { min: alpha0, max: alpha1, indices } = _ref2; - if (alpha0 > alpha1) { const swapped = indices.map(index => { if (index === 0) return 1; @@ -2068,22 +1740,18 @@ writeAlphaBlock(alpha1, alpha0, swapped, result, offset); } else writeAlphaBlock(alpha0, alpha1, indices, result, offset); } - function writeAlphaBlock(alpha0, alpha1, indices, result, offset) { result[offset] = alpha0; result[offset + 1] = alpha1; let indicesPointer = 0; let resultPointer = offset + 2; - for (let i = 0; i < 2; i++) { let value = 0; - for (let j = 0; j < 8; ++j) { let index = indices[indicesPointer]; value |= index << 3 * j; indicesPointer++; } - for (let j = 0; j < 3; ++j) { let byte = value >> 8 * j & 0xff; result[resultPointer] = byte; @@ -2098,13 +1766,11 @@ const blue = color16bit & 0x1f; return [red << 3 | red >> 2, green << 2 | green >> 4, blue << 3 | blue >> 2, 255]; } - function interpolateColorArray(a, b, amount) { const result = a.map((aColor, i) => Math.floor(aColor * (1 - amount) + b[i] * amount)); result[3] = 255; return result; } - function unpackColorCodes(block, offset, isDxt1) { const color1 = block[offset] | block[offset + 1] << 8; const color2 = block[offset + 2] | block[offset + 3] << 8; @@ -2112,11 +1778,9 @@ const unpackedColor2 = unpack565(color2); return [unpackedColor1, unpackedColor2, isDxt1 && color1 <= color2 ? interpolateColorArray(unpackedColor1, unpackedColor2, 1 / 2) : interpolateColorArray(unpackedColor1, unpackedColor2, 1 / 3), isDxt1 && color1 <= color2 ? [0, 0, 0, 0] : interpolateColorArray(unpackedColor1, unpackedColor2, 2 / 3)]; } - function unpackIndices(block, blockOffset) { let offset = blockOffset + 4; let result = new Uint8Array(16); - for (let i = 0; i < 4; i++) { let packedIndices = block[offset + i]; result[i * 4 + 0] = packedIndices & 0x3; @@ -2124,21 +1788,17 @@ result[i * 4 + 2] = packedIndices >> 4 & 0x3; result[i * 4 + 3] = packedIndices >> 6 & 0x3; } - return result; } - function decompressColor(rgba, block, offset, isDxt1) { const colorCode = unpackColorCodes(block, offset, isDxt1); const indices = unpackIndices(block, offset); - for (let i = 0; i < 16; i++) { for (let j = 0; j < 4; j++) { rgba[4 * i + j] = colorCode[indices[i]][j]; } } } - function decompressAlphaDxt3(rgba, block, offset) { for (let i = 0; i < 8; ++i) { let quant = block[offset + i]; @@ -2148,7 +1808,6 @@ rgba[8 * i + 7] = hi | hi >> 4; } } - function decompressAlphaDxt5(rgba, block, offset) { let alpha0 = block[offset + 0]; let alpha1 = block[offset + 1]; @@ -2156,23 +1815,19 @@ let indices = new Uint8Array(16); let indicePointer = 0; let bytePointer = 2; - for (let i = 0; i < 2; i++) { let value = 0; - for (let j = 0; j < 3; j++) { let byte = block[offset + bytePointer]; value |= byte << 8 * j; bytePointer++; } - for (let j = 0; j < 8; j++) { let index = value >> 3 * j & 0x7; indices[indicePointer] = index; indicePointer++; } } - for (let i = 0; i < 16; ++i) { rgba[4 * i + 3] = codes[indices[i]]; } @@ -2203,7 +1858,6 @@ const DXT5_COMPRESSED_BYTES = 16; const COLORS = 4; const DECOMPRESSED_BLOCK_SIZE = 16; - function blockRepeat(width, height, func) { for (let y = 0; y < height; y += 4) { for (let x = 0; x < width; x += 4) { @@ -2211,7 +1865,6 @@ } } } - function rectRepeat(func) { for (let y = 0; y < 4; y++) { for (let x = 0; x < 4; x++) { @@ -2219,7 +1872,6 @@ } } } - function FixFlags(flags) { let method = flags & (kDxt1 | kDxt3 | kDxt5); let fit = flags & (kColourIterativeClusterFit | kColourClusterFit | kColourRangeFit); @@ -2230,14 +1882,12 @@ if (metric != kColourMetricUniform) metric = kColourMetricPerceptual; return method | fit | metric | extra; } - function GetStorageRequirements(width, height, flags) { flags = FixFlags(flags); const blockcount = Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4); const blocksize = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; return blockcount * blocksize; } - function extractColorBlock(img) { let { x = 0, @@ -2251,14 +1901,11 @@ rectRepeat(function (px, py) { let sx = x + px; let sy = y + py; - if (sx < width && sy < height) { let sourceColorOffset = COLORS * (width * sy + sx); - for (let i = 0; i < COLORS; i++) { block[blockColorOffset++] = img[sourceColorOffset++]; } - mask |= 1 << 4 * py + px; } else blockColorOffset += COLORS; }); @@ -2267,7 +1914,6 @@ mask }; } - function copyBuffer(result, block) { let { x = 0, @@ -2279,23 +1925,19 @@ rectRepeat(function (px, py) { let sx = x + px; let sy = y + py; - if (sx < width && sy < height) { let resultColorOffset = COLORS * (width * sy + sx); - for (let i = 0; i < COLORS; i++) { result[resultColorOffset + i] = block[blockColorOffset++]; } } else blockColorOffset += COLORS; }); } - function getCompressor(colorSet) { if (colorSet.count === 1) return new SingleColourFit(colorSet); if ((colorSet.flags & kColourRangeFit) != 0 || colorSet.count == 0) return new RangeFit(colorSet); return new ClusterFit(colorSet); } - function CompressMasked(rgba, mask, result, offset, flags) { flags = FixFlags(flags); let colorOffset = (flags & (kDxt3 | kDxt5)) !== 0 ? 8 : 0; @@ -2304,14 +1946,12 @@ compressor.compress(result, offset + colorOffset); if ((flags & kDxt3) !== 0) compressAlphaDxt3(rgba, mask, result, offset);else if ((flags & kDxt5) !== 0) compressAlphaDxt5(rgba, mask, result, offset); } - function decompressBlock(result, block, offset, flags) { flags = FixFlags(flags); let colorOffset = (flags & (kDxt3 | kDxt5)) !== 0 ? 8 : 0; decompressColor(result, block, offset + colorOffset, (flags & kDxt1) !== 0); if ((flags & kDxt3) !== 0) decompressAlphaDxt3(result, block, offset);else if ((flags & kDxt5) !== 0) decompressAlphaDxt5(result, block, offset); } - function compressImage(source, width, height, result, flags) { flags = FixFlags(flags); const bytesPerBlock = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; @@ -2330,12 +1970,10 @@ targetBlockPointer += bytesPerBlock; }); } - function decompressImage(result, width, height, source, flags) { flags = FixFlags(flags); const bytesPerBlock = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; let sourceBlockPointer = 0; - for (let y = 0; y < height; y += 4) { for (let x = 0; x < width; x += 4) { const targetRGBA = new Uint8Array(DECOMPRESSED_BLOCK_SIZE * COLORS); @@ -2350,7 +1988,6 @@ } } } - const flags = { DXT1: kDxt1, DXT3: kDxt3, @@ -2362,7 +1999,6 @@ ColourMetricUniform: kColourMetricUniform, WeightColourByAlpha: kWeightColourByAlpha }; - function compress(inputData, width, height, flags) { let source = inputData instanceof ArrayBuffer ? new Uint8Array(inputData) : inputData; const targetSize = GetStorageRequirements(width, height, flags); @@ -2370,7 +2006,6 @@ compressImage(source, width, height, result, flags); return result; } - function decompress(inputData, width, height, flags) { let source = inputData instanceof ArrayBuffer ? new Uint8Array(inputData) : inputData; const targetSize = width * height * 4; @@ -2382,7 +2017,6 @@ function extractBits(bitData, amount, offset) { return bitData >> offset & 2 ** amount - 1; } - function colorToBgra5551(red, green, blue, alpha) { const r = Math.round(red / 255 * 31); const g = Math.round(green / 255 * 31); @@ -2390,24 +2024,19 @@ const a = Math.round(alpha / 255); return a << 15 | r << 10 | g << 5 | b; } - function bgra5551ToColor(bgra5551) { const r = extractBits(bgra5551, 5, 10); const g = extractBits(bgra5551, 5, 5); const b = extractBits(bgra5551, 5, 0); const a = bgra5551 >> 15 & 1; - const scaleUp = value => value << 3 | value >> 2; - const [red, green, blue] = [r, g, b].map(scaleUp); return [red, green, blue, a * 255]; } - function convertTo5551(colorBuffer) { const colorArray = new Uint8Array(colorBuffer); const length = colorArray.length / 4; const convertedArray = new Uint8Array(length * 2); - for (let i = 0; i < length; i++) { const red = colorArray[i * 4]; const green = colorArray[i * 4 + 1]; @@ -2417,20 +2046,16 @@ convertedArray[i * 2] = bgra5551 & 0xff; convertedArray[i * 2 + 1] = bgra5551 >> 8; } - return convertedArray; } - function convertFrom5551(colorBuffer) { const colorArray = new Uint8Array(colorBuffer); const length = colorArray.length / 2; const convertedArray = new Uint8Array(length * 4); - for (let i = 0; i < length; i++) { const colors = bgra5551ToColor(colorArray[i * 2] | colorArray[i * 2 + 1] << 8); [convertedArray[i * 4], convertedArray[i * 4 + 1], convertedArray[i * 4 + 2], convertedArray[i * 4 + 3]] = colors; } - return convertedArray; } @@ -2439,12 +2064,10 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.Texture2DReader': return true; - default: return false; } } - read(buffer) { const int32Reader = new Int32Reader(); const uint32Reader = new UInt32Reader(); @@ -2452,22 +2075,31 @@ let width = uint32Reader.read(buffer); let height = uint32Reader.read(buffer); let mipCount = uint32Reader.read(buffer); + let usedWidth = null; + let usedHeight = null; if (mipCount > 1) console.warn("Found mipcount of ".concat(mipCount, ", only the first will be used.")); let dataSize = uint32Reader.read(buffer); + if (width * height * 4 > dataSize) { + usedWidth = width >> 16 & 0xffff; + width = width & 0xffff; + usedHeight = height >> 16 & 0xffff; + height = height & 0xffff; + if (width * height * 4 !== dataSize) { + console.warn("invalid width & height! ".concat(width, " x ").concat(height)); + } + } let data = buffer.read(dataSize); if (format == 4) data = decompress(data, width, height, flags.DXT1);else if (format == 5) data = decompress(data, width, height, flags.DXT3);else if (format == 6) data = decompress(data, width, height, flags.DXT5);else if (format == 2) { data = convertFrom5551(data); } else if (format != 0) throw new Error("Non-implemented Texture2D format type (".concat(format, ") found.")); if (data instanceof ArrayBuffer) data = new Uint8Array(data); - for (let i = 0; i < data.length; i += 4) { let inverseAlpha = 255 / data[i + 3]; data[i] = Math.min(Math.ceil(data[i] * inverseAlpha), 255); data[i + 1] = Math.min(Math.ceil(data[i + 1] * inverseAlpha), 255); data[i + 2] = Math.min(Math.ceil(data[i + 2] * inverseAlpha), 255); } - - return { + const result = { format, export: { type: this.type, @@ -2476,36 +2108,40 @@ height } }; + if (usedWidth !== null) result.additional = { + usedWidth, + usedHeight + }; + return result; } - write(buffer, content, resolver) { const int32Reader = new Int32Reader(); const uint32Reader = new UInt32Reader(); this.writeIndex(buffer, resolver); - const width = content.export.width; - const height = content.export.height; + let width = content.export.width; + let height = content.export.height; + if (content.additional != null) { + width = width | content.additional.usedWidth << 16; + height = height | content.additional.usedHeight << 16; + } int32Reader.write(buffer, content.format, null); - uint32Reader.write(buffer, content.export.width, null); - uint32Reader.write(buffer, content.export.height, null); + uint32Reader.write(buffer, width, null); + uint32Reader.write(buffer, height, null); uint32Reader.write(buffer, 1, null); let data = content.export.data; - for (let i = 0; i < data.length; i += 4) { const alpha = data[i + 3] / 255; data[i] = Math.floor(data[i] * alpha); data[i + 1] = Math.floor(data[i + 1] * alpha); data[i + 2] = Math.floor(data[i + 2] * alpha); } - if (content.format === 4) data = compress(data, width, height, flags.DXT1);else if (content.format === 5) data = compress(data, width, height, flags.DXT3);else if (content.format === 6) data = compress(data, width, height, flags.DXT5);else if (content.format === 2) data = convertTo5551(data); uint32Reader.write(buffer, data.length, null); buffer.concat(data); } - isValueType() { return false; } - } class Vector3Reader extends BaseReader { @@ -2514,12 +2150,10 @@ case 'Microsoft.Xna.Framework.Content.Vector3Reader': case 'Microsoft.Xna.Framework.Vector3': return true; - default: return false; } } - read(buffer) { const singleReader = new SingleReader(); let x = singleReader.read(buffer); @@ -2531,7 +2165,6 @@ z }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const singleReader = new SingleReader(); @@ -2539,7 +2172,6 @@ singleReader.write(buffer, content.y, null); singleReader.write(buffer, content.z, null); } - } class SpriteFontReader extends BaseReader { @@ -2547,16 +2179,13 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.SpriteFontReader': return true; - default: return false; } } - static parseTypeList() { return ["SpriteFont", "Texture2D", 'List', 'Rectangle', 'List', 'Rectangle', 'List', 'Char', null, null, 'List', 'Vector3', 'Nullable', 'Char']; } - read(buffer, resolver) { const int32Reader = new Int32Reader(); const singleReader = new SingleReader(); @@ -2580,7 +2209,6 @@ defaultCharacter }; } - write(buffer, content, resolver) { const int32Reader = new Int32Reader(); const charReader = new CharReader(); @@ -2591,7 +2219,6 @@ const charListReader = new ListReader(charReader); const vector3ListReader = new ListReader(new Vector3Reader()); this.writeIndex(buffer, resolver); - try { texture2DReader.write(buffer, content.texture, resolver); buffer.alloc(100000); @@ -2606,11 +2233,9 @@ throw ex; } } - isValueType() { return false; } - } class TBinReader extends BaseReader { @@ -2618,12 +2243,10 @@ switch (type) { case 'xTile.Pipeline.TideReader': return true; - default: return false; } } - read(buffer) { const int32Reader = new Int32Reader(); let size = int32Reader.read(buffer); @@ -2635,7 +2258,6 @@ } }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const data = content.export.data; @@ -2643,11 +2265,9 @@ int32Reader.write(buffer, data.byteLength, null); buffer.concat(data); } - isValueType() { return false; } - } class LightweightTexture2DReader extends BaseReader { @@ -2655,16 +2275,13 @@ switch (type) { case 'Microsoft.Xna.Framework.Content.Texture2DReader': return true; - default: return false; } } - static type() { return "Texture2D"; } - read(buffer) { const int32Reader = new Int32Reader(); const uint32Reader = new UInt32Reader(); @@ -2677,14 +2294,12 @@ let data = buffer.read(dataSize); data = new Uint8Array(data); if (format != 0) throw new Error("Compressed texture format is not supported!"); - for (let i = 0; i < data.length; i += 4) { let inverseAlpha = 255 / data[i + 3]; data[i] = Math.min(Math.ceil(data[i] * inverseAlpha), 255); data[i + 1] = Math.min(Math.ceil(data[i + 1] * inverseAlpha), 255); data[i + 2] = Math.min(Math.ceil(data[i + 2] * inverseAlpha), 255); } - return { format, export: { @@ -2695,7 +2310,6 @@ } }; } - write(buffer, content, resolver) { if (content.format != 0) throw new Error("Compressed texture format is not supported!"); const int32Reader = new Int32Reader(); @@ -2708,26 +2322,21 @@ uint32Reader.write(buffer, content.export.height, null); uint32Reader.write(buffer, 1, null); let data = content.export.data; - for (let i = 0; i < data.length; i += 4) { const alpha = data[i + 3] / 255; data[i] = Math.floor(data[i] * alpha); data[i + 1] = Math.floor(data[i + 1] * alpha); data[i + 2] = Math.floor(data[i + 2] * alpha); } - uint32Reader.write(buffer, data.length, null); buffer.concat(data); } - isValueType() { return false; } - get type() { return "Texture2D"; } - } class Vector2Reader extends BaseReader { @@ -2736,12 +2345,10 @@ case 'Microsoft.Xna.Framework.Content.Vector2Reader': case 'Microsoft.Xna.Framework.Vector2': return true; - default: return false; } } - read(buffer) { const singleReader = new SingleReader(); let x = singleReader.read(buffer); @@ -2751,7 +2358,12 @@ y }; } - + write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + const singleReader = new SingleReader(); + singleReader.write(buffer, content.x, null); + singleReader.write(buffer, content.y, null); + } } class Vector4Reader extends BaseReader { @@ -2760,12 +2372,10 @@ case 'Microsoft.Xna.Framework.Content.Vector4Reader': case 'Microsoft.Xna.Framework.Vector4': return true; - default: return false; } } - read(buffer) { const singleReader = new SingleReader(); let x = singleReader.read(buffer); @@ -2779,7 +2389,14 @@ w }; } - + write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + const singleReader = new SingleReader(); + singleReader.write(buffer, content.x, null); + singleReader.write(buffer, content.y, null); + singleReader.write(buffer, content.z, null); + singleReader.write(buffer, content.w, null); + } } exports.ArrayReader = ArrayReader; @@ -2794,6 +2411,7 @@ exports.LightweightTexture2DReader = LightweightTexture2DReader; exports.ListReader = ListReader; exports.NullableReader = NullableReader; + exports.PointReader = PointReader; exports.RectangleReader = RectangleReader; exports.ReflectiveReader = ReflectiveReader; exports.SingleReader = SingleReader; diff --git a/dist/readers/xnb-readers.min.js b/dist/readers/xnb-readers.min.js index ab37046..741b82e 100644 --- a/dist/readers/xnb-readers.min.js +++ b/dist/readers/xnb-readers.min.js @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -28,4 +28,4 @@ * -------------------------------------------------------------------------- */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XNB={})}(this,(function(t){"use strict";class e{static isTypeOf(t){return!1}static hasSubType(){return!1}static parseTypeList(){return[this.type()]}static type(){return this.name.slice(0,-6)}isValueType(){return!0}get type(){return this.constructor.type()}read(t,e){throw new Error("Cannot invoke methods on abstract class.")}write(t,e,r){throw new Error("Cannot invoke methods on abstract class.")}writeIndex(t,e){null!=e&&t.write7BitNumber(Number.parseInt(e.getIndex(this))+1)}toString(){return this.type}parseTypeList(){return this.constructor.parseTypeList()}}class r extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.UInt32Reader":case"System.UInt32":return!0;default:return!1}}read(t){return t.readUInt32()}write(t,e,r){this.writeIndex(t,r),t.writeUInt32(e)}}const s=[55296,56320];function n(t){var e;if("number"==typeof t&&(t=[t]),null===(e=t)||void 0===e||!e.length)throw new Error("Invalid codeset!");return 1===t.length?t[0]:((1023&t[0])<<10)+(1023&t[1])+65536}function i(t){const e=function(t){const e=Array.from({length:t.length},((e,r)=>t.charCodeAt(r))),r=[];let i=0;for(;ie<128?t+1:e<2048?t+2:e<65536?t+3:t+4),0)}class a extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.StringReader":case"System.String":return!0;default:return!1}}read(t){let e=t.read7BitNumber();return t.readString(e)}write(t,e,r){this.writeIndex(t,r);const s=i(e);t.write7BitNumber(s),t.writeString(e)}isValueType(){return!1}}class o extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.BooleanReader":case"System.Boolean":return!0;default:return!1}}read(t){return Boolean(t.readInt())}write(t,e,r){this.writeIndex(t,r),t.writeByte(e)}}class l extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.CharReader":case"System.Char":return!0;default:return!1}}read(t){let e=this._getCharSize(t.peekInt());return t.readString(e)}write(t,e,r){this.writeIndex(t,r),t.writeString(e)}_getCharSize(t){return 1+(3841982464>>(t>>3&30)&3)}}class u extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.Int32Reader":case"System.Int32":return!0;default:return!1}}read(t){return t.readInt32()}write(t,e,r){this.writeIndex(t,r),t.writeInt32(e)}}class c extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.ListReader":case"System.Collections.Generic.List":return!0;default:return!1}}static hasSubType(){return!0}constructor(t){super(),this.reader=t}read(t,e){const s=(new r).read(t),n=[];for(let r=0;r")}parseTypeList(){return[this.type,...this.reader.parseTypeList()]}}class h extends e{static isTypeOf(t){return"Microsoft.Xna.Framework.Content.NullableReader"===t}static hasSubType(){return!0}constructor(t){super(),this.reader=t}read(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const r=new o;return t.peekByte(1)?null===e?(r.read(t),this.reader.read(t)):this.reader.isValueType()?this.reader.read(t):e.read(t):(r.read(t),null)}write(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;null!==e?(null===r&&t.writeByte(1),this.reader.write(t,e,this.reader.isValueType()?null:r)):t.writeByte(0)}isValueType(){return!1}get type(){return"Nullable<".concat(this.reader.type,">")}parseTypeList(){const t=this.reader.parseTypeList();return["".concat(this.type,":").concat(t.length),...t]}}class d extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.RectangleReader":case"Microsoft.Xna.Framework.Rectangle":return!0;default:return!1}}read(t){const e=new u;return{x:e.read(t),y:e.read(t),width:e.read(t),height:e.read(t)}}write(t,e,r){this.writeIndex(t,r);const s=new u;s.write(t,e.x,null),s.write(t,e.y,null),s.write(t,e.width,null),s.write(t,e.height,null)}}class p extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.SingleReader":case"System.Single":return!0;default:return!1}}read(t){return t.readSingle()}write(t,e,r){this.writeIndex(t,r),t.writeSingle(e)}}const w=256;function f(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,s)}return r}function y(t){for(var e=1;e{let n=e.map((t=>t[s]));return{value:t[s],vec:n}}));return s.sort(((t,e)=>e.value-t.value)),[s.map((t=>{let{value:e}=t;return e})),s.map((t=>{let{vec:e}=t;return e}))]}function T(t){let[,[e]]=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-7,r=t.length,s=Array(r),n=Math.abs(e/r),i=Array(r);for(let t=0;t=Math.abs(n);){let e=a[0][0],s=a[0][1],n=g(e,s,x(t[e][e],t[s][s],t[e][s]),r);t=_(n,t),i=b(i,n),a=v(t)}for(let e=0;e0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;this._values=[t,e,r]}get x(){return this._values[0]}get y(){return this._values[1]}get z(){return this._values[2]}set x(t){this._values[0]=t}set y(t){this._values[1]=t}set z(t){this._values[2]=t}get length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}get lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}get normalized(){return 0===this.length?null:z.multScalar(this,1/this.length)}get colorInt(){return this._values.map((t=>{const e=parseInt(255*t+.5);return Math.max(Math.min(e,255),0)}))}clone(){return new z(this.x,this.y,this.z)}set(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;return this._values[0]=t,this._values[1]=e,this._values[2]=r,this}toVec4(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new V(this.x,this.y,this.z,t)}addVector(t){return this._values[0]+=t.x,this._values[1]+=t.y,this._values[2]+=t.z,this}addScaledVector(t,e){return this._values[0]+=t.x*e,this._values[1]+=t.y*e,this._values[2]+=t.z*e,this}mult(t){return this._values[0]*=t,this._values[1]*=t,this._values[2]*=t,this}multVector(t){return this._values[0]*=t.x,this._values[1]*=t.y,this._values[2]*=t.z,this}clamp(t,e){const r=r=>t>r?t:e{return Math.trunc((0>(r=t)?0:10&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t;this._values=[t,e,r,s]}get x(){return this._values[0]}get y(){return this._values[1]}get z(){return this._values[2]}get w(){return this._values[3]}set x(t){this._values[0]=t}set y(t){this._values[1]=t}set z(t){this._values[2]=t}set w(t){this._values[3]=t}get length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}get lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}get normalized(){return 0===this.length?null:V.multScalar(this,1/this.length)}get xyz(){return new z(this.x,this.y,this.z)}get splatX(){return new V(this.x)}get splatY(){return new V(this.y)}get splatZ(){return new V(this.z)}get splatW(){return new V(this.w)}clone(){return new V(this.x,this.y,this.z,this.w)}set(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t;return this._values[0]=t,this._values[1]=e,this._values[2]=r,this._values[3]=s,this}toVec3(){return this.xyz}addVector(t){return this._values[0]+=t.x,this._values[1]+=t.y,this._values[2]+=t.z,this._values[3]+=t.w,this}addScaledVector(t,e){return this._values[0]+=t.x*e,this._values[1]+=t.y*e,this._values[2]+=t.z*e,this._values[3]+=t.w*e,this}subVector(t){return this._values[0]-=t.x,this._values[1]-=t.y,this._values[2]-=t.z,this._values[3]-=t.w,this}mult(t){return this._values[0]*=t,this._values[1]*=t,this._values[2]*=t,this._values[3]*=t,this}multVector(t){return this._values[0]*=t.x,this._values[1]*=t.y,this._values[2]*=t.z,this._values[3]*=t.w,this}reciprocal(){return this._values[0]=1/this._values[0],this._values[1]=1/this._values[1],this._values[2]=1/this._values[2],this._values[3]=1/this._values[3],this}clamp(t,e){const r=r=>t>r?t:e0>t?0:1Math.trunc(t(e)*r+.5)/r;return this._values[0]=e(this._values[0],31),this._values[1]=e(this._values[1],63),this._values[2]=e(this._values[2],31),this._values[3]=t(this._values[3]),this}truncate(){return this._values[0]=Math.trunc(this._values[0]),this._values[1]=Math.trunc(this._values[1]),this._values[2]=Math.trunc(this._values[2]),this._values[3]=Math.trunc(this._values[3]),this}normalize(){return this._values[0]/=this.length,this._values[1]/=this.length,this._values[2]/=this.length,this._values[3]/=this.length,this}toString(){return"Vec4( ".concat(this._values.join(", ")," )")}static add(t,e){return new V(t.x+e.x,t.y+e.y,t.z+e.z,t.w+e.w)}static sub(t,e){return new V(t.x-e.x,t.y-e.y,t.z-e.z,t.w-e.w)}static dot(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w}static multScalar(t,e){return new V(t.x*e,t.y*e,t.z*e,t.w*e)}static multVector(t,e){return new V(t.x*e.x,t.y*e.y,t.z*e.z,t.w*e.w)}static interpolate(t,e,r){let s=V.multScalar(t,1-r),n=V.multScalar(e,r);return V.add(s,n)}static multiplyAdd(t,e,r){return new V(t.x*e.x+r.x,t.y*e.y+r.y,t.z*e.z+r.z,t.w*e.w+r.w)}static negativeMultiplySubtract(t,e,r){return new V(r.x-t.x*e.x,r.y-t.y*e.y,r.z-t.z*e.z,r.w-t.w*e.w)}static compareAnyLessThan(t,e){return t.x(r+=e[n],t.addScaledVector(s,e[n]),t)),new z(0));s.mult(1/r);let n=t.reduce(((t,r,n)=>{let i=e[n],a=z.sub(r,s);return t[0][0]+=a.x*a.x*i,t[0][1]+=a.x*a.y*i,t[0][2]+=a.x*a.z*i,t[1][1]+=a.y*a.y*i,t[1][2]+=a.y*a.z*i,t[2][2]+=a.z*a.z*i,t}),[[0,0,0],[0,0,0],[0,0,0]]);return n[1][0]=n[0][1],n[2][0]=n[0][2],n[2][1]=n[1][2],n}(t,e);return new z(...T(r))}const O=[[[0,0,0],[0,0,0]],[[0,0,1],[0,0,1]],[[0,0,2],[0,0,2]],[[0,0,3],[0,1,1]],[[0,0,4],[0,1,0]],[[1,0,3],[0,1,1]],[[1,0,2],[0,1,2]],[[1,0,1],[0,2,1]],[[1,0,0],[0,2,0]],[[1,0,1],[0,2,1]],[[1,0,2],[0,2,2]],[[1,0,3],[0,3,1]],[[1,0,4],[0,3,0]],[[2,0,3],[0,3,1]],[[2,0,2],[0,3,2]],[[2,0,1],[0,4,1]],[[2,0,0],[0,4,0]],[[2,0,1],[0,4,1]],[[2,0,2],[0,4,2]],[[2,0,3],[0,5,1]],[[2,0,4],[0,5,0]],[[3,0,3],[0,5,1]],[[3,0,2],[0,5,2]],[[3,0,1],[0,6,1]],[[3,0,0],[0,6,0]],[[3,0,1],[0,6,1]],[[3,0,2],[0,6,2]],[[3,0,3],[0,7,1]],[[3,0,4],[0,7,0]],[[4,0,4],[0,7,1]],[[4,0,3],[0,7,2]],[[4,0,2],[1,7,1]],[[4,0,1],[1,7,0]],[[4,0,0],[0,8,0]],[[4,0,1],[0,8,1]],[[4,0,2],[2,7,1]],[[4,0,3],[2,7,0]],[[4,0,4],[0,9,0]],[[5,0,3],[0,9,1]],[[5,0,2],[3,7,1]],[[5,0,1],[3,7,0]],[[5,0,0],[0,10,0]],[[5,0,1],[0,10,1]],[[5,0,2],[0,10,2]],[[5,0,3],[0,11,1]],[[5,0,4],[0,11,0]],[[6,0,3],[0,11,1]],[[6,0,2],[0,11,2]],[[6,0,1],[0,12,1]],[[6,0,0],[0,12,0]],[[6,0,1],[0,12,1]],[[6,0,2],[0,12,2]],[[6,0,3],[0,13,1]],[[6,0,4],[0,13,0]],[[7,0,3],[0,13,1]],[[7,0,2],[0,13,2]],[[7,0,1],[0,14,1]],[[7,0,0],[0,14,0]],[[7,0,1],[0,14,1]],[[7,0,2],[0,14,2]],[[7,0,3],[0,15,1]],[[7,0,4],[0,15,0]],[[8,0,4],[0,15,1]],[[8,0,3],[0,15,2]],[[8,0,2],[1,15,1]],[[8,0,1],[1,15,0]],[[8,0,0],[0,16,0]],[[8,0,1],[0,16,1]],[[8,0,2],[2,15,1]],[[8,0,3],[2,15,0]],[[8,0,4],[0,17,0]],[[9,0,3],[0,17,1]],[[9,0,2],[3,15,1]],[[9,0,1],[3,15,0]],[[9,0,0],[0,18,0]],[[9,0,1],[0,18,1]],[[9,0,2],[0,18,2]],[[9,0,3],[0,19,1]],[[9,0,4],[0,19,0]],[[10,0,3],[0,19,1]],[[10,0,2],[0,19,2]],[[10,0,1],[0,20,1]],[[10,0,0],[0,20,0]],[[10,0,1],[0,20,1]],[[10,0,2],[0,20,2]],[[10,0,3],[0,21,1]],[[10,0,4],[0,21,0]],[[11,0,3],[0,21,1]],[[11,0,2],[0,21,2]],[[11,0,1],[0,22,1]],[[11,0,0],[0,22,0]],[[11,0,1],[0,22,1]],[[11,0,2],[0,22,2]],[[11,0,3],[0,23,1]],[[11,0,4],[0,23,0]],[[12,0,4],[0,23,1]],[[12,0,3],[0,23,2]],[[12,0,2],[1,23,1]],[[12,0,1],[1,23,0]],[[12,0,0],[0,24,0]],[[12,0,1],[0,24,1]],[[12,0,2],[2,23,1]],[[12,0,3],[2,23,0]],[[12,0,4],[0,25,0]],[[13,0,3],[0,25,1]],[[13,0,2],[3,23,1]],[[13,0,1],[3,23,0]],[[13,0,0],[0,26,0]],[[13,0,1],[0,26,1]],[[13,0,2],[0,26,2]],[[13,0,3],[0,27,1]],[[13,0,4],[0,27,0]],[[14,0,3],[0,27,1]],[[14,0,2],[0,27,2]],[[14,0,1],[0,28,1]],[[14,0,0],[0,28,0]],[[14,0,1],[0,28,1]],[[14,0,2],[0,28,2]],[[14,0,3],[0,29,1]],[[14,0,4],[0,29,0]],[[15,0,3],[0,29,1]],[[15,0,2],[0,29,2]],[[15,0,1],[0,30,1]],[[15,0,0],[0,30,0]],[[15,0,1],[0,30,1]],[[15,0,2],[0,30,2]],[[15,0,3],[0,31,1]],[[15,0,4],[0,31,0]],[[16,0,4],[0,31,1]],[[16,0,3],[0,31,2]],[[16,0,2],[1,31,1]],[[16,0,1],[1,31,0]],[[16,0,0],[4,28,0]],[[16,0,1],[4,28,1]],[[16,0,2],[2,31,1]],[[16,0,3],[2,31,0]],[[16,0,4],[4,29,0]],[[17,0,3],[4,29,1]],[[17,0,2],[3,31,1]],[[17,0,1],[3,31,0]],[[17,0,0],[4,30,0]],[[17,0,1],[4,30,1]],[[17,0,2],[4,30,2]],[[17,0,3],[4,31,1]],[[17,0,4],[4,31,0]],[[18,0,3],[4,31,1]],[[18,0,2],[4,31,2]],[[18,0,1],[5,31,1]],[[18,0,0],[5,31,0]],[[18,0,1],[5,31,1]],[[18,0,2],[5,31,2]],[[18,0,3],[6,31,1]],[[18,0,4],[6,31,0]],[[19,0,3],[6,31,1]],[[19,0,2],[6,31,2]],[[19,0,1],[7,31,1]],[[19,0,0],[7,31,0]],[[19,0,1],[7,31,1]],[[19,0,2],[7,31,2]],[[19,0,3],[8,31,1]],[[19,0,4],[8,31,0]],[[20,0,4],[8,31,1]],[[20,0,3],[8,31,2]],[[20,0,2],[9,31,1]],[[20,0,1],[9,31,0]],[[20,0,0],[12,28,0]],[[20,0,1],[12,28,1]],[[20,0,2],[10,31,1]],[[20,0,3],[10,31,0]],[[20,0,4],[12,29,0]],[[21,0,3],[12,29,1]],[[21,0,2],[11,31,1]],[[21,0,1],[11,31,0]],[[21,0,0],[12,30,0]],[[21,0,1],[12,30,1]],[[21,0,2],[12,30,2]],[[21,0,3],[12,31,1]],[[21,0,4],[12,31,0]],[[22,0,3],[12,31,1]],[[22,0,2],[12,31,2]],[[22,0,1],[13,31,1]],[[22,0,0],[13,31,0]],[[22,0,1],[13,31,1]],[[22,0,2],[13,31,2]],[[22,0,3],[14,31,1]],[[22,0,4],[14,31,0]],[[23,0,3],[14,31,1]],[[23,0,2],[14,31,2]],[[23,0,1],[15,31,1]],[[23,0,0],[15,31,0]],[[23,0,1],[15,31,1]],[[23,0,2],[15,31,2]],[[23,0,3],[16,31,1]],[[23,0,4],[16,31,0]],[[24,0,4],[16,31,1]],[[24,0,3],[16,31,2]],[[24,0,2],[17,31,1]],[[24,0,1],[17,31,0]],[[24,0,0],[20,28,0]],[[24,0,1],[20,28,1]],[[24,0,2],[18,31,1]],[[24,0,3],[18,31,0]],[[24,0,4],[20,29,0]],[[25,0,3],[20,29,1]],[[25,0,2],[19,31,1]],[[25,0,1],[19,31,0]],[[25,0,0],[20,30,0]],[[25,0,1],[20,30,1]],[[25,0,2],[20,30,2]],[[25,0,3],[20,31,1]],[[25,0,4],[20,31,0]],[[26,0,3],[20,31,1]],[[26,0,2],[20,31,2]],[[26,0,1],[21,31,1]],[[26,0,0],[21,31,0]],[[26,0,1],[21,31,1]],[[26,0,2],[21,31,2]],[[26,0,3],[22,31,1]],[[26,0,4],[22,31,0]],[[27,0,3],[22,31,1]],[[27,0,2],[22,31,2]],[[27,0,1],[23,31,1]],[[27,0,0],[23,31,0]],[[27,0,1],[23,31,1]],[[27,0,2],[23,31,2]],[[27,0,3],[24,31,1]],[[27,0,4],[24,31,0]],[[28,0,4],[24,31,1]],[[28,0,3],[24,31,2]],[[28,0,2],[25,31,1]],[[28,0,1],[25,31,0]],[[28,0,0],[28,28,0]],[[28,0,1],[28,28,1]],[[28,0,2],[26,31,1]],[[28,0,3],[26,31,0]],[[28,0,4],[28,29,0]],[[29,0,3],[28,29,1]],[[29,0,2],[27,31,1]],[[29,0,1],[27,31,0]],[[29,0,0],[28,30,0]],[[29,0,1],[28,30,1]],[[29,0,2],[28,30,2]],[[29,0,3],[28,31,1]],[[29,0,4],[28,31,0]],[[30,0,3],[28,31,1]],[[30,0,2],[28,31,2]],[[30,0,1],[29,31,1]],[[30,0,0],[29,31,0]],[[30,0,1],[29,31,1]],[[30,0,2],[29,31,2]],[[30,0,3],[30,31,1]],[[30,0,4],[30,31,0]],[[31,0,3],[30,31,1]],[[31,0,2],[30,31,2]],[[31,0,1],[31,31,1]],[[31,0,0],[31,31,0]]],k=[[[0,0,0],[0,0,0]],[[0,0,1],[0,1,1]],[[0,0,2],[0,1,0]],[[1,0,1],[0,2,1]],[[1,0,0],[0,2,0]],[[1,0,1],[0,3,1]],[[1,0,2],[0,3,0]],[[2,0,1],[0,4,1]],[[2,0,0],[0,4,0]],[[2,0,1],[0,5,1]],[[2,0,2],[0,5,0]],[[3,0,1],[0,6,1]],[[3,0,0],[0,6,0]],[[3,0,1],[0,7,1]],[[3,0,2],[0,7,0]],[[4,0,1],[0,8,1]],[[4,0,0],[0,8,0]],[[4,0,1],[0,9,1]],[[4,0,2],[0,9,0]],[[5,0,1],[0,10,1]],[[5,0,0],[0,10,0]],[[5,0,1],[0,11,1]],[[5,0,2],[0,11,0]],[[6,0,1],[0,12,1]],[[6,0,0],[0,12,0]],[[6,0,1],[0,13,1]],[[6,0,2],[0,13,0]],[[7,0,1],[0,14,1]],[[7,0,0],[0,14,0]],[[7,0,1],[0,15,1]],[[7,0,2],[0,15,0]],[[8,0,1],[0,16,1]],[[8,0,0],[0,16,0]],[[8,0,1],[0,17,1]],[[8,0,2],[0,17,0]],[[9,0,1],[0,18,1]],[[9,0,0],[0,18,0]],[[9,0,1],[0,19,1]],[[9,0,2],[0,19,0]],[[10,0,1],[0,20,1]],[[10,0,0],[0,20,0]],[[10,0,1],[0,21,1]],[[10,0,2],[0,21,0]],[[11,0,1],[0,22,1]],[[11,0,0],[0,22,0]],[[11,0,1],[0,23,1]],[[11,0,2],[0,23,0]],[[12,0,1],[0,24,1]],[[12,0,0],[0,24,0]],[[12,0,1],[0,25,1]],[[12,0,2],[0,25,0]],[[13,0,1],[0,26,1]],[[13,0,0],[0,26,0]],[[13,0,1],[0,27,1]],[[13,0,2],[0,27,0]],[[14,0,1],[0,28,1]],[[14,0,0],[0,28,0]],[[14,0,1],[0,29,1]],[[14,0,2],[0,29,0]],[[15,0,1],[0,30,1]],[[15,0,0],[0,30,0]],[[15,0,1],[0,31,1]],[[15,0,2],[0,31,0]],[[16,0,2],[1,31,1]],[[16,0,1],[1,31,0]],[[16,0,0],[0,32,0]],[[16,0,1],[2,31,0]],[[16,0,2],[0,33,0]],[[17,0,1],[3,31,0]],[[17,0,0],[0,34,0]],[[17,0,1],[4,31,0]],[[17,0,2],[0,35,0]],[[18,0,1],[5,31,0]],[[18,0,0],[0,36,0]],[[18,0,1],[6,31,0]],[[18,0,2],[0,37,0]],[[19,0,1],[7,31,0]],[[19,0,0],[0,38,0]],[[19,0,1],[8,31,0]],[[19,0,2],[0,39,0]],[[20,0,1],[9,31,0]],[[20,0,0],[0,40,0]],[[20,0,1],[10,31,0]],[[20,0,2],[0,41,0]],[[21,0,1],[11,31,0]],[[21,0,0],[0,42,0]],[[21,0,1],[12,31,0]],[[21,0,2],[0,43,0]],[[22,0,1],[13,31,0]],[[22,0,0],[0,44,0]],[[22,0,1],[14,31,0]],[[22,0,2],[0,45,0]],[[23,0,1],[15,31,0]],[[23,0,0],[0,46,0]],[[23,0,1],[0,47,1]],[[23,0,2],[0,47,0]],[[24,0,1],[0,48,1]],[[24,0,0],[0,48,0]],[[24,0,1],[0,49,1]],[[24,0,2],[0,49,0]],[[25,0,1],[0,50,1]],[[25,0,0],[0,50,0]],[[25,0,1],[0,51,1]],[[25,0,2],[0,51,0]],[[26,0,1],[0,52,1]],[[26,0,0],[0,52,0]],[[26,0,1],[0,53,1]],[[26,0,2],[0,53,0]],[[27,0,1],[0,54,1]],[[27,0,0],[0,54,0]],[[27,0,1],[0,55,1]],[[27,0,2],[0,55,0]],[[28,0,1],[0,56,1]],[[28,0,0],[0,56,0]],[[28,0,1],[0,57,1]],[[28,0,2],[0,57,0]],[[29,0,1],[0,58,1]],[[29,0,0],[0,58,0]],[[29,0,1],[0,59,1]],[[29,0,2],[0,59,0]],[[30,0,1],[0,60,1]],[[30,0,0],[0,60,0]],[[30,0,1],[0,61,1]],[[30,0,2],[0,61,0]],[[31,0,1],[0,62,1]],[[31,0,0],[0,62,0]],[[31,0,1],[0,63,1]],[[31,0,2],[0,63,0]],[[32,0,2],[1,63,1]],[[32,0,1],[1,63,0]],[[32,0,0],[16,48,0]],[[32,0,1],[2,63,0]],[[32,0,2],[16,49,0]],[[33,0,1],[3,63,0]],[[33,0,0],[16,50,0]],[[33,0,1],[4,63,0]],[[33,0,2],[16,51,0]],[[34,0,1],[5,63,0]],[[34,0,0],[16,52,0]],[[34,0,1],[6,63,0]],[[34,0,2],[16,53,0]],[[35,0,1],[7,63,0]],[[35,0,0],[16,54,0]],[[35,0,1],[8,63,0]],[[35,0,2],[16,55,0]],[[36,0,1],[9,63,0]],[[36,0,0],[16,56,0]],[[36,0,1],[10,63,0]],[[36,0,2],[16,57,0]],[[37,0,1],[11,63,0]],[[37,0,0],[16,58,0]],[[37,0,1],[12,63,0]],[[37,0,2],[16,59,0]],[[38,0,1],[13,63,0]],[[38,0,0],[16,60,0]],[[38,0,1],[14,63,0]],[[38,0,2],[16,61,0]],[[39,0,1],[15,63,0]],[[39,0,0],[16,62,0]],[[39,0,1],[16,63,1]],[[39,0,2],[16,63,0]],[[40,0,1],[17,63,1]],[[40,0,0],[17,63,0]],[[40,0,1],[18,63,1]],[[40,0,2],[18,63,0]],[[41,0,1],[19,63,1]],[[41,0,0],[19,63,0]],[[41,0,1],[20,63,1]],[[41,0,2],[20,63,0]],[[42,0,1],[21,63,1]],[[42,0,0],[21,63,0]],[[42,0,1],[22,63,1]],[[42,0,2],[22,63,0]],[[43,0,1],[23,63,1]],[[43,0,0],[23,63,0]],[[43,0,1],[24,63,1]],[[43,0,2],[24,63,0]],[[44,0,1],[25,63,1]],[[44,0,0],[25,63,0]],[[44,0,1],[26,63,1]],[[44,0,2],[26,63,0]],[[45,0,1],[27,63,1]],[[45,0,0],[27,63,0]],[[45,0,1],[28,63,1]],[[45,0,2],[28,63,0]],[[46,0,1],[29,63,1]],[[46,0,0],[29,63,0]],[[46,0,1],[30,63,1]],[[46,0,2],[30,63,0]],[[47,0,1],[31,63,1]],[[47,0,0],[31,63,0]],[[47,0,1],[32,63,1]],[[47,0,2],[32,63,0]],[[48,0,2],[33,63,1]],[[48,0,1],[33,63,0]],[[48,0,0],[48,48,0]],[[48,0,1],[34,63,0]],[[48,0,2],[48,49,0]],[[49,0,1],[35,63,0]],[[49,0,0],[48,50,0]],[[49,0,1],[36,63,0]],[[49,0,2],[48,51,0]],[[50,0,1],[37,63,0]],[[50,0,0],[48,52,0]],[[50,0,1],[38,63,0]],[[50,0,2],[48,53,0]],[[51,0,1],[39,63,0]],[[51,0,0],[48,54,0]],[[51,0,1],[40,63,0]],[[51,0,2],[48,55,0]],[[52,0,1],[41,63,0]],[[52,0,0],[48,56,0]],[[52,0,1],[42,63,0]],[[52,0,2],[48,57,0]],[[53,0,1],[43,63,0]],[[53,0,0],[48,58,0]],[[53,0,1],[44,63,0]],[[53,0,2],[48,59,0]],[[54,0,1],[45,63,0]],[[54,0,0],[48,60,0]],[[54,0,1],[46,63,0]],[[54,0,2],[48,61,0]],[[55,0,1],[47,63,0]],[[55,0,0],[48,62,0]],[[55,0,1],[48,63,1]],[[55,0,2],[48,63,0]],[[56,0,1],[49,63,1]],[[56,0,0],[49,63,0]],[[56,0,1],[50,63,1]],[[56,0,2],[50,63,0]],[[57,0,1],[51,63,1]],[[57,0,0],[51,63,0]],[[57,0,1],[52,63,1]],[[57,0,2],[52,63,0]],[[58,0,1],[53,63,1]],[[58,0,0],[53,63,0]],[[58,0,1],[54,63,1]],[[58,0,2],[54,63,0]],[[59,0,1],[55,63,1]],[[59,0,0],[55,63,0]],[[59,0,1],[56,63,1]],[[59,0,2],[56,63,0]],[[60,0,1],[57,63,1]],[[60,0,0],[57,63,0]],[[60,0,1],[58,63,1]],[[60,0,2],[58,63,0]],[[61,0,1],[59,63,1]],[[61,0,0],[59,63,0]],[[61,0,1],[60,63,1]],[[61,0,2],[60,63,0]],[[62,0,1],[61,63,1]],[[62,0,0],[61,63,0]],[[62,0,1],[62,63,1]],[[62,0,2],[62,63,0]],[[63,0,1],[63,63,1]],[[63,0,0],[63,63,0]]],R=[[[0,0,0],[0,0,0]],[[0,0,1],[0,1,1]],[[0,0,2],[0,1,0]],[[0,0,3],[0,1,1]],[[0,0,4],[0,2,1]],[[1,0,3],[0,2,0]],[[1,0,2],[0,2,1]],[[1,0,1],[0,3,1]],[[1,0,0],[0,3,0]],[[1,0,1],[1,2,1]],[[1,0,2],[1,2,0]],[[1,0,3],[0,4,0]],[[1,0,4],[0,5,1]],[[2,0,3],[0,5,0]],[[2,0,2],[0,5,1]],[[2,0,1],[0,6,1]],[[2,0,0],[0,6,0]],[[2,0,1],[2,3,1]],[[2,0,2],[2,3,0]],[[2,0,3],[0,7,0]],[[2,0,4],[1,6,1]],[[3,0,3],[1,6,0]],[[3,0,2],[0,8,0]],[[3,0,1],[0,9,1]],[[3,0,0],[0,9,0]],[[3,0,1],[0,9,1]],[[3,0,2],[0,10,1]],[[3,0,3],[0,10,0]],[[3,0,4],[2,7,1]],[[4,0,4],[2,7,0]],[[4,0,3],[0,11,0]],[[4,0,2],[1,10,1]],[[4,0,1],[1,10,0]],[[4,0,0],[0,12,0]],[[4,0,1],[0,13,1]],[[4,0,2],[0,13,0]],[[4,0,3],[0,13,1]],[[4,0,4],[0,14,1]],[[5,0,3],[0,14,0]],[[5,0,2],[2,11,1]],[[5,0,1],[2,11,0]],[[5,0,0],[0,15,0]],[[5,0,1],[1,14,1]],[[5,0,2],[1,14,0]],[[5,0,3],[0,16,0]],[[5,0,4],[0,17,1]],[[6,0,3],[0,17,0]],[[6,0,2],[0,17,1]],[[6,0,1],[0,18,1]],[[6,0,0],[0,18,0]],[[6,0,1],[2,15,1]],[[6,0,2],[2,15,0]],[[6,0,3],[0,19,0]],[[6,0,4],[1,18,1]],[[7,0,3],[1,18,0]],[[7,0,2],[0,20,0]],[[7,0,1],[0,21,1]],[[7,0,0],[0,21,0]],[[7,0,1],[0,21,1]],[[7,0,2],[0,22,1]],[[7,0,3],[0,22,0]],[[7,0,4],[2,19,1]],[[8,0,4],[2,19,0]],[[8,0,3],[0,23,0]],[[8,0,2],[1,22,1]],[[8,0,1],[1,22,0]],[[8,0,0],[0,24,0]],[[8,0,1],[0,25,1]],[[8,0,2],[0,25,0]],[[8,0,3],[0,25,1]],[[8,0,4],[0,26,1]],[[9,0,3],[0,26,0]],[[9,0,2],[2,23,1]],[[9,0,1],[2,23,0]],[[9,0,0],[0,27,0]],[[9,0,1],[1,26,1]],[[9,0,2],[1,26,0]],[[9,0,3],[0,28,0]],[[9,0,4],[0,29,1]],[[10,0,3],[0,29,0]],[[10,0,2],[0,29,1]],[[10,0,1],[0,30,1]],[[10,0,0],[0,30,0]],[[10,0,1],[2,27,1]],[[10,0,2],[2,27,0]],[[10,0,3],[0,31,0]],[[10,0,4],[1,30,1]],[[11,0,3],[1,30,0]],[[11,0,2],[4,24,0]],[[11,0,1],[1,31,1]],[[11,0,0],[1,31,0]],[[11,0,1],[1,31,1]],[[11,0,2],[2,30,1]],[[11,0,3],[2,30,0]],[[11,0,4],[2,31,1]],[[12,0,4],[2,31,0]],[[12,0,3],[4,27,0]],[[12,0,2],[3,30,1]],[[12,0,1],[3,30,0]],[[12,0,0],[4,28,0]],[[12,0,1],[3,31,1]],[[12,0,2],[3,31,0]],[[12,0,3],[3,31,1]],[[12,0,4],[4,30,1]],[[13,0,3],[4,30,0]],[[13,0,2],[6,27,1]],[[13,0,1],[6,27,0]],[[13,0,0],[4,31,0]],[[13,0,1],[5,30,1]],[[13,0,2],[5,30,0]],[[13,0,3],[8,24,0]],[[13,0,4],[5,31,1]],[[14,0,3],[5,31,0]],[[14,0,2],[5,31,1]],[[14,0,1],[6,30,1]],[[14,0,0],[6,30,0]],[[14,0,1],[6,31,1]],[[14,0,2],[6,31,0]],[[14,0,3],[8,27,0]],[[14,0,4],[7,30,1]],[[15,0,3],[7,30,0]],[[15,0,2],[8,28,0]],[[15,0,1],[7,31,1]],[[15,0,0],[7,31,0]],[[15,0,1],[7,31,1]],[[15,0,2],[8,30,1]],[[15,0,3],[8,30,0]],[[15,0,4],[10,27,1]],[[16,0,4],[10,27,0]],[[16,0,3],[8,31,0]],[[16,0,2],[9,30,1]],[[16,0,1],[9,30,0]],[[16,0,0],[12,24,0]],[[16,0,1],[9,31,1]],[[16,0,2],[9,31,0]],[[16,0,3],[9,31,1]],[[16,0,4],[10,30,1]],[[17,0,3],[10,30,0]],[[17,0,2],[10,31,1]],[[17,0,1],[10,31,0]],[[17,0,0],[12,27,0]],[[17,0,1],[11,30,1]],[[17,0,2],[11,30,0]],[[17,0,3],[12,28,0]],[[17,0,4],[11,31,1]],[[18,0,3],[11,31,0]],[[18,0,2],[11,31,1]],[[18,0,1],[12,30,1]],[[18,0,0],[12,30,0]],[[18,0,1],[14,27,1]],[[18,0,2],[14,27,0]],[[18,0,3],[12,31,0]],[[18,0,4],[13,30,1]],[[19,0,3],[13,30,0]],[[19,0,2],[16,24,0]],[[19,0,1],[13,31,1]],[[19,0,0],[13,31,0]],[[19,0,1],[13,31,1]],[[19,0,2],[14,30,1]],[[19,0,3],[14,30,0]],[[19,0,4],[14,31,1]],[[20,0,4],[14,31,0]],[[20,0,3],[16,27,0]],[[20,0,2],[15,30,1]],[[20,0,1],[15,30,0]],[[20,0,0],[16,28,0]],[[20,0,1],[15,31,1]],[[20,0,2],[15,31,0]],[[20,0,3],[15,31,1]],[[20,0,4],[16,30,1]],[[21,0,3],[16,30,0]],[[21,0,2],[18,27,1]],[[21,0,1],[18,27,0]],[[21,0,0],[16,31,0]],[[21,0,1],[17,30,1]],[[21,0,2],[17,30,0]],[[21,0,3],[20,24,0]],[[21,0,4],[17,31,1]],[[22,0,3],[17,31,0]],[[22,0,2],[17,31,1]],[[22,0,1],[18,30,1]],[[22,0,0],[18,30,0]],[[22,0,1],[18,31,1]],[[22,0,2],[18,31,0]],[[22,0,3],[20,27,0]],[[22,0,4],[19,30,1]],[[23,0,3],[19,30,0]],[[23,0,2],[20,28,0]],[[23,0,1],[19,31,1]],[[23,0,0],[19,31,0]],[[23,0,1],[19,31,1]],[[23,0,2],[20,30,1]],[[23,0,3],[20,30,0]],[[23,0,4],[22,27,1]],[[24,0,4],[22,27,0]],[[24,0,3],[20,31,0]],[[24,0,2],[21,30,1]],[[24,0,1],[21,30,0]],[[24,0,0],[24,24,0]],[[24,0,1],[21,31,1]],[[24,0,2],[21,31,0]],[[24,0,3],[21,31,1]],[[24,0,4],[22,30,1]],[[25,0,3],[22,30,0]],[[25,0,2],[22,31,1]],[[25,0,1],[22,31,0]],[[25,0,0],[24,27,0]],[[25,0,1],[23,30,1]],[[25,0,2],[23,30,0]],[[25,0,3],[24,28,0]],[[25,0,4],[23,31,1]],[[26,0,3],[23,31,0]],[[26,0,2],[23,31,1]],[[26,0,1],[24,30,1]],[[26,0,0],[24,30,0]],[[26,0,1],[26,27,1]],[[26,0,2],[26,27,0]],[[26,0,3],[24,31,0]],[[26,0,4],[25,30,1]],[[27,0,3],[25,30,0]],[[27,0,2],[28,24,0]],[[27,0,1],[25,31,1]],[[27,0,0],[25,31,0]],[[27,0,1],[25,31,1]],[[27,0,2],[26,30,1]],[[27,0,3],[26,30,0]],[[27,0,4],[26,31,1]],[[28,0,4],[26,31,0]],[[28,0,3],[28,27,0]],[[28,0,2],[27,30,1]],[[28,0,1],[27,30,0]],[[28,0,0],[28,28,0]],[[28,0,1],[27,31,1]],[[28,0,2],[27,31,0]],[[28,0,3],[27,31,1]],[[28,0,4],[28,30,1]],[[29,0,3],[28,30,0]],[[29,0,2],[30,27,1]],[[29,0,1],[30,27,0]],[[29,0,0],[28,31,0]],[[29,0,1],[29,30,1]],[[29,0,2],[29,30,0]],[[29,0,3],[29,30,1]],[[29,0,4],[29,31,1]],[[30,0,3],[29,31,0]],[[30,0,2],[29,31,1]],[[30,0,1],[30,30,1]],[[30,0,0],[30,30,0]],[[30,0,1],[30,31,1]],[[30,0,2],[30,31,0]],[[30,0,3],[30,31,1]],[[30,0,4],[31,30,1]],[[31,0,3],[31,30,0]],[[31,0,2],[31,30,1]],[[31,0,1],[31,31,1]],[[31,0,0],[31,31,0]]],A=[[[0,0,0],[0,0,0]],[[0,0,1],[0,1,0]],[[0,0,2],[0,2,0]],[[1,0,1],[0,3,1]],[[1,0,0],[0,3,0]],[[1,0,1],[0,4,0]],[[1,0,2],[0,5,0]],[[2,0,1],[0,6,1]],[[2,0,0],[0,6,0]],[[2,0,1],[0,7,0]],[[2,0,2],[0,8,0]],[[3,0,1],[0,9,1]],[[3,0,0],[0,9,0]],[[3,0,1],[0,10,0]],[[3,0,2],[0,11,0]],[[4,0,1],[0,12,1]],[[4,0,0],[0,12,0]],[[4,0,1],[0,13,0]],[[4,0,2],[0,14,0]],[[5,0,1],[0,15,1]],[[5,0,0],[0,15,0]],[[5,0,1],[0,16,0]],[[5,0,2],[1,15,0]],[[6,0,1],[0,17,0]],[[6,0,0],[0,18,0]],[[6,0,1],[0,19,0]],[[6,0,2],[3,14,0]],[[7,0,1],[0,20,0]],[[7,0,0],[0,21,0]],[[7,0,1],[0,22,0]],[[7,0,2],[4,15,0]],[[8,0,1],[0,23,0]],[[8,0,0],[0,24,0]],[[8,0,1],[0,25,0]],[[8,0,2],[6,14,0]],[[9,0,1],[0,26,0]],[[9,0,0],[0,27,0]],[[9,0,1],[0,28,0]],[[9,0,2],[7,15,0]],[[10,0,1],[0,29,0]],[[10,0,0],[0,30,0]],[[10,0,1],[0,31,0]],[[10,0,2],[9,14,0]],[[11,0,1],[0,32,0]],[[11,0,0],[0,33,0]],[[11,0,1],[2,30,0]],[[11,0,2],[0,34,0]],[[12,0,1],[0,35,0]],[[12,0,0],[0,36,0]],[[12,0,1],[3,31,0]],[[12,0,2],[0,37,0]],[[13,0,1],[0,38,0]],[[13,0,0],[0,39,0]],[[13,0,1],[5,30,0]],[[13,0,2],[0,40,0]],[[14,0,1],[0,41,0]],[[14,0,0],[0,42,0]],[[14,0,1],[6,31,0]],[[14,0,2],[0,43,0]],[[15,0,1],[0,44,0]],[[15,0,0],[0,45,0]],[[15,0,1],[8,30,0]],[[15,0,2],[0,46,0]],[[16,0,2],[0,47,0]],[[16,0,1],[1,46,0]],[[16,0,0],[0,48,0]],[[16,0,1],[0,49,0]],[[16,0,2],[0,50,0]],[[17,0,1],[2,47,0]],[[17,0,0],[0,51,0]],[[17,0,1],[0,52,0]],[[17,0,2],[0,53,0]],[[18,0,1],[4,46,0]],[[18,0,0],[0,54,0]],[[18,0,1],[0,55,0]],[[18,0,2],[0,56,0]],[[19,0,1],[5,47,0]],[[19,0,0],[0,57,0]],[[19,0,1],[0,58,0]],[[19,0,2],[0,59,0]],[[20,0,1],[7,46,0]],[[20,0,0],[0,60,0]],[[20,0,1],[0,61,0]],[[20,0,2],[0,62,0]],[[21,0,1],[8,47,0]],[[21,0,0],[0,63,0]],[[21,0,1],[1,62,0]],[[21,0,2],[1,63,0]],[[22,0,1],[10,46,0]],[[22,0,0],[2,62,0]],[[22,0,1],[2,63,0]],[[22,0,2],[3,62,0]],[[23,0,1],[11,47,0]],[[23,0,0],[3,63,0]],[[23,0,1],[4,62,0]],[[23,0,2],[4,63,0]],[[24,0,1],[13,46,0]],[[24,0,0],[5,62,0]],[[24,0,1],[5,63,0]],[[24,0,2],[6,62,0]],[[25,0,1],[14,47,0]],[[25,0,0],[6,63,0]],[[25,0,1],[7,62,0]],[[25,0,2],[7,63,0]],[[26,0,1],[16,45,0]],[[26,0,0],[8,62,0]],[[26,0,1],[8,63,0]],[[26,0,2],[9,62,0]],[[27,0,1],[16,48,0]],[[27,0,0],[9,63,0]],[[27,0,1],[10,62,0]],[[27,0,2],[10,63,0]],[[28,0,1],[16,51,0]],[[28,0,0],[11,62,0]],[[28,0,1],[11,63,0]],[[28,0,2],[12,62,0]],[[29,0,1],[16,54,0]],[[29,0,0],[12,63,0]],[[29,0,1],[13,62,0]],[[29,0,2],[13,63,0]],[[30,0,1],[16,57,0]],[[30,0,0],[14,62,0]],[[30,0,1],[14,63,0]],[[30,0,2],[15,62,0]],[[31,0,1],[16,60,0]],[[31,0,0],[15,63,0]],[[31,0,1],[24,46,0]],[[31,0,2],[16,62,0]],[[32,0,2],[16,63,0]],[[32,0,1],[17,62,0]],[[32,0,0],[25,47,0]],[[32,0,1],[17,63,0]],[[32,0,2],[18,62,0]],[[33,0,1],[18,63,0]],[[33,0,0],[27,46,0]],[[33,0,1],[19,62,0]],[[33,0,2],[19,63,0]],[[34,0,1],[20,62,0]],[[34,0,0],[28,47,0]],[[34,0,1],[20,63,0]],[[34,0,2],[21,62,0]],[[35,0,1],[21,63,0]],[[35,0,0],[30,46,0]],[[35,0,1],[22,62,0]],[[35,0,2],[22,63,0]],[[36,0,1],[23,62,0]],[[36,0,0],[31,47,0]],[[36,0,1],[23,63,0]],[[36,0,2],[24,62,0]],[[37,0,1],[24,63,0]],[[37,0,0],[32,47,0]],[[37,0,1],[25,62,0]],[[37,0,2],[25,63,0]],[[38,0,1],[26,62,0]],[[38,0,0],[32,50,0]],[[38,0,1],[26,63,0]],[[38,0,2],[27,62,0]],[[39,0,1],[27,63,0]],[[39,0,0],[32,53,0]],[[39,0,1],[28,62,0]],[[39,0,2],[28,63,0]],[[40,0,1],[29,62,0]],[[40,0,0],[32,56,0]],[[40,0,1],[29,63,0]],[[40,0,2],[30,62,0]],[[41,0,1],[30,63,0]],[[41,0,0],[32,59,0]],[[41,0,1],[31,62,0]],[[41,0,2],[31,63,0]],[[42,0,1],[32,61,0]],[[42,0,0],[32,62,0]],[[42,0,1],[32,63,0]],[[42,0,2],[41,46,0]],[[43,0,1],[33,62,0]],[[43,0,0],[33,63,0]],[[43,0,1],[34,62,0]],[[43,0,2],[42,47,0]],[[44,0,1],[34,63,0]],[[44,0,0],[35,62,0]],[[44,0,1],[35,63,0]],[[44,0,2],[44,46,0]],[[45,0,1],[36,62,0]],[[45,0,0],[36,63,0]],[[45,0,1],[37,62,0]],[[45,0,2],[45,47,0]],[[46,0,1],[37,63,0]],[[46,0,0],[38,62,0]],[[46,0,1],[38,63,0]],[[46,0,2],[47,46,0]],[[47,0,1],[39,62,0]],[[47,0,0],[39,63,0]],[[47,0,1],[40,62,0]],[[47,0,2],[48,46,0]],[[48,0,2],[40,63,0]],[[48,0,1],[41,62,0]],[[48,0,0],[41,63,0]],[[48,0,1],[48,49,0]],[[48,0,2],[42,62,0]],[[49,0,1],[42,63,0]],[[49,0,0],[43,62,0]],[[49,0,1],[48,52,0]],[[49,0,2],[43,63,0]],[[50,0,1],[44,62,0]],[[50,0,0],[44,63,0]],[[50,0,1],[48,55,0]],[[50,0,2],[45,62,0]],[[51,0,1],[45,63,0]],[[51,0,0],[46,62,0]],[[51,0,1],[48,58,0]],[[51,0,2],[46,63,0]],[[52,0,1],[47,62,0]],[[52,0,0],[47,63,0]],[[52,0,1],[48,61,0]],[[52,0,2],[48,62,0]],[[53,0,1],[56,47,0]],[[53,0,0],[48,63,0]],[[53,0,1],[49,62,0]],[[53,0,2],[49,63,0]],[[54,0,1],[58,46,0]],[[54,0,0],[50,62,0]],[[54,0,1],[50,63,0]],[[54,0,2],[51,62,0]],[[55,0,1],[59,47,0]],[[55,0,0],[51,63,0]],[[55,0,1],[52,62,0]],[[55,0,2],[52,63,0]],[[56,0,1],[61,46,0]],[[56,0,0],[53,62,0]],[[56,0,1],[53,63,0]],[[56,0,2],[54,62,0]],[[57,0,1],[62,47,0]],[[57,0,0],[54,63,0]],[[57,0,1],[55,62,0]],[[57,0,2],[55,63,0]],[[58,0,1],[56,62,1]],[[58,0,0],[56,62,0]],[[58,0,1],[56,63,0]],[[58,0,2],[57,62,0]],[[59,0,1],[57,63,1]],[[59,0,0],[57,63,0]],[[59,0,1],[58,62,0]],[[59,0,2],[58,63,0]],[[60,0,1],[59,62,1]],[[60,0,0],[59,62,0]],[[60,0,1],[59,63,0]],[[60,0,2],[60,62,0]],[[61,0,1],[60,63,1]],[[61,0,0],[60,63,0]],[[61,0,1],[61,62,0]],[[61,0,2],[61,63,0]],[[62,0,1],[62,62,1]],[[62,0,0],[62,62,0]],[[62,0,1],[62,63,0]],[[62,0,2],[63,62,0]],[[63,0,1],[63,63,1]],[[63,0,0],[63,63,0]]];function I(t,e){const r=parseInt(t+.5);return r<0?0:r}function C(t){return I(31*t.x)<<11|I(63*t.y)<<5|I(31*t.z)}function F(t,e,r,s,n){s[n+0]=255&t,s[n+1]=t>>8,s[n+2]=255&e,s[n+3]=e>>8;for(let t=0;t<4;t++)s[n+4+t]=r[4*t+0]|r[4*t+1]<<2|r[4*t+2]<<4|r[4*t+3]<<6}function B(t,e,r,s,n){let i,a=C(t),o=C(e);a<=o?i=r.slice():([a,o]=[o,a],i=r.map((t=>0===t?1:1===t?0:t))),F(a,o,i,s,n)}function E(t,e,r,s,n){let i,a=C(t),o=C(e);a3&(1^t)))):i=a==o?new Array(16).fill(0):r.slice(),F(a,o,i,s,n)}class L{constructor(t,e,r){this.flags=r,this._count=0,this._transparent=!1,this._remap=[],this._weights=[],this._points=[];const s=0!=(1&this.flags),n=0!=(128&this.flags);for(let r=0;r<16;r++){if(0!=(e&1<=128||!s)){const e=this._remap[i],s=(t[4*r+3]+1)/256;this._weights[e]+=n?s:1,this._remap[r]=e;break}}else this._remap[r]=-1}for(let t=0;t-1===e?3:t));e.forEach(((t,s)=>e[s]=r[s]))}remapIndices(t,e){const r=this._remap.map((e=>-1===e?3:t[e]));e.forEach(((t,s)=>e[s]=r[s]))}}class U{constructor(t){this.colors=t,this.flags=t.flags}compress(t,e){0!=(1&this.flags)?(this.compress3(t,e),this.colors.transparent||this.compress4(t,e)):this.compress4(t,e)}compress3(t,e){}compress4(t,e){}}class X extends U{constructor(t){super(t);const e=t.points[0];this.color=e.colorInt,this.start=new z(0),this.end=new z(0),this.index=0,this.error=1/0,this.bestError=1/0}compressBase(t,e){if(this.computeEndPoints(t),this.errorB(r,s,n,t,e)))}compress4(t,e){const r=[R,A,R];this.compressBase(r,((r,s,n)=>E(r,s,n,t,e)))}computeEndPoints(t){this.error=1/0;for(let e=0;e<2;e++){const r=[];let s=0;for(let n=0;n<3;n++){const i=t[n],a=this.color[n];r[n]=i[a][e];const o=r[n][2];s+=o*o}s{let r=1/0;const n=t.reduce(((t,s,n)=>{const i=z.sub(e,s).multVector(this.metric).lengthSq;return i>=r?t:(r=i,n)}),0);return s+=r,n}));if(sB(r,s,n,t,e)))}compress4(t,e){const r=[this.start.clone(),this.end.clone(),z.interpolate(this.start,this.end,1/3),z.interpolate(this.start,this.end,2/3)];this.compressBase(r,((r,s,n)=>E(r,s,n,t,e)))}computePoints(){const{count:t,points:e,weights:r}=this.colors;if(t<=0)return;const s=S(e,r);let n,i,a,o;n=i=e[0],a=o=z.dot(n,s);for(let r=1;ro&&(i=e[r],o=t)}this.start=n.clampGrid().clone(),this.end=i.clampGrid().clone()}}class D extends U{constructor(t){super(t);this.iterationCount=t.flags&w?8:1,this.bestError=1/0,this.metric=new V(1),0!=(32&this.flags)&&this.metric.set(.2126,.7152,.0722,0);const{points:e,weights:r}=this.colors;this.principle=S(e,r),this.order=new Uint8Array(128),this.pointsWeights=[],this.xSum_wSum=new V(0)}constructOrdering(t,e){const r=this.makeOrder(t);this.copyOrderToThisOrder(r,e);return!!this.checkOrderUnique(r,e)&&(this.copyOrderWeight(r),!0)}compress3(t,e){this.compressBase((t=>{let[e,,r,s]=t;const n=new V(.5,.5,.5,1/4),i=V.multiplyAdd(r,n,e),a=i.splatW,o=V.multiplyAdd(r,n,s);return{ax:i,aa:a,bx:o,bb:o.splatW,ab:V.multVector(r,n).splatW}}),((r,s,n)=>B(r,s,n,t,e)),2)}compress4(t,e){this.compressBase((t=>{let[e,r,s,n]=t;const i=new V(1/3,1/3,1/3,1/9),a=new V(2/3,2/3,2/3,4/9),o=new V(2/9),l=V.multiplyAdd(s,i,V.multiplyAdd(r,a,e)),u=l.splatW,c=V.multiplyAdd(r,i,V.multiplyAdd(s,a,n));return{ax:l,aa:u,bx:c,bb:c.splatW,ab:V.multVector(o,V.add(r,s)).splatW}}),((r,s,n)=>E(r,s,n,t,e)),3)}compressBase(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;this.constructOrdering(this.principle,0);let s={start:new V(0),end:new V(0),error:this.bestError,iteration:0,bestI:0,bestJ:0};3===r&&(s.bestK=0);const n=(e,r)=>{const n=t(e),i=this.computeOptimalPoints(n);return i.errorz.dot(e,t)));return Array.from({length:e},((t,e)=>e)).sort(((t,e)=>s[t]-s[e]!=0?s[t]-s[e]:t-e))}copyOrderToThisOrder(t,e){const r=16*e;t.forEach(((t,e)=>{this.order[r+e]=t}))}checkOrderUnique(t,e){const{count:r}=this.colors;for(let s=0;s2&&void 0!==arguments[2]?arguments[2]:2;const{count:s}=this.colors,n=(e,s,n)=>{const i={bestI:e,bestJ:2===r?n:s,iteration:t};return 3===r&&(i.bestK=n),i};let i=new V(0);for(let t=0;t15?15:e}function W(t,e,r,s){let n=N(t,e,5),i=N(t,e,7);n.error<=i.error?function(t,e,r){let{min:s,max:n,indices:i}=t;if(s>n){G(n,s,i.map((t=>0===t?1:1===t?0:t<=5?7-t:t)),e,r)}else G(s,n,i,e,r)}(n,r,s):function(t,e,r){let{min:s,max:n,indices:i}=t;if(s>n){G(n,s,i.map((t=>0===t?1:1===t?0:9-t)),e,r)}else G(s,n,i,e,r)}(i,r,s)}function N(t,e,r){let{min:s,max:n}=function(t,e,r){let s=255,n=0;for(let i=0;i<16;i++){if(0==(e&1<n&&(n=a)):(an&&(n=a))}s>n&&(s=n);n-sMath.floor(((r-(n+1))*t+(n+1)*e)/r)))];return 5===r&&(s[6]=0,s[7]=255),s}function G(t,e,r,s,n){s[n]=t,s[n+1]=e;let i=0,a=n+2;for(let t=0;t<2;t++){let t=0;for(let e=0;e<8;++e){t|=r[i]<<3*e,i++}for(let e=0;e<3;++e){let r=t>>8*e&255;s[a]=r,a++}}}function K(t){const e=t>>11&31,r=t>>5&63,s=31&t;return[e<<3|e>>2,r<<2|r>>4,s<<3|s>>2,255]}function J(t,e,r){const s=t.map(((t,s)=>Math.floor(t*(1-r)+e[s]*r)));return s[3]=255,s}function Y(t,e,r,s){const n=function(t,e,r){const s=t[e]|t[e+1]<<8,n=t[e+2]|t[e+3]<<8,i=K(s),a=K(n);return[i,a,J(i,a,r&&s<=n?.5:1/3),r&&s<=n?[0,0,0,0]:J(i,a,2/3)]}(e,r,s),i=function(t,e){let r=e+4,s=new Uint8Array(16);for(let e=0;e<4;e++){let n=t[r+e];s[4*e+0]=3&n,s[4*e+1]=n>>2&3,s[4*e+2]=n>>4&3,s[4*e+3]=n>>6&3}return s}(e,r);for(let e=0;e<16;e++)for(let r=0;r<4;r++)t[4*e+r]=n[i[e]][r]}function Z(t){for(let e=0;e<4;e++)for(let r=0;r<4;r++)t(r,e)}function H(t){let e=7&t,r=280&t,s=96&t;return 2!=e&&4!=e&&(e=1),16!=r&&r!=w&&(r=8),64!=s&&(s=32),e|r|s|128&t}function Q(t,e){let{x:r=0,y:s=0,width:n=0,height:i=0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=0;Z((function(o,l){let u=r+o,c=s+l;if(u>4}}(t,e,r):0!=(4&s)&&function(t,e,r){let s=e[r+0],n=e[r+1],i=q(s,n,s<=n?5:7),a=new Uint8Array(16),o=0,l=2;for(let t=0;t<2;t++){let t=0;for(let s=0;s<3;s++)t|=e[r+l]<<8*s,l++;for(let e=0;e<8;e++){let r=t>>3*e&7;a[o]=r,o++}}for(let e=0;e<16;++e)t[4*e+3]=i[a[e]]}(t,e,r)}function et(t,e,r,s,n){const i=0!=(1&(n=H(n)))?8:16;let a=0;!function(t,e,r){for(let s=0;s1&&void 0!==arguments[1]?arguments[1]:{};const i=new Uint8Array(64);let a=0,o=0;return Z((function(l,u){let c=e+l,h=r+u;if(c>r&2**e-1}function lt(t,e,r,s){const n=Math.round(t/255*31),i=Math.round(e/255*31),a=Math.round(r/255*31);return Math.round(s/255)<<15|n<<10|i<<5|a}function ut(t){const e=ot(t,5,10),r=ot(t,5,5),s=ot(t,5,0),n=t>>15&1,[i,a,o]=[e,r,s].map((t=>t<<3|t>>2));return[i,a,o,255*n]}class ct extends e{static isTypeOf(t){return"Microsoft.Xna.Framework.Content.Texture2DReader"===t}read(t){const e=new u,s=new r;let n=e.read(t),i=s.read(t),a=s.read(t),o=s.read(t);o>1&&console.warn("Found mipcount of ".concat(o,", only the first will be used."));let l=s.read(t),c=t.read(l);if(4==n)c=at(c,i,a,rt);else if(5==n)c=at(c,i,a,st);else if(6==n)c=at(c,i,a,nt);else if(2==n)c=function(t){const e=new Uint8Array(t),r=e.length/2,s=new Uint8Array(4*r);for(let t=0;t>8}return s}(l)),i.write(t,l.length,null),t.concat(l)}isValueType(){return!1}}class ht extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.Vector3Reader":case"Microsoft.Xna.Framework.Vector3":return!0;default:return!1}}read(t){const e=new p;return{x:e.read(t),y:e.read(t),z:e.read(t)}}write(t,e,r){this.writeIndex(t,r);const s=new p;s.write(t,e.x,null),s.write(t,e.y,null),s.write(t,e.z,null)}}t.ArrayReader=class extends e{static isTypeOf(t){return"Microsoft.Xna.Framework.Content.ArrayReader"===t}static hasSubType(){return!0}constructor(t){super(),this.reader=t}read(t,e){let s=(new r).read(t),n=[];for(let r=0;r")}parseTypeList(){return[this.type,...this.reader.parseTypeList()]}},t.BaseReader=e,t.BmFontReader=class extends e{static isTypeOf(t){return"BmFont.XmlSourceReader"===t}read(t){const e=(new a).read(t);return{export:{type:this.type,data:e}}}write(t,e,r){this.writeIndex(t,r);(new a).write(t,e.export.data,null)}isValueType(){return!1}},t.BooleanReader=o,t.CharReader=l,t.DictionaryReader=class extends e{static isTypeOf(t){return"Microsoft.Xna.Framework.Content.DictionaryReader"===t}static hasSubType(){return!0}constructor(t,e){if(null==t||null==e)throw new Error("Cannot create instance of DictionaryReader without Key and Value.");super(),this.key=t,this.value=e}read(t,e){let s={};const n=(new r).read(t);for(let r=0;r")}parseTypeList(){return[this.type,...this.key.parseTypeList(),...this.value.parseTypeList()]}},t.DoubleReader=class extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.DoubleReader":case"System.Double":return!0;default:return!1}}read(t){return t.readDouble()}write(t,e,r){this.writeIndex(t,r),t.writeDouble(e)}},t.EffectReader=class extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.EffectReader":case"Microsoft.Xna.Framework.Graphics.Effect":return!0;default:return!1}}read(t){const e=(new r).read(t),s=t.read(e);return{export:{type:this.type,data:s}}}write(t,e,s){this.writeIndex(t,s);const n=e.export.data;(new r).write(t,n.byteLength,null),t.concat(n)}isValueType(){return!1}},t.Int32Reader=u,t.LightweightTexture2DReader=class extends e{static isTypeOf(t){return"Microsoft.Xna.Framework.Content.Texture2DReader"===t}static type(){return"Texture2D"}read(t){const e=new u,s=new r;let n=e.read(t),i=s.read(t),a=s.read(t),o=s.read(t);o>1&&console.warn("Found mipcount of ".concat(o,", only the first will be used."));let l=s.read(t),c=t.read(l);if(c=new Uint8Array(c),0!=n)throw new Error("Compressed texture format is not supported!");for(let t=0;t","Rectangle","List","Rectangle","List","Char",null,null,"List","Vector3","Nullable","Char"]}read(t,e){const r=new u,s=new p,n=new h(new l);return{texture:e.read(t),glyphs:e.read(t),cropping:e.read(t),characterMap:e.read(t),verticalLineSpacing:r.read(t),horizontalSpacing:s.read(t),kerning:e.read(t),defaultCharacter:n.read(t)}}write(t,e,r){const s=new u,n=new l,i=new p,a=new h(n),o=new ct,w=new c(new d),f=new c(n),y=new c(new ht);this.writeIndex(t,r);try{o.write(t,e.texture,r),t.alloc(1e5),w.write(t,e.glyphs,r),w.write(t,e.cropping,r),f.write(t,e.characterMap,r),s.write(t,e.verticalLineSpacing,null),i.write(t,e.horizontalSpacing,null),y.write(t,e.kerning,r),a.write(t,e.defaultCharacter,null)}catch(t){throw t}}isValueType(){return!1}},t.StringReader=a,t.TBinReader=class extends e{static isTypeOf(t){return"xTile.Pipeline.TideReader"===t}read(t){let e=(new u).read(t),r=t.read(e);return{export:{type:this.type,data:r}}}write(t,e,r){this.writeIndex(t,r);const s=e.export.data;(new u).write(t,s.byteLength,null),t.concat(s)}isValueType(){return!1}},t.Texture2DReader=ct,t.UInt32Reader=r,t.Vector2Reader=class extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.Vector2Reader":case"Microsoft.Xna.Framework.Vector2":return!0;default:return!1}}read(t){const e=new p;return{x:e.read(t),y:e.read(t)}}},t.Vector3Reader=ht,t.Vector4Reader=class extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.Vector4Reader":case"Microsoft.Xna.Framework.Vector4":return!0;default:return!1}}read(t){const e=new p;return{x:e.read(t),y:e.read(t),z:e.read(t),w:e.read(t)}}},Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XNB={})}(this,(function(t){"use strict";class e{static isTypeOf(t){return!1}static hasSubType(){return!1}static parseTypeList(){return[this.type()]}static type(){return this.name.slice(0,-6)}isValueType(){return!0}get type(){return this.constructor.type()}read(t,e){throw new Error("Cannot invoke methods on abstract class.")}write(t,e,r){throw new Error("Cannot invoke methods on abstract class.")}writeIndex(t,e){null!=e&&t.write7BitNumber(Number.parseInt(e.getIndex(this))+1)}toString(){return this.type}parseTypeList(){return this.constructor.parseTypeList()}}class r extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.UInt32Reader":case"System.UInt32":return!0;default:return!1}}read(t){return t.readUInt32()}write(t,e,r){this.writeIndex(t,r),t.writeUInt32(e)}}const s=[55296,56320];function n(t){var e;if("number"==typeof t&&(t=[t]),null===(e=t)||void 0===e||!e.length)throw new Error("Invalid codeset!");return 1===t.length?t[0]:((1023&t[0])<<10)+(1023&t[1])+65536}function i(t){const e=function(t){const e=Array.from({length:t.length},((e,r)=>t.charCodeAt(r))),r=[];let i=0;for(;ie<128?t+1:e<2048?t+2:e<65536?t+3:t+4),0)}class a extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.StringReader":case"System.String":return!0;default:return!1}}read(t){let e=t.read7BitNumber();return t.readString(e)}write(t,e,r){this.writeIndex(t,r);const s=i(e);t.write7BitNumber(s),t.writeString(e)}isValueType(){return!1}}class o extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.BooleanReader":case"System.Boolean":return!0;default:return!1}}read(t){return Boolean(t.readInt())}write(t,e,r){this.writeIndex(t,r),t.writeByte(e)}}class l extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.CharReader":case"System.Char":return!0;default:return!1}}read(t){let e=this._getCharSize(t.peekInt());return t.readString(e)}write(t,e,r){this.writeIndex(t,r),t.writeString(e)}_getCharSize(t){return 1+(3841982464>>(t>>3&30)&3)}}class u extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.Int32Reader":case"Microsoft.Xna.Framework.Content.EnumReader":case"System.Int32":return!0;default:return!1}}read(t){return t.readInt32()}write(t,e,r){this.writeIndex(t,r),t.writeInt32(e)}}class c extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.ListReader":case"System.Collections.Generic.List":return!0;default:return!1}}static hasSubType(){return!0}constructor(t){super(),this.reader=t}read(t,e){const s=(new r).read(t),n=[];for(let r=0;r")}parseTypeList(){const t=this.reader.parseTypeList();return["".concat(this.type,":").concat(t.length),...t]}}class h extends e{static isTypeOf(t){return"Microsoft.Xna.Framework.Content.NullableReader"===t}static hasSubType(){return!0}constructor(t){super(),this.reader=t}read(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const r=new o;return t.peekByte(1)?null===e||this.reader.isValueType()?(r.read(t),this.reader.read(t)):e.read(t):(r.read(t),null)}write(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;null!==e?((null===r||this.reader.isValueType())&&t.writeByte(1),this.reader.write(t,e,this.reader.isValueType()?null:r)):t.writeByte(0)}isValueType(){return!1}get type(){return"Nullable<".concat(this.reader.type,">")}parseTypeList(){const t=this.reader.parseTypeList();return["".concat(this.type,":").concat(t.length),...t]}}class d extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.RectangleReader":case"Microsoft.Xna.Framework.Rectangle":return!0;default:return!1}}read(t){const e=new u;return{x:e.read(t),y:e.read(t),width:e.read(t),height:e.read(t)}}write(t,e,r){this.writeIndex(t,r);const s=new u;s.write(t,e.x,null),s.write(t,e.y,null),s.write(t,e.width,null),s.write(t,e.height,null)}}class w extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.SingleReader":case"System.Single":return!0;default:return!1}}read(t){return t.readSingle()}write(t,e,r){this.writeIndex(t,r),t.writeSingle(e)}}const p=256;function f(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,s)}return r}function y(t){for(var e=1;e{let n=e.map((t=>t[s]));return{value:t[s],vec:n}}));return s.sort(((t,e)=>e.value-t.value)),[s.map((t=>{let{value:e}=t;return e})),s.map((t=>{let{vec:e}=t;return e}))]}function T(t){let[,[e]]=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-7,r=t.length,s=Array(r),n=Math.abs(e/r),i=Array(r);for(let t=0;t=Math.abs(n);){let e=a[0][0],s=a[0][1],n=g(e,s,x(t[e][e],t[s][s],t[e][s]),r);t=_(n,t),i=b(i,n),a=v(t)}for(let e=0;e0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;this._values=[t,e,r]}get x(){return this._values[0]}get y(){return this._values[1]}get z(){return this._values[2]}set x(t){this._values[0]=t}set y(t){this._values[1]=t}set z(t){this._values[2]=t}get length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}get lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}get normalized(){return 0===this.length?null:z.multScalar(this,1/this.length)}get colorInt(){return this._values.map((t=>{const e=parseInt(255*t+.5);return Math.max(Math.min(e,255),0)}))}clone(){return new z(this.x,this.y,this.z)}set(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;return this._values[0]=t,this._values[1]=e,this._values[2]=r,this}toVec4(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new V(this.x,this.y,this.z,t)}addVector(t){return this._values[0]+=t.x,this._values[1]+=t.y,this._values[2]+=t.z,this}addScaledVector(t,e){return this._values[0]+=t.x*e,this._values[1]+=t.y*e,this._values[2]+=t.z*e,this}mult(t){return this._values[0]*=t,this._values[1]*=t,this._values[2]*=t,this}multVector(t){return this._values[0]*=t.x,this._values[1]*=t.y,this._values[2]*=t.z,this}clamp(t,e){const r=r=>t>r?t:e{return Math.trunc((0>(r=t)?0:10&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t;this._values=[t,e,r,s]}get x(){return this._values[0]}get y(){return this._values[1]}get z(){return this._values[2]}get w(){return this._values[3]}set x(t){this._values[0]=t}set y(t){this._values[1]=t}set z(t){this._values[2]=t}set w(t){this._values[3]=t}get length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}get lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}get normalized(){return 0===this.length?null:V.multScalar(this,1/this.length)}get xyz(){return new z(this.x,this.y,this.z)}get splatX(){return new V(this.x)}get splatY(){return new V(this.y)}get splatZ(){return new V(this.z)}get splatW(){return new V(this.w)}clone(){return new V(this.x,this.y,this.z,this.w)}set(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t;return this._values[0]=t,this._values[1]=e,this._values[2]=r,this._values[3]=s,this}toVec3(){return this.xyz}addVector(t){return this._values[0]+=t.x,this._values[1]+=t.y,this._values[2]+=t.z,this._values[3]+=t.w,this}addScaledVector(t,e){return this._values[0]+=t.x*e,this._values[1]+=t.y*e,this._values[2]+=t.z*e,this._values[3]+=t.w*e,this}subVector(t){return this._values[0]-=t.x,this._values[1]-=t.y,this._values[2]-=t.z,this._values[3]-=t.w,this}mult(t){return this._values[0]*=t,this._values[1]*=t,this._values[2]*=t,this._values[3]*=t,this}multVector(t){return this._values[0]*=t.x,this._values[1]*=t.y,this._values[2]*=t.z,this._values[3]*=t.w,this}reciprocal(){return this._values[0]=1/this._values[0],this._values[1]=1/this._values[1],this._values[2]=1/this._values[2],this._values[3]=1/this._values[3],this}clamp(t,e){const r=r=>t>r?t:e0>t?0:1Math.trunc(t(e)*r+.5)/r;return this._values[0]=e(this._values[0],31),this._values[1]=e(this._values[1],63),this._values[2]=e(this._values[2],31),this._values[3]=t(this._values[3]),this}truncate(){return this._values[0]=Math.trunc(this._values[0]),this._values[1]=Math.trunc(this._values[1]),this._values[2]=Math.trunc(this._values[2]),this._values[3]=Math.trunc(this._values[3]),this}normalize(){return this._values[0]/=this.length,this._values[1]/=this.length,this._values[2]/=this.length,this._values[3]/=this.length,this}toString(){return"Vec4( ".concat(this._values.join(", ")," )")}static add(t,e){return new V(t.x+e.x,t.y+e.y,t.z+e.z,t.w+e.w)}static sub(t,e){return new V(t.x-e.x,t.y-e.y,t.z-e.z,t.w-e.w)}static dot(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w}static multScalar(t,e){return new V(t.x*e,t.y*e,t.z*e,t.w*e)}static multVector(t,e){return new V(t.x*e.x,t.y*e.y,t.z*e.z,t.w*e.w)}static interpolate(t,e,r){let s=V.multScalar(t,1-r),n=V.multScalar(e,r);return V.add(s,n)}static multiplyAdd(t,e,r){return new V(t.x*e.x+r.x,t.y*e.y+r.y,t.z*e.z+r.z,t.w*e.w+r.w)}static negativeMultiplySubtract(t,e,r){return new V(r.x-t.x*e.x,r.y-t.y*e.y,r.z-t.z*e.z,r.w-t.w*e.w)}static compareAnyLessThan(t,e){return t.x(r+=e[n],t.addScaledVector(s,e[n]),t)),new z(0));s.mult(1/r);let n=t.reduce(((t,r,n)=>{let i=e[n],a=z.sub(r,s);return t[0][0]+=a.x*a.x*i,t[0][1]+=a.x*a.y*i,t[0][2]+=a.x*a.z*i,t[1][1]+=a.y*a.y*i,t[1][2]+=a.y*a.z*i,t[2][2]+=a.z*a.z*i,t}),[[0,0,0],[0,0,0],[0,0,0]]);return n[1][0]=n[0][1],n[2][0]=n[0][2],n[2][1]=n[1][2],n}(t,e);return new z(...T(r))}const O=[[[0,0,0],[0,0,0]],[[0,0,1],[0,0,1]],[[0,0,2],[0,0,2]],[[0,0,3],[0,1,1]],[[0,0,4],[0,1,0]],[[1,0,3],[0,1,1]],[[1,0,2],[0,1,2]],[[1,0,1],[0,2,1]],[[1,0,0],[0,2,0]],[[1,0,1],[0,2,1]],[[1,0,2],[0,2,2]],[[1,0,3],[0,3,1]],[[1,0,4],[0,3,0]],[[2,0,3],[0,3,1]],[[2,0,2],[0,3,2]],[[2,0,1],[0,4,1]],[[2,0,0],[0,4,0]],[[2,0,1],[0,4,1]],[[2,0,2],[0,4,2]],[[2,0,3],[0,5,1]],[[2,0,4],[0,5,0]],[[3,0,3],[0,5,1]],[[3,0,2],[0,5,2]],[[3,0,1],[0,6,1]],[[3,0,0],[0,6,0]],[[3,0,1],[0,6,1]],[[3,0,2],[0,6,2]],[[3,0,3],[0,7,1]],[[3,0,4],[0,7,0]],[[4,0,4],[0,7,1]],[[4,0,3],[0,7,2]],[[4,0,2],[1,7,1]],[[4,0,1],[1,7,0]],[[4,0,0],[0,8,0]],[[4,0,1],[0,8,1]],[[4,0,2],[2,7,1]],[[4,0,3],[2,7,0]],[[4,0,4],[0,9,0]],[[5,0,3],[0,9,1]],[[5,0,2],[3,7,1]],[[5,0,1],[3,7,0]],[[5,0,0],[0,10,0]],[[5,0,1],[0,10,1]],[[5,0,2],[0,10,2]],[[5,0,3],[0,11,1]],[[5,0,4],[0,11,0]],[[6,0,3],[0,11,1]],[[6,0,2],[0,11,2]],[[6,0,1],[0,12,1]],[[6,0,0],[0,12,0]],[[6,0,1],[0,12,1]],[[6,0,2],[0,12,2]],[[6,0,3],[0,13,1]],[[6,0,4],[0,13,0]],[[7,0,3],[0,13,1]],[[7,0,2],[0,13,2]],[[7,0,1],[0,14,1]],[[7,0,0],[0,14,0]],[[7,0,1],[0,14,1]],[[7,0,2],[0,14,2]],[[7,0,3],[0,15,1]],[[7,0,4],[0,15,0]],[[8,0,4],[0,15,1]],[[8,0,3],[0,15,2]],[[8,0,2],[1,15,1]],[[8,0,1],[1,15,0]],[[8,0,0],[0,16,0]],[[8,0,1],[0,16,1]],[[8,0,2],[2,15,1]],[[8,0,3],[2,15,0]],[[8,0,4],[0,17,0]],[[9,0,3],[0,17,1]],[[9,0,2],[3,15,1]],[[9,0,1],[3,15,0]],[[9,0,0],[0,18,0]],[[9,0,1],[0,18,1]],[[9,0,2],[0,18,2]],[[9,0,3],[0,19,1]],[[9,0,4],[0,19,0]],[[10,0,3],[0,19,1]],[[10,0,2],[0,19,2]],[[10,0,1],[0,20,1]],[[10,0,0],[0,20,0]],[[10,0,1],[0,20,1]],[[10,0,2],[0,20,2]],[[10,0,3],[0,21,1]],[[10,0,4],[0,21,0]],[[11,0,3],[0,21,1]],[[11,0,2],[0,21,2]],[[11,0,1],[0,22,1]],[[11,0,0],[0,22,0]],[[11,0,1],[0,22,1]],[[11,0,2],[0,22,2]],[[11,0,3],[0,23,1]],[[11,0,4],[0,23,0]],[[12,0,4],[0,23,1]],[[12,0,3],[0,23,2]],[[12,0,2],[1,23,1]],[[12,0,1],[1,23,0]],[[12,0,0],[0,24,0]],[[12,0,1],[0,24,1]],[[12,0,2],[2,23,1]],[[12,0,3],[2,23,0]],[[12,0,4],[0,25,0]],[[13,0,3],[0,25,1]],[[13,0,2],[3,23,1]],[[13,0,1],[3,23,0]],[[13,0,0],[0,26,0]],[[13,0,1],[0,26,1]],[[13,0,2],[0,26,2]],[[13,0,3],[0,27,1]],[[13,0,4],[0,27,0]],[[14,0,3],[0,27,1]],[[14,0,2],[0,27,2]],[[14,0,1],[0,28,1]],[[14,0,0],[0,28,0]],[[14,0,1],[0,28,1]],[[14,0,2],[0,28,2]],[[14,0,3],[0,29,1]],[[14,0,4],[0,29,0]],[[15,0,3],[0,29,1]],[[15,0,2],[0,29,2]],[[15,0,1],[0,30,1]],[[15,0,0],[0,30,0]],[[15,0,1],[0,30,1]],[[15,0,2],[0,30,2]],[[15,0,3],[0,31,1]],[[15,0,4],[0,31,0]],[[16,0,4],[0,31,1]],[[16,0,3],[0,31,2]],[[16,0,2],[1,31,1]],[[16,0,1],[1,31,0]],[[16,0,0],[4,28,0]],[[16,0,1],[4,28,1]],[[16,0,2],[2,31,1]],[[16,0,3],[2,31,0]],[[16,0,4],[4,29,0]],[[17,0,3],[4,29,1]],[[17,0,2],[3,31,1]],[[17,0,1],[3,31,0]],[[17,0,0],[4,30,0]],[[17,0,1],[4,30,1]],[[17,0,2],[4,30,2]],[[17,0,3],[4,31,1]],[[17,0,4],[4,31,0]],[[18,0,3],[4,31,1]],[[18,0,2],[4,31,2]],[[18,0,1],[5,31,1]],[[18,0,0],[5,31,0]],[[18,0,1],[5,31,1]],[[18,0,2],[5,31,2]],[[18,0,3],[6,31,1]],[[18,0,4],[6,31,0]],[[19,0,3],[6,31,1]],[[19,0,2],[6,31,2]],[[19,0,1],[7,31,1]],[[19,0,0],[7,31,0]],[[19,0,1],[7,31,1]],[[19,0,2],[7,31,2]],[[19,0,3],[8,31,1]],[[19,0,4],[8,31,0]],[[20,0,4],[8,31,1]],[[20,0,3],[8,31,2]],[[20,0,2],[9,31,1]],[[20,0,1],[9,31,0]],[[20,0,0],[12,28,0]],[[20,0,1],[12,28,1]],[[20,0,2],[10,31,1]],[[20,0,3],[10,31,0]],[[20,0,4],[12,29,0]],[[21,0,3],[12,29,1]],[[21,0,2],[11,31,1]],[[21,0,1],[11,31,0]],[[21,0,0],[12,30,0]],[[21,0,1],[12,30,1]],[[21,0,2],[12,30,2]],[[21,0,3],[12,31,1]],[[21,0,4],[12,31,0]],[[22,0,3],[12,31,1]],[[22,0,2],[12,31,2]],[[22,0,1],[13,31,1]],[[22,0,0],[13,31,0]],[[22,0,1],[13,31,1]],[[22,0,2],[13,31,2]],[[22,0,3],[14,31,1]],[[22,0,4],[14,31,0]],[[23,0,3],[14,31,1]],[[23,0,2],[14,31,2]],[[23,0,1],[15,31,1]],[[23,0,0],[15,31,0]],[[23,0,1],[15,31,1]],[[23,0,2],[15,31,2]],[[23,0,3],[16,31,1]],[[23,0,4],[16,31,0]],[[24,0,4],[16,31,1]],[[24,0,3],[16,31,2]],[[24,0,2],[17,31,1]],[[24,0,1],[17,31,0]],[[24,0,0],[20,28,0]],[[24,0,1],[20,28,1]],[[24,0,2],[18,31,1]],[[24,0,3],[18,31,0]],[[24,0,4],[20,29,0]],[[25,0,3],[20,29,1]],[[25,0,2],[19,31,1]],[[25,0,1],[19,31,0]],[[25,0,0],[20,30,0]],[[25,0,1],[20,30,1]],[[25,0,2],[20,30,2]],[[25,0,3],[20,31,1]],[[25,0,4],[20,31,0]],[[26,0,3],[20,31,1]],[[26,0,2],[20,31,2]],[[26,0,1],[21,31,1]],[[26,0,0],[21,31,0]],[[26,0,1],[21,31,1]],[[26,0,2],[21,31,2]],[[26,0,3],[22,31,1]],[[26,0,4],[22,31,0]],[[27,0,3],[22,31,1]],[[27,0,2],[22,31,2]],[[27,0,1],[23,31,1]],[[27,0,0],[23,31,0]],[[27,0,1],[23,31,1]],[[27,0,2],[23,31,2]],[[27,0,3],[24,31,1]],[[27,0,4],[24,31,0]],[[28,0,4],[24,31,1]],[[28,0,3],[24,31,2]],[[28,0,2],[25,31,1]],[[28,0,1],[25,31,0]],[[28,0,0],[28,28,0]],[[28,0,1],[28,28,1]],[[28,0,2],[26,31,1]],[[28,0,3],[26,31,0]],[[28,0,4],[28,29,0]],[[29,0,3],[28,29,1]],[[29,0,2],[27,31,1]],[[29,0,1],[27,31,0]],[[29,0,0],[28,30,0]],[[29,0,1],[28,30,1]],[[29,0,2],[28,30,2]],[[29,0,3],[28,31,1]],[[29,0,4],[28,31,0]],[[30,0,3],[28,31,1]],[[30,0,2],[28,31,2]],[[30,0,1],[29,31,1]],[[30,0,0],[29,31,0]],[[30,0,1],[29,31,1]],[[30,0,2],[29,31,2]],[[30,0,3],[30,31,1]],[[30,0,4],[30,31,0]],[[31,0,3],[30,31,1]],[[31,0,2],[30,31,2]],[[31,0,1],[31,31,1]],[[31,0,0],[31,31,0]]],k=[[[0,0,0],[0,0,0]],[[0,0,1],[0,1,1]],[[0,0,2],[0,1,0]],[[1,0,1],[0,2,1]],[[1,0,0],[0,2,0]],[[1,0,1],[0,3,1]],[[1,0,2],[0,3,0]],[[2,0,1],[0,4,1]],[[2,0,0],[0,4,0]],[[2,0,1],[0,5,1]],[[2,0,2],[0,5,0]],[[3,0,1],[0,6,1]],[[3,0,0],[0,6,0]],[[3,0,1],[0,7,1]],[[3,0,2],[0,7,0]],[[4,0,1],[0,8,1]],[[4,0,0],[0,8,0]],[[4,0,1],[0,9,1]],[[4,0,2],[0,9,0]],[[5,0,1],[0,10,1]],[[5,0,0],[0,10,0]],[[5,0,1],[0,11,1]],[[5,0,2],[0,11,0]],[[6,0,1],[0,12,1]],[[6,0,0],[0,12,0]],[[6,0,1],[0,13,1]],[[6,0,2],[0,13,0]],[[7,0,1],[0,14,1]],[[7,0,0],[0,14,0]],[[7,0,1],[0,15,1]],[[7,0,2],[0,15,0]],[[8,0,1],[0,16,1]],[[8,0,0],[0,16,0]],[[8,0,1],[0,17,1]],[[8,0,2],[0,17,0]],[[9,0,1],[0,18,1]],[[9,0,0],[0,18,0]],[[9,0,1],[0,19,1]],[[9,0,2],[0,19,0]],[[10,0,1],[0,20,1]],[[10,0,0],[0,20,0]],[[10,0,1],[0,21,1]],[[10,0,2],[0,21,0]],[[11,0,1],[0,22,1]],[[11,0,0],[0,22,0]],[[11,0,1],[0,23,1]],[[11,0,2],[0,23,0]],[[12,0,1],[0,24,1]],[[12,0,0],[0,24,0]],[[12,0,1],[0,25,1]],[[12,0,2],[0,25,0]],[[13,0,1],[0,26,1]],[[13,0,0],[0,26,0]],[[13,0,1],[0,27,1]],[[13,0,2],[0,27,0]],[[14,0,1],[0,28,1]],[[14,0,0],[0,28,0]],[[14,0,1],[0,29,1]],[[14,0,2],[0,29,0]],[[15,0,1],[0,30,1]],[[15,0,0],[0,30,0]],[[15,0,1],[0,31,1]],[[15,0,2],[0,31,0]],[[16,0,2],[1,31,1]],[[16,0,1],[1,31,0]],[[16,0,0],[0,32,0]],[[16,0,1],[2,31,0]],[[16,0,2],[0,33,0]],[[17,0,1],[3,31,0]],[[17,0,0],[0,34,0]],[[17,0,1],[4,31,0]],[[17,0,2],[0,35,0]],[[18,0,1],[5,31,0]],[[18,0,0],[0,36,0]],[[18,0,1],[6,31,0]],[[18,0,2],[0,37,0]],[[19,0,1],[7,31,0]],[[19,0,0],[0,38,0]],[[19,0,1],[8,31,0]],[[19,0,2],[0,39,0]],[[20,0,1],[9,31,0]],[[20,0,0],[0,40,0]],[[20,0,1],[10,31,0]],[[20,0,2],[0,41,0]],[[21,0,1],[11,31,0]],[[21,0,0],[0,42,0]],[[21,0,1],[12,31,0]],[[21,0,2],[0,43,0]],[[22,0,1],[13,31,0]],[[22,0,0],[0,44,0]],[[22,0,1],[14,31,0]],[[22,0,2],[0,45,0]],[[23,0,1],[15,31,0]],[[23,0,0],[0,46,0]],[[23,0,1],[0,47,1]],[[23,0,2],[0,47,0]],[[24,0,1],[0,48,1]],[[24,0,0],[0,48,0]],[[24,0,1],[0,49,1]],[[24,0,2],[0,49,0]],[[25,0,1],[0,50,1]],[[25,0,0],[0,50,0]],[[25,0,1],[0,51,1]],[[25,0,2],[0,51,0]],[[26,0,1],[0,52,1]],[[26,0,0],[0,52,0]],[[26,0,1],[0,53,1]],[[26,0,2],[0,53,0]],[[27,0,1],[0,54,1]],[[27,0,0],[0,54,0]],[[27,0,1],[0,55,1]],[[27,0,2],[0,55,0]],[[28,0,1],[0,56,1]],[[28,0,0],[0,56,0]],[[28,0,1],[0,57,1]],[[28,0,2],[0,57,0]],[[29,0,1],[0,58,1]],[[29,0,0],[0,58,0]],[[29,0,1],[0,59,1]],[[29,0,2],[0,59,0]],[[30,0,1],[0,60,1]],[[30,0,0],[0,60,0]],[[30,0,1],[0,61,1]],[[30,0,2],[0,61,0]],[[31,0,1],[0,62,1]],[[31,0,0],[0,62,0]],[[31,0,1],[0,63,1]],[[31,0,2],[0,63,0]],[[32,0,2],[1,63,1]],[[32,0,1],[1,63,0]],[[32,0,0],[16,48,0]],[[32,0,1],[2,63,0]],[[32,0,2],[16,49,0]],[[33,0,1],[3,63,0]],[[33,0,0],[16,50,0]],[[33,0,1],[4,63,0]],[[33,0,2],[16,51,0]],[[34,0,1],[5,63,0]],[[34,0,0],[16,52,0]],[[34,0,1],[6,63,0]],[[34,0,2],[16,53,0]],[[35,0,1],[7,63,0]],[[35,0,0],[16,54,0]],[[35,0,1],[8,63,0]],[[35,0,2],[16,55,0]],[[36,0,1],[9,63,0]],[[36,0,0],[16,56,0]],[[36,0,1],[10,63,0]],[[36,0,2],[16,57,0]],[[37,0,1],[11,63,0]],[[37,0,0],[16,58,0]],[[37,0,1],[12,63,0]],[[37,0,2],[16,59,0]],[[38,0,1],[13,63,0]],[[38,0,0],[16,60,0]],[[38,0,1],[14,63,0]],[[38,0,2],[16,61,0]],[[39,0,1],[15,63,0]],[[39,0,0],[16,62,0]],[[39,0,1],[16,63,1]],[[39,0,2],[16,63,0]],[[40,0,1],[17,63,1]],[[40,0,0],[17,63,0]],[[40,0,1],[18,63,1]],[[40,0,2],[18,63,0]],[[41,0,1],[19,63,1]],[[41,0,0],[19,63,0]],[[41,0,1],[20,63,1]],[[41,0,2],[20,63,0]],[[42,0,1],[21,63,1]],[[42,0,0],[21,63,0]],[[42,0,1],[22,63,1]],[[42,0,2],[22,63,0]],[[43,0,1],[23,63,1]],[[43,0,0],[23,63,0]],[[43,0,1],[24,63,1]],[[43,0,2],[24,63,0]],[[44,0,1],[25,63,1]],[[44,0,0],[25,63,0]],[[44,0,1],[26,63,1]],[[44,0,2],[26,63,0]],[[45,0,1],[27,63,1]],[[45,0,0],[27,63,0]],[[45,0,1],[28,63,1]],[[45,0,2],[28,63,0]],[[46,0,1],[29,63,1]],[[46,0,0],[29,63,0]],[[46,0,1],[30,63,1]],[[46,0,2],[30,63,0]],[[47,0,1],[31,63,1]],[[47,0,0],[31,63,0]],[[47,0,1],[32,63,1]],[[47,0,2],[32,63,0]],[[48,0,2],[33,63,1]],[[48,0,1],[33,63,0]],[[48,0,0],[48,48,0]],[[48,0,1],[34,63,0]],[[48,0,2],[48,49,0]],[[49,0,1],[35,63,0]],[[49,0,0],[48,50,0]],[[49,0,1],[36,63,0]],[[49,0,2],[48,51,0]],[[50,0,1],[37,63,0]],[[50,0,0],[48,52,0]],[[50,0,1],[38,63,0]],[[50,0,2],[48,53,0]],[[51,0,1],[39,63,0]],[[51,0,0],[48,54,0]],[[51,0,1],[40,63,0]],[[51,0,2],[48,55,0]],[[52,0,1],[41,63,0]],[[52,0,0],[48,56,0]],[[52,0,1],[42,63,0]],[[52,0,2],[48,57,0]],[[53,0,1],[43,63,0]],[[53,0,0],[48,58,0]],[[53,0,1],[44,63,0]],[[53,0,2],[48,59,0]],[[54,0,1],[45,63,0]],[[54,0,0],[48,60,0]],[[54,0,1],[46,63,0]],[[54,0,2],[48,61,0]],[[55,0,1],[47,63,0]],[[55,0,0],[48,62,0]],[[55,0,1],[48,63,1]],[[55,0,2],[48,63,0]],[[56,0,1],[49,63,1]],[[56,0,0],[49,63,0]],[[56,0,1],[50,63,1]],[[56,0,2],[50,63,0]],[[57,0,1],[51,63,1]],[[57,0,0],[51,63,0]],[[57,0,1],[52,63,1]],[[57,0,2],[52,63,0]],[[58,0,1],[53,63,1]],[[58,0,0],[53,63,0]],[[58,0,1],[54,63,1]],[[58,0,2],[54,63,0]],[[59,0,1],[55,63,1]],[[59,0,0],[55,63,0]],[[59,0,1],[56,63,1]],[[59,0,2],[56,63,0]],[[60,0,1],[57,63,1]],[[60,0,0],[57,63,0]],[[60,0,1],[58,63,1]],[[60,0,2],[58,63,0]],[[61,0,1],[59,63,1]],[[61,0,0],[59,63,0]],[[61,0,1],[60,63,1]],[[61,0,2],[60,63,0]],[[62,0,1],[61,63,1]],[[62,0,0],[61,63,0]],[[62,0,1],[62,63,1]],[[62,0,2],[62,63,0]],[[63,0,1],[63,63,1]],[[63,0,0],[63,63,0]]],R=[[[0,0,0],[0,0,0]],[[0,0,1],[0,1,1]],[[0,0,2],[0,1,0]],[[0,0,3],[0,1,1]],[[0,0,4],[0,2,1]],[[1,0,3],[0,2,0]],[[1,0,2],[0,2,1]],[[1,0,1],[0,3,1]],[[1,0,0],[0,3,0]],[[1,0,1],[1,2,1]],[[1,0,2],[1,2,0]],[[1,0,3],[0,4,0]],[[1,0,4],[0,5,1]],[[2,0,3],[0,5,0]],[[2,0,2],[0,5,1]],[[2,0,1],[0,6,1]],[[2,0,0],[0,6,0]],[[2,0,1],[2,3,1]],[[2,0,2],[2,3,0]],[[2,0,3],[0,7,0]],[[2,0,4],[1,6,1]],[[3,0,3],[1,6,0]],[[3,0,2],[0,8,0]],[[3,0,1],[0,9,1]],[[3,0,0],[0,9,0]],[[3,0,1],[0,9,1]],[[3,0,2],[0,10,1]],[[3,0,3],[0,10,0]],[[3,0,4],[2,7,1]],[[4,0,4],[2,7,0]],[[4,0,3],[0,11,0]],[[4,0,2],[1,10,1]],[[4,0,1],[1,10,0]],[[4,0,0],[0,12,0]],[[4,0,1],[0,13,1]],[[4,0,2],[0,13,0]],[[4,0,3],[0,13,1]],[[4,0,4],[0,14,1]],[[5,0,3],[0,14,0]],[[5,0,2],[2,11,1]],[[5,0,1],[2,11,0]],[[5,0,0],[0,15,0]],[[5,0,1],[1,14,1]],[[5,0,2],[1,14,0]],[[5,0,3],[0,16,0]],[[5,0,4],[0,17,1]],[[6,0,3],[0,17,0]],[[6,0,2],[0,17,1]],[[6,0,1],[0,18,1]],[[6,0,0],[0,18,0]],[[6,0,1],[2,15,1]],[[6,0,2],[2,15,0]],[[6,0,3],[0,19,0]],[[6,0,4],[1,18,1]],[[7,0,3],[1,18,0]],[[7,0,2],[0,20,0]],[[7,0,1],[0,21,1]],[[7,0,0],[0,21,0]],[[7,0,1],[0,21,1]],[[7,0,2],[0,22,1]],[[7,0,3],[0,22,0]],[[7,0,4],[2,19,1]],[[8,0,4],[2,19,0]],[[8,0,3],[0,23,0]],[[8,0,2],[1,22,1]],[[8,0,1],[1,22,0]],[[8,0,0],[0,24,0]],[[8,0,1],[0,25,1]],[[8,0,2],[0,25,0]],[[8,0,3],[0,25,1]],[[8,0,4],[0,26,1]],[[9,0,3],[0,26,0]],[[9,0,2],[2,23,1]],[[9,0,1],[2,23,0]],[[9,0,0],[0,27,0]],[[9,0,1],[1,26,1]],[[9,0,2],[1,26,0]],[[9,0,3],[0,28,0]],[[9,0,4],[0,29,1]],[[10,0,3],[0,29,0]],[[10,0,2],[0,29,1]],[[10,0,1],[0,30,1]],[[10,0,0],[0,30,0]],[[10,0,1],[2,27,1]],[[10,0,2],[2,27,0]],[[10,0,3],[0,31,0]],[[10,0,4],[1,30,1]],[[11,0,3],[1,30,0]],[[11,0,2],[4,24,0]],[[11,0,1],[1,31,1]],[[11,0,0],[1,31,0]],[[11,0,1],[1,31,1]],[[11,0,2],[2,30,1]],[[11,0,3],[2,30,0]],[[11,0,4],[2,31,1]],[[12,0,4],[2,31,0]],[[12,0,3],[4,27,0]],[[12,0,2],[3,30,1]],[[12,0,1],[3,30,0]],[[12,0,0],[4,28,0]],[[12,0,1],[3,31,1]],[[12,0,2],[3,31,0]],[[12,0,3],[3,31,1]],[[12,0,4],[4,30,1]],[[13,0,3],[4,30,0]],[[13,0,2],[6,27,1]],[[13,0,1],[6,27,0]],[[13,0,0],[4,31,0]],[[13,0,1],[5,30,1]],[[13,0,2],[5,30,0]],[[13,0,3],[8,24,0]],[[13,0,4],[5,31,1]],[[14,0,3],[5,31,0]],[[14,0,2],[5,31,1]],[[14,0,1],[6,30,1]],[[14,0,0],[6,30,0]],[[14,0,1],[6,31,1]],[[14,0,2],[6,31,0]],[[14,0,3],[8,27,0]],[[14,0,4],[7,30,1]],[[15,0,3],[7,30,0]],[[15,0,2],[8,28,0]],[[15,0,1],[7,31,1]],[[15,0,0],[7,31,0]],[[15,0,1],[7,31,1]],[[15,0,2],[8,30,1]],[[15,0,3],[8,30,0]],[[15,0,4],[10,27,1]],[[16,0,4],[10,27,0]],[[16,0,3],[8,31,0]],[[16,0,2],[9,30,1]],[[16,0,1],[9,30,0]],[[16,0,0],[12,24,0]],[[16,0,1],[9,31,1]],[[16,0,2],[9,31,0]],[[16,0,3],[9,31,1]],[[16,0,4],[10,30,1]],[[17,0,3],[10,30,0]],[[17,0,2],[10,31,1]],[[17,0,1],[10,31,0]],[[17,0,0],[12,27,0]],[[17,0,1],[11,30,1]],[[17,0,2],[11,30,0]],[[17,0,3],[12,28,0]],[[17,0,4],[11,31,1]],[[18,0,3],[11,31,0]],[[18,0,2],[11,31,1]],[[18,0,1],[12,30,1]],[[18,0,0],[12,30,0]],[[18,0,1],[14,27,1]],[[18,0,2],[14,27,0]],[[18,0,3],[12,31,0]],[[18,0,4],[13,30,1]],[[19,0,3],[13,30,0]],[[19,0,2],[16,24,0]],[[19,0,1],[13,31,1]],[[19,0,0],[13,31,0]],[[19,0,1],[13,31,1]],[[19,0,2],[14,30,1]],[[19,0,3],[14,30,0]],[[19,0,4],[14,31,1]],[[20,0,4],[14,31,0]],[[20,0,3],[16,27,0]],[[20,0,2],[15,30,1]],[[20,0,1],[15,30,0]],[[20,0,0],[16,28,0]],[[20,0,1],[15,31,1]],[[20,0,2],[15,31,0]],[[20,0,3],[15,31,1]],[[20,0,4],[16,30,1]],[[21,0,3],[16,30,0]],[[21,0,2],[18,27,1]],[[21,0,1],[18,27,0]],[[21,0,0],[16,31,0]],[[21,0,1],[17,30,1]],[[21,0,2],[17,30,0]],[[21,0,3],[20,24,0]],[[21,0,4],[17,31,1]],[[22,0,3],[17,31,0]],[[22,0,2],[17,31,1]],[[22,0,1],[18,30,1]],[[22,0,0],[18,30,0]],[[22,0,1],[18,31,1]],[[22,0,2],[18,31,0]],[[22,0,3],[20,27,0]],[[22,0,4],[19,30,1]],[[23,0,3],[19,30,0]],[[23,0,2],[20,28,0]],[[23,0,1],[19,31,1]],[[23,0,0],[19,31,0]],[[23,0,1],[19,31,1]],[[23,0,2],[20,30,1]],[[23,0,3],[20,30,0]],[[23,0,4],[22,27,1]],[[24,0,4],[22,27,0]],[[24,0,3],[20,31,0]],[[24,0,2],[21,30,1]],[[24,0,1],[21,30,0]],[[24,0,0],[24,24,0]],[[24,0,1],[21,31,1]],[[24,0,2],[21,31,0]],[[24,0,3],[21,31,1]],[[24,0,4],[22,30,1]],[[25,0,3],[22,30,0]],[[25,0,2],[22,31,1]],[[25,0,1],[22,31,0]],[[25,0,0],[24,27,0]],[[25,0,1],[23,30,1]],[[25,0,2],[23,30,0]],[[25,0,3],[24,28,0]],[[25,0,4],[23,31,1]],[[26,0,3],[23,31,0]],[[26,0,2],[23,31,1]],[[26,0,1],[24,30,1]],[[26,0,0],[24,30,0]],[[26,0,1],[26,27,1]],[[26,0,2],[26,27,0]],[[26,0,3],[24,31,0]],[[26,0,4],[25,30,1]],[[27,0,3],[25,30,0]],[[27,0,2],[28,24,0]],[[27,0,1],[25,31,1]],[[27,0,0],[25,31,0]],[[27,0,1],[25,31,1]],[[27,0,2],[26,30,1]],[[27,0,3],[26,30,0]],[[27,0,4],[26,31,1]],[[28,0,4],[26,31,0]],[[28,0,3],[28,27,0]],[[28,0,2],[27,30,1]],[[28,0,1],[27,30,0]],[[28,0,0],[28,28,0]],[[28,0,1],[27,31,1]],[[28,0,2],[27,31,0]],[[28,0,3],[27,31,1]],[[28,0,4],[28,30,1]],[[29,0,3],[28,30,0]],[[29,0,2],[30,27,1]],[[29,0,1],[30,27,0]],[[29,0,0],[28,31,0]],[[29,0,1],[29,30,1]],[[29,0,2],[29,30,0]],[[29,0,3],[29,30,1]],[[29,0,4],[29,31,1]],[[30,0,3],[29,31,0]],[[30,0,2],[29,31,1]],[[30,0,1],[30,30,1]],[[30,0,0],[30,30,0]],[[30,0,1],[30,31,1]],[[30,0,2],[30,31,0]],[[30,0,3],[30,31,1]],[[30,0,4],[31,30,1]],[[31,0,3],[31,30,0]],[[31,0,2],[31,30,1]],[[31,0,1],[31,31,1]],[[31,0,0],[31,31,0]]],I=[[[0,0,0],[0,0,0]],[[0,0,1],[0,1,0]],[[0,0,2],[0,2,0]],[[1,0,1],[0,3,1]],[[1,0,0],[0,3,0]],[[1,0,1],[0,4,0]],[[1,0,2],[0,5,0]],[[2,0,1],[0,6,1]],[[2,0,0],[0,6,0]],[[2,0,1],[0,7,0]],[[2,0,2],[0,8,0]],[[3,0,1],[0,9,1]],[[3,0,0],[0,9,0]],[[3,0,1],[0,10,0]],[[3,0,2],[0,11,0]],[[4,0,1],[0,12,1]],[[4,0,0],[0,12,0]],[[4,0,1],[0,13,0]],[[4,0,2],[0,14,0]],[[5,0,1],[0,15,1]],[[5,0,0],[0,15,0]],[[5,0,1],[0,16,0]],[[5,0,2],[1,15,0]],[[6,0,1],[0,17,0]],[[6,0,0],[0,18,0]],[[6,0,1],[0,19,0]],[[6,0,2],[3,14,0]],[[7,0,1],[0,20,0]],[[7,0,0],[0,21,0]],[[7,0,1],[0,22,0]],[[7,0,2],[4,15,0]],[[8,0,1],[0,23,0]],[[8,0,0],[0,24,0]],[[8,0,1],[0,25,0]],[[8,0,2],[6,14,0]],[[9,0,1],[0,26,0]],[[9,0,0],[0,27,0]],[[9,0,1],[0,28,0]],[[9,0,2],[7,15,0]],[[10,0,1],[0,29,0]],[[10,0,0],[0,30,0]],[[10,0,1],[0,31,0]],[[10,0,2],[9,14,0]],[[11,0,1],[0,32,0]],[[11,0,0],[0,33,0]],[[11,0,1],[2,30,0]],[[11,0,2],[0,34,0]],[[12,0,1],[0,35,0]],[[12,0,0],[0,36,0]],[[12,0,1],[3,31,0]],[[12,0,2],[0,37,0]],[[13,0,1],[0,38,0]],[[13,0,0],[0,39,0]],[[13,0,1],[5,30,0]],[[13,0,2],[0,40,0]],[[14,0,1],[0,41,0]],[[14,0,0],[0,42,0]],[[14,0,1],[6,31,0]],[[14,0,2],[0,43,0]],[[15,0,1],[0,44,0]],[[15,0,0],[0,45,0]],[[15,0,1],[8,30,0]],[[15,0,2],[0,46,0]],[[16,0,2],[0,47,0]],[[16,0,1],[1,46,0]],[[16,0,0],[0,48,0]],[[16,0,1],[0,49,0]],[[16,0,2],[0,50,0]],[[17,0,1],[2,47,0]],[[17,0,0],[0,51,0]],[[17,0,1],[0,52,0]],[[17,0,2],[0,53,0]],[[18,0,1],[4,46,0]],[[18,0,0],[0,54,0]],[[18,0,1],[0,55,0]],[[18,0,2],[0,56,0]],[[19,0,1],[5,47,0]],[[19,0,0],[0,57,0]],[[19,0,1],[0,58,0]],[[19,0,2],[0,59,0]],[[20,0,1],[7,46,0]],[[20,0,0],[0,60,0]],[[20,0,1],[0,61,0]],[[20,0,2],[0,62,0]],[[21,0,1],[8,47,0]],[[21,0,0],[0,63,0]],[[21,0,1],[1,62,0]],[[21,0,2],[1,63,0]],[[22,0,1],[10,46,0]],[[22,0,0],[2,62,0]],[[22,0,1],[2,63,0]],[[22,0,2],[3,62,0]],[[23,0,1],[11,47,0]],[[23,0,0],[3,63,0]],[[23,0,1],[4,62,0]],[[23,0,2],[4,63,0]],[[24,0,1],[13,46,0]],[[24,0,0],[5,62,0]],[[24,0,1],[5,63,0]],[[24,0,2],[6,62,0]],[[25,0,1],[14,47,0]],[[25,0,0],[6,63,0]],[[25,0,1],[7,62,0]],[[25,0,2],[7,63,0]],[[26,0,1],[16,45,0]],[[26,0,0],[8,62,0]],[[26,0,1],[8,63,0]],[[26,0,2],[9,62,0]],[[27,0,1],[16,48,0]],[[27,0,0],[9,63,0]],[[27,0,1],[10,62,0]],[[27,0,2],[10,63,0]],[[28,0,1],[16,51,0]],[[28,0,0],[11,62,0]],[[28,0,1],[11,63,0]],[[28,0,2],[12,62,0]],[[29,0,1],[16,54,0]],[[29,0,0],[12,63,0]],[[29,0,1],[13,62,0]],[[29,0,2],[13,63,0]],[[30,0,1],[16,57,0]],[[30,0,0],[14,62,0]],[[30,0,1],[14,63,0]],[[30,0,2],[15,62,0]],[[31,0,1],[16,60,0]],[[31,0,0],[15,63,0]],[[31,0,1],[24,46,0]],[[31,0,2],[16,62,0]],[[32,0,2],[16,63,0]],[[32,0,1],[17,62,0]],[[32,0,0],[25,47,0]],[[32,0,1],[17,63,0]],[[32,0,2],[18,62,0]],[[33,0,1],[18,63,0]],[[33,0,0],[27,46,0]],[[33,0,1],[19,62,0]],[[33,0,2],[19,63,0]],[[34,0,1],[20,62,0]],[[34,0,0],[28,47,0]],[[34,0,1],[20,63,0]],[[34,0,2],[21,62,0]],[[35,0,1],[21,63,0]],[[35,0,0],[30,46,0]],[[35,0,1],[22,62,0]],[[35,0,2],[22,63,0]],[[36,0,1],[23,62,0]],[[36,0,0],[31,47,0]],[[36,0,1],[23,63,0]],[[36,0,2],[24,62,0]],[[37,0,1],[24,63,0]],[[37,0,0],[32,47,0]],[[37,0,1],[25,62,0]],[[37,0,2],[25,63,0]],[[38,0,1],[26,62,0]],[[38,0,0],[32,50,0]],[[38,0,1],[26,63,0]],[[38,0,2],[27,62,0]],[[39,0,1],[27,63,0]],[[39,0,0],[32,53,0]],[[39,0,1],[28,62,0]],[[39,0,2],[28,63,0]],[[40,0,1],[29,62,0]],[[40,0,0],[32,56,0]],[[40,0,1],[29,63,0]],[[40,0,2],[30,62,0]],[[41,0,1],[30,63,0]],[[41,0,0],[32,59,0]],[[41,0,1],[31,62,0]],[[41,0,2],[31,63,0]],[[42,0,1],[32,61,0]],[[42,0,0],[32,62,0]],[[42,0,1],[32,63,0]],[[42,0,2],[41,46,0]],[[43,0,1],[33,62,0]],[[43,0,0],[33,63,0]],[[43,0,1],[34,62,0]],[[43,0,2],[42,47,0]],[[44,0,1],[34,63,0]],[[44,0,0],[35,62,0]],[[44,0,1],[35,63,0]],[[44,0,2],[44,46,0]],[[45,0,1],[36,62,0]],[[45,0,0],[36,63,0]],[[45,0,1],[37,62,0]],[[45,0,2],[45,47,0]],[[46,0,1],[37,63,0]],[[46,0,0],[38,62,0]],[[46,0,1],[38,63,0]],[[46,0,2],[47,46,0]],[[47,0,1],[39,62,0]],[[47,0,0],[39,63,0]],[[47,0,1],[40,62,0]],[[47,0,2],[48,46,0]],[[48,0,2],[40,63,0]],[[48,0,1],[41,62,0]],[[48,0,0],[41,63,0]],[[48,0,1],[48,49,0]],[[48,0,2],[42,62,0]],[[49,0,1],[42,63,0]],[[49,0,0],[43,62,0]],[[49,0,1],[48,52,0]],[[49,0,2],[43,63,0]],[[50,0,1],[44,62,0]],[[50,0,0],[44,63,0]],[[50,0,1],[48,55,0]],[[50,0,2],[45,62,0]],[[51,0,1],[45,63,0]],[[51,0,0],[46,62,0]],[[51,0,1],[48,58,0]],[[51,0,2],[46,63,0]],[[52,0,1],[47,62,0]],[[52,0,0],[47,63,0]],[[52,0,1],[48,61,0]],[[52,0,2],[48,62,0]],[[53,0,1],[56,47,0]],[[53,0,0],[48,63,0]],[[53,0,1],[49,62,0]],[[53,0,2],[49,63,0]],[[54,0,1],[58,46,0]],[[54,0,0],[50,62,0]],[[54,0,1],[50,63,0]],[[54,0,2],[51,62,0]],[[55,0,1],[59,47,0]],[[55,0,0],[51,63,0]],[[55,0,1],[52,62,0]],[[55,0,2],[52,63,0]],[[56,0,1],[61,46,0]],[[56,0,0],[53,62,0]],[[56,0,1],[53,63,0]],[[56,0,2],[54,62,0]],[[57,0,1],[62,47,0]],[[57,0,0],[54,63,0]],[[57,0,1],[55,62,0]],[[57,0,2],[55,63,0]],[[58,0,1],[56,62,1]],[[58,0,0],[56,62,0]],[[58,0,1],[56,63,0]],[[58,0,2],[57,62,0]],[[59,0,1],[57,63,1]],[[59,0,0],[57,63,0]],[[59,0,1],[58,62,0]],[[59,0,2],[58,63,0]],[[60,0,1],[59,62,1]],[[60,0,0],[59,62,0]],[[60,0,1],[59,63,0]],[[60,0,2],[60,62,0]],[[61,0,1],[60,63,1]],[[61,0,0],[60,63,0]],[[61,0,1],[61,62,0]],[[61,0,2],[61,63,0]],[[62,0,1],[62,62,1]],[[62,0,0],[62,62,0]],[[62,0,1],[62,63,0]],[[62,0,2],[63,62,0]],[[63,0,1],[63,63,1]],[[63,0,0],[63,63,0]]];function A(t,e){const r=parseInt(t+.5);return r<0?0:r}function C(t){return A(31*t.x)<<11|A(63*t.y)<<5|A(31*t.z)}function F(t,e,r,s,n){s[n+0]=255&t,s[n+1]=t>>8,s[n+2]=255&e,s[n+3]=e>>8;for(let t=0;t<4;t++)s[n+4+t]=r[4*t+0]|r[4*t+1]<<2|r[4*t+2]<<4|r[4*t+3]<<6}function X(t,e,r,s,n){let i,a=C(t),o=C(e);a<=o?i=r.slice():([a,o]=[o,a],i=r.map((t=>0===t?1:1===t?0:t))),F(a,o,i,s,n)}function B(t,e,r,s,n){let i,a=C(t),o=C(e);a3&(1^t)))):i=a==o?new Array(16).fill(0):r.slice(),F(a,o,i,s,n)}class E{constructor(t,e,r){this.flags=r,this._count=0,this._transparent=!1,this._remap=[],this._weights=[],this._points=[];const s=0!=(1&this.flags),n=0!=(128&this.flags);for(let r=0;r<16;r++){if(0!=(e&1<=128||!s)){const e=this._remap[i],s=(t[4*r+3]+1)/256;this._weights[e]+=n?s:1,this._remap[r]=e;break}}else this._remap[r]=-1}for(let t=0;t-1===e?3:t));e.forEach(((t,s)=>e[s]=r[s]))}remapIndices(t,e){const r=this._remap.map((e=>-1===e?3:t[e]));e.forEach(((t,s)=>e[s]=r[s]))}}class L{constructor(t){this.colors=t,this.flags=t.flags}compress(t,e){0!=(1&this.flags)?(this.compress3(t,e),this.colors.transparent||this.compress4(t,e)):this.compress4(t,e)}compress3(t,e){}compress4(t,e){}}class U extends L{constructor(t){super(t);const e=t.points[0];this.color=e.colorInt,this.start=new z(0),this.end=new z(0),this.index=0,this.error=1/0,this.bestError=1/0}compressBase(t,e){if(this.computeEndPoints(t),this.errorX(r,s,n,t,e)))}compress4(t,e){const r=[R,I,R];this.compressBase(r,((r,s,n)=>B(r,s,n,t,e)))}computeEndPoints(t){this.error=1/0;for(let e=0;e<2;e++){const r=[];let s=0;for(let n=0;n<3;n++){const i=t[n],a=this.color[n];r[n]=i[a][e];const o=r[n][2];s+=o*o}s{let r=1/0;const n=t.reduce(((t,s,n)=>{const i=z.sub(e,s).multVector(this.metric).lengthSq;return i>=r?t:(r=i,n)}),0);return s+=r,n}));if(sX(r,s,n,t,e)))}compress4(t,e){const r=[this.start.clone(),this.end.clone(),z.interpolate(this.start,this.end,1/3),z.interpolate(this.start,this.end,2/3)];this.compressBase(r,((r,s,n)=>B(r,s,n,t,e)))}computePoints(){const{count:t,points:e,weights:r}=this.colors;if(t<=0)return;const s=S(e,r);let n,i,a,o;n=i=e[0],a=o=z.dot(n,s);for(let r=1;ro&&(i=e[r],o=t)}this.start=n.clampGrid().clone(),this.end=i.clampGrid().clone()}}class P extends L{constructor(t){super(t);this.iterationCount=t.flags&p?8:1,this.bestError=1/0,this.metric=new V(1),0!=(32&this.flags)&&this.metric.set(.2126,.7152,.0722,0);const{points:e,weights:r}=this.colors;this.principle=S(e,r),this.order=new Uint8Array(128),this.pointsWeights=[],this.xSum_wSum=new V(0)}constructOrdering(t,e){const r=this.makeOrder(t);this.copyOrderToThisOrder(r,e);return!!this.checkOrderUnique(r,e)&&(this.copyOrderWeight(r),!0)}compress3(t,e){this.compressBase((t=>{let[e,,r,s]=t;const n=new V(.5,.5,.5,1/4),i=V.multiplyAdd(r,n,e),a=i.splatW,o=V.multiplyAdd(r,n,s);return{ax:i,aa:a,bx:o,bb:o.splatW,ab:V.multVector(r,n).splatW}}),((r,s,n)=>X(r,s,n,t,e)),2)}compress4(t,e){this.compressBase((t=>{let[e,r,s,n]=t;const i=new V(1/3,1/3,1/3,1/9),a=new V(2/3,2/3,2/3,4/9),o=new V(2/9),l=V.multiplyAdd(s,i,V.multiplyAdd(r,a,e)),u=l.splatW,c=V.multiplyAdd(r,i,V.multiplyAdd(s,a,n));return{ax:l,aa:u,bx:c,bb:c.splatW,ab:V.multVector(o,V.add(r,s)).splatW}}),((r,s,n)=>B(r,s,n,t,e)),3)}compressBase(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;this.constructOrdering(this.principle,0);let s={start:new V(0),end:new V(0),error:this.bestError,iteration:0,bestI:0,bestJ:0};3===r&&(s.bestK=0);const n=(e,r)=>{const n=t(e),i=this.computeOptimalPoints(n);return i.errorz.dot(e,t)));return Array.from({length:e},((t,e)=>e)).sort(((t,e)=>s[t]-s[e]!=0?s[t]-s[e]:t-e))}copyOrderToThisOrder(t,e){const r=16*e;t.forEach(((t,e)=>{this.order[r+e]=t}))}checkOrderUnique(t,e){const{count:r}=this.colors;for(let s=0;s2&&void 0!==arguments[2]?arguments[2]:2;const{count:s}=this.colors,n=(e,s,n)=>{const i={bestI:e,bestJ:2===r?n:s,iteration:t};return 3===r&&(i.bestK=n),i};let i=new V(0);for(let t=0;t15?15:e}function W(t,e,r,s){let n=N(t,e,5),i=N(t,e,7);n.error<=i.error?function(t,e,r){let{min:s,max:n,indices:i}=t;if(s>n){G(n,s,i.map((t=>0===t?1:1===t?0:t<=5?7-t:t)),e,r)}else G(s,n,i,e,r)}(n,r,s):function(t,e,r){let{min:s,max:n,indices:i}=t;if(s>n){G(n,s,i.map((t=>0===t?1:1===t?0:9-t)),e,r)}else G(s,n,i,e,r)}(i,r,s)}function N(t,e,r){let{min:s,max:n}=function(t,e,r){let s=255,n=0;for(let i=0;i<16;i++){if(0==(e&1<n&&(n=a)):(an&&(n=a))}s>n&&(s=n);n-sMath.floor(((r-(n+1))*t+(n+1)*e)/r)))];return 5===r&&(s[6]=0,s[7]=255),s}function G(t,e,r,s,n){s[n]=t,s[n+1]=e;let i=0,a=n+2;for(let t=0;t<2;t++){let t=0;for(let e=0;e<8;++e){t|=r[i]<<3*e,i++}for(let e=0;e<3;++e){let r=t>>8*e&255;s[a]=r,a++}}}function K(t){const e=t>>11&31,r=t>>5&63,s=31&t;return[e<<3|e>>2,r<<2|r>>4,s<<3|s>>2,255]}function J(t,e,r){const s=t.map(((t,s)=>Math.floor(t*(1-r)+e[s]*r)));return s[3]=255,s}function H(t,e,r,s){const n=function(t,e,r){const s=t[e]|t[e+1]<<8,n=t[e+2]|t[e+3]<<8,i=K(s),a=K(n);return[i,a,J(i,a,r&&s<=n?.5:1/3),r&&s<=n?[0,0,0,0]:J(i,a,2/3)]}(e,r,s),i=function(t,e){let r=e+4,s=new Uint8Array(16);for(let e=0;e<4;e++){let n=t[r+e];s[4*e+0]=3&n,s[4*e+1]=n>>2&3,s[4*e+2]=n>>4&3,s[4*e+3]=n>>6&3}return s}(e,r);for(let e=0;e<16;e++)for(let r=0;r<4;r++)t[4*e+r]=n[i[e]][r]}function Y(t){for(let e=0;e<4;e++)for(let r=0;r<4;r++)t(r,e)}function Z(t){let e=7&t,r=280&t,s=96&t;return 2!=e&&4!=e&&(e=1),16!=r&&r!=p&&(r=8),64!=s&&(s=32),e|r|s|128&t}function Q(t,e){let{x:r=0,y:s=0,width:n=0,height:i=0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=0;Y((function(o,l){let u=r+o,c=s+l;if(u>4}}(t,e,r):0!=(4&s)&&function(t,e,r){let s=e[r+0],n=e[r+1],i=q(s,n,s<=n?5:7),a=new Uint8Array(16),o=0,l=2;for(let t=0;t<2;t++){let t=0;for(let s=0;s<3;s++)t|=e[r+l]<<8*s,l++;for(let e=0;e<8;e++){let r=t>>3*e&7;a[o]=r,o++}}for(let e=0;e<16;++e)t[4*e+3]=i[a[e]]}(t,e,r)}function et(t,e,r,s,n){const i=0!=(1&(n=Z(n)))?8:16;let a=0;!function(t,e,r){for(let s=0;s1&&void 0!==arguments[1]?arguments[1]:{};const i=new Uint8Array(64);let a=0,o=0;return Y((function(l,u){let c=e+l,h=r+u;if(c>r&2**e-1}function lt(t,e,r,s){const n=Math.round(t/255*31),i=Math.round(e/255*31),a=Math.round(r/255*31);return Math.round(s/255)<<15|n<<10|i<<5|a}function ut(t){const e=ot(t,5,10),r=ot(t,5,5),s=ot(t,5,0),n=t>>15&1,[i,a,o]=[e,r,s].map((t=>t<<3|t>>2));return[i,a,o,255*n]}class ct extends e{static isTypeOf(t){return"Microsoft.Xna.Framework.Content.Texture2DReader"===t}read(t){const e=new u,s=new r;let n=e.read(t),i=s.read(t),a=s.read(t),o=s.read(t),l=null,c=null;o>1&&console.warn("Found mipcount of ".concat(o,", only the first will be used."));let h=s.read(t);i*a*4>h&&(l=i>>16&65535,i&=65535,c=a>>16&65535,a&=65535,i*a*4!==h&&console.warn("invalid width & height! ".concat(i," x ").concat(a)));let d=t.read(h);if(4==n)d=at(d,i,a,rt);else if(5==n)d=at(d,i,a,st);else if(6==n)d=at(d,i,a,nt);else if(2==n)d=function(t){const e=new Uint8Array(t),r=e.length/2,s=new Uint8Array(4*r);for(let t=0;t>8}return s}(l)),i.write(t,l.length,null),t.concat(l)}isValueType(){return!1}}class ht extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.Vector3Reader":case"Microsoft.Xna.Framework.Vector3":return!0;default:return!1}}read(t){const e=new w;return{x:e.read(t),y:e.read(t),z:e.read(t)}}write(t,e,r){this.writeIndex(t,r);const s=new w;s.write(t,e.x,null),s.write(t,e.y,null),s.write(t,e.z,null)}}t.ArrayReader=class extends e{static isTypeOf(t){return"Microsoft.Xna.Framework.Content.ArrayReader"===t}static hasSubType(){return!0}constructor(t){super(),this.reader=t}read(t,e){let s=(new r).read(t),n=[];for(let r=0;r")}parseTypeList(){const t=this.reader.parseTypeList();return["".concat(this.type,":").concat(t.length),...t]}},t.BaseReader=e,t.BmFontReader=class extends e{static isTypeOf(t){return"BmFont.XmlSourceReader"===t}read(t){const e=(new a).read(t);return{export:{type:this.type,data:e}}}write(t,e,r){this.writeIndex(t,r);(new a).write(t,e.export.data,null)}isValueType(){return!1}},t.BooleanReader=o,t.CharReader=l,t.DictionaryReader=class extends e{static isTypeOf(t){return"Microsoft.Xna.Framework.Content.DictionaryReader"===t}static hasSubType(){return!0}constructor(t,e){if(null==t||null==e)throw new Error("Cannot create instance of DictionaryReader without Key and Value.");super(),this.key=t,this.value=e}read(t,e){let s={};const n=(new r).read(t);for(let r=0;r")}parseTypeList(){return[this.type,...this.key.parseTypeList(),...this.value.parseTypeList()]}},t.DoubleReader=class extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.DoubleReader":case"System.Double":return!0;default:return!1}}read(t){return t.readDouble()}write(t,e,r){this.writeIndex(t,r),t.writeDouble(e)}},t.EffectReader=class extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.EffectReader":case"Microsoft.Xna.Framework.Graphics.Effect":return!0;default:return!1}}read(t){const e=(new r).read(t),s=t.read(e);return{export:{type:this.type,data:s}}}write(t,e,s){this.writeIndex(t,s);const n=e.export.data;(new r).write(t,n.byteLength,null),t.concat(n)}isValueType(){return!1}},t.Int32Reader=u,t.LightweightTexture2DReader=class extends e{static isTypeOf(t){return"Microsoft.Xna.Framework.Content.Texture2DReader"===t}static type(){return"Texture2D"}read(t){const e=new u,s=new r;let n=e.read(t),i=s.read(t),a=s.read(t),o=s.read(t);o>1&&console.warn("Found mipcount of ".concat(o,", only the first will be used."));let l=s.read(t),c=t.read(l);if(c=new Uint8Array(c),0!=n)throw new Error("Compressed texture format is not supported!");for(let t=0;t","Rectangle","List","Rectangle","List","Char",null,null,"List","Vector3","Nullable","Char"]}read(t,e){const r=new u,s=new w,n=new h(new l);return{texture:e.read(t),glyphs:e.read(t),cropping:e.read(t),characterMap:e.read(t),verticalLineSpacing:r.read(t),horizontalSpacing:s.read(t),kerning:e.read(t),defaultCharacter:n.read(t)}}write(t,e,r){const s=new u,n=new l,i=new w,a=new h(n),o=new ct,p=new c(new d),f=new c(n),y=new c(new ht);this.writeIndex(t,r);try{o.write(t,e.texture,r),t.alloc(1e5),p.write(t,e.glyphs,r),p.write(t,e.cropping,r),f.write(t,e.characterMap,r),s.write(t,e.verticalLineSpacing,null),i.write(t,e.horizontalSpacing,null),y.write(t,e.kerning,r),a.write(t,e.defaultCharacter,null)}catch(t){throw t}}isValueType(){return!1}},t.StringReader=a,t.TBinReader=class extends e{static isTypeOf(t){return"xTile.Pipeline.TideReader"===t}read(t){let e=(new u).read(t),r=t.read(e);return{export:{type:this.type,data:r}}}write(t,e,r){this.writeIndex(t,r);const s=e.export.data;(new u).write(t,s.byteLength,null),t.concat(s)}isValueType(){return!1}},t.Texture2DReader=ct,t.UInt32Reader=r,t.Vector2Reader=class extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.Vector2Reader":case"Microsoft.Xna.Framework.Vector2":return!0;default:return!1}}read(t){const e=new w;return{x:e.read(t),y:e.read(t)}}write(t,e,r){this.writeIndex(t,r);const s=new w;s.write(t,e.x,null),s.write(t,e.y,null)}},t.Vector3Reader=ht,t.Vector4Reader=class extends e{static isTypeOf(t){switch(t){case"Microsoft.Xna.Framework.Content.Vector4Reader":case"Microsoft.Xna.Framework.Vector4":return!0;default:return!1}}read(t){const e=new w;return{x:e.read(t),y:e.read(t),z:e.read(t),w:e.read(t)}}write(t,e,r){this.writeIndex(t,r);const s=new w;s.write(t,e.x,null),s.write(t,e.y,null),s.write(t,e.z,null),s.write(t,e.w,null)}},Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/dist/readers/xnb-readers.module.js b/dist/readers/xnb-readers.module.js index 8167e7e..c9ea9a2 100644 --- a/dist/readers/xnb-readers.module.js +++ b/dist/readers/xnb-readers.module.js @@ -1,5 +1,5 @@ /** - * xnb.js 1.2.0 + * xnb.js 1.3.0 * made by Lybell( https://github.com/lybell-art/ ) * This library is based on the XnbCli made by Leonblade. * @@ -11,47 +11,36 @@ class BaseReader { static isTypeOf(type) { return false; } - static hasSubType() { return false; } - static parseTypeList() { return [this.type()]; } - static type() { return this.name.slice(0, -6); } - isValueType() { return true; } - get type() { return this.constructor.type(); } - read(buffer, resolver) { throw new Error('Cannot invoke methods on abstract class.'); } - write(buffer, content, resolver) { throw new Error('Cannot invoke methods on abstract class.'); } - writeIndex(buffer, resolver) { if (resolver != null) buffer.write7BitNumber(Number.parseInt(resolver.getIndex(this)) + 1); } - toString() { return this.type; } - parseTypeList() { return this.constructor.parseTypeList(); } - } class UInt32Reader extends BaseReader { @@ -60,21 +49,17 @@ class UInt32Reader extends BaseReader { case 'Microsoft.Xna.Framework.Content.UInt32Reader': case 'System.UInt32': return true; - default: return false; } } - read(buffer) { return buffer.readUInt32(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeUInt32(content); } - } class ArrayReader extends BaseReader { @@ -82,79 +67,63 @@ class ArrayReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.ArrayReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer, resolver) { const uint32Reader = new UInt32Reader(); let size = uint32Reader.read(buffer); let array = []; - for (let i = 0; i < size; i++) { let value = this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); array.push(value); } - return array; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const uint32Reader = new UInt32Reader(); - uint32Reader.write(buffer, content.length, resolver); - + uint32Reader.write(buffer, content.length, null); for (let i = 0; i < content.length; i++) this.reader.write(buffer, content[i], this.reader.isValueType() ? null : resolver); } - isValueType() { return false; } - get type() { return "Array<".concat(this.reader.type, ">"); } - parseTypeList() { - return [this.type, ...this.reader.parseTypeList()]; + const inBlock = this.reader.parseTypeList(); + return ["".concat(this.type, ":").concat(inBlock.length), ...inBlock]; } - } const UTF16_BITES = [0xD800, 0xDC00]; const UTF16_MASK = 0b1111111111; - function UTF16Decode(codeSet) { var _codeSet2; - if (typeof codeSet === "number") codeSet = [codeSet]; if (!((_codeSet2 = codeSet) !== null && _codeSet2 !== void 0 && _codeSet2.length)) throw new Error("Invalid codeset!"); const codeSetRange = codeSet.length; if (codeSetRange === 1) return codeSet[0]; return ((codeSet[0] & UTF16_MASK) << 10) + (codeSet[1] & UTF16_MASK) + 0x10000; } - function stringToUnicode(str) { const utf16Map = Array.from({ length: str.length }, (_, i) => str.charCodeAt(i)); const result = []; let index = 0; - while (index < str.length) { let code = utf16Map[index]; - if ((UTF16_BITES[0] & code) !== UTF16_BITES[0]) { result.push(code); index++; @@ -163,10 +132,8 @@ function stringToUnicode(str) { index += 2; } } - return result; } - function UTF8Length(str) { const codes = stringToUnicode(str); return codes.reduce((sum, unicode) => { @@ -183,28 +150,23 @@ class StringReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.StringReader': case 'System.String': return true; - default: return false; } } - read(buffer) { let length = buffer.read7BitNumber(); return buffer.readString(length); } - write(buffer, string, resolver) { this.writeIndex(buffer, resolver); const size = UTF8Length(string); buffer.write7BitNumber(size); buffer.writeString(string); } - isValueType() { return false; } - } class BmFontReader extends BaseReader { @@ -212,12 +174,10 @@ class BmFontReader extends BaseReader { switch (type) { case 'BmFont.XmlSourceReader': return true; - default: return false; } } - read(buffer) { const stringReader = new StringReader(); const xml = stringReader.read(buffer); @@ -228,17 +188,14 @@ class BmFontReader extends BaseReader { } }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const stringReader = new StringReader(); stringReader.write(buffer, content.export.data, null); } - isValueType() { return false; } - } class BooleanReader extends BaseReader { @@ -247,21 +204,17 @@ class BooleanReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.BooleanReader': case 'System.Boolean': return true; - default: return false; } } - read(buffer) { return Boolean(buffer.readInt()); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeByte(content); } - } class CharReader extends BaseReader { @@ -270,27 +223,21 @@ class CharReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.CharReader': case 'System.Char': return true; - default: return false; } } - read(buffer) { let charSize = this._getCharSize(buffer.peekInt()); - return buffer.readString(charSize); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeString(content); } - _getCharSize(byte) { return (0xE5000000 >> (byte >> 3 & 0x1e) & 3) + 1; } - } class DictionaryReader extends BaseReader { @@ -298,59 +245,47 @@ class DictionaryReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.DictionaryReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(key, value) { if (key == undefined || value == undefined) throw new Error('Cannot create instance of DictionaryReader without Key and Value.'); super(); this.key = key; this.value = value; } - read(buffer, resolver) { let dictionary = {}; const uint32Reader = new UInt32Reader(); const size = uint32Reader.read(buffer); - for (let i = 0; i < size; i++) { let key = this.key.isValueType() ? this.key.read(buffer) : resolver.read(buffer); let value = this.value.isValueType() ? this.value.read(buffer) : resolver.read(buffer); dictionary[key] = value; } - return dictionary; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeUInt32(Object.keys(content).length); - for (let key of Object.keys(content)) { this.key.write(buffer, key, this.key.isValueType() ? null : resolver); this.value.write(buffer, content[key], this.value.isValueType() ? null : resolver); } } - isValueType() { return false; } - get type() { return "Dictionary<".concat(this.key.type, ",").concat(this.value.type, ">"); } - parseTypeList() { return [this.type, ...this.key.parseTypeList(), ...this.value.parseTypeList()]; } - } class DoubleReader extends BaseReader { @@ -359,21 +294,17 @@ class DoubleReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.DoubleReader': case 'System.Double': return true; - default: return false; } } - read(buffer) { return buffer.readDouble(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeDouble(content); } - } class EffectReader extends BaseReader { @@ -382,12 +313,10 @@ class EffectReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.EffectReader': case 'Microsoft.Xna.Framework.Graphics.Effect': return true; - default: return false; } } - read(buffer) { const uint32Reader = new UInt32Reader(); const size = uint32Reader.read(buffer); @@ -399,7 +328,6 @@ class EffectReader extends BaseReader { } }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const data = content.export.data; @@ -407,34 +335,29 @@ class EffectReader extends BaseReader { uint32Reader.write(buffer, data.byteLength, null); buffer.concat(data); } - isValueType() { return false; } - } class Int32Reader extends BaseReader { static isTypeOf(type) { switch (type) { case 'Microsoft.Xna.Framework.Content.Int32Reader': + case 'Microsoft.Xna.Framework.Content.EnumReader': case 'System.Int32': return true; - default: return false; } } - read(buffer) { return buffer.readInt32(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeInt32(content); } - } class ListReader extends BaseReader { @@ -443,56 +366,45 @@ class ListReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.ListReader': case 'System.Collections.Generic.List': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer, resolver) { const uint32Reader = new UInt32Reader(); const size = uint32Reader.read(buffer); const list = []; - for (let i = 0; i < size; i++) { const value = this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); list.push(value); } - return list; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const uint32Reader = new UInt32Reader(); uint32Reader.write(buffer, content.length, null); - - for (let data of Object.values(content)) { + for (let data of content) { this.reader.write(buffer, data, this.reader.isValueType() ? null : resolver); } } - isValueType() { return false; } - get type() { return "List<".concat(this.reader.type, ">"); } - parseTypeList() { - return [this.type, ...this.reader.parseTypeList()]; + const inBlock = this.reader.parseTypeList(); + return ["".concat(this.type, ":").concat(inBlock.length), ...inBlock]; } - } class NullableReader extends BaseReader { @@ -500,65 +412,78 @@ class NullableReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.NullableReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer) { let resolver = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; const booleanReader = new BooleanReader(); const hasValue = buffer.peekByte(1); - if (!hasValue) { booleanReader.read(buffer); return null; } - - if (resolver === null) { + if (resolver === null || this.reader.isValueType()) { booleanReader.read(buffer); return this.reader.read(buffer); } - - return this.reader.isValueType() ? this.reader.read(buffer) : resolver.read(buffer); + return resolver.read(buffer); } - write(buffer) { let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let resolver = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - if (content === null) { buffer.writeByte(0); return; } - - if (resolver === null) buffer.writeByte(1); + if (resolver === null || this.reader.isValueType()) buffer.writeByte(1); this.reader.write(buffer, content, this.reader.isValueType() ? null : resolver); } - isValueType() { return false; } - get type() { return "Nullable<".concat(this.reader.type, ">"); } - parseTypeList() { const inBlock = this.reader.parseTypeList(); return ["".concat(this.type, ":").concat(inBlock.length), ...inBlock]; } +} +class PointReader extends BaseReader { + static isTypeOf(type) { + switch (type) { + case 'Microsoft.Xna.Framework.Content.PointReader': + case 'Microsoft.Xna.Framework.Point': + return true; + default: + return false; + } + } + read(buffer) { + const int32Reader = new Int32Reader(); + const x = int32Reader.read(buffer); + const y = int32Reader.read(buffer); + return { + x, + y + }; + } + write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + const int32Reader = new Int32Reader(); + int32Reader.write(buffer, content.x, null); + int32Reader.write(buffer, content.y, null); + } } class ReflectiveReader extends BaseReader { @@ -566,42 +491,33 @@ class ReflectiveReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.ReflectiveReader': return true; - default: return false; } } - static hasSubType() { return true; } - constructor(reader) { super(); this.reader = reader; } - read(buffer, resolver) { const reflective = this.reader.read(buffer, resolver); return reflective; } - write(buffer, content, resolver) { this.reader.write(buffer, content, this.reader.isValueType() ? null : resolver); } - isValueType() { return false; } - get type() { return "".concat(this.reader.type); } - parseTypeList() { return [...this.reader.parseTypeList()]; } - } class RectangleReader extends BaseReader { @@ -610,12 +526,10 @@ class RectangleReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.RectangleReader': case 'Microsoft.Xna.Framework.Rectangle': return true; - default: return false; } } - read(buffer) { const int32Reader = new Int32Reader(); const x = int32Reader.read(buffer); @@ -629,7 +543,6 @@ class RectangleReader extends BaseReader { height }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const int32Reader = new Int32Reader(); @@ -638,7 +551,6 @@ class RectangleReader extends BaseReader { int32Reader.write(buffer, content.width, null); int32Reader.write(buffer, content.height, null); } - } class SingleReader extends BaseReader { @@ -647,21 +559,17 @@ class SingleReader extends BaseReader { case 'Microsoft.Xna.Framework.Content.SingleReader': case 'System.Single': return true; - default: return false; } } - read(buffer) { return buffer.readSingle(); } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); buffer.writeSingle(content); } - } const kDxt1 = 1 << 0; @@ -676,17 +584,14 @@ const kWeightColourByAlpha = 1 << 7; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } - return keys; } - function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; @@ -696,10 +601,8 @@ function _objectSpread2(target) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } - return target; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { @@ -711,7 +614,6 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } @@ -719,20 +621,16 @@ function Rot(theta) { let Mat = [[Math.cos(theta), Math.sin(theta)], [-Math.sin(theta), Math.cos(theta)]]; return Mat; } - function Rij(k, l, theta, N) { let Mat = Array(N); - for (let i = 0; i < N; i++) { Mat[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Mat[i][j] = (i === j) * 1.0; } } - let Rotij = Rot(theta); Mat[k][k] = Rotij[0][0]; Mat[l][l] = Rotij[1][1]; @@ -740,25 +638,20 @@ function Rij(k, l, theta, N) { Mat[l][k] = Rotij[1][0]; return Mat; } - function getTheta(aii, ajj, aij) { let th = 0.0; let denom = ajj - aii; - if (Math.abs(denom) <= 1E-12) { th = Math.PI / 4.0; } else { th = 0.5 * Math.atan(2.0 * aij / (ajj - aii)); } - return th; } - function getAij(Mij) { let N = Mij.length; let maxMij = 0.0; let maxIJ = [0, 1]; - for (let i = 0; i < N; i++) { for (let j = i + 1; j < N; j++) { if (Math.abs(maxMij) <= Math.abs(Mij[i][j])) { @@ -767,22 +660,17 @@ function getAij(Mij) { } } } - return [maxIJ, maxMij]; } - function unitary(U, H) { let N = U.length; let Mat = Array(N); - for (let i = 0; i < N; i++) { Mat[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Mat[i][j] = 0; - for (let k = 0; k < N; k++) { for (let l = 0; l < N; l++) { Mat[i][j] = Mat[i][j] + U[k][i] * H[k][l] * U[l][j]; @@ -790,50 +678,39 @@ function unitary(U, H) { } } } - return Mat; } - function AxB(A, B) { let N = A.length; let Mat = Array(N); - for (let i = 0; i < N; i++) { Mat[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Mat[i][j] = 0; - for (let k = 0; k < N; k++) { Mat[i][j] = Mat[i][j] + A[i][k] * B[k][j]; } } } - return Mat; } - function eigens(Hij) { let convergence = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1E-7; let N = Hij.length; let Ei = Array(N); let e0 = Math.abs(convergence / N); let Sij = Array(N); - for (let i = 0; i < N; i++) { Sij[i] = Array(N); } - for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { Sij[i][j] = (i === j) * 1.0; } } - let Vab = getAij(Hij); - while (Math.abs(Vab[1]) >= Math.abs(e0)) { let i = Vab[0][0]; let j = Vab[0][1]; @@ -843,14 +720,11 @@ function eigens(Hij) { Sij = AxB(Sij, Gij); Vab = getAij(Hij); } - for (let i = 0; i < N; i++) { Ei[i] = Hij[i][i]; } - return sorting(Ei, Sij); } - function sorting(values, vectors) { let eigsCount = values.length; vectors.length; @@ -878,7 +752,6 @@ function sorting(values, vectors) { }); return [sortedValues, sortedVectors]; } - function dominentPrincipalVector(matrix) { let [, [dominentVector]] = eigens(matrix); return dominentVector; @@ -891,57 +764,44 @@ class Vec3 { let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; this._values = [x, y, z]; } - get x() { return this._values[0]; } - get y() { return this._values[1]; } - get z() { return this._values[2]; } - set x(value) { this._values[0] = value; } - set y(value) { this._values[1] = value; } - set z(value) { this._values[2] = value; } - get length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } - get lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z; } - get normalized() { if (this.length === 0) return null; return Vec3.multScalar(this, 1 / this.length); } - get colorInt() { const floatToInt = value => { const result = parseInt(value * 255 + 0.5); return Math.max(Math.min(result, 255), 0); }; - return this._values.map(floatToInt); } - clone() { return new Vec3(this.x, this.y, this.z); } - set(x) { let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x; let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; @@ -950,99 +810,79 @@ class Vec3 { this._values[2] = z; return this; } - toVec4() { let w = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return new Vec4(this.x, this.y, this.z, w); } - addVector(v) { this._values[0] += v.x; this._values[1] += v.y; this._values[2] += v.z; return this; } - addScaledVector(v, scalar) { this._values[0] += v.x * scalar; this._values[1] += v.y * scalar; this._values[2] += v.z * scalar; return this; } - mult(scalar) { this._values[0] *= scalar; this._values[1] *= scalar; this._values[2] *= scalar; return this; } - multVector(vec) { this._values[0] *= vec.x; this._values[1] *= vec.y; this._values[2] *= vec.z; return this; } - clamp(min, max) { const clamper = v => min > v ? min : max < v ? max : v; - this._values[0] = clamper(this._values[0]); this._values[1] = clamper(this._values[1]); this._values[2] = clamper(this._values[2]); return this; } - clampGrid() { const clamper = v => 0 > v ? 0 : 1 < v ? 1 : v; - const gridClamper = (value, grid) => Math.trunc(clamper(value) * grid + 0.5) / grid; - this._values[0] = gridClamper(this._values[0], 31); this._values[1] = gridClamper(this._values[1], 63); this._values[2] = gridClamper(this._values[2], 31); return this; } - normalize() { this._values[0] /= this.length; this._values[1] /= this.length; this._values[2] /= this.length; return this; } - toString() { return "Vec3( ".concat(this._values.join(", "), " )"); } - static add(a, b) { return new Vec3(a.x + b.x, a.y + b.y, a.z + b.z); } - static sub(a, b) { return new Vec3(a.x - b.x, a.y - b.y, a.z - b.z); } - static dot(a, b) { return a.x * b.x + a.y * b.y + a.z * b.z; } - static multScalar(a, scalar) { return new Vec3(a.x * scalar, a.y * scalar, a.z * scalar); } - static multVector(a, b) { return new Vec3(a.x * b.x, a.y * b.y, a.z * b.z); } - static interpolate(a, b, p) { let a_ = Vec3.multScalar(a, 1 - p); let b_ = Vec3.multScalar(b, p); return Vec3.add(a_, b_); } - } - class Vec4 { constructor() { let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; @@ -1051,76 +891,58 @@ class Vec4 { let w = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : x; this._values = [x, y, z, w]; } - get x() { return this._values[0]; } - get y() { return this._values[1]; } - get z() { return this._values[2]; } - get w() { return this._values[3]; } - set x(value) { this._values[0] = value; } - set y(value) { this._values[1] = value; } - set z(value) { this._values[2] = value; } - set w(value) { this._values[3] = value; } - get length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); } - get lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; } - get normalized() { if (this.length === 0) return null; return Vec4.multScalar(this, 1 / this.length); } - get xyz() { return new Vec3(this.x, this.y, this.z); } - get splatX() { return new Vec4(this.x); } - get splatY() { return new Vec4(this.y); } - get splatZ() { return new Vec4(this.z); } - get splatW() { return new Vec4(this.w); } - clone() { return new Vec4(this.x, this.y, this.z, this.w); } - set(x) { let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x; let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : x; @@ -1131,11 +953,9 @@ class Vec4 { this._values[3] = w; return this; } - toVec3() { return this.xyz; } - addVector(v) { this._values[0] += v.x; this._values[1] += v.y; @@ -1143,7 +963,6 @@ class Vec4 { this._values[3] += v.w; return this; } - addScaledVector(v, scalar) { this._values[0] += v.x * scalar; this._values[1] += v.y * scalar; @@ -1151,7 +970,6 @@ class Vec4 { this._values[3] += v.w * scalar; return this; } - subVector(v) { this._values[0] -= v.x; this._values[1] -= v.y; @@ -1159,7 +977,6 @@ class Vec4 { this._values[3] -= v.w; return this; } - mult(scalar) { this._values[0] *= scalar; this._values[1] *= scalar; @@ -1167,7 +984,6 @@ class Vec4 { this._values[3] *= scalar; return this; } - multVector(vec) { this._values[0] *= vec.x; this._values[1] *= vec.y; @@ -1175,7 +991,6 @@ class Vec4 { this._values[3] *= vec.w; return this; } - reciprocal() { this._values[0] = 1 / this._values[0]; this._values[1] = 1 / this._values[1]; @@ -1183,29 +998,23 @@ class Vec4 { this._values[3] = 1 / this._values[3]; return this; } - clamp(min, max) { const clamper = v => min > v ? min : max < v ? max : v; - this._values[0] = clamper(this._values[0]); this._values[1] = clamper(this._values[1]); this._values[2] = clamper(this._values[2]); this._values[3] = clamper(this._values[3]); return this; } - clampGrid() { const clamper = v => 0 > v ? 0 : 1 < v ? 1 : v; - const gridClamper = (value, grid) => Math.trunc(clamper(value) * grid + 0.5) / grid; - this._values[0] = gridClamper(this._values[0], 31); this._values[1] = gridClamper(this._values[1], 63); this._values[2] = gridClamper(this._values[2], 31); this._values[3] = clamper(this._values[3]); return this; } - truncate() { this._values[0] = Math.trunc(this._values[0]); this._values[1] = Math.trunc(this._values[1]); @@ -1213,7 +1022,6 @@ class Vec4 { this._values[3] = Math.trunc(this._values[3]); return this; } - normalize() { this._values[0] /= this.length; this._values[1] /= this.length; @@ -1221,51 +1029,39 @@ class Vec4 { this._values[3] /= this.length; return this; } - toString() { return "Vec4( ".concat(this._values.join(", "), " )"); } - static add(a, b) { return new Vec4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); } - static sub(a, b) { return new Vec4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); } - static dot(a, b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } - static multScalar(a, scalar) { return new Vec4(a.x * scalar, a.y * scalar, a.z * scalar, a.w * scalar); } - static multVector(a, b) { return new Vec4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); } - static interpolate(a, b, p) { let a_ = Vec4.multScalar(a, 1 - p); let b_ = Vec4.multScalar(b, p); return Vec4.add(a_, b_); } - static multiplyAdd(a, b, c) { return new Vec4(a.x * b.x + c.x, a.y * b.y + c.y, a.z * b.z + c.z, a.w * b.w + c.w); } - static negativeMultiplySubtract(a, b, c) { return new Vec4(c.x - a.x * b.x, c.y - a.y * b.y, c.z - a.z * b.z, c.w - a.w * b.w); } - static compareAnyLessThan(left, right) { return left.x < right.x || left.y < right.y || left.z < right.z || left.w < right.w; } - } - function computeWeightedCovariance(values, weights) { let total = 0; let mean = values.reduce((sum, value, i) => { @@ -1290,7 +1086,6 @@ function computeWeightedCovariance(values, weights) { covariance[2][1] = covariance[1][2]; return covariance; } - function computePCA(values, weights) { const covariance = computeWeightedCovariance(values, weights); return new Vec3(...dominentPrincipalVector(covariance)); @@ -1307,45 +1102,37 @@ function floatToInt(value, limit) { if (integer > limit) return integer; return integer; } - function floatTo565(color) { const r = floatToInt(31.0 * color.x, 31); const g = floatToInt(63.0 * color.y, 63); const b = floatToInt(31.0 * color.z, 31); return r << 11 | g << 5 | b; } - function writeColourBlock(firstColor, secondColor, indices, result, blockOffset) { result[blockOffset + 0] = firstColor & 0xff; result[blockOffset + 1] = firstColor >> 8; result[blockOffset + 2] = secondColor & 0xff; result[blockOffset + 3] = secondColor >> 8; - for (let y = 0; y < 4; y++) { result[blockOffset + 4 + y] = indices[4 * y + 0] | indices[4 * y + 1] << 2 | indices[4 * y + 2] << 4 | indices[4 * y + 3] << 6; } } - function writeColourBlock3(start, end, indices, result, blockOffset) { let firstColor = floatTo565(start); let secondColor = floatTo565(end); let remapped; - if (firstColor <= secondColor) { remapped = indices.slice(); } else { [firstColor, secondColor] = [secondColor, firstColor]; remapped = indices.map(index => index === 0 ? 1 : index === 1 ? 0 : index); } - writeColourBlock(firstColor, secondColor, remapped, result, blockOffset); } - function writeColourBlock4(start, end, indices, result, blockOffset) { let firstColor = floatTo565(start); let secondColor = floatTo565(end); let remapped; - if (firstColor < secondColor) { [firstColor, secondColor] = [secondColor, firstColor]; remapped = indices.map(index => (index ^ 0x1) & 0x3); @@ -1354,7 +1141,6 @@ function writeColourBlock4(start, end, indices, result, blockOffset) { } else { remapped = indices.slice(); } - writeColourBlock(firstColor, secondColor, remapped, result, blockOffset); } @@ -1368,21 +1154,17 @@ class ColorSet { this._points = []; const isDxt1 = (this.flags & kDxt1) != 0; const weightByAlpha = (this.flags & kWeightColourByAlpha) != 0; - for (let i = 0; i < 16; i++) { const bit = 1 << i; - if ((mask & bit) == 0) { this._remap[i] = -1; continue; } - if (isDxt1 && rgba[4 * i + 3] < 128) { this._remap[i] = -1; this._transparent = true; continue; } - for (let j = 0;; j++) { if (j == i) { const r = rgba[4 * i] / 255.0; @@ -1395,10 +1177,8 @@ class ColorSet { this._count++; break; } - const oldbit = 1 << j; const match = (mask & oldbit) != 0 && rgba[4 * i] == rgba[4 * j] && rgba[4 * i + 1] == rgba[4 * j + 1] && rgba[4 * i + 2] == rgba[4 * j + 2] && (rgba[4 * j + 3] >= 128 || !isDxt1); - if (match) { const index = this._remap[j]; const w = (rgba[4 * i + 3] + 1) / 256.0; @@ -1408,61 +1188,44 @@ class ColorSet { } } } - for (let i = 0; i < this._count; ++i) this._weights[i] = Math.sqrt(this._weights[i]); } - get transparent() { return this._transparent; } - get count() { return this._count; } - get points() { return Object.freeze(this._points.slice()); } - get weights() { return Object.freeze(this._weights.slice()); } - remapIndicesSingle(singleIndex, target) { const result = this._remap.map(index => index === -1 ? 3 : singleIndex); - target.forEach((_, i) => target[i] = result[i]); } - remapIndices(indexMap, target) { const result = this._remap.map(index => index === -1 ? 3 : indexMap[index]); - target.forEach((_, i) => target[i] = result[i]); } - } - class ColorFit { constructor(colorSet) { this.colors = colorSet; this.flags = colorSet.flags; } - compress(result, offset) { const isDxt1 = (this.flags & kDxt1) != 0; - if (isDxt1) { this.compress3(result, offset); if (!this.colors.transparent) this.compress4(result, offset); } else this.compress4(result, offset); } - compress3(result, offset) {} - compress4(result, offset) {} - } - class SingleColourFit extends ColorFit { constructor(colorSet) { super(colorSet); @@ -1474,10 +1237,8 @@ class SingleColourFit extends ColorFit { this.error = Infinity; this.bestError = Infinity; } - compressBase(lookups, saveFunc) { this.computeEndPoints(lookups); - if (this.error < this.bestError) { const indices = new Uint8Array(16); this.colors.remapIndicesSingle(this.index, indices); @@ -1485,30 +1246,21 @@ class SingleColourFit extends ColorFit { this.bestError = this.error; } } - compress3(result, offset) { const lookups = [lookup_5_3, lookup_6_3, lookup_5_3]; - const saveFunc = (start, end, indices) => writeColourBlock3(start, end, indices, result, offset); - this.compressBase(lookups, saveFunc); } - compress4(result, offset) { const lookups = [lookup_5_4, lookup_6_4, lookup_5_4]; - const saveFunc = (start, end, indices) => writeColourBlock4(start, end, indices, result, offset); - this.compressBase(lookups, saveFunc); } - computeEndPoints(lookups) { this.error = Infinity; - for (let index = 0; index < 2; index++) { const sources = []; let error = 0; - for (let channel = 0; channel < 3; channel++) { const lookup = lookups[channel]; const target = this.color[channel]; @@ -1516,7 +1268,6 @@ class SingleColourFit extends ColorFit { const diff = sources[channel][2]; error += diff * diff; } - if (error < this.error) { this.start = new Vec3(sources[0][0] / 31.0, sources[1][0] / 63.0, sources[2][0] / 31.0); this.end = new Vec3(sources[0][1] / 31.0, sources[1][1] / 63.0, sources[2][1] / 31.0); @@ -1525,24 +1276,19 @@ class SingleColourFit extends ColorFit { } } } - } - class RangeFit extends ColorFit { constructor(colorSet) { super(colorSet); this.metric = new Vec3(1); - if ((this.flags & kColourMetricPerceptual) !== 0) { this.metric.set(0.2126, 0.7152, 0.0722); } - this.start = new Vec3(0); this.end = new Vec3(0); this.bestError = Infinity; this.computePoints(); } - compressBase(codes, saveFunc) { const { points: values @@ -1559,7 +1305,6 @@ class RangeFit extends ColorFit { error += minDist; return packedIndex; }); - if (error < this.bestError) { let indices = new Uint8Array(16); this.colors.remapIndices(closest, indices); @@ -1567,23 +1312,16 @@ class RangeFit extends ColorFit { this.bestError = error; } } - compress3(result, offset) { const codes = [this.start.clone(), this.end.clone(), Vec3.interpolate(this.start, this.end, 0.5)]; - const saveFunc = (start, end, indices) => writeColourBlock3(start, end, indices, result, offset); - this.compressBase(codes, saveFunc); } - compress4(result, offset) { const codes = [this.start.clone(), this.end.clone(), Vec3.interpolate(this.start, this.end, 1 / 3), Vec3.interpolate(this.start, this.end, 2 / 3)]; - const saveFunc = (start, end, indices) => writeColourBlock4(start, end, indices, result, offset); - this.compressBase(codes, saveFunc); } - computePoints() { const { count, @@ -1595,10 +1333,8 @@ class RangeFit extends ColorFit { let start, end, min, max; start = end = values[0]; min = max = Vec3.dot(start, principle); - for (let i = 1; i < count; i++) { let value = Vec3.dot(values[i], principle); - if (value < min) { start = values[i]; min = value; @@ -1607,13 +1343,10 @@ class RangeFit extends ColorFit { max = value; } } - this.start = start.clampGrid().clone(); this.end = end.clampGrid().clone(); } - } - class ClusterFit extends ColorFit { constructor(colorSet) { super(colorSet); @@ -1621,11 +1354,9 @@ class ClusterFit extends ColorFit { this.iterationCount = colorSet.flags & kColourIterativeClusterFit ? kMaxIterations : 1; this.bestError = Infinity; this.metric = new Vec4(1); - if ((this.flags & kColourMetricPerceptual) !== 0) { this.metric.set(0.2126, 0.7152, 0.0722, 0); } - const { points: values, weights @@ -1635,7 +1366,6 @@ class ClusterFit extends ColorFit { this.pointsWeights = []; this.xSum_wSum = new Vec4(0); } - constructOrdering(axis, iteration) { const currentOrder = this.makeOrder(axis); this.copyOrderToThisOrder(currentOrder, iteration); @@ -1644,7 +1374,6 @@ class ClusterFit extends ColorFit { this.copyOrderWeight(currentOrder); return true; } - compress3(result, offset) { const aabbx = _ref => { let [part0,, part1, part2] = _ref; @@ -1662,12 +1391,9 @@ class ClusterFit extends ColorFit { ab: alphabeta_sum }; }; - const saveFunc = (start, end, indices) => writeColourBlock3(start, end, indices, result, offset); - this.compressBase(aabbx, saveFunc, 2); } - compress4(result, offset) { const aabbx = _ref2 => { let [part0, part1, part2, part3] = _ref2; @@ -1687,12 +1413,9 @@ class ClusterFit extends ColorFit { ab: alphabeta_sum }; }; - const saveFunc = (start, end, indices) => writeColourBlock4(start, end, indices, result, offset); - this.compressBase(aabbx, saveFunc, 3); } - compressBase(aabbFunc, saveFunc) { let repeater = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; this.constructOrdering(this.principle, 0); @@ -1705,19 +1428,15 @@ class ClusterFit extends ColorFit { bestJ: 0 }; if (repeater === 3) best.bestK = 0; - const leastSquares = (parts, internalIndices) => { const aabbx = aabbFunc(parts); const internalBest = this.computeOptimalPoints(aabbx); - if (internalBest.error < best.error) { best = _objectSpread2(_objectSpread2({}, internalBest), internalIndices); return true; } - return false; }; - for (let iterationIndex = 0;;) { this.clusterIterate(iterationIndex, leastSquares, repeater); if (best.iteration != iterationIndex) break; @@ -1726,10 +1445,8 @@ class ClusterFit extends ColorFit { const newAxis = Vec4.sub(best.end, best.start).xyz; if (!this.constructOrdering(newAxis, iterationIndex)) break; } - if (best.error < this.bestError) this.saveBlock(best, saveFunc); } - makeOrder(axis) { const { count, @@ -1743,36 +1460,29 @@ class ClusterFit extends ColorFit { return a - b; }); } - copyOrderToThisOrder(order, iteration) { const orderOffset = iteration * 16; order.forEach((ord, i) => { this.order[orderOffset + i] = ord; }); } - checkOrderUnique(order, iteration) { const { count } = this.colors; - for (let it = 0; it < iteration; it++) { let prevOffset = it * 16; let same = true; - for (let i = 0; i < count; i++) { if (order[i] !== this.order[prevOffset + i]) { same = false; break; } } - if (same) return false; } - return true; } - copyOrderWeight(order) { const { count, @@ -1780,7 +1490,6 @@ class ClusterFit extends ColorFit { weights } = this.colors; this.xSum_wSum.set(0); - for (let i = 0; i < count; i++) { const j = order[i]; const p = unweighted[j].toVec4(1); @@ -1790,7 +1499,6 @@ class ClusterFit extends ColorFit { this.xSum_wSum.addVector(x); } } - computeOptimalPoints(vectorPoint) { const { ax, @@ -1814,7 +1522,6 @@ class ClusterFit extends ColorFit { error }; } - computeError(_ref3) { let { a, @@ -1833,7 +1540,6 @@ class ClusterFit extends ColorFit { const e5 = Vec4.multVector(e4, this.metric); return e5.x + e5.y + e5.z; } - saveBlock(best, writeFunc) { const { count @@ -1849,30 +1555,25 @@ class ClusterFit extends ColorFit { } = best; const orderOffset = iteration * 16; const unordered = new Uint8Array(16); - const mapper = m => { if (m < bestI) return 0; if (m < bestJ) return 2; if (m < bestK) return 3; return 1; }; - for (let i = 0; i < count; i++) { unordered[this.order[orderOffset + i]] = mapper(i); } - const bestIndices = new Uint8Array(16); this.colors.remapIndices(unordered, bestIndices); writeFunc(start.xyz, end.xyz, bestIndices); this.bestError = error; } - clusterIterate(index, func) { let iterCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; const { count } = this.colors; - const indexMapper = (i, j, k) => { const mapper = { bestI: i, @@ -1882,16 +1583,12 @@ class ClusterFit extends ColorFit { if (iterCount === 3) mapper.bestK = k; return mapper; }; - let part0 = new Vec4(0.0); - for (let i = 0; i < count; i++) { let part1 = new Vec4(0.0); - for (let j = i;;) { let preLastPart = j == 0 ? this.pointsWeights[0].clone() : new Vec4(0.0); const kmin = j == 0 ? 1 : j; - for (let k = kmin;;) { const restPart = Vec4.sub(this.xSum_wSum, preLastPart).subVector(part1).subVector(part0); func([part0, part1, preLastPart, restPart], indexMapper(i, j, k)); @@ -1899,17 +1596,14 @@ class ClusterFit extends ColorFit { preLastPart.addVector(this.pointsWeights[k]); k++; } - if (iterCount === 2) break; if (j === count) break; part1.addVector(this.pointsWeights[j]); j++; } - part0.addVector(this.pointsWeights[i]); } } - } function quantise(alpha) { @@ -1919,7 +1613,6 @@ function quantise(alpha) { if (result > GRID) return GRID; return result; } - function compressAlphaDxt3(rgba, mask, result, offset) { for (let i = 0; i < 8; i++) { let quant1 = quantise(rgba[8 * i + 3]); @@ -1931,13 +1624,11 @@ function compressAlphaDxt3(rgba, mask, result, offset) { result[offset + i] = quant1 | quant2 << 4; } } - function compressAlphaDxt5(rgba, mask, result, offset) { let step5 = interpolateAlpha(rgba, mask, 5); let step7 = interpolateAlpha(rgba, mask, 7); if (step5.error <= step7.error) writeAlphaBlock5(step5, result, offset);else writeAlphaBlock7(step7, result, offset); } - function interpolateAlpha(rgba, mask, steps) { let { min, @@ -1953,16 +1644,13 @@ function interpolateAlpha(rgba, mask, steps) { error }; } - function setAlphaRange(rgba, mask, steps) { let min = 255; let max = 0; - for (let i = 0; i < 16; i++) { let bit = 1 << i; if ((mask & bit) == 0) continue; let value = rgba[4 * i + 3]; - if (steps === 5) { if (value !== 0 && value < min) min = value; if (value !== 255 && value > max) max = value; @@ -1971,7 +1659,6 @@ function setAlphaRange(rgba, mask, steps) { if (value > max) max = value; } } - if (min > max) min = max; if (max - min < steps) max = Math.min(min + steps, 255); if (max - min < steps) min = Math.max(max - steps, 0); @@ -1980,61 +1667,48 @@ function setAlphaRange(rgba, mask, steps) { max }; } - function setAlphaCodeBook(min, max, steps) { let codes = [min, max, ...Array.from({ length: steps - 1 }, (_, i) => { return Math.floor(((steps - (i + 1)) * min + (i + 1) * max) / steps); })]; - if (steps === 5) { codes[6] = 0; codes[7] = 255; } - return codes; } - function fitCodes(rgba, mask, codes, indices) { let err = 0; - for (let i = 0; i < 16; ++i) { let bit = 1 << i; - if ((mask & bit) == 0) { indices[i] = 0; continue; } - let value = rgba[4 * i + 3]; let least = Infinity; let index = 0; - for (let j = 0; j < 8; ++j) { let dist = value - codes[j]; dist *= dist; - if (dist < least) { least = dist; index = j; } } - indices[i] = index; err += least; } - return err; } - function writeAlphaBlock5(_ref, result, offset) { let { min: alpha0, max: alpha1, indices } = _ref; - if (alpha0 > alpha1) { const swapped = indices.map(index => { if (index === 0) return 1; @@ -2045,14 +1719,12 @@ function writeAlphaBlock5(_ref, result, offset) { writeAlphaBlock(alpha1, alpha0, swapped, result, offset); } else writeAlphaBlock(alpha0, alpha1, indices, result, offset); } - function writeAlphaBlock7(_ref2, result, offset) { let { min: alpha0, max: alpha1, indices } = _ref2; - if (alpha0 > alpha1) { const swapped = indices.map(index => { if (index === 0) return 1; @@ -2062,22 +1734,18 @@ function writeAlphaBlock7(_ref2, result, offset) { writeAlphaBlock(alpha1, alpha0, swapped, result, offset); } else writeAlphaBlock(alpha0, alpha1, indices, result, offset); } - function writeAlphaBlock(alpha0, alpha1, indices, result, offset) { result[offset] = alpha0; result[offset + 1] = alpha1; let indicesPointer = 0; let resultPointer = offset + 2; - for (let i = 0; i < 2; i++) { let value = 0; - for (let j = 0; j < 8; ++j) { let index = indices[indicesPointer]; value |= index << 3 * j; indicesPointer++; } - for (let j = 0; j < 3; ++j) { let byte = value >> 8 * j & 0xff; result[resultPointer] = byte; @@ -2092,13 +1760,11 @@ function unpack565(color16bit) { const blue = color16bit & 0x1f; return [red << 3 | red >> 2, green << 2 | green >> 4, blue << 3 | blue >> 2, 255]; } - function interpolateColorArray(a, b, amount) { const result = a.map((aColor, i) => Math.floor(aColor * (1 - amount) + b[i] * amount)); result[3] = 255; return result; } - function unpackColorCodes(block, offset, isDxt1) { const color1 = block[offset] | block[offset + 1] << 8; const color2 = block[offset + 2] | block[offset + 3] << 8; @@ -2106,11 +1772,9 @@ function unpackColorCodes(block, offset, isDxt1) { const unpackedColor2 = unpack565(color2); return [unpackedColor1, unpackedColor2, isDxt1 && color1 <= color2 ? interpolateColorArray(unpackedColor1, unpackedColor2, 1 / 2) : interpolateColorArray(unpackedColor1, unpackedColor2, 1 / 3), isDxt1 && color1 <= color2 ? [0, 0, 0, 0] : interpolateColorArray(unpackedColor1, unpackedColor2, 2 / 3)]; } - function unpackIndices(block, blockOffset) { let offset = blockOffset + 4; let result = new Uint8Array(16); - for (let i = 0; i < 4; i++) { let packedIndices = block[offset + i]; result[i * 4 + 0] = packedIndices & 0x3; @@ -2118,21 +1782,17 @@ function unpackIndices(block, blockOffset) { result[i * 4 + 2] = packedIndices >> 4 & 0x3; result[i * 4 + 3] = packedIndices >> 6 & 0x3; } - return result; } - function decompressColor(rgba, block, offset, isDxt1) { const colorCode = unpackColorCodes(block, offset, isDxt1); const indices = unpackIndices(block, offset); - for (let i = 0; i < 16; i++) { for (let j = 0; j < 4; j++) { rgba[4 * i + j] = colorCode[indices[i]][j]; } } } - function decompressAlphaDxt3(rgba, block, offset) { for (let i = 0; i < 8; ++i) { let quant = block[offset + i]; @@ -2142,7 +1802,6 @@ function decompressAlphaDxt3(rgba, block, offset) { rgba[8 * i + 7] = hi | hi >> 4; } } - function decompressAlphaDxt5(rgba, block, offset) { let alpha0 = block[offset + 0]; let alpha1 = block[offset + 1]; @@ -2150,23 +1809,19 @@ function decompressAlphaDxt5(rgba, block, offset) { let indices = new Uint8Array(16); let indicePointer = 0; let bytePointer = 2; - for (let i = 0; i < 2; i++) { let value = 0; - for (let j = 0; j < 3; j++) { let byte = block[offset + bytePointer]; value |= byte << 8 * j; bytePointer++; } - for (let j = 0; j < 8; j++) { let index = value >> 3 * j & 0x7; indices[indicePointer] = index; indicePointer++; } } - for (let i = 0; i < 16; ++i) { rgba[4 * i + 3] = codes[indices[i]]; } @@ -2197,7 +1852,6 @@ const DXT1_COMPRESSED_BYTES = 8; const DXT5_COMPRESSED_BYTES = 16; const COLORS = 4; const DECOMPRESSED_BLOCK_SIZE = 16; - function blockRepeat(width, height, func) { for (let y = 0; y < height; y += 4) { for (let x = 0; x < width; x += 4) { @@ -2205,7 +1859,6 @@ function blockRepeat(width, height, func) { } } } - function rectRepeat(func) { for (let y = 0; y < 4; y++) { for (let x = 0; x < 4; x++) { @@ -2213,7 +1866,6 @@ function rectRepeat(func) { } } } - function FixFlags(flags) { let method = flags & (kDxt1 | kDxt3 | kDxt5); let fit = flags & (kColourIterativeClusterFit | kColourClusterFit | kColourRangeFit); @@ -2224,14 +1876,12 @@ function FixFlags(flags) { if (metric != kColourMetricUniform) metric = kColourMetricPerceptual; return method | fit | metric | extra; } - function GetStorageRequirements(width, height, flags) { flags = FixFlags(flags); const blockcount = Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4); const blocksize = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; return blockcount * blocksize; } - function extractColorBlock(img) { let { x = 0, @@ -2245,14 +1895,11 @@ function extractColorBlock(img) { rectRepeat(function (px, py) { let sx = x + px; let sy = y + py; - if (sx < width && sy < height) { let sourceColorOffset = COLORS * (width * sy + sx); - for (let i = 0; i < COLORS; i++) { block[blockColorOffset++] = img[sourceColorOffset++]; } - mask |= 1 << 4 * py + px; } else blockColorOffset += COLORS; }); @@ -2261,7 +1908,6 @@ function extractColorBlock(img) { mask }; } - function copyBuffer(result, block) { let { x = 0, @@ -2273,23 +1919,19 @@ function copyBuffer(result, block) { rectRepeat(function (px, py) { let sx = x + px; let sy = y + py; - if (sx < width && sy < height) { let resultColorOffset = COLORS * (width * sy + sx); - for (let i = 0; i < COLORS; i++) { result[resultColorOffset + i] = block[blockColorOffset++]; } } else blockColorOffset += COLORS; }); } - function getCompressor(colorSet) { if (colorSet.count === 1) return new SingleColourFit(colorSet); if ((colorSet.flags & kColourRangeFit) != 0 || colorSet.count == 0) return new RangeFit(colorSet); return new ClusterFit(colorSet); } - function CompressMasked(rgba, mask, result, offset, flags) { flags = FixFlags(flags); let colorOffset = (flags & (kDxt3 | kDxt5)) !== 0 ? 8 : 0; @@ -2298,14 +1940,12 @@ function CompressMasked(rgba, mask, result, offset, flags) { compressor.compress(result, offset + colorOffset); if ((flags & kDxt3) !== 0) compressAlphaDxt3(rgba, mask, result, offset);else if ((flags & kDxt5) !== 0) compressAlphaDxt5(rgba, mask, result, offset); } - function decompressBlock(result, block, offset, flags) { flags = FixFlags(flags); let colorOffset = (flags & (kDxt3 | kDxt5)) !== 0 ? 8 : 0; decompressColor(result, block, offset + colorOffset, (flags & kDxt1) !== 0); if ((flags & kDxt3) !== 0) decompressAlphaDxt3(result, block, offset);else if ((flags & kDxt5) !== 0) decompressAlphaDxt5(result, block, offset); } - function compressImage(source, width, height, result, flags) { flags = FixFlags(flags); const bytesPerBlock = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; @@ -2324,12 +1964,10 @@ function compressImage(source, width, height, result, flags) { targetBlockPointer += bytesPerBlock; }); } - function decompressImage(result, width, height, source, flags) { flags = FixFlags(flags); const bytesPerBlock = (flags & kDxt1) !== 0 ? DXT1_COMPRESSED_BYTES : DXT5_COMPRESSED_BYTES; let sourceBlockPointer = 0; - for (let y = 0; y < height; y += 4) { for (let x = 0; x < width; x += 4) { const targetRGBA = new Uint8Array(DECOMPRESSED_BLOCK_SIZE * COLORS); @@ -2344,7 +1982,6 @@ function decompressImage(result, width, height, source, flags) { } } } - const flags = { DXT1: kDxt1, DXT3: kDxt3, @@ -2356,7 +1993,6 @@ const flags = { ColourMetricUniform: kColourMetricUniform, WeightColourByAlpha: kWeightColourByAlpha }; - function compress(inputData, width, height, flags) { let source = inputData instanceof ArrayBuffer ? new Uint8Array(inputData) : inputData; const targetSize = GetStorageRequirements(width, height, flags); @@ -2364,7 +2000,6 @@ function compress(inputData, width, height, flags) { compressImage(source, width, height, result, flags); return result; } - function decompress(inputData, width, height, flags) { let source = inputData instanceof ArrayBuffer ? new Uint8Array(inputData) : inputData; const targetSize = width * height * 4; @@ -2376,7 +2011,6 @@ function decompress(inputData, width, height, flags) { function extractBits(bitData, amount, offset) { return bitData >> offset & 2 ** amount - 1; } - function colorToBgra5551(red, green, blue, alpha) { const r = Math.round(red / 255 * 31); const g = Math.round(green / 255 * 31); @@ -2384,24 +2018,19 @@ function colorToBgra5551(red, green, blue, alpha) { const a = Math.round(alpha / 255); return a << 15 | r << 10 | g << 5 | b; } - function bgra5551ToColor(bgra5551) { const r = extractBits(bgra5551, 5, 10); const g = extractBits(bgra5551, 5, 5); const b = extractBits(bgra5551, 5, 0); const a = bgra5551 >> 15 & 1; - const scaleUp = value => value << 3 | value >> 2; - const [red, green, blue] = [r, g, b].map(scaleUp); return [red, green, blue, a * 255]; } - function convertTo5551(colorBuffer) { const colorArray = new Uint8Array(colorBuffer); const length = colorArray.length / 4; const convertedArray = new Uint8Array(length * 2); - for (let i = 0; i < length; i++) { const red = colorArray[i * 4]; const green = colorArray[i * 4 + 1]; @@ -2411,20 +2040,16 @@ function convertTo5551(colorBuffer) { convertedArray[i * 2] = bgra5551 & 0xff; convertedArray[i * 2 + 1] = bgra5551 >> 8; } - return convertedArray; } - function convertFrom5551(colorBuffer) { const colorArray = new Uint8Array(colorBuffer); const length = colorArray.length / 2; const convertedArray = new Uint8Array(length * 4); - for (let i = 0; i < length; i++) { const colors = bgra5551ToColor(colorArray[i * 2] | colorArray[i * 2 + 1] << 8); [convertedArray[i * 4], convertedArray[i * 4 + 1], convertedArray[i * 4 + 2], convertedArray[i * 4 + 3]] = colors; } - return convertedArray; } @@ -2433,12 +2058,10 @@ class Texture2DReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.Texture2DReader': return true; - default: return false; } } - read(buffer) { const int32Reader = new Int32Reader(); const uint32Reader = new UInt32Reader(); @@ -2446,22 +2069,31 @@ class Texture2DReader extends BaseReader { let width = uint32Reader.read(buffer); let height = uint32Reader.read(buffer); let mipCount = uint32Reader.read(buffer); + let usedWidth = null; + let usedHeight = null; if (mipCount > 1) console.warn("Found mipcount of ".concat(mipCount, ", only the first will be used.")); let dataSize = uint32Reader.read(buffer); + if (width * height * 4 > dataSize) { + usedWidth = width >> 16 & 0xffff; + width = width & 0xffff; + usedHeight = height >> 16 & 0xffff; + height = height & 0xffff; + if (width * height * 4 !== dataSize) { + console.warn("invalid width & height! ".concat(width, " x ").concat(height)); + } + } let data = buffer.read(dataSize); if (format == 4) data = decompress(data, width, height, flags.DXT1);else if (format == 5) data = decompress(data, width, height, flags.DXT3);else if (format == 6) data = decompress(data, width, height, flags.DXT5);else if (format == 2) { data = convertFrom5551(data); } else if (format != 0) throw new Error("Non-implemented Texture2D format type (".concat(format, ") found.")); if (data instanceof ArrayBuffer) data = new Uint8Array(data); - for (let i = 0; i < data.length; i += 4) { let inverseAlpha = 255 / data[i + 3]; data[i] = Math.min(Math.ceil(data[i] * inverseAlpha), 255); data[i + 1] = Math.min(Math.ceil(data[i + 1] * inverseAlpha), 255); data[i + 2] = Math.min(Math.ceil(data[i + 2] * inverseAlpha), 255); } - - return { + const result = { format, export: { type: this.type, @@ -2470,36 +2102,40 @@ class Texture2DReader extends BaseReader { height } }; + if (usedWidth !== null) result.additional = { + usedWidth, + usedHeight + }; + return result; } - write(buffer, content, resolver) { const int32Reader = new Int32Reader(); const uint32Reader = new UInt32Reader(); this.writeIndex(buffer, resolver); - const width = content.export.width; - const height = content.export.height; + let width = content.export.width; + let height = content.export.height; + if (content.additional != null) { + width = width | content.additional.usedWidth << 16; + height = height | content.additional.usedHeight << 16; + } int32Reader.write(buffer, content.format, null); - uint32Reader.write(buffer, content.export.width, null); - uint32Reader.write(buffer, content.export.height, null); + uint32Reader.write(buffer, width, null); + uint32Reader.write(buffer, height, null); uint32Reader.write(buffer, 1, null); let data = content.export.data; - for (let i = 0; i < data.length; i += 4) { const alpha = data[i + 3] / 255; data[i] = Math.floor(data[i] * alpha); data[i + 1] = Math.floor(data[i + 1] * alpha); data[i + 2] = Math.floor(data[i + 2] * alpha); } - if (content.format === 4) data = compress(data, width, height, flags.DXT1);else if (content.format === 5) data = compress(data, width, height, flags.DXT3);else if (content.format === 6) data = compress(data, width, height, flags.DXT5);else if (content.format === 2) data = convertTo5551(data); uint32Reader.write(buffer, data.length, null); buffer.concat(data); } - isValueType() { return false; } - } class Vector3Reader extends BaseReader { @@ -2508,12 +2144,10 @@ class Vector3Reader extends BaseReader { case 'Microsoft.Xna.Framework.Content.Vector3Reader': case 'Microsoft.Xna.Framework.Vector3': return true; - default: return false; } } - read(buffer) { const singleReader = new SingleReader(); let x = singleReader.read(buffer); @@ -2525,7 +2159,6 @@ class Vector3Reader extends BaseReader { z }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const singleReader = new SingleReader(); @@ -2533,7 +2166,6 @@ class Vector3Reader extends BaseReader { singleReader.write(buffer, content.y, null); singleReader.write(buffer, content.z, null); } - } class SpriteFontReader extends BaseReader { @@ -2541,16 +2173,13 @@ class SpriteFontReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.SpriteFontReader': return true; - default: return false; } } - static parseTypeList() { return ["SpriteFont", "Texture2D", 'List', 'Rectangle', 'List', 'Rectangle', 'List', 'Char', null, null, 'List', 'Vector3', 'Nullable', 'Char']; } - read(buffer, resolver) { const int32Reader = new Int32Reader(); const singleReader = new SingleReader(); @@ -2574,7 +2203,6 @@ class SpriteFontReader extends BaseReader { defaultCharacter }; } - write(buffer, content, resolver) { const int32Reader = new Int32Reader(); const charReader = new CharReader(); @@ -2585,7 +2213,6 @@ class SpriteFontReader extends BaseReader { const charListReader = new ListReader(charReader); const vector3ListReader = new ListReader(new Vector3Reader()); this.writeIndex(buffer, resolver); - try { texture2DReader.write(buffer, content.texture, resolver); buffer.alloc(100000); @@ -2600,11 +2227,9 @@ class SpriteFontReader extends BaseReader { throw ex; } } - isValueType() { return false; } - } class TBinReader extends BaseReader { @@ -2612,12 +2237,10 @@ class TBinReader extends BaseReader { switch (type) { case 'xTile.Pipeline.TideReader': return true; - default: return false; } } - read(buffer) { const int32Reader = new Int32Reader(); let size = int32Reader.read(buffer); @@ -2629,7 +2252,6 @@ class TBinReader extends BaseReader { } }; } - write(buffer, content, resolver) { this.writeIndex(buffer, resolver); const data = content.export.data; @@ -2637,11 +2259,9 @@ class TBinReader extends BaseReader { int32Reader.write(buffer, data.byteLength, null); buffer.concat(data); } - isValueType() { return false; } - } class LightweightTexture2DReader extends BaseReader { @@ -2649,16 +2269,13 @@ class LightweightTexture2DReader extends BaseReader { switch (type) { case 'Microsoft.Xna.Framework.Content.Texture2DReader': return true; - default: return false; } } - static type() { return "Texture2D"; } - read(buffer) { const int32Reader = new Int32Reader(); const uint32Reader = new UInt32Reader(); @@ -2671,14 +2288,12 @@ class LightweightTexture2DReader extends BaseReader { let data = buffer.read(dataSize); data = new Uint8Array(data); if (format != 0) throw new Error("Compressed texture format is not supported!"); - for (let i = 0; i < data.length; i += 4) { let inverseAlpha = 255 / data[i + 3]; data[i] = Math.min(Math.ceil(data[i] * inverseAlpha), 255); data[i + 1] = Math.min(Math.ceil(data[i + 1] * inverseAlpha), 255); data[i + 2] = Math.min(Math.ceil(data[i + 2] * inverseAlpha), 255); } - return { format, export: { @@ -2689,7 +2304,6 @@ class LightweightTexture2DReader extends BaseReader { } }; } - write(buffer, content, resolver) { if (content.format != 0) throw new Error("Compressed texture format is not supported!"); const int32Reader = new Int32Reader(); @@ -2702,26 +2316,21 @@ class LightweightTexture2DReader extends BaseReader { uint32Reader.write(buffer, content.export.height, null); uint32Reader.write(buffer, 1, null); let data = content.export.data; - for (let i = 0; i < data.length; i += 4) { const alpha = data[i + 3] / 255; data[i] = Math.floor(data[i] * alpha); data[i + 1] = Math.floor(data[i + 1] * alpha); data[i + 2] = Math.floor(data[i + 2] * alpha); } - uint32Reader.write(buffer, data.length, null); buffer.concat(data); } - isValueType() { return false; } - get type() { return "Texture2D"; } - } class Vector2Reader extends BaseReader { @@ -2730,12 +2339,10 @@ class Vector2Reader extends BaseReader { case 'Microsoft.Xna.Framework.Content.Vector2Reader': case 'Microsoft.Xna.Framework.Vector2': return true; - default: return false; } } - read(buffer) { const singleReader = new SingleReader(); let x = singleReader.read(buffer); @@ -2745,7 +2352,12 @@ class Vector2Reader extends BaseReader { y }; } - + write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + const singleReader = new SingleReader(); + singleReader.write(buffer, content.x, null); + singleReader.write(buffer, content.y, null); + } } class Vector4Reader extends BaseReader { @@ -2754,12 +2366,10 @@ class Vector4Reader extends BaseReader { case 'Microsoft.Xna.Framework.Content.Vector4Reader': case 'Microsoft.Xna.Framework.Vector4': return true; - default: return false; } } - read(buffer) { const singleReader = new SingleReader(); let x = singleReader.read(buffer); @@ -2773,7 +2383,14 @@ class Vector4Reader extends BaseReader { w }; } - + write(buffer, content, resolver) { + this.writeIndex(buffer, resolver); + const singleReader = new SingleReader(); + singleReader.write(buffer, content.x, null); + singleReader.write(buffer, content.y, null); + singleReader.write(buffer, content.z, null); + singleReader.write(buffer, content.w, null); + } } -export { ArrayReader, BaseReader, BmFontReader, BooleanReader, CharReader, DictionaryReader, DoubleReader, EffectReader, Int32Reader, LightweightTexture2DReader, ListReader, NullableReader, RectangleReader, ReflectiveReader, SingleReader, SpriteFontReader, StringReader, TBinReader, Texture2DReader, UInt32Reader, Vector2Reader, Vector3Reader, Vector4Reader }; +export { ArrayReader, BaseReader, BmFontReader, BooleanReader, CharReader, DictionaryReader, DoubleReader, EffectReader, Int32Reader, LightweightTexture2DReader, ListReader, NullableReader, PointReader, RectangleReader, ReflectiveReader, SingleReader, SpriteFontReader, StringReader, TBinReader, Texture2DReader, UInt32Reader, Vector2Reader, Vector3Reader, Vector4Reader }; diff --git a/package.json b/package.json index cbd90ab..69cf17e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xnb", - "version": "1.3.0", + "version": "1.3.0a", "description": "Javascript XNB packing & unpacking library for es6.", "main": "./dist/xnb.js", "module": "./dist/xnb.module.js",