From 0290fb8f9c38a2db69f91879cb985a7331f98e68 Mon Sep 17 00:00:00 2001 From: UmamiAppearance Date: Fri, 26 May 2023 09:53:03 +0200 Subject: [PATCH 1/2] fixed slow decoding --- cjs/base-ex.cjs | 61 +++++---- cjs/base-ex.cjs.map | 2 +- dist/base-ex.esm.js | 61 +++++---- dist/base-ex.esm.min.js | 6 +- dist/base-ex.iife.js | 61 +++++---- dist/base-ex.iife.min.js | 6 +- dist/converters/Base1/base-1.esm.js | 33 +++-- dist/converters/Base1/base-1.esm.min.js | 4 +- dist/converters/Base1/base-1.iife.js | 33 +++-- dist/converters/Base1/base-1.iife.min.js | 4 +- dist/converters/Base16/base-16.esm.js | 33 +++-- dist/converters/Base16/base-16.esm.min.js | 4 +- dist/converters/Base16/base-16.iife.js | 33 +++-- dist/converters/Base16/base-16.iife.min.js | 4 +- dist/converters/Base2048/base-2048.esm.js | 2 +- dist/converters/Base2048/base-2048.esm.min.js | 2 +- dist/converters/Base2048/base-2048.iife.js | 2 +- .../converters/Base2048/base-2048.iife.min.js | 2 +- dist/converters/Base32/base-32.esm.js | 33 +++-- dist/converters/Base32/base-32.esm.min.js | 6 +- dist/converters/Base32/base-32.iife.js | 33 +++-- dist/converters/Base32/base-32.iife.min.js | 4 +- dist/converters/Base58/base-58.esm.js | 33 +++-- dist/converters/Base58/base-58.esm.min.js | 4 +- dist/converters/Base58/base-58.iife.js | 33 +++-- dist/converters/Base58/base-58.iife.min.js | 4 +- dist/converters/Base64/base-64.esm.js | 33 +++-- dist/converters/Base64/base-64.esm.min.js | 4 +- dist/converters/Base64/base-64.iife.js | 33 +++-- dist/converters/Base64/base-64.iife.min.js | 4 +- dist/converters/Base85/base-85.esm.js | 33 +++-- dist/converters/Base85/base-85.esm.min.js | 6 +- dist/converters/Base85/base-85.iife.js | 33 +++-- dist/converters/Base85/base-85.iife.min.js | 6 +- dist/converters/Base91/base-91.esm.js | 2 +- dist/converters/Base91/base-91.esm.min.js | 2 +- dist/converters/Base91/base-91.iife.js | 2 +- dist/converters/Base91/base-91.iife.min.js | 2 +- dist/converters/BasePhi/base-phi.esm.js | 33 +++-- dist/converters/BasePhi/base-phi.esm.min.js | 6 +- dist/converters/BasePhi/base-phi.iife.js | 33 +++-- dist/converters/BasePhi/base-phi.iife.min.js | 6 +- .../ByteConverter/byte-converter.esm.js | 2 +- .../ByteConverter/byte-converter.esm.min.js | 2 +- .../ByteConverter/byte-converter.iife.js | 2 +- .../ByteConverter/byte-converter.iife.min.js | 2 +- dist/converters/Ecoji/ecoji.esm.js | 33 +++-- dist/converters/Ecoji/ecoji.esm.min.js | 4 +- dist/converters/Ecoji/ecoji.iife.js | 33 +++-- dist/converters/Ecoji/ecoji.iife.min.js | 4 +- dist/converters/LEB128/leb-128.esm.js | 33 +++-- dist/converters/LEB128/leb-128.esm.min.js | 6 +- dist/converters/LEB128/leb-128.iife.js | 33 +++-- dist/converters/LEB128/leb-128.iife.min.js | 6 +- dist/converters/SimpleBase/simple-base.esm.js | 33 +++-- .../SimpleBase/simple-base.esm.min.js | 4 +- .../converters/SimpleBase/simple-base.iife.js | 33 +++-- .../SimpleBase/simple-base.iife.min.js | 4 +- dist/converters/UUencode/uuencode.esm.js | 33 +++-- dist/converters/UUencode/uuencode.esm.min.js | 6 +- dist/converters/UUencode/uuencode.iife.js | 33 +++-- dist/converters/UUencode/uuencode.iife.min.js | 4 +- package-lock.json | 129 ++++-------------- package.json | 2 +- src/base-ex.js | 2 +- src/converters/base-1.js | 2 +- src/converters/base-16.js | 2 +- src/converters/base-2048.js | 2 +- src/converters/base-32.js | 2 +- src/converters/base-58.js | 2 +- src/converters/base-64.js | 2 +- src/converters/base-85.js | 2 +- src/converters/base-91.js | 2 +- src/converters/base-phi.js | 2 +- src/converters/byte-converter.js | 2 +- src/converters/ecoji.js | 2 +- src/converters/leb-128.js | 2 +- src/converters/simple-base.js | 2 +- src/converters/uuencode.js | 2 +- src/core.js | 31 +++-- 80 files changed, 753 insertions(+), 490 deletions(-) diff --git a/cjs/base-ex.cjs b/cjs/base-ex.cjs index bf2b5bf..76bf95b 100644 --- a/cjs/base-ex.cjs +++ b/cjs/base-ex.cjs @@ -978,6 +978,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1151,19 +1152,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1187,17 +1194,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1225,7 +1238,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1453,7 +1466,7 @@ class BaseTemplate { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1610,7 +1623,7 @@ class Base1 extends BaseTemplate { /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-16.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1699,7 +1712,7 @@ class Base16 extends BaseTemplate { /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1805,7 +1818,7 @@ class Base32 extends BaseTemplate { /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1956,7 +1969,7 @@ class Base58 extends BaseTemplate{ /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2045,7 +2058,7 @@ class Base64 extends BaseTemplate { /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2258,7 +2271,7 @@ const ees = () => { /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2382,7 +2395,7 @@ class Base85 extends BaseTemplate { /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ @@ -2616,7 +2629,7 @@ class Base91 extends BaseTemplate { /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2782,7 +2795,7 @@ class LEB128 extends BaseTemplate { /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT OR Apache-2.0 * @see https://github.com/keith-turner/ecoji @@ -3125,7 +3138,7 @@ class Ecoji extends BaseTemplate { /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3304,7 +3317,7 @@ class Base2048 extends BaseTemplate { /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3405,7 +3418,7 @@ let DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME="[big.js] ",INVALID=NAME+"I /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3743,7 +3756,7 @@ class BasePhi extends BaseTemplate { /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3862,7 +3875,7 @@ class ByteConverter { /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/cjs/base-ex.cjs.map b/cjs/base-ex.cjs.map index 821a47a..b0637f5 100644 --- a/cjs/base-ex.cjs.map +++ b/cjs/base-ex.cjs.map @@ -1 +1 @@ -{"version":3,"file":"base-ex.cjs","sources":["../src/io-handlers.js","../src/utils.js","../src/core.js","../src/converters/base-1.js","../src/converters/base-16.js","../src/converters/base-32.js","../src/converters/base-58.js","../src/converters/base-64.js","../src/converters/uuencode.js","../src/converters/base-85.js","../src/converters/base-91.js","../src/converters/leb-128.js","../src/converters/ecoji.js","../src/converters/base-2048.js","../src/converters/simple-base.js","../lib/big.js/big.min.js","../src/converters/base-phi.js","../src/converters/byte-converter.js","../src/base-ex.js"],"sourcesContent":["/**\n * Simple Input Handler.\n * --------------------\n * Accepts only bytes eg. TypedArray, ArrayBuffer,\n * DataView, also a regular array (filled with integers)\n * is possible.\n */\nclass BytesInput {\n static toBytes(input) {\n if (ArrayBuffer.isView(input)) {\n input = input.buffer;\n } \n return [new Uint8Array(input), false, \"bytes\"];\n }\n}\n\n/**\n * Simple Output Handler.\n * ---------------------\n * Returns bytes in the form of:\n * - ArrayBuffer\n * - Uint8Array\n * - DataView \n */\nclass BytesOutput {\n\n static get typeList() {\n return [\n \"buffer\",\n \"bytes\",\n \"uint8\",\n \"view\"\n ];\n }\n\n static getType(type) {\n if (!BytesOutput.typeList.includes(type)) {\n throw new TypeError(`Unknown output type: '${type}'`);\n }\n return type;\n }\n\n static compile(Uint8ArrayOut, type) {\n type = BytesOutput.getType(type);\n let compiled;\n\n if (type === \"buffer\") {\n compiled = Uint8ArrayOut.buffer;\n } \n\n else if (type === \"view\") {\n compiled = new DataView(Uint8ArrayOut.buffer);\n }\n\n else {\n compiled = Uint8ArrayOut;\n }\n \n return compiled;\n }\n}\n\n\n/**\n * Advanced Input Handler.\n * ----------------------\n * Accepts almost every Input and converts it\n * into an Uint8Array (bytes).\n */\nclass SmartInput {\n\n static makeDataView(byteLen) {\n const buffer = new ArrayBuffer(byteLen);\n return new DataView(buffer);\n }\n\n static floatingPoints(input, littleEndian=false) {\n const view = this.makeDataView(8);\n view.setFloat64(0, input, littleEndian);\n return view;\n }\n\n static numbers(input, littleEndian=false) {\n\n let view;\n let type;\n\n // Integer\n if (Number.isInteger(input)) {\n\n type = \"int\";\n\n if (!Number.isSafeInteger(input)) {\n \n let safeInt;\n let smallerOrBigger;\n let minMax;\n\n if (input < 0) {\n safeInt = Number.MIN_SAFE_INTEGER;\n smallerOrBigger = \"smaller\";\n minMax = \"MIN\";\n } else {\n safeInt = Number.MAX_SAFE_INTEGER;\n smallerOrBigger = \"bigger\";\n minMax = \"MAX\";\n }\n\n throw new RangeError(`The provided integer is ${smallerOrBigger} than ${minMax}_SAFE_INTEGER: '${safeInt}'\\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`);\n }\n\n // Signed Integer\n if (input < 0) {\n \n // 64 bit\n if (input < -2147483648) {\n view = this.makeDataView(8);\n view.setBigInt64(0, BigInt(input), littleEndian);\n }\n \n // 32 littleEndian\n else if (input < -32768) {\n view = this.makeDataView(4);\n view.setInt32(0, input, littleEndian);\n }\n\n // 16 littleEndian\n else {\n view = this.makeDataView(2);\n view.setInt16(0, input, littleEndian);\n }\n }\n\n // Unsigned Integer\n else if (input > 0) {\n\n // 64 bit\n if (input > 4294967295) {\n view = this.makeDataView(8);\n view.setBigUint64(0, BigInt(input), littleEndian);\n }\n \n // 32 bit\n else if (input > 65535) {\n view = this.makeDataView(4);\n view.setUint32(0, input, littleEndian);\n }\n \n // 16 bit\n else {\n view = this.makeDataView(2);\n view.setInt16(0, input, littleEndian);\n }\n }\n\n // Zero\n else {\n view = new Uint16Array([0]);\n }\n }\n \n // Floating Point Number:\n else {\n type = \"float\";\n view = this.floatingPoints(input, littleEndian);\n }\n\n return [new Uint8Array(view.buffer), type];\n\n }\n\n\n static bigInts(input, littleEndian=false) {\n // Since BigInts are not limited to 64 bits, they might\n // overflow the BigInt64Array values. A little more \n // handwork is therefore needed.\n\n // as the integer size is not known yet, the bytes get a\n // makeshift home \"byteArray\", which is a regular array\n\n const byteArray = new Array();\n const append = (littleEndian) ? \"push\" : \"unshift\";\n const maxN = 18446744073709551616n;\n\n // split the input into 64 bit integers\n if (input < 0) {\n while (input < -9223372036854775808n) {\n byteArray[append](input % maxN);\n input >>= 64n;\n }\n } else { \n while (input >= maxN) {\n byteArray[append](input % maxN);\n input >>= 64n;\n }\n }\n\n // append the remaining byte\n byteArray[append](input);\n\n // determine the required size for the typed array\n // by taking the amount of 64 bit integers * 8\n // (8 bytes for each 64 bit integer)\n const byteLen = byteArray.length * 8;\n \n // create a fresh data view\n const view = this.makeDataView(byteLen);\n\n // set all 64 bit integers \n byteArray.forEach((bigInt, i) => {\n const offset = i * 8;\n view.setBigUint64(offset, bigInt, littleEndian);\n });\n\n return new Uint8Array(view.buffer);\n }\n\n\n static toBytes(input, settings) {\n\n let inputUint8;\n let negative = false;\n let type = \"bytes\";\n \n // Buffer:\n if (input instanceof ArrayBuffer) {\n inputUint8 = new Uint8Array(input.slice());\n }\n\n // TypedArray or DataView:\n else if (ArrayBuffer.isView(input)) {\n inputUint8 = new Uint8Array(input.buffer.slice());\n }\n \n // String:\n else if (typeof input === \"string\" || input instanceof String) {\n inputUint8 = new TextEncoder().encode(input);\n }\n \n // Number:\n else if (typeof input === \"number\") {\n if (isNaN(input)) {\n throw new TypeError(\"Cannot proceed. Input is NaN.\");\n } else if (input == Infinity) {\n throw new TypeError(\"Cannot proceed. Input is Infinity.\");\n }\n\n if (settings.signed && input < 0) {\n negative = true;\n input = -input;\n }\n\n if (settings.numberMode) {\n const view = this.floatingPoints(input, settings.littleEndian);\n inputUint8 = new Uint8Array(view.buffer);\n type = \"float\";\n } else {\n [inputUint8, type] = this.numbers(input, settings.littleEndian);\n }\n }\n\n // BigInt:\n else if (typeof input === \"bigint\") {\n if (settings.signed && input < 0) {\n negative = true;\n input *= -1n;\n }\n inputUint8 = this.bigInts(input, settings.littleEndian);\n type = \"int\";\n }\n\n // Array\n else if (Array.isArray(input)) {\n const collection = new Array();\n for (const elem of input) {\n collection.push(...this.toBytes(elem, settings)[0]);\n }\n inputUint8 = Uint8Array.from(collection);\n }\n\n else {\n throw new TypeError(\"The provided input type can not be processed.\");\n }\n\n return [inputUint8, negative, type];\n }\n}\n\n/** \n * Advanced Output Handler.\n * ----------------------- \n * This Output handler makes it possible to\n * convert an Uint8Array (bytes) into a desired\n * format of a big variety.\n * \n * The default output is an ArrayBuffer.\n */\nclass SmartOutput {\n\n static get typeList() {\n return [\n \"bigint64\",\n \"bigint_n\",\n \"biguint64\",\n \"buffer\",\n \"bytes\",\n \"float32\",\n \"float64\",\n \"float_n\",\n \"int8\",\n \"int16\",\n \"int32\",\n \"int_n\",\n \"str\",\n \"uint8\",\n \"uint16\",\n \"uint32\",\n \"uint_n\",\n \"view\"\n ];\n }\n\n static getType(type) {\n if (!this.typeList.includes(type)) {\n throw new TypeError(`Unknown output type: '${type}'`);\n }\n return type;\n }\n\n static makeTypedArrayBuffer(Uint8ArrayOut, bytesPerElem, littleEndian, negative) {\n \n const len = Uint8ArrayOut.byteLength;\n const delta = (bytesPerElem - (Uint8ArrayOut.byteLength % bytesPerElem)) % bytesPerElem;\n const newLen = len + delta;\n \n // if the array is negative and the len is gt 1\n // fill the whole array with 255\n const fillVal = (negative && len > 1) ? 255 : 0;\n\n let newArray = Uint8ArrayOut;\n\n if (delta) {\n newArray = new Uint8Array(newLen);\n newArray.fill(fillVal);\n \n const offset = (littleEndian) ? 0 : delta;\n newArray.set(Uint8ArrayOut, offset)\n }\n\n\n return newArray.buffer;\n }\n\n static makeTypedArray(inArray, type, littleEndian, negative) {\n let outArray;\n\n if (type === \"int16\" || type === \"uint16\") {\n\n const buffer = this.makeTypedArrayBuffer(inArray, 2, littleEndian, negative);\n outArray = (type === \"int16\") ? new Int16Array(buffer) : new Uint16Array(buffer);\n\n } else if (type === \"int32\" || type === \"uint32\" || type === \"float32\") {\n\n const buffer = this.makeTypedArrayBuffer(inArray, 4, littleEndian, negative);\n \n if (type === \"int32\") {\n outArray = new Int32Array(buffer);\n } else if (type === \"uint32\") {\n outArray = new Uint32Array(buffer);\n } else {\n outArray = new Float32Array(buffer);\n }\n\n } else if (type === \"bigint64\" || type === \"biguint64\" || type === \"float64\") {\n \n const buffer = this.makeTypedArrayBuffer(inArray, 8, littleEndian, negative);\n \n if (type === \"bigint64\") {\n outArray = new BigInt64Array(buffer);\n } else if (type === \"biguint64\") {\n outArray = new BigUint64Array(buffer);\n } else {\n outArray = new Float64Array(buffer);\n }\n }\n\n return outArray;\n }\n\n static compile(Uint8ArrayOut, type, littleEndian=false, negative=false) {\n type = this.getType(type);\n let compiled;\n\n // If the array is negative (which is only\n // true for signed encoding) get the positive\n // decimal number first and feed it with a \n // negative sign to SmartInput to construct\n // the unsigned output which is not shortened.\n\n if (negative) {\n let n;\n if (type.match(/^float/)) {\n n = -(this.compile(Uint8ArrayOut, \"float_n\", littleEndian));\n } else {\n n = -(this.compile(Uint8ArrayOut, \"uint_n\", littleEndian));\n }\n if (type === \"float_n\") {\n return n;\n }\n Uint8ArrayOut = SmartInput.toBytes(n, {littleEndian, numberMode: false, signed: false})[0];\n }\n\n if (type === \"buffer\") {\n compiled = Uint8ArrayOut.buffer;\n } \n \n else if (type === \"bytes\" || type === \"uint8\") {\n compiled = Uint8ArrayOut;\n }\n \n else if (type === \"int8\") {\n compiled = new Int8Array(Uint8ArrayOut.buffer);\n } \n \n else if (type === \"view\") {\n compiled = new DataView(Uint8ArrayOut.buffer);\n }\n \n else if (type === \"str\") {\n compiled = new TextDecoder().decode(Uint8ArrayOut);\n }\n \n else if (type === \"uint_n\" || type === \"int_n\" || type === \"bigint_n\") {\n\n // If the input consists of only one byte, expand it\n if (Uint8ArrayOut.length === 1) {\n const uint16Buffer = this.makeTypedArrayBuffer(Uint8ArrayOut, 2, littleEndian, negative);\n Uint8ArrayOut = new Uint8Array(uint16Buffer);\n }\n \n if (littleEndian) {\n Uint8ArrayOut.reverse();\n }\n\n // calculate a unsigned big integer\n let n = 0n;\n Uint8ArrayOut.forEach((b) => n = (n << 8n) + BigInt(b));\n\n // convert to signed int if requested \n if (type !== \"uint_n\") {\n n = BigInt.asIntN(Uint8ArrayOut.length*8, n);\n }\n \n // convert to regular number if possible (and no bigint was requested)\n if (type !== \"bigint_n\" && n >= Number.MIN_SAFE_INTEGER && n <= Number.MAX_SAFE_INTEGER) { \n compiled = Number(n);\n } else {\n compiled = n;\n }\n } \n \n else if (type === \"float_n\") {\n\n if (Uint8ArrayOut.length <= 4) {\n \n let array;\n if (Uint8ArrayOut.length === 4) {\n array = Uint8ArrayOut;\n } else {\n array = this.makeTypedArray(Uint8ArrayOut, \"float32\", false, negative);\n }\n\n const view = new DataView(array.buffer);\n compiled = view.getFloat32(0, littleEndian);\n \n }\n \n else if (Uint8ArrayOut.length <= 8) {\n \n let array;\n if (Uint8ArrayOut.length === 8) {\n array = Uint8ArrayOut;\n } else {\n array = this.makeTypedArray(Uint8ArrayOut, \"float64\", false, negative);\n }\n\n const view = new DataView(array.buffer);\n compiled = view.getFloat64(0, littleEndian);\n \n }\n\n else {\n throw new RangeError(\"The provided input is to complex to be converted into a floating point.\")\n }\n }\n\n else if (type === \"number\") {\n if (Uint8ArrayOut.length !== 8) {\n throw new TypeError(\"Type mismatch. Cannot convert into number.\");\n }\n\n const float64 = new Float64Array(Uint8ArrayOut.buffer);\n compiled = Number(float64);\n }\n\n else {\n compiled = this.makeTypedArray(Uint8ArrayOut, type, littleEndian, negative);\n } \n\n return compiled;\n }\n}\n\nexport { BytesInput, BytesOutput, SmartInput, SmartOutput };\n","import { BytesInput, BytesOutput, SmartInput, SmartOutput } from \"./io-handlers.js\";\n\nconst DEFAULT_INPUT_HANDLER = SmartInput;\nconst DEFAULT_OUTPUT_HANDLER = SmartOutput;\n\nclass SignError extends TypeError {\n constructor() {\n super(\"The input is signed but the converter is not set to treat input as signed.\\nYou can pass the string 'signed' to the decode function or when constructing the converter.\");\n this.name = \"SignError\";\n }\n}\n\nclass DecodingError extends TypeError {\n constructor(char, msg=null) {\n if (msg === null) {\n msg = `Character '${char}' is not part of the charset.`;\n }\n super(msg);\n this.name = \"DecodingError\";\n }\n}\n\n\n/**\n * Utilities for every BaseEx class.\n * --------------------------------\n * Requires IO Handlers\n */\nclass Utils {\n\n constructor(main) {\n\n // Store the calling class in this.root\n // for accessability.\n this.root = main;\n \n // set specific args object for converters\n this.converterArgs = {};\n\n // If charsets are uses by the parent class,\n // add extra functions for the user.\n\n this.#charsetUserToolsConstructor();\n }\n\n setIOHandlers(inputHandler=DEFAULT_INPUT_HANDLER, outputHandler=DEFAULT_OUTPUT_HANDLER) {\n this.inputHandler = inputHandler;\n this.outputHandler = outputHandler;\n }\n\n\n /**\n * Constructor for the ability to add a charset and \n * change the default version.\n */\n #charsetUserToolsConstructor() {\n\n /**\n * Save method to add a charset.\n * @param {string} name - \"Charset name.\"\n * @param {[string|set|array]} - \"Charset\"\n */\n this.root.addCharset = (name, _charset, _padChars=[], info=true) => {\n\n const normalize = (typeName, set, setLen) => {\n\n if (setLen === 0 && set.length) {\n console.warn(`This converter has no ${typeName}. The following argument was ignored:\\n'${set}'`);\n return [];\n }\n\n let inputLen = setLen;\n\n if (typeof set === \"string\") {\n set = [...set];\n }\n \n if (Array.isArray(set)) {\n \n // Store the input length of the input\n inputLen = set.length;\n \n // Convert to \"Set\" -> eliminate duplicates\n // If duplicates are found the length of the\n // Set and the length of the initial input\n // differ.\n\n set = new Set(set);\n\n } else if (!(set instanceof Set)) {\n throw new TypeError(`The ${typeName} must be one of the types:\\n'str', 'set', 'array'.\"`);\n }\n \n if (set.size === setLen) {\n return [...set];\n }\n \n if (inputLen !== setLen) {\n throw new Error(`Your ${typeName} has a length of ${inputLen}. The converter requires a length of ${setLen}.`);\n } else {\n const charAmounts = {};\n _charset = [..._charset];\n _charset.forEach(c => {\n if (c in charAmounts) {\n charAmounts[c]++;\n } else {\n charAmounts[c] = 1;\n }\n })\n \n let infoStr = \"\";\n if (setLen < 100) {\n infoStr = `${_charset.join(\"\")}\\n`;\n _charset.forEach(c => {\n if (charAmounts[c] > 1) {\n infoStr += \"^\";\n } else {\n infoStr += \" \";\n }\n });\n }\n const rChars = Object.keys(charAmounts).filter(c => charAmounts[c] > 1);\n throw new Error(`You have repetitive char(s) [ ${rChars.join(\" | \")} ] in your ${typeName}. Make sure each character is unique.\\n${infoStr}`);\n }\n }\n\n if (this.root.frozenCharsets) {\n throw new Error(\"The charsets of this converter cannot be changed.\");\n }\n\n if (typeof name !== \"string\") {\n throw new TypeError(\"The charset name must be a string.\");\n }\n\n if (info && name in this.root.charsets) {\n console.warn(`An existing charset with name ${name} will get replaced.`);\n }\n\n const charset = normalize(\"charset\", _charset, this.root.converter.radix);\n const padChars = normalize(\"padding set\", _padChars, this.root.padCharAmount);\n\n this.root.charsets[name] = charset;\n if (padChars.length) {\n this.root.padChars[name] = padChars\n }\n\n if (info) {\n console.info(`New charset '${name}' was added and is ready to use`);\n }\n }\n\n // Save method (argument gets validated) to \n // change the default version.\n this.root.setDefaultCharset = (version) => {\n if (!(version in this.root.charsets)) {\n const sets = Object.keys(this.root.charsets).join(\"\\n * \");\n const msg = `Charset ${version} was not found. Available charsets are:\\n * ${sets}`;\n throw new TypeError(msg);\n }\n this.root.version = version;\n }\n }\n\n /**\n * Argument lists for error messages.\n * @param {string[]} args \n * @returns string - Arguments joined as a string. \n */\n #makeArgList(args) {\n return args.map(s => `'${s}'`).join(\", \");\n }\n\n /**\n * Removes all padded zeros a the start of the string,\n * adds a \"-\" if value is negative.\n * @param {string} output - Former output.\n * @param {boolean} negative - Indicates a negative value if true.\n * @returns {string} - Output without zero padding and a sign if negative.\n */\n toSignedStr(output, negative) {\n\n output = output.replace(/^0+(?!$)/, \"\");\n\n if (negative) {\n output = \"-\".concat(output);\n }\n\n return output;\n }\n\n /**\n * Analyzes the input for a negative sign.\n * If a sign is found, it gets removed but\n * negative bool gets true;\n * @param {string} input - Input number as a string. \n * @returns {array} - Number without sign and negativity indication bool.\n */\n extractSign(input) {\n let negative = false;\n if (input[0] === \"-\") {\n negative = true;\n input = input.slice(1);\n }\n\n return [input, negative];\n }\n\n /**\n * All possible error messages for invalid arguments,\n * gets adjusted according to the converter settings.\n * @param {string} arg - Argument. \n * @param {string[]} versions - Charset array. \n * @param {string[]} outputTypes - Array of output types. \n * @param {boolean} initial - Indicates if the arguments where passed during construction. \n */\n #invalidArgument(arg, versions, outputTypes, initial) {\n const loopConverterArgs = () => Object.keys(this.converterArgs).map(\n key => this.converterArgs[key].map(\n keyword => `'${keyword}'`\n )\n .join(\" and \")\n )\n .join(\"\\n - \");\n \n throw new TypeError([\n `'${arg}'\\n\\nParameters:`,\n initial ? \"\\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'\" : \"\",\n this.root.isMutable.signed ? \"\\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers\" : \"\",\n this.root.isMutable.littleEndian ? \"\\n * 'be' for big , 'le' for little endian byte order for case conversion\" : \"\",\n this.root.isMutable.padding ? \"\\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding\" : \"\",\n this.root.isMutable.upper ? \"\\n * valid args for changing the encoded output case are 'upper' and 'lower'\" : \"\",\n `\\n * valid args for the output type are ${this.#makeArgList(outputTypes)}`,\n versions ? `\\n * the option(s) for version/charset are: ${this.#makeArgList(versions)}` : \"\",\n \"\\n * valid args for integrity check are: 'integrity' and 'nointegrity'\",\n this.root.hasDecimalMode ? \"\\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)\" : \"\",\n \"\\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)\",\n Object.keys(this.converterArgs).length ? `\\n * converter specific args:\\n - ${loopConverterArgs()}` : \"\",\n \"\\n\\nTraceback:\"\n ].join(\"\"));\n }\n\n\n /**\n * Test if provided arguments are in the argument list.\n * Everything gets converted to lowercase and returned.\n * @param {string[]} args - Passed arguments. \n * @param {boolean} initial - Indicates if the arguments where passed during construction. \n * @returns {Object} - Converter settings object.\n */\n validateArgs(args, initial=false) {\n \n // default settings\n const parameters = {\n decimalMode: this.root.decimalMode,\n integrity: this.root.integrity,\n littleEndian: this.root.littleEndian,\n numberMode: this.root.numberMode,\n options: this.root.options,\n outputType: this.root.outputType,\n padding: this.root.padding,\n signed: this.root.signed,\n upper: this.root.upper,\n version: this.root.version\n }\n\n // add any existing converter specific args\n for (const param in this.converterArgs) {\n parameters[param] = this.root[param];\n }\n\n // if no args are provided return the default settings immediately\n if (!args.length) {\n\n // if initial call set default IO handlers\n if (initial) {\n this.setIOHandlers();\n }\n \n return parameters;\n }\n\n // Helper function to test the presence of a \n // particular arg. If found, true is returned\n // and it gets removed from the array.\n const extractArg = (arg) => {\n if (args.includes(arg)) {\n args.splice(args.indexOf(arg), 1);\n return true;\n }\n return false;\n }\n\n // set available versions and extra arguments\n const versions = Object.keys(this.root.charsets);\n const extraArgList = {\n integrity: [\"nointegrity\", \"integrity\"],\n littleEndian: [\"be\", \"le\"],\n padding: [\"nopad\", \"pad\"],\n signed: [\"unsigned\", \"signed\"],\n upper: [\"lower\", \"upper\"],\n ...this.converterArgs\n }\n\n // if initial, look for IO specifications\n if (initial) {\n if (extractArg(\"bytes_only\")) {\n this.setIOHandlers(BytesInput, BytesOutput);\n } else {\n const inHandler = (extractArg(\"bytes_in\")) ? BytesInput : DEFAULT_INPUT_HANDLER;\n const outHandler = (extractArg(\"bytes_out\")) ? BytesOutput : DEFAULT_OUTPUT_HANDLER;\n this.setIOHandlers(inHandler, outHandler);\n }\n }\n\n // set valid output types\n const outputTypes = this.outputHandler.typeList;\n\n // test for special \"number\" keyword\n if (extractArg(\"number\")) {\n parameters.numberMode = true;\n parameters.outputType = \"float_n\";\n } \n \n // test for the special \"decimal\" keyword\n if (extractArg(\"decimal\")) {\n if (!this.root.hasDecimalMode) {\n throw TypeError(`Argument 'decimal' is only allowed for converters with a non-integer base.`);\n }\n parameters.decimalMode = true;\n parameters.outputType = \"decimal\";\n\n if (parameters.numberMode) {\n parameters.numberMode = false;\n console.warn(\"-> number-mode was disabled due to the decimal-mode\");\n }\n }\n\n // walk through the remaining arguments\n args.forEach((arg) => {\n \n // additional/optional non boolean options\n if (typeof arg === \"object\") {\n parameters.options = {...parameters.options, ...arg};\n return;\n }\n\n arg = String(arg).toLowerCase();\n\n if (versions.includes(arg)) {\n parameters.version = arg;\n } else if (outputTypes.includes(arg)) {\n parameters.outputType = arg;\n } else {\n // set invalid args to true for starters\n // if a valid arg is found later it will\n // get changed\n\n let invalidArg = true;\n\n // walk through the mutable parameter list\n\n for (const param in extraArgList) {\n \n if (extraArgList[param].includes(arg)) {\n \n invalidArg = false;\n\n // extra params always have two options\n // they are converted into booleans \n // index 0 > false\n // index 1 > true\n\n if (this.root.isMutable[param]) {\n parameters[param] = Boolean(extraArgList[param].indexOf(arg));\n } else {\n throw TypeError(`Argument '${arg}' is not allowed for this type of converter.`);\n }\n }\n }\n\n if (invalidArg) {\n this.#invalidArgument(arg, versions, outputTypes, initial);\n }\n }\n });\n\n // If padding and signed are true, padding\n // is set to false and a warning is getting\n // displayed.\n if (parameters.padding && parameters.signed) {\n parameters.padding = false;\n console.warn(\"-> padding was set to false due to the signed conversion\");\n }\n \n // overwrite the default parameters for the initial call\n if (initial) {\n for (const param in parameters) {\n this.root[param] = parameters[param];\n }\n }\n\n return parameters;\n }\n\n /**\n * A TypeError specifically for sign errors.\n */\n signError() {\n throw new SignError();\n }\n\n /**\n * Wrap output to \"cols\" characters per line.\n * @param {string} output - Output string. \n * @param {number} cols - Number of cols per line. \n * @returns {string} - Wrapped output.\n */\n wrapOutput(output, cols=0) {\n if (!cols) {\n return output;\n }\n const m = new RegExp(`.{1,${cols}}`, \"gu\");\n return output.match(m).join(\"\\n\");\n }\n\n /**\n * Ensures a string input.\n * @param {*} input - Input.\n * @param {boolean} [keepWS=false] - If set to false, whitespace is getting removed from the input if present.\n * @returns {string} - Normalized input.\n */\n normalizeInput(input, keepWS=false) {\n if (keepWS) {\n return String(input);\n }\n return String(input).replace(/\\s/g, \"\");\n }\n\n}\n\nexport {\n DEFAULT_INPUT_HANDLER,\n DEFAULT_OUTPUT_HANDLER,\n DecodingError,\n Utils\n};\n","import { DecodingError, Utils } from \"./utils.js\";\n\n\n/**\n * BaseEx Base Converter.\n * ---------------------\n * Core class for base-conversion and substitution\n * based on a given charset.\n */\nclass BaseConverter {\n\n /**\n * BaseEx BaseConverter Constructor.\n * @param {number} radix - Radix for the converter.\n * @param {number} [bsEnc] - Block Size (input bytes grouped by bs) for encoding (if zero the integer has no limitation).\n * @param {number} [bsDec] - Block Size (input bytes grouped by bs) for decoding (if zero the integer has no limitation).\n * @param {number} [decPadVal=0] - Value used for padding during decoding.\n */\n constructor(radix, bsEnc=null, bsDec=null, decPadVal=0) {\n \n this.radix = radix;\n\n if (bsEnc !== null && bsDec !== null) {\n this.bsEnc = bsEnc;\n this.bsDec = bsDec;\n } else {\n [this.bsEnc, this.bsDec] = this.constructor.guessBS(radix);\n }\n\n this.decPadVal = decPadVal;\n }\n\n /**\n * Experimental feature!\n * Calc how many bits are needed to represent\n * 256 conditions (1 byte). If the radix is \n * less than 8 bits, skip that part and use\n * the radix value directly.\n */\n static guessBS(radix) {\n\n let bsDecPre = (radix < 8) ? radix : Math.ceil(256 / radix);\n \n // If the result is a multiple of 8 it\n // is appropriate to reduce the result\n\n while (bsDecPre > 8 && !(bsDecPre % 8)) {\n bsDecPre /= 8;\n }\n\n // Search for the amount of bytes, which are necessary\n // to represent the assumed amount of bytes. If the result\n // is equal or bigger than the assumption for decoding, the\n // amount of bytes for encoding is found. \n\n let bsEnc = 0;\n while (((bsEnc * 8) * Math.log(2) / Math.log(radix)) < bsDecPre) {\n bsEnc++;\n }\n\n // The result for decoding can now get calculated accurately.\n const bsDec = Math.ceil((bsEnc * 8) * Math.log(2) / Math.log(radix));\n\n return [bsEnc, bsDec];\n }\n\n\n /**\n * BaseEx Universal Base Encoding.\n * @param {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} inputBytes - Input as Uint8Array.\n * @param {string} charset - The charset used for conversion.\n * @param {boolean} littleEndian - Byte order, little endian bool.\n * @param {function} replacer - Replacer function can replace groups of characters during encoding.\n * @returns {number[]} - Output string and padding amount. \n */\n encode(inputBytes, charset, littleEndian=false, replacer=null) {\n\n // Initialize output string and set yet unknown\n // zero padding to zero.\n let bs = this.bsEnc;\n if (bs === 0) {\n bs = inputBytes.byteLength;\n }\n\n let output = \"\";\n\n const zeroPadding = (bs) ? (bs - inputBytes.length % bs) % bs : 0;\n const zeroArray = new Array(zeroPadding).fill(0);\n let byteArray;\n \n if (littleEndian) {\n \n // as the following loop walks through the array\n // from left to right, the input bytes get reversed\n // to favor the least significant first\n\n inputBytes.reverse();\n byteArray = [...zeroArray, ...inputBytes];\n } else {\n byteArray = [...inputBytes, ...zeroArray];\n }\n \n // Iterate over the input array in groups with the length\n // of the given blocksize.\n\n // If the radix is 10, make a shortcut here by converting\n // all bytes into the decimal number \"n\" and return the\n // result as a string.\n if (this.radix === 10) {\n let n = 0n;\n \n for (let i=0; i= this.radix) {\n [q, r] = this.divmod(q, this.radix);\n bXarray.unshift(parseInt(r, 10));\n }\n\n // Append the remaining quotient to the array\n bXarray.unshift(parseInt(q, 10));\n\n // If the length of the array is less than the\n // given output bs, it gets filled up with zeros.\n // (This happens in groups of null bytes)\n \n while (bXarray.length < this.bsDec) {\n bXarray.unshift(0);\n }\n\n // Each digit is used as an index to pick a \n // corresponding char from the charset. The \n // chars get concatenated and stored in \"frame\".\n\n let frame = \"\";\n bXarray.forEach(\n charIndex => frame = frame.concat(charset[charIndex])\n );\n\n // Ascii85 is replacing four consecutive \"!\" into \"z\"\n // Also other replacements can be implemented and used\n // at this point.\n if (replacer) {\n frame = replacer(frame, zeroPadding);\n }\n\n output = output.concat(frame);\n }\n\n // The output string is returned. Also the amount \n // of padded zeros. The specific class decides how \n // to handle the padding.\n\n return [output, zeroPadding];\n }\n\n\n /**\n * BaseEx Universal Base Decoding.\n * Decodes to a string of the given radix to a byte array.\n * @param {string} inputBaseStr - Base as string (will also get converted to string but can only be used if valid after that).\n * @param {string[]} charset - The charset used for conversion.\n * @param {string[]} padSet - Padding characters for integrity check.\n * @param {boolean} integrity - If set to false invalid character will be ignored.\n * @param {boolean} littleEndian - Byte order, little endian bool.\n * @returns {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} - The decoded output as Uint8Array.\n */\n decode(inputBaseStr, charset, padSet=[], integrity=true, littleEndian=false) {\n\n // Convert each char of the input to the radix-integer\n // (this becomes the corresponding index of the char\n // from the charset). Every char, that is not found in\n // in the set is getting ignored.\n\n if (!inputBaseStr) {\n return new Uint8Array(0);\n }\n\n \n let bs = this.bsDec;\n const byteArray = new Array();\n\n [...inputBaseStr].forEach(c => {\n const index = charset.indexOf(c);\n if (index > -1) { \n byteArray.push(index);\n } else if (integrity && padSet.indexOf(c) === -1) {\n throw new DecodingError(c);\n }\n });\n \n let padChars;\n\n if (bs === 0) {\n bs = byteArray.length;\n } else {\n padChars = (bs - byteArray.length % bs) % bs;\n const fillArray = new Array(padChars).fill(this.decPadVal);\n if (littleEndian) {\n byteArray.unshift(...fillArray);\n } else {\n byteArray.push(...fillArray);\n }\n }\n\n // Initialize a new default array to store\n // the converted radix-256 integers.\n\n let b256Array = new Array();\n\n // Iterate over the input bytes in groups of \n // the blocksize.\n\n for (let i=0, l=byteArray.length; i= 256) {\n [q, r] = this.divmod(q, 256);\n subArray256.unshift(parseInt(r, 10));\n }\n\n // Append the remaining quotient to the array\n subArray256.unshift(parseInt(q, 10));\n \n // If the length of the array is less than the required\n // bs after decoding it gets filled up with zeros.\n // (Again, this happens with null bytes.)\n\n while (subArray256.length < this.bsEnc) {\n subArray256.unshift(0);\n }\n \n // The subarray gets concatenated with the\n // main array.\n b256Array = b256Array.concat(subArray256);\n }\n\n // Remove padded zeros (or in case of LE all leading zeros)\n\n if (littleEndian) {\n if (b256Array.length > 1) {\n \n // remove all zeros from the start of the array\n while (!b256Array[0]) {\n b256Array.shift(); \n }\n \n if (!b256Array.length) {\n b256Array.push(0);\n }\n\n b256Array.reverse();\n }\n } else if (this.bsDec) {\n const padding = this.padChars(padChars);\n\n // remove all bytes according to the padding\n b256Array.splice(b256Array.length-padding);\n }\n\n return Uint8Array.from(b256Array);\n }\n\n\n /**\n * Calculates the amount of bytes, which are padding bytes. \n * @param {number} charCount - Pass the amount of characters, which were added during encoding. \n * @returns {number} - Amount of padding characters.\n */\n padBytes(charCount) {\n return Math.floor((charCount * this.bsDec) / this.bsEnc);\n }\n\n /**\n * Calculates the amount of bytes which can get removed\n * from the decoded output bytes. \n * @param {number} byteCount - Added bytes for padding \n * @returns {number} - Amount of output bytes to be removed.\n */\n padChars(byteCount) {\n return Math.ceil((byteCount * this.bsEnc) / this.bsDec);\n }\n\n\n /**\n * Calculates the power for the current base\n * according to the given position as BigInt.\n * \n * @param {number} n - Position \n * @returns {BigInt} - BigInt power value\n */\n pow(n) {\n return BigInt(this.radix)**BigInt(n);\n }\n\n\n /**\n * Divmod function, which returns the results as\n * an array of two BigInts.\n * @param {*} x - Dividend\n * @param {*} y - Divisor\n * @returns {number[]} - [Quotient, Remainder]\n */\n divmod(x, y) {\n [x, y] = [BigInt(x), BigInt(y)];\n return [(x / y), (x % y)];\n }\n}\n\n\n/**\n * Base of every BaseConverter. Provides basic\n * en- and decoding, makes sure, that every \n * property is set (to false by default).\n * Also allows global feature additions.\n * \n * Requires BaseEx Utils\n */\nclass BaseTemplate {\n\n /**\n * BaseEx BaseTemplate Constructor.\n * @param {boolean} appendUtils - If set to false, the utils are not getting used. \n */\n constructor(appendUtils=true) {\n\n // predefined settings\n this.charsets = {};\n this.decimalMode = false;\n this.frozenCharsets = false;\n this.hasDecimalMode = false;\n this.hasSignedMode = false;\n this.integrity = true;\n this.littleEndian = false;\n this.numberMode = false;\n this.outputType = \"buffer\";\n this.padding = false;\n this.padCharAmount = 0;\n this.padChars = {} \n this.signed = false;\n this.upper = null;\n if (appendUtils) this.utils = new Utils(this);\n this.version = \"default\";\n this.options = {\n lineWrap: 0\n }\n \n // list of allowed/disallowed args to change\n this.isMutable = {\n integrity: true,\n littleEndian: false,\n padding: false,\n signed: false,\n upper: false,\n };\n }\n\n /**\n * BaseEx Generic Encoder.\n * @param {*} input - Any input the used byte converter allows.\n * @param {function} [replacerFN] - Replacer function, which is passed to the encoder. \n * @param {function} [postEncodeFN] - Function, which is executed after encoding.\n * @param {...any} args - Converter settings.\n * @returns {string} - Base encoded string.\n */\n encode(input, replacerFN, postEncodeFN, ...args) {\n\n // apply settings\n const settings = this.utils.validateArgs(args);\n \n // handle input\n let [inputBytes, negative, type] = this.utils.inputHandler.toBytes(input, settings);\n\n // generate replacer function if given\n let replacer = null;\n if (replacerFN) {\n replacer = replacerFN(settings);\n }\n \n // Convert to base string\n let [output, zeroPadding] = this.converter.encode(inputBytes, this.charsets[settings.version], settings.littleEndian, replacer);\n\n // set sign if requested\n if (settings.signed) {\n output = this.utils.toSignedStr(output, negative);\n }\n\n // set upper case if requested\n if (settings.upper) {\n output = output.toUpperCase();\n }\n\n // modify the output based on a given function (optionally)\n if (postEncodeFN) {\n output = postEncodeFN({ inputBytes, output, settings, zeroPadding, type });\n }\n\n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n\n /**\n * BaseEx Generic Decoder.\n * @param {string} input - Base String.\n * @param {function} [preDecodeFN] - Function, which gets executed before decoding. \n * @param {function} [postDecodeFN] - Function, which gets executed after decoding\n * @param {...any} args - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, preDecodeFN, postDecodeFN, keepNL, ...args) {\n \n // apply settings\n const settings = this.utils.validateArgs(args);\n\n // ensure a string input\n input = this.utils.normalizeInput(input, keepNL);\n\n // set negative to false for starters\n let negative = false;\n \n // Test for a negative sign if converter supports it\n if (this.hasSignedMode) {\n [ input, negative ] = this.utils.extractSign(input); \n \n // But don't allow a sign if the decoder is not configured to use it\n if (negative && !settings.signed) {\n this.utils.signError();\n }\n }\n\n // Make the input lower case if alphabet has only one case\n // (single case alphabets are stored as lower case strings)\n if (this.isMutable.upper) {\n input = input.toLowerCase();\n }\n\n // Run pre decode function if provided\n if (preDecodeFN) {\n input = preDecodeFN({ input, settings });\n }\n\n // Run the decoder\n let output = this.converter.decode(\n input,\n this.charsets[settings.version],\n this.padChars[settings.version],\n settings.integrity,\n settings.littleEndian\n );\n\n // Run post decode function if provided\n if (postDecodeFN) {\n output = postDecodeFN({ input, output, settings });\n }\n\n return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative);\n }\n}\n\n\nexport { BaseConverter, BaseTemplate };\n","/**\n * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 1 Converter.\n * -----------------------\n * This is a unary/base1 converter. It is converting input \n * to a decimal number, which is converted into an unary\n * string. Due to the limitations on string (or array) length\n * it is only suitable for the conversions of numbers up to\n * roughly 2^28.\n */\nexport default class Base1 extends BaseTemplate {\n \n /**\n * BaseEx Base1 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // All chars in the string are used and picked randomly (prob. suitable for obfuscation)\n this.charsets.all = [...\" !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\"];\n \n // The sequence is used from left to right again and again\n this.charsets.sequence = [...\"Hello World!\"];\n \n // Standard unary string with one character\n this.charsets.default = [\"1\"];\n\n // Telly Mark string, using hash for 5 and vertical bar for 1 \n this.charsets.tmark = [\"|\", \"#\"];\n\n // Base 10 converter\n this.converter = new BaseConverter(10, 0, 0);\n \n // converter settings\n this.hasSignedMode = true;\n this.littleEndian = true;\n this.signed = true;\n \n // mutable extra args\n this.isMutable.charsets = false;\n this.isMutable.signed = true;\n this.isMutable.upper = true;\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx Base1 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base1 encoded string.\n */\n encode(input, ...args) {\n\n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n \n let inputBytes, negative;\n [inputBytes, negative,] = this.utils.inputHandler.toBytes(input, settings);\n\n // Convert to BaseRadix string\n let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0];\n \n let n = BigInt(base10);\n\n // Limit the input before it even starts.\n // The executing engine will most likely\n // give up much earlier.\n // (2**29-24 during tests)\n\n if (n > Number.MAX_SAFE_INTEGER) {\n throw new RangeError(\"Invalid string length.\");\n } else if (n > 16777216) {\n console.warn(\"The string length is really long. The JavaScript engine may have memory issues generating the output string.\");\n }\n \n n = Number(n);\n \n const charset = this.charsets[settings.version];\n const charAmount = charset.length;\n let output = \"\";\n\n // Convert to unary in respect to the version differences\n if (charAmount === 1) {\n output = charset.at(0).repeat(n)\n } else if (settings.version === \"all\") {\n for (let i=0; i 4) {\n output = charset.at(1).repeat((n - singulars) / 5);\n }\n output += charset.at(0).repeat(singulars);\n } else {\n for (let i=0; i {\n \n // Remove \"0x\" if present\n normInput = normInput.replace(/^0x/, \"\");\n\n // remove non-charset characters if integrity\n // check is disabled\n if (!settings.integrity) {\n normInput = normInput\n .toLowerCase()\n .replace(/[^0-9a-f]/g, \"\");\n }\n\n // Ensure even number of characters\n if (normInput.length % 2) {\n normInput = \"0\".concat(normInput);\n }\n\n return normInput;\n }\n \n return super.decode(input, normalizeInput, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 32 Converter.\n * ------------------------\n * \n * This is a base32 converter. Various input can be \n * converted to a base32 string or a base32 string\n * can be decoded into various formats. It is possible\n * to convert in both signed and unsigned mode in little\n * and big endian byte order.\n * \n * Available charsets are:\n * - RFC 3548\n * - RFC 4648\n * - crockford\n * - zbase32\n */\nexport default class Base32 extends BaseTemplate {\n \n /**\n * BaseEx Base32 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(32, 5, 8);\n\n // charsets\n this.charsets.crockford = [ ...\"0123456789abcdefghjkmnpqrstvwxyz\" ];\n this.padChars.crockford = [\"=\"],\n\n this.charsets.rfc3548 = [...\"abcdefghijklmnopqrstuvwxyz234567\"];\n this.padChars.rfc3548 = [\"=\"];\n\n this.charsets.rfc4648 = [...\"0123456789abcdefghijklmnopqrstuv\"];\n this.padChars.rfc4648 = [\"=\"];\n\n this.charsets.zbase32 = [...\"ybndrfg8ejkmcpqxot1uwisza345h769\"];\n this.padChars.zbase32 = [\"=\"];\n \n // predefined settings\n this.padCharAmount = 1;\n this.hasSignedMode = true;\n this.version = \"rfc4648\";\n \n // mutable extra args\n this.isMutable.littleEndian = true;\n this.isMutable.padding = true;\n this.isMutable.signed = true;\n this.isMutable.upper = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n this.padding = (/rfc3548|rfc4648/).test(this.version);\n this.upper = this.version === \"crockford\";\n }\n \n\n /**\n * BaseEx Base32 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base32 encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n if (!settings.littleEndian) {\n // Cut of redundant chars and append padding if set\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n const padChar = this.padChars[settings.version].at(0);\n output = output.slice(0, -padValue);\n if (settings.padding) { \n output = output.concat(padChar.repeat(padValue));\n }\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base32 Decoder.\n * @param {string} input - Base32 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n return super.decode(input, null, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 58 Converter.\n * ------------------------\n * \n * This is a base58 converter. Various input can be \n * converted to a base58 string or a base58 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - bitcoin\n * - flickr\n */\nexport default class Base58 extends BaseTemplate{\n\n /**\n * BaseEx Base58 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(58, 0, 0);\n\n // charsets\n this.charsets.default = [...\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"];\n Object.defineProperty(this.padChars, \"default\", {\n get: () => [ this.charsets.default.at(0) ]\n });\n\n this.charsets.bitcoin = [...\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\"];\n Object.defineProperty(this.padChars, \"bitcoin\", {\n get: () => [ this.charsets.bitcoin.at(0) ]\n });\n \n this.charsets.flickr = [...\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"];\n Object.defineProperty(this.padChars, \"flickr\", {\n get: () => [ this.charsets.flickr.at(0) ]\n });\n \n\n // predefined settings\n this.padding = true;\n this.version = \"bitcoin\";\n \n // mutable extra args\n this.isMutable.padding = true;\n this.isMutable.signed = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n \n /**\n * BaseEx Base58 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base58 encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ inputBytes, output, settings, type }) => {\n\n if (settings.padding && type !== \"int\") { \n \n // Count all null bytes at the start of the array\n // stop if a byte with a value is reached. If it goes\n // all the way through it, reset index and stop.\n let i = 0;\n const end = inputBytes.length;\n\n // pad char is always! the first char in the set\n const padChar = this.charsets[settings.version].at(0);\n\n // only proceed if input has a length at all\n if (end) {\n while (!inputBytes[i]) {\n i++;\n if (i === end) {\n i = 0;\n break;\n }\n }\n\n // The value for zero padding is the index of the\n // first byte with a value plus one.\n const zeroPadding = i;\n\n // Set a one for every leading null byte\n if (zeroPadding) {\n output = (padChar.repeat(zeroPadding)).concat(output);\n }\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base58 Decoder.\n * @param {string} input - Base58 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // post decoding function\n const applyPadding = ({ input, output, settings }) => {\n\n // pad char is always! the first char in the set\n const padChar = this.charsets[settings.version].at(0);\n\n if (settings.padding && input.length > 1) {\n \n // Count leading padding (char should be 1)\n let i = 0;\n while (input[i] === padChar) {\n i++;\n }\n \n // The counter becomes the zero padding value\n const zeroPadding = i;\n \n // Create a new Uint8Array with leading null bytes \n // with the amount of zeroPadding\n if (zeroPadding) {\n output = Uint8Array.from([...new Array(zeroPadding).fill(0), ...output]);\n }\n \n }\n\n return output;\n }\n\n return super.decode(input, null, applyPadding, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 64 Converter.\n * ------------------------\n * \n * This is a base64 converter. Various input can be \n * converted to a base64 string or a base64 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - urlsafe\n */\nexport default class Base64 extends BaseTemplate {\n\n /**this.padChars.\n * BaseEx Base64 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(64, 3, 4);\n\n // charsets\n this.charsets.default = [...\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"];\n this.padChars.default = [\"=\"];\n \n this.charsets.urlsafe = this.charsets.default.slice(0, -2).concat([\"-\", \"_\"]);\n this.padChars.urlsafe = [\"=\"];\n\n\n // predefined settings\n this.padCharAmount = 1;\n this.padding = true;\n \n // mutable extra args\n this.isMutable.padding = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Base64 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base64 encoded string.\n */\n encode(input, ...args) {\n \n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n // Cut of redundant chars and append padding if set\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n const padChar = this.padChars[settings.version].at(0);\n output = output.slice(0, -padValue);\n if (settings.padding) { \n output = output.concat(padChar.repeat(padValue));\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base64 Decoder.\n * @param {string} input - Base64 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n return super.decode(input, null, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx UUencode Converter.\n * ------------------------\n * \n * This is a UUencoder/UUdecoder. Various input can be \n * converted to a UUencoded string or a UUencoded string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - original\n * - xx\n */\nexport default class UUencode extends BaseTemplate {\n\n /**\n * BaseEx UUencode Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(64, 3, 4);\n\n // charsets\n this.charsets.default = [...\"`!\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_\"];\n Object.defineProperty(this.padChars, \"default\", {\n get: () => [ this.charsets.default.at(0) ]\n });\n\n this.charsets.original = [\" \", ...this.charsets.default.slice(1)];\n Object.defineProperty(this.padChars, \"original\", {\n get: () => [ this.charsets.original.at(0) ]\n });\n\n this.charsets.xx = [...\"+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"];\n Object.defineProperty(this.padChars, \"xx\", {\n get: () => [ this.charsets.xx.at(0) ]\n });\n\n\n // predefined settings\n this.padding = true;\n this.header = false;\n this.utils.converterArgs.header = [\"noheader\", \"header\"];\n this.isMutable.header = true;\n this.isMutable.integrity = false;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx UUencoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - UUencode string.\n */\n encode(input, ...args) {\n\n const format = ({ output, settings, zeroPadding }) => {\n\n const charset = this.charsets[settings.version];\n const outArray = [...output];\n \n \n if (settings.header) {\n const permissions = settings.options.permissions || een();\n const fileName = settings.options.file || ees();\n output = `begin ${permissions} ${fileName}\\n`;\n } else {\n output = \"\";\n }\n\n // repeatedly take 60 chars from the output until it is empty \n for (;;) {\n const lArray = outArray.splice(0, 60);\n \n // if all chars are taken, remove eventually added pad zeros\n if (!outArray.length) { \n const byteCount = this.converter.padChars(lArray.length) - zeroPadding;\n \n // add the the current chars plus the leading\n // count char\n output += `${charset.at(byteCount)}${lArray.join(\"\")}\\n`;\n break;\n }\n \n // add the the current chars plus the leading\n // count char (\"M\" for default charsets) \n output += `${charset.at(45)}${lArray.join(\"\")}\\n`;\n }\n\n output += `${charset.at(0)}\\n`;\n\n if (settings.header) {\n output += \"\\nend\";\n }\n\n\n return output;\n }\n \n return super.encode(input, null, format, ...args);\n }\n\n\n /**\n * BaseEx UUdecoder.\n * @param {string} input - UUencode String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n let padChars = 0;\n\n const format = ({ input, settings }) => {\n\n const charset = this.charsets[settings.version];\n const lines = input.trim().split(/\\r?\\n/);\n const inArray = [];\n \n if ((/^begin/i).test(lines.at(0))) {\n lines.shift();\n }\n \n for (const line of lines) {\n const lArray = [...line];\n const byteCount = charset.indexOf(lArray.shift());\n \n if (!(byteCount > 0)) {\n break;\n }\n\n inArray.push(...lArray);\n\n if (byteCount !== 45) { \n padChars = this.converter.padChars(lArray.length) - byteCount;\n break;\n }\n\n // fix probably missing spaces for original charset\n else if (lArray.length !== 60 && settings.version === \"original\") {\n while (inArray.length % 60) {\n inArray.push(\" \");\n }\n }\n }\n\n return inArray.join(\"\");\n\n }\n\n const removePadChars = ({ output }) => {\n if (padChars) {\n output = new Uint8Array(output.slice(0, -padChars));\n }\n return output;\n }\n\n return super.decode(input, format, removePadChars, true, ...args);\n }\n}\n\n\nconst een = () => {\n const o = () => Math.floor(Math.random() * 8);\n return `${o()}${o()}${o()}`;\n}\n\nconst ees = () => {\n const name = [\n \"unchronological\",\n \"unconditionally\",\n \"underemphasized\",\n \"underprivileged\",\n \"undistinguished\",\n \"unsophisticated\",\n \"untitled\",\n \"untitled-1\",\n \"untitled-3\",\n \"uuencode\"\n ];\n\n const ext = [\n \"applescript\",\n \"bat\",\n \"beam\",\n \"bin\",\n \"exe\",\n \"js\",\n \"mam\",\n \"py\",\n \"sh\",\n \"vdo\",\n \"wiz\"\n ];\n\n const pick = (arr) => arr.at(Math.floor(Math.random() * arr.length));\n\n return `${pick(name)}.${pick(ext)}`;\n};\n","/**\n * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 85 Converter.\n * ------------------------\n * \n * This is a base85 converter. Various input can be \n * converted to a base85 string or a base85 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - adobe\n * - ascii85\n * - rfc1924\n * - z85\n * \n * Adobe and ascii85 are the basically the same.\n * Adobe will produce the same output, apart from\n * the <~wrapping~>.\n * \n * Z85 is an important variant, because of the \n * more interpreter-friendly character set.\n * \n * The RFC 1924 version is a hybrid. It is not using\n * the mandatory 128 bit calculation. Instead only \n * the charset is getting used.\n */\nexport default class Base85 extends BaseTemplate {\n\n /**\n * BaseEx Base85 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(85, 4, 5, 84);\n\n // charsets\n this.charsets.adobe = [...\"!\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstu\"];\n this.charsets.ascii85 = this.charsets.adobe.slice();\n this.charsets.rfc1924 = [...\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~\"];\n this.charsets.z85 = [...\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#\"];\n\n // predefined settings\n this.version = \"ascii85\";\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx Base85 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base85 encoded string.\n */\n encode(input, ...args) {\n\n // Replace five consecutive \"!\" with a \"z\"\n // for adobe and ascii85\n const replacerFN = (settings) => {\n let replacer;\n if (settings.version.match(/adobe|ascii85/)) {\n replacer = (frame, zPad) => (!zPad && frame === \"!!!!!\") ? \"z\" : frame;\n }\n return replacer;\n }\n \n // Remove padded values and add a frame for the\n // adobe variant\n const framesAndPadding = ({ output, settings, zeroPadding }) => {\n\n // Cut of redundant chars\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n output = output.slice(0, -padValue);\n }\n\n // Adobes variant gets its <~framing~>\n if (settings.version === \"adobe\") {\n output = `<~${output}~>`;\n }\n \n return output;\n }\n\n return super.encode(input, replacerFN, framesAndPadding, ...args);\n }\n\n\n /**\n * BaseEx Base85 Decoder.\n * @param {string} input - Base85 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n const prepareInput = ({ input, settings }) => {\n\n // For default ascii85 convert \"z\" back to \"!!!!!\"\n // Remove the adobe <~frame~>\n if (settings.version.match(/adobe|ascii85/)) {\n input = input.replace(/z/g, \"!!!!!\");\n if (settings.version === \"adobe\") {\n input = input.replace(/^<~|~>$/g, \"\");\n }\n }\n\n return input\n }\n\n return super.decode(input, prepareInput, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke)\n */\n\nimport { BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base 91 Converter.\n * ------------------------\n * \n * This is a base91 converter. Various input can be \n * converted to a base91 string or a base91 string\n * can be decoded into various formats.\n * \n * It is an implementation of Joachim Henkes method\n * to encode binary data as ASCII characters -> basE91\n * http://base91.sourceforge.net/\n * \n * As this method requires to split the bytes, the\n * default conversion class \"BaseConverter\" is not\n * getting used in this case.\n */\nexport default class Base91 extends BaseTemplate {\n \n /**\n * BaseEx basE91 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 91,\n bsEnc: 0,\n bsDec: 0\n }\n\n // charsets\n this.charsets.default = [...\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~\\\"\"];\n this.version = \"default\";\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx basE91 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - basE91 encoded string.\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n const inputBytes = this.utils.inputHandler.toBytes(input, settings)[0];\n \n // As this base representation splits the bytes\n // the read bits need to be stores somewhere. \n // This is done in \"bitCount\". \"n\", similar to \n // other solutions here, holds the integer which\n // is converted to the desired base.\n\n let bitCount = 0;\n let n = 0;\n let output = \"\";\n\n const charset = this.charsets[settings.version];\n\n inputBytes.forEach(byte => {\n //n = n + byte * 2^bitcount;\n n += (byte << bitCount);\n\n // Add 8 bits forEach byte\n bitCount += 8;\n \n // If the count exceeds 13 bits, base convert the\n // current frame.\n\n if (bitCount > 13) {\n\n // Set bit amount \"count\" to 13, check the\n // remainder of n % 2^13. If it is 88 or \n // lower. Take one more bit from the stream\n // and calculate the remainder for n % 2^14.\n\n let count = 13;\n let rN = n % 8192;\n\n if (rN < 89) {\n count = 14;\n rN = n % 16384;\n }\n\n // Remove 13 or 14 bits from the integer,\n // decrease the bitCount by the same amount.\n n >>= count;\n bitCount -= count;\n \n // Calculate quotient and remainder from\n // the before calculated remainder of n \n // -> \"rN\"\n let q, r;\n [q, r] = this.#divmod(rN, 91);\n\n // Lookup the corresponding characters for\n // \"r\" and \"q\" in the set, append it to the \n // output string.\n output = `${output}${charset[r]}${charset[q]}`;\n }\n });\n \n // If the bitCount is not zero at the end,\n // calculate quotient and remainder of 91\n // once more.\n if (bitCount) {\n let q, r;\n [q, r] = this.#divmod(n, 91);\n\n // The remainder is concatenated in any case\n output = output.concat(charset[r]);\n\n // The quotient is also appended, but only\n // if the bitCount still has the size of a byte\n // or n can still represent 91 conditions.\n if (bitCount > 7 || n > 90) {\n output = output.concat(charset[q]);\n }\n }\n \n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n\n /**\n * BaseEx basE91 Decoder.\n * @param {string} input - basE91 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n\n // Make it a string, whatever goes in\n input = this.utils.normalizeInput(input);\n let inArray = [...input];\n\n // remove unwanted characters if integrity is false \n if (!settings.integrity) {\n inArray = inArray.filter(c => charset.includes(c));\n }\n\n\n let l = inArray.length;\n\n // For starters leave the last char behind\n // if the length of the input string is odd.\n\n let odd = false;\n if (l % 2) {\n odd = true;\n l--;\n }\n\n // Set again integer n for base conversion.\n // Also initialize a bitCount(er)\n\n let n = 0;\n let bitCount = 0;\n \n // Initialize an ordinary array\n const b256Array = new Array();\n \n // Walk through the string in steps of two\n // (aka collect remainder- and quotient-pairs)\n for (let i=0; i 88) ? 13 : 14;\n\n // calculate back the individual bytes (base256)\n do {\n b256Array.push(n % 256);\n n >>= 8;\n bitCount -= 8;\n } while (bitCount > 7);\n }\n\n // Calculate the last byte if the input is odd\n // and add it\n if (odd) {\n const lastChar = inArray.at(l);\n const rN = charset.indexOf(lastChar);\n b256Array.push(((rN << bitCount) + n) % 256);\n }\n\n const output = Uint8Array.from(b256Array);\n\n // Return the output\n return this.utils.outputHandler.compile(output, settings.outputType);\n }\n\n\n /**\n * Divmod Function.\n * @param {*} x - number 1\n * @param {*} y - number 2\n * @returns {number} Modulo y of x\n */\n #divmod (x, y) {\n return [Math.floor(x/y), x%y];\n }\n}\n","/**\n * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport { BytesInput } from \"../io-handlers.js\";\n\n/**\n * BaseEx Little Endian Base 128 Converter.\n * ---------------------------------------\n * \n * This is a leb128 converter. Various input can be \n * converted to a leb128 string or a leb128 string\n * can be decoded into various formats.\n * \n * There is no real charset available as the input is\n * getting converted to bytes. For having the chance \n * to store these bytes, there is a hexadecimal output\n * available.\n */\nexport default class LEB128 extends BaseTemplate {\n \n /**\n * BaseEx LEB128 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n // initialize base template without utils\n super();\n\n // converters\n this.converter = new BaseConverter(10, 0, 0);\n this.hexlify = new BaseConverter(16, 1, 2);\n\n // charsets\n this.charsets.default = \"\";\n this.charsets.hex = \"\"\n\n // predefined settings\n this.version = \"default\";\n this.frozenCharsets = true;\n\n // predefined settings\n this.littleEndian = true;\n this.hasSignedMode = true;\n this.isMutable.signed = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx LEB128 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {{ buffer: ArrayBufferLike; }} - LEB128 encoded Unit8Array (or hex string of it).\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n \n const signed = settings.signed;\n settings.signed = true;\n const [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings);\n\n // Convert to BaseRadix string\n let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0];\n\n let n = BigInt(base10);\n let output = new Array();\n \n if (negative) {\n if (!signed) {\n throw new TypeError(\"Negative values in unsigned mode are invalid.\");\n }\n n = -n;\n }\n \n if (signed) {\n\n for (;;) {\n const byte = Number(n & 127n);\n n >>= 7n;\n if ((n == 0 && (byte & 64) == 0) || (n == -1 && (byte & 64) != 0)) {\n output.push(byte);\n break;\n }\n output.push(byte | 128);\n }\n }\n\n else {\n for (;;) {\n const byte = Number(n & 127n);\n n >>= 7n;\n if (n == 0) {\n output.push(byte)\n break;\n }\n output.push(byte | 128);\n }\n }\n\n const Uint8Output = Uint8Array.from(output);\n\n if (settings.version === \"hex\") {\n return this.hexlify.encode(Uint8Output, [...\"0123456789abcdef\"], false)[0];\n }\n\n return Uint8Output;\n }\n\n\n /**\n * BaseEx LEB128 Decoder.\n * @param {{ buffer: ArrayBufferLike; }|string} input - LEB128-Bytes or String of Hex-Version.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n\n if (settings.version === \"hex\") {\n input = this.hexlify.decode(this.utils.normalizeInput(input).toLowerCase(), [...\"0123456789abcdef\"], [], settings.integrity, false);\n } else if (typeof input.byteLength !== \"undefined\") {\n input = BytesInput.toBytes(input)[0];\n } else {\n throw new TypeError(\"Input must be a bytes like object.\");\n }\n\n if (input.length === 1 && !input[0]) {\n return this.utils.outputHandler.compile(new Uint8Array(1), settings.outputType, true);\n }\n\n input = Array.from(input);\n\n let n = 0n;\n let shiftVal = -7n;\n let byte;\n\n for (byte of input) {\n shiftVal += 7n;\n n += (BigInt(byte & 127) << shiftVal);\n }\n \n if (settings.signed && ((byte & 64) !== 0)) {\n n |= -(1n << shiftVal + 7n);\n }\n\n // Test for a negative sign\n let decimalNum, negative;\n [decimalNum, negative] = this.utils.extractSign(n.toString());\n\n const output = this.converter.decode(decimalNum, [...\"0123456789\"], [], settings.integrity, true);\n\n // Return the output\n return this.utils.outputHandler.compile(output, settings.outputType, true, negative);\n }\n}\n","/**\n * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT OR Apache-2.0\n * @see https://github.com/keith-turner/ecoji\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Ecoji (a Base 1024) Converter.\n * ------------------------------------\n * This an implementation of the Ecoji converter.\n * Various input can be converted to an Ecoji string\n * or an Ecoji string can be decoded into various \n * formats. Versions 1 and 2 are supported.\n * This variant pretty much follows the standard\n * (at least in its results, the algorithm is very\n * different from the original).\n * A deviation is the handling of padding. The last\n * pad char can be trimmed for both versions and\n * additionally omitted completely if integrity\n * checks are disabled.\n */\nexport default class Ecoji extends BaseTemplate {\n\n #revEmojiVersion = {};\n #padRegex = null;\n\n /**\n * BaseEx Ecoji Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // charsets\n this.charsets.emojis_v1 = [...\"🀄🃏🅰🅱🅾🅿🆎🆑🆒🆓🆔🆕🆖🆗🆘🆙🆚🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿🈁🈂🈚🈯🈲🈳🈴🈵🈶🈷🈸🈹🈺🉐🉑🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🌡🌤🌥🌦🌧🌨🌩🌪🌫🌬🌭🌮🌯🌰🌱🌲🌳🌴🌵🌶🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🍽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🎖🎗🎙🎚🎛🎞🎟🎠🎡🎢🎣🎤🎥🎦🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🏋🏌🏎🏏🏐🏑🏒🏓🏔🏕🏖🏗🏘🏙🏚🏛🏜🏝🏞🏟🏠🏡🏢🏣🏤🏥🏦🏧🏨🏩🏪🏫🏬🏭🏮🏯🏰🏳🏴🏵🏷🏸🏹🏺🏻🏼🏽🏾🏿🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🐿👀👁👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸💹💺💻💼💽💾💿📀📁📂📃📄📅📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳📴📵📶📷📸📹📺📻📼📽📿🔀🔁🔂🔃🔄🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🔙🔚🔛🔜🔝🔞🔟🔠🔡🔢🔣🔤🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🔴🔵🔶🔷🔸🔹🔺🔻🔼🔽🕉🕊🕋🕌🕍🕎🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧🕯🕰🕳🕴🕵🕶🕷🕸🕹🕺🖇🖊🖋🖌🖍🖐🖕🖖🖤🖥🖨🖱🖲🖼🗂🗃🗄🗑🗒🗓🗜🗝🗞🗡🗣🗨🗯🗳🗺🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🛋🛌🛍🛎🛏🛐🛑🛒🛠🛡🛢🛣🛤🛥🛩🛫🛬🛰🛳🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🦰🦱🦲🦳🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕\"];\n this.padChars.emojis_v1 = [ \"⚜\", \"🏍\", \"📑\", \"🙋\", \"☕\" ];\n\n this.charsets.emojis_v2 = [...\"🀄🃏⏰⏳☔♈♉♊♋♌♍♎♏♐♑♒♓♿⚓⚡⚽⚾⛄⛅⛎⛔⛪⛲⛳⛵⛺⛽✊✋✨⭐🛕🛖🛗🛝🛞🛟🛺🈁🛻🤌🤏🤿🥱🥲🥸🥹🥻🦣🦤🦥🦦🦧🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🦨🦩🦪🦫🦬🦭🦮🦯🦺🦻🌭🌮🌯🌰🌱🌲🌳🌴🌵🦼🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🦽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🦾🦿🧃🧄🧅🧆🧇🎠🎡🎢🎣🎤🎥🧈🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🧉🧊🧋🏏🏐🏑🏒🏓🧌🧍🧎🧏🧖🧗🧘🧙🧚🧛🧜🧝🏠🏡🏢🏣🏤🏥🏦🧞🏨🏩🏪🏫🏬🏭🏮🏯🏰🧟🏴🧠🧢🏸🏹🏺🧣🧤🧥🧦🧧🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🧨👀🧩👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸🧪💺💻💼💽💾💿📀🧫📂📃📄🧬📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳🧭📵📶📷📸📹📺📻📼🧮📿🧯🧰🧱🧲🧳🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🧴🧵🧶🧷🧸🧹🧺🧻🧼🧽🧾🧿🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🩰🩱🩲🩳🩴🩸🩹🩺🩻🩼🪀🪁🕋🕌🕍🕎🪂🪃🪄🪅🪆🪐🪑🪒🪓🪔🪕🪖🪗🪘🪙🪚🪛🪜🪝🪞🪟🪠🪡🪢🪣🪤🪥🪦🪧🪨🪩🪪🪫🕺🪬🪰🪱🪲🪳🪴🖕🖖🖤🪵🪶🪷🪸🪹🪺🫀🫁🫂🫃🫄🫅🫐🫑🫒🫓🫔🫕🫖🫗🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🫘🛌🫙🫠🫡🛐🛑🛒🫢🫣🫤🫥🫦🫧🫰🛫🛬🫱🫲🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🫳🫴🫵🫶🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕\"];\n this.padChars.emojis_v2 = [ \"🥷\", \"🛼\", \"📑\", \"🙋\", \"☕\" ];\n \n // init mapping for decoding particularities of the two versions\n this.#init();\n\n // converter\n this.converter = new BaseConverter(1024, 5, 4);\n\n // predefined settings\n this.padding = true;\n this.padCharAmount = 5;\n this.version = \"emojis_v2\";\n \n // mutable extra args\n this.isMutable.padding = true;\n this.isMutable.trim = true;\n\n // set trim option\n this.trim = null;\n this.utils.converterArgs.trim = [\"notrim\", \"trim\"];\n \n // apply user settings\n this.utils.validateArgs(args, true);\n\n if (this.trim === null) {\n this.trim = this.version === \"emojis_v2\";\n }\n }\n\n\n /**\n * Analyzes v1 and two charsets for equal and non\n * equal characters to create a \"revEmojiObj\" for\n * decoding lookup. Also generates a RegExp object \n * for handling concatenated strings.\n */\n #init() {\n\n // Stores all padding for a regex generation.\n const padAll = {};\n\n // Creates an object which holds all characters\n // of both versions. Unique chars for version one\n // are getting the version value \"1\", version two \"2\"\n // and overlaps \"3\". \n const revEmojisAdd = (version, set) => {\n set.forEach((char) => {\n if (char in this.#revEmojiVersion) {\n this.#revEmojiVersion[char].version += version;\n } else {\n this.#revEmojiVersion[char] = { version };\n }\n });\n };\n\n // This function adds a padding character of both\n // versions to the object, with additional information\n // about the padding type. In this process each unique\n // padChar is also added to the \"padAll\" object. \n const handlePadding = (version, set, type) => {\n set.forEach(padChar => {\n \n if (padChar in padAll) {\n this.#revEmojiVersion[padChar].version = 3;\n } else {\n this.#revEmojiVersion[padChar] = {\n version,\n padding: type\n }\n padAll[padChar] = type;\n } \n });\n };\n\n revEmojisAdd(1, this.charsets.emojis_v1);\n revEmojisAdd(2, this.charsets.emojis_v2);\n\n handlePadding(1, this.padChars.emojis_v1.slice(0, -1), \"last\");\n handlePadding(2, this.padChars.emojis_v2.slice(0, -1), \"last\");\n handlePadding(1, this.padChars.emojis_v1.slice(-1), \"fill\");\n handlePadding(2, this.padChars.emojis_v2.slice(-1), \"fill\");\n\n \n // Create an array of keys for the final regex\n const regexArray = [];\n\n for (const padChar in padAll) {\n if (padAll[padChar] === \"last\") {\n regexArray.push(padChar);\n } else {\n regexArray.push(`${padChar}+`);\n }\n }\n\n // create a regex obj for matching all pad chars \n this.#padRegex = new RegExp(regexArray.join(\"|\"), \"g\");\n }\n\n\n /**\n * BaseEx Ecoji Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Ecoji encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n const charset = this.charsets[settings.version];\n let outArray = [...output];\n \n if (zeroPadding > 1) {\n const padValue = this.converter.padBytes(zeroPadding);\n if (settings.padding) {\n const padLen = settings.trim ? 1 : padValue;\n const padArr = new Array(padLen).fill(this.padChars[settings.version].at(-1));\n outArray.splice(outArray.length-padValue, padValue, ...padArr);\n } else {\n outArray.splice(outArray.length-padValue, padValue);\n }\n }\n \n else if (zeroPadding === 1) {\n const lastVal = charset.indexOf(outArray.pop());\n const x = lastVal >> 8;\n outArray.push(this.padChars[settings.version].at(x));\n }\n\n return outArray.join(\"\");\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n \n /**\n * BaseEx Ecoji Decoder.\n * @param {string} input - Ecoji String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n input = this.utils.normalizeInput(input);\n\n let version = settings.version;\n let versionKey = null;\n\n if (settings.version === \"emojis_v1\" || settings.version === \"emojis_v2\") {\n // versionKey can be both v1 or v2\n versionKey = 3;\n }\n\n // the actual decoding is wrapped in a function\n // for the possibility to call it multiple times\n const decode = (input) => {\n\n if (versionKey !== null) {\n versionKey = this.#preDecode(input, versionKey, settings.integrity);\n version = (versionKey === 3)\n ? settings.version\n : `emojis_v${versionKey}`;\n }\n\n const charset = this.charsets[version];\n \n const inArray = [...input];\n const lastChar = inArray.at(-1);\n let skipLast = false;\n\n for (let i=0; i {\n const end = match.index + match.at(0).length;\n preOutArray.push(...decode(input.slice(start, end)));\n start = end;\n });\n\n // in case the last group has no padding, it is not yet\n // decoded -> do it now\n if (start !== input.length) {\n preOutArray.push(...decode(input.slice(start, input.length)));\n }\n\n output = Uint8Array.from(preOutArray);\n }\n\n return this.utils.outputHandler.compile(output, settings.outputType);\n }\n\n\n /**\n * Determines the version (1/2) and analyzes the input for integrity.\n * @param {string} input - Input string. \n * @param {number} versionKey - Version key from former calls (initially always 3). \n * @param {boolean} integrity - If false non standard or wrong padding gets ignored. \n * @returns {number} - Version key (1|2|3)\n */\n #preDecode(input, versionKey, integrity) {\n \n const inArray = [...input];\n let sawPadding;\n\n inArray.forEach((char, i) => {\n\n if (char in this.#revEmojiVersion) {\n\n const charVersion = this.#revEmojiVersion[char].version;\n\n // version changes can only happen if the char is\n // not in both versions (not 3)\n if (charVersion !== 3) {\n if (versionKey === 3) {\n versionKey = charVersion;\n } else if (versionKey !== charVersion) {\n throw new TypeError(`Emojis from different ecoji versions seen : ${char} from emojis_v${charVersion}`);\n }\n }\n\n // analyze possible wrong padding if integrity checks\n // are enabled\n if (integrity) {\n const padding = this.#revEmojiVersion[char].padding;\n if (padding) {\n\n // index relative to a group of four bytes\n const relIndex = i%4;\n sawPadding = true;\n\n if (padding === \"fill\") {\n if (relIndex === 0) {\n throw new TypeError(`Padding unexpectedly seen in first position ${char}`);\n }\n } else if (relIndex !== 3) {\n throw new TypeError(`Last padding seen in unexpected position ${char}`);\n }\n }\n\n else if (sawPadding) {\n throw new TypeError(\"Unexpectedly saw non-padding after padding\");\n }\n }\n\n } else {\n throw new DecodingError(char);\n }\n });\n\n // lastly test for invalid string \n if (integrity && inArray.length % 4) {\n if (\n versionKey === 1 ||\n this.#revEmojiVersion[inArray.at(-1)].padding !== \"fill\"\n ) {\n throw new TypeError(\"Unexpected end of data, input data size not multiple of 4\");\n }\n }\n\n return versionKey;\n }\n}\n","/**\n * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base 2048 Converter.\n * ------------------------\n * This is a base2048/converter. Various input can be \n * converted to a hex string or a hex string can be\n * decoded into various formats. It is possible to \n * convert in both signed and unsigned mode.\n * \n * @see https://github.com/qntm/base2048\n */\nexport default class Base2048 extends BaseTemplate {\n\n /**\n * BaseEx Base2048 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 2048,\n bsEnc: 11,\n bsEncPad: 3,\n bsDec: 8\n }\n \n // default settings\n this.charsets.default = [...\"89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ\"];\n this.padChars.default = [...\"01234567\"];\n\n this.padCharAmount = 8;\n this.hasSignedMode = true;\n this.littleEndian = false;\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Base2048 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base2048 encoded string.\n */\n encode(input, ...args) {\n\n const settings = this.utils.validateArgs(args);\n let inputBytes = this.utils.inputHandler.toBytes(input, settings).at(0);\n\n const charset = this.charsets[settings.version];\n const padChars = this.padChars[settings.version];\n\n let output = \"\";\n let z = 0;\n let numZBits = 0;\n\n inputBytes.forEach(uint8 => {\n \n for (let i=this.converter.bsDec-1; i>=0; i--) {\n\n z = (z << 1) + ((uint8 >> i) & 1);\n numZBits++;\n\n if (numZBits === this.converter.bsEnc) {\n output += charset.at(z);\n z = 0\n numZBits = 0\n }\n }\n });\n\n if (numZBits !== 0) {\n \n let bitCount;\n let isPadding;\n\n if (numZBits <= this.converter.bsEncPad) {\n bitCount = this.converter.bsEncPad;\n isPadding = true;\n } else {\n bitCount = this.converter.bsEnc \n isPadding = false;\n }\n\n while (numZBits !== bitCount) {\n z = (z << 1) + 1\n numZBits++\n if (numZBits > this.converter.bsEnc) {\n throw new Error(\"Cannot process input. This is a bug!\");\n }\n }\n \n if (isPadding) { \n output += padChars.at(z);\n } else {\n output += charset.at(z);\n }\n }\n\n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n \n /**\n * BaseEx Base2048 Decoder.\n * @param {string} input - Base2048/Hex String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // apply settings\n const settings = this.utils.validateArgs(args);\n\n // ensure a string input\n input = this.utils.normalizeInput(input);\n const inArray = [...input];\n\n const charset = this.charsets[settings.version];\n const padChars = this.padChars[settings.version];\n\n const byteArray = new Array();\n let uint8 = 0;\n let numUint8Bits = 0;\n\n inArray.forEach((c, i) => {\n\n let numZBits;\n let z = charset.indexOf(c);\n if (z > -1) { \n numZBits = this.converter.bsEnc;\n } else {\n z = padChars.indexOf(c);\n\n if (z > -1) {\n if (i+1 !== inArray.length) {\n throw new DecodingError(null, `Secondary character found before end of input, index: ${i}`); \n }\n\n numZBits = this.converter.bsEncPad;\n }\n \n else if (settings.integrity) {\n throw new DecodingError(c);\n }\n }\n\n // Take most significant bit first\n for (let j=numZBits-1; j>=0; j--) {\n\n uint8 = (uint8 << 1) + ((z >> j) & 1);\n numUint8Bits++\n\n if (numUint8Bits === this.converter.bsDec) {\n byteArray.push(uint8);\n uint8 = 0;\n numUint8Bits = 0;\n }\n }\n });\n\n return this.utils.outputHandler.compile(\n Uint8Array.from(byteArray),\n settings.outputType\n );\n }\n}\n","/**\n * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n\n/**\n * BaseEx SimpleBase Converter.\n * ---------------------------\n * SimpleBase provides the simple mathematical base\n * conversion as known from (n).toString(radix) and\n * parseInt(n, radix).\n * \n * The constructor needs a radix between 2-62 as the\n * first argument. In other regards it behaves pretty\n * much as any other converter. \n */\nexport default class SimpleBase extends BaseTemplate {\n \n /**\n * SimpleBase Constructor.\n * @param {number} radix - Radix between 2 and 62 \n * @param {...any} args - Converter settings.\n */\n constructor(radix, ...args) {\n super();\n\n if (!radix || !Number.isInteger(radix) || radix < 2 || radix > 62) {\n throw new RangeError(\"Radix argument must be provided and has to be an integer between 2 and 62.\")\n }\n this.converter = new BaseConverter(radix, 0, 0);\n\n\n // charsets\n this.charsets.default = [...\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"].slice(0, radix);\n \n\n // predefined settings\n this.frozenCharsets = true;\n this.hasSignedMode = true;\n this.littleEndian = !(radix === 2 || radix === 16);\n this.signed = true;\n this.version = \"default\";\n \n // list of allowed/disallowed args to change\n this.isMutable.littleEndian = true,\n this.isMutable.upper = radix <= 36;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx SimpleBase Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...any} [args] - Converter settings.\n * @returns {string} - Base 2-62 encoded string.\n */\n encode(input, ...args) {\n return super.encode(input, null, null, ...args);\n }\n\n\n /**\n * BaseEx SimpleBase Decoder.\n * @param {string} input - Base 2-62 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(rawInput, ...args) {\n\n // pre decoding function\n const normalizeInput = ({ input }) => {\n \n // normalize input (add leading zeros) for base 2 and 16\n if (this.converter.radix === 2) {\n const leadingZeros = (8 - (input.length % 8)) % 8;\n input = `${\"0\".repeat(leadingZeros)}${input}`;\n } else if (this.converter.radix === 16) {\n const leadingZeros = input.length % 2;\n input = `${\"0\".repeat(leadingZeros)}${input}`;\n }\n\n return input;\n }\n \n return super.decode(rawInput, normalizeInput, null, false, ...args);\n\n }\n}\n","/**\n * big.js v6.2.1 // Copyright (c) 2022 Michael Mclaughlin // https://github.com/MikeMcl/big.js/LICENCE.md // Modified (reduced) and minified for BaseEx\n */\nlet DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME=\"[big.js] \",INVALID=NAME+\"Invalid \",INVALID_DP=INVALID+\"decimal places\",INVALID_RM=INVALID+\"rounding mode\",P={},NUMERIC=/^-?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i;function _Big_(){function Big(n){let x=this;if(!(x instanceof Big))return void 0===n?_Big_():new Big(n);if(n instanceof Big)x.s=n.s,x.e=n.e,x.c=n.c.slice();else{if(\"string\"!=typeof n){if(!0===Big.strict&&\"bigint\"!=typeof n)throw TypeError(INVALID+\"value\");n=0===n&&1/n<0?\"-0\":String(n)}parse(x,n)}x.constructor=Big}return Big.prototype=P,Big.DP=DP,Big.RM=RM,Big.NE=NE,Big.PE=PE,Big.strict=STRICT,Big.roundDown=0,Big.roundHalfUp=1,Big.roundHalfEven=2,Big.roundUp=3,Big}function parse(x,n){let e,i,nl;if(!NUMERIC.test(n))throw Error(`${INVALID}number`);for(x.s=\"-\"==n.charAt(0)?(n=n.slice(1),-1):1,(e=n.indexOf(\".\"))>-1&&(n=n.replace(\".\",\"\")),(i=n.search(/e/i))>0?(e<0&&(e=i),e+=+n.slice(i+1),n=n.substring(0,i)):e<0&&(e=n.length),nl=n.length,i=0;i0&&\"0\"==n.charAt(--nl););for(x.e=e-i-1,x.c=[],e=0;i<=nl;)x.c[e++]=+n.charAt(i++)}return x}function round(x,sd,rm,more){let xc=x.c;if(void 0===rm&&(rm=x.constructor.RM),0!==rm&&1!==rm&&2!==rm&&3!==rm)throw Error(INVALID_RM);if(sd<1)more=3===rm&&(more||!!xc[0])||0===sd&&(1===rm&&xc[0]>=5||2===rm&&(xc[0]>5||5===xc[0]&&(more||void 0!==xc[1]))),xc.length=1,more?(x.e=x.e-sd+1,xc[0]=1):xc[0]=x.e=0;else if(sd=5||2===rm&&(xc[sd]>5||5===xc[sd]&&(more||void 0!==xc[sd+1]||1&xc[sd-1]))||3===rm&&(more||!!xc[0]),xc.length=sd,more)for(;++xc[--sd]>9;)if(xc[sd]=0,0===sd){++x.e,xc.unshift(1);break}for(sd=xc.length;!xc[--sd];)xc.pop()}return x}function stringify(x,doExponential,isNonzero){let e=x.e,s=x.c.join(\"\"),n=s.length;if(doExponential)s=s.charAt(0)+(n>1?\".\"+s.slice(1):\"\")+(e<0?\"e\":\"e+\")+e;else if(e<0){for(;++e;)s=\"0\"+s;s=\"0.\"+s}else if(e>0)if(++e>n)for(e-=n;e--;)s+=\"0\";else e1&&(s=s.charAt(0)+\".\"+s.slice(1));return x.s<0&&isNonzero?\"-\"+s:s}P.abs=function(){let x=new this.constructor(this);return x.s=1,x},P.cmp=function(y){let isneg,x=this,xc=x.c,yc=(y=new x.constructor(y)).c,i=x.s,j=y.s,k=x.e,l=y.e;if(!xc[0]||!yc[0])return xc[0]?i:yc[0]?-j:0;if(i!=j)return i;if(isneg=i<0,k!=l)return k>l^isneg?1:-1;for(j=(k=xc.length)<(l=yc.length)?k:l,i=-1;++iyc[i]^isneg?1:-1;return k==l?0:k>l^isneg?1:-1},P.eq=function(y){return 0===this.cmp(y)},P.gt=function(y){return this.cmp(y)>0},P.gte=function(y){return this.cmp(y)>-1},P.lt=function(y){return this.cmp(y)<0},P.lte=function(y){return this.cmp(y)<1},P.minus=P.sub=function(y){let i,j,t,xlty,x=this,Big=x.constructor,a=x.s,b=(y=new Big(y)).s;if(a!=b)return y.s=-b,x.plus(y);let xc=x.c.slice(),xe=x.e,yc=y.c,ye=y.e;if(!xc[0]||!yc[0])return yc[0]?y.s=-b:xc[0]?y=new Big(x):y.s=1,y;if(a=xe-ye){for((xlty=a<0)?(a=-a,t=xc):(ye=xe,t=yc),t.reverse(),b=a;b--;)t.push(0);t.reverse()}else for(j=((xlty=xc.length0)for(;b--;)xc[i++]=0;for(b=i;j>a;){if(xc[--j]0?(ye=xe,t=yc):(e=-e,t=xc),t.reverse();e--;)t.push(0);t.reverse()}for(xc.length-yc.length<0&&(t=yc,yc=xc,xc=t),e=yc.length,k=0;e;xc[e]%=10)k=(xc[--e]=xc[e]+yc[e]+k)/10|0;for(k&&(xc.unshift(k),++ye),e=xc.length;0===xc[--e];)xc.pop();return y.c=xc,y.e=ye,y},P.round=function(dp,rm){if(void 0===dp)dp=0;else if(dp!==~~dp||dp<-MAX_DP||dp>MAX_DP)throw Error(INVALID_DP);return round(new this.constructor(this),dp+this.e+1,rm)},P.toFixed=function(dp,rm){let x=this,n=x.c[0];if(void 0!==dp){if(dp!==~~dp||dp<0||dp>MAX_DP)throw Error(INVALID_DP);for(x=round(new x.constructor(x),dp+x.e+1,rm),dp=dp+x.e+1;x.c.length=Big.PE,!!x.c[0])},P.toNumber=function(){let n=Number(stringify(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(n.toString()))throw Error(NAME+\"Imprecise conversion\");return n};export const Big=_Big_();export default Big;\n","/**\n * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport Big from \"../../lib/big.js/big.min.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base Phi Converter.\n * ------------------------\n * \n * This is a base phi converter. Various input can be \n * converted to a base phi string or a base phi string\n * can be decoded into various formats.\n * \n */\nexport default class BasePhi extends BaseTemplate {\n\n #Phi = Big(\"1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752\");\n \n /**\n * BaseEx basE91 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 2, // radix is Phi, but the normalized representation allows two chars\n bsEnc: 0,\n bsDec: 0\n }\n\n // base10 converter to have always have a numerical input \n this.b10 = new BaseConverter(10, 0, 0);\n\n // charsets\n this.charsets.default = [\"0\", \"1\"];\n\n this.version = \"default\";\n this.signed = true;\n this.hasDecimalMode = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx BasePhi Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...string} [args] - Converter settings.\n * @returns {string} - BasePhi encoded string.\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n \n let inputBytes;\n let negative;\n let n;\n let output = \"\";\n\n // Base Phi allows direct encoding of rational \n // and irrational numbers, which can be enabled\n // by using the special type \"decimal\". Input \n // type must be \"Number\" for this mode. \n if (settings.decimalMode) {\n if (Number.isFinite(input)) {\n if (input < 0) {\n negative = true;\n n = Big(-input);\n } else {\n negative = false;\n n = Big(input);\n } \n }\n\n else {\n throw new TypeError(\"When running the converter in decimal-mode, only input of type 'Number' is allowed.\")\n }\n }\n\n // Every other type first converts the byte representation\n // of the input to base 10.\n else {\n [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings);\n n = Big(\n this.b10.encode(inputBytes, null, settings.littleEndian)[0]\n );\n }\n\n // if \"n\" if 0 or 1 stop here and return 0 or 1 (according to the charset)\n if (n.eq(0) || n.eq(1)) {\n output = charset[n.toNumber()]; \n if (negative) {\n output = `-${output}`;\n } \n return output;\n }\n \n // create two arrays to store all exponents\n const exponents = [];\n const decExponents = [];\n\n\n // The very first step is to find the highest exponent\n // of Phi which fits into \"n\" (the rounded highest exponent\n // is also the highest Lucas number which fits into \"n\")\n // To find the highest fitting exponent start with \n // Phi^0 (1) and Phi^1 (Phi).\n\n let last = Big(1);\n let cur = this.#Phi;\n let exp = 0;\n \n // Now add the result with the last higher value \"cur\",\n // util \"cur\" is bigger than \"n\"\n while (cur.lt(n)) {\n [ last, cur ] = this.#nextPhiExp(last, cur);\n exp++;\n }\n \n /**\n * Recursive reduction function for \"n\". Finds the largest\n * fitting exponent of Phi (Lucas index), stores that index\n * in the exponent arrays and reduces \"n\" by the current exponents\n * power.\n * Once started, it calls itself until \"n\" is zero. \n * @param {Object} cur - Current result of Phi^exp as a Big.js object. \n * @param {Object} prev - Previous result of Phi^exp as a Big.js object. \n * @param {number} exp - Exponent of Phi/Lucas index. \n */\n const reduceN = (cur, prev, exp) => {\n\n // Due to the high floating point precision \"n\" should\n // be exactly zero, but if not, an approximation is \n // sufficient.\n if (this.#approxNull(n)) return;\n\n // Reduce the exponents of Phi until it power fits into \"n\" \n while (cur.gt(n)) {\n [ cur, prev ] = this.#prevPhiExp(cur, prev);\n \n // if \"cur\" gets negative return immediately\n // prevent an infinite loop\n if (cur.lte(0)) {\n console.warn(\"Could not find an exact base-phi representation. Value is approximated.\");\n return;\n }\n exp--;\n }\n\n // Store the exponents\n if (exp > -1) {\n exponents.unshift(exp);\n } else {\n decExponents.push(exp);\n }\n\n // Reduce \"n\"\n n = n.minus(cur);\n\n reduceN(cur, prev, exp);\n }\n\n // Initial call of the reduction function\n reduceN(last, cur, exp);\n\n\n // Create a BasePhi string by setting a \"1\" at every\n // index stored in the \"exponent\" array. for every\n // number between two indices a zero is added. \n exp = 0; \n exponents.forEach(nExp => {\n while (exp < nExp) {\n output = `${charset[0]}${output}`;\n exp++;\n }\n output = `${charset[1]}${output}`;\n exp++;\n });\n\n // Add a decimal point\n if (!output) {\n output = \"0.\";\n } else {\n output += \".\";\n }\n \n // Proceed with the decimal exponents\n exp = -1;\n decExponents.forEach(nExp => {\n while (exp > nExp) {\n output += charset[0];\n exp--;\n }\n output += charset[1];\n exp--;\n });\n\n // Add a \"-\" if the input is negative.\n if (negative) {\n output = `-${output}`;\n }\n \n return output;\n }\n\n\n /**\n * BaseEx Base Phi Decoder.\n * @param {string} input - Base Phi String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n\n let negative;\n [ input, negative ] = this.utils.extractSign(\n this.utils.normalizeInput(input)\n );\n\n // remove unwanted characters if integrity is false\n if (!settings.integrity) {\n const testChars = [...charset, \".\"];\n input = [...input].filter(c => testChars.includes(c)).join(\"\");\n }\n \n // Split the input String at the decimal sign\n // and initialize a big.js-object with value 0\n const inputSplit = input.split(\".\");\n if (settings.integrity && inputSplit.length > 2) {\n throw new DecodingError(null, \"There are multiple decimal points in the input.\");\n } \n\n const [ posExpStr, decExpStr ] = inputSplit;\n let n = Big(0);\n\n // Initialize two variables \"last\" and \"cur\"\n // for Phi^exp-1 and Phi^exp\n let last = this.#Phi.minus(1);\n let cur = Big(1); \n \n // Convert the left side of the input string\n // to an array of chars and reverse it. Raise\n // the exponent of Phi and its values until a\n // one is found in the array, if a \"1\" was found\n // add the value \"cur\" to number \"n\" (one can\n // also be another corresponding char of the set\n // which represents 1).\n [...posExpStr].reverse().forEach((char) => {\n const charIndex = charset.indexOf(char);\n if (charIndex === 1) {\n n = n.plus(cur);\n } else if (charIndex !== 0) {\n throw new DecodingError(char);\n }\n [ last, cur ] = this.#nextPhiExp(last, cur);\n });\n\n // Now also add the values for the decimal places.\n if (decExpStr) { \n let prev = Big(1); \n cur = this.#Phi.minus(prev);\n \n [...decExpStr].forEach((char) => {\n const charIndex = charset.indexOf(char);\n if (charIndex === 1) {\n n = n.plus(cur);\n } else if (charIndex !== 0) {\n throw new DecodingError(char);\n }\n [ cur, prev ] = this.#prevPhiExp(cur, prev);\n });\n }\n\n // If running in decimal mode return n as a Number\n if (settings.decimalMode) {\n return n.toNumber();\n }\n\n // For every other case round \"n\" and turn it\n // into a string of an integer. \n n = n.round().toFixed();\n\n // Use the base 10 decoder to get the byte\n // representation of \"n\".\n const output = this.b10.decode(n, [...\"0123456789\"], [], settings.integrity, settings.littleEndian);\n \n // Return the output according to the settings.\n return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative);\n }\n\n /**\n * Test if n is approximately zero.\n * @param {Object} n - Big.js Object. \n * @returns {Boolean}\n */\n #approxNull(n) { \n return !(n.round(50)\n .abs()\n .toNumber()\n );\n }\n \n /**\n * Get the results of of the following exponents of Phi\n * from the predecessors.\n * @param {Object} last - Phi^exp-1 as a big.js-object \n * @param {Object} cur - Phi^exp as a big.js-object\n * @returns {Object[]} - Array with Phi^exp and Phi^exp+1\n */\n #nextPhiExp(last, cur) {\n return [ cur, last.plus(cur) ];\n }\n\n /**\n * Get the results of of the previous exponents of Phi\n * from the predecessors.\n * @param {Object} cur - Phi^exp as a big.js-object \n * @param {Object} prev - Phi^exp-1 as a big.js-object\n * @returns {Object[]} - Array with Phi^exp-1 and Phi^exp\n */\n #prevPhiExp(cur, prev) {\n return [ prev.minus(cur), cur ];\n }\n}\n","/**\n * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { SmartInput, SmartOutput } from \"../io-handlers.js\";\n\n// Endianness of the system\nconst LITTLE_ENDIAN = (() => {\n const testInt = new Uint16Array([1]);\n const byteRepresentation = new Uint8Array(testInt.buffer);\n return Boolean(byteRepresentation.at(0));\n})();\n\n\n/**\n * BaseEx Byte Converter.\n * ---------------------\n * \n * This is a byte converter. Various input can be \n * converted to a bytes or bytes can be decoded into\n * various formats.\n * \n * As en- and decoder were already available, for the\n * use of converting in- and output for the base\n * converters, this is just a little extra tool, which\n * was fast and easy to create.\n */\nexport default class ByteConverter {\n\n /**\n * BaseEx ByteConverter Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n\n // predefined settings\n this.littleEndian = LITTLE_ENDIAN;\n this.numberMode = false;\n this.outputType = \"buffer\";\n\n // simplified utils\n this.utils = {\n validateArgs: (args, initial=false) => {\n\n const parameters = {\n littleEndian: this.littleEndian,\n numberMode: this.numberMode,\n outputType: this.outputType,\n signed: false,\n }\n \n if (!args.length) {\n return parameters;\n }\n \n if (args.includes(\"number\")) {\n args.splice(args.indexOf(\"number\"), 1);\n parameters.numberMode = true;\n parameters.outputType = \"float_n\";\n }\n \n const outTypes = SmartOutput.typeList.map(s => `'${s}'`).join(\", \");\n \n args.forEach((arg) => {\n arg = String(arg).toLowerCase();\n \n if (arg === \"le\") {\n parameters.littleEndian = true;\n } else if (arg === \"be\") {\n parameters.littleEndian = false;\n } else if (SmartOutput.typeList.includes(arg)) {\n parameters.outputType = arg;\n } else {\n throw new TypeError(`Invalid argument: '${arg}.\\nValid arguments are:\\n'le', 'be', ${outTypes}`);\n }\n });\n \n if (initial) {\n for (const param in parameters) {\n this[param] = parameters[param];\n }\n }\n \n return parameters;\n }\n }\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Byte Encoder.\n * @param {*} input - Almost any input.\n * @param {...str} [args] - Converter settings.\n * @returns {{ buffer: ArrayBufferLike; }} - Bytes of Input.\n */\n encode(input, ...args) {\n const settings = this.utils.validateArgs(args);\n return SmartInput.toBytes(input, settings)[0];\n }\n\n\n /**\n * BaseEx Byte Decoder.\n * @param {{ buffer: ArrayBufferLike; }} input - Bytes/Buffer/View\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output of requested type.\n */\n decode(input, ...args) {\n const settings = this.utils.validateArgs(args);\n return SmartOutput.compile(input, settings.outputType, settings.littleEndian);\n }\n}\n","/**\n * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS}\n *\n * @version 0.7.8\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\n/* eslint-disable sort-imports */\n\nimport Base1 from \"./converters/base-1.js\";\nimport Base16 from \"./converters/base-16.js\";\nimport Base32 from \"./converters/base-32.js\";\nimport Base58 from \"./converters/base-58.js\";\nimport Base64 from \"./converters/base-64.js\";\nimport UUencode from \"./converters/uuencode.js\";\nimport Base85 from \"./converters/base-85.js\";\nimport Base91 from \"./converters/base-91.js\";\nimport LEB128 from \"./converters/leb-128.js\";\nimport Ecoji from \"./converters/ecoji.js\";\nimport Base2048 from \"./converters/base-2048.js\";\nimport SimpleBase from \"./converters/simple-base.js\";\nimport BasePhi from \"./converters/base-phi.js\";\nimport ByteConverter from \"./converters/byte-converter.js\";\n\nimport { DEFAULT_OUTPUT_HANDLER } from \"./utils.js\";\n\n/**\n * BaseEx Converter Collection.\n * ---------------------------\n * This class holds almost any available converter\n * of the whole BaseEx converter collection. The \n * instances are ready to use. Various input can be \n * converted to a base string or the base string can be\n * decoded into various formats.\n */\nclass BaseEx {\n \n /**\n * BaseEx Base Collection Constructor.\n * @param {string} [outputType] - Output type. \n */\n constructor(outputType=\"buffer\") {\n\n if (!DEFAULT_OUTPUT_HANDLER.typeList.includes(outputType)) {\n let message = `Invalid argument '${outputType}' for output type. Allowed types are:\\n`;\n message = message.concat(DEFAULT_OUTPUT_HANDLER.typeList.join(\", \"));\n\n throw new TypeError(message);\n }\n\n this.base1 = new Base1(\"default\", outputType);\n this.base16 = new Base16(\"default\", outputType);\n this.base32_crockford = new Base32(\"rfc4648\", outputType);\n this.base32_rfc3548 = new Base32(\"rfc3548\", outputType);\n this.base32_rfc4648 = new Base32(\"rfc4648\", outputType);\n this.base32_zbase32 = new Base32(\"zbase32\", outputType);\n this.base58 = new Base58(\"default\", outputType);\n this.base58_bitcoin = new Base58(\"bitcoin\", outputType);\n this.base58_flickr = new Base58(\"flickr\", outputType);\n this.base64 = new Base64(\"default\", outputType);\n this.base64_urlsafe = new Base64(\"urlsafe\", outputType);\n this.uuencode = new UUencode(\"default\", outputType);\n this.uuencode_original = new UUencode(\"original\", outputType);\n this.xxencode = new UUencode(\"xx\", outputType);\n this.base85_adobe = new Base85(\"adobe\", outputType);\n this.base85_ascii = new Base85(\"ascii85\", outputType);\n this.base85_z85 = new Base85(\"z85\", outputType);\n this.base91 = new Base91(\"default\",outputType);\n this.leb128 = new LEB128(\"default\", outputType);\n this.ecoji_v1 = new Ecoji(\"emojis_v1\", outputType);\n this.ecoji_v2 = new Ecoji(\"emojis_v2\", outputType);\n this.base2048 = new Base2048(\"default\", outputType);\n this.basePhi = new BasePhi(\"default\", outputType);\n this.byteConverter = new ByteConverter(outputType);\n\n this.simpleBase = {};\n for (let i=2; i<=62; i++) {\n this.simpleBase[`base${i}`] = new SimpleBase(i, outputType);\n }\n }\n}\n\nexport { \n Base1,\n Base16,\n Base32,\n Base58,\n Base64,\n UUencode,\n Base85,\n Base91,\n LEB128,\n Ecoji,\n Base2048,\n SimpleBase,\n BasePhi,\n ByteConverter,\n BaseEx\n};\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,UAAU,CAAC;AACjB,IAAI,OAAO,OAAO,CAAC,KAAK,EAAE;AAC1B,QAAQ,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAA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Q,IAAI,CAAC,YAAY,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC9D,QAAQ,IAAI,CAAC,UAAU,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACxD,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACvD,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACxD,QAAQ,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC3D,QAAQ,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC3D,QAAQ,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC5D,QAAQ,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC1D,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;AAC3D;AACA,QAAQ,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;AAC7B,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE;AAClC,YAAY,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACxE,SAAS;AACT,KAAK;AACL;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"base-ex.cjs","sources":["../src/io-handlers.js","../src/utils.js","../src/core.js","../src/converters/base-1.js","../src/converters/base-16.js","../src/converters/base-32.js","../src/converters/base-58.js","../src/converters/base-64.js","../src/converters/uuencode.js","../src/converters/base-85.js","../src/converters/base-91.js","../src/converters/leb-128.js","../src/converters/ecoji.js","../src/converters/base-2048.js","../src/converters/simple-base.js","../lib/big.js/big.min.js","../src/converters/base-phi.js","../src/converters/byte-converter.js","../src/base-ex.js"],"sourcesContent":["/**\n * Simple Input Handler.\n * --------------------\n * Accepts only bytes eg. TypedArray, ArrayBuffer,\n * DataView, also a regular array (filled with integers)\n * is possible.\n */\nclass BytesInput {\n static toBytes(input) {\n if (ArrayBuffer.isView(input)) {\n input = input.buffer;\n } \n return [new Uint8Array(input), false, \"bytes\"];\n }\n}\n\n/**\n * Simple Output Handler.\n * ---------------------\n * Returns bytes in the form of:\n * - ArrayBuffer\n * - Uint8Array\n * - DataView \n */\nclass BytesOutput {\n\n static get typeList() {\n return [\n \"buffer\",\n \"bytes\",\n \"uint8\",\n \"view\"\n ];\n }\n\n static getType(type) {\n if (!BytesOutput.typeList.includes(type)) {\n throw new TypeError(`Unknown output type: '${type}'`);\n }\n return type;\n }\n\n static compile(Uint8ArrayOut, type) {\n type = BytesOutput.getType(type);\n let compiled;\n\n if (type === \"buffer\") {\n compiled = Uint8ArrayOut.buffer;\n } \n\n else if (type === \"view\") {\n compiled = new DataView(Uint8ArrayOut.buffer);\n }\n\n else {\n compiled = Uint8ArrayOut;\n }\n \n return compiled;\n }\n}\n\n\n/**\n * Advanced Input Handler.\n * ----------------------\n * Accepts almost every Input and converts it\n * into an Uint8Array (bytes).\n */\nclass SmartInput {\n\n static makeDataView(byteLen) {\n const buffer = new ArrayBuffer(byteLen);\n return new DataView(buffer);\n }\n\n static floatingPoints(input, littleEndian=false) {\n const view = this.makeDataView(8);\n view.setFloat64(0, input, littleEndian);\n return view;\n }\n\n static numbers(input, littleEndian=false) {\n\n let view;\n let type;\n\n // Integer\n if (Number.isInteger(input)) {\n\n type = \"int\";\n\n if (!Number.isSafeInteger(input)) {\n \n let safeInt;\n let smallerOrBigger;\n let minMax;\n\n if (input < 0) {\n safeInt = Number.MIN_SAFE_INTEGER;\n smallerOrBigger = \"smaller\";\n minMax = \"MIN\";\n } else {\n safeInt = Number.MAX_SAFE_INTEGER;\n smallerOrBigger = \"bigger\";\n minMax = \"MAX\";\n }\n\n throw new RangeError(`The provided integer is ${smallerOrBigger} than ${minMax}_SAFE_INTEGER: '${safeInt}'\\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`);\n }\n\n // Signed Integer\n if (input < 0) {\n \n // 64 bit\n if (input < -2147483648) {\n view = this.makeDataView(8);\n view.setBigInt64(0, BigInt(input), littleEndian);\n }\n \n // 32 littleEndian\n else if (input < -32768) {\n view = this.makeDataView(4);\n view.setInt32(0, input, littleEndian);\n }\n\n // 16 littleEndian\n else {\n view = this.makeDataView(2);\n view.setInt16(0, input, littleEndian);\n }\n }\n\n // Unsigned Integer\n else if (input > 0) {\n\n // 64 bit\n if (input > 4294967295) {\n view = this.makeDataView(8);\n view.setBigUint64(0, BigInt(input), littleEndian);\n }\n \n // 32 bit\n else if (input > 65535) {\n view = this.makeDataView(4);\n view.setUint32(0, input, littleEndian);\n }\n \n // 16 bit\n else {\n view = this.makeDataView(2);\n view.setInt16(0, input, littleEndian);\n }\n }\n\n // Zero\n else {\n view = new Uint16Array([0]);\n }\n }\n \n // Floating Point Number:\n else {\n type = \"float\";\n view = this.floatingPoints(input, littleEndian);\n }\n\n return [new Uint8Array(view.buffer), type];\n\n }\n\n\n static bigInts(input, littleEndian=false) {\n // Since BigInts are not limited to 64 bits, they might\n // overflow the BigInt64Array values. A little more \n // handwork is therefore needed.\n\n // as the integer size is not known yet, the bytes get a\n // makeshift home \"byteArray\", which is a regular array\n\n const byteArray = new Array();\n const append = (littleEndian) ? \"push\" : \"unshift\";\n const maxN = 18446744073709551616n;\n\n // split the input into 64 bit integers\n if (input < 0) {\n while (input < -9223372036854775808n) {\n byteArray[append](input % maxN);\n input >>= 64n;\n }\n } else { \n while (input >= maxN) {\n byteArray[append](input % maxN);\n input >>= 64n;\n }\n }\n\n // append the remaining byte\n byteArray[append](input);\n\n // determine the required size for the typed array\n // by taking the amount of 64 bit integers * 8\n // (8 bytes for each 64 bit integer)\n const byteLen = byteArray.length * 8;\n \n // create a fresh data view\n const view = this.makeDataView(byteLen);\n\n // set all 64 bit integers \n byteArray.forEach((bigInt, i) => {\n const offset = i * 8;\n view.setBigUint64(offset, bigInt, littleEndian);\n });\n\n return new Uint8Array(view.buffer);\n }\n\n\n static toBytes(input, settings) {\n\n let inputUint8;\n let negative = false;\n let type = \"bytes\";\n \n // Buffer:\n if (input instanceof ArrayBuffer) {\n inputUint8 = new Uint8Array(input.slice());\n }\n\n // TypedArray or DataView:\n else if (ArrayBuffer.isView(input)) {\n inputUint8 = new Uint8Array(input.buffer.slice());\n }\n \n // String:\n else if (typeof input === \"string\" || input instanceof String) {\n inputUint8 = new TextEncoder().encode(input);\n }\n \n // Number:\n else if (typeof input === \"number\") {\n if (isNaN(input)) {\n throw new TypeError(\"Cannot proceed. Input is NaN.\");\n } else if (input == Infinity) {\n throw new TypeError(\"Cannot proceed. Input is Infinity.\");\n }\n\n if (settings.signed && input < 0) {\n negative = true;\n input = -input;\n }\n\n if (settings.numberMode) {\n const view = this.floatingPoints(input, settings.littleEndian);\n inputUint8 = new Uint8Array(view.buffer);\n type = \"float\";\n } else {\n [inputUint8, type] = this.numbers(input, settings.littleEndian);\n }\n }\n\n // BigInt:\n else if (typeof input === \"bigint\") {\n if (settings.signed && input < 0) {\n negative = true;\n input *= -1n;\n }\n inputUint8 = this.bigInts(input, settings.littleEndian);\n type = \"int\";\n }\n\n // Array\n else if (Array.isArray(input)) {\n const collection = new Array();\n for (const elem of input) {\n collection.push(...this.toBytes(elem, settings)[0]);\n }\n inputUint8 = Uint8Array.from(collection);\n }\n\n else {\n throw new TypeError(\"The provided input type can not be processed.\");\n }\n\n return [inputUint8, negative, type];\n }\n}\n\n/** \n * Advanced Output Handler.\n * ----------------------- \n * This Output handler makes it possible to\n * convert an Uint8Array (bytes) into a desired\n * format of a big variety.\n * \n * The default output is an ArrayBuffer.\n */\nclass SmartOutput {\n\n static get typeList() {\n return [\n \"bigint64\",\n \"bigint_n\",\n \"biguint64\",\n \"buffer\",\n \"bytes\",\n \"float32\",\n \"float64\",\n \"float_n\",\n \"int8\",\n \"int16\",\n \"int32\",\n \"int_n\",\n \"str\",\n \"uint8\",\n \"uint16\",\n \"uint32\",\n \"uint_n\",\n \"view\"\n ];\n }\n\n static getType(type) {\n if (!this.typeList.includes(type)) {\n throw new TypeError(`Unknown output type: '${type}'`);\n }\n return type;\n }\n\n static makeTypedArrayBuffer(Uint8ArrayOut, bytesPerElem, littleEndian, negative) {\n \n const len = Uint8ArrayOut.byteLength;\n const delta = (bytesPerElem - (Uint8ArrayOut.byteLength % bytesPerElem)) % bytesPerElem;\n const newLen = len + delta;\n \n // if the array is negative and the len is gt 1\n // fill the whole array with 255\n const fillVal = (negative && len > 1) ? 255 : 0;\n\n let newArray = Uint8ArrayOut;\n\n if (delta) {\n newArray = new Uint8Array(newLen);\n newArray.fill(fillVal);\n \n const offset = (littleEndian) ? 0 : delta;\n newArray.set(Uint8ArrayOut, offset)\n }\n\n\n return newArray.buffer;\n }\n\n static makeTypedArray(inArray, type, littleEndian, negative) {\n let outArray;\n\n if (type === \"int16\" || type === \"uint16\") {\n\n const buffer = this.makeTypedArrayBuffer(inArray, 2, littleEndian, negative);\n outArray = (type === \"int16\") ? new Int16Array(buffer) : new Uint16Array(buffer);\n\n } else if (type === \"int32\" || type === \"uint32\" || type === \"float32\") {\n\n const buffer = this.makeTypedArrayBuffer(inArray, 4, littleEndian, negative);\n \n if (type === \"int32\") {\n outArray = new Int32Array(buffer);\n } else if (type === \"uint32\") {\n outArray = new Uint32Array(buffer);\n } else {\n outArray = new Float32Array(buffer);\n }\n\n } else if (type === \"bigint64\" || type === \"biguint64\" || type === \"float64\") {\n \n const buffer = this.makeTypedArrayBuffer(inArray, 8, littleEndian, negative);\n \n if (type === \"bigint64\") {\n outArray = new BigInt64Array(buffer);\n } else if (type === \"biguint64\") {\n outArray = new BigUint64Array(buffer);\n } else {\n outArray = new Float64Array(buffer);\n }\n }\n\n return outArray;\n }\n\n static compile(Uint8ArrayOut, type, littleEndian=false, negative=false) {\n type = this.getType(type);\n let compiled;\n\n // If the array is negative (which is only\n // true for signed encoding) get the positive\n // decimal number first and feed it with a \n // negative sign to SmartInput to construct\n // the unsigned output which is not shortened.\n\n if (negative) {\n let n;\n if (type.match(/^float/)) {\n n = -(this.compile(Uint8ArrayOut, \"float_n\", littleEndian));\n } else {\n n = -(this.compile(Uint8ArrayOut, \"uint_n\", littleEndian));\n }\n if (type === \"float_n\") {\n return n;\n }\n Uint8ArrayOut = SmartInput.toBytes(n, {littleEndian, numberMode: false, signed: false})[0];\n }\n\n if (type === \"buffer\") {\n compiled = Uint8ArrayOut.buffer;\n } \n \n else if (type === \"bytes\" || type === \"uint8\") {\n compiled = Uint8ArrayOut;\n }\n \n else if (type === \"int8\") {\n compiled = new Int8Array(Uint8ArrayOut.buffer);\n } \n \n else if (type === \"view\") {\n compiled = new DataView(Uint8ArrayOut.buffer);\n }\n \n else if (type === \"str\") {\n compiled = new TextDecoder().decode(Uint8ArrayOut);\n }\n \n else if (type === \"uint_n\" || type === \"int_n\" || type === \"bigint_n\") {\n\n // If the input consists of only one byte, expand it\n if (Uint8ArrayOut.length === 1) {\n const uint16Buffer = this.makeTypedArrayBuffer(Uint8ArrayOut, 2, littleEndian, negative);\n Uint8ArrayOut = new Uint8Array(uint16Buffer);\n }\n \n if (littleEndian) {\n Uint8ArrayOut.reverse();\n }\n\n // calculate a unsigned big integer\n let n = 0n;\n Uint8ArrayOut.forEach((b) => n = (n << 8n) + BigInt(b));\n\n // convert to signed int if requested \n if (type !== \"uint_n\") {\n n = BigInt.asIntN(Uint8ArrayOut.length*8, n);\n }\n \n // convert to regular number if possible (and no bigint was requested)\n if (type !== \"bigint_n\" && n >= Number.MIN_SAFE_INTEGER && n <= Number.MAX_SAFE_INTEGER) { \n compiled = Number(n);\n } else {\n compiled = n;\n }\n } \n \n else if (type === \"float_n\") {\n\n if (Uint8ArrayOut.length <= 4) {\n \n let array;\n if (Uint8ArrayOut.length === 4) {\n array = Uint8ArrayOut;\n } else {\n array = this.makeTypedArray(Uint8ArrayOut, \"float32\", false, negative);\n }\n\n const view = new DataView(array.buffer);\n compiled = view.getFloat32(0, littleEndian);\n \n }\n \n else if (Uint8ArrayOut.length <= 8) {\n \n let array;\n if (Uint8ArrayOut.length === 8) {\n array = Uint8ArrayOut;\n } else {\n array = this.makeTypedArray(Uint8ArrayOut, \"float64\", false, negative);\n }\n\n const view = new DataView(array.buffer);\n compiled = view.getFloat64(0, littleEndian);\n \n }\n\n else {\n throw new RangeError(\"The provided input is to complex to be converted into a floating point.\")\n }\n }\n\n else if (type === \"number\") {\n if (Uint8ArrayOut.length !== 8) {\n throw new TypeError(\"Type mismatch. Cannot convert into number.\");\n }\n\n const float64 = new Float64Array(Uint8ArrayOut.buffer);\n compiled = Number(float64);\n }\n\n else {\n compiled = this.makeTypedArray(Uint8ArrayOut, type, littleEndian, negative);\n } \n\n return compiled;\n }\n}\n\nexport { BytesInput, BytesOutput, SmartInput, SmartOutput };\n","import { BytesInput, BytesOutput, SmartInput, SmartOutput } from \"./io-handlers.js\";\n\nconst DEFAULT_INPUT_HANDLER = SmartInput;\nconst DEFAULT_OUTPUT_HANDLER = SmartOutput;\n\nclass SignError extends TypeError {\n constructor() {\n super(\"The input is signed but the converter is not set to treat input as signed.\\nYou can pass the string 'signed' to the decode function or when constructing the converter.\");\n this.name = \"SignError\";\n }\n}\n\nclass DecodingError extends TypeError {\n constructor(char, msg=null) {\n if (msg === null) {\n msg = `Character '${char}' is not part of the charset.`;\n }\n super(msg);\n this.name = \"DecodingError\";\n }\n}\n\n\n/**\n * Utilities for every BaseEx class.\n * --------------------------------\n * Requires IO Handlers\n */\nclass Utils {\n\n constructor(main) {\n\n // Store the calling class in this.root\n // for accessability.\n this.root = main;\n \n // set specific args object for converters\n this.converterArgs = {};\n\n // If charsets are uses by the parent class,\n // add extra functions for the user.\n\n this.#charsetUserToolsConstructor();\n }\n\n setIOHandlers(inputHandler=DEFAULT_INPUT_HANDLER, outputHandler=DEFAULT_OUTPUT_HANDLER) {\n this.inputHandler = inputHandler;\n this.outputHandler = outputHandler;\n }\n\n\n /**\n * Constructor for the ability to add a charset and \n * change the default version.\n */\n #charsetUserToolsConstructor() {\n\n /**\n * Save method to add a charset.\n * @param {string} name - \"Charset name.\"\n * @param {[string|set|array]} - \"Charset\"\n */\n this.root.addCharset = (name, _charset, _padChars=[], info=true) => {\n\n const normalize = (typeName, set, setLen) => {\n\n if (setLen === 0 && set.length) {\n console.warn(`This converter has no ${typeName}. The following argument was ignored:\\n'${set}'`);\n return [];\n }\n\n let inputLen = setLen;\n\n if (typeof set === \"string\") {\n set = [...set];\n }\n \n if (Array.isArray(set)) {\n \n // Store the input length of the input\n inputLen = set.length;\n \n // Convert to \"Set\" -> eliminate duplicates\n // If duplicates are found the length of the\n // Set and the length of the initial input\n // differ.\n\n set = new Set(set);\n\n } else if (!(set instanceof Set)) {\n throw new TypeError(`The ${typeName} must be one of the types:\\n'str', 'set', 'array'.\"`);\n }\n \n if (set.size === setLen) {\n return [...set];\n }\n \n if (inputLen !== setLen) {\n throw new Error(`Your ${typeName} has a length of ${inputLen}. The converter requires a length of ${setLen}.`);\n } else {\n const charAmounts = {};\n _charset = [..._charset];\n _charset.forEach(c => {\n if (c in charAmounts) {\n charAmounts[c]++;\n } else {\n charAmounts[c] = 1;\n }\n })\n \n let infoStr = \"\";\n if (setLen < 100) {\n infoStr = `${_charset.join(\"\")}\\n`;\n _charset.forEach(c => {\n if (charAmounts[c] > 1) {\n infoStr += \"^\";\n } else {\n infoStr += \" \";\n }\n });\n }\n const rChars = Object.keys(charAmounts).filter(c => charAmounts[c] > 1);\n throw new Error(`You have repetitive char(s) [ ${rChars.join(\" | \")} ] in your ${typeName}. Make sure each character is unique.\\n${infoStr}`);\n }\n }\n\n if (this.root.frozenCharsets) {\n throw new Error(\"The charsets of this converter cannot be changed.\");\n }\n\n if (typeof name !== \"string\") {\n throw new TypeError(\"The charset name must be a string.\");\n }\n\n if (info && name in this.root.charsets) {\n console.warn(`An existing charset with name ${name} will get replaced.`);\n }\n\n const charset = normalize(\"charset\", _charset, this.root.converter.radix);\n const padChars = normalize(\"padding set\", _padChars, this.root.padCharAmount);\n\n this.root.charsets[name] = charset;\n if (padChars.length) {\n this.root.padChars[name] = padChars\n }\n\n if (info) {\n console.info(`New charset '${name}' was added and is ready to use`);\n }\n }\n\n // Save method (argument gets validated) to \n // change the default version.\n this.root.setDefaultCharset = (version) => {\n if (!(version in this.root.charsets)) {\n const sets = Object.keys(this.root.charsets).join(\"\\n * \");\n const msg = `Charset ${version} was not found. Available charsets are:\\n * ${sets}`;\n throw new TypeError(msg);\n }\n this.root.version = version;\n }\n }\n\n /**\n * Argument lists for error messages.\n * @param {string[]} args \n * @returns string - Arguments joined as a string. \n */\n #makeArgList(args) {\n return args.map(s => `'${s}'`).join(\", \");\n }\n\n /**\n * Removes all padded zeros a the start of the string,\n * adds a \"-\" if value is negative.\n * @param {string} output - Former output.\n * @param {boolean} negative - Indicates a negative value if true.\n * @returns {string} - Output without zero padding and a sign if negative.\n */\n toSignedStr(output, negative) {\n\n output = output.replace(/^0+(?!$)/, \"\");\n\n if (negative) {\n output = \"-\".concat(output);\n }\n\n return output;\n }\n\n /**\n * Analyzes the input for a negative sign.\n * If a sign is found, it gets removed but\n * negative bool gets true;\n * @param {string} input - Input number as a string. \n * @returns {array} - Number without sign and negativity indication bool.\n */\n extractSign(input) {\n let negative = false;\n if (input[0] === \"-\") {\n negative = true;\n input = input.slice(1);\n }\n\n return [input, negative];\n }\n\n /**\n * All possible error messages for invalid arguments,\n * gets adjusted according to the converter settings.\n * @param {string} arg - Argument. \n * @param {string[]} versions - Charset array. \n * @param {string[]} outputTypes - Array of output types. \n * @param {boolean} initial - Indicates if the arguments where passed during construction. \n */\n #invalidArgument(arg, versions, outputTypes, initial) {\n const loopConverterArgs = () => Object.keys(this.converterArgs).map(\n key => this.converterArgs[key].map(\n keyword => `'${keyword}'`\n )\n .join(\" and \")\n )\n .join(\"\\n - \");\n \n throw new TypeError([\n `'${arg}'\\n\\nParameters:`,\n initial ? \"\\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'\" : \"\",\n this.root.isMutable.signed ? \"\\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers\" : \"\",\n this.root.isMutable.littleEndian ? \"\\n * 'be' for big , 'le' for little endian byte order for case conversion\" : \"\",\n this.root.isMutable.padding ? \"\\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding\" : \"\",\n this.root.isMutable.upper ? \"\\n * valid args for changing the encoded output case are 'upper' and 'lower'\" : \"\",\n `\\n * valid args for the output type are ${this.#makeArgList(outputTypes)}`,\n versions ? `\\n * the option(s) for version/charset are: ${this.#makeArgList(versions)}` : \"\",\n \"\\n * valid args for integrity check are: 'integrity' and 'nointegrity'\",\n this.root.hasDecimalMode ? \"\\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)\" : \"\",\n \"\\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)\",\n Object.keys(this.converterArgs).length ? `\\n * converter specific args:\\n - ${loopConverterArgs()}` : \"\",\n \"\\n\\nTraceback:\"\n ].join(\"\"));\n }\n\n\n /**\n * Test if provided arguments are in the argument list.\n * Everything gets converted to lowercase and returned.\n * @param {string[]} args - Passed arguments. \n * @param {boolean} initial - Indicates if the arguments where passed during construction. \n * @returns {Object} - Converter settings object.\n */\n validateArgs(args, initial=false) {\n \n // default settings\n const parameters = {\n decimalMode: this.root.decimalMode,\n integrity: this.root.integrity,\n littleEndian: this.root.littleEndian,\n numberMode: this.root.numberMode,\n options: this.root.options,\n outputType: this.root.outputType,\n padding: this.root.padding,\n signed: this.root.signed,\n upper: this.root.upper,\n version: this.root.version\n }\n\n // add any existing converter specific args\n for (const param in this.converterArgs) {\n parameters[param] = this.root[param];\n }\n\n // if no args are provided return the default settings immediately\n if (!args.length) {\n\n // if initial call set default IO handlers\n if (initial) {\n this.setIOHandlers();\n }\n \n return parameters;\n }\n\n // Helper function to test the presence of a \n // particular arg. If found, true is returned\n // and it gets removed from the array.\n const extractArg = (arg) => {\n if (args.includes(arg)) {\n args.splice(args.indexOf(arg), 1);\n return true;\n }\n return false;\n }\n\n // set available versions and extra arguments\n const versions = Object.keys(this.root.charsets);\n const extraArgList = {\n integrity: [\"nointegrity\", \"integrity\"],\n littleEndian: [\"be\", \"le\"],\n padding: [\"nopad\", \"pad\"],\n signed: [\"unsigned\", \"signed\"],\n upper: [\"lower\", \"upper\"],\n ...this.converterArgs\n }\n\n // if initial, look for IO specifications\n if (initial) {\n if (extractArg(\"bytes_only\")) {\n this.setIOHandlers(BytesInput, BytesOutput);\n } else {\n const inHandler = (extractArg(\"bytes_in\")) ? BytesInput : DEFAULT_INPUT_HANDLER;\n const outHandler = (extractArg(\"bytes_out\")) ? BytesOutput : DEFAULT_OUTPUT_HANDLER;\n this.setIOHandlers(inHandler, outHandler);\n }\n }\n\n // set valid output types\n const outputTypes = this.outputHandler.typeList;\n\n // test for special \"number\" keyword\n if (extractArg(\"number\")) {\n parameters.numberMode = true;\n parameters.outputType = \"float_n\";\n } \n \n // test for the special \"decimal\" keyword\n if (extractArg(\"decimal\")) {\n if (!this.root.hasDecimalMode) {\n throw TypeError(`Argument 'decimal' is only allowed for converters with a non-integer base.`);\n }\n parameters.decimalMode = true;\n parameters.outputType = \"decimal\";\n\n if (parameters.numberMode) {\n parameters.numberMode = false;\n console.warn(\"-> number-mode was disabled due to the decimal-mode\");\n }\n }\n\n // walk through the remaining arguments\n args.forEach((arg) => {\n \n // additional/optional non boolean options\n if (typeof arg === \"object\") {\n parameters.options = {...parameters.options, ...arg};\n return;\n }\n\n arg = String(arg).toLowerCase();\n\n if (versions.includes(arg)) {\n parameters.version = arg;\n } else if (outputTypes.includes(arg)) {\n parameters.outputType = arg;\n } else {\n // set invalid args to true for starters\n // if a valid arg is found later it will\n // get changed\n\n let invalidArg = true;\n\n // walk through the mutable parameter list\n\n for (const param in extraArgList) {\n \n if (extraArgList[param].includes(arg)) {\n \n invalidArg = false;\n\n // extra params always have two options\n // they are converted into booleans \n // index 0 > false\n // index 1 > true\n\n if (this.root.isMutable[param]) {\n parameters[param] = Boolean(extraArgList[param].indexOf(arg));\n } else {\n throw TypeError(`Argument '${arg}' is not allowed for this type of converter.`);\n }\n }\n }\n\n if (invalidArg) {\n this.#invalidArgument(arg, versions, outputTypes, initial);\n }\n }\n });\n\n // If padding and signed are true, padding\n // is set to false and a warning is getting\n // displayed.\n if (parameters.padding && parameters.signed) {\n parameters.padding = false;\n console.warn(\"-> padding was set to false due to the signed conversion\");\n }\n \n // overwrite the default parameters for the initial call\n if (initial) {\n for (const param in parameters) {\n this.root[param] = parameters[param];\n }\n }\n\n return parameters;\n }\n\n /**\n * A TypeError specifically for sign errors.\n */\n signError() {\n throw new SignError();\n }\n\n /**\n * Wrap output to \"cols\" characters per line.\n * @param {string} output - Output string. \n * @param {number} cols - Number of cols per line. \n * @returns {string} - Wrapped output.\n */\n wrapOutput(output, cols=0) {\n if (!cols) {\n return output;\n }\n const m = new RegExp(`.{1,${cols}}`, \"gu\");\n return output.match(m).join(\"\\n\");\n }\n\n /**\n * Ensures a string input.\n * @param {*} input - Input.\n * @param {boolean} [keepWS=false] - If set to false, whitespace is getting removed from the input if present.\n * @returns {string} - Normalized input.\n */\n normalizeInput(input, keepWS=false) {\n if (keepWS) {\n return String(input);\n }\n return String(input).replace(/\\s/g, \"\");\n }\n\n}\n\nexport {\n DEFAULT_INPUT_HANDLER,\n DEFAULT_OUTPUT_HANDLER,\n DecodingError,\n Utils\n};\n","import { DecodingError, Utils } from \"./utils.js\";\n\n\n/**\n * BaseEx Base Converter.\n * ---------------------\n * Core class for base-conversion and substitution\n * based on a given charset.\n */\nclass BaseConverter {\n\n /**\n * BaseEx BaseConverter Constructor.\n * @param {number} radix - Radix for the converter.\n * @param {number} [bsEnc] - Block Size (input bytes grouped by bs) for encoding (if zero the integer has no limitation).\n * @param {number} [bsDec] - Block Size (input bytes grouped by bs) for decoding (if zero the integer has no limitation).\n * @param {number} [decPadVal=0] - Value used for padding during decoding.\n */\n constructor(radix, bsEnc=null, bsDec=null, decPadVal=0) {\n \n this.radix = radix;\n\n if (bsEnc !== null && bsDec !== null) {\n this.bsEnc = bsEnc;\n this.bsDec = bsDec;\n } else {\n [this.bsEnc, this.bsDec] = this.constructor.guessBS(radix);\n }\n\n this.decPadVal = decPadVal;\n this.powers = {};\n }\n\n /**\n * Experimental feature!\n * Calc how many bits are needed to represent\n * 256 conditions (1 byte). If the radix is \n * less than 8 bits, skip that part and use\n * the radix value directly.\n */\n static guessBS(radix) {\n\n let bsDecPre = (radix < 8) ? radix : Math.ceil(256 / radix);\n \n // If the result is a multiple of 8 it\n // is appropriate to reduce the result\n\n while (bsDecPre > 8 && !(bsDecPre % 8)) {\n bsDecPre /= 8;\n }\n\n // Search for the amount of bytes, which are necessary\n // to represent the assumed amount of bytes. If the result\n // is equal or bigger than the assumption for decoding, the\n // amount of bytes for encoding is found. \n\n let bsEnc = 0;\n while (((bsEnc * 8) * Math.log(2) / Math.log(radix)) < bsDecPre) {\n bsEnc++;\n }\n\n // The result for decoding can now get calculated accurately.\n const bsDec = Math.ceil((bsEnc * 8) * Math.log(2) / Math.log(radix));\n\n return [bsEnc, bsDec];\n }\n\n\n /**\n * BaseEx Universal Base Encoding.\n * @param {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} inputBytes - Input as Uint8Array.\n * @param {string} charset - The charset used for conversion.\n * @param {boolean} littleEndian - Byte order, little endian bool.\n * @param {function} replacer - Replacer function can replace groups of characters during encoding.\n * @returns {number[]} - Output string and padding amount. \n */\n encode(inputBytes, charset, littleEndian=false, replacer=null) {\n\n // Initialize output string and set yet unknown\n // zero padding to zero.\n let bs = this.bsEnc;\n if (bs === 0) {\n bs = inputBytes.byteLength;\n }\n\n let output = \"\";\n\n const zeroPadding = (bs) ? (bs - inputBytes.length % bs) % bs : 0;\n const zeroArray = new Array(zeroPadding).fill(0);\n let byteArray;\n \n if (littleEndian) {\n \n // as the following loop walks through the array\n // from left to right, the input bytes get reversed\n // to favor the least significant first\n\n inputBytes.reverse();\n byteArray = [...zeroArray, ...inputBytes];\n } else {\n byteArray = [...inputBytes, ...zeroArray];\n }\n \n // Iterate over the input array in groups with the length\n // of the given blocksize.\n\n // If the radix is 10, make a shortcut here by converting\n // all bytes into the decimal number \"n\" and return the\n // result as a string.\n if (this.radix === 10) {\n let n = 0n;\n \n for (let i=0; i= this.radix) {\n [q, r] = this.divmod(q, this.radix);\n bXarray.unshift(parseInt(r, 10));\n }\n\n // Append the remaining quotient to the array\n bXarray.unshift(parseInt(q, 10));\n\n // If the length of the array is less than the\n // given output bs, it gets filled up with zeros.\n // (This happens in groups of null bytes)\n \n while (bXarray.length < this.bsDec) {\n bXarray.unshift(0);\n }\n\n // Each digit is used as an index to pick a \n // corresponding char from the charset. The \n // chars get concatenated and stored in \"frame\".\n\n let frame = \"\";\n bXarray.forEach(\n charIndex => frame = frame.concat(charset[charIndex])\n );\n\n // Ascii85 is replacing four consecutive \"!\" into \"z\"\n // Also other replacements can be implemented and used\n // at this point.\n if (replacer) {\n frame = replacer(frame, zeroPadding);\n }\n\n output = output.concat(frame);\n }\n\n // The output string is returned. Also the amount \n // of padded zeros. The specific class decides how \n // to handle the padding.\n\n return [output, zeroPadding];\n }\n\n\n /**\n * BaseEx Universal Base Decoding.\n * Decodes to a string of the given radix to a byte array.\n * @param {string} inputBaseStr - Base as string (will also get converted to string but can only be used if valid after that).\n * @param {string[]} charset - The charset used for conversion.\n * @param {string[]} padSet - Padding characters for integrity check.\n * @param {boolean} integrity - If set to false invalid character will be ignored.\n * @param {boolean} littleEndian - Byte order, little endian bool.\n * @returns {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} - The decoded output as Uint8Array.\n */\n decode(inputBaseStr, charset, padSet=[], integrity=true, littleEndian=false) {\n\n // Convert each char of the input to the radix-integer\n // (this becomes the corresponding index of the char\n // from the charset). Every char, that is not found in\n // in the set is getting ignored.\n\n if (!inputBaseStr) {\n return new Uint8Array(0);\n }\n\n let bs = this.bsDec;\n const byteArray = [];\n\n const toObj = arr => {\n const obj = {};\n arr.forEach((v, i) => obj[v] = i);\n return obj;\n }\n const charsetLookup = toObj(charset);\n\n [...inputBaseStr].forEach(c => {\n const index = charsetLookup[c];\n if (typeof index !== \"undefined\") { \n byteArray.push(index);\n } else if (integrity && padSet.indexOf(c) === -1) {\n throw new DecodingError(c);\n }\n });\n\n let padChars;\n\n if (bs === 0) {\n bs = byteArray.length;\n } else {\n padChars = (bs - byteArray.length % bs) % bs;\n const fillArray = new Array(padChars).fill(this.decPadVal);\n if (littleEndian) {\n byteArray.unshift(...fillArray);\n } else {\n byteArray.push(...fillArray);\n }\n }\n\n // Initialize a new default array to store\n // the converted radix-256 integers.\n\n let b256Array = new Array();\n\n // Iterate over the input bytes in groups of \n // the blocksize.\n\n for (let i=0, l=byteArray.length; i {\n this.powers[exp] = BigInt(this.pow(exp));\n return this.powers[exp];\n })();\n\n n += BigInt(byteArray[i+j]) * pow;\n }\n \n // To store the output chunks, initialize a\n // new default array.\n const subArray256 = [];\n\n // The subarray gets converted into a bs*8-bit \n // binary number \"n\", most significant byte \n // first (big endian).\n\n // Initialize quotient and remainder for base conversion\n let q = n, r;\n\n // Divide n until the quotient is less than 256.\n while (q >= 256) {\n [q, r] = this.divmod(q, 256);\n subArray256.unshift(parseInt(r, 10));\n }\n\n // Append the remaining quotient to the array\n subArray256.unshift(parseInt(q, 10));\n \n // If the length of the array is less than the required\n // bs after decoding it gets filled up with zeros.\n // (Again, this happens with null bytes.)\n\n while (subArray256.length < this.bsEnc) {\n subArray256.unshift(0);\n }\n \n // The subarray gets concatenated with the\n // main array.\n b256Array.push(...subArray256);\n }\n\n // Remove padded zeros (or in case of LE all leading zeros)\n\n if (littleEndian) {\n if (b256Array.length > 1) {\n \n // remove all zeros from the start of the array\n while (!b256Array[0]) {\n b256Array.shift(); \n }\n \n if (!b256Array.length) {\n b256Array.push(0);\n }\n\n b256Array.reverse();\n }\n } else if (this.bsDec) {\n const padding = this.padChars(padChars);\n\n // remove all bytes according to the padding\n b256Array.splice(b256Array.length-padding);\n }\n\n return Uint8Array.from(b256Array);\n }\n\n\n /**\n * Calculates the amount of bytes, which are padding bytes. \n * @param {number} charCount - Pass the amount of characters, which were added during encoding. \n * @returns {number} - Amount of padding characters.\n */\n padBytes(charCount) {\n return Math.floor((charCount * this.bsDec) / this.bsEnc);\n }\n\n /**\n * Calculates the amount of bytes which can get removed\n * from the decoded output bytes. \n * @param {number} byteCount - Added bytes for padding \n * @returns {number} - Amount of output bytes to be removed.\n */\n padChars(byteCount) {\n return Math.ceil((byteCount * this.bsEnc) / this.bsDec);\n }\n\n\n /**\n * Calculates the power for the current base\n * according to the given position as BigInt.\n * \n * @param {number} n - Position \n * @returns {BigInt} - BigInt power value\n */\n pow(n) {\n return BigInt(this.radix)**BigInt(n);\n }\n\n\n /**\n * Divmod function, which returns the results as\n * an array of two BigInts.\n * @param {*} x - Dividend\n * @param {*} y - Divisor\n * @returns {number[]} - [Quotient, Remainder]\n */\n divmod(x, y) {\n [x, y] = [BigInt(x), BigInt(y)];\n return [(x / y), (x % y)];\n }\n}\n\n\n/**\n * Base of every BaseConverter. Provides basic\n * en- and decoding, makes sure, that every \n * property is set (to false by default).\n * Also allows global feature additions.\n * \n * Requires BaseEx Utils\n */\nclass BaseTemplate {\n\n /**\n * BaseEx BaseTemplate Constructor.\n * @param {boolean} appendUtils - If set to false, the utils are not getting used. \n */\n constructor(appendUtils=true) {\n\n // predefined settings\n this.charsets = {};\n this.decimalMode = false;\n this.frozenCharsets = false;\n this.hasDecimalMode = false;\n this.hasSignedMode = false;\n this.integrity = true;\n this.littleEndian = false;\n this.numberMode = false;\n this.outputType = \"buffer\";\n this.padding = false;\n this.padCharAmount = 0;\n this.padChars = {} \n this.signed = false;\n this.upper = null;\n if (appendUtils) this.utils = new Utils(this);\n this.version = \"default\";\n this.options = {\n lineWrap: 0\n }\n \n // list of allowed/disallowed args to change\n this.isMutable = {\n integrity: true,\n littleEndian: false,\n padding: false,\n signed: false,\n upper: false,\n };\n }\n\n /**\n * BaseEx Generic Encoder.\n * @param {*} input - Any input the used byte converter allows.\n * @param {function} [replacerFN] - Replacer function, which is passed to the encoder. \n * @param {function} [postEncodeFN] - Function, which is executed after encoding.\n * @param {...any} args - Converter settings.\n * @returns {string} - Base encoded string.\n */\n encode(input, replacerFN, postEncodeFN, ...args) {\n\n // apply settings\n const settings = this.utils.validateArgs(args);\n \n // handle input\n let [inputBytes, negative, type] = this.utils.inputHandler.toBytes(input, settings);\n\n // generate replacer function if given\n let replacer = null;\n if (replacerFN) {\n replacer = replacerFN(settings);\n }\n \n // Convert to base string\n let [output, zeroPadding] = this.converter.encode(inputBytes, this.charsets[settings.version], settings.littleEndian, replacer);\n\n // set sign if requested\n if (settings.signed) {\n output = this.utils.toSignedStr(output, negative);\n }\n\n // set upper case if requested\n if (settings.upper) {\n output = output.toUpperCase();\n }\n\n // modify the output based on a given function (optionally)\n if (postEncodeFN) {\n output = postEncodeFN({ inputBytes, output, settings, zeroPadding, type });\n }\n\n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n\n /**\n * BaseEx Generic Decoder.\n * @param {string} input - Base String.\n * @param {function} [preDecodeFN] - Function, which gets executed before decoding. \n * @param {function} [postDecodeFN] - Function, which gets executed after decoding\n * @param {...any} args - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, preDecodeFN, postDecodeFN, keepNL, ...args) {\n \n // apply settings\n const settings = this.utils.validateArgs(args);\n\n // ensure a string input\n input = this.utils.normalizeInput(input, keepNL);\n\n // set negative to false for starters\n let negative = false;\n \n // Test for a negative sign if converter supports it\n if (this.hasSignedMode) {\n [ input, negative ] = this.utils.extractSign(input); \n \n // But don't allow a sign if the decoder is not configured to use it\n if (negative && !settings.signed) {\n this.utils.signError();\n }\n }\n\n // Make the input lower case if alphabet has only one case\n // (single case alphabets are stored as lower case strings)\n if (this.isMutable.upper) {\n input = input.toLowerCase();\n }\n\n // Run pre decode function if provided\n if (preDecodeFN) {\n input = preDecodeFN({ input, settings });\n }\n\n // Run the decoder\n let output = this.converter.decode(\n input,\n this.charsets[settings.version],\n this.padChars[settings.version],\n settings.integrity,\n settings.littleEndian\n );\n\n // Run post decode function if provided\n if (postDecodeFN) {\n output = postDecodeFN({ input, output, settings });\n }\n\n return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative);\n }\n}\n\n\nexport { BaseConverter, BaseTemplate };\n","/**\n * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 1 Converter.\n * -----------------------\n * This is a unary/base1 converter. It is converting input \n * to a decimal number, which is converted into an unary\n * string. Due to the limitations on string (or array) length\n * it is only suitable for the conversions of numbers up to\n * roughly 2^28.\n */\nexport default class Base1 extends BaseTemplate {\n \n /**\n * BaseEx Base1 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // All chars in the string are used and picked randomly (prob. suitable for obfuscation)\n this.charsets.all = [...\" !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\"];\n \n // The sequence is used from left to right again and again\n this.charsets.sequence = [...\"Hello World!\"];\n \n // Standard unary string with one character\n this.charsets.default = [\"1\"];\n\n // Telly Mark string, using hash for 5 and vertical bar for 1 \n this.charsets.tmark = [\"|\", \"#\"];\n\n // Base 10 converter\n this.converter = new BaseConverter(10, 0, 0);\n \n // converter settings\n this.hasSignedMode = true;\n this.littleEndian = true;\n this.signed = true;\n \n // mutable extra args\n this.isMutable.charsets = false;\n this.isMutable.signed = true;\n this.isMutable.upper = true;\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx Base1 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base1 encoded string.\n */\n encode(input, ...args) {\n\n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n \n let inputBytes, negative;\n [inputBytes, negative,] = this.utils.inputHandler.toBytes(input, settings);\n\n // Convert to BaseRadix string\n let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0];\n \n let n = BigInt(base10);\n\n // Limit the input before it even starts.\n // The executing engine will most likely\n // give up much earlier.\n // (2**29-24 during tests)\n\n if (n > Number.MAX_SAFE_INTEGER) {\n throw new RangeError(\"Invalid string length.\");\n } else if (n > 16777216) {\n console.warn(\"The string length is really long. The JavaScript engine may have memory issues generating the output string.\");\n }\n \n n = Number(n);\n \n const charset = this.charsets[settings.version];\n const charAmount = charset.length;\n let output = \"\";\n\n // Convert to unary in respect to the version differences\n if (charAmount === 1) {\n output = charset.at(0).repeat(n)\n } else if (settings.version === \"all\") {\n for (let i=0; i 4) {\n output = charset.at(1).repeat((n - singulars) / 5);\n }\n output += charset.at(0).repeat(singulars);\n } else {\n for (let i=0; i {\n \n // Remove \"0x\" if present\n normInput = normInput.replace(/^0x/, \"\");\n\n // remove non-charset characters if integrity\n // check is disabled\n if (!settings.integrity) {\n normInput = normInput\n .toLowerCase()\n .replace(/[^0-9a-f]/g, \"\");\n }\n\n // Ensure even number of characters\n if (normInput.length % 2) {\n normInput = \"0\".concat(normInput);\n }\n\n return normInput;\n }\n \n return super.decode(input, normalizeInput, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 32 Converter.\n * ------------------------\n * \n * This is a base32 converter. Various input can be \n * converted to a base32 string or a base32 string\n * can be decoded into various formats. It is possible\n * to convert in both signed and unsigned mode in little\n * and big endian byte order.\n * \n * Available charsets are:\n * - RFC 3548\n * - RFC 4648\n * - crockford\n * - zbase32\n */\nexport default class Base32 extends BaseTemplate {\n \n /**\n * BaseEx Base32 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(32, 5, 8);\n\n // charsets\n this.charsets.crockford = [ ...\"0123456789abcdefghjkmnpqrstvwxyz\" ];\n this.padChars.crockford = [\"=\"],\n\n this.charsets.rfc3548 = [...\"abcdefghijklmnopqrstuvwxyz234567\"];\n this.padChars.rfc3548 = [\"=\"];\n\n this.charsets.rfc4648 = [...\"0123456789abcdefghijklmnopqrstuv\"];\n this.padChars.rfc4648 = [\"=\"];\n\n this.charsets.zbase32 = [...\"ybndrfg8ejkmcpqxot1uwisza345h769\"];\n this.padChars.zbase32 = [\"=\"];\n \n // predefined settings\n this.padCharAmount = 1;\n this.hasSignedMode = true;\n this.version = \"rfc4648\";\n \n // mutable extra args\n this.isMutable.littleEndian = true;\n this.isMutable.padding = true;\n this.isMutable.signed = true;\n this.isMutable.upper = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n this.padding = (/rfc3548|rfc4648/).test(this.version);\n this.upper = this.version === \"crockford\";\n }\n \n\n /**\n * BaseEx Base32 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base32 encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n if (!settings.littleEndian) {\n // Cut of redundant chars and append padding if set\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n const padChar = this.padChars[settings.version].at(0);\n output = output.slice(0, -padValue);\n if (settings.padding) { \n output = output.concat(padChar.repeat(padValue));\n }\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base32 Decoder.\n * @param {string} input - Base32 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n return super.decode(input, null, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 58 Converter.\n * ------------------------\n * \n * This is a base58 converter. Various input can be \n * converted to a base58 string or a base58 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - bitcoin\n * - flickr\n */\nexport default class Base58 extends BaseTemplate{\n\n /**\n * BaseEx Base58 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(58, 0, 0);\n\n // charsets\n this.charsets.default = [...\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"];\n Object.defineProperty(this.padChars, \"default\", {\n get: () => [ this.charsets.default.at(0) ]\n });\n\n this.charsets.bitcoin = [...\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\"];\n Object.defineProperty(this.padChars, \"bitcoin\", {\n get: () => [ this.charsets.bitcoin.at(0) ]\n });\n \n this.charsets.flickr = [...\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"];\n Object.defineProperty(this.padChars, \"flickr\", {\n get: () => [ this.charsets.flickr.at(0) ]\n });\n \n\n // predefined settings\n this.padding = true;\n this.version = \"bitcoin\";\n \n // mutable extra args\n this.isMutable.padding = true;\n this.isMutable.signed = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n \n /**\n * BaseEx Base58 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base58 encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ inputBytes, output, settings, type }) => {\n\n if (settings.padding && type !== \"int\") { \n \n // Count all null bytes at the start of the array\n // stop if a byte with a value is reached. If it goes\n // all the way through it, reset index and stop.\n let i = 0;\n const end = inputBytes.length;\n\n // pad char is always! the first char in the set\n const padChar = this.charsets[settings.version].at(0);\n\n // only proceed if input has a length at all\n if (end) {\n while (!inputBytes[i]) {\n i++;\n if (i === end) {\n i = 0;\n break;\n }\n }\n\n // The value for zero padding is the index of the\n // first byte with a value plus one.\n const zeroPadding = i;\n\n // Set a one for every leading null byte\n if (zeroPadding) {\n output = (padChar.repeat(zeroPadding)).concat(output);\n }\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base58 Decoder.\n * @param {string} input - Base58 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // post decoding function\n const applyPadding = ({ input, output, settings }) => {\n\n // pad char is always! the first char in the set\n const padChar = this.charsets[settings.version].at(0);\n\n if (settings.padding && input.length > 1) {\n \n // Count leading padding (char should be 1)\n let i = 0;\n while (input[i] === padChar) {\n i++;\n }\n \n // The counter becomes the zero padding value\n const zeroPadding = i;\n \n // Create a new Uint8Array with leading null bytes \n // with the amount of zeroPadding\n if (zeroPadding) {\n output = Uint8Array.from([...new Array(zeroPadding).fill(0), ...output]);\n }\n \n }\n\n return output;\n }\n\n return super.decode(input, null, applyPadding, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 64 Converter.\n * ------------------------\n * \n * This is a base64 converter. Various input can be \n * converted to a base64 string or a base64 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - urlsafe\n */\nexport default class Base64 extends BaseTemplate {\n\n /**this.padChars.\n * BaseEx Base64 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(64, 3, 4);\n\n // charsets\n this.charsets.default = [...\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"];\n this.padChars.default = [\"=\"];\n \n this.charsets.urlsafe = this.charsets.default.slice(0, -2).concat([\"-\", \"_\"]);\n this.padChars.urlsafe = [\"=\"];\n\n\n // predefined settings\n this.padCharAmount = 1;\n this.padding = true;\n \n // mutable extra args\n this.isMutable.padding = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Base64 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base64 encoded string.\n */\n encode(input, ...args) {\n \n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n // Cut of redundant chars and append padding if set\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n const padChar = this.padChars[settings.version].at(0);\n output = output.slice(0, -padValue);\n if (settings.padding) { \n output = output.concat(padChar.repeat(padValue));\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base64 Decoder.\n * @param {string} input - Base64 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n return super.decode(input, null, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx UUencode Converter.\n * ------------------------\n * \n * This is a UUencoder/UUdecoder. Various input can be \n * converted to a UUencoded string or a UUencoded string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - original\n * - xx\n */\nexport default class UUencode extends BaseTemplate {\n\n /**\n * BaseEx UUencode Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(64, 3, 4);\n\n // charsets\n this.charsets.default = [...\"`!\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_\"];\n Object.defineProperty(this.padChars, \"default\", {\n get: () => [ this.charsets.default.at(0) ]\n });\n\n this.charsets.original = [\" \", ...this.charsets.default.slice(1)];\n Object.defineProperty(this.padChars, \"original\", {\n get: () => [ this.charsets.original.at(0) ]\n });\n\n this.charsets.xx = [...\"+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"];\n Object.defineProperty(this.padChars, \"xx\", {\n get: () => [ this.charsets.xx.at(0) ]\n });\n\n\n // predefined settings\n this.padding = true;\n this.header = false;\n this.utils.converterArgs.header = [\"noheader\", \"header\"];\n this.isMutable.header = true;\n this.isMutable.integrity = false;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx UUencoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - UUencode string.\n */\n encode(input, ...args) {\n\n const format = ({ output, settings, zeroPadding }) => {\n\n const charset = this.charsets[settings.version];\n const outArray = [...output];\n \n \n if (settings.header) {\n const permissions = settings.options.permissions || een();\n const fileName = settings.options.file || ees();\n output = `begin ${permissions} ${fileName}\\n`;\n } else {\n output = \"\";\n }\n\n // repeatedly take 60 chars from the output until it is empty \n for (;;) {\n const lArray = outArray.splice(0, 60);\n \n // if all chars are taken, remove eventually added pad zeros\n if (!outArray.length) { \n const byteCount = this.converter.padChars(lArray.length) - zeroPadding;\n \n // add the the current chars plus the leading\n // count char\n output += `${charset.at(byteCount)}${lArray.join(\"\")}\\n`;\n break;\n }\n \n // add the the current chars plus the leading\n // count char (\"M\" for default charsets) \n output += `${charset.at(45)}${lArray.join(\"\")}\\n`;\n }\n\n output += `${charset.at(0)}\\n`;\n\n if (settings.header) {\n output += \"\\nend\";\n }\n\n\n return output;\n }\n \n return super.encode(input, null, format, ...args);\n }\n\n\n /**\n * BaseEx UUdecoder.\n * @param {string} input - UUencode String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n let padChars = 0;\n\n const format = ({ input, settings }) => {\n\n const charset = this.charsets[settings.version];\n const lines = input.trim().split(/\\r?\\n/);\n const inArray = [];\n \n if ((/^begin/i).test(lines.at(0))) {\n lines.shift();\n }\n \n for (const line of lines) {\n const lArray = [...line];\n const byteCount = charset.indexOf(lArray.shift());\n \n if (!(byteCount > 0)) {\n break;\n }\n\n inArray.push(...lArray);\n\n if (byteCount !== 45) { \n padChars = this.converter.padChars(lArray.length) - byteCount;\n break;\n }\n\n // fix probably missing spaces for original charset\n else if (lArray.length !== 60 && settings.version === \"original\") {\n while (inArray.length % 60) {\n inArray.push(\" \");\n }\n }\n }\n\n return inArray.join(\"\");\n\n }\n\n const removePadChars = ({ output }) => {\n if (padChars) {\n output = new Uint8Array(output.slice(0, -padChars));\n }\n return output;\n }\n\n return super.decode(input, format, removePadChars, true, ...args);\n }\n}\n\n\nconst een = () => {\n const o = () => Math.floor(Math.random() * 8);\n return `${o()}${o()}${o()}`;\n}\n\nconst ees = () => {\n const name = [\n \"unchronological\",\n \"unconditionally\",\n \"underemphasized\",\n \"underprivileged\",\n \"undistinguished\",\n \"unsophisticated\",\n \"untitled\",\n \"untitled-1\",\n \"untitled-3\",\n \"uuencode\"\n ];\n\n const ext = [\n \"applescript\",\n \"bat\",\n \"beam\",\n \"bin\",\n \"exe\",\n \"js\",\n \"mam\",\n \"py\",\n \"sh\",\n \"vdo\",\n \"wiz\"\n ];\n\n const pick = (arr) => arr.at(Math.floor(Math.random() * arr.length));\n\n return `${pick(name)}.${pick(ext)}`;\n};\n","/**\n * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 85 Converter.\n * ------------------------\n * \n * This is a base85 converter. Various input can be \n * converted to a base85 string or a base85 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - adobe\n * - ascii85\n * - rfc1924\n * - z85\n * \n * Adobe and ascii85 are the basically the same.\n * Adobe will produce the same output, apart from\n * the <~wrapping~>.\n * \n * Z85 is an important variant, because of the \n * more interpreter-friendly character set.\n * \n * The RFC 1924 version is a hybrid. It is not using\n * the mandatory 128 bit calculation. Instead only \n * the charset is getting used.\n */\nexport default class Base85 extends BaseTemplate {\n\n /**\n * BaseEx Base85 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(85, 4, 5, 84);\n\n // charsets\n this.charsets.adobe = [...\"!\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstu\"];\n this.charsets.ascii85 = this.charsets.adobe.slice();\n this.charsets.rfc1924 = [...\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~\"];\n this.charsets.z85 = [...\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#\"];\n\n // predefined settings\n this.version = \"ascii85\";\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx Base85 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base85 encoded string.\n */\n encode(input, ...args) {\n\n // Replace five consecutive \"!\" with a \"z\"\n // for adobe and ascii85\n const replacerFN = (settings) => {\n let replacer;\n if (settings.version.match(/adobe|ascii85/)) {\n replacer = (frame, zPad) => (!zPad && frame === \"!!!!!\") ? \"z\" : frame;\n }\n return replacer;\n }\n \n // Remove padded values and add a frame for the\n // adobe variant\n const framesAndPadding = ({ output, settings, zeroPadding }) => {\n\n // Cut of redundant chars\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n output = output.slice(0, -padValue);\n }\n\n // Adobes variant gets its <~framing~>\n if (settings.version === \"adobe\") {\n output = `<~${output}~>`;\n }\n \n return output;\n }\n\n return super.encode(input, replacerFN, framesAndPadding, ...args);\n }\n\n\n /**\n * BaseEx Base85 Decoder.\n * @param {string} input - Base85 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n const prepareInput = ({ input, settings }) => {\n\n // For default ascii85 convert \"z\" back to \"!!!!!\"\n // Remove the adobe <~frame~>\n if (settings.version.match(/adobe|ascii85/)) {\n input = input.replace(/z/g, \"!!!!!\");\n if (settings.version === \"adobe\") {\n input = input.replace(/^<~|~>$/g, \"\");\n }\n }\n\n return input\n }\n\n return super.decode(input, prepareInput, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke)\n */\n\nimport { BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base 91 Converter.\n * ------------------------\n * \n * This is a base91 converter. Various input can be \n * converted to a base91 string or a base91 string\n * can be decoded into various formats.\n * \n * It is an implementation of Joachim Henkes method\n * to encode binary data as ASCII characters -> basE91\n * http://base91.sourceforge.net/\n * \n * As this method requires to split the bytes, the\n * default conversion class \"BaseConverter\" is not\n * getting used in this case.\n */\nexport default class Base91 extends BaseTemplate {\n \n /**\n * BaseEx basE91 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 91,\n bsEnc: 0,\n bsDec: 0\n }\n\n // charsets\n this.charsets.default = [...\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~\\\"\"];\n this.version = \"default\";\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx basE91 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - basE91 encoded string.\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n const inputBytes = this.utils.inputHandler.toBytes(input, settings)[0];\n \n // As this base representation splits the bytes\n // the read bits need to be stores somewhere. \n // This is done in \"bitCount\". \"n\", similar to \n // other solutions here, holds the integer which\n // is converted to the desired base.\n\n let bitCount = 0;\n let n = 0;\n let output = \"\";\n\n const charset = this.charsets[settings.version];\n\n inputBytes.forEach(byte => {\n //n = n + byte * 2^bitcount;\n n += (byte << bitCount);\n\n // Add 8 bits forEach byte\n bitCount += 8;\n \n // If the count exceeds 13 bits, base convert the\n // current frame.\n\n if (bitCount > 13) {\n\n // Set bit amount \"count\" to 13, check the\n // remainder of n % 2^13. If it is 88 or \n // lower. Take one more bit from the stream\n // and calculate the remainder for n % 2^14.\n\n let count = 13;\n let rN = n % 8192;\n\n if (rN < 89) {\n count = 14;\n rN = n % 16384;\n }\n\n // Remove 13 or 14 bits from the integer,\n // decrease the bitCount by the same amount.\n n >>= count;\n bitCount -= count;\n \n // Calculate quotient and remainder from\n // the before calculated remainder of n \n // -> \"rN\"\n let q, r;\n [q, r] = this.#divmod(rN, 91);\n\n // Lookup the corresponding characters for\n // \"r\" and \"q\" in the set, append it to the \n // output string.\n output = `${output}${charset[r]}${charset[q]}`;\n }\n });\n \n // If the bitCount is not zero at the end,\n // calculate quotient and remainder of 91\n // once more.\n if (bitCount) {\n let q, r;\n [q, r] = this.#divmod(n, 91);\n\n // The remainder is concatenated in any case\n output = output.concat(charset[r]);\n\n // The quotient is also appended, but only\n // if the bitCount still has the size of a byte\n // or n can still represent 91 conditions.\n if (bitCount > 7 || n > 90) {\n output = output.concat(charset[q]);\n }\n }\n \n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n\n /**\n * BaseEx basE91 Decoder.\n * @param {string} input - basE91 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n\n // Make it a string, whatever goes in\n input = this.utils.normalizeInput(input);\n let inArray = [...input];\n\n // remove unwanted characters if integrity is false \n if (!settings.integrity) {\n inArray = inArray.filter(c => charset.includes(c));\n }\n\n\n let l = inArray.length;\n\n // For starters leave the last char behind\n // if the length of the input string is odd.\n\n let odd = false;\n if (l % 2) {\n odd = true;\n l--;\n }\n\n // Set again integer n for base conversion.\n // Also initialize a bitCount(er)\n\n let n = 0;\n let bitCount = 0;\n \n // Initialize an ordinary array\n const b256Array = new Array();\n \n // Walk through the string in steps of two\n // (aka collect remainder- and quotient-pairs)\n for (let i=0; i 88) ? 13 : 14;\n\n // calculate back the individual bytes (base256)\n do {\n b256Array.push(n % 256);\n n >>= 8;\n bitCount -= 8;\n } while (bitCount > 7);\n }\n\n // Calculate the last byte if the input is odd\n // and add it\n if (odd) {\n const lastChar = inArray.at(l);\n const rN = charset.indexOf(lastChar);\n b256Array.push(((rN << bitCount) + n) % 256);\n }\n\n const output = Uint8Array.from(b256Array);\n\n // Return the output\n return this.utils.outputHandler.compile(output, settings.outputType);\n }\n\n\n /**\n * Divmod Function.\n * @param {*} x - number 1\n * @param {*} y - number 2\n * @returns {number} Modulo y of x\n */\n #divmod (x, y) {\n return [Math.floor(x/y), x%y];\n }\n}\n","/**\n * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport { BytesInput } from \"../io-handlers.js\";\n\n/**\n * BaseEx Little Endian Base 128 Converter.\n * ---------------------------------------\n * \n * This is a leb128 converter. Various input can be \n * converted to a leb128 string or a leb128 string\n * can be decoded into various formats.\n * \n * There is no real charset available as the input is\n * getting converted to bytes. For having the chance \n * to store these bytes, there is a hexadecimal output\n * available.\n */\nexport default class LEB128 extends BaseTemplate {\n \n /**\n * BaseEx LEB128 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n // initialize base template without utils\n super();\n\n // converters\n this.converter = new BaseConverter(10, 0, 0);\n this.hexlify = new BaseConverter(16, 1, 2);\n\n // charsets\n this.charsets.default = \"\";\n this.charsets.hex = \"\"\n\n // predefined settings\n this.version = \"default\";\n this.frozenCharsets = true;\n\n // predefined settings\n this.littleEndian = true;\n this.hasSignedMode = true;\n this.isMutable.signed = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx LEB128 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {{ buffer: ArrayBufferLike; }} - LEB128 encoded Unit8Array (or hex string of it).\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n \n const signed = settings.signed;\n settings.signed = true;\n const [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings);\n\n // Convert to BaseRadix string\n let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0];\n\n let n = BigInt(base10);\n let output = new Array();\n \n if (negative) {\n if (!signed) {\n throw new TypeError(\"Negative values in unsigned mode are invalid.\");\n }\n n = -n;\n }\n \n if (signed) {\n\n for (;;) {\n const byte = Number(n & 127n);\n n >>= 7n;\n if ((n == 0 && (byte & 64) == 0) || (n == -1 && (byte & 64) != 0)) {\n output.push(byte);\n break;\n }\n output.push(byte | 128);\n }\n }\n\n else {\n for (;;) {\n const byte = Number(n & 127n);\n n >>= 7n;\n if (n == 0) {\n output.push(byte)\n break;\n }\n output.push(byte | 128);\n }\n }\n\n const Uint8Output = Uint8Array.from(output);\n\n if (settings.version === \"hex\") {\n return this.hexlify.encode(Uint8Output, [...\"0123456789abcdef\"], false)[0];\n }\n\n return Uint8Output;\n }\n\n\n /**\n * BaseEx LEB128 Decoder.\n * @param {{ buffer: ArrayBufferLike; }|string} input - LEB128-Bytes or String of Hex-Version.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n\n if (settings.version === \"hex\") {\n input = this.hexlify.decode(this.utils.normalizeInput(input).toLowerCase(), [...\"0123456789abcdef\"], [], settings.integrity, false);\n } else if (typeof input.byteLength !== \"undefined\") {\n input = BytesInput.toBytes(input)[0];\n } else {\n throw new TypeError(\"Input must be a bytes like object.\");\n }\n\n if (input.length === 1 && !input[0]) {\n return this.utils.outputHandler.compile(new Uint8Array(1), settings.outputType, true);\n }\n\n input = Array.from(input);\n\n let n = 0n;\n let shiftVal = -7n;\n let byte;\n\n for (byte of input) {\n shiftVal += 7n;\n n += (BigInt(byte & 127) << shiftVal);\n }\n \n if (settings.signed && ((byte & 64) !== 0)) {\n n |= -(1n << shiftVal + 7n);\n }\n\n // Test for a negative sign\n let decimalNum, negative;\n [decimalNum, negative] = this.utils.extractSign(n.toString());\n\n const output = this.converter.decode(decimalNum, [...\"0123456789\"], [], settings.integrity, true);\n\n // Return the output\n return this.utils.outputHandler.compile(output, settings.outputType, true, negative);\n }\n}\n","/**\n * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT OR Apache-2.0\n * @see https://github.com/keith-turner/ecoji\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Ecoji (a Base 1024) Converter.\n * ------------------------------------\n * This an implementation of the Ecoji converter.\n * Various input can be converted to an Ecoji string\n * or an Ecoji string can be decoded into various \n * formats. Versions 1 and 2 are supported.\n * This variant pretty much follows the standard\n * (at least in its results, the algorithm is very\n * different from the original).\n * A deviation is the handling of padding. The last\n * pad char can be trimmed for both versions and\n * additionally omitted completely if integrity\n * checks are disabled.\n */\nexport default class Ecoji extends BaseTemplate {\n\n #revEmojiVersion = {};\n #padRegex = null;\n\n /**\n * BaseEx Ecoji Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // charsets\n this.charsets.emojis_v1 = [...\"🀄🃏🅰🅱🅾🅿🆎🆑🆒🆓🆔🆕🆖🆗🆘🆙🆚🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿🈁🈂🈚🈯🈲🈳🈴🈵🈶🈷🈸🈹🈺🉐🉑🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🌡🌤🌥🌦🌧🌨🌩🌪🌫🌬🌭🌮🌯🌰🌱🌲🌳🌴🌵🌶🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🍽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🎖🎗🎙🎚🎛🎞🎟🎠🎡🎢🎣🎤🎥🎦🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🏋🏌🏎🏏🏐🏑🏒🏓🏔🏕🏖🏗🏘🏙🏚🏛🏜🏝🏞🏟🏠🏡🏢🏣🏤🏥🏦🏧🏨🏩🏪🏫🏬🏭🏮🏯🏰🏳🏴🏵🏷🏸🏹🏺🏻🏼🏽🏾🏿🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🐿👀👁👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸💹💺💻💼💽💾💿📀📁📂📃📄📅📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳📴📵📶📷📸📹📺📻📼📽📿🔀🔁🔂🔃🔄🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🔙🔚🔛🔜🔝🔞🔟🔠🔡🔢🔣🔤🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🔴🔵🔶🔷🔸🔹🔺🔻🔼🔽🕉🕊🕋🕌🕍🕎🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧🕯🕰🕳🕴🕵🕶🕷🕸🕹🕺🖇🖊🖋🖌🖍🖐🖕🖖🖤🖥🖨🖱🖲🖼🗂🗃🗄🗑🗒🗓🗜🗝🗞🗡🗣🗨🗯🗳🗺🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🛋🛌🛍🛎🛏🛐🛑🛒🛠🛡🛢🛣🛤🛥🛩🛫🛬🛰🛳🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🦰🦱🦲🦳🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕\"];\n this.padChars.emojis_v1 = [ \"⚜\", \"🏍\", \"📑\", \"🙋\", \"☕\" ];\n\n this.charsets.emojis_v2 = [...\"🀄🃏⏰⏳☔♈♉♊♋♌♍♎♏♐♑♒♓♿⚓⚡⚽⚾⛄⛅⛎⛔⛪⛲⛳⛵⛺⛽✊✋✨⭐🛕🛖🛗🛝🛞🛟🛺🈁🛻🤌🤏🤿🥱🥲🥸🥹🥻🦣🦤🦥🦦🦧🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🦨🦩🦪🦫🦬🦭🦮🦯🦺🦻🌭🌮🌯🌰🌱🌲🌳🌴🌵🦼🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🦽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🦾🦿🧃🧄🧅🧆🧇🎠🎡🎢🎣🎤🎥🧈🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🧉🧊🧋🏏🏐🏑🏒🏓🧌🧍🧎🧏🧖🧗🧘🧙🧚🧛🧜🧝🏠🏡🏢🏣🏤🏥🏦🧞🏨🏩🏪🏫🏬🏭🏮🏯🏰🧟🏴🧠🧢🏸🏹🏺🧣🧤🧥🧦🧧🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🧨👀🧩👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸🧪💺💻💼💽💾💿📀🧫📂📃📄🧬📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳🧭📵📶📷📸📹📺📻📼🧮📿🧯🧰🧱🧲🧳🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🧴🧵🧶🧷🧸🧹🧺🧻🧼🧽🧾🧿🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🩰🩱🩲🩳🩴🩸🩹🩺🩻🩼🪀🪁🕋🕌🕍🕎🪂🪃🪄🪅🪆🪐🪑🪒🪓🪔🪕🪖🪗🪘🪙🪚🪛🪜🪝🪞🪟🪠🪡🪢🪣🪤🪥🪦🪧🪨🪩🪪🪫🕺🪬🪰🪱🪲🪳🪴🖕🖖🖤🪵🪶🪷🪸🪹🪺🫀🫁🫂🫃🫄🫅🫐🫑🫒🫓🫔🫕🫖🫗🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🫘🛌🫙🫠🫡🛐🛑🛒🫢🫣🫤🫥🫦🫧🫰🛫🛬🫱🫲🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🫳🫴🫵🫶🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕\"];\n this.padChars.emojis_v2 = [ \"🥷\", \"🛼\", \"📑\", \"🙋\", \"☕\" ];\n \n // init mapping for decoding particularities of the two versions\n this.#init();\n\n // converter\n this.converter = new BaseConverter(1024, 5, 4);\n\n // predefined settings\n this.padding = true;\n this.padCharAmount = 5;\n this.version = \"emojis_v2\";\n \n // mutable extra args\n this.isMutable.padding = true;\n this.isMutable.trim = true;\n\n // set trim option\n this.trim = null;\n this.utils.converterArgs.trim = [\"notrim\", \"trim\"];\n \n // apply user settings\n this.utils.validateArgs(args, true);\n\n if (this.trim === null) {\n this.trim = this.version === \"emojis_v2\";\n }\n }\n\n\n /**\n * Analyzes v1 and two charsets for equal and non\n * equal characters to create a \"revEmojiObj\" for\n * decoding lookup. Also generates a RegExp object \n * for handling concatenated strings.\n */\n #init() {\n\n // Stores all padding for a regex generation.\n const padAll = {};\n\n // Creates an object which holds all characters\n // of both versions. Unique chars for version one\n // are getting the version value \"1\", version two \"2\"\n // and overlaps \"3\". \n const revEmojisAdd = (version, set) => {\n set.forEach((char) => {\n if (char in this.#revEmojiVersion) {\n this.#revEmojiVersion[char].version += version;\n } else {\n this.#revEmojiVersion[char] = { version };\n }\n });\n };\n\n // This function adds a padding character of both\n // versions to the object, with additional information\n // about the padding type. In this process each unique\n // padChar is also added to the \"padAll\" object. \n const handlePadding = (version, set, type) => {\n set.forEach(padChar => {\n \n if (padChar in padAll) {\n this.#revEmojiVersion[padChar].version = 3;\n } else {\n this.#revEmojiVersion[padChar] = {\n version,\n padding: type\n }\n padAll[padChar] = type;\n } \n });\n };\n\n revEmojisAdd(1, this.charsets.emojis_v1);\n revEmojisAdd(2, this.charsets.emojis_v2);\n\n handlePadding(1, this.padChars.emojis_v1.slice(0, -1), \"last\");\n handlePadding(2, this.padChars.emojis_v2.slice(0, -1), \"last\");\n handlePadding(1, this.padChars.emojis_v1.slice(-1), \"fill\");\n handlePadding(2, this.padChars.emojis_v2.slice(-1), \"fill\");\n\n \n // Create an array of keys for the final regex\n const regexArray = [];\n\n for (const padChar in padAll) {\n if (padAll[padChar] === \"last\") {\n regexArray.push(padChar);\n } else {\n regexArray.push(`${padChar}+`);\n }\n }\n\n // create a regex obj for matching all pad chars \n this.#padRegex = new RegExp(regexArray.join(\"|\"), \"g\");\n }\n\n\n /**\n * BaseEx Ecoji Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Ecoji encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n const charset = this.charsets[settings.version];\n let outArray = [...output];\n \n if (zeroPadding > 1) {\n const padValue = this.converter.padBytes(zeroPadding);\n if (settings.padding) {\n const padLen = settings.trim ? 1 : padValue;\n const padArr = new Array(padLen).fill(this.padChars[settings.version].at(-1));\n outArray.splice(outArray.length-padValue, padValue, ...padArr);\n } else {\n outArray.splice(outArray.length-padValue, padValue);\n }\n }\n \n else if (zeroPadding === 1) {\n const lastVal = charset.indexOf(outArray.pop());\n const x = lastVal >> 8;\n outArray.push(this.padChars[settings.version].at(x));\n }\n\n return outArray.join(\"\");\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n \n /**\n * BaseEx Ecoji Decoder.\n * @param {string} input - Ecoji String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n input = this.utils.normalizeInput(input);\n\n let version = settings.version;\n let versionKey = null;\n\n if (settings.version === \"emojis_v1\" || settings.version === \"emojis_v2\") {\n // versionKey can be both v1 or v2\n versionKey = 3;\n }\n\n // the actual decoding is wrapped in a function\n // for the possibility to call it multiple times\n const decode = (input) => {\n\n if (versionKey !== null) {\n versionKey = this.#preDecode(input, versionKey, settings.integrity);\n version = (versionKey === 3)\n ? settings.version\n : `emojis_v${versionKey}`;\n }\n\n const charset = this.charsets[version];\n \n const inArray = [...input];\n const lastChar = inArray.at(-1);\n let skipLast = false;\n\n for (let i=0; i {\n const end = match.index + match.at(0).length;\n preOutArray.push(...decode(input.slice(start, end)));\n start = end;\n });\n\n // in case the last group has no padding, it is not yet\n // decoded -> do it now\n if (start !== input.length) {\n preOutArray.push(...decode(input.slice(start, input.length)));\n }\n\n output = Uint8Array.from(preOutArray);\n }\n\n return this.utils.outputHandler.compile(output, settings.outputType);\n }\n\n\n /**\n * Determines the version (1/2) and analyzes the input for integrity.\n * @param {string} input - Input string. \n * @param {number} versionKey - Version key from former calls (initially always 3). \n * @param {boolean} integrity - If false non standard or wrong padding gets ignored. \n * @returns {number} - Version key (1|2|3)\n */\n #preDecode(input, versionKey, integrity) {\n \n const inArray = [...input];\n let sawPadding;\n\n inArray.forEach((char, i) => {\n\n if (char in this.#revEmojiVersion) {\n\n const charVersion = this.#revEmojiVersion[char].version;\n\n // version changes can only happen if the char is\n // not in both versions (not 3)\n if (charVersion !== 3) {\n if (versionKey === 3) {\n versionKey = charVersion;\n } else if (versionKey !== charVersion) {\n throw new TypeError(`Emojis from different ecoji versions seen : ${char} from emojis_v${charVersion}`);\n }\n }\n\n // analyze possible wrong padding if integrity checks\n // are enabled\n if (integrity) {\n const padding = this.#revEmojiVersion[char].padding;\n if (padding) {\n\n // index relative to a group of four bytes\n const relIndex = i%4;\n sawPadding = true;\n\n if (padding === \"fill\") {\n if (relIndex === 0) {\n throw new TypeError(`Padding unexpectedly seen in first position ${char}`);\n }\n } else if (relIndex !== 3) {\n throw new TypeError(`Last padding seen in unexpected position ${char}`);\n }\n }\n\n else if (sawPadding) {\n throw new TypeError(\"Unexpectedly saw non-padding after padding\");\n }\n }\n\n } else {\n throw new DecodingError(char);\n }\n });\n\n // lastly test for invalid string \n if (integrity && inArray.length % 4) {\n if (\n versionKey === 1 ||\n this.#revEmojiVersion[inArray.at(-1)].padding !== \"fill\"\n ) {\n throw new TypeError(\"Unexpected end of data, input data size not multiple of 4\");\n }\n }\n\n return versionKey;\n }\n}\n","/**\n * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base 2048 Converter.\n * ------------------------\n * This is a base2048/converter. Various input can be \n * converted to a hex string or a hex string can be\n * decoded into various formats. It is possible to \n * convert in both signed and unsigned mode.\n * \n * @see https://github.com/qntm/base2048\n */\nexport default class Base2048 extends BaseTemplate {\n\n /**\n * BaseEx Base2048 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 2048,\n bsEnc: 11,\n bsEncPad: 3,\n bsDec: 8\n }\n \n // default settings\n this.charsets.default = [...\"89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ\"];\n this.padChars.default = [...\"01234567\"];\n\n this.padCharAmount = 8;\n this.hasSignedMode = true;\n this.littleEndian = false;\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Base2048 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base2048 encoded string.\n */\n encode(input, ...args) {\n\n const settings = this.utils.validateArgs(args);\n let inputBytes = this.utils.inputHandler.toBytes(input, settings).at(0);\n\n const charset = this.charsets[settings.version];\n const padChars = this.padChars[settings.version];\n\n let output = \"\";\n let z = 0;\n let numZBits = 0;\n\n inputBytes.forEach(uint8 => {\n \n for (let i=this.converter.bsDec-1; i>=0; i--) {\n\n z = (z << 1) + ((uint8 >> i) & 1);\n numZBits++;\n\n if (numZBits === this.converter.bsEnc) {\n output += charset.at(z);\n z = 0\n numZBits = 0\n }\n }\n });\n\n if (numZBits !== 0) {\n \n let bitCount;\n let isPadding;\n\n if (numZBits <= this.converter.bsEncPad) {\n bitCount = this.converter.bsEncPad;\n isPadding = true;\n } else {\n bitCount = this.converter.bsEnc \n isPadding = false;\n }\n\n while (numZBits !== bitCount) {\n z = (z << 1) + 1\n numZBits++\n if (numZBits > this.converter.bsEnc) {\n throw new Error(\"Cannot process input. This is a bug!\");\n }\n }\n \n if (isPadding) { \n output += padChars.at(z);\n } else {\n output += charset.at(z);\n }\n }\n\n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n \n /**\n * BaseEx Base2048 Decoder.\n * @param {string} input - Base2048/Hex String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // apply settings\n const settings = this.utils.validateArgs(args);\n\n // ensure a string input\n input = this.utils.normalizeInput(input);\n const inArray = [...input];\n\n const charset = this.charsets[settings.version];\n const padChars = this.padChars[settings.version];\n\n const byteArray = new Array();\n let uint8 = 0;\n let numUint8Bits = 0;\n\n inArray.forEach((c, i) => {\n\n let numZBits;\n let z = charset.indexOf(c);\n if (z > -1) { \n numZBits = this.converter.bsEnc;\n } else {\n z = padChars.indexOf(c);\n\n if (z > -1) {\n if (i+1 !== inArray.length) {\n throw new DecodingError(null, `Secondary character found before end of input, index: ${i}`); \n }\n\n numZBits = this.converter.bsEncPad;\n }\n \n else if (settings.integrity) {\n throw new DecodingError(c);\n }\n }\n\n // Take most significant bit first\n for (let j=numZBits-1; j>=0; j--) {\n\n uint8 = (uint8 << 1) + ((z >> j) & 1);\n numUint8Bits++\n\n if (numUint8Bits === this.converter.bsDec) {\n byteArray.push(uint8);\n uint8 = 0;\n numUint8Bits = 0;\n }\n }\n });\n\n return this.utils.outputHandler.compile(\n Uint8Array.from(byteArray),\n settings.outputType\n );\n }\n}\n","/**\n * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n\n/**\n * BaseEx SimpleBase Converter.\n * ---------------------------\n * SimpleBase provides the simple mathematical base\n * conversion as known from (n).toString(radix) and\n * parseInt(n, radix).\n * \n * The constructor needs a radix between 2-62 as the\n * first argument. In other regards it behaves pretty\n * much as any other converter. \n */\nexport default class SimpleBase extends BaseTemplate {\n \n /**\n * SimpleBase Constructor.\n * @param {number} radix - Radix between 2 and 62 \n * @param {...any} args - Converter settings.\n */\n constructor(radix, ...args) {\n super();\n\n if (!radix || !Number.isInteger(radix) || radix < 2 || radix > 62) {\n throw new RangeError(\"Radix argument must be provided and has to be an integer between 2 and 62.\")\n }\n this.converter = new BaseConverter(radix, 0, 0);\n\n\n // charsets\n this.charsets.default = [...\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"].slice(0, radix);\n \n\n // predefined settings\n this.frozenCharsets = true;\n this.hasSignedMode = true;\n this.littleEndian = !(radix === 2 || radix === 16);\n this.signed = true;\n this.version = \"default\";\n \n // list of allowed/disallowed args to change\n this.isMutable.littleEndian = true,\n this.isMutable.upper = radix <= 36;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx SimpleBase Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...any} [args] - Converter settings.\n * @returns {string} - Base 2-62 encoded string.\n */\n encode(input, ...args) {\n return super.encode(input, null, null, ...args);\n }\n\n\n /**\n * BaseEx SimpleBase Decoder.\n * @param {string} input - Base 2-62 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(rawInput, ...args) {\n\n // pre decoding function\n const normalizeInput = ({ input }) => {\n \n // normalize input (add leading zeros) for base 2 and 16\n if (this.converter.radix === 2) {\n const leadingZeros = (8 - (input.length % 8)) % 8;\n input = `${\"0\".repeat(leadingZeros)}${input}`;\n } else if (this.converter.radix === 16) {\n const leadingZeros = input.length % 2;\n input = `${\"0\".repeat(leadingZeros)}${input}`;\n }\n\n return input;\n }\n \n return super.decode(rawInput, normalizeInput, null, false, ...args);\n\n }\n}\n","/**\n * big.js v6.2.1 // Copyright (c) 2022 Michael Mclaughlin // https://github.com/MikeMcl/big.js/LICENCE.md // Modified (reduced) and minified for BaseEx\n */\nlet DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME=\"[big.js] \",INVALID=NAME+\"Invalid \",INVALID_DP=INVALID+\"decimal places\",INVALID_RM=INVALID+\"rounding mode\",P={},NUMERIC=/^-?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i;function _Big_(){function Big(n){let x=this;if(!(x instanceof Big))return void 0===n?_Big_():new Big(n);if(n instanceof Big)x.s=n.s,x.e=n.e,x.c=n.c.slice();else{if(\"string\"!=typeof n){if(!0===Big.strict&&\"bigint\"!=typeof n)throw TypeError(INVALID+\"value\");n=0===n&&1/n<0?\"-0\":String(n)}parse(x,n)}x.constructor=Big}return Big.prototype=P,Big.DP=DP,Big.RM=RM,Big.NE=NE,Big.PE=PE,Big.strict=STRICT,Big.roundDown=0,Big.roundHalfUp=1,Big.roundHalfEven=2,Big.roundUp=3,Big}function parse(x,n){let e,i,nl;if(!NUMERIC.test(n))throw Error(`${INVALID}number`);for(x.s=\"-\"==n.charAt(0)?(n=n.slice(1),-1):1,(e=n.indexOf(\".\"))>-1&&(n=n.replace(\".\",\"\")),(i=n.search(/e/i))>0?(e<0&&(e=i),e+=+n.slice(i+1),n=n.substring(0,i)):e<0&&(e=n.length),nl=n.length,i=0;i0&&\"0\"==n.charAt(--nl););for(x.e=e-i-1,x.c=[],e=0;i<=nl;)x.c[e++]=+n.charAt(i++)}return x}function round(x,sd,rm,more){let xc=x.c;if(void 0===rm&&(rm=x.constructor.RM),0!==rm&&1!==rm&&2!==rm&&3!==rm)throw Error(INVALID_RM);if(sd<1)more=3===rm&&(more||!!xc[0])||0===sd&&(1===rm&&xc[0]>=5||2===rm&&(xc[0]>5||5===xc[0]&&(more||void 0!==xc[1]))),xc.length=1,more?(x.e=x.e-sd+1,xc[0]=1):xc[0]=x.e=0;else if(sd=5||2===rm&&(xc[sd]>5||5===xc[sd]&&(more||void 0!==xc[sd+1]||1&xc[sd-1]))||3===rm&&(more||!!xc[0]),xc.length=sd,more)for(;++xc[--sd]>9;)if(xc[sd]=0,0===sd){++x.e,xc.unshift(1);break}for(sd=xc.length;!xc[--sd];)xc.pop()}return x}function stringify(x,doExponential,isNonzero){let e=x.e,s=x.c.join(\"\"),n=s.length;if(doExponential)s=s.charAt(0)+(n>1?\".\"+s.slice(1):\"\")+(e<0?\"e\":\"e+\")+e;else if(e<0){for(;++e;)s=\"0\"+s;s=\"0.\"+s}else if(e>0)if(++e>n)for(e-=n;e--;)s+=\"0\";else e1&&(s=s.charAt(0)+\".\"+s.slice(1));return x.s<0&&isNonzero?\"-\"+s:s}P.abs=function(){let x=new this.constructor(this);return x.s=1,x},P.cmp=function(y){let isneg,x=this,xc=x.c,yc=(y=new x.constructor(y)).c,i=x.s,j=y.s,k=x.e,l=y.e;if(!xc[0]||!yc[0])return xc[0]?i:yc[0]?-j:0;if(i!=j)return i;if(isneg=i<0,k!=l)return k>l^isneg?1:-1;for(j=(k=xc.length)<(l=yc.length)?k:l,i=-1;++iyc[i]^isneg?1:-1;return k==l?0:k>l^isneg?1:-1},P.eq=function(y){return 0===this.cmp(y)},P.gt=function(y){return this.cmp(y)>0},P.gte=function(y){return this.cmp(y)>-1},P.lt=function(y){return this.cmp(y)<0},P.lte=function(y){return this.cmp(y)<1},P.minus=P.sub=function(y){let i,j,t,xlty,x=this,Big=x.constructor,a=x.s,b=(y=new Big(y)).s;if(a!=b)return y.s=-b,x.plus(y);let xc=x.c.slice(),xe=x.e,yc=y.c,ye=y.e;if(!xc[0]||!yc[0])return yc[0]?y.s=-b:xc[0]?y=new Big(x):y.s=1,y;if(a=xe-ye){for((xlty=a<0)?(a=-a,t=xc):(ye=xe,t=yc),t.reverse(),b=a;b--;)t.push(0);t.reverse()}else for(j=((xlty=xc.length0)for(;b--;)xc[i++]=0;for(b=i;j>a;){if(xc[--j]0?(ye=xe,t=yc):(e=-e,t=xc),t.reverse();e--;)t.push(0);t.reverse()}for(xc.length-yc.length<0&&(t=yc,yc=xc,xc=t),e=yc.length,k=0;e;xc[e]%=10)k=(xc[--e]=xc[e]+yc[e]+k)/10|0;for(k&&(xc.unshift(k),++ye),e=xc.length;0===xc[--e];)xc.pop();return y.c=xc,y.e=ye,y},P.round=function(dp,rm){if(void 0===dp)dp=0;else if(dp!==~~dp||dp<-MAX_DP||dp>MAX_DP)throw Error(INVALID_DP);return round(new this.constructor(this),dp+this.e+1,rm)},P.toFixed=function(dp,rm){let x=this,n=x.c[0];if(void 0!==dp){if(dp!==~~dp||dp<0||dp>MAX_DP)throw Error(INVALID_DP);for(x=round(new x.constructor(x),dp+x.e+1,rm),dp=dp+x.e+1;x.c.length=Big.PE,!!x.c[0])},P.toNumber=function(){let n=Number(stringify(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(n.toString()))throw Error(NAME+\"Imprecise conversion\");return n};export const Big=_Big_();export default Big;\n","/**\n * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport Big from \"../../lib/big.js/big.min.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base Phi Converter.\n * ------------------------\n * \n * This is a base phi converter. Various input can be \n * converted to a base phi string or a base phi string\n * can be decoded into various formats.\n * \n */\nexport default class BasePhi extends BaseTemplate {\n\n #Phi = Big(\"1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752\");\n \n /**\n * BaseEx basE91 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 2, // radix is Phi, but the normalized representation allows two chars\n bsEnc: 0,\n bsDec: 0\n }\n\n // base10 converter to have always have a numerical input \n this.b10 = new BaseConverter(10, 0, 0);\n\n // charsets\n this.charsets.default = [\"0\", \"1\"];\n\n this.version = \"default\";\n this.signed = true;\n this.hasDecimalMode = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx BasePhi Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...string} [args] - Converter settings.\n * @returns {string} - BasePhi encoded string.\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n \n let inputBytes;\n let negative;\n let n;\n let output = \"\";\n\n // Base Phi allows direct encoding of rational \n // and irrational numbers, which can be enabled\n // by using the special type \"decimal\". Input \n // type must be \"Number\" for this mode. \n if (settings.decimalMode) {\n if (Number.isFinite(input)) {\n if (input < 0) {\n negative = true;\n n = Big(-input);\n } else {\n negative = false;\n n = Big(input);\n } \n }\n\n else {\n throw new TypeError(\"When running the converter in decimal-mode, only input of type 'Number' is allowed.\")\n }\n }\n\n // Every other type first converts the byte representation\n // of the input to base 10.\n else {\n [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings);\n n = Big(\n this.b10.encode(inputBytes, null, settings.littleEndian)[0]\n );\n }\n\n // if \"n\" if 0 or 1 stop here and return 0 or 1 (according to the charset)\n if (n.eq(0) || n.eq(1)) {\n output = charset[n.toNumber()]; \n if (negative) {\n output = `-${output}`;\n } \n return output;\n }\n \n // create two arrays to store all exponents\n const exponents = [];\n const decExponents = [];\n\n\n // The very first step is to find the highest exponent\n // of Phi which fits into \"n\" (the rounded highest exponent\n // is also the highest Lucas number which fits into \"n\")\n // To find the highest fitting exponent start with \n // Phi^0 (1) and Phi^1 (Phi).\n\n let last = Big(1);\n let cur = this.#Phi;\n let exp = 0;\n \n // Now add the result with the last higher value \"cur\",\n // util \"cur\" is bigger than \"n\"\n while (cur.lt(n)) {\n [ last, cur ] = this.#nextPhiExp(last, cur);\n exp++;\n }\n \n /**\n * Recursive reduction function for \"n\". Finds the largest\n * fitting exponent of Phi (Lucas index), stores that index\n * in the exponent arrays and reduces \"n\" by the current exponents\n * power.\n * Once started, it calls itself until \"n\" is zero. \n * @param {Object} cur - Current result of Phi^exp as a Big.js object. \n * @param {Object} prev - Previous result of Phi^exp as a Big.js object. \n * @param {number} exp - Exponent of Phi/Lucas index. \n */\n const reduceN = (cur, prev, exp) => {\n\n // Due to the high floating point precision \"n\" should\n // be exactly zero, but if not, an approximation is \n // sufficient.\n if (this.#approxNull(n)) return;\n\n // Reduce the exponents of Phi until it power fits into \"n\" \n while (cur.gt(n)) {\n [ cur, prev ] = this.#prevPhiExp(cur, prev);\n \n // if \"cur\" gets negative return immediately\n // prevent an infinite loop\n if (cur.lte(0)) {\n console.warn(\"Could not find an exact base-phi representation. Value is approximated.\");\n return;\n }\n exp--;\n }\n\n // Store the exponents\n if (exp > -1) {\n exponents.unshift(exp);\n } else {\n decExponents.push(exp);\n }\n\n // Reduce \"n\"\n n = n.minus(cur);\n\n reduceN(cur, prev, exp);\n }\n\n // Initial call of the reduction function\n reduceN(last, cur, exp);\n\n\n // Create a BasePhi string by setting a \"1\" at every\n // index stored in the \"exponent\" array. for every\n // number between two indices a zero is added. \n exp = 0; \n exponents.forEach(nExp => {\n while (exp < nExp) {\n output = `${charset[0]}${output}`;\n exp++;\n }\n output = `${charset[1]}${output}`;\n exp++;\n });\n\n // Add a decimal point\n if (!output) {\n output = \"0.\";\n } else {\n output += \".\";\n }\n \n // Proceed with the decimal exponents\n exp = -1;\n decExponents.forEach(nExp => {\n while (exp > nExp) {\n output += charset[0];\n exp--;\n }\n output += charset[1];\n exp--;\n });\n\n // Add a \"-\" if the input is negative.\n if (negative) {\n output = `-${output}`;\n }\n \n return output;\n }\n\n\n /**\n * BaseEx Base Phi Decoder.\n * @param {string} input - Base Phi String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n\n let negative;\n [ input, negative ] = this.utils.extractSign(\n this.utils.normalizeInput(input)\n );\n\n // remove unwanted characters if integrity is false\n if (!settings.integrity) {\n const testChars = [...charset, \".\"];\n input = [...input].filter(c => testChars.includes(c)).join(\"\");\n }\n \n // Split the input String at the decimal sign\n // and initialize a big.js-object with value 0\n const inputSplit = input.split(\".\");\n if (settings.integrity && inputSplit.length > 2) {\n throw new DecodingError(null, \"There are multiple decimal points in the input.\");\n } \n\n const [ posExpStr, decExpStr ] = inputSplit;\n let n = Big(0);\n\n // Initialize two variables \"last\" and \"cur\"\n // for Phi^exp-1 and Phi^exp\n let last = this.#Phi.minus(1);\n let cur = Big(1); \n \n // Convert the left side of the input string\n // to an array of chars and reverse it. Raise\n // the exponent of Phi and its values until a\n // one is found in the array, if a \"1\" was found\n // add the value \"cur\" to number \"n\" (one can\n // also be another corresponding char of the set\n // which represents 1).\n [...posExpStr].reverse().forEach((char) => {\n const charIndex = charset.indexOf(char);\n if (charIndex === 1) {\n n = n.plus(cur);\n } else if (charIndex !== 0) {\n throw new DecodingError(char);\n }\n [ last, cur ] = this.#nextPhiExp(last, cur);\n });\n\n // Now also add the values for the decimal places.\n if (decExpStr) { \n let prev = Big(1); \n cur = this.#Phi.minus(prev);\n \n [...decExpStr].forEach((char) => {\n const charIndex = charset.indexOf(char);\n if (charIndex === 1) {\n n = n.plus(cur);\n } else if (charIndex !== 0) {\n throw new DecodingError(char);\n }\n [ cur, prev ] = this.#prevPhiExp(cur, prev);\n });\n }\n\n // If running in decimal mode return n as a Number\n if (settings.decimalMode) {\n return n.toNumber();\n }\n\n // For every other case round \"n\" and turn it\n // into a string of an integer. \n n = n.round().toFixed();\n\n // Use the base 10 decoder to get the byte\n // representation of \"n\".\n const output = this.b10.decode(n, [...\"0123456789\"], [], settings.integrity, settings.littleEndian);\n \n // Return the output according to the settings.\n return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative);\n }\n\n /**\n * Test if n is approximately zero.\n * @param {Object} n - Big.js Object. \n * @returns {Boolean}\n */\n #approxNull(n) { \n return !(n.round(50)\n .abs()\n .toNumber()\n );\n }\n \n /**\n * Get the results of of the following exponents of Phi\n * from the predecessors.\n * @param {Object} last - Phi^exp-1 as a big.js-object \n * @param {Object} cur - Phi^exp as a big.js-object\n * @returns {Object[]} - Array with Phi^exp and Phi^exp+1\n */\n #nextPhiExp(last, cur) {\n return [ cur, last.plus(cur) ];\n }\n\n /**\n * Get the results of of the previous exponents of Phi\n * from the predecessors.\n * @param {Object} cur - Phi^exp as a big.js-object \n * @param {Object} prev - Phi^exp-1 as a big.js-object\n * @returns {Object[]} - Array with Phi^exp-1 and Phi^exp\n */\n #prevPhiExp(cur, prev) {\n return [ prev.minus(cur), cur ];\n }\n}\n","/**\n * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { SmartInput, SmartOutput } from \"../io-handlers.js\";\n\n// Endianness of the system\nconst LITTLE_ENDIAN = (() => {\n const testInt = new Uint16Array([1]);\n const byteRepresentation = new Uint8Array(testInt.buffer);\n return Boolean(byteRepresentation.at(0));\n})();\n\n\n/**\n * BaseEx Byte Converter.\n * ---------------------\n * \n * This is a byte converter. Various input can be \n * converted to a bytes or bytes can be decoded into\n * various formats.\n * \n * As en- and decoder were already available, for the\n * use of converting in- and output for the base\n * converters, this is just a little extra tool, which\n * was fast and easy to create.\n */\nexport default class ByteConverter {\n\n /**\n * BaseEx ByteConverter Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n\n // predefined settings\n this.littleEndian = LITTLE_ENDIAN;\n this.numberMode = false;\n this.outputType = \"buffer\";\n\n // simplified utils\n this.utils = {\n validateArgs: (args, initial=false) => {\n\n const parameters = {\n littleEndian: this.littleEndian,\n numberMode: this.numberMode,\n outputType: this.outputType,\n signed: false,\n }\n \n if (!args.length) {\n return parameters;\n }\n \n if (args.includes(\"number\")) {\n args.splice(args.indexOf(\"number\"), 1);\n parameters.numberMode = true;\n parameters.outputType = \"float_n\";\n }\n \n const outTypes = SmartOutput.typeList.map(s => `'${s}'`).join(\", \");\n \n args.forEach((arg) => {\n arg = String(arg).toLowerCase();\n \n if (arg === \"le\") {\n parameters.littleEndian = true;\n } else if (arg === \"be\") {\n parameters.littleEndian = false;\n } else if (SmartOutput.typeList.includes(arg)) {\n parameters.outputType = arg;\n } else {\n throw new TypeError(`Invalid argument: '${arg}.\\nValid arguments are:\\n'le', 'be', ${outTypes}`);\n }\n });\n \n if (initial) {\n for (const param in parameters) {\n this[param] = parameters[param];\n }\n }\n \n return parameters;\n }\n }\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Byte Encoder.\n * @param {*} input - Almost any input.\n * @param {...str} [args] - Converter settings.\n * @returns {{ buffer: ArrayBufferLike; }} - Bytes of Input.\n */\n encode(input, ...args) {\n const settings = this.utils.validateArgs(args);\n return SmartInput.toBytes(input, settings)[0];\n }\n\n\n /**\n * BaseEx Byte Decoder.\n * @param {{ buffer: ArrayBufferLike; }} input - Bytes/Buffer/View\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output of requested type.\n */\n decode(input, ...args) {\n const settings = this.utils.validateArgs(args);\n return SmartOutput.compile(input, settings.outputType, settings.littleEndian);\n }\n}\n","/**\n * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\n/* eslint-disable sort-imports */\n\nimport Base1 from \"./converters/base-1.js\";\nimport Base16 from \"./converters/base-16.js\";\nimport Base32 from \"./converters/base-32.js\";\nimport Base58 from \"./converters/base-58.js\";\nimport Base64 from \"./converters/base-64.js\";\nimport UUencode from \"./converters/uuencode.js\";\nimport Base85 from \"./converters/base-85.js\";\nimport Base91 from \"./converters/base-91.js\";\nimport LEB128 from \"./converters/leb-128.js\";\nimport Ecoji from \"./converters/ecoji.js\";\nimport Base2048 from \"./converters/base-2048.js\";\nimport SimpleBase from \"./converters/simple-base.js\";\nimport BasePhi from \"./converters/base-phi.js\";\nimport ByteConverter from \"./converters/byte-converter.js\";\n\nimport { DEFAULT_OUTPUT_HANDLER } from \"./utils.js\";\n\n/**\n * BaseEx Converter Collection.\n * ---------------------------\n * This class holds almost any available converter\n * of the whole BaseEx converter collection. The \n * instances are ready to use. Various input can be \n * converted to a base string or the base string can be\n * decoded into various formats.\n */\nclass BaseEx {\n \n /**\n * BaseEx Base Collection Constructor.\n * @param {string} [outputType] - Output type. \n */\n constructor(outputType=\"buffer\") {\n\n if (!DEFAULT_OUTPUT_HANDLER.typeList.includes(outputType)) {\n let message = `Invalid argument '${outputType}' for output type. Allowed types are:\\n`;\n message = message.concat(DEFAULT_OUTPUT_HANDLER.typeList.join(\", \"));\n\n throw new TypeError(message);\n }\n\n this.base1 = new Base1(\"default\", outputType);\n this.base16 = new Base16(\"default\", outputType);\n this.base32_crockford = new Base32(\"rfc4648\", outputType);\n this.base32_rfc3548 = new Base32(\"rfc3548\", outputType);\n this.base32_rfc4648 = new Base32(\"rfc4648\", outputType);\n this.base32_zbase32 = new Base32(\"zbase32\", outputType);\n this.base58 = new Base58(\"default\", outputType);\n this.base58_bitcoin = new Base58(\"bitcoin\", outputType);\n this.base58_flickr = new Base58(\"flickr\", outputType);\n this.base64 = new Base64(\"default\", outputType);\n this.base64_urlsafe = new Base64(\"urlsafe\", outputType);\n this.uuencode = new UUencode(\"default\", outputType);\n this.uuencode_original = new UUencode(\"original\", outputType);\n this.xxencode = new UUencode(\"xx\", outputType);\n this.base85_adobe = new Base85(\"adobe\", outputType);\n this.base85_ascii = new Base85(\"ascii85\", outputType);\n this.base85_z85 = new Base85(\"z85\", outputType);\n this.base91 = new Base91(\"default\",outputType);\n this.leb128 = new LEB128(\"default\", outputType);\n this.ecoji_v1 = new Ecoji(\"emojis_v1\", outputType);\n this.ecoji_v2 = new Ecoji(\"emojis_v2\", outputType);\n this.base2048 = new Base2048(\"default\", outputType);\n this.basePhi = new BasePhi(\"default\", outputType);\n this.byteConverter = new ByteConverter(outputType);\n\n this.simpleBase = {};\n for (let i=2; i<=62; i++) {\n this.simpleBase[`base${i}`] = new SimpleBase(i, outputType);\n }\n }\n}\n\nexport { \n Base1,\n Base16,\n Base32,\n Base58,\n Base64,\n UUencode,\n Base85,\n Base91,\n LEB128,\n Ecoji,\n Base2048,\n SimpleBase,\n BasePhi,\n ByteConverter,\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,CAAC;AAC3D,QAAQ,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC3D,QAAQ,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC5D,QAAQ,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC1D,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;AAC3D;AACA,QAAQ,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;AAC7B,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE;AAClC,YAAY,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACxE,SAAS;AACT,KAAK;AACL;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/base-ex.esm.js b/dist/base-ex.esm.js index 6d754ff..b0fa800 100644 --- a/dist/base-ex.esm.js +++ b/dist/base-ex.esm.js @@ -976,6 +976,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1149,19 +1150,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1608,7 +1621,7 @@ class Base1 extends BaseTemplate { /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-16.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1697,7 +1710,7 @@ class Base16 extends BaseTemplate { /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1803,7 +1816,7 @@ class Base32 extends BaseTemplate { /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1954,7 +1967,7 @@ class Base58 extends BaseTemplate{ /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2043,7 +2056,7 @@ class Base64 extends BaseTemplate { /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2256,7 +2269,7 @@ const ees = () => { /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2380,7 +2393,7 @@ class Base85 extends BaseTemplate { /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ @@ -2614,7 +2627,7 @@ class Base91 extends BaseTemplate { /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2780,7 +2793,7 @@ class LEB128 extends BaseTemplate { /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT OR Apache-2.0 * @see https://github.com/keith-turner/ecoji @@ -3123,7 +3136,7 @@ class Ecoji extends BaseTemplate { /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3302,7 +3315,7 @@ class Base2048 extends BaseTemplate { /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3403,7 +3416,7 @@ let DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME="[big.js] ",INVALID=NAME+"I /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3741,7 +3754,7 @@ class BasePhi extends BaseTemplate { /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3860,7 +3873,7 @@ class ByteConverter { /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/base-ex.esm.min.js b/dist/base-ex.esm.min.js index 630c5c3..d70f21a 100644 --- a/dist/base-ex.esm.min.js +++ b/dist/base-ex.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let s;return s="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,s}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,s;if(Number.isInteger(t)){if(s="int",!Number.isSafeInteger(t)){let e,i,s;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",s="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",s="MAX"),new RangeError(`The provided integer is ${i} than ${s}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else s="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),s]}static bigInts(t,e=!1){const i=new Array,s=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[s](t%r),t>>=64n;else for(;t>=r;)i[s](t%r),t>>=64n;i[s](t);const n=8*i.length,o=this.makeDataView(n);return i.forEach(((t,i)=>{const s=8*i;o.setBigUint64(s,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,s=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(s=!0,t=-t),e.numberMode){const s=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(s.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(s=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const s=new Array;for(const i of t)s.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(s)}}return[i,s,r]}}class s{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,s){const r=t.byteLength,n=(e-t.byteLength%e)%e,o=s&&r>1?255:0;let a=t;if(n){a=new Uint8Array(r+n),a.fill(o);const e=i?0:n;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,s){let r;if("int16"===e||"uint16"===e){const n=this.makeTypedArrayBuffer(t,2,i,s);r="int16"===e?new Int16Array(n):new Uint16Array(n)}else if("int32"===e||"uint32"===e||"float32"===e){const n=this.makeTypedArrayBuffer(t,4,i,s);r="int32"===e?new Int32Array(n):"uint32"===e?new Uint32Array(n):new Float32Array(n)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const n=this.makeTypedArrayBuffer(t,8,i,s);r="bigint64"===e?new BigInt64Array(n):"biguint64"===e?new BigUint64Array(n):new Float64Array(n)}return r}static compile(t,e,s=!1,r=!1){let n;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",s):-this.compile(t,"uint_n",s),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:s,numberMode:!1,signed:!1})[0]}if("buffer"===e)n=t.buffer;else if("bytes"===e||"uint8"===e)n=t;else if("int8"===e)n=new Int8Array(t.buffer);else if("view"===e)n=new DataView(t.buffer);else if("str"===e)n=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,s,r);t=new Uint8Array(e)}s&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),n="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);n=new DataView(e.buffer).getFloat32(0,s)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);n=new DataView(e.buffer).getFloat64(0,s)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);n=Number(e)}else n=this.makeTypedArray(t,e,s,r);return n}}const r=i,n=s;class o extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class a extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class h{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],s=!0)=>{const r=(t,i,s)=>{if(0===s&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=s;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===s)return[...i];if(r!==s)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${s}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";s<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const n=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${n.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");s&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const n=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=n,o.length&&(this.root.padChars[t]=o),s&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,s){throw new TypeError([`'${t}'\n\nParameters:`,s?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const c=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(c.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,c,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new o}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,s=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=s}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[c,l]=this.divmod(c,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(c,10));a.lengthu=u.concat(e[t]))),s&&(u=s(u,o)),n=n.concat(u)}return[n,o]}decode(t,e,i=[],s=!0,r=!1){if(!t)return new Uint8Array(0);let n=this.bsDec;const o=new Array;let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)o.push(r);else if(s&&-1===i.indexOf(t))throw new a(t)})),0===n)n=o.length;else{h=(n-o.length%n)%n;const t=new Array(h).fill(this.decPadVal);r?o.unshift(...t):o.push(...t)}let l=new Array;for(let t=0,e=o.length;t=256;)[r,s]=this.divmod(r,256),i.unshift(parseInt(s,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class c{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new h(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...s){const r=this.utils.validateArgs(s);let[n,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,c]=this.converter.encode(n,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:n,output:l,settings:r,zeroPadding:c,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,s,...r){const n=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,s);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:n}));let a=this.converter.decode(t,this.charsets[n.version],this.padChars[n.version],n.integrity,n.littleEndian);return i&&(a=i({input:t,output:a,settings:n})),this.utils.outputHandler.compile(a,n.outputType,n.littleEndian,o)}}class u extends c{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new l(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s,r;[s,r]=this.utils.inputHandler.toBytes(t,i);let n=this.converter.encode(s,null,i.littleEndian)[0],o=BigInt(n);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],h=a.length;let l="";if(1===h)l=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(l=a.at(1).repeat((o-t)/5)),l+=a.at(0).repeat(t)}else for(let t=0;t(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}class f extends c{constructor(...t){super(),this.converter=new l(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class p extends c{constructor(...t){super(),this.converter=new l(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:s})=>{if(i.padding&&"int"!==s){let s=0;const r=t.length,n=this.charsets[i.version].at(0);if(r){for(;!t[s];)if(s++,s===r){s=0;break}const i=s;i&&(e=n.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const s=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===s;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}class g extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class b extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||w()} ${e.options.file||y()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${s.at(r)}${e.join("")}\n`;break}t+=`${s.at(45)}${e.join("")}\n`}return t+=`${s.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const s=this.charsets[e.version],r=t.trim().split(/\r?\n/),n=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=s.indexOf(r.shift());if(!(o>0))break;if(n.push(...r),45!==o){i=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;n.length%60;)n.push(" ")}return n.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const w=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},y=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};class m extends c{constructor(...t){super(),this.converter=new l(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}class v extends c{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.utils.inputHandler.toBytes(t,i)[0];let r=0,n=0,o="";const a=this.charsets[i.version];if(s.forEach((t=>{if(n+=t<13){let t,e,i=13,s=n%8192;s<89&&(i=14,s=n%16384),n>>=i,r-=i,[t,e]=this.#s(s,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#s(n,91),o=o.concat(a[e]),(r>7||n>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>s.includes(t))));let n=r.length,o=!1;n%2&&(o=!0,n--);let h=0,l=0;const c=new Array;for(let t=0;t88?13:14;do{c.push(h%256),h>>=8,l-=8}while(l>7)}if(o){const t=r.at(n),e=s.indexOf(t);c.push(((e<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){h.push(t);break}h.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){h.push(t);break}h.push(128|t)}const l=Uint8Array.from(h);return"hex"===i.version?this.hexlify.encode(l,[..."0123456789abcdef"],!1)[0]:l}decode(e,...i){const s=this.utils.validateArgs(i);if("hex"===s.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],s.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);e=Array.from(e);let r,n,o,a=0n,h=-7n;for(r of e)h+=7n,a+=BigInt(127&r)<{e.forEach((e=>{e in this.#r?this.#r[e].version+=t:this.#r[e]={version:t}}))},i=(e,i,s)=>{i.forEach((i=>{i in t?this.#r[i].version=3:(this.#r[i]={version:e,padding:s},t[i]=s)}))};e(1,this.charsets.emojis_v1),e(2,this.charsets.emojis_v2),i(1,this.padChars.emojis_v1.slice(0,-1),"last"),i(2,this.padChars.emojis_v2.slice(0,-1),"last"),i(1,this.padChars.emojis_v1.slice(-1),"fill"),i(2,this.padChars.emojis_v2.slice(-1),"fill");const s=[];for(const e in t)"last"===t[e]?s.push(e):s.push(`${e}+`);this.#n=new RegExp(s.join("|"),"g")}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version];let r=[...t];if(i>1){const t=this.converter.padBytes(i);if(e.padding){const i=e.trim?1:t,s=new Array(i).fill(this.padChars[e.version].at(-1));r.splice(r.length-t,t,...s)}else r.splice(r.length-t,t)}else if(1===i){const t=s.indexOf(r.pop())>>8;r.push(this.padChars[e.version].at(t))}return r.join("")}),...e)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);let s=i.version,r=null;"emojis_v1"!==i.version&&"emojis_v2"!==i.version||(r=3);const n=t=>{null!==r&&(r=this.#a(t,r,i.integrity),s=3===r?i.version:`emojis_v${r}`);const e=this.charsets[s],n=[...t],o=n.at(-1);let a=!1;for(let i=0;i{const r=s.index+s.at(0).length;e.push(...n(t.slice(i,r))),i=r})),i!==t.length&&e.push(...n(t.slice(i,t.length))),a=Uint8Array.from(e)}return this.utils.outputHandler.compile(a,i.outputType)}#a(t,e,i){const s=[...t];let r;if(s.forEach(((t,s)=>{if(!(t in this.#r))throw new a(t);{const n=this.#r[t].version;if(3!==n)if(3===e)e=n;else if(e!==n)throw new TypeError(`Emojis from different ecoji versions seen : ${t} from emojis_v${n}`);if(i){const e=this.#r[t].padding;if(e){const i=s%4;if(r=!0,"fill"===e){if(0===i)throw new TypeError(`Padding unexpectedly seen in first position ${t}`)}else if(3!==i)throw new TypeError(`Last padding seen in unexpected position ${t}`)}else if(r)throw new TypeError("Unexpectedly saw non-padding after padding")}}})),i&&s.length%4&&(1===e||"fill"!==this.#r[s.at(-1)].padding))throw new TypeError("Unexpected end of data, input data size not multiple of 4");return e}}class x extends c{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s=this.utils.inputHandler.toBytes(t,i).at(0);const r=this.charsets[i.version],n=this.padChars[i.version];let o="",a=0,h=0;if(s.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=r.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?n.at(a):r.at(a)}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const s=[...t],r=this.charsets[i.version],n=this.padChars[i.version],o=new Array;let h=0,l=0;return s.forEach(((t,e)=>{let c,u=r.indexOf(t);if(u>-1)c=this.converter.bsEnc;else if(u=n.indexOf(t),u>-1){if(e+1!==s.length)throw new a(null,`Secondary character found before end of input, index: ${e}`);c=this.converter.bsEncPad}else if(i.integrity)throw new a(t);for(let t=c-1;t>=0;t--)h=(h<<1)+(u>>t&1),l++,l===this.converter.bsDec&&(o.push(h),h=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(o),i.outputType)}}class T extends c{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new l(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}let M=1e6,j="[big.js] ",C=j+"Invalid ",$=C+"decimal places",I=C+"rounding mode",k={},B=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function _(t,e,i,s){let r=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error(I);if(e<1)s=3===i&&(s||!!r[0])||0===e&&(1===i&&r[0]>=5||2===i&&(r[0]>5||5===r[0]&&(s||void 0!==r[1]))),r.length=1,s?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e=5||2===i&&(r[e]>5||5===r[e]&&(s||void 0!==r[e+1]||1&r[e-1]))||3===i&&(s||!!r[0]),r.length=e,s)for(;++r[--e]>9;)if(r[e]=0,0===e){++t.e,r.unshift(1);break}for(e=r.length;!r[--e];)r.pop()}return t}function S(t,e,i){let s=t.e,r=t.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)r="0"+r;r="0."+r}else if(s>0)if(++s>n)for(s-=n;s--;)r+="0";else s1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&i?"-"+r:r}k.abs=function(){let t=new this.constructor(this);return t.s=1,t},k.cmp=function(t){let e,i=this,s=i.c,r=(t=new i.constructor(t)).c,n=i.s,o=t.s,a=i.e,h=t.e;if(!s[0]||!r[0])return s[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=h)return a>h^e?1:-1;for(o=(a=s.length)<(h=r.length)?a:h,n=-1;++nr[n]^e?1:-1;return a==h?0:a>h^e?1:-1},k.eq=function(t){return 0===this.cmp(t)},k.gt=function(t){return this.cmp(t)>0},k.gte=function(t){return this.cmp(t)>-1},k.lt=function(t){return this.cmp(t)<0},k.lte=function(t){return this.cmp(t)<1},k.minus=k.sub=function(t){let e,i,s,r,n=this,o=n.constructor,a=n.s,h=(t=new o(t)).s;if(a!=h)return t.s=-h,n.plus(t);let l=n.c.slice(),c=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-h:l[0]?t=new o(n):t.s=1,t;if(a=c-d){for((r=a<0)?(a=-a,s=l):(d=c,s=u),s.reverse(),h=a;h--;)s.push(0);s.reverse()}else for(i=((r=l.length0)for(;h--;)l[e++]=0;for(h=e;i>a;){if(l[--i]0?(h=o,s=l):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),e=l.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+l[e]+i)/10|0;for(i&&(a.unshift(i),++h),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=h,t},k.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-M||t>M)throw Error($);return _(new this.constructor(this),t+this.e+1,e)},k.toFixed=function(t,e){let i=this,s=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>M)throw Error($);for(i=_(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},k.toNumber=function(){let t=Number(S(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(j+"Imprecise conversion");return t};const N=function t(){function e(i){let s=this;if(!(s instanceof e))return void 0===i?t():new e(i);if(i instanceof e)s.s=i.s,s.e=i.e,s.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(C+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,s,r;if(!B.test(e))throw Error(`${C}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(i<0&&(i=s),i+=+e.slice(s+1),e=e.substring(0,s)):i<0&&(i=e.length),r=e.length,s=0;s0&&"0"==e.charAt(--r););for(t.e=i-s-1,t.c=[],i=0;s<=r;)t.c[i++]=+e.charAt(s++)}}(s,i)}s.constructor=e}return e.prototype=k,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();class U extends c{#h=N("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r,n,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(n=!0,o=N(-t)):(n=!1,o=N(t))}else[r,n]=this.utils.inputHandler.toBytes(t,i),o=N(this.b10.encode(r,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=s[o.toNumber()],n&&(a=`-${a}`),a;const h=[],l=[];let c=N(1),u=this.#h,d=0;for(;u.lt(o);)[c,u]=this.#l(c,u),d++;const f=(t,e,i)=>{if(!this.#c(o)){for(;t.gt(o);){if([t,e]=this.#u(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?h.unshift(i):l.push(i),o=o.minus(t),f(t,e,i)}};return f(c,u,d),d=0,h.forEach((t=>{for(;d{for(;d>t;)a+=s[0],d--;a+=s[1],d--})),n&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r;if([t,r]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...s,"."];t=[...t].filter((t=>e.includes(t))).join("")}const n=t.split(".");if(i.integrity&&n.length>2)throw new a(null,"There are multiple decimal points in the input.");const[o,h]=n;let l=N(0),c=this.#h.minus(1),u=N(1);if([...o].reverse().forEach((t=>{const e=s.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new a(t);[c,u]=this.#l(c,u)})),h){let t=N(1);u=this.#h.minus(t),[...h].forEach((e=>{const i=s.indexOf(e);if(1===i)l=l.plus(u);else if(0!==i)throw new a(e);[u,t]=this.#u(u,t)}))}if(i.decimalMode)return l.toNumber();l=l.round().toFixed();const d=this.b10.decode(l,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(d,i.outputType,i.littleEndian,r)}#c(t){return!t.round(50).abs().toNumber()}#l(t,e){return[e,t.plus(e)]}#u(t,e){return[e.minus(t),t]}}const D=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class P{constructor(...t){this.littleEndian=D,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,e=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const r=s.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!s.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${r}`);i.outputType=t}})),e)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e);return i.toBytes(t,s)[0]}decode(t,...e){const i=this.utils.validateArgs(e);return s.compile(t,i.outputType,i.littleEndian)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let s;return s="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,s}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,s;if(Number.isInteger(t)){if(s="int",!Number.isSafeInteger(t)){let e,i,s;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",s="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",s="MAX"),new RangeError(`The provided integer is ${i} than ${s}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else s="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),s]}static bigInts(t,e=!1){const i=new Array,s=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[s](t%r),t>>=64n;else for(;t>=r;)i[s](t%r),t>>=64n;i[s](t);const n=8*i.length,o=this.makeDataView(n);return i.forEach(((t,i)=>{const s=8*i;o.setBigUint64(s,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,s=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(s=!0,t=-t),e.numberMode){const s=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(s.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(s=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const s=new Array;for(const i of t)s.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(s)}}return[i,s,r]}}class s{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,s){const r=t.byteLength,n=(e-t.byteLength%e)%e,o=s&&r>1?255:0;let a=t;if(n){a=new Uint8Array(r+n),a.fill(o);const e=i?0:n;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,s){let r;if("int16"===e||"uint16"===e){const n=this.makeTypedArrayBuffer(t,2,i,s);r="int16"===e?new Int16Array(n):new Uint16Array(n)}else if("int32"===e||"uint32"===e||"float32"===e){const n=this.makeTypedArrayBuffer(t,4,i,s);r="int32"===e?new Int32Array(n):"uint32"===e?new Uint32Array(n):new Float32Array(n)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const n=this.makeTypedArrayBuffer(t,8,i,s);r="bigint64"===e?new BigInt64Array(n):"biguint64"===e?new BigUint64Array(n):new Float64Array(n)}return r}static compile(t,e,s=!1,r=!1){let n;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",s):-this.compile(t,"uint_n",s),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:s,numberMode:!1,signed:!1})[0]}if("buffer"===e)n=t.buffer;else if("bytes"===e||"uint8"===e)n=t;else if("int8"===e)n=new Int8Array(t.buffer);else if("view"===e)n=new DataView(t.buffer);else if("str"===e)n=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,s,r);t=new Uint8Array(e)}s&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),n="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);n=new DataView(e.buffer).getFloat32(0,s)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);n=new DataView(e.buffer).getFloat64(0,s)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);n=Number(e)}else n=this.makeTypedArray(t,e,s,r);return n}}const r=i,n=s;class o extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class a extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class h{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],s=!0)=>{const r=(t,i,s)=>{if(0===s&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=s;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===s)return[...i];if(r!==s)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${s}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";s<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const n=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${n.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");s&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const n=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=n,o.length&&(this.root.padChars[t]=o),s&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,s){throw new TypeError([`'${t}'\n\nParameters:`,s?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const c=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(c.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,c,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new o}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,s=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=s,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[c,l]=this.divmod(c,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(c,10));a.lengthu=u.concat(e[t]))),s&&(u=s(u,o)),n=n.concat(u)}return[n,o]}decode(t,e,i=[],s=!0,r=!1){if(!t)return new Uint8Array(0);let n=this.bsDec;const o=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)o.push(e);else if(s&&-1===i.indexOf(t))throw new a(t)})),0===n)n=o.length;else{l=(n-o.length%n)%n;const t=new Array(l).fill(this.decPadVal);r?o.unshift(...t):o.push(...t)}let c=new Array;for(let t=0,e=o.length;t(this.powers[s]=BigInt(this.pow(s)),this.powers[s]))();e+=BigInt(o[t+i])*r}const i=[];let s,r=e;for(;r>=256;)[r,s]=this.divmod(r,256),i.unshift(parseInt(s,10));for(i.unshift(parseInt(r,10));i.length1){for(;!c[0];)c.shift();c.length||c.push(0),c.reverse()}}else if(this.bsDec){const t=this.padChars(l);c.splice(c.length-t)}return Uint8Array.from(c)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class c{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new h(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...s){const r=this.utils.validateArgs(s);let[n,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,c]=this.converter.encode(n,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:n,output:l,settings:r,zeroPadding:c,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,s,...r){const n=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,s);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:n}));let a=this.converter.decode(t,this.charsets[n.version],this.padChars[n.version],n.integrity,n.littleEndian);return i&&(a=i({input:t,output:a,settings:n})),this.utils.outputHandler.compile(a,n.outputType,n.littleEndian,o)}}class u extends c{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new l(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s,r;[s,r]=this.utils.inputHandler.toBytes(t,i);let n=this.converter.encode(s,null,i.littleEndian)[0],o=BigInt(n);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],h=a.length;let l="";if(1===h)l=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(l=a.at(1).repeat((o-t)/5)),l+=a.at(0).repeat(t)}else for(let t=0;t(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}class f extends c{constructor(...t){super(),this.converter=new l(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class p extends c{constructor(...t){super(),this.converter=new l(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:s})=>{if(i.padding&&"int"!==s){let s=0;const r=t.length,n=this.charsets[i.version].at(0);if(r){for(;!t[s];)if(s++,s===r){s=0;break}const i=s;i&&(e=n.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const s=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===s;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}class g extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class b extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||w()} ${e.options.file||m()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${s.at(r)}${e.join("")}\n`;break}t+=`${s.at(45)}${e.join("")}\n`}return t+=`${s.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const s=this.charsets[e.version],r=t.trim().split(/\r?\n/),n=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=s.indexOf(r.shift());if(!(o>0))break;if(n.push(...r),45!==o){i=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;n.length%60;)n.push(" ")}return n.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const w=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},m=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};class y extends c{constructor(...t){super(),this.converter=new l(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}class v extends c{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.utils.inputHandler.toBytes(t,i)[0];let r=0,n=0,o="";const a=this.charsets[i.version];if(s.forEach((t=>{if(n+=t<13){let t,e,i=13,s=n%8192;s<89&&(i=14,s=n%16384),n>>=i,r-=i,[t,e]=this.#s(s,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#s(n,91),o=o.concat(a[e]),(r>7||n>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>s.includes(t))));let n=r.length,o=!1;n%2&&(o=!0,n--);let h=0,l=0;const c=new Array;for(let t=0;t88?13:14;do{c.push(h%256),h>>=8,l-=8}while(l>7)}if(o){const t=r.at(n),e=s.indexOf(t);c.push(((e<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){h.push(t);break}h.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){h.push(t);break}h.push(128|t)}const l=Uint8Array.from(h);return"hex"===i.version?this.hexlify.encode(l,[..."0123456789abcdef"],!1)[0]:l}decode(e,...i){const s=this.utils.validateArgs(i);if("hex"===s.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],s.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);e=Array.from(e);let r,n,o,a=0n,h=-7n;for(r of e)h+=7n,a+=BigInt(127&r)<{e.forEach((e=>{e in this.#r?this.#r[e].version+=t:this.#r[e]={version:t}}))},i=(e,i,s)=>{i.forEach((i=>{i in t?this.#r[i].version=3:(this.#r[i]={version:e,padding:s},t[i]=s)}))};e(1,this.charsets.emojis_v1),e(2,this.charsets.emojis_v2),i(1,this.padChars.emojis_v1.slice(0,-1),"last"),i(2,this.padChars.emojis_v2.slice(0,-1),"last"),i(1,this.padChars.emojis_v1.slice(-1),"fill"),i(2,this.padChars.emojis_v2.slice(-1),"fill");const s=[];for(const e in t)"last"===t[e]?s.push(e):s.push(`${e}+`);this.#n=new RegExp(s.join("|"),"g")}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version];let r=[...t];if(i>1){const t=this.converter.padBytes(i);if(e.padding){const i=e.trim?1:t,s=new Array(i).fill(this.padChars[e.version].at(-1));r.splice(r.length-t,t,...s)}else r.splice(r.length-t,t)}else if(1===i){const t=s.indexOf(r.pop())>>8;r.push(this.padChars[e.version].at(t))}return r.join("")}),...e)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);let s=i.version,r=null;"emojis_v1"!==i.version&&"emojis_v2"!==i.version||(r=3);const n=t=>{null!==r&&(r=this.#a(t,r,i.integrity),s=3===r?i.version:`emojis_v${r}`);const e=this.charsets[s],n=[...t],o=n.at(-1);let a=!1;for(let i=0;i{const r=s.index+s.at(0).length;e.push(...n(t.slice(i,r))),i=r})),i!==t.length&&e.push(...n(t.slice(i,t.length))),a=Uint8Array.from(e)}return this.utils.outputHandler.compile(a,i.outputType)}#a(t,e,i){const s=[...t];let r;if(s.forEach(((t,s)=>{if(!(t in this.#r))throw new a(t);{const n=this.#r[t].version;if(3!==n)if(3===e)e=n;else if(e!==n)throw new TypeError(`Emojis from different ecoji versions seen : ${t} from emojis_v${n}`);if(i){const e=this.#r[t].padding;if(e){const i=s%4;if(r=!0,"fill"===e){if(0===i)throw new TypeError(`Padding unexpectedly seen in first position ${t}`)}else if(3!==i)throw new TypeError(`Last padding seen in unexpected position ${t}`)}else if(r)throw new TypeError("Unexpectedly saw non-padding after padding")}}})),i&&s.length%4&&(1===e||"fill"!==this.#r[s.at(-1)].padding))throw new TypeError("Unexpected end of data, input data size not multiple of 4");return e}}class x extends c{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s=this.utils.inputHandler.toBytes(t,i).at(0);const r=this.charsets[i.version],n=this.padChars[i.version];let o="",a=0,h=0;if(s.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=r.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?n.at(a):r.at(a)}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const s=[...t],r=this.charsets[i.version],n=this.padChars[i.version],o=new Array;let h=0,l=0;return s.forEach(((t,e)=>{let c,u=r.indexOf(t);if(u>-1)c=this.converter.bsEnc;else if(u=n.indexOf(t),u>-1){if(e+1!==s.length)throw new a(null,`Secondary character found before end of input, index: ${e}`);c=this.converter.bsEncPad}else if(i.integrity)throw new a(t);for(let t=c-1;t>=0;t--)h=(h<<1)+(u>>t&1),l++,l===this.converter.bsDec&&(o.push(h),h=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(o),i.outputType)}}class T extends c{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new l(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}let M=1e6,j="[big.js] ",C=j+"Invalid ",I=C+"decimal places",$=C+"rounding mode",k={},B=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function _(t,e,i,s){let r=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error($);if(e<1)s=3===i&&(s||!!r[0])||0===e&&(1===i&&r[0]>=5||2===i&&(r[0]>5||5===r[0]&&(s||void 0!==r[1]))),r.length=1,s?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e=5||2===i&&(r[e]>5||5===r[e]&&(s||void 0!==r[e+1]||1&r[e-1]))||3===i&&(s||!!r[0]),r.length=e,s)for(;++r[--e]>9;)if(r[e]=0,0===e){++t.e,r.unshift(1);break}for(e=r.length;!r[--e];)r.pop()}return t}function S(t,e,i){let s=t.e,r=t.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)r="0"+r;r="0."+r}else if(s>0)if(++s>n)for(s-=n;s--;)r+="0";else s1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&i?"-"+r:r}k.abs=function(){let t=new this.constructor(this);return t.s=1,t},k.cmp=function(t){let e,i=this,s=i.c,r=(t=new i.constructor(t)).c,n=i.s,o=t.s,a=i.e,h=t.e;if(!s[0]||!r[0])return s[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=h)return a>h^e?1:-1;for(o=(a=s.length)<(h=r.length)?a:h,n=-1;++nr[n]^e?1:-1;return a==h?0:a>h^e?1:-1},k.eq=function(t){return 0===this.cmp(t)},k.gt=function(t){return this.cmp(t)>0},k.gte=function(t){return this.cmp(t)>-1},k.lt=function(t){return this.cmp(t)<0},k.lte=function(t){return this.cmp(t)<1},k.minus=k.sub=function(t){let e,i,s,r,n=this,o=n.constructor,a=n.s,h=(t=new o(t)).s;if(a!=h)return t.s=-h,n.plus(t);let l=n.c.slice(),c=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-h:l[0]?t=new o(n):t.s=1,t;if(a=c-d){for((r=a<0)?(a=-a,s=l):(d=c,s=u),s.reverse(),h=a;h--;)s.push(0);s.reverse()}else for(i=((r=l.length0)for(;h--;)l[e++]=0;for(h=e;i>a;){if(l[--i]0?(h=o,s=l):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),e=l.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+l[e]+i)/10|0;for(i&&(a.unshift(i),++h),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=h,t},k.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-M||t>M)throw Error(I);return _(new this.constructor(this),t+this.e+1,e)},k.toFixed=function(t,e){let i=this,s=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>M)throw Error(I);for(i=_(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},k.toNumber=function(){let t=Number(S(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(j+"Imprecise conversion");return t};const N=function t(){function e(i){let s=this;if(!(s instanceof e))return void 0===i?t():new e(i);if(i instanceof e)s.s=i.s,s.e=i.e,s.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(C+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,s,r;if(!B.test(e))throw Error(`${C}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(i<0&&(i=s),i+=+e.slice(s+1),e=e.substring(0,s)):i<0&&(i=e.length),r=e.length,s=0;s0&&"0"==e.charAt(--r););for(t.e=i-s-1,t.c=[],i=0;s<=r;)t.c[i++]=+e.charAt(s++)}}(s,i)}s.constructor=e}return e.prototype=k,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();class U extends c{#h=N("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r,n,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(n=!0,o=N(-t)):(n=!1,o=N(t))}else[r,n]=this.utils.inputHandler.toBytes(t,i),o=N(this.b10.encode(r,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=s[o.toNumber()],n&&(a=`-${a}`),a;const h=[],l=[];let c=N(1),u=this.#h,d=0;for(;u.lt(o);)[c,u]=this.#l(c,u),d++;const f=(t,e,i)=>{if(!this.#c(o)){for(;t.gt(o);){if([t,e]=this.#u(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?h.unshift(i):l.push(i),o=o.minus(t),f(t,e,i)}};return f(c,u,d),d=0,h.forEach((t=>{for(;d{for(;d>t;)a+=s[0],d--;a+=s[1],d--})),n&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r;if([t,r]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...s,"."];t=[...t].filter((t=>e.includes(t))).join("")}const n=t.split(".");if(i.integrity&&n.length>2)throw new a(null,"There are multiple decimal points in the input.");const[o,h]=n;let l=N(0),c=this.#h.minus(1),u=N(1);if([...o].reverse().forEach((t=>{const e=s.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new a(t);[c,u]=this.#l(c,u)})),h){let t=N(1);u=this.#h.minus(t),[...h].forEach((e=>{const i=s.indexOf(e);if(1===i)l=l.plus(u);else if(0!==i)throw new a(e);[u,t]=this.#u(u,t)}))}if(i.decimalMode)return l.toNumber();l=l.round().toFixed();const d=this.b10.decode(l,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(d,i.outputType,i.littleEndian,r)}#c(t){return!t.round(50).abs().toNumber()}#l(t,e){return[e,t.plus(e)]}#u(t,e){return[e.minus(t),t]}}const D=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class P{constructor(...t){this.littleEndian=D,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,e=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const r=s.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!s.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${r}`);i.outputType=t}})),e)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e);return i.toBytes(t,s)[0]}decode(t,...e){const i=this.utils.validateArgs(e);return s.compile(t,i.outputType,i.littleEndian)}} /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */class O{constructor(t="buffer"){if(!n.typeList.includes(t)){let e=`Invalid argument '${t}' for output type. Allowed types are:\n`;throw e=e.concat(n.typeList.join(", ")),new TypeError(e)}this.base1=new u("default",t),this.base16=new d("default",t),this.base32_crockford=new f("rfc4648",t),this.base32_rfc3548=new f("rfc3548",t),this.base32_rfc4648=new f("rfc4648",t),this.base32_zbase32=new f("zbase32",t),this.base58=new p("default",t),this.base58_bitcoin=new p("bitcoin",t),this.base58_flickr=new p("flickr",t),this.base64=new g("default",t),this.base64_urlsafe=new g("urlsafe",t),this.uuencode=new b("default",t),this.uuencode_original=new b("original",t),this.xxencode=new b("xx",t),this.base85_adobe=new m("adobe",t),this.base85_ascii=new m("ascii85",t),this.base85_z85=new m("z85",t),this.base91=new v("default",t),this.leb128=new E("default",t),this.ecoji_v1=new A("emojis_v1",t),this.ecoji_v2=new A("emojis_v2",t),this.base2048=new x("default",t),this.basePhi=new U("default",t),this.byteConverter=new P(t),this.simpleBase={};for(let e=2;e<=62;e++)this.simpleBase[`base${e}`]=new T(e,t)}}export{u as Base1,d as Base16,x as Base2048,f as Base32,p as Base58,g as Base64,m as Base85,v as Base91,O as BaseEx,U as BasePhi,P as ByteConverter,A as Ecoji,E as LEB128,T as SimpleBase,b as UUencode}; + */class O{constructor(t="buffer"){if(!n.typeList.includes(t)){let e=`Invalid argument '${t}' for output type. Allowed types are:\n`;throw e=e.concat(n.typeList.join(", ")),new TypeError(e)}this.base1=new u("default",t),this.base16=new d("default",t),this.base32_crockford=new f("rfc4648",t),this.base32_rfc3548=new f("rfc3548",t),this.base32_rfc4648=new f("rfc4648",t),this.base32_zbase32=new f("zbase32",t),this.base58=new p("default",t),this.base58_bitcoin=new p("bitcoin",t),this.base58_flickr=new p("flickr",t),this.base64=new g("default",t),this.base64_urlsafe=new g("urlsafe",t),this.uuencode=new b("default",t),this.uuencode_original=new b("original",t),this.xxencode=new b("xx",t),this.base85_adobe=new y("adobe",t),this.base85_ascii=new y("ascii85",t),this.base85_z85=new y("z85",t),this.base91=new v("default",t),this.leb128=new E("default",t),this.ecoji_v1=new A("emojis_v1",t),this.ecoji_v2=new A("emojis_v2",t),this.base2048=new x("default",t),this.basePhi=new U("default",t),this.byteConverter=new P(t),this.simpleBase={};for(let e=2;e<=62;e++)this.simpleBase[`base${e}`]=new T(e,t)}}export{u as Base1,d as Base16,x as Base2048,f as Base32,p as Base58,g as Base64,y as Base85,v as Base91,O as BaseEx,U as BasePhi,P as ByteConverter,A as Ecoji,E as LEB128,T as SimpleBase,b as UUencode}; diff --git a/dist/base-ex.iife.js b/dist/base-ex.iife.js index 87b083b..de43f3b 100644 --- a/dist/base-ex.iife.js +++ b/dist/base-ex.iife.js @@ -979,6 +979,7 @@ var BaseEx = (function (exports) { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1152,19 +1153,25 @@ var BaseEx = (function (exports) { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var BaseEx = (function (exports) { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var BaseEx = (function (exports) { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1611,7 +1624,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-16.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1700,7 +1713,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1806,7 +1819,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -1957,7 +1970,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2046,7 +2059,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2259,7 +2272,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2383,7 +2396,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ @@ -2617,7 +2630,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -2783,7 +2796,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT OR Apache-2.0 * @see https://github.com/keith-turner/ecoji @@ -3126,7 +3139,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3305,7 +3318,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3406,7 +3419,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3744,7 +3757,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ @@ -3863,7 +3876,7 @@ var BaseEx = (function (exports) { /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/base-ex.iife.min.js b/dist/base-ex.iife.min.js index fbfa8a9..53e11ea 100644 --- a/dist/base-ex.iife.min.js +++ b/dist/base-ex.iife.min.js @@ -1,8 +1,8 @@ -var BaseEx=function(t){"use strict";class e{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class i{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!i.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,e){let s;return s="buffer"===(e=i.getType(e))?t.buffer:"view"===e?new DataView(t.buffer):t,s}}class s{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,s;if(Number.isInteger(t)){if(s="int",!Number.isSafeInteger(t)){let e,i,s;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",s="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",s="MAX"),new RangeError(`The provided integer is ${i} than ${s}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else s="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),s]}static bigInts(t,e=!1){const i=new Array,s=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[s](t%r),t>>=64n;else for(;t>=r;)i[s](t%r),t>>=64n;i[s](t);const n=8*i.length,o=this.makeDataView(n);return i.forEach(((t,i)=>{const s=8*i;o.setBigUint64(s,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,s=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(s=!0,t=-t),e.numberMode){const s=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(s.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(s=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const s=new Array;for(const i of t)s.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(s)}}return[i,s,r]}}class r{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,s){const r=t.byteLength,n=(e-t.byteLength%e)%e,o=s&&r>1?255:0;let a=t;if(n){a=new Uint8Array(r+n),a.fill(o);const e=i?0:n;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,s){let r;if("int16"===e||"uint16"===e){const n=this.makeTypedArrayBuffer(t,2,i,s);r="int16"===e?new Int16Array(n):new Uint16Array(n)}else if("int32"===e||"uint32"===e||"float32"===e){const n=this.makeTypedArrayBuffer(t,4,i,s);r="int32"===e?new Int32Array(n):"uint32"===e?new Uint32Array(n):new Float32Array(n)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const n=this.makeTypedArrayBuffer(t,8,i,s);r="bigint64"===e?new BigInt64Array(n):"biguint64"===e?new BigUint64Array(n):new Float64Array(n)}return r}static compile(t,e,i=!1,r=!1){let n;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=s.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)n=t.buffer;else if("bytes"===e||"uint8"===e)n=t;else if("int8"===e)n=new Int8Array(t.buffer);else if("view"===e)n=new DataView(t.buffer);else if("str"===e)n=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let s=0n;t.forEach((t=>s=(s<<8n)+BigInt(t))),"uint_n"!==e&&(s=BigInt.asIntN(8*t.length,s)),n="bigint_n"!==e&&s>=Number.MIN_SAFE_INTEGER&&s<=Number.MAX_SAFE_INTEGER?Number(s):s}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);n=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);n=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);n=Number(e)}else n=this.makeTypedArray(t,e,i,r);return n}}const n=s,o=r;class a extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class h extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class l{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=o){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],s=!0)=>{const r=(t,i,s)=>{if(0===s&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=s;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===s)return[...i];if(r!==s)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${s}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";s<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const n=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${n.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");s&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const n=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=n,o.length&&(this.root.padChars[t]=o),s&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,s){throw new TypeError([`'${t}'\n\nParameters:`,s?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(t,s=!1){const r={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)r[t]=this.root[t];if(!t.length)return s&&this.setIOHandlers(),r;const a=e=>!!t.includes(e)&&(t.splice(t.indexOf(e),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(e,i);else{const t=a("bytes_in")?e:n,s=a("bytes_out")?i:o;this.setIOHandlers(t,s)}const c=this.outputHandler.typeList;if(a("number")&&(r.numberMode=!0,r.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");r.decimalMode=!0,r.outputType="decimal",r.numberMode&&(r.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(t.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))r.version=t;else if(c.includes(t))r.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);r[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,c,s)}else r.options={...r.options,...t}})),r.padding&&r.signed&&(r.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in r)this.root[t]=r[t];return r}signError(){throw new a}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class c{constructor(t,e=null,i=null,s=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=s}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[c,l]=this.divmod(c,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(c,10));a.lengthu=u.concat(e[t]))),s&&(u=s(u,o)),n=n.concat(u)}return[n,o]}decode(t,e,i=[],s=!0,r=!1){if(!t)return new Uint8Array(0);let n=this.bsDec;const o=new Array;let a;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)o.push(r);else if(s&&-1===i.indexOf(t))throw new h(t)})),0===n)n=o.length;else{a=(n-o.length%n)%n;const t=new Array(a).fill(this.decPadVal);r?o.unshift(...t):o.push(...t)}let l=new Array;for(let t=0,e=o.length;t=256;)[r,s]=this.divmod(r,256),i.unshift(parseInt(s,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(a);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class u{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new l(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...s){const r=this.utils.validateArgs(s);let[n,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,c]=this.converter.encode(n,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:n,output:l,settings:r,zeroPadding:c,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,s,...r){const n=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,s);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:n}));let a=this.converter.decode(t,this.charsets[n.version],this.padChars[n.version],n.integrity,n.littleEndian);return i&&(a=i({input:t,output:a,settings:n})),this.utils.outputHandler.compile(a,n.outputType,n.littleEndian,o)}}class d extends u{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new c(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s,r;[s,r]=this.utils.inputHandler.toBytes(t,i);let n=this.converter.encode(s,null,i.littleEndian)[0],o=BigInt(n);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],h=a.length;let l="";if(1===h)l=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(l=a.at(1).repeat((o-t)/5)),l+=a.at(0).repeat(t)}else for(let t=0;t(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}class p extends u{constructor(...t){super(),this.converter=new c(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class g extends u{constructor(...t){super(),this.converter=new c(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:s})=>{if(i.padding&&"int"!==s){let s=0;const r=t.length,n=this.charsets[i.version].at(0);if(r){for(;!t[s];)if(s++,s===r){s=0;break}const i=s;i&&(e=n.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const s=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===s;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}class b extends u{constructor(...t){super(),this.converter=new c(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class y extends u{constructor(...t){super(),this.converter=new c(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||w()} ${e.options.file||m()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${s.at(r)}${e.join("")}\n`;break}t+=`${s.at(45)}${e.join("")}\n`}return t+=`${s.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const s=this.charsets[e.version],r=t.trim().split(/\r?\n/),n=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=s.indexOf(r.shift());if(!(o>0))break;if(n.push(...r),45!==o){i=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;n.length%60;)n.push(" ")}return n.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const w=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},m=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};class v extends u{constructor(...t){super(),this.converter=new c(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}class E extends u{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.utils.inputHandler.toBytes(t,i)[0];let r=0,n=0,o="";const a=this.charsets[i.version];if(s.forEach((t=>{if(n+=t<13){let t,e,i=13,s=n%8192;s<89&&(i=14,s=n%16384),n>>=i,r-=i,[t,e]=this.#s(s,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#s(n,91),o=o.concat(a[e]),(r>7||n>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>s.includes(t))));let n=r.length,o=!1;n%2&&(o=!0,n--);let a=0,l=0;const c=new Array;for(let t=0;t88?13:14;do{c.push(a%256),a>>=8,l-=8}while(l>7)}if(o){const t=r.at(n),e=s.indexOf(t);c.push(((e<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){h.push(t);break}h.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){h.push(t);break}h.push(128|t)}const l=Uint8Array.from(h);return"hex"===i.version?this.hexlify.encode(l,[..."0123456789abcdef"],!1)[0]:l}decode(t,...i){const s=this.utils.validateArgs(i);if("hex"===s.version)t=this.hexlify.decode(this.utils.normalizeInput(t).toLowerCase(),[..."0123456789abcdef"],[],s.integrity,!1);else{if(void 0===t.byteLength)throw new TypeError("Input must be a bytes like object.");t=e.toBytes(t)[0]}if(1===t.length&&!t[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);t=Array.from(t);let r,n,o,a=0n,h=-7n;for(r of t)h+=7n,a+=BigInt(127&r)<{e.forEach((e=>{e in this.#r?this.#r[e].version+=t:this.#r[e]={version:t}}))},i=(e,i,s)=>{i.forEach((i=>{i in t?this.#r[i].version=3:(this.#r[i]={version:e,padding:s},t[i]=s)}))};e(1,this.charsets.emojis_v1),e(2,this.charsets.emojis_v2),i(1,this.padChars.emojis_v1.slice(0,-1),"last"),i(2,this.padChars.emojis_v2.slice(0,-1),"last"),i(1,this.padChars.emojis_v1.slice(-1),"fill"),i(2,this.padChars.emojis_v2.slice(-1),"fill");const s=[];for(const e in t)"last"===t[e]?s.push(e):s.push(`${e}+`);this.#n=new RegExp(s.join("|"),"g")}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version];let r=[...t];if(i>1){const t=this.converter.padBytes(i);if(e.padding){const i=e.trim?1:t,s=new Array(i).fill(this.padChars[e.version].at(-1));r.splice(r.length-t,t,...s)}else r.splice(r.length-t,t)}else if(1===i){const t=s.indexOf(r.pop())>>8;r.push(this.padChars[e.version].at(t))}return r.join("")}),...e)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);let s=i.version,r=null;"emojis_v1"!==i.version&&"emojis_v2"!==i.version||(r=3);const n=t=>{null!==r&&(r=this.#a(t,r,i.integrity),s=3===r?i.version:`emojis_v${r}`);const e=this.charsets[s],n=[...t],o=n.at(-1);let a=!1;for(let i=0;i{const r=s.index+s.at(0).length;e.push(...n(t.slice(i,r))),i=r})),i!==t.length&&e.push(...n(t.slice(i,t.length))),a=Uint8Array.from(e)}return this.utils.outputHandler.compile(a,i.outputType)}#a(t,e,i){const s=[...t];let r;if(s.forEach(((t,s)=>{if(!(t in this.#r))throw new h(t);{const n=this.#r[t].version;if(3!==n)if(3===e)e=n;else if(e!==n)throw new TypeError(`Emojis from different ecoji versions seen : ${t} from emojis_v${n}`);if(i){const e=this.#r[t].padding;if(e){const i=s%4;if(r=!0,"fill"===e){if(0===i)throw new TypeError(`Padding unexpectedly seen in first position ${t}`)}else if(3!==i)throw new TypeError(`Last padding seen in unexpected position ${t}`)}else if(r)throw new TypeError("Unexpectedly saw non-padding after padding")}}})),i&&s.length%4&&(1===e||"fill"!==this.#r[s.at(-1)].padding))throw new TypeError("Unexpected end of data, input data size not multiple of 4");return e}}class T extends u{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s=this.utils.inputHandler.toBytes(t,i).at(0);const r=this.charsets[i.version],n=this.padChars[i.version];let o="",a=0,h=0;if(s.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=r.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?n.at(a):r.at(a)}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const s=[...t],r=this.charsets[i.version],n=this.padChars[i.version],o=new Array;let a=0,l=0;return s.forEach(((t,e)=>{let c,u=r.indexOf(t);if(u>-1)c=this.converter.bsEnc;else if(u=n.indexOf(t),u>-1){if(e+1!==s.length)throw new h(null,`Secondary character found before end of input, index: ${e}`);c=this.converter.bsEncPad}else if(i.integrity)throw new h(t);for(let t=c-1;t>=0;t--)a=(a<<1)+(u>>t&1),l++,l===this.converter.bsDec&&(o.push(a),a=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(o),i.outputType)}}class M extends u{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new c(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}let j=1e6,B="[big.js] ",C=B+"Invalid ",$=C+"decimal places",I=C+"rounding mode",k={},_=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function S(t,e,i,s){let r=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error(I);if(e<1)s=3===i&&(s||!!r[0])||0===e&&(1===i&&r[0]>=5||2===i&&(r[0]>5||5===r[0]&&(s||void 0!==r[1]))),r.length=1,s?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e=5||2===i&&(r[e]>5||5===r[e]&&(s||void 0!==r[e+1]||1&r[e-1]))||3===i&&(s||!!r[0]),r.length=e,s)for(;++r[--e]>9;)if(r[e]=0,0===e){++t.e,r.unshift(1);break}for(e=r.length;!r[--e];)r.pop()}return t}function N(t,e,i){let s=t.e,r=t.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)r="0"+r;r="0."+r}else if(s>0)if(++s>n)for(s-=n;s--;)r+="0";else s1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&i?"-"+r:r}k.abs=function(){let t=new this.constructor(this);return t.s=1,t},k.cmp=function(t){let e,i=this,s=i.c,r=(t=new i.constructor(t)).c,n=i.s,o=t.s,a=i.e,h=t.e;if(!s[0]||!r[0])return s[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=h)return a>h^e?1:-1;for(o=(a=s.length)<(h=r.length)?a:h,n=-1;++nr[n]^e?1:-1;return a==h?0:a>h^e?1:-1},k.eq=function(t){return 0===this.cmp(t)},k.gt=function(t){return this.cmp(t)>0},k.gte=function(t){return this.cmp(t)>-1},k.lt=function(t){return this.cmp(t)<0},k.lte=function(t){return this.cmp(t)<1},k.minus=k.sub=function(t){let e,i,s,r,n=this,o=n.constructor,a=n.s,h=(t=new o(t)).s;if(a!=h)return t.s=-h,n.plus(t);let l=n.c.slice(),c=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-h:l[0]?t=new o(n):t.s=1,t;if(a=c-d){for((r=a<0)?(a=-a,s=l):(d=c,s=u),s.reverse(),h=a;h--;)s.push(0);s.reverse()}else for(i=((r=l.length0)for(;h--;)l[e++]=0;for(h=e;i>a;){if(l[--i]0?(h=o,s=l):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),e=l.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+l[e]+i)/10|0;for(i&&(a.unshift(i),++h),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=h,t},k.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-j||t>j)throw Error($);return S(new this.constructor(this),t+this.e+1,e)},k.toFixed=function(t,e){let i=this,s=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>j)throw Error($);for(i=S(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},k.toNumber=function(){let t=Number(N(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(B+"Imprecise conversion");return t};const U=function t(){function e(i){let s=this;if(!(s instanceof e))return void 0===i?t():new e(i);if(i instanceof e)s.s=i.s,s.e=i.e,s.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(C+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,s,r;if(!_.test(e))throw Error(`${C}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(i<0&&(i=s),i+=+e.slice(s+1),e=e.substring(0,s)):i<0&&(i=e.length),r=e.length,s=0;s0&&"0"==e.charAt(--r););for(t.e=i-s-1,t.c=[],i=0;s<=r;)t.c[i++]=+e.charAt(s++)}}(s,i)}s.constructor=e}return e.prototype=k,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();class D extends u{#h=U("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new c(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r,n,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(n=!0,o=U(-t)):(n=!1,o=U(t))}else[r,n]=this.utils.inputHandler.toBytes(t,i),o=U(this.b10.encode(r,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=s[o.toNumber()],n&&(a=`-${a}`),a;const h=[],l=[];let c=U(1),u=this.#h,d=0;for(;u.lt(o);)[c,u]=this.#l(c,u),d++;const f=(t,e,i)=>{if(!this.#c(o)){for(;t.gt(o);){if([t,e]=this.#u(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?h.unshift(i):l.push(i),o=o.minus(t),f(t,e,i)}};return f(c,u,d),d=0,h.forEach((t=>{for(;d{for(;d>t;)a+=s[0],d--;a+=s[1],d--})),n&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r;if([t,r]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...s,"."];t=[...t].filter((t=>e.includes(t))).join("")}const n=t.split(".");if(i.integrity&&n.length>2)throw new h(null,"There are multiple decimal points in the input.");const[o,a]=n;let l=U(0),c=this.#h.minus(1),u=U(1);if([...o].reverse().forEach((t=>{const e=s.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new h(t);[c,u]=this.#l(c,u)})),a){let t=U(1);u=this.#h.minus(t),[...a].forEach((e=>{const i=s.indexOf(e);if(1===i)l=l.plus(u);else if(0!==i)throw new h(e);[u,t]=this.#u(u,t)}))}if(i.decimalMode)return l.toNumber();l=l.round().toFixed();const d=this.b10.decode(l,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(d,i.outputType,i.littleEndian,r)}#c(t){return!t.round(50).abs().toNumber()}#l(t,e){return[e,t.plus(e)]}#u(t,e){return[e.minus(t),t]}}const P=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class O{constructor(...t){this.littleEndian=P,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,e=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const s=r.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!r.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${s}`);i.outputType=t}})),e)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);return s.toBytes(t,i)[0]}decode(t,...e){const i=this.utils.validateArgs(e);return r.compile(t,i.outputType,i.littleEndian)}} +var BaseEx=function(t){"use strict";class e{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class i{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!i.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,e){let s;return s="buffer"===(e=i.getType(e))?t.buffer:"view"===e?new DataView(t.buffer):t,s}}class s{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,s;if(Number.isInteger(t)){if(s="int",!Number.isSafeInteger(t)){let e,i,s;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",s="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",s="MAX"),new RangeError(`The provided integer is ${i} than ${s}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else s="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),s]}static bigInts(t,e=!1){const i=new Array,s=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[s](t%r),t>>=64n;else for(;t>=r;)i[s](t%r),t>>=64n;i[s](t);const n=8*i.length,o=this.makeDataView(n);return i.forEach(((t,i)=>{const s=8*i;o.setBigUint64(s,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,s=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(s=!0,t=-t),e.numberMode){const s=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(s.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(s=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const s=new Array;for(const i of t)s.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(s)}}return[i,s,r]}}class r{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,s){const r=t.byteLength,n=(e-t.byteLength%e)%e,o=s&&r>1?255:0;let a=t;if(n){a=new Uint8Array(r+n),a.fill(o);const e=i?0:n;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,s){let r;if("int16"===e||"uint16"===e){const n=this.makeTypedArrayBuffer(t,2,i,s);r="int16"===e?new Int16Array(n):new Uint16Array(n)}else if("int32"===e||"uint32"===e||"float32"===e){const n=this.makeTypedArrayBuffer(t,4,i,s);r="int32"===e?new Int32Array(n):"uint32"===e?new Uint32Array(n):new Float32Array(n)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const n=this.makeTypedArrayBuffer(t,8,i,s);r="bigint64"===e?new BigInt64Array(n):"biguint64"===e?new BigUint64Array(n):new Float64Array(n)}return r}static compile(t,e,i=!1,r=!1){let n;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=s.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)n=t.buffer;else if("bytes"===e||"uint8"===e)n=t;else if("int8"===e)n=new Int8Array(t.buffer);else if("view"===e)n=new DataView(t.buffer);else if("str"===e)n=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let s=0n;t.forEach((t=>s=(s<<8n)+BigInt(t))),"uint_n"!==e&&(s=BigInt.asIntN(8*t.length,s)),n="bigint_n"!==e&&s>=Number.MIN_SAFE_INTEGER&&s<=Number.MAX_SAFE_INTEGER?Number(s):s}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);n=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);n=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);n=Number(e)}else n=this.makeTypedArray(t,e,i,r);return n}}const n=s,o=r;class a extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class h extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class l{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=o){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],s=!0)=>{const r=(t,i,s)=>{if(0===s&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=s;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===s)return[...i];if(r!==s)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${s}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";s<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const n=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${n.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");s&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const n=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=n,o.length&&(this.root.padChars[t]=o),s&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,s){throw new TypeError([`'${t}'\n\nParameters:`,s?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(t,s=!1){const r={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)r[t]=this.root[t];if(!t.length)return s&&this.setIOHandlers(),r;const a=e=>!!t.includes(e)&&(t.splice(t.indexOf(e),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(e,i);else{const t=a("bytes_in")?e:n,s=a("bytes_out")?i:o;this.setIOHandlers(t,s)}const c=this.outputHandler.typeList;if(a("number")&&(r.numberMode=!0,r.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");r.decimalMode=!0,r.outputType="decimal",r.numberMode&&(r.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(t.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))r.version=t;else if(c.includes(t))r.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);r[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,c,s)}else r.options={...r.options,...t}})),r.padding&&r.signed&&(r.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in r)this.root[t]=r[t];return r}signError(){throw new a}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class c{constructor(t,e=null,i=null,s=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=s,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[c,l]=this.divmod(c,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(c,10));a.lengthu=u.concat(e[t]))),s&&(u=s(u,o)),n=n.concat(u)}return[n,o]}decode(t,e,i=[],s=!0,r=!1){if(!t)return new Uint8Array(0);let n=this.bsDec;const o=[],a=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=a[t];if(void 0!==e)o.push(e);else if(s&&-1===i.indexOf(t))throw new h(t)})),0===n)n=o.length;else{l=(n-o.length%n)%n;const t=new Array(l).fill(this.decPadVal);r?o.unshift(...t):o.push(...t)}let c=new Array;for(let t=0,e=o.length;t(this.powers[s]=BigInt(this.pow(s)),this.powers[s]))();e+=BigInt(o[t+i])*r}const i=[];let s,r=e;for(;r>=256;)[r,s]=this.divmod(r,256),i.unshift(parseInt(s,10));for(i.unshift(parseInt(r,10));i.length1){for(;!c[0];)c.shift();c.length||c.push(0),c.reverse()}}else if(this.bsDec){const t=this.padChars(l);c.splice(c.length-t)}return Uint8Array.from(c)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class u{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new l(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...s){const r=this.utils.validateArgs(s);let[n,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,c]=this.converter.encode(n,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:n,output:l,settings:r,zeroPadding:c,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,s,...r){const n=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,s);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:n}));let a=this.converter.decode(t,this.charsets[n.version],this.padChars[n.version],n.integrity,n.littleEndian);return i&&(a=i({input:t,output:a,settings:n})),this.utils.outputHandler.compile(a,n.outputType,n.littleEndian,o)}}class d extends u{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new c(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s,r;[s,r]=this.utils.inputHandler.toBytes(t,i);let n=this.converter.encode(s,null,i.littleEndian)[0],o=BigInt(n);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],h=a.length;let l="";if(1===h)l=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(l=a.at(1).repeat((o-t)/5)),l+=a.at(0).repeat(t)}else for(let t=0;t(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}class p extends u{constructor(...t){super(),this.converter=new c(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class g extends u{constructor(...t){super(),this.converter=new c(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:s})=>{if(i.padding&&"int"!==s){let s=0;const r=t.length,n=this.charsets[i.version].at(0);if(r){for(;!t[s];)if(s++,s===r){s=0;break}const i=s;i&&(e=n.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const s=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===s;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}class b extends u{constructor(...t){super(),this.converter=new c(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class w extends u{constructor(...t){super(),this.converter=new c(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||m()} ${e.options.file||y()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${s.at(r)}${e.join("")}\n`;break}t+=`${s.at(45)}${e.join("")}\n`}return t+=`${s.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const s=this.charsets[e.version],r=t.trim().split(/\r?\n/),n=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=s.indexOf(r.shift());if(!(o>0))break;if(n.push(...r),45!==o){i=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;n.length%60;)n.push(" ")}return n.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const m=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},y=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};class v extends u{constructor(...t){super(),this.converter=new c(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}class E extends u{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.utils.inputHandler.toBytes(t,i)[0];let r=0,n=0,o="";const a=this.charsets[i.version];if(s.forEach((t=>{if(n+=t<13){let t,e,i=13,s=n%8192;s<89&&(i=14,s=n%16384),n>>=i,r-=i,[t,e]=this.#s(s,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#s(n,91),o=o.concat(a[e]),(r>7||n>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>s.includes(t))));let n=r.length,o=!1;n%2&&(o=!0,n--);let a=0,l=0;const c=new Array;for(let t=0;t88?13:14;do{c.push(a%256),a>>=8,l-=8}while(l>7)}if(o){const t=r.at(n),e=s.indexOf(t);c.push(((e<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){h.push(t);break}h.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){h.push(t);break}h.push(128|t)}const l=Uint8Array.from(h);return"hex"===i.version?this.hexlify.encode(l,[..."0123456789abcdef"],!1)[0]:l}decode(t,...i){const s=this.utils.validateArgs(i);if("hex"===s.version)t=this.hexlify.decode(this.utils.normalizeInput(t).toLowerCase(),[..."0123456789abcdef"],[],s.integrity,!1);else{if(void 0===t.byteLength)throw new TypeError("Input must be a bytes like object.");t=e.toBytes(t)[0]}if(1===t.length&&!t[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);t=Array.from(t);let r,n,o,a=0n,h=-7n;for(r of t)h+=7n,a+=BigInt(127&r)<{e.forEach((e=>{e in this.#r?this.#r[e].version+=t:this.#r[e]={version:t}}))},i=(e,i,s)=>{i.forEach((i=>{i in t?this.#r[i].version=3:(this.#r[i]={version:e,padding:s},t[i]=s)}))};e(1,this.charsets.emojis_v1),e(2,this.charsets.emojis_v2),i(1,this.padChars.emojis_v1.slice(0,-1),"last"),i(2,this.padChars.emojis_v2.slice(0,-1),"last"),i(1,this.padChars.emojis_v1.slice(-1),"fill"),i(2,this.padChars.emojis_v2.slice(-1),"fill");const s=[];for(const e in t)"last"===t[e]?s.push(e):s.push(`${e}+`);this.#n=new RegExp(s.join("|"),"g")}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version];let r=[...t];if(i>1){const t=this.converter.padBytes(i);if(e.padding){const i=e.trim?1:t,s=new Array(i).fill(this.padChars[e.version].at(-1));r.splice(r.length-t,t,...s)}else r.splice(r.length-t,t)}else if(1===i){const t=s.indexOf(r.pop())>>8;r.push(this.padChars[e.version].at(t))}return r.join("")}),...e)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);let s=i.version,r=null;"emojis_v1"!==i.version&&"emojis_v2"!==i.version||(r=3);const n=t=>{null!==r&&(r=this.#a(t,r,i.integrity),s=3===r?i.version:`emojis_v${r}`);const e=this.charsets[s],n=[...t],o=n.at(-1);let a=!1;for(let i=0;i{const r=s.index+s.at(0).length;e.push(...n(t.slice(i,r))),i=r})),i!==t.length&&e.push(...n(t.slice(i,t.length))),a=Uint8Array.from(e)}return this.utils.outputHandler.compile(a,i.outputType)}#a(t,e,i){const s=[...t];let r;if(s.forEach(((t,s)=>{if(!(t in this.#r))throw new h(t);{const n=this.#r[t].version;if(3!==n)if(3===e)e=n;else if(e!==n)throw new TypeError(`Emojis from different ecoji versions seen : ${t} from emojis_v${n}`);if(i){const e=this.#r[t].padding;if(e){const i=s%4;if(r=!0,"fill"===e){if(0===i)throw new TypeError(`Padding unexpectedly seen in first position ${t}`)}else if(3!==i)throw new TypeError(`Last padding seen in unexpected position ${t}`)}else if(r)throw new TypeError("Unexpectedly saw non-padding after padding")}}})),i&&s.length%4&&(1===e||"fill"!==this.#r[s.at(-1)].padding))throw new TypeError("Unexpected end of data, input data size not multiple of 4");return e}}class T extends u{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s=this.utils.inputHandler.toBytes(t,i).at(0);const r=this.charsets[i.version],n=this.padChars[i.version];let o="",a=0,h=0;if(s.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=r.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?n.at(a):r.at(a)}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const s=[...t],r=this.charsets[i.version],n=this.padChars[i.version],o=new Array;let a=0,l=0;return s.forEach(((t,e)=>{let c,u=r.indexOf(t);if(u>-1)c=this.converter.bsEnc;else if(u=n.indexOf(t),u>-1){if(e+1!==s.length)throw new h(null,`Secondary character found before end of input, index: ${e}`);c=this.converter.bsEncPad}else if(i.integrity)throw new h(t);for(let t=c-1;t>=0;t--)a=(a<<1)+(u>>t&1),l++,l===this.converter.bsDec&&(o.push(a),a=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(o),i.outputType)}}class M extends u{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new c(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}let j=1e6,B="[big.js] ",C=B+"Invalid ",I=C+"decimal places",$=C+"rounding mode",k={},_=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function S(t,e,i,s){let r=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error($);if(e<1)s=3===i&&(s||!!r[0])||0===e&&(1===i&&r[0]>=5||2===i&&(r[0]>5||5===r[0]&&(s||void 0!==r[1]))),r.length=1,s?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e=5||2===i&&(r[e]>5||5===r[e]&&(s||void 0!==r[e+1]||1&r[e-1]))||3===i&&(s||!!r[0]),r.length=e,s)for(;++r[--e]>9;)if(r[e]=0,0===e){++t.e,r.unshift(1);break}for(e=r.length;!r[--e];)r.pop()}return t}function N(t,e,i){let s=t.e,r=t.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)r="0"+r;r="0."+r}else if(s>0)if(++s>n)for(s-=n;s--;)r+="0";else s1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&i?"-"+r:r}k.abs=function(){let t=new this.constructor(this);return t.s=1,t},k.cmp=function(t){let e,i=this,s=i.c,r=(t=new i.constructor(t)).c,n=i.s,o=t.s,a=i.e,h=t.e;if(!s[0]||!r[0])return s[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=h)return a>h^e?1:-1;for(o=(a=s.length)<(h=r.length)?a:h,n=-1;++nr[n]^e?1:-1;return a==h?0:a>h^e?1:-1},k.eq=function(t){return 0===this.cmp(t)},k.gt=function(t){return this.cmp(t)>0},k.gte=function(t){return this.cmp(t)>-1},k.lt=function(t){return this.cmp(t)<0},k.lte=function(t){return this.cmp(t)<1},k.minus=k.sub=function(t){let e,i,s,r,n=this,o=n.constructor,a=n.s,h=(t=new o(t)).s;if(a!=h)return t.s=-h,n.plus(t);let l=n.c.slice(),c=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-h:l[0]?t=new o(n):t.s=1,t;if(a=c-d){for((r=a<0)?(a=-a,s=l):(d=c,s=u),s.reverse(),h=a;h--;)s.push(0);s.reverse()}else for(i=((r=l.length0)for(;h--;)l[e++]=0;for(h=e;i>a;){if(l[--i]0?(h=o,s=l):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),e=l.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+l[e]+i)/10|0;for(i&&(a.unshift(i),++h),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=h,t},k.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-j||t>j)throw Error(I);return S(new this.constructor(this),t+this.e+1,e)},k.toFixed=function(t,e){let i=this,s=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>j)throw Error(I);for(i=S(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},k.toNumber=function(){let t=Number(N(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(B+"Imprecise conversion");return t};const U=function t(){function e(i){let s=this;if(!(s instanceof e))return void 0===i?t():new e(i);if(i instanceof e)s.s=i.s,s.e=i.e,s.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(C+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,s,r;if(!_.test(e))throw Error(`${C}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(i<0&&(i=s),i+=+e.slice(s+1),e=e.substring(0,s)):i<0&&(i=e.length),r=e.length,s=0;s0&&"0"==e.charAt(--r););for(t.e=i-s-1,t.c=[],i=0;s<=r;)t.c[i++]=+e.charAt(s++)}}(s,i)}s.constructor=e}return e.prototype=k,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();class D extends u{#h=U("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new c(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r,n,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(n=!0,o=U(-t)):(n=!1,o=U(t))}else[r,n]=this.utils.inputHandler.toBytes(t,i),o=U(this.b10.encode(r,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=s[o.toNumber()],n&&(a=`-${a}`),a;const h=[],l=[];let c=U(1),u=this.#h,d=0;for(;u.lt(o);)[c,u]=this.#l(c,u),d++;const f=(t,e,i)=>{if(!this.#c(o)){for(;t.gt(o);){if([t,e]=this.#u(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?h.unshift(i):l.push(i),o=o.minus(t),f(t,e,i)}};return f(c,u,d),d=0,h.forEach((t=>{for(;d{for(;d>t;)a+=s[0],d--;a+=s[1],d--})),n&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r;if([t,r]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...s,"."];t=[...t].filter((t=>e.includes(t))).join("")}const n=t.split(".");if(i.integrity&&n.length>2)throw new h(null,"There are multiple decimal points in the input.");const[o,a]=n;let l=U(0),c=this.#h.minus(1),u=U(1);if([...o].reverse().forEach((t=>{const e=s.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new h(t);[c,u]=this.#l(c,u)})),a){let t=U(1);u=this.#h.minus(t),[...a].forEach((e=>{const i=s.indexOf(e);if(1===i)l=l.plus(u);else if(0!==i)throw new h(e);[u,t]=this.#u(u,t)}))}if(i.decimalMode)return l.toNumber();l=l.round().toFixed();const d=this.b10.decode(l,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(d,i.outputType,i.littleEndian,r)}#c(t){return!t.round(50).abs().toNumber()}#l(t,e){return[e,t.plus(e)]}#u(t,e){return[e.minus(t),t]}}const P=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class O{constructor(...t){this.littleEndian=P,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,e=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const s=r.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!r.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${s}`);i.outputType=t}})),e)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);return s.toBytes(t,i)[0]}decode(t,...e){const i=this.utils.validateArgs(e);return r.compile(t,i.outputType,i.littleEndian)}} /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */return t.Base1=d,t.Base16=f,t.Base2048=T,t.Base32=p,t.Base58=g,t.Base64=b,t.Base85=v,t.Base91=E,t.BaseEx=class{constructor(t="buffer"){if(!o.typeList.includes(t)){let e=`Invalid argument '${t}' for output type. Allowed types are:\n`;throw e=e.concat(o.typeList.join(", ")),new TypeError(e)}this.base1=new d("default",t),this.base16=new f("default",t),this.base32_crockford=new p("rfc4648",t),this.base32_rfc3548=new p("rfc3548",t),this.base32_rfc4648=new p("rfc4648",t),this.base32_zbase32=new p("zbase32",t),this.base58=new g("default",t),this.base58_bitcoin=new g("bitcoin",t),this.base58_flickr=new g("flickr",t),this.base64=new b("default",t),this.base64_urlsafe=new b("urlsafe",t),this.uuencode=new y("default",t),this.uuencode_original=new y("original",t),this.xxencode=new y("xx",t),this.base85_adobe=new v("adobe",t),this.base85_ascii=new v("ascii85",t),this.base85_z85=new v("z85",t),this.base91=new E("default",t),this.leb128=new A("default",t),this.ecoji_v1=new x("emojis_v1",t),this.ecoji_v2=new x("emojis_v2",t),this.base2048=new T("default",t),this.basePhi=new D("default",t),this.byteConverter=new O(t),this.simpleBase={};for(let e=2;e<=62;e++)this.simpleBase[`base${e}`]=new M(e,t)}},t.BasePhi=D,t.ByteConverter=O,t.Ecoji=x,t.LEB128=A,t.SimpleBase=M,t.UUencode=y,t}({}); + */return t.Base1=d,t.Base16=f,t.Base2048=T,t.Base32=p,t.Base58=g,t.Base64=b,t.Base85=v,t.Base91=E,t.BaseEx=class{constructor(t="buffer"){if(!o.typeList.includes(t)){let e=`Invalid argument '${t}' for output type. Allowed types are:\n`;throw e=e.concat(o.typeList.join(", ")),new TypeError(e)}this.base1=new d("default",t),this.base16=new f("default",t),this.base32_crockford=new p("rfc4648",t),this.base32_rfc3548=new p("rfc3548",t),this.base32_rfc4648=new p("rfc4648",t),this.base32_zbase32=new p("zbase32",t),this.base58=new g("default",t),this.base58_bitcoin=new g("bitcoin",t),this.base58_flickr=new g("flickr",t),this.base64=new b("default",t),this.base64_urlsafe=new b("urlsafe",t),this.uuencode=new w("default",t),this.uuencode_original=new w("original",t),this.xxencode=new w("xx",t),this.base85_adobe=new v("adobe",t),this.base85_ascii=new v("ascii85",t),this.base85_z85=new v("z85",t),this.base91=new E("default",t),this.leb128=new A("default",t),this.ecoji_v1=new x("emojis_v1",t),this.ecoji_v2=new x("emojis_v2",t),this.base2048=new T("default",t),this.basePhi=new D("default",t),this.byteConverter=new O(t),this.simpleBase={};for(let e=2;e<=62;e++)this.simpleBase[`base${e}`]=new M(e,t)}},t.BasePhi=D,t.ByteConverter=O,t.Ecoji=x,t.LEB128=A,t.SimpleBase=M,t.UUencode=w,t}({}); diff --git a/dist/converters/Base1/base-1.esm.js b/dist/converters/Base1/base-1.esm.js index 3e64ce8..ff0e304 100644 --- a/dist/converters/Base1/base-1.esm.js +++ b/dist/converters/Base1/base-1.esm.js @@ -976,6 +976,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1149,19 +1150,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base1/base-1.esm.min.js b/dist/converters/Base1/base-1.esm.min.js index 7151e24..1017fe2 100644 --- a/dist/converters/Base1/base-1.esm.min.js +++ b/dist/converters/Base1/base-1.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */class u extends h{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new l(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let n,r;[n,r]=this.utils.inputHandler.toBytes(t,i);let s=this.converter.encode(n,null,i.littleEndian)[0],o=BigInt(s);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],l=a.length;let h="";if(1===l)h=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(h=a.at(1).repeat((o-t)/5)),h+=a.at(0).repeat(t)}else for(let t=0;t { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var Base1 = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var Base1 = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var Base1 = (function () { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base1/base-1.iife.min.js b/dist/converters/Base1/base-1.iife.min.js index 2859896..69841d1 100644 --- a/dist/converters/Base1/base-1.iife.min.js +++ b/dist/converters/Base1/base-1.iife.min.js @@ -1,8 +1,8 @@ -var Base1=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base1=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */return class extends h{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new l(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let n,r;[n,r]=this.utils.inputHandler.toBytes(t,i);let s=this.converter.encode(n,null,i.littleEndian)[0],o=BigInt(s);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],l=a.length;let h="";if(1===l)h=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(h=a.at(1).repeat((o-t)/5)),h+=a.at(0).repeat(t)}else for(let t=0;t { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-16.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base16/base-16.esm.min.js b/dist/converters/Base16/base-16.esm.min.js index f46e971..05ed634 100644 --- a/dist/converters/Base16/base-16.esm.min.js +++ b/dist/converters/Base16/base-16.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const i=e.indexOf(t);if(i>-1)a.push(i);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-16.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */class u extends h{constructor(...t){super(),this.converter=new l(16,1,2),this.charsets.default=[..."0123456789abcdef"],this.padChars.default=[],this.hasSignedMode=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}export{u as default}; diff --git a/dist/converters/Base16/base-16.iife.js b/dist/converters/Base16/base-16.iife.js index 57fc7c2..9de175a 100644 --- a/dist/converters/Base16/base-16.iife.js +++ b/dist/converters/Base16/base-16.iife.js @@ -979,6 +979,7 @@ var Base16 = (function () { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1152,19 +1153,25 @@ var Base16 = (function () { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var Base16 = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var Base16 = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var Base16 = (function () { /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-16.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base16/base-16.iife.min.js b/dist/converters/Base16/base-16.iife.min.js index 43ced4b..b0e758c 100644 --- a/dist/converters/Base16/base-16.iife.min.js +++ b/dist/converters/Base16/base-16.iife.min.js @@ -1,8 +1,8 @@ -var Base16=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const i=e.indexOf(t);if(i>-1)a.push(i);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base16=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+n])*i}const n=[];let r,i=e;for(;i>=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-16.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */return class extends h{constructor(...t){super(),this.converter=new l(16,1,2),this.charsets.default=[..."0123456789abcdef"],this.padChars.default=[],this.hasSignedMode=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}}(); diff --git a/dist/converters/Base2048/base-2048.esm.js b/dist/converters/Base2048/base-2048.esm.js index 09005e1..b8ec56c 100644 --- a/dist/converters/Base2048/base-2048.esm.js +++ b/dist/converters/Base2048/base-2048.esm.js @@ -1101,7 +1101,7 @@ class BaseTemplate { /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base2048/base-2048.esm.min.js b/dist/converters/Base2048/base-2048.esm.min.js index d819f1d..be43a3e 100644 --- a/dist/converters/Base2048/base-2048.esm.min.js +++ b/dist/converters/Base2048/base-2048.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */class h extends l{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const r=this.utils.validateArgs(e);let i=this.utils.inputHandler.toBytes(t,r).at(0);const n=this.charsets[r.version],s=this.padChars[r.version];let o="",a=0,l=0;if(i.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),l++,l===this.converter.bsEnc&&(o+=n.at(a),a=0,l=0)})),0!==l){let t,e;for(l<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);l!==t;)if(a=1+(a<<1),l++,l>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?s.at(a):n.at(a)}return this.utils.wrapOutput(o,r.options.lineWrap)}decode(t,...e){const r=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const i=[...t],n=this.charsets[r.version],s=this.padChars[r.version],a=new Array;let l=0,h=0;return i.forEach(((t,e)=>{let u,c=n.indexOf(t);if(c>-1)u=this.converter.bsEnc;else if(c=s.indexOf(t),c>-1){if(e+1!==i.length)throw new o(null,`Secondary character found before end of input, index: ${e}`);u=this.converter.bsEncPad}else if(r.integrity)throw new o(t);for(let t=u-1;t>=0;t--)l=(l<<1)+(c>>t&1),h++,h===this.converter.bsDec&&(a.push(l),l=0,h=0)})),this.utils.outputHandler.compile(Uint8Array.from(a),r.outputType)}}export{h as default}; diff --git a/dist/converters/Base2048/base-2048.iife.js b/dist/converters/Base2048/base-2048.iife.js index 04f9f54..1df9205 100644 --- a/dist/converters/Base2048/base-2048.iife.js +++ b/dist/converters/Base2048/base-2048.iife.js @@ -1104,7 +1104,7 @@ var Base2048 = (function () { /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base2048/base-2048.iife.min.js b/dist/converters/Base2048/base-2048.iife.min.js index 73d6721..402b801 100644 --- a/dist/converters/Base2048/base-2048.iife.min.js +++ b/dist/converters/Base2048/base-2048.iife.min.js @@ -2,7 +2,7 @@ var Base2048=function(){"use strict";class t{static toBytes(t){return ArrayBuffe /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */return class extends h{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const r=this.utils.validateArgs(e);let i=this.utils.inputHandler.toBytes(t,r).at(0);const n=this.charsets[r.version],s=this.padChars[r.version];let o="",a=0,h=0;if(i.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=n.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?s.at(a):n.at(a)}return this.utils.wrapOutput(o,r.options.lineWrap)}decode(t,...e){const r=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const i=[...t],n=this.charsets[r.version],s=this.padChars[r.version],a=new Array;let h=0,l=0;return i.forEach(((t,e)=>{let u,c=n.indexOf(t);if(c>-1)u=this.converter.bsEnc;else if(c=s.indexOf(t),c>-1){if(e+1!==i.length)throw new o(null,`Secondary character found before end of input, index: ${e}`);u=this.converter.bsEncPad}else if(r.integrity)throw new o(t);for(let t=u-1;t>=0;t--)h=(h<<1)+(c>>t&1),l++,l===this.converter.bsDec&&(a.push(h),h=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(a),r.outputType)}}}(); diff --git a/dist/converters/Base32/base-32.esm.js b/dist/converters/Base32/base-32.esm.js index 1ecbafd..314adc9 100644 --- a/dist/converters/Base32/base-32.esm.js +++ b/dist/converters/Base32/base-32.esm.js @@ -976,6 +976,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1149,19 +1150,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base32/base-32.esm.min.js b/dist/converters/Base32/base-32.esm.min.js index 55ead90..a9fe454 100644 --- a/dist/converters/Base32/base-32.esm.min.js +++ b/dist/converters/Base32/base-32.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,r){let i;return i="buffer"===(r=e.getType(r))?t.buffer:"view"===r?new DataView(t.buffer):t,i}}class r{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const r=this.makeDataView(8);return r.setFloat64(0,t,e),r}static numbers(t,e=!1){let r,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,r,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,r="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,r="bigger",i="MAX"),new RangeError(`The provided integer is ${r} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(r=this.makeDataView(8),r.setBigInt64(0,BigInt(t),e)):t<-32768?(r=this.makeDataView(4),r.setInt32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):t>0?t>4294967295?(r=this.makeDataView(8),r.setBigUint64(0,BigInt(t),e)):t>65535?(r=this.makeDataView(4),r.setUint32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):r=new Uint16Array([0])}else i="float",r=this.floatingPoints(t,e);return[new Uint8Array(r.buffer),i]}static bigInts(t,e=!1){const r=new Array,i=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)r[i](t%n),t>>=64n;else for(;t>=n;)r[i](t%n),t>>=64n;r[i](t);const s=8*r.length,o=this.makeDataView(s);return r.forEach(((t,r)=>{const i=8*r;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let r,i=!1,n="bytes";if(t instanceof ArrayBuffer)r=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)r=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);r=new Uint8Array(i.buffer),n="float"}else[r,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),r=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const r of t)i.push(...this.toBytes(r,e)[0]);r=Uint8Array.from(i)}}return[r,i,n]}}const i=r,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,r,i){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=r?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,r,i){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,r,i);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,r,i);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,r,i);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,i=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return n;t=r.toBytes(n,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,n);t=new Uint8Array(e)}i&&t.reverse();let r=0n;t.forEach((t=>r=(r<<8n)+BigInt(t))),"uint_n"!==e&&(r=BigInt.asIntN(8*t.length,r)),s="bigint_n"!==e&&r>=Number.MIN_SAFE_INTEGER&&r<=Number.MAX_SAFE_INTEGER?Number(r):r}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,r=[],i=!0)=>{const n=(t,r,i)=>{if(0===i&&r.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${r}'`),[];let n=i;if("string"==typeof r&&(r=[...r]),Array.isArray(r))n=r.length,r=new Set(r);else if(!(r instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(r.size===i)return[...r];if(n!==i)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${i}.`);{const r={};(e=[...e]).forEach((t=>{t in r?r[t]++:r[t]=1}));let n="";i<100&&(n=`${e.join("")}\n`,e.forEach((t=>{r[t]>1?n+="^":n+=" "})));const s=Object.keys(r).filter((t=>r[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",r,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#r(t,e,r,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(r)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(r,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!r.length)return s&&this.setIOHandlers(),o;const a=t=>!!r.includes(t)&&(r.splice(r.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const r=a("bytes_in")?t:i,s=a("bytes_out")?e:n;this.setIOHandlers(r,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(r.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const r in l)if(l[r].includes(t)){if(e=!1,!this.root.isMutable[r])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[r]=Boolean(l[r].indexOf(t))}e&&this.#r(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const r=new RegExp(`.{1,${e}}`,"gu");return t.match(r).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,r=null,i=0){this.radix=t,null!==e&&null!==r?(this.bsEnc=e,this.bsDec=r):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let r=0;for(;8*r*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,r=[],i=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let h;if([...t].forEach((t=>{const n=e.indexOf(t);if(n>-1)a.push(n);else if(i&&-1===r.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t=256;)[n,i]=this.divmod(n,256),r.unshift(parseInt(i,10));for(r.unshift(parseInt(n,10));r.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,r,...i){const n=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),r&&(l=r({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,r,i,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return r&&(a=r({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */class u extends l{constructor(...t){super(),this.converter=new h(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:r})=>{if(!e.littleEndian&&r){const i=this.converter.padBytes(r),n=this.padChars[e.version].at(0);t=t.slice(0,-i),e.padding&&(t=t.concat(n.repeat(i)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}export{u as default}; + */class u extends l{constructor(...t){super(),this.converter=new h(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const r=this.converter.padBytes(i),n=this.padChars[e.version].at(0);t=t.slice(0,-r),e.padding&&(t=t.concat(n.repeat(r)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}export{u as default}; diff --git a/dist/converters/Base32/base-32.iife.js b/dist/converters/Base32/base-32.iife.js index 4487f09..e8f432b 100644 --- a/dist/converters/Base32/base-32.iife.js +++ b/dist/converters/Base32/base-32.iife.js @@ -979,6 +979,7 @@ var Base32 = (function () { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1152,19 +1153,25 @@ var Base32 = (function () { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var Base32 = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var Base32 = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var Base32 = (function () { /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base32/base-32.iife.min.js b/dist/converters/Base32/base-32.iife.min.js index 9f2969d..bff3ea1 100644 --- a/dist/converters/Base32/base-32.iife.min.js +++ b/dist/converters/Base32/base-32.iife.min.js @@ -1,8 +1,8 @@ -var Base32=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,r){let i;return i="buffer"===(r=e.getType(r))?t.buffer:"view"===r?new DataView(t.buffer):t,i}}class r{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const r=this.makeDataView(8);return r.setFloat64(0,t,e),r}static numbers(t,e=!1){let r,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,r,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,r="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,r="bigger",i="MAX"),new RangeError(`The provided integer is ${r} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(r=this.makeDataView(8),r.setBigInt64(0,BigInt(t),e)):t<-32768?(r=this.makeDataView(4),r.setInt32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):t>0?t>4294967295?(r=this.makeDataView(8),r.setBigUint64(0,BigInt(t),e)):t>65535?(r=this.makeDataView(4),r.setUint32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):r=new Uint16Array([0])}else i="float",r=this.floatingPoints(t,e);return[new Uint8Array(r.buffer),i]}static bigInts(t,e=!1){const r=new Array,i=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)r[i](t%n),t>>=64n;else for(;t>=n;)r[i](t%n),t>>=64n;r[i](t);const s=8*r.length,o=this.makeDataView(s);return r.forEach(((t,r)=>{const i=8*r;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let r,i=!1,n="bytes";if(t instanceof ArrayBuffer)r=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)r=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);r=new Uint8Array(i.buffer),n="float"}else[r,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),r=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const r of t)i.push(...this.toBytes(r,e)[0]);r=Uint8Array.from(i)}}return[r,i,n]}}const i=r,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,r,i){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=r?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,r,i){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,r,i);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,r,i);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,r,i);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,i=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return n;t=r.toBytes(n,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,n);t=new Uint8Array(e)}i&&t.reverse();let r=0n;t.forEach((t=>r=(r<<8n)+BigInt(t))),"uint_n"!==e&&(r=BigInt.asIntN(8*t.length,r)),s="bigint_n"!==e&&r>=Number.MIN_SAFE_INTEGER&&r<=Number.MAX_SAFE_INTEGER?Number(r):r}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,r=[],i=!0)=>{const n=(t,r,i)=>{if(0===i&&r.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${r}'`),[];let n=i;if("string"==typeof r&&(r=[...r]),Array.isArray(r))n=r.length,r=new Set(r);else if(!(r instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(r.size===i)return[...r];if(n!==i)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${i}.`);{const r={};(e=[...e]).forEach((t=>{t in r?r[t]++:r[t]=1}));let n="";i<100&&(n=`${e.join("")}\n`,e.forEach((t=>{r[t]>1?n+="^":n+=" "})));const s=Object.keys(r).filter((t=>r[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",r,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#r(t,e,r,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(r)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(r,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!r.length)return s&&this.setIOHandlers(),o;const a=t=>!!r.includes(t)&&(r.splice(r.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const r=a("bytes_in")?t:i,s=a("bytes_out")?e:n;this.setIOHandlers(r,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(r.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const r in l)if(l[r].includes(t)){if(e=!1,!this.root.isMutable[r])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[r]=Boolean(l[r].indexOf(t))}e&&this.#r(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const r=new RegExp(`.{1,${e}}`,"gu");return t.match(r).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,r=null,i=0){this.radix=t,null!==e&&null!==r?(this.bsEnc=e,this.bsDec=r):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let r=0;for(;8*r*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,r=[],i=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let h;if([...t].forEach((t=>{const n=e.indexOf(t);if(n>-1)a.push(n);else if(i&&-1===r.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t=256;)[n,i]=this.divmod(n,256),r.unshift(parseInt(i,10));for(r.unshift(parseInt(n,10));r.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,r,...i){const n=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),r&&(l=r({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,r,i,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return r&&(a=r({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base32=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,r){let i;return i="buffer"===(r=e.getType(r))?t.buffer:"view"===r?new DataView(t.buffer):t,i}}class r{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const r=this.makeDataView(8);return r.setFloat64(0,t,e),r}static numbers(t,e=!1){let r,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,r,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,r="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,r="bigger",i="MAX"),new RangeError(`The provided integer is ${r} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(r=this.makeDataView(8),r.setBigInt64(0,BigInt(t),e)):t<-32768?(r=this.makeDataView(4),r.setInt32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):t>0?t>4294967295?(r=this.makeDataView(8),r.setBigUint64(0,BigInt(t),e)):t>65535?(r=this.makeDataView(4),r.setUint32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):r=new Uint16Array([0])}else i="float",r=this.floatingPoints(t,e);return[new Uint8Array(r.buffer),i]}static bigInts(t,e=!1){const r=new Array,i=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)r[i](t%n),t>>=64n;else for(;t>=n;)r[i](t%n),t>>=64n;r[i](t);const s=8*r.length,o=this.makeDataView(s);return r.forEach(((t,r)=>{const i=8*r;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let r,i=!1,n="bytes";if(t instanceof ArrayBuffer)r=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)r=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);r=new Uint8Array(i.buffer),n="float"}else[r,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),r=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const r of t)i.push(...this.toBytes(r,e)[0]);r=Uint8Array.from(i)}}return[r,i,n]}}const i=r,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,r,i){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=r?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,r,i){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,r,i);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,r,i);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,r,i);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,i=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return n;t=r.toBytes(n,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,n);t=new Uint8Array(e)}i&&t.reverse();let r=0n;t.forEach((t=>r=(r<<8n)+BigInt(t))),"uint_n"!==e&&(r=BigInt.asIntN(8*t.length,r)),s="bigint_n"!==e&&r>=Number.MIN_SAFE_INTEGER&&r<=Number.MAX_SAFE_INTEGER?Number(r):r}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,r=[],i=!0)=>{const n=(t,r,i)=>{if(0===i&&r.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${r}'`),[];let n=i;if("string"==typeof r&&(r=[...r]),Array.isArray(r))n=r.length,r=new Set(r);else if(!(r instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(r.size===i)return[...r];if(n!==i)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${i}.`);{const r={};(e=[...e]).forEach((t=>{t in r?r[t]++:r[t]=1}));let n="";i<100&&(n=`${e.join("")}\n`,e.forEach((t=>{r[t]>1?n+="^":n+=" "})));const s=Object.keys(r).filter((t=>r[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",r,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#r(t,e,r,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(r)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(r,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!r.length)return s&&this.setIOHandlers(),o;const a=t=>!!r.includes(t)&&(r.splice(r.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const r=a("bytes_in")?t:i,s=a("bytes_out")?e:n;this.setIOHandlers(r,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(r.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const r in l)if(l[r].includes(t)){if(e=!1,!this.root.isMutable[r])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[r]=Boolean(l[r].indexOf(t))}e&&this.#r(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const r=new RegExp(`.{1,${e}}`,"gu");return t.match(r).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,r=null,i=0){this.radix=t,null!==e&&null!==r?(this.bsEnc=e,this.bsDec=r):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let r=0;for(;8*r*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,r=[],i=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,r)=>e[t]=r)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(i&&-1===r.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+r])*n}const r=[];let i,n=e;for(;n>=256;)[n,i]=this.divmod(n,256),r.unshift(parseInt(i,10));for(r.unshift(parseInt(n,10));r.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,r,...i){const n=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),r&&(l=r({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,r,i,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return r&&(a=r({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */return class extends l{constructor(...t){super(),this.converter=new h(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:r})=>{if(!e.littleEndian&&r){const i=this.converter.padBytes(r),n=this.padChars[e.version].at(0);t=t.slice(0,-i),e.padding&&(t=t.concat(n.repeat(i)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}}(); diff --git a/dist/converters/Base58/base-58.esm.js b/dist/converters/Base58/base-58.esm.js index 5493c1d..1813c71 100644 --- a/dist/converters/Base58/base-58.esm.js +++ b/dist/converters/Base58/base-58.esm.js @@ -976,6 +976,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1149,19 +1150,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base58/base-58.esm.min.js b/dist/converters/Base58/base-58.esm.min.js index 57443e4..7b1a28f 100644 --- a/dist/converters/Base58/base-58.esm.min.js +++ b/dist/converters/Base58/base-58.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */class u extends l{constructor(...t){super(),this.converter=new h(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:n})=>{if(i.padding&&"int"!==n){let n=0;const r=t.length,s=this.charsets[i.version].at(0);if(r){for(;!t[n];)if(n++,n===r){n=0;break}const i=n;i&&(e=s.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const n=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===n;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}export{u as default}; diff --git a/dist/converters/Base58/base-58.iife.js b/dist/converters/Base58/base-58.iife.js index adb3f52..dc15890 100644 --- a/dist/converters/Base58/base-58.iife.js +++ b/dist/converters/Base58/base-58.iife.js @@ -979,6 +979,7 @@ var Base58 = (function () { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1152,19 +1153,25 @@ var Base58 = (function () { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var Base58 = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var Base58 = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var Base58 = (function () { /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base58/base-58.iife.min.js b/dist/converters/Base58/base-58.iife.min.js index 0174a78..3fe56af 100644 --- a/dist/converters/Base58/base-58.iife.min.js +++ b/dist/converters/Base58/base-58.iife.min.js @@ -1,8 +1,8 @@ -var Base58=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base58=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */return class extends l{constructor(...t){super(),this.converter=new h(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:n})=>{if(i.padding&&"int"!==n){let n=0;const r=t.length,s=this.charsets[i.version].at(0);if(r){for(;!t[n];)if(n++,n===r){n=0;break}const i=n;i&&(e=s.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const n=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===n;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}}(); diff --git a/dist/converters/Base64/base-64.esm.js b/dist/converters/Base64/base-64.esm.js index cd0a21a..aeaff20 100644 --- a/dist/converters/Base64/base-64.esm.js +++ b/dist/converters/Base64/base-64.esm.js @@ -976,6 +976,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1149,19 +1150,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base64/base-64.esm.min.js b/dist/converters/Base64/base-64.esm.min.js index e0c323d..9b2e394 100644 --- a/dist/converters/Base64/base-64.esm.min.js +++ b/dist/converters/Base64/base-64.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const i=e.indexOf(t);if(i>-1)a.push(i);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+n])*i}const n=[];let r,i=e;for(;i>=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */class u extends h{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{if(n){const r=this.converter.padBytes(n),i=this.padChars[e.version].at(0);t=t.slice(0,-r),e.padding&&(t=t.concat(i.repeat(r)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}export{u as default}; diff --git a/dist/converters/Base64/base-64.iife.js b/dist/converters/Base64/base-64.iife.js index e520004..53418e6 100644 --- a/dist/converters/Base64/base-64.iife.js +++ b/dist/converters/Base64/base-64.iife.js @@ -979,6 +979,7 @@ var Base64 = (function () { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1152,19 +1153,25 @@ var Base64 = (function () { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var Base64 = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var Base64 = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var Base64 = (function () { /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base64/base-64.iife.min.js b/dist/converters/Base64/base-64.iife.min.js index 59f3aca..8285ec5 100644 --- a/dist/converters/Base64/base-64.iife.min.js +++ b/dist/converters/Base64/base-64.iife.min.js @@ -1,8 +1,8 @@ -var Base64=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const i=e.indexOf(t);if(i>-1)a.push(i);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base64=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+n])*i}const n=[];let r,i=e;for(;i>=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */return class extends h{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{if(n){const r=this.converter.padBytes(n),i=this.padChars[e.version].at(0);t=t.slice(0,-r),e.padding&&(t=t.concat(i.repeat(r)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}}(); diff --git a/dist/converters/Base85/base-85.esm.js b/dist/converters/Base85/base-85.esm.js index a41202d..d1ad5d2 100644 --- a/dist/converters/Base85/base-85.esm.js +++ b/dist/converters/Base85/base-85.esm.js @@ -976,6 +976,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1149,19 +1150,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base85/base-85.esm.min.js b/dist/converters/Base85/base-85.esm.min.js index 8ee5567..58c58e1 100644 --- a/dist/converters/Base85/base-85.esm.min.js +++ b/dist/converters/Base85/base-85.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const i=e.indexOf(t);if(i>-1)a.push(i);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */class u extends h{constructor(...t){super(),this.converter=new l(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:n})=>{if(n){const e=this.converter.padBytes(n);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}export{u as default}; + */class u extends l{constructor(...t){super(),this.converter=new h(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}export{u as default}; diff --git a/dist/converters/Base85/base-85.iife.js b/dist/converters/Base85/base-85.iife.js index 1aef7ab..172123a 100644 --- a/dist/converters/Base85/base-85.iife.js +++ b/dist/converters/Base85/base-85.iife.js @@ -979,6 +979,7 @@ var Base85 = (function () { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1152,19 +1153,25 @@ var Base85 = (function () { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var Base85 = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var Base85 = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var Base85 = (function () { /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/Base85/base-85.iife.min.js b/dist/converters/Base85/base-85.iife.min.js index fc94b05..b0614e7 100644 --- a/dist/converters/Base85/base-85.iife.min.js +++ b/dist/converters/Base85/base-85.iife.min.js @@ -1,8 +1,8 @@ -var Base85=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const i=e.indexOf(t);if(i>-1)a.push(i);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base85=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */return class extends h{constructor(...t){super(),this.converter=new l(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:n})=>{if(n){const e=this.converter.padBytes(n);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}}(); + */return class extends l{constructor(...t){super(),this.converter=new h(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}}(); diff --git a/dist/converters/Base91/base-91.esm.js b/dist/converters/Base91/base-91.esm.js index 0c1acaa..2a7583d 100644 --- a/dist/converters/Base91/base-91.esm.js +++ b/dist/converters/Base91/base-91.esm.js @@ -1101,7 +1101,7 @@ class BaseTemplate { /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ diff --git a/dist/converters/Base91/base-91.esm.min.js b/dist/converters/Base91/base-91.esm.min.js index 686f151..15a0bb2 100644 --- a/dist/converters/Base91/base-91.esm.min.js +++ b/dist/converters/Base91/base-91.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */class h extends l{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),n=this.utils.inputHandler.toBytes(t,i)[0];let r=0,s=0,o="";const a=this.charsets[i.version];if(n.forEach((t=>{if(s+=t<13){let t,e,i=13,n=s%8192;n<89&&(i=14,n=s%16384),s>>=i,r-=i,[t,e]=this.#n(n,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#n(s,91),o=o.concat(a[e]),(r>7||s>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),n=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>n.includes(t))));let s=r.length,a=!1;s%2&&(a=!0,s--);let l=0,h=0;const u=new Array;for(let t=0;t88?13:14;do{u.push(l%256),l>>=8,h-=8}while(h>7)}if(a){const t=r.at(s),e=n.indexOf(t);u.push(((e<?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),n=this.utils.inputHandler.toBytes(t,i)[0];let r=0,s=0,o="";const a=this.charsets[i.version];if(n.forEach((t=>{if(s+=t<13){let t,e,i=13,n=s%8192;n<89&&(i=14,n=s%16384),s>>=i,r-=i,[t,e]=this.#n(n,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#n(s,91),o=o.concat(a[e]),(r>7||s>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),n=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>n.includes(t))));let s=r.length,a=!1;s%2&&(a=!0,s--);let l=0,u=0;const h=new Array;for(let t=0;t88?13:14;do{h.push(l%256),l>>=8,u-=8}while(u>7)}if(a){const t=r.at(s),e=n.indexOf(t);h.push(((e< { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1456,7 +1469,7 @@ let DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME="[big.js] ",INVALID=NAME+"I /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/BasePhi/base-phi.esm.min.js b/dist/converters/BasePhi/base-phi.esm.min.js index 33a2444..4f51913 100644 --- a/dist/converters/BasePhi/base-phi.esm.min.js +++ b/dist/converters/BasePhi/base-phi.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,r){let i;return i="buffer"===(r=e.getType(r))?t.buffer:"view"===r?new DataView(t.buffer):t,i}}class r{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const r=this.makeDataView(8);return r.setFloat64(0,t,e),r}static numbers(t,e=!1){let r,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,r,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,r="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,r="bigger",i="MAX"),new RangeError(`The provided integer is ${r} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(r=this.makeDataView(8),r.setBigInt64(0,BigInt(t),e)):t<-32768?(r=this.makeDataView(4),r.setInt32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):t>0?t>4294967295?(r=this.makeDataView(8),r.setBigUint64(0,BigInt(t),e)):t>65535?(r=this.makeDataView(4),r.setUint32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):r=new Uint16Array([0])}else i="float",r=this.floatingPoints(t,e);return[new Uint8Array(r.buffer),i]}static bigInts(t,e=!1){const r=new Array,i=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)r[i](t%n),t>>=64n;else for(;t>=n;)r[i](t%n),t>>=64n;r[i](t);const s=8*r.length,o=this.makeDataView(s);return r.forEach(((t,r)=>{const i=8*r;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let r,i=!1,n="bytes";if(t instanceof ArrayBuffer)r=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)r=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);r=new Uint8Array(i.buffer),n="float"}else[r,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),r=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const r of t)i.push(...this.toBytes(r,e)[0]);r=Uint8Array.from(i)}}return[r,i,n]}}const i=r,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,r,i){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=r?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,r,i){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,r,i);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,r,i);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,r,i);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,i=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return n;t=r.toBytes(n,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,n);t=new Uint8Array(e)}i&&t.reverse();let r=0n;t.forEach((t=>r=(r<<8n)+BigInt(t))),"uint_n"!==e&&(r=BigInt.asIntN(8*t.length,r)),s="bigint_n"!==e&&r>=Number.MIN_SAFE_INTEGER&&r<=Number.MAX_SAFE_INTEGER?Number(r):r}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,r=[],i=!0)=>{const n=(t,r,i)=>{if(0===i&&r.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${r}'`),[];let n=i;if("string"==typeof r&&(r=[...r]),Array.isArray(r))n=r.length,r=new Set(r);else if(!(r instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(r.size===i)return[...r];if(n!==i)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${i}.`);{const r={};(e=[...e]).forEach((t=>{t in r?r[t]++:r[t]=1}));let n="";i<100&&(n=`${e.join("")}\n`,e.forEach((t=>{r[t]>1?n+="^":n+=" "})));const s=Object.keys(r).filter((t=>r[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",r,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#r(t,e,r,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(r)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(r,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!r.length)return s&&this.setIOHandlers(),o;const a=t=>!!r.includes(t)&&(r.splice(r.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const r=a("bytes_in")?t:i,s=a("bytes_out")?e:n;this.setIOHandlers(r,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(r.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const r in h)if(h[r].includes(t)){if(e=!1,!this.root.isMutable[r])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[r]=Boolean(h[r].indexOf(t))}e&&this.#r(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const r=new RegExp(`.{1,${e}}`,"gu");return t.match(r).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,r=null,i=0){this.radix=t,null!==e&&null!==r?(this.bsEnc=e,this.bsDec=r):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let r=0;for(;8*r*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,r=[],i=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const n=e.indexOf(t);if(n>-1)a.push(n);else if(i&&-1===r.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[n,i]=this.divmod(n,256),r.unshift(parseInt(i,10));for(r.unshift(parseInt(n,10));r.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,r,...i){const n=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),l=null;e&&(l=e(n));let[h,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,l);return n.signed&&(h=this.utils.toSignedStr(h,o)),n.upper&&(h=h.toUpperCase()),r&&(h=r({inputBytes:s,output:h,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(h,n.options.lineWrap)}decode(t,e,r,i,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return r&&(a=r({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}}let u=1e6,c="[big.js] ",f=c+"Invalid ",d=f+"decimal places",p=f+"rounding mode",g={},y=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function w(t,e,r,i){let n=t.c;if(void 0===r&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(p);if(e<1)i=3===r&&(i||!!n[0])||0===e&&(1===r&&n[0]>=5||2===r&&(n[0]>5||5===n[0]&&(i||void 0!==n[1]))),n.length=1,i?(t.e=t.e-e+1,n[0]=1):n[0]=t.e=0;else if(e=5||2===r&&(n[e]>5||5===n[e]&&(i||void 0!==n[e+1]||1&n[e-1]))||3===r&&(i||!!n[0]),n.length=e,i)for(;++n[--e]>9;)if(n[e]=0,0===e){++t.e,n.unshift(1);break}for(e=n.length;!n[--e];)n.pop()}return t}function b(t,e,r){let i=t.e,n=t.c.join(""),s=n.length;if(e)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(i<0?"e":"e+")+i;else if(i<0){for(;++i;)n="0"+n;n="0."+n}else if(i>0)if(++i>s)for(i-=s;i--;)n+="0";else i1&&(n=n.charAt(0)+"."+n.slice(1));return t.s<0&&r?"-"+n:n}g.abs=function(){let t=new this.constructor(this);return t.s=1,t},g.cmp=function(t){let e,r=this,i=r.c,n=(t=new r.constructor(t)).c,s=r.s,o=t.s,a=r.e,l=t.e;if(!i[0]||!n[0])return i[0]?s:n[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=i.length)<(l=n.length)?a:l,s=-1;++sn[s]^e?1:-1;return a==l?0:a>l^e?1:-1},g.eq=function(t){return 0===this.cmp(t)},g.gt=function(t){return this.cmp(t)>0},g.gte=function(t){return this.cmp(t)>-1},g.lt=function(t){return this.cmp(t)<0},g.lte=function(t){return this.cmp(t)<1},g.minus=g.sub=function(t){let e,r,i,n,s=this,o=s.constructor,a=s.s,l=(t=new o(t)).s;if(a!=l)return t.s=-l,s.plus(t);let h=s.c.slice(),u=s.e,c=t.c,f=t.e;if(!h[0]||!c[0])return c[0]?t.s=-l:h[0]?t=new o(s):t.s=1,t;if(a=u-f){for((n=a<0)?(a=-a,i=h):(f=u,i=c),i.reverse(),l=a;l--;)i.push(0);i.reverse()}else for(r=((n=h.length0)for(;l--;)h[e++]=0;for(l=e;r>a;){if(h[--r]0?(l=o,i=h):(e=-e,i=a),i.reverse();e--;)i.push(0);i.reverse()}for(a.length-h.length<0&&(i=h,h=a,a=i),e=h.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+h[e]+r)/10|0;for(r&&(a.unshift(r),++l),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=l,t},g.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-u||t>u)throw Error(d);return w(new this.constructor(this),t+this.e+1,e)},g.toFixed=function(t,e){let r=this,i=r.c[0];if(void 0!==t){if(t!==~~t||t<0||t>u)throw Error(d);for(r=w(new r.constructor(r),t+r.e+1,e),t=t+r.e+1;r.c.length=e.PE,!!t.c[0])},g.toNumber=function(){let t=Number(b(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(c+"Imprecise conversion");return t};const m=function t(){function e(r){let i=this;if(!(i instanceof e))return void 0===r?t():new e(r);if(r instanceof e)i.s=r.s,i.e=r.e,i.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(f+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){let r,i,n;if(!y.test(e))throw Error(`${f}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(r<0&&(r=i),r+=+e.slice(i+1),e=e.substring(0,i)):r<0&&(r=e.length),n=e.length,i=0;i0&&"0"==e.charAt(--n););for(t.e=r-i-1,t.c=[],r=0;i<=n;)t.c[r++]=+e.charAt(i++)}}(i,r)}i.constructor=e}return e.prototype=g,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}(); +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),l=null;e&&(l=e(n));let[h,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,l);return n.signed&&(h=this.utils.toSignedStr(h,o)),n.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(h,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}}let u=1e6,c="[big.js] ",f=c+"Invalid ",d=f+"decimal places",p=f+"rounding mode",g={},y=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function w(t,e,i,r){let n=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error(p);if(e<1)r=3===i&&(r||!!n[0])||0===e&&(1===i&&n[0]>=5||2===i&&(n[0]>5||5===n[0]&&(r||void 0!==n[1]))),n.length=1,r?(t.e=t.e-e+1,n[0]=1):n[0]=t.e=0;else if(e=5||2===i&&(n[e]>5||5===n[e]&&(r||void 0!==n[e+1]||1&n[e-1]))||3===i&&(r||!!n[0]),n.length=e,r)for(;++n[--e]>9;)if(n[e]=0,0===e){++t.e,n.unshift(1);break}for(e=n.length;!n[--e];)n.pop()}return t}function b(t,e,i){let r=t.e,n=t.c.join(""),s=n.length;if(e)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)n="0"+n;n="0."+n}else if(r>0)if(++r>s)for(r-=s;r--;)n+="0";else r1&&(n=n.charAt(0)+"."+n.slice(1));return t.s<0&&i?"-"+n:n}g.abs=function(){let t=new this.constructor(this);return t.s=1,t},g.cmp=function(t){let e,i=this,r=i.c,n=(t=new i.constructor(t)).c,s=i.s,o=t.s,a=i.e,l=t.e;if(!r[0]||!n[0])return r[0]?s:n[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=r.length)<(l=n.length)?a:l,s=-1;++sn[s]^e?1:-1;return a==l?0:a>l^e?1:-1},g.eq=function(t){return 0===this.cmp(t)},g.gt=function(t){return this.cmp(t)>0},g.gte=function(t){return this.cmp(t)>-1},g.lt=function(t){return this.cmp(t)<0},g.lte=function(t){return this.cmp(t)<1},g.minus=g.sub=function(t){let e,i,r,n,s=this,o=s.constructor,a=s.s,l=(t=new o(t)).s;if(a!=l)return t.s=-l,s.plus(t);let h=s.c.slice(),u=s.e,c=t.c,f=t.e;if(!h[0]||!c[0])return c[0]?t.s=-l:h[0]?t=new o(s):t.s=1,t;if(a=u-f){for((n=a<0)?(a=-a,r=h):(f=u,r=c),r.reverse(),l=a;l--;)r.push(0);r.reverse()}else for(i=((n=h.length0)for(;l--;)h[e++]=0;for(l=e;i>a;){if(h[--i]0?(l=o,r=h):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-h.length<0&&(r=h,h=a,a=r),e=h.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+h[e]+i)/10|0;for(i&&(a.unshift(i),++l),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=l,t},g.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-u||t>u)throw Error(d);return w(new this.constructor(this),t+this.e+1,e)},g.toFixed=function(t,e){let i=this,r=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>u)throw Error(d);for(i=w(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},g.toNumber=function(){let t=Number(b(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(c+"Imprecise conversion");return t};const m=function t(){function e(i){let r=this;if(!(r instanceof e))return void 0===i?t():new e(i);if(i instanceof e)r.s=i.s,r.e=i.e,r.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(f+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,r,n;if(!y.test(e))throw Error(`${f}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(i<0&&(i=r),i+=+e.slice(r+1),e=e.substring(0,r)):i<0&&(i=e.length),n=e.length,r=0;r0&&"0"==e.charAt(--n););for(t.e=i-r-1,t.c=[],i=0;r<=n;)t.c[i++]=+e.charAt(r++)}}(r,i)}r.constructor=e}return e.prototype=g,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}(); /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */class E extends h{#i=m("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const r=this.utils.validateArgs(e),i=this.charsets[r.version];let n,s,o,a="";if(r.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(s=!0,o=m(-t)):(s=!1,o=m(t))}else[n,s]=this.utils.inputHandler.toBytes(t,r),o=m(this.b10.encode(n,null,r.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=i[o.toNumber()],s&&(a=`-${a}`),a;const l=[],h=[];let u=m(1),c=this.#i,f=0;for(;c.lt(o);)[u,c]=this.#n(u,c),f++;const d=(t,e,r)=>{if(!this.#s(o)){for(;t.gt(o);){if([t,e]=this.#o(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");r--}r>-1?l.unshift(r):h.push(r),o=o.minus(t),d(t,e,r)}};return d(u,c,f),f=0,l.forEach((t=>{for(;f{for(;f>t;)a+=i[0],f--;a+=i[1],f--})),s&&(a=`-${a}`),a}decode(t,...e){const r=this.utils.validateArgs(e),i=this.charsets[r.version];let n;if([t,n]=this.utils.extractSign(this.utils.normalizeInput(t)),!r.integrity){const e=[...i,"."];t=[...t].filter((t=>e.includes(t))).join("")}const s=t.split(".");if(r.integrity&&s.length>2)throw new o(null,"There are multiple decimal points in the input.");const[a,l]=s;let h=m(0),u=this.#i.minus(1),c=m(1);if([...a].reverse().forEach((t=>{const e=i.indexOf(t);if(1===e)h=h.plus(c);else if(0!==e)throw new o(t);[u,c]=this.#n(u,c)})),l){let t=m(1);c=this.#i.minus(t),[...l].forEach((e=>{const r=i.indexOf(e);if(1===r)h=h.plus(c);else if(0!==r)throw new o(e);[c,t]=this.#o(c,t)}))}if(r.decimalMode)return h.toNumber();h=h.round().toFixed();const f=this.b10.decode(h,[..."0123456789"],[],r.integrity,r.littleEndian);return this.utils.outputHandler.compile(f,r.outputType,r.littleEndian,n)}#s(t){return!t.round(50).abs().toNumber()}#n(t,e){return[e,t.plus(e)]}#o(t,e){return[e.minus(t),t]}}export{E as default}; + */class E extends h{#r=m("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),r=this.charsets[i.version];let n,s,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(s=!0,o=m(-t)):(s=!1,o=m(t))}else[n,s]=this.utils.inputHandler.toBytes(t,i),o=m(this.b10.encode(n,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=r[o.toNumber()],s&&(a=`-${a}`),a;const l=[],h=[];let u=m(1),c=this.#r,f=0;for(;c.lt(o);)[u,c]=this.#n(u,c),f++;const d=(t,e,i)=>{if(!this.#s(o)){for(;t.gt(o);){if([t,e]=this.#o(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?l.unshift(i):h.push(i),o=o.minus(t),d(t,e,i)}};return d(u,c,f),f=0,l.forEach((t=>{for(;f{for(;f>t;)a+=r[0],f--;a+=r[1],f--})),s&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),r=this.charsets[i.version];let n;if([t,n]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...r,"."];t=[...t].filter((t=>e.includes(t))).join("")}const s=t.split(".");if(i.integrity&&s.length>2)throw new o(null,"There are multiple decimal points in the input.");const[a,l]=s;let h=m(0),u=this.#r.minus(1),c=m(1);if([...a].reverse().forEach((t=>{const e=r.indexOf(t);if(1===e)h=h.plus(c);else if(0!==e)throw new o(t);[u,c]=this.#n(u,c)})),l){let t=m(1);c=this.#r.minus(t),[...l].forEach((e=>{const i=r.indexOf(e);if(1===i)h=h.plus(c);else if(0!==i)throw new o(e);[c,t]=this.#o(c,t)}))}if(i.decimalMode)return h.toNumber();h=h.round().toFixed();const f=this.b10.decode(h,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(f,i.outputType,i.littleEndian,n)}#s(t){return!t.round(50).abs().toNumber()}#n(t,e){return[e,t.plus(e)]}#o(t,e){return[e.minus(t),t]}}export{E as default}; diff --git a/dist/converters/BasePhi/base-phi.iife.js b/dist/converters/BasePhi/base-phi.iife.js index 2e37b8c..b3d7989 100644 --- a/dist/converters/BasePhi/base-phi.iife.js +++ b/dist/converters/BasePhi/base-phi.iife.js @@ -979,6 +979,7 @@ var BasePhi = (function () { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1152,19 +1153,25 @@ var BasePhi = (function () { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var BasePhi = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var BasePhi = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1459,7 +1472,7 @@ var BasePhi = (function () { /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/BasePhi/base-phi.iife.min.js b/dist/converters/BasePhi/base-phi.iife.min.js index 1531d59..6e4bc18 100644 --- a/dist/converters/BasePhi/base-phi.iife.min.js +++ b/dist/converters/BasePhi/base-phi.iife.min.js @@ -1,8 +1,8 @@ -var BasePhi=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,r){let i;return i="buffer"===(r=e.getType(r))?t.buffer:"view"===r?new DataView(t.buffer):t,i}}class r{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const r=this.makeDataView(8);return r.setFloat64(0,t,e),r}static numbers(t,e=!1){let r,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,r,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,r="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,r="bigger",i="MAX"),new RangeError(`The provided integer is ${r} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(r=this.makeDataView(8),r.setBigInt64(0,BigInt(t),e)):t<-32768?(r=this.makeDataView(4),r.setInt32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):t>0?t>4294967295?(r=this.makeDataView(8),r.setBigUint64(0,BigInt(t),e)):t>65535?(r=this.makeDataView(4),r.setUint32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):r=new Uint16Array([0])}else i="float",r=this.floatingPoints(t,e);return[new Uint8Array(r.buffer),i]}static bigInts(t,e=!1){const r=new Array,i=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)r[i](t%n),t>>=64n;else for(;t>=n;)r[i](t%n),t>>=64n;r[i](t);const s=8*r.length,o=this.makeDataView(s);return r.forEach(((t,r)=>{const i=8*r;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let r,i=!1,n="bytes";if(t instanceof ArrayBuffer)r=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)r=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);r=new Uint8Array(i.buffer),n="float"}else[r,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),r=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const r of t)i.push(...this.toBytes(r,e)[0]);r=Uint8Array.from(i)}}return[r,i,n]}}const i=r,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,r,i){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=r?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,r,i){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,r,i);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,r,i);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,r,i);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,i=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return n;t=r.toBytes(n,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,n);t=new Uint8Array(e)}i&&t.reverse();let r=0n;t.forEach((t=>r=(r<<8n)+BigInt(t))),"uint_n"!==e&&(r=BigInt.asIntN(8*t.length,r)),s="bigint_n"!==e&&r>=Number.MIN_SAFE_INTEGER&&r<=Number.MAX_SAFE_INTEGER?Number(r):r}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,r=[],i=!0)=>{const n=(t,r,i)=>{if(0===i&&r.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${r}'`),[];let n=i;if("string"==typeof r&&(r=[...r]),Array.isArray(r))n=r.length,r=new Set(r);else if(!(r instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(r.size===i)return[...r];if(n!==i)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${i}.`);{const r={};(e=[...e]).forEach((t=>{t in r?r[t]++:r[t]=1}));let n="";i<100&&(n=`${e.join("")}\n`,e.forEach((t=>{r[t]>1?n+="^":n+=" "})));const s=Object.keys(r).filter((t=>r[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",r,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#r(t,e,r,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(r)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(r,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!r.length)return s&&this.setIOHandlers(),o;const a=t=>!!r.includes(t)&&(r.splice(r.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const r=a("bytes_in")?t:i,s=a("bytes_out")?e:n;this.setIOHandlers(r,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(r.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const r in h)if(h[r].includes(t)){if(e=!1,!this.root.isMutable[r])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[r]=Boolean(h[r].indexOf(t))}e&&this.#r(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const r=new RegExp(`.{1,${e}}`,"gu");return t.match(r).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,r=null,i=0){this.radix=t,null!==e&&null!==r?(this.bsEnc=e,this.bsDec=r):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let r=0;for(;8*r*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,r=[],i=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const n=e.indexOf(t);if(n>-1)a.push(n);else if(i&&-1===r.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[n,i]=this.divmod(n,256),r.unshift(parseInt(i,10));for(r.unshift(parseInt(n,10));r.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,r,...i){const n=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),l=null;e&&(l=e(n));let[h,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,l);return n.signed&&(h=this.utils.toSignedStr(h,o)),n.upper&&(h=h.toUpperCase()),r&&(h=r({inputBytes:s,output:h,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(h,n.options.lineWrap)}decode(t,e,r,i,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return r&&(a=r({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}}let u=1e6,c="[big.js] ",f=c+"Invalid ",d=f+"decimal places",p=f+"rounding mode",g={},y=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function w(t,e,r,i){let n=t.c;if(void 0===r&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(p);if(e<1)i=3===r&&(i||!!n[0])||0===e&&(1===r&&n[0]>=5||2===r&&(n[0]>5||5===n[0]&&(i||void 0!==n[1]))),n.length=1,i?(t.e=t.e-e+1,n[0]=1):n[0]=t.e=0;else if(e=5||2===r&&(n[e]>5||5===n[e]&&(i||void 0!==n[e+1]||1&n[e-1]))||3===r&&(i||!!n[0]),n.length=e,i)for(;++n[--e]>9;)if(n[e]=0,0===e){++t.e,n.unshift(1);break}for(e=n.length;!n[--e];)n.pop()}return t}function b(t,e,r){let i=t.e,n=t.c.join(""),s=n.length;if(e)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(i<0?"e":"e+")+i;else if(i<0){for(;++i;)n="0"+n;n="0."+n}else if(i>0)if(++i>s)for(i-=s;i--;)n+="0";else i1&&(n=n.charAt(0)+"."+n.slice(1));return t.s<0&&r?"-"+n:n}g.abs=function(){let t=new this.constructor(this);return t.s=1,t},g.cmp=function(t){let e,r=this,i=r.c,n=(t=new r.constructor(t)).c,s=r.s,o=t.s,a=r.e,l=t.e;if(!i[0]||!n[0])return i[0]?s:n[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=i.length)<(l=n.length)?a:l,s=-1;++sn[s]^e?1:-1;return a==l?0:a>l^e?1:-1},g.eq=function(t){return 0===this.cmp(t)},g.gt=function(t){return this.cmp(t)>0},g.gte=function(t){return this.cmp(t)>-1},g.lt=function(t){return this.cmp(t)<0},g.lte=function(t){return this.cmp(t)<1},g.minus=g.sub=function(t){let e,r,i,n,s=this,o=s.constructor,a=s.s,l=(t=new o(t)).s;if(a!=l)return t.s=-l,s.plus(t);let h=s.c.slice(),u=s.e,c=t.c,f=t.e;if(!h[0]||!c[0])return c[0]?t.s=-l:h[0]?t=new o(s):t.s=1,t;if(a=u-f){for((n=a<0)?(a=-a,i=h):(f=u,i=c),i.reverse(),l=a;l--;)i.push(0);i.reverse()}else for(r=((n=h.length0)for(;l--;)h[e++]=0;for(l=e;r>a;){if(h[--r]0?(l=o,i=h):(e=-e,i=a),i.reverse();e--;)i.push(0);i.reverse()}for(a.length-h.length<0&&(i=h,h=a,a=i),e=h.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+h[e]+r)/10|0;for(r&&(a.unshift(r),++l),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=l,t},g.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-u||t>u)throw Error(d);return w(new this.constructor(this),t+this.e+1,e)},g.toFixed=function(t,e){let r=this,i=r.c[0];if(void 0!==t){if(t!==~~t||t<0||t>u)throw Error(d);for(r=w(new r.constructor(r),t+r.e+1,e),t=t+r.e+1;r.c.length=e.PE,!!t.c[0])},g.toNumber=function(){let t=Number(b(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(c+"Imprecise conversion");return t};const m=function t(){function e(r){let i=this;if(!(i instanceof e))return void 0===r?t():new e(r);if(r instanceof e)i.s=r.s,i.e=r.e,i.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(f+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){let r,i,n;if(!y.test(e))throw Error(`${f}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(r<0&&(r=i),r+=+e.slice(i+1),e=e.substring(0,i)):r<0&&(r=e.length),n=e.length,i=0;i0&&"0"==e.charAt(--n););for(t.e=r-i-1,t.c=[],r=0;i<=n;)t.c[r++]=+e.charAt(i++)}}(i,r)}i.constructor=e}return e.prototype=g,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}(); +var BasePhi=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),l=null;e&&(l=e(n));let[h,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,l);return n.signed&&(h=this.utils.toSignedStr(h,o)),n.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(h,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}}let u=1e6,c="[big.js] ",f=c+"Invalid ",d=f+"decimal places",p=f+"rounding mode",g={},y=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function w(t,e,i,r){let n=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error(p);if(e<1)r=3===i&&(r||!!n[0])||0===e&&(1===i&&n[0]>=5||2===i&&(n[0]>5||5===n[0]&&(r||void 0!==n[1]))),n.length=1,r?(t.e=t.e-e+1,n[0]=1):n[0]=t.e=0;else if(e=5||2===i&&(n[e]>5||5===n[e]&&(r||void 0!==n[e+1]||1&n[e-1]))||3===i&&(r||!!n[0]),n.length=e,r)for(;++n[--e]>9;)if(n[e]=0,0===e){++t.e,n.unshift(1);break}for(e=n.length;!n[--e];)n.pop()}return t}function b(t,e,i){let r=t.e,n=t.c.join(""),s=n.length;if(e)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)n="0"+n;n="0."+n}else if(r>0)if(++r>s)for(r-=s;r--;)n+="0";else r1&&(n=n.charAt(0)+"."+n.slice(1));return t.s<0&&i?"-"+n:n}g.abs=function(){let t=new this.constructor(this);return t.s=1,t},g.cmp=function(t){let e,i=this,r=i.c,n=(t=new i.constructor(t)).c,s=i.s,o=t.s,a=i.e,l=t.e;if(!r[0]||!n[0])return r[0]?s:n[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=r.length)<(l=n.length)?a:l,s=-1;++sn[s]^e?1:-1;return a==l?0:a>l^e?1:-1},g.eq=function(t){return 0===this.cmp(t)},g.gt=function(t){return this.cmp(t)>0},g.gte=function(t){return this.cmp(t)>-1},g.lt=function(t){return this.cmp(t)<0},g.lte=function(t){return this.cmp(t)<1},g.minus=g.sub=function(t){let e,i,r,n,s=this,o=s.constructor,a=s.s,l=(t=new o(t)).s;if(a!=l)return t.s=-l,s.plus(t);let h=s.c.slice(),u=s.e,c=t.c,f=t.e;if(!h[0]||!c[0])return c[0]?t.s=-l:h[0]?t=new o(s):t.s=1,t;if(a=u-f){for((n=a<0)?(a=-a,r=h):(f=u,r=c),r.reverse(),l=a;l--;)r.push(0);r.reverse()}else for(i=((n=h.length0)for(;l--;)h[e++]=0;for(l=e;i>a;){if(h[--i]0?(l=o,r=h):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-h.length<0&&(r=h,h=a,a=r),e=h.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+h[e]+i)/10|0;for(i&&(a.unshift(i),++l),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=l,t},g.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-u||t>u)throw Error(d);return w(new this.constructor(this),t+this.e+1,e)},g.toFixed=function(t,e){let i=this,r=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>u)throw Error(d);for(i=w(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},g.toNumber=function(){let t=Number(b(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(c+"Imprecise conversion");return t};const m=function t(){function e(i){let r=this;if(!(r instanceof e))return void 0===i?t():new e(i);if(i instanceof e)r.s=i.s,r.e=i.e,r.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(f+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,r,n;if(!y.test(e))throw Error(`${f}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(i<0&&(i=r),i+=+e.slice(r+1),e=e.substring(0,r)):i<0&&(i=e.length),n=e.length,r=0;r0&&"0"==e.charAt(--n););for(t.e=i-r-1,t.c=[],i=0;r<=n;)t.c[i++]=+e.charAt(r++)}}(r,i)}r.constructor=e}return e.prototype=g,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}(); /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */return class extends h{#i=m("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const r=this.utils.validateArgs(e),i=this.charsets[r.version];let n,s,o,a="";if(r.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(s=!0,o=m(-t)):(s=!1,o=m(t))}else[n,s]=this.utils.inputHandler.toBytes(t,r),o=m(this.b10.encode(n,null,r.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=i[o.toNumber()],s&&(a=`-${a}`),a;const l=[],h=[];let u=m(1),c=this.#i,f=0;for(;c.lt(o);)[u,c]=this.#n(u,c),f++;const d=(t,e,r)=>{if(!this.#s(o)){for(;t.gt(o);){if([t,e]=this.#o(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");r--}r>-1?l.unshift(r):h.push(r),o=o.minus(t),d(t,e,r)}};return d(u,c,f),f=0,l.forEach((t=>{for(;f{for(;f>t;)a+=i[0],f--;a+=i[1],f--})),s&&(a=`-${a}`),a}decode(t,...e){const r=this.utils.validateArgs(e),i=this.charsets[r.version];let n;if([t,n]=this.utils.extractSign(this.utils.normalizeInput(t)),!r.integrity){const e=[...i,"."];t=[...t].filter((t=>e.includes(t))).join("")}const s=t.split(".");if(r.integrity&&s.length>2)throw new o(null,"There are multiple decimal points in the input.");const[a,l]=s;let h=m(0),u=this.#i.minus(1),c=m(1);if([...a].reverse().forEach((t=>{const e=i.indexOf(t);if(1===e)h=h.plus(c);else if(0!==e)throw new o(t);[u,c]=this.#n(u,c)})),l){let t=m(1);c=this.#i.minus(t),[...l].forEach((e=>{const r=i.indexOf(e);if(1===r)h=h.plus(c);else if(0!==r)throw new o(e);[c,t]=this.#o(c,t)}))}if(r.decimalMode)return h.toNumber();h=h.round().toFixed();const f=this.b10.decode(h,[..."0123456789"],[],r.integrity,r.littleEndian);return this.utils.outputHandler.compile(f,r.outputType,r.littleEndian,n)}#s(t){return!t.round(50).abs().toNumber()}#n(t,e){return[e,t.plus(e)]}#o(t,e){return[e.minus(t),t]}}}(); + */return class extends h{#r=m("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),r=this.charsets[i.version];let n,s,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(s=!0,o=m(-t)):(s=!1,o=m(t))}else[n,s]=this.utils.inputHandler.toBytes(t,i),o=m(this.b10.encode(n,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=r[o.toNumber()],s&&(a=`-${a}`),a;const l=[],h=[];let u=m(1),c=this.#r,f=0;for(;c.lt(o);)[u,c]=this.#n(u,c),f++;const d=(t,e,i)=>{if(!this.#s(o)){for(;t.gt(o);){if([t,e]=this.#o(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?l.unshift(i):h.push(i),o=o.minus(t),d(t,e,i)}};return d(u,c,f),f=0,l.forEach((t=>{for(;f{for(;f>t;)a+=r[0],f--;a+=r[1],f--})),s&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),r=this.charsets[i.version];let n;if([t,n]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...r,"."];t=[...t].filter((t=>e.includes(t))).join("")}const s=t.split(".");if(i.integrity&&s.length>2)throw new o(null,"There are multiple decimal points in the input.");const[a,l]=s;let h=m(0),u=this.#r.minus(1),c=m(1);if([...a].reverse().forEach((t=>{const e=r.indexOf(t);if(1===e)h=h.plus(c);else if(0!==e)throw new o(t);[u,c]=this.#n(u,c)})),l){let t=m(1);c=this.#r.minus(t),[...l].forEach((e=>{const i=r.indexOf(e);if(1===i)h=h.plus(c);else if(0!==i)throw new o(e);[c,t]=this.#o(c,t)}))}if(i.decimalMode)return h.toNumber();h=h.round().toFixed();const f=this.b10.decode(h,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(f,i.outputType,i.littleEndian,n)}#s(t){return!t.round(50).abs().toNumber()}#n(t,e){return[e,t.plus(e)]}#o(t,e){return[e.minus(t),t]}}}(); diff --git a/dist/converters/ByteConverter/byte-converter.esm.js b/dist/converters/ByteConverter/byte-converter.esm.js index 0a81df4..82a7736 100644 --- a/dist/converters/ByteConverter/byte-converter.esm.js +++ b/dist/converters/ByteConverter/byte-converter.esm.js @@ -460,7 +460,7 @@ class SmartOutput { /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/ByteConverter/byte-converter.esm.min.js b/dist/converters/ByteConverter/byte-converter.esm.min.js index 5e4f755..abaa384 100644 --- a/dist/converters/ByteConverter/byte-converter.esm.min.js +++ b/dist/converters/ByteConverter/byte-converter.esm.min.js @@ -2,7 +2,7 @@ class t{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e) /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */const n=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class i{constructor(...t){this.littleEndian=n,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,n=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const r=e.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!e.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${r}`);i.outputType=t}})),n)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(e,...n){const i=this.utils.validateArgs(n);return t.toBytes(e,i)[0]}decode(t,...n){const i=this.utils.validateArgs(n);return e.compile(t,i.outputType,i.littleEndian)}}export{i as default}; diff --git a/dist/converters/ByteConverter/byte-converter.iife.js b/dist/converters/ByteConverter/byte-converter.iife.js index a91bbb4..f25c4f3 100644 --- a/dist/converters/ByteConverter/byte-converter.iife.js +++ b/dist/converters/ByteConverter/byte-converter.iife.js @@ -463,7 +463,7 @@ var ByteConverter = (function () { /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/ByteConverter/byte-converter.iife.min.js b/dist/converters/ByteConverter/byte-converter.iife.min.js index 266d1cf..3d5aedf 100644 --- a/dist/converters/ByteConverter/byte-converter.iife.min.js +++ b/dist/converters/ByteConverter/byte-converter.iife.min.js @@ -2,7 +2,7 @@ var ByteConverter=function(){"use strict";class t{static makeDataView(t){const e /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */const n=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();return class{constructor(...t){this.littleEndian=n,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,n=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const r=e.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!e.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${r}`);i.outputType=t}})),n)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(e,...n){const i=this.utils.validateArgs(n);return t.toBytes(e,i)[0]}decode(t,...n){const i=this.utils.validateArgs(n);return e.compile(t,i.outputType,i.littleEndian)}}}(); diff --git a/dist/converters/Ecoji/ecoji.esm.js b/dist/converters/Ecoji/ecoji.esm.js index cc336d6..528674f 100644 --- a/dist/converters/Ecoji/ecoji.esm.js +++ b/dist/converters/Ecoji/ecoji.esm.js @@ -976,6 +976,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1149,19 +1150,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT OR Apache-2.0 * @see https://github.com/keith-turner/ecoji diff --git a/dist/converters/Ecoji/ecoji.esm.min.js b/dist/converters/Ecoji/ecoji.esm.min.js index 1021250..94b1440 100644 --- a/dist/converters/Ecoji/ecoji.esm.min.js +++ b/dist/converters/Ecoji/ecoji.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT OR Apache-2.0 * @see https://github.com/keith-turner/ecoji diff --git a/dist/converters/Ecoji/ecoji.iife.js b/dist/converters/Ecoji/ecoji.iife.js index 1527bc0..c983d9e 100644 --- a/dist/converters/Ecoji/ecoji.iife.js +++ b/dist/converters/Ecoji/ecoji.iife.js @@ -979,6 +979,7 @@ var Ecoji = (function () { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1152,19 +1153,25 @@ var Ecoji = (function () { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var Ecoji = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var Ecoji = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var Ecoji = (function () { /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT OR Apache-2.0 * @see https://github.com/keith-turner/ecoji diff --git a/dist/converters/Ecoji/ecoji.iife.min.js b/dist/converters/Ecoji/ecoji.iife.min.js index 363d8cb..ebec6be 100644 --- a/dist/converters/Ecoji/ecoji.iife.min.js +++ b/dist/converters/Ecoji/ecoji.iife.min.js @@ -1,8 +1,8 @@ -var Ecoji=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Ecoji=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT OR Apache-2.0 * @see https://github.com/keith-turner/ecoji diff --git a/dist/converters/LEB128/leb-128.esm.js b/dist/converters/LEB128/leb-128.esm.js index 581e2e1..b74cfe4 100644 --- a/dist/converters/LEB128/leb-128.esm.js +++ b/dist/converters/LEB128/leb-128.esm.js @@ -976,6 +976,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1149,19 +1150,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/LEB128/leb-128.esm.min.js b/dist/converters/LEB128/leb-128.esm.min.js index c3c2e54..5bd7a0b 100644 --- a/dist/converters/LEB128/leb-128.esm.min.js +++ b/dist/converters/LEB128/leb-128.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */class u extends h{constructor(...t){super(),this.converter=new l(10,0,0),this.hexlify=new l(16,1,2),this.charsets.default="",this.charsets.hex="",this.version="default",this.frozenCharsets=!0,this.littleEndian=!0,this.hasSignedMode=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const n=this.utils.validateArgs(e),i=n.signed;n.signed=!0;const[r,s]=this.utils.inputHandler.toBytes(t,n);let o=this.converter.encode(r,null,n.littleEndian)[0],a=BigInt(o),l=new Array;if(s){if(!i)throw new TypeError("Negative values in unsigned mode are invalid.");a=-a}if(i)for(;;){const t=Number(127n&a);if(a>>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){l.push(t);break}l.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){l.push(t);break}l.push(128|t)}const h=Uint8Array.from(l);return"hex"===n.version?this.hexlify.encode(h,[..."0123456789abcdef"],!1)[0]:h}decode(e,...n){const i=this.utils.validateArgs(n);if("hex"===i.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],i.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),i.outputType,!0);e=Array.from(e);let r,s,o,a=0n,l=-7n;for(r of e)l+=7n,a+=BigInt(127&r)<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){l.push(t);break}l.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){l.push(t);break}l.push(128|t)}const h=Uint8Array.from(l);return"hex"===i.version?this.hexlify.encode(h,[..."0123456789abcdef"],!1)[0]:h}decode(e,...i){const n=this.utils.validateArgs(i);if("hex"===n.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],n.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),n.outputType,!0);e=Array.from(e);let r,s,o,a=0n,l=-7n;for(r of e)l+=7n,a+=BigInt(127&r)< { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var LEB128 = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var LEB128 = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var LEB128 = (function () { /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/LEB128/leb-128.iife.min.js b/dist/converters/LEB128/leb-128.iife.min.js index 55256b2..ad933d4 100644 --- a/dist/converters/LEB128/leb-128.iife.min.js +++ b/dist/converters/LEB128/leb-128.iife.min.js @@ -1,8 +1,8 @@ -var LEB128=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var LEB128=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */return class extends h{constructor(...t){super(),this.converter=new l(10,0,0),this.hexlify=new l(16,1,2),this.charsets.default="",this.charsets.hex="",this.version="default",this.frozenCharsets=!0,this.littleEndian=!0,this.hasSignedMode=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const n=this.utils.validateArgs(e),i=n.signed;n.signed=!0;const[r,s]=this.utils.inputHandler.toBytes(t,n);let o=this.converter.encode(r,null,n.littleEndian)[0],a=BigInt(o),l=new Array;if(s){if(!i)throw new TypeError("Negative values in unsigned mode are invalid.");a=-a}if(i)for(;;){const t=Number(127n&a);if(a>>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){l.push(t);break}l.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){l.push(t);break}l.push(128|t)}const h=Uint8Array.from(l);return"hex"===n.version?this.hexlify.encode(h,[..."0123456789abcdef"],!1)[0]:h}decode(e,...n){const i=this.utils.validateArgs(n);if("hex"===i.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],i.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),i.outputType,!0);e=Array.from(e);let r,s,o,a=0n,l=-7n;for(r of e)l+=7n,a+=BigInt(127&r)<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){l.push(t);break}l.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){l.push(t);break}l.push(128|t)}const h=Uint8Array.from(l);return"hex"===i.version?this.hexlify.encode(h,[..."0123456789abcdef"],!1)[0]:h}decode(e,...i){const n=this.utils.validateArgs(i);if("hex"===n.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],n.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),n.outputType,!0);e=Array.from(e);let r,s,o,a=0n,l=-7n;for(r of e)l+=7n,a+=BigInt(127&r)< { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/SimpleBase/simple-base.esm.min.js b/dist/converters/SimpleBase/simple-base.esm.min.js index e84c9f8..fb46df5 100644 --- a/dist/converters/SimpleBase/simple-base.esm.min.js +++ b/dist/converters/SimpleBase/simple-base.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const i=e.indexOf(t);if(i>-1)a.push(i);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */class u extends h{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new l(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}export{u as default}; diff --git a/dist/converters/SimpleBase/simple-base.iife.js b/dist/converters/SimpleBase/simple-base.iife.js index 50eb982..3ff1d81 100644 --- a/dist/converters/SimpleBase/simple-base.iife.js +++ b/dist/converters/SimpleBase/simple-base.iife.js @@ -979,6 +979,7 @@ var SimpleBase = (function () { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1152,19 +1153,25 @@ var SimpleBase = (function () { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var SimpleBase = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var SimpleBase = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var SimpleBase = (function () { /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/SimpleBase/simple-base.iife.min.js b/dist/converters/SimpleBase/simple-base.iife.min.js index 3054445..c0ac07e 100644 --- a/dist/converters/SimpleBase/simple-base.iife.min.js +++ b/dist/converters/SimpleBase/simple-base.iife.min.js @@ -1,8 +1,8 @@ -var SimpleBase=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const i=e.indexOf(t);if(i>-1)a.push(i);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var SimpleBase=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */return class extends h{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new l(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}}(); diff --git a/dist/converters/UUencode/uuencode.esm.js b/dist/converters/UUencode/uuencode.esm.js index fea73e1..d129f3a 100644 --- a/dist/converters/UUencode/uuencode.esm.js +++ b/dist/converters/UUencode/uuencode.esm.js @@ -976,6 +976,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1149,19 +1150,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1185,17 +1192,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1223,7 +1236,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1451,7 +1464,7 @@ class BaseTemplate { /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/UUencode/uuencode.esm.min.js b/dist/converters/UUencode/uuencode.esm.min.js index c2bdec0..7a3bd06 100644 --- a/dist/converters/UUencode/uuencode.esm.min.js +++ b/dist/converters/UUencode/uuencode.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in l)if(l[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(l[n].indexOf(t))}e&&this.#n(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),n&&(l=n({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */class u extends l{constructor(...t){super(),this.converter=new h(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{const i=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||c()} ${e.options.file||d()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-n;t+=`${i.at(r)}${e.join("")}\n`;break}t+=`${i.at(45)}${e.join("")}\n`}return t+=`${i.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let n=0;return super.decode(t,(({input:t,settings:e})=>{const i=this.charsets[e.version],r=t.trim().split(/\r?\n/),s=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=i.indexOf(r.shift());if(!(o>0))break;if(s.push(...r),45!==o){n=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;s.length%60;)s.push(" ")}return s.join("")}),(({output:t})=>(n&&(t=new Uint8Array(t.slice(0,-n))),t)),!0,...e)}}const c=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},d=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};export{u as default}; + */class u extends l{constructor(...t){super(),this.converter=new h(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const n=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||c()} ${e.options.file||d()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${n.at(r)}${e.join("")}\n`;break}t+=`${n.at(45)}${e.join("")}\n`}return t+=`${n.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const n=this.charsets[e.version],r=t.trim().split(/\r?\n/),s=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=n.indexOf(r.shift());if(!(o>0))break;if(s.push(...r),45!==o){i=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;s.length%60;)s.push(" ")}return s.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const c=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},d=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};export{u as default}; diff --git a/dist/converters/UUencode/uuencode.iife.js b/dist/converters/UUencode/uuencode.iife.js index 0c68bb2..29bc9c1 100644 --- a/dist/converters/UUencode/uuencode.iife.js +++ b/dist/converters/UUencode/uuencode.iife.js @@ -979,6 +979,7 @@ var UUencode = (function () { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -1152,19 +1153,25 @@ var UUencode = (function () { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + }; + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -1188,17 +1195,23 @@ var UUencode = (function () { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -1226,7 +1239,7 @@ var UUencode = (function () { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) @@ -1454,7 +1467,7 @@ var UUencode = (function () { /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/dist/converters/UUencode/uuencode.iife.min.js b/dist/converters/UUencode/uuencode.iife.min.js index 6e1a9e8..eeb8598 100644 --- a/dist/converters/UUencode/uuencode.iife.min.js +++ b/dist/converters/UUencode/uuencode.iife.min.js @@ -1,8 +1,8 @@ -var UUencode=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in l)if(l[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(l[n].indexOf(t))}e&&this.#n(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),n&&(l=n({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var UUencode=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in l)if(l[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(l[n].indexOf(t))}e&&this.#n(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),n&&(l=n({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */const u=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},c=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};return class extends l{constructor(...t){super(),this.converter=new h(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{const i=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||u()} ${e.options.file||c()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-n;t+=`${i.at(r)}${e.join("")}\n`;break}t+=`${i.at(45)}${e.join("")}\n`}return t+=`${i.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let n=0;return super.decode(t,(({input:t,settings:e})=>{const i=this.charsets[e.version],r=t.trim().split(/\r?\n/),s=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=i.indexOf(r.shift());if(!(o>0))break;if(s.push(...r),45!==o){n=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;s.length%60;)s.push(" ")}return s.join("")}),(({output:t})=>(n&&(t=new Uint8Array(t.slice(0,-n))),t)),!0,...e)}}}(); diff --git a/package-lock.json b/package-lock.json index ed4aa7d..fa1a32d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "base-ex", - "version": "0.7.8", + "version": "0.7.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "base-ex", - "version": "0.7.8", + "version": "0.7.9", "license": "MIT", "devDependencies": { "@rollup/plugin-terser": "^0.4.3", @@ -402,12 +402,12 @@ } }, "node_modules/ava": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ava/-/ava-5.2.0.tgz", - "integrity": "sha512-W8yxFXJr/P68JP55eMpQIa6AiXhCX3VeuajM8nolyWNExcMDD6rnIWKTjw0B/+GkFHBIaN6Jd0LtcMThcoqVfg==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ava/-/ava-5.3.0.tgz", + "integrity": "sha512-QYvBdyygl1LGX13IuYsC4bkwVCzZeovMGbxYkD73i7DVJxNlWnFa06YgrBOTbjw2QvSKUl5fOJ92Kj5WK9hSeg==", "dev": true, "dependencies": { - "acorn": "^8.8.1", + "acorn": "^8.8.2", "acorn-walk": "^8.2.0", "ansi-styles": "^6.2.1", "arrgv": "^1.0.2", @@ -417,7 +417,7 @@ "chalk": "^5.2.0", "chokidar": "^3.5.3", "chunkd": "^2.0.1", - "ci-info": "^3.7.1", + "ci-info": "^3.8.0", "ci-parallel-vars": "^1.0.1", "clean-yaml-object": "^0.1.0", "cli-truncate": "^3.1.0", @@ -426,10 +426,9 @@ "concordance": "^5.0.4", "currently-unhandled": "^0.4.1", "debug": "^4.3.4", - "del": "^7.0.0", "emittery": "^1.0.1", "figures": "^5.0.0", - "globby": "^13.1.3", + "globby": "^13.1.4", "ignore-by-default": "^2.1.0", "indent-string": "^5.0.0", "is-error": "^2.2.2", @@ -445,13 +444,12 @@ "plur": "^5.1.0", "pretty-ms": "^8.0.0", "resolve-cwd": "^3.0.0", - "slash": "^3.0.0", "stack-utils": "^2.0.6", "strip-ansi": "^7.0.1", "supertap": "^3.0.1", "temp-dir": "^3.0.0", - "write-file-atomic": "^5.0.0", - "yargs": "^17.6.2" + "write-file-atomic": "^5.0.1", + "yargs": "^17.7.2" }, "bin": { "ava": "entrypoints/cli.mjs" @@ -919,40 +917,6 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, - "node_modules/del": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/del/-/del-7.0.0.tgz", - "integrity": "sha512-tQbV/4u5WVB8HMJr08pgw0b6nG4RGt/tj+7Numvq+zqcvUFeMaIWWOUFltiU+6go8BSO2/ogsB4EasDaj0y68Q==", - "dev": true, - "dependencies": { - "globby": "^13.1.2", - "graceful-fs": "^4.2.10", - "is-glob": "^4.0.3", - "is-path-cwd": "^3.0.0", - "is-path-inside": "^4.0.0", - "p-map": "^5.5.0", - "rimraf": "^3.0.2", - "slash": "^4.0.0" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/del/node_modules/slash": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", - "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/diff": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", @@ -1167,15 +1131,6 @@ "node": ">=10.13.0" } }, - "node_modules/eslint/node_modules/is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/eslint/node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -1544,24 +1499,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/globby/node_modules/slash": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", - "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true - }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -1858,28 +1795,13 @@ "node": ">=0.12.0" } }, - "node_modules/is-path-cwd": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-3.0.0.tgz", - "integrity": "sha512-kyiNFFLU0Ampr6SDZitD/DwUo4Zs1nSdnygUBqsu3LooL00Qvb5j+UnvApUn/TTj1J3OuE6BTdQ5rudKmU2ZaA==", - "dev": true, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-path-inside": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz", - "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", "dev": true, "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=8" } }, "node_modules/is-plain-object": { @@ -2714,9 +2636,9 @@ } }, "node_modules/rollup": { - "version": "3.22.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.22.0.tgz", - "integrity": "sha512-imsigcWor5Y/dC0rz2q0bBt9PabcL3TORry2hAa6O6BuMvY71bqHyfReAz5qyAqiQATD1m70qdntqBfBQjVWpQ==", + "version": "3.23.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.23.0.tgz", + "integrity": "sha512-h31UlwEi7FHihLe1zbk+3Q7z1k/84rb9BSwmBSr/XjOCEaBJ2YyedQDuM0t/kfOS0IxM+vk1/zI9XxYj9V+NJQ==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -2881,12 +2803,15 @@ } }, "node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", "dev": true, "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/slice-ansi": { @@ -3060,9 +2985,9 @@ } }, "node_modules/terser": { - "version": "5.17.4", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.17.4.tgz", - "integrity": "sha512-jcEKZw6UPrgugz/0Tuk/PVyLAPfMBJf5clnGueo45wTweoV8yh7Q7PEkhkJ5uuUbC7zAxEcG3tqNr1bstkQ8nw==", + "version": "5.17.6", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.17.6.tgz", + "integrity": "sha512-V8QHcs8YuyLkLHsJO5ucyff1ykrLVsR4dNnS//L5Y3NiSXpbK1J+WMVUs67eI0KTxs9JtHhgEQpXQVHlHI92DQ==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.2", diff --git a/package.json b/package.json index 9573192..5589ffb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "base-ex", - "version": "0.7.8", + "version": "0.7.9", "description": "A collection of classes for data representation written in JavaScript.", "main": "./cjs/base-ex.cjs", "module": "./src/base-ex.js", diff --git a/src/base-ex.js b/src/base-ex.js index 21a066a..ef4b006 100644 --- a/src/base-ex.js +++ b/src/base-ex.js @@ -1,7 +1,7 @@ /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/base-1.js b/src/converters/base-1.js index c9326b9..9d0cfe6 100644 --- a/src/converters/base-1.js +++ b/src/converters/base-1.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/base-16.js b/src/converters/base-16.js index 4cda7d1..c271b04 100644 --- a/src/converters/base-16.js +++ b/src/converters/base-16.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-16.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/base-2048.js b/src/converters/base-2048.js index 3c1eb8b..b48c31f 100644 --- a/src/converters/base-2048.js +++ b/src/converters/base-2048.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/base-32.js b/src/converters/base-32.js index 294ebd3..e5377ab 100644 --- a/src/converters/base-32.js +++ b/src/converters/base-32.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/base-58.js b/src/converters/base-58.js index 877cd24..dc642ac 100644 --- a/src/converters/base-58.js +++ b/src/converters/base-58.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/base-64.js b/src/converters/base-64.js index bcf340a..7b95b07 100644 --- a/src/converters/base-64.js +++ b/src/converters/base-64.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/base-85.js b/src/converters/base-85.js index 6de094f..f9b0a5b 100644 --- a/src/converters/base-85.js +++ b/src/converters/base-85.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/base-91.js b/src/converters/base-91.js index d454f58..04fad98 100644 --- a/src/converters/base-91.js +++ b/src/converters/base-91.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ diff --git a/src/converters/base-phi.js b/src/converters/base-phi.js index f2d297e..cb441f3 100644 --- a/src/converters/base-phi.js +++ b/src/converters/base-phi.js @@ -1,7 +1,7 @@ /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/byte-converter.js b/src/converters/byte-converter.js index 72175b7..07fd8df 100644 --- a/src/converters/byte-converter.js +++ b/src/converters/byte-converter.js @@ -1,7 +1,7 @@ /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/ecoji.js b/src/converters/ecoji.js index df0ee4b..4ab2257 100644 --- a/src/converters/ecoji.js +++ b/src/converters/ecoji.js @@ -1,7 +1,7 @@ /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT OR Apache-2.0 * @see https://github.com/keith-turner/ecoji diff --git a/src/converters/leb-128.js b/src/converters/leb-128.js index 990e550..ddee89a 100644 --- a/src/converters/leb-128.js +++ b/src/converters/leb-128.js @@ -1,7 +1,7 @@ /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/simple-base.js b/src/converters/simple-base.js index bd4a696..f26ee23 100644 --- a/src/converters/simple-base.js +++ b/src/converters/simple-base.js @@ -1,7 +1,7 @@ /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/converters/uuencode.js b/src/converters/uuencode.js index 196e35f..63209b9 100644 --- a/src/converters/uuencode.js +++ b/src/converters/uuencode.js @@ -1,7 +1,7 @@ /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} * - * @version 0.7.8 + * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT */ diff --git a/src/core.js b/src/core.js index 33c7590..6e43bbb 100644 --- a/src/core.js +++ b/src/core.js @@ -28,6 +28,7 @@ class BaseConverter { } this.decPadVal = decPadVal; + this.powers = {}; } /** @@ -201,19 +202,25 @@ class BaseConverter { return new Uint8Array(0); } - let bs = this.bsDec; - const byteArray = new Array(); + const byteArray = []; + + const toObj = arr => { + const obj = {}; + arr.forEach((v, i) => obj[v] = i); + return obj; + } + const charsetLookup = toObj(charset); [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { + const index = charsetLookup[c]; + if (typeof index !== "undefined") { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); - + let padChars; if (bs === 0) { @@ -237,17 +244,23 @@ class BaseConverter { // the blocksize. for (let i=0, l=byteArray.length; i { + this.powers[exp] = BigInt(this.pow(exp)); + return this.powers[exp]; + })(); + + n += BigInt(byteArray[i+j]) * pow; } // To store the output chunks, initialize a // new default array. - const subArray256 = new Array(); + const subArray256 = []; // The subarray gets converted into a bs*8-bit // binary number "n", most significant byte @@ -275,7 +288,7 @@ class BaseConverter { // The subarray gets concatenated with the // main array. - b256Array = b256Array.concat(subArray256); + b256Array.push(...subArray256); } // Remove padded zeros (or in case of LE all leading zeros) From 5b802a86add51765c6b0ac13cac02a13ed25e109 Mon Sep 17 00:00:00 2001 From: UmamiAppearance Date: Fri, 26 May 2023 10:04:36 +0200 Subject: [PATCH 2/2] v0.7.9 --- cjs/base-ex.cjs | 14 ++++---------- cjs/base-ex.cjs.map | 2 +- dist/base-ex.esm.js | 14 ++++---------- dist/base-ex.esm.min.js | 2 +- dist/base-ex.iife.js | 14 ++++---------- dist/base-ex.iife.min.js | 2 +- dist/converters/Base1/base-1.esm.js | 14 ++++---------- dist/converters/Base1/base-1.esm.min.js | 2 +- dist/converters/Base1/base-1.iife.js | 14 ++++---------- dist/converters/Base1/base-1.iife.min.js | 2 +- dist/converters/Base16/base-16.esm.js | 14 ++++---------- dist/converters/Base16/base-16.esm.min.js | 2 +- dist/converters/Base16/base-16.iife.js | 14 ++++---------- dist/converters/Base16/base-16.iife.min.js | 2 +- dist/converters/Base32/base-32.esm.js | 14 ++++---------- dist/converters/Base32/base-32.esm.min.js | 2 +- dist/converters/Base32/base-32.iife.js | 14 ++++---------- dist/converters/Base32/base-32.iife.min.js | 4 ++-- dist/converters/Base58/base-58.esm.js | 14 ++++---------- dist/converters/Base58/base-58.esm.min.js | 2 +- dist/converters/Base58/base-58.iife.js | 14 ++++---------- dist/converters/Base58/base-58.iife.min.js | 2 +- dist/converters/Base64/base-64.esm.js | 14 ++++---------- dist/converters/Base64/base-64.esm.min.js | 4 ++-- dist/converters/Base64/base-64.iife.js | 14 ++++---------- dist/converters/Base64/base-64.iife.min.js | 4 ++-- dist/converters/Base85/base-85.esm.js | 14 ++++---------- dist/converters/Base85/base-85.esm.min.js | 2 +- dist/converters/Base85/base-85.iife.js | 14 ++++---------- dist/converters/Base85/base-85.iife.min.js | 2 +- dist/converters/BasePhi/base-phi.esm.js | 14 ++++---------- dist/converters/BasePhi/base-phi.esm.min.js | 2 +- dist/converters/BasePhi/base-phi.iife.js | 14 ++++---------- dist/converters/BasePhi/base-phi.iife.min.js | 2 +- dist/converters/Ecoji/ecoji.esm.js | 14 ++++---------- dist/converters/Ecoji/ecoji.esm.min.js | 2 +- dist/converters/Ecoji/ecoji.iife.js | 14 ++++---------- dist/converters/Ecoji/ecoji.iife.min.js | 2 +- dist/converters/LEB128/leb-128.esm.js | 14 ++++---------- dist/converters/LEB128/leb-128.esm.min.js | 2 +- dist/converters/LEB128/leb-128.iife.js | 14 ++++---------- dist/converters/LEB128/leb-128.iife.min.js | 2 +- dist/converters/SimpleBase/simple-base.esm.js | 14 ++++---------- dist/converters/SimpleBase/simple-base.esm.min.js | 2 +- dist/converters/SimpleBase/simple-base.iife.js | 14 ++++---------- dist/converters/SimpleBase/simple-base.iife.min.js | 2 +- dist/converters/UUencode/uuencode.esm.js | 14 ++++---------- dist/converters/UUencode/uuencode.esm.min.js | 2 +- dist/converters/UUencode/uuencode.iife.js | 14 ++++---------- dist/converters/UUencode/uuencode.iife.min.js | 2 +- src/core.js | 14 ++++---------- 51 files changed, 132 insertions(+), 288 deletions(-) diff --git a/cjs/base-ex.cjs b/cjs/base-ex.cjs index 76bf95b..075f457 100644 --- a/cjs/base-ex.cjs +++ b/cjs/base-ex.cjs @@ -1154,23 +1154,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/cjs/base-ex.cjs.map b/cjs/base-ex.cjs.map index b0637f5..bc3e6cc 100644 --- a/cjs/base-ex.cjs.map +++ b/cjs/base-ex.cjs.map @@ -1 +1 @@ -{"version":3,"file":"base-ex.cjs","sources":["../src/io-handlers.js","../src/utils.js","../src/core.js","../src/converters/base-1.js","../src/converters/base-16.js","../src/converters/base-32.js","../src/converters/base-58.js","../src/converters/base-64.js","../src/converters/uuencode.js","../src/converters/base-85.js","../src/converters/base-91.js","../src/converters/leb-128.js","../src/converters/ecoji.js","../src/converters/base-2048.js","../src/converters/simple-base.js","../lib/big.js/big.min.js","../src/converters/base-phi.js","../src/converters/byte-converter.js","../src/base-ex.js"],"sourcesContent":["/**\n * Simple Input Handler.\n * --------------------\n * Accepts only bytes eg. TypedArray, ArrayBuffer,\n * DataView, also a regular array (filled with integers)\n * is possible.\n */\nclass BytesInput {\n static toBytes(input) {\n if (ArrayBuffer.isView(input)) {\n input = input.buffer;\n } \n return [new Uint8Array(input), false, \"bytes\"];\n }\n}\n\n/**\n * Simple Output Handler.\n * ---------------------\n * Returns bytes in the form of:\n * - ArrayBuffer\n * - Uint8Array\n * - DataView \n */\nclass BytesOutput {\n\n static get typeList() {\n return [\n \"buffer\",\n \"bytes\",\n \"uint8\",\n \"view\"\n ];\n }\n\n static getType(type) {\n if (!BytesOutput.typeList.includes(type)) {\n throw new TypeError(`Unknown output type: '${type}'`);\n }\n return type;\n }\n\n static compile(Uint8ArrayOut, type) {\n type = BytesOutput.getType(type);\n let compiled;\n\n if (type === \"buffer\") {\n compiled = Uint8ArrayOut.buffer;\n } \n\n else if (type === \"view\") {\n compiled = new DataView(Uint8ArrayOut.buffer);\n }\n\n else {\n compiled = Uint8ArrayOut;\n }\n \n return compiled;\n }\n}\n\n\n/**\n * Advanced Input Handler.\n * ----------------------\n * Accepts almost every Input and converts it\n * into an Uint8Array (bytes).\n */\nclass SmartInput {\n\n static makeDataView(byteLen) {\n const buffer = new ArrayBuffer(byteLen);\n return new DataView(buffer);\n }\n\n static floatingPoints(input, littleEndian=false) {\n const view = this.makeDataView(8);\n view.setFloat64(0, input, littleEndian);\n return view;\n }\n\n static numbers(input, littleEndian=false) {\n\n let view;\n let type;\n\n // Integer\n if (Number.isInteger(input)) {\n\n type = \"int\";\n\n if (!Number.isSafeInteger(input)) {\n \n let safeInt;\n let smallerOrBigger;\n let minMax;\n\n if (input < 0) {\n safeInt = Number.MIN_SAFE_INTEGER;\n smallerOrBigger = \"smaller\";\n minMax = \"MIN\";\n } else {\n safeInt = Number.MAX_SAFE_INTEGER;\n smallerOrBigger = \"bigger\";\n minMax = \"MAX\";\n }\n\n throw new RangeError(`The provided integer is ${smallerOrBigger} than ${minMax}_SAFE_INTEGER: '${safeInt}'\\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`);\n }\n\n // Signed Integer\n if (input < 0) {\n \n // 64 bit\n if (input < -2147483648) {\n view = this.makeDataView(8);\n view.setBigInt64(0, BigInt(input), littleEndian);\n }\n \n // 32 littleEndian\n else if (input < -32768) {\n view = this.makeDataView(4);\n view.setInt32(0, input, littleEndian);\n }\n\n // 16 littleEndian\n else {\n view = this.makeDataView(2);\n view.setInt16(0, input, littleEndian);\n }\n }\n\n // Unsigned Integer\n else if (input > 0) {\n\n // 64 bit\n if (input > 4294967295) {\n view = this.makeDataView(8);\n view.setBigUint64(0, BigInt(input), littleEndian);\n }\n \n // 32 bit\n else if (input > 65535) {\n view = this.makeDataView(4);\n view.setUint32(0, input, littleEndian);\n }\n \n // 16 bit\n else {\n view = this.makeDataView(2);\n view.setInt16(0, input, littleEndian);\n }\n }\n\n // Zero\n else {\n view = new Uint16Array([0]);\n }\n }\n \n // Floating Point Number:\n else {\n type = \"float\";\n view = this.floatingPoints(input, littleEndian);\n }\n\n return [new Uint8Array(view.buffer), type];\n\n }\n\n\n static bigInts(input, littleEndian=false) {\n // Since BigInts are not limited to 64 bits, they might\n // overflow the BigInt64Array values. A little more \n // handwork is therefore needed.\n\n // as the integer size is not known yet, the bytes get a\n // makeshift home \"byteArray\", which is a regular array\n\n const byteArray = new Array();\n const append = (littleEndian) ? \"push\" : \"unshift\";\n const maxN = 18446744073709551616n;\n\n // split the input into 64 bit integers\n if (input < 0) {\n while (input < -9223372036854775808n) {\n byteArray[append](input % maxN);\n input >>= 64n;\n }\n } else { \n while (input >= maxN) {\n byteArray[append](input % maxN);\n input >>= 64n;\n }\n }\n\n // append the remaining byte\n byteArray[append](input);\n\n // determine the required size for the typed array\n // by taking the amount of 64 bit integers * 8\n // (8 bytes for each 64 bit integer)\n const byteLen = byteArray.length * 8;\n \n // create a fresh data view\n const view = this.makeDataView(byteLen);\n\n // set all 64 bit integers \n byteArray.forEach((bigInt, i) => {\n const offset = i * 8;\n view.setBigUint64(offset, bigInt, littleEndian);\n });\n\n return new Uint8Array(view.buffer);\n }\n\n\n static toBytes(input, settings) {\n\n let inputUint8;\n let negative = false;\n let type = \"bytes\";\n \n // Buffer:\n if (input instanceof ArrayBuffer) {\n inputUint8 = new Uint8Array(input.slice());\n }\n\n // TypedArray or DataView:\n else if (ArrayBuffer.isView(input)) {\n inputUint8 = new Uint8Array(input.buffer.slice());\n }\n \n // String:\n else if (typeof input === \"string\" || input instanceof String) {\n inputUint8 = new TextEncoder().encode(input);\n }\n \n // Number:\n else if (typeof input === \"number\") {\n if (isNaN(input)) {\n throw new TypeError(\"Cannot proceed. Input is NaN.\");\n } else if (input == Infinity) {\n throw new TypeError(\"Cannot proceed. Input is Infinity.\");\n }\n\n if (settings.signed && input < 0) {\n negative = true;\n input = -input;\n }\n\n if (settings.numberMode) {\n const view = this.floatingPoints(input, settings.littleEndian);\n inputUint8 = new Uint8Array(view.buffer);\n type = \"float\";\n } else {\n [inputUint8, type] = this.numbers(input, settings.littleEndian);\n }\n }\n\n // BigInt:\n else if (typeof input === \"bigint\") {\n if (settings.signed && input < 0) {\n negative = true;\n input *= -1n;\n }\n inputUint8 = this.bigInts(input, settings.littleEndian);\n type = \"int\";\n }\n\n // Array\n else if (Array.isArray(input)) {\n const collection = new Array();\n for (const elem of input) {\n collection.push(...this.toBytes(elem, settings)[0]);\n }\n inputUint8 = Uint8Array.from(collection);\n }\n\n else {\n throw new TypeError(\"The provided input type can not be processed.\");\n }\n\n return [inputUint8, negative, type];\n }\n}\n\n/** \n * Advanced Output Handler.\n * ----------------------- \n * This Output handler makes it possible to\n * convert an Uint8Array (bytes) into a desired\n * format of a big variety.\n * \n * The default output is an ArrayBuffer.\n */\nclass SmartOutput {\n\n static get typeList() {\n return [\n \"bigint64\",\n \"bigint_n\",\n \"biguint64\",\n \"buffer\",\n \"bytes\",\n \"float32\",\n \"float64\",\n \"float_n\",\n \"int8\",\n \"int16\",\n \"int32\",\n \"int_n\",\n \"str\",\n \"uint8\",\n \"uint16\",\n \"uint32\",\n \"uint_n\",\n \"view\"\n ];\n }\n\n static getType(type) {\n if (!this.typeList.includes(type)) {\n throw new TypeError(`Unknown output type: '${type}'`);\n }\n return type;\n }\n\n static makeTypedArrayBuffer(Uint8ArrayOut, bytesPerElem, littleEndian, negative) {\n \n const len = Uint8ArrayOut.byteLength;\n const delta = (bytesPerElem - (Uint8ArrayOut.byteLength % bytesPerElem)) % bytesPerElem;\n const newLen = len + delta;\n \n // if the array is negative and the len is gt 1\n // fill the whole array with 255\n const fillVal = (negative && len > 1) ? 255 : 0;\n\n let newArray = Uint8ArrayOut;\n\n if (delta) {\n newArray = new Uint8Array(newLen);\n newArray.fill(fillVal);\n \n const offset = (littleEndian) ? 0 : delta;\n newArray.set(Uint8ArrayOut, offset)\n }\n\n\n return newArray.buffer;\n }\n\n static makeTypedArray(inArray, type, littleEndian, negative) {\n let outArray;\n\n if (type === \"int16\" || type === \"uint16\") {\n\n const buffer = this.makeTypedArrayBuffer(inArray, 2, littleEndian, negative);\n outArray = (type === \"int16\") ? new Int16Array(buffer) : new Uint16Array(buffer);\n\n } else if (type === \"int32\" || type === \"uint32\" || type === \"float32\") {\n\n const buffer = this.makeTypedArrayBuffer(inArray, 4, littleEndian, negative);\n \n if (type === \"int32\") {\n outArray = new Int32Array(buffer);\n } else if (type === \"uint32\") {\n outArray = new Uint32Array(buffer);\n } else {\n outArray = new Float32Array(buffer);\n }\n\n } else if (type === \"bigint64\" || type === \"biguint64\" || type === \"float64\") {\n \n const buffer = this.makeTypedArrayBuffer(inArray, 8, littleEndian, negative);\n \n if (type === \"bigint64\") {\n outArray = new BigInt64Array(buffer);\n } else if (type === \"biguint64\") {\n outArray = new BigUint64Array(buffer);\n } else {\n outArray = new Float64Array(buffer);\n }\n }\n\n return outArray;\n }\n\n static compile(Uint8ArrayOut, type, littleEndian=false, negative=false) {\n type = this.getType(type);\n let compiled;\n\n // If the array is negative (which is only\n // true for signed encoding) get the positive\n // decimal number first and feed it with a \n // negative sign to SmartInput to construct\n // the unsigned output which is not shortened.\n\n if (negative) {\n let n;\n if (type.match(/^float/)) {\n n = -(this.compile(Uint8ArrayOut, \"float_n\", littleEndian));\n } else {\n n = -(this.compile(Uint8ArrayOut, \"uint_n\", littleEndian));\n }\n if (type === \"float_n\") {\n return n;\n }\n Uint8ArrayOut = SmartInput.toBytes(n, {littleEndian, numberMode: false, signed: false})[0];\n }\n\n if (type === \"buffer\") {\n compiled = Uint8ArrayOut.buffer;\n } \n \n else if (type === \"bytes\" || type === \"uint8\") {\n compiled = Uint8ArrayOut;\n }\n \n else if (type === \"int8\") {\n compiled = new Int8Array(Uint8ArrayOut.buffer);\n } \n \n else if (type === \"view\") {\n compiled = new DataView(Uint8ArrayOut.buffer);\n }\n \n else if (type === \"str\") {\n compiled = new TextDecoder().decode(Uint8ArrayOut);\n }\n \n else if (type === \"uint_n\" || type === \"int_n\" || type === \"bigint_n\") {\n\n // If the input consists of only one byte, expand it\n if (Uint8ArrayOut.length === 1) {\n const uint16Buffer = this.makeTypedArrayBuffer(Uint8ArrayOut, 2, littleEndian, negative);\n Uint8ArrayOut = new Uint8Array(uint16Buffer);\n }\n \n if (littleEndian) {\n Uint8ArrayOut.reverse();\n }\n\n // calculate a unsigned big integer\n let n = 0n;\n Uint8ArrayOut.forEach((b) => n = (n << 8n) + BigInt(b));\n\n // convert to signed int if requested \n if (type !== \"uint_n\") {\n n = BigInt.asIntN(Uint8ArrayOut.length*8, n);\n }\n \n // convert to regular number if possible (and no bigint was requested)\n if (type !== \"bigint_n\" && n >= Number.MIN_SAFE_INTEGER && n <= Number.MAX_SAFE_INTEGER) { \n compiled = Number(n);\n } else {\n compiled = n;\n }\n } \n \n else if (type === \"float_n\") {\n\n if (Uint8ArrayOut.length <= 4) {\n \n let array;\n if (Uint8ArrayOut.length === 4) {\n array = Uint8ArrayOut;\n } else {\n array = this.makeTypedArray(Uint8ArrayOut, \"float32\", false, negative);\n }\n\n const view = new DataView(array.buffer);\n compiled = view.getFloat32(0, littleEndian);\n \n }\n \n else if (Uint8ArrayOut.length <= 8) {\n \n let array;\n if (Uint8ArrayOut.length === 8) {\n array = Uint8ArrayOut;\n } else {\n array = this.makeTypedArray(Uint8ArrayOut, \"float64\", false, negative);\n }\n\n const view = new DataView(array.buffer);\n compiled = view.getFloat64(0, littleEndian);\n \n }\n\n else {\n throw new RangeError(\"The provided input is to complex to be converted into a floating point.\")\n }\n }\n\n else if (type === \"number\") {\n if (Uint8ArrayOut.length !== 8) {\n throw new TypeError(\"Type mismatch. Cannot convert into number.\");\n }\n\n const float64 = new Float64Array(Uint8ArrayOut.buffer);\n compiled = Number(float64);\n }\n\n else {\n compiled = this.makeTypedArray(Uint8ArrayOut, type, littleEndian, negative);\n } \n\n return compiled;\n }\n}\n\nexport { BytesInput, BytesOutput, SmartInput, SmartOutput };\n","import { BytesInput, BytesOutput, SmartInput, SmartOutput } from \"./io-handlers.js\";\n\nconst DEFAULT_INPUT_HANDLER = SmartInput;\nconst DEFAULT_OUTPUT_HANDLER = SmartOutput;\n\nclass SignError extends TypeError {\n constructor() {\n super(\"The input is signed but the converter is not set to treat input as signed.\\nYou can pass the string 'signed' to the decode function or when constructing the converter.\");\n this.name = \"SignError\";\n }\n}\n\nclass DecodingError extends TypeError {\n constructor(char, msg=null) {\n if (msg === null) {\n msg = `Character '${char}' is not part of the charset.`;\n }\n super(msg);\n this.name = \"DecodingError\";\n }\n}\n\n\n/**\n * Utilities for every BaseEx class.\n * --------------------------------\n * Requires IO Handlers\n */\nclass Utils {\n\n constructor(main) {\n\n // Store the calling class in this.root\n // for accessability.\n this.root = main;\n \n // set specific args object for converters\n this.converterArgs = {};\n\n // If charsets are uses by the parent class,\n // add extra functions for the user.\n\n this.#charsetUserToolsConstructor();\n }\n\n setIOHandlers(inputHandler=DEFAULT_INPUT_HANDLER, outputHandler=DEFAULT_OUTPUT_HANDLER) {\n this.inputHandler = inputHandler;\n this.outputHandler = outputHandler;\n }\n\n\n /**\n * Constructor for the ability to add a charset and \n * change the default version.\n */\n #charsetUserToolsConstructor() {\n\n /**\n * Save method to add a charset.\n * @param {string} name - \"Charset name.\"\n * @param {[string|set|array]} - \"Charset\"\n */\n this.root.addCharset = (name, _charset, _padChars=[], info=true) => {\n\n const normalize = (typeName, set, setLen) => {\n\n if (setLen === 0 && set.length) {\n console.warn(`This converter has no ${typeName}. The following argument was ignored:\\n'${set}'`);\n return [];\n }\n\n let inputLen = setLen;\n\n if (typeof set === \"string\") {\n set = [...set];\n }\n \n if (Array.isArray(set)) {\n \n // Store the input length of the input\n inputLen = set.length;\n \n // Convert to \"Set\" -> eliminate duplicates\n // If duplicates are found the length of the\n // Set and the length of the initial input\n // differ.\n\n set = new Set(set);\n\n } else if (!(set instanceof Set)) {\n throw new TypeError(`The ${typeName} must be one of the types:\\n'str', 'set', 'array'.\"`);\n }\n \n if (set.size === setLen) {\n return [...set];\n }\n \n if (inputLen !== setLen) {\n throw new Error(`Your ${typeName} has a length of ${inputLen}. The converter requires a length of ${setLen}.`);\n } else {\n const charAmounts = {};\n _charset = [..._charset];\n _charset.forEach(c => {\n if (c in charAmounts) {\n charAmounts[c]++;\n } else {\n charAmounts[c] = 1;\n }\n })\n \n let infoStr = \"\";\n if (setLen < 100) {\n infoStr = `${_charset.join(\"\")}\\n`;\n _charset.forEach(c => {\n if (charAmounts[c] > 1) {\n infoStr += \"^\";\n } else {\n infoStr += \" \";\n }\n });\n }\n const rChars = Object.keys(charAmounts).filter(c => charAmounts[c] > 1);\n throw new Error(`You have repetitive char(s) [ ${rChars.join(\" | \")} ] in your ${typeName}. Make sure each character is unique.\\n${infoStr}`);\n }\n }\n\n if (this.root.frozenCharsets) {\n throw new Error(\"The charsets of this converter cannot be changed.\");\n }\n\n if (typeof name !== \"string\") {\n throw new TypeError(\"The charset name must be a string.\");\n }\n\n if (info && name in this.root.charsets) {\n console.warn(`An existing charset with name ${name} will get replaced.`);\n }\n\n const charset = normalize(\"charset\", _charset, this.root.converter.radix);\n const padChars = normalize(\"padding set\", _padChars, this.root.padCharAmount);\n\n this.root.charsets[name] = charset;\n if (padChars.length) {\n this.root.padChars[name] = padChars\n }\n\n if (info) {\n console.info(`New charset '${name}' was added and is ready to use`);\n }\n }\n\n // Save method (argument gets validated) to \n // change the default version.\n this.root.setDefaultCharset = (version) => {\n if (!(version in this.root.charsets)) {\n const sets = Object.keys(this.root.charsets).join(\"\\n * \");\n const msg = `Charset ${version} was not found. Available charsets are:\\n * ${sets}`;\n throw new TypeError(msg);\n }\n this.root.version = version;\n }\n }\n\n /**\n * Argument lists for error messages.\n * @param {string[]} args \n * @returns string - Arguments joined as a string. \n */\n #makeArgList(args) {\n return args.map(s => `'${s}'`).join(\", \");\n }\n\n /**\n * Removes all padded zeros a the start of the string,\n * adds a \"-\" if value is negative.\n * @param {string} output - Former output.\n * @param {boolean} negative - Indicates a negative value if true.\n * @returns {string} - Output without zero padding and a sign if negative.\n */\n toSignedStr(output, negative) {\n\n output = output.replace(/^0+(?!$)/, \"\");\n\n if (negative) {\n output = \"-\".concat(output);\n }\n\n return output;\n }\n\n /**\n * Analyzes the input for a negative sign.\n * If a sign is found, it gets removed but\n * negative bool gets true;\n * @param {string} input - Input number as a string. \n * @returns {array} - Number without sign and negativity indication bool.\n */\n extractSign(input) {\n let negative = false;\n if (input[0] === \"-\") {\n negative = true;\n input = input.slice(1);\n }\n\n return [input, negative];\n }\n\n /**\n * All possible error messages for invalid arguments,\n * gets adjusted according to the converter settings.\n * @param {string} arg - Argument. \n * @param {string[]} versions - Charset array. \n * @param {string[]} outputTypes - Array of output types. \n * @param {boolean} initial - Indicates if the arguments where passed during construction. \n */\n #invalidArgument(arg, versions, outputTypes, initial) {\n const loopConverterArgs = () => Object.keys(this.converterArgs).map(\n key => this.converterArgs[key].map(\n keyword => `'${keyword}'`\n )\n .join(\" and \")\n )\n .join(\"\\n - \");\n \n throw new TypeError([\n `'${arg}'\\n\\nParameters:`,\n initial ? \"\\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'\" : \"\",\n this.root.isMutable.signed ? \"\\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers\" : \"\",\n this.root.isMutable.littleEndian ? \"\\n * 'be' for big , 'le' for little endian byte order for case conversion\" : \"\",\n this.root.isMutable.padding ? \"\\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding\" : \"\",\n this.root.isMutable.upper ? \"\\n * valid args for changing the encoded output case are 'upper' and 'lower'\" : \"\",\n `\\n * valid args for the output type are ${this.#makeArgList(outputTypes)}`,\n versions ? `\\n * the option(s) for version/charset are: ${this.#makeArgList(versions)}` : \"\",\n \"\\n * valid args for integrity check are: 'integrity' and 'nointegrity'\",\n this.root.hasDecimalMode ? \"\\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)\" : \"\",\n \"\\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)\",\n Object.keys(this.converterArgs).length ? `\\n * converter specific args:\\n - ${loopConverterArgs()}` : \"\",\n \"\\n\\nTraceback:\"\n ].join(\"\"));\n }\n\n\n /**\n * Test if provided arguments are in the argument list.\n * Everything gets converted to lowercase and returned.\n * @param {string[]} args - Passed arguments. \n * @param {boolean} initial - Indicates if the arguments where passed during construction. \n * @returns {Object} - Converter settings object.\n */\n validateArgs(args, initial=false) {\n \n // default settings\n const parameters = {\n decimalMode: this.root.decimalMode,\n integrity: this.root.integrity,\n littleEndian: this.root.littleEndian,\n numberMode: this.root.numberMode,\n options: this.root.options,\n outputType: this.root.outputType,\n padding: this.root.padding,\n signed: this.root.signed,\n upper: this.root.upper,\n version: this.root.version\n }\n\n // add any existing converter specific args\n for (const param in this.converterArgs) {\n parameters[param] = this.root[param];\n }\n\n // if no args are provided return the default settings immediately\n if (!args.length) {\n\n // if initial call set default IO handlers\n if (initial) {\n this.setIOHandlers();\n }\n \n return parameters;\n }\n\n // Helper function to test the presence of a \n // particular arg. If found, true is returned\n // and it gets removed from the array.\n const extractArg = (arg) => {\n if (args.includes(arg)) {\n args.splice(args.indexOf(arg), 1);\n return true;\n }\n return false;\n }\n\n // set available versions and extra arguments\n const versions = Object.keys(this.root.charsets);\n const extraArgList = {\n integrity: [\"nointegrity\", \"integrity\"],\n littleEndian: [\"be\", \"le\"],\n padding: [\"nopad\", \"pad\"],\n signed: [\"unsigned\", \"signed\"],\n upper: [\"lower\", \"upper\"],\n ...this.converterArgs\n }\n\n // if initial, look for IO specifications\n if (initial) {\n if (extractArg(\"bytes_only\")) {\n this.setIOHandlers(BytesInput, BytesOutput);\n } else {\n const inHandler = (extractArg(\"bytes_in\")) ? BytesInput : DEFAULT_INPUT_HANDLER;\n const outHandler = (extractArg(\"bytes_out\")) ? BytesOutput : DEFAULT_OUTPUT_HANDLER;\n this.setIOHandlers(inHandler, outHandler);\n }\n }\n\n // set valid output types\n const outputTypes = this.outputHandler.typeList;\n\n // test for special \"number\" keyword\n if (extractArg(\"number\")) {\n parameters.numberMode = true;\n parameters.outputType = \"float_n\";\n } \n \n // test for the special \"decimal\" keyword\n if (extractArg(\"decimal\")) {\n if (!this.root.hasDecimalMode) {\n throw TypeError(`Argument 'decimal' is only allowed for converters with a non-integer base.`);\n }\n parameters.decimalMode = true;\n parameters.outputType = \"decimal\";\n\n if (parameters.numberMode) {\n parameters.numberMode = false;\n console.warn(\"-> number-mode was disabled due to the decimal-mode\");\n }\n }\n\n // walk through the remaining arguments\n args.forEach((arg) => {\n \n // additional/optional non boolean options\n if (typeof arg === \"object\") {\n parameters.options = {...parameters.options, ...arg};\n return;\n }\n\n arg = String(arg).toLowerCase();\n\n if (versions.includes(arg)) {\n parameters.version = arg;\n } else if (outputTypes.includes(arg)) {\n parameters.outputType = arg;\n } else {\n // set invalid args to true for starters\n // if a valid arg is found later it will\n // get changed\n\n let invalidArg = true;\n\n // walk through the mutable parameter list\n\n for (const param in extraArgList) {\n \n if (extraArgList[param].includes(arg)) {\n \n invalidArg = false;\n\n // extra params always have two options\n // they are converted into booleans \n // index 0 > false\n // index 1 > true\n\n if (this.root.isMutable[param]) {\n parameters[param] = Boolean(extraArgList[param].indexOf(arg));\n } else {\n throw TypeError(`Argument '${arg}' is not allowed for this type of converter.`);\n }\n }\n }\n\n if (invalidArg) {\n this.#invalidArgument(arg, versions, outputTypes, initial);\n }\n }\n });\n\n // If padding and signed are true, padding\n // is set to false and a warning is getting\n // displayed.\n if (parameters.padding && parameters.signed) {\n parameters.padding = false;\n console.warn(\"-> padding was set to false due to the signed conversion\");\n }\n \n // overwrite the default parameters for the initial call\n if (initial) {\n for (const param in parameters) {\n this.root[param] = parameters[param];\n }\n }\n\n return parameters;\n }\n\n /**\n * A TypeError specifically for sign errors.\n */\n signError() {\n throw new SignError();\n }\n\n /**\n * Wrap output to \"cols\" characters per line.\n * @param {string} output - Output string. \n * @param {number} cols - Number of cols per line. \n * @returns {string} - Wrapped output.\n */\n wrapOutput(output, cols=0) {\n if (!cols) {\n return output;\n }\n const m = new RegExp(`.{1,${cols}}`, \"gu\");\n return output.match(m).join(\"\\n\");\n }\n\n /**\n * Ensures a string input.\n * @param {*} input - Input.\n * @param {boolean} [keepWS=false] - If set to false, whitespace is getting removed from the input if present.\n * @returns {string} - Normalized input.\n */\n normalizeInput(input, keepWS=false) {\n if (keepWS) {\n return String(input);\n }\n return String(input).replace(/\\s/g, \"\");\n }\n\n}\n\nexport {\n DEFAULT_INPUT_HANDLER,\n DEFAULT_OUTPUT_HANDLER,\n DecodingError,\n Utils\n};\n","import { DecodingError, Utils } from \"./utils.js\";\n\n\n/**\n * BaseEx Base Converter.\n * ---------------------\n * Core class for base-conversion and substitution\n * based on a given charset.\n */\nclass BaseConverter {\n\n /**\n * BaseEx BaseConverter Constructor.\n * @param {number} radix - Radix for the converter.\n * @param {number} [bsEnc] - Block Size (input bytes grouped by bs) for encoding (if zero the integer has no limitation).\n * @param {number} [bsDec] - Block Size (input bytes grouped by bs) for decoding (if zero the integer has no limitation).\n * @param {number} [decPadVal=0] - Value used for padding during decoding.\n */\n constructor(radix, bsEnc=null, bsDec=null, decPadVal=0) {\n \n this.radix = radix;\n\n if (bsEnc !== null && bsDec !== null) {\n this.bsEnc = bsEnc;\n this.bsDec = bsDec;\n } else {\n [this.bsEnc, this.bsDec] = this.constructor.guessBS(radix);\n }\n\n this.decPadVal = decPadVal;\n this.powers = {};\n }\n\n /**\n * Experimental feature!\n * Calc how many bits are needed to represent\n * 256 conditions (1 byte). If the radix is \n * less than 8 bits, skip that part and use\n * the radix value directly.\n */\n static guessBS(radix) {\n\n let bsDecPre = (radix < 8) ? radix : Math.ceil(256 / radix);\n \n // If the result is a multiple of 8 it\n // is appropriate to reduce the result\n\n while (bsDecPre > 8 && !(bsDecPre % 8)) {\n bsDecPre /= 8;\n }\n\n // Search for the amount of bytes, which are necessary\n // to represent the assumed amount of bytes. If the result\n // is equal or bigger than the assumption for decoding, the\n // amount of bytes for encoding is found. \n\n let bsEnc = 0;\n while (((bsEnc * 8) * Math.log(2) / Math.log(radix)) < bsDecPre) {\n bsEnc++;\n }\n\n // The result for decoding can now get calculated accurately.\n const bsDec = Math.ceil((bsEnc * 8) * Math.log(2) / Math.log(radix));\n\n return [bsEnc, bsDec];\n }\n\n\n /**\n * BaseEx Universal Base Encoding.\n * @param {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} inputBytes - Input as Uint8Array.\n * @param {string} charset - The charset used for conversion.\n * @param {boolean} littleEndian - Byte order, little endian bool.\n * @param {function} replacer - Replacer function can replace groups of characters during encoding.\n * @returns {number[]} - Output string and padding amount. \n */\n encode(inputBytes, charset, littleEndian=false, replacer=null) {\n\n // Initialize output string and set yet unknown\n // zero padding to zero.\n let bs = this.bsEnc;\n if (bs === 0) {\n bs = inputBytes.byteLength;\n }\n\n let output = \"\";\n\n const zeroPadding = (bs) ? (bs - inputBytes.length % bs) % bs : 0;\n const zeroArray = new Array(zeroPadding).fill(0);\n let byteArray;\n \n if (littleEndian) {\n \n // as the following loop walks through the array\n // from left to right, the input bytes get reversed\n // to favor the least significant first\n\n inputBytes.reverse();\n byteArray = [...zeroArray, ...inputBytes];\n } else {\n byteArray = [...inputBytes, ...zeroArray];\n }\n \n // Iterate over the input array in groups with the length\n // of the given blocksize.\n\n // If the radix is 10, make a shortcut here by converting\n // all bytes into the decimal number \"n\" and return the\n // result as a string.\n if (this.radix === 10) {\n let n = 0n;\n \n for (let i=0; i= this.radix) {\n [q, r] = this.divmod(q, this.radix);\n bXarray.unshift(parseInt(r, 10));\n }\n\n // Append the remaining quotient to the array\n bXarray.unshift(parseInt(q, 10));\n\n // If the length of the array is less than the\n // given output bs, it gets filled up with zeros.\n // (This happens in groups of null bytes)\n \n while (bXarray.length < this.bsDec) {\n bXarray.unshift(0);\n }\n\n // Each digit is used as an index to pick a \n // corresponding char from the charset. The \n // chars get concatenated and stored in \"frame\".\n\n let frame = \"\";\n bXarray.forEach(\n charIndex => frame = frame.concat(charset[charIndex])\n );\n\n // Ascii85 is replacing four consecutive \"!\" into \"z\"\n // Also other replacements can be implemented and used\n // at this point.\n if (replacer) {\n frame = replacer(frame, zeroPadding);\n }\n\n output = output.concat(frame);\n }\n\n // The output string is returned. Also the amount \n // of padded zeros. The specific class decides how \n // to handle the padding.\n\n return [output, zeroPadding];\n }\n\n\n /**\n * BaseEx Universal Base Decoding.\n * Decodes to a string of the given radix to a byte array.\n * @param {string} inputBaseStr - Base as string (will also get converted to string but can only be used if valid after that).\n * @param {string[]} charset - The charset used for conversion.\n * @param {string[]} padSet - Padding characters for integrity check.\n * @param {boolean} integrity - If set to false invalid character will be ignored.\n * @param {boolean} littleEndian - Byte order, little endian bool.\n * @returns {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} - The decoded output as Uint8Array.\n */\n decode(inputBaseStr, charset, padSet=[], integrity=true, littleEndian=false) {\n\n // Convert each char of the input to the radix-integer\n // (this becomes the corresponding index of the char\n // from the charset). Every char, that is not found in\n // in the set is getting ignored.\n\n if (!inputBaseStr) {\n return new Uint8Array(0);\n }\n\n let bs = this.bsDec;\n const byteArray = [];\n\n const toObj = arr => {\n const obj = {};\n arr.forEach((v, i) => obj[v] = i);\n return obj;\n }\n const charsetLookup = toObj(charset);\n\n [...inputBaseStr].forEach(c => {\n const index = charsetLookup[c];\n if (typeof index !== \"undefined\") { \n byteArray.push(index);\n } else if (integrity && padSet.indexOf(c) === -1) {\n throw new DecodingError(c);\n }\n });\n\n let padChars;\n\n if (bs === 0) {\n bs = byteArray.length;\n } else {\n padChars = (bs - byteArray.length % bs) % bs;\n const fillArray = new Array(padChars).fill(this.decPadVal);\n if (littleEndian) {\n byteArray.unshift(...fillArray);\n } else {\n byteArray.push(...fillArray);\n }\n }\n\n // Initialize a new default array to store\n // the converted radix-256 integers.\n\n let b256Array = new Array();\n\n // Iterate over the input bytes in groups of \n // the blocksize.\n\n for (let i=0, l=byteArray.length; i {\n this.powers[exp] = BigInt(this.pow(exp));\n return this.powers[exp];\n })();\n\n n += BigInt(byteArray[i+j]) * pow;\n }\n \n // To store the output chunks, initialize a\n // new default array.\n const subArray256 = [];\n\n // The subarray gets converted into a bs*8-bit \n // binary number \"n\", most significant byte \n // first (big endian).\n\n // Initialize quotient and remainder for base conversion\n let q = n, r;\n\n // Divide n until the quotient is less than 256.\n while (q >= 256) {\n [q, r] = this.divmod(q, 256);\n subArray256.unshift(parseInt(r, 10));\n }\n\n // Append the remaining quotient to the array\n subArray256.unshift(parseInt(q, 10));\n \n // If the length of the array is less than the required\n // bs after decoding it gets filled up with zeros.\n // (Again, this happens with null bytes.)\n\n while (subArray256.length < this.bsEnc) {\n subArray256.unshift(0);\n }\n \n // The subarray gets concatenated with the\n // main array.\n b256Array.push(...subArray256);\n }\n\n // Remove padded zeros (or in case of LE all leading zeros)\n\n if (littleEndian) {\n if (b256Array.length > 1) {\n \n // remove all zeros from the start of the array\n while (!b256Array[0]) {\n b256Array.shift(); \n }\n \n if (!b256Array.length) {\n b256Array.push(0);\n }\n\n b256Array.reverse();\n }\n } else if (this.bsDec) {\n const padding = this.padChars(padChars);\n\n // remove all bytes according to the padding\n b256Array.splice(b256Array.length-padding);\n }\n\n return Uint8Array.from(b256Array);\n }\n\n\n /**\n * Calculates the amount of bytes, which are padding bytes. \n * @param {number} charCount - Pass the amount of characters, which were added during encoding. \n * @returns {number} - Amount of padding characters.\n */\n padBytes(charCount) {\n return Math.floor((charCount * this.bsDec) / this.bsEnc);\n }\n\n /**\n * Calculates the amount of bytes which can get removed\n * from the decoded output bytes. \n * @param {number} byteCount - Added bytes for padding \n * @returns {number} - Amount of output bytes to be removed.\n */\n padChars(byteCount) {\n return Math.ceil((byteCount * this.bsEnc) / this.bsDec);\n }\n\n\n /**\n * Calculates the power for the current base\n * according to the given position as BigInt.\n * \n * @param {number} n - Position \n * @returns {BigInt} - BigInt power value\n */\n pow(n) {\n return BigInt(this.radix)**BigInt(n);\n }\n\n\n /**\n * Divmod function, which returns the results as\n * an array of two BigInts.\n * @param {*} x - Dividend\n * @param {*} y - Divisor\n * @returns {number[]} - [Quotient, Remainder]\n */\n divmod(x, y) {\n [x, y] = [BigInt(x), BigInt(y)];\n return [(x / y), (x % y)];\n }\n}\n\n\n/**\n * Base of every BaseConverter. Provides basic\n * en- and decoding, makes sure, that every \n * property is set (to false by default).\n * Also allows global feature additions.\n * \n * Requires BaseEx Utils\n */\nclass BaseTemplate {\n\n /**\n * BaseEx BaseTemplate Constructor.\n * @param {boolean} appendUtils - If set to false, the utils are not getting used. \n */\n constructor(appendUtils=true) {\n\n // predefined settings\n this.charsets = {};\n this.decimalMode = false;\n this.frozenCharsets = false;\n this.hasDecimalMode = false;\n this.hasSignedMode = false;\n this.integrity = true;\n this.littleEndian = false;\n this.numberMode = false;\n this.outputType = \"buffer\";\n this.padding = false;\n this.padCharAmount = 0;\n this.padChars = {} \n this.signed = false;\n this.upper = null;\n if (appendUtils) this.utils = new Utils(this);\n this.version = \"default\";\n this.options = {\n lineWrap: 0\n }\n \n // list of allowed/disallowed args to change\n this.isMutable = {\n integrity: true,\n littleEndian: false,\n padding: false,\n signed: false,\n upper: false,\n };\n }\n\n /**\n * BaseEx Generic Encoder.\n * @param {*} input - Any input the used byte converter allows.\n * @param {function} [replacerFN] - Replacer function, which is passed to the encoder. \n * @param {function} [postEncodeFN] - Function, which is executed after encoding.\n * @param {...any} args - Converter settings.\n * @returns {string} - Base encoded string.\n */\n encode(input, replacerFN, postEncodeFN, ...args) {\n\n // apply settings\n const settings = this.utils.validateArgs(args);\n \n // handle input\n let [inputBytes, negative, type] = this.utils.inputHandler.toBytes(input, settings);\n\n // generate replacer function if given\n let replacer = null;\n if (replacerFN) {\n replacer = replacerFN(settings);\n }\n \n // Convert to base string\n let [output, zeroPadding] = this.converter.encode(inputBytes, this.charsets[settings.version], settings.littleEndian, replacer);\n\n // set sign if requested\n if (settings.signed) {\n output = this.utils.toSignedStr(output, negative);\n }\n\n // set upper case if requested\n if (settings.upper) {\n output = output.toUpperCase();\n }\n\n // modify the output based on a given function (optionally)\n if (postEncodeFN) {\n output = postEncodeFN({ inputBytes, output, settings, zeroPadding, type });\n }\n\n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n\n /**\n * BaseEx Generic Decoder.\n * @param {string} input - Base String.\n * @param {function} [preDecodeFN] - Function, which gets executed before decoding. \n * @param {function} [postDecodeFN] - Function, which gets executed after decoding\n * @param {...any} args - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, preDecodeFN, postDecodeFN, keepNL, ...args) {\n \n // apply settings\n const settings = this.utils.validateArgs(args);\n\n // ensure a string input\n input = this.utils.normalizeInput(input, keepNL);\n\n // set negative to false for starters\n let negative = false;\n \n // Test for a negative sign if converter supports it\n if (this.hasSignedMode) {\n [ input, negative ] = this.utils.extractSign(input); \n \n // But don't allow a sign if the decoder is not configured to use it\n if (negative && !settings.signed) {\n this.utils.signError();\n }\n }\n\n // Make the input lower case if alphabet has only one case\n // (single case alphabets are stored as lower case strings)\n if (this.isMutable.upper) {\n input = input.toLowerCase();\n }\n\n // Run pre decode function if provided\n if (preDecodeFN) {\n input = preDecodeFN({ input, settings });\n }\n\n // Run the decoder\n let output = this.converter.decode(\n input,\n this.charsets[settings.version],\n this.padChars[settings.version],\n settings.integrity,\n settings.littleEndian\n );\n\n // Run post decode function if provided\n if (postDecodeFN) {\n output = postDecodeFN({ input, output, settings });\n }\n\n return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative);\n }\n}\n\n\nexport { BaseConverter, BaseTemplate };\n","/**\n * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 1 Converter.\n * -----------------------\n * This is a unary/base1 converter. It is converting input \n * to a decimal number, which is converted into an unary\n * string. Due to the limitations on string (or array) length\n * it is only suitable for the conversions of numbers up to\n * roughly 2^28.\n */\nexport default class Base1 extends BaseTemplate {\n \n /**\n * BaseEx Base1 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // All chars in the string are used and picked randomly (prob. suitable for obfuscation)\n this.charsets.all = [...\" !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\"];\n \n // The sequence is used from left to right again and again\n this.charsets.sequence = [...\"Hello World!\"];\n \n // Standard unary string with one character\n this.charsets.default = [\"1\"];\n\n // Telly Mark string, using hash for 5 and vertical bar for 1 \n this.charsets.tmark = [\"|\", \"#\"];\n\n // Base 10 converter\n this.converter = new BaseConverter(10, 0, 0);\n \n // converter settings\n this.hasSignedMode = true;\n this.littleEndian = true;\n this.signed = true;\n \n // mutable extra args\n this.isMutable.charsets = false;\n this.isMutable.signed = true;\n this.isMutable.upper = true;\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx Base1 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base1 encoded string.\n */\n encode(input, ...args) {\n\n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n \n let inputBytes, negative;\n [inputBytes, negative,] = this.utils.inputHandler.toBytes(input, settings);\n\n // Convert to BaseRadix string\n let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0];\n \n let n = BigInt(base10);\n\n // Limit the input before it even starts.\n // The executing engine will most likely\n // give up much earlier.\n // (2**29-24 during tests)\n\n if (n > Number.MAX_SAFE_INTEGER) {\n throw new RangeError(\"Invalid string length.\");\n } else if (n > 16777216) {\n console.warn(\"The string length is really long. The JavaScript engine may have memory issues generating the output string.\");\n }\n \n n = Number(n);\n \n const charset = this.charsets[settings.version];\n const charAmount = charset.length;\n let output = \"\";\n\n // Convert to unary in respect to the version differences\n if (charAmount === 1) {\n output = charset.at(0).repeat(n)\n } else if (settings.version === \"all\") {\n for (let i=0; i 4) {\n output = charset.at(1).repeat((n - singulars) / 5);\n }\n output += charset.at(0).repeat(singulars);\n } else {\n for (let i=0; i {\n \n // Remove \"0x\" if present\n normInput = normInput.replace(/^0x/, \"\");\n\n // remove non-charset characters if integrity\n // check is disabled\n if (!settings.integrity) {\n normInput = normInput\n .toLowerCase()\n .replace(/[^0-9a-f]/g, \"\");\n }\n\n // Ensure even number of characters\n if (normInput.length % 2) {\n normInput = \"0\".concat(normInput);\n }\n\n return normInput;\n }\n \n return super.decode(input, normalizeInput, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 32 Converter.\n * ------------------------\n * \n * This is a base32 converter. Various input can be \n * converted to a base32 string or a base32 string\n * can be decoded into various formats. It is possible\n * to convert in both signed and unsigned mode in little\n * and big endian byte order.\n * \n * Available charsets are:\n * - RFC 3548\n * - RFC 4648\n * - crockford\n * - zbase32\n */\nexport default class Base32 extends BaseTemplate {\n \n /**\n * BaseEx Base32 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(32, 5, 8);\n\n // charsets\n this.charsets.crockford = [ ...\"0123456789abcdefghjkmnpqrstvwxyz\" ];\n this.padChars.crockford = [\"=\"],\n\n this.charsets.rfc3548 = [...\"abcdefghijklmnopqrstuvwxyz234567\"];\n this.padChars.rfc3548 = [\"=\"];\n\n this.charsets.rfc4648 = [...\"0123456789abcdefghijklmnopqrstuv\"];\n this.padChars.rfc4648 = [\"=\"];\n\n this.charsets.zbase32 = [...\"ybndrfg8ejkmcpqxot1uwisza345h769\"];\n this.padChars.zbase32 = [\"=\"];\n \n // predefined settings\n this.padCharAmount = 1;\n this.hasSignedMode = true;\n this.version = \"rfc4648\";\n \n // mutable extra args\n this.isMutable.littleEndian = true;\n this.isMutable.padding = true;\n this.isMutable.signed = true;\n this.isMutable.upper = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n this.padding = (/rfc3548|rfc4648/).test(this.version);\n this.upper = this.version === \"crockford\";\n }\n \n\n /**\n * BaseEx Base32 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base32 encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n if (!settings.littleEndian) {\n // Cut of redundant chars and append padding if set\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n const padChar = this.padChars[settings.version].at(0);\n output = output.slice(0, -padValue);\n if (settings.padding) { \n output = output.concat(padChar.repeat(padValue));\n }\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base32 Decoder.\n * @param {string} input - Base32 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n return super.decode(input, null, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 58 Converter.\n * ------------------------\n * \n * This is a base58 converter. Various input can be \n * converted to a base58 string or a base58 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - bitcoin\n * - flickr\n */\nexport default class Base58 extends BaseTemplate{\n\n /**\n * BaseEx Base58 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(58, 0, 0);\n\n // charsets\n this.charsets.default = [...\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"];\n Object.defineProperty(this.padChars, \"default\", {\n get: () => [ this.charsets.default.at(0) ]\n });\n\n this.charsets.bitcoin = [...\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\"];\n Object.defineProperty(this.padChars, \"bitcoin\", {\n get: () => [ this.charsets.bitcoin.at(0) ]\n });\n \n this.charsets.flickr = [...\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"];\n Object.defineProperty(this.padChars, \"flickr\", {\n get: () => [ this.charsets.flickr.at(0) ]\n });\n \n\n // predefined settings\n this.padding = true;\n this.version = \"bitcoin\";\n \n // mutable extra args\n this.isMutable.padding = true;\n this.isMutable.signed = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n \n /**\n * BaseEx Base58 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base58 encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ inputBytes, output, settings, type }) => {\n\n if (settings.padding && type !== \"int\") { \n \n // Count all null bytes at the start of the array\n // stop if a byte with a value is reached. If it goes\n // all the way through it, reset index and stop.\n let i = 0;\n const end = inputBytes.length;\n\n // pad char is always! the first char in the set\n const padChar = this.charsets[settings.version].at(0);\n\n // only proceed if input has a length at all\n if (end) {\n while (!inputBytes[i]) {\n i++;\n if (i === end) {\n i = 0;\n break;\n }\n }\n\n // The value for zero padding is the index of the\n // first byte with a value plus one.\n const zeroPadding = i;\n\n // Set a one for every leading null byte\n if (zeroPadding) {\n output = (padChar.repeat(zeroPadding)).concat(output);\n }\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base58 Decoder.\n * @param {string} input - Base58 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // post decoding function\n const applyPadding = ({ input, output, settings }) => {\n\n // pad char is always! the first char in the set\n const padChar = this.charsets[settings.version].at(0);\n\n if (settings.padding && input.length > 1) {\n \n // Count leading padding (char should be 1)\n let i = 0;\n while (input[i] === padChar) {\n i++;\n }\n \n // The counter becomes the zero padding value\n const zeroPadding = i;\n \n // Create a new Uint8Array with leading null bytes \n // with the amount of zeroPadding\n if (zeroPadding) {\n output = Uint8Array.from([...new Array(zeroPadding).fill(0), ...output]);\n }\n \n }\n\n return output;\n }\n\n return super.decode(input, null, applyPadding, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 64 Converter.\n * ------------------------\n * \n * This is a base64 converter. Various input can be \n * converted to a base64 string or a base64 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - urlsafe\n */\nexport default class Base64 extends BaseTemplate {\n\n /**this.padChars.\n * BaseEx Base64 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(64, 3, 4);\n\n // charsets\n this.charsets.default = [...\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"];\n this.padChars.default = [\"=\"];\n \n this.charsets.urlsafe = this.charsets.default.slice(0, -2).concat([\"-\", \"_\"]);\n this.padChars.urlsafe = [\"=\"];\n\n\n // predefined settings\n this.padCharAmount = 1;\n this.padding = true;\n \n // mutable extra args\n this.isMutable.padding = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Base64 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base64 encoded string.\n */\n encode(input, ...args) {\n \n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n // Cut of redundant chars and append padding if set\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n const padChar = this.padChars[settings.version].at(0);\n output = output.slice(0, -padValue);\n if (settings.padding) { \n output = output.concat(padChar.repeat(padValue));\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base64 Decoder.\n * @param {string} input - Base64 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n return super.decode(input, null, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx UUencode Converter.\n * ------------------------\n * \n * This is a UUencoder/UUdecoder. Various input can be \n * converted to a UUencoded string or a UUencoded string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - original\n * - xx\n */\nexport default class UUencode extends BaseTemplate {\n\n /**\n * BaseEx UUencode Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(64, 3, 4);\n\n // charsets\n this.charsets.default = [...\"`!\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_\"];\n Object.defineProperty(this.padChars, \"default\", {\n get: () => [ this.charsets.default.at(0) ]\n });\n\n this.charsets.original = [\" \", ...this.charsets.default.slice(1)];\n Object.defineProperty(this.padChars, \"original\", {\n get: () => [ this.charsets.original.at(0) ]\n });\n\n this.charsets.xx = [...\"+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"];\n Object.defineProperty(this.padChars, \"xx\", {\n get: () => [ this.charsets.xx.at(0) ]\n });\n\n\n // predefined settings\n this.padding = true;\n this.header = false;\n this.utils.converterArgs.header = [\"noheader\", \"header\"];\n this.isMutable.header = true;\n this.isMutable.integrity = false;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx UUencoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - UUencode string.\n */\n encode(input, ...args) {\n\n const format = ({ output, settings, zeroPadding }) => {\n\n const charset = this.charsets[settings.version];\n const outArray = [...output];\n \n \n if (settings.header) {\n const permissions = settings.options.permissions || een();\n const fileName = settings.options.file || ees();\n output = `begin ${permissions} ${fileName}\\n`;\n } else {\n output = \"\";\n }\n\n // repeatedly take 60 chars from the output until it is empty \n for (;;) {\n const lArray = outArray.splice(0, 60);\n \n // if all chars are taken, remove eventually added pad zeros\n if (!outArray.length) { \n const byteCount = this.converter.padChars(lArray.length) - zeroPadding;\n \n // add the the current chars plus the leading\n // count char\n output += `${charset.at(byteCount)}${lArray.join(\"\")}\\n`;\n break;\n }\n \n // add the the current chars plus the leading\n // count char (\"M\" for default charsets) \n output += `${charset.at(45)}${lArray.join(\"\")}\\n`;\n }\n\n output += `${charset.at(0)}\\n`;\n\n if (settings.header) {\n output += \"\\nend\";\n }\n\n\n return output;\n }\n \n return super.encode(input, null, format, ...args);\n }\n\n\n /**\n * BaseEx UUdecoder.\n * @param {string} input - UUencode String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n let padChars = 0;\n\n const format = ({ input, settings }) => {\n\n const charset = this.charsets[settings.version];\n const lines = input.trim().split(/\\r?\\n/);\n const inArray = [];\n \n if ((/^begin/i).test(lines.at(0))) {\n lines.shift();\n }\n \n for (const line of lines) {\n const lArray = [...line];\n const byteCount = charset.indexOf(lArray.shift());\n \n if (!(byteCount > 0)) {\n break;\n }\n\n inArray.push(...lArray);\n\n if (byteCount !== 45) { \n padChars = this.converter.padChars(lArray.length) - byteCount;\n break;\n }\n\n // fix probably missing spaces for original charset\n else if (lArray.length !== 60 && settings.version === \"original\") {\n while (inArray.length % 60) {\n inArray.push(\" \");\n }\n }\n }\n\n return inArray.join(\"\");\n\n }\n\n const removePadChars = ({ output }) => {\n if (padChars) {\n output = new Uint8Array(output.slice(0, -padChars));\n }\n return output;\n }\n\n return super.decode(input, format, removePadChars, true, ...args);\n }\n}\n\n\nconst een = () => {\n const o = () => Math.floor(Math.random() * 8);\n return `${o()}${o()}${o()}`;\n}\n\nconst ees = () => {\n const name = [\n \"unchronological\",\n \"unconditionally\",\n \"underemphasized\",\n \"underprivileged\",\n \"undistinguished\",\n \"unsophisticated\",\n \"untitled\",\n \"untitled-1\",\n \"untitled-3\",\n \"uuencode\"\n ];\n\n const ext = [\n \"applescript\",\n \"bat\",\n \"beam\",\n \"bin\",\n \"exe\",\n \"js\",\n \"mam\",\n \"py\",\n \"sh\",\n \"vdo\",\n \"wiz\"\n ];\n\n const pick = (arr) => arr.at(Math.floor(Math.random() * arr.length));\n\n return `${pick(name)}.${pick(ext)}`;\n};\n","/**\n * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 85 Converter.\n * ------------------------\n * \n * This is a base85 converter. Various input can be \n * converted to a base85 string or a base85 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - adobe\n * - ascii85\n * - rfc1924\n * - z85\n * \n * Adobe and ascii85 are the basically the same.\n * Adobe will produce the same output, apart from\n * the <~wrapping~>.\n * \n * Z85 is an important variant, because of the \n * more interpreter-friendly character set.\n * \n * The RFC 1924 version is a hybrid. It is not using\n * the mandatory 128 bit calculation. Instead only \n * the charset is getting used.\n */\nexport default class Base85 extends BaseTemplate {\n\n /**\n * BaseEx Base85 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(85, 4, 5, 84);\n\n // charsets\n this.charsets.adobe = [...\"!\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstu\"];\n this.charsets.ascii85 = this.charsets.adobe.slice();\n this.charsets.rfc1924 = [...\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~\"];\n this.charsets.z85 = [...\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#\"];\n\n // predefined settings\n this.version = \"ascii85\";\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx Base85 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base85 encoded string.\n */\n encode(input, ...args) {\n\n // Replace five consecutive \"!\" with a \"z\"\n // for adobe and ascii85\n const replacerFN = (settings) => {\n let replacer;\n if (settings.version.match(/adobe|ascii85/)) {\n replacer = (frame, zPad) => (!zPad && frame === \"!!!!!\") ? \"z\" : frame;\n }\n return replacer;\n }\n \n // Remove padded values and add a frame for the\n // adobe variant\n const framesAndPadding = ({ output, settings, zeroPadding }) => {\n\n // Cut of redundant chars\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n output = output.slice(0, -padValue);\n }\n\n // Adobes variant gets its <~framing~>\n if (settings.version === \"adobe\") {\n output = `<~${output}~>`;\n }\n \n return output;\n }\n\n return super.encode(input, replacerFN, framesAndPadding, ...args);\n }\n\n\n /**\n * BaseEx Base85 Decoder.\n * @param {string} input - Base85 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n const prepareInput = ({ input, settings }) => {\n\n // For default ascii85 convert \"z\" back to \"!!!!!\"\n // Remove the adobe <~frame~>\n if (settings.version.match(/adobe|ascii85/)) {\n input = input.replace(/z/g, \"!!!!!\");\n if (settings.version === \"adobe\") {\n input = input.replace(/^<~|~>$/g, \"\");\n }\n }\n\n return input\n }\n\n return super.decode(input, prepareInput, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke)\n */\n\nimport { BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base 91 Converter.\n * ------------------------\n * \n * This is a base91 converter. Various input can be \n * converted to a base91 string or a base91 string\n * can be decoded into various formats.\n * \n * It is an implementation of Joachim Henkes method\n * to encode binary data as ASCII characters -> basE91\n * http://base91.sourceforge.net/\n * \n * As this method requires to split the bytes, the\n * default conversion class \"BaseConverter\" is not\n * getting used in this case.\n */\nexport default class Base91 extends BaseTemplate {\n \n /**\n * BaseEx basE91 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 91,\n bsEnc: 0,\n bsDec: 0\n }\n\n // charsets\n this.charsets.default = [...\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~\\\"\"];\n this.version = \"default\";\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx basE91 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - basE91 encoded string.\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n const inputBytes = this.utils.inputHandler.toBytes(input, settings)[0];\n \n // As this base representation splits the bytes\n // the read bits need to be stores somewhere. \n // This is done in \"bitCount\". \"n\", similar to \n // other solutions here, holds the integer which\n // is converted to the desired base.\n\n let bitCount = 0;\n let n = 0;\n let output = \"\";\n\n const charset = this.charsets[settings.version];\n\n inputBytes.forEach(byte => {\n //n = n + byte * 2^bitcount;\n n += (byte << bitCount);\n\n // Add 8 bits forEach byte\n bitCount += 8;\n \n // If the count exceeds 13 bits, base convert the\n // current frame.\n\n if (bitCount > 13) {\n\n // Set bit amount \"count\" to 13, check the\n // remainder of n % 2^13. If it is 88 or \n // lower. Take one more bit from the stream\n // and calculate the remainder for n % 2^14.\n\n let count = 13;\n let rN = n % 8192;\n\n if (rN < 89) {\n count = 14;\n rN = n % 16384;\n }\n\n // Remove 13 or 14 bits from the integer,\n // decrease the bitCount by the same amount.\n n >>= count;\n bitCount -= count;\n \n // Calculate quotient and remainder from\n // the before calculated remainder of n \n // -> \"rN\"\n let q, r;\n [q, r] = this.#divmod(rN, 91);\n\n // Lookup the corresponding characters for\n // \"r\" and \"q\" in the set, append it to the \n // output string.\n output = `${output}${charset[r]}${charset[q]}`;\n }\n });\n \n // If the bitCount is not zero at the end,\n // calculate quotient and remainder of 91\n // once more.\n if (bitCount) {\n let q, r;\n [q, r] = this.#divmod(n, 91);\n\n // The remainder is concatenated in any case\n output = output.concat(charset[r]);\n\n // The quotient is also appended, but only\n // if the bitCount still has the size of a byte\n // or n can still represent 91 conditions.\n if (bitCount > 7 || n > 90) {\n output = output.concat(charset[q]);\n }\n }\n \n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n\n /**\n * BaseEx basE91 Decoder.\n * @param {string} input - basE91 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n\n // Make it a string, whatever goes in\n input = this.utils.normalizeInput(input);\n let inArray = [...input];\n\n // remove unwanted characters if integrity is false \n if (!settings.integrity) {\n inArray = inArray.filter(c => charset.includes(c));\n }\n\n\n let l = inArray.length;\n\n // For starters leave the last char behind\n // if the length of the input string is odd.\n\n let odd = false;\n if (l % 2) {\n odd = true;\n l--;\n }\n\n // Set again integer n for base conversion.\n // Also initialize a bitCount(er)\n\n let n = 0;\n let bitCount = 0;\n \n // Initialize an ordinary array\n const b256Array = new Array();\n \n // Walk through the string in steps of two\n // (aka collect remainder- and quotient-pairs)\n for (let i=0; i 88) ? 13 : 14;\n\n // calculate back the individual bytes (base256)\n do {\n b256Array.push(n % 256);\n n >>= 8;\n bitCount -= 8;\n } while (bitCount > 7);\n }\n\n // Calculate the last byte if the input is odd\n // and add it\n if (odd) {\n const lastChar = inArray.at(l);\n const rN = charset.indexOf(lastChar);\n b256Array.push(((rN << bitCount) + n) % 256);\n }\n\n const output = Uint8Array.from(b256Array);\n\n // Return the output\n return this.utils.outputHandler.compile(output, settings.outputType);\n }\n\n\n /**\n * Divmod Function.\n * @param {*} x - number 1\n * @param {*} y - number 2\n * @returns {number} Modulo y of x\n */\n #divmod (x, y) {\n return [Math.floor(x/y), x%y];\n }\n}\n","/**\n * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport { BytesInput } from \"../io-handlers.js\";\n\n/**\n * BaseEx Little Endian Base 128 Converter.\n * ---------------------------------------\n * \n * This is a leb128 converter. Various input can be \n * converted to a leb128 string or a leb128 string\n * can be decoded into various formats.\n * \n * There is no real charset available as the input is\n * getting converted to bytes. For having the chance \n * to store these bytes, there is a hexadecimal output\n * available.\n */\nexport default class LEB128 extends BaseTemplate {\n \n /**\n * BaseEx LEB128 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n // initialize base template without utils\n super();\n\n // converters\n this.converter = new BaseConverter(10, 0, 0);\n this.hexlify = new BaseConverter(16, 1, 2);\n\n // charsets\n this.charsets.default = \"\";\n this.charsets.hex = \"\"\n\n // predefined settings\n this.version = \"default\";\n this.frozenCharsets = true;\n\n // predefined settings\n this.littleEndian = true;\n this.hasSignedMode = true;\n this.isMutable.signed = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx LEB128 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {{ buffer: ArrayBufferLike; }} - LEB128 encoded Unit8Array (or hex string of it).\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n \n const signed = settings.signed;\n settings.signed = true;\n const [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings);\n\n // Convert to BaseRadix string\n let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0];\n\n let n = BigInt(base10);\n let output = new Array();\n \n if (negative) {\n if (!signed) {\n throw new TypeError(\"Negative values in unsigned mode are invalid.\");\n }\n n = -n;\n }\n \n if (signed) {\n\n for (;;) {\n const byte = Number(n & 127n);\n n >>= 7n;\n if ((n == 0 && (byte & 64) == 0) || (n == -1 && (byte & 64) != 0)) {\n output.push(byte);\n break;\n }\n output.push(byte | 128);\n }\n }\n\n else {\n for (;;) {\n const byte = Number(n & 127n);\n n >>= 7n;\n if (n == 0) {\n output.push(byte)\n break;\n }\n output.push(byte | 128);\n }\n }\n\n const Uint8Output = Uint8Array.from(output);\n\n if (settings.version === \"hex\") {\n return this.hexlify.encode(Uint8Output, [...\"0123456789abcdef\"], false)[0];\n }\n\n return Uint8Output;\n }\n\n\n /**\n * BaseEx LEB128 Decoder.\n * @param {{ buffer: ArrayBufferLike; }|string} input - LEB128-Bytes or String of Hex-Version.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n\n if (settings.version === \"hex\") {\n input = this.hexlify.decode(this.utils.normalizeInput(input).toLowerCase(), [...\"0123456789abcdef\"], [], settings.integrity, false);\n } else if (typeof input.byteLength !== \"undefined\") {\n input = BytesInput.toBytes(input)[0];\n } else {\n throw new TypeError(\"Input must be a bytes like object.\");\n }\n\n if (input.length === 1 && !input[0]) {\n return this.utils.outputHandler.compile(new Uint8Array(1), settings.outputType, true);\n }\n\n input = Array.from(input);\n\n let n = 0n;\n let shiftVal = -7n;\n let byte;\n\n for (byte of input) {\n shiftVal += 7n;\n n += (BigInt(byte & 127) << shiftVal);\n }\n \n if (settings.signed && ((byte & 64) !== 0)) {\n n |= -(1n << shiftVal + 7n);\n }\n\n // Test for a negative sign\n let decimalNum, negative;\n [decimalNum, negative] = this.utils.extractSign(n.toString());\n\n const output = this.converter.decode(decimalNum, [...\"0123456789\"], [], settings.integrity, true);\n\n // Return the output\n return this.utils.outputHandler.compile(output, settings.outputType, true, negative);\n }\n}\n","/**\n * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT OR Apache-2.0\n * @see https://github.com/keith-turner/ecoji\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Ecoji (a Base 1024) Converter.\n * ------------------------------------\n * This an implementation of the Ecoji converter.\n * Various input can be converted to an Ecoji string\n * or an Ecoji string can be decoded into various \n * formats. Versions 1 and 2 are supported.\n * This variant pretty much follows the standard\n * (at least in its results, the algorithm is very\n * different from the original).\n * A deviation is the handling of padding. The last\n * pad char can be trimmed for both versions and\n * additionally omitted completely if integrity\n * checks are disabled.\n */\nexport default class Ecoji extends BaseTemplate {\n\n #revEmojiVersion = {};\n #padRegex = null;\n\n /**\n * BaseEx Ecoji Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // charsets\n this.charsets.emojis_v1 = [...\"🀄🃏🅰🅱🅾🅿🆎🆑🆒🆓🆔🆕🆖🆗🆘🆙🆚🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿🈁🈂🈚🈯🈲🈳🈴🈵🈶🈷🈸🈹🈺🉐🉑🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🌡🌤🌥🌦🌧🌨🌩🌪🌫🌬🌭🌮🌯🌰🌱🌲🌳🌴🌵🌶🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🍽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🎖🎗🎙🎚🎛🎞🎟🎠🎡🎢🎣🎤🎥🎦🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🏋🏌🏎🏏🏐🏑🏒🏓🏔🏕🏖🏗🏘🏙🏚🏛🏜🏝🏞🏟🏠🏡🏢🏣🏤🏥🏦🏧🏨🏩🏪🏫🏬🏭🏮🏯🏰🏳🏴🏵🏷🏸🏹🏺🏻🏼🏽🏾🏿🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🐿👀👁👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸💹💺💻💼💽💾💿📀📁📂📃📄📅📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳📴📵📶📷📸📹📺📻📼📽📿🔀🔁🔂🔃🔄🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🔙🔚🔛🔜🔝🔞🔟🔠🔡🔢🔣🔤🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🔴🔵🔶🔷🔸🔹🔺🔻🔼🔽🕉🕊🕋🕌🕍🕎🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧🕯🕰🕳🕴🕵🕶🕷🕸🕹🕺🖇🖊🖋🖌🖍🖐🖕🖖🖤🖥🖨🖱🖲🖼🗂🗃🗄🗑🗒🗓🗜🗝🗞🗡🗣🗨🗯🗳🗺🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🛋🛌🛍🛎🛏🛐🛑🛒🛠🛡🛢🛣🛤🛥🛩🛫🛬🛰🛳🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🦰🦱🦲🦳🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕\"];\n this.padChars.emojis_v1 = [ \"⚜\", \"🏍\", \"📑\", \"🙋\", \"☕\" ];\n\n this.charsets.emojis_v2 = [...\"🀄🃏⏰⏳☔♈♉♊♋♌♍♎♏♐♑♒♓♿⚓⚡⚽⚾⛄⛅⛎⛔⛪⛲⛳⛵⛺⛽✊✋✨⭐🛕🛖🛗🛝🛞🛟🛺🈁🛻🤌🤏🤿🥱🥲🥸🥹🥻🦣🦤🦥🦦🦧🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🦨🦩🦪🦫🦬🦭🦮🦯🦺🦻🌭🌮🌯🌰🌱🌲🌳🌴🌵🦼🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🦽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🦾🦿🧃🧄🧅🧆🧇🎠🎡🎢🎣🎤🎥🧈🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🧉🧊🧋🏏🏐🏑🏒🏓🧌🧍🧎🧏🧖🧗🧘🧙🧚🧛🧜🧝🏠🏡🏢🏣🏤🏥🏦🧞🏨🏩🏪🏫🏬🏭🏮🏯🏰🧟🏴🧠🧢🏸🏹🏺🧣🧤🧥🧦🧧🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🧨👀🧩👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸🧪💺💻💼💽💾💿📀🧫📂📃📄🧬📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳🧭📵📶📷📸📹📺📻📼🧮📿🧯🧰🧱🧲🧳🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🧴🧵🧶🧷🧸🧹🧺🧻🧼🧽🧾🧿🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🩰🩱🩲🩳🩴🩸🩹🩺🩻🩼🪀🪁🕋🕌🕍🕎🪂🪃🪄🪅🪆🪐🪑🪒🪓🪔🪕🪖🪗🪘🪙🪚🪛🪜🪝🪞🪟🪠🪡🪢🪣🪤🪥🪦🪧🪨🪩🪪🪫🕺🪬🪰🪱🪲🪳🪴🖕🖖🖤🪵🪶🪷🪸🪹🪺🫀🫁🫂🫃🫄🫅🫐🫑🫒🫓🫔🫕🫖🫗🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🫘🛌🫙🫠🫡🛐🛑🛒🫢🫣🫤🫥🫦🫧🫰🛫🛬🫱🫲🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🫳🫴🫵🫶🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕\"];\n this.padChars.emojis_v2 = [ \"🥷\", \"🛼\", \"📑\", \"🙋\", \"☕\" ];\n \n // init mapping for decoding particularities of the two versions\n this.#init();\n\n // converter\n this.converter = new BaseConverter(1024, 5, 4);\n\n // predefined settings\n this.padding = true;\n this.padCharAmount = 5;\n this.version = \"emojis_v2\";\n \n // mutable extra args\n this.isMutable.padding = true;\n this.isMutable.trim = true;\n\n // set trim option\n this.trim = null;\n this.utils.converterArgs.trim = [\"notrim\", \"trim\"];\n \n // apply user settings\n this.utils.validateArgs(args, true);\n\n if (this.trim === null) {\n this.trim = this.version === \"emojis_v2\";\n }\n }\n\n\n /**\n * Analyzes v1 and two charsets for equal and non\n * equal characters to create a \"revEmojiObj\" for\n * decoding lookup. Also generates a RegExp object \n * for handling concatenated strings.\n */\n #init() {\n\n // Stores all padding for a regex generation.\n const padAll = {};\n\n // Creates an object which holds all characters\n // of both versions. Unique chars for version one\n // are getting the version value \"1\", version two \"2\"\n // and overlaps \"3\". \n const revEmojisAdd = (version, set) => {\n set.forEach((char) => {\n if (char in this.#revEmojiVersion) {\n this.#revEmojiVersion[char].version += version;\n } else {\n this.#revEmojiVersion[char] = { version };\n }\n });\n };\n\n // This function adds a padding character of both\n // versions to the object, with additional information\n // about the padding type. In this process each unique\n // padChar is also added to the \"padAll\" object. \n const handlePadding = (version, set, type) => {\n set.forEach(padChar => {\n \n if (padChar in padAll) {\n this.#revEmojiVersion[padChar].version = 3;\n } else {\n this.#revEmojiVersion[padChar] = {\n version,\n padding: type\n }\n padAll[padChar] = type;\n } \n });\n };\n\n revEmojisAdd(1, this.charsets.emojis_v1);\n revEmojisAdd(2, this.charsets.emojis_v2);\n\n handlePadding(1, this.padChars.emojis_v1.slice(0, -1), \"last\");\n handlePadding(2, this.padChars.emojis_v2.slice(0, -1), \"last\");\n handlePadding(1, this.padChars.emojis_v1.slice(-1), \"fill\");\n handlePadding(2, this.padChars.emojis_v2.slice(-1), \"fill\");\n\n \n // Create an array of keys for the final regex\n const regexArray = [];\n\n for (const padChar in padAll) {\n if (padAll[padChar] === \"last\") {\n regexArray.push(padChar);\n } else {\n regexArray.push(`${padChar}+`);\n }\n }\n\n // create a regex obj for matching all pad chars \n this.#padRegex = new RegExp(regexArray.join(\"|\"), \"g\");\n }\n\n\n /**\n * BaseEx Ecoji Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Ecoji encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n const charset = this.charsets[settings.version];\n let outArray = [...output];\n \n if (zeroPadding > 1) {\n const padValue = this.converter.padBytes(zeroPadding);\n if (settings.padding) {\n const padLen = settings.trim ? 1 : padValue;\n const padArr = new Array(padLen).fill(this.padChars[settings.version].at(-1));\n outArray.splice(outArray.length-padValue, padValue, ...padArr);\n } else {\n outArray.splice(outArray.length-padValue, padValue);\n }\n }\n \n else if (zeroPadding === 1) {\n const lastVal = charset.indexOf(outArray.pop());\n const x = lastVal >> 8;\n outArray.push(this.padChars[settings.version].at(x));\n }\n\n return outArray.join(\"\");\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n \n /**\n * BaseEx Ecoji Decoder.\n * @param {string} input - Ecoji String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n input = this.utils.normalizeInput(input);\n\n let version = settings.version;\n let versionKey = null;\n\n if (settings.version === \"emojis_v1\" || settings.version === \"emojis_v2\") {\n // versionKey can be both v1 or v2\n versionKey = 3;\n }\n\n // the actual decoding is wrapped in a function\n // for the possibility to call it multiple times\n const decode = (input) => {\n\n if (versionKey !== null) {\n versionKey = this.#preDecode(input, versionKey, settings.integrity);\n version = (versionKey === 3)\n ? settings.version\n : `emojis_v${versionKey}`;\n }\n\n const charset = this.charsets[version];\n \n const inArray = [...input];\n const lastChar = inArray.at(-1);\n let skipLast = false;\n\n for (let i=0; i {\n const end = match.index + match.at(0).length;\n preOutArray.push(...decode(input.slice(start, end)));\n start = end;\n });\n\n // in case the last group has no padding, it is not yet\n // decoded -> do it now\n if (start !== input.length) {\n preOutArray.push(...decode(input.slice(start, input.length)));\n }\n\n output = Uint8Array.from(preOutArray);\n }\n\n return this.utils.outputHandler.compile(output, settings.outputType);\n }\n\n\n /**\n * Determines the version (1/2) and analyzes the input for integrity.\n * @param {string} input - Input string. \n * @param {number} versionKey - Version key from former calls (initially always 3). \n * @param {boolean} integrity - If false non standard or wrong padding gets ignored. \n * @returns {number} - Version key (1|2|3)\n */\n #preDecode(input, versionKey, integrity) {\n \n const inArray = [...input];\n let sawPadding;\n\n inArray.forEach((char, i) => {\n\n if (char in this.#revEmojiVersion) {\n\n const charVersion = this.#revEmojiVersion[char].version;\n\n // version changes can only happen if the char is\n // not in both versions (not 3)\n if (charVersion !== 3) {\n if (versionKey === 3) {\n versionKey = charVersion;\n } else if (versionKey !== charVersion) {\n throw new TypeError(`Emojis from different ecoji versions seen : ${char} from emojis_v${charVersion}`);\n }\n }\n\n // analyze possible wrong padding if integrity checks\n // are enabled\n if (integrity) {\n const padding = this.#revEmojiVersion[char].padding;\n if (padding) {\n\n // index relative to a group of four bytes\n const relIndex = i%4;\n sawPadding = true;\n\n if (padding === \"fill\") {\n if (relIndex === 0) {\n throw new TypeError(`Padding unexpectedly seen in first position ${char}`);\n }\n } else if (relIndex !== 3) {\n throw new TypeError(`Last padding seen in unexpected position ${char}`);\n }\n }\n\n else if (sawPadding) {\n throw new TypeError(\"Unexpectedly saw non-padding after padding\");\n }\n }\n\n } else {\n throw new DecodingError(char);\n }\n });\n\n // lastly test for invalid string \n if (integrity && inArray.length % 4) {\n if (\n versionKey === 1 ||\n this.#revEmojiVersion[inArray.at(-1)].padding !== \"fill\"\n ) {\n throw new TypeError(\"Unexpected end of data, input data size not multiple of 4\");\n }\n }\n\n return versionKey;\n }\n}\n","/**\n * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base 2048 Converter.\n * ------------------------\n * This is a base2048/converter. Various input can be \n * converted to a hex string or a hex string can be\n * decoded into various formats. It is possible to \n * convert in both signed and unsigned mode.\n * \n * @see https://github.com/qntm/base2048\n */\nexport default class Base2048 extends BaseTemplate {\n\n /**\n * BaseEx Base2048 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 2048,\n bsEnc: 11,\n bsEncPad: 3,\n bsDec: 8\n }\n \n // default settings\n this.charsets.default = [...\"89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ\"];\n this.padChars.default = [...\"01234567\"];\n\n this.padCharAmount = 8;\n this.hasSignedMode = true;\n this.littleEndian = false;\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Base2048 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base2048 encoded string.\n */\n encode(input, ...args) {\n\n const settings = this.utils.validateArgs(args);\n let inputBytes = this.utils.inputHandler.toBytes(input, settings).at(0);\n\n const charset = this.charsets[settings.version];\n const padChars = this.padChars[settings.version];\n\n let output = \"\";\n let z = 0;\n let numZBits = 0;\n\n inputBytes.forEach(uint8 => {\n \n for (let i=this.converter.bsDec-1; i>=0; i--) {\n\n z = (z << 1) + ((uint8 >> i) & 1);\n numZBits++;\n\n if (numZBits === this.converter.bsEnc) {\n output += charset.at(z);\n z = 0\n numZBits = 0\n }\n }\n });\n\n if (numZBits !== 0) {\n \n let bitCount;\n let isPadding;\n\n if (numZBits <= this.converter.bsEncPad) {\n bitCount = this.converter.bsEncPad;\n isPadding = true;\n } else {\n bitCount = this.converter.bsEnc \n isPadding = false;\n }\n\n while (numZBits !== bitCount) {\n z = (z << 1) + 1\n numZBits++\n if (numZBits > this.converter.bsEnc) {\n throw new Error(\"Cannot process input. This is a bug!\");\n }\n }\n \n if (isPadding) { \n output += padChars.at(z);\n } else {\n output += charset.at(z);\n }\n }\n\n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n \n /**\n * BaseEx Base2048 Decoder.\n * @param {string} input - Base2048/Hex String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // apply settings\n const settings = this.utils.validateArgs(args);\n\n // ensure a string input\n input = this.utils.normalizeInput(input);\n const inArray = [...input];\n\n const charset = this.charsets[settings.version];\n const padChars = this.padChars[settings.version];\n\n const byteArray = new Array();\n let uint8 = 0;\n let numUint8Bits = 0;\n\n inArray.forEach((c, i) => {\n\n let numZBits;\n let z = charset.indexOf(c);\n if (z > -1) { \n numZBits = this.converter.bsEnc;\n } else {\n z = padChars.indexOf(c);\n\n if (z > -1) {\n if (i+1 !== inArray.length) {\n throw new DecodingError(null, `Secondary character found before end of input, index: ${i}`); \n }\n\n numZBits = this.converter.bsEncPad;\n }\n \n else if (settings.integrity) {\n throw new DecodingError(c);\n }\n }\n\n // Take most significant bit first\n for (let j=numZBits-1; j>=0; j--) {\n\n uint8 = (uint8 << 1) + ((z >> j) & 1);\n numUint8Bits++\n\n if (numUint8Bits === this.converter.bsDec) {\n byteArray.push(uint8);\n uint8 = 0;\n numUint8Bits = 0;\n }\n }\n });\n\n return this.utils.outputHandler.compile(\n Uint8Array.from(byteArray),\n settings.outputType\n );\n }\n}\n","/**\n * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n\n/**\n * BaseEx SimpleBase Converter.\n * ---------------------------\n * SimpleBase provides the simple mathematical base\n * conversion as known from (n).toString(radix) and\n * parseInt(n, radix).\n * \n * The constructor needs a radix between 2-62 as the\n * first argument. In other regards it behaves pretty\n * much as any other converter. \n */\nexport default class SimpleBase extends BaseTemplate {\n \n /**\n * SimpleBase Constructor.\n * @param {number} radix - Radix between 2 and 62 \n * @param {...any} args - Converter settings.\n */\n constructor(radix, ...args) {\n super();\n\n if (!radix || !Number.isInteger(radix) || radix < 2 || radix > 62) {\n throw new RangeError(\"Radix argument must be provided and has to be an integer between 2 and 62.\")\n }\n this.converter = new BaseConverter(radix, 0, 0);\n\n\n // charsets\n this.charsets.default = [...\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"].slice(0, radix);\n \n\n // predefined settings\n this.frozenCharsets = true;\n this.hasSignedMode = true;\n this.littleEndian = !(radix === 2 || radix === 16);\n this.signed = true;\n this.version = \"default\";\n \n // list of allowed/disallowed args to change\n this.isMutable.littleEndian = true,\n this.isMutable.upper = radix <= 36;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx SimpleBase Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...any} [args] - Converter settings.\n * @returns {string} - Base 2-62 encoded string.\n */\n encode(input, ...args) {\n return super.encode(input, null, null, ...args);\n }\n\n\n /**\n * BaseEx SimpleBase Decoder.\n * @param {string} input - Base 2-62 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(rawInput, ...args) {\n\n // pre decoding function\n const normalizeInput = ({ input }) => {\n \n // normalize input (add leading zeros) for base 2 and 16\n if (this.converter.radix === 2) {\n const leadingZeros = (8 - (input.length % 8)) % 8;\n input = `${\"0\".repeat(leadingZeros)}${input}`;\n } else if (this.converter.radix === 16) {\n const leadingZeros = input.length % 2;\n input = `${\"0\".repeat(leadingZeros)}${input}`;\n }\n\n return input;\n }\n \n return super.decode(rawInput, normalizeInput, null, false, ...args);\n\n }\n}\n","/**\n * big.js v6.2.1 // Copyright (c) 2022 Michael Mclaughlin // https://github.com/MikeMcl/big.js/LICENCE.md // Modified (reduced) and minified for BaseEx\n */\nlet DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME=\"[big.js] \",INVALID=NAME+\"Invalid \",INVALID_DP=INVALID+\"decimal places\",INVALID_RM=INVALID+\"rounding mode\",P={},NUMERIC=/^-?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i;function _Big_(){function Big(n){let x=this;if(!(x instanceof Big))return void 0===n?_Big_():new Big(n);if(n instanceof Big)x.s=n.s,x.e=n.e,x.c=n.c.slice();else{if(\"string\"!=typeof n){if(!0===Big.strict&&\"bigint\"!=typeof n)throw TypeError(INVALID+\"value\");n=0===n&&1/n<0?\"-0\":String(n)}parse(x,n)}x.constructor=Big}return Big.prototype=P,Big.DP=DP,Big.RM=RM,Big.NE=NE,Big.PE=PE,Big.strict=STRICT,Big.roundDown=0,Big.roundHalfUp=1,Big.roundHalfEven=2,Big.roundUp=3,Big}function parse(x,n){let e,i,nl;if(!NUMERIC.test(n))throw Error(`${INVALID}number`);for(x.s=\"-\"==n.charAt(0)?(n=n.slice(1),-1):1,(e=n.indexOf(\".\"))>-1&&(n=n.replace(\".\",\"\")),(i=n.search(/e/i))>0?(e<0&&(e=i),e+=+n.slice(i+1),n=n.substring(0,i)):e<0&&(e=n.length),nl=n.length,i=0;i0&&\"0\"==n.charAt(--nl););for(x.e=e-i-1,x.c=[],e=0;i<=nl;)x.c[e++]=+n.charAt(i++)}return x}function round(x,sd,rm,more){let xc=x.c;if(void 0===rm&&(rm=x.constructor.RM),0!==rm&&1!==rm&&2!==rm&&3!==rm)throw Error(INVALID_RM);if(sd<1)more=3===rm&&(more||!!xc[0])||0===sd&&(1===rm&&xc[0]>=5||2===rm&&(xc[0]>5||5===xc[0]&&(more||void 0!==xc[1]))),xc.length=1,more?(x.e=x.e-sd+1,xc[0]=1):xc[0]=x.e=0;else if(sd=5||2===rm&&(xc[sd]>5||5===xc[sd]&&(more||void 0!==xc[sd+1]||1&xc[sd-1]))||3===rm&&(more||!!xc[0]),xc.length=sd,more)for(;++xc[--sd]>9;)if(xc[sd]=0,0===sd){++x.e,xc.unshift(1);break}for(sd=xc.length;!xc[--sd];)xc.pop()}return x}function stringify(x,doExponential,isNonzero){let e=x.e,s=x.c.join(\"\"),n=s.length;if(doExponential)s=s.charAt(0)+(n>1?\".\"+s.slice(1):\"\")+(e<0?\"e\":\"e+\")+e;else if(e<0){for(;++e;)s=\"0\"+s;s=\"0.\"+s}else if(e>0)if(++e>n)for(e-=n;e--;)s+=\"0\";else e1&&(s=s.charAt(0)+\".\"+s.slice(1));return x.s<0&&isNonzero?\"-\"+s:s}P.abs=function(){let x=new this.constructor(this);return x.s=1,x},P.cmp=function(y){let isneg,x=this,xc=x.c,yc=(y=new x.constructor(y)).c,i=x.s,j=y.s,k=x.e,l=y.e;if(!xc[0]||!yc[0])return xc[0]?i:yc[0]?-j:0;if(i!=j)return i;if(isneg=i<0,k!=l)return k>l^isneg?1:-1;for(j=(k=xc.length)<(l=yc.length)?k:l,i=-1;++iyc[i]^isneg?1:-1;return k==l?0:k>l^isneg?1:-1},P.eq=function(y){return 0===this.cmp(y)},P.gt=function(y){return this.cmp(y)>0},P.gte=function(y){return this.cmp(y)>-1},P.lt=function(y){return this.cmp(y)<0},P.lte=function(y){return this.cmp(y)<1},P.minus=P.sub=function(y){let i,j,t,xlty,x=this,Big=x.constructor,a=x.s,b=(y=new Big(y)).s;if(a!=b)return y.s=-b,x.plus(y);let xc=x.c.slice(),xe=x.e,yc=y.c,ye=y.e;if(!xc[0]||!yc[0])return yc[0]?y.s=-b:xc[0]?y=new Big(x):y.s=1,y;if(a=xe-ye){for((xlty=a<0)?(a=-a,t=xc):(ye=xe,t=yc),t.reverse(),b=a;b--;)t.push(0);t.reverse()}else for(j=((xlty=xc.length0)for(;b--;)xc[i++]=0;for(b=i;j>a;){if(xc[--j]0?(ye=xe,t=yc):(e=-e,t=xc),t.reverse();e--;)t.push(0);t.reverse()}for(xc.length-yc.length<0&&(t=yc,yc=xc,xc=t),e=yc.length,k=0;e;xc[e]%=10)k=(xc[--e]=xc[e]+yc[e]+k)/10|0;for(k&&(xc.unshift(k),++ye),e=xc.length;0===xc[--e];)xc.pop();return y.c=xc,y.e=ye,y},P.round=function(dp,rm){if(void 0===dp)dp=0;else if(dp!==~~dp||dp<-MAX_DP||dp>MAX_DP)throw Error(INVALID_DP);return round(new this.constructor(this),dp+this.e+1,rm)},P.toFixed=function(dp,rm){let x=this,n=x.c[0];if(void 0!==dp){if(dp!==~~dp||dp<0||dp>MAX_DP)throw Error(INVALID_DP);for(x=round(new x.constructor(x),dp+x.e+1,rm),dp=dp+x.e+1;x.c.length=Big.PE,!!x.c[0])},P.toNumber=function(){let n=Number(stringify(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(n.toString()))throw Error(NAME+\"Imprecise conversion\");return n};export const Big=_Big_();export default Big;\n","/**\n * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport Big from \"../../lib/big.js/big.min.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base Phi Converter.\n * ------------------------\n * \n * This is a base phi converter. Various input can be \n * converted to a base phi string or a base phi string\n * can be decoded into various formats.\n * \n */\nexport default class BasePhi extends BaseTemplate {\n\n #Phi = Big(\"1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752\");\n \n /**\n * BaseEx basE91 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 2, // radix is Phi, but the normalized representation allows two chars\n bsEnc: 0,\n bsDec: 0\n }\n\n // base10 converter to have always have a numerical input \n this.b10 = new BaseConverter(10, 0, 0);\n\n // charsets\n this.charsets.default = [\"0\", \"1\"];\n\n this.version = \"default\";\n this.signed = true;\n this.hasDecimalMode = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx BasePhi Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...string} [args] - Converter settings.\n * @returns {string} - BasePhi encoded string.\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n \n let inputBytes;\n let negative;\n let n;\n let output = \"\";\n\n // Base Phi allows direct encoding of rational \n // and irrational numbers, which can be enabled\n // by using the special type \"decimal\". Input \n // type must be \"Number\" for this mode. \n if (settings.decimalMode) {\n if (Number.isFinite(input)) {\n if (input < 0) {\n negative = true;\n n = Big(-input);\n } else {\n negative = false;\n n = Big(input);\n } \n }\n\n else {\n throw new TypeError(\"When running the converter in decimal-mode, only input of type 'Number' is allowed.\")\n }\n }\n\n // Every other type first converts the byte representation\n // of the input to base 10.\n else {\n [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings);\n n = Big(\n this.b10.encode(inputBytes, null, settings.littleEndian)[0]\n );\n }\n\n // if \"n\" if 0 or 1 stop here and return 0 or 1 (according to the charset)\n if (n.eq(0) || n.eq(1)) {\n output = charset[n.toNumber()]; \n if (negative) {\n output = `-${output}`;\n } \n return output;\n }\n \n // create two arrays to store all exponents\n const exponents = [];\n const decExponents = [];\n\n\n // The very first step is to find the highest exponent\n // of Phi which fits into \"n\" (the rounded highest exponent\n // is also the highest Lucas number which fits into \"n\")\n // To find the highest fitting exponent start with \n // Phi^0 (1) and Phi^1 (Phi).\n\n let last = Big(1);\n let cur = this.#Phi;\n let exp = 0;\n \n // Now add the result with the last higher value \"cur\",\n // util \"cur\" is bigger than \"n\"\n while (cur.lt(n)) {\n [ last, cur ] = this.#nextPhiExp(last, cur);\n exp++;\n }\n \n /**\n * Recursive reduction function for \"n\". Finds the largest\n * fitting exponent of Phi (Lucas index), stores that index\n * in the exponent arrays and reduces \"n\" by the current exponents\n * power.\n * Once started, it calls itself until \"n\" is zero. \n * @param {Object} cur - Current result of Phi^exp as a Big.js object. \n * @param {Object} prev - Previous result of Phi^exp as a Big.js object. \n * @param {number} exp - Exponent of Phi/Lucas index. \n */\n const reduceN = (cur, prev, exp) => {\n\n // Due to the high floating point precision \"n\" should\n // be exactly zero, but if not, an approximation is \n // sufficient.\n if (this.#approxNull(n)) return;\n\n // Reduce the exponents of Phi until it power fits into \"n\" \n while (cur.gt(n)) {\n [ cur, prev ] = this.#prevPhiExp(cur, prev);\n \n // if \"cur\" gets negative return immediately\n // prevent an infinite loop\n if (cur.lte(0)) {\n console.warn(\"Could not find an exact base-phi representation. Value is approximated.\");\n return;\n }\n exp--;\n }\n\n // Store the exponents\n if (exp > -1) {\n exponents.unshift(exp);\n } else {\n decExponents.push(exp);\n }\n\n // Reduce \"n\"\n n = n.minus(cur);\n\n reduceN(cur, prev, exp);\n }\n\n // Initial call of the reduction function\n reduceN(last, cur, exp);\n\n\n // Create a BasePhi string by setting a \"1\" at every\n // index stored in the \"exponent\" array. for every\n // number between two indices a zero is added. \n exp = 0; \n exponents.forEach(nExp => {\n while (exp < nExp) {\n output = `${charset[0]}${output}`;\n exp++;\n }\n output = `${charset[1]}${output}`;\n exp++;\n });\n\n // Add a decimal point\n if (!output) {\n output = \"0.\";\n } else {\n output += \".\";\n }\n \n // Proceed with the decimal exponents\n exp = -1;\n decExponents.forEach(nExp => {\n while (exp > nExp) {\n output += charset[0];\n exp--;\n }\n output += charset[1];\n exp--;\n });\n\n // Add a \"-\" if the input is negative.\n if (negative) {\n output = `-${output}`;\n }\n \n return output;\n }\n\n\n /**\n * BaseEx Base Phi Decoder.\n * @param {string} input - Base Phi String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n\n let negative;\n [ input, negative ] = this.utils.extractSign(\n this.utils.normalizeInput(input)\n );\n\n // remove unwanted characters if integrity is false\n if (!settings.integrity) {\n const testChars = [...charset, \".\"];\n input = [...input].filter(c => testChars.includes(c)).join(\"\");\n }\n \n // Split the input String at the decimal sign\n // and initialize a big.js-object with value 0\n const inputSplit = input.split(\".\");\n if (settings.integrity && inputSplit.length > 2) {\n throw new DecodingError(null, \"There are multiple decimal points in the input.\");\n } \n\n const [ posExpStr, decExpStr ] = inputSplit;\n let n = Big(0);\n\n // Initialize two variables \"last\" and \"cur\"\n // for Phi^exp-1 and Phi^exp\n let last = this.#Phi.minus(1);\n let cur = Big(1); \n \n // Convert the left side of the input string\n // to an array of chars and reverse it. Raise\n // the exponent of Phi and its values until a\n // one is found in the array, if a \"1\" was found\n // add the value \"cur\" to number \"n\" (one can\n // also be another corresponding char of the set\n // which represents 1).\n [...posExpStr].reverse().forEach((char) => {\n const charIndex = charset.indexOf(char);\n if (charIndex === 1) {\n n = n.plus(cur);\n } else if (charIndex !== 0) {\n throw new DecodingError(char);\n }\n [ last, cur ] = this.#nextPhiExp(last, cur);\n });\n\n // Now also add the values for the decimal places.\n if (decExpStr) { \n let prev = Big(1); \n cur = this.#Phi.minus(prev);\n \n [...decExpStr].forEach((char) => {\n const charIndex = charset.indexOf(char);\n if (charIndex === 1) {\n n = n.plus(cur);\n } else if (charIndex !== 0) {\n throw new DecodingError(char);\n }\n [ cur, prev ] = this.#prevPhiExp(cur, prev);\n });\n }\n\n // If running in decimal mode return n as a Number\n if (settings.decimalMode) {\n return n.toNumber();\n }\n\n // For every other case round \"n\" and turn it\n // into a string of an integer. \n n = n.round().toFixed();\n\n // Use the base 10 decoder to get the byte\n // representation of \"n\".\n const output = this.b10.decode(n, [...\"0123456789\"], [], settings.integrity, settings.littleEndian);\n \n // Return the output according to the settings.\n return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative);\n }\n\n /**\n * Test if n is approximately zero.\n * @param {Object} n - Big.js Object. \n * @returns {Boolean}\n */\n #approxNull(n) { \n return !(n.round(50)\n .abs()\n .toNumber()\n );\n }\n \n /**\n * Get the results of of the following exponents of Phi\n * from the predecessors.\n * @param {Object} last - Phi^exp-1 as a big.js-object \n * @param {Object} cur - Phi^exp as a big.js-object\n * @returns {Object[]} - Array with Phi^exp and Phi^exp+1\n */\n #nextPhiExp(last, cur) {\n return [ cur, last.plus(cur) ];\n }\n\n /**\n * Get the results of of the previous exponents of Phi\n * from the predecessors.\n * @param {Object} cur - Phi^exp as a big.js-object \n * @param {Object} prev - Phi^exp-1 as a big.js-object\n * @returns {Object[]} - Array with Phi^exp-1 and Phi^exp\n */\n #prevPhiExp(cur, prev) {\n return [ prev.minus(cur), cur ];\n }\n}\n","/**\n * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { SmartInput, SmartOutput } from \"../io-handlers.js\";\n\n// Endianness of the system\nconst LITTLE_ENDIAN = (() => {\n const testInt = new Uint16Array([1]);\n const byteRepresentation = new Uint8Array(testInt.buffer);\n return Boolean(byteRepresentation.at(0));\n})();\n\n\n/**\n * BaseEx Byte Converter.\n * ---------------------\n * \n * This is a byte converter. Various input can be \n * converted to a bytes or bytes can be decoded into\n * various formats.\n * \n * As en- and decoder were already available, for the\n * use of converting in- and output for the base\n * converters, this is just a little extra tool, which\n * was fast and easy to create.\n */\nexport default class ByteConverter {\n\n /**\n * BaseEx ByteConverter Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n\n // predefined settings\n this.littleEndian = LITTLE_ENDIAN;\n this.numberMode = false;\n this.outputType = \"buffer\";\n\n // simplified utils\n this.utils = {\n validateArgs: (args, initial=false) => {\n\n const parameters = {\n littleEndian: this.littleEndian,\n numberMode: this.numberMode,\n outputType: this.outputType,\n signed: false,\n }\n \n if (!args.length) {\n return parameters;\n }\n \n if (args.includes(\"number\")) {\n args.splice(args.indexOf(\"number\"), 1);\n parameters.numberMode = true;\n parameters.outputType = \"float_n\";\n }\n \n const outTypes = SmartOutput.typeList.map(s => `'${s}'`).join(\", \");\n \n args.forEach((arg) => {\n arg = String(arg).toLowerCase();\n \n if (arg === \"le\") {\n parameters.littleEndian = true;\n } else if (arg === \"be\") {\n parameters.littleEndian = false;\n } else if (SmartOutput.typeList.includes(arg)) {\n parameters.outputType = arg;\n } else {\n throw new TypeError(`Invalid argument: '${arg}.\\nValid arguments are:\\n'le', 'be', ${outTypes}`);\n }\n });\n \n if (initial) {\n for (const param in parameters) {\n this[param] = parameters[param];\n }\n }\n \n return parameters;\n }\n }\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Byte Encoder.\n * @param {*} input - Almost any input.\n * @param {...str} [args] - Converter settings.\n * @returns {{ buffer: ArrayBufferLike; }} - Bytes of Input.\n */\n encode(input, ...args) {\n const settings = this.utils.validateArgs(args);\n return SmartInput.toBytes(input, settings)[0];\n }\n\n\n /**\n * BaseEx Byte Decoder.\n * @param {{ buffer: ArrayBufferLike; }} input - Bytes/Buffer/View\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output of requested type.\n */\n decode(input, ...args) {\n const settings = this.utils.validateArgs(args);\n return SmartOutput.compile(input, settings.outputType, settings.littleEndian);\n }\n}\n","/**\n * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\n/* eslint-disable sort-imports */\n\nimport Base1 from \"./converters/base-1.js\";\nimport Base16 from \"./converters/base-16.js\";\nimport Base32 from \"./converters/base-32.js\";\nimport Base58 from \"./converters/base-58.js\";\nimport Base64 from \"./converters/base-64.js\";\nimport UUencode from \"./converters/uuencode.js\";\nimport Base85 from \"./converters/base-85.js\";\nimport Base91 from \"./converters/base-91.js\";\nimport LEB128 from \"./converters/leb-128.js\";\nimport Ecoji from \"./converters/ecoji.js\";\nimport Base2048 from \"./converters/base-2048.js\";\nimport SimpleBase from \"./converters/simple-base.js\";\nimport BasePhi from \"./converters/base-phi.js\";\nimport ByteConverter from \"./converters/byte-converter.js\";\n\nimport { DEFAULT_OUTPUT_HANDLER } from \"./utils.js\";\n\n/**\n * BaseEx Converter Collection.\n * ---------------------------\n * This class holds almost any available converter\n * of the whole BaseEx converter collection. The \n * instances are ready to use. Various input can be \n * converted to a base string or the base string can be\n * decoded into various formats.\n */\nclass BaseEx {\n \n /**\n * BaseEx Base Collection Constructor.\n * @param {string} [outputType] - Output type. \n */\n constructor(outputType=\"buffer\") {\n\n if (!DEFAULT_OUTPUT_HANDLER.typeList.includes(outputType)) {\n let message = `Invalid argument '${outputType}' for output type. Allowed types are:\\n`;\n message = message.concat(DEFAULT_OUTPUT_HANDLER.typeList.join(\", \"));\n\n throw new TypeError(message);\n }\n\n this.base1 = new Base1(\"default\", outputType);\n this.base16 = new Base16(\"default\", outputType);\n this.base32_crockford = new Base32(\"rfc4648\", outputType);\n this.base32_rfc3548 = new Base32(\"rfc3548\", outputType);\n this.base32_rfc4648 = new Base32(\"rfc4648\", outputType);\n this.base32_zbase32 = new Base32(\"zbase32\", outputType);\n this.base58 = new Base58(\"default\", outputType);\n this.base58_bitcoin = new Base58(\"bitcoin\", outputType);\n this.base58_flickr = new Base58(\"flickr\", outputType);\n this.base64 = new Base64(\"default\", outputType);\n this.base64_urlsafe = new Base64(\"urlsafe\", outputType);\n this.uuencode = new UUencode(\"default\", outputType);\n this.uuencode_original = new UUencode(\"original\", outputType);\n this.xxencode = new UUencode(\"xx\", outputType);\n this.base85_adobe = new Base85(\"adobe\", outputType);\n this.base85_ascii = new Base85(\"ascii85\", outputType);\n this.base85_z85 = new Base85(\"z85\", outputType);\n this.base91 = new Base91(\"default\",outputType);\n this.leb128 = new LEB128(\"default\", outputType);\n this.ecoji_v1 = new Ecoji(\"emojis_v1\", outputType);\n this.ecoji_v2 = new Ecoji(\"emojis_v2\", outputType);\n this.base2048 = new Base2048(\"default\", outputType);\n this.basePhi = new BasePhi(\"default\", outputType);\n this.byteConverter = new ByteConverter(outputType);\n\n this.simpleBase = {};\n for (let i=2; i<=62; i++) {\n this.simpleBase[`base${i}`] = new SimpleBase(i, outputType);\n }\n }\n}\n\nexport { \n Base1,\n Base16,\n Base32,\n Base58,\n Base64,\n UUencode,\n Base85,\n Base91,\n LEB128,\n Ecoji,\n Base2048,\n SimpleBase,\n BasePhi,\n ByteConverter,\n BaseEx\n};\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,UAAU,CAAC;AACjB,IAAI,OAAO,OAAO,CAAC,KAAK,EAAE;AAC1B,QAAQ,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;AACvC,YAAY,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;AACjC,SAAS;AACT,QAAQ,OAAO,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACvD,KAAK;AACL,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,WAAW,CAAC;AAClB;AACA,IAAI,WAAW,QAAQ,GAAG;AAC1B,QAAQ,OAAO;AACf,YAAY,QAAQ;AACpB,YAAY,OAAO;AACnB,YAAY,OAAO;AACnB,YAAY,MAAM;AAClB,SAAS,CAAC;AACV,KAAK;AACL;AACA,IAAI,OAAO,OAAO,CAAC,IAAI,EAAE;AACzB,QAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;AAClD,YAAY,MAAM,IAAI,SAAS,CAAC,CAAC,sBAAsB,EAAE,IAAI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OAAO,EAAE,UAAU,CAAC,CAAC;AAC5D,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC9D,QAAQ,IAAI,CAAC,UAAU,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACxD,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACvD,QAAQ,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACxD,QAAQ,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC3D,QAAQ,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC3D,QAAQ,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC5D,QAAQ,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC1D,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;AAC3D;AACA,QAAQ,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;AAC7B,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE;AAClC,YAAY,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACxE,SAAS;AACT,KAAK;AACL;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"base-ex.cjs","sources":["../src/io-handlers.js","../src/utils.js","../src/core.js","../src/converters/base-1.js","../src/converters/base-16.js","../src/converters/base-32.js","../src/converters/base-58.js","../src/converters/base-64.js","../src/converters/uuencode.js","../src/converters/base-85.js","../src/converters/base-91.js","../src/converters/leb-128.js","../src/converters/ecoji.js","../src/converters/base-2048.js","../src/converters/simple-base.js","../lib/big.js/big.min.js","../src/converters/base-phi.js","../src/converters/byte-converter.js","../src/base-ex.js"],"sourcesContent":["/**\n * Simple Input Handler.\n * --------------------\n * Accepts only bytes eg. TypedArray, ArrayBuffer,\n * DataView, also a regular array (filled with integers)\n * is possible.\n */\nclass BytesInput {\n static toBytes(input) {\n if (ArrayBuffer.isView(input)) {\n input = input.buffer;\n } \n return [new Uint8Array(input), false, \"bytes\"];\n }\n}\n\n/**\n * Simple Output Handler.\n * ---------------------\n * Returns bytes in the form of:\n * - ArrayBuffer\n * - Uint8Array\n * - DataView \n */\nclass BytesOutput {\n\n static get typeList() {\n return [\n \"buffer\",\n \"bytes\",\n \"uint8\",\n \"view\"\n ];\n }\n\n static getType(type) {\n if (!BytesOutput.typeList.includes(type)) {\n throw new TypeError(`Unknown output type: '${type}'`);\n }\n return type;\n }\n\n static compile(Uint8ArrayOut, type) {\n type = BytesOutput.getType(type);\n let compiled;\n\n if (type === \"buffer\") {\n compiled = Uint8ArrayOut.buffer;\n } \n\n else if (type === \"view\") {\n compiled = new DataView(Uint8ArrayOut.buffer);\n }\n\n else {\n compiled = Uint8ArrayOut;\n }\n \n return compiled;\n }\n}\n\n\n/**\n * Advanced Input Handler.\n * ----------------------\n * Accepts almost every Input and converts it\n * into an Uint8Array (bytes).\n */\nclass SmartInput {\n\n static makeDataView(byteLen) {\n const buffer = new ArrayBuffer(byteLen);\n return new DataView(buffer);\n }\n\n static floatingPoints(input, littleEndian=false) {\n const view = this.makeDataView(8);\n view.setFloat64(0, input, littleEndian);\n return view;\n }\n\n static numbers(input, littleEndian=false) {\n\n let view;\n let type;\n\n // Integer\n if (Number.isInteger(input)) {\n\n type = \"int\";\n\n if (!Number.isSafeInteger(input)) {\n \n let safeInt;\n let smallerOrBigger;\n let minMax;\n\n if (input < 0) {\n safeInt = Number.MIN_SAFE_INTEGER;\n smallerOrBigger = \"smaller\";\n minMax = \"MIN\";\n } else {\n safeInt = Number.MAX_SAFE_INTEGER;\n smallerOrBigger = \"bigger\";\n minMax = \"MAX\";\n }\n\n throw new RangeError(`The provided integer is ${smallerOrBigger} than ${minMax}_SAFE_INTEGER: '${safeInt}'\\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`);\n }\n\n // Signed Integer\n if (input < 0) {\n \n // 64 bit\n if (input < -2147483648) {\n view = this.makeDataView(8);\n view.setBigInt64(0, BigInt(input), littleEndian);\n }\n \n // 32 littleEndian\n else if (input < -32768) {\n view = this.makeDataView(4);\n view.setInt32(0, input, littleEndian);\n }\n\n // 16 littleEndian\n else {\n view = this.makeDataView(2);\n view.setInt16(0, input, littleEndian);\n }\n }\n\n // Unsigned Integer\n else if (input > 0) {\n\n // 64 bit\n if (input > 4294967295) {\n view = this.makeDataView(8);\n view.setBigUint64(0, BigInt(input), littleEndian);\n }\n \n // 32 bit\n else if (input > 65535) {\n view = this.makeDataView(4);\n view.setUint32(0, input, littleEndian);\n }\n \n // 16 bit\n else {\n view = this.makeDataView(2);\n view.setInt16(0, input, littleEndian);\n }\n }\n\n // Zero\n else {\n view = new Uint16Array([0]);\n }\n }\n \n // Floating Point Number:\n else {\n type = \"float\";\n view = this.floatingPoints(input, littleEndian);\n }\n\n return [new Uint8Array(view.buffer), type];\n\n }\n\n\n static bigInts(input, littleEndian=false) {\n // Since BigInts are not limited to 64 bits, they might\n // overflow the BigInt64Array values. A little more \n // handwork is therefore needed.\n\n // as the integer size is not known yet, the bytes get a\n // makeshift home \"byteArray\", which is a regular array\n\n const byteArray = new Array();\n const append = (littleEndian) ? \"push\" : \"unshift\";\n const maxN = 18446744073709551616n;\n\n // split the input into 64 bit integers\n if (input < 0) {\n while (input < -9223372036854775808n) {\n byteArray[append](input % maxN);\n input >>= 64n;\n }\n } else { \n while (input >= maxN) {\n byteArray[append](input % maxN);\n input >>= 64n;\n }\n }\n\n // append the remaining byte\n byteArray[append](input);\n\n // determine the required size for the typed array\n // by taking the amount of 64 bit integers * 8\n // (8 bytes for each 64 bit integer)\n const byteLen = byteArray.length * 8;\n \n // create a fresh data view\n const view = this.makeDataView(byteLen);\n\n // set all 64 bit integers \n byteArray.forEach((bigInt, i) => {\n const offset = i * 8;\n view.setBigUint64(offset, bigInt, littleEndian);\n });\n\n return new Uint8Array(view.buffer);\n }\n\n\n static toBytes(input, settings) {\n\n let inputUint8;\n let negative = false;\n let type = \"bytes\";\n \n // Buffer:\n if (input instanceof ArrayBuffer) {\n inputUint8 = new Uint8Array(input.slice());\n }\n\n // TypedArray or DataView:\n else if (ArrayBuffer.isView(input)) {\n inputUint8 = new Uint8Array(input.buffer.slice());\n }\n \n // String:\n else if (typeof input === \"string\" || input instanceof String) {\n inputUint8 = new TextEncoder().encode(input);\n }\n \n // Number:\n else if (typeof input === \"number\") {\n if (isNaN(input)) {\n throw new TypeError(\"Cannot proceed. Input is NaN.\");\n } else if (input == Infinity) {\n throw new TypeError(\"Cannot proceed. Input is Infinity.\");\n }\n\n if (settings.signed && input < 0) {\n negative = true;\n input = -input;\n }\n\n if (settings.numberMode) {\n const view = this.floatingPoints(input, settings.littleEndian);\n inputUint8 = new Uint8Array(view.buffer);\n type = \"float\";\n } else {\n [inputUint8, type] = this.numbers(input, settings.littleEndian);\n }\n }\n\n // BigInt:\n else if (typeof input === \"bigint\") {\n if (settings.signed && input < 0) {\n negative = true;\n input *= -1n;\n }\n inputUint8 = this.bigInts(input, settings.littleEndian);\n type = \"int\";\n }\n\n // Array\n else if (Array.isArray(input)) {\n const collection = new Array();\n for (const elem of input) {\n collection.push(...this.toBytes(elem, settings)[0]);\n }\n inputUint8 = Uint8Array.from(collection);\n }\n\n else {\n throw new TypeError(\"The provided input type can not be processed.\");\n }\n\n return [inputUint8, negative, type];\n }\n}\n\n/** \n * Advanced Output Handler.\n * ----------------------- \n * This Output handler makes it possible to\n * convert an Uint8Array (bytes) into a desired\n * format of a big variety.\n * \n * The default output is an ArrayBuffer.\n */\nclass SmartOutput {\n\n static get typeList() {\n return [\n \"bigint64\",\n \"bigint_n\",\n \"biguint64\",\n \"buffer\",\n \"bytes\",\n \"float32\",\n \"float64\",\n \"float_n\",\n \"int8\",\n \"int16\",\n \"int32\",\n \"int_n\",\n \"str\",\n \"uint8\",\n \"uint16\",\n \"uint32\",\n \"uint_n\",\n \"view\"\n ];\n }\n\n static getType(type) {\n if (!this.typeList.includes(type)) {\n throw new TypeError(`Unknown output type: '${type}'`);\n }\n return type;\n }\n\n static makeTypedArrayBuffer(Uint8ArrayOut, bytesPerElem, littleEndian, negative) {\n \n const len = Uint8ArrayOut.byteLength;\n const delta = (bytesPerElem - (Uint8ArrayOut.byteLength % bytesPerElem)) % bytesPerElem;\n const newLen = len + delta;\n \n // if the array is negative and the len is gt 1\n // fill the whole array with 255\n const fillVal = (negative && len > 1) ? 255 : 0;\n\n let newArray = Uint8ArrayOut;\n\n if (delta) {\n newArray = new Uint8Array(newLen);\n newArray.fill(fillVal);\n \n const offset = (littleEndian) ? 0 : delta;\n newArray.set(Uint8ArrayOut, offset)\n }\n\n\n return newArray.buffer;\n }\n\n static makeTypedArray(inArray, type, littleEndian, negative) {\n let outArray;\n\n if (type === \"int16\" || type === \"uint16\") {\n\n const buffer = this.makeTypedArrayBuffer(inArray, 2, littleEndian, negative);\n outArray = (type === \"int16\") ? new Int16Array(buffer) : new Uint16Array(buffer);\n\n } else if (type === \"int32\" || type === \"uint32\" || type === \"float32\") {\n\n const buffer = this.makeTypedArrayBuffer(inArray, 4, littleEndian, negative);\n \n if (type === \"int32\") {\n outArray = new Int32Array(buffer);\n } else if (type === \"uint32\") {\n outArray = new Uint32Array(buffer);\n } else {\n outArray = new Float32Array(buffer);\n }\n\n } else if (type === \"bigint64\" || type === \"biguint64\" || type === \"float64\") {\n \n const buffer = this.makeTypedArrayBuffer(inArray, 8, littleEndian, negative);\n \n if (type === \"bigint64\") {\n outArray = new BigInt64Array(buffer);\n } else if (type === \"biguint64\") {\n outArray = new BigUint64Array(buffer);\n } else {\n outArray = new Float64Array(buffer);\n }\n }\n\n return outArray;\n }\n\n static compile(Uint8ArrayOut, type, littleEndian=false, negative=false) {\n type = this.getType(type);\n let compiled;\n\n // If the array is negative (which is only\n // true for signed encoding) get the positive\n // decimal number first and feed it with a \n // negative sign to SmartInput to construct\n // the unsigned output which is not shortened.\n\n if (negative) {\n let n;\n if (type.match(/^float/)) {\n n = -(this.compile(Uint8ArrayOut, \"float_n\", littleEndian));\n } else {\n n = -(this.compile(Uint8ArrayOut, \"uint_n\", littleEndian));\n }\n if (type === \"float_n\") {\n return n;\n }\n Uint8ArrayOut = SmartInput.toBytes(n, {littleEndian, numberMode: false, signed: false})[0];\n }\n\n if (type === \"buffer\") {\n compiled = Uint8ArrayOut.buffer;\n } \n \n else if (type === \"bytes\" || type === \"uint8\") {\n compiled = Uint8ArrayOut;\n }\n \n else if (type === \"int8\") {\n compiled = new Int8Array(Uint8ArrayOut.buffer);\n } \n \n else if (type === \"view\") {\n compiled = new DataView(Uint8ArrayOut.buffer);\n }\n \n else if (type === \"str\") {\n compiled = new TextDecoder().decode(Uint8ArrayOut);\n }\n \n else if (type === \"uint_n\" || type === \"int_n\" || type === \"bigint_n\") {\n\n // If the input consists of only one byte, expand it\n if (Uint8ArrayOut.length === 1) {\n const uint16Buffer = this.makeTypedArrayBuffer(Uint8ArrayOut, 2, littleEndian, negative);\n Uint8ArrayOut = new Uint8Array(uint16Buffer);\n }\n \n if (littleEndian) {\n Uint8ArrayOut.reverse();\n }\n\n // calculate a unsigned big integer\n let n = 0n;\n Uint8ArrayOut.forEach((b) => n = (n << 8n) + BigInt(b));\n\n // convert to signed int if requested \n if (type !== \"uint_n\") {\n n = BigInt.asIntN(Uint8ArrayOut.length*8, n);\n }\n \n // convert to regular number if possible (and no bigint was requested)\n if (type !== \"bigint_n\" && n >= Number.MIN_SAFE_INTEGER && n <= Number.MAX_SAFE_INTEGER) { \n compiled = Number(n);\n } else {\n compiled = n;\n }\n } \n \n else if (type === \"float_n\") {\n\n if (Uint8ArrayOut.length <= 4) {\n \n let array;\n if (Uint8ArrayOut.length === 4) {\n array = Uint8ArrayOut;\n } else {\n array = this.makeTypedArray(Uint8ArrayOut, \"float32\", false, negative);\n }\n\n const view = new DataView(array.buffer);\n compiled = view.getFloat32(0, littleEndian);\n \n }\n \n else if (Uint8ArrayOut.length <= 8) {\n \n let array;\n if (Uint8ArrayOut.length === 8) {\n array = Uint8ArrayOut;\n } else {\n array = this.makeTypedArray(Uint8ArrayOut, \"float64\", false, negative);\n }\n\n const view = new DataView(array.buffer);\n compiled = view.getFloat64(0, littleEndian);\n \n }\n\n else {\n throw new RangeError(\"The provided input is to complex to be converted into a floating point.\")\n }\n }\n\n else if (type === \"number\") {\n if (Uint8ArrayOut.length !== 8) {\n throw new TypeError(\"Type mismatch. Cannot convert into number.\");\n }\n\n const float64 = new Float64Array(Uint8ArrayOut.buffer);\n compiled = Number(float64);\n }\n\n else {\n compiled = this.makeTypedArray(Uint8ArrayOut, type, littleEndian, negative);\n } \n\n return compiled;\n }\n}\n\nexport { BytesInput, BytesOutput, SmartInput, SmartOutput };\n","import { BytesInput, BytesOutput, SmartInput, SmartOutput } from \"./io-handlers.js\";\n\nconst DEFAULT_INPUT_HANDLER = SmartInput;\nconst DEFAULT_OUTPUT_HANDLER = SmartOutput;\n\nclass SignError extends TypeError {\n constructor() {\n super(\"The input is signed but the converter is not set to treat input as signed.\\nYou can pass the string 'signed' to the decode function or when constructing the converter.\");\n this.name = \"SignError\";\n }\n}\n\nclass DecodingError extends TypeError {\n constructor(char, msg=null) {\n if (msg === null) {\n msg = `Character '${char}' is not part of the charset.`;\n }\n super(msg);\n this.name = \"DecodingError\";\n }\n}\n\n\n/**\n * Utilities for every BaseEx class.\n * --------------------------------\n * Requires IO Handlers\n */\nclass Utils {\n\n constructor(main) {\n\n // Store the calling class in this.root\n // for accessability.\n this.root = main;\n \n // set specific args object for converters\n this.converterArgs = {};\n\n // If charsets are uses by the parent class,\n // add extra functions for the user.\n\n this.#charsetUserToolsConstructor();\n }\n\n setIOHandlers(inputHandler=DEFAULT_INPUT_HANDLER, outputHandler=DEFAULT_OUTPUT_HANDLER) {\n this.inputHandler = inputHandler;\n this.outputHandler = outputHandler;\n }\n\n\n /**\n * Constructor for the ability to add a charset and \n * change the default version.\n */\n #charsetUserToolsConstructor() {\n\n /**\n * Save method to add a charset.\n * @param {string} name - \"Charset name.\"\n * @param {[string|set|array]} - \"Charset\"\n */\n this.root.addCharset = (name, _charset, _padChars=[], info=true) => {\n\n const normalize = (typeName, set, setLen) => {\n\n if (setLen === 0 && set.length) {\n console.warn(`This converter has no ${typeName}. The following argument was ignored:\\n'${set}'`);\n return [];\n }\n\n let inputLen = setLen;\n\n if (typeof set === \"string\") {\n set = [...set];\n }\n \n if (Array.isArray(set)) {\n \n // Store the input length of the input\n inputLen = set.length;\n \n // Convert to \"Set\" -> eliminate duplicates\n // If duplicates are found the length of the\n // Set and the length of the initial input\n // differ.\n\n set = new Set(set);\n\n } else if (!(set instanceof Set)) {\n throw new TypeError(`The ${typeName} must be one of the types:\\n'str', 'set', 'array'.\"`);\n }\n \n if (set.size === setLen) {\n return [...set];\n }\n \n if (inputLen !== setLen) {\n throw new Error(`Your ${typeName} has a length of ${inputLen}. The converter requires a length of ${setLen}.`);\n } else {\n const charAmounts = {};\n _charset = [..._charset];\n _charset.forEach(c => {\n if (c in charAmounts) {\n charAmounts[c]++;\n } else {\n charAmounts[c] = 1;\n }\n })\n \n let infoStr = \"\";\n if (setLen < 100) {\n infoStr = `${_charset.join(\"\")}\\n`;\n _charset.forEach(c => {\n if (charAmounts[c] > 1) {\n infoStr += \"^\";\n } else {\n infoStr += \" \";\n }\n });\n }\n const rChars = Object.keys(charAmounts).filter(c => charAmounts[c] > 1);\n throw new Error(`You have repetitive char(s) [ ${rChars.join(\" | \")} ] in your ${typeName}. Make sure each character is unique.\\n${infoStr}`);\n }\n }\n\n if (this.root.frozenCharsets) {\n throw new Error(\"The charsets of this converter cannot be changed.\");\n }\n\n if (typeof name !== \"string\") {\n throw new TypeError(\"The charset name must be a string.\");\n }\n\n if (info && name in this.root.charsets) {\n console.warn(`An existing charset with name ${name} will get replaced.`);\n }\n\n const charset = normalize(\"charset\", _charset, this.root.converter.radix);\n const padChars = normalize(\"padding set\", _padChars, this.root.padCharAmount);\n\n this.root.charsets[name] = charset;\n if (padChars.length) {\n this.root.padChars[name] = padChars\n }\n\n if (info) {\n console.info(`New charset '${name}' was added and is ready to use`);\n }\n }\n\n // Save method (argument gets validated) to \n // change the default version.\n this.root.setDefaultCharset = (version) => {\n if (!(version in this.root.charsets)) {\n const sets = Object.keys(this.root.charsets).join(\"\\n * \");\n const msg = `Charset ${version} was not found. Available charsets are:\\n * ${sets}`;\n throw new TypeError(msg);\n }\n this.root.version = version;\n }\n }\n\n /**\n * Argument lists for error messages.\n * @param {string[]} args \n * @returns string - Arguments joined as a string. \n */\n #makeArgList(args) {\n return args.map(s => `'${s}'`).join(\", \");\n }\n\n /**\n * Removes all padded zeros a the start of the string,\n * adds a \"-\" if value is negative.\n * @param {string} output - Former output.\n * @param {boolean} negative - Indicates a negative value if true.\n * @returns {string} - Output without zero padding and a sign if negative.\n */\n toSignedStr(output, negative) {\n\n output = output.replace(/^0+(?!$)/, \"\");\n\n if (negative) {\n output = \"-\".concat(output);\n }\n\n return output;\n }\n\n /**\n * Analyzes the input for a negative sign.\n * If a sign is found, it gets removed but\n * negative bool gets true;\n * @param {string} input - Input number as a string. \n * @returns {array} - Number without sign and negativity indication bool.\n */\n extractSign(input) {\n let negative = false;\n if (input[0] === \"-\") {\n negative = true;\n input = input.slice(1);\n }\n\n return [input, negative];\n }\n\n /**\n * All possible error messages for invalid arguments,\n * gets adjusted according to the converter settings.\n * @param {string} arg - Argument. \n * @param {string[]} versions - Charset array. \n * @param {string[]} outputTypes - Array of output types. \n * @param {boolean} initial - Indicates if the arguments where passed during construction. \n */\n #invalidArgument(arg, versions, outputTypes, initial) {\n const loopConverterArgs = () => Object.keys(this.converterArgs).map(\n key => this.converterArgs[key].map(\n keyword => `'${keyword}'`\n )\n .join(\" and \")\n )\n .join(\"\\n - \");\n \n throw new TypeError([\n `'${arg}'\\n\\nParameters:`,\n initial ? \"\\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'\" : \"\",\n this.root.isMutable.signed ? \"\\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers\" : \"\",\n this.root.isMutable.littleEndian ? \"\\n * 'be' for big , 'le' for little endian byte order for case conversion\" : \"\",\n this.root.isMutable.padding ? \"\\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding\" : \"\",\n this.root.isMutable.upper ? \"\\n * valid args for changing the encoded output case are 'upper' and 'lower'\" : \"\",\n `\\n * valid args for the output type are ${this.#makeArgList(outputTypes)}`,\n versions ? `\\n * the option(s) for version/charset are: ${this.#makeArgList(versions)}` : \"\",\n \"\\n * valid args for integrity check are: 'integrity' and 'nointegrity'\",\n this.root.hasDecimalMode ? \"\\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)\" : \"\",\n \"\\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)\",\n Object.keys(this.converterArgs).length ? `\\n * converter specific args:\\n - ${loopConverterArgs()}` : \"\",\n \"\\n\\nTraceback:\"\n ].join(\"\"));\n }\n\n\n /**\n * Test if provided arguments are in the argument list.\n * Everything gets converted to lowercase and returned.\n * @param {string[]} args - Passed arguments. \n * @param {boolean} initial - Indicates if the arguments where passed during construction. \n * @returns {Object} - Converter settings object.\n */\n validateArgs(args, initial=false) {\n \n // default settings\n const parameters = {\n decimalMode: this.root.decimalMode,\n integrity: this.root.integrity,\n littleEndian: this.root.littleEndian,\n numberMode: this.root.numberMode,\n options: this.root.options,\n outputType: this.root.outputType,\n padding: this.root.padding,\n signed: this.root.signed,\n upper: this.root.upper,\n version: this.root.version\n }\n\n // add any existing converter specific args\n for (const param in this.converterArgs) {\n parameters[param] = this.root[param];\n }\n\n // if no args are provided return the default settings immediately\n if (!args.length) {\n\n // if initial call set default IO handlers\n if (initial) {\n this.setIOHandlers();\n }\n \n return parameters;\n }\n\n // Helper function to test the presence of a \n // particular arg. If found, true is returned\n // and it gets removed from the array.\n const extractArg = (arg) => {\n if (args.includes(arg)) {\n args.splice(args.indexOf(arg), 1);\n return true;\n }\n return false;\n }\n\n // set available versions and extra arguments\n const versions = Object.keys(this.root.charsets);\n const extraArgList = {\n integrity: [\"nointegrity\", \"integrity\"],\n littleEndian: [\"be\", \"le\"],\n padding: [\"nopad\", \"pad\"],\n signed: [\"unsigned\", \"signed\"],\n upper: [\"lower\", \"upper\"],\n ...this.converterArgs\n }\n\n // if initial, look for IO specifications\n if (initial) {\n if (extractArg(\"bytes_only\")) {\n this.setIOHandlers(BytesInput, BytesOutput);\n } else {\n const inHandler = (extractArg(\"bytes_in\")) ? BytesInput : DEFAULT_INPUT_HANDLER;\n const outHandler = (extractArg(\"bytes_out\")) ? BytesOutput : DEFAULT_OUTPUT_HANDLER;\n this.setIOHandlers(inHandler, outHandler);\n }\n }\n\n // set valid output types\n const outputTypes = this.outputHandler.typeList;\n\n // test for special \"number\" keyword\n if (extractArg(\"number\")) {\n parameters.numberMode = true;\n parameters.outputType = \"float_n\";\n } \n \n // test for the special \"decimal\" keyword\n if (extractArg(\"decimal\")) {\n if (!this.root.hasDecimalMode) {\n throw TypeError(`Argument 'decimal' is only allowed for converters with a non-integer base.`);\n }\n parameters.decimalMode = true;\n parameters.outputType = \"decimal\";\n\n if (parameters.numberMode) {\n parameters.numberMode = false;\n console.warn(\"-> number-mode was disabled due to the decimal-mode\");\n }\n }\n\n // walk through the remaining arguments\n args.forEach((arg) => {\n \n // additional/optional non boolean options\n if (typeof arg === \"object\") {\n parameters.options = {...parameters.options, ...arg};\n return;\n }\n\n arg = String(arg).toLowerCase();\n\n if (versions.includes(arg)) {\n parameters.version = arg;\n } else if (outputTypes.includes(arg)) {\n parameters.outputType = arg;\n } else {\n // set invalid args to true for starters\n // if a valid arg is found later it will\n // get changed\n\n let invalidArg = true;\n\n // walk through the mutable parameter list\n\n for (const param in extraArgList) {\n \n if (extraArgList[param].includes(arg)) {\n \n invalidArg = false;\n\n // extra params always have two options\n // they are converted into booleans \n // index 0 > false\n // index 1 > true\n\n if (this.root.isMutable[param]) {\n parameters[param] = Boolean(extraArgList[param].indexOf(arg));\n } else {\n throw TypeError(`Argument '${arg}' is not allowed for this type of converter.`);\n }\n }\n }\n\n if (invalidArg) {\n this.#invalidArgument(arg, versions, outputTypes, initial);\n }\n }\n });\n\n // If padding and signed are true, padding\n // is set to false and a warning is getting\n // displayed.\n if (parameters.padding && parameters.signed) {\n parameters.padding = false;\n console.warn(\"-> padding was set to false due to the signed conversion\");\n }\n \n // overwrite the default parameters for the initial call\n if (initial) {\n for (const param in parameters) {\n this.root[param] = parameters[param];\n }\n }\n\n return parameters;\n }\n\n /**\n * A TypeError specifically for sign errors.\n */\n signError() {\n throw new SignError();\n }\n\n /**\n * Wrap output to \"cols\" characters per line.\n * @param {string} output - Output string. \n * @param {number} cols - Number of cols per line. \n * @returns {string} - Wrapped output.\n */\n wrapOutput(output, cols=0) {\n if (!cols) {\n return output;\n }\n const m = new RegExp(`.{1,${cols}}`, \"gu\");\n return output.match(m).join(\"\\n\");\n }\n\n /**\n * Ensures a string input.\n * @param {*} input - Input.\n * @param {boolean} [keepWS=false] - If set to false, whitespace is getting removed from the input if present.\n * @returns {string} - Normalized input.\n */\n normalizeInput(input, keepWS=false) {\n if (keepWS) {\n return String(input);\n }\n return String(input).replace(/\\s/g, \"\");\n }\n\n}\n\nexport {\n DEFAULT_INPUT_HANDLER,\n DEFAULT_OUTPUT_HANDLER,\n DecodingError,\n Utils\n};\n","import { DecodingError, Utils } from \"./utils.js\";\n\n\n/**\n * BaseEx Base Converter.\n * ---------------------\n * Core class for base-conversion and substitution\n * based on a given charset.\n */\nclass BaseConverter {\n\n /**\n * BaseEx BaseConverter Constructor.\n * @param {number} radix - Radix for the converter.\n * @param {number} [bsEnc] - Block Size (input bytes grouped by bs) for encoding (if zero the integer has no limitation).\n * @param {number} [bsDec] - Block Size (input bytes grouped by bs) for decoding (if zero the integer has no limitation).\n * @param {number} [decPadVal=0] - Value used for padding during decoding.\n */\n constructor(radix, bsEnc=null, bsDec=null, decPadVal=0) {\n \n this.radix = radix;\n\n if (bsEnc !== null && bsDec !== null) {\n this.bsEnc = bsEnc;\n this.bsDec = bsDec;\n } else {\n [this.bsEnc, this.bsDec] = this.constructor.guessBS(radix);\n }\n\n this.decPadVal = decPadVal;\n this.powers = {};\n }\n\n /**\n * Experimental feature!\n * Calc how many bits are needed to represent\n * 256 conditions (1 byte). If the radix is \n * less than 8 bits, skip that part and use\n * the radix value directly.\n */\n static guessBS(radix) {\n\n let bsDecPre = (radix < 8) ? radix : Math.ceil(256 / radix);\n \n // If the result is a multiple of 8 it\n // is appropriate to reduce the result\n\n while (bsDecPre > 8 && !(bsDecPre % 8)) {\n bsDecPre /= 8;\n }\n\n // Search for the amount of bytes, which are necessary\n // to represent the assumed amount of bytes. If the result\n // is equal or bigger than the assumption for decoding, the\n // amount of bytes for encoding is found. \n\n let bsEnc = 0;\n while (((bsEnc * 8) * Math.log(2) / Math.log(radix)) < bsDecPre) {\n bsEnc++;\n }\n\n // The result for decoding can now get calculated accurately.\n const bsDec = Math.ceil((bsEnc * 8) * Math.log(2) / Math.log(radix));\n\n return [bsEnc, bsDec];\n }\n\n\n /**\n * BaseEx Universal Base Encoding.\n * @param {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} inputBytes - Input as Uint8Array.\n * @param {string} charset - The charset used for conversion.\n * @param {boolean} littleEndian - Byte order, little endian bool.\n * @param {function} replacer - Replacer function can replace groups of characters during encoding.\n * @returns {number[]} - Output string and padding amount. \n */\n encode(inputBytes, charset, littleEndian=false, replacer=null) {\n\n // Initialize output string and set yet unknown\n // zero padding to zero.\n let bs = this.bsEnc;\n if (bs === 0) {\n bs = inputBytes.byteLength;\n }\n\n let output = \"\";\n\n const zeroPadding = (bs) ? (bs - inputBytes.length % bs) % bs : 0;\n const zeroArray = new Array(zeroPadding).fill(0);\n let byteArray;\n \n if (littleEndian) {\n \n // as the following loop walks through the array\n // from left to right, the input bytes get reversed\n // to favor the least significant first\n\n inputBytes.reverse();\n byteArray = [...zeroArray, ...inputBytes];\n } else {\n byteArray = [...inputBytes, ...zeroArray];\n }\n \n // Iterate over the input array in groups with the length\n // of the given blocksize.\n\n // If the radix is 10, make a shortcut here by converting\n // all bytes into the decimal number \"n\" and return the\n // result as a string.\n if (this.radix === 10) {\n let n = 0n;\n \n for (let i=0; i= this.radix) {\n [q, r] = this.divmod(q, this.radix);\n bXarray.unshift(parseInt(r, 10));\n }\n\n // Append the remaining quotient to the array\n bXarray.unshift(parseInt(q, 10));\n\n // If the length of the array is less than the\n // given output bs, it gets filled up with zeros.\n // (This happens in groups of null bytes)\n \n while (bXarray.length < this.bsDec) {\n bXarray.unshift(0);\n }\n\n // Each digit is used as an index to pick a \n // corresponding char from the charset. The \n // chars get concatenated and stored in \"frame\".\n\n let frame = \"\";\n bXarray.forEach(\n charIndex => frame = frame.concat(charset[charIndex])\n );\n\n // Ascii85 is replacing four consecutive \"!\" into \"z\"\n // Also other replacements can be implemented and used\n // at this point.\n if (replacer) {\n frame = replacer(frame, zeroPadding);\n }\n\n output = output.concat(frame);\n }\n\n // The output string is returned. Also the amount \n // of padded zeros. The specific class decides how \n // to handle the padding.\n\n return [output, zeroPadding];\n }\n\n\n /**\n * BaseEx Universal Base Decoding.\n * Decodes to a string of the given radix to a byte array.\n * @param {string} inputBaseStr - Base as string (will also get converted to string but can only be used if valid after that).\n * @param {string[]} charset - The charset used for conversion.\n * @param {string[]} padSet - Padding characters for integrity check.\n * @param {boolean} integrity - If set to false invalid character will be ignored.\n * @param {boolean} littleEndian - Byte order, little endian bool.\n * @returns {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} - The decoded output as Uint8Array.\n */\n decode(inputBaseStr, charset, padSet=[], integrity=true, littleEndian=false) {\n\n // Convert each char of the input to the radix-integer\n // (this becomes the corresponding index of the char\n // from the charset). Every char, that is not found in\n // in the set is getting ignored.\n\n if (!inputBaseStr) {\n return new Uint8Array(0);\n }\n\n let bs = this.bsDec;\n const byteArray = [];\n \n [...inputBaseStr].forEach(c => {\n const index = charset.indexOf(c);\n if (index > -1) { \n byteArray.push(index);\n } else if (integrity && padSet.indexOf(c) === -1) {\n throw new DecodingError(c);\n }\n });\n\n \n let padChars;\n\n if (bs === 0) {\n bs = byteArray.length;\n } else {\n padChars = (bs - byteArray.length % bs) % bs;\n const fillArray = new Array(padChars).fill(this.decPadVal);\n if (littleEndian) {\n byteArray.unshift(...fillArray);\n } else {\n byteArray.push(...fillArray);\n }\n }\n\n // Initialize a new default array to store\n // the converted radix-256 integers.\n\n let b256Array = new Array();\n\n // Iterate over the input bytes in groups of \n // the blocksize.\n\n for (let i=0, l=byteArray.length; i {\n this.powers[exp] = BigInt(this.pow(exp));\n return this.powers[exp];\n })();\n\n n += BigInt(byteArray[i+j]) * pow;\n }\n \n // To store the output chunks, initialize a\n // new default array.\n const subArray256 = [];\n\n // The subarray gets converted into a bs*8-bit \n // binary number \"n\", most significant byte \n // first (big endian).\n\n // Initialize quotient and remainder for base conversion\n let q = n, r;\n\n // Divide n until the quotient is less than 256.\n while (q >= 256) {\n [q, r] = this.divmod(q, 256);\n subArray256.unshift(parseInt(r, 10));\n }\n\n // Append the remaining quotient to the array\n subArray256.unshift(parseInt(q, 10));\n \n // If the length of the array is less than the required\n // bs after decoding it gets filled up with zeros.\n // (Again, this happens with null bytes.)\n\n while (subArray256.length < this.bsEnc) {\n subArray256.unshift(0);\n }\n \n // The subarray gets concatenated with the\n // main array.\n b256Array.push(...subArray256);\n }\n\n // Remove padded zeros (or in case of LE all leading zeros)\n\n if (littleEndian) {\n if (b256Array.length > 1) {\n \n // remove all zeros from the start of the array\n while (!b256Array[0]) {\n b256Array.shift(); \n }\n \n if (!b256Array.length) {\n b256Array.push(0);\n }\n\n b256Array.reverse();\n }\n } else if (this.bsDec) {\n const padding = this.padChars(padChars);\n\n // remove all bytes according to the padding\n b256Array.splice(b256Array.length-padding);\n }\n\n return Uint8Array.from(b256Array);\n }\n\n\n /**\n * Calculates the amount of bytes, which are padding bytes. \n * @param {number} charCount - Pass the amount of characters, which were added during encoding. \n * @returns {number} - Amount of padding characters.\n */\n padBytes(charCount) {\n return Math.floor((charCount * this.bsDec) / this.bsEnc);\n }\n\n /**\n * Calculates the amount of bytes which can get removed\n * from the decoded output bytes. \n * @param {number} byteCount - Added bytes for padding \n * @returns {number} - Amount of output bytes to be removed.\n */\n padChars(byteCount) {\n return Math.ceil((byteCount * this.bsEnc) / this.bsDec);\n }\n\n\n /**\n * Calculates the power for the current base\n * according to the given position as BigInt.\n * \n * @param {number} n - Position \n * @returns {BigInt} - BigInt power value\n */\n pow(n) {\n return BigInt(this.radix)**BigInt(n);\n }\n\n\n /**\n * Divmod function, which returns the results as\n * an array of two BigInts.\n * @param {*} x - Dividend\n * @param {*} y - Divisor\n * @returns {number[]} - [Quotient, Remainder]\n */\n divmod(x, y) {\n [x, y] = [BigInt(x), BigInt(y)];\n return [(x / y), (x % y)];\n }\n}\n\n\n/**\n * Base of every BaseConverter. Provides basic\n * en- and decoding, makes sure, that every \n * property is set (to false by default).\n * Also allows global feature additions.\n * \n * Requires BaseEx Utils\n */\nclass BaseTemplate {\n\n /**\n * BaseEx BaseTemplate Constructor.\n * @param {boolean} appendUtils - If set to false, the utils are not getting used. \n */\n constructor(appendUtils=true) {\n\n // predefined settings\n this.charsets = {};\n this.decimalMode = false;\n this.frozenCharsets = false;\n this.hasDecimalMode = false;\n this.hasSignedMode = false;\n this.integrity = true;\n this.littleEndian = false;\n this.numberMode = false;\n this.outputType = \"buffer\";\n this.padding = false;\n this.padCharAmount = 0;\n this.padChars = {} \n this.signed = false;\n this.upper = null;\n if (appendUtils) this.utils = new Utils(this);\n this.version = \"default\";\n this.options = {\n lineWrap: 0\n }\n \n // list of allowed/disallowed args to change\n this.isMutable = {\n integrity: true,\n littleEndian: false,\n padding: false,\n signed: false,\n upper: false,\n };\n }\n\n /**\n * BaseEx Generic Encoder.\n * @param {*} input - Any input the used byte converter allows.\n * @param {function} [replacerFN] - Replacer function, which is passed to the encoder. \n * @param {function} [postEncodeFN] - Function, which is executed after encoding.\n * @param {...any} args - Converter settings.\n * @returns {string} - Base encoded string.\n */\n encode(input, replacerFN, postEncodeFN, ...args) {\n\n // apply settings\n const settings = this.utils.validateArgs(args);\n \n // handle input\n let [inputBytes, negative, type] = this.utils.inputHandler.toBytes(input, settings);\n\n // generate replacer function if given\n let replacer = null;\n if (replacerFN) {\n replacer = replacerFN(settings);\n }\n \n // Convert to base string\n let [output, zeroPadding] = this.converter.encode(inputBytes, this.charsets[settings.version], settings.littleEndian, replacer);\n\n // set sign if requested\n if (settings.signed) {\n output = this.utils.toSignedStr(output, negative);\n }\n\n // set upper case if requested\n if (settings.upper) {\n output = output.toUpperCase();\n }\n\n // modify the output based on a given function (optionally)\n if (postEncodeFN) {\n output = postEncodeFN({ inputBytes, output, settings, zeroPadding, type });\n }\n\n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n\n /**\n * BaseEx Generic Decoder.\n * @param {string} input - Base String.\n * @param {function} [preDecodeFN] - Function, which gets executed before decoding. \n * @param {function} [postDecodeFN] - Function, which gets executed after decoding\n * @param {...any} args - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, preDecodeFN, postDecodeFN, keepNL, ...args) {\n \n // apply settings\n const settings = this.utils.validateArgs(args);\n\n // ensure a string input\n input = this.utils.normalizeInput(input, keepNL);\n\n // set negative to false for starters\n let negative = false;\n \n // Test for a negative sign if converter supports it\n if (this.hasSignedMode) {\n [ input, negative ] = this.utils.extractSign(input); \n \n // But don't allow a sign if the decoder is not configured to use it\n if (negative && !settings.signed) {\n this.utils.signError();\n }\n }\n\n // Make the input lower case if alphabet has only one case\n // (single case alphabets are stored as lower case strings)\n if (this.isMutable.upper) {\n input = input.toLowerCase();\n }\n\n // Run pre decode function if provided\n if (preDecodeFN) {\n input = preDecodeFN({ input, settings });\n }\n\n // Run the decoder\n let output = this.converter.decode(\n input,\n this.charsets[settings.version],\n this.padChars[settings.version],\n settings.integrity,\n settings.littleEndian\n );\n\n // Run post decode function if provided\n if (postDecodeFN) {\n output = postDecodeFN({ input, output, settings });\n }\n\n return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative);\n }\n}\n\n\nexport { BaseConverter, BaseTemplate };\n","/**\n * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 1 Converter.\n * -----------------------\n * This is a unary/base1 converter. It is converting input \n * to a decimal number, which is converted into an unary\n * string. Due to the limitations on string (or array) length\n * it is only suitable for the conversions of numbers up to\n * roughly 2^28.\n */\nexport default class Base1 extends BaseTemplate {\n \n /**\n * BaseEx Base1 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // All chars in the string are used and picked randomly (prob. suitable for obfuscation)\n this.charsets.all = [...\" !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\"];\n \n // The sequence is used from left to right again and again\n this.charsets.sequence = [...\"Hello World!\"];\n \n // Standard unary string with one character\n this.charsets.default = [\"1\"];\n\n // Telly Mark string, using hash for 5 and vertical bar for 1 \n this.charsets.tmark = [\"|\", \"#\"];\n\n // Base 10 converter\n this.converter = new BaseConverter(10, 0, 0);\n \n // converter settings\n this.hasSignedMode = true;\n this.littleEndian = true;\n this.signed = true;\n \n // mutable extra args\n this.isMutable.charsets = false;\n this.isMutable.signed = true;\n this.isMutable.upper = true;\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx Base1 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base1 encoded string.\n */\n encode(input, ...args) {\n\n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n \n let inputBytes, negative;\n [inputBytes, negative,] = this.utils.inputHandler.toBytes(input, settings);\n\n // Convert to BaseRadix string\n let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0];\n \n let n = BigInt(base10);\n\n // Limit the input before it even starts.\n // The executing engine will most likely\n // give up much earlier.\n // (2**29-24 during tests)\n\n if (n > Number.MAX_SAFE_INTEGER) {\n throw new RangeError(\"Invalid string length.\");\n } else if (n > 16777216) {\n console.warn(\"The string length is really long. The JavaScript engine may have memory issues generating the output string.\");\n }\n \n n = Number(n);\n \n const charset = this.charsets[settings.version];\n const charAmount = charset.length;\n let output = \"\";\n\n // Convert to unary in respect to the version differences\n if (charAmount === 1) {\n output = charset.at(0).repeat(n)\n } else if (settings.version === \"all\") {\n for (let i=0; i 4) {\n output = charset.at(1).repeat((n - singulars) / 5);\n }\n output += charset.at(0).repeat(singulars);\n } else {\n for (let i=0; i {\n \n // Remove \"0x\" if present\n normInput = normInput.replace(/^0x/, \"\");\n\n // remove non-charset characters if integrity\n // check is disabled\n if (!settings.integrity) {\n normInput = normInput\n .toLowerCase()\n .replace(/[^0-9a-f]/g, \"\");\n }\n\n // Ensure even number of characters\n if (normInput.length % 2) {\n normInput = \"0\".concat(normInput);\n }\n\n return normInput;\n }\n \n return super.decode(input, normalizeInput, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 32 Converter.\n * ------------------------\n * \n * This is a base32 converter. Various input can be \n * converted to a base32 string or a base32 string\n * can be decoded into various formats. It is possible\n * to convert in both signed and unsigned mode in little\n * and big endian byte order.\n * \n * Available charsets are:\n * - RFC 3548\n * - RFC 4648\n * - crockford\n * - zbase32\n */\nexport default class Base32 extends BaseTemplate {\n \n /**\n * BaseEx Base32 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(32, 5, 8);\n\n // charsets\n this.charsets.crockford = [ ...\"0123456789abcdefghjkmnpqrstvwxyz\" ];\n this.padChars.crockford = [\"=\"],\n\n this.charsets.rfc3548 = [...\"abcdefghijklmnopqrstuvwxyz234567\"];\n this.padChars.rfc3548 = [\"=\"];\n\n this.charsets.rfc4648 = [...\"0123456789abcdefghijklmnopqrstuv\"];\n this.padChars.rfc4648 = [\"=\"];\n\n this.charsets.zbase32 = [...\"ybndrfg8ejkmcpqxot1uwisza345h769\"];\n this.padChars.zbase32 = [\"=\"];\n \n // predefined settings\n this.padCharAmount = 1;\n this.hasSignedMode = true;\n this.version = \"rfc4648\";\n \n // mutable extra args\n this.isMutable.littleEndian = true;\n this.isMutable.padding = true;\n this.isMutable.signed = true;\n this.isMutable.upper = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n this.padding = (/rfc3548|rfc4648/).test(this.version);\n this.upper = this.version === \"crockford\";\n }\n \n\n /**\n * BaseEx Base32 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base32 encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n if (!settings.littleEndian) {\n // Cut of redundant chars and append padding if set\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n const padChar = this.padChars[settings.version].at(0);\n output = output.slice(0, -padValue);\n if (settings.padding) { \n output = output.concat(padChar.repeat(padValue));\n }\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base32 Decoder.\n * @param {string} input - Base32 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n return super.decode(input, null, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 58 Converter.\n * ------------------------\n * \n * This is a base58 converter. Various input can be \n * converted to a base58 string or a base58 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - bitcoin\n * - flickr\n */\nexport default class Base58 extends BaseTemplate{\n\n /**\n * BaseEx Base58 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(58, 0, 0);\n\n // charsets\n this.charsets.default = [...\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"];\n Object.defineProperty(this.padChars, \"default\", {\n get: () => [ this.charsets.default.at(0) ]\n });\n\n this.charsets.bitcoin = [...\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\"];\n Object.defineProperty(this.padChars, \"bitcoin\", {\n get: () => [ this.charsets.bitcoin.at(0) ]\n });\n \n this.charsets.flickr = [...\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"];\n Object.defineProperty(this.padChars, \"flickr\", {\n get: () => [ this.charsets.flickr.at(0) ]\n });\n \n\n // predefined settings\n this.padding = true;\n this.version = \"bitcoin\";\n \n // mutable extra args\n this.isMutable.padding = true;\n this.isMutable.signed = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n \n /**\n * BaseEx Base58 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base58 encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ inputBytes, output, settings, type }) => {\n\n if (settings.padding && type !== \"int\") { \n \n // Count all null bytes at the start of the array\n // stop if a byte with a value is reached. If it goes\n // all the way through it, reset index and stop.\n let i = 0;\n const end = inputBytes.length;\n\n // pad char is always! the first char in the set\n const padChar = this.charsets[settings.version].at(0);\n\n // only proceed if input has a length at all\n if (end) {\n while (!inputBytes[i]) {\n i++;\n if (i === end) {\n i = 0;\n break;\n }\n }\n\n // The value for zero padding is the index of the\n // first byte with a value plus one.\n const zeroPadding = i;\n\n // Set a one for every leading null byte\n if (zeroPadding) {\n output = (padChar.repeat(zeroPadding)).concat(output);\n }\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base58 Decoder.\n * @param {string} input - Base58 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // post decoding function\n const applyPadding = ({ input, output, settings }) => {\n\n // pad char is always! the first char in the set\n const padChar = this.charsets[settings.version].at(0);\n\n if (settings.padding && input.length > 1) {\n \n // Count leading padding (char should be 1)\n let i = 0;\n while (input[i] === padChar) {\n i++;\n }\n \n // The counter becomes the zero padding value\n const zeroPadding = i;\n \n // Create a new Uint8Array with leading null bytes \n // with the amount of zeroPadding\n if (zeroPadding) {\n output = Uint8Array.from([...new Array(zeroPadding).fill(0), ...output]);\n }\n \n }\n\n return output;\n }\n\n return super.decode(input, null, applyPadding, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 64 Converter.\n * ------------------------\n * \n * This is a base64 converter. Various input can be \n * converted to a base64 string or a base64 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - urlsafe\n */\nexport default class Base64 extends BaseTemplate {\n\n /**this.padChars.\n * BaseEx Base64 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(64, 3, 4);\n\n // charsets\n this.charsets.default = [...\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"];\n this.padChars.default = [\"=\"];\n \n this.charsets.urlsafe = this.charsets.default.slice(0, -2).concat([\"-\", \"_\"]);\n this.padChars.urlsafe = [\"=\"];\n\n\n // predefined settings\n this.padCharAmount = 1;\n this.padding = true;\n \n // mutable extra args\n this.isMutable.padding = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Base64 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base64 encoded string.\n */\n encode(input, ...args) {\n \n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n // Cut of redundant chars and append padding if set\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n const padChar = this.padChars[settings.version].at(0);\n output = output.slice(0, -padValue);\n if (settings.padding) { \n output = output.concat(padChar.repeat(padValue));\n }\n }\n\n return output;\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n\n /**\n * BaseEx Base64 Decoder.\n * @param {string} input - Base64 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n return super.decode(input, null, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx UUencode Converter.\n * ------------------------\n * \n * This is a UUencoder/UUdecoder. Various input can be \n * converted to a UUencoded string or a UUencoded string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - default\n * - original\n * - xx\n */\nexport default class UUencode extends BaseTemplate {\n\n /**\n * BaseEx UUencode Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(64, 3, 4);\n\n // charsets\n this.charsets.default = [...\"`!\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_\"];\n Object.defineProperty(this.padChars, \"default\", {\n get: () => [ this.charsets.default.at(0) ]\n });\n\n this.charsets.original = [\" \", ...this.charsets.default.slice(1)];\n Object.defineProperty(this.padChars, \"original\", {\n get: () => [ this.charsets.original.at(0) ]\n });\n\n this.charsets.xx = [...\"+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"];\n Object.defineProperty(this.padChars, \"xx\", {\n get: () => [ this.charsets.xx.at(0) ]\n });\n\n\n // predefined settings\n this.padding = true;\n this.header = false;\n this.utils.converterArgs.header = [\"noheader\", \"header\"];\n this.isMutable.header = true;\n this.isMutable.integrity = false;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx UUencoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - UUencode string.\n */\n encode(input, ...args) {\n\n const format = ({ output, settings, zeroPadding }) => {\n\n const charset = this.charsets[settings.version];\n const outArray = [...output];\n \n \n if (settings.header) {\n const permissions = settings.options.permissions || een();\n const fileName = settings.options.file || ees();\n output = `begin ${permissions} ${fileName}\\n`;\n } else {\n output = \"\";\n }\n\n // repeatedly take 60 chars from the output until it is empty \n for (;;) {\n const lArray = outArray.splice(0, 60);\n \n // if all chars are taken, remove eventually added pad zeros\n if (!outArray.length) { \n const byteCount = this.converter.padChars(lArray.length) - zeroPadding;\n \n // add the the current chars plus the leading\n // count char\n output += `${charset.at(byteCount)}${lArray.join(\"\")}\\n`;\n break;\n }\n \n // add the the current chars plus the leading\n // count char (\"M\" for default charsets) \n output += `${charset.at(45)}${lArray.join(\"\")}\\n`;\n }\n\n output += `${charset.at(0)}\\n`;\n\n if (settings.header) {\n output += \"\\nend\";\n }\n\n\n return output;\n }\n \n return super.encode(input, null, format, ...args);\n }\n\n\n /**\n * BaseEx UUdecoder.\n * @param {string} input - UUencode String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n let padChars = 0;\n\n const format = ({ input, settings }) => {\n\n const charset = this.charsets[settings.version];\n const lines = input.trim().split(/\\r?\\n/);\n const inArray = [];\n \n if ((/^begin/i).test(lines.at(0))) {\n lines.shift();\n }\n \n for (const line of lines) {\n const lArray = [...line];\n const byteCount = charset.indexOf(lArray.shift());\n \n if (!(byteCount > 0)) {\n break;\n }\n\n inArray.push(...lArray);\n\n if (byteCount !== 45) { \n padChars = this.converter.padChars(lArray.length) - byteCount;\n break;\n }\n\n // fix probably missing spaces for original charset\n else if (lArray.length !== 60 && settings.version === \"original\") {\n while (inArray.length % 60) {\n inArray.push(\" \");\n }\n }\n }\n\n return inArray.join(\"\");\n\n }\n\n const removePadChars = ({ output }) => {\n if (padChars) {\n output = new Uint8Array(output.slice(0, -padChars));\n }\n return output;\n }\n\n return super.decode(input, format, removePadChars, true, ...args);\n }\n}\n\n\nconst een = () => {\n const o = () => Math.floor(Math.random() * 8);\n return `${o()}${o()}${o()}`;\n}\n\nconst ees = () => {\n const name = [\n \"unchronological\",\n \"unconditionally\",\n \"underemphasized\",\n \"underprivileged\",\n \"undistinguished\",\n \"unsophisticated\",\n \"untitled\",\n \"untitled-1\",\n \"untitled-3\",\n \"uuencode\"\n ];\n\n const ext = [\n \"applescript\",\n \"bat\",\n \"beam\",\n \"bin\",\n \"exe\",\n \"js\",\n \"mam\",\n \"py\",\n \"sh\",\n \"vdo\",\n \"wiz\"\n ];\n\n const pick = (arr) => arr.at(Math.floor(Math.random() * arr.length));\n\n return `${pick(name)}.${pick(ext)}`;\n};\n","/**\n * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n/**\n * BaseEx Base 85 Converter.\n * ------------------------\n * \n * This is a base85 converter. Various input can be \n * converted to a base85 string or a base85 string\n * can be decoded into various formats.\n * \n * Available charsets are:\n * - adobe\n * - ascii85\n * - rfc1924\n * - z85\n * \n * Adobe and ascii85 are the basically the same.\n * Adobe will produce the same output, apart from\n * the <~wrapping~>.\n * \n * Z85 is an important variant, because of the \n * more interpreter-friendly character set.\n * \n * The RFC 1924 version is a hybrid. It is not using\n * the mandatory 128 bit calculation. Instead only \n * the charset is getting used.\n */\nexport default class Base85 extends BaseTemplate {\n\n /**\n * BaseEx Base85 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n this.converter = new BaseConverter(85, 4, 5, 84);\n\n // charsets\n this.charsets.adobe = [...\"!\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstu\"];\n this.charsets.ascii85 = this.charsets.adobe.slice();\n this.charsets.rfc1924 = [...\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~\"];\n this.charsets.z85 = [...\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#\"];\n\n // predefined settings\n this.version = \"ascii85\";\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx Base85 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base85 encoded string.\n */\n encode(input, ...args) {\n\n // Replace five consecutive \"!\" with a \"z\"\n // for adobe and ascii85\n const replacerFN = (settings) => {\n let replacer;\n if (settings.version.match(/adobe|ascii85/)) {\n replacer = (frame, zPad) => (!zPad && frame === \"!!!!!\") ? \"z\" : frame;\n }\n return replacer;\n }\n \n // Remove padded values and add a frame for the\n // adobe variant\n const framesAndPadding = ({ output, settings, zeroPadding }) => {\n\n // Cut of redundant chars\n if (zeroPadding) {\n const padValue = this.converter.padBytes(zeroPadding);\n output = output.slice(0, -padValue);\n }\n\n // Adobes variant gets its <~framing~>\n if (settings.version === \"adobe\") {\n output = `<~${output}~>`;\n }\n \n return output;\n }\n\n return super.encode(input, replacerFN, framesAndPadding, ...args);\n }\n\n\n /**\n * BaseEx Base85 Decoder.\n * @param {string} input - Base85 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n const prepareInput = ({ input, settings }) => {\n\n // For default ascii85 convert \"z\" back to \"!!!!!\"\n // Remove the adobe <~frame~>\n if (settings.version.match(/adobe|ascii85/)) {\n input = input.replace(/z/g, \"!!!!!\");\n if (settings.version === \"adobe\") {\n input = input.replace(/^<~|~>$/g, \"\");\n }\n }\n\n return input\n }\n\n return super.decode(input, prepareInput, null, false, ...args);\n }\n}\n","/**\n * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke)\n */\n\nimport { BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base 91 Converter.\n * ------------------------\n * \n * This is a base91 converter. Various input can be \n * converted to a base91 string or a base91 string\n * can be decoded into various formats.\n * \n * It is an implementation of Joachim Henkes method\n * to encode binary data as ASCII characters -> basE91\n * http://base91.sourceforge.net/\n * \n * As this method requires to split the bytes, the\n * default conversion class \"BaseConverter\" is not\n * getting used in this case.\n */\nexport default class Base91 extends BaseTemplate {\n \n /**\n * BaseEx basE91 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 91,\n bsEnc: 0,\n bsDec: 0\n }\n\n // charsets\n this.charsets.default = [...\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~\\\"\"];\n this.version = \"default\";\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx basE91 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - basE91 encoded string.\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n const inputBytes = this.utils.inputHandler.toBytes(input, settings)[0];\n \n // As this base representation splits the bytes\n // the read bits need to be stores somewhere. \n // This is done in \"bitCount\". \"n\", similar to \n // other solutions here, holds the integer which\n // is converted to the desired base.\n\n let bitCount = 0;\n let n = 0;\n let output = \"\";\n\n const charset = this.charsets[settings.version];\n\n inputBytes.forEach(byte => {\n //n = n + byte * 2^bitcount;\n n += (byte << bitCount);\n\n // Add 8 bits forEach byte\n bitCount += 8;\n \n // If the count exceeds 13 bits, base convert the\n // current frame.\n\n if (bitCount > 13) {\n\n // Set bit amount \"count\" to 13, check the\n // remainder of n % 2^13. If it is 88 or \n // lower. Take one more bit from the stream\n // and calculate the remainder for n % 2^14.\n\n let count = 13;\n let rN = n % 8192;\n\n if (rN < 89) {\n count = 14;\n rN = n % 16384;\n }\n\n // Remove 13 or 14 bits from the integer,\n // decrease the bitCount by the same amount.\n n >>= count;\n bitCount -= count;\n \n // Calculate quotient and remainder from\n // the before calculated remainder of n \n // -> \"rN\"\n let q, r;\n [q, r] = this.#divmod(rN, 91);\n\n // Lookup the corresponding characters for\n // \"r\" and \"q\" in the set, append it to the \n // output string.\n output = `${output}${charset[r]}${charset[q]}`;\n }\n });\n \n // If the bitCount is not zero at the end,\n // calculate quotient and remainder of 91\n // once more.\n if (bitCount) {\n let q, r;\n [q, r] = this.#divmod(n, 91);\n\n // The remainder is concatenated in any case\n output = output.concat(charset[r]);\n\n // The quotient is also appended, but only\n // if the bitCount still has the size of a byte\n // or n can still represent 91 conditions.\n if (bitCount > 7 || n > 90) {\n output = output.concat(charset[q]);\n }\n }\n \n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n\n /**\n * BaseEx basE91 Decoder.\n * @param {string} input - basE91 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n\n // Make it a string, whatever goes in\n input = this.utils.normalizeInput(input);\n let inArray = [...input];\n\n // remove unwanted characters if integrity is false \n if (!settings.integrity) {\n inArray = inArray.filter(c => charset.includes(c));\n }\n\n\n let l = inArray.length;\n\n // For starters leave the last char behind\n // if the length of the input string is odd.\n\n let odd = false;\n if (l % 2) {\n odd = true;\n l--;\n }\n\n // Set again integer n for base conversion.\n // Also initialize a bitCount(er)\n\n let n = 0;\n let bitCount = 0;\n \n // Initialize an ordinary array\n const b256Array = new Array();\n \n // Walk through the string in steps of two\n // (aka collect remainder- and quotient-pairs)\n for (let i=0; i 88) ? 13 : 14;\n\n // calculate back the individual bytes (base256)\n do {\n b256Array.push(n % 256);\n n >>= 8;\n bitCount -= 8;\n } while (bitCount > 7);\n }\n\n // Calculate the last byte if the input is odd\n // and add it\n if (odd) {\n const lastChar = inArray.at(l);\n const rN = charset.indexOf(lastChar);\n b256Array.push(((rN << bitCount) + n) % 256);\n }\n\n const output = Uint8Array.from(b256Array);\n\n // Return the output\n return this.utils.outputHandler.compile(output, settings.outputType);\n }\n\n\n /**\n * Divmod Function.\n * @param {*} x - number 1\n * @param {*} y - number 2\n * @returns {number} Modulo y of x\n */\n #divmod (x, y) {\n return [Math.floor(x/y), x%y];\n }\n}\n","/**\n * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport { BytesInput } from \"../io-handlers.js\";\n\n/**\n * BaseEx Little Endian Base 128 Converter.\n * ---------------------------------------\n * \n * This is a leb128 converter. Various input can be \n * converted to a leb128 string or a leb128 string\n * can be decoded into various formats.\n * \n * There is no real charset available as the input is\n * getting converted to bytes. For having the chance \n * to store these bytes, there is a hexadecimal output\n * available.\n */\nexport default class LEB128 extends BaseTemplate {\n \n /**\n * BaseEx LEB128 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n // initialize base template without utils\n super();\n\n // converters\n this.converter = new BaseConverter(10, 0, 0);\n this.hexlify = new BaseConverter(16, 1, 2);\n\n // charsets\n this.charsets.default = \"\";\n this.charsets.hex = \"\"\n\n // predefined settings\n this.version = \"default\";\n this.frozenCharsets = true;\n\n // predefined settings\n this.littleEndian = true;\n this.hasSignedMode = true;\n this.isMutable.signed = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx LEB128 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {{ buffer: ArrayBufferLike; }} - LEB128 encoded Unit8Array (or hex string of it).\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n \n const signed = settings.signed;\n settings.signed = true;\n const [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings);\n\n // Convert to BaseRadix string\n let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0];\n\n let n = BigInt(base10);\n let output = new Array();\n \n if (negative) {\n if (!signed) {\n throw new TypeError(\"Negative values in unsigned mode are invalid.\");\n }\n n = -n;\n }\n \n if (signed) {\n\n for (;;) {\n const byte = Number(n & 127n);\n n >>= 7n;\n if ((n == 0 && (byte & 64) == 0) || (n == -1 && (byte & 64) != 0)) {\n output.push(byte);\n break;\n }\n output.push(byte | 128);\n }\n }\n\n else {\n for (;;) {\n const byte = Number(n & 127n);\n n >>= 7n;\n if (n == 0) {\n output.push(byte)\n break;\n }\n output.push(byte | 128);\n }\n }\n\n const Uint8Output = Uint8Array.from(output);\n\n if (settings.version === \"hex\") {\n return this.hexlify.encode(Uint8Output, [...\"0123456789abcdef\"], false)[0];\n }\n\n return Uint8Output;\n }\n\n\n /**\n * BaseEx LEB128 Decoder.\n * @param {{ buffer: ArrayBufferLike; }|string} input - LEB128-Bytes or String of Hex-Version.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n\n if (settings.version === \"hex\") {\n input = this.hexlify.decode(this.utils.normalizeInput(input).toLowerCase(), [...\"0123456789abcdef\"], [], settings.integrity, false);\n } else if (typeof input.byteLength !== \"undefined\") {\n input = BytesInput.toBytes(input)[0];\n } else {\n throw new TypeError(\"Input must be a bytes like object.\");\n }\n\n if (input.length === 1 && !input[0]) {\n return this.utils.outputHandler.compile(new Uint8Array(1), settings.outputType, true);\n }\n\n input = Array.from(input);\n\n let n = 0n;\n let shiftVal = -7n;\n let byte;\n\n for (byte of input) {\n shiftVal += 7n;\n n += (BigInt(byte & 127) << shiftVal);\n }\n \n if (settings.signed && ((byte & 64) !== 0)) {\n n |= -(1n << shiftVal + 7n);\n }\n\n // Test for a negative sign\n let decimalNum, negative;\n [decimalNum, negative] = this.utils.extractSign(n.toString());\n\n const output = this.converter.decode(decimalNum, [...\"0123456789\"], [], settings.integrity, true);\n\n // Return the output\n return this.utils.outputHandler.compile(output, settings.outputType, true, negative);\n }\n}\n","/**\n * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT OR Apache-2.0\n * @see https://github.com/keith-turner/ecoji\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Ecoji (a Base 1024) Converter.\n * ------------------------------------\n * This an implementation of the Ecoji converter.\n * Various input can be converted to an Ecoji string\n * or an Ecoji string can be decoded into various \n * formats. Versions 1 and 2 are supported.\n * This variant pretty much follows the standard\n * (at least in its results, the algorithm is very\n * different from the original).\n * A deviation is the handling of padding. The last\n * pad char can be trimmed for both versions and\n * additionally omitted completely if integrity\n * checks are disabled.\n */\nexport default class Ecoji extends BaseTemplate {\n\n #revEmojiVersion = {};\n #padRegex = null;\n\n /**\n * BaseEx Ecoji Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // charsets\n this.charsets.emojis_v1 = [...\"🀄🃏🅰🅱🅾🅿🆎🆑🆒🆓🆔🆕🆖🆗🆘🆙🆚🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿🈁🈂🈚🈯🈲🈳🈴🈵🈶🈷🈸🈹🈺🉐🉑🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🌡🌤🌥🌦🌧🌨🌩🌪🌫🌬🌭🌮🌯🌰🌱🌲🌳🌴🌵🌶🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🍽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🎖🎗🎙🎚🎛🎞🎟🎠🎡🎢🎣🎤🎥🎦🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🏋🏌🏎🏏🏐🏑🏒🏓🏔🏕🏖🏗🏘🏙🏚🏛🏜🏝🏞🏟🏠🏡🏢🏣🏤🏥🏦🏧🏨🏩🏪🏫🏬🏭🏮🏯🏰🏳🏴🏵🏷🏸🏹🏺🏻🏼🏽🏾🏿🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🐿👀👁👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸💹💺💻💼💽💾💿📀📁📂📃📄📅📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳📴📵📶📷📸📹📺📻📼📽📿🔀🔁🔂🔃🔄🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🔙🔚🔛🔜🔝🔞🔟🔠🔡🔢🔣🔤🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🔴🔵🔶🔷🔸🔹🔺🔻🔼🔽🕉🕊🕋🕌🕍🕎🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧🕯🕰🕳🕴🕵🕶🕷🕸🕹🕺🖇🖊🖋🖌🖍🖐🖕🖖🖤🖥🖨🖱🖲🖼🗂🗃🗄🗑🗒🗓🗜🗝🗞🗡🗣🗨🗯🗳🗺🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🛋🛌🛍🛎🛏🛐🛑🛒🛠🛡🛢🛣🛤🛥🛩🛫🛬🛰🛳🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🦰🦱🦲🦳🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕\"];\n this.padChars.emojis_v1 = [ \"⚜\", \"🏍\", \"📑\", \"🙋\", \"☕\" ];\n\n this.charsets.emojis_v2 = [...\"🀄🃏⏰⏳☔♈♉♊♋♌♍♎♏♐♑♒♓♿⚓⚡⚽⚾⛄⛅⛎⛔⛪⛲⛳⛵⛺⛽✊✋✨⭐🛕🛖🛗🛝🛞🛟🛺🈁🛻🤌🤏🤿🥱🥲🥸🥹🥻🦣🦤🦥🦦🦧🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🦨🦩🦪🦫🦬🦭🦮🦯🦺🦻🌭🌮🌯🌰🌱🌲🌳🌴🌵🦼🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🦽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🦾🦿🧃🧄🧅🧆🧇🎠🎡🎢🎣🎤🎥🧈🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🧉🧊🧋🏏🏐🏑🏒🏓🧌🧍🧎🧏🧖🧗🧘🧙🧚🧛🧜🧝🏠🏡🏢🏣🏤🏥🏦🧞🏨🏩🏪🏫🏬🏭🏮🏯🏰🧟🏴🧠🧢🏸🏹🏺🧣🧤🧥🧦🧧🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🧨👀🧩👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸🧪💺💻💼💽💾💿📀🧫📂📃📄🧬📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳🧭📵📶📷📸📹📺📻📼🧮📿🧯🧰🧱🧲🧳🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🧴🧵🧶🧷🧸🧹🧺🧻🧼🧽🧾🧿🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🩰🩱🩲🩳🩴🩸🩹🩺🩻🩼🪀🪁🕋🕌🕍🕎🪂🪃🪄🪅🪆🪐🪑🪒🪓🪔🪕🪖🪗🪘🪙🪚🪛🪜🪝🪞🪟🪠🪡🪢🪣🪤🪥🪦🪧🪨🪩🪪🪫🕺🪬🪰🪱🪲🪳🪴🖕🖖🖤🪵🪶🪷🪸🪹🪺🫀🫁🫂🫃🫄🫅🫐🫑🫒🫓🫔🫕🫖🫗🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🫘🛌🫙🫠🫡🛐🛑🛒🫢🫣🫤🫥🫦🫧🫰🛫🛬🫱🫲🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🫳🫴🫵🫶🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕\"];\n this.padChars.emojis_v2 = [ \"🥷\", \"🛼\", \"📑\", \"🙋\", \"☕\" ];\n \n // init mapping for decoding particularities of the two versions\n this.#init();\n\n // converter\n this.converter = new BaseConverter(1024, 5, 4);\n\n // predefined settings\n this.padding = true;\n this.padCharAmount = 5;\n this.version = \"emojis_v2\";\n \n // mutable extra args\n this.isMutable.padding = true;\n this.isMutable.trim = true;\n\n // set trim option\n this.trim = null;\n this.utils.converterArgs.trim = [\"notrim\", \"trim\"];\n \n // apply user settings\n this.utils.validateArgs(args, true);\n\n if (this.trim === null) {\n this.trim = this.version === \"emojis_v2\";\n }\n }\n\n\n /**\n * Analyzes v1 and two charsets for equal and non\n * equal characters to create a \"revEmojiObj\" for\n * decoding lookup. Also generates a RegExp object \n * for handling concatenated strings.\n */\n #init() {\n\n // Stores all padding for a regex generation.\n const padAll = {};\n\n // Creates an object which holds all characters\n // of both versions. Unique chars for version one\n // are getting the version value \"1\", version two \"2\"\n // and overlaps \"3\". \n const revEmojisAdd = (version, set) => {\n set.forEach((char) => {\n if (char in this.#revEmojiVersion) {\n this.#revEmojiVersion[char].version += version;\n } else {\n this.#revEmojiVersion[char] = { version };\n }\n });\n };\n\n // This function adds a padding character of both\n // versions to the object, with additional information\n // about the padding type. In this process each unique\n // padChar is also added to the \"padAll\" object. \n const handlePadding = (version, set, type) => {\n set.forEach(padChar => {\n \n if (padChar in padAll) {\n this.#revEmojiVersion[padChar].version = 3;\n } else {\n this.#revEmojiVersion[padChar] = {\n version,\n padding: type\n }\n padAll[padChar] = type;\n } \n });\n };\n\n revEmojisAdd(1, this.charsets.emojis_v1);\n revEmojisAdd(2, this.charsets.emojis_v2);\n\n handlePadding(1, this.padChars.emojis_v1.slice(0, -1), \"last\");\n handlePadding(2, this.padChars.emojis_v2.slice(0, -1), \"last\");\n handlePadding(1, this.padChars.emojis_v1.slice(-1), \"fill\");\n handlePadding(2, this.padChars.emojis_v2.slice(-1), \"fill\");\n\n \n // Create an array of keys for the final regex\n const regexArray = [];\n\n for (const padChar in padAll) {\n if (padAll[padChar] === \"last\") {\n regexArray.push(padChar);\n } else {\n regexArray.push(`${padChar}+`);\n }\n }\n\n // create a regex obj for matching all pad chars \n this.#padRegex = new RegExp(regexArray.join(\"|\"), \"g\");\n }\n\n\n /**\n * BaseEx Ecoji Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Ecoji encoded string.\n */\n encode(input, ...args) {\n\n const applyPadding = ({ output, settings, zeroPadding }) => {\n\n const charset = this.charsets[settings.version];\n let outArray = [...output];\n \n if (zeroPadding > 1) {\n const padValue = this.converter.padBytes(zeroPadding);\n if (settings.padding) {\n const padLen = settings.trim ? 1 : padValue;\n const padArr = new Array(padLen).fill(this.padChars[settings.version].at(-1));\n outArray.splice(outArray.length-padValue, padValue, ...padArr);\n } else {\n outArray.splice(outArray.length-padValue, padValue);\n }\n }\n \n else if (zeroPadding === 1) {\n const lastVal = charset.indexOf(outArray.pop());\n const x = lastVal >> 8;\n outArray.push(this.padChars[settings.version].at(x));\n }\n\n return outArray.join(\"\");\n }\n \n return super.encode(input, null, applyPadding, ...args);\n }\n\n \n /**\n * BaseEx Ecoji Decoder.\n * @param {string} input - Ecoji String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n input = this.utils.normalizeInput(input);\n\n let version = settings.version;\n let versionKey = null;\n\n if (settings.version === \"emojis_v1\" || settings.version === \"emojis_v2\") {\n // versionKey can be both v1 or v2\n versionKey = 3;\n }\n\n // the actual decoding is wrapped in a function\n // for the possibility to call it multiple times\n const decode = (input) => {\n\n if (versionKey !== null) {\n versionKey = this.#preDecode(input, versionKey, settings.integrity);\n version = (versionKey === 3)\n ? settings.version\n : `emojis_v${versionKey}`;\n }\n\n const charset = this.charsets[version];\n \n const inArray = [...input];\n const lastChar = inArray.at(-1);\n let skipLast = false;\n\n for (let i=0; i {\n const end = match.index + match.at(0).length;\n preOutArray.push(...decode(input.slice(start, end)));\n start = end;\n });\n\n // in case the last group has no padding, it is not yet\n // decoded -> do it now\n if (start !== input.length) {\n preOutArray.push(...decode(input.slice(start, input.length)));\n }\n\n output = Uint8Array.from(preOutArray);\n }\n\n return this.utils.outputHandler.compile(output, settings.outputType);\n }\n\n\n /**\n * Determines the version (1/2) and analyzes the input for integrity.\n * @param {string} input - Input string. \n * @param {number} versionKey - Version key from former calls (initially always 3). \n * @param {boolean} integrity - If false non standard or wrong padding gets ignored. \n * @returns {number} - Version key (1|2|3)\n */\n #preDecode(input, versionKey, integrity) {\n \n const inArray = [...input];\n let sawPadding;\n\n inArray.forEach((char, i) => {\n\n if (char in this.#revEmojiVersion) {\n\n const charVersion = this.#revEmojiVersion[char].version;\n\n // version changes can only happen if the char is\n // not in both versions (not 3)\n if (charVersion !== 3) {\n if (versionKey === 3) {\n versionKey = charVersion;\n } else if (versionKey !== charVersion) {\n throw new TypeError(`Emojis from different ecoji versions seen : ${char} from emojis_v${charVersion}`);\n }\n }\n\n // analyze possible wrong padding if integrity checks\n // are enabled\n if (integrity) {\n const padding = this.#revEmojiVersion[char].padding;\n if (padding) {\n\n // index relative to a group of four bytes\n const relIndex = i%4;\n sawPadding = true;\n\n if (padding === \"fill\") {\n if (relIndex === 0) {\n throw new TypeError(`Padding unexpectedly seen in first position ${char}`);\n }\n } else if (relIndex !== 3) {\n throw new TypeError(`Last padding seen in unexpected position ${char}`);\n }\n }\n\n else if (sawPadding) {\n throw new TypeError(\"Unexpectedly saw non-padding after padding\");\n }\n }\n\n } else {\n throw new DecodingError(char);\n }\n });\n\n // lastly test for invalid string \n if (integrity && inArray.length % 4) {\n if (\n versionKey === 1 ||\n this.#revEmojiVersion[inArray.at(-1)].padding !== \"fill\"\n ) {\n throw new TypeError(\"Unexpected end of data, input data size not multiple of 4\");\n }\n }\n\n return versionKey;\n }\n}\n","/**\n * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseTemplate } from \"../core.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base 2048 Converter.\n * ------------------------\n * This is a base2048/converter. Various input can be \n * converted to a hex string or a hex string can be\n * decoded into various formats. It is possible to \n * convert in both signed and unsigned mode.\n * \n * @see https://github.com/qntm/base2048\n */\nexport default class Base2048 extends BaseTemplate {\n\n /**\n * BaseEx Base2048 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 2048,\n bsEnc: 11,\n bsEncPad: 3,\n bsDec: 8\n }\n \n // default settings\n this.charsets.default = [...\"89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ\"];\n this.padChars.default = [...\"01234567\"];\n\n this.padCharAmount = 8;\n this.hasSignedMode = true;\n this.littleEndian = false;\n \n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Base2048 Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...str} [args] - Converter settings.\n * @returns {string} - Base2048 encoded string.\n */\n encode(input, ...args) {\n\n const settings = this.utils.validateArgs(args);\n let inputBytes = this.utils.inputHandler.toBytes(input, settings).at(0);\n\n const charset = this.charsets[settings.version];\n const padChars = this.padChars[settings.version];\n\n let output = \"\";\n let z = 0;\n let numZBits = 0;\n\n inputBytes.forEach(uint8 => {\n \n for (let i=this.converter.bsDec-1; i>=0; i--) {\n\n z = (z << 1) + ((uint8 >> i) & 1);\n numZBits++;\n\n if (numZBits === this.converter.bsEnc) {\n output += charset.at(z);\n z = 0\n numZBits = 0\n }\n }\n });\n\n if (numZBits !== 0) {\n \n let bitCount;\n let isPadding;\n\n if (numZBits <= this.converter.bsEncPad) {\n bitCount = this.converter.bsEncPad;\n isPadding = true;\n } else {\n bitCount = this.converter.bsEnc \n isPadding = false;\n }\n\n while (numZBits !== bitCount) {\n z = (z << 1) + 1\n numZBits++\n if (numZBits > this.converter.bsEnc) {\n throw new Error(\"Cannot process input. This is a bug!\");\n }\n }\n \n if (isPadding) { \n output += padChars.at(z);\n } else {\n output += charset.at(z);\n }\n }\n\n return this.utils.wrapOutput(output, settings.options.lineWrap);\n }\n\n \n /**\n * BaseEx Base2048 Decoder.\n * @param {string} input - Base2048/Hex String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n\n // apply settings\n const settings = this.utils.validateArgs(args);\n\n // ensure a string input\n input = this.utils.normalizeInput(input);\n const inArray = [...input];\n\n const charset = this.charsets[settings.version];\n const padChars = this.padChars[settings.version];\n\n const byteArray = new Array();\n let uint8 = 0;\n let numUint8Bits = 0;\n\n inArray.forEach((c, i) => {\n\n let numZBits;\n let z = charset.indexOf(c);\n if (z > -1) { \n numZBits = this.converter.bsEnc;\n } else {\n z = padChars.indexOf(c);\n\n if (z > -1) {\n if (i+1 !== inArray.length) {\n throw new DecodingError(null, `Secondary character found before end of input, index: ${i}`); \n }\n\n numZBits = this.converter.bsEncPad;\n }\n \n else if (settings.integrity) {\n throw new DecodingError(c);\n }\n }\n\n // Take most significant bit first\n for (let j=numZBits-1; j>=0; j--) {\n\n uint8 = (uint8 << 1) + ((z >> j) & 1);\n numUint8Bits++\n\n if (numUint8Bits === this.converter.bsDec) {\n byteArray.push(uint8);\n uint8 = 0;\n numUint8Bits = 0;\n }\n }\n });\n\n return this.utils.outputHandler.compile(\n Uint8Array.from(byteArray),\n settings.outputType\n );\n }\n}\n","/**\n * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\n\n\n/**\n * BaseEx SimpleBase Converter.\n * ---------------------------\n * SimpleBase provides the simple mathematical base\n * conversion as known from (n).toString(radix) and\n * parseInt(n, radix).\n * \n * The constructor needs a radix between 2-62 as the\n * first argument. In other regards it behaves pretty\n * much as any other converter. \n */\nexport default class SimpleBase extends BaseTemplate {\n \n /**\n * SimpleBase Constructor.\n * @param {number} radix - Radix between 2 and 62 \n * @param {...any} args - Converter settings.\n */\n constructor(radix, ...args) {\n super();\n\n if (!radix || !Number.isInteger(radix) || radix < 2 || radix > 62) {\n throw new RangeError(\"Radix argument must be provided and has to be an integer between 2 and 62.\")\n }\n this.converter = new BaseConverter(radix, 0, 0);\n\n\n // charsets\n this.charsets.default = [...\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"].slice(0, radix);\n \n\n // predefined settings\n this.frozenCharsets = true;\n this.hasSignedMode = true;\n this.littleEndian = !(radix === 2 || radix === 16);\n this.signed = true;\n this.version = \"default\";\n \n // list of allowed/disallowed args to change\n this.isMutable.littleEndian = true,\n this.isMutable.upper = radix <= 36;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n \n\n /**\n * BaseEx SimpleBase Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...any} [args] - Converter settings.\n * @returns {string} - Base 2-62 encoded string.\n */\n encode(input, ...args) {\n return super.encode(input, null, null, ...args);\n }\n\n\n /**\n * BaseEx SimpleBase Decoder.\n * @param {string} input - Base 2-62 String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(rawInput, ...args) {\n\n // pre decoding function\n const normalizeInput = ({ input }) => {\n \n // normalize input (add leading zeros) for base 2 and 16\n if (this.converter.radix === 2) {\n const leadingZeros = (8 - (input.length % 8)) % 8;\n input = `${\"0\".repeat(leadingZeros)}${input}`;\n } else if (this.converter.radix === 16) {\n const leadingZeros = input.length % 2;\n input = `${\"0\".repeat(leadingZeros)}${input}`;\n }\n\n return input;\n }\n \n return super.decode(rawInput, normalizeInput, null, false, ...args);\n\n }\n}\n","/**\n * big.js v6.2.1 // Copyright (c) 2022 Michael Mclaughlin // https://github.com/MikeMcl/big.js/LICENCE.md // Modified (reduced) and minified for BaseEx\n */\nlet DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME=\"[big.js] \",INVALID=NAME+\"Invalid \",INVALID_DP=INVALID+\"decimal places\",INVALID_RM=INVALID+\"rounding mode\",P={},NUMERIC=/^-?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i;function _Big_(){function Big(n){let x=this;if(!(x instanceof Big))return void 0===n?_Big_():new Big(n);if(n instanceof Big)x.s=n.s,x.e=n.e,x.c=n.c.slice();else{if(\"string\"!=typeof n){if(!0===Big.strict&&\"bigint\"!=typeof n)throw TypeError(INVALID+\"value\");n=0===n&&1/n<0?\"-0\":String(n)}parse(x,n)}x.constructor=Big}return Big.prototype=P,Big.DP=DP,Big.RM=RM,Big.NE=NE,Big.PE=PE,Big.strict=STRICT,Big.roundDown=0,Big.roundHalfUp=1,Big.roundHalfEven=2,Big.roundUp=3,Big}function parse(x,n){let e,i,nl;if(!NUMERIC.test(n))throw Error(`${INVALID}number`);for(x.s=\"-\"==n.charAt(0)?(n=n.slice(1),-1):1,(e=n.indexOf(\".\"))>-1&&(n=n.replace(\".\",\"\")),(i=n.search(/e/i))>0?(e<0&&(e=i),e+=+n.slice(i+1),n=n.substring(0,i)):e<0&&(e=n.length),nl=n.length,i=0;i0&&\"0\"==n.charAt(--nl););for(x.e=e-i-1,x.c=[],e=0;i<=nl;)x.c[e++]=+n.charAt(i++)}return x}function round(x,sd,rm,more){let xc=x.c;if(void 0===rm&&(rm=x.constructor.RM),0!==rm&&1!==rm&&2!==rm&&3!==rm)throw Error(INVALID_RM);if(sd<1)more=3===rm&&(more||!!xc[0])||0===sd&&(1===rm&&xc[0]>=5||2===rm&&(xc[0]>5||5===xc[0]&&(more||void 0!==xc[1]))),xc.length=1,more?(x.e=x.e-sd+1,xc[0]=1):xc[0]=x.e=0;else if(sd=5||2===rm&&(xc[sd]>5||5===xc[sd]&&(more||void 0!==xc[sd+1]||1&xc[sd-1]))||3===rm&&(more||!!xc[0]),xc.length=sd,more)for(;++xc[--sd]>9;)if(xc[sd]=0,0===sd){++x.e,xc.unshift(1);break}for(sd=xc.length;!xc[--sd];)xc.pop()}return x}function stringify(x,doExponential,isNonzero){let e=x.e,s=x.c.join(\"\"),n=s.length;if(doExponential)s=s.charAt(0)+(n>1?\".\"+s.slice(1):\"\")+(e<0?\"e\":\"e+\")+e;else if(e<0){for(;++e;)s=\"0\"+s;s=\"0.\"+s}else if(e>0)if(++e>n)for(e-=n;e--;)s+=\"0\";else e1&&(s=s.charAt(0)+\".\"+s.slice(1));return x.s<0&&isNonzero?\"-\"+s:s}P.abs=function(){let x=new this.constructor(this);return x.s=1,x},P.cmp=function(y){let isneg,x=this,xc=x.c,yc=(y=new x.constructor(y)).c,i=x.s,j=y.s,k=x.e,l=y.e;if(!xc[0]||!yc[0])return xc[0]?i:yc[0]?-j:0;if(i!=j)return i;if(isneg=i<0,k!=l)return k>l^isneg?1:-1;for(j=(k=xc.length)<(l=yc.length)?k:l,i=-1;++iyc[i]^isneg?1:-1;return k==l?0:k>l^isneg?1:-1},P.eq=function(y){return 0===this.cmp(y)},P.gt=function(y){return this.cmp(y)>0},P.gte=function(y){return this.cmp(y)>-1},P.lt=function(y){return this.cmp(y)<0},P.lte=function(y){return this.cmp(y)<1},P.minus=P.sub=function(y){let i,j,t,xlty,x=this,Big=x.constructor,a=x.s,b=(y=new Big(y)).s;if(a!=b)return y.s=-b,x.plus(y);let xc=x.c.slice(),xe=x.e,yc=y.c,ye=y.e;if(!xc[0]||!yc[0])return yc[0]?y.s=-b:xc[0]?y=new Big(x):y.s=1,y;if(a=xe-ye){for((xlty=a<0)?(a=-a,t=xc):(ye=xe,t=yc),t.reverse(),b=a;b--;)t.push(0);t.reverse()}else for(j=((xlty=xc.length0)for(;b--;)xc[i++]=0;for(b=i;j>a;){if(xc[--j]0?(ye=xe,t=yc):(e=-e,t=xc),t.reverse();e--;)t.push(0);t.reverse()}for(xc.length-yc.length<0&&(t=yc,yc=xc,xc=t),e=yc.length,k=0;e;xc[e]%=10)k=(xc[--e]=xc[e]+yc[e]+k)/10|0;for(k&&(xc.unshift(k),++ye),e=xc.length;0===xc[--e];)xc.pop();return y.c=xc,y.e=ye,y},P.round=function(dp,rm){if(void 0===dp)dp=0;else if(dp!==~~dp||dp<-MAX_DP||dp>MAX_DP)throw Error(INVALID_DP);return round(new this.constructor(this),dp+this.e+1,rm)},P.toFixed=function(dp,rm){let x=this,n=x.c[0];if(void 0!==dp){if(dp!==~~dp||dp<0||dp>MAX_DP)throw Error(INVALID_DP);for(x=round(new x.constructor(x),dp+x.e+1,rm),dp=dp+x.e+1;x.c.length=Big.PE,!!x.c[0])},P.toNumber=function(){let n=Number(stringify(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(n.toString()))throw Error(NAME+\"Imprecise conversion\");return n};export const Big=_Big_();export default Big;\n","/**\n * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { BaseConverter, BaseTemplate } from \"../core.js\";\nimport Big from \"../../lib/big.js/big.min.js\";\nimport { DecodingError } from \"../utils.js\";\n\n/**\n * BaseEx Base Phi Converter.\n * ------------------------\n * \n * This is a base phi converter. Various input can be \n * converted to a base phi string or a base phi string\n * can be decoded into various formats.\n * \n */\nexport default class BasePhi extends BaseTemplate {\n\n #Phi = Big(\"1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752\");\n \n /**\n * BaseEx basE91 Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n super();\n\n // converter (properties only)\n this.converter = {\n radix: 2, // radix is Phi, but the normalized representation allows two chars\n bsEnc: 0,\n bsDec: 0\n }\n\n // base10 converter to have always have a numerical input \n this.b10 = new BaseConverter(10, 0, 0);\n\n // charsets\n this.charsets.default = [\"0\", \"1\"];\n\n this.version = \"default\";\n this.signed = true;\n this.hasDecimalMode = true;\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx BasePhi Encoder.\n * @param {*} input - Input according to the used byte converter.\n * @param {...string} [args] - Converter settings.\n * @returns {string} - BasePhi encoded string.\n */\n encode(input, ...args) {\n \n // argument validation and input settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n \n let inputBytes;\n let negative;\n let n;\n let output = \"\";\n\n // Base Phi allows direct encoding of rational \n // and irrational numbers, which can be enabled\n // by using the special type \"decimal\". Input \n // type must be \"Number\" for this mode. \n if (settings.decimalMode) {\n if (Number.isFinite(input)) {\n if (input < 0) {\n negative = true;\n n = Big(-input);\n } else {\n negative = false;\n n = Big(input);\n } \n }\n\n else {\n throw new TypeError(\"When running the converter in decimal-mode, only input of type 'Number' is allowed.\")\n }\n }\n\n // Every other type first converts the byte representation\n // of the input to base 10.\n else {\n [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings);\n n = Big(\n this.b10.encode(inputBytes, null, settings.littleEndian)[0]\n );\n }\n\n // if \"n\" if 0 or 1 stop here and return 0 or 1 (according to the charset)\n if (n.eq(0) || n.eq(1)) {\n output = charset[n.toNumber()]; \n if (negative) {\n output = `-${output}`;\n } \n return output;\n }\n \n // create two arrays to store all exponents\n const exponents = [];\n const decExponents = [];\n\n\n // The very first step is to find the highest exponent\n // of Phi which fits into \"n\" (the rounded highest exponent\n // is also the highest Lucas number which fits into \"n\")\n // To find the highest fitting exponent start with \n // Phi^0 (1) and Phi^1 (Phi).\n\n let last = Big(1);\n let cur = this.#Phi;\n let exp = 0;\n \n // Now add the result with the last higher value \"cur\",\n // util \"cur\" is bigger than \"n\"\n while (cur.lt(n)) {\n [ last, cur ] = this.#nextPhiExp(last, cur);\n exp++;\n }\n \n /**\n * Recursive reduction function for \"n\". Finds the largest\n * fitting exponent of Phi (Lucas index), stores that index\n * in the exponent arrays and reduces \"n\" by the current exponents\n * power.\n * Once started, it calls itself until \"n\" is zero. \n * @param {Object} cur - Current result of Phi^exp as a Big.js object. \n * @param {Object} prev - Previous result of Phi^exp as a Big.js object. \n * @param {number} exp - Exponent of Phi/Lucas index. \n */\n const reduceN = (cur, prev, exp) => {\n\n // Due to the high floating point precision \"n\" should\n // be exactly zero, but if not, an approximation is \n // sufficient.\n if (this.#approxNull(n)) return;\n\n // Reduce the exponents of Phi until it power fits into \"n\" \n while (cur.gt(n)) {\n [ cur, prev ] = this.#prevPhiExp(cur, prev);\n \n // if \"cur\" gets negative return immediately\n // prevent an infinite loop\n if (cur.lte(0)) {\n console.warn(\"Could not find an exact base-phi representation. Value is approximated.\");\n return;\n }\n exp--;\n }\n\n // Store the exponents\n if (exp > -1) {\n exponents.unshift(exp);\n } else {\n decExponents.push(exp);\n }\n\n // Reduce \"n\"\n n = n.minus(cur);\n\n reduceN(cur, prev, exp);\n }\n\n // Initial call of the reduction function\n reduceN(last, cur, exp);\n\n\n // Create a BasePhi string by setting a \"1\" at every\n // index stored in the \"exponent\" array. for every\n // number between two indices a zero is added. \n exp = 0; \n exponents.forEach(nExp => {\n while (exp < nExp) {\n output = `${charset[0]}${output}`;\n exp++;\n }\n output = `${charset[1]}${output}`;\n exp++;\n });\n\n // Add a decimal point\n if (!output) {\n output = \"0.\";\n } else {\n output += \".\";\n }\n \n // Proceed with the decimal exponents\n exp = -1;\n decExponents.forEach(nExp => {\n while (exp > nExp) {\n output += charset[0];\n exp--;\n }\n output += charset[1];\n exp--;\n });\n\n // Add a \"-\" if the input is negative.\n if (negative) {\n output = `-${output}`;\n }\n \n return output;\n }\n\n\n /**\n * BaseEx Base Phi Decoder.\n * @param {string} input - Base Phi String.\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output according to converter settings.\n */\n decode(input, ...args) {\n \n // Argument validation and output settings\n const settings = this.utils.validateArgs(args);\n const charset = this.charsets[settings.version];\n\n let negative;\n [ input, negative ] = this.utils.extractSign(\n this.utils.normalizeInput(input)\n );\n\n // remove unwanted characters if integrity is false\n if (!settings.integrity) {\n const testChars = [...charset, \".\"];\n input = [...input].filter(c => testChars.includes(c)).join(\"\");\n }\n \n // Split the input String at the decimal sign\n // and initialize a big.js-object with value 0\n const inputSplit = input.split(\".\");\n if (settings.integrity && inputSplit.length > 2) {\n throw new DecodingError(null, \"There are multiple decimal points in the input.\");\n } \n\n const [ posExpStr, decExpStr ] = inputSplit;\n let n = Big(0);\n\n // Initialize two variables \"last\" and \"cur\"\n // for Phi^exp-1 and Phi^exp\n let last = this.#Phi.minus(1);\n let cur = Big(1); \n \n // Convert the left side of the input string\n // to an array of chars and reverse it. Raise\n // the exponent of Phi and its values until a\n // one is found in the array, if a \"1\" was found\n // add the value \"cur\" to number \"n\" (one can\n // also be another corresponding char of the set\n // which represents 1).\n [...posExpStr].reverse().forEach((char) => {\n const charIndex = charset.indexOf(char);\n if (charIndex === 1) {\n n = n.plus(cur);\n } else if (charIndex !== 0) {\n throw new DecodingError(char);\n }\n [ last, cur ] = this.#nextPhiExp(last, cur);\n });\n\n // Now also add the values for the decimal places.\n if (decExpStr) { \n let prev = Big(1); \n cur = this.#Phi.minus(prev);\n \n [...decExpStr].forEach((char) => {\n const charIndex = charset.indexOf(char);\n if (charIndex === 1) {\n n = n.plus(cur);\n } else if (charIndex !== 0) {\n throw new DecodingError(char);\n }\n [ cur, prev ] = this.#prevPhiExp(cur, prev);\n });\n }\n\n // If running in decimal mode return n as a Number\n if (settings.decimalMode) {\n return n.toNumber();\n }\n\n // For every other case round \"n\" and turn it\n // into a string of an integer. \n n = n.round().toFixed();\n\n // Use the base 10 decoder to get the byte\n // representation of \"n\".\n const output = this.b10.decode(n, [...\"0123456789\"], [], settings.integrity, settings.littleEndian);\n \n // Return the output according to the settings.\n return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative);\n }\n\n /**\n * Test if n is approximately zero.\n * @param {Object} n - Big.js Object. \n * @returns {Boolean}\n */\n #approxNull(n) { \n return !(n.round(50)\n .abs()\n .toNumber()\n );\n }\n \n /**\n * Get the results of of the following exponents of Phi\n * from the predecessors.\n * @param {Object} last - Phi^exp-1 as a big.js-object \n * @param {Object} cur - Phi^exp as a big.js-object\n * @returns {Object[]} - Array with Phi^exp and Phi^exp+1\n */\n #nextPhiExp(last, cur) {\n return [ cur, last.plus(cur) ];\n }\n\n /**\n * Get the results of of the previous exponents of Phi\n * from the predecessors.\n * @param {Object} cur - Phi^exp as a big.js-object \n * @param {Object} prev - Phi^exp-1 as a big.js-object\n * @returns {Object[]} - Array with Phi^exp-1 and Phi^exp\n */\n #prevPhiExp(cur, prev) {\n return [ prev.minus(cur), cur ];\n }\n}\n","/**\n * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\nimport { SmartInput, SmartOutput } from \"../io-handlers.js\";\n\n// Endianness of the system\nconst LITTLE_ENDIAN = (() => {\n const testInt = new Uint16Array([1]);\n const byteRepresentation = new Uint8Array(testInt.buffer);\n return Boolean(byteRepresentation.at(0));\n})();\n\n\n/**\n * BaseEx Byte Converter.\n * ---------------------\n * \n * This is a byte converter. Various input can be \n * converted to a bytes or bytes can be decoded into\n * various formats.\n * \n * As en- and decoder were already available, for the\n * use of converting in- and output for the base\n * converters, this is just a little extra tool, which\n * was fast and easy to create.\n */\nexport default class ByteConverter {\n\n /**\n * BaseEx ByteConverter Constructor.\n * @param {...string} [args] - Converter settings.\n */\n constructor(...args) {\n\n // predefined settings\n this.littleEndian = LITTLE_ENDIAN;\n this.numberMode = false;\n this.outputType = \"buffer\";\n\n // simplified utils\n this.utils = {\n validateArgs: (args, initial=false) => {\n\n const parameters = {\n littleEndian: this.littleEndian,\n numberMode: this.numberMode,\n outputType: this.outputType,\n signed: false,\n }\n \n if (!args.length) {\n return parameters;\n }\n \n if (args.includes(\"number\")) {\n args.splice(args.indexOf(\"number\"), 1);\n parameters.numberMode = true;\n parameters.outputType = \"float_n\";\n }\n \n const outTypes = SmartOutput.typeList.map(s => `'${s}'`).join(\", \");\n \n args.forEach((arg) => {\n arg = String(arg).toLowerCase();\n \n if (arg === \"le\") {\n parameters.littleEndian = true;\n } else if (arg === \"be\") {\n parameters.littleEndian = false;\n } else if (SmartOutput.typeList.includes(arg)) {\n parameters.outputType = arg;\n } else {\n throw new TypeError(`Invalid argument: '${arg}.\\nValid arguments are:\\n'le', 'be', ${outTypes}`);\n }\n });\n \n if (initial) {\n for (const param in parameters) {\n this[param] = parameters[param];\n }\n }\n \n return parameters;\n }\n }\n\n // apply user settings\n this.utils.validateArgs(args, true);\n }\n\n\n /**\n * BaseEx Byte Encoder.\n * @param {*} input - Almost any input.\n * @param {...str} [args] - Converter settings.\n * @returns {{ buffer: ArrayBufferLike; }} - Bytes of Input.\n */\n encode(input, ...args) {\n const settings = this.utils.validateArgs(args);\n return SmartInput.toBytes(input, settings)[0];\n }\n\n\n /**\n * BaseEx Byte Decoder.\n * @param {{ buffer: ArrayBufferLike; }} input - Bytes/Buffer/View\n * @param {...any} [args] - Converter settings.\n * @returns {*} - Output of requested type.\n */\n decode(input, ...args) {\n const settings = this.utils.validateArgs(args);\n return SmartOutput.compile(input, settings.outputType, settings.littleEndian);\n }\n}\n","/**\n * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS}\n *\n * @version 0.7.9\n * @author UmamiAppearance [mail@umamiappearance.eu]\n * @license MIT\n */\n\n/* eslint-disable sort-imports */\n\nimport Base1 from \"./converters/base-1.js\";\nimport Base16 from \"./converters/base-16.js\";\nimport Base32 from \"./converters/base-32.js\";\nimport Base58 from \"./converters/base-58.js\";\nimport Base64 from \"./converters/base-64.js\";\nimport UUencode from \"./converters/uuencode.js\";\nimport Base85 from \"./converters/base-85.js\";\nimport Base91 from \"./converters/base-91.js\";\nimport LEB128 from \"./converters/leb-128.js\";\nimport Ecoji from \"./converters/ecoji.js\";\nimport Base2048 from \"./converters/base-2048.js\";\nimport SimpleBase from \"./converters/simple-base.js\";\nimport BasePhi from \"./converters/base-phi.js\";\nimport ByteConverter from \"./converters/byte-converter.js\";\n\nimport { DEFAULT_OUTPUT_HANDLER } from \"./utils.js\";\n\n/**\n * BaseEx Converter Collection.\n * ---------------------------\n * This class holds almost any available converter\n * of the whole BaseEx converter collection. The \n * instances are ready to use. Various input can be \n * converted to a base string or the base string can be\n * decoded into various formats.\n */\nclass BaseEx {\n \n /**\n * BaseEx Base Collection Constructor.\n * @param {string} [outputType] - Output type. \n */\n constructor(outputType=\"buffer\") {\n\n if (!DEFAULT_OUTPUT_HANDLER.typeList.includes(outputType)) {\n let message = `Invalid argument '${outputType}' for output type. Allowed types are:\\n`;\n message = message.concat(DEFAULT_OUTPUT_HANDLER.typeList.join(\", \"));\n\n throw new TypeError(message);\n }\n\n this.base1 = new Base1(\"default\", outputType);\n this.base16 = new Base16(\"default\", outputType);\n this.base32_crockford = new Base32(\"rfc4648\", outputType);\n this.base32_rfc3548 = new Base32(\"rfc3548\", outputType);\n this.base32_rfc4648 = new Base32(\"rfc4648\", outputType);\n this.base32_zbase32 = new Base32(\"zbase32\", outputType);\n this.base58 = new Base58(\"default\", outputType);\n this.base58_bitcoin = new Base58(\"bitcoin\", outputType);\n this.base58_flickr = new Base58(\"flickr\", outputType);\n this.base64 = new Base64(\"default\", outputType);\n this.base64_urlsafe = new Base64(\"urlsafe\", outputType);\n this.uuencode = new UUencode(\"default\", outputType);\n this.uuencode_original = new UUencode(\"original\", outputType);\n this.xxencode = new UUencode(\"xx\", outputType);\n this.base85_adobe = new Base85(\"adobe\", outputType);\n this.base85_ascii = new Base85(\"ascii85\", outputType);\n this.base85_z85 = new Base85(\"z85\", outputType);\n this.base91 = new Base91(\"default\",outputType);\n this.leb128 = new LEB128(\"default\", outputType);\n this.ecoji_v1 = new Ecoji(\"emojis_v1\", outputType);\n this.ecoji_v2 = new Ecoji(\"emojis_v2\", outputType);\n this.base2048 = new Base2048(\"default\", outputType);\n this.basePhi = new BasePhi(\"default\", outputType);\n this.byteConverter = new ByteConverter(outputType);\n\n this.simpleBase = {};\n for (let i=2; i<=62; i++) {\n this.simpleBase[`base${i}`] = new SimpleBase(i, outputType);\n }\n }\n}\n\nexport { \n Base1,\n Base16,\n Base32,\n Base58,\n Base64,\n UUencode,\n Base85,\n Base91,\n LEB128,\n Ecoji,\n Base2048,\n SimpleBase,\n BasePhi,\n ByteConverter,\n BaseEx\n};\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AAC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;AAC3D;AACA,QAAQ,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;AAC7B,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE;AAClC,YAAY,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACxE,SAAS;AACT,KAAK;AACL;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/base-ex.esm.js b/dist/base-ex.esm.js index b0fa800..fe7115c 100644 --- a/dist/base-ex.esm.js +++ b/dist/base-ex.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/base-ex.esm.min.js b/dist/base-ex.esm.min.js index d70f21a..f44fa38 100644 --- a/dist/base-ex.esm.min.js +++ b/dist/base-ex.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let s;return s="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,s}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,s;if(Number.isInteger(t)){if(s="int",!Number.isSafeInteger(t)){let e,i,s;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",s="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",s="MAX"),new RangeError(`The provided integer is ${i} than ${s}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else s="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),s]}static bigInts(t,e=!1){const i=new Array,s=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[s](t%r),t>>=64n;else for(;t>=r;)i[s](t%r),t>>=64n;i[s](t);const n=8*i.length,o=this.makeDataView(n);return i.forEach(((t,i)=>{const s=8*i;o.setBigUint64(s,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,s=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(s=!0,t=-t),e.numberMode){const s=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(s.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(s=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const s=new Array;for(const i of t)s.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(s)}}return[i,s,r]}}class s{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,s){const r=t.byteLength,n=(e-t.byteLength%e)%e,o=s&&r>1?255:0;let a=t;if(n){a=new Uint8Array(r+n),a.fill(o);const e=i?0:n;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,s){let r;if("int16"===e||"uint16"===e){const n=this.makeTypedArrayBuffer(t,2,i,s);r="int16"===e?new Int16Array(n):new Uint16Array(n)}else if("int32"===e||"uint32"===e||"float32"===e){const n=this.makeTypedArrayBuffer(t,4,i,s);r="int32"===e?new Int32Array(n):"uint32"===e?new Uint32Array(n):new Float32Array(n)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const n=this.makeTypedArrayBuffer(t,8,i,s);r="bigint64"===e?new BigInt64Array(n):"biguint64"===e?new BigUint64Array(n):new Float64Array(n)}return r}static compile(t,e,s=!1,r=!1){let n;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",s):-this.compile(t,"uint_n",s),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:s,numberMode:!1,signed:!1})[0]}if("buffer"===e)n=t.buffer;else if("bytes"===e||"uint8"===e)n=t;else if("int8"===e)n=new Int8Array(t.buffer);else if("view"===e)n=new DataView(t.buffer);else if("str"===e)n=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,s,r);t=new Uint8Array(e)}s&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),n="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);n=new DataView(e.buffer).getFloat32(0,s)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);n=new DataView(e.buffer).getFloat64(0,s)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);n=Number(e)}else n=this.makeTypedArray(t,e,s,r);return n}}const r=i,n=s;class o extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class a extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class h{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],s=!0)=>{const r=(t,i,s)=>{if(0===s&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=s;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===s)return[...i];if(r!==s)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${s}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";s<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const n=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${n.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");s&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const n=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=n,o.length&&(this.root.padChars[t]=o),s&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,s){throw new TypeError([`'${t}'\n\nParameters:`,s?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const c=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(c.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,c,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new o}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,s=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=s,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[c,l]=this.divmod(c,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(c,10));a.lengthu=u.concat(e[t]))),s&&(u=s(u,o)),n=n.concat(u)}return[n,o]}decode(t,e,i=[],s=!0,r=!1){if(!t)return new Uint8Array(0);let n=this.bsDec;const o=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)o.push(e);else if(s&&-1===i.indexOf(t))throw new a(t)})),0===n)n=o.length;else{l=(n-o.length%n)%n;const t=new Array(l).fill(this.decPadVal);r?o.unshift(...t):o.push(...t)}let c=new Array;for(let t=0,e=o.length;t(this.powers[s]=BigInt(this.pow(s)),this.powers[s]))();e+=BigInt(o[t+i])*r}const i=[];let s,r=e;for(;r>=256;)[r,s]=this.divmod(r,256),i.unshift(parseInt(s,10));for(i.unshift(parseInt(r,10));i.length1){for(;!c[0];)c.shift();c.length||c.push(0),c.reverse()}}else if(this.bsDec){const t=this.padChars(l);c.splice(c.length-t)}return Uint8Array.from(c)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class c{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new h(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...s){const r=this.utils.validateArgs(s);let[n,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,c]=this.converter.encode(n,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:n,output:l,settings:r,zeroPadding:c,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,s,...r){const n=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,s);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:n}));let a=this.converter.decode(t,this.charsets[n.version],this.padChars[n.version],n.integrity,n.littleEndian);return i&&(a=i({input:t,output:a,settings:n})),this.utils.outputHandler.compile(a,n.outputType,n.littleEndian,o)}}class u extends c{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new l(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s,r;[s,r]=this.utils.inputHandler.toBytes(t,i);let n=this.converter.encode(s,null,i.littleEndian)[0],o=BigInt(n);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],h=a.length;let l="";if(1===h)l=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(l=a.at(1).repeat((o-t)/5)),l+=a.at(0).repeat(t)}else for(let t=0;t(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}class f extends c{constructor(...t){super(),this.converter=new l(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class p extends c{constructor(...t){super(),this.converter=new l(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:s})=>{if(i.padding&&"int"!==s){let s=0;const r=t.length,n=this.charsets[i.version].at(0);if(r){for(;!t[s];)if(s++,s===r){s=0;break}const i=s;i&&(e=n.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const s=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===s;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}class g extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class b extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||w()} ${e.options.file||m()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${s.at(r)}${e.join("")}\n`;break}t+=`${s.at(45)}${e.join("")}\n`}return t+=`${s.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const s=this.charsets[e.version],r=t.trim().split(/\r?\n/),n=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=s.indexOf(r.shift());if(!(o>0))break;if(n.push(...r),45!==o){i=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;n.length%60;)n.push(" ")}return n.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const w=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},m=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};class y extends c{constructor(...t){super(),this.converter=new l(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}class v extends c{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.utils.inputHandler.toBytes(t,i)[0];let r=0,n=0,o="";const a=this.charsets[i.version];if(s.forEach((t=>{if(n+=t<13){let t,e,i=13,s=n%8192;s<89&&(i=14,s=n%16384),n>>=i,r-=i,[t,e]=this.#s(s,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#s(n,91),o=o.concat(a[e]),(r>7||n>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>s.includes(t))));let n=r.length,o=!1;n%2&&(o=!0,n--);let h=0,l=0;const c=new Array;for(let t=0;t88?13:14;do{c.push(h%256),h>>=8,l-=8}while(l>7)}if(o){const t=r.at(n),e=s.indexOf(t);c.push(((e<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){h.push(t);break}h.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){h.push(t);break}h.push(128|t)}const l=Uint8Array.from(h);return"hex"===i.version?this.hexlify.encode(l,[..."0123456789abcdef"],!1)[0]:l}decode(e,...i){const s=this.utils.validateArgs(i);if("hex"===s.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],s.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);e=Array.from(e);let r,n,o,a=0n,h=-7n;for(r of e)h+=7n,a+=BigInt(127&r)<{e.forEach((e=>{e in this.#r?this.#r[e].version+=t:this.#r[e]={version:t}}))},i=(e,i,s)=>{i.forEach((i=>{i in t?this.#r[i].version=3:(this.#r[i]={version:e,padding:s},t[i]=s)}))};e(1,this.charsets.emojis_v1),e(2,this.charsets.emojis_v2),i(1,this.padChars.emojis_v1.slice(0,-1),"last"),i(2,this.padChars.emojis_v2.slice(0,-1),"last"),i(1,this.padChars.emojis_v1.slice(-1),"fill"),i(2,this.padChars.emojis_v2.slice(-1),"fill");const s=[];for(const e in t)"last"===t[e]?s.push(e):s.push(`${e}+`);this.#n=new RegExp(s.join("|"),"g")}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version];let r=[...t];if(i>1){const t=this.converter.padBytes(i);if(e.padding){const i=e.trim?1:t,s=new Array(i).fill(this.padChars[e.version].at(-1));r.splice(r.length-t,t,...s)}else r.splice(r.length-t,t)}else if(1===i){const t=s.indexOf(r.pop())>>8;r.push(this.padChars[e.version].at(t))}return r.join("")}),...e)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);let s=i.version,r=null;"emojis_v1"!==i.version&&"emojis_v2"!==i.version||(r=3);const n=t=>{null!==r&&(r=this.#a(t,r,i.integrity),s=3===r?i.version:`emojis_v${r}`);const e=this.charsets[s],n=[...t],o=n.at(-1);let a=!1;for(let i=0;i{const r=s.index+s.at(0).length;e.push(...n(t.slice(i,r))),i=r})),i!==t.length&&e.push(...n(t.slice(i,t.length))),a=Uint8Array.from(e)}return this.utils.outputHandler.compile(a,i.outputType)}#a(t,e,i){const s=[...t];let r;if(s.forEach(((t,s)=>{if(!(t in this.#r))throw new a(t);{const n=this.#r[t].version;if(3!==n)if(3===e)e=n;else if(e!==n)throw new TypeError(`Emojis from different ecoji versions seen : ${t} from emojis_v${n}`);if(i){const e=this.#r[t].padding;if(e){const i=s%4;if(r=!0,"fill"===e){if(0===i)throw new TypeError(`Padding unexpectedly seen in first position ${t}`)}else if(3!==i)throw new TypeError(`Last padding seen in unexpected position ${t}`)}else if(r)throw new TypeError("Unexpectedly saw non-padding after padding")}}})),i&&s.length%4&&(1===e||"fill"!==this.#r[s.at(-1)].padding))throw new TypeError("Unexpected end of data, input data size not multiple of 4");return e}}class x extends c{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s=this.utils.inputHandler.toBytes(t,i).at(0);const r=this.charsets[i.version],n=this.padChars[i.version];let o="",a=0,h=0;if(s.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=r.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?n.at(a):r.at(a)}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const s=[...t],r=this.charsets[i.version],n=this.padChars[i.version],o=new Array;let h=0,l=0;return s.forEach(((t,e)=>{let c,u=r.indexOf(t);if(u>-1)c=this.converter.bsEnc;else if(u=n.indexOf(t),u>-1){if(e+1!==s.length)throw new a(null,`Secondary character found before end of input, index: ${e}`);c=this.converter.bsEncPad}else if(i.integrity)throw new a(t);for(let t=c-1;t>=0;t--)h=(h<<1)+(u>>t&1),l++,l===this.converter.bsDec&&(o.push(h),h=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(o),i.outputType)}}class T extends c{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new l(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}let M=1e6,j="[big.js] ",C=j+"Invalid ",I=C+"decimal places",$=C+"rounding mode",k={},B=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function _(t,e,i,s){let r=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error($);if(e<1)s=3===i&&(s||!!r[0])||0===e&&(1===i&&r[0]>=5||2===i&&(r[0]>5||5===r[0]&&(s||void 0!==r[1]))),r.length=1,s?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e=5||2===i&&(r[e]>5||5===r[e]&&(s||void 0!==r[e+1]||1&r[e-1]))||3===i&&(s||!!r[0]),r.length=e,s)for(;++r[--e]>9;)if(r[e]=0,0===e){++t.e,r.unshift(1);break}for(e=r.length;!r[--e];)r.pop()}return t}function S(t,e,i){let s=t.e,r=t.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)r="0"+r;r="0."+r}else if(s>0)if(++s>n)for(s-=n;s--;)r+="0";else s1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&i?"-"+r:r}k.abs=function(){let t=new this.constructor(this);return t.s=1,t},k.cmp=function(t){let e,i=this,s=i.c,r=(t=new i.constructor(t)).c,n=i.s,o=t.s,a=i.e,h=t.e;if(!s[0]||!r[0])return s[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=h)return a>h^e?1:-1;for(o=(a=s.length)<(h=r.length)?a:h,n=-1;++nr[n]^e?1:-1;return a==h?0:a>h^e?1:-1},k.eq=function(t){return 0===this.cmp(t)},k.gt=function(t){return this.cmp(t)>0},k.gte=function(t){return this.cmp(t)>-1},k.lt=function(t){return this.cmp(t)<0},k.lte=function(t){return this.cmp(t)<1},k.minus=k.sub=function(t){let e,i,s,r,n=this,o=n.constructor,a=n.s,h=(t=new o(t)).s;if(a!=h)return t.s=-h,n.plus(t);let l=n.c.slice(),c=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-h:l[0]?t=new o(n):t.s=1,t;if(a=c-d){for((r=a<0)?(a=-a,s=l):(d=c,s=u),s.reverse(),h=a;h--;)s.push(0);s.reverse()}else for(i=((r=l.length0)for(;h--;)l[e++]=0;for(h=e;i>a;){if(l[--i]0?(h=o,s=l):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),e=l.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+l[e]+i)/10|0;for(i&&(a.unshift(i),++h),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=h,t},k.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-M||t>M)throw Error(I);return _(new this.constructor(this),t+this.e+1,e)},k.toFixed=function(t,e){let i=this,s=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>M)throw Error(I);for(i=_(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},k.toNumber=function(){let t=Number(S(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(j+"Imprecise conversion");return t};const N=function t(){function e(i){let s=this;if(!(s instanceof e))return void 0===i?t():new e(i);if(i instanceof e)s.s=i.s,s.e=i.e,s.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(C+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,s,r;if(!B.test(e))throw Error(`${C}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(i<0&&(i=s),i+=+e.slice(s+1),e=e.substring(0,s)):i<0&&(i=e.length),r=e.length,s=0;s0&&"0"==e.charAt(--r););for(t.e=i-s-1,t.c=[],i=0;s<=r;)t.c[i++]=+e.charAt(s++)}}(s,i)}s.constructor=e}return e.prototype=k,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();class U extends c{#h=N("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r,n,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(n=!0,o=N(-t)):(n=!1,o=N(t))}else[r,n]=this.utils.inputHandler.toBytes(t,i),o=N(this.b10.encode(r,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=s[o.toNumber()],n&&(a=`-${a}`),a;const h=[],l=[];let c=N(1),u=this.#h,d=0;for(;u.lt(o);)[c,u]=this.#l(c,u),d++;const f=(t,e,i)=>{if(!this.#c(o)){for(;t.gt(o);){if([t,e]=this.#u(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?h.unshift(i):l.push(i),o=o.minus(t),f(t,e,i)}};return f(c,u,d),d=0,h.forEach((t=>{for(;d{for(;d>t;)a+=s[0],d--;a+=s[1],d--})),n&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r;if([t,r]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...s,"."];t=[...t].filter((t=>e.includes(t))).join("")}const n=t.split(".");if(i.integrity&&n.length>2)throw new a(null,"There are multiple decimal points in the input.");const[o,h]=n;let l=N(0),c=this.#h.minus(1),u=N(1);if([...o].reverse().forEach((t=>{const e=s.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new a(t);[c,u]=this.#l(c,u)})),h){let t=N(1);u=this.#h.minus(t),[...h].forEach((e=>{const i=s.indexOf(e);if(1===i)l=l.plus(u);else if(0!==i)throw new a(e);[u,t]=this.#u(u,t)}))}if(i.decimalMode)return l.toNumber();l=l.round().toFixed();const d=this.b10.decode(l,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(d,i.outputType,i.littleEndian,r)}#c(t){return!t.round(50).abs().toNumber()}#l(t,e){return[e,t.plus(e)]}#u(t,e){return[e.minus(t),t]}}const D=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class P{constructor(...t){this.littleEndian=D,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,e=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const r=s.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!s.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${r}`);i.outputType=t}})),e)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e);return i.toBytes(t,s)[0]}decode(t,...e){const i=this.utils.validateArgs(e);return s.compile(t,i.outputType,i.littleEndian)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let s;return s="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,s}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,s;if(Number.isInteger(t)){if(s="int",!Number.isSafeInteger(t)){let e,i,s;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",s="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",s="MAX"),new RangeError(`The provided integer is ${i} than ${s}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else s="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),s]}static bigInts(t,e=!1){const i=new Array,s=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[s](t%r),t>>=64n;else for(;t>=r;)i[s](t%r),t>>=64n;i[s](t);const n=8*i.length,o=this.makeDataView(n);return i.forEach(((t,i)=>{const s=8*i;o.setBigUint64(s,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,s=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(s=!0,t=-t),e.numberMode){const s=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(s.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(s=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const s=new Array;for(const i of t)s.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(s)}}return[i,s,r]}}class s{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,s){const r=t.byteLength,n=(e-t.byteLength%e)%e,o=s&&r>1?255:0;let a=t;if(n){a=new Uint8Array(r+n),a.fill(o);const e=i?0:n;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,s){let r;if("int16"===e||"uint16"===e){const n=this.makeTypedArrayBuffer(t,2,i,s);r="int16"===e?new Int16Array(n):new Uint16Array(n)}else if("int32"===e||"uint32"===e||"float32"===e){const n=this.makeTypedArrayBuffer(t,4,i,s);r="int32"===e?new Int32Array(n):"uint32"===e?new Uint32Array(n):new Float32Array(n)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const n=this.makeTypedArrayBuffer(t,8,i,s);r="bigint64"===e?new BigInt64Array(n):"biguint64"===e?new BigUint64Array(n):new Float64Array(n)}return r}static compile(t,e,s=!1,r=!1){let n;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",s):-this.compile(t,"uint_n",s),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:s,numberMode:!1,signed:!1})[0]}if("buffer"===e)n=t.buffer;else if("bytes"===e||"uint8"===e)n=t;else if("int8"===e)n=new Int8Array(t.buffer);else if("view"===e)n=new DataView(t.buffer);else if("str"===e)n=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,s,r);t=new Uint8Array(e)}s&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),n="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);n=new DataView(e.buffer).getFloat32(0,s)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);n=new DataView(e.buffer).getFloat64(0,s)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);n=Number(e)}else n=this.makeTypedArray(t,e,s,r);return n}}const r=i,n=s;class o extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class a extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class h{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],s=!0)=>{const r=(t,i,s)=>{if(0===s&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=s;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===s)return[...i];if(r!==s)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${s}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";s<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const n=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${n.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");s&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const n=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=n,o.length&&(this.root.padChars[t]=o),s&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,s){throw new TypeError([`'${t}'\n\nParameters:`,s?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const c=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(c.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,c,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new o}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,s=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=s,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[c,l]=this.divmod(c,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(c,10));a.lengthu=u.concat(e[t]))),s&&(u=s(u,o)),n=n.concat(u)}return[n,o]}decode(t,e,i=[],s=!0,r=!1){if(!t)return new Uint8Array(0);let n=this.bsDec;const o=[];let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)o.push(r);else if(s&&-1===i.indexOf(t))throw new a(t)})),0===n)n=o.length;else{h=(n-o.length%n)%n;const t=new Array(h).fill(this.decPadVal);r?o.unshift(...t):o.push(...t)}let l=new Array;for(let t=0,e=o.length;t(this.powers[s]=BigInt(this.pow(s)),this.powers[s]))();e+=BigInt(o[t+i])*r}const i=[];let s,r=e;for(;r>=256;)[r,s]=this.divmod(r,256),i.unshift(parseInt(s,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class c{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new h(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...s){const r=this.utils.validateArgs(s);let[n,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,c]=this.converter.encode(n,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:n,output:l,settings:r,zeroPadding:c,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,s,...r){const n=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,s);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:n}));let a=this.converter.decode(t,this.charsets[n.version],this.padChars[n.version],n.integrity,n.littleEndian);return i&&(a=i({input:t,output:a,settings:n})),this.utils.outputHandler.compile(a,n.outputType,n.littleEndian,o)}}class u extends c{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new l(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s,r;[s,r]=this.utils.inputHandler.toBytes(t,i);let n=this.converter.encode(s,null,i.littleEndian)[0],o=BigInt(n);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],h=a.length;let l="";if(1===h)l=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(l=a.at(1).repeat((o-t)/5)),l+=a.at(0).repeat(t)}else for(let t=0;t(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}class f extends c{constructor(...t){super(),this.converter=new l(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class p extends c{constructor(...t){super(),this.converter=new l(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:s})=>{if(i.padding&&"int"!==s){let s=0;const r=t.length,n=this.charsets[i.version].at(0);if(r){for(;!t[s];)if(s++,s===r){s=0;break}const i=s;i&&(e=n.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const s=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===s;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}class g extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class b extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||w()} ${e.options.file||m()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${s.at(r)}${e.join("")}\n`;break}t+=`${s.at(45)}${e.join("")}\n`}return t+=`${s.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const s=this.charsets[e.version],r=t.trim().split(/\r?\n/),n=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=s.indexOf(r.shift());if(!(o>0))break;if(n.push(...r),45!==o){i=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;n.length%60;)n.push(" ")}return n.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const w=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},m=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};class y extends c{constructor(...t){super(),this.converter=new l(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}class v extends c{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.utils.inputHandler.toBytes(t,i)[0];let r=0,n=0,o="";const a=this.charsets[i.version];if(s.forEach((t=>{if(n+=t<13){let t,e,i=13,s=n%8192;s<89&&(i=14,s=n%16384),n>>=i,r-=i,[t,e]=this.#s(s,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#s(n,91),o=o.concat(a[e]),(r>7||n>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>s.includes(t))));let n=r.length,o=!1;n%2&&(o=!0,n--);let h=0,l=0;const c=new Array;for(let t=0;t88?13:14;do{c.push(h%256),h>>=8,l-=8}while(l>7)}if(o){const t=r.at(n),e=s.indexOf(t);c.push(((e<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){h.push(t);break}h.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){h.push(t);break}h.push(128|t)}const l=Uint8Array.from(h);return"hex"===i.version?this.hexlify.encode(l,[..."0123456789abcdef"],!1)[0]:l}decode(e,...i){const s=this.utils.validateArgs(i);if("hex"===s.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],s.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);e=Array.from(e);let r,n,o,a=0n,h=-7n;for(r of e)h+=7n,a+=BigInt(127&r)<{e.forEach((e=>{e in this.#r?this.#r[e].version+=t:this.#r[e]={version:t}}))},i=(e,i,s)=>{i.forEach((i=>{i in t?this.#r[i].version=3:(this.#r[i]={version:e,padding:s},t[i]=s)}))};e(1,this.charsets.emojis_v1),e(2,this.charsets.emojis_v2),i(1,this.padChars.emojis_v1.slice(0,-1),"last"),i(2,this.padChars.emojis_v2.slice(0,-1),"last"),i(1,this.padChars.emojis_v1.slice(-1),"fill"),i(2,this.padChars.emojis_v2.slice(-1),"fill");const s=[];for(const e in t)"last"===t[e]?s.push(e):s.push(`${e}+`);this.#n=new RegExp(s.join("|"),"g")}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version];let r=[...t];if(i>1){const t=this.converter.padBytes(i);if(e.padding){const i=e.trim?1:t,s=new Array(i).fill(this.padChars[e.version].at(-1));r.splice(r.length-t,t,...s)}else r.splice(r.length-t,t)}else if(1===i){const t=s.indexOf(r.pop())>>8;r.push(this.padChars[e.version].at(t))}return r.join("")}),...e)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);let s=i.version,r=null;"emojis_v1"!==i.version&&"emojis_v2"!==i.version||(r=3);const n=t=>{null!==r&&(r=this.#a(t,r,i.integrity),s=3===r?i.version:`emojis_v${r}`);const e=this.charsets[s],n=[...t],o=n.at(-1);let a=!1;for(let i=0;i{const r=s.index+s.at(0).length;e.push(...n(t.slice(i,r))),i=r})),i!==t.length&&e.push(...n(t.slice(i,t.length))),a=Uint8Array.from(e)}return this.utils.outputHandler.compile(a,i.outputType)}#a(t,e,i){const s=[...t];let r;if(s.forEach(((t,s)=>{if(!(t in this.#r))throw new a(t);{const n=this.#r[t].version;if(3!==n)if(3===e)e=n;else if(e!==n)throw new TypeError(`Emojis from different ecoji versions seen : ${t} from emojis_v${n}`);if(i){const e=this.#r[t].padding;if(e){const i=s%4;if(r=!0,"fill"===e){if(0===i)throw new TypeError(`Padding unexpectedly seen in first position ${t}`)}else if(3!==i)throw new TypeError(`Last padding seen in unexpected position ${t}`)}else if(r)throw new TypeError("Unexpectedly saw non-padding after padding")}}})),i&&s.length%4&&(1===e||"fill"!==this.#r[s.at(-1)].padding))throw new TypeError("Unexpected end of data, input data size not multiple of 4");return e}}class x extends c{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s=this.utils.inputHandler.toBytes(t,i).at(0);const r=this.charsets[i.version],n=this.padChars[i.version];let o="",a=0,h=0;if(s.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=r.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?n.at(a):r.at(a)}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const s=[...t],r=this.charsets[i.version],n=this.padChars[i.version],o=new Array;let h=0,l=0;return s.forEach(((t,e)=>{let c,u=r.indexOf(t);if(u>-1)c=this.converter.bsEnc;else if(u=n.indexOf(t),u>-1){if(e+1!==s.length)throw new a(null,`Secondary character found before end of input, index: ${e}`);c=this.converter.bsEncPad}else if(i.integrity)throw new a(t);for(let t=c-1;t>=0;t--)h=(h<<1)+(u>>t&1),l++,l===this.converter.bsDec&&(o.push(h),h=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(o),i.outputType)}}class T extends c{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new l(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}let M=1e6,j="[big.js] ",C=j+"Invalid ",I=C+"decimal places",$=C+"rounding mode",k={},B=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function _(t,e,i,s){let r=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error($);if(e<1)s=3===i&&(s||!!r[0])||0===e&&(1===i&&r[0]>=5||2===i&&(r[0]>5||5===r[0]&&(s||void 0!==r[1]))),r.length=1,s?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e=5||2===i&&(r[e]>5||5===r[e]&&(s||void 0!==r[e+1]||1&r[e-1]))||3===i&&(s||!!r[0]),r.length=e,s)for(;++r[--e]>9;)if(r[e]=0,0===e){++t.e,r.unshift(1);break}for(e=r.length;!r[--e];)r.pop()}return t}function S(t,e,i){let s=t.e,r=t.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)r="0"+r;r="0."+r}else if(s>0)if(++s>n)for(s-=n;s--;)r+="0";else s1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&i?"-"+r:r}k.abs=function(){let t=new this.constructor(this);return t.s=1,t},k.cmp=function(t){let e,i=this,s=i.c,r=(t=new i.constructor(t)).c,n=i.s,o=t.s,a=i.e,h=t.e;if(!s[0]||!r[0])return s[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=h)return a>h^e?1:-1;for(o=(a=s.length)<(h=r.length)?a:h,n=-1;++nr[n]^e?1:-1;return a==h?0:a>h^e?1:-1},k.eq=function(t){return 0===this.cmp(t)},k.gt=function(t){return this.cmp(t)>0},k.gte=function(t){return this.cmp(t)>-1},k.lt=function(t){return this.cmp(t)<0},k.lte=function(t){return this.cmp(t)<1},k.minus=k.sub=function(t){let e,i,s,r,n=this,o=n.constructor,a=n.s,h=(t=new o(t)).s;if(a!=h)return t.s=-h,n.plus(t);let l=n.c.slice(),c=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-h:l[0]?t=new o(n):t.s=1,t;if(a=c-d){for((r=a<0)?(a=-a,s=l):(d=c,s=u),s.reverse(),h=a;h--;)s.push(0);s.reverse()}else for(i=((r=l.length0)for(;h--;)l[e++]=0;for(h=e;i>a;){if(l[--i]0?(h=o,s=l):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),e=l.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+l[e]+i)/10|0;for(i&&(a.unshift(i),++h),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=h,t},k.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-M||t>M)throw Error(I);return _(new this.constructor(this),t+this.e+1,e)},k.toFixed=function(t,e){let i=this,s=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>M)throw Error(I);for(i=_(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},k.toNumber=function(){let t=Number(S(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(j+"Imprecise conversion");return t};const N=function t(){function e(i){let s=this;if(!(s instanceof e))return void 0===i?t():new e(i);if(i instanceof e)s.s=i.s,s.e=i.e,s.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(C+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,s,r;if(!B.test(e))throw Error(`${C}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(i<0&&(i=s),i+=+e.slice(s+1),e=e.substring(0,s)):i<0&&(i=e.length),r=e.length,s=0;s0&&"0"==e.charAt(--r););for(t.e=i-s-1,t.c=[],i=0;s<=r;)t.c[i++]=+e.charAt(s++)}}(s,i)}s.constructor=e}return e.prototype=k,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();class U extends c{#h=N("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r,n,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(n=!0,o=N(-t)):(n=!1,o=N(t))}else[r,n]=this.utils.inputHandler.toBytes(t,i),o=N(this.b10.encode(r,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=s[o.toNumber()],n&&(a=`-${a}`),a;const h=[],l=[];let c=N(1),u=this.#h,d=0;for(;u.lt(o);)[c,u]=this.#l(c,u),d++;const f=(t,e,i)=>{if(!this.#c(o)){for(;t.gt(o);){if([t,e]=this.#u(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?h.unshift(i):l.push(i),o=o.minus(t),f(t,e,i)}};return f(c,u,d),d=0,h.forEach((t=>{for(;d{for(;d>t;)a+=s[0],d--;a+=s[1],d--})),n&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r;if([t,r]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...s,"."];t=[...t].filter((t=>e.includes(t))).join("")}const n=t.split(".");if(i.integrity&&n.length>2)throw new a(null,"There are multiple decimal points in the input.");const[o,h]=n;let l=N(0),c=this.#h.minus(1),u=N(1);if([...o].reverse().forEach((t=>{const e=s.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new a(t);[c,u]=this.#l(c,u)})),h){let t=N(1);u=this.#h.minus(t),[...h].forEach((e=>{const i=s.indexOf(e);if(1===i)l=l.plus(u);else if(0!==i)throw new a(e);[u,t]=this.#u(u,t)}))}if(i.decimalMode)return l.toNumber();l=l.round().toFixed();const d=this.b10.decode(l,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(d,i.outputType,i.littleEndian,r)}#c(t){return!t.round(50).abs().toNumber()}#l(t,e){return[e,t.plus(e)]}#u(t,e){return[e.minus(t),t]}}const D=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class P{constructor(...t){this.littleEndian=D,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,e=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const r=s.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!s.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${r}`);i.outputType=t}})),e)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e);return i.toBytes(t,s)[0]}decode(t,...e){const i=this.utils.validateArgs(e);return s.compile(t,i.outputType,i.littleEndian)}} /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * diff --git a/dist/base-ex.iife.js b/dist/base-ex.iife.js index de43f3b..0e311f9 100644 --- a/dist/base-ex.iife.js +++ b/dist/base-ex.iife.js @@ -1155,23 +1155,17 @@ var BaseEx = (function (exports) { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/base-ex.iife.min.js b/dist/base-ex.iife.min.js index 53e11ea..9a24318 100644 --- a/dist/base-ex.iife.min.js +++ b/dist/base-ex.iife.min.js @@ -1,4 +1,4 @@ -var BaseEx=function(t){"use strict";class e{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class i{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!i.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,e){let s;return s="buffer"===(e=i.getType(e))?t.buffer:"view"===e?new DataView(t.buffer):t,s}}class s{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,s;if(Number.isInteger(t)){if(s="int",!Number.isSafeInteger(t)){let e,i,s;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",s="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",s="MAX"),new RangeError(`The provided integer is ${i} than ${s}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else s="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),s]}static bigInts(t,e=!1){const i=new Array,s=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[s](t%r),t>>=64n;else for(;t>=r;)i[s](t%r),t>>=64n;i[s](t);const n=8*i.length,o=this.makeDataView(n);return i.forEach(((t,i)=>{const s=8*i;o.setBigUint64(s,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,s=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(s=!0,t=-t),e.numberMode){const s=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(s.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(s=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const s=new Array;for(const i of t)s.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(s)}}return[i,s,r]}}class r{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,s){const r=t.byteLength,n=(e-t.byteLength%e)%e,o=s&&r>1?255:0;let a=t;if(n){a=new Uint8Array(r+n),a.fill(o);const e=i?0:n;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,s){let r;if("int16"===e||"uint16"===e){const n=this.makeTypedArrayBuffer(t,2,i,s);r="int16"===e?new Int16Array(n):new Uint16Array(n)}else if("int32"===e||"uint32"===e||"float32"===e){const n=this.makeTypedArrayBuffer(t,4,i,s);r="int32"===e?new Int32Array(n):"uint32"===e?new Uint32Array(n):new Float32Array(n)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const n=this.makeTypedArrayBuffer(t,8,i,s);r="bigint64"===e?new BigInt64Array(n):"biguint64"===e?new BigUint64Array(n):new Float64Array(n)}return r}static compile(t,e,i=!1,r=!1){let n;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=s.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)n=t.buffer;else if("bytes"===e||"uint8"===e)n=t;else if("int8"===e)n=new Int8Array(t.buffer);else if("view"===e)n=new DataView(t.buffer);else if("str"===e)n=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let s=0n;t.forEach((t=>s=(s<<8n)+BigInt(t))),"uint_n"!==e&&(s=BigInt.asIntN(8*t.length,s)),n="bigint_n"!==e&&s>=Number.MIN_SAFE_INTEGER&&s<=Number.MAX_SAFE_INTEGER?Number(s):s}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);n=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);n=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);n=Number(e)}else n=this.makeTypedArray(t,e,i,r);return n}}const n=s,o=r;class a extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class h extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class l{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=o){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],s=!0)=>{const r=(t,i,s)=>{if(0===s&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=s;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===s)return[...i];if(r!==s)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${s}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";s<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const n=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${n.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");s&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const n=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=n,o.length&&(this.root.padChars[t]=o),s&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,s){throw new TypeError([`'${t}'\n\nParameters:`,s?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(t,s=!1){const r={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)r[t]=this.root[t];if(!t.length)return s&&this.setIOHandlers(),r;const a=e=>!!t.includes(e)&&(t.splice(t.indexOf(e),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(e,i);else{const t=a("bytes_in")?e:n,s=a("bytes_out")?i:o;this.setIOHandlers(t,s)}const c=this.outputHandler.typeList;if(a("number")&&(r.numberMode=!0,r.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");r.decimalMode=!0,r.outputType="decimal",r.numberMode&&(r.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(t.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))r.version=t;else if(c.includes(t))r.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);r[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,c,s)}else r.options={...r.options,...t}})),r.padding&&r.signed&&(r.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in r)this.root[t]=r[t];return r}signError(){throw new a}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class c{constructor(t,e=null,i=null,s=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=s,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[c,l]=this.divmod(c,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(c,10));a.lengthu=u.concat(e[t]))),s&&(u=s(u,o)),n=n.concat(u)}return[n,o]}decode(t,e,i=[],s=!0,r=!1){if(!t)return new Uint8Array(0);let n=this.bsDec;const o=[],a=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=a[t];if(void 0!==e)o.push(e);else if(s&&-1===i.indexOf(t))throw new h(t)})),0===n)n=o.length;else{l=(n-o.length%n)%n;const t=new Array(l).fill(this.decPadVal);r?o.unshift(...t):o.push(...t)}let c=new Array;for(let t=0,e=o.length;t(this.powers[s]=BigInt(this.pow(s)),this.powers[s]))();e+=BigInt(o[t+i])*r}const i=[];let s,r=e;for(;r>=256;)[r,s]=this.divmod(r,256),i.unshift(parseInt(s,10));for(i.unshift(parseInt(r,10));i.length1){for(;!c[0];)c.shift();c.length||c.push(0),c.reverse()}}else if(this.bsDec){const t=this.padChars(l);c.splice(c.length-t)}return Uint8Array.from(c)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class u{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new l(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...s){const r=this.utils.validateArgs(s);let[n,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,c]=this.converter.encode(n,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:n,output:l,settings:r,zeroPadding:c,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,s,...r){const n=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,s);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:n}));let a=this.converter.decode(t,this.charsets[n.version],this.padChars[n.version],n.integrity,n.littleEndian);return i&&(a=i({input:t,output:a,settings:n})),this.utils.outputHandler.compile(a,n.outputType,n.littleEndian,o)}}class d extends u{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new c(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s,r;[s,r]=this.utils.inputHandler.toBytes(t,i);let n=this.converter.encode(s,null,i.littleEndian)[0],o=BigInt(n);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],h=a.length;let l="";if(1===h)l=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(l=a.at(1).repeat((o-t)/5)),l+=a.at(0).repeat(t)}else for(let t=0;t(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}class p extends u{constructor(...t){super(),this.converter=new c(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class g extends u{constructor(...t){super(),this.converter=new c(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:s})=>{if(i.padding&&"int"!==s){let s=0;const r=t.length,n=this.charsets[i.version].at(0);if(r){for(;!t[s];)if(s++,s===r){s=0;break}const i=s;i&&(e=n.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const s=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===s;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}class b extends u{constructor(...t){super(),this.converter=new c(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class w extends u{constructor(...t){super(),this.converter=new c(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||m()} ${e.options.file||y()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${s.at(r)}${e.join("")}\n`;break}t+=`${s.at(45)}${e.join("")}\n`}return t+=`${s.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const s=this.charsets[e.version],r=t.trim().split(/\r?\n/),n=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=s.indexOf(r.shift());if(!(o>0))break;if(n.push(...r),45!==o){i=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;n.length%60;)n.push(" ")}return n.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const m=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},y=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};class v extends u{constructor(...t){super(),this.converter=new c(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}class E extends u{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.utils.inputHandler.toBytes(t,i)[0];let r=0,n=0,o="";const a=this.charsets[i.version];if(s.forEach((t=>{if(n+=t<13){let t,e,i=13,s=n%8192;s<89&&(i=14,s=n%16384),n>>=i,r-=i,[t,e]=this.#s(s,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#s(n,91),o=o.concat(a[e]),(r>7||n>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>s.includes(t))));let n=r.length,o=!1;n%2&&(o=!0,n--);let a=0,l=0;const c=new Array;for(let t=0;t88?13:14;do{c.push(a%256),a>>=8,l-=8}while(l>7)}if(o){const t=r.at(n),e=s.indexOf(t);c.push(((e<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){h.push(t);break}h.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){h.push(t);break}h.push(128|t)}const l=Uint8Array.from(h);return"hex"===i.version?this.hexlify.encode(l,[..."0123456789abcdef"],!1)[0]:l}decode(t,...i){const s=this.utils.validateArgs(i);if("hex"===s.version)t=this.hexlify.decode(this.utils.normalizeInput(t).toLowerCase(),[..."0123456789abcdef"],[],s.integrity,!1);else{if(void 0===t.byteLength)throw new TypeError("Input must be a bytes like object.");t=e.toBytes(t)[0]}if(1===t.length&&!t[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);t=Array.from(t);let r,n,o,a=0n,h=-7n;for(r of t)h+=7n,a+=BigInt(127&r)<{e.forEach((e=>{e in this.#r?this.#r[e].version+=t:this.#r[e]={version:t}}))},i=(e,i,s)=>{i.forEach((i=>{i in t?this.#r[i].version=3:(this.#r[i]={version:e,padding:s},t[i]=s)}))};e(1,this.charsets.emojis_v1),e(2,this.charsets.emojis_v2),i(1,this.padChars.emojis_v1.slice(0,-1),"last"),i(2,this.padChars.emojis_v2.slice(0,-1),"last"),i(1,this.padChars.emojis_v1.slice(-1),"fill"),i(2,this.padChars.emojis_v2.slice(-1),"fill");const s=[];for(const e in t)"last"===t[e]?s.push(e):s.push(`${e}+`);this.#n=new RegExp(s.join("|"),"g")}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version];let r=[...t];if(i>1){const t=this.converter.padBytes(i);if(e.padding){const i=e.trim?1:t,s=new Array(i).fill(this.padChars[e.version].at(-1));r.splice(r.length-t,t,...s)}else r.splice(r.length-t,t)}else if(1===i){const t=s.indexOf(r.pop())>>8;r.push(this.padChars[e.version].at(t))}return r.join("")}),...e)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);let s=i.version,r=null;"emojis_v1"!==i.version&&"emojis_v2"!==i.version||(r=3);const n=t=>{null!==r&&(r=this.#a(t,r,i.integrity),s=3===r?i.version:`emojis_v${r}`);const e=this.charsets[s],n=[...t],o=n.at(-1);let a=!1;for(let i=0;i{const r=s.index+s.at(0).length;e.push(...n(t.slice(i,r))),i=r})),i!==t.length&&e.push(...n(t.slice(i,t.length))),a=Uint8Array.from(e)}return this.utils.outputHandler.compile(a,i.outputType)}#a(t,e,i){const s=[...t];let r;if(s.forEach(((t,s)=>{if(!(t in this.#r))throw new h(t);{const n=this.#r[t].version;if(3!==n)if(3===e)e=n;else if(e!==n)throw new TypeError(`Emojis from different ecoji versions seen : ${t} from emojis_v${n}`);if(i){const e=this.#r[t].padding;if(e){const i=s%4;if(r=!0,"fill"===e){if(0===i)throw new TypeError(`Padding unexpectedly seen in first position ${t}`)}else if(3!==i)throw new TypeError(`Last padding seen in unexpected position ${t}`)}else if(r)throw new TypeError("Unexpectedly saw non-padding after padding")}}})),i&&s.length%4&&(1===e||"fill"!==this.#r[s.at(-1)].padding))throw new TypeError("Unexpected end of data, input data size not multiple of 4");return e}}class T extends u{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s=this.utils.inputHandler.toBytes(t,i).at(0);const r=this.charsets[i.version],n=this.padChars[i.version];let o="",a=0,h=0;if(s.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=r.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?n.at(a):r.at(a)}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const s=[...t],r=this.charsets[i.version],n=this.padChars[i.version],o=new Array;let a=0,l=0;return s.forEach(((t,e)=>{let c,u=r.indexOf(t);if(u>-1)c=this.converter.bsEnc;else if(u=n.indexOf(t),u>-1){if(e+1!==s.length)throw new h(null,`Secondary character found before end of input, index: ${e}`);c=this.converter.bsEncPad}else if(i.integrity)throw new h(t);for(let t=c-1;t>=0;t--)a=(a<<1)+(u>>t&1),l++,l===this.converter.bsDec&&(o.push(a),a=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(o),i.outputType)}}class M extends u{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new c(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}let j=1e6,B="[big.js] ",C=B+"Invalid ",I=C+"decimal places",$=C+"rounding mode",k={},_=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function S(t,e,i,s){let r=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error($);if(e<1)s=3===i&&(s||!!r[0])||0===e&&(1===i&&r[0]>=5||2===i&&(r[0]>5||5===r[0]&&(s||void 0!==r[1]))),r.length=1,s?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e=5||2===i&&(r[e]>5||5===r[e]&&(s||void 0!==r[e+1]||1&r[e-1]))||3===i&&(s||!!r[0]),r.length=e,s)for(;++r[--e]>9;)if(r[e]=0,0===e){++t.e,r.unshift(1);break}for(e=r.length;!r[--e];)r.pop()}return t}function N(t,e,i){let s=t.e,r=t.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)r="0"+r;r="0."+r}else if(s>0)if(++s>n)for(s-=n;s--;)r+="0";else s1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&i?"-"+r:r}k.abs=function(){let t=new this.constructor(this);return t.s=1,t},k.cmp=function(t){let e,i=this,s=i.c,r=(t=new i.constructor(t)).c,n=i.s,o=t.s,a=i.e,h=t.e;if(!s[0]||!r[0])return s[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=h)return a>h^e?1:-1;for(o=(a=s.length)<(h=r.length)?a:h,n=-1;++nr[n]^e?1:-1;return a==h?0:a>h^e?1:-1},k.eq=function(t){return 0===this.cmp(t)},k.gt=function(t){return this.cmp(t)>0},k.gte=function(t){return this.cmp(t)>-1},k.lt=function(t){return this.cmp(t)<0},k.lte=function(t){return this.cmp(t)<1},k.minus=k.sub=function(t){let e,i,s,r,n=this,o=n.constructor,a=n.s,h=(t=new o(t)).s;if(a!=h)return t.s=-h,n.plus(t);let l=n.c.slice(),c=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-h:l[0]?t=new o(n):t.s=1,t;if(a=c-d){for((r=a<0)?(a=-a,s=l):(d=c,s=u),s.reverse(),h=a;h--;)s.push(0);s.reverse()}else for(i=((r=l.length0)for(;h--;)l[e++]=0;for(h=e;i>a;){if(l[--i]0?(h=o,s=l):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),e=l.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+l[e]+i)/10|0;for(i&&(a.unshift(i),++h),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=h,t},k.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-j||t>j)throw Error(I);return S(new this.constructor(this),t+this.e+1,e)},k.toFixed=function(t,e){let i=this,s=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>j)throw Error(I);for(i=S(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},k.toNumber=function(){let t=Number(N(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(B+"Imprecise conversion");return t};const U=function t(){function e(i){let s=this;if(!(s instanceof e))return void 0===i?t():new e(i);if(i instanceof e)s.s=i.s,s.e=i.e,s.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(C+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,s,r;if(!_.test(e))throw Error(`${C}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(i<0&&(i=s),i+=+e.slice(s+1),e=e.substring(0,s)):i<0&&(i=e.length),r=e.length,s=0;s0&&"0"==e.charAt(--r););for(t.e=i-s-1,t.c=[],i=0;s<=r;)t.c[i++]=+e.charAt(s++)}}(s,i)}s.constructor=e}return e.prototype=k,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();class D extends u{#h=U("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new c(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r,n,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(n=!0,o=U(-t)):(n=!1,o=U(t))}else[r,n]=this.utils.inputHandler.toBytes(t,i),o=U(this.b10.encode(r,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=s[o.toNumber()],n&&(a=`-${a}`),a;const h=[],l=[];let c=U(1),u=this.#h,d=0;for(;u.lt(o);)[c,u]=this.#l(c,u),d++;const f=(t,e,i)=>{if(!this.#c(o)){for(;t.gt(o);){if([t,e]=this.#u(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?h.unshift(i):l.push(i),o=o.minus(t),f(t,e,i)}};return f(c,u,d),d=0,h.forEach((t=>{for(;d{for(;d>t;)a+=s[0],d--;a+=s[1],d--})),n&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r;if([t,r]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...s,"."];t=[...t].filter((t=>e.includes(t))).join("")}const n=t.split(".");if(i.integrity&&n.length>2)throw new h(null,"There are multiple decimal points in the input.");const[o,a]=n;let l=U(0),c=this.#h.minus(1),u=U(1);if([...o].reverse().forEach((t=>{const e=s.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new h(t);[c,u]=this.#l(c,u)})),a){let t=U(1);u=this.#h.minus(t),[...a].forEach((e=>{const i=s.indexOf(e);if(1===i)l=l.plus(u);else if(0!==i)throw new h(e);[u,t]=this.#u(u,t)}))}if(i.decimalMode)return l.toNumber();l=l.round().toFixed();const d=this.b10.decode(l,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(d,i.outputType,i.littleEndian,r)}#c(t){return!t.round(50).abs().toNumber()}#l(t,e){return[e,t.plus(e)]}#u(t,e){return[e.minus(t),t]}}const P=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class O{constructor(...t){this.littleEndian=P,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,e=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const s=r.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!r.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${s}`);i.outputType=t}})),e)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);return s.toBytes(t,i)[0]}decode(t,...e){const i=this.utils.validateArgs(e);return r.compile(t,i.outputType,i.littleEndian)}} +var BaseEx=function(t){"use strict";class e{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class i{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!i.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,e){let s;return s="buffer"===(e=i.getType(e))?t.buffer:"view"===e?new DataView(t.buffer):t,s}}class s{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,s;if(Number.isInteger(t)){if(s="int",!Number.isSafeInteger(t)){let e,i,s;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",s="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",s="MAX"),new RangeError(`The provided integer is ${i} than ${s}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else s="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),s]}static bigInts(t,e=!1){const i=new Array,s=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[s](t%r),t>>=64n;else for(;t>=r;)i[s](t%r),t>>=64n;i[s](t);const n=8*i.length,o=this.makeDataView(n);return i.forEach(((t,i)=>{const s=8*i;o.setBigUint64(s,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,s=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(s=!0,t=-t),e.numberMode){const s=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(s.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(s=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const s=new Array;for(const i of t)s.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(s)}}return[i,s,r]}}class r{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,s){const r=t.byteLength,n=(e-t.byteLength%e)%e,o=s&&r>1?255:0;let a=t;if(n){a=new Uint8Array(r+n),a.fill(o);const e=i?0:n;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,s){let r;if("int16"===e||"uint16"===e){const n=this.makeTypedArrayBuffer(t,2,i,s);r="int16"===e?new Int16Array(n):new Uint16Array(n)}else if("int32"===e||"uint32"===e||"float32"===e){const n=this.makeTypedArrayBuffer(t,4,i,s);r="int32"===e?new Int32Array(n):"uint32"===e?new Uint32Array(n):new Float32Array(n)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const n=this.makeTypedArrayBuffer(t,8,i,s);r="bigint64"===e?new BigInt64Array(n):"biguint64"===e?new BigUint64Array(n):new Float64Array(n)}return r}static compile(t,e,i=!1,r=!1){let n;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=s.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)n=t.buffer;else if("bytes"===e||"uint8"===e)n=t;else if("int8"===e)n=new Int8Array(t.buffer);else if("view"===e)n=new DataView(t.buffer);else if("str"===e)n=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let s=0n;t.forEach((t=>s=(s<<8n)+BigInt(t))),"uint_n"!==e&&(s=BigInt.asIntN(8*t.length,s)),n="bigint_n"!==e&&s>=Number.MIN_SAFE_INTEGER&&s<=Number.MAX_SAFE_INTEGER?Number(s):s}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);n=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);n=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);n=Number(e)}else n=this.makeTypedArray(t,e,i,r);return n}}const n=s,o=r;class a extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class h extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class l{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=o){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],s=!0)=>{const r=(t,i,s)=>{if(0===s&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=s;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===s)return[...i];if(r!==s)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${s}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";s<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const n=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${n.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");s&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const n=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=n,o.length&&(this.root.padChars[t]=o),s&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,s){throw new TypeError([`'${t}'\n\nParameters:`,s?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(t,s=!1){const r={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)r[t]=this.root[t];if(!t.length)return s&&this.setIOHandlers(),r;const a=e=>!!t.includes(e)&&(t.splice(t.indexOf(e),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(e,i);else{const t=a("bytes_in")?e:n,s=a("bytes_out")?i:o;this.setIOHandlers(t,s)}const c=this.outputHandler.typeList;if(a("number")&&(r.numberMode=!0,r.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");r.decimalMode=!0,r.outputType="decimal",r.numberMode&&(r.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(t.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))r.version=t;else if(c.includes(t))r.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);r[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,c,s)}else r.options={...r.options,...t}})),r.padding&&r.signed&&(r.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in r)this.root[t]=r[t];return r}signError(){throw new a}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class c{constructor(t,e=null,i=null,s=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=s,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[c,l]=this.divmod(c,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(c,10));a.lengthu=u.concat(e[t]))),s&&(u=s(u,o)),n=n.concat(u)}return[n,o]}decode(t,e,i=[],s=!0,r=!1){if(!t)return new Uint8Array(0);let n=this.bsDec;const o=[];let a;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)o.push(r);else if(s&&-1===i.indexOf(t))throw new h(t)})),0===n)n=o.length;else{a=(n-o.length%n)%n;const t=new Array(a).fill(this.decPadVal);r?o.unshift(...t):o.push(...t)}let l=new Array;for(let t=0,e=o.length;t(this.powers[s]=BigInt(this.pow(s)),this.powers[s]))();e+=BigInt(o[t+i])*r}const i=[];let s,r=e;for(;r>=256;)[r,s]=this.divmod(r,256),i.unshift(parseInt(s,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(a);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class u{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new l(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...s){const r=this.utils.validateArgs(s);let[n,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,c]=this.converter.encode(n,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:n,output:l,settings:r,zeroPadding:c,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,s,...r){const n=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,s);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:n}));let a=this.converter.decode(t,this.charsets[n.version],this.padChars[n.version],n.integrity,n.littleEndian);return i&&(a=i({input:t,output:a,settings:n})),this.utils.outputHandler.compile(a,n.outputType,n.littleEndian,o)}}class d extends u{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new c(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s,r;[s,r]=this.utils.inputHandler.toBytes(t,i);let n=this.converter.encode(s,null,i.littleEndian)[0],o=BigInt(n);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],h=a.length;let l="";if(1===h)l=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(l=a.at(1).repeat((o-t)/5)),l+=a.at(0).repeat(t)}else for(let t=0;t(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}class p extends u{constructor(...t){super(),this.converter=new c(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class g extends u{constructor(...t){super(),this.converter=new c(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:s})=>{if(i.padding&&"int"!==s){let s=0;const r=t.length,n=this.charsets[i.version].at(0);if(r){for(;!t[s];)if(s++,s===r){s=0;break}const i=s;i&&(e=n.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const s=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===s;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}class b extends u{constructor(...t){super(),this.converter=new c(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class w extends u{constructor(...t){super(),this.converter=new c(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||m()} ${e.options.file||y()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${s.at(r)}${e.join("")}\n`;break}t+=`${s.at(45)}${e.join("")}\n`}return t+=`${s.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const s=this.charsets[e.version],r=t.trim().split(/\r?\n/),n=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const r=[...t],o=s.indexOf(r.shift());if(!(o>0))break;if(n.push(...r),45!==o){i=this.converter.padChars(r.length)-o;break}if(60!==r.length&&"original"===e.version)for(;n.length%60;)n.push(" ")}return n.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const m=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},y=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};class v extends u{constructor(...t){super(),this.converter=new c(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}class E extends u{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.utils.inputHandler.toBytes(t,i)[0];let r=0,n=0,o="";const a=this.charsets[i.version];if(s.forEach((t=>{if(n+=t<13){let t,e,i=13,s=n%8192;s<89&&(i=14,s=n%16384),n>>=i,r-=i,[t,e]=this.#s(s,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#s(n,91),o=o.concat(a[e]),(r>7||n>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>s.includes(t))));let n=r.length,o=!1;n%2&&(o=!0,n--);let a=0,l=0;const c=new Array;for(let t=0;t88?13:14;do{c.push(a%256),a>>=8,l-=8}while(l>7)}if(o){const t=r.at(n),e=s.indexOf(t);c.push(((e<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){h.push(t);break}h.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){h.push(t);break}h.push(128|t)}const l=Uint8Array.from(h);return"hex"===i.version?this.hexlify.encode(l,[..."0123456789abcdef"],!1)[0]:l}decode(t,...i){const s=this.utils.validateArgs(i);if("hex"===s.version)t=this.hexlify.decode(this.utils.normalizeInput(t).toLowerCase(),[..."0123456789abcdef"],[],s.integrity,!1);else{if(void 0===t.byteLength)throw new TypeError("Input must be a bytes like object.");t=e.toBytes(t)[0]}if(1===t.length&&!t[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);t=Array.from(t);let r,n,o,a=0n,h=-7n;for(r of t)h+=7n,a+=BigInt(127&r)<{e.forEach((e=>{e in this.#r?this.#r[e].version+=t:this.#r[e]={version:t}}))},i=(e,i,s)=>{i.forEach((i=>{i in t?this.#r[i].version=3:(this.#r[i]={version:e,padding:s},t[i]=s)}))};e(1,this.charsets.emojis_v1),e(2,this.charsets.emojis_v2),i(1,this.padChars.emojis_v1.slice(0,-1),"last"),i(2,this.padChars.emojis_v2.slice(0,-1),"last"),i(1,this.padChars.emojis_v1.slice(-1),"fill"),i(2,this.padChars.emojis_v2.slice(-1),"fill");const s=[];for(const e in t)"last"===t[e]?s.push(e):s.push(`${e}+`);this.#n=new RegExp(s.join("|"),"g")}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version];let r=[...t];if(i>1){const t=this.converter.padBytes(i);if(e.padding){const i=e.trim?1:t,s=new Array(i).fill(this.padChars[e.version].at(-1));r.splice(r.length-t,t,...s)}else r.splice(r.length-t,t)}else if(1===i){const t=s.indexOf(r.pop())>>8;r.push(this.padChars[e.version].at(t))}return r.join("")}),...e)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);let s=i.version,r=null;"emojis_v1"!==i.version&&"emojis_v2"!==i.version||(r=3);const n=t=>{null!==r&&(r=this.#a(t,r,i.integrity),s=3===r?i.version:`emojis_v${r}`);const e=this.charsets[s],n=[...t],o=n.at(-1);let a=!1;for(let i=0;i{const r=s.index+s.at(0).length;e.push(...n(t.slice(i,r))),i=r})),i!==t.length&&e.push(...n(t.slice(i,t.length))),a=Uint8Array.from(e)}return this.utils.outputHandler.compile(a,i.outputType)}#a(t,e,i){const s=[...t];let r;if(s.forEach(((t,s)=>{if(!(t in this.#r))throw new h(t);{const n=this.#r[t].version;if(3!==n)if(3===e)e=n;else if(e!==n)throw new TypeError(`Emojis from different ecoji versions seen : ${t} from emojis_v${n}`);if(i){const e=this.#r[t].padding;if(e){const i=s%4;if(r=!0,"fill"===e){if(0===i)throw new TypeError(`Padding unexpectedly seen in first position ${t}`)}else if(3!==i)throw new TypeError(`Last padding seen in unexpected position ${t}`)}else if(r)throw new TypeError("Unexpectedly saw non-padding after padding")}}})),i&&s.length%4&&(1===e||"fill"!==this.#r[s.at(-1)].padding))throw new TypeError("Unexpected end of data, input data size not multiple of 4");return e}}class T extends u{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s=this.utils.inputHandler.toBytes(t,i).at(0);const r=this.charsets[i.version],n=this.padChars[i.version];let o="",a=0,h=0;if(s.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=r.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?n.at(a):r.at(a)}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const s=[...t],r=this.charsets[i.version],n=this.padChars[i.version],o=new Array;let a=0,l=0;return s.forEach(((t,e)=>{let c,u=r.indexOf(t);if(u>-1)c=this.converter.bsEnc;else if(u=n.indexOf(t),u>-1){if(e+1!==s.length)throw new h(null,`Secondary character found before end of input, index: ${e}`);c=this.converter.bsEncPad}else if(i.integrity)throw new h(t);for(let t=c-1;t>=0;t--)a=(a<<1)+(u>>t&1),l++,l===this.converter.bsDec&&(o.push(a),a=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(o),i.outputType)}}class M extends u{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new c(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}let j=1e6,B="[big.js] ",C=B+"Invalid ",I=C+"decimal places",$=C+"rounding mode",k={},_=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function S(t,e,i,s){let r=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error($);if(e<1)s=3===i&&(s||!!r[0])||0===e&&(1===i&&r[0]>=5||2===i&&(r[0]>5||5===r[0]&&(s||void 0!==r[1]))),r.length=1,s?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e=5||2===i&&(r[e]>5||5===r[e]&&(s||void 0!==r[e+1]||1&r[e-1]))||3===i&&(s||!!r[0]),r.length=e,s)for(;++r[--e]>9;)if(r[e]=0,0===e){++t.e,r.unshift(1);break}for(e=r.length;!r[--e];)r.pop()}return t}function N(t,e,i){let s=t.e,r=t.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)r="0"+r;r="0."+r}else if(s>0)if(++s>n)for(s-=n;s--;)r+="0";else s1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&i?"-"+r:r}k.abs=function(){let t=new this.constructor(this);return t.s=1,t},k.cmp=function(t){let e,i=this,s=i.c,r=(t=new i.constructor(t)).c,n=i.s,o=t.s,a=i.e,h=t.e;if(!s[0]||!r[0])return s[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=h)return a>h^e?1:-1;for(o=(a=s.length)<(h=r.length)?a:h,n=-1;++nr[n]^e?1:-1;return a==h?0:a>h^e?1:-1},k.eq=function(t){return 0===this.cmp(t)},k.gt=function(t){return this.cmp(t)>0},k.gte=function(t){return this.cmp(t)>-1},k.lt=function(t){return this.cmp(t)<0},k.lte=function(t){return this.cmp(t)<1},k.minus=k.sub=function(t){let e,i,s,r,n=this,o=n.constructor,a=n.s,h=(t=new o(t)).s;if(a!=h)return t.s=-h,n.plus(t);let l=n.c.slice(),c=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-h:l[0]?t=new o(n):t.s=1,t;if(a=c-d){for((r=a<0)?(a=-a,s=l):(d=c,s=u),s.reverse(),h=a;h--;)s.push(0);s.reverse()}else for(i=((r=l.length0)for(;h--;)l[e++]=0;for(h=e;i>a;){if(l[--i]0?(h=o,s=l):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),e=l.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+l[e]+i)/10|0;for(i&&(a.unshift(i),++h),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=h,t},k.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-j||t>j)throw Error(I);return S(new this.constructor(this),t+this.e+1,e)},k.toFixed=function(t,e){let i=this,s=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>j)throw Error(I);for(i=S(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},k.toNumber=function(){let t=Number(N(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(B+"Imprecise conversion");return t};const U=function t(){function e(i){let s=this;if(!(s instanceof e))return void 0===i?t():new e(i);if(i instanceof e)s.s=i.s,s.e=i.e,s.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(C+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,s,r;if(!_.test(e))throw Error(`${C}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(i<0&&(i=s),i+=+e.slice(s+1),e=e.substring(0,s)):i<0&&(i=e.length),r=e.length,s=0;s0&&"0"==e.charAt(--r););for(t.e=i-s-1,t.c=[],i=0;s<=r;)t.c[i++]=+e.charAt(s++)}}(s,i)}s.constructor=e}return e.prototype=k,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();class D extends u{#h=U("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new c(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r,n,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(n=!0,o=U(-t)):(n=!1,o=U(t))}else[r,n]=this.utils.inputHandler.toBytes(t,i),o=U(this.b10.encode(r,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=s[o.toNumber()],n&&(a=`-${a}`),a;const h=[],l=[];let c=U(1),u=this.#h,d=0;for(;u.lt(o);)[c,u]=this.#l(c,u),d++;const f=(t,e,i)=>{if(!this.#c(o)){for(;t.gt(o);){if([t,e]=this.#u(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?h.unshift(i):l.push(i),o=o.minus(t),f(t,e,i)}};return f(c,u,d),d=0,h.forEach((t=>{for(;d{for(;d>t;)a+=s[0],d--;a+=s[1],d--})),n&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r;if([t,r]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...s,"."];t=[...t].filter((t=>e.includes(t))).join("")}const n=t.split(".");if(i.integrity&&n.length>2)throw new h(null,"There are multiple decimal points in the input.");const[o,a]=n;let l=U(0),c=this.#h.minus(1),u=U(1);if([...o].reverse().forEach((t=>{const e=s.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new h(t);[c,u]=this.#l(c,u)})),a){let t=U(1);u=this.#h.minus(t),[...a].forEach((e=>{const i=s.indexOf(e);if(1===i)l=l.plus(u);else if(0!==i)throw new h(e);[u,t]=this.#u(u,t)}))}if(i.decimalMode)return l.toNumber();l=l.round().toFixed();const d=this.b10.decode(l,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(d,i.outputType,i.littleEndian,r)}#c(t){return!t.round(50).abs().toNumber()}#l(t,e){return[e,t.plus(e)]}#u(t,e){return[e.minus(t),t]}}const P=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class O{constructor(...t){this.littleEndian=P,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,e=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const s=r.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!r.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${s}`);i.outputType=t}})),e)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);return s.toBytes(t,i)[0]}decode(t,...e){const i=this.utils.validateArgs(e);return r.compile(t,i.outputType,i.littleEndian)}} /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * diff --git a/dist/converters/Base1/base-1.esm.js b/dist/converters/Base1/base-1.esm.js index ff0e304..c1338b9 100644 --- a/dist/converters/Base1/base-1.esm.js +++ b/dist/converters/Base1/base-1.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base1/base-1.esm.min.js b/dist/converters/Base1/base-1.esm.min.js index 1017fe2..1a601c9 100644 --- a/dist/converters/Base1/base-1.esm.min.js +++ b/dist/converters/Base1/base-1.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * diff --git a/dist/converters/Base1/base-1.iife.js b/dist/converters/Base1/base-1.iife.js index 9023497..4f89f21 100644 --- a/dist/converters/Base1/base-1.iife.js +++ b/dist/converters/Base1/base-1.iife.js @@ -1155,23 +1155,17 @@ var Base1 = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base1/base-1.iife.min.js b/dist/converters/Base1/base-1.iife.min.js index 69841d1..eeb237e 100644 --- a/dist/converters/Base1/base-1.iife.min.js +++ b/dist/converters/Base1/base-1.iife.min.js @@ -1,4 +1,4 @@ -var Base1=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base1=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * diff --git a/dist/converters/Base16/base-16.esm.js b/dist/converters/Base16/base-16.esm.js index a30f752..fbee29d 100644 --- a/dist/converters/Base16/base-16.esm.js +++ b/dist/converters/Base16/base-16.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base16/base-16.esm.min.js b/dist/converters/Base16/base-16.esm.min.js index 05ed634..49a2b92 100644 --- a/dist/converters/Base16/base-16.esm.min.js +++ b/dist/converters/Base16/base-16.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-16.js} * diff --git a/dist/converters/Base16/base-16.iife.js b/dist/converters/Base16/base-16.iife.js index 9de175a..bd022fc 100644 --- a/dist/converters/Base16/base-16.iife.js +++ b/dist/converters/Base16/base-16.iife.js @@ -1155,23 +1155,17 @@ var Base16 = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base16/base-16.iife.min.js b/dist/converters/Base16/base-16.iife.min.js index b0e758c..d805101 100644 --- a/dist/converters/Base16/base-16.iife.min.js +++ b/dist/converters/Base16/base-16.iife.min.js @@ -1,4 +1,4 @@ -var Base16=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+n])*i}const n=[];let r,i=e;for(;i>=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base16=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-16.js} * diff --git a/dist/converters/Base32/base-32.esm.js b/dist/converters/Base32/base-32.esm.js index 314adc9..f759d0c 100644 --- a/dist/converters/Base32/base-32.esm.js +++ b/dist/converters/Base32/base-32.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base32/base-32.esm.min.js b/dist/converters/Base32/base-32.esm.min.js index a9fe454..3bc8788 100644 --- a/dist/converters/Base32/base-32.esm.min.js +++ b/dist/converters/Base32/base-32.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let h;if([...t].forEach((t=>{const n=e.indexOf(t);if(n>-1)a.push(n);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * diff --git a/dist/converters/Base32/base-32.iife.js b/dist/converters/Base32/base-32.iife.js index e8f432b..31be598 100644 --- a/dist/converters/Base32/base-32.iife.js +++ b/dist/converters/Base32/base-32.iife.js @@ -1155,23 +1155,17 @@ var Base32 = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base32/base-32.iife.min.js b/dist/converters/Base32/base-32.iife.min.js index bff3ea1..cc9e4de 100644 --- a/dist/converters/Base32/base-32.iife.min.js +++ b/dist/converters/Base32/base-32.iife.min.js @@ -1,8 +1,8 @@ -var Base32=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,r){let i;return i="buffer"===(r=e.getType(r))?t.buffer:"view"===r?new DataView(t.buffer):t,i}}class r{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const r=this.makeDataView(8);return r.setFloat64(0,t,e),r}static numbers(t,e=!1){let r,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,r,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,r="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,r="bigger",i="MAX"),new RangeError(`The provided integer is ${r} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(r=this.makeDataView(8),r.setBigInt64(0,BigInt(t),e)):t<-32768?(r=this.makeDataView(4),r.setInt32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):t>0?t>4294967295?(r=this.makeDataView(8),r.setBigUint64(0,BigInt(t),e)):t>65535?(r=this.makeDataView(4),r.setUint32(0,t,e)):(r=this.makeDataView(2),r.setInt16(0,t,e)):r=new Uint16Array([0])}else i="float",r=this.floatingPoints(t,e);return[new Uint8Array(r.buffer),i]}static bigInts(t,e=!1){const r=new Array,i=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)r[i](t%n),t>>=64n;else for(;t>=n;)r[i](t%n),t>>=64n;r[i](t);const s=8*r.length,o=this.makeDataView(s);return r.forEach(((t,r)=>{const i=8*r;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let r,i=!1,n="bytes";if(t instanceof ArrayBuffer)r=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)r=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);r=new Uint8Array(i.buffer),n="float"}else[r,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),r=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const r of t)i.push(...this.toBytes(r,e)[0]);r=Uint8Array.from(i)}}return[r,i,n]}}const i=r,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,r,i){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=r?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,r,i){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,r,i);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,r,i);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,r,i);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,i=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return n;t=r.toBytes(n,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,n);t=new Uint8Array(e)}i&&t.reverse();let r=0n;t.forEach((t=>r=(r<<8n)+BigInt(t))),"uint_n"!==e&&(r=BigInt.asIntN(8*t.length,r)),s="bigint_n"!==e&&r>=Number.MIN_SAFE_INTEGER&&r<=Number.MAX_SAFE_INTEGER?Number(r):r}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,r=[],i=!0)=>{const n=(t,r,i)=>{if(0===i&&r.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${r}'`),[];let n=i;if("string"==typeof r&&(r=[...r]),Array.isArray(r))n=r.length,r=new Set(r);else if(!(r instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(r.size===i)return[...r];if(n!==i)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${i}.`);{const r={};(e=[...e]).forEach((t=>{t in r?r[t]++:r[t]=1}));let n="";i<100&&(n=`${e.join("")}\n`,e.forEach((t=>{r[t]>1?n+="^":n+=" "})));const s=Object.keys(r).filter((t=>r[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",r,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#r(t,e,r,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(r)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(r,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!r.length)return s&&this.setIOHandlers(),o;const a=t=>!!r.includes(t)&&(r.splice(r.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const r=a("bytes_in")?t:i,s=a("bytes_out")?e:n;this.setIOHandlers(r,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(r.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const r in l)if(l[r].includes(t)){if(e=!1,!this.root.isMutable[r])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[r]=Boolean(l[r].indexOf(t))}e&&this.#r(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const r=new RegExp(`.{1,${e}}`,"gu");return t.match(r).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,r=null,i=0){this.radix=t,null!==e&&null!==r?(this.bsEnc=e,this.bsDec=r):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let r=0;for(;8*r*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,r=[],i=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,r)=>e[t]=r)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(i&&-1===r.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+r])*n}const r=[];let i,n=e;for(;n>=256;)[n,i]=this.divmod(n,256),r.unshift(parseInt(i,10));for(r.unshift(parseInt(n,10));r.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,r,...i){const n=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),r&&(l=r({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,r,i,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return r&&(a=r({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base32=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let h;if([...t].forEach((t=>{const n=e.indexOf(t);if(n>-1)a.push(n);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */return class extends l{constructor(...t){super(),this.converter=new h(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:r})=>{if(!e.littleEndian&&r){const i=this.converter.padBytes(r),n=this.padChars[e.version].at(0);t=t.slice(0,-i),e.padding&&(t=t.concat(n.repeat(i)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}}(); + */return class extends l{constructor(...t){super(),this.converter=new h(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const r=this.converter.padBytes(i),n=this.padChars[e.version].at(0);t=t.slice(0,-r),e.padding&&(t=t.concat(n.repeat(r)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}}(); diff --git a/dist/converters/Base58/base-58.esm.js b/dist/converters/Base58/base-58.esm.js index 1813c71..717e7d6 100644 --- a/dist/converters/Base58/base-58.esm.js +++ b/dist/converters/Base58/base-58.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base58/base-58.esm.min.js b/dist/converters/Base58/base-58.esm.min.js index 7b1a28f..e1bf2c4 100644 --- a/dist/converters/Base58/base-58.esm.min.js +++ b/dist/converters/Base58/base-58.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * diff --git a/dist/converters/Base58/base-58.iife.js b/dist/converters/Base58/base-58.iife.js index dc15890..20a5bc1 100644 --- a/dist/converters/Base58/base-58.iife.js +++ b/dist/converters/Base58/base-58.iife.js @@ -1155,23 +1155,17 @@ var Base58 = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base58/base-58.iife.min.js b/dist/converters/Base58/base-58.iife.min.js index 3fe56af..5056afe 100644 --- a/dist/converters/Base58/base-58.iife.min.js +++ b/dist/converters/Base58/base-58.iife.min.js @@ -1,4 +1,4 @@ -var Base58=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base58=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * diff --git a/dist/converters/Base64/base-64.esm.js b/dist/converters/Base64/base-64.esm.js index aeaff20..a72f69e 100644 --- a/dist/converters/Base64/base-64.esm.js +++ b/dist/converters/Base64/base-64.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base64/base-64.esm.min.js b/dist/converters/Base64/base-64.esm.min.js index 9b2e394..fc13e4f 100644 --- a/dist/converters/Base64/base-64.esm.min.js +++ b/dist/converters/Base64/base-64.esm.min.js @@ -1,8 +1,8 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+n])*i}const n=[];let r,i=e;for(;i>=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */class u extends h{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{if(n){const r=this.converter.padBytes(n),i=this.padChars[e.version].at(0);t=t.slice(0,-r),e.padding&&(t=t.concat(i.repeat(r)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}export{u as default}; + */class u extends h{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{if(n){const i=this.converter.padBytes(n),r=this.padChars[e.version].at(0);t=t.slice(0,-i),e.padding&&(t=t.concat(r.repeat(i)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}export{u as default}; diff --git a/dist/converters/Base64/base-64.iife.js b/dist/converters/Base64/base-64.iife.js index 53418e6..e340e45 100644 --- a/dist/converters/Base64/base-64.iife.js +++ b/dist/converters/Base64/base-64.iife.js @@ -1155,23 +1155,17 @@ var Base64 = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base64/base-64.iife.min.js b/dist/converters/Base64/base-64.iife.min.js index 8285ec5..ccb8632 100644 --- a/dist/converters/Base64/base-64.iife.min.js +++ b/dist/converters/Base64/base-64.iife.min.js @@ -1,8 +1,8 @@ -var Base64=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let r;return r="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,r}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,n,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",r="MAX"),new RangeError(`The provided integer is ${n} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else r="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),r]}static bigInts(t,e=!1){const n=new Array,r=e?"push":"unshift",i=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[r](t%i),t>>=64n;else for(;t>=i;)n[r](t%i),t>>=64n;n[r](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const r=8*n;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,r=!1,i="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(r.buffer),i="float"}else[n,i]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),i="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const n of t)r.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(r)}}return[n,r,i]}}const r=n,i=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,r){const i=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&i>1?255:0;let a=t;if(s){a=new Uint8Array(i+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,r){let i;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,r);i="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,r);i="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,r);i="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return i}static compile(t,e,r=!1,i=!1){let s;if(e=this.getType(e),i){let i;if(i=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return i;t=n.toBytes(i,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,i);t=new Uint8Array(e)}r&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,i);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,i);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,i);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=i){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],r=!0)=>{const i=(t,n,r)=>{if(0===r&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let i=r;if("string"==typeof n&&(n=[...n]),Array.isArray(n))i=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===r)return[...n];if(i!==r)throw new Error(`Your ${t} has a length of ${i}. The converter requires a length of ${r}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let i="";r<100&&(i=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?i+="^":i+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${i}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=i("charset",e,this.root.converter.radix),o=i("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:r,s=a("bytes_out")?e:i;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,r=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],r=!0,i=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(r&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);i?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+n])*i}const n=[];let r,i=e;for(;i>=256;)[i,r]=this.divmod(i,256),n.unshift(parseInt(r,10));for(n.unshift(parseInt(i,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...r){const i=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,i),l=null;e&&(l=e(i));let[h,u]=this.converter.encode(s,this.charsets[i.version],i.littleEndian,l);return i.signed&&(h=this.utils.toSignedStr(h,o)),i.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:i,zeroPadding:u,type:a})),this.utils.wrapOutput(h,i.options.lineWrap)}decode(t,e,n,r,...i){const s=this.utils.validateArgs(i);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base64=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * * @version 0.7.9 * @author UmamiAppearance [mail@umamiappearance.eu] * @license MIT - */return class extends h{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{if(n){const r=this.converter.padBytes(n),i=this.padChars[e.version].at(0);t=t.slice(0,-r),e.padding&&(t=t.concat(i.repeat(r)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}}(); + */return class extends h{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{if(n){const i=this.converter.padBytes(n),r=this.padChars[e.version].at(0);t=t.slice(0,-i),e.padding&&(t=t.concat(r.repeat(i)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}}(); diff --git a/dist/converters/Base85/base-85.esm.js b/dist/converters/Base85/base-85.esm.js index d1ad5d2..2ce44cf 100644 --- a/dist/converters/Base85/base-85.esm.js +++ b/dist/converters/Base85/base-85.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base85/base-85.esm.min.js b/dist/converters/Base85/base-85.esm.min.js index 58c58e1..e36c137 100644 --- a/dist/converters/Base85/base-85.esm.min.js +++ b/dist/converters/Base85/base-85.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * diff --git a/dist/converters/Base85/base-85.iife.js b/dist/converters/Base85/base-85.iife.js index 172123a..0399cb9 100644 --- a/dist/converters/Base85/base-85.iife.js +++ b/dist/converters/Base85/base-85.iife.js @@ -1155,23 +1155,17 @@ var Base85 = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Base85/base-85.iife.min.js b/dist/converters/Base85/base-85.iife.min.js index b0614e7..5c004c4 100644 --- a/dist/converters/Base85/base-85.iife.min.js +++ b/dist/converters/Base85/base-85.iife.min.js @@ -1,4 +1,4 @@ -var Base85=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),h=null;e&&(h=e(n));let[l,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,h);return n.signed&&(l=this.utils.toSignedStr(l,o)),n.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(l,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Base85=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * diff --git a/dist/converters/BasePhi/base-phi.esm.js b/dist/converters/BasePhi/base-phi.esm.js index da0594d..0dcc468 100644 --- a/dist/converters/BasePhi/base-phi.esm.js +++ b/dist/converters/BasePhi/base-phi.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/BasePhi/base-phi.esm.min.js b/dist/converters/BasePhi/base-phi.esm.min.js index 4f51913..f117910 100644 --- a/dist/converters/BasePhi/base-phi.esm.min.js +++ b/dist/converters/BasePhi/base-phi.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),l=null;e&&(l=e(n));let[h,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,l);return n.signed&&(h=this.utils.toSignedStr(h,o)),n.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(h,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}}let u=1e6,c="[big.js] ",f=c+"Invalid ",d=f+"decimal places",p=f+"rounding mode",g={},y=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function w(t,e,i,r){let n=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error(p);if(e<1)r=3===i&&(r||!!n[0])||0===e&&(1===i&&n[0]>=5||2===i&&(n[0]>5||5===n[0]&&(r||void 0!==n[1]))),n.length=1,r?(t.e=t.e-e+1,n[0]=1):n[0]=t.e=0;else if(e=5||2===i&&(n[e]>5||5===n[e]&&(r||void 0!==n[e+1]||1&n[e-1]))||3===i&&(r||!!n[0]),n.length=e,r)for(;++n[--e]>9;)if(n[e]=0,0===e){++t.e,n.unshift(1);break}for(e=n.length;!n[--e];)n.pop()}return t}function b(t,e,i){let r=t.e,n=t.c.join(""),s=n.length;if(e)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)n="0"+n;n="0."+n}else if(r>0)if(++r>s)for(r-=s;r--;)n+="0";else r1&&(n=n.charAt(0)+"."+n.slice(1));return t.s<0&&i?"-"+n:n}g.abs=function(){let t=new this.constructor(this);return t.s=1,t},g.cmp=function(t){let e,i=this,r=i.c,n=(t=new i.constructor(t)).c,s=i.s,o=t.s,a=i.e,l=t.e;if(!r[0]||!n[0])return r[0]?s:n[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=r.length)<(l=n.length)?a:l,s=-1;++sn[s]^e?1:-1;return a==l?0:a>l^e?1:-1},g.eq=function(t){return 0===this.cmp(t)},g.gt=function(t){return this.cmp(t)>0},g.gte=function(t){return this.cmp(t)>-1},g.lt=function(t){return this.cmp(t)<0},g.lte=function(t){return this.cmp(t)<1},g.minus=g.sub=function(t){let e,i,r,n,s=this,o=s.constructor,a=s.s,l=(t=new o(t)).s;if(a!=l)return t.s=-l,s.plus(t);let h=s.c.slice(),u=s.e,c=t.c,f=t.e;if(!h[0]||!c[0])return c[0]?t.s=-l:h[0]?t=new o(s):t.s=1,t;if(a=u-f){for((n=a<0)?(a=-a,r=h):(f=u,r=c),r.reverse(),l=a;l--;)r.push(0);r.reverse()}else for(i=((n=h.length0)for(;l--;)h[e++]=0;for(l=e;i>a;){if(h[--i]0?(l=o,r=h):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-h.length<0&&(r=h,h=a,a=r),e=h.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+h[e]+i)/10|0;for(i&&(a.unshift(i),++l),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=l,t},g.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-u||t>u)throw Error(d);return w(new this.constructor(this),t+this.e+1,e)},g.toFixed=function(t,e){let i=this,r=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>u)throw Error(d);for(i=w(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},g.toNumber=function(){let t=Number(b(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(c+"Imprecise conversion");return t};const m=function t(){function e(i){let r=this;if(!(r instanceof e))return void 0===i?t():new e(i);if(i instanceof e)r.s=i.s,r.e=i.e,r.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(f+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,r,n;if(!y.test(e))throw Error(`${f}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(i<0&&(i=r),i+=+e.slice(r+1),e=e.substring(0,r)):i<0&&(i=e.length),n=e.length,r=0;r0&&"0"==e.charAt(--n););for(t.e=i-r-1,t.c=[],i=0;r<=n;)t.c[i++]=+e.charAt(r++)}}(r,i)}r.constructor=e}return e.prototype=g,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}(); +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const n=e.indexOf(t);if(n>-1)a.push(n);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),l=null;e&&(l=e(n));let[h,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,l);return n.signed&&(h=this.utils.toSignedStr(h,o)),n.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(h,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}}let u=1e6,c="[big.js] ",f=c+"Invalid ",d=f+"decimal places",p=f+"rounding mode",g={},y=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function w(t,e,i,r){let n=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error(p);if(e<1)r=3===i&&(r||!!n[0])||0===e&&(1===i&&n[0]>=5||2===i&&(n[0]>5||5===n[0]&&(r||void 0!==n[1]))),n.length=1,r?(t.e=t.e-e+1,n[0]=1):n[0]=t.e=0;else if(e=5||2===i&&(n[e]>5||5===n[e]&&(r||void 0!==n[e+1]||1&n[e-1]))||3===i&&(r||!!n[0]),n.length=e,r)for(;++n[--e]>9;)if(n[e]=0,0===e){++t.e,n.unshift(1);break}for(e=n.length;!n[--e];)n.pop()}return t}function b(t,e,i){let r=t.e,n=t.c.join(""),s=n.length;if(e)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)n="0"+n;n="0."+n}else if(r>0)if(++r>s)for(r-=s;r--;)n+="0";else r1&&(n=n.charAt(0)+"."+n.slice(1));return t.s<0&&i?"-"+n:n}g.abs=function(){let t=new this.constructor(this);return t.s=1,t},g.cmp=function(t){let e,i=this,r=i.c,n=(t=new i.constructor(t)).c,s=i.s,o=t.s,a=i.e,l=t.e;if(!r[0]||!n[0])return r[0]?s:n[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=r.length)<(l=n.length)?a:l,s=-1;++sn[s]^e?1:-1;return a==l?0:a>l^e?1:-1},g.eq=function(t){return 0===this.cmp(t)},g.gt=function(t){return this.cmp(t)>0},g.gte=function(t){return this.cmp(t)>-1},g.lt=function(t){return this.cmp(t)<0},g.lte=function(t){return this.cmp(t)<1},g.minus=g.sub=function(t){let e,i,r,n,s=this,o=s.constructor,a=s.s,l=(t=new o(t)).s;if(a!=l)return t.s=-l,s.plus(t);let h=s.c.slice(),u=s.e,c=t.c,f=t.e;if(!h[0]||!c[0])return c[0]?t.s=-l:h[0]?t=new o(s):t.s=1,t;if(a=u-f){for((n=a<0)?(a=-a,r=h):(f=u,r=c),r.reverse(),l=a;l--;)r.push(0);r.reverse()}else for(i=((n=h.length0)for(;l--;)h[e++]=0;for(l=e;i>a;){if(h[--i]0?(l=o,r=h):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-h.length<0&&(r=h,h=a,a=r),e=h.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+h[e]+i)/10|0;for(i&&(a.unshift(i),++l),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=l,t},g.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-u||t>u)throw Error(d);return w(new this.constructor(this),t+this.e+1,e)},g.toFixed=function(t,e){let i=this,r=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>u)throw Error(d);for(i=w(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},g.toNumber=function(){let t=Number(b(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(c+"Imprecise conversion");return t};const m=function t(){function e(i){let r=this;if(!(r instanceof e))return void 0===i?t():new e(i);if(i instanceof e)r.s=i.s,r.e=i.e,r.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(f+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,r,n;if(!y.test(e))throw Error(`${f}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(i<0&&(i=r),i+=+e.slice(r+1),e=e.substring(0,r)):i<0&&(i=e.length),n=e.length,r=0;r0&&"0"==e.charAt(--n););for(t.e=i-r-1,t.c=[],i=0;r<=n;)t.c[i++]=+e.charAt(r++)}}(r,i)}r.constructor=e}return e.prototype=g,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}(); /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * diff --git a/dist/converters/BasePhi/base-phi.iife.js b/dist/converters/BasePhi/base-phi.iife.js index b3d7989..f9b685b 100644 --- a/dist/converters/BasePhi/base-phi.iife.js +++ b/dist/converters/BasePhi/base-phi.iife.js @@ -1155,23 +1155,17 @@ var BasePhi = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/BasePhi/base-phi.iife.min.js b/dist/converters/BasePhi/base-phi.iife.min.js index 6e4bc18..ccec168 100644 --- a/dist/converters/BasePhi/base-phi.iife.min.js +++ b/dist/converters/BasePhi/base-phi.iife.min.js @@ -1,4 +1,4 @@ -var BasePhi=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),l=null;e&&(l=e(n));let[h,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,l);return n.signed&&(h=this.utils.toSignedStr(h,o)),n.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(h,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}}let u=1e6,c="[big.js] ",f=c+"Invalid ",d=f+"decimal places",p=f+"rounding mode",g={},y=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function w(t,e,i,r){let n=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error(p);if(e<1)r=3===i&&(r||!!n[0])||0===e&&(1===i&&n[0]>=5||2===i&&(n[0]>5||5===n[0]&&(r||void 0!==n[1]))),n.length=1,r?(t.e=t.e-e+1,n[0]=1):n[0]=t.e=0;else if(e=5||2===i&&(n[e]>5||5===n[e]&&(r||void 0!==n[e+1]||1&n[e-1]))||3===i&&(r||!!n[0]),n.length=e,r)for(;++n[--e]>9;)if(n[e]=0,0===e){++t.e,n.unshift(1);break}for(e=n.length;!n[--e];)n.pop()}return t}function b(t,e,i){let r=t.e,n=t.c.join(""),s=n.length;if(e)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)n="0"+n;n="0."+n}else if(r>0)if(++r>s)for(r-=s;r--;)n+="0";else r1&&(n=n.charAt(0)+"."+n.slice(1));return t.s<0&&i?"-"+n:n}g.abs=function(){let t=new this.constructor(this);return t.s=1,t},g.cmp=function(t){let e,i=this,r=i.c,n=(t=new i.constructor(t)).c,s=i.s,o=t.s,a=i.e,l=t.e;if(!r[0]||!n[0])return r[0]?s:n[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=r.length)<(l=n.length)?a:l,s=-1;++sn[s]^e?1:-1;return a==l?0:a>l^e?1:-1},g.eq=function(t){return 0===this.cmp(t)},g.gt=function(t){return this.cmp(t)>0},g.gte=function(t){return this.cmp(t)>-1},g.lt=function(t){return this.cmp(t)<0},g.lte=function(t){return this.cmp(t)<1},g.minus=g.sub=function(t){let e,i,r,n,s=this,o=s.constructor,a=s.s,l=(t=new o(t)).s;if(a!=l)return t.s=-l,s.plus(t);let h=s.c.slice(),u=s.e,c=t.c,f=t.e;if(!h[0]||!c[0])return c[0]?t.s=-l:h[0]?t=new o(s):t.s=1,t;if(a=u-f){for((n=a<0)?(a=-a,r=h):(f=u,r=c),r.reverse(),l=a;l--;)r.push(0);r.reverse()}else for(i=((n=h.length0)for(;l--;)h[e++]=0;for(l=e;i>a;){if(h[--i]0?(l=o,r=h):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-h.length<0&&(r=h,h=a,a=r),e=h.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+h[e]+i)/10|0;for(i&&(a.unshift(i),++l),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=l,t},g.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-u||t>u)throw Error(d);return w(new this.constructor(this),t+this.e+1,e)},g.toFixed=function(t,e){let i=this,r=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>u)throw Error(d);for(i=w(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},g.toNumber=function(){let t=Number(b(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(c+"Imprecise conversion");return t};const m=function t(){function e(i){let r=this;if(!(r instanceof e))return void 0===i?t():new e(i);if(i instanceof e)r.s=i.s,r.e=i.e,r.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(f+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,r,n;if(!y.test(e))throw Error(`${f}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(i<0&&(i=r),i+=+e.slice(r+1),e=e.substring(0,r)):i<0&&(i=e.length),n=e.length,r=0;r0&&"0"==e.charAt(--n););for(t.e=i-r-1,t.c=[],i=0;r<=n;)t.c[i++]=+e.charAt(r++)}}(r,i)}r.constructor=e}return e.prototype=g,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}(); +var BasePhi=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let r;return r="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,r}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,r;if(Number.isInteger(t)){if(r="int",!Number.isSafeInteger(t)){let e,i,r;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",r="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",r="MAX"),new RangeError(`The provided integer is ${i} than ${r}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else r="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),r]}static bigInts(t,e=!1){const i=new Array,r=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[r](t%n),t>>=64n;else for(;t>=n;)i[r](t%n),t>>=64n;i[r](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const r=8*i;o.setBigUint64(r,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,r=!1,n="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(r=!0,t=-t),e.numberMode){const r=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(r.buffer),n="float"}else[i,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(r=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const r=new Array;for(const i of t)r.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(r)}}return[i,r,n]}}const r=i,n=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,r){const n=t.byteLength,s=(e-t.byteLength%e)%e,o=r&&n>1?255:0;let a=t;if(s){a=new Uint8Array(n+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,r){let n;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,r);n="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,r);n="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,r);n="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return n}static compile(t,e,r=!1,n=!1){let s;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",r):-this.compile(t,"uint_n",r),"float_n"===e)return n;t=i.toBytes(n,{littleEndian:r,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,r,n);t=new Uint8Array(e)}r&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);s=new DataView(e.buffer).getFloat32(0,r)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);s=new DataView(e.buffer).getFloat64(0,r)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,r,n);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],r=!0)=>{const n=(t,i,r)=>{if(0===r&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let n=r;if("string"==typeof i&&(i=[...i]),Array.isArray(i))n=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===r)return[...i];if(n!==r)throw new Error(`Your ${t} has a length of ${n}. The converter requires a length of ${r}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let n="";r<100&&(n=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?n+="^":n+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${n}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");r&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=n("charset",e,this.root.converter.radix),o=n("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),r&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,r){throw new TypeError([`'${t}'\n\nParameters:`,r?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,r=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=r,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),r&&(c=r(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],r=!0,n=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const n=e.indexOf(t);if(n>-1)a.push(n);else if(r&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);n?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[r]=BigInt(this.pow(r)),this.powers[r]))();e+=BigInt(a[t+i])*n}const i=[];let r,n=e;for(;n>=256;)[n,r]=this.divmod(n,256),i.unshift(parseInt(r,10));for(i.unshift(parseInt(n,10));i.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...r){const n=this.utils.validateArgs(r);let[s,o,a]=this.utils.inputHandler.toBytes(t,n),l=null;e&&(l=e(n));let[h,u]=this.converter.encode(s,this.charsets[n.version],n.littleEndian,l);return n.signed&&(h=this.utils.toSignedStr(h,o)),n.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:n,zeroPadding:u,type:a})),this.utils.wrapOutput(h,n.options.lineWrap)}decode(t,e,i,r,...n){const s=this.utils.validateArgs(n);t=this.utils.normalizeInput(t,r);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}}let u=1e6,c="[big.js] ",f=c+"Invalid ",d=f+"decimal places",p=f+"rounding mode",g={},y=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function w(t,e,i,r){let n=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error(p);if(e<1)r=3===i&&(r||!!n[0])||0===e&&(1===i&&n[0]>=5||2===i&&(n[0]>5||5===n[0]&&(r||void 0!==n[1]))),n.length=1,r?(t.e=t.e-e+1,n[0]=1):n[0]=t.e=0;else if(e=5||2===i&&(n[e]>5||5===n[e]&&(r||void 0!==n[e+1]||1&n[e-1]))||3===i&&(r||!!n[0]),n.length=e,r)for(;++n[--e]>9;)if(n[e]=0,0===e){++t.e,n.unshift(1);break}for(e=n.length;!n[--e];)n.pop()}return t}function b(t,e,i){let r=t.e,n=t.c.join(""),s=n.length;if(e)n=n.charAt(0)+(s>1?"."+n.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)n="0"+n;n="0."+n}else if(r>0)if(++r>s)for(r-=s;r--;)n+="0";else r1&&(n=n.charAt(0)+"."+n.slice(1));return t.s<0&&i?"-"+n:n}g.abs=function(){let t=new this.constructor(this);return t.s=1,t},g.cmp=function(t){let e,i=this,r=i.c,n=(t=new i.constructor(t)).c,s=i.s,o=t.s,a=i.e,l=t.e;if(!r[0]||!n[0])return r[0]?s:n[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=r.length)<(l=n.length)?a:l,s=-1;++sn[s]^e?1:-1;return a==l?0:a>l^e?1:-1},g.eq=function(t){return 0===this.cmp(t)},g.gt=function(t){return this.cmp(t)>0},g.gte=function(t){return this.cmp(t)>-1},g.lt=function(t){return this.cmp(t)<0},g.lte=function(t){return this.cmp(t)<1},g.minus=g.sub=function(t){let e,i,r,n,s=this,o=s.constructor,a=s.s,l=(t=new o(t)).s;if(a!=l)return t.s=-l,s.plus(t);let h=s.c.slice(),u=s.e,c=t.c,f=t.e;if(!h[0]||!c[0])return c[0]?t.s=-l:h[0]?t=new o(s):t.s=1,t;if(a=u-f){for((n=a<0)?(a=-a,r=h):(f=u,r=c),r.reverse(),l=a;l--;)r.push(0);r.reverse()}else for(i=((n=h.length0)for(;l--;)h[e++]=0;for(l=e;i>a;){if(h[--i]0?(l=o,r=h):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-h.length<0&&(r=h,h=a,a=r),e=h.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+h[e]+i)/10|0;for(i&&(a.unshift(i),++l),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=l,t},g.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-u||t>u)throw Error(d);return w(new this.constructor(this),t+this.e+1,e)},g.toFixed=function(t,e){let i=this,r=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>u)throw Error(d);for(i=w(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},g.toNumber=function(){let t=Number(b(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(c+"Imprecise conversion");return t};const m=function t(){function e(i){let r=this;if(!(r instanceof e))return void 0===i?t():new e(i);if(i instanceof e)r.s=i.s,r.e=i.e,r.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(f+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,r,n;if(!y.test(e))throw Error(`${f}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(i<0&&(i=r),i+=+e.slice(r+1),e=e.substring(0,r)):i<0&&(i=e.length),n=e.length,r=0;r0&&"0"==e.charAt(--n););for(t.e=i-r-1,t.c=[],i=0;r<=n;)t.c[i++]=+e.charAt(r++)}}(r,i)}r.constructor=e}return e.prototype=g,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}(); /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * diff --git a/dist/converters/Ecoji/ecoji.esm.js b/dist/converters/Ecoji/ecoji.esm.js index 528674f..6518221 100644 --- a/dist/converters/Ecoji/ecoji.esm.js +++ b/dist/converters/Ecoji/ecoji.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Ecoji/ecoji.esm.min.js b/dist/converters/Ecoji/ecoji.esm.min.js index 94b1440..8a7f53f 100644 --- a/dist/converters/Ecoji/ecoji.esm.min.js +++ b/dist/converters/Ecoji/ecoji.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * diff --git a/dist/converters/Ecoji/ecoji.iife.js b/dist/converters/Ecoji/ecoji.iife.js index c983d9e..93f08af 100644 --- a/dist/converters/Ecoji/ecoji.iife.js +++ b/dist/converters/Ecoji/ecoji.iife.js @@ -1155,23 +1155,17 @@ var Ecoji = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/Ecoji/ecoji.iife.min.js b/dist/converters/Ecoji/ecoji.iife.min.js index ebec6be..240894d 100644 --- a/dist/converters/Ecoji/ecoji.iife.min.js +++ b/dist/converters/Ecoji/ecoji.iife.min.js @@ -1,4 +1,4 @@ -var Ecoji=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var Ecoji=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * diff --git a/dist/converters/LEB128/leb-128.esm.js b/dist/converters/LEB128/leb-128.esm.js index b74cfe4..5e7c50f 100644 --- a/dist/converters/LEB128/leb-128.esm.js +++ b/dist/converters/LEB128/leb-128.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/LEB128/leb-128.esm.min.js b/dist/converters/LEB128/leb-128.esm.min.js index 5bd7a0b..9653057 100644 --- a/dist/converters/LEB128/leb-128.esm.min.js +++ b/dist/converters/LEB128/leb-128.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * diff --git a/dist/converters/LEB128/leb-128.iife.js b/dist/converters/LEB128/leb-128.iife.js index 41ebf4a..b4da486 100644 --- a/dist/converters/LEB128/leb-128.iife.js +++ b/dist/converters/LEB128/leb-128.iife.js @@ -1155,23 +1155,17 @@ var LEB128 = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/LEB128/leb-128.iife.min.js b/dist/converters/LEB128/leb-128.iife.min.js index ad933d4..6bc9f98 100644 --- a/dist/converters/LEB128/leb-128.iife.min.js +++ b/dist/converters/LEB128/leb-128.iife.min.js @@ -1,4 +1,4 @@ -var LEB128=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var LEB128=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in h)if(h[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(h[i].indexOf(t))}e&&this.#i(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),i&&(h=i({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * diff --git a/dist/converters/SimpleBase/simple-base.esm.js b/dist/converters/SimpleBase/simple-base.esm.js index d1f4be2..5e2089d 100644 --- a/dist/converters/SimpleBase/simple-base.esm.js +++ b/dist/converters/SimpleBase/simple-base.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/SimpleBase/simple-base.esm.min.js b/dist/converters/SimpleBase/simple-base.esm.min.js index fb46df5..9703da6 100644 --- a/dist/converters/SimpleBase/simple-base.esm.min.js +++ b/dist/converters/SimpleBase/simple-base.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} * diff --git a/dist/converters/SimpleBase/simple-base.iife.js b/dist/converters/SimpleBase/simple-base.iife.js index 3ff1d81..d60b8b8 100644 --- a/dist/converters/SimpleBase/simple-base.iife.js +++ b/dist/converters/SimpleBase/simple-base.iife.js @@ -1155,23 +1155,17 @@ var SimpleBase = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/SimpleBase/simple-base.iife.min.js b/dist/converters/SimpleBase/simple-base.iife.min.js index c0ac07e..15b924b 100644 --- a/dist/converters/SimpleBase/simple-base.iife.min.js +++ b/dist/converters/SimpleBase/simple-base.iife.min.js @@ -1,4 +1,4 @@ -var SimpleBase=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],l=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let h;if([...t].forEach((t=>{const e=l[t];if(void 0!==e)a.push(e);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(h);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var SimpleBase=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} * diff --git a/dist/converters/UUencode/uuencode.esm.js b/dist/converters/UUencode/uuencode.esm.js index d129f3a..854d03d 100644 --- a/dist/converters/UUencode/uuencode.esm.js +++ b/dist/converters/UUencode/uuencode.esm.js @@ -1152,23 +1152,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/UUencode/uuencode.esm.min.js b/dist/converters/UUencode/uuencode.esm.min.js index 7a3bd06..ab1bd27 100644 --- a/dist/converters/UUencode/uuencode.esm.min.js +++ b/dist/converters/UUencode/uuencode.esm.min.js @@ -1,4 +1,4 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,i)=>e[t]=i)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let n;return n="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,n}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,n;if(Number.isInteger(t)){if(n="int",!Number.isSafeInteger(t)){let e,i,n;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",n="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",n="MAX"),new RangeError(`The provided integer is ${i} than ${n}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else n="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),n]}static bigInts(t,e=!1){const i=new Array,n=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[n](t%r),t>>=64n;else for(;t>=r;)i[n](t%r),t>>=64n;i[n](t);const s=8*i.length,o=this.makeDataView(s);return i.forEach(((t,i)=>{const n=8*i;o.setBigUint64(n,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,n=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(n=!0,t=-t),e.numberMode){const n=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(n.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(n=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const n=new Array;for(const i of t)n.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(n)}}return[i,n,r]}}const n=i,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,n){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=n&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=i?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,n){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,i,n);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,i,n);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,i,n);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,n=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",n):-this.compile(t,"uint_n",n),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:n,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,n,r);t=new Uint8Array(e)}n&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),s="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,n)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,n)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,n,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],n=!0)=>{const r=(t,i,n)=>{if(0===n&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=n;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===n)return[...i];if(r!==n)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${n}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";n<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const s=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");n&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),n&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,n){throw new TypeError([`'${t}'\n\nParameters:`,n?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:n,s=a("bytes_out")?e:r;this.setIOHandlers(i,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,i=null,n=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=n,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),n&&(c=n(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,i=[],n=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(n&&-1===i.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t(this.powers[n]=BigInt(this.pow(n)),this.powers[n]))();e+=BigInt(a[t+i])*r}const i=[];let n,r=e;for(;r>=256;)[r,n]=this.divmod(r,256),i.unshift(parseInt(n,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...n){const r=this.utils.validateArgs(n);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,n,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,n);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return i&&(a=i({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} * diff --git a/dist/converters/UUencode/uuencode.iife.js b/dist/converters/UUencode/uuencode.iife.js index 29bc9c1..38811b7 100644 --- a/dist/converters/UUencode/uuencode.iife.js +++ b/dist/converters/UUencode/uuencode.iife.js @@ -1155,23 +1155,17 @@ var UUencode = (function () { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - }; - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) { diff --git a/dist/converters/UUencode/uuencode.iife.min.js b/dist/converters/UUencode/uuencode.iife.min.js index eeb8598..91c8b0c 100644 --- a/dist/converters/UUencode/uuencode.iife.min.js +++ b/dist/converters/UUencode/uuencode.iife.min.js @@ -1,4 +1,4 @@ -var UUencode=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in l)if(l[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(l[n].indexOf(t))}e&&this.#n(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[],h=(t=>{const e={};return t.forEach(((t,n)=>e[t]=n)),e})(e);let l;if([...t].forEach((t=>{const e=h[t];if(void 0!==e)a.push(e);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let u=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!u[0];)u.shift();u.length||u.push(0),u.reverse()}}else if(this.bsDec){const t=this.padChars(l);u.splice(u.length-t)}return Uint8Array.from(u)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),n&&(l=n({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} +var UUencode=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in l)if(l[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(l[n].indexOf(t))}e&&this.#n(t,h,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class h{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i,this.powers={}}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,l]=this.divmod(u,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=[];let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{h=(s-a.length%s)%s;const t=new Array(h).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let l=new Array;for(let t=0,e=a.length;t(this.powers[i]=BigInt(this.pow(i)),this.powers[i]))();e+=BigInt(a[t+n])*r}const n=[];let i,r=e;for(;r>=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),n&&(l=n({inputBytes:s,output:l,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} * diff --git a/src/core.js b/src/core.js index 6e43bbb..2f8b5cf 100644 --- a/src/core.js +++ b/src/core.js @@ -204,23 +204,17 @@ class BaseConverter { let bs = this.bsDec; const byteArray = []; - - const toObj = arr => { - const obj = {}; - arr.forEach((v, i) => obj[v] = i); - return obj; - } - const charsetLookup = toObj(charset); - + [...inputBaseStr].forEach(c => { - const index = charsetLookup[c]; - if (typeof index !== "undefined") { + const index = charset.indexOf(c); + if (index > -1) { byteArray.push(index); } else if (integrity && padSet.indexOf(c) === -1) { throw new DecodingError(c); } }); + let padChars; if (bs === 0) {