diff --git a/dist/game/eMath.game.js b/dist/game/eMath.game.js index 310ea16..ffd4882 100644 --- a/dist/game/eMath.game.js +++ b/dist/game/eMath.game.js @@ -75,7 +75,9 @@ var require_lz_string = __commonJS({ return keyStrBase64.charAt(a); }); switch (res.length % 4) { + // To produce valid Base64 default: + // When could this happen ? case 0: return res; case 1: @@ -914,7 +916,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega.config.greek.length) + ); let lastLetter = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -955,7 +959,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega_short.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega_short.config.greek.length) + ); let lastLetter = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -981,6 +987,7 @@ function decimalFormatGenerator(Decimal2) { elemental: { config: { /** The list of elements */ + /* eslint-disable prettier/prettier */ element_lists: [ ["H"], ["He", "Li", "Be", "B", "C", "N", "O", "F"], @@ -1095,6 +1102,7 @@ function decimalFormatGenerator(Decimal2) { ], ["Og"] ] + /* eslint-enable prettier/prettier */ }, getOffset(group) { if (group == 1) return 1; @@ -1126,11 +1134,20 @@ function decimalFormatGenerator(Decimal2) { getAbbreviationAndValue(x) { const abbreviationListUnfloored = x.log(118).toNumber(); const abbreviationListIndex = Math.floor(abbreviationListUnfloored) + 1; - const abbreviationLength = FORMATS2.elemental.abbreviationLength(abbreviationListIndex); + const abbreviationLength = FORMATS2.elemental.abbreviationLength( + abbreviationListIndex + ); const abbreviationProgress = abbreviationListUnfloored - abbreviationListIndex + 1; - const abbreviationIndex = Math.floor(abbreviationProgress * abbreviationLength); - const abbreviation = FORMATS2.elemental.getAbbreviation(abbreviationListIndex, abbreviationProgress); - const value = new Decimal2(118).pow(abbreviationListIndex + abbreviationIndex / abbreviationLength - 1); + const abbreviationIndex = Math.floor( + abbreviationProgress * abbreviationLength + ); + const abbreviation = FORMATS2.elemental.getAbbreviation( + abbreviationListIndex, + abbreviationProgress + ); + const value = new Decimal2(118).pow( + abbreviationListIndex + abbreviationIndex / abbreviationLength - 1 + ); return [abbreviation, value]; }, formatElementalPart(abbreviation, n) { @@ -1140,7 +1157,12 @@ function decimalFormatGenerator(Decimal2) { return `${n.toString()} ${abbreviation}`; }, format(value, acc = 2) { - if (value.gt(new Decimal2(118).pow(new Decimal2(118).pow(new Decimal2(118).pow(4))))) return "e" + FORMATS2.elemental.format(value.log10(), acc); + if (value.gt( + new Decimal2(118).pow( + new Decimal2(118).pow(new Decimal2(118).pow(4)) + ) + )) + return "e" + FORMATS2.elemental.format(value.log10(), acc); let log = value.log(118); const slog = log.log(118); const sslog = slog.log(118).toNumber(); @@ -1153,7 +1175,12 @@ function decimalFormatGenerator(Decimal2) { parts.unshift([abbreviation, n]); } if (parts.length >= max) { - return parts.map((x) => FORMATS2.elemental.formatElementalPart(x[0], x[1])).join(" + "); + return parts.map( + (x) => ( + // @ts-expect-error - x has both string and decimal for some reason + FORMATS2.elemental.formatElementalPart(x[0], x[1]) + ) + ).join(" + "); } const formattedMantissa = new Decimal2(118).pow(log).toFixed(parts.length === 1 ? 3 : acc); if (parts.length === 0) { @@ -1215,7 +1242,9 @@ function decimalFormatGenerator(Decimal2) { return (slog.gte(1e9) ? "" : Decimal2.dTen.pow(slog.sub(slog.floor())).toFixed(4)) + "F" + FORMATS2.eng.format(slog.floor(), 0); } const m = ex.div(new Decimal2(1e3).pow(e.div(3).floor())); - return (e.log10().gte(9) ? "" : m.toFixed(new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber())) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); + return (e.log10().gte(9) ? "" : m.toFixed( + new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber() + )) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); } } }, @@ -1240,12 +1269,25 @@ function decimalFormatGenerator(Decimal2) { }, /** Layer format */ layer: { - layers: ["infinity", "eternity", "reality", "equality", "affinity", "celerity", "identity", "vitality", "immunity", "atrocity"], + layers: [ + "infinity", + "eternity", + "reality", + "equality", + "affinity", + "celerity", + "identity", + "vitality", + "immunity", + "atrocity" + ], format(ex, acc = 2, max) { ex = new Decimal2(ex); const layer = ex.max(1).log10().max(1).log(INFINITY_NUM.log10()).floor(); if (layer.lte(0)) return format(ex, acc, max, "sc"); - ex = Decimal2.dTen.pow(ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0)); + ex = Decimal2.dTen.pow( + ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0) + ); const meta = layer.div(10).floor(); const layer_id = layer.toNumber() % 10 - 1; return format(ex, Math.max(4, acc), max, "sc") + " " + (meta.gte(1) ? "meta" + (meta.gte(2) ? "^" + format(meta, 0, max, "sc") : "") + "-" : "") + (isNaN(layer_id) ? "nanity" : FORMATS2.layer.layers[layer_id]); @@ -1291,8 +1333,10 @@ function decimalFormatGenerator(Decimal2) { meta++; } if (meta == 0) return format(ex, acc, max, "sc"); - if (ex.gte(3)) return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); - if (ex.gte(2)) return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); + if (ex.gte(3)) + return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); + if (ex.gte(2)) + return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); return symbols2[meta] + symbols[meta] + "-" + format(inf.pow(ex.sub(1)), acc, max, "sc"); } }, @@ -1337,7 +1381,10 @@ function decimalFormatGenerator(Decimal2) { } else { const trunc = numLetters.sub(abbStart).add(1); const truncExponent = exponent.div(Decimal2.pow(alphabetLength + 1, trunc.sub(1))).floor(); - const truncLetters = convertToLetters(truncExponent, new Decimal2(abbStart)); + const truncLetters = convertToLetters( + truncExponent, + new Decimal2(abbStart) + ); letters = `${truncLetters}(${trunc.gt("1e9") ? trunc.format() : trunc.format(0)})`; } return letters; @@ -1359,7 +1406,12 @@ function decimalFormatGenerator(Decimal2) { ex = new Decimal2(ex); start = new Decimal2(start).div(1e3); if (ex.lt(start.mul(1e3))) return format(ex, acc, max, type); - const letters = FORMATS2.alphabet.getAbbreviation(ex, start, startDouble, abbStart); + const letters = FORMATS2.alphabet.getAbbreviation( + ex, + start, + startDouble, + abbStart + ); const mantissa = ex.div(Decimal2.pow(1e3, ex.log(1e3).floor())); const isAbbreviation = letters.length > (abbStart ?? 9) + 2; return `${!isAbbreviation ? mantissa.toFixed(acc) + " " : ""}${letters}`; @@ -1373,7 +1425,9 @@ function decimalFormatGenerator(Decimal2) { return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUBSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); } function toSuperscript(value) { - return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); + return value.toFixed(0).split("").map( + (x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)] + ).join(""); } function formatST(ex, acc = 2, max = 9, type = "st") { return format(ex, acc, max, type); @@ -1391,7 +1445,9 @@ function decimalFormatGenerator(Decimal2) { case "scientific": { if (ex.log10().lt(Math.min(-acc, 0)) && acc > 1) { const e2 = ex.log10().ceil(); - const m = ex.div(e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2)); + const m = ex.div( + e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2) + ); const be = e2.mul(-1).max(1).log10().gte(9); return neg + (be ? "" : m.toFixed(2)) + "e" + format(e2, 0, max, "mixed_sc"); } else if (e.lt(max)) { @@ -1411,13 +1467,16 @@ function decimalFormatGenerator(Decimal2) { case "standard": { let e3 = ex.log(1e3).floor(); if (e3.lt(1)) { - return neg + ex.toFixed(Math.max(Math.min(acc - e.toNumber(), acc), 0)); + return neg + ex.toFixed( + Math.max(Math.min(acc - e.toNumber(), acc), 0) + ); } const e3_mul = e3.mul(3); const ee = e3.log10().floor(); if (ee.gte(3e3)) return "e" + format(e, acc, max, "st"); let final = ""; - if (e3.lt(4)) final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; + if (e3.lt(4)) + final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; else { let ee3 = Math.floor(e3.log(1e3).toNumber()); if (ee3 < 100) ee3 = Math.max(ee3 - 1, 0); @@ -1427,8 +1486,10 @@ function decimalFormatGenerator(Decimal2) { const mod1000 = e3.sub(div1000.mul(1e3)).floor().toNumber(); if (mod1000 > 0) { if (mod1000 == 1 && !ee3) final = "U"; - if (ee3) final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); - if (mod1000 > 1) final = FORMATS2.standard.tier1(mod1000) + final; + if (ee3) + final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); + if (mod1000 > 1) + final = FORMATS2.standard.tier1(mod1000) + final; } e3 = div1000; ee3++; @@ -1439,7 +1500,8 @@ function decimalFormatGenerator(Decimal2) { return neg + (ee.gte(10) ? "" : m.toFixed(fixedAmt) + " ") + final; } default: - if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); + if (!FORMATS2[type]) + console.error(`Invalid format type "`, type, `"`); return neg + FORMATS2[type].format(ex, acc, max); } } @@ -1457,9 +1519,12 @@ function decimalFormatGenerator(Decimal2) { } function formatTime(ex, acc = 2, type = "s") { ex = new Decimal2(ex); - if (ex.gte(86400)) return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); - if (ex.gte(3600) || type == "d") return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); - if (ex.gte(60) || type == "h") return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); + if (ex.gte(86400)) + return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); + if (ex.gte(3600) || type == "d") + return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); + if (ex.gte(60) || type == "h") + return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); return (ex.gte(10) || type != "m" ? "" : "0") + format(ex, acc, 12, "sc"); } function formatTimeLong(ex, ms = false, acc = 0, max = 9, type = "mixed_sc") { @@ -5797,7 +5862,7 @@ function inverseFunctionApprox(f, n, mode = "geometric", iterations = DEFAULT_IT } if (f(upperBound).lt(n)) { console.warn( - "The function is not monotonically increasing. (f(n) < n)" + "eMath.js: The function is not monotonically increasing. (f(n) < n)" ); return { value: upperBound, @@ -5875,7 +5940,7 @@ function calculateUpgrade(value, upgrade, start, end = Decimal.dInf, mode, itera end = new Decimal(end); const target = end.sub(start); if (target.lt(0)) { - console.warn("calculateUpgrade: Invalid target: ", target); + console.warn("eMath.js: Invalid target for calculateItem: ", target); return [Decimal.dZero, Decimal.dZero]; } el = (typeof upgrade.el === "function" ? upgrade.el() : upgrade.el) ?? el; @@ -6048,7 +6113,7 @@ function calculateItem(value, item, tier = Decimal.dOne, target = Decimal.dInf) tier = new Decimal(tier); target = new Decimal(target); if (target.lt(0)) { - console.warn("calculateItem: Invalid target: ", target); + console.warn("eMath.js: Invalid target for calculateItem: ", target); return [Decimal.dZero, Decimal.dZero]; } if (target.eq(1)) { @@ -6336,6 +6401,7 @@ var CurrencyStatic = class { this.pointerAddUpgrade(upgrade); const addedUpgradeStatic = new UpgradeStatic( upgrade, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion () => this.pointerGetUpgrade(upgrade.id), () => this ); @@ -6395,7 +6461,7 @@ var CurrencyStatic = class { calculateUpgrade(id, target = Infinity, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return [Decimal.dZero, Decimal.dZero]; } target = upgrade.level.add(target); @@ -6426,7 +6492,7 @@ var CurrencyStatic = class { getNextCost(id, target = 1, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return Decimal.dZero; } const amount = this.calculateUpgrade(id, target, mode, iterations)[0]; @@ -6449,7 +6515,7 @@ var CurrencyStatic = class { getNextCostMax(id, target = 1, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return Decimal.dZero; } const upgCalc = this.calculateUpgrade(id, target, mode, iterations); @@ -6470,7 +6536,7 @@ var CurrencyStatic = class { buyUpgrade(id, target, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return false; } const [amount, cost] = this.calculateUpgrade( @@ -6516,6 +6582,7 @@ var CurrencyStatic = class { this.pointerAddItem(item); const addedUpgradeStatic = new Item( item, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion () => this.pointerGetItem(item.id), () => this ); @@ -6542,7 +6609,7 @@ var CurrencyStatic = class { calculateItem(id, tier, target) { const item = this.getItem(id); if (item === null) { - console.warn(`Item "${id}" not found.`); + console.warn(`eMath.js: Item "${id}" not found.`); return [Decimal.dZero, Decimal.dZero]; } return calculateItem(this.value, item, tier, target); @@ -6557,7 +6624,7 @@ var CurrencyStatic = class { buyItem(id, tier, target) { const item = this.getItem(id); if (item === null) { - console.warn(`Item "${id}" not found.`); + console.warn(`eMath.js: Item "${id}" not found.`); return false; } const [amount, cost] = this.calculateItem(id, tier, target); @@ -6610,7 +6677,7 @@ var AttributeStatic = class { */ update() { console.warn( - "AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed." + "eMath.js: AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed." ); if (this.boost) { this.pointer.value = this.boost.calculate(); @@ -7080,7 +7147,7 @@ var DataManager = class { setData(key, value) { if (typeof this.data[key] === "undefined" && this.normalData) { console.warn( - "After initializing data, you should not add new properties to data." + "eMath.js: After initializing data, you should not add new properties to data." ); } this.data[key] = value; @@ -7116,11 +7183,11 @@ var DataManager = class { */ setStatic(key, value) { console.warn( - "setStatic: Static data is basically useless and should not be used. Use variables in local scope instead." + "eMath.js: setStatic: Static data is basically useless and should not be used. Use variables in local scope instead." ); if (typeof this.static[key] === "undefined" && this.normalData) { console.warn( - "After initializing data, you should not add new properties to staticData." + "eMath.js: After initializing data, you should not add new properties to staticData." ); } this.static[key] = value; @@ -7134,7 +7201,7 @@ var DataManager = class { */ getStatic(key) { console.warn( - "getStatic: Static data is basically useless and should not be used. Use variables in local scope instead." + "eMath.js: Static data is basically useless and should not be used. Use variables in local scope instead." ); return this.static[key]; } @@ -7305,7 +7372,7 @@ var DataManager = class { function deepMerge(sourcePlain, source, target) { if (!sourcePlain || !source || !target) { console.warn( - "dataManager.deepMerge(): Missing arguments:", + "eMath.js: dataManager.deepMerge(): Missing arguments:", sourcePlain, source, target @@ -7350,7 +7417,7 @@ var DataManager = class { const upgradeDataProperties = Object.getOwnPropertyNames( new UpgradeData({ id: "", level: Decimal.dZero }) ); - const ItemDataProperties = Object.getOwnPropertyNames( + const itemDataProperties = Object.getOwnPropertyNames( new ItemData({ id: "", amount: Decimal.dZero }) ); function convertTemplateClass(templateClassToConvert, plain) { @@ -7374,7 +7441,7 @@ var DataManager = class { } for (const itemName in out.items) { const item = out.items[itemName]; - if (!item || !ItemDataProperties.every( + if (!item || !itemDataProperties.every( (prop) => Object.getOwnPropertyNames(item).includes(prop) )) { delete out.items[itemName]; @@ -7399,7 +7466,9 @@ var DataManager = class { const out = plain; for (const key in normal) { if (plain[key] === void 0) { - console.warn(`Missing property "${key}" in loaded data.`); + console.warn( + `eMath.js: Missing property "${key}" in loaded data.` + ); continue; } if (!isPlainObject(plain[key])) continue; @@ -7702,7 +7771,7 @@ var Game = class _Game { // public addReset (currenciesToReset: GameCurrency | GameCurrency[], extender?: GameReset): GameReset { addReset(...args) { console.warn( - "Game.addReset is deprecated. Use the GameReset class instead." + "eMath.js: Game.addReset is deprecated. Use the GameReset class instead." ); const reset = new GameReset(...args); return reset; diff --git a/dist/game/eMath.game.min.js b/dist/game/eMath.game.min.js index 3c437fb..379fb6f 100644 --- a/dist/game/eMath.game.min.js +++ b/dist/game/eMath.game.min.js @@ -1,4 +1,4 @@ -"use strict";(function(Ot,ut){var Ft=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],ut);else if(typeof module=="object"&&module.exports)module.exports=ut();else{var ct=ut(),Pt=Ft?exports:Ot;for(var Ct in ct)Pt[Ct]=ct[Ct]}})(typeof self<"u"?self:exports,()=>{var Ot={},ut={exports:Ot},Ft=Object.create,ct=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Ct=Object.getOwnPropertyNames,Xe=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty,bt=(t,e)=>function(){return e||(0,t[Ct(t)[0]])((e={exports:{}}).exports,e),e.exports},jt=(t,e)=>{for(var r in e)ct(t,r,{get:e[r],enumerable:!0})},oe=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ct(e))!Je.call(t,n)&&n!==r&&ct(t,n,{get:()=>e[n],enumerable:!(i=Pt(e,n))||i.enumerable});return t},ot=(t,e,r)=>(r=t!=null?Ft(Xe(t)):{},oe(e||!t||!t.__esModule?ct(r,"default",{value:t,enumerable:!0}):r,t)),Qe=t=>oe(ct({},"__esModule",{value:!0}),t),st=(t,e,r,i)=>{for(var n=i>1?void 0:i?Pt(e,r):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(n=(i?u(e,r,n):u(n))||n);return i&&n&&ct(e,r,n),n},ft=bt({"node_modules/reflect-metadata/Reflect.js"(){var t;(function(e){(function(r){var i=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:g(),n=o(e);typeof i.Reflect<"u"&&(n=o(i.Reflect,n)),r(n,i),typeof i.Reflect>"u"&&(i.Reflect=e);function o(l,v){return function(c,f){Object.defineProperty(l,c,{configurable:!0,writable:!0,value:f}),v&&v(c,f)}}function u(){try{return Function("return this;")()}catch{}}function m(){try{return(0,eval)("(function() { return this; })()")}catch{}}function g(){return u()||m()}})(function(r,i){var n=Object.prototype.hasOwnProperty,o=typeof Symbol=="function",u=o&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",m=o&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",g=typeof Object.create=="function",l={__proto__:[]}instanceof Array,v=!g&&!l,c={create:g?function(){return ie(Object.create(null))}:l?function(){return ie({__proto__:null})}:function(){return ie({})},has:v?function(N,b){return n.call(N,b)}:function(N,b){return b in N},get:v?function(N,b){return n.call(N,b)?N[b]:void 0}:function(N,b){return N[b]}},f=Object.getPrototypeOf(Function),h=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Yr(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Vr(),d=typeof WeakMap=="function"?WeakMap:Hr(),O=o?Symbol.for("@reflect-metadata:registry"):void 0,T=$r(),k=zr(T);function a(N,b,A,E){if(j(A)){if(!De(N))throw new TypeError;if(!Re(b))throw new TypeError;return K(N,b)}else{if(!De(N))throw new TypeError;if(!X(b))throw new TypeError;if(!X(E)&&!j(E)&&!It(E))throw new TypeError;return It(E)&&(E=void 0),A=lt(A),nt(N,b,A,E)}}r("decorate",a);function S(N,b){function A(E,U){if(!X(E))throw new TypeError;if(!j(U)&&!Gr(U))throw new TypeError;Dt(N,b,E,U)}return A}r("metadata",S);function y(N,b,A,E){if(!X(A))throw new TypeError;return j(E)||(E=lt(E)),Dt(N,b,A,E)}r("defineMetadata",y);function I(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),H(N,b,A)}r("hasMetadata",I);function _(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),Z(N,b,A)}r("hasOwnMetadata",_);function M(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),W(N,b,A)}r("getMetadata",M);function F(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),pt(N,b,A)}r("getOwnMetadata",F);function P(N,b){if(!X(N))throw new TypeError;return j(b)||(b=lt(b)),Rt(N,b)}r("getMetadataKeys",P);function G(N,b){if(!X(N))throw new TypeError;return j(b)||(b=lt(b)),Ut(N,b)}r("getOwnMetadataKeys",G);function Y(N,b,A){if(!X(b))throw new TypeError;if(j(A)||(A=lt(A)),!X(b))throw new TypeError;j(A)||(A=lt(A));var E=Et(b,A,!1);return j(E)?!1:E.OrdinaryDeleteMetadata(N,b,A)}r("deleteMetadata",Y);function K(N,b){for(var A=N.length-1;A>=0;--A){var E=N[A],U=E(b);if(!j(U)&&!It(U)){if(!Re(U))throw new TypeError;b=U}}return b}function nt(N,b,A,E){for(var U=N.length-1;U>=0;--U){var J=N[U],tt=J(b,A,E);if(!j(tt)&&!It(tt)){if(!X(tt))throw new TypeError;E=tt}}return E}function H(N,b,A){var E=Z(N,b,A);if(E)return!0;var U=re(b);return It(U)?!1:H(N,U,A)}function Z(N,b,A){var E=Et(b,A,!1);return j(E)?!1:qe(E.OrdinaryHasOwnMetadata(N,b,A))}function W(N,b,A){var E=Z(N,b,A);if(E)return pt(N,b,A);var U=re(b);if(!It(U))return W(N,U,A)}function pt(N,b,A){var E=Et(b,A,!1);if(!j(E))return E.OrdinaryGetOwnMetadata(N,b,A)}function Dt(N,b,A,E){var U=Et(A,E,!0);U.OrdinaryDefineOwnMetadata(N,b,A,E)}function Rt(N,b){var A=Ut(N,b),E=re(N);if(E===null)return A;var U=Rt(E,b);if(U.length<=0)return A;if(A.length<=0)return U;for(var J=new p,tt=[],$=0,x=A;$=0&&x=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:L,done:!1}}return{value:void 0,done:!0}},$.prototype.throw=function(x){throw this._index>=0&&(this._index=-1,this._keys=b,this._values=b),x},$.prototype.return=function(x){return this._index>=0&&(this._index=-1,this._keys=b,this._values=b),{value:x,done:!0}},$}(),E=function(){function $(){this._keys=[],this._values=[],this._cacheKey=N,this._cacheIndex=-2}return Object.defineProperty($.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),$.prototype.has=function(x){return this._find(x,!1)>=0},$.prototype.get=function(x){var L=this._find(x,!1);return L>=0?this._values[L]:void 0},$.prototype.set=function(x,L){var q=this._find(x,!0);return this._values[q]=L,this},$.prototype.delete=function(x){var L=this._find(x,!1);if(L>=0){for(var q=this._keys.length,D=L+1;D>>8,c[f*2+1]=p%256}return c},decompressFromUint8Array:function(l){if(l==null)return g.decompress(l);for(var v=new Array(l.length/2),c=0,f=v.length;c>1}else{for(h=1,f=0;f>1}a--,a==0&&(a=Math.pow(2,y),y++),delete d[k]}else for(h=p[k],f=0;f>1;a--,a==0&&(a=Math.pow(2,y),y++),p[T]=S++,k=String(O)}if(k!==""){if(Object.prototype.hasOwnProperty.call(d,k)){if(k.charCodeAt(0)<256){for(f=0;f>1}else{for(h=1,f=0;f>1}a--,a==0&&(a=Math.pow(2,y),y++),delete d[k]}else for(h=p[k],f=0;f>1;a--,a==0&&(a=Math.pow(2,y),y++)}for(h=2,f=0;f>1;for(;;)if(_=_<<1,M==v-1){I.push(c(_));break}else M++;return I.join("")},decompress:function(l){return l==null?"":l==""?null:g._decompress(l.length,32768,function(v){return l.charCodeAt(v)})},_decompress:function(l,v,c){var f=[],h,p=4,d=4,O=3,T="",k=[],a,S,y,I,_,M,F,P={val:c(0),position:v,index:1};for(a=0;a<3;a+=1)f[a]=a;for(y=0,_=Math.pow(2,2),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;switch(h=y){case 0:for(y=0,_=Math.pow(2,8),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;F=i(y);break;case 1:for(y=0,_=Math.pow(2,16),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;F=i(y);break;case 2:return""}for(f[3]=F,S=F,k.push(F);;){if(P.index>l)return"";for(y=0,_=Math.pow(2,O),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;switch(F=y){case 0:for(y=0,_=Math.pow(2,8),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;f[d++]=i(y),F=d-1,p--;break;case 1:for(y=0,_=Math.pow(2,16),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;f[d++]=i(y),F=d-1,p--;break;case 2:return k.join("")}if(p==0&&(p=Math.pow(2,O),O++),f[F])T=f[F];else if(F===d)T=S+S.charAt(0);else return null;k.push(T),f[d++]=S+T.charAt(0),p--,S=T,p==0&&(p=Math.pow(2,O),O++)}}};return g}();typeof define=="function"&&define.amd?define(function(){return r}):typeof e<"u"&&e!=null?e.exports=r:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return r})}}),tr=bt({"node_modules/crypt/crypt.js"(t,e){(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i={rotl:function(n,o){return n<>>32-o},rotr:function(n,o){return n<<32-o|n>>>o},endian:function(n){if(n.constructor==Number)return i.rotl(n,8)&16711935|i.rotl(n,24)&4278255360;for(var o=0;o0;n--)o.push(Math.floor(Math.random()*256));return o},bytesToWords:function(n){for(var o=[],u=0,m=0;u>>5]|=n[u]<<24-m%32;return o},wordsToBytes:function(n){for(var o=[],u=0;u>>5]>>>24-u%32&255);return o},bytesToHex:function(n){for(var o=[],u=0;u>>4).toString(16)),o.push((n[u]&15).toString(16));return o.join("")},hexToBytes:function(n){for(var o=[],u=0;u>>6*(3-g)&63)):o.push("=");return o.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var o=[],u=0,m=0;u>>6-m*2);return o}};e.exports=i})()}}),ae=bt({"node_modules/charenc/charenc.js"(t,e){var r={utf8:{stringToBytes:function(i){return r.bin.stringToBytes(unescape(encodeURIComponent(i)))},bytesToString:function(i){return decodeURIComponent(escape(r.bin.bytesToString(i)))}},bin:{stringToBytes:function(i){for(var n=[],o=0;o>>24)&16711935|(l[d]<<24|l[d]>>>8)&4278255360;l[v>>>5]|=128<>>9<<4)+14]=v;for(var O=u._ff,T=u._gg,k=u._hh,a=u._ii,d=0;d>>0,f=f+y>>>0,h=h+I>>>0,p=p+_>>>0}return r.endian([c,f,h,p])};u._ff=function(m,g,l,v,c,f,h){var p=m+(g&l|~g&v)+(c>>>0)+h;return(p<>>32-f)+g},u._gg=function(m,g,l,v,c,f,h){var p=m+(g&v|l&~v)+(c>>>0)+h;return(p<>>32-f)+g},u._hh=function(m,g,l,v,c,f,h){var p=m+(g^l^v)+(c>>>0)+h;return(p<>>32-f)+g},u._ii=function(m,g,l,v,c,f,h){var p=m+(l^(g|~v))+(c>>>0)+h;return(p<>>32-f)+g},u._blocksize=16,u._digestsize=16,e.exports=function(m,g){if(m==null)throw new Error("Illegal argument "+m);var l=r.wordsToBytes(u(m,g));return g&&g.asBytes?l:g&&g.asString?o.bytesToString(l):r.bytesToHex(l)}})()}}),ue={};jt(ue,{default:()=>Lr}),ut.exports=Qe(ue);var Jr=ot(ft()),Qr=ot(ft()),le={};jt(le,{Attribute:()=>xt,AttributeStatic:()=>Se,Boost:()=>Vt,BoostObject:()=>St,Currency:()=>gt,CurrencyStatic:()=>_e,DEFAULT_ITERATIONS:()=>kt,Decimal:()=>s,E:()=>Cr,FORMATS:()=>Sr,FormatTypeList:()=>lr,Grid:()=>Qt,GridCell:()=>Lt,GridCellCollection:()=>rt,Item:()=>Me,ItemData:()=>vt,LRUCache:()=>Gt,ListNode:()=>fe,ST_NAMES:()=>ht,UpgradeData:()=>yt,UpgradeStatic:()=>be,calculateItem:()=>we,calculateSum:()=>Jt,calculateSumApprox:()=>Ne,calculateSumLoop:()=>pe,calculateUpgrade:()=>ye,decimalToJSONString:()=>ve,equalsTolerance:()=>Wt,formats:()=>dt,inverseFunctionApprox:()=>Xt,roundingBase:()=>Ar,upgradeToCacheNameEL:()=>Or});var Kr=ot(ft()),Gt=class{constructor(t){this.map=new Map,this.first=void 0,this.last=void 0,this.maxSize=t}get size(){return this.map.size}get(t){let e=this.map.get(t);if(e!==void 0)return e!==this.first&&(e===this.last?(this.last=e.prev,this.last.next=void 0):(e.prev.next=e.next,e.next.prev=e.prev),e.next=this.first,this.first.prev=e,this.first=e),e.value}set(t,e){if(this.maxSize<1)return;if(this.map.has(t))throw new Error("Cannot update existing keys in the cache");let r=new fe(t,e);for(this.first===void 0?(this.first=r,this.last=r):(r.next=this.first,this.first.prev=r,this.first=r),this.map.set(t,r);this.map.size>this.maxSize;){let i=this.last;this.map.delete(i.key),this.last=i.prev,this.last.next=void 0}}},fe=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},B;(function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(B||(B={}));var ir=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},t.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.findTransformMetadatas=function(e,r,i){return this.findMetadatas(this._transformMetadatas,e,r).filter(function(n){return!n.options||n.options.toClassOnly===!0&&n.options.toPlainOnly===!0?!0:n.options.toClassOnly===!0?i===B.CLASS_TO_CLASS||i===B.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?i===B.CLASS_TO_PLAIN:!0})},t.prototype.findExcludeMetadata=function(e,r){return this.findMetadata(this._excludeMetadatas,e,r)},t.prototype.findExposeMetadata=function(e,r){return this.findMetadata(this._exposeMetadatas,e,r)},t.prototype.findExposeMetadataByCustomName=function(e,r){return this.getExposedMetadatas(e).find(function(i){return i.options&&i.options.name===r})},t.prototype.findTypeMetadata=function(e,r){return this.findMetadata(this._typeMetadatas,e,r)},t.prototype.getStrategy=function(e){var r=this._excludeMetadatas.get(e),i=r&&r.get(void 0),n=this._exposeMetadatas.get(e),o=n&&n.get(void 0);return i&&o||!i&&!o?"none":i?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},t.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},t.prototype.getExposedProperties=function(e,r){return this.getExposedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===B.CLASS_TO_CLASS||r===B.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===B.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.getExcludedProperties=function(e,r){return this.getExcludedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===B.CLASS_TO_CLASS||r===B.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===B.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(e,r){var i=e.get(r),n;i&&(n=Array.from(i.values()).filter(function(c){return c.propertyName!==void 0}));for(var o=[],u=0,m=this.getAncestors(r);u0&&(u=u.filter(function(c){return!l.includes(c)})),this.options.version!==void 0&&(u=u.filter(function(c){var f=et.findExposeMetadata(e,c);return!f||!f.options?!0:n.checkVersion(f.options.since,f.options.until)})),this.options.groups&&this.options.groups.length?u=u.filter(function(c){var f=et.findExposeMetadata(e,c);return!f||!f.options?!0:n.checkGroups(f.options.groups)}):u=u.filter(function(c){var f=et.findExposeMetadata(e,c);return!f||!f.options||!f.options.groups||!f.options.groups.length})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(u=u.filter(function(v){return n.options.excludePrefixes.every(function(c){return v.substr(0,c.length)!==c})})),u=u.filter(function(v,c,f){return f.indexOf(v)===c}),u},t.prototype.checkVersion=function(e,r){var i=!0;return i&&e&&(i=this.options.version>=e),i&&r&&(i=this.options.versionNumber.MAX_SAFE_INTEGER)&&(I="\u03C9");let M=t.log(a,8e3).toNumber();if(y.equals(0))return I;if(y.gt(0)&&y.lte(3)){let G=[];for(let Y=0;YNumber.MAX_SAFE_INTEGER)&&(I="\u03C9");let M=t.log(a,8e3).toNumber();if(y.equals(0))return I;if(y.gt(0)&&y.lte(2)){let G=[];for(let Y=0;Y118?e.elemental.beyondOg(_):e.elemental.config.element_lists[a-1][I]},beyondOg(a){let S=Math.floor(Math.log10(a)),y=["n","u","b","t","q","p","h","s","o","e"],I="";for(let _=S;_>=0;_--){let M=Math.floor(a/Math.pow(10,_))%10;I==""?I=y[M].toUpperCase():I+=y[M]}return I},abbreviationLength(a){return a==1?1:Math.pow(Math.floor(a/2)+1,2)*2},getAbbreviationAndValue(a){let S=a.log(118).toNumber(),y=Math.floor(S)+1,I=e.elemental.abbreviationLength(y),_=S-y+1,M=Math.floor(_*I),F=e.elemental.getAbbreviation(y,_),P=new t(118).pow(y+M/I-1);return[F,P]},formatElementalPart(a,S){return S.eq(1)?a:`${S.toString()} ${a}`},format(a,S=2){if(a.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(a.log10(),S);let y=a.log(118),_=y.log(118).log(118).toNumber(),M=Math.max(4-_*2,1),F=[];for(;y.gte(1)&&F.length=M)return F.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ");let P=new t(118).pow(y).toFixed(F.length===1?3:S);return F.length===0?P:F.length===1?`${P} \xD7 ${e.elemental.formatElementalPart(F[0][0],F[0][1])}`:`${P} \xD7 (${F.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ")})`}},old_sc:{format(a,S){a=new t(a);let y=a.log10().floor();if(y.lt(9))return y.lt(3)?a.toFixed(S):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let _=a.slog();return(_.gte(1e9)?"":t.dTen.pow(_.sub(_.floor())).toFixed(4))+"F"+e.old_sc.format(_.floor(),0)}let I=a.div(t.dTen.pow(y));return(y.log10().gte(9)?"":I.toFixed(4))+"e"+e.old_sc.format(y,0)}}},eng:{format(a,S=2){a=new t(a);let y=a.log10().floor();if(y.lt(9))return y.lt(3)?a.toFixed(S):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let _=a.slog();return(_.gte(1e9)?"":t.dTen.pow(_.sub(_.floor())).toFixed(4))+"F"+e.eng.format(_.floor(),0)}let I=a.div(new t(1e3).pow(y.div(3).floor()));return(y.log10().gte(9)?"":I.toFixed(new t(4).sub(y.sub(y.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(y.div(3).floor().mul(3),0)}}},mixed_sc:{format(a,S,y=9){a=new t(a);let I=a.log10().floor();return I.lt(303)&&I.gte(y)?g(a,S,y,"st"):g(a,S,y,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(a,S=2,y){a=new t(a);let I=a.max(1).log10().max(1).log(r.log10()).floor();if(I.lte(0))return g(a,S,y,"sc");a=t.dTen.pow(a.max(1).log10().div(r.log10().pow(I)).sub(I.gte(1)?1:0));let _=I.div(10).floor(),M=I.toNumber()%10-1;return g(a,Math.max(4,S),y,"sc")+" "+(_.gte(1)?"meta"+(_.gte(2)?"^"+g(_,0,y,"sc"):"")+"-":"")+(isNaN(M)?"nanity":e.layer.layers[M])}},standard:{tier1(a){return ht[0][0][a%10]+ht[0][1][Math.floor(a/10)%10]+ht[0][2][Math.floor(a/100)]},tier2(a){let S=a%10,y=Math.floor(a/10)%10,I=Math.floor(a/100)%10,_="";return a<10?ht[1][0][a]:(y==1&&S==0?_+="Vec":_+=ht[1][1][S]+ht[1][2][y],_+=ht[1][3][I],_)}},inf:{format(a,S,y){a=new t(a);let I=0,_=new t(Number.MAX_VALUE),M=["","\u221E","\u03A9","\u03A8","\u028A"],F=["","","m","mm","mmm"];for(;a.gte(_);)a=a.log(_),I++;return I==0?g(a,S,y,"sc"):a.gte(3)?F[I]+M[I]+"\u03C9^"+g(a.sub(1),S,y,"sc"):a.gte(2)?F[I]+"\u03C9"+M[I]+"-"+g(_.pow(a.sub(2)),S,y,"sc"):F[I]+M[I]+"-"+g(_.pow(a.sub(1)),S,y,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(a,S=new t(1e15),y=!1,I=9){if(a=new t(a),S=new t(S).div(1e3),a.lt(S.mul(1e3)))return"";let{alphabet:_}=e.alphabet.config,M=_.length,F=a.log(1e3).sub(S.log(1e3)).floor(),P=F.add(1).log(M+1).ceil(),G="",Y=(K,nt)=>{let H=K,Z="";for(let W=0;W=M)return"\u03C9";Z=_[pt]+Z,H=H.sub(1).div(M).floor()}return Z};if(P.lt(I))G=Y(F,P);else{let K=P.sub(I).add(1),nt=F.div(t.pow(M+1,K.sub(1))).floor();G=`${Y(nt,new t(I))}(${K.gt("1e9")?K.format():K.format(0)})`}return G},format(a,S=2,y=9,I="mixed_sc",_=new t(1e15),M=!1,F){if(a=new t(a),_=new t(_).div(1e3),a.lt(_.mul(1e3)))return g(a,S,y,I);let P=e.alphabet.getAbbreviation(a,_,M,F),G=a.div(t.pow(1e3,a.log(1e3).floor()));return`${P.length>(F??9)+2?"":G.toFixed(S)+" "}${P}`}}},r=t.dTwo.pow(1024),i="\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089",n="\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079";function o(a){return a.toFixed(0).split("").map(S=>S==="-"?"\u208B":i[parseInt(S,10)]).join("")}function u(a){return a.toFixed(0).split("").map(S=>S==="-"?"\u208B":n[parseInt(S,10)]).join("")}function m(a,S=2,y=9,I="st"){return g(a,S,y,I)}function g(a,S=2,y=9,I="mixed_sc"){a=new t(a);let _=a.lt(0)?"-":"";if(a.mag==1/0)return _+"Infinity";if(Number.isNaN(a.mag))return _+"NaN";if(a.lt(0)&&(a=a.mul(-1)),a.eq(0))return a.toFixed(S);let M=a.log10().floor();switch(I){case"sc":case"scientific":if(a.log10().lt(Math.min(-S,0))&&S>1){let F=a.log10().ceil(),P=a.div(F.eq(-1)?new t(.1):t.dTen.pow(F)),G=F.mul(-1).max(1).log10().gte(9);return _+(G?"":P.toFixed(2))+"e"+g(F,0,y,"mixed_sc")}else if(M.lt(y)){let F=Math.max(Math.min(S-M.toNumber(),S),0);return _+(F>0?a.toFixed(F):a.toFixed(F).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(a.gte("eeee10")){let G=a.slog();return(G.gte(1e9)?"":t.dTen.pow(G.sub(G.floor())).toFixed(2))+"F"+g(G.floor(),0)}let F=a.div(t.dTen.pow(M)),P=M.log10().gte(9);return _+(P?"":F.toFixed(2))+"e"+g(M,0,y,"mixed_sc")}case"st":case"standard":{let F=a.log(1e3).floor();if(F.lt(1))return _+a.toFixed(Math.max(Math.min(S-M.toNumber(),S),0));let P=F.mul(3),G=F.log10().floor();if(G.gte(3e3))return"e"+g(M,S,y,"st");let Y="";if(F.lt(4))Y=["","K","M","B"][Math.round(F.toNumber())];else{let H=Math.floor(F.log(1e3).toNumber());for(H<100&&(H=Math.max(H-1,0)),F=F.sub(1).div(t.dTen.pow(H*3));F.gt(0);){let Z=F.div(1e3).floor(),W=F.sub(Z.mul(1e3)).floor().toNumber();W>0&&(W==1&&!H&&(Y="U"),H&&(Y=e.standard.tier2(H)+(Y?"-"+Y:"")),W>1&&(Y=e.standard.tier1(W)+Y)),F=Z,H++}}let K=a.div(t.dTen.pow(P)),nt=S===2?t.dTwo.sub(M.sub(P)).add(1).toNumber():S;return _+(G.gte(10)?"":K.toFixed(nt)+" ")+Y}default:return e[I]||console.error('Invalid format type "',I,'"'),_+e[I].format(a,S,y)}}function l(a,S,y="mixed_sc",I,_){a=new t(a),S=new t(S);let M=a.add(S),F,P=M.div(a);return P.gte(10)&&a.gte(1e100)?(P=P.log10().mul(20),F="(+"+g(P,I,_,y)+" OoMs/sec)"):F="(+"+g(S,I,_,y)+"/sec)",F}function v(a,S=2,y="s"){return a=new t(a),a.gte(86400)?g(a.div(86400).floor(),0,12,"sc")+":"+v(a.mod(86400),S,"d"):a.gte(3600)||y=="d"?(a.div(3600).gte(10)||y!="d"?"":"0")+g(a.div(3600).floor(),0,12,"sc")+":"+v(a.mod(3600),S,"h"):a.gte(60)||y=="h"?(a.div(60).gte(10)||y!="h"?"":"0")+g(a.div(60).floor(),0,12,"sc")+":"+v(a.mod(60),S,"m"):(a.gte(10)||y!="m"?"":"0")+g(a,S,12,"sc")}function c(a,S=!1,y=0,I=9,_="mixed_sc"){let M=Ut=>g(Ut,y,I,_);a=new t(a);let F=a.mul(1e3).mod(1e3).floor(),P=a.mod(60).floor(),G=a.div(60).mod(60).floor(),Y=a.div(3600).mod(24).floor(),K=a.div(86400).mod(365.2425).floor(),nt=a.div(31556952).floor(),H=nt.eq(1)?" year":" years",Z=K.eq(1)?" day":" days",W=Y.eq(1)?" hour":" hours",pt=G.eq(1)?" minute":" minutes",Dt=P.eq(1)?" second":" seconds",Rt=F.eq(1)?" millisecond":" milliseconds";return`${nt.gt(0)?M(nt)+H+", ":""}${K.gt(0)?M(K)+Z+", ":""}${Y.gt(0)?M(Y)+W+", ":""}${G.gt(0)?M(G)+pt+", ":""}${P.gt(0)?M(P)+Dt+",":""}${S&&F.gt(0)?" "+M(F)+Rt:""}`.replace(/,([^,]*)$/,"$1").trim()}function f(a){return a=new t(a),g(t.dOne.sub(a).mul(100))+"%"}function h(a){return a=new t(a),g(a.mul(100))+"%"}function p(a,S=2){return a=new t(a),a.gte(1)?"\xD7"+a.format(S):"/"+a.pow(-1).format(S)}function d(a,S,y=10){return t.gte(a,10)?t.pow(y,t.log(a,y).pow(S)):new t(a)}function O(a,S=0){a=new t(a);let y=(F=>F.map((P,G)=>({name:P.name,altName:P.altName,value:t.pow(1e3,new t(G).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"Decimal",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),I="",_=a.lte(0)?0:t.min(t.log(a,1e3).sub(1),y.length-1).floor().toNumber(),M=y[_];if(_===0)switch(S){case 1:I="";break;case 2:case 0:default:I=a.format();break}switch(S){case 1:I=M.name;break;case 2:I=a.divide(M.value).format();break;case 3:I=M.altName;break;case 0:default:I=`${a.divide(M.value).format()} ${M.name}`;break}return I}function T(a,S=!1){return`${O(a,2)} ${O(a,1)}eV${S?"/c^2":""}`}let k={...e,toSubscript:o,toSuperscript:u,formatST:m,format:g,formatGain:l,formatTime:v,formatTimeLong:c,formatReduction:f,formatPercent:h,formatMult:p,expMult:d,metric:O,ev:T};return{FORMATS:e,formats:k}}var zt=17,cr=9e15,hr=Math.log10(9e15),mr=1/9e15,dr=308,gr=-324,me=5,pr=1023,Nr=!0,yr=!1,vr=function(){let t=[];for(let r=gr+1;r<=dr;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),Nt=[2,Math.E,3,4,5,6,7,8,9,10],br=[[1,1.0891180521811203,1.1789767925673957,1.2701455431742086,1.3632090180450092,1.4587818160364217,1.5575237916251419,1.6601571006859253,1.767485818836978,1.8804192098842727,2],[1,1.1121114330934079,1.231038924931609,1.3583836963111375,1.4960519303993531,1.6463542337511945,1.8121385357018724,1.996971324618307,2.2053895545527546,2.4432574483385254,Math.E],[1,1.1187738849693603,1.2464963939368214,1.38527004705667,1.5376664685821402,1.7068895236551784,1.897001227148399,2.1132403089001035,2.362480153784171,2.6539010333870774,3],[1,1.1367350847096405,1.2889510672956703,1.4606478703324786,1.6570295196661111,1.8850062585672889,2.1539465047453485,2.476829779693097,2.872061932789197,3.3664204535587183,4],[1,1.1494592900767588,1.319708228183931,1.5166291280087583,1.748171114438024,2.0253263297298045,2.3636668498288547,2.7858359149579424,3.3257226212448145,4.035730287722532,5],[1,1.159225940787673,1.343712473580932,1.5611293155111927,1.8221199554561318,2.14183924486326,2.542468319282638,3.0574682501653316,3.7390572020926873,4.6719550537360774,6],[1,1.1670905356972596,1.3632807444991446,1.5979222279405536,1.8842640123816674,2.2416069644878687,2.69893426559423,3.3012632110403577,4.121250340630164,5.281493033448316,7],[1,1.1736630594087796,1.379783782386201,1.6292821855668218,1.9378971836180754,2.3289975651071977,2.8384347394720835,3.5232708454565906,4.478242031114584,5.868592169644505,8],[1,1.1793017514670474,1.394054150657457,1.65664127441059,1.985170999970283,2.4069682290577457,2.9647310119960752,3.7278665320924946,4.814462547283592,6.436522247411611,9],[1,1.1840100246247336,1.4061375836156955,1.6802272208863964,2.026757028388619,2.4770056063449646,3.080525271755482,3.9191964192627284,5.135152840833187,6.989961179534715,10]],wr=[[-1,-.9194161097107025,-.8335625019330468,-.7425599821143978,-.6466611521029437,-.5462617907227869,-.4419033816638769,-.3342645487554494,-.224140440909962,-.11241087890006762,0],[-1,-.90603157029014,-.80786507256596,-.7064666939634,-.60294836853664,-.49849837513117,-.39430303318768,-.29147201034755,-.19097820800866,-.09361896280296,0],[-1,-.9021579584316141,-.8005762598234203,-.6964780623319391,-.5911906810998454,-.486050182576545,-.3823089430815083,-.28106046722897615,-.1831906535795894,-.08935809204418144,0],[-1,-.8917227442365535,-.781258746326964,-.6705130326902455,-.5612813129406509,-.4551067709033134,-.35319256652135966,-.2563741554088552,-.1651412821106526,-.0796919581982668,0],[-1,-.8843387974366064,-.7678744063886243,-.6529563724510552,-.5415870994657841,-.4352842206588936,-.33504449124791424,-.24138853420685147,-.15445285440944467,-.07409659641336663,0],[-1,-.8786709358426346,-.7577735191184886,-.6399546189952064,-.527284921869926,-.4211627631006314,-.3223479611761232,-.23107655627789858,-.1472057700818259,-.07035171210706326,0],[-1,-.8740862815291583,-.7497032990976209,-.6297119746181752,-.5161838335958787,-.41036238255751956,-.31277212146489963,-.2233976621705518,-.1418697367979619,-.06762117662323441,0],[-1,-.8702632331800649,-.7430366914122081,-.6213373075161548,-.5072025698095242,-.40171437727184167,-.30517930701410456,-.21736343968190863,-.137710238299109,-.06550774483471955,0],[-1,-.8670016295947213,-.7373984232432306,-.6143173985094293,-.49973884395492807,-.394584953527678,-.2989649949848695,-.21245647317021688,-.13434688362382652,-.0638072667348083,0],[-1,-.8641642839543857,-.732534623168535,-.6083127477059322,-.4934049257184696,-.3885773075899922,-.29376029055315767,-.2083678561173622,-.13155653399373268,-.062401588652553186,0]],w=function(e){return s.fromValue_noAlloc(e)},R=function(t,e,r){return s.fromComponents(t,e,r)},C=function(e,r,i){return s.fromComponents_noNormalize(e,r,i)},mt=function(e,r){let i=r+1,n=Math.ceil(Math.log10(Math.abs(e))),o=Math.round(e*Math.pow(10,i-n))*Math.pow(10,n-i);return parseFloat(o.toFixed(Math.max(i-n,0)))},Zt=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},Mr=function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;let e=1;for(;t<10;)e=e*t,++t;t-=1;let r=.9189385332046727;r=r+(t+.5)*Math.log(t),r=r-t;let i=t*t,n=t;return r=r+1/(12*n),n=n*i,r=r-1/(360*n),n=n*i,r=r+1/(1260*n),n=n*i,r=r-1/(1680*n),n=n*i,r=r+1/(1188*n),n=n*i,r=r-691/(360360*n),n=n*i,r=r+7/(1092*n),n=n*i,r=r-3617/(122400*n),Math.exp(r)/e},_r=.36787944117144233,de=.5671432904097838,Yt=function(t,e=1e-10,r=!0){let i,n;if(!Number.isFinite(t))return t;if(r){if(t===0)return t;if(t===1)return de;t<10?i=0:i=Math.log(t)-Math.log(Math.log(t))}else{if(t===0)return-1/0;t<=-.1?i=-2:i=Math.log(-t)-Math.log(-Math.log(-t))}for(let o=0;o<100;++o){if(n=(t*Math.exp(-i)+i*i)/(i+1),Math.abs(n-i).5?1:-1;if(Math.random()*20<1)return C(e,0,1);let r=Math.floor(Math.random()*(t+1)),i=r===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let n=Math.pow(10,i);return Math.random()>.9&&(n=Math.trunc(n)),R(e,r,n)}static affordGeometricSeries_core(t,e,r,i){let n=e.mul(r.pow(i));return s.floor(t.div(n).mul(r.sub(1)).add(1).log10().div(r.log10()))}static sumGeometricSeries_core(t,e,r,i){return e.mul(r.pow(i)).mul(s.sub(1,r.pow(t))).div(s.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let o=e.add(i.mul(r)).sub(r.div(2)),u=o.pow(2);return o.neg().add(u.add(r.mul(t).mul(2)).sqrt()).div(r).floor()}static sumArithmeticSeries_core(t,e,r,i){let n=e.add(i.mul(r));return t.div(2).mul(n.mul(2).plus(t.sub(1).mul(r)))}static efficiencyOfPurchase_core(t,e,r){return t.div(e).add(t.div(r))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0||this.mag===Number.NEGATIVE_INFINITY&&this.layer>0&&Number.isFinite(this.layer))return this.sign=0,this.mag=0,this.layer=0,this;if(this.layer===0&&this.mag<0&&(this.mag=-this.mag,this.sign=-this.sign),this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_INFINITY)return this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY,this;if(this.layer===0&&this.mag=cr)return this.layer+=1,this.mag=e*Math.log10(t),this;for(;t0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=e*Math.pow(10,t),t=Math.abs(this.mag),e=Math.sign(this.mag));return this.layer===0&&(this.mag<0?(this.mag=-this.mag,this.sign=-this.sign):this.mag===0&&(this.sign=0)),(Number.isNaN(this.sign)||Number.isNaN(this.layer)||Number.isNaN(this.mag))&&(this.sign=Number.NaN,this.layer=Number.NaN,this.mag=Number.NaN),this}fromComponents(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this.normalize(),this}fromComponents_noNormalize(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this}fromMantissaExponent(t,e){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=e+Math.log10(t),this.normalize(),this}fromMantissaExponent_noNormalize(t,e){return this.fromMantissaExponent(t,e),this}fromDecimal(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this}fromNumber(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this}fromString(t,e=!1){let r=t,i=s.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);Nr?t=t.replace(",",""):yr&&(t=t.replace(",","."));let n=t.split("^^^");if(n.length===2){let d=parseFloat(n[0]),O=parseFloat(n[1]),T=n[1].split(";"),k=1;if(T.length===2&&(k=parseFloat(T[1]),isFinite(k)||(k=1)),isFinite(d)&&isFinite(O)){let a=s.pentate(d,O,k,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let o=t.split("^^");if(o.length===2){let d=parseFloat(o[0]),O=parseFloat(o[1]),T=o[1].split(";"),k=1;if(T.length===2&&(k=parseFloat(T[1]),isFinite(k)||(k=1)),isFinite(d)&&isFinite(O)){let a=s.tetrate(d,O,k,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let u=t.split("^");if(u.length===2){let d=parseFloat(u[0]),O=parseFloat(u[1]);if(isFinite(d)&&isFinite(O)){let T=s.pow(d,O);return this.sign=T.sign,this.layer=T.layer,this.mag=T.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}t=t.trim().toLowerCase();let m,g,l=t.split("pt");if(l.length===2){m=10;let d=!1;l[0].startsWith("-")&&(d=!0,l[0]=l[0].slice(1)),g=parseFloat(l[0]),l[1]=l[1].replace("(",""),l[1]=l[1].replace(")","");let O=parseFloat(l[1]);if(isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let T=s.tetrate(m,g,O,e);return this.sign=T.sign,this.layer=T.layer,this.mag=T.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}if(l=t.split("p"),l.length===2){m=10;let d=!1;l[0].startsWith("-")&&(d=!0,l[0]=l[0].slice(1)),g=parseFloat(l[0]),l[1]=l[1].replace("(",""),l[1]=l[1].replace(")","");let O=parseFloat(l[1]);if(isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let T=s.tetrate(m,g,O,e);return this.sign=T.sign,this.layer=T.layer,this.mag=T.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}if(l=t.split("f"),l.length===2){m=10;let d=!1;l[0].startsWith("-")&&(d=!0,l[0]=l[0].slice(1)),l[0]=l[0].replace("(",""),l[0]=l[0].replace(")","");let O=parseFloat(l[0]);if(l[1]=l[1].replace("(",""),l[1]=l[1].replace(")",""),g=parseFloat(l[1]),isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let T=s.tetrate(m,g,O,e);return this.sign=T.sign,this.layer=T.layer,this.mag=T.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}let v=t.split("e"),c=v.length-1;if(c===0){let d=parseFloat(t);if(isFinite(d))return this.fromNumber(d),s.fromStringCache.size>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else if(c===1){let d=parseFloat(t);if(isFinite(d)&&d!==0)return this.fromNumber(d),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}let f=t.split("e^");if(f.length===2){this.sign=1,f[0].startsWith("-")&&(this.sign=-1);let d="";for(let O=0;O=43&&T<=57||T===101)d+=f[1].charAt(O);else return this.layer=parseFloat(d),this.mag=parseFloat(f[1].substr(O+1)),this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(c<1)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let h=parseFloat(v[0]);if(h===0)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let p=parseFloat(v[v.length-1]);if(c>=2){let d=parseFloat(v[v.length-2]);isFinite(d)&&(p*=Math.sign(d),p+=Zt(d))}if(!isFinite(h))this.sign=v[0]==="-"?-1:1,this.layer=c,this.mag=p;else if(c===1)this.sign=Math.sign(h),this.layer=1,this.mag=p+Math.log10(Math.abs(h));else if(this.sign=Math.sign(h),this.layer=c,c===2){let d=s.mul(R(1,2,p),w(h));return this.sign=d.sign,this.layer=d.layer,this.mag=d.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else this.mag=p;return this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}fromValue(t){return t instanceof s?this.fromDecimal(t):typeof t=="number"?this.fromNumber(t):typeof t=="string"?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===1?Number.POSITIVE_INFINITY:this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===-1?Number.NEGATIVE_INFINITY:Number.isFinite(this.layer)?this.layer===0?this.sign*this.mag:this.layer===1?this.sign*Math.pow(10,this.mag):this.mag>0?this.sign>0?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:0:Number.NaN}mantissaWithDecimalPlaces(t){return isNaN(this.m)?Number.NaN:this.m===0?0:mt(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:mt(this.mag,t)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY?this.sign===1?"Infinity":"-Infinity":this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toString():this.m+"e"+this.e:this.layer===1?this.m+"e"+this.e:this.layer<=me?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(t){return this.layer===0?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)}toFixed(t){return this.layer===0?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)}toPrecision(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(t){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(t):mt(this.m,t)+"e"+mt(this.e,t):this.layer===1?mt(this.m,t)+"e"+mt(this.e,t):this.layer<=me?(this.sign===-1?"-":"")+"e".repeat(this.layer)+mt(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+mt(this.mag,t)}abs(){return C(this.sign===0?0:1,this.layer,this.mag)}neg(){return C(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?C(0,0,0):this.layer===0?R(this.sign,0,Math.round(this.mag)):new s(this)}floor(){return this.mag<0?this.sign===-1?C(-1,0,1):C(0,0,0):this.sign===-1?this.neg().ceil().neg():this.layer===0?R(this.sign,0,Math.floor(this.mag)):new s(this)}ceil(){return this.mag<0?this.sign===1?C(1,0,1):C(0,0,0):this.sign===-1?this.neg().floor().neg():this.layer===0?R(this.sign,0,Math.ceil(this.mag)):new s(this)}trunc(){return this.mag<0?C(0,0,0):this.layer===0?R(this.sign,0,Math.trunc(this.mag)):new s(this)}add(t){let e=w(t);if(this.eq(s.dInf)&&e.eq(s.dNegInf)||this.eq(s.dNegInf)&&e.eq(s.dInf))return C(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new s(this);if(!Number.isFinite(e.layer))return new s(e);if(this.sign===0)return new s(e);if(e.sign===0)return new s(this);if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return C(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(s.cmpabs(this,e)>0?(r=new s(this),i=new s(e)):(r=new s(e),i=new s(this)),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*r.mag+i.sign*i.mag);let n=r.layer*Math.sign(r.mag),o=i.layer*Math.sign(i.mag);if(n-o>=2)return r;if(n===0&&o===-1){if(Math.abs(i.mag-Math.log10(r.mag))>zt)return r;{let u=Math.pow(10,Math.log10(r.mag)-i.mag),m=i.sign+r.sign*u;return R(Math.sign(m),1,i.mag+Math.log10(Math.abs(m)))}}if(n===1&&o===0){if(Math.abs(r.mag-Math.log10(i.mag))>zt)return r;{let u=Math.pow(10,r.mag-Math.log10(i.mag)),m=i.sign+r.sign*u;return R(Math.sign(m),1,Math.log10(i.mag)+Math.log10(Math.abs(m)))}}if(Math.abs(r.mag-i.mag)>zt)return r;{let u=Math.pow(10,r.mag-i.mag),m=i.sign+r.sign*u;return R(Math.sign(m),1,i.mag+Math.log10(Math.abs(m)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(w(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=w(t);if(this.eq(s.dInf)&&e.eq(s.dNegInf)||this.eq(s.dNegInf)&&e.eq(s.dInf))return C(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.mag==Number.POSITIVE_INFINITY&&e.eq(s.dZero)||this.eq(s.dZero)&&this.mag==Number.POSITIVE_INFINITY)return C(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new s(this);if(!Number.isFinite(e.layer))return new s(e);if(this.sign===0||e.sign===0)return C(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return C(this.sign*e.sign,0,1);let r,i;if(this.layer>e.layer||this.layer==e.layer&&Math.abs(this.mag)>Math.abs(e.mag)?(r=new s(this),i=new s(e)):(r=new s(e),i=new s(this)),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return R(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return R(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return R(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let n=R(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(R(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return R(r.sign*i.sign,n.layer+1,n.sign*n.mag)}if(r.layer===2&&i.layer===2){let n=R(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(R(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return R(r.sign*i.sign,n.layer+1,n.sign*n.mag)}throw Error("Bad arguments to mul: "+this+", "+t)}multiply(t){return this.mul(t)}times(t){return this.mul(t)}div(t){let e=w(t);return this.mul(e.recip())}divide(t){return this.div(t)}divideBy(t){return this.div(t)}dividedBy(t){return this.div(t)}recip(){return this.mag===0?C(Number.NaN,Number.NaN,Number.NaN):this.mag===Number.POSITIVE_INFINITY?C(0,0,0):this.layer===0?R(this.sign,0,1/this.mag):R(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=w(t).abs();if(e.eq(s.dZero))return C(0,0,0);let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new s(r%i):this.sub(e).eq(this)?C(0,0,0):e.sub(this).eq(e)?new s(this):this.sign==-1?this.abs().mod(e).neg():this.sub(this.div(e).floor().mul(e))}modulo(t){return this.mod(t)}modular(t){return this.mod(t)}cmp(t){let e=w(t);return this.sign>e.sign?1:this.sign0?this.layer:-this.layer,i=e.mag>0?e.layer:-e.layer;return r>i?1:re.mag?1:this.mag0?new s(e):new s(this)}clamp(t,e){return this.max(t).min(e)}clampMin(t){return this.max(t)}clampMax(t){return this.min(t)}cmp_tolerance(t,e){let r=w(t);return this.eq_tolerance(r,e)?0:this.cmp(r)}compare_tolerance(t,e){return this.cmp_tolerance(t,e)}eq_tolerance(t,e){let r=w(t);if(e==null&&(e=1e-7),this.sign!==r.sign||Math.abs(this.layer-r.layer)>1)return!1;let i=this.mag,n=r.mag;return this.layer>r.layer&&(n=Zt(n)),this.layer0?R(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):R(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?C(Number.NaN,Number.NaN,Number.NaN):this.layer>0?R(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):R(this.sign,0,Math.log10(this.mag))}log(t){return t=w(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?C(Number.NaN,Number.NaN,Number.NaN):this.layer===0&&t.layer===0?R(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):s.div(this.log10(),t.log10())}log2(){return this.sign<=0?C(Number.NaN,Number.NaN,Number.NaN):this.layer===0?R(this.sign,0,Math.log2(this.mag)):this.layer===1?R(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?R(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):R(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?C(Number.NaN,Number.NaN,Number.NaN):this.layer===0?R(this.sign,0,Math.log(this.mag)):this.layer===1?R(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?R(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):R(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=w(t),r=new s(this),i=new s(e);if(r.sign===0)return i.eq(0)?C(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return C(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return r;let n=r.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?n.neg():Math.abs(i.toNumber()%2)%2===0?n:C(Number.NaN,Number.NaN,Number.NaN):n}pow10(){if(this.eq(s.dInf))return C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.eq(s.dNegInf))return C(0,0,0);if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return C(Number.NaN,Number.NaN,Number.NaN);let t=new s(this);if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return R(1,0,e);if(t.sign===0)return C(1,0,1);t=C(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?R(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?R(-t.sign,t.layer+1,-t.mag):C(1,0,1)}pow_base(t){return w(t).pow(this)}root(t){let e=w(t);return this.pow(e.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(C(1,0,24)))return s.fromNumber(Mr(this.sign*this.mag));let t=this.mag-1,e=.9189385332046727;e=e+(t+.5)*Math.log(t),e=e-t;let r=t*t,i=t,n=12*i,o=1/n,u=e+o;if(u===e||(e=u,i=i*r,n=360*i,o=1/n,u=e-o,u===e))return s.exp(e);e=u,i=i*r,n=1260*i;let m=1/n;return e=e+m,i=i*r,n=1680*i,m=1/n,e=e-m,s.exp(e)}else return this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?C(1,0,1):this.layer===0&&this.mag<=709.7?s.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?R(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?R(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):R(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return s.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return R(1,2,Math.log10(this.mag)-.3010299956639812);{let t=s.div(C(this.sign,this.layer-1,this.mag),C(1,0,2));return t.layer+=1,t.normalize(),t}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(t=2,e=C(1,0,1),r=!1){if(t===1)return s.pow(this,e);if(t===0)return new s(e);if(this.eq(s.dOne))return C(1,0,1);if(this.eq(-1))return s.pow(this,e);if(t===Number.POSITIVE_INFINITY){let o=this.toNumber();if(o<=1.444667861009766&&o>=.06598803584531254){let u=s.ln(this).neg(),m=u.lambertw().div(u);if(o<1)return m;let g=u.lambertw(!1).div(u);return o>1.444667861009099&&(m=g=s.fromNumber(Math.E)),e=w(e),e.eq(g)?g:e.lt(g)?m:C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}else return o>1.444667861009766?C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY):C(Number.NaN,Number.NaN,Number.NaN)}if(this.eq(s.dZero)){let o=Math.abs((t+1)%2);return o>1&&(o=2-o),s.fromNumber(o)}if(t<0)return s.iteratedlog(e,this,-t,r);e=new s(e);let i=t;t=Math.trunc(t);let n=i-t;if(this.gt(s.dZero)&&(this.lt(1)||this.lte(1.444667861009766)&&e.lte(s.ln(this).neg().lambertw(!1).div(s.ln(this).neg())))&&(i>1e4||!r)){let o=Math.min(1e4,t);e.eq(s.dOne)?e=this.pow(n):this.lt(1)?e=e.pow(1-n).mul(this.pow(e).pow(n)):e=e.layeradd(n,this);for(let u=0;u1e4&&Math.ceil(i)%2==1?this.pow(e):e}n!==0&&(e.eq(s.dOne)?this.gt(10)||r?e=this.pow(n):(e=s.fromNumber(s.tetrate_critical(this.toNumber(),n)),this.lt(2)&&(e=e.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?e=e.layeradd10(n,r):this.lt(1)?e=e.pow(1-n).mul(this.pow(e).pow(n)):e=e.layeradd(n,this,r));for(let o=0;o3)return C(e.sign,e.layer+(t-o-1),e.mag);if(o>1e4)return e}return e}iteratedexp(t=2,e=C(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return s.tetrate(t,-e,this,r);t=w(t);let i=s.fromDecimal(this),n=e;e=Math.trunc(e);let o=n-e;if(i.layer-t.layer>3){let u=Math.min(e,i.layer-t.layer-3);e-=u,i.layer-=u}for(let u=0;u1e4)return i}return o>0&&o<1&&(t.eq(10)?i=i.layeradd10(-o,r):i=i.layeradd(-o,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,n=!1,o=!1,u=this.slog_internal(t,r).toNumber();for(let m=1;m1&&o!=l&&(n=!0),o=l,n?i/=2:i*=2,i=Math.abs(i)*(l?-1:1),u+=i,i===0)break}return s.fromNumber(u)}slog_internal(t=10,e=!1){if(t=w(t),t.lte(s.dZero)||t.eq(s.dOne))return C(Number.NaN,Number.NaN,Number.NaN);if(t.lt(s.dOne))return this.eq(s.dOne)?C(0,0,0):this.eq(s.dZero)?C(-1,0,1):C(Number.NaN,Number.NaN,Number.NaN);if(this.mag<0||this.eq(s.dZero))return C(-1,0,1);if(t.lt(1.444667861009766)){let n=s.ln(t).neg(),o=n.lambertw().div(n);if(this.eq(o))return C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.gt(o))return C(Number.NaN,Number.NaN,Number.NaN)}let r=0,i=s.fromDecimal(this);if(i.layer-t.layer>3){let n=i.layer-t.layer-3;r+=n,i.layer-=n}for(let n=0;n<100;++n)if(i.lt(s.dZero))i=s.pow(t,i),r-=1;else{if(i.lte(s.dOne))return e?s.fromNumber(r+i.toNumber()-1):s.fromNumber(r+s.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=s.log(i,t)}return s.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:s.critical_section(t,e,wr)}static tetrate_critical(t,e){return s.critical_section(t,e,br)}static critical_section(t,e,r,i=!1){e*=10,e<0&&(e=0),e>10&&(e=10),t<2&&(t=2),t>10&&(t=10);let n=0,o=0;for(let m=0;mt){let g=(t-Nt[m])/(Nt[m+1]-Nt[m]);n=r[m][Math.floor(e)]*(1-g)+r[m+1][Math.floor(e)]*g,o=r[m][Math.ceil(e)]*(1-g)+r[m+1][Math.ceil(e)]*g;break}let u=e-Math.floor(e);return n<=0||o<=0?n*(1-u)+o*u:Math.pow(t,Math.log(n)/Math.log(t)*(1-u)+Math.log(o)/Math.log(t)*u)}layeradd10(t,e=!1){t=s.fromValue_noAlloc(t).toNumber();let r=s.fromDecimal(this);if(t>=1){r.mag<0&&r.layer>0?(r.sign=0,r.mag=0,r.layer=0):r.sign===-1&&r.layer==0&&(r.sign=1,r.mag=-r.mag);let i=Math.trunc(t);t-=i,r.layer+=i}if(t<=-1){let i=Math.trunc(t);if(t-=i,r.layer+=i,r.layer<0)for(let n=0;n<100;++n){if(r.layer++,r.mag=Math.log10(r.mag),!isFinite(r.mag))return r.sign===0&&(r.sign=1),r.layer<0&&(r.layer=0),r.normalize();if(r.layer>=0)break}}for(;r.layer<0;)r.layer++,r.mag=Math.log10(r.mag);return r.sign===0&&(r.sign=1,r.mag===0&&r.layer>=1&&(r.layer-=1,r.mag=1)),r.normalize(),t!==0?r.layeradd(t,10,e):r}layeradd(t,e,r=!1){let i=w(e);if(i.gt(1)&&i.lte(1.444667861009766)){let u=s.excess_slog(this,e,r),m=u[0].toNumber(),g=u[1],l=m+t,v=s.ln(e).neg(),c=v.lambertw().div(v),f=v.lambertw(!1).div(v),h=s.dOne;g==1?h=c.mul(f).sqrt():g==2&&(h=f.mul(2));let p=i.pow(h),d=Math.floor(l),O=l-d,T=h.pow(1-O).mul(p.pow(O));return s.tetrate(i,d,T,r)}let o=this.slog(e,100,r).toNumber()+t;return o>=0?s.tetrate(e,o,s.dOne,r):Number.isFinite(o)?o>=-1?s.log(s.tetrate(e,o+1,s.dOne,r),e):s.log(s.log(s.tetrate(e,o+2,s.dOne,r),e),e):C(Number.NaN,Number.NaN,Number.NaN)}static excess_slog(t,e,r=!1){t=w(t),e=w(e);let i=e;if(e=e.toNumber(),e==1||e<=0)return[C(Number.NaN,Number.NaN,Number.NaN),0];if(e>1.444667861009766)return[t.slog(e,100,r),0];let n=s.ln(e).neg(),o=n.lambertw().div(n),u=s.dInf;if(e>1&&(u=n.lambertw(!1).div(n)),e>1.444667861009099&&(o=u=s.fromNumber(Math.E)),t.lt(o))return[t.slog(e,100,r),0];if(t.eq(o))return[C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),0];if(t.eq(u))return[C(1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),2];if(t.gt(u)){let m=u.mul(2),g=i.pow(m),l=0;if(t.gte(m)&&t.lt(g))l=0;else if(t.gte(g)){let d=g;for(l=1;d.lt(t);)if(d=i.pow(d),l=l+1,d.layer>3){let O=Math.floor(t.layer-d.layer+1);d=i.iteratedexp(O,d,r),l=l+O}d.gt(t)&&(d=d.log(e),l=l-1)}else if(t.lt(m)){let d=m;for(l=0;d.gt(t);)d=d.log(e),l=l-1}let v=0,c=0,f=.5,h=m,p=s.dZero;for(;f>1e-16;){if(c=v+f,h=m.pow(1-c).mul(g.pow(c)),p=s.iteratedexp(e,l,h),p.eq(t))return[new s(l+c),2];p.lt(t)&&(v+=f),f/=2}return p.neq_tolerance(t,1e-7)?[C(Number.NaN,Number.NaN,Number.NaN),0]:[new s(l+v),2]}if(t.lt(u)&&t.gt(o)){let m=o.mul(u).sqrt(),g=i.pow(m),l=0;if(t.lte(m)&&t.gt(g))l=0;else if(t.lte(g)){let d=g;for(l=1;d.gt(t);)d=i.pow(d),l=l+1;d.lt(t)&&(d=d.log(e),l=l-1)}else if(t.gt(m)){let d=m;for(l=0;d.lt(t);)d=d.log(e),l=l-1}let v=0,c=0,f=.5,h=m,p=s.dZero;for(;f>1e-16;){if(c=v+f,h=m.pow(1-c).mul(g.pow(c)),p=s.iteratedexp(e,l,h),p.eq(t))return[new s(l+c),1];p.gt(t)&&(v+=f),f/=2}return p.neq_tolerance(t,1e-7)?[C(Number.NaN,Number.NaN,Number.NaN),0]:[new s(l+v),1]}throw new Error("Unhandled behavior in excess_slog")}lambertw(t=!0){return this.lt(-.3678794411710499)?C(Number.NaN,Number.NaN,Number.NaN):t?this.abs().lt("1e-300")?new s(this):this.mag<0?s.fromNumber(Yt(this.toNumber())):this.layer===0?s.fromNumber(Yt(this.sign*this.mag)):this.lt("eee15")?ge(this):this.ln():this.sign===1?C(Number.NaN,Number.NaN,Number.NaN):this.layer===0?s.fromNumber(Yt(this.sign*this.mag,1e-10,!1)):this.layer==1?ge(this,1e-10,!1):this.neg().recip().lambertw().neg()}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(s.dInf))return C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(!this.isFinite())return C(Number.NaN,Number.NaN,Number.NaN);if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return s.fromNumber(t).add(2).pow(this.recip());if(t<=0)return C(Number.NaN,Number.NaN,Number.NaN);if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return e_r?this.pow(this.recip()):C(Number.NaN,Number.NaN,Number.NaN)}if(this.eq(1))return C(1,0,1);if(this.lt(0))return C(Number.NaN,Number.NaN,Number.NaN);if(this.lte("1ee-16"))return t%2==1?new s(this):C(Number.NaN,Number.NaN,Number.NaN);if(this.gt(1)){let e=s.dTen;this.gte(s.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=s.dZero,i=e.layer,n=e.iteratedlog(10,i,!0),o=n,u=n.div(2),m=!0;for(;m;)u=r.add(n).div(2),s.iteratedexp(10,i,u,!0).tetrate(t,1,!0).gt(this)?n=u:r=u,u.eq(o)?m=!1:o=u;return s.iteratedexp(10,i,u,!0)}else{let e=1,r=R(1,10,1),i=R(1,10,1),n=R(1,10,1),o=R(1,1,-16),u=s.dZero,m=R(1,10,1),g=o.pow10().recip(),l=s.dZero,v=g,c=g,f=Math.ceil(t)%2==0,h=0,p=R(1,10,1),d=!1,O=s.dZero,T=!1;for(;e<4;){if(e==2){if(f)break;n=R(1,10,1),o=r,e=3,m=R(1,10,1),p=R(1,10,1)}for(d=!1;o.neq(n);){if(O=o,o.pow10().recip().tetrate(t,1,!0).eq(1)&&o.pow10().recip().lt(.4))g=o.pow10().recip(),v=o.pow10().recip(),c=o.pow10().recip(),l=s.dZero,h=-1,e==3&&(p=o);else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip())&&!f&&o.pow10().recip().lt(.4))g=o.pow10().recip(),v=o.pow10().recip(),c=o.pow10().recip(),l=s.dZero,h=0;else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip().mul(2).tetrate(t,1,!0)))g=o.pow10().recip(),v=s.dZero,c=g.mul(2),l=g,f?h=-1:h=0;else{for(u=o.mul(12e-17),g=o.pow10().recip(),v=o.add(u).pow10().recip(),l=g.sub(v),c=g.add(l);v.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||c.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||v.gte(g)||c.lte(g);)u=u.mul(2),v=o.add(u).pow10().recip(),l=g.sub(v),c=g.add(l);if((e==1&&c.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))&&v.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))||e==3&&c.tetrate(t,1,!0).lt(g.tetrate(t,1,!0))&&v.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))&&(p=o),c.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))h=-1;else if(f)h=1;else if(e==3&&o.gt_tolerance(r,1e-8))h=0;else{for(;v.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||c.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||v.gte(g)||c.lte(g);)u=u.mul(2),v=o.add(u).pow10().recip(),l=g.sub(v),c=g.add(l);c.tetrate(t,1,!0).sub(g.tetrate(t,1,!0)).lt(g.tetrate(t,1,!0).sub(v.tetrate(t,1,!0)))?h=0:h=1}}if(h==-1&&(T=!0),e==1&&h==1||e==3&&h!=0)if(n.eq(R(1,10,1)))o=o.mul(2);else{let y=!1;if(d&&(h==1&&e==1||h==-1&&e==3)&&(y=!0),o=o.add(n).div(2),y)break}else if(n.eq(R(1,10,1)))n=o,o=o.div(2);else{let y=!1;if(d&&(h==1&&e==1||h==-1&&e==3)&&(y=!0),n=n.sub(m),o=o.sub(m),y)break}if(n.sub(o).div(2).abs().gt(m.mul(1.5))&&(d=!0),m=n.sub(o).div(2).abs(),o.gt("1e18")||o.eq(O))break}if(o.gt("1e18")||!T||p==R(1,10,1))break;e==1?r=p:e==3&&(i=p),e++}n=r,o=R(1,1,-18);let k=o,a=s.dZero,S=!0;for(;S;)if(n.eq(R(1,10,1))?a=o.mul(2):a=n.add(o).div(2),s.pow(10,a).recip().tetrate(t,1,!0).gt(this)?o=a:n=a,a.eq(k)?S=!1:k=a,o.gt("1e18"))return C(Number.NaN,Number.NaN,Number.NaN);if(a.eq_tolerance(r,1e-15)){if(i.eq(R(1,10,1)))return C(Number.NaN,Number.NaN,Number.NaN);for(n=R(1,10,1),o=i,k=o,a=s.dZero,S=!0;S;)if(n.eq(R(1,10,1))?a=o.mul(2):a=n.add(o).div(2),s.pow(10,a).recip().tetrate(t,1,!0).gt(this)?o=a:n=a,a.eq(k)?S=!1:k=a,o.gt("1e18"))return C(Number.NaN,Number.NaN,Number.NaN);return a.pow10().recip()}else return a.pow10().recip()}}pentate(t=2,e=C(1,0,1),r=!1){e=new s(e);let i=t;t=Math.trunc(t);let n=i-t;n!==0&&(e.eq(s.dOne)?(++t,e=s.fromNumber(n)):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let o=0;o10)return e}return e}sin(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.sin(this.sign*this.mag)):C(0,0,0)}cos(){return this.mag<0?C(1,0,1):this.layer===0?s.fromNumber(Math.cos(this.sign*this.mag)):C(0,0,0)}tan(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.tan(this.sign*this.mag)):C(0,0,0)}asin(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.asin(this.sign*this.mag)):C(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?s.fromNumber(Math.acos(this.toNumber())):this.layer===0?s.fromNumber(Math.acos(this.sign*this.mag)):C(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.atan(this.sign*this.mag)):s.fromNumber(Math.atan(this.sign*(1/0)))}sinh(){return this.exp().sub(this.negate().exp()).div(2)}cosh(){return this.exp().add(this.negate().exp()).div(2)}tanh(){return this.sinh().div(this.cosh())}asinh(){return s.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return s.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?C(Number.NaN,Number.NaN,Number.NaN):s.ln(this.add(1).div(s.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?new s(this):this.root(s.pow(10,t))}egg(){return this.add(9)}lessThanOrEqualTo(t){return this.cmp(t)<1}lessThan(t){return this.cmp(t)<0}greaterThanOrEqualTo(t){return this.cmp(t)>-1}greaterThan(t){return this.cmp(t)>0}static smoothDamp(t,e,r,i){return new s(t).add(new s(e).minus(new s(t)).times(new s(r)).times(new s(i)))}clone(){return this}static clone(t){return s.fromComponents(t.sign,t.layer,t.mag)}softcap(t,e,r){let i=this.clone();return i.gte(t)&&([0,"pow"].includes(r)&&(i=i.div(t).pow(e).mul(t)),[1,"mul"].includes(r)&&(i=i.sub(t).div(e).add(t))),i}static softcap(t,e,r,i){return new s(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new s(t),e=new s(e);let n=this.clone();return n.gte(t)&&([0,"pow"].includes(r)&&(n=i?n.mul(t.pow(e.sub(1))).root(e):n.pow(e).div(t.pow(e.sub(1)))),[1,"exp"].includes(r)&&(n=i?n.div(t).max(1).log(e).add(t):s.pow(e,n.sub(t)).mul(t))),n}static scale(t,e,r,i,n=!1){return new s(t).scale(e,r,i,n)}format(t=2,e=9,r="mixed_sc"){return dt.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return dt.format(new s(t),e,r,i)}formatST(t=2,e=9,r="st"){return dt.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return dt.format(new s(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return dt.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,n){return dt.formatGain(new s(t),e,r,i,n)}toRoman(t=5e3){t=new s(t);let e=this.clone();if(e.gte(t)||e.lt(1))return e;let r=e.toNumber(),i={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},n="";for(let o of Object.keys(i)){let u=Math.floor(r/i[o]);r-=u*i[o],n+=o.repeat(u)}return n}static toRoman(t,e){return new s(t).toRoman(e)}static random(t=0,e=1){return t=new s(t),e=new s(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new s(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new s(Math.random()).lt(t)}};s.dZero=C(0,0,0),s.dOne=C(1,0,1),s.dNegOne=C(-1,0,1),s.dTwo=C(1,0,2),s.dTen=C(1,0,10),s.dNaN=C(Number.NaN,Number.NaN,Number.NaN),s.dInf=C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNegInf=C(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNumberMax=R(1,0,Number.MAX_VALUE),s.dNumberMin=R(1,0,Number.MIN_VALUE),s.fromStringCache=new Gt(pr),st([Tt()],s.prototype,"sign",2),st([Tt()],s.prototype,"mag",2),st([Tt()],s.prototype,"layer",2),s=st([ur()],s);var{formats:dt,FORMATS:Sr}=fr(s);s.formats=dt;var St=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.value=t.value,this.order=t.order??99,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>""}},Vt=class{constructor(t=1,e){this.addBoost=this.setBoost.bind(this),e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=new s(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new St(r))})}getBoosts(t,e){let r=[],i=[];for(let n=0;nc),l=n,v=this.getBoosts(o,!0);v[0][0]?this.boostArray[v[1][0]]=new St({id:o,name:u,description:m,value:g,order:l}):this.boostArray.push(new St({id:o,name:u,description:m,value:g,order:l}))}else{t=Array.isArray(t)?t:[t];for(let o of t){let u=this.getBoosts(o.id,!0);u[0][0]?this.boostArray[u[1][0]]=new St(o):this.boostArray.push(new St(o))}}}clearBoosts(){this.boostArray.length=0}calculate(t=this.baseEffect){let e=new s(t),r=this.boostArray;r=r.sort((i,n)=>i.order-n.order);for(let i of r)e=i.value(e);return e}},ti=ot(ft()),kt=30,Ht=.001;function Ir(t,e,r="geometric"){switch(t=new s(t),e=new s(e),r){case"arithmetic":case 1:return t.add(e).div(2);case"geometric":case 2:default:return t.mul(e).sqrt();case"harmonic":case 3:return s.dTwo.div(t.reciprocal().add(e.reciprocal()))}}function Wt(t,e,r,i){i=Object.assign({},{verbose:!1,mode:"geometric"},i),t=new s(t),e=new s(e),r=new s(r);let n,o;return i.mode==="geometric"?(n=t.sub(e).abs().div(t.abs().add(e.abs()).div(2)),o=n.lte(r)):(n=t.sub(e).abs(),o=n.lte(r)),(i.verbose===!0||i.verbose==="onlyOnFail"&&!o)&&console.log({a:t,b:e,tolerance:r,config:i,diff:n,result:o}),o}function Xt(t,e,r="geometric",i=kt,n=Ht,o=1,u){if(o=new s(o),u=new s(u??e),o.gt(u)&&([o,u]=[u,o]),t(u).eq(0))return{value:s.dZero,lowerBound:s.dZero,upperBound:s.dZero};if(t(u).lt(e))return console.warn("The function is not monotonically increasing. (f(n) < n)"),{value:u,lowerBound:u,upperBound:u};for(let g=0;g=0;m--){let g=r.add(u.mul(m)),l=r.add(u.mul(m+1)),v=o;if(o=o.add(t(g).add(t(l)).div(2).mul(u)),Wt(v,o,n,{verbose:!1,mode:"geometric"}))break}return o}function Jt(t,e,r=0,i,n){return r=new s(r),e=new s(e),e.sub(r).lte(kt)?pe(t,e,r,i):Ne(t,e,r,n)}function Ar(t,e=10,r=0,i=1e3){if(t=new s(t),e=new s(e),r=new s(r),i=new s(i),e.lt(1)||r.lt(1))return s.dNaN;let n=t.sign;if(t=t.abs(),t.gte(s.pow(e,i)))return t;let o=s.floor(s.log(t,e)),u=t.div(s.pow(e,o));return u=u.mul(s.pow(e,r)).round(),u=u.div(s.pow(e,r)),u=u.mul(s.pow(e,o)).mul(n),u}function ye(t,e,r,i=s.dInf,n,o,u=!1){t=new s(t),r=new s(r??e.level),i=new s(i);let m=i.sub(r);if(m.lt(0))return console.warn("calculateUpgrade: Invalid target: ",m),[s.dZero,s.dZero];if(u=(typeof e.el=="function"?e.el():e.el)??u,m.eq(1)){let c=e.cost(e.level),f=t.gte(c),h=[s.dZero,s.dZero];return u?(h[0]=f?s.dOne:s.dZero,h):(h=[f?s.dOne:s.dZero,f?c:s.dZero],h)}if(e.costBulk){let[c,f]=e.costBulk(t,e.level,m),h=t.gte(f);return[h?c:s.dZero,h&&!u?f:s.dZero]}if(u){let c=p=>e.cost(p.add(r)),f=s.min(i,Xt(c,t,n,o).value.floor()),h=s.dZero;return[f,h]}let g=Xt(c=>Jt(e.cost,c,r),t,n,o).value.floor().min(r.add(m).sub(1)),l=Jt(e.cost,g,r);return[g.sub(r).add(1).max(0),l]}function ve(t){return t=new s(t),`${t.sign}/${t.mag}/${t.layer}`}function Or(t){return`el/${ve(t)}`}var yt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?new s(t.level):s.dOne}};st([Tt()],yt.prototype,"id",2),st([_t(()=>s)],yt.prototype,"level",2);var be=class Ze{static{this.cacheSize=15}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.level,this,this.currencyPointerFn())}set description(e){this.descriptionFn=typeof e=="function"?e:()=>e}get level(){return((this??{data:{level:s.dOne}}).data??{level:s.dOne}).level}set level(e){this.data.level=new s(e)}constructor(e,r,i,n){let o=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>o,this.currencyPointerFn=typeof i=="function"?i:()=>i,this.cache=new Gt(n??Ze.cacheSize),this.id=e.id,this.name=e.name??e.id,this.descriptionFn=e.description?typeof e.description=="function"?e.description:()=>e.description:()=>"",this.cost=e.cost,this.costBulk=e.costBulk,this.maxLevel=e.maxLevel,this.effect=e.effect,this.el=e.el,this.defaultLevel=e.level??s.dOne}},ei=ot(ft());function we(t,e,r=s.dOne,i=s.dInf){if(t=new s(t),r=new s(r),i=new s(i),i.lt(0))return console.warn("calculateItem: Invalid target: ",i),[s.dZero,s.dZero];if(i.eq(1)){let u=e.cost(r);return[t.gte(u)?s.dOne:s.dZero,t.gte(u)?u:s.dZero]}let n=t.div(e.cost(r)).floor().min(i),o=e.cost(r).mul(n);return[n,o]}var Me=class{constructor(t,e,r){this.defaultAmount=s.dZero;let i=typeof e=="function"?e():e;this.dataPointerFn=typeof e=="function"?e:()=>i,this.currencyPointerFn=typeof r=="function"?r:()=>r,this.id=t.id,this.name=t.name??t.id,this.cost=t.cost,this.effect=t.effect,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.defaultAmount=t.amount??s.dZero}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.amount,this,this.currencyPointerFn())}set description(t){this.descriptionFn=typeof t=="function"?t:()=>t}get amount(){return((this??{data:{amount:s.dOne}}).data??{amount:s.dOne}).amount}set amount(t){this.data.amount=new s(t)}},vt=class{constructor(t){t=t??{},this.id=t.id,this.amount=t.amount??s.dZero}};st([Tt()],vt.prototype,"id",2),st([_t(()=>s)],vt.prototype,"amount",2);var ri=ot(ft()),gt=class{constructor(){this.value=s.dZero,this.upgrades={},this.items={}}};st([_t(()=>s)],gt.prototype,"value",2),st([_t(()=>yt)],gt.prototype,"upgrades",2),st([_t(()=>vt)],gt.prototype,"items",2);var _e=class{get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}constructor(t=new gt,e,r,i={defaultVal:s.dZero,defaultBoost:s.dOne}){this.defaultVal=i.defaultVal,this.defaultBoost=i.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new Vt(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e),this.items={},r&&this.addItem(r)}onLoadData(){for(let t of Object.values(this.upgrades))this.runUpgradeEffect(t)}reset(t,e,r){let i={resetCurrency:!0,resetUpgradeLevels:!0,resetItemAmounts:!0,runUpgradeEffect:!0};if(typeof t=="object"?Object.assign(i,t):Object.assign(i,{resetCurrency:t,resetUpgradeLevels:e,runUpgradeEffect:r}),i.resetCurrency&&(this.value=this.defaultVal),i.resetUpgradeLevels)for(let n of Object.values(this.upgrades))n.level=new s(n.defaultLevel),i.runUpgradeEffect&&this.runUpgradeEffect(n);if(i.resetItemAmounts)for(let n of Object.values(this.items))n.amount=new s(n.defaultAmount),i.runUpgradeEffect&&this.runItemEffect(n)}gain(t=1e3){let e=this.boost.calculate().mul(new s(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new yt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}queryUpgrade(t){let e=Object.keys(this.upgrades);if(t instanceof RegExp){let i=t;return e.filter(o=>i.test(o)).map(o=>this.upgrades[o])}return typeof t=="string"&&(t=[t]),e.filter(i=>t.includes(i)).map(i=>this.upgrades[i])}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r=[];for(let i of t){this.pointerAddUpgrade(i);let n=new be(i,()=>this.pointerGetUpgrade(i.id),()=>this);e&&this.runUpgradeEffect(n),this.upgrades[i.id]=n,r.push(n)}return r}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&Object.assign(r,e)}runUpgradeEffect(t){t.effect?.(t.level,t,this)}runItemEffect(t,e=s.dOne){e=new s(e),t.effect?.(t.amount,e,t,this)}calculateUpgrade(t,e=1/0,r,i){let n=this.getUpgrade(t);return n===null?(console.warn(`Upgrade "${t}" not found.`),[s.dZero,s.dZero]):(e=n.level.add(e),n.maxLevel!==void 0&&(e=s.min(e,n.maxLevel)),ye(this.value,n,n.level,e,r,i))}getNextCost(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),s.dZero;let o=this.calculateUpgrade(t,e,r,i)[0];return n.cost(n.level.add(o))}getNextCostMax(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),s.dZero;let o=this.calculateUpgrade(t,e,r,i);return n.cost(n.level.add(o[0])).add(o[1])}buyUpgrade(t,e,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),!1;let[o,u]=this.calculateUpgrade(t,e,r,i);return o.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(u),n.level=n.level.add(o),this.runUpgradeEffect(n),!0)}pointerAddItem(t){let e=new vt(t);return this.pointer.items[t.id]=e,e}pointerGetItem(t){return this.pointer.items[t]??null}addItem(t,e=!0){Array.isArray(t)||(t=[t]);for(let r of t){this.pointerAddItem(r);let i=new Me(r,()=>this.pointerGetItem(r.id),()=>this);e&&this.runItemEffect(i),this.items[r.id]=i}}getItem(t){return this.items[t]??null}calculateItem(t,e,r){let i=this.getItem(t);return i===null?(console.warn(`Item "${t}" not found.`),[s.dZero,s.dZero]):we(this.value,i,e,r)}buyItem(t,e,r){let i=this.getItem(t);if(i===null)return console.warn(`Item "${t}" not found.`),!1;let[n,o]=this.calculateItem(t,e,r);return n.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(o),i.amount=i.amount.add(n),this.runItemEffect(i,e),!0)}},ii=ot(ft()),xt=class{constructor(t=0){this.value=new s(t)}};st([_t(()=>s)],xt.prototype,"value",2);var Se=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=new s(r),t??=new xt(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new Vt(this.initial):null}update(){console.warn("AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed."),this.boost&&(this.pointer.value=this.boost.calculate())}get value(){return this.boost&&(this.pointer.value=this.boost.calculate()),this.pointer.value}set value(t){if(this.boost)throw new Error("Cannot set value of attributeStatic when boost is enabled.");this.pointer.value=t}},Lt=class{constructor(t,e,r={},i){this.setValue=this.set.bind(this),this.getValue=this.get.bind(this),this.x=t,this.y=e,this.properties=typeof r=="function"?r(this):{...r},this.gridSymbol=i}get grid(){return Qt.getInstance(this.gridSymbol)}set(t,e){return this.properties[t]=e,e}get(t){return this.properties[t]}translate(t=0,e=0){return Qt.getInstance(this.gridSymbol).getCell(this.x+t,this.y+e)}direction(t,e=1,r){let i=this.grid;return(()=>{switch(t){case"up":return i.getCell(this.x,this.y-e);case"right":return i.getCell(this.x+e,this.y);case"down":return i.getCell(this.x,this.y+e);case"left":return i.getCell(this.x-e,this.y);case"adjacent":return i.getAdjacent(this.x,this.y,e,r);case"diagonal":return i.getDiagonal(this.x,this.y,e,r);case"encircling":return i.getEncircling(this.x,this.y,e,r);default:throw new Error("Invalid direction")}})()}up(t=1){return this.direction("up",t)}right(t=1){return this.direction("right",t)}down(t=1){return this.direction("down",t)}left(t=1){return this.direction("left",t)}};function Ie(t,e,r=!0){let i=r?"Size":"Coordinates";if(typeof t!="number"||typeof e!="number")throw new RangeError(`${i} must be numbers: ${t}, ${e}`);if(!Number.isInteger(t)||!Number.isInteger(e))throw new RangeError(`${i} must be integers: ${t}, ${e}`);if(t<0||e<0)throw new RangeError(`${i} must be positive: ${t}, ${e}`);if(!Number.isFinite(t)||!Number.isFinite(e))throw new RangeError(`${i} must be finite: ${t}, ${e}`);if(!Number.isSafeInteger(t)||!Number.isSafeInteger(e))throw new RangeError(`${i} must be safe integers: ${t}, ${e}`)}var rt=class ne extends Array{constructor(e){e=Array.isArray(e)?e:[e],e=e.filter(r=>r!==void 0),super(...e),this.removeDuplicates()}removeDuplicates(){let e=[];this.forEach((r,i)=>{this.indexOf(r)!==i&&e.push(i)}),e.forEach(r=>this.splice(r,1))}translate(e=0,r=0){return new ne(this.map(i=>i.translate(e,r)))}direction(e,r,i){return new ne(this.flatMap(n=>n.direction(e,r,i)))}up(e){return this.direction("up",e)}right(e){return this.direction("right",e)}down(e){return this.direction("down",e)}left(e){return this.direction("left",e)}adjacent(e,r){return this.direction("adjacent",e,r)}diagonal(e,r){return this.direction("diagonal",e,r)}encircling(e,r){return this.direction("encircling",e,r)}},Qt=class se{constructor(e,r,i){this.cells=[],this.gridSymbol=Symbol(),this.all=this.getAll.bind(this),this.allX=this.getAllX.bind(this),this.allY=this.getAllY.bind(this),this.get=this.getCell.bind(this),this.set=this.setCell.bind(this),se.instances[this.gridSymbol]=this,this.starterProps=i??{},this.xSize=e,this.ySize=r??e,Ie(this.xSize,this.ySize,!0);for(let n=0;n{if(this.ySize!==n&&(this.ySizen))for(let o=n;o{if(this.xSize!==i){if(this.xSizei)for(let o=0;o{let t=!1,e=r=>(t||(console.warn("The E function is deprecated. Use the Decimal class directly."),t=!0),new s(r));return Object.getOwnPropertyNames(s).filter(r=>!Object.getOwnPropertyNames(class{}).includes(r)).forEach(r=>{e[r]=s[r]}),e})(),Tr=le,Ae={};jt(Ae,{ConfigManager:()=>qt,DataManager:()=>Fe,EventManager:()=>Te,EventTypes:()=>Ce,Game:()=>kr,GameAttribute:()=>ke,GameCurrency:()=>Pe,GameReset:()=>te,KeyManager:()=>Oe,gameDefaultConfig:()=>xe,keys:()=>Fr});var ni=ot(ft()),qt=class{constructor(t){this.configOptionTemplate=t}parse(t){if(typeof t>"u")return this.configOptionTemplate;function e(r,i){for(let n in i)typeof r[n]>"u"?r[n]=i[n]:typeof r[n]=="object"&&typeof i[n]=="object"&&!Array.isArray(r[n])&&!Array.isArray(i[n])&&(r[n]=e(r[n],i[n]));return r}return e(t,this.configOptionTemplate)}get options(){return this.configOptionTemplate}},Er={autoAddInterval:!0,fps:30},Fr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ".split("").concat(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),Oe=class Ye{constructor(e){if(this.addKeys=this.addKey.bind(this),this.keysPressed=[],this.binds=[],this.tickers=[],this.config=Ye.configManager.parse(e),this.config.autoAddInterval){let r=this.config.fps?this.config.fps:30;this.tickerInterval=setInterval(()=>{for(let i of this.tickers)i(1e3/r)},1e3/r)}typeof document>"u"||(this.tickers.push(r=>{for(let i of this.binds)(typeof i.onDownContinuous<"u"||typeof i.fn<"u")&&this.isPressing(i.id)&&(i.onDownContinuous?.(r),i.fn?.(r))}),document.addEventListener("keydown",r=>{this.logKey(r,!0),this.onAll("down",r.key)}),document.addEventListener("keyup",r=>{this.logKey(r,!1),this.onAll("up",r.key)}),document.addEventListener("keypress",r=>{this.onAll("press",r.key)}))}static{this.configManager=new qt(Er)}changeFps(e){this.config.fps=e,this.tickerInterval&&(clearInterval(this.tickerInterval),this.tickerInterval=setInterval(()=>{for(let r of this.tickers)r(1e3/e)},1e3/e))}logKey(e,r){let i=e.key;r&&!this.keysPressed.includes(i)?this.keysPressed.push(i):!r&&this.keysPressed.includes(i)&&this.keysPressed.splice(this.keysPressed.indexOf(i),1)}onAll(e,r){for(let i of this.binds)if(i.key===r)switch(e){case"down":i.onDown?.();break;case"press":default:i.onPress?.();break;case"up":i.onUp?.();break}}isPressing(e){for(let r of this.binds)if(r.id===e)return this.keysPressed.includes(r.key);return!1}getBind(e){return this.binds.find(r=>r.id===e)}addKey(e,r,i){e=typeof e=="string"?{id:e,name:e,key:r??"",fn:i}:e,e=Array.isArray(e)?e:[e];for(let n of e){n.id=n.id??n.name;let o=this.getBind(n.id);if(o){Object.assign(o,n);continue}this.binds.push(n)}}},Ce=(t=>(t.interval="interval",t.timeout="timeout",t))(Ce||{}),Pr={autoAddInterval:!0,fps:30},Te=class Ve{constructor(e,r){if(this.addEvent=this.setEvent.bind(this),this.config=Ve.configManager.parse(e),this.events={},this.callbackEvents={},r)for(let i of r)this.callbackEvents[i]=[];if(this.config.autoAddInterval){let i=this.config.fps??30;this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/i)}}static{this.configManager=new qt(Pr)}on(e,r){this.callbackEvents[e]||(this.callbackEvents[e]=[]),this.callbackEvents[e].push({type:e,callback:r})}dispatch(e){if(this.callbackEvents[e])for(let r of this.callbackEvents[e])r.callback()}tickerFunction(){let e=Date.now();for(let r of Object.values(this.events))switch(r.type){case"interval":if(e-r.intervalLast>=r.delay){let i=e-r.intervalLast;r.callback(i),r.intervalLast=e}break;case"timeout":{let i=e-r.timeCreated;e-r.timeCreated>=r.delay&&(r.callback(i),delete this.events[r.name])}break}}changeFps(e){this.config.fps=e,this.tickerInterval&&(clearInterval(this.tickerInterval),this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/e))}timeWarp(e){for(let r of Object.values(this.events))switch(r.type){case"interval":r.intervalLast-=e;break;case"timeout":r.timeCreated-=e;break}}setEvent(e,r,i,n){this.events[e]=(()=>{switch(r){case"interval":return{name:e,type:r,delay:typeof i=="number"?i:i.toNumber(),callback:n,timeCreated:Date.now(),intervalLast:Date.now()};case"timeout":default:return{name:e,type:r,delay:typeof i=="number"?i:i.toNumber(),callback:n,timeCreated:Date.now()}}})()}removeEvent(e){delete this.events[e]}},si=ot(ft()),Ee=ot(Ke()),Kt=ot(rr()),Fe=class{constructor(t){this.data={},this.static={},this.eventsOnLoad=[],this.gameRef=typeof t=="function"?t():t}addEventOnLoad(t){this.eventsOnLoad.push(t)}setData(t,e){typeof this.data[t]>"u"&&this.normalData&&console.warn("After initializing data, you should not add new properties to data."),this.data[t]=e;let r=()=>this.data;return{get value(){return r()[t]},set value(i){r()[t]=i},setValue(i){r()[t]=i}}}getData(t){return this.data[t]}setStatic(t,e){return console.warn("setStatic: Static data is basically useless and should not be used. Use variables in local scope instead."),typeof this.static[t]>"u"&&this.normalData&&console.warn("After initializing data, you should not add new properties to staticData."),this.static[t]=e,this.static[t]}getStatic(t){return console.warn("getStatic: Static data is basically useless and should not be used. Use variables in local scope instead."),this.static[t]}init(){this.normalData=this.data,this.normalDataPlain=Bt(this.data)}compileDataRaw(t=this.data){this.gameRef.eventManager.dispatch("beforeCompileData");let e=Bt(t),r=(0,Kt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(e)}`),i;try{i="9.4.0"}catch{i="9.3.0"}return[{hash:r,game:{title:this.gameRef.config.name.title,id:this.gameRef.config.name.id,version:this.gameRef.config.name.version},emath:{version:i}},e]}compileData(t=this.data){let e=JSON.stringify(this.compileDataRaw(t));return(0,Ee.compressToBase64)(e)}decompileData(t=window.localStorage.getItem(`${this.gameRef.config.name.id}-data`)){if(!t)return null;let e;try{return e=JSON.parse((0,Ee.decompressFromBase64)(t)),e}catch(r){if(r instanceof SyntaxError)console.error(`Failed to decompile data (corrupted) "${t}":`,r);else throw r;return null}}validateData(t){let[e,r]=t;if(typeof e=="string")return(0,Kt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`)===e;let i=e.hash,n=(0,Kt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`);return i===n}resetData(t=!1){if(!this.normalData)throw new Error("dataManager.resetData(): You must call init() before writing to data.");this.data=this.normalData,this.saveData(),t&&window.location.reload()}saveData(t=this.compileData()){if(this.gameRef.eventManager.dispatch("beforeSaveData"),!t)throw new Error("dataManager.saveData(): Data to save is empty.");if(!window.localStorage)throw new Error("dataManager.saveData(): Local storage is not supported. You can use compileData() instead to implement a custom save system.");window.localStorage.setItem(`${this.gameRef.config.name.id}-data`,t),this.gameRef.eventManager.dispatch("saveData")}exportData(){let t=this.compileData();if(prompt("Download save data?:",t)!=null){let e=new Blob([t],{type:"text/plain"}),r=document.createElement("a");r.href=URL.createObjectURL(e),r.download=`${this.gameRef.config.name.id}-data.txt`,r.textContent=`Download ${this.gameRef.config.name.id}-data.txt file`,document.body.appendChild(r),r.click(),document.body.removeChild(r)}}parseData(t=this.decompileData(),e=!0){if((!this.normalData||!this.normalDataPlain)&&e)throw new Error("dataManager.parseData(): You must call init() before writing to data.");if(!t)return null;let[,r]=t;function i(c){return typeof c=="object"&&c?.constructor===Object}let n=(c,f)=>Object.prototype.hasOwnProperty.call(c,f);function o(c,f,h){if(!c||!f||!h)return console.warn("dataManager.deepMerge(): Missing arguments:",c,f,h),h??{};let p=h;for(let d in c)if(n(c,d)&&!n(h,d)&&(p[d]=c[d]),f[d]instanceof gt){let O=c[d],T=h[d];if(Array.isArray(T.upgrades)){let k=T.upgrades;T.upgrades={};for(let a of k)T.upgrades[a.id]=a}T.upgrades={...O.upgrades,...T.upgrades},p[d]=T,T.items={...O.items,...T.items}}else i(c[d])&&i(h[d])&&(p[d]=o(c[d],f[d],h[d]));return p}let u=e?o(this.normalDataPlain,this.normalData,r):r,m=Object.getOwnPropertyNames(new yt({id:"",level:s.dZero})),g=Object.getOwnPropertyNames(new vt({id:"",amount:s.dZero}));function l(c,f){let h=$t(c,f);if(h instanceof gt){for(let p in h.upgrades){let d=h.upgrades[p];if(!d||!m.every(O=>Object.getOwnPropertyNames(d).includes(O))){delete h.upgrades[p];continue}h.upgrades[p]=$t(yt,d)}for(let p in h.items){let d=h.items[p];if(!d||!g.every(O=>Object.getOwnPropertyNames(d).includes(O))){delete h.items[p];continue}h.items[p]=$t(vt,d)}}if(!h)throw new Error(`Failed to convert ${c.name} to class instance.`);return h}function v(c,f){if(!c||!f)throw new Error("dataManager.plainToInstanceRecursive(): Missing arguments.");let h=f;for(let p in c){if(f[p]===void 0){console.warn(`Missing property "${p}" in loaded data.`);continue}if(!i(f[p]))continue;let d=c[p].constructor;if(d===Object){h[p]=v(c[p],f[p]);continue}h[p]=l(d,f[p])}return h}return u=v(this.normalData,u),u}loadData(t=this.decompileData()){if(t=typeof t=="string"?this.decompileData(t):t,!t)return null;let e=this.validateData([t[0],Bt(t[1])]),r=this.parseData(t);if(!r)return null;this.data=r;for(let i of this.eventsOnLoad)i();return this.gameRef.eventManager.dispatch("loadData"),e}},Pe=class extends _e{get data(){return this.pointer}get static(){return this}constructor(t,e,r){if(typeof t=="function")throw new Error("GameCurrency constructor does not accept a function as the first parameter. Use the .addCurrency method instead.");super(...t),this.game=e,this.name=r,this.game.dataManager.addEventOnLoad(()=>{this.static.onLoadData()})}},ke=class extends Se{get data(){return this.pointer}get static(){return this}constructor(t,e){if(typeof t=="function")throw new Error("GameAttribute constructor does not accept a function as the first parameter. Use the .addAttribute method instead.");super(...t),this.game=e}},te=class He{static fromObject(e){return new He(e.currenciesToReset,e.extender,e.onReset,e.condition)}constructor(e,r,i,n){this.currenciesToReset=Array.isArray(e)?e:[e],r=r??[],this.extender=Array.isArray(r)?r:[r],this.onReset=i,this.condition=n,this.id=Symbol()}reset(e=!1,r=!0,i=new Set){if(e||(typeof this.condition=="function"?!this.condition(this):!this.condition)&&typeof this.condition<"u")return;let n=()=>{this.onReset?.(this),this.currenciesToReset.forEach(o=>{o.static.reset()})};if(this.extender.length===0){n();return}this.extender.forEach(o=>{i.has(o.id)||(i.add(o.id),o.reset(r||e,r,i))}),n()}},xe={mode:"production",name:{title:"",id:"",version:"0.0.0"},settings:{framerate:30},initIntervalBasedManagers:!0},kr=class We{static{this.configManager=new qt(xe)}constructor(e){this.config=We.configManager.parse(e),this.dataManager=new Fe(this),this.keyManager=new Oe({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.eventManager=new Te({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.tickers=[]}init(){this.dataManager.init()}changeFps(e){this.keyManager.changeFps(e),this.eventManager.changeFps(e)}addCurrency(e,r=[],i=[]){return this.dataManager.setData(e,{currency:new gt}),new Pe([()=>this.dataManager.getData(e).currency,r,i],this,e)}addAttribute(e,r=!0,i=0){return this.dataManager.setData(e,new xt(i)),new ke([this.dataManager.getData(e),r,i],this)}addReset(...e){return console.warn("Game.addReset is deprecated. Use the GameReset class instead."),new te(...e)}addResetFromObject(e){return te.fromObject(e)}},xr={...Tr,...Ae},Lr=xr;if(typeof ut.exports=="object"&&typeof Ot=="object"){var qr=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Object.getOwnPropertyNames(e))!Object.prototype.hasOwnProperty.call(t,n)&&n!==r&&Object.defineProperty(t,n,{get:()=>e[n],enumerable:!(i=Object.getOwnPropertyDescriptor(e,n))||i.enumerable});return t};ut.exports=qr(ut.exports,Ot)}return ut.exports}); +"use strict";(function(Ot,ut){var Ft=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],ut);else if(typeof module=="object"&&module.exports)module.exports=ut();else{var ct=ut(),Pt=Ft?exports:Ot;for(var Ct in ct)Pt[Ct]=ct[Ct]}})(typeof self<"u"?self:exports,()=>{var Ot={},ut={exports:Ot},Ft=Object.create,ct=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Ct=Object.getOwnPropertyNames,Xe=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty,bt=(t,e)=>function(){return e||(0,t[Ct(t)[0]])((e={exports:{}}).exports,e),e.exports},Ut=(t,e)=>{for(var r in e)ct(t,r,{get:e[r],enumerable:!0})},oe=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ct(e))!Je.call(t,n)&&n!==r&&ct(t,n,{get:()=>e[n],enumerable:!(i=Pt(e,n))||i.enumerable});return t},ot=(t,e,r)=>(r=t!=null?Ft(Xe(t)):{},oe(e||!t||!t.__esModule?ct(r,"default",{value:t,enumerable:!0}):r,t)),Qe=t=>oe(ct({},"__esModule",{value:!0}),t),st=(t,e,r,i)=>{for(var n=i>1?void 0:i?Pt(e,r):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(n=(i?u(e,r,n):u(n))||n);return i&&n&&ct(e,r,n),n},ft=bt({"node_modules/reflect-metadata/Reflect.js"(){var t;(function(e){(function(r){var i=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:g(),n=o(e);typeof i.Reflect<"u"&&(n=o(i.Reflect,n)),r(n,i),typeof i.Reflect>"u"&&(i.Reflect=e);function o(l,v){return function(c,f){Object.defineProperty(l,c,{configurable:!0,writable:!0,value:f}),v&&v(c,f)}}function u(){try{return Function("return this;")()}catch{}}function m(){try{return(0,eval)("(function() { return this; })()")}catch{}}function g(){return u()||m()}})(function(r,i){var n=Object.prototype.hasOwnProperty,o=typeof Symbol=="function",u=o&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",m=o&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",g=typeof Object.create=="function",l={__proto__:[]}instanceof Array,v=!g&&!l,c={create:g?function(){return ie(Object.create(null))}:l?function(){return ie({__proto__:null})}:function(){return ie({})},has:v?function(N,b){return n.call(N,b)}:function(N,b){return b in N},get:v?function(N,b){return n.call(N,b)?N[b]:void 0}:function(N,b){return N[b]}},f=Object.getPrototypeOf(Function),h=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Yr(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Vr(),d=typeof WeakMap=="function"?WeakMap:Hr(),O=o?Symbol.for("@reflect-metadata:registry"):void 0,T=$r(),k=zr(T);function a(N,b,A,E){if(U(A)){if(!De(N))throw new TypeError;if(!je(b))throw new TypeError;return K(N,b)}else{if(!De(N))throw new TypeError;if(!X(b))throw new TypeError;if(!X(E)&&!U(E)&&!It(E))throw new TypeError;return It(E)&&(E=void 0),A=lt(A),nt(N,b,A,E)}}r("decorate",a);function S(N,b){function A(E,R){if(!X(E))throw new TypeError;if(!U(R)&&!Gr(R))throw new TypeError;Dt(N,b,E,R)}return A}r("metadata",S);function y(N,b,A,E){if(!X(A))throw new TypeError;return U(E)||(E=lt(E)),Dt(N,b,A,E)}r("defineMetadata",y);function I(N,b,A){if(!X(b))throw new TypeError;return U(A)||(A=lt(A)),H(N,b,A)}r("hasMetadata",I);function _(N,b,A){if(!X(b))throw new TypeError;return U(A)||(A=lt(A)),Z(N,b,A)}r("hasOwnMetadata",_);function M(N,b,A){if(!X(b))throw new TypeError;return U(A)||(A=lt(A)),W(N,b,A)}r("getMetadata",M);function F(N,b,A){if(!X(b))throw new TypeError;return U(A)||(A=lt(A)),pt(N,b,A)}r("getOwnMetadata",F);function P(N,b){if(!X(N))throw new TypeError;return U(b)||(b=lt(b)),jt(N,b)}r("getMetadataKeys",P);function G(N,b){if(!X(N))throw new TypeError;return U(b)||(b=lt(b)),Rt(N,b)}r("getOwnMetadataKeys",G);function Y(N,b,A){if(!X(b))throw new TypeError;if(U(A)||(A=lt(A)),!X(b))throw new TypeError;U(A)||(A=lt(A));var E=Et(b,A,!1);return U(E)?!1:E.OrdinaryDeleteMetadata(N,b,A)}r("deleteMetadata",Y);function K(N,b){for(var A=N.length-1;A>=0;--A){var E=N[A],R=E(b);if(!U(R)&&!It(R)){if(!je(R))throw new TypeError;b=R}}return b}function nt(N,b,A,E){for(var R=N.length-1;R>=0;--R){var J=N[R],tt=J(b,A,E);if(!U(tt)&&!It(tt)){if(!X(tt))throw new TypeError;E=tt}}return E}function H(N,b,A){var E=Z(N,b,A);if(E)return!0;var R=re(b);return It(R)?!1:H(N,R,A)}function Z(N,b,A){var E=Et(b,A,!1);return U(E)?!1:qe(E.OrdinaryHasOwnMetadata(N,b,A))}function W(N,b,A){var E=Z(N,b,A);if(E)return pt(N,b,A);var R=re(b);if(!It(R))return W(N,R,A)}function pt(N,b,A){var E=Et(b,A,!1);if(!U(E))return E.OrdinaryGetOwnMetadata(N,b,A)}function Dt(N,b,A,E){var R=Et(A,E,!0);R.OrdinaryDefineOwnMetadata(N,b,A,E)}function jt(N,b){var A=Rt(N,b),E=re(N);if(E===null)return A;var R=jt(E,b);if(R.length<=0)return A;if(A.length<=0)return R;for(var J=new p,tt=[],$=0,x=A;$=0&&x=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:L,done:!1}}return{value:void 0,done:!0}},$.prototype.throw=function(x){throw this._index>=0&&(this._index=-1,this._keys=b,this._values=b),x},$.prototype.return=function(x){return this._index>=0&&(this._index=-1,this._keys=b,this._values=b),{value:x,done:!0}},$}(),E=function(){function $(){this._keys=[],this._values=[],this._cacheKey=N,this._cacheIndex=-2}return Object.defineProperty($.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),$.prototype.has=function(x){return this._find(x,!1)>=0},$.prototype.get=function(x){var L=this._find(x,!1);return L>=0?this._values[L]:void 0},$.prototype.set=function(x,L){var q=this._find(x,!0);return this._values[q]=L,this},$.prototype.delete=function(x){var L=this._find(x,!1);if(L>=0){for(var q=this._keys.length,D=L+1;D>>8,c[f*2+1]=p%256}return c},decompressFromUint8Array:function(l){if(l==null)return g.decompress(l);for(var v=new Array(l.length/2),c=0,f=v.length;c>1}else{for(h=1,f=0;f>1}a--,a==0&&(a=Math.pow(2,y),y++),delete d[k]}else for(h=p[k],f=0;f>1;a--,a==0&&(a=Math.pow(2,y),y++),p[T]=S++,k=String(O)}if(k!==""){if(Object.prototype.hasOwnProperty.call(d,k)){if(k.charCodeAt(0)<256){for(f=0;f>1}else{for(h=1,f=0;f>1}a--,a==0&&(a=Math.pow(2,y),y++),delete d[k]}else for(h=p[k],f=0;f>1;a--,a==0&&(a=Math.pow(2,y),y++)}for(h=2,f=0;f>1;for(;;)if(_=_<<1,M==v-1){I.push(c(_));break}else M++;return I.join("")},decompress:function(l){return l==null?"":l==""?null:g._decompress(l.length,32768,function(v){return l.charCodeAt(v)})},_decompress:function(l,v,c){var f=[],h,p=4,d=4,O=3,T="",k=[],a,S,y,I,_,M,F,P={val:c(0),position:v,index:1};for(a=0;a<3;a+=1)f[a]=a;for(y=0,_=Math.pow(2,2),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;switch(h=y){case 0:for(y=0,_=Math.pow(2,8),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;F=i(y);break;case 1:for(y=0,_=Math.pow(2,16),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;F=i(y);break;case 2:return""}for(f[3]=F,S=F,k.push(F);;){if(P.index>l)return"";for(y=0,_=Math.pow(2,O),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;switch(F=y){case 0:for(y=0,_=Math.pow(2,8),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;f[d++]=i(y),F=d-1,p--;break;case 1:for(y=0,_=Math.pow(2,16),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;f[d++]=i(y),F=d-1,p--;break;case 2:return k.join("")}if(p==0&&(p=Math.pow(2,O),O++),f[F])T=f[F];else if(F===d)T=S+S.charAt(0);else return null;k.push(T),f[d++]=S+T.charAt(0),p--,S=T,p==0&&(p=Math.pow(2,O),O++)}}};return g}();typeof define=="function"&&define.amd?define(function(){return r}):typeof e<"u"&&e!=null?e.exports=r:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return r})}}),tr=bt({"node_modules/crypt/crypt.js"(t,e){(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i={rotl:function(n,o){return n<>>32-o},rotr:function(n,o){return n<<32-o|n>>>o},endian:function(n){if(n.constructor==Number)return i.rotl(n,8)&16711935|i.rotl(n,24)&4278255360;for(var o=0;o0;n--)o.push(Math.floor(Math.random()*256));return o},bytesToWords:function(n){for(var o=[],u=0,m=0;u>>5]|=n[u]<<24-m%32;return o},wordsToBytes:function(n){for(var o=[],u=0;u>>5]>>>24-u%32&255);return o},bytesToHex:function(n){for(var o=[],u=0;u>>4).toString(16)),o.push((n[u]&15).toString(16));return o.join("")},hexToBytes:function(n){for(var o=[],u=0;u>>6*(3-g)&63)):o.push("=");return o.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var o=[],u=0,m=0;u>>6-m*2);return o}};e.exports=i})()}}),ae=bt({"node_modules/charenc/charenc.js"(t,e){var r={utf8:{stringToBytes:function(i){return r.bin.stringToBytes(unescape(encodeURIComponent(i)))},bytesToString:function(i){return decodeURIComponent(escape(r.bin.bytesToString(i)))}},bin:{stringToBytes:function(i){for(var n=[],o=0;o>>24)&16711935|(l[d]<<24|l[d]>>>8)&4278255360;l[v>>>5]|=128<>>9<<4)+14]=v;for(var O=u._ff,T=u._gg,k=u._hh,a=u._ii,d=0;d>>0,f=f+y>>>0,h=h+I>>>0,p=p+_>>>0}return r.endian([c,f,h,p])};u._ff=function(m,g,l,v,c,f,h){var p=m+(g&l|~g&v)+(c>>>0)+h;return(p<>>32-f)+g},u._gg=function(m,g,l,v,c,f,h){var p=m+(g&v|l&~v)+(c>>>0)+h;return(p<>>32-f)+g},u._hh=function(m,g,l,v,c,f,h){var p=m+(g^l^v)+(c>>>0)+h;return(p<>>32-f)+g},u._ii=function(m,g,l,v,c,f,h){var p=m+(l^(g|~v))+(c>>>0)+h;return(p<>>32-f)+g},u._blocksize=16,u._digestsize=16,e.exports=function(m,g){if(m==null)throw new Error("Illegal argument "+m);var l=r.wordsToBytes(u(m,g));return g&&g.asBytes?l:g&&g.asString?o.bytesToString(l):r.bytesToHex(l)}})()}}),ue={};Ut(ue,{default:()=>Lr}),ut.exports=Qe(ue);var Jr=ot(ft()),Qr=ot(ft()),le={};Ut(le,{Attribute:()=>xt,AttributeStatic:()=>Se,Boost:()=>Vt,BoostObject:()=>St,Currency:()=>gt,CurrencyStatic:()=>_e,DEFAULT_ITERATIONS:()=>kt,Decimal:()=>s,E:()=>Cr,FORMATS:()=>Sr,FormatTypeList:()=>lr,Grid:()=>Qt,GridCell:()=>Lt,GridCellCollection:()=>rt,Item:()=>Me,ItemData:()=>vt,LRUCache:()=>Gt,ListNode:()=>fe,ST_NAMES:()=>ht,UpgradeData:()=>yt,UpgradeStatic:()=>be,calculateItem:()=>we,calculateSum:()=>Jt,calculateSumApprox:()=>Ne,calculateSumLoop:()=>pe,calculateUpgrade:()=>ye,decimalToJSONString:()=>ve,equalsTolerance:()=>Wt,formats:()=>dt,inverseFunctionApprox:()=>Xt,roundingBase:()=>Ar,upgradeToCacheNameEL:()=>Or});var Kr=ot(ft()),Gt=class{constructor(t){this.map=new Map,this.first=void 0,this.last=void 0,this.maxSize=t}get size(){return this.map.size}get(t){let e=this.map.get(t);if(e!==void 0)return e!==this.first&&(e===this.last?(this.last=e.prev,this.last.next=void 0):(e.prev.next=e.next,e.next.prev=e.prev),e.next=this.first,this.first.prev=e,this.first=e),e.value}set(t,e){if(this.maxSize<1)return;if(this.map.has(t))throw new Error("Cannot update existing keys in the cache");let r=new fe(t,e);for(this.first===void 0?(this.first=r,this.last=r):(r.next=this.first,this.first.prev=r,this.first=r),this.map.set(t,r);this.map.size>this.maxSize;){let i=this.last;this.map.delete(i.key),this.last=i.prev,this.last.next=void 0}}},fe=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},B;(function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(B||(B={}));var ir=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},t.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.findTransformMetadatas=function(e,r,i){return this.findMetadatas(this._transformMetadatas,e,r).filter(function(n){return!n.options||n.options.toClassOnly===!0&&n.options.toPlainOnly===!0?!0:n.options.toClassOnly===!0?i===B.CLASS_TO_CLASS||i===B.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?i===B.CLASS_TO_PLAIN:!0})},t.prototype.findExcludeMetadata=function(e,r){return this.findMetadata(this._excludeMetadatas,e,r)},t.prototype.findExposeMetadata=function(e,r){return this.findMetadata(this._exposeMetadatas,e,r)},t.prototype.findExposeMetadataByCustomName=function(e,r){return this.getExposedMetadatas(e).find(function(i){return i.options&&i.options.name===r})},t.prototype.findTypeMetadata=function(e,r){return this.findMetadata(this._typeMetadatas,e,r)},t.prototype.getStrategy=function(e){var r=this._excludeMetadatas.get(e),i=r&&r.get(void 0),n=this._exposeMetadatas.get(e),o=n&&n.get(void 0);return i&&o||!i&&!o?"none":i?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},t.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},t.prototype.getExposedProperties=function(e,r){return this.getExposedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===B.CLASS_TO_CLASS||r===B.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===B.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.getExcludedProperties=function(e,r){return this.getExcludedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===B.CLASS_TO_CLASS||r===B.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===B.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(e,r){var i=e.get(r),n;i&&(n=Array.from(i.values()).filter(function(c){return c.propertyName!==void 0}));for(var o=[],u=0,m=this.getAncestors(r);u0&&(u=u.filter(function(c){return!l.includes(c)})),this.options.version!==void 0&&(u=u.filter(function(c){var f=et.findExposeMetadata(e,c);return!f||!f.options?!0:n.checkVersion(f.options.since,f.options.until)})),this.options.groups&&this.options.groups.length?u=u.filter(function(c){var f=et.findExposeMetadata(e,c);return!f||!f.options?!0:n.checkGroups(f.options.groups)}):u=u.filter(function(c){var f=et.findExposeMetadata(e,c);return!f||!f.options||!f.options.groups||!f.options.groups.length})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(u=u.filter(function(v){return n.options.excludePrefixes.every(function(c){return v.substr(0,c.length)!==c})})),u=u.filter(function(v,c,f){return f.indexOf(v)===c}),u},t.prototype.checkVersion=function(e,r){var i=!0;return i&&e&&(i=this.options.version>=e),i&&r&&(i=this.options.versionNumber.MAX_SAFE_INTEGER)&&(I="\u03C9");let M=t.log(a,8e3).toNumber();if(y.equals(0))return I;if(y.gt(0)&&y.lte(3)){let G=[];for(let Y=0;YNumber.MAX_SAFE_INTEGER)&&(I="\u03C9");let M=t.log(a,8e3).toNumber();if(y.equals(0))return I;if(y.gt(0)&&y.lte(2)){let G=[];for(let Y=0;Y118?e.elemental.beyondOg(_):e.elemental.config.element_lists[a-1][I]},beyondOg(a){let S=Math.floor(Math.log10(a)),y=["n","u","b","t","q","p","h","s","o","e"],I="";for(let _=S;_>=0;_--){let M=Math.floor(a/Math.pow(10,_))%10;I==""?I=y[M].toUpperCase():I+=y[M]}return I},abbreviationLength(a){return a==1?1:Math.pow(Math.floor(a/2)+1,2)*2},getAbbreviationAndValue(a){let S=a.log(118).toNumber(),y=Math.floor(S)+1,I=e.elemental.abbreviationLength(y),_=S-y+1,M=Math.floor(_*I),F=e.elemental.getAbbreviation(y,_),P=new t(118).pow(y+M/I-1);return[F,P]},formatElementalPart(a,S){return S.eq(1)?a:`${S.toString()} ${a}`},format(a,S=2){if(a.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(a.log10(),S);let y=a.log(118),_=y.log(118).log(118).toNumber(),M=Math.max(4-_*2,1),F=[];for(;y.gte(1)&&F.length=M)return F.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ");let P=new t(118).pow(y).toFixed(F.length===1?3:S);return F.length===0?P:F.length===1?`${P} \xD7 ${e.elemental.formatElementalPart(F[0][0],F[0][1])}`:`${P} \xD7 (${F.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ")})`}},old_sc:{format(a,S){a=new t(a);let y=a.log10().floor();if(y.lt(9))return y.lt(3)?a.toFixed(S):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let _=a.slog();return(_.gte(1e9)?"":t.dTen.pow(_.sub(_.floor())).toFixed(4))+"F"+e.old_sc.format(_.floor(),0)}let I=a.div(t.dTen.pow(y));return(y.log10().gte(9)?"":I.toFixed(4))+"e"+e.old_sc.format(y,0)}}},eng:{format(a,S=2){a=new t(a);let y=a.log10().floor();if(y.lt(9))return y.lt(3)?a.toFixed(S):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let _=a.slog();return(_.gte(1e9)?"":t.dTen.pow(_.sub(_.floor())).toFixed(4))+"F"+e.eng.format(_.floor(),0)}let I=a.div(new t(1e3).pow(y.div(3).floor()));return(y.log10().gte(9)?"":I.toFixed(new t(4).sub(y.sub(y.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(y.div(3).floor().mul(3),0)}}},mixed_sc:{format(a,S,y=9){a=new t(a);let I=a.log10().floor();return I.lt(303)&&I.gte(y)?g(a,S,y,"st"):g(a,S,y,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(a,S=2,y){a=new t(a);let I=a.max(1).log10().max(1).log(r.log10()).floor();if(I.lte(0))return g(a,S,y,"sc");a=t.dTen.pow(a.max(1).log10().div(r.log10().pow(I)).sub(I.gte(1)?1:0));let _=I.div(10).floor(),M=I.toNumber()%10-1;return g(a,Math.max(4,S),y,"sc")+" "+(_.gte(1)?"meta"+(_.gte(2)?"^"+g(_,0,y,"sc"):"")+"-":"")+(isNaN(M)?"nanity":e.layer.layers[M])}},standard:{tier1(a){return ht[0][0][a%10]+ht[0][1][Math.floor(a/10)%10]+ht[0][2][Math.floor(a/100)]},tier2(a){let S=a%10,y=Math.floor(a/10)%10,I=Math.floor(a/100)%10,_="";return a<10?ht[1][0][a]:(y==1&&S==0?_+="Vec":_+=ht[1][1][S]+ht[1][2][y],_+=ht[1][3][I],_)}},inf:{format(a,S,y){a=new t(a);let I=0,_=new t(Number.MAX_VALUE),M=["","\u221E","\u03A9","\u03A8","\u028A"],F=["","","m","mm","mmm"];for(;a.gte(_);)a=a.log(_),I++;return I==0?g(a,S,y,"sc"):a.gte(3)?F[I]+M[I]+"\u03C9^"+g(a.sub(1),S,y,"sc"):a.gte(2)?F[I]+"\u03C9"+M[I]+"-"+g(_.pow(a.sub(2)),S,y,"sc"):F[I]+M[I]+"-"+g(_.pow(a.sub(1)),S,y,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(a,S=new t(1e15),y=!1,I=9){if(a=new t(a),S=new t(S).div(1e3),a.lt(S.mul(1e3)))return"";let{alphabet:_}=e.alphabet.config,M=_.length,F=a.log(1e3).sub(S.log(1e3)).floor(),P=F.add(1).log(M+1).ceil(),G="",Y=(K,nt)=>{let H=K,Z="";for(let W=0;W=M)return"\u03C9";Z=_[pt]+Z,H=H.sub(1).div(M).floor()}return Z};if(P.lt(I))G=Y(F,P);else{let K=P.sub(I).add(1),nt=F.div(t.pow(M+1,K.sub(1))).floor();G=`${Y(nt,new t(I))}(${K.gt("1e9")?K.format():K.format(0)})`}return G},format(a,S=2,y=9,I="mixed_sc",_=new t(1e15),M=!1,F){if(a=new t(a),_=new t(_).div(1e3),a.lt(_.mul(1e3)))return g(a,S,y,I);let P=e.alphabet.getAbbreviation(a,_,M,F),G=a.div(t.pow(1e3,a.log(1e3).floor()));return`${P.length>(F??9)+2?"":G.toFixed(S)+" "}${P}`}}},r=t.dTwo.pow(1024),i="\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089",n="\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079";function o(a){return a.toFixed(0).split("").map(S=>S==="-"?"\u208B":i[parseInt(S,10)]).join("")}function u(a){return a.toFixed(0).split("").map(S=>S==="-"?"\u208B":n[parseInt(S,10)]).join("")}function m(a,S=2,y=9,I="st"){return g(a,S,y,I)}function g(a,S=2,y=9,I="mixed_sc"){a=new t(a);let _=a.lt(0)?"-":"";if(a.mag==1/0)return _+"Infinity";if(Number.isNaN(a.mag))return _+"NaN";if(a.lt(0)&&(a=a.mul(-1)),a.eq(0))return a.toFixed(S);let M=a.log10().floor();switch(I){case"sc":case"scientific":if(a.log10().lt(Math.min(-S,0))&&S>1){let F=a.log10().ceil(),P=a.div(F.eq(-1)?new t(.1):t.dTen.pow(F)),G=F.mul(-1).max(1).log10().gte(9);return _+(G?"":P.toFixed(2))+"e"+g(F,0,y,"mixed_sc")}else if(M.lt(y)){let F=Math.max(Math.min(S-M.toNumber(),S),0);return _+(F>0?a.toFixed(F):a.toFixed(F).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(a.gte("eeee10")){let G=a.slog();return(G.gte(1e9)?"":t.dTen.pow(G.sub(G.floor())).toFixed(2))+"F"+g(G.floor(),0)}let F=a.div(t.dTen.pow(M)),P=M.log10().gte(9);return _+(P?"":F.toFixed(2))+"e"+g(M,0,y,"mixed_sc")}case"st":case"standard":{let F=a.log(1e3).floor();if(F.lt(1))return _+a.toFixed(Math.max(Math.min(S-M.toNumber(),S),0));let P=F.mul(3),G=F.log10().floor();if(G.gte(3e3))return"e"+g(M,S,y,"st");let Y="";if(F.lt(4))Y=["","K","M","B"][Math.round(F.toNumber())];else{let H=Math.floor(F.log(1e3).toNumber());for(H<100&&(H=Math.max(H-1,0)),F=F.sub(1).div(t.dTen.pow(H*3));F.gt(0);){let Z=F.div(1e3).floor(),W=F.sub(Z.mul(1e3)).floor().toNumber();W>0&&(W==1&&!H&&(Y="U"),H&&(Y=e.standard.tier2(H)+(Y?"-"+Y:"")),W>1&&(Y=e.standard.tier1(W)+Y)),F=Z,H++}}let K=a.div(t.dTen.pow(P)),nt=S===2?t.dTwo.sub(M.sub(P)).add(1).toNumber():S;return _+(G.gte(10)?"":K.toFixed(nt)+" ")+Y}default:return e[I]||console.error('Invalid format type "',I,'"'),_+e[I].format(a,S,y)}}function l(a,S,y="mixed_sc",I,_){a=new t(a),S=new t(S);let M=a.add(S),F,P=M.div(a);return P.gte(10)&&a.gte(1e100)?(P=P.log10().mul(20),F="(+"+g(P,I,_,y)+" OoMs/sec)"):F="(+"+g(S,I,_,y)+"/sec)",F}function v(a,S=2,y="s"){return a=new t(a),a.gte(86400)?g(a.div(86400).floor(),0,12,"sc")+":"+v(a.mod(86400),S,"d"):a.gte(3600)||y=="d"?(a.div(3600).gte(10)||y!="d"?"":"0")+g(a.div(3600).floor(),0,12,"sc")+":"+v(a.mod(3600),S,"h"):a.gte(60)||y=="h"?(a.div(60).gte(10)||y!="h"?"":"0")+g(a.div(60).floor(),0,12,"sc")+":"+v(a.mod(60),S,"m"):(a.gte(10)||y!="m"?"":"0")+g(a,S,12,"sc")}function c(a,S=!1,y=0,I=9,_="mixed_sc"){let M=Rt=>g(Rt,y,I,_);a=new t(a);let F=a.mul(1e3).mod(1e3).floor(),P=a.mod(60).floor(),G=a.div(60).mod(60).floor(),Y=a.div(3600).mod(24).floor(),K=a.div(86400).mod(365.2425).floor(),nt=a.div(31556952).floor(),H=nt.eq(1)?" year":" years",Z=K.eq(1)?" day":" days",W=Y.eq(1)?" hour":" hours",pt=G.eq(1)?" minute":" minutes",Dt=P.eq(1)?" second":" seconds",jt=F.eq(1)?" millisecond":" milliseconds";return`${nt.gt(0)?M(nt)+H+", ":""}${K.gt(0)?M(K)+Z+", ":""}${Y.gt(0)?M(Y)+W+", ":""}${G.gt(0)?M(G)+pt+", ":""}${P.gt(0)?M(P)+Dt+",":""}${S&&F.gt(0)?" "+M(F)+jt:""}`.replace(/,([^,]*)$/,"$1").trim()}function f(a){return a=new t(a),g(t.dOne.sub(a).mul(100))+"%"}function h(a){return a=new t(a),g(a.mul(100))+"%"}function p(a,S=2){return a=new t(a),a.gte(1)?"\xD7"+a.format(S):"/"+a.pow(-1).format(S)}function d(a,S,y=10){return t.gte(a,10)?t.pow(y,t.log(a,y).pow(S)):new t(a)}function O(a,S=0){a=new t(a);let y=(F=>F.map((P,G)=>({name:P.name,altName:P.altName,value:t.pow(1e3,new t(G).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"Decimal",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),I="",_=a.lte(0)?0:t.min(t.log(a,1e3).sub(1),y.length-1).floor().toNumber(),M=y[_];if(_===0)switch(S){case 1:I="";break;case 2:case 0:default:I=a.format();break}switch(S){case 1:I=M.name;break;case 2:I=a.divide(M.value).format();break;case 3:I=M.altName;break;case 0:default:I=`${a.divide(M.value).format()} ${M.name}`;break}return I}function T(a,S=!1){return`${O(a,2)} ${O(a,1)}eV${S?"/c^2":""}`}let k={...e,toSubscript:o,toSuperscript:u,formatST:m,format:g,formatGain:l,formatTime:v,formatTimeLong:c,formatReduction:f,formatPercent:h,formatMult:p,expMult:d,metric:O,ev:T};return{FORMATS:e,formats:k}}var zt=17,cr=9e15,hr=Math.log10(9e15),mr=1/9e15,dr=308,gr=-324,me=5,pr=1023,Nr=!0,yr=!1,vr=function(){let t=[];for(let r=gr+1;r<=dr;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),Nt=[2,Math.E,3,4,5,6,7,8,9,10],br=[[1,1.0891180521811203,1.1789767925673957,1.2701455431742086,1.3632090180450092,1.4587818160364217,1.5575237916251419,1.6601571006859253,1.767485818836978,1.8804192098842727,2],[1,1.1121114330934079,1.231038924931609,1.3583836963111375,1.4960519303993531,1.6463542337511945,1.8121385357018724,1.996971324618307,2.2053895545527546,2.4432574483385254,Math.E],[1,1.1187738849693603,1.2464963939368214,1.38527004705667,1.5376664685821402,1.7068895236551784,1.897001227148399,2.1132403089001035,2.362480153784171,2.6539010333870774,3],[1,1.1367350847096405,1.2889510672956703,1.4606478703324786,1.6570295196661111,1.8850062585672889,2.1539465047453485,2.476829779693097,2.872061932789197,3.3664204535587183,4],[1,1.1494592900767588,1.319708228183931,1.5166291280087583,1.748171114438024,2.0253263297298045,2.3636668498288547,2.7858359149579424,3.3257226212448145,4.035730287722532,5],[1,1.159225940787673,1.343712473580932,1.5611293155111927,1.8221199554561318,2.14183924486326,2.542468319282638,3.0574682501653316,3.7390572020926873,4.6719550537360774,6],[1,1.1670905356972596,1.3632807444991446,1.5979222279405536,1.8842640123816674,2.2416069644878687,2.69893426559423,3.3012632110403577,4.121250340630164,5.281493033448316,7],[1,1.1736630594087796,1.379783782386201,1.6292821855668218,1.9378971836180754,2.3289975651071977,2.8384347394720835,3.5232708454565906,4.478242031114584,5.868592169644505,8],[1,1.1793017514670474,1.394054150657457,1.65664127441059,1.985170999970283,2.4069682290577457,2.9647310119960752,3.7278665320924946,4.814462547283592,6.436522247411611,9],[1,1.1840100246247336,1.4061375836156955,1.6802272208863964,2.026757028388619,2.4770056063449646,3.080525271755482,3.9191964192627284,5.135152840833187,6.989961179534715,10]],wr=[[-1,-.9194161097107025,-.8335625019330468,-.7425599821143978,-.6466611521029437,-.5462617907227869,-.4419033816638769,-.3342645487554494,-.224140440909962,-.11241087890006762,0],[-1,-.90603157029014,-.80786507256596,-.7064666939634,-.60294836853664,-.49849837513117,-.39430303318768,-.29147201034755,-.19097820800866,-.09361896280296,0],[-1,-.9021579584316141,-.8005762598234203,-.6964780623319391,-.5911906810998454,-.486050182576545,-.3823089430815083,-.28106046722897615,-.1831906535795894,-.08935809204418144,0],[-1,-.8917227442365535,-.781258746326964,-.6705130326902455,-.5612813129406509,-.4551067709033134,-.35319256652135966,-.2563741554088552,-.1651412821106526,-.0796919581982668,0],[-1,-.8843387974366064,-.7678744063886243,-.6529563724510552,-.5415870994657841,-.4352842206588936,-.33504449124791424,-.24138853420685147,-.15445285440944467,-.07409659641336663,0],[-1,-.8786709358426346,-.7577735191184886,-.6399546189952064,-.527284921869926,-.4211627631006314,-.3223479611761232,-.23107655627789858,-.1472057700818259,-.07035171210706326,0],[-1,-.8740862815291583,-.7497032990976209,-.6297119746181752,-.5161838335958787,-.41036238255751956,-.31277212146489963,-.2233976621705518,-.1418697367979619,-.06762117662323441,0],[-1,-.8702632331800649,-.7430366914122081,-.6213373075161548,-.5072025698095242,-.40171437727184167,-.30517930701410456,-.21736343968190863,-.137710238299109,-.06550774483471955,0],[-1,-.8670016295947213,-.7373984232432306,-.6143173985094293,-.49973884395492807,-.394584953527678,-.2989649949848695,-.21245647317021688,-.13434688362382652,-.0638072667348083,0],[-1,-.8641642839543857,-.732534623168535,-.6083127477059322,-.4934049257184696,-.3885773075899922,-.29376029055315767,-.2083678561173622,-.13155653399373268,-.062401588652553186,0]],w=function(e){return s.fromValue_noAlloc(e)},j=function(t,e,r){return s.fromComponents(t,e,r)},C=function(e,r,i){return s.fromComponents_noNormalize(e,r,i)},mt=function(e,r){let i=r+1,n=Math.ceil(Math.log10(Math.abs(e))),o=Math.round(e*Math.pow(10,i-n))*Math.pow(10,n-i);return parseFloat(o.toFixed(Math.max(i-n,0)))},Zt=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},Mr=function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;let e=1;for(;t<10;)e=e*t,++t;t-=1;let r=.9189385332046727;r=r+(t+.5)*Math.log(t),r=r-t;let i=t*t,n=t;return r=r+1/(12*n),n=n*i,r=r-1/(360*n),n=n*i,r=r+1/(1260*n),n=n*i,r=r-1/(1680*n),n=n*i,r=r+1/(1188*n),n=n*i,r=r-691/(360360*n),n=n*i,r=r+7/(1092*n),n=n*i,r=r-3617/(122400*n),Math.exp(r)/e},_r=.36787944117144233,de=.5671432904097838,Yt=function(t,e=1e-10,r=!0){let i,n;if(!Number.isFinite(t))return t;if(r){if(t===0)return t;if(t===1)return de;t<10?i=0:i=Math.log(t)-Math.log(Math.log(t))}else{if(t===0)return-1/0;t<=-.1?i=-2:i=Math.log(-t)-Math.log(-Math.log(-t))}for(let o=0;o<100;++o){if(n=(t*Math.exp(-i)+i*i)/(i+1),Math.abs(n-i).5?1:-1;if(Math.random()*20<1)return C(e,0,1);let r=Math.floor(Math.random()*(t+1)),i=r===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let n=Math.pow(10,i);return Math.random()>.9&&(n=Math.trunc(n)),j(e,r,n)}static affordGeometricSeries_core(t,e,r,i){let n=e.mul(r.pow(i));return s.floor(t.div(n).mul(r.sub(1)).add(1).log10().div(r.log10()))}static sumGeometricSeries_core(t,e,r,i){return e.mul(r.pow(i)).mul(s.sub(1,r.pow(t))).div(s.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let o=e.add(i.mul(r)).sub(r.div(2)),u=o.pow(2);return o.neg().add(u.add(r.mul(t).mul(2)).sqrt()).div(r).floor()}static sumArithmeticSeries_core(t,e,r,i){let n=e.add(i.mul(r));return t.div(2).mul(n.mul(2).plus(t.sub(1).mul(r)))}static efficiencyOfPurchase_core(t,e,r){return t.div(e).add(t.div(r))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0||this.mag===Number.NEGATIVE_INFINITY&&this.layer>0&&Number.isFinite(this.layer))return this.sign=0,this.mag=0,this.layer=0,this;if(this.layer===0&&this.mag<0&&(this.mag=-this.mag,this.sign=-this.sign),this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_INFINITY)return this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY,this;if(this.layer===0&&this.mag=cr)return this.layer+=1,this.mag=e*Math.log10(t),this;for(;t0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=e*Math.pow(10,t),t=Math.abs(this.mag),e=Math.sign(this.mag));return this.layer===0&&(this.mag<0?(this.mag=-this.mag,this.sign=-this.sign):this.mag===0&&(this.sign=0)),(Number.isNaN(this.sign)||Number.isNaN(this.layer)||Number.isNaN(this.mag))&&(this.sign=Number.NaN,this.layer=Number.NaN,this.mag=Number.NaN),this}fromComponents(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this.normalize(),this}fromComponents_noNormalize(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this}fromMantissaExponent(t,e){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=e+Math.log10(t),this.normalize(),this}fromMantissaExponent_noNormalize(t,e){return this.fromMantissaExponent(t,e),this}fromDecimal(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this}fromNumber(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this}fromString(t,e=!1){let r=t,i=s.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);Nr?t=t.replace(",",""):yr&&(t=t.replace(",","."));let n=t.split("^^^");if(n.length===2){let d=parseFloat(n[0]),O=parseFloat(n[1]),T=n[1].split(";"),k=1;if(T.length===2&&(k=parseFloat(T[1]),isFinite(k)||(k=1)),isFinite(d)&&isFinite(O)){let a=s.pentate(d,O,k,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let o=t.split("^^");if(o.length===2){let d=parseFloat(o[0]),O=parseFloat(o[1]),T=o[1].split(";"),k=1;if(T.length===2&&(k=parseFloat(T[1]),isFinite(k)||(k=1)),isFinite(d)&&isFinite(O)){let a=s.tetrate(d,O,k,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let u=t.split("^");if(u.length===2){let d=parseFloat(u[0]),O=parseFloat(u[1]);if(isFinite(d)&&isFinite(O)){let T=s.pow(d,O);return this.sign=T.sign,this.layer=T.layer,this.mag=T.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}t=t.trim().toLowerCase();let m,g,l=t.split("pt");if(l.length===2){m=10;let d=!1;l[0].startsWith("-")&&(d=!0,l[0]=l[0].slice(1)),g=parseFloat(l[0]),l[1]=l[1].replace("(",""),l[1]=l[1].replace(")","");let O=parseFloat(l[1]);if(isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let T=s.tetrate(m,g,O,e);return this.sign=T.sign,this.layer=T.layer,this.mag=T.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}if(l=t.split("p"),l.length===2){m=10;let d=!1;l[0].startsWith("-")&&(d=!0,l[0]=l[0].slice(1)),g=parseFloat(l[0]),l[1]=l[1].replace("(",""),l[1]=l[1].replace(")","");let O=parseFloat(l[1]);if(isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let T=s.tetrate(m,g,O,e);return this.sign=T.sign,this.layer=T.layer,this.mag=T.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}if(l=t.split("f"),l.length===2){m=10;let d=!1;l[0].startsWith("-")&&(d=!0,l[0]=l[0].slice(1)),l[0]=l[0].replace("(",""),l[0]=l[0].replace(")","");let O=parseFloat(l[0]);if(l[1]=l[1].replace("(",""),l[1]=l[1].replace(")",""),g=parseFloat(l[1]),isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let T=s.tetrate(m,g,O,e);return this.sign=T.sign,this.layer=T.layer,this.mag=T.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}let v=t.split("e"),c=v.length-1;if(c===0){let d=parseFloat(t);if(isFinite(d))return this.fromNumber(d),s.fromStringCache.size>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else if(c===1){let d=parseFloat(t);if(isFinite(d)&&d!==0)return this.fromNumber(d),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}let f=t.split("e^");if(f.length===2){this.sign=1,f[0].startsWith("-")&&(this.sign=-1);let d="";for(let O=0;O=43&&T<=57||T===101)d+=f[1].charAt(O);else return this.layer=parseFloat(d),this.mag=parseFloat(f[1].substr(O+1)),this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(c<1)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let h=parseFloat(v[0]);if(h===0)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let p=parseFloat(v[v.length-1]);if(c>=2){let d=parseFloat(v[v.length-2]);isFinite(d)&&(p*=Math.sign(d),p+=Zt(d))}if(!isFinite(h))this.sign=v[0]==="-"?-1:1,this.layer=c,this.mag=p;else if(c===1)this.sign=Math.sign(h),this.layer=1,this.mag=p+Math.log10(Math.abs(h));else if(this.sign=Math.sign(h),this.layer=c,c===2){let d=s.mul(j(1,2,p),w(h));return this.sign=d.sign,this.layer=d.layer,this.mag=d.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else this.mag=p;return this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}fromValue(t){return t instanceof s?this.fromDecimal(t):typeof t=="number"?this.fromNumber(t):typeof t=="string"?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===1?Number.POSITIVE_INFINITY:this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===-1?Number.NEGATIVE_INFINITY:Number.isFinite(this.layer)?this.layer===0?this.sign*this.mag:this.layer===1?this.sign*Math.pow(10,this.mag):this.mag>0?this.sign>0?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:0:Number.NaN}mantissaWithDecimalPlaces(t){return isNaN(this.m)?Number.NaN:this.m===0?0:mt(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:mt(this.mag,t)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY?this.sign===1?"Infinity":"-Infinity":this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toString():this.m+"e"+this.e:this.layer===1?this.m+"e"+this.e:this.layer<=me?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(t){return this.layer===0?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)}toFixed(t){return this.layer===0?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)}toPrecision(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(t){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(t):mt(this.m,t)+"e"+mt(this.e,t):this.layer===1?mt(this.m,t)+"e"+mt(this.e,t):this.layer<=me?(this.sign===-1?"-":"")+"e".repeat(this.layer)+mt(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+mt(this.mag,t)}abs(){return C(this.sign===0?0:1,this.layer,this.mag)}neg(){return C(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?C(0,0,0):this.layer===0?j(this.sign,0,Math.round(this.mag)):new s(this)}floor(){return this.mag<0?this.sign===-1?C(-1,0,1):C(0,0,0):this.sign===-1?this.neg().ceil().neg():this.layer===0?j(this.sign,0,Math.floor(this.mag)):new s(this)}ceil(){return this.mag<0?this.sign===1?C(1,0,1):C(0,0,0):this.sign===-1?this.neg().floor().neg():this.layer===0?j(this.sign,0,Math.ceil(this.mag)):new s(this)}trunc(){return this.mag<0?C(0,0,0):this.layer===0?j(this.sign,0,Math.trunc(this.mag)):new s(this)}add(t){let e=w(t);if(this.eq(s.dInf)&&e.eq(s.dNegInf)||this.eq(s.dNegInf)&&e.eq(s.dInf))return C(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new s(this);if(!Number.isFinite(e.layer))return new s(e);if(this.sign===0)return new s(e);if(e.sign===0)return new s(this);if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return C(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(s.cmpabs(this,e)>0?(r=new s(this),i=new s(e)):(r=new s(e),i=new s(this)),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*r.mag+i.sign*i.mag);let n=r.layer*Math.sign(r.mag),o=i.layer*Math.sign(i.mag);if(n-o>=2)return r;if(n===0&&o===-1){if(Math.abs(i.mag-Math.log10(r.mag))>zt)return r;{let u=Math.pow(10,Math.log10(r.mag)-i.mag),m=i.sign+r.sign*u;return j(Math.sign(m),1,i.mag+Math.log10(Math.abs(m)))}}if(n===1&&o===0){if(Math.abs(r.mag-Math.log10(i.mag))>zt)return r;{let u=Math.pow(10,r.mag-Math.log10(i.mag)),m=i.sign+r.sign*u;return j(Math.sign(m),1,Math.log10(i.mag)+Math.log10(Math.abs(m)))}}if(Math.abs(r.mag-i.mag)>zt)return r;{let u=Math.pow(10,r.mag-i.mag),m=i.sign+r.sign*u;return j(Math.sign(m),1,i.mag+Math.log10(Math.abs(m)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(w(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=w(t);if(this.eq(s.dInf)&&e.eq(s.dNegInf)||this.eq(s.dNegInf)&&e.eq(s.dInf))return C(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.mag==Number.POSITIVE_INFINITY&&e.eq(s.dZero)||this.eq(s.dZero)&&this.mag==Number.POSITIVE_INFINITY)return C(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new s(this);if(!Number.isFinite(e.layer))return new s(e);if(this.sign===0||e.sign===0)return C(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return C(this.sign*e.sign,0,1);let r,i;if(this.layer>e.layer||this.layer==e.layer&&Math.abs(this.mag)>Math.abs(e.mag)?(r=new s(this),i=new s(e)):(r=new s(e),i=new s(this)),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return j(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return j(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return j(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let n=j(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(j(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return j(r.sign*i.sign,n.layer+1,n.sign*n.mag)}if(r.layer===2&&i.layer===2){let n=j(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(j(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return j(r.sign*i.sign,n.layer+1,n.sign*n.mag)}throw Error("Bad arguments to mul: "+this+", "+t)}multiply(t){return this.mul(t)}times(t){return this.mul(t)}div(t){let e=w(t);return this.mul(e.recip())}divide(t){return this.div(t)}divideBy(t){return this.div(t)}dividedBy(t){return this.div(t)}recip(){return this.mag===0?C(Number.NaN,Number.NaN,Number.NaN):this.mag===Number.POSITIVE_INFINITY?C(0,0,0):this.layer===0?j(this.sign,0,1/this.mag):j(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=w(t).abs();if(e.eq(s.dZero))return C(0,0,0);let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new s(r%i):this.sub(e).eq(this)?C(0,0,0):e.sub(this).eq(e)?new s(this):this.sign==-1?this.abs().mod(e).neg():this.sub(this.div(e).floor().mul(e))}modulo(t){return this.mod(t)}modular(t){return this.mod(t)}cmp(t){let e=w(t);return this.sign>e.sign?1:this.sign0?this.layer:-this.layer,i=e.mag>0?e.layer:-e.layer;return r>i?1:re.mag?1:this.mag0?new s(e):new s(this)}clamp(t,e){return this.max(t).min(e)}clampMin(t){return this.max(t)}clampMax(t){return this.min(t)}cmp_tolerance(t,e){let r=w(t);return this.eq_tolerance(r,e)?0:this.cmp(r)}compare_tolerance(t,e){return this.cmp_tolerance(t,e)}eq_tolerance(t,e){let r=w(t);if(e==null&&(e=1e-7),this.sign!==r.sign||Math.abs(this.layer-r.layer)>1)return!1;let i=this.mag,n=r.mag;return this.layer>r.layer&&(n=Zt(n)),this.layer0?j(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):j(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?C(Number.NaN,Number.NaN,Number.NaN):this.layer>0?j(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):j(this.sign,0,Math.log10(this.mag))}log(t){return t=w(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?C(Number.NaN,Number.NaN,Number.NaN):this.layer===0&&t.layer===0?j(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):s.div(this.log10(),t.log10())}log2(){return this.sign<=0?C(Number.NaN,Number.NaN,Number.NaN):this.layer===0?j(this.sign,0,Math.log2(this.mag)):this.layer===1?j(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?j(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):j(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?C(Number.NaN,Number.NaN,Number.NaN):this.layer===0?j(this.sign,0,Math.log(this.mag)):this.layer===1?j(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?j(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):j(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=w(t),r=new s(this),i=new s(e);if(r.sign===0)return i.eq(0)?C(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return C(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return r;let n=r.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?n.neg():Math.abs(i.toNumber()%2)%2===0?n:C(Number.NaN,Number.NaN,Number.NaN):n}pow10(){if(this.eq(s.dInf))return C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.eq(s.dNegInf))return C(0,0,0);if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return C(Number.NaN,Number.NaN,Number.NaN);let t=new s(this);if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return j(1,0,e);if(t.sign===0)return C(1,0,1);t=C(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?j(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?j(-t.sign,t.layer+1,-t.mag):C(1,0,1)}pow_base(t){return w(t).pow(this)}root(t){let e=w(t);return this.pow(e.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(C(1,0,24)))return s.fromNumber(Mr(this.sign*this.mag));let t=this.mag-1,e=.9189385332046727;e=e+(t+.5)*Math.log(t),e=e-t;let r=t*t,i=t,n=12*i,o=1/n,u=e+o;if(u===e||(e=u,i=i*r,n=360*i,o=1/n,u=e-o,u===e))return s.exp(e);e=u,i=i*r,n=1260*i;let m=1/n;return e=e+m,i=i*r,n=1680*i,m=1/n,e=e-m,s.exp(e)}else return this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?C(1,0,1):this.layer===0&&this.mag<=709.7?s.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?j(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?j(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):j(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return s.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return j(1,2,Math.log10(this.mag)-.3010299956639812);{let t=s.div(C(this.sign,this.layer-1,this.mag),C(1,0,2));return t.layer+=1,t.normalize(),t}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(t=2,e=C(1,0,1),r=!1){if(t===1)return s.pow(this,e);if(t===0)return new s(e);if(this.eq(s.dOne))return C(1,0,1);if(this.eq(-1))return s.pow(this,e);if(t===Number.POSITIVE_INFINITY){let o=this.toNumber();if(o<=1.444667861009766&&o>=.06598803584531254){let u=s.ln(this).neg(),m=u.lambertw().div(u);if(o<1)return m;let g=u.lambertw(!1).div(u);return o>1.444667861009099&&(m=g=s.fromNumber(Math.E)),e=w(e),e.eq(g)?g:e.lt(g)?m:C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}else return o>1.444667861009766?C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY):C(Number.NaN,Number.NaN,Number.NaN)}if(this.eq(s.dZero)){let o=Math.abs((t+1)%2);return o>1&&(o=2-o),s.fromNumber(o)}if(t<0)return s.iteratedlog(e,this,-t,r);e=new s(e);let i=t;t=Math.trunc(t);let n=i-t;if(this.gt(s.dZero)&&(this.lt(1)||this.lte(1.444667861009766)&&e.lte(s.ln(this).neg().lambertw(!1).div(s.ln(this).neg())))&&(i>1e4||!r)){let o=Math.min(1e4,t);e.eq(s.dOne)?e=this.pow(n):this.lt(1)?e=e.pow(1-n).mul(this.pow(e).pow(n)):e=e.layeradd(n,this);for(let u=0;u1e4&&Math.ceil(i)%2==1?this.pow(e):e}n!==0&&(e.eq(s.dOne)?this.gt(10)||r?e=this.pow(n):(e=s.fromNumber(s.tetrate_critical(this.toNumber(),n)),this.lt(2)&&(e=e.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?e=e.layeradd10(n,r):this.lt(1)?e=e.pow(1-n).mul(this.pow(e).pow(n)):e=e.layeradd(n,this,r));for(let o=0;o3)return C(e.sign,e.layer+(t-o-1),e.mag);if(o>1e4)return e}return e}iteratedexp(t=2,e=C(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return s.tetrate(t,-e,this,r);t=w(t);let i=s.fromDecimal(this),n=e;e=Math.trunc(e);let o=n-e;if(i.layer-t.layer>3){let u=Math.min(e,i.layer-t.layer-3);e-=u,i.layer-=u}for(let u=0;u1e4)return i}return o>0&&o<1&&(t.eq(10)?i=i.layeradd10(-o,r):i=i.layeradd(-o,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,n=!1,o=!1,u=this.slog_internal(t,r).toNumber();for(let m=1;m1&&o!=l&&(n=!0),o=l,n?i/=2:i*=2,i=Math.abs(i)*(l?-1:1),u+=i,i===0)break}return s.fromNumber(u)}slog_internal(t=10,e=!1){if(t=w(t),t.lte(s.dZero)||t.eq(s.dOne))return C(Number.NaN,Number.NaN,Number.NaN);if(t.lt(s.dOne))return this.eq(s.dOne)?C(0,0,0):this.eq(s.dZero)?C(-1,0,1):C(Number.NaN,Number.NaN,Number.NaN);if(this.mag<0||this.eq(s.dZero))return C(-1,0,1);if(t.lt(1.444667861009766)){let n=s.ln(t).neg(),o=n.lambertw().div(n);if(this.eq(o))return C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.gt(o))return C(Number.NaN,Number.NaN,Number.NaN)}let r=0,i=s.fromDecimal(this);if(i.layer-t.layer>3){let n=i.layer-t.layer-3;r+=n,i.layer-=n}for(let n=0;n<100;++n)if(i.lt(s.dZero))i=s.pow(t,i),r-=1;else{if(i.lte(s.dOne))return e?s.fromNumber(r+i.toNumber()-1):s.fromNumber(r+s.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=s.log(i,t)}return s.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:s.critical_section(t,e,wr)}static tetrate_critical(t,e){return s.critical_section(t,e,br)}static critical_section(t,e,r,i=!1){e*=10,e<0&&(e=0),e>10&&(e=10),t<2&&(t=2),t>10&&(t=10);let n=0,o=0;for(let m=0;mt){let g=(t-Nt[m])/(Nt[m+1]-Nt[m]);n=r[m][Math.floor(e)]*(1-g)+r[m+1][Math.floor(e)]*g,o=r[m][Math.ceil(e)]*(1-g)+r[m+1][Math.ceil(e)]*g;break}let u=e-Math.floor(e);return n<=0||o<=0?n*(1-u)+o*u:Math.pow(t,Math.log(n)/Math.log(t)*(1-u)+Math.log(o)/Math.log(t)*u)}layeradd10(t,e=!1){t=s.fromValue_noAlloc(t).toNumber();let r=s.fromDecimal(this);if(t>=1){r.mag<0&&r.layer>0?(r.sign=0,r.mag=0,r.layer=0):r.sign===-1&&r.layer==0&&(r.sign=1,r.mag=-r.mag);let i=Math.trunc(t);t-=i,r.layer+=i}if(t<=-1){let i=Math.trunc(t);if(t-=i,r.layer+=i,r.layer<0)for(let n=0;n<100;++n){if(r.layer++,r.mag=Math.log10(r.mag),!isFinite(r.mag))return r.sign===0&&(r.sign=1),r.layer<0&&(r.layer=0),r.normalize();if(r.layer>=0)break}}for(;r.layer<0;)r.layer++,r.mag=Math.log10(r.mag);return r.sign===0&&(r.sign=1,r.mag===0&&r.layer>=1&&(r.layer-=1,r.mag=1)),r.normalize(),t!==0?r.layeradd(t,10,e):r}layeradd(t,e,r=!1){let i=w(e);if(i.gt(1)&&i.lte(1.444667861009766)){let u=s.excess_slog(this,e,r),m=u[0].toNumber(),g=u[1],l=m+t,v=s.ln(e).neg(),c=v.lambertw().div(v),f=v.lambertw(!1).div(v),h=s.dOne;g==1?h=c.mul(f).sqrt():g==2&&(h=f.mul(2));let p=i.pow(h),d=Math.floor(l),O=l-d,T=h.pow(1-O).mul(p.pow(O));return s.tetrate(i,d,T,r)}let o=this.slog(e,100,r).toNumber()+t;return o>=0?s.tetrate(e,o,s.dOne,r):Number.isFinite(o)?o>=-1?s.log(s.tetrate(e,o+1,s.dOne,r),e):s.log(s.log(s.tetrate(e,o+2,s.dOne,r),e),e):C(Number.NaN,Number.NaN,Number.NaN)}static excess_slog(t,e,r=!1){t=w(t),e=w(e);let i=e;if(e=e.toNumber(),e==1||e<=0)return[C(Number.NaN,Number.NaN,Number.NaN),0];if(e>1.444667861009766)return[t.slog(e,100,r),0];let n=s.ln(e).neg(),o=n.lambertw().div(n),u=s.dInf;if(e>1&&(u=n.lambertw(!1).div(n)),e>1.444667861009099&&(o=u=s.fromNumber(Math.E)),t.lt(o))return[t.slog(e,100,r),0];if(t.eq(o))return[C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),0];if(t.eq(u))return[C(1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),2];if(t.gt(u)){let m=u.mul(2),g=i.pow(m),l=0;if(t.gte(m)&&t.lt(g))l=0;else if(t.gte(g)){let d=g;for(l=1;d.lt(t);)if(d=i.pow(d),l=l+1,d.layer>3){let O=Math.floor(t.layer-d.layer+1);d=i.iteratedexp(O,d,r),l=l+O}d.gt(t)&&(d=d.log(e),l=l-1)}else if(t.lt(m)){let d=m;for(l=0;d.gt(t);)d=d.log(e),l=l-1}let v=0,c=0,f=.5,h=m,p=s.dZero;for(;f>1e-16;){if(c=v+f,h=m.pow(1-c).mul(g.pow(c)),p=s.iteratedexp(e,l,h),p.eq(t))return[new s(l+c),2];p.lt(t)&&(v+=f),f/=2}return p.neq_tolerance(t,1e-7)?[C(Number.NaN,Number.NaN,Number.NaN),0]:[new s(l+v),2]}if(t.lt(u)&&t.gt(o)){let m=o.mul(u).sqrt(),g=i.pow(m),l=0;if(t.lte(m)&&t.gt(g))l=0;else if(t.lte(g)){let d=g;for(l=1;d.gt(t);)d=i.pow(d),l=l+1;d.lt(t)&&(d=d.log(e),l=l-1)}else if(t.gt(m)){let d=m;for(l=0;d.lt(t);)d=d.log(e),l=l-1}let v=0,c=0,f=.5,h=m,p=s.dZero;for(;f>1e-16;){if(c=v+f,h=m.pow(1-c).mul(g.pow(c)),p=s.iteratedexp(e,l,h),p.eq(t))return[new s(l+c),1];p.gt(t)&&(v+=f),f/=2}return p.neq_tolerance(t,1e-7)?[C(Number.NaN,Number.NaN,Number.NaN),0]:[new s(l+v),1]}throw new Error("Unhandled behavior in excess_slog")}lambertw(t=!0){return this.lt(-.3678794411710499)?C(Number.NaN,Number.NaN,Number.NaN):t?this.abs().lt("1e-300")?new s(this):this.mag<0?s.fromNumber(Yt(this.toNumber())):this.layer===0?s.fromNumber(Yt(this.sign*this.mag)):this.lt("eee15")?ge(this):this.ln():this.sign===1?C(Number.NaN,Number.NaN,Number.NaN):this.layer===0?s.fromNumber(Yt(this.sign*this.mag,1e-10,!1)):this.layer==1?ge(this,1e-10,!1):this.neg().recip().lambertw().neg()}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(s.dInf))return C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(!this.isFinite())return C(Number.NaN,Number.NaN,Number.NaN);if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return s.fromNumber(t).add(2).pow(this.recip());if(t<=0)return C(Number.NaN,Number.NaN,Number.NaN);if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return e_r?this.pow(this.recip()):C(Number.NaN,Number.NaN,Number.NaN)}if(this.eq(1))return C(1,0,1);if(this.lt(0))return C(Number.NaN,Number.NaN,Number.NaN);if(this.lte("1ee-16"))return t%2==1?new s(this):C(Number.NaN,Number.NaN,Number.NaN);if(this.gt(1)){let e=s.dTen;this.gte(s.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=s.dZero,i=e.layer,n=e.iteratedlog(10,i,!0),o=n,u=n.div(2),m=!0;for(;m;)u=r.add(n).div(2),s.iteratedexp(10,i,u,!0).tetrate(t,1,!0).gt(this)?n=u:r=u,u.eq(o)?m=!1:o=u;return s.iteratedexp(10,i,u,!0)}else{let e=1,r=j(1,10,1),i=j(1,10,1),n=j(1,10,1),o=j(1,1,-16),u=s.dZero,m=j(1,10,1),g=o.pow10().recip(),l=s.dZero,v=g,c=g,f=Math.ceil(t)%2==0,h=0,p=j(1,10,1),d=!1,O=s.dZero,T=!1;for(;e<4;){if(e==2){if(f)break;n=j(1,10,1),o=r,e=3,m=j(1,10,1),p=j(1,10,1)}for(d=!1;o.neq(n);){if(O=o,o.pow10().recip().tetrate(t,1,!0).eq(1)&&o.pow10().recip().lt(.4))g=o.pow10().recip(),v=o.pow10().recip(),c=o.pow10().recip(),l=s.dZero,h=-1,e==3&&(p=o);else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip())&&!f&&o.pow10().recip().lt(.4))g=o.pow10().recip(),v=o.pow10().recip(),c=o.pow10().recip(),l=s.dZero,h=0;else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip().mul(2).tetrate(t,1,!0)))g=o.pow10().recip(),v=s.dZero,c=g.mul(2),l=g,f?h=-1:h=0;else{for(u=o.mul(12e-17),g=o.pow10().recip(),v=o.add(u).pow10().recip(),l=g.sub(v),c=g.add(l);v.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||c.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||v.gte(g)||c.lte(g);)u=u.mul(2),v=o.add(u).pow10().recip(),l=g.sub(v),c=g.add(l);if((e==1&&c.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))&&v.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))||e==3&&c.tetrate(t,1,!0).lt(g.tetrate(t,1,!0))&&v.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))&&(p=o),c.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))h=-1;else if(f)h=1;else if(e==3&&o.gt_tolerance(r,1e-8))h=0;else{for(;v.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||c.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||v.gte(g)||c.lte(g);)u=u.mul(2),v=o.add(u).pow10().recip(),l=g.sub(v),c=g.add(l);c.tetrate(t,1,!0).sub(g.tetrate(t,1,!0)).lt(g.tetrate(t,1,!0).sub(v.tetrate(t,1,!0)))?h=0:h=1}}if(h==-1&&(T=!0),e==1&&h==1||e==3&&h!=0)if(n.eq(j(1,10,1)))o=o.mul(2);else{let y=!1;if(d&&(h==1&&e==1||h==-1&&e==3)&&(y=!0),o=o.add(n).div(2),y)break}else if(n.eq(j(1,10,1)))n=o,o=o.div(2);else{let y=!1;if(d&&(h==1&&e==1||h==-1&&e==3)&&(y=!0),n=n.sub(m),o=o.sub(m),y)break}if(n.sub(o).div(2).abs().gt(m.mul(1.5))&&(d=!0),m=n.sub(o).div(2).abs(),o.gt("1e18")||o.eq(O))break}if(o.gt("1e18")||!T||p==j(1,10,1))break;e==1?r=p:e==3&&(i=p),e++}n=r,o=j(1,1,-18);let k=o,a=s.dZero,S=!0;for(;S;)if(n.eq(j(1,10,1))?a=o.mul(2):a=n.add(o).div(2),s.pow(10,a).recip().tetrate(t,1,!0).gt(this)?o=a:n=a,a.eq(k)?S=!1:k=a,o.gt("1e18"))return C(Number.NaN,Number.NaN,Number.NaN);if(a.eq_tolerance(r,1e-15)){if(i.eq(j(1,10,1)))return C(Number.NaN,Number.NaN,Number.NaN);for(n=j(1,10,1),o=i,k=o,a=s.dZero,S=!0;S;)if(n.eq(j(1,10,1))?a=o.mul(2):a=n.add(o).div(2),s.pow(10,a).recip().tetrate(t,1,!0).gt(this)?o=a:n=a,a.eq(k)?S=!1:k=a,o.gt("1e18"))return C(Number.NaN,Number.NaN,Number.NaN);return a.pow10().recip()}else return a.pow10().recip()}}pentate(t=2,e=C(1,0,1),r=!1){e=new s(e);let i=t;t=Math.trunc(t);let n=i-t;n!==0&&(e.eq(s.dOne)?(++t,e=s.fromNumber(n)):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let o=0;o10)return e}return e}sin(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.sin(this.sign*this.mag)):C(0,0,0)}cos(){return this.mag<0?C(1,0,1):this.layer===0?s.fromNumber(Math.cos(this.sign*this.mag)):C(0,0,0)}tan(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.tan(this.sign*this.mag)):C(0,0,0)}asin(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.asin(this.sign*this.mag)):C(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?s.fromNumber(Math.acos(this.toNumber())):this.layer===0?s.fromNumber(Math.acos(this.sign*this.mag)):C(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.atan(this.sign*this.mag)):s.fromNumber(Math.atan(this.sign*(1/0)))}sinh(){return this.exp().sub(this.negate().exp()).div(2)}cosh(){return this.exp().add(this.negate().exp()).div(2)}tanh(){return this.sinh().div(this.cosh())}asinh(){return s.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return s.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?C(Number.NaN,Number.NaN,Number.NaN):s.ln(this.add(1).div(s.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?new s(this):this.root(s.pow(10,t))}egg(){return this.add(9)}lessThanOrEqualTo(t){return this.cmp(t)<1}lessThan(t){return this.cmp(t)<0}greaterThanOrEqualTo(t){return this.cmp(t)>-1}greaterThan(t){return this.cmp(t)>0}static smoothDamp(t,e,r,i){return new s(t).add(new s(e).minus(new s(t)).times(new s(r)).times(new s(i)))}clone(){return this}static clone(t){return s.fromComponents(t.sign,t.layer,t.mag)}softcap(t,e,r){let i=this.clone();return i.gte(t)&&([0,"pow"].includes(r)&&(i=i.div(t).pow(e).mul(t)),[1,"mul"].includes(r)&&(i=i.sub(t).div(e).add(t))),i}static softcap(t,e,r,i){return new s(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new s(t),e=new s(e);let n=this.clone();return n.gte(t)&&([0,"pow"].includes(r)&&(n=i?n.mul(t.pow(e.sub(1))).root(e):n.pow(e).div(t.pow(e.sub(1)))),[1,"exp"].includes(r)&&(n=i?n.div(t).max(1).log(e).add(t):s.pow(e,n.sub(t)).mul(t))),n}static scale(t,e,r,i,n=!1){return new s(t).scale(e,r,i,n)}format(t=2,e=9,r="mixed_sc"){return dt.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return dt.format(new s(t),e,r,i)}formatST(t=2,e=9,r="st"){return dt.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return dt.format(new s(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return dt.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,n){return dt.formatGain(new s(t),e,r,i,n)}toRoman(t=5e3){t=new s(t);let e=this.clone();if(e.gte(t)||e.lt(1))return e;let r=e.toNumber(),i={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},n="";for(let o of Object.keys(i)){let u=Math.floor(r/i[o]);r-=u*i[o],n+=o.repeat(u)}return n}static toRoman(t,e){return new s(t).toRoman(e)}static random(t=0,e=1){return t=new s(t),e=new s(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new s(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new s(Math.random()).lt(t)}};s.dZero=C(0,0,0),s.dOne=C(1,0,1),s.dNegOne=C(-1,0,1),s.dTwo=C(1,0,2),s.dTen=C(1,0,10),s.dNaN=C(Number.NaN,Number.NaN,Number.NaN),s.dInf=C(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNegInf=C(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNumberMax=j(1,0,Number.MAX_VALUE),s.dNumberMin=j(1,0,Number.MIN_VALUE),s.fromStringCache=new Gt(pr),st([Tt()],s.prototype,"sign",2),st([Tt()],s.prototype,"mag",2),st([Tt()],s.prototype,"layer",2),s=st([ur()],s);var{formats:dt,FORMATS:Sr}=fr(s);s.formats=dt;var St=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.value=t.value,this.order=t.order??99,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>""}},Vt=class{constructor(t=1,e){this.addBoost=this.setBoost.bind(this),e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=new s(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new St(r))})}getBoosts(t,e){let r=[],i=[];for(let n=0;nc),l=n,v=this.getBoosts(o,!0);v[0][0]?this.boostArray[v[1][0]]=new St({id:o,name:u,description:m,value:g,order:l}):this.boostArray.push(new St({id:o,name:u,description:m,value:g,order:l}))}else{t=Array.isArray(t)?t:[t];for(let o of t){let u=this.getBoosts(o.id,!0);u[0][0]?this.boostArray[u[1][0]]=new St(o):this.boostArray.push(new St(o))}}}clearBoosts(){this.boostArray.length=0}calculate(t=this.baseEffect){let e=new s(t),r=this.boostArray;r=r.sort((i,n)=>i.order-n.order);for(let i of r)e=i.value(e);return e}},ti=ot(ft()),kt=30,Ht=.001;function Ir(t,e,r="geometric"){switch(t=new s(t),e=new s(e),r){case"arithmetic":case 1:return t.add(e).div(2);case"geometric":case 2:default:return t.mul(e).sqrt();case"harmonic":case 3:return s.dTwo.div(t.reciprocal().add(e.reciprocal()))}}function Wt(t,e,r,i){i=Object.assign({},{verbose:!1,mode:"geometric"},i),t=new s(t),e=new s(e),r=new s(r);let n,o;return i.mode==="geometric"?(n=t.sub(e).abs().div(t.abs().add(e.abs()).div(2)),o=n.lte(r)):(n=t.sub(e).abs(),o=n.lte(r)),(i.verbose===!0||i.verbose==="onlyOnFail"&&!o)&&console.log({a:t,b:e,tolerance:r,config:i,diff:n,result:o}),o}function Xt(t,e,r="geometric",i=kt,n=Ht,o=1,u){if(o=new s(o),u=new s(u??e),o.gt(u)&&([o,u]=[u,o]),t(u).eq(0))return{value:s.dZero,lowerBound:s.dZero,upperBound:s.dZero};if(t(u).lt(e))return console.warn("eMath.js: The function is not monotonically increasing. (f(n) < n)"),{value:u,lowerBound:u,upperBound:u};for(let g=0;g=0;m--){let g=r.add(u.mul(m)),l=r.add(u.mul(m+1)),v=o;if(o=o.add(t(g).add(t(l)).div(2).mul(u)),Wt(v,o,n,{verbose:!1,mode:"geometric"}))break}return o}function Jt(t,e,r=0,i,n){return r=new s(r),e=new s(e),e.sub(r).lte(kt)?pe(t,e,r,i):Ne(t,e,r,n)}function Ar(t,e=10,r=0,i=1e3){if(t=new s(t),e=new s(e),r=new s(r),i=new s(i),e.lt(1)||r.lt(1))return s.dNaN;let n=t.sign;if(t=t.abs(),t.gte(s.pow(e,i)))return t;let o=s.floor(s.log(t,e)),u=t.div(s.pow(e,o));return u=u.mul(s.pow(e,r)).round(),u=u.div(s.pow(e,r)),u=u.mul(s.pow(e,o)).mul(n),u}function ye(t,e,r,i=s.dInf,n,o,u=!1){t=new s(t),r=new s(r??e.level),i=new s(i);let m=i.sub(r);if(m.lt(0))return console.warn("eMath.js: Invalid target for calculateItem: ",m),[s.dZero,s.dZero];if(u=(typeof e.el=="function"?e.el():e.el)??u,m.eq(1)){let c=e.cost(e.level),f=t.gte(c),h=[s.dZero,s.dZero];return u?(h[0]=f?s.dOne:s.dZero,h):(h=[f?s.dOne:s.dZero,f?c:s.dZero],h)}if(e.costBulk){let[c,f]=e.costBulk(t,e.level,m),h=t.gte(f);return[h?c:s.dZero,h&&!u?f:s.dZero]}if(u){let c=p=>e.cost(p.add(r)),f=s.min(i,Xt(c,t,n,o).value.floor()),h=s.dZero;return[f,h]}let g=Xt(c=>Jt(e.cost,c,r),t,n,o).value.floor().min(r.add(m).sub(1)),l=Jt(e.cost,g,r);return[g.sub(r).add(1).max(0),l]}function ve(t){return t=new s(t),`${t.sign}/${t.mag}/${t.layer}`}function Or(t){return`el/${ve(t)}`}var yt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?new s(t.level):s.dOne}};st([Tt()],yt.prototype,"id",2),st([_t(()=>s)],yt.prototype,"level",2);var be=class Ze{static{this.cacheSize=15}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.level,this,this.currencyPointerFn())}set description(e){this.descriptionFn=typeof e=="function"?e:()=>e}get level(){return((this??{data:{level:s.dOne}}).data??{level:s.dOne}).level}set level(e){this.data.level=new s(e)}constructor(e,r,i,n){let o=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>o,this.currencyPointerFn=typeof i=="function"?i:()=>i,this.cache=new Gt(n??Ze.cacheSize),this.id=e.id,this.name=e.name??e.id,this.descriptionFn=e.description?typeof e.description=="function"?e.description:()=>e.description:()=>"",this.cost=e.cost,this.costBulk=e.costBulk,this.maxLevel=e.maxLevel,this.effect=e.effect,this.el=e.el,this.defaultLevel=e.level??s.dOne}},ei=ot(ft());function we(t,e,r=s.dOne,i=s.dInf){if(t=new s(t),r=new s(r),i=new s(i),i.lt(0))return console.warn("eMath.js: Invalid target for calculateItem: ",i),[s.dZero,s.dZero];if(i.eq(1)){let u=e.cost(r);return[t.gte(u)?s.dOne:s.dZero,t.gte(u)?u:s.dZero]}let n=t.div(e.cost(r)).floor().min(i),o=e.cost(r).mul(n);return[n,o]}var Me=class{constructor(t,e,r){this.defaultAmount=s.dZero;let i=typeof e=="function"?e():e;this.dataPointerFn=typeof e=="function"?e:()=>i,this.currencyPointerFn=typeof r=="function"?r:()=>r,this.id=t.id,this.name=t.name??t.id,this.cost=t.cost,this.effect=t.effect,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.defaultAmount=t.amount??s.dZero}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.amount,this,this.currencyPointerFn())}set description(t){this.descriptionFn=typeof t=="function"?t:()=>t}get amount(){return((this??{data:{amount:s.dOne}}).data??{amount:s.dOne}).amount}set amount(t){this.data.amount=new s(t)}},vt=class{constructor(t){t=t??{},this.id=t.id,this.amount=t.amount??s.dZero}};st([Tt()],vt.prototype,"id",2),st([_t(()=>s)],vt.prototype,"amount",2);var ri=ot(ft()),gt=class{constructor(){this.value=s.dZero,this.upgrades={},this.items={}}};st([_t(()=>s)],gt.prototype,"value",2),st([_t(()=>yt)],gt.prototype,"upgrades",2),st([_t(()=>vt)],gt.prototype,"items",2);var _e=class{get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}constructor(t=new gt,e,r,i={defaultVal:s.dZero,defaultBoost:s.dOne}){this.defaultVal=i.defaultVal,this.defaultBoost=i.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new Vt(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e),this.items={},r&&this.addItem(r)}onLoadData(){for(let t of Object.values(this.upgrades))this.runUpgradeEffect(t)}reset(t,e,r){let i={resetCurrency:!0,resetUpgradeLevels:!0,resetItemAmounts:!0,runUpgradeEffect:!0};if(typeof t=="object"?Object.assign(i,t):Object.assign(i,{resetCurrency:t,resetUpgradeLevels:e,runUpgradeEffect:r}),i.resetCurrency&&(this.value=this.defaultVal),i.resetUpgradeLevels)for(let n of Object.values(this.upgrades))n.level=new s(n.defaultLevel),i.runUpgradeEffect&&this.runUpgradeEffect(n);if(i.resetItemAmounts)for(let n of Object.values(this.items))n.amount=new s(n.defaultAmount),i.runUpgradeEffect&&this.runItemEffect(n)}gain(t=1e3){let e=this.boost.calculate().mul(new s(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new yt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}queryUpgrade(t){let e=Object.keys(this.upgrades);if(t instanceof RegExp){let i=t;return e.filter(o=>i.test(o)).map(o=>this.upgrades[o])}return typeof t=="string"&&(t=[t]),e.filter(i=>t.includes(i)).map(i=>this.upgrades[i])}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r=[];for(let i of t){this.pointerAddUpgrade(i);let n=new be(i,()=>this.pointerGetUpgrade(i.id),()=>this);e&&this.runUpgradeEffect(n),this.upgrades[i.id]=n,r.push(n)}return r}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&Object.assign(r,e)}runUpgradeEffect(t){t.effect?.(t.level,t,this)}runItemEffect(t,e=s.dOne){e=new s(e),t.effect?.(t.amount,e,t,this)}calculateUpgrade(t,e=1/0,r,i){let n=this.getUpgrade(t);return n===null?(console.warn(`eMath.js: Upgrade "${t}" not found.`),[s.dZero,s.dZero]):(e=n.level.add(e),n.maxLevel!==void 0&&(e=s.min(e,n.maxLevel)),ye(this.value,n,n.level,e,r,i))}getNextCost(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`eMath.js: Upgrade "${t}" not found.`),s.dZero;let o=this.calculateUpgrade(t,e,r,i)[0];return n.cost(n.level.add(o))}getNextCostMax(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`eMath.js: Upgrade "${t}" not found.`),s.dZero;let o=this.calculateUpgrade(t,e,r,i);return n.cost(n.level.add(o[0])).add(o[1])}buyUpgrade(t,e,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`eMath.js: Upgrade "${t}" not found.`),!1;let[o,u]=this.calculateUpgrade(t,e,r,i);return o.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(u),n.level=n.level.add(o),this.runUpgradeEffect(n),!0)}pointerAddItem(t){let e=new vt(t);return this.pointer.items[t.id]=e,e}pointerGetItem(t){return this.pointer.items[t]??null}addItem(t,e=!0){Array.isArray(t)||(t=[t]);for(let r of t){this.pointerAddItem(r);let i=new Me(r,()=>this.pointerGetItem(r.id),()=>this);e&&this.runItemEffect(i),this.items[r.id]=i}}getItem(t){return this.items[t]??null}calculateItem(t,e,r){let i=this.getItem(t);return i===null?(console.warn(`eMath.js: Item "${t}" not found.`),[s.dZero,s.dZero]):we(this.value,i,e,r)}buyItem(t,e,r){let i=this.getItem(t);if(i===null)return console.warn(`eMath.js: Item "${t}" not found.`),!1;let[n,o]=this.calculateItem(t,e,r);return n.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(o),i.amount=i.amount.add(n),this.runItemEffect(i,e),!0)}},ii=ot(ft()),xt=class{constructor(t=0){this.value=new s(t)}};st([_t(()=>s)],xt.prototype,"value",2);var Se=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=new s(r),t??=new xt(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new Vt(this.initial):null}update(){console.warn("eMath.js: AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed."),this.boost&&(this.pointer.value=this.boost.calculate())}get value(){return this.boost&&(this.pointer.value=this.boost.calculate()),this.pointer.value}set value(t){if(this.boost)throw new Error("Cannot set value of attributeStatic when boost is enabled.");this.pointer.value=t}},Lt=class{constructor(t,e,r={},i){this.setValue=this.set.bind(this),this.getValue=this.get.bind(this),this.x=t,this.y=e,this.properties=typeof r=="function"?r(this):{...r},this.gridSymbol=i}get grid(){return Qt.getInstance(this.gridSymbol)}set(t,e){return this.properties[t]=e,e}get(t){return this.properties[t]}translate(t=0,e=0){return Qt.getInstance(this.gridSymbol).getCell(this.x+t,this.y+e)}direction(t,e=1,r){let i=this.grid;return(()=>{switch(t){case"up":return i.getCell(this.x,this.y-e);case"right":return i.getCell(this.x+e,this.y);case"down":return i.getCell(this.x,this.y+e);case"left":return i.getCell(this.x-e,this.y);case"adjacent":return i.getAdjacent(this.x,this.y,e,r);case"diagonal":return i.getDiagonal(this.x,this.y,e,r);case"encircling":return i.getEncircling(this.x,this.y,e,r);default:throw new Error("Invalid direction")}})()}up(t=1){return this.direction("up",t)}right(t=1){return this.direction("right",t)}down(t=1){return this.direction("down",t)}left(t=1){return this.direction("left",t)}};function Ie(t,e,r=!0){let i=r?"Size":"Coordinates";if(typeof t!="number"||typeof e!="number")throw new RangeError(`${i} must be numbers: ${t}, ${e}`);if(!Number.isInteger(t)||!Number.isInteger(e))throw new RangeError(`${i} must be integers: ${t}, ${e}`);if(t<0||e<0)throw new RangeError(`${i} must be positive: ${t}, ${e}`);if(!Number.isFinite(t)||!Number.isFinite(e))throw new RangeError(`${i} must be finite: ${t}, ${e}`);if(!Number.isSafeInteger(t)||!Number.isSafeInteger(e))throw new RangeError(`${i} must be safe integers: ${t}, ${e}`)}var rt=class ne extends Array{constructor(e){e=Array.isArray(e)?e:[e],e=e.filter(r=>r!==void 0),super(...e),this.removeDuplicates()}removeDuplicates(){let e=[];this.forEach((r,i)=>{this.indexOf(r)!==i&&e.push(i)}),e.forEach(r=>this.splice(r,1))}translate(e=0,r=0){return new ne(this.map(i=>i.translate(e,r)))}direction(e,r,i){return new ne(this.flatMap(n=>n.direction(e,r,i)))}up(e){return this.direction("up",e)}right(e){return this.direction("right",e)}down(e){return this.direction("down",e)}left(e){return this.direction("left",e)}adjacent(e,r){return this.direction("adjacent",e,r)}diagonal(e,r){return this.direction("diagonal",e,r)}encircling(e,r){return this.direction("encircling",e,r)}},Qt=class se{constructor(e,r,i){this.cells=[],this.gridSymbol=Symbol(),this.all=this.getAll.bind(this),this.allX=this.getAllX.bind(this),this.allY=this.getAllY.bind(this),this.get=this.getCell.bind(this),this.set=this.setCell.bind(this),se.instances[this.gridSymbol]=this,this.starterProps=i??{},this.xSize=e,this.ySize=r??e,Ie(this.xSize,this.ySize,!0);for(let n=0;n{if(this.ySize!==n&&(this.ySizen))for(let o=n;o{if(this.xSize!==i){if(this.xSizei)for(let o=0;o{let t=!1,e=r=>(t||(console.warn("eMath.js: The E function is deprecated. Use the Decimal class directly."),t=!0),new s(r));return Object.getOwnPropertyNames(s).filter(r=>!Object.getOwnPropertyNames(class{}).includes(r)).forEach(r=>{e[r]=s[r]}),e})(),Tr=le,Ae={};Ut(Ae,{ConfigManager:()=>qt,DataManager:()=>Fe,EventManager:()=>Te,EventTypes:()=>Ce,Game:()=>kr,GameAttribute:()=>ke,GameCurrency:()=>Pe,GameReset:()=>te,KeyManager:()=>Oe,gameDefaultConfig:()=>xe,keys:()=>Fr});var ni=ot(ft()),qt=class{constructor(t){this.configOptionTemplate=t}parse(t){if(typeof t>"u")return this.configOptionTemplate;function e(r,i){for(let n in i)typeof r[n]>"u"?r[n]=i[n]:typeof r[n]=="object"&&typeof i[n]=="object"&&!Array.isArray(r[n])&&!Array.isArray(i[n])&&(r[n]=e(r[n],i[n]));return r}return e(t,this.configOptionTemplate)}get options(){return this.configOptionTemplate}},Er={autoAddInterval:!0,fps:30},Fr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ".split("").concat(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),Oe=class Ye{constructor(e){if(this.addKeys=this.addKey.bind(this),this.keysPressed=[],this.binds=[],this.tickers=[],this.config=Ye.configManager.parse(e),this.config.autoAddInterval){let r=this.config.fps?this.config.fps:30;this.tickerInterval=setInterval(()=>{for(let i of this.tickers)i(1e3/r)},1e3/r)}typeof document>"u"||(this.tickers.push(r=>{for(let i of this.binds)(typeof i.onDownContinuous<"u"||typeof i.fn<"u")&&this.isPressing(i.id)&&(i.onDownContinuous?.(r),i.fn?.(r))}),document.addEventListener("keydown",r=>{this.logKey(r,!0),this.onAll("down",r.key)}),document.addEventListener("keyup",r=>{this.logKey(r,!1),this.onAll("up",r.key)}),document.addEventListener("keypress",r=>{this.onAll("press",r.key)}))}static{this.configManager=new qt(Er)}changeFps(e){this.config.fps=e,this.tickerInterval&&(clearInterval(this.tickerInterval),this.tickerInterval=setInterval(()=>{for(let r of this.tickers)r(1e3/e)},1e3/e))}logKey(e,r){let i=e.key;r&&!this.keysPressed.includes(i)?this.keysPressed.push(i):!r&&this.keysPressed.includes(i)&&this.keysPressed.splice(this.keysPressed.indexOf(i),1)}onAll(e,r){for(let i of this.binds)if(i.key===r)switch(e){case"down":i.onDown?.();break;case"press":default:i.onPress?.();break;case"up":i.onUp?.();break}}isPressing(e){for(let r of this.binds)if(r.id===e)return this.keysPressed.includes(r.key);return!1}getBind(e){return this.binds.find(r=>r.id===e)}addKey(e,r,i){e=typeof e=="string"?{id:e,name:e,key:r??"",fn:i}:e,e=Array.isArray(e)?e:[e];for(let n of e){n.id=n.id??n.name;let o=this.getBind(n.id);if(o){Object.assign(o,n);continue}this.binds.push(n)}}},Ce=(t=>(t.interval="interval",t.timeout="timeout",t))(Ce||{}),Pr={autoAddInterval:!0,fps:30},Te=class Ve{constructor(e,r){if(this.addEvent=this.setEvent.bind(this),this.config=Ve.configManager.parse(e),this.events={},this.callbackEvents={},r)for(let i of r)this.callbackEvents[i]=[];if(this.config.autoAddInterval){let i=this.config.fps??30;this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/i)}}static{this.configManager=new qt(Pr)}on(e,r){this.callbackEvents[e]||(this.callbackEvents[e]=[]),this.callbackEvents[e].push({type:e,callback:r})}dispatch(e){if(this.callbackEvents[e])for(let r of this.callbackEvents[e])r.callback()}tickerFunction(){let e=Date.now();for(let r of Object.values(this.events))switch(r.type){case"interval":if(e-r.intervalLast>=r.delay){let i=e-r.intervalLast;r.callback(i),r.intervalLast=e}break;case"timeout":{let i=e-r.timeCreated;e-r.timeCreated>=r.delay&&(r.callback(i),delete this.events[r.name])}break}}changeFps(e){this.config.fps=e,this.tickerInterval&&(clearInterval(this.tickerInterval),this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/e))}timeWarp(e){for(let r of Object.values(this.events))switch(r.type){case"interval":r.intervalLast-=e;break;case"timeout":r.timeCreated-=e;break}}setEvent(e,r,i,n){this.events[e]=(()=>{switch(r){case"interval":return{name:e,type:r,delay:typeof i=="number"?i:i.toNumber(),callback:n,timeCreated:Date.now(),intervalLast:Date.now()};case"timeout":default:return{name:e,type:r,delay:typeof i=="number"?i:i.toNumber(),callback:n,timeCreated:Date.now()}}})()}removeEvent(e){delete this.events[e]}},si=ot(ft()),Ee=ot(Ke()),Kt=ot(rr()),Fe=class{constructor(t){this.data={},this.static={},this.eventsOnLoad=[],this.gameRef=typeof t=="function"?t():t}addEventOnLoad(t){this.eventsOnLoad.push(t)}setData(t,e){typeof this.data[t]>"u"&&this.normalData&&console.warn("eMath.js: After initializing data, you should not add new properties to data."),this.data[t]=e;let r=()=>this.data;return{get value(){return r()[t]},set value(i){r()[t]=i},setValue(i){r()[t]=i}}}getData(t){return this.data[t]}setStatic(t,e){return console.warn("eMath.js: setStatic: Static data is basically useless and should not be used. Use variables in local scope instead."),typeof this.static[t]>"u"&&this.normalData&&console.warn("eMath.js: After initializing data, you should not add new properties to staticData."),this.static[t]=e,this.static[t]}getStatic(t){return console.warn("eMath.js: Static data is basically useless and should not be used. Use variables in local scope instead."),this.static[t]}init(){this.normalData=this.data,this.normalDataPlain=Bt(this.data)}compileDataRaw(t=this.data){this.gameRef.eventManager.dispatch("beforeCompileData");let e=Bt(t),r=(0,Kt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(e)}`),i;try{i="9.4.0"}catch{i="9.3.0"}return[{hash:r,game:{title:this.gameRef.config.name.title,id:this.gameRef.config.name.id,version:this.gameRef.config.name.version},emath:{version:i}},e]}compileData(t=this.data){let e=JSON.stringify(this.compileDataRaw(t));return(0,Ee.compressToBase64)(e)}decompileData(t=window.localStorage.getItem(`${this.gameRef.config.name.id}-data`)){if(!t)return null;let e;try{return e=JSON.parse((0,Ee.decompressFromBase64)(t)),e}catch(r){if(r instanceof SyntaxError)console.error(`Failed to decompile data (corrupted) "${t}":`,r);else throw r;return null}}validateData(t){let[e,r]=t;if(typeof e=="string")return(0,Kt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`)===e;let i=e.hash,n=(0,Kt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`);return i===n}resetData(t=!1){if(!this.normalData)throw new Error("dataManager.resetData(): You must call init() before writing to data.");this.data=this.normalData,this.saveData(),t&&window.location.reload()}saveData(t=this.compileData()){if(this.gameRef.eventManager.dispatch("beforeSaveData"),!t)throw new Error("dataManager.saveData(): Data to save is empty.");if(!window.localStorage)throw new Error("dataManager.saveData(): Local storage is not supported. You can use compileData() instead to implement a custom save system.");window.localStorage.setItem(`${this.gameRef.config.name.id}-data`,t),this.gameRef.eventManager.dispatch("saveData")}exportData(){let t=this.compileData();if(prompt("Download save data?:",t)!=null){let e=new Blob([t],{type:"text/plain"}),r=document.createElement("a");r.href=URL.createObjectURL(e),r.download=`${this.gameRef.config.name.id}-data.txt`,r.textContent=`Download ${this.gameRef.config.name.id}-data.txt file`,document.body.appendChild(r),r.click(),document.body.removeChild(r)}}parseData(t=this.decompileData(),e=!0){if((!this.normalData||!this.normalDataPlain)&&e)throw new Error("dataManager.parseData(): You must call init() before writing to data.");if(!t)return null;let[,r]=t;function i(c){return typeof c=="object"&&c?.constructor===Object}let n=(c,f)=>Object.prototype.hasOwnProperty.call(c,f);function o(c,f,h){if(!c||!f||!h)return console.warn("eMath.js: dataManager.deepMerge(): Missing arguments:",c,f,h),h??{};let p=h;for(let d in c)if(n(c,d)&&!n(h,d)&&(p[d]=c[d]),f[d]instanceof gt){let O=c[d],T=h[d];if(Array.isArray(T.upgrades)){let k=T.upgrades;T.upgrades={};for(let a of k)T.upgrades[a.id]=a}T.upgrades={...O.upgrades,...T.upgrades},p[d]=T,T.items={...O.items,...T.items}}else i(c[d])&&i(h[d])&&(p[d]=o(c[d],f[d],h[d]));return p}let u=e?o(this.normalDataPlain,this.normalData,r):r,m=Object.getOwnPropertyNames(new yt({id:"",level:s.dZero})),g=Object.getOwnPropertyNames(new vt({id:"",amount:s.dZero}));function l(c,f){let h=$t(c,f);if(h instanceof gt){for(let p in h.upgrades){let d=h.upgrades[p];if(!d||!m.every(O=>Object.getOwnPropertyNames(d).includes(O))){delete h.upgrades[p];continue}h.upgrades[p]=$t(yt,d)}for(let p in h.items){let d=h.items[p];if(!d||!g.every(O=>Object.getOwnPropertyNames(d).includes(O))){delete h.items[p];continue}h.items[p]=$t(vt,d)}}if(!h)throw new Error(`Failed to convert ${c.name} to class instance.`);return h}function v(c,f){if(!c||!f)throw new Error("dataManager.plainToInstanceRecursive(): Missing arguments.");let h=f;for(let p in c){if(f[p]===void 0){console.warn(`eMath.js: Missing property "${p}" in loaded data.`);continue}if(!i(f[p]))continue;let d=c[p].constructor;if(d===Object){h[p]=v(c[p],f[p]);continue}h[p]=l(d,f[p])}return h}return u=v(this.normalData,u),u}loadData(t=this.decompileData()){if(t=typeof t=="string"?this.decompileData(t):t,!t)return null;let e=this.validateData([t[0],Bt(t[1])]),r=this.parseData(t);if(!r)return null;this.data=r;for(let i of this.eventsOnLoad)i();return this.gameRef.eventManager.dispatch("loadData"),e}},Pe=class extends _e{get data(){return this.pointer}get static(){return this}constructor(t,e,r){if(typeof t=="function")throw new Error("GameCurrency constructor does not accept a function as the first parameter. Use the .addCurrency method instead.");super(...t),this.game=e,this.name=r,this.game.dataManager.addEventOnLoad(()=>{this.static.onLoadData()})}},ke=class extends Se{get data(){return this.pointer}get static(){return this}constructor(t,e){if(typeof t=="function")throw new Error("GameAttribute constructor does not accept a function as the first parameter. Use the .addAttribute method instead.");super(...t),this.game=e}},te=class He{static fromObject(e){return new He(e.currenciesToReset,e.extender,e.onReset,e.condition)}constructor(e,r,i,n){this.currenciesToReset=Array.isArray(e)?e:[e],r=r??[],this.extender=Array.isArray(r)?r:[r],this.onReset=i,this.condition=n,this.id=Symbol()}reset(e=!1,r=!0,i=new Set){if(e||(typeof this.condition=="function"?!this.condition(this):!this.condition)&&typeof this.condition<"u")return;let n=()=>{this.onReset?.(this),this.currenciesToReset.forEach(o=>{o.static.reset()})};if(this.extender.length===0){n();return}this.extender.forEach(o=>{i.has(o.id)||(i.add(o.id),o.reset(r||e,r,i))}),n()}},xe={mode:"production",name:{title:"",id:"",version:"0.0.0"},settings:{framerate:30},initIntervalBasedManagers:!0},kr=class We{static{this.configManager=new qt(xe)}constructor(e){this.config=We.configManager.parse(e),this.dataManager=new Fe(this),this.keyManager=new Oe({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.eventManager=new Te({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.tickers=[]}init(){this.dataManager.init()}changeFps(e){this.keyManager.changeFps(e),this.eventManager.changeFps(e)}addCurrency(e,r=[],i=[]){return this.dataManager.setData(e,{currency:new gt}),new Pe([()=>this.dataManager.getData(e).currency,r,i],this,e)}addAttribute(e,r=!0,i=0){return this.dataManager.setData(e,new xt(i)),new ke([this.dataManager.getData(e),r,i],this)}addReset(...e){return console.warn("eMath.js: Game.addReset is deprecated. Use the GameReset class instead."),new te(...e)}addResetFromObject(e){return te.fromObject(e)}},xr={...Tr,...Ae},Lr=xr;if(typeof ut.exports=="object"&&typeof Ot=="object"){var qr=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Object.getOwnPropertyNames(e))!Object.prototype.hasOwnProperty.call(t,n)&&n!==r&&Object.defineProperty(t,n,{get:()=>e[n],enumerable:!(i=Object.getOwnPropertyDescriptor(e,n))||i.enumerable});return t};ut.exports=qr(ut.exports,Ot)}return ut.exports}); /*! Bundled license information: reflect-metadata/Reflect.js: diff --git a/dist/game/eMath.game.mjs b/dist/game/eMath.game.mjs index cd582cb..2c5b694 100644 --- a/dist/game/eMath.game.mjs +++ b/dist/game/eMath.game.mjs @@ -56,7 +56,9 @@ var require_lz_string = __commonJS({ return keyStrBase64.charAt(a); }); switch (res.length % 4) { + // To produce valid Base64 default: + // When could this happen ? case 0: return res; case 1: @@ -880,7 +882,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega.config.greek.length) + ); let lastLetter = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -921,7 +925,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega_short.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega_short.config.greek.length) + ); let lastLetter = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -947,6 +953,7 @@ function decimalFormatGenerator(Decimal2) { elemental: { config: { /** The list of elements */ + /* eslint-disable prettier/prettier */ element_lists: [ ["H"], ["He", "Li", "Be", "B", "C", "N", "O", "F"], @@ -1061,6 +1068,7 @@ function decimalFormatGenerator(Decimal2) { ], ["Og"] ] + /* eslint-enable prettier/prettier */ }, getOffset(group) { if (group == 1) return 1; @@ -1092,11 +1100,20 @@ function decimalFormatGenerator(Decimal2) { getAbbreviationAndValue(x) { const abbreviationListUnfloored = x.log(118).toNumber(); const abbreviationListIndex = Math.floor(abbreviationListUnfloored) + 1; - const abbreviationLength = FORMATS2.elemental.abbreviationLength(abbreviationListIndex); + const abbreviationLength = FORMATS2.elemental.abbreviationLength( + abbreviationListIndex + ); const abbreviationProgress = abbreviationListUnfloored - abbreviationListIndex + 1; - const abbreviationIndex = Math.floor(abbreviationProgress * abbreviationLength); - const abbreviation = FORMATS2.elemental.getAbbreviation(abbreviationListIndex, abbreviationProgress); - const value = new Decimal2(118).pow(abbreviationListIndex + abbreviationIndex / abbreviationLength - 1); + const abbreviationIndex = Math.floor( + abbreviationProgress * abbreviationLength + ); + const abbreviation = FORMATS2.elemental.getAbbreviation( + abbreviationListIndex, + abbreviationProgress + ); + const value = new Decimal2(118).pow( + abbreviationListIndex + abbreviationIndex / abbreviationLength - 1 + ); return [abbreviation, value]; }, formatElementalPart(abbreviation, n) { @@ -1106,7 +1123,12 @@ function decimalFormatGenerator(Decimal2) { return `${n.toString()} ${abbreviation}`; }, format(value, acc = 2) { - if (value.gt(new Decimal2(118).pow(new Decimal2(118).pow(new Decimal2(118).pow(4))))) return "e" + FORMATS2.elemental.format(value.log10(), acc); + if (value.gt( + new Decimal2(118).pow( + new Decimal2(118).pow(new Decimal2(118).pow(4)) + ) + )) + return "e" + FORMATS2.elemental.format(value.log10(), acc); let log = value.log(118); const slog = log.log(118); const sslog = slog.log(118).toNumber(); @@ -1119,7 +1141,12 @@ function decimalFormatGenerator(Decimal2) { parts.unshift([abbreviation, n]); } if (parts.length >= max) { - return parts.map((x) => FORMATS2.elemental.formatElementalPart(x[0], x[1])).join(" + "); + return parts.map( + (x) => ( + // @ts-expect-error - x has both string and decimal for some reason + FORMATS2.elemental.formatElementalPart(x[0], x[1]) + ) + ).join(" + "); } const formattedMantissa = new Decimal2(118).pow(log).toFixed(parts.length === 1 ? 3 : acc); if (parts.length === 0) { @@ -1181,7 +1208,9 @@ function decimalFormatGenerator(Decimal2) { return (slog.gte(1e9) ? "" : Decimal2.dTen.pow(slog.sub(slog.floor())).toFixed(4)) + "F" + FORMATS2.eng.format(slog.floor(), 0); } const m = ex.div(new Decimal2(1e3).pow(e.div(3).floor())); - return (e.log10().gte(9) ? "" : m.toFixed(new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber())) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); + return (e.log10().gte(9) ? "" : m.toFixed( + new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber() + )) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); } } }, @@ -1206,12 +1235,25 @@ function decimalFormatGenerator(Decimal2) { }, /** Layer format */ layer: { - layers: ["infinity", "eternity", "reality", "equality", "affinity", "celerity", "identity", "vitality", "immunity", "atrocity"], + layers: [ + "infinity", + "eternity", + "reality", + "equality", + "affinity", + "celerity", + "identity", + "vitality", + "immunity", + "atrocity" + ], format(ex, acc = 2, max) { ex = new Decimal2(ex); const layer = ex.max(1).log10().max(1).log(INFINITY_NUM.log10()).floor(); if (layer.lte(0)) return format(ex, acc, max, "sc"); - ex = Decimal2.dTen.pow(ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0)); + ex = Decimal2.dTen.pow( + ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0) + ); const meta = layer.div(10).floor(); const layer_id = layer.toNumber() % 10 - 1; return format(ex, Math.max(4, acc), max, "sc") + " " + (meta.gte(1) ? "meta" + (meta.gte(2) ? "^" + format(meta, 0, max, "sc") : "") + "-" : "") + (isNaN(layer_id) ? "nanity" : FORMATS2.layer.layers[layer_id]); @@ -1257,8 +1299,10 @@ function decimalFormatGenerator(Decimal2) { meta++; } if (meta == 0) return format(ex, acc, max, "sc"); - if (ex.gte(3)) return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); - if (ex.gte(2)) return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); + if (ex.gte(3)) + return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); + if (ex.gte(2)) + return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); return symbols2[meta] + symbols[meta] + "-" + format(inf.pow(ex.sub(1)), acc, max, "sc"); } }, @@ -1303,7 +1347,10 @@ function decimalFormatGenerator(Decimal2) { } else { const trunc = numLetters.sub(abbStart).add(1); const truncExponent = exponent.div(Decimal2.pow(alphabetLength + 1, trunc.sub(1))).floor(); - const truncLetters = convertToLetters(truncExponent, new Decimal2(abbStart)); + const truncLetters = convertToLetters( + truncExponent, + new Decimal2(abbStart) + ); letters = `${truncLetters}(${trunc.gt("1e9") ? trunc.format() : trunc.format(0)})`; } return letters; @@ -1325,7 +1372,12 @@ function decimalFormatGenerator(Decimal2) { ex = new Decimal2(ex); start = new Decimal2(start).div(1e3); if (ex.lt(start.mul(1e3))) return format(ex, acc, max, type); - const letters = FORMATS2.alphabet.getAbbreviation(ex, start, startDouble, abbStart); + const letters = FORMATS2.alphabet.getAbbreviation( + ex, + start, + startDouble, + abbStart + ); const mantissa = ex.div(Decimal2.pow(1e3, ex.log(1e3).floor())); const isAbbreviation = letters.length > (abbStart ?? 9) + 2; return `${!isAbbreviation ? mantissa.toFixed(acc) + " " : ""}${letters}`; @@ -1339,7 +1391,9 @@ function decimalFormatGenerator(Decimal2) { return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUBSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); } function toSuperscript(value) { - return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); + return value.toFixed(0).split("").map( + (x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)] + ).join(""); } function formatST(ex, acc = 2, max = 9, type = "st") { return format(ex, acc, max, type); @@ -1357,7 +1411,9 @@ function decimalFormatGenerator(Decimal2) { case "scientific": { if (ex.log10().lt(Math.min(-acc, 0)) && acc > 1) { const e2 = ex.log10().ceil(); - const m = ex.div(e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2)); + const m = ex.div( + e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2) + ); const be = e2.mul(-1).max(1).log10().gte(9); return neg + (be ? "" : m.toFixed(2)) + "e" + format(e2, 0, max, "mixed_sc"); } else if (e.lt(max)) { @@ -1377,13 +1433,16 @@ function decimalFormatGenerator(Decimal2) { case "standard": { let e3 = ex.log(1e3).floor(); if (e3.lt(1)) { - return neg + ex.toFixed(Math.max(Math.min(acc - e.toNumber(), acc), 0)); + return neg + ex.toFixed( + Math.max(Math.min(acc - e.toNumber(), acc), 0) + ); } const e3_mul = e3.mul(3); const ee = e3.log10().floor(); if (ee.gte(3e3)) return "e" + format(e, acc, max, "st"); let final = ""; - if (e3.lt(4)) final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; + if (e3.lt(4)) + final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; else { let ee3 = Math.floor(e3.log(1e3).toNumber()); if (ee3 < 100) ee3 = Math.max(ee3 - 1, 0); @@ -1393,8 +1452,10 @@ function decimalFormatGenerator(Decimal2) { const mod1000 = e3.sub(div1000.mul(1e3)).floor().toNumber(); if (mod1000 > 0) { if (mod1000 == 1 && !ee3) final = "U"; - if (ee3) final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); - if (mod1000 > 1) final = FORMATS2.standard.tier1(mod1000) + final; + if (ee3) + final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); + if (mod1000 > 1) + final = FORMATS2.standard.tier1(mod1000) + final; } e3 = div1000; ee3++; @@ -1405,7 +1466,8 @@ function decimalFormatGenerator(Decimal2) { return neg + (ee.gte(10) ? "" : m.toFixed(fixedAmt) + " ") + final; } default: - if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); + if (!FORMATS2[type]) + console.error(`Invalid format type "`, type, `"`); return neg + FORMATS2[type].format(ex, acc, max); } } @@ -1423,9 +1485,12 @@ function decimalFormatGenerator(Decimal2) { } function formatTime(ex, acc = 2, type = "s") { ex = new Decimal2(ex); - if (ex.gte(86400)) return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); - if (ex.gte(3600) || type == "d") return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); - if (ex.gte(60) || type == "h") return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); + if (ex.gte(86400)) + return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); + if (ex.gte(3600) || type == "d") + return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); + if (ex.gte(60) || type == "h") + return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); return (ex.gte(10) || type != "m" ? "" : "0") + format(ex, acc, 12, "sc"); } function formatTimeLong(ex, ms = false, acc = 0, max = 9, type = "mixed_sc") { @@ -5763,7 +5828,7 @@ function inverseFunctionApprox(f, n, mode = "geometric", iterations = DEFAULT_IT } if (f(upperBound).lt(n)) { console.warn( - "The function is not monotonically increasing. (f(n) < n)" + "eMath.js: The function is not monotonically increasing. (f(n) < n)" ); return { value: upperBound, @@ -5841,7 +5906,7 @@ function calculateUpgrade(value, upgrade, start, end = Decimal.dInf, mode, itera end = new Decimal(end); const target = end.sub(start); if (target.lt(0)) { - console.warn("calculateUpgrade: Invalid target: ", target); + console.warn("eMath.js: Invalid target for calculateItem: ", target); return [Decimal.dZero, Decimal.dZero]; } el = (typeof upgrade.el === "function" ? upgrade.el() : upgrade.el) ?? el; @@ -6014,7 +6079,7 @@ function calculateItem(value, item, tier = Decimal.dOne, target = Decimal.dInf) tier = new Decimal(tier); target = new Decimal(target); if (target.lt(0)) { - console.warn("calculateItem: Invalid target: ", target); + console.warn("eMath.js: Invalid target for calculateItem: ", target); return [Decimal.dZero, Decimal.dZero]; } if (target.eq(1)) { @@ -6302,6 +6367,7 @@ var CurrencyStatic = class { this.pointerAddUpgrade(upgrade); const addedUpgradeStatic = new UpgradeStatic( upgrade, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion () => this.pointerGetUpgrade(upgrade.id), () => this ); @@ -6361,7 +6427,7 @@ var CurrencyStatic = class { calculateUpgrade(id, target = Infinity, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return [Decimal.dZero, Decimal.dZero]; } target = upgrade.level.add(target); @@ -6392,7 +6458,7 @@ var CurrencyStatic = class { getNextCost(id, target = 1, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return Decimal.dZero; } const amount = this.calculateUpgrade(id, target, mode, iterations)[0]; @@ -6415,7 +6481,7 @@ var CurrencyStatic = class { getNextCostMax(id, target = 1, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return Decimal.dZero; } const upgCalc = this.calculateUpgrade(id, target, mode, iterations); @@ -6436,7 +6502,7 @@ var CurrencyStatic = class { buyUpgrade(id, target, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return false; } const [amount, cost] = this.calculateUpgrade( @@ -6482,6 +6548,7 @@ var CurrencyStatic = class { this.pointerAddItem(item); const addedUpgradeStatic = new Item( item, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion () => this.pointerGetItem(item.id), () => this ); @@ -6508,7 +6575,7 @@ var CurrencyStatic = class { calculateItem(id, tier, target) { const item = this.getItem(id); if (item === null) { - console.warn(`Item "${id}" not found.`); + console.warn(`eMath.js: Item "${id}" not found.`); return [Decimal.dZero, Decimal.dZero]; } return calculateItem(this.value, item, tier, target); @@ -6523,7 +6590,7 @@ var CurrencyStatic = class { buyItem(id, tier, target) { const item = this.getItem(id); if (item === null) { - console.warn(`Item "${id}" not found.`); + console.warn(`eMath.js: Item "${id}" not found.`); return false; } const [amount, cost] = this.calculateItem(id, tier, target); @@ -6576,7 +6643,7 @@ var AttributeStatic = class { */ update() { console.warn( - "AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed." + "eMath.js: AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed." ); if (this.boost) { this.pointer.value = this.boost.calculate(); @@ -7046,7 +7113,7 @@ var DataManager = class { setData(key, value) { if (typeof this.data[key] === "undefined" && this.normalData) { console.warn( - "After initializing data, you should not add new properties to data." + "eMath.js: After initializing data, you should not add new properties to data." ); } this.data[key] = value; @@ -7082,11 +7149,11 @@ var DataManager = class { */ setStatic(key, value) { console.warn( - "setStatic: Static data is basically useless and should not be used. Use variables in local scope instead." + "eMath.js: setStatic: Static data is basically useless and should not be used. Use variables in local scope instead." ); if (typeof this.static[key] === "undefined" && this.normalData) { console.warn( - "After initializing data, you should not add new properties to staticData." + "eMath.js: After initializing data, you should not add new properties to staticData." ); } this.static[key] = value; @@ -7100,7 +7167,7 @@ var DataManager = class { */ getStatic(key) { console.warn( - "getStatic: Static data is basically useless and should not be used. Use variables in local scope instead." + "eMath.js: Static data is basically useless and should not be used. Use variables in local scope instead." ); return this.static[key]; } @@ -7271,7 +7338,7 @@ var DataManager = class { function deepMerge(sourcePlain, source, target) { if (!sourcePlain || !source || !target) { console.warn( - "dataManager.deepMerge(): Missing arguments:", + "eMath.js: dataManager.deepMerge(): Missing arguments:", sourcePlain, source, target @@ -7316,7 +7383,7 @@ var DataManager = class { const upgradeDataProperties = Object.getOwnPropertyNames( new UpgradeData({ id: "", level: Decimal.dZero }) ); - const ItemDataProperties = Object.getOwnPropertyNames( + const itemDataProperties = Object.getOwnPropertyNames( new ItemData({ id: "", amount: Decimal.dZero }) ); function convertTemplateClass(templateClassToConvert, plain) { @@ -7340,7 +7407,7 @@ var DataManager = class { } for (const itemName in out.items) { const item = out.items[itemName]; - if (!item || !ItemDataProperties.every( + if (!item || !itemDataProperties.every( (prop) => Object.getOwnPropertyNames(item).includes(prop) )) { delete out.items[itemName]; @@ -7365,7 +7432,9 @@ var DataManager = class { const out = plain; for (const key in normal) { if (plain[key] === void 0) { - console.warn(`Missing property "${key}" in loaded data.`); + console.warn( + `eMath.js: Missing property "${key}" in loaded data.` + ); continue; } if (!isPlainObject(plain[key])) continue; @@ -7668,7 +7737,7 @@ var Game = class _Game { // public addReset (currenciesToReset: GameCurrency | GameCurrency[], extender?: GameReset): GameReset { addReset(...args) { console.warn( - "Game.addReset is deprecated. Use the GameReset class instead." + "eMath.js: Game.addReset is deprecated. Use the GameReset class instead." ); const reset = new GameReset(...args); return reset; diff --git a/dist/main/eMath.js b/dist/main/eMath.js index 6b13f08..fe0da45 100644 --- a/dist/main/eMath.js +++ b/dist/main/eMath.js @@ -51,7 +51,7 @@ __export(src_exports, { Decimal: () => Decimal, E: () => E, FORMATS: () => FORMATS, - FormatTypeList: () => FormatTypeList, + FormatTypeList: () => formatTypeList, Grid: () => Grid, GridCell: () => GridCell, GridCellCollection: () => GridCellCollection, @@ -199,7 +199,21 @@ var ST_NAMES = [ ["", "Hc", "DHe", "THt", "TeH", "PHc", "HHe", "HpH", "OHt", "EHc"] ] ]; -var FormatTypeList = ["st", "sc", "scientific", "omega", "omega_short", "elemental", "old_sc", "eng", "mixed_sc", "layer", "standard", "inf", "alphabet"]; +var formatTypeList = [ + "st", + "sc", + "scientific", + "omega", + "omega_short", + "elemental", + "old_sc", + "eng", + "mixed_sc", + "layer", + "standard", + "inf", + "alphabet" +]; function decimalFormatGenerator(Decimal2) { const FORMATS2 = { /** Omega format */ @@ -216,7 +230,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega.config.greek.length) + ); let lastLetter = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -257,7 +273,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega_short.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega_short.config.greek.length) + ); let lastLetter = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -283,6 +301,7 @@ function decimalFormatGenerator(Decimal2) { elemental: { config: { /** The list of elements */ + /* eslint-disable prettier/prettier */ element_lists: [ ["H"], ["He", "Li", "Be", "B", "C", "N", "O", "F"], @@ -397,6 +416,7 @@ function decimalFormatGenerator(Decimal2) { ], ["Og"] ] + /* eslint-enable prettier/prettier */ }, getOffset(group) { if (group == 1) return 1; @@ -428,11 +448,20 @@ function decimalFormatGenerator(Decimal2) { getAbbreviationAndValue(x) { const abbreviationListUnfloored = x.log(118).toNumber(); const abbreviationListIndex = Math.floor(abbreviationListUnfloored) + 1; - const abbreviationLength = FORMATS2.elemental.abbreviationLength(abbreviationListIndex); + const abbreviationLength = FORMATS2.elemental.abbreviationLength( + abbreviationListIndex + ); const abbreviationProgress = abbreviationListUnfloored - abbreviationListIndex + 1; - const abbreviationIndex = Math.floor(abbreviationProgress * abbreviationLength); - const abbreviation = FORMATS2.elemental.getAbbreviation(abbreviationListIndex, abbreviationProgress); - const value = new Decimal2(118).pow(abbreviationListIndex + abbreviationIndex / abbreviationLength - 1); + const abbreviationIndex = Math.floor( + abbreviationProgress * abbreviationLength + ); + const abbreviation = FORMATS2.elemental.getAbbreviation( + abbreviationListIndex, + abbreviationProgress + ); + const value = new Decimal2(118).pow( + abbreviationListIndex + abbreviationIndex / abbreviationLength - 1 + ); return [abbreviation, value]; }, formatElementalPart(abbreviation, n) { @@ -442,7 +471,12 @@ function decimalFormatGenerator(Decimal2) { return `${n.toString()} ${abbreviation}`; }, format(value, acc = 2) { - if (value.gt(new Decimal2(118).pow(new Decimal2(118).pow(new Decimal2(118).pow(4))))) return "e" + FORMATS2.elemental.format(value.log10(), acc); + if (value.gt( + new Decimal2(118).pow( + new Decimal2(118).pow(new Decimal2(118).pow(4)) + ) + )) + return "e" + FORMATS2.elemental.format(value.log10(), acc); let log = value.log(118); const slog = log.log(118); const sslog = slog.log(118).toNumber(); @@ -455,7 +489,12 @@ function decimalFormatGenerator(Decimal2) { parts.unshift([abbreviation, n]); } if (parts.length >= max) { - return parts.map((x) => FORMATS2.elemental.formatElementalPart(x[0], x[1])).join(" + "); + return parts.map( + (x) => ( + // @ts-expect-error - x has both string and decimal for some reason + FORMATS2.elemental.formatElementalPart(x[0], x[1]) + ) + ).join(" + "); } const formattedMantissa = new Decimal2(118).pow(log).toFixed(parts.length === 1 ? 3 : acc); if (parts.length === 0) { @@ -517,7 +556,9 @@ function decimalFormatGenerator(Decimal2) { return (slog.gte(1e9) ? "" : Decimal2.dTen.pow(slog.sub(slog.floor())).toFixed(4)) + "F" + FORMATS2.eng.format(slog.floor(), 0); } const m = ex.div(new Decimal2(1e3).pow(e.div(3).floor())); - return (e.log10().gte(9) ? "" : m.toFixed(new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber())) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); + return (e.log10().gte(9) ? "" : m.toFixed( + new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber() + )) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); } } }, @@ -542,12 +583,25 @@ function decimalFormatGenerator(Decimal2) { }, /** Layer format */ layer: { - layers: ["infinity", "eternity", "reality", "equality", "affinity", "celerity", "identity", "vitality", "immunity", "atrocity"], + layers: [ + "infinity", + "eternity", + "reality", + "equality", + "affinity", + "celerity", + "identity", + "vitality", + "immunity", + "atrocity" + ], format(ex, acc = 2, max) { ex = new Decimal2(ex); const layer = ex.max(1).log10().max(1).log(INFINITY_NUM.log10()).floor(); if (layer.lte(0)) return format(ex, acc, max, "sc"); - ex = Decimal2.dTen.pow(ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0)); + ex = Decimal2.dTen.pow( + ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0) + ); const meta = layer.div(10).floor(); const layer_id = layer.toNumber() % 10 - 1; return format(ex, Math.max(4, acc), max, "sc") + " " + (meta.gte(1) ? "meta" + (meta.gte(2) ? "^" + format(meta, 0, max, "sc") : "") + "-" : "") + (isNaN(layer_id) ? "nanity" : FORMATS2.layer.layers[layer_id]); @@ -593,8 +647,10 @@ function decimalFormatGenerator(Decimal2) { meta++; } if (meta == 0) return format(ex, acc, max, "sc"); - if (ex.gte(3)) return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); - if (ex.gte(2)) return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); + if (ex.gte(3)) + return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); + if (ex.gte(2)) + return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); return symbols2[meta] + symbols[meta] + "-" + format(inf.pow(ex.sub(1)), acc, max, "sc"); } }, @@ -639,7 +695,10 @@ function decimalFormatGenerator(Decimal2) { } else { const trunc = numLetters.sub(abbStart).add(1); const truncExponent = exponent.div(Decimal2.pow(alphabetLength + 1, trunc.sub(1))).floor(); - const truncLetters = convertToLetters(truncExponent, new Decimal2(abbStart)); + const truncLetters = convertToLetters( + truncExponent, + new Decimal2(abbStart) + ); letters = `${truncLetters}(${trunc.gt("1e9") ? trunc.format() : trunc.format(0)})`; } return letters; @@ -661,7 +720,12 @@ function decimalFormatGenerator(Decimal2) { ex = new Decimal2(ex); start = new Decimal2(start).div(1e3); if (ex.lt(start.mul(1e3))) return format(ex, acc, max, type); - const letters = FORMATS2.alphabet.getAbbreviation(ex, start, startDouble, abbStart); + const letters = FORMATS2.alphabet.getAbbreviation( + ex, + start, + startDouble, + abbStart + ); const mantissa = ex.div(Decimal2.pow(1e3, ex.log(1e3).floor())); const isAbbreviation = letters.length > (abbStart ?? 9) + 2; return `${!isAbbreviation ? mantissa.toFixed(acc) + " " : ""}${letters}`; @@ -675,7 +739,9 @@ function decimalFormatGenerator(Decimal2) { return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUBSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); } function toSuperscript(value) { - return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); + return value.toFixed(0).split("").map( + (x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)] + ).join(""); } function formatST(ex, acc = 2, max = 9, type = "st") { return format(ex, acc, max, type); @@ -693,7 +759,9 @@ function decimalFormatGenerator(Decimal2) { case "scientific": { if (ex.log10().lt(Math.min(-acc, 0)) && acc > 1) { const e2 = ex.log10().ceil(); - const m = ex.div(e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2)); + const m = ex.div( + e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2) + ); const be = e2.mul(-1).max(1).log10().gte(9); return neg + (be ? "" : m.toFixed(2)) + "e" + format(e2, 0, max, "mixed_sc"); } else if (e.lt(max)) { @@ -713,13 +781,16 @@ function decimalFormatGenerator(Decimal2) { case "standard": { let e3 = ex.log(1e3).floor(); if (e3.lt(1)) { - return neg + ex.toFixed(Math.max(Math.min(acc - e.toNumber(), acc), 0)); + return neg + ex.toFixed( + Math.max(Math.min(acc - e.toNumber(), acc), 0) + ); } const e3_mul = e3.mul(3); const ee = e3.log10().floor(); if (ee.gte(3e3)) return "e" + format(e, acc, max, "st"); let final = ""; - if (e3.lt(4)) final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; + if (e3.lt(4)) + final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; else { let ee3 = Math.floor(e3.log(1e3).toNumber()); if (ee3 < 100) ee3 = Math.max(ee3 - 1, 0); @@ -729,8 +800,10 @@ function decimalFormatGenerator(Decimal2) { const mod1000 = e3.sub(div1000.mul(1e3)).floor().toNumber(); if (mod1000 > 0) { if (mod1000 == 1 && !ee3) final = "U"; - if (ee3) final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); - if (mod1000 > 1) final = FORMATS2.standard.tier1(mod1000) + final; + if (ee3) + final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); + if (mod1000 > 1) + final = FORMATS2.standard.tier1(mod1000) + final; } e3 = div1000; ee3++; @@ -741,7 +814,8 @@ function decimalFormatGenerator(Decimal2) { return neg + (ee.gte(10) ? "" : m.toFixed(fixedAmt) + " ") + final; } default: - if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); + if (!FORMATS2[type]) + console.error(`Invalid format type "`, type, `"`); return neg + FORMATS2[type].format(ex, acc, max); } } @@ -759,9 +833,12 @@ function decimalFormatGenerator(Decimal2) { } function formatTime(ex, acc = 2, type = "s") { ex = new Decimal2(ex); - if (ex.gte(86400)) return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); - if (ex.gte(3600) || type == "d") return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); - if (ex.gte(60) || type == "h") return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); + if (ex.gte(86400)) + return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); + if (ex.gte(3600) || type == "d") + return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); + if (ex.gte(60) || type == "h") + return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); return (ex.gte(10) || type != "m" ? "" : "0") + format(ex, acc, 12, "sc"); } function formatTimeLong(ex, ms = false, acc = 0, max = 9, type = "mixed_sc") { @@ -5095,7 +5172,7 @@ function inverseFunctionApprox(f, n, mode = "geometric", iterations = DEFAULT_IT } if (f(upperBound).lt(n)) { console.warn( - "The function is not monotonically increasing. (f(n) < n)" + "eMath.js: The function is not monotonically increasing. (f(n) < n)" ); return { value: upperBound, @@ -5189,7 +5266,7 @@ function calculateUpgrade(value, upgrade, start, end = Decimal.dInf, mode, itera end = new Decimal(end); const target = end.sub(start); if (target.lt(0)) { - console.warn("calculateUpgrade: Invalid target: ", target); + console.warn("eMath.js: Invalid target for calculateItem: ", target); return [Decimal.dZero, Decimal.dZero]; } el = (typeof upgrade.el === "function" ? upgrade.el() : upgrade.el) ?? el; @@ -5369,7 +5446,7 @@ function calculateItem(value, item, tier = Decimal.dOne, target = Decimal.dInf) tier = new Decimal(tier); target = new Decimal(target); if (target.lt(0)) { - console.warn("calculateItem: Invalid target: ", target); + console.warn("eMath.js: Invalid target for calculateItem: ", target); return [Decimal.dZero, Decimal.dZero]; } if (target.eq(1)) { @@ -5659,6 +5736,7 @@ var CurrencyStatic = class { this.pointerAddUpgrade(upgrade); const addedUpgradeStatic = new UpgradeStatic( upgrade, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion () => this.pointerGetUpgrade(upgrade.id), () => this ); @@ -5718,7 +5796,7 @@ var CurrencyStatic = class { calculateUpgrade(id, target = Infinity, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return [Decimal.dZero, Decimal.dZero]; } target = upgrade.level.add(target); @@ -5749,7 +5827,7 @@ var CurrencyStatic = class { getNextCost(id, target = 1, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return Decimal.dZero; } const amount = this.calculateUpgrade(id, target, mode, iterations)[0]; @@ -5772,7 +5850,7 @@ var CurrencyStatic = class { getNextCostMax(id, target = 1, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return Decimal.dZero; } const upgCalc = this.calculateUpgrade(id, target, mode, iterations); @@ -5793,7 +5871,7 @@ var CurrencyStatic = class { buyUpgrade(id, target, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return false; } const [amount, cost] = this.calculateUpgrade( @@ -5839,6 +5917,7 @@ var CurrencyStatic = class { this.pointerAddItem(item); const addedUpgradeStatic = new Item( item, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion () => this.pointerGetItem(item.id), () => this ); @@ -5865,7 +5944,7 @@ var CurrencyStatic = class { calculateItem(id, tier, target) { const item = this.getItem(id); if (item === null) { - console.warn(`Item "${id}" not found.`); + console.warn(`eMath.js: Item "${id}" not found.`); return [Decimal.dZero, Decimal.dZero]; } return calculateItem(this.value, item, tier, target); @@ -5880,7 +5959,7 @@ var CurrencyStatic = class { buyItem(id, tier, target) { const item = this.getItem(id); if (item === null) { - console.warn(`Item "${id}" not found.`); + console.warn(`eMath.js: Item "${id}" not found.`); return false; } const [amount, cost] = this.calculateItem(id, tier, target); @@ -5933,7 +6012,7 @@ var AttributeStatic = class { */ update() { console.warn( - "AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed." + "eMath.js: AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed." ); if (this.boost) { this.pointer.value = this.boost.calculate(); @@ -6520,7 +6599,9 @@ var E = (() => { let shownWarning = false; const out = (x) => { if (!shownWarning) { - console.warn("The E function is deprecated. Use the Decimal class directly."); + console.warn( + "eMath.js: The E function is deprecated. Use the Decimal class directly." + ); shownWarning = true; } return new Decimal(x); diff --git a/dist/main/eMath.min.js b/dist/main/eMath.min.js index a83a5ca..8547f2c 100644 --- a/dist/main/eMath.min.js +++ b/dist/main/eMath.min.js @@ -1,4 +1,4 @@ -"use strict";(function(yt,st){var Ot=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],st);else if(typeof module=="object"&&module.exports)module.exports=st();else{var ot=st(),Tt=Ot?exports:yt;for(var wt in ot)Tt[wt]=ot[wt]}})(typeof self<"u"?self:exports,()=>{var yt={},st={exports:yt},Ot=Object.create,ot=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,wt=Object.getOwnPropertyNames,_e=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty,Se=(t,e)=>function(){return e||(0,t[wt(t)[0]])((e={exports:{}}).exports,e),e.exports},Xt=(t,e)=>{for(var r in e)ot(t,r,{get:e[r],enumerable:!0})},Qt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of wt(e))!Ie.call(t,s)&&s!==r&&ot(t,s,{get:()=>e[s],enumerable:!(i=Tt(e,s))||i.enumerable});return t},mt=(t,e,r)=>(r=t!=null?Ot(_e(t)):{},Qt(e||!t||!t.__esModule?ot(r,"default",{value:t,enumerable:!0}):r,t)),Oe=t=>Qt(ot({},"__esModule",{value:!0}),t),K=(t,e,r,i)=>{for(var s=i>1?void 0:i?Tt(e,r):e,a=t.length-1,u;a>=0;a--)(u=t[a])&&(s=(i?u(e,r,s):u(s))||s);return i&&s&&ot(e,r,s),s},gt=Se({"node_modules/reflect-metadata/Reflect.js"(){var t;(function(e){(function(r){var i=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:g(),s=a(e);typeof i.Reflect<"u"&&(s=a(i.Reflect,s)),r(s,i),typeof i.Reflect>"u"&&(i.Reflect=e);function a(d,I){return function(E,x){Object.defineProperty(d,E,{configurable:!0,writable:!0,value:x}),I&&I(E,x)}}function u(){try{return Function("return this;")()}catch{}}function c(){try{return(0,eval)("(function() { return this; })()")}catch{}}function g(){return u()||c()}})(function(r,i){var s=Object.prototype.hasOwnProperty,a=typeof Symbol=="function",u=a&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",c=a&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",g=typeof Object.create=="function",d={__proto__:[]}instanceof Array,I=!g&&!d,E={create:g?function(){return Dt(Object.create(null))}:d?function(){return Dt({__proto__:null})}:function(){return Dt({})},has:I?function(l,h){return s.call(l,h)}:function(l,h){return h in l},get:I?function(l,h){return s.call(l,h)?l[h]:void 0}:function(l,h){return l[h]}},x=Object.getPrototypeOf(Function),q=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:ur(),j=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:lr(),w=typeof WeakMap=="function"?WeakMap:hr(),k=a?Symbol.for("@reflect-metadata:registry"):void 0,U=sr(),H=ar(U);function o(l,h,m,y){if(L(m)){if(!ge(l))throw new TypeError;if(!de(h))throw new TypeError;return Q(l,h)}else{if(!ge(l))throw new TypeError;if(!Y(h))throw new TypeError;if(!Y(y)&&!L(y)&&!Nt(y))throw new TypeError;return Nt(y)&&(y=void 0),m=at(m),it(l,h,m,y)}}r("decorate",o);function N(l,h){function m(y,P){if(!Y(y))throw new TypeError;if(!L(P)&&!ir(P))throw new TypeError;Ct(l,h,y,P)}return m}r("metadata",N);function p(l,h,m,y){if(!Y(m))throw new TypeError;return L(y)||(y=at(y)),Ct(l,h,m,y)}r("defineMetadata",p);function v(l,h,m){if(!Y(h))throw new TypeError;return L(m)||(m=at(m)),X(l,h,m)}r("hasMetadata",v);function S(l,h,m){if(!Y(h))throw new TypeError;return L(m)||(m=at(m)),tt(l,h,m)}r("hasOwnMetadata",S);function F(l,h,m){if(!Y(h))throw new TypeError;return L(m)||(m=at(m)),et(l,h,m)}r("getMetadata",F);function O(l,h,m){if(!Y(h))throw new TypeError;return L(m)||(m=at(m)),ft(l,h,m)}r("getOwnMetadata",O);function R(l,h){if(!Y(l))throw new TypeError;return L(h)||(h=at(h)),At(l,h)}r("getMetadataKeys",R);function V(l,h){if(!Y(l))throw new TypeError;return L(h)||(h=at(h)),Pt(l,h)}r("getOwnMetadataKeys",V);function z(l,h,m){if(!Y(h))throw new TypeError;if(L(m)||(m=at(m)),!Y(h))throw new TypeError;L(m)||(m=at(m));var y=St(h,m,!1);return L(y)?!1:y.OrdinaryDeleteMetadata(l,h,m)}r("deleteMetadata",z);function Q(l,h){for(var m=l.length-1;m>=0;--m){var y=l[m],P=y(h);if(!L(P)&&!Nt(P)){if(!de(P))throw new TypeError;h=P}}return h}function it(l,h,m,y){for(var P=l.length-1;P>=0;--P){var B=l[P],W=B(h,m,y);if(!L(W)&&!Nt(W)){if(!Y(W))throw new TypeError;y=W}}return y}function X(l,h,m){var y=tt(l,h,m);if(y)return!0;var P=Bt(h);return Nt(P)?!1:X(l,P,m)}function tt(l,h,m){var y=St(h,m,!1);return L(y)?!1:me(y.OrdinaryHasOwnMetadata(l,h,m))}function et(l,h,m){var y=tt(l,h,m);if(y)return ft(l,h,m);var P=Bt(h);if(!Nt(P))return et(l,P,m)}function ft(l,h,m){var y=St(h,m,!1);if(!L(y))return y.OrdinaryGetOwnMetadata(l,h,m)}function Ct(l,h,m,y){var P=St(m,y,!0);P.OrdinaryDefineOwnMetadata(l,h,m,y)}function At(l,h){var m=Pt(l,h),y=Bt(l);if(y===null)return m;var P=At(y,h);if(P.length<=0)return m;if(m.length<=0)return P;for(var B=new j,W=[],$=0,M=m;$=0&&M=this._keys.length?(this._index=-1,this._keys=h,this._values=h):this._index++,{value:_,done:!1}}return{value:void 0,done:!0}},$.prototype.throw=function(M){throw this._index>=0&&(this._index=-1,this._keys=h,this._values=h),M},$.prototype.return=function(M){return this._index>=0&&(this._index=-1,this._keys=h,this._values=h),{value:M,done:!0}},$}(),y=function(){function $(){this._keys=[],this._values=[],this._cacheKey=l,this._cacheIndex=-2}return Object.defineProperty($.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),$.prototype.has=function(M){return this._find(M,!1)>=0},$.prototype.get=function(M){var _=this._find(M,!1);return _>=0?this._values[_]:void 0},$.prototype.set=function(M,_){var T=this._find(M,!0);return this._values[T]=_,this},$.prototype.delete=function(M){var _=this._find(M,!1);if(_>=0){for(var T=this._keys.length,C=_+1;CQe}),st.exports=Oe(Jt);var mr=mt(gt()),Kt={};Xt(Kt,{Attribute:()=>zt,AttributeStatic:()=>We,Boost:()=>Vt,BoostObject:()=>pt,Currency:()=>It,CurrencyStatic:()=>He,DEFAULT_ITERATIONS:()=>Et,Decimal:()=>n,E:()=>Xe,FORMATS:()=>Ze,FormatTypeList:()=>Fe,Grid:()=>Zt,GridCell:()=>Ft,GridCellCollection:()=>J,Item:()=>he,ItemData:()=>_t,LRUCache:()=>qt,ListNode:()=>te,ST_NAMES:()=>ut,UpgradeData:()=>Mt,UpgradeStatic:()=>ue,calculateItem:()=>le,calculateSum:()=>jt,calculateSumApprox:()=>se,calculateSumLoop:()=>ne,calculateUpgrade:()=>ae,decimalToJSONString:()=>oe,equalsTolerance:()=>Gt,formats:()=>ht,inverseFunctionApprox:()=>Rt,roundingBase:()=>Be,upgradeToCacheNameEL:()=>De});var gr=mt(gt()),qt=class{constructor(t){this.map=new Map,this.first=void 0,this.last=void 0,this.maxSize=t}get size(){return this.map.size}get(t){let e=this.map.get(t);if(e!==void 0)return e!==this.first&&(e===this.last?(this.last=e.prev,this.last.next=void 0):(e.prev.next=e.next,e.next.prev=e.prev),e.next=this.first,this.first.prev=e,this.first=e),e.value}set(t,e){if(this.maxSize<1)return;if(this.map.has(t))throw new Error("Cannot update existing keys in the cache");let r=new te(t,e);for(this.first===void 0?(this.first=r,this.last=r):(r.next=this.first,this.first.prev=r,this.first=r),this.map.set(t,r);this.map.size>this.maxSize;){let i=this.last;this.map.delete(i.key),this.last=i.prev,this.last.next=void 0}}},te=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},rt;(function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(rt||(rt={}));var Te=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},t.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.findTransformMetadatas=function(e,r,i){return this.findMetadatas(this._transformMetadatas,e,r).filter(function(s){return!s.options||s.options.toClassOnly===!0&&s.options.toPlainOnly===!0?!0:s.options.toClassOnly===!0?i===rt.CLASS_TO_CLASS||i===rt.PLAIN_TO_CLASS:s.options.toPlainOnly===!0?i===rt.CLASS_TO_PLAIN:!0})},t.prototype.findExcludeMetadata=function(e,r){return this.findMetadata(this._excludeMetadatas,e,r)},t.prototype.findExposeMetadata=function(e,r){return this.findMetadata(this._exposeMetadatas,e,r)},t.prototype.findExposeMetadataByCustomName=function(e,r){return this.getExposedMetadatas(e).find(function(i){return i.options&&i.options.name===r})},t.prototype.findTypeMetadata=function(e,r){return this.findMetadata(this._typeMetadatas,e,r)},t.prototype.getStrategy=function(e){var r=this._excludeMetadatas.get(e),i=r&&r.get(void 0),s=this._exposeMetadatas.get(e),a=s&&s.get(void 0);return i&&a||!i&&!a?"none":i?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},t.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},t.prototype.getExposedProperties=function(e,r){return this.getExposedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===rt.CLASS_TO_CLASS||r===rt.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===rt.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.getExcludedProperties=function(e,r){return this.getExcludedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===rt.CLASS_TO_CLASS||r===rt.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===rt.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(e,r){var i=e.get(r),s;i&&(s=Array.from(i.values()).filter(function(E){return E.propertyName!==void 0}));for(var a=[],u=0,c=this.getAncestors(r);uNumber.MAX_SAFE_INTEGER)&&(v="\u03C9");let F=t.log(o,8e3).toNumber();if(p.equals(0))return v;if(p.gt(0)&&p.lte(3)){let V=[];for(let z=0;zNumber.MAX_SAFE_INTEGER)&&(v="\u03C9");let F=t.log(o,8e3).toNumber();if(p.equals(0))return v;if(p.gt(0)&&p.lte(2)){let V=[];for(let z=0;z118?e.elemental.beyondOg(S):e.elemental.config.element_lists[o-1][v]},beyondOg(o){let N=Math.floor(Math.log10(o)),p=["n","u","b","t","q","p","h","s","o","e"],v="";for(let S=N;S>=0;S--){let F=Math.floor(o/Math.pow(10,S))%10;v==""?v=p[F].toUpperCase():v+=p[F]}return v},abbreviationLength(o){return o==1?1:Math.pow(Math.floor(o/2)+1,2)*2},getAbbreviationAndValue(o){let N=o.log(118).toNumber(),p=Math.floor(N)+1,v=e.elemental.abbreviationLength(p),S=N-p+1,F=Math.floor(S*v),O=e.elemental.getAbbreviation(p,S),R=new t(118).pow(p+F/v-1);return[O,R]},formatElementalPart(o,N){return N.eq(1)?o:`${N.toString()} ${o}`},format(o,N=2){if(o.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(o.log10(),N);let p=o.log(118),S=p.log(118).log(118).toNumber(),F=Math.max(4-S*2,1),O=[];for(;p.gte(1)&&O.length=F)return O.map(V=>e.elemental.formatElementalPart(V[0],V[1])).join(" + ");let R=new t(118).pow(p).toFixed(O.length===1?3:N);return O.length===0?R:O.length===1?`${R} \xD7 ${e.elemental.formatElementalPart(O[0][0],O[0][1])}`:`${R} \xD7 (${O.map(V=>e.elemental.formatElementalPart(V[0],V[1])).join(" + ")})`}},old_sc:{format(o,N){o=new t(o);let p=o.log10().floor();if(p.lt(9))return p.lt(3)?o.toFixed(N):o.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(o.gte("eeee10")){let S=o.slog();return(S.gte(1e9)?"":t.dTen.pow(S.sub(S.floor())).toFixed(4))+"F"+e.old_sc.format(S.floor(),0)}let v=o.div(t.dTen.pow(p));return(p.log10().gte(9)?"":v.toFixed(4))+"e"+e.old_sc.format(p,0)}}},eng:{format(o,N=2){o=new t(o);let p=o.log10().floor();if(p.lt(9))return p.lt(3)?o.toFixed(N):o.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(o.gte("eeee10")){let S=o.slog();return(S.gte(1e9)?"":t.dTen.pow(S.sub(S.floor())).toFixed(4))+"F"+e.eng.format(S.floor(),0)}let v=o.div(new t(1e3).pow(p.div(3).floor()));return(p.log10().gte(9)?"":v.toFixed(new t(4).sub(p.sub(p.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(p.div(3).floor().mul(3),0)}}},mixed_sc:{format(o,N,p=9){o=new t(o);let v=o.log10().floor();return v.lt(303)&&v.gte(p)?g(o,N,p,"st"):g(o,N,p,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(o,N=2,p){o=new t(o);let v=o.max(1).log10().max(1).log(r.log10()).floor();if(v.lte(0))return g(o,N,p,"sc");o=t.dTen.pow(o.max(1).log10().div(r.log10().pow(v)).sub(v.gte(1)?1:0));let S=v.div(10).floor(),F=v.toNumber()%10-1;return g(o,Math.max(4,N),p,"sc")+" "+(S.gte(1)?"meta"+(S.gte(2)?"^"+g(S,0,p,"sc"):"")+"-":"")+(isNaN(F)?"nanity":e.layer.layers[F])}},standard:{tier1(o){return ut[0][0][o%10]+ut[0][1][Math.floor(o/10)%10]+ut[0][2][Math.floor(o/100)]},tier2(o){let N=o%10,p=Math.floor(o/10)%10,v=Math.floor(o/100)%10,S="";return o<10?ut[1][0][o]:(p==1&&N==0?S+="Vec":S+=ut[1][1][N]+ut[1][2][p],S+=ut[1][3][v],S)}},inf:{format(o,N,p){o=new t(o);let v=0,S=new t(Number.MAX_VALUE),F=["","\u221E","\u03A9","\u03A8","\u028A"],O=["","","m","mm","mmm"];for(;o.gte(S);)o=o.log(S),v++;return v==0?g(o,N,p,"sc"):o.gte(3)?O[v]+F[v]+"\u03C9^"+g(o.sub(1),N,p,"sc"):o.gte(2)?O[v]+"\u03C9"+F[v]+"-"+g(S.pow(o.sub(2)),N,p,"sc"):O[v]+F[v]+"-"+g(S.pow(o.sub(1)),N,p,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(o,N=new t(1e15),p=!1,v=9){if(o=new t(o),N=new t(N).div(1e3),o.lt(N.mul(1e3)))return"";let{alphabet:S}=e.alphabet.config,F=S.length,O=o.log(1e3).sub(N.log(1e3)).floor(),R=O.add(1).log(F+1).ceil(),V="",z=(Q,it)=>{let X=Q,tt="";for(let et=0;et=F)return"\u03C9";tt=S[ft]+tt,X=X.sub(1).div(F).floor()}return tt};if(R.lt(v))V=z(O,R);else{let Q=R.sub(v).add(1),it=O.div(t.pow(F+1,Q.sub(1))).floor();V=`${z(it,new t(v))}(${Q.gt("1e9")?Q.format():Q.format(0)})`}return V},format(o,N=2,p=9,v="mixed_sc",S=new t(1e15),F=!1,O){if(o=new t(o),S=new t(S).div(1e3),o.lt(S.mul(1e3)))return g(o,N,p,v);let R=e.alphabet.getAbbreviation(o,S,F,O),V=o.div(t.pow(1e3,o.log(1e3).floor()));return`${R.length>(O??9)+2?"":V.toFixed(N)+" "}${R}`}}},r=t.dTwo.pow(1024),i="\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089",s="\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079";function a(o){return o.toFixed(0).split("").map(N=>N==="-"?"\u208B":i[parseInt(N,10)]).join("")}function u(o){return o.toFixed(0).split("").map(N=>N==="-"?"\u208B":s[parseInt(N,10)]).join("")}function c(o,N=2,p=9,v="st"){return g(o,N,p,v)}function g(o,N=2,p=9,v="mixed_sc"){o=new t(o);let S=o.lt(0)?"-":"";if(o.mag==1/0)return S+"Infinity";if(Number.isNaN(o.mag))return S+"NaN";if(o.lt(0)&&(o=o.mul(-1)),o.eq(0))return o.toFixed(N);let F=o.log10().floor();switch(v){case"sc":case"scientific":if(o.log10().lt(Math.min(-N,0))&&N>1){let O=o.log10().ceil(),R=o.div(O.eq(-1)?new t(.1):t.dTen.pow(O)),V=O.mul(-1).max(1).log10().gte(9);return S+(V?"":R.toFixed(2))+"e"+g(O,0,p,"mixed_sc")}else if(F.lt(p)){let O=Math.max(Math.min(N-F.toNumber(),N),0);return S+(O>0?o.toFixed(O):o.toFixed(O).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(o.gte("eeee10")){let V=o.slog();return(V.gte(1e9)?"":t.dTen.pow(V.sub(V.floor())).toFixed(2))+"F"+g(V.floor(),0)}let O=o.div(t.dTen.pow(F)),R=F.log10().gte(9);return S+(R?"":O.toFixed(2))+"e"+g(F,0,p,"mixed_sc")}case"st":case"standard":{let O=o.log(1e3).floor();if(O.lt(1))return S+o.toFixed(Math.max(Math.min(N-F.toNumber(),N),0));let R=O.mul(3),V=O.log10().floor();if(V.gte(3e3))return"e"+g(F,N,p,"st");let z="";if(O.lt(4))z=["","K","M","B"][Math.round(O.toNumber())];else{let X=Math.floor(O.log(1e3).toNumber());for(X<100&&(X=Math.max(X-1,0)),O=O.sub(1).div(t.dTen.pow(X*3));O.gt(0);){let tt=O.div(1e3).floor(),et=O.sub(tt.mul(1e3)).floor().toNumber();et>0&&(et==1&&!X&&(z="U"),X&&(z=e.standard.tier2(X)+(z?"-"+z:"")),et>1&&(z=e.standard.tier1(et)+z)),O=tt,X++}}let Q=o.div(t.dTen.pow(R)),it=N===2?t.dTwo.sub(F.sub(R)).add(1).toNumber():N;return S+(V.gte(10)?"":Q.toFixed(it)+" ")+z}default:return e[v]||console.error('Invalid format type "',v,'"'),S+e[v].format(o,N,p)}}function d(o,N,p="mixed_sc",v,S){o=new t(o),N=new t(N);let F=o.add(N),O,R=F.div(o);return R.gte(10)&&o.gte(1e100)?(R=R.log10().mul(20),O="(+"+g(R,v,S,p)+" OoMs/sec)"):O="(+"+g(N,v,S,p)+"/sec)",O}function I(o,N=2,p="s"){return o=new t(o),o.gte(86400)?g(o.div(86400).floor(),0,12,"sc")+":"+I(o.mod(86400),N,"d"):o.gte(3600)||p=="d"?(o.div(3600).gte(10)||p!="d"?"":"0")+g(o.div(3600).floor(),0,12,"sc")+":"+I(o.mod(3600),N,"h"):o.gte(60)||p=="h"?(o.div(60).gte(10)||p!="h"?"":"0")+g(o.div(60).floor(),0,12,"sc")+":"+I(o.mod(60),N,"m"):(o.gte(10)||p!="m"?"":"0")+g(o,N,12,"sc")}function E(o,N=!1,p=0,v=9,S="mixed_sc"){let F=Pt=>g(Pt,p,v,S);o=new t(o);let O=o.mul(1e3).mod(1e3).floor(),R=o.mod(60).floor(),V=o.div(60).mod(60).floor(),z=o.div(3600).mod(24).floor(),Q=o.div(86400).mod(365.2425).floor(),it=o.div(31556952).floor(),X=it.eq(1)?" year":" years",tt=Q.eq(1)?" day":" days",et=z.eq(1)?" hour":" hours",ft=V.eq(1)?" minute":" minutes",Ct=R.eq(1)?" second":" seconds",At=O.eq(1)?" millisecond":" milliseconds";return`${it.gt(0)?F(it)+X+", ":""}${Q.gt(0)?F(Q)+tt+", ":""}${z.gt(0)?F(z)+et+", ":""}${V.gt(0)?F(V)+ft+", ":""}${R.gt(0)?F(R)+Ct+",":""}${N&&O.gt(0)?" "+F(O)+At:""}`.replace(/,([^,]*)$/,"$1").trim()}function x(o){return o=new t(o),g(t.dOne.sub(o).mul(100))+"%"}function q(o){return o=new t(o),g(o.mul(100))+"%"}function j(o,N=2){return o=new t(o),o.gte(1)?"\xD7"+o.format(N):"/"+o.pow(-1).format(N)}function w(o,N,p=10){return t.gte(o,10)?t.pow(p,t.log(o,p).pow(N)):new t(o)}function k(o,N=0){o=new t(o);let p=(O=>O.map((R,V)=>({name:R.name,altName:R.altName,value:t.pow(1e3,new t(V).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"Decimal",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),v="",S=o.lte(0)?0:t.min(t.log(o,1e3).sub(1),p.length-1).floor().toNumber(),F=p[S];if(S===0)switch(N){case 1:v="";break;case 2:case 0:default:v=o.format();break}switch(N){case 1:v=F.name;break;case 2:v=o.divide(F.value).format();break;case 3:v=F.altName;break;case 0:default:v=`${o.divide(F.value).format()} ${F.name}`;break}return v}function U(o,N=!1){return`${k(o,2)} ${k(o,1)}eV${N?"/c^2":""}`}let H={...e,toSubscript:a,toSuperscript:u,formatST:c,format:g,formatGain:d,formatTime:I,formatTimeLong:E,formatReduction:x,formatPercent:q,formatMult:j,expMult:w,metric:k,ev:U};return{FORMATS:e,formats:H}}var Lt=17,Ae=9e15,Pe=Math.log10(9e15),qe=1/9e15,ke=308,Le=-324,ee=5,xe=1023,Ue=!0,Ve=!1,$e=function(){let t=[];for(let r=Le+1;r<=ke;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),ct=[2,Math.E,3,4,5,6,7,8,9,10],Ge=[[1,1.0891180521811203,1.1789767925673957,1.2701455431742086,1.3632090180450092,1.4587818160364217,1.5575237916251419,1.6601571006859253,1.767485818836978,1.8804192098842727,2],[1,1.1121114330934079,1.231038924931609,1.3583836963111375,1.4960519303993531,1.6463542337511945,1.8121385357018724,1.996971324618307,2.2053895545527546,2.4432574483385254,Math.E],[1,1.1187738849693603,1.2464963939368214,1.38527004705667,1.5376664685821402,1.7068895236551784,1.897001227148399,2.1132403089001035,2.362480153784171,2.6539010333870774,3],[1,1.1367350847096405,1.2889510672956703,1.4606478703324786,1.6570295196661111,1.8850062585672889,2.1539465047453485,2.476829779693097,2.872061932789197,3.3664204535587183,4],[1,1.1494592900767588,1.319708228183931,1.5166291280087583,1.748171114438024,2.0253263297298045,2.3636668498288547,2.7858359149579424,3.3257226212448145,4.035730287722532,5],[1,1.159225940787673,1.343712473580932,1.5611293155111927,1.8221199554561318,2.14183924486326,2.542468319282638,3.0574682501653316,3.7390572020926873,4.6719550537360774,6],[1,1.1670905356972596,1.3632807444991446,1.5979222279405536,1.8842640123816674,2.2416069644878687,2.69893426559423,3.3012632110403577,4.121250340630164,5.281493033448316,7],[1,1.1736630594087796,1.379783782386201,1.6292821855668218,1.9378971836180754,2.3289975651071977,2.8384347394720835,3.5232708454565906,4.478242031114584,5.868592169644505,8],[1,1.1793017514670474,1.394054150657457,1.65664127441059,1.985170999970283,2.4069682290577457,2.9647310119960752,3.7278665320924946,4.814462547283592,6.436522247411611,9],[1,1.1840100246247336,1.4061375836156955,1.6802272208863964,2.026757028388619,2.4770056063449646,3.080525271755482,3.9191964192627284,5.135152840833187,6.989961179534715,10]],Re=[[-1,-.9194161097107025,-.8335625019330468,-.7425599821143978,-.6466611521029437,-.5462617907227869,-.4419033816638769,-.3342645487554494,-.224140440909962,-.11241087890006762,0],[-1,-.90603157029014,-.80786507256596,-.7064666939634,-.60294836853664,-.49849837513117,-.39430303318768,-.29147201034755,-.19097820800866,-.09361896280296,0],[-1,-.9021579584316141,-.8005762598234203,-.6964780623319391,-.5911906810998454,-.486050182576545,-.3823089430815083,-.28106046722897615,-.1831906535795894,-.08935809204418144,0],[-1,-.8917227442365535,-.781258746326964,-.6705130326902455,-.5612813129406509,-.4551067709033134,-.35319256652135966,-.2563741554088552,-.1651412821106526,-.0796919581982668,0],[-1,-.8843387974366064,-.7678744063886243,-.6529563724510552,-.5415870994657841,-.4352842206588936,-.33504449124791424,-.24138853420685147,-.15445285440944467,-.07409659641336663,0],[-1,-.8786709358426346,-.7577735191184886,-.6399546189952064,-.527284921869926,-.4211627631006314,-.3223479611761232,-.23107655627789858,-.1472057700818259,-.07035171210706326,0],[-1,-.8740862815291583,-.7497032990976209,-.6297119746181752,-.5161838335958787,-.41036238255751956,-.31277212146489963,-.2233976621705518,-.1418697367979619,-.06762117662323441,0],[-1,-.8702632331800649,-.7430366914122081,-.6213373075161548,-.5072025698095242,-.40171437727184167,-.30517930701410456,-.21736343968190863,-.137710238299109,-.06550774483471955,0],[-1,-.8670016295947213,-.7373984232432306,-.6143173985094293,-.49973884395492807,-.394584953527678,-.2989649949848695,-.21245647317021688,-.13434688362382652,-.0638072667348083,0],[-1,-.8641642839543857,-.732534623168535,-.6083127477059322,-.4934049257184696,-.3885773075899922,-.29376029055315767,-.2083678561173622,-.13155653399373268,-.062401588652553186,0]],f=function(e){return n.fromValue_noAlloc(e)},A=function(t,e,r){return n.fromComponents(t,e,r)},b=function(e,r,i){return n.fromComponents_noNormalize(e,r,i)},lt=function(e,r){let i=r+1,s=Math.ceil(Math.log10(Math.abs(e))),a=Math.round(e*Math.pow(10,i-s))*Math.pow(10,s-i);return parseFloat(a.toFixed(Math.max(i-s,0)))},xt=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},je=function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;let e=1;for(;t<10;)e=e*t,++t;t-=1;let r=.9189385332046727;r=r+(t+.5)*Math.log(t),r=r-t;let i=t*t,s=t;return r=r+1/(12*s),s=s*i,r=r-1/(360*s),s=s*i,r=r+1/(1260*s),s=s*i,r=r-1/(1680*s),s=s*i,r=r+1/(1188*s),s=s*i,r=r-691/(360360*s),s=s*i,r=r+7/(1092*s),s=s*i,r=r-3617/(122400*s),Math.exp(r)/e},ze=.36787944117144233,re=.5671432904097838,Ut=function(t,e=1e-10,r=!0){let i,s;if(!Number.isFinite(t))return t;if(r){if(t===0)return t;if(t===1)return re;t<10?i=0:i=Math.log(t)-Math.log(Math.log(t))}else{if(t===0)return-1/0;t<=-.1?i=-2:i=Math.log(-t)-Math.log(-Math.log(-t))}for(let a=0;a<100;++a){if(s=(t*Math.exp(-i)+i*i)/(i+1),Math.abs(s-i).5?1:-1;if(Math.random()*20<1)return b(e,0,1);let r=Math.floor(Math.random()*(t+1)),i=r===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let s=Math.pow(10,i);return Math.random()>.9&&(s=Math.trunc(s)),A(e,r,s)}static affordGeometricSeries_core(t,e,r,i){let s=e.mul(r.pow(i));return n.floor(t.div(s).mul(r.sub(1)).add(1).log10().div(r.log10()))}static sumGeometricSeries_core(t,e,r,i){return e.mul(r.pow(i)).mul(n.sub(1,r.pow(t))).div(n.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let a=e.add(i.mul(r)).sub(r.div(2)),u=a.pow(2);return a.neg().add(u.add(r.mul(t).mul(2)).sqrt()).div(r).floor()}static sumArithmeticSeries_core(t,e,r,i){let s=e.add(i.mul(r));return t.div(2).mul(s.mul(2).plus(t.sub(1).mul(r)))}static efficiencyOfPurchase_core(t,e,r){return t.div(e).add(t.div(r))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0||this.mag===Number.NEGATIVE_INFINITY&&this.layer>0&&Number.isFinite(this.layer))return this.sign=0,this.mag=0,this.layer=0,this;if(this.layer===0&&this.mag<0&&(this.mag=-this.mag,this.sign=-this.sign),this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_INFINITY)return this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY,this;if(this.layer===0&&this.mag=Ae)return this.layer+=1,this.mag=e*Math.log10(t),this;for(;t0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=e*Math.pow(10,t),t=Math.abs(this.mag),e=Math.sign(this.mag));return this.layer===0&&(this.mag<0?(this.mag=-this.mag,this.sign=-this.sign):this.mag===0&&(this.sign=0)),(Number.isNaN(this.sign)||Number.isNaN(this.layer)||Number.isNaN(this.mag))&&(this.sign=Number.NaN,this.layer=Number.NaN,this.mag=Number.NaN),this}fromComponents(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this.normalize(),this}fromComponents_noNormalize(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this}fromMantissaExponent(t,e){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=e+Math.log10(t),this.normalize(),this}fromMantissaExponent_noNormalize(t,e){return this.fromMantissaExponent(t,e),this}fromDecimal(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this}fromNumber(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this}fromString(t,e=!1){let r=t,i=n.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);Ue?t=t.replace(",",""):Ve&&(t=t.replace(",","."));let s=t.split("^^^");if(s.length===2){let w=parseFloat(s[0]),k=parseFloat(s[1]),U=s[1].split(";"),H=1;if(U.length===2&&(H=parseFloat(U[1]),isFinite(H)||(H=1)),isFinite(w)&&isFinite(k)){let o=n.pentate(w,k,H,e);return this.sign=o.sign,this.layer=o.layer,this.mag=o.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}}let a=t.split("^^");if(a.length===2){let w=parseFloat(a[0]),k=parseFloat(a[1]),U=a[1].split(";"),H=1;if(U.length===2&&(H=parseFloat(U[1]),isFinite(H)||(H=1)),isFinite(w)&&isFinite(k)){let o=n.tetrate(w,k,H,e);return this.sign=o.sign,this.layer=o.layer,this.mag=o.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}}let u=t.split("^");if(u.length===2){let w=parseFloat(u[0]),k=parseFloat(u[1]);if(isFinite(w)&&isFinite(k)){let U=n.pow(w,k);return this.sign=U.sign,this.layer=U.layer,this.mag=U.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}}t=t.trim().toLowerCase();let c,g,d=t.split("pt");if(d.length===2){c=10;let w=!1;d[0].startsWith("-")&&(w=!0,d[0]=d[0].slice(1)),g=parseFloat(d[0]),d[1]=d[1].replace("(",""),d[1]=d[1].replace(")","");let k=parseFloat(d[1]);if(isFinite(k)||(k=1),isFinite(c)&&isFinite(g)){let U=n.tetrate(c,g,k,e);return this.sign=U.sign,this.layer=U.layer,this.mag=U.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),w&&(this.sign*=-1),this}}if(d=t.split("p"),d.length===2){c=10;let w=!1;d[0].startsWith("-")&&(w=!0,d[0]=d[0].slice(1)),g=parseFloat(d[0]),d[1]=d[1].replace("(",""),d[1]=d[1].replace(")","");let k=parseFloat(d[1]);if(isFinite(k)||(k=1),isFinite(c)&&isFinite(g)){let U=n.tetrate(c,g,k,e);return this.sign=U.sign,this.layer=U.layer,this.mag=U.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),w&&(this.sign*=-1),this}}if(d=t.split("f"),d.length===2){c=10;let w=!1;d[0].startsWith("-")&&(w=!0,d[0]=d[0].slice(1)),d[0]=d[0].replace("(",""),d[0]=d[0].replace(")","");let k=parseFloat(d[0]);if(d[1]=d[1].replace("(",""),d[1]=d[1].replace(")",""),g=parseFloat(d[1]),isFinite(k)||(k=1),isFinite(c)&&isFinite(g)){let U=n.tetrate(c,g,k,e);return this.sign=U.sign,this.layer=U.layer,this.mag=U.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),w&&(this.sign*=-1),this}}let I=t.split("e"),E=I.length-1;if(E===0){let w=parseFloat(t);if(isFinite(w))return this.fromNumber(w),n.fromStringCache.size>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}else if(E===1){let w=parseFloat(t);if(isFinite(w)&&w!==0)return this.fromNumber(w),n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}let x=t.split("e^");if(x.length===2){this.sign=1,x[0].startsWith("-")&&(this.sign=-1);let w="";for(let k=0;k=43&&U<=57||U===101)w+=x[1].charAt(k);else return this.layer=parseFloat(w),this.mag=parseFloat(x[1].substr(k+1)),this.normalize(),n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}}if(E<1)return this.sign=0,this.layer=0,this.mag=0,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this;let q=parseFloat(I[0]);if(q===0)return this.sign=0,this.layer=0,this.mag=0,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this;let j=parseFloat(I[I.length-1]);if(E>=2){let w=parseFloat(I[I.length-2]);isFinite(w)&&(j*=Math.sign(w),j+=xt(w))}if(!isFinite(q))this.sign=I[0]==="-"?-1:1,this.layer=E,this.mag=j;else if(E===1)this.sign=Math.sign(q),this.layer=1,this.mag=j+Math.log10(Math.abs(q));else if(this.sign=Math.sign(q),this.layer=E,E===2){let w=n.mul(A(1,2,j),f(q));return this.sign=w.sign,this.layer=w.layer,this.mag=w.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}else this.mag=j;return this.normalize(),n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}fromValue(t){return t instanceof n?this.fromDecimal(t):typeof t=="number"?this.fromNumber(t):typeof t=="string"?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===1?Number.POSITIVE_INFINITY:this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===-1?Number.NEGATIVE_INFINITY:Number.isFinite(this.layer)?this.layer===0?this.sign*this.mag:this.layer===1?this.sign*Math.pow(10,this.mag):this.mag>0?this.sign>0?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:0:Number.NaN}mantissaWithDecimalPlaces(t){return isNaN(this.m)?Number.NaN:this.m===0?0:lt(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:lt(this.mag,t)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY?this.sign===1?"Infinity":"-Infinity":this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toString():this.m+"e"+this.e:this.layer===1?this.m+"e"+this.e:this.layer<=ee?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(t){return this.layer===0?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)}toFixed(t){return this.layer===0?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)}toPrecision(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(t){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(t):lt(this.m,t)+"e"+lt(this.e,t):this.layer===1?lt(this.m,t)+"e"+lt(this.e,t):this.layer<=ee?(this.sign===-1?"-":"")+"e".repeat(this.layer)+lt(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+lt(this.mag,t)}abs(){return b(this.sign===0?0:1,this.layer,this.mag)}neg(){return b(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?b(0,0,0):this.layer===0?A(this.sign,0,Math.round(this.mag)):new n(this)}floor(){return this.mag<0?this.sign===-1?b(-1,0,1):b(0,0,0):this.sign===-1?this.neg().ceil().neg():this.layer===0?A(this.sign,0,Math.floor(this.mag)):new n(this)}ceil(){return this.mag<0?this.sign===1?b(1,0,1):b(0,0,0):this.sign===-1?this.neg().floor().neg():this.layer===0?A(this.sign,0,Math.ceil(this.mag)):new n(this)}trunc(){return this.mag<0?b(0,0,0):this.layer===0?A(this.sign,0,Math.trunc(this.mag)):new n(this)}add(t){let e=f(t);if(this.eq(n.dInf)&&e.eq(n.dNegInf)||this.eq(n.dNegInf)&&e.eq(n.dInf))return b(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new n(this);if(!Number.isFinite(e.layer))return new n(e);if(this.sign===0)return new n(e);if(e.sign===0)return new n(this);if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return b(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(n.cmpabs(this,e)>0?(r=new n(this),i=new n(e)):(r=new n(e),i=new n(this)),r.layer===0&&i.layer===0)return n.fromNumber(r.sign*r.mag+i.sign*i.mag);let s=r.layer*Math.sign(r.mag),a=i.layer*Math.sign(i.mag);if(s-a>=2)return r;if(s===0&&a===-1){if(Math.abs(i.mag-Math.log10(r.mag))>Lt)return r;{let u=Math.pow(10,Math.log10(r.mag)-i.mag),c=i.sign+r.sign*u;return A(Math.sign(c),1,i.mag+Math.log10(Math.abs(c)))}}if(s===1&&a===0){if(Math.abs(r.mag-Math.log10(i.mag))>Lt)return r;{let u=Math.pow(10,r.mag-Math.log10(i.mag)),c=i.sign+r.sign*u;return A(Math.sign(c),1,Math.log10(i.mag)+Math.log10(Math.abs(c)))}}if(Math.abs(r.mag-i.mag)>Lt)return r;{let u=Math.pow(10,r.mag-i.mag),c=i.sign+r.sign*u;return A(Math.sign(c),1,i.mag+Math.log10(Math.abs(c)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(f(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=f(t);if(this.eq(n.dInf)&&e.eq(n.dNegInf)||this.eq(n.dNegInf)&&e.eq(n.dInf))return b(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.mag==Number.POSITIVE_INFINITY&&e.eq(n.dZero)||this.eq(n.dZero)&&this.mag==Number.POSITIVE_INFINITY)return b(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new n(this);if(!Number.isFinite(e.layer))return new n(e);if(this.sign===0||e.sign===0)return b(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return b(this.sign*e.sign,0,1);let r,i;if(this.layer>e.layer||this.layer==e.layer&&Math.abs(this.mag)>Math.abs(e.mag)?(r=new n(this),i=new n(e)):(r=new n(e),i=new n(this)),r.layer===0&&i.layer===0)return n.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return A(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return A(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return A(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let s=A(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(A(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return A(r.sign*i.sign,s.layer+1,s.sign*s.mag)}if(r.layer===2&&i.layer===2){let s=A(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(A(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return A(r.sign*i.sign,s.layer+1,s.sign*s.mag)}throw Error("Bad arguments to mul: "+this+", "+t)}multiply(t){return this.mul(t)}times(t){return this.mul(t)}div(t){let e=f(t);return this.mul(e.recip())}divide(t){return this.div(t)}divideBy(t){return this.div(t)}dividedBy(t){return this.div(t)}recip(){return this.mag===0?b(Number.NaN,Number.NaN,Number.NaN):this.mag===Number.POSITIVE_INFINITY?b(0,0,0):this.layer===0?A(this.sign,0,1/this.mag):A(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=f(t).abs();if(e.eq(n.dZero))return b(0,0,0);let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new n(r%i):this.sub(e).eq(this)?b(0,0,0):e.sub(this).eq(e)?new n(this):this.sign==-1?this.abs().mod(e).neg():this.sub(this.div(e).floor().mul(e))}modulo(t){return this.mod(t)}modular(t){return this.mod(t)}cmp(t){let e=f(t);return this.sign>e.sign?1:this.sign0?this.layer:-this.layer,i=e.mag>0?e.layer:-e.layer;return r>i?1:re.mag?1:this.mag0?new n(e):new n(this)}clamp(t,e){return this.max(t).min(e)}clampMin(t){return this.max(t)}clampMax(t){return this.min(t)}cmp_tolerance(t,e){let r=f(t);return this.eq_tolerance(r,e)?0:this.cmp(r)}compare_tolerance(t,e){return this.cmp_tolerance(t,e)}eq_tolerance(t,e){let r=f(t);if(e==null&&(e=1e-7),this.sign!==r.sign||Math.abs(this.layer-r.layer)>1)return!1;let i=this.mag,s=r.mag;return this.layer>r.layer&&(s=xt(s)),this.layer0?A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):A(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?b(Number.NaN,Number.NaN,Number.NaN):this.layer>0?A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):A(this.sign,0,Math.log10(this.mag))}log(t){return t=f(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?b(Number.NaN,Number.NaN,Number.NaN):this.layer===0&&t.layer===0?A(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):n.div(this.log10(),t.log10())}log2(){return this.sign<=0?b(Number.NaN,Number.NaN,Number.NaN):this.layer===0?A(this.sign,0,Math.log2(this.mag)):this.layer===1?A(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?A(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?b(Number.NaN,Number.NaN,Number.NaN):this.layer===0?A(this.sign,0,Math.log(this.mag)):this.layer===1?A(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?A(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=f(t),r=new n(this),i=new n(e);if(r.sign===0)return i.eq(0)?b(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return b(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return r;let s=r.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?s.neg():Math.abs(i.toNumber()%2)%2===0?s:b(Number.NaN,Number.NaN,Number.NaN):s}pow10(){if(this.eq(n.dInf))return b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.eq(n.dNegInf))return b(0,0,0);if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return b(Number.NaN,Number.NaN,Number.NaN);let t=new n(this);if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return A(1,0,e);if(t.sign===0)return b(1,0,1);t=b(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?A(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?A(-t.sign,t.layer+1,-t.mag):b(1,0,1)}pow_base(t){return f(t).pow(this)}root(t){let e=f(t);return this.pow(e.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?n.exp(n.mul(this,n.ln(this).sub(1))):n.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(b(1,0,24)))return n.fromNumber(je(this.sign*this.mag));let t=this.mag-1,e=.9189385332046727;e=e+(t+.5)*Math.log(t),e=e-t;let r=t*t,i=t,s=12*i,a=1/s,u=e+a;if(u===e||(e=u,i=i*r,s=360*i,a=1/s,u=e-a,u===e))return n.exp(e);e=u,i=i*r,s=1260*i;let c=1/s;return e=e+c,i=i*r,s=1680*i,c=1/s,e=e-c,n.exp(e)}else return this.layer===1?n.exp(n.mul(this,n.ln(this).sub(1))):n.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?b(1,0,1):this.layer===0&&this.mag<=709.7?n.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?A(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?A(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):A(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return n.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return A(1,2,Math.log10(this.mag)-.3010299956639812);{let t=n.div(b(this.sign,this.layer-1,this.mag),b(1,0,2));return t.layer+=1,t.normalize(),t}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(t=2,e=b(1,0,1),r=!1){if(t===1)return n.pow(this,e);if(t===0)return new n(e);if(this.eq(n.dOne))return b(1,0,1);if(this.eq(-1))return n.pow(this,e);if(t===Number.POSITIVE_INFINITY){let a=this.toNumber();if(a<=1.444667861009766&&a>=.06598803584531254){let u=n.ln(this).neg(),c=u.lambertw().div(u);if(a<1)return c;let g=u.lambertw(!1).div(u);return a>1.444667861009099&&(c=g=n.fromNumber(Math.E)),e=f(e),e.eq(g)?g:e.lt(g)?c:b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}else return a>1.444667861009766?b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY):b(Number.NaN,Number.NaN,Number.NaN)}if(this.eq(n.dZero)){let a=Math.abs((t+1)%2);return a>1&&(a=2-a),n.fromNumber(a)}if(t<0)return n.iteratedlog(e,this,-t,r);e=new n(e);let i=t;t=Math.trunc(t);let s=i-t;if(this.gt(n.dZero)&&(this.lt(1)||this.lte(1.444667861009766)&&e.lte(n.ln(this).neg().lambertw(!1).div(n.ln(this).neg())))&&(i>1e4||!r)){let a=Math.min(1e4,t);e.eq(n.dOne)?e=this.pow(s):this.lt(1)?e=e.pow(1-s).mul(this.pow(e).pow(s)):e=e.layeradd(s,this);for(let u=0;u1e4&&Math.ceil(i)%2==1?this.pow(e):e}s!==0&&(e.eq(n.dOne)?this.gt(10)||r?e=this.pow(s):(e=n.fromNumber(n.tetrate_critical(this.toNumber(),s)),this.lt(2)&&(e=e.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?e=e.layeradd10(s,r):this.lt(1)?e=e.pow(1-s).mul(this.pow(e).pow(s)):e=e.layeradd(s,this,r));for(let a=0;a3)return b(e.sign,e.layer+(t-a-1),e.mag);if(a>1e4)return e}return e}iteratedexp(t=2,e=b(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return n.tetrate(t,-e,this,r);t=f(t);let i=n.fromDecimal(this),s=e;e=Math.trunc(e);let a=s-e;if(i.layer-t.layer>3){let u=Math.min(e,i.layer-t.layer-3);e-=u,i.layer-=u}for(let u=0;u1e4)return i}return a>0&&a<1&&(t.eq(10)?i=i.layeradd10(-a,r):i=i.layeradd(-a,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,s=!1,a=!1,u=this.slog_internal(t,r).toNumber();for(let c=1;c1&&a!=d&&(s=!0),a=d,s?i/=2:i*=2,i=Math.abs(i)*(d?-1:1),u+=i,i===0)break}return n.fromNumber(u)}slog_internal(t=10,e=!1){if(t=f(t),t.lte(n.dZero)||t.eq(n.dOne))return b(Number.NaN,Number.NaN,Number.NaN);if(t.lt(n.dOne))return this.eq(n.dOne)?b(0,0,0):this.eq(n.dZero)?b(-1,0,1):b(Number.NaN,Number.NaN,Number.NaN);if(this.mag<0||this.eq(n.dZero))return b(-1,0,1);if(t.lt(1.444667861009766)){let s=n.ln(t).neg(),a=s.lambertw().div(s);if(this.eq(a))return b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.gt(a))return b(Number.NaN,Number.NaN,Number.NaN)}let r=0,i=n.fromDecimal(this);if(i.layer-t.layer>3){let s=i.layer-t.layer-3;r+=s,i.layer-=s}for(let s=0;s<100;++s)if(i.lt(n.dZero))i=n.pow(t,i),r-=1;else{if(i.lte(n.dOne))return e?n.fromNumber(r+i.toNumber()-1):n.fromNumber(r+n.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=n.log(i,t)}return n.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:n.critical_section(t,e,Re)}static tetrate_critical(t,e){return n.critical_section(t,e,Ge)}static critical_section(t,e,r,i=!1){e*=10,e<0&&(e=0),e>10&&(e=10),t<2&&(t=2),t>10&&(t=10);let s=0,a=0;for(let c=0;ct){let g=(t-ct[c])/(ct[c+1]-ct[c]);s=r[c][Math.floor(e)]*(1-g)+r[c+1][Math.floor(e)]*g,a=r[c][Math.ceil(e)]*(1-g)+r[c+1][Math.ceil(e)]*g;break}let u=e-Math.floor(e);return s<=0||a<=0?s*(1-u)+a*u:Math.pow(t,Math.log(s)/Math.log(t)*(1-u)+Math.log(a)/Math.log(t)*u)}layeradd10(t,e=!1){t=n.fromValue_noAlloc(t).toNumber();let r=n.fromDecimal(this);if(t>=1){r.mag<0&&r.layer>0?(r.sign=0,r.mag=0,r.layer=0):r.sign===-1&&r.layer==0&&(r.sign=1,r.mag=-r.mag);let i=Math.trunc(t);t-=i,r.layer+=i}if(t<=-1){let i=Math.trunc(t);if(t-=i,r.layer+=i,r.layer<0)for(let s=0;s<100;++s){if(r.layer++,r.mag=Math.log10(r.mag),!isFinite(r.mag))return r.sign===0&&(r.sign=1),r.layer<0&&(r.layer=0),r.normalize();if(r.layer>=0)break}}for(;r.layer<0;)r.layer++,r.mag=Math.log10(r.mag);return r.sign===0&&(r.sign=1,r.mag===0&&r.layer>=1&&(r.layer-=1,r.mag=1)),r.normalize(),t!==0?r.layeradd(t,10,e):r}layeradd(t,e,r=!1){let i=f(e);if(i.gt(1)&&i.lte(1.444667861009766)){let u=n.excess_slog(this,e,r),c=u[0].toNumber(),g=u[1],d=c+t,I=n.ln(e).neg(),E=I.lambertw().div(I),x=I.lambertw(!1).div(I),q=n.dOne;g==1?q=E.mul(x).sqrt():g==2&&(q=x.mul(2));let j=i.pow(q),w=Math.floor(d),k=d-w,U=q.pow(1-k).mul(j.pow(k));return n.tetrate(i,w,U,r)}let a=this.slog(e,100,r).toNumber()+t;return a>=0?n.tetrate(e,a,n.dOne,r):Number.isFinite(a)?a>=-1?n.log(n.tetrate(e,a+1,n.dOne,r),e):n.log(n.log(n.tetrate(e,a+2,n.dOne,r),e),e):b(Number.NaN,Number.NaN,Number.NaN)}static excess_slog(t,e,r=!1){t=f(t),e=f(e);let i=e;if(e=e.toNumber(),e==1||e<=0)return[b(Number.NaN,Number.NaN,Number.NaN),0];if(e>1.444667861009766)return[t.slog(e,100,r),0];let s=n.ln(e).neg(),a=s.lambertw().div(s),u=n.dInf;if(e>1&&(u=s.lambertw(!1).div(s)),e>1.444667861009099&&(a=u=n.fromNumber(Math.E)),t.lt(a))return[t.slog(e,100,r),0];if(t.eq(a))return[b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),0];if(t.eq(u))return[b(1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),2];if(t.gt(u)){let c=u.mul(2),g=i.pow(c),d=0;if(t.gte(c)&&t.lt(g))d=0;else if(t.gte(g)){let w=g;for(d=1;w.lt(t);)if(w=i.pow(w),d=d+1,w.layer>3){let k=Math.floor(t.layer-w.layer+1);w=i.iteratedexp(k,w,r),d=d+k}w.gt(t)&&(w=w.log(e),d=d-1)}else if(t.lt(c)){let w=c;for(d=0;w.gt(t);)w=w.log(e),d=d-1}let I=0,E=0,x=.5,q=c,j=n.dZero;for(;x>1e-16;){if(E=I+x,q=c.pow(1-E).mul(g.pow(E)),j=n.iteratedexp(e,d,q),j.eq(t))return[new n(d+E),2];j.lt(t)&&(I+=x),x/=2}return j.neq_tolerance(t,1e-7)?[b(Number.NaN,Number.NaN,Number.NaN),0]:[new n(d+I),2]}if(t.lt(u)&&t.gt(a)){let c=a.mul(u).sqrt(),g=i.pow(c),d=0;if(t.lte(c)&&t.gt(g))d=0;else if(t.lte(g)){let w=g;for(d=1;w.gt(t);)w=i.pow(w),d=d+1;w.lt(t)&&(w=w.log(e),d=d-1)}else if(t.gt(c)){let w=c;for(d=0;w.lt(t);)w=w.log(e),d=d-1}let I=0,E=0,x=.5,q=c,j=n.dZero;for(;x>1e-16;){if(E=I+x,q=c.pow(1-E).mul(g.pow(E)),j=n.iteratedexp(e,d,q),j.eq(t))return[new n(d+E),1];j.gt(t)&&(I+=x),x/=2}return j.neq_tolerance(t,1e-7)?[b(Number.NaN,Number.NaN,Number.NaN),0]:[new n(d+I),1]}throw new Error("Unhandled behavior in excess_slog")}lambertw(t=!0){return this.lt(-.3678794411710499)?b(Number.NaN,Number.NaN,Number.NaN):t?this.abs().lt("1e-300")?new n(this):this.mag<0?n.fromNumber(Ut(this.toNumber())):this.layer===0?n.fromNumber(Ut(this.sign*this.mag)):this.lt("eee15")?ie(this):this.ln():this.sign===1?b(Number.NaN,Number.NaN,Number.NaN):this.layer===0?n.fromNumber(Ut(this.sign*this.mag,1e-10,!1)):this.layer==1?ie(this,1e-10,!1):this.neg().recip().lambertw().neg()}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(n.dInf))return b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(!this.isFinite())return b(Number.NaN,Number.NaN,Number.NaN);if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return n.fromNumber(t).add(2).pow(this.recip());if(t<=0)return b(Number.NaN,Number.NaN,Number.NaN);if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return eze?this.pow(this.recip()):b(Number.NaN,Number.NaN,Number.NaN)}if(this.eq(1))return b(1,0,1);if(this.lt(0))return b(Number.NaN,Number.NaN,Number.NaN);if(this.lte("1ee-16"))return t%2==1?new n(this):b(Number.NaN,Number.NaN,Number.NaN);if(this.gt(1)){let e=n.dTen;this.gte(n.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=n.dZero,i=e.layer,s=e.iteratedlog(10,i,!0),a=s,u=s.div(2),c=!0;for(;c;)u=r.add(s).div(2),n.iteratedexp(10,i,u,!0).tetrate(t,1,!0).gt(this)?s=u:r=u,u.eq(a)?c=!1:a=u;return n.iteratedexp(10,i,u,!0)}else{let e=1,r=A(1,10,1),i=A(1,10,1),s=A(1,10,1),a=A(1,1,-16),u=n.dZero,c=A(1,10,1),g=a.pow10().recip(),d=n.dZero,I=g,E=g,x=Math.ceil(t)%2==0,q=0,j=A(1,10,1),w=!1,k=n.dZero,U=!1;for(;e<4;){if(e==2){if(x)break;s=A(1,10,1),a=r,e=3,c=A(1,10,1),j=A(1,10,1)}for(w=!1;a.neq(s);){if(k=a,a.pow10().recip().tetrate(t,1,!0).eq(1)&&a.pow10().recip().lt(.4))g=a.pow10().recip(),I=a.pow10().recip(),E=a.pow10().recip(),d=n.dZero,q=-1,e==3&&(j=a);else if(a.pow10().recip().tetrate(t,1,!0).eq(a.pow10().recip())&&!x&&a.pow10().recip().lt(.4))g=a.pow10().recip(),I=a.pow10().recip(),E=a.pow10().recip(),d=n.dZero,q=0;else if(a.pow10().recip().tetrate(t,1,!0).eq(a.pow10().recip().mul(2).tetrate(t,1,!0)))g=a.pow10().recip(),I=n.dZero,E=g.mul(2),d=g,x?q=-1:q=0;else{for(u=a.mul(12e-17),g=a.pow10().recip(),I=a.add(u).pow10().recip(),d=g.sub(I),E=g.add(d);I.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||E.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||I.gte(g)||E.lte(g);)u=u.mul(2),I=a.add(u).pow10().recip(),d=g.sub(I),E=g.add(d);if((e==1&&E.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))&&I.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))||e==3&&E.tetrate(t,1,!0).lt(g.tetrate(t,1,!0))&&I.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))&&(j=a),E.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))q=-1;else if(x)q=1;else if(e==3&&a.gt_tolerance(r,1e-8))q=0;else{for(;I.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||E.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||I.gte(g)||E.lte(g);)u=u.mul(2),I=a.add(u).pow10().recip(),d=g.sub(I),E=g.add(d);E.tetrate(t,1,!0).sub(g.tetrate(t,1,!0)).lt(g.tetrate(t,1,!0).sub(I.tetrate(t,1,!0)))?q=0:q=1}}if(q==-1&&(U=!0),e==1&&q==1||e==3&&q!=0)if(s.eq(A(1,10,1)))a=a.mul(2);else{let p=!1;if(w&&(q==1&&e==1||q==-1&&e==3)&&(p=!0),a=a.add(s).div(2),p)break}else if(s.eq(A(1,10,1)))s=a,a=a.div(2);else{let p=!1;if(w&&(q==1&&e==1||q==-1&&e==3)&&(p=!0),s=s.sub(c),a=a.sub(c),p)break}if(s.sub(a).div(2).abs().gt(c.mul(1.5))&&(w=!0),c=s.sub(a).div(2).abs(),a.gt("1e18")||a.eq(k))break}if(a.gt("1e18")||!U||j==A(1,10,1))break;e==1?r=j:e==3&&(i=j),e++}s=r,a=A(1,1,-18);let H=a,o=n.dZero,N=!0;for(;N;)if(s.eq(A(1,10,1))?o=a.mul(2):o=s.add(a).div(2),n.pow(10,o).recip().tetrate(t,1,!0).gt(this)?a=o:s=o,o.eq(H)?N=!1:H=o,a.gt("1e18"))return b(Number.NaN,Number.NaN,Number.NaN);if(o.eq_tolerance(r,1e-15)){if(i.eq(A(1,10,1)))return b(Number.NaN,Number.NaN,Number.NaN);for(s=A(1,10,1),a=i,H=a,o=n.dZero,N=!0;N;)if(s.eq(A(1,10,1))?o=a.mul(2):o=s.add(a).div(2),n.pow(10,o).recip().tetrate(t,1,!0).gt(this)?a=o:s=o,o.eq(H)?N=!1:H=o,a.gt("1e18"))return b(Number.NaN,Number.NaN,Number.NaN);return o.pow10().recip()}else return o.pow10().recip()}}pentate(t=2,e=b(1,0,1),r=!1){e=new n(e);let i=t;t=Math.trunc(t);let s=i-t;s!==0&&(e.eq(n.dOne)?(++t,e=n.fromNumber(s)):this.eq(10)?e=e.layeradd10(s,r):e=e.layeradd(s,this,r));for(let a=0;a10)return e}return e}sin(){return this.mag<0?new n(this):this.layer===0?n.fromNumber(Math.sin(this.sign*this.mag)):b(0,0,0)}cos(){return this.mag<0?b(1,0,1):this.layer===0?n.fromNumber(Math.cos(this.sign*this.mag)):b(0,0,0)}tan(){return this.mag<0?new n(this):this.layer===0?n.fromNumber(Math.tan(this.sign*this.mag)):b(0,0,0)}asin(){return this.mag<0?new n(this):this.layer===0?n.fromNumber(Math.asin(this.sign*this.mag)):b(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?n.fromNumber(Math.acos(this.toNumber())):this.layer===0?n.fromNumber(Math.acos(this.sign*this.mag)):b(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?new n(this):this.layer===0?n.fromNumber(Math.atan(this.sign*this.mag)):n.fromNumber(Math.atan(this.sign*(1/0)))}sinh(){return this.exp().sub(this.negate().exp()).div(2)}cosh(){return this.exp().add(this.negate().exp()).div(2)}tanh(){return this.sinh().div(this.cosh())}asinh(){return n.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return n.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?b(Number.NaN,Number.NaN,Number.NaN):n.ln(this.add(1).div(n.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?new n(this):this.root(n.pow(10,t))}egg(){return this.add(9)}lessThanOrEqualTo(t){return this.cmp(t)<1}lessThan(t){return this.cmp(t)<0}greaterThanOrEqualTo(t){return this.cmp(t)>-1}greaterThan(t){return this.cmp(t)>0}static smoothDamp(t,e,r,i){return new n(t).add(new n(e).minus(new n(t)).times(new n(r)).times(new n(i)))}clone(){return this}static clone(t){return n.fromComponents(t.sign,t.layer,t.mag)}softcap(t,e,r){let i=this.clone();return i.gte(t)&&([0,"pow"].includes(r)&&(i=i.div(t).pow(e).mul(t)),[1,"mul"].includes(r)&&(i=i.sub(t).div(e).add(t))),i}static softcap(t,e,r,i){return new n(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new n(t),e=new n(e);let s=this.clone();return s.gte(t)&&([0,"pow"].includes(r)&&(s=i?s.mul(t.pow(e.sub(1))).root(e):s.pow(e).div(t.pow(e.sub(1)))),[1,"exp"].includes(r)&&(s=i?s.div(t).max(1).log(e).add(t):n.pow(e,s.sub(t)).mul(t))),s}static scale(t,e,r,i,s=!1){return new n(t).scale(e,r,i,s)}format(t=2,e=9,r="mixed_sc"){return ht.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return ht.format(new n(t),e,r,i)}formatST(t=2,e=9,r="st"){return ht.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return ht.format(new n(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return ht.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,s){return ht.formatGain(new n(t),e,r,i,s)}toRoman(t=5e3){t=new n(t);let e=this.clone();if(e.gte(t)||e.lt(1))return e;let r=e.toNumber(),i={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},s="";for(let a of Object.keys(i)){let u=Math.floor(r/i[a]);r-=u*i[a],s+=a.repeat(u)}return s}static toRoman(t,e){return new n(t).toRoman(e)}static random(t=0,e=1){return t=new n(t),e=new n(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new n(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new n(Math.random()).lt(t)}};n.dZero=b(0,0,0),n.dOne=b(1,0,1),n.dNegOne=b(-1,0,1),n.dTwo=b(1,0,2),n.dTen=b(1,0,10),n.dNaN=b(Number.NaN,Number.NaN,Number.NaN),n.dInf=b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),n.dNegInf=b(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),n.dNumberMax=A(1,0,Number.MAX_VALUE),n.dNumberMin=A(1,0,Number.MIN_VALUE),n.fromStringCache=new qt(xe),K([vt()],n.prototype,"sign",2),K([vt()],n.prototype,"mag",2),K([vt()],n.prototype,"layer",2),n=K([Ee()],n);var{formats:ht,FORMATS:Ze}=Ce(n);n.formats=ht;var pt=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.value=t.value,this.order=t.order??99,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>""}},Vt=class{constructor(t=1,e){this.addBoost=this.setBoost.bind(this),e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=new n(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new pt(r))})}getBoosts(t,e){let r=[],i=[];for(let s=0;sE),d=s,I=this.getBoosts(a,!0);I[0][0]?this.boostArray[I[1][0]]=new pt({id:a,name:u,description:c,value:g,order:d}):this.boostArray.push(new pt({id:a,name:u,description:c,value:g,order:d}))}else{t=Array.isArray(t)?t:[t];for(let a of t){let u=this.getBoosts(a.id,!0);u[0][0]?this.boostArray[u[1][0]]=new pt(a):this.boostArray.push(new pt(a))}}}clearBoosts(){this.boostArray.length=0}calculate(t=this.baseEffect){let e=new n(t),r=this.boostArray;r=r.sort((i,s)=>i.order-s.order);for(let i of r)e=i.value(e);return e}},dr=mt(gt()),Et=30,$t=.001;function Ye(t,e,r="geometric"){switch(t=new n(t),e=new n(e),r){case"arithmetic":case 1:return t.add(e).div(2);case"geometric":case 2:default:return t.mul(e).sqrt();case"harmonic":case 3:return n.dTwo.div(t.reciprocal().add(e.reciprocal()))}}function Gt(t,e,r,i){i=Object.assign({},{verbose:!1,mode:"geometric"},i),t=new n(t),e=new n(e),r=new n(r);let s,a;return i.mode==="geometric"?(s=t.sub(e).abs().div(t.abs().add(e.abs()).div(2)),a=s.lte(r)):(s=t.sub(e).abs(),a=s.lte(r)),(i.verbose===!0||i.verbose==="onlyOnFail"&&!a)&&console.log({a:t,b:e,tolerance:r,config:i,diff:s,result:a}),a}function Rt(t,e,r="geometric",i=Et,s=$t,a=1,u){if(a=new n(a),u=new n(u??e),a.gt(u)&&([a,u]=[u,a]),t(u).eq(0))return{value:n.dZero,lowerBound:n.dZero,upperBound:n.dZero};if(t(u).lt(e))return console.warn("The function is not monotonically increasing. (f(n) < n)"),{value:u,lowerBound:u,upperBound:u};for(let g=0;g=0;c--){let g=r.add(u.mul(c)),d=r.add(u.mul(c+1)),I=a;if(a=a.add(t(g).add(t(d)).div(2).mul(u)),Gt(I,a,s,{verbose:!1,mode:"geometric"}))break}return a}function jt(t,e,r=0,i,s){return r=new n(r),e=new n(e),e.sub(r).lte(Et)?ne(t,e,r,i):se(t,e,r,s)}function Be(t,e=10,r=0,i=1e3){if(t=new n(t),e=new n(e),r=new n(r),i=new n(i),e.lt(1)||r.lt(1))return n.dNaN;let s=t.sign;if(t=t.abs(),t.gte(n.pow(e,i)))return t;let a=n.floor(n.log(t,e)),u=t.div(n.pow(e,a));return u=u.mul(n.pow(e,r)).round(),u=u.div(n.pow(e,r)),u=u.mul(n.pow(e,a)).mul(s),u}function ae(t,e,r,i=n.dInf,s,a,u=!1){t=new n(t),r=new n(r??e.level),i=new n(i);let c=i.sub(r);if(c.lt(0))return console.warn("calculateUpgrade: Invalid target: ",c),[n.dZero,n.dZero];if(u=(typeof e.el=="function"?e.el():e.el)??u,c.eq(1)){let E=e.cost(e.level),x=t.gte(E),q=[n.dZero,n.dZero];return u?(q[0]=x?n.dOne:n.dZero,q):(q=[x?n.dOne:n.dZero,x?E:n.dZero],q)}if(e.costBulk){let[E,x]=e.costBulk(t,e.level,c),q=t.gte(x);return[q?E:n.dZero,q&&!u?x:n.dZero]}if(u){let E=j=>e.cost(j.add(r)),x=n.min(i,Rt(E,t,s,a).value.floor()),q=n.dZero;return[x,q]}let g=Rt(E=>jt(e.cost,E,r),t,s,a).value.floor().min(r.add(c).sub(1)),d=jt(e.cost,g,r);return[g.sub(r).add(1).max(0),d]}function oe(t){return t=new n(t),`${t.sign}/${t.mag}/${t.layer}`}function De(t){return`el/${oe(t)}`}var Mt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?new n(t.level):n.dOne}};K([vt()],Mt.prototype,"id",2),K([dt(()=>n)],Mt.prototype,"level",2);var ue=class Me{static{this.cacheSize=15}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.level,this,this.currencyPointerFn())}set description(e){this.descriptionFn=typeof e=="function"?e:()=>e}get level(){return((this??{data:{level:n.dOne}}).data??{level:n.dOne}).level}set level(e){this.data.level=new n(e)}constructor(e,r,i,s){let a=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>a,this.currencyPointerFn=typeof i=="function"?i:()=>i,this.cache=new qt(s??Me.cacheSize),this.id=e.id,this.name=e.name??e.id,this.descriptionFn=e.description?typeof e.description=="function"?e.description:()=>e.description:()=>"",this.cost=e.cost,this.costBulk=e.costBulk,this.maxLevel=e.maxLevel,this.effect=e.effect,this.el=e.el,this.defaultLevel=e.level??n.dOne}},pr=mt(gt());function le(t,e,r=n.dOne,i=n.dInf){if(t=new n(t),r=new n(r),i=new n(i),i.lt(0))return console.warn("calculateItem: Invalid target: ",i),[n.dZero,n.dZero];if(i.eq(1)){let u=e.cost(r);return[t.gte(u)?n.dOne:n.dZero,t.gte(u)?u:n.dZero]}let s=t.div(e.cost(r)).floor().min(i),a=e.cost(r).mul(s);return[s,a]}var he=class{constructor(t,e,r){this.defaultAmount=n.dZero;let i=typeof e=="function"?e():e;this.dataPointerFn=typeof e=="function"?e:()=>i,this.currencyPointerFn=typeof r=="function"?r:()=>r,this.id=t.id,this.name=t.name??t.id,this.cost=t.cost,this.effect=t.effect,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.defaultAmount=t.amount??n.dZero}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.amount,this,this.currencyPointerFn())}set description(t){this.descriptionFn=typeof t=="function"?t:()=>t}get amount(){return((this??{data:{amount:n.dOne}}).data??{amount:n.dOne}).amount}set amount(t){this.data.amount=new n(t)}},_t=class{constructor(t){t=t??{},this.id=t.id,this.amount=t.amount??n.dZero}};K([vt()],_t.prototype,"id",2),K([dt(()=>n)],_t.prototype,"amount",2);var Nr=mt(gt()),It=class{constructor(){this.value=n.dZero,this.upgrades={},this.items={}}};K([dt(()=>n)],It.prototype,"value",2),K([dt(()=>Mt)],It.prototype,"upgrades",2),K([dt(()=>_t)],It.prototype,"items",2);var He=class{get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}constructor(t=new It,e,r,i={defaultVal:n.dZero,defaultBoost:n.dOne}){this.defaultVal=i.defaultVal,this.defaultBoost=i.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new Vt(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e),this.items={},r&&this.addItem(r)}onLoadData(){for(let t of Object.values(this.upgrades))this.runUpgradeEffect(t)}reset(t,e,r){let i={resetCurrency:!0,resetUpgradeLevels:!0,resetItemAmounts:!0,runUpgradeEffect:!0};if(typeof t=="object"?Object.assign(i,t):Object.assign(i,{resetCurrency:t,resetUpgradeLevels:e,runUpgradeEffect:r}),i.resetCurrency&&(this.value=this.defaultVal),i.resetUpgradeLevels)for(let s of Object.values(this.upgrades))s.level=new n(s.defaultLevel),i.runUpgradeEffect&&this.runUpgradeEffect(s);if(i.resetItemAmounts)for(let s of Object.values(this.items))s.amount=new n(s.defaultAmount),i.runUpgradeEffect&&this.runItemEffect(s)}gain(t=1e3){let e=this.boost.calculate().mul(new n(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new Mt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}queryUpgrade(t){let e=Object.keys(this.upgrades);if(t instanceof RegExp){let i=t;return e.filter(a=>i.test(a)).map(a=>this.upgrades[a])}return typeof t=="string"&&(t=[t]),e.filter(i=>t.includes(i)).map(i=>this.upgrades[i])}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r=[];for(let i of t){this.pointerAddUpgrade(i);let s=new ue(i,()=>this.pointerGetUpgrade(i.id),()=>this);e&&this.runUpgradeEffect(s),this.upgrades[i.id]=s,r.push(s)}return r}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&Object.assign(r,e)}runUpgradeEffect(t){t.effect?.(t.level,t,this)}runItemEffect(t,e=n.dOne){e=new n(e),t.effect?.(t.amount,e,t,this)}calculateUpgrade(t,e=1/0,r,i){let s=this.getUpgrade(t);return s===null?(console.warn(`Upgrade "${t}" not found.`),[n.dZero,n.dZero]):(e=s.level.add(e),s.maxLevel!==void 0&&(e=n.min(e,s.maxLevel)),ae(this.value,s,s.level,e,r,i))}getNextCost(t,e=1,r,i){let s=this.getUpgrade(t);if(s===null)return console.warn(`Upgrade "${t}" not found.`),n.dZero;let a=this.calculateUpgrade(t,e,r,i)[0];return s.cost(s.level.add(a))}getNextCostMax(t,e=1,r,i){let s=this.getUpgrade(t);if(s===null)return console.warn(`Upgrade "${t}" not found.`),n.dZero;let a=this.calculateUpgrade(t,e,r,i);return s.cost(s.level.add(a[0])).add(a[1])}buyUpgrade(t,e,r,i){let s=this.getUpgrade(t);if(s===null)return console.warn(`Upgrade "${t}" not found.`),!1;let[a,u]=this.calculateUpgrade(t,e,r,i);return a.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(u),s.level=s.level.add(a),this.runUpgradeEffect(s),!0)}pointerAddItem(t){let e=new _t(t);return this.pointer.items[t.id]=e,e}pointerGetItem(t){return this.pointer.items[t]??null}addItem(t,e=!0){Array.isArray(t)||(t=[t]);for(let r of t){this.pointerAddItem(r);let i=new he(r,()=>this.pointerGetItem(r.id),()=>this);e&&this.runItemEffect(i),this.items[r.id]=i}}getItem(t){return this.items[t]??null}calculateItem(t,e,r){let i=this.getItem(t);return i===null?(console.warn(`Item "${t}" not found.`),[n.dZero,n.dZero]):le(this.value,i,e,r)}buyItem(t,e,r){let i=this.getItem(t);if(i===null)return console.warn(`Item "${t}" not found.`),!1;let[s,a]=this.calculateItem(t,e,r);return s.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(a),i.amount=i.amount.add(s),this.runItemEffect(i,e),!0)}},br=mt(gt()),zt=class{constructor(t=0){this.value=new n(t)}};K([dt(()=>n)],zt.prototype,"value",2);var We=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=new n(r),t??=new zt(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new Vt(this.initial):null}update(){console.warn("AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed."),this.boost&&(this.pointer.value=this.boost.calculate())}get value(){return this.boost&&(this.pointer.value=this.boost.calculate()),this.pointer.value}set value(t){if(this.boost)throw new Error("Cannot set value of attributeStatic when boost is enabled.");this.pointer.value=t}},Ft=class{constructor(t,e,r={},i){this.setValue=this.set.bind(this),this.getValue=this.get.bind(this),this.x=t,this.y=e,this.properties=typeof r=="function"?r(this):{...r},this.gridSymbol=i}get grid(){return Zt.getInstance(this.gridSymbol)}set(t,e){return this.properties[t]=e,e}get(t){return this.properties[t]}translate(t=0,e=0){return Zt.getInstance(this.gridSymbol).getCell(this.x+t,this.y+e)}direction(t,e=1,r){let i=this.grid;return(()=>{switch(t){case"up":return i.getCell(this.x,this.y-e);case"right":return i.getCell(this.x+e,this.y);case"down":return i.getCell(this.x,this.y+e);case"left":return i.getCell(this.x-e,this.y);case"adjacent":return i.getAdjacent(this.x,this.y,e,r);case"diagonal":return i.getDiagonal(this.x,this.y,e,r);case"encircling":return i.getEncircling(this.x,this.y,e,r);default:throw new Error("Invalid direction")}})()}up(t=1){return this.direction("up",t)}right(t=1){return this.direction("right",t)}down(t=1){return this.direction("down",t)}left(t=1){return this.direction("left",t)}};function fe(t,e,r=!0){let i=r?"Size":"Coordinates";if(typeof t!="number"||typeof e!="number")throw new RangeError(`${i} must be numbers: ${t}, ${e}`);if(!Number.isInteger(t)||!Number.isInteger(e))throw new RangeError(`${i} must be integers: ${t}, ${e}`);if(t<0||e<0)throw new RangeError(`${i} must be positive: ${t}, ${e}`);if(!Number.isFinite(t)||!Number.isFinite(e))throw new RangeError(`${i} must be finite: ${t}, ${e}`);if(!Number.isSafeInteger(t)||!Number.isSafeInteger(e))throw new RangeError(`${i} must be safe integers: ${t}, ${e}`)}var J=class Ht extends Array{constructor(e){e=Array.isArray(e)?e:[e],e=e.filter(r=>r!==void 0),super(...e),this.removeDuplicates()}removeDuplicates(){let e=[];this.forEach((r,i)=>{this.indexOf(r)!==i&&e.push(i)}),e.forEach(r=>this.splice(r,1))}translate(e=0,r=0){return new Ht(this.map(i=>i.translate(e,r)))}direction(e,r,i){return new Ht(this.flatMap(s=>s.direction(e,r,i)))}up(e){return this.direction("up",e)}right(e){return this.direction("right",e)}down(e){return this.direction("down",e)}left(e){return this.direction("left",e)}adjacent(e,r){return this.direction("adjacent",e,r)}diagonal(e,r){return this.direction("diagonal",e,r)}encircling(e,r){return this.direction("encircling",e,r)}},Zt=class Wt{constructor(e,r,i){this.cells=[],this.gridSymbol=Symbol(),this.all=this.getAll.bind(this),this.allX=this.getAllX.bind(this),this.allY=this.getAllY.bind(this),this.get=this.getCell.bind(this),this.set=this.setCell.bind(this),Wt.instances[this.gridSymbol]=this,this.starterProps=i??{},this.xSize=e,this.ySize=r??e,fe(this.xSize,this.ySize,!0);for(let s=0;s{if(this.ySize!==s&&(this.ySizes))for(let a=s;a{if(this.xSize!==i){if(this.xSizei)for(let a=0;a{let t=!1,e=r=>(t||(console.warn("The E function is deprecated. Use the Decimal class directly."),t=!0),new n(r));return Object.getOwnPropertyNames(n).filter(r=>!Object.getOwnPropertyNames(class{}).includes(r)).forEach(r=>{e[r]=n[r]}),e})(),Qe=Kt;if(typeof st.exports=="object"&&typeof yt=="object"){var Je=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Object.getOwnPropertyNames(e))!Object.prototype.hasOwnProperty.call(t,s)&&s!==r&&Object.defineProperty(t,s,{get:()=>e[s],enumerable:!(i=Object.getOwnPropertyDescriptor(e,s))||i.enumerable});return t};st.exports=Je(st.exports,yt)}return st.exports}); +"use strict";(function(yt,st){var Ot=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],st);else if(typeof module=="object"&&module.exports)module.exports=st();else{var ot=st(),Tt=Ot?exports:yt;for(var wt in ot)Tt[wt]=ot[wt]}})(typeof self<"u"?self:exports,()=>{var yt={},st={exports:yt},Ot=Object.create,ot=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,wt=Object.getOwnPropertyNames,_e=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty,Se=(t,e)=>function(){return e||(0,t[wt(t)[0]])((e={exports:{}}).exports,e),e.exports},Xt=(t,e)=>{for(var r in e)ot(t,r,{get:e[r],enumerable:!0})},Qt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of wt(e))!Ie.call(t,s)&&s!==r&&ot(t,s,{get:()=>e[s],enumerable:!(i=Tt(e,s))||i.enumerable});return t},mt=(t,e,r)=>(r=t!=null?Ot(_e(t)):{},Qt(e||!t||!t.__esModule?ot(r,"default",{value:t,enumerable:!0}):r,t)),Oe=t=>Qt(ot({},"__esModule",{value:!0}),t),K=(t,e,r,i)=>{for(var s=i>1?void 0:i?Tt(e,r):e,a=t.length-1,u;a>=0;a--)(u=t[a])&&(s=(i?u(e,r,s):u(s))||s);return i&&s&&ot(e,r,s),s},gt=Se({"node_modules/reflect-metadata/Reflect.js"(){var t;(function(e){(function(r){var i=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:g(),s=a(e);typeof i.Reflect<"u"&&(s=a(i.Reflect,s)),r(s,i),typeof i.Reflect>"u"&&(i.Reflect=e);function a(d,I){return function(E,x){Object.defineProperty(d,E,{configurable:!0,writable:!0,value:x}),I&&I(E,x)}}function u(){try{return Function("return this;")()}catch{}}function c(){try{return(0,eval)("(function() { return this; })()")}catch{}}function g(){return u()||c()}})(function(r,i){var s=Object.prototype.hasOwnProperty,a=typeof Symbol=="function",u=a&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",c=a&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",g=typeof Object.create=="function",d={__proto__:[]}instanceof Array,I=!g&&!d,E={create:g?function(){return Dt(Object.create(null))}:d?function(){return Dt({__proto__:null})}:function(){return Dt({})},has:I?function(l,h){return s.call(l,h)}:function(l,h){return h in l},get:I?function(l,h){return s.call(l,h)?l[h]:void 0}:function(l,h){return l[h]}},x=Object.getPrototypeOf(Function),q=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:ur(),R=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:lr(),w=typeof WeakMap=="function"?WeakMap:hr(),k=a?Symbol.for("@reflect-metadata:registry"):void 0,U=sr(),H=ar(U);function o(l,h,m,y){if(L(m)){if(!ge(l))throw new TypeError;if(!de(h))throw new TypeError;return Q(l,h)}else{if(!ge(l))throw new TypeError;if(!Y(h))throw new TypeError;if(!Y(y)&&!L(y)&&!Nt(y))throw new TypeError;return Nt(y)&&(y=void 0),m=at(m),it(l,h,m,y)}}r("decorate",o);function N(l,h){function m(y,P){if(!Y(y))throw new TypeError;if(!L(P)&&!ir(P))throw new TypeError;Ct(l,h,y,P)}return m}r("metadata",N);function p(l,h,m,y){if(!Y(m))throw new TypeError;return L(y)||(y=at(y)),Ct(l,h,m,y)}r("defineMetadata",p);function v(l,h,m){if(!Y(h))throw new TypeError;return L(m)||(m=at(m)),X(l,h,m)}r("hasMetadata",v);function S(l,h,m){if(!Y(h))throw new TypeError;return L(m)||(m=at(m)),tt(l,h,m)}r("hasOwnMetadata",S);function F(l,h,m){if(!Y(h))throw new TypeError;return L(m)||(m=at(m)),et(l,h,m)}r("getMetadata",F);function O(l,h,m){if(!Y(h))throw new TypeError;return L(m)||(m=at(m)),ft(l,h,m)}r("getOwnMetadata",O);function G(l,h){if(!Y(l))throw new TypeError;return L(h)||(h=at(h)),At(l,h)}r("getMetadataKeys",G);function V(l,h){if(!Y(l))throw new TypeError;return L(h)||(h=at(h)),Pt(l,h)}r("getOwnMetadataKeys",V);function z(l,h,m){if(!Y(h))throw new TypeError;if(L(m)||(m=at(m)),!Y(h))throw new TypeError;L(m)||(m=at(m));var y=St(h,m,!1);return L(y)?!1:y.OrdinaryDeleteMetadata(l,h,m)}r("deleteMetadata",z);function Q(l,h){for(var m=l.length-1;m>=0;--m){var y=l[m],P=y(h);if(!L(P)&&!Nt(P)){if(!de(P))throw new TypeError;h=P}}return h}function it(l,h,m,y){for(var P=l.length-1;P>=0;--P){var B=l[P],W=B(h,m,y);if(!L(W)&&!Nt(W)){if(!Y(W))throw new TypeError;y=W}}return y}function X(l,h,m){var y=tt(l,h,m);if(y)return!0;var P=Bt(h);return Nt(P)?!1:X(l,P,m)}function tt(l,h,m){var y=St(h,m,!1);return L(y)?!1:me(y.OrdinaryHasOwnMetadata(l,h,m))}function et(l,h,m){var y=tt(l,h,m);if(y)return ft(l,h,m);var P=Bt(h);if(!Nt(P))return et(l,P,m)}function ft(l,h,m){var y=St(h,m,!1);if(!L(y))return y.OrdinaryGetOwnMetadata(l,h,m)}function Ct(l,h,m,y){var P=St(m,y,!0);P.OrdinaryDefineOwnMetadata(l,h,m,y)}function At(l,h){var m=Pt(l,h),y=Bt(l);if(y===null)return m;var P=At(y,h);if(P.length<=0)return m;if(m.length<=0)return P;for(var B=new R,W=[],j=0,M=m;j=0&&M=this._keys.length?(this._index=-1,this._keys=h,this._values=h):this._index++,{value:_,done:!1}}return{value:void 0,done:!0}},j.prototype.throw=function(M){throw this._index>=0&&(this._index=-1,this._keys=h,this._values=h),M},j.prototype.return=function(M){return this._index>=0&&(this._index=-1,this._keys=h,this._values=h),{value:M,done:!0}},j}(),y=function(){function j(){this._keys=[],this._values=[],this._cacheKey=l,this._cacheIndex=-2}return Object.defineProperty(j.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),j.prototype.has=function(M){return this._find(M,!1)>=0},j.prototype.get=function(M){var _=this._find(M,!1);return _>=0?this._values[_]:void 0},j.prototype.set=function(M,_){var T=this._find(M,!0);return this._values[T]=_,this},j.prototype.delete=function(M){var _=this._find(M,!1);if(_>=0){for(var T=this._keys.length,C=_+1;CQe}),st.exports=Oe(Jt);var mr=mt(gt()),Kt={};Xt(Kt,{Attribute:()=>zt,AttributeStatic:()=>We,Boost:()=>Vt,BoostObject:()=>pt,Currency:()=>It,CurrencyStatic:()=>He,DEFAULT_ITERATIONS:()=>Et,Decimal:()=>n,E:()=>Xe,FORMATS:()=>Ze,FormatTypeList:()=>Fe,Grid:()=>Zt,GridCell:()=>Ft,GridCellCollection:()=>J,Item:()=>he,ItemData:()=>_t,LRUCache:()=>qt,ListNode:()=>te,ST_NAMES:()=>ut,UpgradeData:()=>Mt,UpgradeStatic:()=>ue,calculateItem:()=>le,calculateSum:()=>Rt,calculateSumApprox:()=>se,calculateSumLoop:()=>ne,calculateUpgrade:()=>ae,decimalToJSONString:()=>oe,equalsTolerance:()=>$t,formats:()=>ht,inverseFunctionApprox:()=>Gt,roundingBase:()=>Be,upgradeToCacheNameEL:()=>De});var gr=mt(gt()),qt=class{constructor(t){this.map=new Map,this.first=void 0,this.last=void 0,this.maxSize=t}get size(){return this.map.size}get(t){let e=this.map.get(t);if(e!==void 0)return e!==this.first&&(e===this.last?(this.last=e.prev,this.last.next=void 0):(e.prev.next=e.next,e.next.prev=e.prev),e.next=this.first,this.first.prev=e,this.first=e),e.value}set(t,e){if(this.maxSize<1)return;if(this.map.has(t))throw new Error("Cannot update existing keys in the cache");let r=new te(t,e);for(this.first===void 0?(this.first=r,this.last=r):(r.next=this.first,this.first.prev=r,this.first=r),this.map.set(t,r);this.map.size>this.maxSize;){let i=this.last;this.map.delete(i.key),this.last=i.prev,this.last.next=void 0}}},te=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},rt;(function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(rt||(rt={}));var Te=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},t.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.findTransformMetadatas=function(e,r,i){return this.findMetadatas(this._transformMetadatas,e,r).filter(function(s){return!s.options||s.options.toClassOnly===!0&&s.options.toPlainOnly===!0?!0:s.options.toClassOnly===!0?i===rt.CLASS_TO_CLASS||i===rt.PLAIN_TO_CLASS:s.options.toPlainOnly===!0?i===rt.CLASS_TO_PLAIN:!0})},t.prototype.findExcludeMetadata=function(e,r){return this.findMetadata(this._excludeMetadatas,e,r)},t.prototype.findExposeMetadata=function(e,r){return this.findMetadata(this._exposeMetadatas,e,r)},t.prototype.findExposeMetadataByCustomName=function(e,r){return this.getExposedMetadatas(e).find(function(i){return i.options&&i.options.name===r})},t.prototype.findTypeMetadata=function(e,r){return this.findMetadata(this._typeMetadatas,e,r)},t.prototype.getStrategy=function(e){var r=this._excludeMetadatas.get(e),i=r&&r.get(void 0),s=this._exposeMetadatas.get(e),a=s&&s.get(void 0);return i&&a||!i&&!a?"none":i?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},t.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},t.prototype.getExposedProperties=function(e,r){return this.getExposedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===rt.CLASS_TO_CLASS||r===rt.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===rt.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.getExcludedProperties=function(e,r){return this.getExcludedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===rt.CLASS_TO_CLASS||r===rt.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===rt.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(e,r){var i=e.get(r),s;i&&(s=Array.from(i.values()).filter(function(E){return E.propertyName!==void 0}));for(var a=[],u=0,c=this.getAncestors(r);uNumber.MAX_SAFE_INTEGER)&&(v="\u03C9");let F=t.log(o,8e3).toNumber();if(p.equals(0))return v;if(p.gt(0)&&p.lte(3)){let V=[];for(let z=0;zNumber.MAX_SAFE_INTEGER)&&(v="\u03C9");let F=t.log(o,8e3).toNumber();if(p.equals(0))return v;if(p.gt(0)&&p.lte(2)){let V=[];for(let z=0;z118?e.elemental.beyondOg(S):e.elemental.config.element_lists[o-1][v]},beyondOg(o){let N=Math.floor(Math.log10(o)),p=["n","u","b","t","q","p","h","s","o","e"],v="";for(let S=N;S>=0;S--){let F=Math.floor(o/Math.pow(10,S))%10;v==""?v=p[F].toUpperCase():v+=p[F]}return v},abbreviationLength(o){return o==1?1:Math.pow(Math.floor(o/2)+1,2)*2},getAbbreviationAndValue(o){let N=o.log(118).toNumber(),p=Math.floor(N)+1,v=e.elemental.abbreviationLength(p),S=N-p+1,F=Math.floor(S*v),O=e.elemental.getAbbreviation(p,S),G=new t(118).pow(p+F/v-1);return[O,G]},formatElementalPart(o,N){return N.eq(1)?o:`${N.toString()} ${o}`},format(o,N=2){if(o.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(o.log10(),N);let p=o.log(118),S=p.log(118).log(118).toNumber(),F=Math.max(4-S*2,1),O=[];for(;p.gte(1)&&O.length=F)return O.map(V=>e.elemental.formatElementalPart(V[0],V[1])).join(" + ");let G=new t(118).pow(p).toFixed(O.length===1?3:N);return O.length===0?G:O.length===1?`${G} \xD7 ${e.elemental.formatElementalPart(O[0][0],O[0][1])}`:`${G} \xD7 (${O.map(V=>e.elemental.formatElementalPart(V[0],V[1])).join(" + ")})`}},old_sc:{format(o,N){o=new t(o);let p=o.log10().floor();if(p.lt(9))return p.lt(3)?o.toFixed(N):o.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(o.gte("eeee10")){let S=o.slog();return(S.gte(1e9)?"":t.dTen.pow(S.sub(S.floor())).toFixed(4))+"F"+e.old_sc.format(S.floor(),0)}let v=o.div(t.dTen.pow(p));return(p.log10().gte(9)?"":v.toFixed(4))+"e"+e.old_sc.format(p,0)}}},eng:{format(o,N=2){o=new t(o);let p=o.log10().floor();if(p.lt(9))return p.lt(3)?o.toFixed(N):o.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(o.gte("eeee10")){let S=o.slog();return(S.gte(1e9)?"":t.dTen.pow(S.sub(S.floor())).toFixed(4))+"F"+e.eng.format(S.floor(),0)}let v=o.div(new t(1e3).pow(p.div(3).floor()));return(p.log10().gte(9)?"":v.toFixed(new t(4).sub(p.sub(p.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(p.div(3).floor().mul(3),0)}}},mixed_sc:{format(o,N,p=9){o=new t(o);let v=o.log10().floor();return v.lt(303)&&v.gte(p)?g(o,N,p,"st"):g(o,N,p,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(o,N=2,p){o=new t(o);let v=o.max(1).log10().max(1).log(r.log10()).floor();if(v.lte(0))return g(o,N,p,"sc");o=t.dTen.pow(o.max(1).log10().div(r.log10().pow(v)).sub(v.gte(1)?1:0));let S=v.div(10).floor(),F=v.toNumber()%10-1;return g(o,Math.max(4,N),p,"sc")+" "+(S.gte(1)?"meta"+(S.gte(2)?"^"+g(S,0,p,"sc"):"")+"-":"")+(isNaN(F)?"nanity":e.layer.layers[F])}},standard:{tier1(o){return ut[0][0][o%10]+ut[0][1][Math.floor(o/10)%10]+ut[0][2][Math.floor(o/100)]},tier2(o){let N=o%10,p=Math.floor(o/10)%10,v=Math.floor(o/100)%10,S="";return o<10?ut[1][0][o]:(p==1&&N==0?S+="Vec":S+=ut[1][1][N]+ut[1][2][p],S+=ut[1][3][v],S)}},inf:{format(o,N,p){o=new t(o);let v=0,S=new t(Number.MAX_VALUE),F=["","\u221E","\u03A9","\u03A8","\u028A"],O=["","","m","mm","mmm"];for(;o.gte(S);)o=o.log(S),v++;return v==0?g(o,N,p,"sc"):o.gte(3)?O[v]+F[v]+"\u03C9^"+g(o.sub(1),N,p,"sc"):o.gte(2)?O[v]+"\u03C9"+F[v]+"-"+g(S.pow(o.sub(2)),N,p,"sc"):O[v]+F[v]+"-"+g(S.pow(o.sub(1)),N,p,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(o,N=new t(1e15),p=!1,v=9){if(o=new t(o),N=new t(N).div(1e3),o.lt(N.mul(1e3)))return"";let{alphabet:S}=e.alphabet.config,F=S.length,O=o.log(1e3).sub(N.log(1e3)).floor(),G=O.add(1).log(F+1).ceil(),V="",z=(Q,it)=>{let X=Q,tt="";for(let et=0;et=F)return"\u03C9";tt=S[ft]+tt,X=X.sub(1).div(F).floor()}return tt};if(G.lt(v))V=z(O,G);else{let Q=G.sub(v).add(1),it=O.div(t.pow(F+1,Q.sub(1))).floor();V=`${z(it,new t(v))}(${Q.gt("1e9")?Q.format():Q.format(0)})`}return V},format(o,N=2,p=9,v="mixed_sc",S=new t(1e15),F=!1,O){if(o=new t(o),S=new t(S).div(1e3),o.lt(S.mul(1e3)))return g(o,N,p,v);let G=e.alphabet.getAbbreviation(o,S,F,O),V=o.div(t.pow(1e3,o.log(1e3).floor()));return`${G.length>(O??9)+2?"":V.toFixed(N)+" "}${G}`}}},r=t.dTwo.pow(1024),i="\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089",s="\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079";function a(o){return o.toFixed(0).split("").map(N=>N==="-"?"\u208B":i[parseInt(N,10)]).join("")}function u(o){return o.toFixed(0).split("").map(N=>N==="-"?"\u208B":s[parseInt(N,10)]).join("")}function c(o,N=2,p=9,v="st"){return g(o,N,p,v)}function g(o,N=2,p=9,v="mixed_sc"){o=new t(o);let S=o.lt(0)?"-":"";if(o.mag==1/0)return S+"Infinity";if(Number.isNaN(o.mag))return S+"NaN";if(o.lt(0)&&(o=o.mul(-1)),o.eq(0))return o.toFixed(N);let F=o.log10().floor();switch(v){case"sc":case"scientific":if(o.log10().lt(Math.min(-N,0))&&N>1){let O=o.log10().ceil(),G=o.div(O.eq(-1)?new t(.1):t.dTen.pow(O)),V=O.mul(-1).max(1).log10().gte(9);return S+(V?"":G.toFixed(2))+"e"+g(O,0,p,"mixed_sc")}else if(F.lt(p)){let O=Math.max(Math.min(N-F.toNumber(),N),0);return S+(O>0?o.toFixed(O):o.toFixed(O).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(o.gte("eeee10")){let V=o.slog();return(V.gte(1e9)?"":t.dTen.pow(V.sub(V.floor())).toFixed(2))+"F"+g(V.floor(),0)}let O=o.div(t.dTen.pow(F)),G=F.log10().gte(9);return S+(G?"":O.toFixed(2))+"e"+g(F,0,p,"mixed_sc")}case"st":case"standard":{let O=o.log(1e3).floor();if(O.lt(1))return S+o.toFixed(Math.max(Math.min(N-F.toNumber(),N),0));let G=O.mul(3),V=O.log10().floor();if(V.gte(3e3))return"e"+g(F,N,p,"st");let z="";if(O.lt(4))z=["","K","M","B"][Math.round(O.toNumber())];else{let X=Math.floor(O.log(1e3).toNumber());for(X<100&&(X=Math.max(X-1,0)),O=O.sub(1).div(t.dTen.pow(X*3));O.gt(0);){let tt=O.div(1e3).floor(),et=O.sub(tt.mul(1e3)).floor().toNumber();et>0&&(et==1&&!X&&(z="U"),X&&(z=e.standard.tier2(X)+(z?"-"+z:"")),et>1&&(z=e.standard.tier1(et)+z)),O=tt,X++}}let Q=o.div(t.dTen.pow(G)),it=N===2?t.dTwo.sub(F.sub(G)).add(1).toNumber():N;return S+(V.gte(10)?"":Q.toFixed(it)+" ")+z}default:return e[v]||console.error('Invalid format type "',v,'"'),S+e[v].format(o,N,p)}}function d(o,N,p="mixed_sc",v,S){o=new t(o),N=new t(N);let F=o.add(N),O,G=F.div(o);return G.gte(10)&&o.gte(1e100)?(G=G.log10().mul(20),O="(+"+g(G,v,S,p)+" OoMs/sec)"):O="(+"+g(N,v,S,p)+"/sec)",O}function I(o,N=2,p="s"){return o=new t(o),o.gte(86400)?g(o.div(86400).floor(),0,12,"sc")+":"+I(o.mod(86400),N,"d"):o.gte(3600)||p=="d"?(o.div(3600).gte(10)||p!="d"?"":"0")+g(o.div(3600).floor(),0,12,"sc")+":"+I(o.mod(3600),N,"h"):o.gte(60)||p=="h"?(o.div(60).gte(10)||p!="h"?"":"0")+g(o.div(60).floor(),0,12,"sc")+":"+I(o.mod(60),N,"m"):(o.gte(10)||p!="m"?"":"0")+g(o,N,12,"sc")}function E(o,N=!1,p=0,v=9,S="mixed_sc"){let F=Pt=>g(Pt,p,v,S);o=new t(o);let O=o.mul(1e3).mod(1e3).floor(),G=o.mod(60).floor(),V=o.div(60).mod(60).floor(),z=o.div(3600).mod(24).floor(),Q=o.div(86400).mod(365.2425).floor(),it=o.div(31556952).floor(),X=it.eq(1)?" year":" years",tt=Q.eq(1)?" day":" days",et=z.eq(1)?" hour":" hours",ft=V.eq(1)?" minute":" minutes",Ct=G.eq(1)?" second":" seconds",At=O.eq(1)?" millisecond":" milliseconds";return`${it.gt(0)?F(it)+X+", ":""}${Q.gt(0)?F(Q)+tt+", ":""}${z.gt(0)?F(z)+et+", ":""}${V.gt(0)?F(V)+ft+", ":""}${G.gt(0)?F(G)+Ct+",":""}${N&&O.gt(0)?" "+F(O)+At:""}`.replace(/,([^,]*)$/,"$1").trim()}function x(o){return o=new t(o),g(t.dOne.sub(o).mul(100))+"%"}function q(o){return o=new t(o),g(o.mul(100))+"%"}function R(o,N=2){return o=new t(o),o.gte(1)?"\xD7"+o.format(N):"/"+o.pow(-1).format(N)}function w(o,N,p=10){return t.gte(o,10)?t.pow(p,t.log(o,p).pow(N)):new t(o)}function k(o,N=0){o=new t(o);let p=(O=>O.map((G,V)=>({name:G.name,altName:G.altName,value:t.pow(1e3,new t(V).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"Decimal",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),v="",S=o.lte(0)?0:t.min(t.log(o,1e3).sub(1),p.length-1).floor().toNumber(),F=p[S];if(S===0)switch(N){case 1:v="";break;case 2:case 0:default:v=o.format();break}switch(N){case 1:v=F.name;break;case 2:v=o.divide(F.value).format();break;case 3:v=F.altName;break;case 0:default:v=`${o.divide(F.value).format()} ${F.name}`;break}return v}function U(o,N=!1){return`${k(o,2)} ${k(o,1)}eV${N?"/c^2":""}`}let H={...e,toSubscript:a,toSuperscript:u,formatST:c,format:g,formatGain:d,formatTime:I,formatTimeLong:E,formatReduction:x,formatPercent:q,formatMult:R,expMult:w,metric:k,ev:U};return{FORMATS:e,formats:H}}var Lt=17,Ae=9e15,Pe=Math.log10(9e15),qe=1/9e15,ke=308,Le=-324,ee=5,xe=1023,Ue=!0,Ve=!1,je=function(){let t=[];for(let r=Le+1;r<=ke;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),ct=[2,Math.E,3,4,5,6,7,8,9,10],$e=[[1,1.0891180521811203,1.1789767925673957,1.2701455431742086,1.3632090180450092,1.4587818160364217,1.5575237916251419,1.6601571006859253,1.767485818836978,1.8804192098842727,2],[1,1.1121114330934079,1.231038924931609,1.3583836963111375,1.4960519303993531,1.6463542337511945,1.8121385357018724,1.996971324618307,2.2053895545527546,2.4432574483385254,Math.E],[1,1.1187738849693603,1.2464963939368214,1.38527004705667,1.5376664685821402,1.7068895236551784,1.897001227148399,2.1132403089001035,2.362480153784171,2.6539010333870774,3],[1,1.1367350847096405,1.2889510672956703,1.4606478703324786,1.6570295196661111,1.8850062585672889,2.1539465047453485,2.476829779693097,2.872061932789197,3.3664204535587183,4],[1,1.1494592900767588,1.319708228183931,1.5166291280087583,1.748171114438024,2.0253263297298045,2.3636668498288547,2.7858359149579424,3.3257226212448145,4.035730287722532,5],[1,1.159225940787673,1.343712473580932,1.5611293155111927,1.8221199554561318,2.14183924486326,2.542468319282638,3.0574682501653316,3.7390572020926873,4.6719550537360774,6],[1,1.1670905356972596,1.3632807444991446,1.5979222279405536,1.8842640123816674,2.2416069644878687,2.69893426559423,3.3012632110403577,4.121250340630164,5.281493033448316,7],[1,1.1736630594087796,1.379783782386201,1.6292821855668218,1.9378971836180754,2.3289975651071977,2.8384347394720835,3.5232708454565906,4.478242031114584,5.868592169644505,8],[1,1.1793017514670474,1.394054150657457,1.65664127441059,1.985170999970283,2.4069682290577457,2.9647310119960752,3.7278665320924946,4.814462547283592,6.436522247411611,9],[1,1.1840100246247336,1.4061375836156955,1.6802272208863964,2.026757028388619,2.4770056063449646,3.080525271755482,3.9191964192627284,5.135152840833187,6.989961179534715,10]],Ge=[[-1,-.9194161097107025,-.8335625019330468,-.7425599821143978,-.6466611521029437,-.5462617907227869,-.4419033816638769,-.3342645487554494,-.224140440909962,-.11241087890006762,0],[-1,-.90603157029014,-.80786507256596,-.7064666939634,-.60294836853664,-.49849837513117,-.39430303318768,-.29147201034755,-.19097820800866,-.09361896280296,0],[-1,-.9021579584316141,-.8005762598234203,-.6964780623319391,-.5911906810998454,-.486050182576545,-.3823089430815083,-.28106046722897615,-.1831906535795894,-.08935809204418144,0],[-1,-.8917227442365535,-.781258746326964,-.6705130326902455,-.5612813129406509,-.4551067709033134,-.35319256652135966,-.2563741554088552,-.1651412821106526,-.0796919581982668,0],[-1,-.8843387974366064,-.7678744063886243,-.6529563724510552,-.5415870994657841,-.4352842206588936,-.33504449124791424,-.24138853420685147,-.15445285440944467,-.07409659641336663,0],[-1,-.8786709358426346,-.7577735191184886,-.6399546189952064,-.527284921869926,-.4211627631006314,-.3223479611761232,-.23107655627789858,-.1472057700818259,-.07035171210706326,0],[-1,-.8740862815291583,-.7497032990976209,-.6297119746181752,-.5161838335958787,-.41036238255751956,-.31277212146489963,-.2233976621705518,-.1418697367979619,-.06762117662323441,0],[-1,-.8702632331800649,-.7430366914122081,-.6213373075161548,-.5072025698095242,-.40171437727184167,-.30517930701410456,-.21736343968190863,-.137710238299109,-.06550774483471955,0],[-1,-.8670016295947213,-.7373984232432306,-.6143173985094293,-.49973884395492807,-.394584953527678,-.2989649949848695,-.21245647317021688,-.13434688362382652,-.0638072667348083,0],[-1,-.8641642839543857,-.732534623168535,-.6083127477059322,-.4934049257184696,-.3885773075899922,-.29376029055315767,-.2083678561173622,-.13155653399373268,-.062401588652553186,0]],f=function(e){return n.fromValue_noAlloc(e)},A=function(t,e,r){return n.fromComponents(t,e,r)},b=function(e,r,i){return n.fromComponents_noNormalize(e,r,i)},lt=function(e,r){let i=r+1,s=Math.ceil(Math.log10(Math.abs(e))),a=Math.round(e*Math.pow(10,i-s))*Math.pow(10,s-i);return parseFloat(a.toFixed(Math.max(i-s,0)))},xt=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},Re=function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;let e=1;for(;t<10;)e=e*t,++t;t-=1;let r=.9189385332046727;r=r+(t+.5)*Math.log(t),r=r-t;let i=t*t,s=t;return r=r+1/(12*s),s=s*i,r=r-1/(360*s),s=s*i,r=r+1/(1260*s),s=s*i,r=r-1/(1680*s),s=s*i,r=r+1/(1188*s),s=s*i,r=r-691/(360360*s),s=s*i,r=r+7/(1092*s),s=s*i,r=r-3617/(122400*s),Math.exp(r)/e},ze=.36787944117144233,re=.5671432904097838,Ut=function(t,e=1e-10,r=!0){let i,s;if(!Number.isFinite(t))return t;if(r){if(t===0)return t;if(t===1)return re;t<10?i=0:i=Math.log(t)-Math.log(Math.log(t))}else{if(t===0)return-1/0;t<=-.1?i=-2:i=Math.log(-t)-Math.log(-Math.log(-t))}for(let a=0;a<100;++a){if(s=(t*Math.exp(-i)+i*i)/(i+1),Math.abs(s-i).5?1:-1;if(Math.random()*20<1)return b(e,0,1);let r=Math.floor(Math.random()*(t+1)),i=r===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let s=Math.pow(10,i);return Math.random()>.9&&(s=Math.trunc(s)),A(e,r,s)}static affordGeometricSeries_core(t,e,r,i){let s=e.mul(r.pow(i));return n.floor(t.div(s).mul(r.sub(1)).add(1).log10().div(r.log10()))}static sumGeometricSeries_core(t,e,r,i){return e.mul(r.pow(i)).mul(n.sub(1,r.pow(t))).div(n.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let a=e.add(i.mul(r)).sub(r.div(2)),u=a.pow(2);return a.neg().add(u.add(r.mul(t).mul(2)).sqrt()).div(r).floor()}static sumArithmeticSeries_core(t,e,r,i){let s=e.add(i.mul(r));return t.div(2).mul(s.mul(2).plus(t.sub(1).mul(r)))}static efficiencyOfPurchase_core(t,e,r){return t.div(e).add(t.div(r))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0||this.mag===Number.NEGATIVE_INFINITY&&this.layer>0&&Number.isFinite(this.layer))return this.sign=0,this.mag=0,this.layer=0,this;if(this.layer===0&&this.mag<0&&(this.mag=-this.mag,this.sign=-this.sign),this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_INFINITY)return this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY,this;if(this.layer===0&&this.mag=Ae)return this.layer+=1,this.mag=e*Math.log10(t),this;for(;t0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=e*Math.pow(10,t),t=Math.abs(this.mag),e=Math.sign(this.mag));return this.layer===0&&(this.mag<0?(this.mag=-this.mag,this.sign=-this.sign):this.mag===0&&(this.sign=0)),(Number.isNaN(this.sign)||Number.isNaN(this.layer)||Number.isNaN(this.mag))&&(this.sign=Number.NaN,this.layer=Number.NaN,this.mag=Number.NaN),this}fromComponents(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this.normalize(),this}fromComponents_noNormalize(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this}fromMantissaExponent(t,e){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=e+Math.log10(t),this.normalize(),this}fromMantissaExponent_noNormalize(t,e){return this.fromMantissaExponent(t,e),this}fromDecimal(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this}fromNumber(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this}fromString(t,e=!1){let r=t,i=n.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);Ue?t=t.replace(",",""):Ve&&(t=t.replace(",","."));let s=t.split("^^^");if(s.length===2){let w=parseFloat(s[0]),k=parseFloat(s[1]),U=s[1].split(";"),H=1;if(U.length===2&&(H=parseFloat(U[1]),isFinite(H)||(H=1)),isFinite(w)&&isFinite(k)){let o=n.pentate(w,k,H,e);return this.sign=o.sign,this.layer=o.layer,this.mag=o.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}}let a=t.split("^^");if(a.length===2){let w=parseFloat(a[0]),k=parseFloat(a[1]),U=a[1].split(";"),H=1;if(U.length===2&&(H=parseFloat(U[1]),isFinite(H)||(H=1)),isFinite(w)&&isFinite(k)){let o=n.tetrate(w,k,H,e);return this.sign=o.sign,this.layer=o.layer,this.mag=o.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}}let u=t.split("^");if(u.length===2){let w=parseFloat(u[0]),k=parseFloat(u[1]);if(isFinite(w)&&isFinite(k)){let U=n.pow(w,k);return this.sign=U.sign,this.layer=U.layer,this.mag=U.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}}t=t.trim().toLowerCase();let c,g,d=t.split("pt");if(d.length===2){c=10;let w=!1;d[0].startsWith("-")&&(w=!0,d[0]=d[0].slice(1)),g=parseFloat(d[0]),d[1]=d[1].replace("(",""),d[1]=d[1].replace(")","");let k=parseFloat(d[1]);if(isFinite(k)||(k=1),isFinite(c)&&isFinite(g)){let U=n.tetrate(c,g,k,e);return this.sign=U.sign,this.layer=U.layer,this.mag=U.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),w&&(this.sign*=-1),this}}if(d=t.split("p"),d.length===2){c=10;let w=!1;d[0].startsWith("-")&&(w=!0,d[0]=d[0].slice(1)),g=parseFloat(d[0]),d[1]=d[1].replace("(",""),d[1]=d[1].replace(")","");let k=parseFloat(d[1]);if(isFinite(k)||(k=1),isFinite(c)&&isFinite(g)){let U=n.tetrate(c,g,k,e);return this.sign=U.sign,this.layer=U.layer,this.mag=U.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),w&&(this.sign*=-1),this}}if(d=t.split("f"),d.length===2){c=10;let w=!1;d[0].startsWith("-")&&(w=!0,d[0]=d[0].slice(1)),d[0]=d[0].replace("(",""),d[0]=d[0].replace(")","");let k=parseFloat(d[0]);if(d[1]=d[1].replace("(",""),d[1]=d[1].replace(")",""),g=parseFloat(d[1]),isFinite(k)||(k=1),isFinite(c)&&isFinite(g)){let U=n.tetrate(c,g,k,e);return this.sign=U.sign,this.layer=U.layer,this.mag=U.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),w&&(this.sign*=-1),this}}let I=t.split("e"),E=I.length-1;if(E===0){let w=parseFloat(t);if(isFinite(w))return this.fromNumber(w),n.fromStringCache.size>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}else if(E===1){let w=parseFloat(t);if(isFinite(w)&&w!==0)return this.fromNumber(w),n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}let x=t.split("e^");if(x.length===2){this.sign=1,x[0].startsWith("-")&&(this.sign=-1);let w="";for(let k=0;k=43&&U<=57||U===101)w+=x[1].charAt(k);else return this.layer=parseFloat(w),this.mag=parseFloat(x[1].substr(k+1)),this.normalize(),n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}}if(E<1)return this.sign=0,this.layer=0,this.mag=0,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this;let q=parseFloat(I[0]);if(q===0)return this.sign=0,this.layer=0,this.mag=0,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this;let R=parseFloat(I[I.length-1]);if(E>=2){let w=parseFloat(I[I.length-2]);isFinite(w)&&(R*=Math.sign(w),R+=xt(w))}if(!isFinite(q))this.sign=I[0]==="-"?-1:1,this.layer=E,this.mag=R;else if(E===1)this.sign=Math.sign(q),this.layer=1,this.mag=R+Math.log10(Math.abs(q));else if(this.sign=Math.sign(q),this.layer=E,E===2){let w=n.mul(A(1,2,R),f(q));return this.sign=w.sign,this.layer=w.layer,this.mag=w.mag,n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}else this.mag=R;return this.normalize(),n.fromStringCache.maxSize>=1&&n.fromStringCache.set(r,n.fromDecimal(this)),this}fromValue(t){return t instanceof n?this.fromDecimal(t):typeof t=="number"?this.fromNumber(t):typeof t=="string"?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===1?Number.POSITIVE_INFINITY:this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===-1?Number.NEGATIVE_INFINITY:Number.isFinite(this.layer)?this.layer===0?this.sign*this.mag:this.layer===1?this.sign*Math.pow(10,this.mag):this.mag>0?this.sign>0?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:0:Number.NaN}mantissaWithDecimalPlaces(t){return isNaN(this.m)?Number.NaN:this.m===0?0:lt(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:lt(this.mag,t)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY?this.sign===1?"Infinity":"-Infinity":this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toString():this.m+"e"+this.e:this.layer===1?this.m+"e"+this.e:this.layer<=ee?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(t){return this.layer===0?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)}toFixed(t){return this.layer===0?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)}toPrecision(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(t){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(t):lt(this.m,t)+"e"+lt(this.e,t):this.layer===1?lt(this.m,t)+"e"+lt(this.e,t):this.layer<=ee?(this.sign===-1?"-":"")+"e".repeat(this.layer)+lt(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+lt(this.mag,t)}abs(){return b(this.sign===0?0:1,this.layer,this.mag)}neg(){return b(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?b(0,0,0):this.layer===0?A(this.sign,0,Math.round(this.mag)):new n(this)}floor(){return this.mag<0?this.sign===-1?b(-1,0,1):b(0,0,0):this.sign===-1?this.neg().ceil().neg():this.layer===0?A(this.sign,0,Math.floor(this.mag)):new n(this)}ceil(){return this.mag<0?this.sign===1?b(1,0,1):b(0,0,0):this.sign===-1?this.neg().floor().neg():this.layer===0?A(this.sign,0,Math.ceil(this.mag)):new n(this)}trunc(){return this.mag<0?b(0,0,0):this.layer===0?A(this.sign,0,Math.trunc(this.mag)):new n(this)}add(t){let e=f(t);if(this.eq(n.dInf)&&e.eq(n.dNegInf)||this.eq(n.dNegInf)&&e.eq(n.dInf))return b(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new n(this);if(!Number.isFinite(e.layer))return new n(e);if(this.sign===0)return new n(e);if(e.sign===0)return new n(this);if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return b(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(n.cmpabs(this,e)>0?(r=new n(this),i=new n(e)):(r=new n(e),i=new n(this)),r.layer===0&&i.layer===0)return n.fromNumber(r.sign*r.mag+i.sign*i.mag);let s=r.layer*Math.sign(r.mag),a=i.layer*Math.sign(i.mag);if(s-a>=2)return r;if(s===0&&a===-1){if(Math.abs(i.mag-Math.log10(r.mag))>Lt)return r;{let u=Math.pow(10,Math.log10(r.mag)-i.mag),c=i.sign+r.sign*u;return A(Math.sign(c),1,i.mag+Math.log10(Math.abs(c)))}}if(s===1&&a===0){if(Math.abs(r.mag-Math.log10(i.mag))>Lt)return r;{let u=Math.pow(10,r.mag-Math.log10(i.mag)),c=i.sign+r.sign*u;return A(Math.sign(c),1,Math.log10(i.mag)+Math.log10(Math.abs(c)))}}if(Math.abs(r.mag-i.mag)>Lt)return r;{let u=Math.pow(10,r.mag-i.mag),c=i.sign+r.sign*u;return A(Math.sign(c),1,i.mag+Math.log10(Math.abs(c)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(f(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=f(t);if(this.eq(n.dInf)&&e.eq(n.dNegInf)||this.eq(n.dNegInf)&&e.eq(n.dInf))return b(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.mag==Number.POSITIVE_INFINITY&&e.eq(n.dZero)||this.eq(n.dZero)&&this.mag==Number.POSITIVE_INFINITY)return b(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new n(this);if(!Number.isFinite(e.layer))return new n(e);if(this.sign===0||e.sign===0)return b(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return b(this.sign*e.sign,0,1);let r,i;if(this.layer>e.layer||this.layer==e.layer&&Math.abs(this.mag)>Math.abs(e.mag)?(r=new n(this),i=new n(e)):(r=new n(e),i=new n(this)),r.layer===0&&i.layer===0)return n.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return A(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return A(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return A(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let s=A(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(A(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return A(r.sign*i.sign,s.layer+1,s.sign*s.mag)}if(r.layer===2&&i.layer===2){let s=A(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(A(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return A(r.sign*i.sign,s.layer+1,s.sign*s.mag)}throw Error("Bad arguments to mul: "+this+", "+t)}multiply(t){return this.mul(t)}times(t){return this.mul(t)}div(t){let e=f(t);return this.mul(e.recip())}divide(t){return this.div(t)}divideBy(t){return this.div(t)}dividedBy(t){return this.div(t)}recip(){return this.mag===0?b(Number.NaN,Number.NaN,Number.NaN):this.mag===Number.POSITIVE_INFINITY?b(0,0,0):this.layer===0?A(this.sign,0,1/this.mag):A(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=f(t).abs();if(e.eq(n.dZero))return b(0,0,0);let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new n(r%i):this.sub(e).eq(this)?b(0,0,0):e.sub(this).eq(e)?new n(this):this.sign==-1?this.abs().mod(e).neg():this.sub(this.div(e).floor().mul(e))}modulo(t){return this.mod(t)}modular(t){return this.mod(t)}cmp(t){let e=f(t);return this.sign>e.sign?1:this.sign0?this.layer:-this.layer,i=e.mag>0?e.layer:-e.layer;return r>i?1:re.mag?1:this.mag0?new n(e):new n(this)}clamp(t,e){return this.max(t).min(e)}clampMin(t){return this.max(t)}clampMax(t){return this.min(t)}cmp_tolerance(t,e){let r=f(t);return this.eq_tolerance(r,e)?0:this.cmp(r)}compare_tolerance(t,e){return this.cmp_tolerance(t,e)}eq_tolerance(t,e){let r=f(t);if(e==null&&(e=1e-7),this.sign!==r.sign||Math.abs(this.layer-r.layer)>1)return!1;let i=this.mag,s=r.mag;return this.layer>r.layer&&(s=xt(s)),this.layer0?A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):A(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?b(Number.NaN,Number.NaN,Number.NaN):this.layer>0?A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):A(this.sign,0,Math.log10(this.mag))}log(t){return t=f(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?b(Number.NaN,Number.NaN,Number.NaN):this.layer===0&&t.layer===0?A(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):n.div(this.log10(),t.log10())}log2(){return this.sign<=0?b(Number.NaN,Number.NaN,Number.NaN):this.layer===0?A(this.sign,0,Math.log2(this.mag)):this.layer===1?A(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?A(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?b(Number.NaN,Number.NaN,Number.NaN):this.layer===0?A(this.sign,0,Math.log(this.mag)):this.layer===1?A(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?A(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=f(t),r=new n(this),i=new n(e);if(r.sign===0)return i.eq(0)?b(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return b(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return r;let s=r.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?s.neg():Math.abs(i.toNumber()%2)%2===0?s:b(Number.NaN,Number.NaN,Number.NaN):s}pow10(){if(this.eq(n.dInf))return b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.eq(n.dNegInf))return b(0,0,0);if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return b(Number.NaN,Number.NaN,Number.NaN);let t=new n(this);if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return A(1,0,e);if(t.sign===0)return b(1,0,1);t=b(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?A(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?A(-t.sign,t.layer+1,-t.mag):b(1,0,1)}pow_base(t){return f(t).pow(this)}root(t){let e=f(t);return this.pow(e.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?n.exp(n.mul(this,n.ln(this).sub(1))):n.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(b(1,0,24)))return n.fromNumber(Re(this.sign*this.mag));let t=this.mag-1,e=.9189385332046727;e=e+(t+.5)*Math.log(t),e=e-t;let r=t*t,i=t,s=12*i,a=1/s,u=e+a;if(u===e||(e=u,i=i*r,s=360*i,a=1/s,u=e-a,u===e))return n.exp(e);e=u,i=i*r,s=1260*i;let c=1/s;return e=e+c,i=i*r,s=1680*i,c=1/s,e=e-c,n.exp(e)}else return this.layer===1?n.exp(n.mul(this,n.ln(this).sub(1))):n.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?b(1,0,1):this.layer===0&&this.mag<=709.7?n.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?A(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?A(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):A(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return n.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return A(1,2,Math.log10(this.mag)-.3010299956639812);{let t=n.div(b(this.sign,this.layer-1,this.mag),b(1,0,2));return t.layer+=1,t.normalize(),t}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(t=2,e=b(1,0,1),r=!1){if(t===1)return n.pow(this,e);if(t===0)return new n(e);if(this.eq(n.dOne))return b(1,0,1);if(this.eq(-1))return n.pow(this,e);if(t===Number.POSITIVE_INFINITY){let a=this.toNumber();if(a<=1.444667861009766&&a>=.06598803584531254){let u=n.ln(this).neg(),c=u.lambertw().div(u);if(a<1)return c;let g=u.lambertw(!1).div(u);return a>1.444667861009099&&(c=g=n.fromNumber(Math.E)),e=f(e),e.eq(g)?g:e.lt(g)?c:b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}else return a>1.444667861009766?b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY):b(Number.NaN,Number.NaN,Number.NaN)}if(this.eq(n.dZero)){let a=Math.abs((t+1)%2);return a>1&&(a=2-a),n.fromNumber(a)}if(t<0)return n.iteratedlog(e,this,-t,r);e=new n(e);let i=t;t=Math.trunc(t);let s=i-t;if(this.gt(n.dZero)&&(this.lt(1)||this.lte(1.444667861009766)&&e.lte(n.ln(this).neg().lambertw(!1).div(n.ln(this).neg())))&&(i>1e4||!r)){let a=Math.min(1e4,t);e.eq(n.dOne)?e=this.pow(s):this.lt(1)?e=e.pow(1-s).mul(this.pow(e).pow(s)):e=e.layeradd(s,this);for(let u=0;u1e4&&Math.ceil(i)%2==1?this.pow(e):e}s!==0&&(e.eq(n.dOne)?this.gt(10)||r?e=this.pow(s):(e=n.fromNumber(n.tetrate_critical(this.toNumber(),s)),this.lt(2)&&(e=e.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?e=e.layeradd10(s,r):this.lt(1)?e=e.pow(1-s).mul(this.pow(e).pow(s)):e=e.layeradd(s,this,r));for(let a=0;a3)return b(e.sign,e.layer+(t-a-1),e.mag);if(a>1e4)return e}return e}iteratedexp(t=2,e=b(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return n.tetrate(t,-e,this,r);t=f(t);let i=n.fromDecimal(this),s=e;e=Math.trunc(e);let a=s-e;if(i.layer-t.layer>3){let u=Math.min(e,i.layer-t.layer-3);e-=u,i.layer-=u}for(let u=0;u1e4)return i}return a>0&&a<1&&(t.eq(10)?i=i.layeradd10(-a,r):i=i.layeradd(-a,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,s=!1,a=!1,u=this.slog_internal(t,r).toNumber();for(let c=1;c1&&a!=d&&(s=!0),a=d,s?i/=2:i*=2,i=Math.abs(i)*(d?-1:1),u+=i,i===0)break}return n.fromNumber(u)}slog_internal(t=10,e=!1){if(t=f(t),t.lte(n.dZero)||t.eq(n.dOne))return b(Number.NaN,Number.NaN,Number.NaN);if(t.lt(n.dOne))return this.eq(n.dOne)?b(0,0,0):this.eq(n.dZero)?b(-1,0,1):b(Number.NaN,Number.NaN,Number.NaN);if(this.mag<0||this.eq(n.dZero))return b(-1,0,1);if(t.lt(1.444667861009766)){let s=n.ln(t).neg(),a=s.lambertw().div(s);if(this.eq(a))return b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.gt(a))return b(Number.NaN,Number.NaN,Number.NaN)}let r=0,i=n.fromDecimal(this);if(i.layer-t.layer>3){let s=i.layer-t.layer-3;r+=s,i.layer-=s}for(let s=0;s<100;++s)if(i.lt(n.dZero))i=n.pow(t,i),r-=1;else{if(i.lte(n.dOne))return e?n.fromNumber(r+i.toNumber()-1):n.fromNumber(r+n.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=n.log(i,t)}return n.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:n.critical_section(t,e,Ge)}static tetrate_critical(t,e){return n.critical_section(t,e,$e)}static critical_section(t,e,r,i=!1){e*=10,e<0&&(e=0),e>10&&(e=10),t<2&&(t=2),t>10&&(t=10);let s=0,a=0;for(let c=0;ct){let g=(t-ct[c])/(ct[c+1]-ct[c]);s=r[c][Math.floor(e)]*(1-g)+r[c+1][Math.floor(e)]*g,a=r[c][Math.ceil(e)]*(1-g)+r[c+1][Math.ceil(e)]*g;break}let u=e-Math.floor(e);return s<=0||a<=0?s*(1-u)+a*u:Math.pow(t,Math.log(s)/Math.log(t)*(1-u)+Math.log(a)/Math.log(t)*u)}layeradd10(t,e=!1){t=n.fromValue_noAlloc(t).toNumber();let r=n.fromDecimal(this);if(t>=1){r.mag<0&&r.layer>0?(r.sign=0,r.mag=0,r.layer=0):r.sign===-1&&r.layer==0&&(r.sign=1,r.mag=-r.mag);let i=Math.trunc(t);t-=i,r.layer+=i}if(t<=-1){let i=Math.trunc(t);if(t-=i,r.layer+=i,r.layer<0)for(let s=0;s<100;++s){if(r.layer++,r.mag=Math.log10(r.mag),!isFinite(r.mag))return r.sign===0&&(r.sign=1),r.layer<0&&(r.layer=0),r.normalize();if(r.layer>=0)break}}for(;r.layer<0;)r.layer++,r.mag=Math.log10(r.mag);return r.sign===0&&(r.sign=1,r.mag===0&&r.layer>=1&&(r.layer-=1,r.mag=1)),r.normalize(),t!==0?r.layeradd(t,10,e):r}layeradd(t,e,r=!1){let i=f(e);if(i.gt(1)&&i.lte(1.444667861009766)){let u=n.excess_slog(this,e,r),c=u[0].toNumber(),g=u[1],d=c+t,I=n.ln(e).neg(),E=I.lambertw().div(I),x=I.lambertw(!1).div(I),q=n.dOne;g==1?q=E.mul(x).sqrt():g==2&&(q=x.mul(2));let R=i.pow(q),w=Math.floor(d),k=d-w,U=q.pow(1-k).mul(R.pow(k));return n.tetrate(i,w,U,r)}let a=this.slog(e,100,r).toNumber()+t;return a>=0?n.tetrate(e,a,n.dOne,r):Number.isFinite(a)?a>=-1?n.log(n.tetrate(e,a+1,n.dOne,r),e):n.log(n.log(n.tetrate(e,a+2,n.dOne,r),e),e):b(Number.NaN,Number.NaN,Number.NaN)}static excess_slog(t,e,r=!1){t=f(t),e=f(e);let i=e;if(e=e.toNumber(),e==1||e<=0)return[b(Number.NaN,Number.NaN,Number.NaN),0];if(e>1.444667861009766)return[t.slog(e,100,r),0];let s=n.ln(e).neg(),a=s.lambertw().div(s),u=n.dInf;if(e>1&&(u=s.lambertw(!1).div(s)),e>1.444667861009099&&(a=u=n.fromNumber(Math.E)),t.lt(a))return[t.slog(e,100,r),0];if(t.eq(a))return[b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),0];if(t.eq(u))return[b(1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),2];if(t.gt(u)){let c=u.mul(2),g=i.pow(c),d=0;if(t.gte(c)&&t.lt(g))d=0;else if(t.gte(g)){let w=g;for(d=1;w.lt(t);)if(w=i.pow(w),d=d+1,w.layer>3){let k=Math.floor(t.layer-w.layer+1);w=i.iteratedexp(k,w,r),d=d+k}w.gt(t)&&(w=w.log(e),d=d-1)}else if(t.lt(c)){let w=c;for(d=0;w.gt(t);)w=w.log(e),d=d-1}let I=0,E=0,x=.5,q=c,R=n.dZero;for(;x>1e-16;){if(E=I+x,q=c.pow(1-E).mul(g.pow(E)),R=n.iteratedexp(e,d,q),R.eq(t))return[new n(d+E),2];R.lt(t)&&(I+=x),x/=2}return R.neq_tolerance(t,1e-7)?[b(Number.NaN,Number.NaN,Number.NaN),0]:[new n(d+I),2]}if(t.lt(u)&&t.gt(a)){let c=a.mul(u).sqrt(),g=i.pow(c),d=0;if(t.lte(c)&&t.gt(g))d=0;else if(t.lte(g)){let w=g;for(d=1;w.gt(t);)w=i.pow(w),d=d+1;w.lt(t)&&(w=w.log(e),d=d-1)}else if(t.gt(c)){let w=c;for(d=0;w.lt(t);)w=w.log(e),d=d-1}let I=0,E=0,x=.5,q=c,R=n.dZero;for(;x>1e-16;){if(E=I+x,q=c.pow(1-E).mul(g.pow(E)),R=n.iteratedexp(e,d,q),R.eq(t))return[new n(d+E),1];R.gt(t)&&(I+=x),x/=2}return R.neq_tolerance(t,1e-7)?[b(Number.NaN,Number.NaN,Number.NaN),0]:[new n(d+I),1]}throw new Error("Unhandled behavior in excess_slog")}lambertw(t=!0){return this.lt(-.3678794411710499)?b(Number.NaN,Number.NaN,Number.NaN):t?this.abs().lt("1e-300")?new n(this):this.mag<0?n.fromNumber(Ut(this.toNumber())):this.layer===0?n.fromNumber(Ut(this.sign*this.mag)):this.lt("eee15")?ie(this):this.ln():this.sign===1?b(Number.NaN,Number.NaN,Number.NaN):this.layer===0?n.fromNumber(Ut(this.sign*this.mag,1e-10,!1)):this.layer==1?ie(this,1e-10,!1):this.neg().recip().lambertw().neg()}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(n.dInf))return b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(!this.isFinite())return b(Number.NaN,Number.NaN,Number.NaN);if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return n.fromNumber(t).add(2).pow(this.recip());if(t<=0)return b(Number.NaN,Number.NaN,Number.NaN);if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return eze?this.pow(this.recip()):b(Number.NaN,Number.NaN,Number.NaN)}if(this.eq(1))return b(1,0,1);if(this.lt(0))return b(Number.NaN,Number.NaN,Number.NaN);if(this.lte("1ee-16"))return t%2==1?new n(this):b(Number.NaN,Number.NaN,Number.NaN);if(this.gt(1)){let e=n.dTen;this.gte(n.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=n.dZero,i=e.layer,s=e.iteratedlog(10,i,!0),a=s,u=s.div(2),c=!0;for(;c;)u=r.add(s).div(2),n.iteratedexp(10,i,u,!0).tetrate(t,1,!0).gt(this)?s=u:r=u,u.eq(a)?c=!1:a=u;return n.iteratedexp(10,i,u,!0)}else{let e=1,r=A(1,10,1),i=A(1,10,1),s=A(1,10,1),a=A(1,1,-16),u=n.dZero,c=A(1,10,1),g=a.pow10().recip(),d=n.dZero,I=g,E=g,x=Math.ceil(t)%2==0,q=0,R=A(1,10,1),w=!1,k=n.dZero,U=!1;for(;e<4;){if(e==2){if(x)break;s=A(1,10,1),a=r,e=3,c=A(1,10,1),R=A(1,10,1)}for(w=!1;a.neq(s);){if(k=a,a.pow10().recip().tetrate(t,1,!0).eq(1)&&a.pow10().recip().lt(.4))g=a.pow10().recip(),I=a.pow10().recip(),E=a.pow10().recip(),d=n.dZero,q=-1,e==3&&(R=a);else if(a.pow10().recip().tetrate(t,1,!0).eq(a.pow10().recip())&&!x&&a.pow10().recip().lt(.4))g=a.pow10().recip(),I=a.pow10().recip(),E=a.pow10().recip(),d=n.dZero,q=0;else if(a.pow10().recip().tetrate(t,1,!0).eq(a.pow10().recip().mul(2).tetrate(t,1,!0)))g=a.pow10().recip(),I=n.dZero,E=g.mul(2),d=g,x?q=-1:q=0;else{for(u=a.mul(12e-17),g=a.pow10().recip(),I=a.add(u).pow10().recip(),d=g.sub(I),E=g.add(d);I.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||E.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||I.gte(g)||E.lte(g);)u=u.mul(2),I=a.add(u).pow10().recip(),d=g.sub(I),E=g.add(d);if((e==1&&E.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))&&I.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))||e==3&&E.tetrate(t,1,!0).lt(g.tetrate(t,1,!0))&&I.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))&&(R=a),E.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))q=-1;else if(x)q=1;else if(e==3&&a.gt_tolerance(r,1e-8))q=0;else{for(;I.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||E.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||I.gte(g)||E.lte(g);)u=u.mul(2),I=a.add(u).pow10().recip(),d=g.sub(I),E=g.add(d);E.tetrate(t,1,!0).sub(g.tetrate(t,1,!0)).lt(g.tetrate(t,1,!0).sub(I.tetrate(t,1,!0)))?q=0:q=1}}if(q==-1&&(U=!0),e==1&&q==1||e==3&&q!=0)if(s.eq(A(1,10,1)))a=a.mul(2);else{let p=!1;if(w&&(q==1&&e==1||q==-1&&e==3)&&(p=!0),a=a.add(s).div(2),p)break}else if(s.eq(A(1,10,1)))s=a,a=a.div(2);else{let p=!1;if(w&&(q==1&&e==1||q==-1&&e==3)&&(p=!0),s=s.sub(c),a=a.sub(c),p)break}if(s.sub(a).div(2).abs().gt(c.mul(1.5))&&(w=!0),c=s.sub(a).div(2).abs(),a.gt("1e18")||a.eq(k))break}if(a.gt("1e18")||!U||R==A(1,10,1))break;e==1?r=R:e==3&&(i=R),e++}s=r,a=A(1,1,-18);let H=a,o=n.dZero,N=!0;for(;N;)if(s.eq(A(1,10,1))?o=a.mul(2):o=s.add(a).div(2),n.pow(10,o).recip().tetrate(t,1,!0).gt(this)?a=o:s=o,o.eq(H)?N=!1:H=o,a.gt("1e18"))return b(Number.NaN,Number.NaN,Number.NaN);if(o.eq_tolerance(r,1e-15)){if(i.eq(A(1,10,1)))return b(Number.NaN,Number.NaN,Number.NaN);for(s=A(1,10,1),a=i,H=a,o=n.dZero,N=!0;N;)if(s.eq(A(1,10,1))?o=a.mul(2):o=s.add(a).div(2),n.pow(10,o).recip().tetrate(t,1,!0).gt(this)?a=o:s=o,o.eq(H)?N=!1:H=o,a.gt("1e18"))return b(Number.NaN,Number.NaN,Number.NaN);return o.pow10().recip()}else return o.pow10().recip()}}pentate(t=2,e=b(1,0,1),r=!1){e=new n(e);let i=t;t=Math.trunc(t);let s=i-t;s!==0&&(e.eq(n.dOne)?(++t,e=n.fromNumber(s)):this.eq(10)?e=e.layeradd10(s,r):e=e.layeradd(s,this,r));for(let a=0;a10)return e}return e}sin(){return this.mag<0?new n(this):this.layer===0?n.fromNumber(Math.sin(this.sign*this.mag)):b(0,0,0)}cos(){return this.mag<0?b(1,0,1):this.layer===0?n.fromNumber(Math.cos(this.sign*this.mag)):b(0,0,0)}tan(){return this.mag<0?new n(this):this.layer===0?n.fromNumber(Math.tan(this.sign*this.mag)):b(0,0,0)}asin(){return this.mag<0?new n(this):this.layer===0?n.fromNumber(Math.asin(this.sign*this.mag)):b(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?n.fromNumber(Math.acos(this.toNumber())):this.layer===0?n.fromNumber(Math.acos(this.sign*this.mag)):b(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?new n(this):this.layer===0?n.fromNumber(Math.atan(this.sign*this.mag)):n.fromNumber(Math.atan(this.sign*(1/0)))}sinh(){return this.exp().sub(this.negate().exp()).div(2)}cosh(){return this.exp().add(this.negate().exp()).div(2)}tanh(){return this.sinh().div(this.cosh())}asinh(){return n.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return n.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?b(Number.NaN,Number.NaN,Number.NaN):n.ln(this.add(1).div(n.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?new n(this):this.root(n.pow(10,t))}egg(){return this.add(9)}lessThanOrEqualTo(t){return this.cmp(t)<1}lessThan(t){return this.cmp(t)<0}greaterThanOrEqualTo(t){return this.cmp(t)>-1}greaterThan(t){return this.cmp(t)>0}static smoothDamp(t,e,r,i){return new n(t).add(new n(e).minus(new n(t)).times(new n(r)).times(new n(i)))}clone(){return this}static clone(t){return n.fromComponents(t.sign,t.layer,t.mag)}softcap(t,e,r){let i=this.clone();return i.gte(t)&&([0,"pow"].includes(r)&&(i=i.div(t).pow(e).mul(t)),[1,"mul"].includes(r)&&(i=i.sub(t).div(e).add(t))),i}static softcap(t,e,r,i){return new n(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new n(t),e=new n(e);let s=this.clone();return s.gte(t)&&([0,"pow"].includes(r)&&(s=i?s.mul(t.pow(e.sub(1))).root(e):s.pow(e).div(t.pow(e.sub(1)))),[1,"exp"].includes(r)&&(s=i?s.div(t).max(1).log(e).add(t):n.pow(e,s.sub(t)).mul(t))),s}static scale(t,e,r,i,s=!1){return new n(t).scale(e,r,i,s)}format(t=2,e=9,r="mixed_sc"){return ht.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return ht.format(new n(t),e,r,i)}formatST(t=2,e=9,r="st"){return ht.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return ht.format(new n(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return ht.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,s){return ht.formatGain(new n(t),e,r,i,s)}toRoman(t=5e3){t=new n(t);let e=this.clone();if(e.gte(t)||e.lt(1))return e;let r=e.toNumber(),i={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},s="";for(let a of Object.keys(i)){let u=Math.floor(r/i[a]);r-=u*i[a],s+=a.repeat(u)}return s}static toRoman(t,e){return new n(t).toRoman(e)}static random(t=0,e=1){return t=new n(t),e=new n(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new n(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new n(Math.random()).lt(t)}};n.dZero=b(0,0,0),n.dOne=b(1,0,1),n.dNegOne=b(-1,0,1),n.dTwo=b(1,0,2),n.dTen=b(1,0,10),n.dNaN=b(Number.NaN,Number.NaN,Number.NaN),n.dInf=b(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),n.dNegInf=b(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),n.dNumberMax=A(1,0,Number.MAX_VALUE),n.dNumberMin=A(1,0,Number.MIN_VALUE),n.fromStringCache=new qt(xe),K([vt()],n.prototype,"sign",2),K([vt()],n.prototype,"mag",2),K([vt()],n.prototype,"layer",2),n=K([Ee()],n);var{formats:ht,FORMATS:Ze}=Ce(n);n.formats=ht;var pt=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.value=t.value,this.order=t.order??99,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>""}},Vt=class{constructor(t=1,e){this.addBoost=this.setBoost.bind(this),e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=new n(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new pt(r))})}getBoosts(t,e){let r=[],i=[];for(let s=0;sE),d=s,I=this.getBoosts(a,!0);I[0][0]?this.boostArray[I[1][0]]=new pt({id:a,name:u,description:c,value:g,order:d}):this.boostArray.push(new pt({id:a,name:u,description:c,value:g,order:d}))}else{t=Array.isArray(t)?t:[t];for(let a of t){let u=this.getBoosts(a.id,!0);u[0][0]?this.boostArray[u[1][0]]=new pt(a):this.boostArray.push(new pt(a))}}}clearBoosts(){this.boostArray.length=0}calculate(t=this.baseEffect){let e=new n(t),r=this.boostArray;r=r.sort((i,s)=>i.order-s.order);for(let i of r)e=i.value(e);return e}},dr=mt(gt()),Et=30,jt=.001;function Ye(t,e,r="geometric"){switch(t=new n(t),e=new n(e),r){case"arithmetic":case 1:return t.add(e).div(2);case"geometric":case 2:default:return t.mul(e).sqrt();case"harmonic":case 3:return n.dTwo.div(t.reciprocal().add(e.reciprocal()))}}function $t(t,e,r,i){i=Object.assign({},{verbose:!1,mode:"geometric"},i),t=new n(t),e=new n(e),r=new n(r);let s,a;return i.mode==="geometric"?(s=t.sub(e).abs().div(t.abs().add(e.abs()).div(2)),a=s.lte(r)):(s=t.sub(e).abs(),a=s.lte(r)),(i.verbose===!0||i.verbose==="onlyOnFail"&&!a)&&console.log({a:t,b:e,tolerance:r,config:i,diff:s,result:a}),a}function Gt(t,e,r="geometric",i=Et,s=jt,a=1,u){if(a=new n(a),u=new n(u??e),a.gt(u)&&([a,u]=[u,a]),t(u).eq(0))return{value:n.dZero,lowerBound:n.dZero,upperBound:n.dZero};if(t(u).lt(e))return console.warn("eMath.js: The function is not monotonically increasing. (f(n) < n)"),{value:u,lowerBound:u,upperBound:u};for(let g=0;g=0;c--){let g=r.add(u.mul(c)),d=r.add(u.mul(c+1)),I=a;if(a=a.add(t(g).add(t(d)).div(2).mul(u)),$t(I,a,s,{verbose:!1,mode:"geometric"}))break}return a}function Rt(t,e,r=0,i,s){return r=new n(r),e=new n(e),e.sub(r).lte(Et)?ne(t,e,r,i):se(t,e,r,s)}function Be(t,e=10,r=0,i=1e3){if(t=new n(t),e=new n(e),r=new n(r),i=new n(i),e.lt(1)||r.lt(1))return n.dNaN;let s=t.sign;if(t=t.abs(),t.gte(n.pow(e,i)))return t;let a=n.floor(n.log(t,e)),u=t.div(n.pow(e,a));return u=u.mul(n.pow(e,r)).round(),u=u.div(n.pow(e,r)),u=u.mul(n.pow(e,a)).mul(s),u}function ae(t,e,r,i=n.dInf,s,a,u=!1){t=new n(t),r=new n(r??e.level),i=new n(i);let c=i.sub(r);if(c.lt(0))return console.warn("eMath.js: Invalid target for calculateItem: ",c),[n.dZero,n.dZero];if(u=(typeof e.el=="function"?e.el():e.el)??u,c.eq(1)){let E=e.cost(e.level),x=t.gte(E),q=[n.dZero,n.dZero];return u?(q[0]=x?n.dOne:n.dZero,q):(q=[x?n.dOne:n.dZero,x?E:n.dZero],q)}if(e.costBulk){let[E,x]=e.costBulk(t,e.level,c),q=t.gte(x);return[q?E:n.dZero,q&&!u?x:n.dZero]}if(u){let E=R=>e.cost(R.add(r)),x=n.min(i,Gt(E,t,s,a).value.floor()),q=n.dZero;return[x,q]}let g=Gt(E=>Rt(e.cost,E,r),t,s,a).value.floor().min(r.add(c).sub(1)),d=Rt(e.cost,g,r);return[g.sub(r).add(1).max(0),d]}function oe(t){return t=new n(t),`${t.sign}/${t.mag}/${t.layer}`}function De(t){return`el/${oe(t)}`}var Mt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?new n(t.level):n.dOne}};K([vt()],Mt.prototype,"id",2),K([dt(()=>n)],Mt.prototype,"level",2);var ue=class Me{static{this.cacheSize=15}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.level,this,this.currencyPointerFn())}set description(e){this.descriptionFn=typeof e=="function"?e:()=>e}get level(){return((this??{data:{level:n.dOne}}).data??{level:n.dOne}).level}set level(e){this.data.level=new n(e)}constructor(e,r,i,s){let a=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>a,this.currencyPointerFn=typeof i=="function"?i:()=>i,this.cache=new qt(s??Me.cacheSize),this.id=e.id,this.name=e.name??e.id,this.descriptionFn=e.description?typeof e.description=="function"?e.description:()=>e.description:()=>"",this.cost=e.cost,this.costBulk=e.costBulk,this.maxLevel=e.maxLevel,this.effect=e.effect,this.el=e.el,this.defaultLevel=e.level??n.dOne}},pr=mt(gt());function le(t,e,r=n.dOne,i=n.dInf){if(t=new n(t),r=new n(r),i=new n(i),i.lt(0))return console.warn("eMath.js: Invalid target for calculateItem: ",i),[n.dZero,n.dZero];if(i.eq(1)){let u=e.cost(r);return[t.gte(u)?n.dOne:n.dZero,t.gte(u)?u:n.dZero]}let s=t.div(e.cost(r)).floor().min(i),a=e.cost(r).mul(s);return[s,a]}var he=class{constructor(t,e,r){this.defaultAmount=n.dZero;let i=typeof e=="function"?e():e;this.dataPointerFn=typeof e=="function"?e:()=>i,this.currencyPointerFn=typeof r=="function"?r:()=>r,this.id=t.id,this.name=t.name??t.id,this.cost=t.cost,this.effect=t.effect,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.defaultAmount=t.amount??n.dZero}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.amount,this,this.currencyPointerFn())}set description(t){this.descriptionFn=typeof t=="function"?t:()=>t}get amount(){return((this??{data:{amount:n.dOne}}).data??{amount:n.dOne}).amount}set amount(t){this.data.amount=new n(t)}},_t=class{constructor(t){t=t??{},this.id=t.id,this.amount=t.amount??n.dZero}};K([vt()],_t.prototype,"id",2),K([dt(()=>n)],_t.prototype,"amount",2);var Nr=mt(gt()),It=class{constructor(){this.value=n.dZero,this.upgrades={},this.items={}}};K([dt(()=>n)],It.prototype,"value",2),K([dt(()=>Mt)],It.prototype,"upgrades",2),K([dt(()=>_t)],It.prototype,"items",2);var He=class{get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}constructor(t=new It,e,r,i={defaultVal:n.dZero,defaultBoost:n.dOne}){this.defaultVal=i.defaultVal,this.defaultBoost=i.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new Vt(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e),this.items={},r&&this.addItem(r)}onLoadData(){for(let t of Object.values(this.upgrades))this.runUpgradeEffect(t)}reset(t,e,r){let i={resetCurrency:!0,resetUpgradeLevels:!0,resetItemAmounts:!0,runUpgradeEffect:!0};if(typeof t=="object"?Object.assign(i,t):Object.assign(i,{resetCurrency:t,resetUpgradeLevels:e,runUpgradeEffect:r}),i.resetCurrency&&(this.value=this.defaultVal),i.resetUpgradeLevels)for(let s of Object.values(this.upgrades))s.level=new n(s.defaultLevel),i.runUpgradeEffect&&this.runUpgradeEffect(s);if(i.resetItemAmounts)for(let s of Object.values(this.items))s.amount=new n(s.defaultAmount),i.runUpgradeEffect&&this.runItemEffect(s)}gain(t=1e3){let e=this.boost.calculate().mul(new n(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new Mt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}queryUpgrade(t){let e=Object.keys(this.upgrades);if(t instanceof RegExp){let i=t;return e.filter(a=>i.test(a)).map(a=>this.upgrades[a])}return typeof t=="string"&&(t=[t]),e.filter(i=>t.includes(i)).map(i=>this.upgrades[i])}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r=[];for(let i of t){this.pointerAddUpgrade(i);let s=new ue(i,()=>this.pointerGetUpgrade(i.id),()=>this);e&&this.runUpgradeEffect(s),this.upgrades[i.id]=s,r.push(s)}return r}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&Object.assign(r,e)}runUpgradeEffect(t){t.effect?.(t.level,t,this)}runItemEffect(t,e=n.dOne){e=new n(e),t.effect?.(t.amount,e,t,this)}calculateUpgrade(t,e=1/0,r,i){let s=this.getUpgrade(t);return s===null?(console.warn(`eMath.js: Upgrade "${t}" not found.`),[n.dZero,n.dZero]):(e=s.level.add(e),s.maxLevel!==void 0&&(e=n.min(e,s.maxLevel)),ae(this.value,s,s.level,e,r,i))}getNextCost(t,e=1,r,i){let s=this.getUpgrade(t);if(s===null)return console.warn(`eMath.js: Upgrade "${t}" not found.`),n.dZero;let a=this.calculateUpgrade(t,e,r,i)[0];return s.cost(s.level.add(a))}getNextCostMax(t,e=1,r,i){let s=this.getUpgrade(t);if(s===null)return console.warn(`eMath.js: Upgrade "${t}" not found.`),n.dZero;let a=this.calculateUpgrade(t,e,r,i);return s.cost(s.level.add(a[0])).add(a[1])}buyUpgrade(t,e,r,i){let s=this.getUpgrade(t);if(s===null)return console.warn(`eMath.js: Upgrade "${t}" not found.`),!1;let[a,u]=this.calculateUpgrade(t,e,r,i);return a.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(u),s.level=s.level.add(a),this.runUpgradeEffect(s),!0)}pointerAddItem(t){let e=new _t(t);return this.pointer.items[t.id]=e,e}pointerGetItem(t){return this.pointer.items[t]??null}addItem(t,e=!0){Array.isArray(t)||(t=[t]);for(let r of t){this.pointerAddItem(r);let i=new he(r,()=>this.pointerGetItem(r.id),()=>this);e&&this.runItemEffect(i),this.items[r.id]=i}}getItem(t){return this.items[t]??null}calculateItem(t,e,r){let i=this.getItem(t);return i===null?(console.warn(`eMath.js: Item "${t}" not found.`),[n.dZero,n.dZero]):le(this.value,i,e,r)}buyItem(t,e,r){let i=this.getItem(t);if(i===null)return console.warn(`eMath.js: Item "${t}" not found.`),!1;let[s,a]=this.calculateItem(t,e,r);return s.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(a),i.amount=i.amount.add(s),this.runItemEffect(i,e),!0)}},br=mt(gt()),zt=class{constructor(t=0){this.value=new n(t)}};K([dt(()=>n)],zt.prototype,"value",2);var We=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=new n(r),t??=new zt(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new Vt(this.initial):null}update(){console.warn("eMath.js: AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed."),this.boost&&(this.pointer.value=this.boost.calculate())}get value(){return this.boost&&(this.pointer.value=this.boost.calculate()),this.pointer.value}set value(t){if(this.boost)throw new Error("Cannot set value of attributeStatic when boost is enabled.");this.pointer.value=t}},Ft=class{constructor(t,e,r={},i){this.setValue=this.set.bind(this),this.getValue=this.get.bind(this),this.x=t,this.y=e,this.properties=typeof r=="function"?r(this):{...r},this.gridSymbol=i}get grid(){return Zt.getInstance(this.gridSymbol)}set(t,e){return this.properties[t]=e,e}get(t){return this.properties[t]}translate(t=0,e=0){return Zt.getInstance(this.gridSymbol).getCell(this.x+t,this.y+e)}direction(t,e=1,r){let i=this.grid;return(()=>{switch(t){case"up":return i.getCell(this.x,this.y-e);case"right":return i.getCell(this.x+e,this.y);case"down":return i.getCell(this.x,this.y+e);case"left":return i.getCell(this.x-e,this.y);case"adjacent":return i.getAdjacent(this.x,this.y,e,r);case"diagonal":return i.getDiagonal(this.x,this.y,e,r);case"encircling":return i.getEncircling(this.x,this.y,e,r);default:throw new Error("Invalid direction")}})()}up(t=1){return this.direction("up",t)}right(t=1){return this.direction("right",t)}down(t=1){return this.direction("down",t)}left(t=1){return this.direction("left",t)}};function fe(t,e,r=!0){let i=r?"Size":"Coordinates";if(typeof t!="number"||typeof e!="number")throw new RangeError(`${i} must be numbers: ${t}, ${e}`);if(!Number.isInteger(t)||!Number.isInteger(e))throw new RangeError(`${i} must be integers: ${t}, ${e}`);if(t<0||e<0)throw new RangeError(`${i} must be positive: ${t}, ${e}`);if(!Number.isFinite(t)||!Number.isFinite(e))throw new RangeError(`${i} must be finite: ${t}, ${e}`);if(!Number.isSafeInteger(t)||!Number.isSafeInteger(e))throw new RangeError(`${i} must be safe integers: ${t}, ${e}`)}var J=class Ht extends Array{constructor(e){e=Array.isArray(e)?e:[e],e=e.filter(r=>r!==void 0),super(...e),this.removeDuplicates()}removeDuplicates(){let e=[];this.forEach((r,i)=>{this.indexOf(r)!==i&&e.push(i)}),e.forEach(r=>this.splice(r,1))}translate(e=0,r=0){return new Ht(this.map(i=>i.translate(e,r)))}direction(e,r,i){return new Ht(this.flatMap(s=>s.direction(e,r,i)))}up(e){return this.direction("up",e)}right(e){return this.direction("right",e)}down(e){return this.direction("down",e)}left(e){return this.direction("left",e)}adjacent(e,r){return this.direction("adjacent",e,r)}diagonal(e,r){return this.direction("diagonal",e,r)}encircling(e,r){return this.direction("encircling",e,r)}},Zt=class Wt{constructor(e,r,i){this.cells=[],this.gridSymbol=Symbol(),this.all=this.getAll.bind(this),this.allX=this.getAllX.bind(this),this.allY=this.getAllY.bind(this),this.get=this.getCell.bind(this),this.set=this.setCell.bind(this),Wt.instances[this.gridSymbol]=this,this.starterProps=i??{},this.xSize=e,this.ySize=r??e,fe(this.xSize,this.ySize,!0);for(let s=0;s{if(this.ySize!==s&&(this.ySizes))for(let a=s;a{if(this.xSize!==i){if(this.xSizei)for(let a=0;a{let t=!1,e=r=>(t||(console.warn("eMath.js: The E function is deprecated. Use the Decimal class directly."),t=!0),new n(r));return Object.getOwnPropertyNames(n).filter(r=>!Object.getOwnPropertyNames(class{}).includes(r)).forEach(r=>{e[r]=n[r]}),e})(),Qe=Kt;if(typeof st.exports=="object"&&typeof yt=="object"){var Je=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Object.getOwnPropertyNames(e))!Object.prototype.hasOwnProperty.call(t,s)&&s!==r&&Object.defineProperty(t,s,{get:()=>e[s],enumerable:!(i=Object.getOwnPropertyDescriptor(e,s))||i.enumerable});return t};st.exports=Je(st.exports,yt)}return st.exports}); /*! Bundled license information: reflect-metadata/Reflect.js: diff --git a/dist/main/eMath.mjs b/dist/main/eMath.mjs index d22dfbf..13af2ea 100644 --- a/dist/main/eMath.mjs +++ b/dist/main/eMath.mjs @@ -134,7 +134,21 @@ var ST_NAMES = [ ["", "Hc", "DHe", "THt", "TeH", "PHc", "HHe", "HpH", "OHt", "EHc"] ] ]; -var FormatTypeList = ["st", "sc", "scientific", "omega", "omega_short", "elemental", "old_sc", "eng", "mixed_sc", "layer", "standard", "inf", "alphabet"]; +var formatTypeList = [ + "st", + "sc", + "scientific", + "omega", + "omega_short", + "elemental", + "old_sc", + "eng", + "mixed_sc", + "layer", + "standard", + "inf", + "alphabet" +]; function decimalFormatGenerator(Decimal2) { const FORMATS2 = { /** Omega format */ @@ -151,7 +165,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega.config.greek.length) + ); let lastLetter = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -192,7 +208,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega_short.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega_short.config.greek.length) + ); let lastLetter = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -218,6 +236,7 @@ function decimalFormatGenerator(Decimal2) { elemental: { config: { /** The list of elements */ + /* eslint-disable prettier/prettier */ element_lists: [ ["H"], ["He", "Li", "Be", "B", "C", "N", "O", "F"], @@ -332,6 +351,7 @@ function decimalFormatGenerator(Decimal2) { ], ["Og"] ] + /* eslint-enable prettier/prettier */ }, getOffset(group) { if (group == 1) return 1; @@ -363,11 +383,20 @@ function decimalFormatGenerator(Decimal2) { getAbbreviationAndValue(x) { const abbreviationListUnfloored = x.log(118).toNumber(); const abbreviationListIndex = Math.floor(abbreviationListUnfloored) + 1; - const abbreviationLength = FORMATS2.elemental.abbreviationLength(abbreviationListIndex); + const abbreviationLength = FORMATS2.elemental.abbreviationLength( + abbreviationListIndex + ); const abbreviationProgress = abbreviationListUnfloored - abbreviationListIndex + 1; - const abbreviationIndex = Math.floor(abbreviationProgress * abbreviationLength); - const abbreviation = FORMATS2.elemental.getAbbreviation(abbreviationListIndex, abbreviationProgress); - const value = new Decimal2(118).pow(abbreviationListIndex + abbreviationIndex / abbreviationLength - 1); + const abbreviationIndex = Math.floor( + abbreviationProgress * abbreviationLength + ); + const abbreviation = FORMATS2.elemental.getAbbreviation( + abbreviationListIndex, + abbreviationProgress + ); + const value = new Decimal2(118).pow( + abbreviationListIndex + abbreviationIndex / abbreviationLength - 1 + ); return [abbreviation, value]; }, formatElementalPart(abbreviation, n) { @@ -377,7 +406,12 @@ function decimalFormatGenerator(Decimal2) { return `${n.toString()} ${abbreviation}`; }, format(value, acc = 2) { - if (value.gt(new Decimal2(118).pow(new Decimal2(118).pow(new Decimal2(118).pow(4))))) return "e" + FORMATS2.elemental.format(value.log10(), acc); + if (value.gt( + new Decimal2(118).pow( + new Decimal2(118).pow(new Decimal2(118).pow(4)) + ) + )) + return "e" + FORMATS2.elemental.format(value.log10(), acc); let log = value.log(118); const slog = log.log(118); const sslog = slog.log(118).toNumber(); @@ -390,7 +424,12 @@ function decimalFormatGenerator(Decimal2) { parts.unshift([abbreviation, n]); } if (parts.length >= max) { - return parts.map((x) => FORMATS2.elemental.formatElementalPart(x[0], x[1])).join(" + "); + return parts.map( + (x) => ( + // @ts-expect-error - x has both string and decimal for some reason + FORMATS2.elemental.formatElementalPart(x[0], x[1]) + ) + ).join(" + "); } const formattedMantissa = new Decimal2(118).pow(log).toFixed(parts.length === 1 ? 3 : acc); if (parts.length === 0) { @@ -452,7 +491,9 @@ function decimalFormatGenerator(Decimal2) { return (slog.gte(1e9) ? "" : Decimal2.dTen.pow(slog.sub(slog.floor())).toFixed(4)) + "F" + FORMATS2.eng.format(slog.floor(), 0); } const m = ex.div(new Decimal2(1e3).pow(e.div(3).floor())); - return (e.log10().gte(9) ? "" : m.toFixed(new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber())) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); + return (e.log10().gte(9) ? "" : m.toFixed( + new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber() + )) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); } } }, @@ -477,12 +518,25 @@ function decimalFormatGenerator(Decimal2) { }, /** Layer format */ layer: { - layers: ["infinity", "eternity", "reality", "equality", "affinity", "celerity", "identity", "vitality", "immunity", "atrocity"], + layers: [ + "infinity", + "eternity", + "reality", + "equality", + "affinity", + "celerity", + "identity", + "vitality", + "immunity", + "atrocity" + ], format(ex, acc = 2, max) { ex = new Decimal2(ex); const layer = ex.max(1).log10().max(1).log(INFINITY_NUM.log10()).floor(); if (layer.lte(0)) return format(ex, acc, max, "sc"); - ex = Decimal2.dTen.pow(ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0)); + ex = Decimal2.dTen.pow( + ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0) + ); const meta = layer.div(10).floor(); const layer_id = layer.toNumber() % 10 - 1; return format(ex, Math.max(4, acc), max, "sc") + " " + (meta.gte(1) ? "meta" + (meta.gte(2) ? "^" + format(meta, 0, max, "sc") : "") + "-" : "") + (isNaN(layer_id) ? "nanity" : FORMATS2.layer.layers[layer_id]); @@ -528,8 +582,10 @@ function decimalFormatGenerator(Decimal2) { meta++; } if (meta == 0) return format(ex, acc, max, "sc"); - if (ex.gte(3)) return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); - if (ex.gte(2)) return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); + if (ex.gte(3)) + return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); + if (ex.gte(2)) + return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); return symbols2[meta] + symbols[meta] + "-" + format(inf.pow(ex.sub(1)), acc, max, "sc"); } }, @@ -574,7 +630,10 @@ function decimalFormatGenerator(Decimal2) { } else { const trunc = numLetters.sub(abbStart).add(1); const truncExponent = exponent.div(Decimal2.pow(alphabetLength + 1, trunc.sub(1))).floor(); - const truncLetters = convertToLetters(truncExponent, new Decimal2(abbStart)); + const truncLetters = convertToLetters( + truncExponent, + new Decimal2(abbStart) + ); letters = `${truncLetters}(${trunc.gt("1e9") ? trunc.format() : trunc.format(0)})`; } return letters; @@ -596,7 +655,12 @@ function decimalFormatGenerator(Decimal2) { ex = new Decimal2(ex); start = new Decimal2(start).div(1e3); if (ex.lt(start.mul(1e3))) return format(ex, acc, max, type); - const letters = FORMATS2.alphabet.getAbbreviation(ex, start, startDouble, abbStart); + const letters = FORMATS2.alphabet.getAbbreviation( + ex, + start, + startDouble, + abbStart + ); const mantissa = ex.div(Decimal2.pow(1e3, ex.log(1e3).floor())); const isAbbreviation = letters.length > (abbStart ?? 9) + 2; return `${!isAbbreviation ? mantissa.toFixed(acc) + " " : ""}${letters}`; @@ -610,7 +674,9 @@ function decimalFormatGenerator(Decimal2) { return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUBSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); } function toSuperscript(value) { - return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); + return value.toFixed(0).split("").map( + (x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)] + ).join(""); } function formatST(ex, acc = 2, max = 9, type = "st") { return format(ex, acc, max, type); @@ -628,7 +694,9 @@ function decimalFormatGenerator(Decimal2) { case "scientific": { if (ex.log10().lt(Math.min(-acc, 0)) && acc > 1) { const e2 = ex.log10().ceil(); - const m = ex.div(e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2)); + const m = ex.div( + e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2) + ); const be = e2.mul(-1).max(1).log10().gte(9); return neg + (be ? "" : m.toFixed(2)) + "e" + format(e2, 0, max, "mixed_sc"); } else if (e.lt(max)) { @@ -648,13 +716,16 @@ function decimalFormatGenerator(Decimal2) { case "standard": { let e3 = ex.log(1e3).floor(); if (e3.lt(1)) { - return neg + ex.toFixed(Math.max(Math.min(acc - e.toNumber(), acc), 0)); + return neg + ex.toFixed( + Math.max(Math.min(acc - e.toNumber(), acc), 0) + ); } const e3_mul = e3.mul(3); const ee = e3.log10().floor(); if (ee.gte(3e3)) return "e" + format(e, acc, max, "st"); let final = ""; - if (e3.lt(4)) final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; + if (e3.lt(4)) + final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; else { let ee3 = Math.floor(e3.log(1e3).toNumber()); if (ee3 < 100) ee3 = Math.max(ee3 - 1, 0); @@ -664,8 +735,10 @@ function decimalFormatGenerator(Decimal2) { const mod1000 = e3.sub(div1000.mul(1e3)).floor().toNumber(); if (mod1000 > 0) { if (mod1000 == 1 && !ee3) final = "U"; - if (ee3) final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); - if (mod1000 > 1) final = FORMATS2.standard.tier1(mod1000) + final; + if (ee3) + final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); + if (mod1000 > 1) + final = FORMATS2.standard.tier1(mod1000) + final; } e3 = div1000; ee3++; @@ -676,7 +749,8 @@ function decimalFormatGenerator(Decimal2) { return neg + (ee.gte(10) ? "" : m.toFixed(fixedAmt) + " ") + final; } default: - if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); + if (!FORMATS2[type]) + console.error(`Invalid format type "`, type, `"`); return neg + FORMATS2[type].format(ex, acc, max); } } @@ -694,9 +768,12 @@ function decimalFormatGenerator(Decimal2) { } function formatTime(ex, acc = 2, type = "s") { ex = new Decimal2(ex); - if (ex.gte(86400)) return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); - if (ex.gte(3600) || type == "d") return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); - if (ex.gte(60) || type == "h") return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); + if (ex.gte(86400)) + return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); + if (ex.gte(3600) || type == "d") + return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); + if (ex.gte(60) || type == "h") + return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); return (ex.gte(10) || type != "m" ? "" : "0") + format(ex, acc, 12, "sc"); } function formatTimeLong(ex, ms = false, acc = 0, max = 9, type = "mixed_sc") { @@ -5030,7 +5107,7 @@ function inverseFunctionApprox(f, n, mode = "geometric", iterations = DEFAULT_IT } if (f(upperBound).lt(n)) { console.warn( - "The function is not monotonically increasing. (f(n) < n)" + "eMath.js: The function is not monotonically increasing. (f(n) < n)" ); return { value: upperBound, @@ -5124,7 +5201,7 @@ function calculateUpgrade(value, upgrade, start, end = Decimal.dInf, mode, itera end = new Decimal(end); const target = end.sub(start); if (target.lt(0)) { - console.warn("calculateUpgrade: Invalid target: ", target); + console.warn("eMath.js: Invalid target for calculateItem: ", target); return [Decimal.dZero, Decimal.dZero]; } el = (typeof upgrade.el === "function" ? upgrade.el() : upgrade.el) ?? el; @@ -5304,7 +5381,7 @@ function calculateItem(value, item, tier = Decimal.dOne, target = Decimal.dInf) tier = new Decimal(tier); target = new Decimal(target); if (target.lt(0)) { - console.warn("calculateItem: Invalid target: ", target); + console.warn("eMath.js: Invalid target for calculateItem: ", target); return [Decimal.dZero, Decimal.dZero]; } if (target.eq(1)) { @@ -5594,6 +5671,7 @@ var CurrencyStatic = class { this.pointerAddUpgrade(upgrade); const addedUpgradeStatic = new UpgradeStatic( upgrade, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion () => this.pointerGetUpgrade(upgrade.id), () => this ); @@ -5653,7 +5731,7 @@ var CurrencyStatic = class { calculateUpgrade(id, target = Infinity, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return [Decimal.dZero, Decimal.dZero]; } target = upgrade.level.add(target); @@ -5684,7 +5762,7 @@ var CurrencyStatic = class { getNextCost(id, target = 1, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return Decimal.dZero; } const amount = this.calculateUpgrade(id, target, mode, iterations)[0]; @@ -5707,7 +5785,7 @@ var CurrencyStatic = class { getNextCostMax(id, target = 1, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return Decimal.dZero; } const upgCalc = this.calculateUpgrade(id, target, mode, iterations); @@ -5728,7 +5806,7 @@ var CurrencyStatic = class { buyUpgrade(id, target, mode, iterations) { const upgrade = this.getUpgrade(id); if (upgrade === null) { - console.warn(`Upgrade "${id}" not found.`); + console.warn(`eMath.js: Upgrade "${id}" not found.`); return false; } const [amount, cost] = this.calculateUpgrade( @@ -5774,6 +5852,7 @@ var CurrencyStatic = class { this.pointerAddItem(item); const addedUpgradeStatic = new Item( item, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion () => this.pointerGetItem(item.id), () => this ); @@ -5800,7 +5879,7 @@ var CurrencyStatic = class { calculateItem(id, tier, target) { const item = this.getItem(id); if (item === null) { - console.warn(`Item "${id}" not found.`); + console.warn(`eMath.js: Item "${id}" not found.`); return [Decimal.dZero, Decimal.dZero]; } return calculateItem(this.value, item, tier, target); @@ -5815,7 +5894,7 @@ var CurrencyStatic = class { buyItem(id, tier, target) { const item = this.getItem(id); if (item === null) { - console.warn(`Item "${id}" not found.`); + console.warn(`eMath.js: Item "${id}" not found.`); return false; } const [amount, cost] = this.calculateItem(id, tier, target); @@ -5868,7 +5947,7 @@ var AttributeStatic = class { */ update() { console.warn( - "AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed." + "eMath.js: AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed." ); if (this.boost) { this.pointer.value = this.boost.calculate(); @@ -6455,7 +6534,9 @@ var E = (() => { let shownWarning = false; const out = (x) => { if (!shownWarning) { - console.warn("The E function is deprecated. Use the Decimal class directly."); + console.warn( + "eMath.js: The E function is deprecated. Use the Decimal class directly." + ); shownWarning = true; } return new Decimal(x); @@ -6477,7 +6558,7 @@ export { Decimal, E, FORMATS, - FormatTypeList, + formatTypeList as FormatTypeList, Grid, GridCell, GridCellCollection, diff --git a/dist/presets/eMath.presets.js b/dist/presets/eMath.presets.js index 6f07de8..837907c 100644 --- a/dist/presets/eMath.presets.js +++ b/dist/presets/eMath.presets.js @@ -187,7 +187,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega.config.greek.length) + ); let lastLetter = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -228,7 +230,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega_short.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega_short.config.greek.length) + ); let lastLetter = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -254,6 +258,7 @@ function decimalFormatGenerator(Decimal2) { elemental: { config: { /** The list of elements */ + /* eslint-disable prettier/prettier */ element_lists: [ ["H"], ["He", "Li", "Be", "B", "C", "N", "O", "F"], @@ -368,6 +373,7 @@ function decimalFormatGenerator(Decimal2) { ], ["Og"] ] + /* eslint-enable prettier/prettier */ }, getOffset(group) { if (group == 1) return 1; @@ -399,11 +405,20 @@ function decimalFormatGenerator(Decimal2) { getAbbreviationAndValue(x) { const abbreviationListUnfloored = x.log(118).toNumber(); const abbreviationListIndex = Math.floor(abbreviationListUnfloored) + 1; - const abbreviationLength = FORMATS2.elemental.abbreviationLength(abbreviationListIndex); + const abbreviationLength = FORMATS2.elemental.abbreviationLength( + abbreviationListIndex + ); const abbreviationProgress = abbreviationListUnfloored - abbreviationListIndex + 1; - const abbreviationIndex = Math.floor(abbreviationProgress * abbreviationLength); - const abbreviation = FORMATS2.elemental.getAbbreviation(abbreviationListIndex, abbreviationProgress); - const value = new Decimal2(118).pow(abbreviationListIndex + abbreviationIndex / abbreviationLength - 1); + const abbreviationIndex = Math.floor( + abbreviationProgress * abbreviationLength + ); + const abbreviation = FORMATS2.elemental.getAbbreviation( + abbreviationListIndex, + abbreviationProgress + ); + const value = new Decimal2(118).pow( + abbreviationListIndex + abbreviationIndex / abbreviationLength - 1 + ); return [abbreviation, value]; }, formatElementalPart(abbreviation, n) { @@ -413,7 +428,12 @@ function decimalFormatGenerator(Decimal2) { return `${n.toString()} ${abbreviation}`; }, format(value, acc = 2) { - if (value.gt(new Decimal2(118).pow(new Decimal2(118).pow(new Decimal2(118).pow(4))))) return "e" + FORMATS2.elemental.format(value.log10(), acc); + if (value.gt( + new Decimal2(118).pow( + new Decimal2(118).pow(new Decimal2(118).pow(4)) + ) + )) + return "e" + FORMATS2.elemental.format(value.log10(), acc); let log = value.log(118); const slog = log.log(118); const sslog = slog.log(118).toNumber(); @@ -426,7 +446,12 @@ function decimalFormatGenerator(Decimal2) { parts.unshift([abbreviation, n]); } if (parts.length >= max) { - return parts.map((x) => FORMATS2.elemental.formatElementalPart(x[0], x[1])).join(" + "); + return parts.map( + (x) => ( + // @ts-expect-error - x has both string and decimal for some reason + FORMATS2.elemental.formatElementalPart(x[0], x[1]) + ) + ).join(" + "); } const formattedMantissa = new Decimal2(118).pow(log).toFixed(parts.length === 1 ? 3 : acc); if (parts.length === 0) { @@ -488,7 +513,9 @@ function decimalFormatGenerator(Decimal2) { return (slog.gte(1e9) ? "" : Decimal2.dTen.pow(slog.sub(slog.floor())).toFixed(4)) + "F" + FORMATS2.eng.format(slog.floor(), 0); } const m = ex.div(new Decimal2(1e3).pow(e.div(3).floor())); - return (e.log10().gte(9) ? "" : m.toFixed(new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber())) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); + return (e.log10().gte(9) ? "" : m.toFixed( + new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber() + )) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); } } }, @@ -513,12 +540,25 @@ function decimalFormatGenerator(Decimal2) { }, /** Layer format */ layer: { - layers: ["infinity", "eternity", "reality", "equality", "affinity", "celerity", "identity", "vitality", "immunity", "atrocity"], + layers: [ + "infinity", + "eternity", + "reality", + "equality", + "affinity", + "celerity", + "identity", + "vitality", + "immunity", + "atrocity" + ], format(ex, acc = 2, max) { ex = new Decimal2(ex); const layer = ex.max(1).log10().max(1).log(INFINITY_NUM.log10()).floor(); if (layer.lte(0)) return format(ex, acc, max, "sc"); - ex = Decimal2.dTen.pow(ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0)); + ex = Decimal2.dTen.pow( + ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0) + ); const meta = layer.div(10).floor(); const layer_id = layer.toNumber() % 10 - 1; return format(ex, Math.max(4, acc), max, "sc") + " " + (meta.gte(1) ? "meta" + (meta.gte(2) ? "^" + format(meta, 0, max, "sc") : "") + "-" : "") + (isNaN(layer_id) ? "nanity" : FORMATS2.layer.layers[layer_id]); @@ -564,8 +604,10 @@ function decimalFormatGenerator(Decimal2) { meta++; } if (meta == 0) return format(ex, acc, max, "sc"); - if (ex.gte(3)) return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); - if (ex.gte(2)) return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); + if (ex.gte(3)) + return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); + if (ex.gte(2)) + return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); return symbols2[meta] + symbols[meta] + "-" + format(inf.pow(ex.sub(1)), acc, max, "sc"); } }, @@ -610,7 +652,10 @@ function decimalFormatGenerator(Decimal2) { } else { const trunc = numLetters.sub(abbStart).add(1); const truncExponent = exponent.div(Decimal2.pow(alphabetLength + 1, trunc.sub(1))).floor(); - const truncLetters = convertToLetters(truncExponent, new Decimal2(abbStart)); + const truncLetters = convertToLetters( + truncExponent, + new Decimal2(abbStart) + ); letters = `${truncLetters}(${trunc.gt("1e9") ? trunc.format() : trunc.format(0)})`; } return letters; @@ -632,7 +677,12 @@ function decimalFormatGenerator(Decimal2) { ex = new Decimal2(ex); start = new Decimal2(start).div(1e3); if (ex.lt(start.mul(1e3))) return format(ex, acc, max, type); - const letters = FORMATS2.alphabet.getAbbreviation(ex, start, startDouble, abbStart); + const letters = FORMATS2.alphabet.getAbbreviation( + ex, + start, + startDouble, + abbStart + ); const mantissa = ex.div(Decimal2.pow(1e3, ex.log(1e3).floor())); const isAbbreviation = letters.length > (abbStart ?? 9) + 2; return `${!isAbbreviation ? mantissa.toFixed(acc) + " " : ""}${letters}`; @@ -646,7 +696,9 @@ function decimalFormatGenerator(Decimal2) { return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUBSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); } function toSuperscript(value) { - return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); + return value.toFixed(0).split("").map( + (x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)] + ).join(""); } function formatST(ex, acc = 2, max = 9, type = "st") { return format(ex, acc, max, type); @@ -664,7 +716,9 @@ function decimalFormatGenerator(Decimal2) { case "scientific": { if (ex.log10().lt(Math.min(-acc, 0)) && acc > 1) { const e2 = ex.log10().ceil(); - const m = ex.div(e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2)); + const m = ex.div( + e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2) + ); const be = e2.mul(-1).max(1).log10().gte(9); return neg + (be ? "" : m.toFixed(2)) + "e" + format(e2, 0, max, "mixed_sc"); } else if (e.lt(max)) { @@ -684,13 +738,16 @@ function decimalFormatGenerator(Decimal2) { case "standard": { let e3 = ex.log(1e3).floor(); if (e3.lt(1)) { - return neg + ex.toFixed(Math.max(Math.min(acc - e.toNumber(), acc), 0)); + return neg + ex.toFixed( + Math.max(Math.min(acc - e.toNumber(), acc), 0) + ); } const e3_mul = e3.mul(3); const ee = e3.log10().floor(); if (ee.gte(3e3)) return "e" + format(e, acc, max, "st"); let final = ""; - if (e3.lt(4)) final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; + if (e3.lt(4)) + final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; else { let ee3 = Math.floor(e3.log(1e3).toNumber()); if (ee3 < 100) ee3 = Math.max(ee3 - 1, 0); @@ -700,8 +757,10 @@ function decimalFormatGenerator(Decimal2) { const mod1000 = e3.sub(div1000.mul(1e3)).floor().toNumber(); if (mod1000 > 0) { if (mod1000 == 1 && !ee3) final = "U"; - if (ee3) final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); - if (mod1000 > 1) final = FORMATS2.standard.tier1(mod1000) + final; + if (ee3) + final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); + if (mod1000 > 1) + final = FORMATS2.standard.tier1(mod1000) + final; } e3 = div1000; ee3++; @@ -712,7 +771,8 @@ function decimalFormatGenerator(Decimal2) { return neg + (ee.gte(10) ? "" : m.toFixed(fixedAmt) + " ") + final; } default: - if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); + if (!FORMATS2[type]) + console.error(`Invalid format type "`, type, `"`); return neg + FORMATS2[type].format(ex, acc, max); } } @@ -730,9 +790,12 @@ function decimalFormatGenerator(Decimal2) { } function formatTime(ex, acc = 2, type = "s") { ex = new Decimal2(ex); - if (ex.gte(86400)) return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); - if (ex.gte(3600) || type == "d") return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); - if (ex.gte(60) || type == "h") return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); + if (ex.gte(86400)) + return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); + if (ex.gte(3600) || type == "d") + return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); + if (ex.gte(60) || type == "h") + return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); return (ex.gte(10) || type != "m" ? "" : "0") + format(ex, acc, 12, "sc"); } function formatTimeLong(ex, ms = false, acc = 0, max = 9, type = "mixed_sc") { diff --git a/dist/presets/eMath.presets.mjs b/dist/presets/eMath.presets.mjs index d183d0b..02f649a 100644 --- a/dist/presets/eMath.presets.mjs +++ b/dist/presets/eMath.presets.mjs @@ -147,7 +147,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega.config.greek.length) + ); let lastLetter = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -188,7 +190,9 @@ function decimalFormatGenerator(Decimal2) { format(value) { value = new Decimal2(value); const step = Decimal2.floor(value.div(1e3)); - const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega_short.config.greek.length)); + const omegaAmount = Decimal2.floor( + step.div(FORMATS2.omega_short.config.greek.length) + ); let lastLetter = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] + toSubscript(value.toNumber() % 1e3); const beyondGreekArrayBounds = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] === void 0; if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) { @@ -214,6 +218,7 @@ function decimalFormatGenerator(Decimal2) { elemental: { config: { /** The list of elements */ + /* eslint-disable prettier/prettier */ element_lists: [ ["H"], ["He", "Li", "Be", "B", "C", "N", "O", "F"], @@ -328,6 +333,7 @@ function decimalFormatGenerator(Decimal2) { ], ["Og"] ] + /* eslint-enable prettier/prettier */ }, getOffset(group) { if (group == 1) return 1; @@ -359,11 +365,20 @@ function decimalFormatGenerator(Decimal2) { getAbbreviationAndValue(x) { const abbreviationListUnfloored = x.log(118).toNumber(); const abbreviationListIndex = Math.floor(abbreviationListUnfloored) + 1; - const abbreviationLength = FORMATS2.elemental.abbreviationLength(abbreviationListIndex); + const abbreviationLength = FORMATS2.elemental.abbreviationLength( + abbreviationListIndex + ); const abbreviationProgress = abbreviationListUnfloored - abbreviationListIndex + 1; - const abbreviationIndex = Math.floor(abbreviationProgress * abbreviationLength); - const abbreviation = FORMATS2.elemental.getAbbreviation(abbreviationListIndex, abbreviationProgress); - const value = new Decimal2(118).pow(abbreviationListIndex + abbreviationIndex / abbreviationLength - 1); + const abbreviationIndex = Math.floor( + abbreviationProgress * abbreviationLength + ); + const abbreviation = FORMATS2.elemental.getAbbreviation( + abbreviationListIndex, + abbreviationProgress + ); + const value = new Decimal2(118).pow( + abbreviationListIndex + abbreviationIndex / abbreviationLength - 1 + ); return [abbreviation, value]; }, formatElementalPart(abbreviation, n) { @@ -373,7 +388,12 @@ function decimalFormatGenerator(Decimal2) { return `${n.toString()} ${abbreviation}`; }, format(value, acc = 2) { - if (value.gt(new Decimal2(118).pow(new Decimal2(118).pow(new Decimal2(118).pow(4))))) return "e" + FORMATS2.elemental.format(value.log10(), acc); + if (value.gt( + new Decimal2(118).pow( + new Decimal2(118).pow(new Decimal2(118).pow(4)) + ) + )) + return "e" + FORMATS2.elemental.format(value.log10(), acc); let log = value.log(118); const slog = log.log(118); const sslog = slog.log(118).toNumber(); @@ -386,7 +406,12 @@ function decimalFormatGenerator(Decimal2) { parts.unshift([abbreviation, n]); } if (parts.length >= max) { - return parts.map((x) => FORMATS2.elemental.formatElementalPart(x[0], x[1])).join(" + "); + return parts.map( + (x) => ( + // @ts-expect-error - x has both string and decimal for some reason + FORMATS2.elemental.formatElementalPart(x[0], x[1]) + ) + ).join(" + "); } const formattedMantissa = new Decimal2(118).pow(log).toFixed(parts.length === 1 ? 3 : acc); if (parts.length === 0) { @@ -448,7 +473,9 @@ function decimalFormatGenerator(Decimal2) { return (slog.gte(1e9) ? "" : Decimal2.dTen.pow(slog.sub(slog.floor())).toFixed(4)) + "F" + FORMATS2.eng.format(slog.floor(), 0); } const m = ex.div(new Decimal2(1e3).pow(e.div(3).floor())); - return (e.log10().gte(9) ? "" : m.toFixed(new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber())) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); + return (e.log10().gte(9) ? "" : m.toFixed( + new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber() + )) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0); } } }, @@ -473,12 +500,25 @@ function decimalFormatGenerator(Decimal2) { }, /** Layer format */ layer: { - layers: ["infinity", "eternity", "reality", "equality", "affinity", "celerity", "identity", "vitality", "immunity", "atrocity"], + layers: [ + "infinity", + "eternity", + "reality", + "equality", + "affinity", + "celerity", + "identity", + "vitality", + "immunity", + "atrocity" + ], format(ex, acc = 2, max) { ex = new Decimal2(ex); const layer = ex.max(1).log10().max(1).log(INFINITY_NUM.log10()).floor(); if (layer.lte(0)) return format(ex, acc, max, "sc"); - ex = Decimal2.dTen.pow(ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0)); + ex = Decimal2.dTen.pow( + ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0) + ); const meta = layer.div(10).floor(); const layer_id = layer.toNumber() % 10 - 1; return format(ex, Math.max(4, acc), max, "sc") + " " + (meta.gte(1) ? "meta" + (meta.gte(2) ? "^" + format(meta, 0, max, "sc") : "") + "-" : "") + (isNaN(layer_id) ? "nanity" : FORMATS2.layer.layers[layer_id]); @@ -524,8 +564,10 @@ function decimalFormatGenerator(Decimal2) { meta++; } if (meta == 0) return format(ex, acc, max, "sc"); - if (ex.gte(3)) return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); - if (ex.gte(2)) return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); + if (ex.gte(3)) + return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc"); + if (ex.gte(2)) + return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc"); return symbols2[meta] + symbols[meta] + "-" + format(inf.pow(ex.sub(1)), acc, max, "sc"); } }, @@ -570,7 +612,10 @@ function decimalFormatGenerator(Decimal2) { } else { const trunc = numLetters.sub(abbStart).add(1); const truncExponent = exponent.div(Decimal2.pow(alphabetLength + 1, trunc.sub(1))).floor(); - const truncLetters = convertToLetters(truncExponent, new Decimal2(abbStart)); + const truncLetters = convertToLetters( + truncExponent, + new Decimal2(abbStart) + ); letters = `${truncLetters}(${trunc.gt("1e9") ? trunc.format() : trunc.format(0)})`; } return letters; @@ -592,7 +637,12 @@ function decimalFormatGenerator(Decimal2) { ex = new Decimal2(ex); start = new Decimal2(start).div(1e3); if (ex.lt(start.mul(1e3))) return format(ex, acc, max, type); - const letters = FORMATS2.alphabet.getAbbreviation(ex, start, startDouble, abbStart); + const letters = FORMATS2.alphabet.getAbbreviation( + ex, + start, + startDouble, + abbStart + ); const mantissa = ex.div(Decimal2.pow(1e3, ex.log(1e3).floor())); const isAbbreviation = letters.length > (abbStart ?? 9) + 2; return `${!isAbbreviation ? mantissa.toFixed(acc) + " " : ""}${letters}`; @@ -606,7 +656,9 @@ function decimalFormatGenerator(Decimal2) { return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUBSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); } function toSuperscript(value) { - return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)]).join(""); + return value.toFixed(0).split("").map( + (x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)] + ).join(""); } function formatST(ex, acc = 2, max = 9, type = "st") { return format(ex, acc, max, type); @@ -624,7 +676,9 @@ function decimalFormatGenerator(Decimal2) { case "scientific": { if (ex.log10().lt(Math.min(-acc, 0)) && acc > 1) { const e2 = ex.log10().ceil(); - const m = ex.div(e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2)); + const m = ex.div( + e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2) + ); const be = e2.mul(-1).max(1).log10().gte(9); return neg + (be ? "" : m.toFixed(2)) + "e" + format(e2, 0, max, "mixed_sc"); } else if (e.lt(max)) { @@ -644,13 +698,16 @@ function decimalFormatGenerator(Decimal2) { case "standard": { let e3 = ex.log(1e3).floor(); if (e3.lt(1)) { - return neg + ex.toFixed(Math.max(Math.min(acc - e.toNumber(), acc), 0)); + return neg + ex.toFixed( + Math.max(Math.min(acc - e.toNumber(), acc), 0) + ); } const e3_mul = e3.mul(3); const ee = e3.log10().floor(); if (ee.gte(3e3)) return "e" + format(e, acc, max, "st"); let final = ""; - if (e3.lt(4)) final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; + if (e3.lt(4)) + final = ["", "K", "M", "B"][Math.round(e3.toNumber())]; else { let ee3 = Math.floor(e3.log(1e3).toNumber()); if (ee3 < 100) ee3 = Math.max(ee3 - 1, 0); @@ -660,8 +717,10 @@ function decimalFormatGenerator(Decimal2) { const mod1000 = e3.sub(div1000.mul(1e3)).floor().toNumber(); if (mod1000 > 0) { if (mod1000 == 1 && !ee3) final = "U"; - if (ee3) final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); - if (mod1000 > 1) final = FORMATS2.standard.tier1(mod1000) + final; + if (ee3) + final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : ""); + if (mod1000 > 1) + final = FORMATS2.standard.tier1(mod1000) + final; } e3 = div1000; ee3++; @@ -672,7 +731,8 @@ function decimalFormatGenerator(Decimal2) { return neg + (ee.gte(10) ? "" : m.toFixed(fixedAmt) + " ") + final; } default: - if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); + if (!FORMATS2[type]) + console.error(`Invalid format type "`, type, `"`); return neg + FORMATS2[type].format(ex, acc, max); } } @@ -690,9 +750,12 @@ function decimalFormatGenerator(Decimal2) { } function formatTime(ex, acc = 2, type = "s") { ex = new Decimal2(ex); - if (ex.gte(86400)) return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); - if (ex.gte(3600) || type == "d") return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); - if (ex.gte(60) || type == "h") return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); + if (ex.gte(86400)) + return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d"); + if (ex.gte(3600) || type == "d") + return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h"); + if (ex.gte(60) || type == "h") + return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m"); return (ex.gte(10) || type != "m" ? "" : "0") + format(ex, acc, 12, "sc"); } function formatTimeLong(ex, ms = false, acc = 0, max = 9, type = "mixed_sc") { diff --git a/dist/types/E/eMain.d.ts b/dist/types/E/eMain.d.ts index 67edb0b..26de19f 100644 --- a/dist/types/E/eMain.d.ts +++ b/dist/types/E/eMain.d.ts @@ -1,18 +1,19 @@ /** - * @file The main file for the Decimal library. + * @file The main file for the Decimal library. Declares the E function and the E type. */ import { Decimal } from "./e"; import type { DecimalSource } from "./e"; /** - * A function that returns a Decimal instance. Also contains static methods and properties of the Decimal class. - * @deprecated Use the Decimal class directly. This function will be removed in a future version. + * A function that returns a {@link Decimal} instance. + * Also contains static methods and properties of the {@link Decimal} class, + * and also functions as a type alias for the {@link Decimal} class. * @param x - The value to convert to a Decimal instance. - * @returns - The Decimal instance. + * @returns The Decimal instance. */ declare const E: ((x?: DecimalSource) => Decimal) & typeof Decimal; type E = Decimal; /** - * @deprecated Use the DecimalSource type directly. This type will be removed in a future version. + * A Decimal source, which can be a number, a Decimal instance, or a string that can be converted to a Decimal. */ type ESource = DecimalSource; export { E }; diff --git a/dist/types/E/format.d.ts b/dist/types/E/format.d.ts index dcb045b..2267fa9 100644 --- a/dist/types/E/format.d.ts +++ b/dist/types/E/format.d.ts @@ -23,7 +23,7 @@ type Decimal = DecimalType; type FormatType = "st" | "sc" | "scientific" | "omega" | "omega_short" | "elemental" | "old_sc" | "eng" | "mixed_sc" | "layer" | "standard" | "inf" | "alphabet"; /** A list of names for the standard notation */ declare const ST_NAMES: string[][][]; -declare const FormatTypeList: FormatType[]; +declare const formatTypeList: FormatType[]; /** * Generates a format function for the Decimal library. * @param Decimal - The Decimal constructor to use. @@ -305,4 +305,4 @@ declare function decimalFormatGenerator(Decimal: typeof DecimalType): { }; }; export type { FormatType }; -export { decimalFormatGenerator, ST_NAMES, FormatTypeList }; +export { decimalFormatGenerator, ST_NAMES, formatTypeList as FormatTypeList }; diff --git a/dist/types/E/lru-cache.d.ts b/dist/types/E/lru-cache.d.ts index 5ff0a15..7fd6a2c 100644 --- a/dist/types/E/lru-cache.d.ts +++ b/dist/types/E/lru-cache.d.ts @@ -7,14 +7,14 @@ * @template V The type of the value. */ declare class LRUCache { + /** The maximum size of the cache. */ + readonly maxSize: number; /** The map of keys to ListNodes. */ private map; /** The first node in the list. */ private first; /** The last node in the list. */ private last; - /** The maximum size of the cache. */ - readonly maxSize: number; /** * Constructs a new instance of the LRUCache class. * @param maxSize The maximum size for this cache. We recommend setting this diff --git a/dist/types/game/managers/DataManager.d.ts b/dist/types/game/managers/DataManager.d.ts index 5845e8c..9180b27 100644 --- a/dist/types/game/managers/DataManager.d.ts +++ b/dist/types/game/managers/DataManager.d.ts @@ -109,7 +109,7 @@ declare class DataManager { * @param value - The value to set the static data to. * @returns A getter for the static data. */ - setStatic(key: string, value: t): t; + setStatic(key: string, value: T): T; /** * Gets the static data for the given key. * @deprecated Set the return value of {@link setStatic} to a variable instead, as that is a getter and provides type checking. Also, static data is basically useless and should not be used. Use variables in local scope instead.