From d75e7a526a39892e93f25e6d46cf254da96fc1a5 Mon Sep 17 00:00:00 2001 From: zBlade Date: Mon, 6 May 2024 20:15:14 -0400 Subject: [PATCH] Fix various types --- dist/game/eMath.game.js | 6 ++++-- dist/game/eMath.game.min.js | 2 +- dist/game/eMath.game.mjs | 6 ++++-- dist/pixiGame/eMath.pixiGame.js | 6 ++++-- dist/pixiGame/eMath.pixiGame.mjs | 6 ++++-- dist/types/classes/Attribute.d.ts | 3 +++ dist/types/classes/Currency.d.ts | 2 +- dist/types/game/Game.d.ts | 6 ++++-- src/classes/Attribute.ts | 3 +++ src/classes/Currency.ts | 3 +-- src/game/Game.ts | 18 ++++++++---------- 11 files changed, 37 insertions(+), 24 deletions(-) diff --git a/dist/game/eMath.game.js b/dist/game/eMath.game.js index 1dab1c6f..eb562ada 100644 --- a/dist/game/eMath.game.js +++ b/dist/game/eMath.game.js @@ -7031,20 +7031,22 @@ var Game = class _Game { * Adds a new currency section to the game. {@link GameCurrency} is the class. * It automatically adds the currency and currencyStatic objects to the data and static objects for saving and loading. * @template N - The name + * @template U - The upgrade names for the currency. See {@link CurrencyStatic} for more information. * @param name - The name of the currency section. This is also the name of the data and static objects, so it must be unique. + * @param upgrades - The upgrades for the currency. * @returns A new instance of the gameCurrency class. * @example * const currency = game.addCurrency("currency"); * currency.static.gain(); * console.log(currency.value); // E(1) */ - addCurrency(name) { + addCurrency(name, upgrades = []) { this.dataManager.setData(name, { currency: new Currency() }); this.dataManager.setStatic(name, { // @ts-expect-error - fix this - currency: new CurrencyStatic(() => this.dataManager.getData(name).currency) + currency: new CurrencyStatic(() => this.dataManager.getData(name).currency, upgrades) // attributes: {}, }); const classInstance = new GameCurrency(() => this.dataManager.getData(name).currency, () => this.dataManager.getStatic(name).currency, this, name); diff --git a/dist/game/eMath.game.min.js b/dist/game/eMath.game.min.js index da56ac66..c9177523 100644 --- a/dist/game/eMath.game.min.js +++ b/dist/game/eMath.game.min.js @@ -1,4 +1,4 @@ -"use strict";(function(At,at){var Ct=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],at);else if(typeof module=="object"&&module.exports)module.exports=at();else{var lt=at(),Et=Ct?exports:At;for(var Ot in lt)Et[Ot]=lt[Ot]}})(typeof self<"u"?self:exports,()=>{var At={},at={exports:At},Ct=Object.create,lt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Ot=Object.getOwnPropertyNames,Ue=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty,bt=(t,e)=>function(){return e||(0,t[Ot(t)[0]])((e={exports:{}}).exports,e),e.exports},Rt=(t,e)=>{for(var r in e)lt(t,r,{get:e[r],enumerable:!0})},Qt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ot(e))!$e.call(t,n)&&n!==r&<(t,n,{get:()=>e[n],enumerable:!(i=Et(e,n))||i.enumerable});return t},ot=(t,e,r)=>(r=t!=null?Ct(Ue(t)):{},Qt(e||!t||!t.__esModule?lt(r,"default",{value:t,enumerable:!0}):r,t)),ze=t=>Qt(lt({},"__esModule",{value:!0}),t),ft=(t,e,r,i)=>{for(var n=i>1?void 0:i?Et(e,r):e,s=t.length-1,h;s>=0;s--)(h=t[s])&&(n=(i?h(e,r,n):h(n))||n);return i&&n&<(e,r,n),n},ct=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:d(),n=s(e);typeof i.Reflect<"u"&&(n=s(i.Reflect,n)),r(n,i),typeof i.Reflect>"u"&&(i.Reflect=e);function s(f,y){return function(l,u){Object.defineProperty(f,l,{configurable:!0,writable:!0,value:u}),y&&y(l,u)}}function h(){try{return Function("return this;")()}catch{}}function v(){try{return(0,eval)("(function() { return this; })()")}catch{}}function d(){return h()||v()}})(function(r,i){var n=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",h=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",v=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",d=typeof Object.create=="function",f={__proto__:[]}instanceof Array,y=!d&&!f,l={create:d?function(){return Jt(Object.create(null))}:f?function(){return Jt({__proto__:null})}:function(){return Jt({})},has:y?function(g,b){return n.call(g,b)}:function(g,b){return b in g},get:y?function(g,b){return n.call(g,b)?g[b]:void 0}:function(g,b){return g[b]}},u=Object.getPrototypeOf(Function),c=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Lr(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Pr(),w=typeof WeakMap=="function"?WeakMap:qr(),I=s?Symbol.for("@reflect-metadata:registry"):void 0,L=Fr(),F=xr(L);function a(g,b,O,C){if(j(O)){if(!Te(g))throw new TypeError;if(!Fe(b))throw new TypeError;return tt(g,b)}else{if(!Te(g))throw new TypeError;if(!J(b))throw new TypeError;if(!J(C)&&!j(C)&&!_t(C))throw new TypeError;return _t(C)&&(C=void 0),O=ut(O),nt(g,b,O,C)}}r("decorate",a);function S(g,b){function O(C,R){if(!J(C))throw new TypeError;if(!j(R)&&!Er(R))throw new TypeError;qt(g,b,C,R)}return O}r("metadata",S);function m(g,b,O,C){if(!J(O))throw new TypeError;return j(C)||(C=ut(C)),qt(g,b,O,C)}r("defineMetadata",m);function A(g,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),W(g,b,O)}r("hasMetadata",A);function _(g,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),Z(g,b,O)}r("hasOwnMetadata",_);function M(g,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),X(g,b,O)}r("getMetadata",M);function E(g,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),dt(g,b,O)}r("getOwnMetadata",E);function T(g,b){if(!J(g))throw new TypeError;return j(b)||(b=ut(b)),Bt(g,b)}r("getMetadataKeys",T);function G(g,b){if(!J(g))throw new TypeError;return j(b)||(b=ut(b)),Dt(g,b)}r("getOwnMetadataKeys",G);function H(g,b,O){if(!J(b))throw new TypeError;if(j(O)||(O=ut(O)),!J(b))throw new TypeError;j(O)||(O=ut(O));var C=It(b,O,!1);return j(C)?!1:C.OrdinaryDeleteMetadata(g,b,O)}r("deleteMetadata",H);function tt(g,b){for(var O=g.length-1;O>=0;--O){var C=g[O],R=C(b);if(!j(R)&&!_t(R)){if(!Fe(R))throw new TypeError;b=R}}return b}function nt(g,b,O,C){for(var R=g.length-1;R>=0;--R){var Q=g[R],et=Q(b,O,C);if(!j(et)&&!_t(et)){if(!J(et))throw new TypeError;C=et}}return C}function W(g,b,O){var C=Z(g,b,O);if(C)return!0;var R=Xt(b);return _t(R)?!1:W(g,R,O)}function Z(g,b,O){var C=It(b,O,!1);return j(C)?!1:Ee(C.OrdinaryHasOwnMetadata(g,b,O))}function X(g,b,O){var C=Z(g,b,O);if(C)return dt(g,b,O);var R=Xt(b);if(!_t(R))return X(g,R,O)}function dt(g,b,O){var C=It(b,O,!1);if(!j(C))return C.OrdinaryGetOwnMetadata(g,b,O)}function qt(g,b,O,C){var R=It(O,C,!0);R.OrdinaryDefineOwnMetadata(g,b,O,C)}function Bt(g,b){var O=Dt(g,b),C=Xt(g);if(C===null)return O;var R=Bt(C,b);if(R.length<=0)return O;if(O.length<=0)return R;for(var Q=new p,et=[],$=0,x=O;$=0&&x=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:P,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}},$}(),C=function(){function $(){this._keys=[],this._values=[],this._cacheKey=g,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 P=this._find(x,!1);return P>=0?this._values[P]:void 0},$.prototype.set=function(x,P){var q=this._find(x,!0);return this._values[q]=P,this},$.prototype.delete=function(x){var P=this._find(x,!1);if(P>=0){for(var q=this._keys.length,B=P+1;B>>8,l[u*2+1]=p%256}return l},decompressFromUint8Array:function(f){if(f==null)return d.decompress(f);for(var y=new Array(f.length/2),l=0,u=y.length;l>1}else{for(c=1,u=0;u>1}a--,a==0&&(a=Math.pow(2,m),m++),delete w[F]}else for(c=p[F],u=0;u>1;a--,a==0&&(a=Math.pow(2,m),m++),p[L]=S++,F=String(I)}if(F!==""){if(Object.prototype.hasOwnProperty.call(w,F)){if(F.charCodeAt(0)<256){for(u=0;u>1}else{for(c=1,u=0;u>1}a--,a==0&&(a=Math.pow(2,m),m++),delete w[F]}else for(c=p[F],u=0;u>1;a--,a==0&&(a=Math.pow(2,m),m++)}for(c=2,u=0;u>1;for(;;)if(_=_<<1,M==y-1){A.push(l(_));break}else M++;return A.join("")},decompress:function(f){return f==null?"":f==""?null:d._decompress(f.length,32768,function(y){return f.charCodeAt(y)})},_decompress:function(f,y,l){var u=[],c,p=4,w=4,I=3,L="",F=[],a,S,m,A,_,M,E,T={val:l(0),position:y,index:1};for(a=0;a<3;a+=1)u[a]=a;for(m=0,_=Math.pow(2,2),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;switch(c=m){case 0:for(m=0,_=Math.pow(2,8),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;E=i(m);break;case 1:for(m=0,_=Math.pow(2,16),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;E=i(m);break;case 2:return""}for(u[3]=E,S=E,F.push(E);;){if(T.index>f)return"";for(m=0,_=Math.pow(2,I),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;switch(E=m){case 0:for(m=0,_=Math.pow(2,8),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;u[w++]=i(m),E=w-1,p--;break;case 1:for(m=0,_=Math.pow(2,16),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;u[w++]=i(m),E=w-1,p--;break;case 2:return F.join("")}if(p==0&&(p=Math.pow(2,I),I++),u[E])L=u[E];else if(E===w)L=S+S.charAt(0);else return null;F.push(L),u[w++]=S+L.charAt(0),p--,S=L,p==0&&(p=Math.pow(2,I),I++)}}};return d}();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})}}),Ze=bt({"node_modules/crypt/crypt.js"(t,e){(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i={rotl:function(n,s){return n<>>32-s},rotr:function(n,s){return n<<32-s|n>>>s},endian:function(n){if(n.constructor==Number)return i.rotl(n,8)&16711935|i.rotl(n,24)&4278255360;for(var s=0;s0;n--)s.push(Math.floor(Math.random()*256));return s},bytesToWords:function(n){for(var s=[],h=0,v=0;h>>5]|=n[h]<<24-v%32;return s},wordsToBytes:function(n){for(var s=[],h=0;h>>5]>>>24-h%32&255);return s},bytesToHex:function(n){for(var s=[],h=0;h>>4).toString(16)),s.push((n[h]&15).toString(16));return s.join("")},hexToBytes:function(n){for(var s=[],h=0;h>>6*(3-d)&63)):s.push("=");return s.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var s=[],h=0,v=0;h>>6-v*2);return s}};e.exports=i})()}}),Kt=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=[],s=0;s>>24)&16711935|(f[w]<<24|f[w]>>>8)&4278255360;f[y>>>5]|=128<>>9<<4)+14]=y;for(var I=h._ff,L=h._gg,F=h._hh,a=h._ii,w=0;w>>0,u=u+m>>>0,c=c+A>>>0,p=p+_>>>0}return r.endian([l,u,c,p])};h._ff=function(v,d,f,y,l,u,c){var p=v+(d&f|~d&y)+(l>>>0)+c;return(p<>>32-u)+d},h._gg=function(v,d,f,y,l,u,c){var p=v+(d&y|f&~y)+(l>>>0)+c;return(p<>>32-u)+d},h._hh=function(v,d,f,y,l,u,c){var p=v+(d^f^y)+(l>>>0)+c;return(p<>>32-u)+d},h._ii=function(v,d,f,y,l,u,c){var p=v+(f^(d|~y))+(l>>>0)+c;return(p<>>32-u)+d},h._blocksize=16,h._digestsize=16,e.exports=function(v,d){if(v==null)throw new Error("Illegal argument "+v);var f=r.wordsToBytes(h(v,d));return d&&d.asBytes?f:d&&d.asString?s.bytesToString(f):r.bytesToHex(f)}})()}}),te={};Rt(te,{eMath:()=>_r}),at.exports=ze(te);var Rr=ot(ct()),jr=ot(ct()),ee={};Rt(ee,{Attribute:()=>Lt,AttributeStatic:()=>pe,Boost:()=>zt,BoostObject:()=>Nt,Currency:()=>yt,CurrencyStatic:()=>me,DEFAULT_ITERATIONS:()=>xt,E:()=>k,FORMATS:()=>pr,FormatTypeList:()=>er,Grid:()=>yr,GridCell:()=>ve,LRUCache:()=>jt,ListNode:()=>re,UpgradeData:()=>vt,UpgradeStatic:()=>ge,calculateSum:()=>Zt,calculateSumApprox:()=>ce,calculateSumLoop:()=>le,calculateUpgrade:()=>he,decimalToJSONString:()=>kt,inverseFunctionApprox:()=>Yt,roundingBase:()=>vr,upgradeToCacheNameEL:()=>Ht});var Gr=ot(ct()),jt=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 re(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}}},re=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},U;(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"})(U||(U={}));var We=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===U.CLASS_TO_CLASS||i===U.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?i===U.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),s=n&&n.get(void 0);return i&&s||!i&&!s?"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===U.CLASS_TO_CLASS||r===U.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===U.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===U.CLASS_TO_CLASS||r===U.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===U.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(l){return l.propertyName!==void 0}));for(var s=[],h=0,v=this.getAncestors(r);h0&&(h=h.filter(function(l){return!f.includes(l)})),this.options.version!==void 0&&(h=h.filter(function(l){var u=rt.findExposeMetadata(e,l);return!u||!u.options?!0:n.checkVersion(u.options.since,u.options.until)})),this.options.groups&&this.options.groups.length?h=h.filter(function(l){var u=rt.findExposeMetadata(e,l);return!u||!u.options?!0:n.checkGroups(u.options.groups)}):h=h.filter(function(l){var u=rt.findExposeMetadata(e,l);return!u||!u.options||!u.options.groups||!u.options.groups.length})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(h=h.filter(function(y){return n.options.excludePrefixes.every(function(l){return y.substr(0,l.length)!==l})})),h=h.filter(function(y,l,u){return u.indexOf(y)===l}),h},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)&&(A="\u03C9");let M=t.log(a,8e3).toNumber();if(m.equals(0))return A;if(m.gt(0)&&m.lte(3)){let G=[];for(let H=0;HNumber.MAX_SAFE_INTEGER)&&(A="\u03C9");let M=t.log(a,8e3).toNumber();if(m.equals(0))return A;if(m.gt(0)&&m.lte(2)){let G=[];for(let H=0;H118?e.elemental.beyondOg(_):e.elemental.config.element_lists[a-1][A]},beyondOg(a){let S=Math.floor(Math.log10(a)),m=["n","u","b","t","q","p","h","s","o","e"],A="";for(let _=S;_>=0;_--){let M=Math.floor(a/Math.pow(10,_))%10;A==""?A=m[M].toUpperCase():A+=m[M]}return A},abbreviationLength(a){return a==1?1:Math.pow(Math.floor(a/2)+1,2)*2},getAbbreviationAndValue(a){let S=a.log(118).toNumber(),m=Math.floor(S)+1,A=e.elemental.abbreviationLength(m),_=S-m+1,M=Math.floor(_*A),E=e.elemental.getAbbreviation(m,_),T=new t(118).pow(m+M/A-1);return[E,T]},formatElementalPart(a,S){return S.eq(1)?a:`${S} ${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 m=a.log(118),_=m.log(118).log(118).toNumber(),M=Math.max(4-_*2,1),E=[];for(;m.gte(1)&&E.length=M)return E.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ");let T=new t(118).pow(m).toFixed(E.length===1?3:S);return E.length===0?T:E.length===1?`${T} \xD7 ${e.elemental.formatElementalPart(E[0][0],E[0][1])}`:`${T} \xD7 (${E.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ")})`}},old_sc:{format(a,S){a=new t(a);let m=a.log10().floor();if(m.lt(9))return m.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)?"":new t(10).pow(_.sub(_.floor())).toFixed(4))+"F"+e.old_sc.format(_.floor(),0)}let A=a.div(new t(10).pow(m));return(m.log10().gte(9)?"":A.toFixed(4))+"e"+e.old_sc.format(m,0)}}},eng:{format(a,S=2){a=new t(a);let m=a.log10().floor();if(m.lt(9))return m.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)?"":new t(10).pow(_.sub(_.floor())).toFixed(4))+"F"+e.eng.format(_.floor(),0)}let A=a.div(new t(1e3).pow(m.div(3).floor()));return(m.log10().gte(9)?"":A.toFixed(new t(4).sub(m.sub(m.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(m.div(3).floor().mul(3),0)}}},mixed_sc:{format(a,S,m=9){a=new t(a);let A=a.log10().floor();return A.lt(303)&&A.gte(m)?d(a,S,m,"st"):d(a,S,m,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(a,S=2,m){a=new t(a);let A=a.max(1).log10().max(1).log(r.log10()).floor();if(A.lte(0))return d(a,S,m,"sc");a=new t(10).pow(a.max(1).log10().div(r.log10().pow(A)).sub(A.gte(1)?1:0));let _=A.div(10).floor(),M=A.toNumber()%10-1;return d(a,Math.max(4,S),m,"sc")+" "+(_.gte(1)?"meta"+(_.gte(2)?"^"+d(_,0,m,"sc"):"")+"-":"")+(isNaN(M)?"nanity":e.layer.layers[M])}},standard:{tier1(a){return gt[0][0][a%10]+gt[0][1][Math.floor(a/10)%10]+gt[0][2][Math.floor(a/100)]},tier2(a){let S=a%10,m=Math.floor(a/10)%10,A=Math.floor(a/100)%10,_="";return a<10?gt[1][0][a]:(m==1&&S==0?_+="Vec":_+=gt[1][1][S]+gt[1][2][m],_+=gt[1][3][A],_)}},inf:{format(a,S,m){a=new t(a);let A=0,_=new t(Number.MAX_VALUE),M=["","\u221E","\u03A9","\u03A8","\u028A"],E=["","","m","mm","mmm"];for(;a.gte(_);)a=a.log(_),A++;return A==0?d(a,S,m,"sc"):a.gte(3)?E[A]+M[A]+"\u03C9^"+d(a.sub(1),S,m,"sc"):a.gte(2)?E[A]+"\u03C9"+M[A]+"-"+d(_.pow(a.sub(2)),S,m,"sc"):E[A]+M[A]+"-"+d(_.pow(a.sub(1)),S,m,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(a,S=new t(1e15),m=!1,A=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,E=a.log(1e3).sub(S.log(1e3)).floor(),T=E.add(1).log(M+1).ceil(),G="",H=(tt,nt)=>{let W=tt,Z="";for(let X=0;X=M)return"\u03C9";Z=_[dt]+Z,W=W.sub(1).div(M).floor()}return Z};if(T.lt(A))G=H(E,T);else{let tt=T.sub(A).add(1),nt=E.div(t.pow(M+1,tt.sub(1))).floor();G=`${H(nt,new t(A))}(${tt.gt("1e9")?tt.format():tt.format(0)})`}return G},format(a,S=2,m=9,A="mixed_sc",_=new t(1e15),M=!1,E){if(a=new t(a),_=new t(_).div(1e3),a.lt(_.mul(1e3)))return d(a,S,m,A);let T=e.alphabet.getAbbreviation(a,_,M,E),G=a.div(t.pow(1e3,a.log(1e3).floor()));return`${T.length>(E??9)+2?"":G.toFixed(S)+" "}${T}`}}},r=new t(2).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 s(a){return a.toFixed(0).split("").map(S=>S==="-"?"\u208B":i[parseInt(S,10)]).join("")}function h(a){return a.toFixed(0).split("").map(S=>S==="-"?"\u208B":n[parseInt(S,10)]).join("")}function v(a,S=2,m=9,A="st"){return d(a,S,m,A)}function d(a,S=2,m=9,A="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(A){case"sc":case"scientific":if(a.log10().lt(Math.min(-S,0))&&S>1){let E=a.log10().ceil(),T=a.div(E.eq(-1)?new t(.1):new t(10).pow(E)),G=E.mul(-1).max(1).log10().gte(9);return _+(G?"":T.toFixed(2))+"e"+d(E,0,m,"mixed_sc")}else if(M.lt(m)){let E=Math.max(Math.min(S-M.toNumber(),S),0);return _+(E>0?a.toFixed(E):a.toFixed(E).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(a.gte("eeee10")){let G=a.slog();return(G.gte(1e9)?"":new t(10).pow(G.sub(G.floor())).toFixed(2))+"F"+d(G.floor(),0)}let E=a.div(new t(10).pow(M)),T=M.log10().gte(9);return _+(T?"":E.toFixed(2))+"e"+d(M,0,m,"mixed_sc")}case"st":case"standard":{let E=a.log(1e3).floor();if(E.lt(1))return _+a.toFixed(Math.max(Math.min(S-M.toNumber(),S),0));let T=E.mul(3),G=E.log10().floor();if(G.gte(3e3))return"e"+d(M,S,m,"st");let H="";if(E.lt(4))H=["","K","M","B"][Math.round(E.toNumber())];else{let W=Math.floor(E.log(1e3).toNumber());for(W<100&&(W=Math.max(W-1,0)),E=E.sub(1).div(new t(10).pow(W*3));E.gt(0);){let Z=E.div(1e3).floor(),X=E.sub(Z.mul(1e3)).floor().toNumber();X>0&&(X==1&&!W&&(H="U"),W&&(H=e.standard.tier2(W)+(H?"-"+H:"")),X>1&&(H=e.standard.tier1(X)+H)),E=Z,W++}}let tt=a.div(new t(10).pow(T)),nt=S===2?new t(2).sub(M.sub(T)).add(1).toNumber():S;return _+(G.gte(10)?"":tt.toFixed(nt)+" ")+H}default:return e[A]||console.error('Invalid format type "',A,'"'),_+e[A].format(a,S,m)}}function f(a,S,m="mixed_sc",A,_){a=new t(a),S=new t(S);let M=a.add(S),E,T=M.div(a);return T.gte(10)&&a.gte(1e100)?(T=T.log10().mul(20),E="(+"+d(T,A,_,m)+" OoMs/sec)"):E="(+"+d(S,A,_,m)+"/sec)",E}function y(a,S=2,m="s"){return a=new t(a),a.gte(86400)?d(a.div(86400).floor(),0,12,"sc")+":"+y(a.mod(86400),S,"d"):a.gte(3600)||m=="d"?(a.div(3600).gte(10)||m!="d"?"":"0")+d(a.div(3600).floor(),0,12,"sc")+":"+y(a.mod(3600),S,"h"):a.gte(60)||m=="h"?(a.div(60).gte(10)||m!="h"?"":"0")+d(a.div(60).floor(),0,12,"sc")+":"+y(a.mod(60),S,"m"):(a.gte(10)||m!="m"?"":"0")+d(a,S,12,"sc")}function l(a,S=!1,m=0,A=9,_="mixed_sc"){let M=Dt=>d(Dt,m,A,_);a=new t(a);let E=a.mul(1e3).mod(1e3).floor(),T=a.mod(60).floor(),G=a.div(60).mod(60).floor(),H=a.div(3600).mod(24).floor(),tt=a.div(86400).mod(365.2425).floor(),nt=a.div(31556952).floor(),W=nt.eq(1)?" year":" years",Z=tt.eq(1)?" day":" days",X=H.eq(1)?" hour":" hours",dt=G.eq(1)?" minute":" minutes",qt=T.eq(1)?" second":" seconds",Bt=E.eq(1)?" millisecond":" milliseconds";return`${nt.gt(0)?M(nt)+W+", ":""}${tt.gt(0)?M(tt)+Z+", ":""}${H.gt(0)?M(H)+X+", ":""}${G.gt(0)?M(G)+dt+", ":""}${T.gt(0)?M(T)+qt+",":""}${S&&E.gt(0)?" "+M(E)+Bt:""}`.replace(/,([^,]*)$/,"$1").trim()}function u(a){return a=new t(a),d(new t(1).sub(a).mul(100))+"%"}function c(a){return a=new t(a),d(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 w(a,S,m=10){return t.gte(a,10)?t.pow(m,t.log(a,m).pow(S)):new t(a)}function I(a,S=0){a=new t(a);let m=(E=>E.map((T,G)=>({name:T.name,altName:T.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:"E",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),A="",_=a.lte(0)?0:t.min(t.log(a,1e3).sub(1),m.length-1).floor().toNumber(),M=m[_];if(_===0)switch(S){case 1:A="";break;case 2:case 0:default:A=a.format();break}switch(S){case 1:A=M.name;break;case 2:A=a.divide(M.value).format();break;case 3:A=M.altName;break;case 0:default:A=`${a.divide(M.value).format()} ${M.name}`;break}return A}function L(a,S=!1){return`${I(a,2)} ${I(a,1)}eV${S?"/c^2":""}`}let F={...e,toSubscript:s,toSuperscript:h,formatST:v,format:d,formatGain:f,formatTime:y,formatTimeLong:l,formatReduction:u,formatPercent:c,formatMult:p,expMult:w,metric:I,ev:L};return{FORMATS:e,formats:F}}var Ut=17,ir=9e15,nr=Math.log10(9e15),sr=1/9e15,ar=308,or=-324,ae=5,ur=1023,fr=!0,lr=!1,cr=function(){let t=[];for(let r=or+1;r<=ar;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),mt=[2,Math.E,3,4,5,6,7,8,9,10],hr=[[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]],dr=[[-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]],N=function(e){return o.fromValue_noAlloc(e)},D=function(t,e,r){return o.fromComponents(t,e,r)},Y=function(e,r,i){return o.fromComponents_noNormalize(e,r,i)},ht=function(e,r){let i=r+1,n=Math.ceil(Math.log10(Math.abs(e))),s=Math.round(e*Math.pow(10,i-n))*Math.pow(10,n-i);return parseFloat(s.toFixed(Math.max(i-n,0)))},$t=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},gr=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},mr=.36787944117144233,oe=.5671432904097838,ue=function(t,e=1e-10){let r,i;if(!Number.isFinite(t)||t===0)return t;if(t===1)return oe;t<10?r=0:r=Math.log(t)-Math.log(Math.log(t));for(let n=0;n<100;++n){if(i=(t*Math.exp(-r)+r*r)/(r+1),Math.abs(i-r).5?1:-1;if(Math.random()*20<1)return Y(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)),D(e,r,n)}static affordGeometricSeries_core(t,e,r,i){let n=e.mul(r.pow(i));return o.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(o.sub(1,r.pow(t))).div(o.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let s=e.add(i.mul(r)).sub(r.div(2)),h=s.pow(2);return s.neg().add(h.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.sign==1?(this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY):this.sign==-1&&(this.mag=Number.NEGATIVE_INFINITY,this.layer=Number.NEGATIVE_INFINITY),this;if(this.layer===0&&this.mag=ir)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=o.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);fr?t=t.replace(",",""):lr&&(t=t.replace(",","."));let n=t.split("^^^");if(n.length===2){let w=parseFloat(n[0]),I=parseFloat(n[1]),L=n[1].split(";"),F=1;if(L.length===2&&(F=parseFloat(L[1]),isFinite(F)||(F=1)),isFinite(w)&&isFinite(I)){let a=o.pentate(w,I,F,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}let s=t.split("^^");if(s.length===2){let w=parseFloat(s[0]),I=parseFloat(s[1]),L=s[1].split(";"),F=1;if(L.length===2&&(F=parseFloat(L[1]),isFinite(F)||(F=1)),isFinite(w)&&isFinite(I)){let a=o.tetrate(w,I,F,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}let h=t.split("^");if(h.length===2){let w=parseFloat(h[0]),I=parseFloat(h[1]);if(isFinite(w)&&isFinite(I)){let L=o.pow(w,I);return this.sign=L.sign,this.layer=L.layer,this.mag=L.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}t=t.trim().toLowerCase();let v,d,f=t.split("pt");if(f.length===2){v=10,d=parseFloat(f[0]),f[1]=f[1].replace("(",""),f[1]=f[1].replace(")","");let w=parseFloat(f[1]);if(isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=o.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}if(f=t.split("p"),f.length===2){v=10,d=parseFloat(f[0]),f[1]=f[1].replace("(",""),f[1]=f[1].replace(")","");let w=parseFloat(f[1]);if(isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=o.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}if(f=t.split("f"),f.length===2){v=10,f[0]=f[0].replace("(",""),f[0]=f[0].replace(")","");let w=parseFloat(f[0]);if(f[1]=f[1].replace("(",""),f[1]=f[1].replace(")",""),d=parseFloat(f[1]),isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=o.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}let y=t.split("e"),l=y.length-1;if(l===0){let w=parseFloat(t);if(isFinite(w))return this.fromNumber(w),o.fromStringCache.size>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}else if(l===1){let w=parseFloat(t);if(isFinite(w)&&w!==0)return this.fromNumber(w),o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}let u=t.split("e^");if(u.length===2){this.sign=1,u[0].charAt(0)=="-"&&(this.sign=-1);let w="";for(let I=0;I=43&&L<=57||L===101)w+=u[1].charAt(I);else return this.layer=parseFloat(w),this.mag=parseFloat(u[1].substr(I+1)),this.normalize(),o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}if(l<1)return this.sign=0,this.layer=0,this.mag=0,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this;let c=parseFloat(y[0]);if(c===0)return this.sign=0,this.layer=0,this.mag=0,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this;let p=parseFloat(y[y.length-1]);if(l>=2){let w=parseFloat(y[y.length-2]);isFinite(w)&&(p*=Math.sign(w),p+=$t(w))}if(!isFinite(c))this.sign=y[0]==="-"?-1:1,this.layer=l,this.mag=p;else if(l===1)this.sign=Math.sign(c),this.layer=1,this.mag=p+Math.log10(Math.abs(c));else if(this.sign=Math.sign(c),this.layer=l,l===2){let w=o.mul(D(1,2,p),N(c));return this.sign=w.sign,this.layer=w.layer,this.mag=w.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}else this.mag=p;return this.normalize(),o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}fromValue(t){return t instanceof o?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.NEGATIVE_INFINITY&&this.layer===Number.NEGATIVE_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:ht(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:ht(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.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_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<=ae?(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):ht(this.m,t)+"e"+ht(this.e,t):this.layer===1?ht(this.m,t)+"e"+ht(this.e,t):this.layer<=ae?(this.sign===-1?"-":"")+"e".repeat(this.layer)+ht(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+ht(this.mag,t)}abs(){return Y(this.sign===0?0:1,this.layer,this.mag)}neg(){return Y(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?o.dZero:this.layer===0?D(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?this.sign===-1?o.dNegOne:o.dZero:this.sign===-1?this.neg().ceil().neg():this.layer===0?D(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?this.sign===1?o.dOne:o.dZero:this.sign===-1?this.neg().floor().neg():this.layer===0?D(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?o.dZero:this.layer===0?D(this.sign,0,Math.trunc(this.mag)):this}add(t){let e=N(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer)||this.sign===0)return e;if(e.sign===0)return this;if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return Y(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(o.cmpabs(this,e)>0?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return o.fromNumber(r.sign*r.mag+i.sign*i.mag);let n=r.layer*Math.sign(r.mag),s=i.layer*Math.sign(i.mag);if(n-s>=2)return r;if(n===0&&s===-1){if(Math.abs(i.mag-Math.log10(r.mag))>Ut)return r;{let h=Math.pow(10,Math.log10(r.mag)-i.mag),v=i.sign+r.sign*h;return D(Math.sign(v),1,i.mag+Math.log10(Math.abs(v)))}}if(n===1&&s===0){if(Math.abs(r.mag-Math.log10(i.mag))>Ut)return r;{let h=Math.pow(10,r.mag-Math.log10(i.mag)),v=i.sign+r.sign*h;return D(Math.sign(v),1,Math.log10(i.mag)+Math.log10(Math.abs(v)))}}if(Math.abs(r.mag-i.mag)>Ut)return r;{let h=Math.pow(10,r.mag-i.mag),v=i.sign+r.sign*h;return D(Math.sign(v),1,i.mag+Math.log10(Math.abs(v)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(N(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=N(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer))return e;if(this.sign===0||e.sign===0)return Y(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return Y(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=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return o.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return D(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return D(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return D(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let n=D(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(D(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return D(r.sign*i.sign,n.layer+1,n.sign*n.mag)}if(r.layer===2&&i.layer===2){let n=D(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(D(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return D(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=N(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?o.dNaN:this.layer===0?D(this.sign,0,1/this.mag):D(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=N(t).abs();if(e.eq(o.dZero))return o.dZero;let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new o(r%i):this.sub(e).eq(this)?o.dZero:e.sub(this).eq(e)?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=N(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?e: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=N(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=N(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=$t(n)),this.layer0?D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):D(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?o.dNaN:this.layer>0?D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):D(this.sign,0,Math.log10(this.mag))}log(t){return t=N(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?o.dNaN:this.layer===0&&t.layer===0?D(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):o.div(this.log10(),t.log10())}log2(){return this.sign<=0?o.dNaN:this.layer===0?D(this.sign,0,Math.log2(this.mag)):this.layer===1?D(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?D(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?o.dNaN:this.layer===0?D(this.sign,0,Math.log(this.mag)):this.layer===1?D(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?D(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=N(t),r=this,i=e;if(r.sign===0)return i.eq(0)?Y(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return Y(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:o.dNaN:n}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return o.dNaN;let t=this;if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return D(1,0,e);if(t.sign===0)return o.dOne;t=Y(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?D(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?D(-t.sign,t.layer+1,-t.mag):o.dOne}pow_base(t){return N(t).pow(this)}root(t){let e=N(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?o.exp(o.mul(this,o.ln(this).sub(1))):o.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(Y(1,0,24)))return o.fromNumber(gr(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,s=1/n,h=e+s;if(h===e||(e=h,i=i*r,n=360*i,s=1/n,h=e-s,h===e))return o.exp(e);e=h,i=i*r,n=1260*i;let v=1/n;return e=e+v,i=i*r,n=1680*i,v=1/n,e=e-v,o.exp(e)}else return this.layer===1?o.exp(o.mul(this,o.ln(this).sub(1))):o.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?o.dOne:this.layer===0&&this.mag<=709.7?o.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?D(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?D(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):D(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return o.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return D(1,2,Math.log10(this.mag)-.3010299956639812);{let t=o.div(Y(this.sign,this.layer-1,this.mag),Y(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=Y(1,0,1),r=!1){if(t===1)return o.pow(this,e);if(t===0)return new o(e);if(this.eq(o.dOne))return o.dOne;if(this.eq(-1))return o.pow(this,e);if(t===Number.POSITIVE_INFINITY){let s=this.toNumber();if(s<=1.444667861009766&&s>=.06598803584531254){if(s>1.444667861009099)return o.fromNumber(Math.E);let h=o.ln(this).neg();return h.lambertw().div(h)}else return s>1.444667861009766?o.fromNumber(Number.POSITIVE_INFINITY):o.dNaN}if(this.eq(o.dZero)){let s=Math.abs((t+1)%2);return s>1&&(s=2-s),o.fromNumber(s)}if(t<0)return o.iteratedlog(e,this,-t,r);e=N(e);let i=t;t=Math.trunc(t);let n=i-t;if(this.gt(o.dZero)&&this.lte(1.444667861009766)&&(i>1e4||!r)){t=Math.min(1e4,t);for(let s=0;s1e4){let s=this.pow(e);return i<=1e4||Math.ceil(i)%2==0?e.mul(1-n).add(s.mul(n)):e.mul(n).add(s.mul(1-n))}return e}n!==0&&(e.eq(o.dOne)?this.gt(10)||r?e=this.pow(n):(e=o.fromNumber(o.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):e=e.layeradd(n,this,r));for(let s=0;s3)return Y(e.sign,e.layer+(t-s-1),e.mag);if(s>1e4)return e}return e}iteratedexp(t=2,e=Y(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return o.tetrate(t,-e,this,r);t=N(t);let i=o.fromDecimal(this),n=e;e=Math.trunc(e);let s=n-e;if(i.layer-t.layer>3){let h=Math.min(e,i.layer-t.layer-3);e-=h,i.layer-=h}for(let h=0;h1e4)return i}return s>0&&s<1&&(t.eq(10)?i=i.layeradd10(-s,r):i=i.layeradd(-s,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,n=!1,s=!1,h=this.slog_internal(t,r).toNumber();for(let v=1;v1&&s!=f&&(n=!0),s=f,n?i/=2:i*=2,i=Math.abs(i)*(f?-1:1),h+=i,i===0)break}return o.fromNumber(h)}slog_internal(t=10,e=!1){if(t=N(t),t.lte(o.dZero)||t.eq(o.dOne))return o.dNaN;if(t.lt(o.dOne))return this.eq(o.dOne)?o.dZero:this.eq(o.dZero)?o.dNegOne:o.dNaN;if(this.mag<0||this.eq(o.dZero))return o.dNegOne;let r=0,i=o.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(o.dZero))i=o.pow(t,i),r-=1;else{if(i.lte(o.dOne))return e?o.fromNumber(r+i.toNumber()-1):o.fromNumber(r+o.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=o.log(i,t)}return o.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:o.critical_section(t,e,dr)}static tetrate_critical(t,e){return o.critical_section(t,e,hr)}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,s=0;for(let v=0;vt){let d=(t-mt[v])/(mt[v+1]-mt[v]);n=r[v][Math.floor(e)]*(1-d)+r[v+1][Math.floor(e)]*d,s=r[v][Math.ceil(e)]*(1-d)+r[v+1][Math.ceil(e)]*d;break}let h=e-Math.floor(e);return n<=0||s<=0?n*(1-h)+s*h:Math.pow(t,Math.log(n)/Math.log(t)*(1-h)+Math.log(s)/Math.log(t)*h)}layeradd10(t,e=!1){t=o.fromValue_noAlloc(t).toNumber();let r=o.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 n=this.slog(e).toNumber()+t;return n>=0?o.tetrate(e,n,o.dOne,r):Number.isFinite(n)?n>=-1?o.log(o.tetrate(e,n+1,o.dOne,r),e):o.log(o.log(o.tetrate(e,n+2,o.dOne,r),e),e):o.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return o.fromNumber(ue(this.toNumber()));if(this.layer===0)return o.fromNumber(ue(this.sign*this.mag));if(this.layer===1)return fe(this);if(this.layer===2)return fe(this);if(this.layer>=3)return Y(this.sign,this.layer-1,this.mag);throw"Unhandled behavior in lambertw()"}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(o.dInf))return o.dInf;if(!this.isFinite())return o.dNaN;if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return o.fromNumber(t).add(2).pow(this.recip());if(t<=0)return o.dNaN;if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return emr?this.pow(this.recip()):o.dNaN}if(this.eq(1))return o.dOne;if(this.lt(0))return o.dNaN;if(this.lte("1ee-16"))return t%2==1?this:o.dNaN;if(this.gt(1)){let e=o.dTen;this.gte(o.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=o.dZero,i=e.layer,n=e.iteratedlog(10,i,!0),s=n,h=n.div(2),v=!0;for(;v;)h=r.add(n).div(2),o.iteratedexp(10,i,h,!0).tetrate(t,1,!0).gt(this)?n=h:r=h,h.eq(s)?v=!1:s=h;return o.iteratedexp(10,i,h,!0)}else{let e=1,r=D(1,10,1),i=D(1,10,1),n=D(1,10,1),s=D(1,1,-16),h=o.dZero,v=D(1,10,1),d=s.pow10().recip(),f=o.dZero,y=d,l=d,u=Math.ceil(t)%2==0,c=0,p=D(1,10,1),w=!1,I=o.dZero,L=!1;for(;e<4;){if(e==2){if(u)break;n=D(1,10,1),s=r,e=3,v=D(1,10,1),p=D(1,10,1)}for(w=!1;s.neq(n);){if(I=s,s.pow10().recip().tetrate(t,1,!0).eq(1)&&s.pow10().recip().lt(.4))d=s.pow10().recip(),y=s.pow10().recip(),l=s.pow10().recip(),f=o.dZero,c=-1,e==3&&(p=s);else if(s.pow10().recip().tetrate(t,1,!0).eq(s.pow10().recip())&&!u&&s.pow10().recip().lt(.4))d=s.pow10().recip(),y=s.pow10().recip(),l=s.pow10().recip(),f=o.dZero,c=0;else if(s.pow10().recip().tetrate(t,1,!0).eq(s.pow10().recip().mul(2).tetrate(t,1,!0)))d=s.pow10().recip(),y=o.dZero,l=d.mul(2),f=d,u?c=-1:c=0;else{for(h=s.mul(12e-17),d=s.pow10().recip(),y=s.add(h).pow10().recip(),f=d.sub(y),l=d.add(f);y.tetrate(t,1,!0).eq(d.tetrate(t,1,!0))||l.tetrate(t,1,!0).eq(d.tetrate(t,1,!0))||y.gte(d)||l.lte(d);)h=h.mul(2),y=s.add(h).pow10().recip(),f=d.sub(y),l=d.add(f);if((e==1&&l.tetrate(t,1,!0).gt(d.tetrate(t,1,!0))&&y.tetrate(t,1,!0).gt(d.tetrate(t,1,!0))||e==3&&l.tetrate(t,1,!0).lt(d.tetrate(t,1,!0))&&y.tetrate(t,1,!0).lt(d.tetrate(t,1,!0)))&&(p=s),l.tetrate(t,1,!0).lt(d.tetrate(t,1,!0)))c=-1;else if(u)c=1;else if(e==3&&s.gt_tolerance(r,1e-8))c=0;else{for(;y.tetrate(t,1,!0).eq_tolerance(d.tetrate(t,1,!0),1e-8)||l.tetrate(t,1,!0).eq_tolerance(d.tetrate(t,1,!0),1e-8)||y.gte(d)||l.lte(d);)h=h.mul(2),y=s.add(h).pow10().recip(),f=d.sub(y),l=d.add(f);l.tetrate(t,1,!0).sub(d.tetrate(t,1,!0)).lt(d.tetrate(t,1,!0).sub(y.tetrate(t,1,!0)))?c=0:c=1}}if(c==-1&&(L=!0),e==1&&c==1||e==3&&c!=0)if(n.eq(D(1,10,1)))s=s.mul(2);else{let m=!1;if(w&&(c==1&&e==1||c==-1&&e==3)&&(m=!0),s=s.add(n).div(2),m)break}else if(n.eq(D(1,10,1)))n=s,s=s.div(2);else{let m=!1;if(w&&(c==1&&e==1||c==-1&&e==3)&&(m=!0),n=n.sub(v),s=s.sub(v),m)break}if(n.sub(s).div(2).abs().gt(v.mul(1.5))&&(w=!0),v=n.sub(s).div(2).abs(),s.gt("1e18")||s.eq(I))break}if(s.gt("1e18")||!L||p==D(1,10,1))break;e==1?r=p:e==3&&(i=p),e++}n=r,s=D(1,1,-18);let F=s,a=o.dZero,S=!0;for(;S;)if(n.eq(D(1,10,1))?a=s.mul(2):a=n.add(s).div(2),o.pow(10,a).recip().tetrate(t,1,!0).gt(this)?s=a:n=a,a.eq(F)?S=!1:F=a,s.gt("1e18"))return o.dNaN;if(a.eq_tolerance(r,1e-15)){if(i.eq(D(1,10,1)))return o.dNaN;for(n=D(1,10,1),s=i,F=s,a=o.dZero,S=!0;S;)if(n.eq(D(1,10,1))?a=s.mul(2):a=n.add(s).div(2),o.pow(10,a).recip().tetrate(t,1,!0).gt(this)?s=a:n=a,a.eq(F)?S=!1:F=a,s.gt("1e18"))return o.dNaN;return a.pow10().recip()}else return a.pow10().recip()}}pentate(t=2,e=Y(1,0,1),r=!1){e=N(e);let i=t;t=Math.trunc(t);let n=i-t;n!==0&&(e.eq(o.dOne)?(++t,e=o.fromNumber(n)):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let s=0;s10)return e}return e}sin(){return this.mag<0?this:this.layer===0?o.fromNumber(Math.sin(this.sign*this.mag)):Y(0,0,0)}cos(){return this.mag<0?o.dOne:this.layer===0?o.fromNumber(Math.cos(this.sign*this.mag)):Y(0,0,0)}tan(){return this.mag<0?this:this.layer===0?o.fromNumber(Math.tan(this.sign*this.mag)):Y(0,0,0)}asin(){return this.mag<0?this:this.layer===0?o.fromNumber(Math.asin(this.sign*this.mag)):Y(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?o.fromNumber(Math.acos(this.toNumber())):this.layer===0?o.fromNumber(Math.acos(this.sign*this.mag)):Y(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?o.fromNumber(Math.atan(this.sign*this.mag)):o.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 o.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return o.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?Y(Number.NaN,Number.NaN,Number.NaN):o.ln(this.add(1).div(o.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?this:this.root(o.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 o(t).add(new o(e).minus(new o(t)).times(new o(r)).times(new o(i)))}clone(){return this}static clone(t){return o.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 o(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new o(t),e=new o(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):o.pow(e,n.sub(t)).mul(t))),n}static scale(t,e,r,i,n=!1){return new o(t).scale(e,r,i,n)}format(t=2,e=9,r="mixed_sc"){return pt.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return pt.format(new o(t),e,r,i)}formatST(t=2,e=9,r="st"){return pt.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return pt.format(new o(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return pt.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,n){return pt.formatGain(new o(t),e,r,i,n)}toRoman(t=5e3){t=new o(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 s of Object.keys(i)){let h=Math.floor(r/i[s]);r-=h*i[s],n+=s.repeat(h)}return n}static toRoman(t,e){return new o(t).toRoman(e)}static random(t=0,e=1){return t=new o(t),e=new o(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new o(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new o(Math.random()).lt(t)}};o.dZero=Y(0,0,0),o.dOne=Y(1,0,1),o.dNegOne=Y(-1,0,1),o.dTwo=Y(1,0,2),o.dTen=Y(1,0,10),o.dNaN=Y(Number.NaN,Number.NaN,Number.NaN),o.dInf=Y(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),o.dNegInf=Y(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),o.dNumberMax=D(1,0,Number.MAX_VALUE),o.dNumberMin=D(1,0,Number.MIN_VALUE),o.fromStringCache=new jt(ur),ft([Tt()],o.prototype,"sign",2),ft([Tt()],o.prototype,"mag",2),ft([Tt()],o.prototype,"layer",2),o=ft([tr()],o);var{formats:pt,FORMATS:pr}=rr(o);o.formats=pt;var k=(()=>{let t=e=>new o(e);return Object.getOwnPropertyNames(o).filter(e=>!Object.getOwnPropertyNames(class{}).includes(e)).forEach(e=>{t[e]=o[e]}),t})(),Nt=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.value=t.value,this.order=t.order??99}},zt=class{constructor(t=1,e){this.addBoost=this.setBoost.bind(this),e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=k(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new Nt(r))})}getBoosts(t,e){let r=[],i=[];for(let n=0;nl),f=n,y=this.getBoosts(s,!0);y[0][0]?this.boostArray[y[1][0]]=new Nt({id:s,name:h,description:v,value:d,order:f}):this.boostArray.push(new Nt({id:s,name:h,description:v,value:d,order:f}))}else{t=Array.isArray(t)?t:[t];for(let s of t){let h=this.getBoosts(s.id,!0);h[0][0]?this.boostArray[h[1][0]]=new Nt(s):this.boostArray.push(new Nt(s))}}}calculate(t=this.baseEffect){let e=k(t),r=this.boostArray;r=r.sort((i,n)=>i.order-n.order);for(let i of r)e=i.value(e);return e}},Ur=ot(ct()),xt=35;function Yt(t,e,r="geometric",i=xt){let n=k(1),s=k(e);if(t(s).eq(0))return{value:k(0),lowerBound:k(0),upperBound:k(0)};if(t(s).lt(e))return console.warn("The function is not monotonically increasing. (f(n) < n)"),{value:s,lowerBound:s,upperBound:s};for(let v=0;ve.cost(p.add(r)),u=k.min(i,Yt(l,t,n,s).value.floor()),c=k(0);return[u,c]}let d=Yt(l=>Zt(e.cost,l,r),t,n,s).value.floor().min(r.add(v).sub(1)),f=Zt(e.cost,d,r);return[d.sub(r).add(1).max(0),f]}function kt(t){return t=k(t),`${t.sign}/${t.mag}/${t.layer}`}function de(t,e){return`sum/${kt(t)}/${kt(e)}}`}function Ht(t){return`el/${kt(t)}`}var vt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?k(t.level):k(1)}};ft([Tt()],vt.prototype,"id",2),ft([Ft(()=>o)],vt.prototype,"level",2);var ge=class De{static{this.cacheSize=63}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn()}get level(){return((this??{data:{level:k(1)}}).data??{level:k(1)}).level}set level(e){this.data.level=k(e)}constructor(e,r,i){let n=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>n,this.cache=new jt(i??De.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??k(1)}getCached(e,r,i){return e==="sum"?this.cache.get(de(r,i??k(0))):this.cache.get(Ht(r))}setCached(e,r,i,n){let s=e==="sum"?{id:this.id,el:!1,start:k(r),end:k(i),cost:k(n)}:{id:this.id,el:!0,level:k(r),cost:k(i)};return e==="sum"?this.cache.set(de(r,i),s):this.cache.set(Ht(r),s),s}},$r=ot(ct()),yt=class{constructor(){this.value=k(0),this.upgrades={}}};ft([Ft(()=>o)],yt.prototype,"value",2),ft([Ft(()=>vt)],yt.prototype,"upgrades",2);var me=class{get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}constructor(t=new yt,e,r={defaultVal:k(0),defaultBoost:k(1)}){this.defaultVal=r.defaultVal,this.defaultBoost=r.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new zt(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e)}onLoadData(){for(let t of Object.values(this.upgrades))t.effect?.(t.level,t)}reset(t=!0,e=!0,r=!0){if(t&&(this.value=this.defaultVal),e)for(let i of Object.values(this.upgrades))i.level=k(i.defaultLevel),r&&i.effect?.(i.level,i)}gain(t=1e3){let e=this.boost.calculate().mul(k(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new vt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r={};for(let i of t){let n=this.pointerAddUpgrade(i),s=new ge(i,()=>this.pointerGetUpgrade(i.id));s.effect&&e&&s.effect(s.level,s),r[i.id]=s,this.upgrades[i.id]=s}return Object.values(r)}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&(r.name=e.name??r.name,r.cost=e.cost??r.cost,r.maxLevel=e.maxLevel??r.maxLevel,r.effect=e.effect??r.effect)}calculateUpgrade(t,e,r,i){let n=this.getUpgrade(t);return n===null?(console.warn(`Upgrade "${t}" not found.`),[k(0),k(0)]):he(this.value,n,n.level,e?n.level.add(e):void 0,r,i)}getNextCost(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),k(0);let s=this.calculateUpgrade(t,e,r,i)[0];return n.cost(n.level.add(s))}getNextCostMax(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),k(0);let s=this.calculateUpgrade(t,e,r,i);return n.cost(n.level.add(s[0])).add(s[1])}buyUpgrade(t,e,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),!1;let[s,h]=this.calculateUpgrade(t,e,r,i);return s.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(h),n.level=n.level.add(s),n.effect?.(n.level,n),!0)}},zr=ot(ct()),Lt=class{constructor(t=0){this.value=k(t)}};ft([Ft(()=>o)],Lt.prototype,"value",2);var pe=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=k(r),t??=new Lt(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new zt(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}},ve=class{constructor(t,e,r){this.x=t,this.y=e,this.properties=r??{}}setValue(t,e){return this.properties[t]=e,e}getValue(t){return this.properties[t]}},yr=class{constructor(t,e,r){this.xSize=t,this.ySize=e,this.cells=[];for(let i=0;iPt,DataManager:()=>_e,EventManager:()=>Me,EventTypes:()=>we,Game:()=>Nr,GameAttribute:()=>Ae,GameCurrency:()=>Se,GameReset:()=>Oe,KeyManager:()=>be,gameDefaultConfig:()=>Ie,keys:()=>wr});var Yr=ot(ct()),Pt=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}},br={autoAddInterval:!0,fps:30,pixiApp:void 0},wr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ".split("").concat(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),be=class Re{constructor(e){if(this.addKeys=this.addKey.bind(this),this.keysPressed=[],this.binds=[],this.tickers=[],this.config=Re.configManager.parse(e),this.config.autoAddInterval)if(this.config.pixiApp)this.config.pixiApp.ticker.add(r=>{for(let i of this.tickers)i(r)});else{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 Pt(br)}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)):this.config.pixiApp&&(this.config.pixiApp.ticker.maxFPS=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 s=this.getBind(n.id);if(s){Object.assign(s,n);continue}this.binds.push(n)}}},we=(t=>(t.interval="interval",t.timeout="timeout",t))(we||{}),Mr={autoAddInterval:!0,fps:30,pixiApp:void 0},Me=class je{constructor(e){if(this.addEvent=this.setEvent.bind(this),this.config=je.configManager.parse(e),this.events={},this.config.autoAddInterval)if(this.config.pixiApp)this.config.pixiApp.ticker.add(()=>{this.tickerFunction()});else{let r=this.config.fps??30;this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/r)}}static{this.configManager=new Pt(Mr)}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.callbackFn(i),r.intervalLast=e}break;case"timeout":{let i=e-r.timeCreated;e-r.timeCreated>=r.delay&&(r.callbackFn(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)):this.config.pixiApp&&(this.config.pixiApp.ticker.maxFPS=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(),callbackFn:n,timeCreated:Date.now(),intervalLast:Date.now()};case"timeout":default:return{name:e,type:r,delay:typeof i=="number"?i:i.toNumber(),callbackFn:n,timeCreated:Date.now()}}})()}removeEvent(e){delete this.events[e]}},Zr=ot(ct()),Ne=ot(Ye()),Vt=ot(Ve()),_e=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 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 this.static[t]}init(){this.normalData=this.data,this.normalDataPlain=Gt(this.data)}compileDataRaw(t=this.data){let e=Gt(t),r=(0,Vt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(e)}`),i;try{i="8.2.0"}catch{i="8.2.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,Ne.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,Ne.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,Vt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`)===e;let i=e.hash,n=(0,Vt.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(!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)}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(y){return typeof y=="object"&&y?.constructor===Object}let n=(y,l)=>Object.prototype.hasOwnProperty.call(y,l);function s(y,l,u){if(!y||!l||!u)throw new Error("dataManager.deepMerge(): Missing arguments.");let c=u;for(let p in y)if(n(y,p)&&!n(u,p)&&(c[p]=y[p]),l[p]instanceof yt){let w=y[p],I=u[p];if(Array.isArray(I.upgrades)){let L=I.upgrades;I.upgrades={};for(let F of L)I.upgrades[F.id]=F}I.upgrades={...w.upgrades,...I.upgrades},c[p]=I}else i(y[p])&&i(u[p])&&(c[p]=s(y[p],l[p],u[p]));return c}let h=e?s(this.normalDataPlain,this.normalData,r):r,v=Object.getOwnPropertyNames(new vt({id:"",level:k(0)}));function d(y,l){let u=se(y,l);if(u instanceof yt)for(let c in u.upgrades){let p=u.upgrades[c];if(!p||!v.every(w=>Object.getOwnPropertyNames(p).includes(w))){delete u.upgrades[c];continue}u.upgrades[c]=se(vt,p)}if(!u)throw new Error(`Failed to convert ${y.name} to class instance.`);return u}function f(y,l){if(!y||!l)throw new Error("dataManager.plainToInstanceRecursive(): Missing arguments.");let u=l;for(let c in y){if(l[c]===void 0){console.warn(`Missing property "${c}" in loaded data.`);continue}if(!i(l[c]))continue;let p=y[c].constructor;if(p===Object){u[c]=f(y[c],l[c]);continue}u[c]=d(p,l[c])}return u}return h=f(this.normalData,h),h}loadData(t=this.decompileData()){if(t=typeof t=="string"?this.decompileData(t):t,!t)return null;let e=this.validateData([t[0],Gt(t[1])]),r=this.parseData(t);if(!r)return null;this.data=r;for(let i of this.eventsOnLoad)i();return e}},Se=class{get data(){return this.dataPointer()}get static(){return this.staticPointer()}constructor(t,e,r,i){this.dataPointer=typeof t=="function"?t:()=>t,this.staticPointer=typeof e=="function"?e:()=>e,this.game=r,this.name=i,this.game.dataManager.addEventOnLoad(()=>{this.static.onLoadData()})}get value(){return this.data.value}},Ae=class{constructor(t,e,r){this.data=typeof t=="function"?t():t,this.static=typeof e=="function"?e():e,this.game=r}get value(){return this.static.value}set value(t){this.data.value=t}},Oe=class{constructor(t,e){this.currenciesToReset=Array.isArray(t)?t:[t],this.extender=Array.isArray(e)?e:e?[e]:[],this.id=Symbol()}reset(){this.onReset?.(),this.currenciesToReset.forEach(t=>{t.static.reset()}),this.extender.forEach(t=>{t.id!==this.id&&t.reset()})}},Ie={mode:"production",name:{title:"",id:"",version:"0.0.0"},settings:{framerate:30},initIntervalBasedManagers:!0},Nr=class Ge{static{this.configManager=new Pt(Ie)}constructor(e){this.config=Ge.configManager.parse(e),this.dataManager=new _e(this),this.keyManager=new be({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.eventManager=new Me({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){return this.dataManager.setData(e,{currency:new yt}),this.dataManager.setStatic(e,{currency:new me(()=>this.dataManager.getData(e).currency)}),new Se(()=>this.dataManager.getData(e).currency,()=>this.dataManager.getStatic(e).currency,this,e)}addAttribute(e,r=!0,i=0){let n=this.dataManager.setData(e,new Lt(i)),s=this.dataManager.setStatic(e,new pe(this.dataManager.getData(e),r,i));return new Ae(this.dataManager.getData(e),this.dataManager.getStatic(e),this)}addReset(e,r){return new Oe(e,r)}},_r={...ee,...ye};if(typeof at.exports=="object"&&typeof At=="object"){var Sr=(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};at.exports=Sr(at.exports,At)}return at.exports}); +"use strict";(function(At,at){var Ct=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],at);else if(typeof module=="object"&&module.exports)module.exports=at();else{var lt=at(),Et=Ct?exports:At;for(var Ot in lt)Et[Ot]=lt[Ot]}})(typeof self<"u"?self:exports,()=>{var At={},at={exports:At},Ct=Object.create,lt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Ot=Object.getOwnPropertyNames,Ue=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty,bt=(t,e)=>function(){return e||(0,t[Ot(t)[0]])((e={exports:{}}).exports,e),e.exports},Rt=(t,e)=>{for(var r in e)lt(t,r,{get:e[r],enumerable:!0})},Qt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ot(e))!$e.call(t,n)&&n!==r&<(t,n,{get:()=>e[n],enumerable:!(i=Et(e,n))||i.enumerable});return t},ot=(t,e,r)=>(r=t!=null?Ct(Ue(t)):{},Qt(e||!t||!t.__esModule?lt(r,"default",{value:t,enumerable:!0}):r,t)),ze=t=>Qt(lt({},"__esModule",{value:!0}),t),ft=(t,e,r,i)=>{for(var n=i>1?void 0:i?Et(e,r):e,s=t.length-1,h;s>=0;s--)(h=t[s])&&(n=(i?h(e,r,n):h(n))||n);return i&&n&<(e,r,n),n},ct=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:d(),n=s(e);typeof i.Reflect<"u"&&(n=s(i.Reflect,n)),r(n,i),typeof i.Reflect>"u"&&(i.Reflect=e);function s(f,y){return function(l,u){Object.defineProperty(f,l,{configurable:!0,writable:!0,value:u}),y&&y(l,u)}}function h(){try{return Function("return this;")()}catch{}}function v(){try{return(0,eval)("(function() { return this; })()")}catch{}}function d(){return h()||v()}})(function(r,i){var n=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",h=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",v=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",d=typeof Object.create=="function",f={__proto__:[]}instanceof Array,y=!d&&!f,l={create:d?function(){return Jt(Object.create(null))}:f?function(){return Jt({__proto__:null})}:function(){return Jt({})},has:y?function(g,b){return n.call(g,b)}:function(g,b){return b in g},get:y?function(g,b){return n.call(g,b)?g[b]:void 0}:function(g,b){return g[b]}},u=Object.getPrototypeOf(Function),c=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Lr(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Pr(),w=typeof WeakMap=="function"?WeakMap:qr(),I=s?Symbol.for("@reflect-metadata:registry"):void 0,L=Fr(),F=xr(L);function a(g,b,O,C){if(j(O)){if(!Te(g))throw new TypeError;if(!Fe(b))throw new TypeError;return tt(g,b)}else{if(!Te(g))throw new TypeError;if(!J(b))throw new TypeError;if(!J(C)&&!j(C)&&!_t(C))throw new TypeError;return _t(C)&&(C=void 0),O=ut(O),nt(g,b,O,C)}}r("decorate",a);function S(g,b){function O(C,R){if(!J(C))throw new TypeError;if(!j(R)&&!Er(R))throw new TypeError;qt(g,b,C,R)}return O}r("metadata",S);function m(g,b,O,C){if(!J(O))throw new TypeError;return j(C)||(C=ut(C)),qt(g,b,O,C)}r("defineMetadata",m);function A(g,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),W(g,b,O)}r("hasMetadata",A);function _(g,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),Z(g,b,O)}r("hasOwnMetadata",_);function M(g,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),X(g,b,O)}r("getMetadata",M);function E(g,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),dt(g,b,O)}r("getOwnMetadata",E);function T(g,b){if(!J(g))throw new TypeError;return j(b)||(b=ut(b)),Bt(g,b)}r("getMetadataKeys",T);function G(g,b){if(!J(g))throw new TypeError;return j(b)||(b=ut(b)),Dt(g,b)}r("getOwnMetadataKeys",G);function H(g,b,O){if(!J(b))throw new TypeError;if(j(O)||(O=ut(O)),!J(b))throw new TypeError;j(O)||(O=ut(O));var C=It(b,O,!1);return j(C)?!1:C.OrdinaryDeleteMetadata(g,b,O)}r("deleteMetadata",H);function tt(g,b){for(var O=g.length-1;O>=0;--O){var C=g[O],R=C(b);if(!j(R)&&!_t(R)){if(!Fe(R))throw new TypeError;b=R}}return b}function nt(g,b,O,C){for(var R=g.length-1;R>=0;--R){var Q=g[R],et=Q(b,O,C);if(!j(et)&&!_t(et)){if(!J(et))throw new TypeError;C=et}}return C}function W(g,b,O){var C=Z(g,b,O);if(C)return!0;var R=Xt(b);return _t(R)?!1:W(g,R,O)}function Z(g,b,O){var C=It(b,O,!1);return j(C)?!1:Ee(C.OrdinaryHasOwnMetadata(g,b,O))}function X(g,b,O){var C=Z(g,b,O);if(C)return dt(g,b,O);var R=Xt(b);if(!_t(R))return X(g,R,O)}function dt(g,b,O){var C=It(b,O,!1);if(!j(C))return C.OrdinaryGetOwnMetadata(g,b,O)}function qt(g,b,O,C){var R=It(O,C,!0);R.OrdinaryDefineOwnMetadata(g,b,O,C)}function Bt(g,b){var O=Dt(g,b),C=Xt(g);if(C===null)return O;var R=Bt(C,b);if(R.length<=0)return O;if(O.length<=0)return R;for(var Q=new p,et=[],$=0,x=O;$=0&&x=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:P,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}},$}(),C=function(){function $(){this._keys=[],this._values=[],this._cacheKey=g,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 P=this._find(x,!1);return P>=0?this._values[P]:void 0},$.prototype.set=function(x,P){var q=this._find(x,!0);return this._values[q]=P,this},$.prototype.delete=function(x){var P=this._find(x,!1);if(P>=0){for(var q=this._keys.length,B=P+1;B>>8,l[u*2+1]=p%256}return l},decompressFromUint8Array:function(f){if(f==null)return d.decompress(f);for(var y=new Array(f.length/2),l=0,u=y.length;l>1}else{for(c=1,u=0;u>1}a--,a==0&&(a=Math.pow(2,m),m++),delete w[F]}else for(c=p[F],u=0;u>1;a--,a==0&&(a=Math.pow(2,m),m++),p[L]=S++,F=String(I)}if(F!==""){if(Object.prototype.hasOwnProperty.call(w,F)){if(F.charCodeAt(0)<256){for(u=0;u>1}else{for(c=1,u=0;u>1}a--,a==0&&(a=Math.pow(2,m),m++),delete w[F]}else for(c=p[F],u=0;u>1;a--,a==0&&(a=Math.pow(2,m),m++)}for(c=2,u=0;u>1;for(;;)if(_=_<<1,M==y-1){A.push(l(_));break}else M++;return A.join("")},decompress:function(f){return f==null?"":f==""?null:d._decompress(f.length,32768,function(y){return f.charCodeAt(y)})},_decompress:function(f,y,l){var u=[],c,p=4,w=4,I=3,L="",F=[],a,S,m,A,_,M,E,T={val:l(0),position:y,index:1};for(a=0;a<3;a+=1)u[a]=a;for(m=0,_=Math.pow(2,2),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;switch(c=m){case 0:for(m=0,_=Math.pow(2,8),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;E=i(m);break;case 1:for(m=0,_=Math.pow(2,16),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;E=i(m);break;case 2:return""}for(u[3]=E,S=E,F.push(E);;){if(T.index>f)return"";for(m=0,_=Math.pow(2,I),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;switch(E=m){case 0:for(m=0,_=Math.pow(2,8),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;u[w++]=i(m),E=w-1,p--;break;case 1:for(m=0,_=Math.pow(2,16),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),m|=(A>0?1:0)*M,M<<=1;u[w++]=i(m),E=w-1,p--;break;case 2:return F.join("")}if(p==0&&(p=Math.pow(2,I),I++),u[E])L=u[E];else if(E===w)L=S+S.charAt(0);else return null;F.push(L),u[w++]=S+L.charAt(0),p--,S=L,p==0&&(p=Math.pow(2,I),I++)}}};return d}();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})}}),Ze=bt({"node_modules/crypt/crypt.js"(t,e){(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i={rotl:function(n,s){return n<>>32-s},rotr:function(n,s){return n<<32-s|n>>>s},endian:function(n){if(n.constructor==Number)return i.rotl(n,8)&16711935|i.rotl(n,24)&4278255360;for(var s=0;s0;n--)s.push(Math.floor(Math.random()*256));return s},bytesToWords:function(n){for(var s=[],h=0,v=0;h>>5]|=n[h]<<24-v%32;return s},wordsToBytes:function(n){for(var s=[],h=0;h>>5]>>>24-h%32&255);return s},bytesToHex:function(n){for(var s=[],h=0;h>>4).toString(16)),s.push((n[h]&15).toString(16));return s.join("")},hexToBytes:function(n){for(var s=[],h=0;h>>6*(3-d)&63)):s.push("=");return s.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var s=[],h=0,v=0;h>>6-v*2);return s}};e.exports=i})()}}),Kt=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=[],s=0;s>>24)&16711935|(f[w]<<24|f[w]>>>8)&4278255360;f[y>>>5]|=128<>>9<<4)+14]=y;for(var I=h._ff,L=h._gg,F=h._hh,a=h._ii,w=0;w>>0,u=u+m>>>0,c=c+A>>>0,p=p+_>>>0}return r.endian([l,u,c,p])};h._ff=function(v,d,f,y,l,u,c){var p=v+(d&f|~d&y)+(l>>>0)+c;return(p<>>32-u)+d},h._gg=function(v,d,f,y,l,u,c){var p=v+(d&y|f&~y)+(l>>>0)+c;return(p<>>32-u)+d},h._hh=function(v,d,f,y,l,u,c){var p=v+(d^f^y)+(l>>>0)+c;return(p<>>32-u)+d},h._ii=function(v,d,f,y,l,u,c){var p=v+(f^(d|~y))+(l>>>0)+c;return(p<>>32-u)+d},h._blocksize=16,h._digestsize=16,e.exports=function(v,d){if(v==null)throw new Error("Illegal argument "+v);var f=r.wordsToBytes(h(v,d));return d&&d.asBytes?f:d&&d.asString?s.bytesToString(f):r.bytesToHex(f)}})()}}),te={};Rt(te,{eMath:()=>_r}),at.exports=ze(te);var Rr=ot(ct()),jr=ot(ct()),ee={};Rt(ee,{Attribute:()=>Lt,AttributeStatic:()=>pe,Boost:()=>zt,BoostObject:()=>Nt,Currency:()=>yt,CurrencyStatic:()=>me,DEFAULT_ITERATIONS:()=>xt,E:()=>k,FORMATS:()=>pr,FormatTypeList:()=>er,Grid:()=>yr,GridCell:()=>ve,LRUCache:()=>jt,ListNode:()=>re,UpgradeData:()=>vt,UpgradeStatic:()=>ge,calculateSum:()=>Zt,calculateSumApprox:()=>ce,calculateSumLoop:()=>le,calculateUpgrade:()=>he,decimalToJSONString:()=>kt,inverseFunctionApprox:()=>Yt,roundingBase:()=>vr,upgradeToCacheNameEL:()=>Ht});var Gr=ot(ct()),jt=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 re(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}}},re=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},U;(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"})(U||(U={}));var We=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===U.CLASS_TO_CLASS||i===U.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?i===U.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),s=n&&n.get(void 0);return i&&s||!i&&!s?"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===U.CLASS_TO_CLASS||r===U.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===U.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===U.CLASS_TO_CLASS||r===U.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===U.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(l){return l.propertyName!==void 0}));for(var s=[],h=0,v=this.getAncestors(r);h0&&(h=h.filter(function(l){return!f.includes(l)})),this.options.version!==void 0&&(h=h.filter(function(l){var u=rt.findExposeMetadata(e,l);return!u||!u.options?!0:n.checkVersion(u.options.since,u.options.until)})),this.options.groups&&this.options.groups.length?h=h.filter(function(l){var u=rt.findExposeMetadata(e,l);return!u||!u.options?!0:n.checkGroups(u.options.groups)}):h=h.filter(function(l){var u=rt.findExposeMetadata(e,l);return!u||!u.options||!u.options.groups||!u.options.groups.length})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(h=h.filter(function(y){return n.options.excludePrefixes.every(function(l){return y.substr(0,l.length)!==l})})),h=h.filter(function(y,l,u){return u.indexOf(y)===l}),h},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)&&(A="\u03C9");let M=t.log(a,8e3).toNumber();if(m.equals(0))return A;if(m.gt(0)&&m.lte(3)){let G=[];for(let H=0;HNumber.MAX_SAFE_INTEGER)&&(A="\u03C9");let M=t.log(a,8e3).toNumber();if(m.equals(0))return A;if(m.gt(0)&&m.lte(2)){let G=[];for(let H=0;H118?e.elemental.beyondOg(_):e.elemental.config.element_lists[a-1][A]},beyondOg(a){let S=Math.floor(Math.log10(a)),m=["n","u","b","t","q","p","h","s","o","e"],A="";for(let _=S;_>=0;_--){let M=Math.floor(a/Math.pow(10,_))%10;A==""?A=m[M].toUpperCase():A+=m[M]}return A},abbreviationLength(a){return a==1?1:Math.pow(Math.floor(a/2)+1,2)*2},getAbbreviationAndValue(a){let S=a.log(118).toNumber(),m=Math.floor(S)+1,A=e.elemental.abbreviationLength(m),_=S-m+1,M=Math.floor(_*A),E=e.elemental.getAbbreviation(m,_),T=new t(118).pow(m+M/A-1);return[E,T]},formatElementalPart(a,S){return S.eq(1)?a:`${S} ${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 m=a.log(118),_=m.log(118).log(118).toNumber(),M=Math.max(4-_*2,1),E=[];for(;m.gte(1)&&E.length=M)return E.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ");let T=new t(118).pow(m).toFixed(E.length===1?3:S);return E.length===0?T:E.length===1?`${T} \xD7 ${e.elemental.formatElementalPart(E[0][0],E[0][1])}`:`${T} \xD7 (${E.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ")})`}},old_sc:{format(a,S){a=new t(a);let m=a.log10().floor();if(m.lt(9))return m.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)?"":new t(10).pow(_.sub(_.floor())).toFixed(4))+"F"+e.old_sc.format(_.floor(),0)}let A=a.div(new t(10).pow(m));return(m.log10().gte(9)?"":A.toFixed(4))+"e"+e.old_sc.format(m,0)}}},eng:{format(a,S=2){a=new t(a);let m=a.log10().floor();if(m.lt(9))return m.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)?"":new t(10).pow(_.sub(_.floor())).toFixed(4))+"F"+e.eng.format(_.floor(),0)}let A=a.div(new t(1e3).pow(m.div(3).floor()));return(m.log10().gte(9)?"":A.toFixed(new t(4).sub(m.sub(m.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(m.div(3).floor().mul(3),0)}}},mixed_sc:{format(a,S,m=9){a=new t(a);let A=a.log10().floor();return A.lt(303)&&A.gte(m)?d(a,S,m,"st"):d(a,S,m,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(a,S=2,m){a=new t(a);let A=a.max(1).log10().max(1).log(r.log10()).floor();if(A.lte(0))return d(a,S,m,"sc");a=new t(10).pow(a.max(1).log10().div(r.log10().pow(A)).sub(A.gte(1)?1:0));let _=A.div(10).floor(),M=A.toNumber()%10-1;return d(a,Math.max(4,S),m,"sc")+" "+(_.gte(1)?"meta"+(_.gte(2)?"^"+d(_,0,m,"sc"):"")+"-":"")+(isNaN(M)?"nanity":e.layer.layers[M])}},standard:{tier1(a){return gt[0][0][a%10]+gt[0][1][Math.floor(a/10)%10]+gt[0][2][Math.floor(a/100)]},tier2(a){let S=a%10,m=Math.floor(a/10)%10,A=Math.floor(a/100)%10,_="";return a<10?gt[1][0][a]:(m==1&&S==0?_+="Vec":_+=gt[1][1][S]+gt[1][2][m],_+=gt[1][3][A],_)}},inf:{format(a,S,m){a=new t(a);let A=0,_=new t(Number.MAX_VALUE),M=["","\u221E","\u03A9","\u03A8","\u028A"],E=["","","m","mm","mmm"];for(;a.gte(_);)a=a.log(_),A++;return A==0?d(a,S,m,"sc"):a.gte(3)?E[A]+M[A]+"\u03C9^"+d(a.sub(1),S,m,"sc"):a.gte(2)?E[A]+"\u03C9"+M[A]+"-"+d(_.pow(a.sub(2)),S,m,"sc"):E[A]+M[A]+"-"+d(_.pow(a.sub(1)),S,m,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(a,S=new t(1e15),m=!1,A=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,E=a.log(1e3).sub(S.log(1e3)).floor(),T=E.add(1).log(M+1).ceil(),G="",H=(tt,nt)=>{let W=tt,Z="";for(let X=0;X=M)return"\u03C9";Z=_[dt]+Z,W=W.sub(1).div(M).floor()}return Z};if(T.lt(A))G=H(E,T);else{let tt=T.sub(A).add(1),nt=E.div(t.pow(M+1,tt.sub(1))).floor();G=`${H(nt,new t(A))}(${tt.gt("1e9")?tt.format():tt.format(0)})`}return G},format(a,S=2,m=9,A="mixed_sc",_=new t(1e15),M=!1,E){if(a=new t(a),_=new t(_).div(1e3),a.lt(_.mul(1e3)))return d(a,S,m,A);let T=e.alphabet.getAbbreviation(a,_,M,E),G=a.div(t.pow(1e3,a.log(1e3).floor()));return`${T.length>(E??9)+2?"":G.toFixed(S)+" "}${T}`}}},r=new t(2).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 s(a){return a.toFixed(0).split("").map(S=>S==="-"?"\u208B":i[parseInt(S,10)]).join("")}function h(a){return a.toFixed(0).split("").map(S=>S==="-"?"\u208B":n[parseInt(S,10)]).join("")}function v(a,S=2,m=9,A="st"){return d(a,S,m,A)}function d(a,S=2,m=9,A="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(A){case"sc":case"scientific":if(a.log10().lt(Math.min(-S,0))&&S>1){let E=a.log10().ceil(),T=a.div(E.eq(-1)?new t(.1):new t(10).pow(E)),G=E.mul(-1).max(1).log10().gte(9);return _+(G?"":T.toFixed(2))+"e"+d(E,0,m,"mixed_sc")}else if(M.lt(m)){let E=Math.max(Math.min(S-M.toNumber(),S),0);return _+(E>0?a.toFixed(E):a.toFixed(E).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(a.gte("eeee10")){let G=a.slog();return(G.gte(1e9)?"":new t(10).pow(G.sub(G.floor())).toFixed(2))+"F"+d(G.floor(),0)}let E=a.div(new t(10).pow(M)),T=M.log10().gte(9);return _+(T?"":E.toFixed(2))+"e"+d(M,0,m,"mixed_sc")}case"st":case"standard":{let E=a.log(1e3).floor();if(E.lt(1))return _+a.toFixed(Math.max(Math.min(S-M.toNumber(),S),0));let T=E.mul(3),G=E.log10().floor();if(G.gte(3e3))return"e"+d(M,S,m,"st");let H="";if(E.lt(4))H=["","K","M","B"][Math.round(E.toNumber())];else{let W=Math.floor(E.log(1e3).toNumber());for(W<100&&(W=Math.max(W-1,0)),E=E.sub(1).div(new t(10).pow(W*3));E.gt(0);){let Z=E.div(1e3).floor(),X=E.sub(Z.mul(1e3)).floor().toNumber();X>0&&(X==1&&!W&&(H="U"),W&&(H=e.standard.tier2(W)+(H?"-"+H:"")),X>1&&(H=e.standard.tier1(X)+H)),E=Z,W++}}let tt=a.div(new t(10).pow(T)),nt=S===2?new t(2).sub(M.sub(T)).add(1).toNumber():S;return _+(G.gte(10)?"":tt.toFixed(nt)+" ")+H}default:return e[A]||console.error('Invalid format type "',A,'"'),_+e[A].format(a,S,m)}}function f(a,S,m="mixed_sc",A,_){a=new t(a),S=new t(S);let M=a.add(S),E,T=M.div(a);return T.gte(10)&&a.gte(1e100)?(T=T.log10().mul(20),E="(+"+d(T,A,_,m)+" OoMs/sec)"):E="(+"+d(S,A,_,m)+"/sec)",E}function y(a,S=2,m="s"){return a=new t(a),a.gte(86400)?d(a.div(86400).floor(),0,12,"sc")+":"+y(a.mod(86400),S,"d"):a.gte(3600)||m=="d"?(a.div(3600).gte(10)||m!="d"?"":"0")+d(a.div(3600).floor(),0,12,"sc")+":"+y(a.mod(3600),S,"h"):a.gte(60)||m=="h"?(a.div(60).gte(10)||m!="h"?"":"0")+d(a.div(60).floor(),0,12,"sc")+":"+y(a.mod(60),S,"m"):(a.gte(10)||m!="m"?"":"0")+d(a,S,12,"sc")}function l(a,S=!1,m=0,A=9,_="mixed_sc"){let M=Dt=>d(Dt,m,A,_);a=new t(a);let E=a.mul(1e3).mod(1e3).floor(),T=a.mod(60).floor(),G=a.div(60).mod(60).floor(),H=a.div(3600).mod(24).floor(),tt=a.div(86400).mod(365.2425).floor(),nt=a.div(31556952).floor(),W=nt.eq(1)?" year":" years",Z=tt.eq(1)?" day":" days",X=H.eq(1)?" hour":" hours",dt=G.eq(1)?" minute":" minutes",qt=T.eq(1)?" second":" seconds",Bt=E.eq(1)?" millisecond":" milliseconds";return`${nt.gt(0)?M(nt)+W+", ":""}${tt.gt(0)?M(tt)+Z+", ":""}${H.gt(0)?M(H)+X+", ":""}${G.gt(0)?M(G)+dt+", ":""}${T.gt(0)?M(T)+qt+",":""}${S&&E.gt(0)?" "+M(E)+Bt:""}`.replace(/,([^,]*)$/,"$1").trim()}function u(a){return a=new t(a),d(new t(1).sub(a).mul(100))+"%"}function c(a){return a=new t(a),d(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 w(a,S,m=10){return t.gte(a,10)?t.pow(m,t.log(a,m).pow(S)):new t(a)}function I(a,S=0){a=new t(a);let m=(E=>E.map((T,G)=>({name:T.name,altName:T.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:"E",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),A="",_=a.lte(0)?0:t.min(t.log(a,1e3).sub(1),m.length-1).floor().toNumber(),M=m[_];if(_===0)switch(S){case 1:A="";break;case 2:case 0:default:A=a.format();break}switch(S){case 1:A=M.name;break;case 2:A=a.divide(M.value).format();break;case 3:A=M.altName;break;case 0:default:A=`${a.divide(M.value).format()} ${M.name}`;break}return A}function L(a,S=!1){return`${I(a,2)} ${I(a,1)}eV${S?"/c^2":""}`}let F={...e,toSubscript:s,toSuperscript:h,formatST:v,format:d,formatGain:f,formatTime:y,formatTimeLong:l,formatReduction:u,formatPercent:c,formatMult:p,expMult:w,metric:I,ev:L};return{FORMATS:e,formats:F}}var Ut=17,ir=9e15,nr=Math.log10(9e15),sr=1/9e15,ar=308,or=-324,ae=5,ur=1023,fr=!0,lr=!1,cr=function(){let t=[];for(let r=or+1;r<=ar;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),mt=[2,Math.E,3,4,5,6,7,8,9,10],hr=[[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]],dr=[[-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]],N=function(e){return o.fromValue_noAlloc(e)},D=function(t,e,r){return o.fromComponents(t,e,r)},Y=function(e,r,i){return o.fromComponents_noNormalize(e,r,i)},ht=function(e,r){let i=r+1,n=Math.ceil(Math.log10(Math.abs(e))),s=Math.round(e*Math.pow(10,i-n))*Math.pow(10,n-i);return parseFloat(s.toFixed(Math.max(i-n,0)))},$t=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},gr=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},mr=.36787944117144233,oe=.5671432904097838,ue=function(t,e=1e-10){let r,i;if(!Number.isFinite(t)||t===0)return t;if(t===1)return oe;t<10?r=0:r=Math.log(t)-Math.log(Math.log(t));for(let n=0;n<100;++n){if(i=(t*Math.exp(-r)+r*r)/(r+1),Math.abs(i-r).5?1:-1;if(Math.random()*20<1)return Y(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)),D(e,r,n)}static affordGeometricSeries_core(t,e,r,i){let n=e.mul(r.pow(i));return o.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(o.sub(1,r.pow(t))).div(o.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let s=e.add(i.mul(r)).sub(r.div(2)),h=s.pow(2);return s.neg().add(h.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.sign==1?(this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY):this.sign==-1&&(this.mag=Number.NEGATIVE_INFINITY,this.layer=Number.NEGATIVE_INFINITY),this;if(this.layer===0&&this.mag=ir)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=o.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);fr?t=t.replace(",",""):lr&&(t=t.replace(",","."));let n=t.split("^^^");if(n.length===2){let w=parseFloat(n[0]),I=parseFloat(n[1]),L=n[1].split(";"),F=1;if(L.length===2&&(F=parseFloat(L[1]),isFinite(F)||(F=1)),isFinite(w)&&isFinite(I)){let a=o.pentate(w,I,F,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}let s=t.split("^^");if(s.length===2){let w=parseFloat(s[0]),I=parseFloat(s[1]),L=s[1].split(";"),F=1;if(L.length===2&&(F=parseFloat(L[1]),isFinite(F)||(F=1)),isFinite(w)&&isFinite(I)){let a=o.tetrate(w,I,F,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}let h=t.split("^");if(h.length===2){let w=parseFloat(h[0]),I=parseFloat(h[1]);if(isFinite(w)&&isFinite(I)){let L=o.pow(w,I);return this.sign=L.sign,this.layer=L.layer,this.mag=L.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}t=t.trim().toLowerCase();let v,d,f=t.split("pt");if(f.length===2){v=10,d=parseFloat(f[0]),f[1]=f[1].replace("(",""),f[1]=f[1].replace(")","");let w=parseFloat(f[1]);if(isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=o.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}if(f=t.split("p"),f.length===2){v=10,d=parseFloat(f[0]),f[1]=f[1].replace("(",""),f[1]=f[1].replace(")","");let w=parseFloat(f[1]);if(isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=o.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}if(f=t.split("f"),f.length===2){v=10,f[0]=f[0].replace("(",""),f[0]=f[0].replace(")","");let w=parseFloat(f[0]);if(f[1]=f[1].replace("(",""),f[1]=f[1].replace(")",""),d=parseFloat(f[1]),isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=o.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}let y=t.split("e"),l=y.length-1;if(l===0){let w=parseFloat(t);if(isFinite(w))return this.fromNumber(w),o.fromStringCache.size>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}else if(l===1){let w=parseFloat(t);if(isFinite(w)&&w!==0)return this.fromNumber(w),o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}let u=t.split("e^");if(u.length===2){this.sign=1,u[0].charAt(0)=="-"&&(this.sign=-1);let w="";for(let I=0;I=43&&L<=57||L===101)w+=u[1].charAt(I);else return this.layer=parseFloat(w),this.mag=parseFloat(u[1].substr(I+1)),this.normalize(),o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}}if(l<1)return this.sign=0,this.layer=0,this.mag=0,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this;let c=parseFloat(y[0]);if(c===0)return this.sign=0,this.layer=0,this.mag=0,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this;let p=parseFloat(y[y.length-1]);if(l>=2){let w=parseFloat(y[y.length-2]);isFinite(w)&&(p*=Math.sign(w),p+=$t(w))}if(!isFinite(c))this.sign=y[0]==="-"?-1:1,this.layer=l,this.mag=p;else if(l===1)this.sign=Math.sign(c),this.layer=1,this.mag=p+Math.log10(Math.abs(c));else if(this.sign=Math.sign(c),this.layer=l,l===2){let w=o.mul(D(1,2,p),N(c));return this.sign=w.sign,this.layer=w.layer,this.mag=w.mag,o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}else this.mag=p;return this.normalize(),o.fromStringCache.maxSize>=1&&o.fromStringCache.set(r,o.fromDecimal(this)),this}fromValue(t){return t instanceof o?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.NEGATIVE_INFINITY&&this.layer===Number.NEGATIVE_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:ht(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:ht(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.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_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<=ae?(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):ht(this.m,t)+"e"+ht(this.e,t):this.layer===1?ht(this.m,t)+"e"+ht(this.e,t):this.layer<=ae?(this.sign===-1?"-":"")+"e".repeat(this.layer)+ht(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+ht(this.mag,t)}abs(){return Y(this.sign===0?0:1,this.layer,this.mag)}neg(){return Y(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?o.dZero:this.layer===0?D(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?this.sign===-1?o.dNegOne:o.dZero:this.sign===-1?this.neg().ceil().neg():this.layer===0?D(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?this.sign===1?o.dOne:o.dZero:this.sign===-1?this.neg().floor().neg():this.layer===0?D(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?o.dZero:this.layer===0?D(this.sign,0,Math.trunc(this.mag)):this}add(t){let e=N(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer)||this.sign===0)return e;if(e.sign===0)return this;if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return Y(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(o.cmpabs(this,e)>0?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return o.fromNumber(r.sign*r.mag+i.sign*i.mag);let n=r.layer*Math.sign(r.mag),s=i.layer*Math.sign(i.mag);if(n-s>=2)return r;if(n===0&&s===-1){if(Math.abs(i.mag-Math.log10(r.mag))>Ut)return r;{let h=Math.pow(10,Math.log10(r.mag)-i.mag),v=i.sign+r.sign*h;return D(Math.sign(v),1,i.mag+Math.log10(Math.abs(v)))}}if(n===1&&s===0){if(Math.abs(r.mag-Math.log10(i.mag))>Ut)return r;{let h=Math.pow(10,r.mag-Math.log10(i.mag)),v=i.sign+r.sign*h;return D(Math.sign(v),1,Math.log10(i.mag)+Math.log10(Math.abs(v)))}}if(Math.abs(r.mag-i.mag)>Ut)return r;{let h=Math.pow(10,r.mag-i.mag),v=i.sign+r.sign*h;return D(Math.sign(v),1,i.mag+Math.log10(Math.abs(v)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(N(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=N(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer))return e;if(this.sign===0||e.sign===0)return Y(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return Y(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=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return o.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return D(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return D(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return D(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let n=D(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(D(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return D(r.sign*i.sign,n.layer+1,n.sign*n.mag)}if(r.layer===2&&i.layer===2){let n=D(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(D(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return D(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=N(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?o.dNaN:this.layer===0?D(this.sign,0,1/this.mag):D(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=N(t).abs();if(e.eq(o.dZero))return o.dZero;let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new o(r%i):this.sub(e).eq(this)?o.dZero:e.sub(this).eq(e)?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=N(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?e: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=N(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=N(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=$t(n)),this.layer0?D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):D(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?o.dNaN:this.layer>0?D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):D(this.sign,0,Math.log10(this.mag))}log(t){return t=N(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?o.dNaN:this.layer===0&&t.layer===0?D(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):o.div(this.log10(),t.log10())}log2(){return this.sign<=0?o.dNaN:this.layer===0?D(this.sign,0,Math.log2(this.mag)):this.layer===1?D(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?D(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?o.dNaN:this.layer===0?D(this.sign,0,Math.log(this.mag)):this.layer===1?D(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?D(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=N(t),r=this,i=e;if(r.sign===0)return i.eq(0)?Y(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return Y(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:o.dNaN:n}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return o.dNaN;let t=this;if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return D(1,0,e);if(t.sign===0)return o.dOne;t=Y(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?D(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?D(-t.sign,t.layer+1,-t.mag):o.dOne}pow_base(t){return N(t).pow(this)}root(t){let e=N(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?o.exp(o.mul(this,o.ln(this).sub(1))):o.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(Y(1,0,24)))return o.fromNumber(gr(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,s=1/n,h=e+s;if(h===e||(e=h,i=i*r,n=360*i,s=1/n,h=e-s,h===e))return o.exp(e);e=h,i=i*r,n=1260*i;let v=1/n;return e=e+v,i=i*r,n=1680*i,v=1/n,e=e-v,o.exp(e)}else return this.layer===1?o.exp(o.mul(this,o.ln(this).sub(1))):o.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?o.dOne:this.layer===0&&this.mag<=709.7?o.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?D(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?D(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):D(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return o.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return D(1,2,Math.log10(this.mag)-.3010299956639812);{let t=o.div(Y(this.sign,this.layer-1,this.mag),Y(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=Y(1,0,1),r=!1){if(t===1)return o.pow(this,e);if(t===0)return new o(e);if(this.eq(o.dOne))return o.dOne;if(this.eq(-1))return o.pow(this,e);if(t===Number.POSITIVE_INFINITY){let s=this.toNumber();if(s<=1.444667861009766&&s>=.06598803584531254){if(s>1.444667861009099)return o.fromNumber(Math.E);let h=o.ln(this).neg();return h.lambertw().div(h)}else return s>1.444667861009766?o.fromNumber(Number.POSITIVE_INFINITY):o.dNaN}if(this.eq(o.dZero)){let s=Math.abs((t+1)%2);return s>1&&(s=2-s),o.fromNumber(s)}if(t<0)return o.iteratedlog(e,this,-t,r);e=N(e);let i=t;t=Math.trunc(t);let n=i-t;if(this.gt(o.dZero)&&this.lte(1.444667861009766)&&(i>1e4||!r)){t=Math.min(1e4,t);for(let s=0;s1e4){let s=this.pow(e);return i<=1e4||Math.ceil(i)%2==0?e.mul(1-n).add(s.mul(n)):e.mul(n).add(s.mul(1-n))}return e}n!==0&&(e.eq(o.dOne)?this.gt(10)||r?e=this.pow(n):(e=o.fromNumber(o.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):e=e.layeradd(n,this,r));for(let s=0;s3)return Y(e.sign,e.layer+(t-s-1),e.mag);if(s>1e4)return e}return e}iteratedexp(t=2,e=Y(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return o.tetrate(t,-e,this,r);t=N(t);let i=o.fromDecimal(this),n=e;e=Math.trunc(e);let s=n-e;if(i.layer-t.layer>3){let h=Math.min(e,i.layer-t.layer-3);e-=h,i.layer-=h}for(let h=0;h1e4)return i}return s>0&&s<1&&(t.eq(10)?i=i.layeradd10(-s,r):i=i.layeradd(-s,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,n=!1,s=!1,h=this.slog_internal(t,r).toNumber();for(let v=1;v1&&s!=f&&(n=!0),s=f,n?i/=2:i*=2,i=Math.abs(i)*(f?-1:1),h+=i,i===0)break}return o.fromNumber(h)}slog_internal(t=10,e=!1){if(t=N(t),t.lte(o.dZero)||t.eq(o.dOne))return o.dNaN;if(t.lt(o.dOne))return this.eq(o.dOne)?o.dZero:this.eq(o.dZero)?o.dNegOne:o.dNaN;if(this.mag<0||this.eq(o.dZero))return o.dNegOne;let r=0,i=o.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(o.dZero))i=o.pow(t,i),r-=1;else{if(i.lte(o.dOne))return e?o.fromNumber(r+i.toNumber()-1):o.fromNumber(r+o.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=o.log(i,t)}return o.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:o.critical_section(t,e,dr)}static tetrate_critical(t,e){return o.critical_section(t,e,hr)}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,s=0;for(let v=0;vt){let d=(t-mt[v])/(mt[v+1]-mt[v]);n=r[v][Math.floor(e)]*(1-d)+r[v+1][Math.floor(e)]*d,s=r[v][Math.ceil(e)]*(1-d)+r[v+1][Math.ceil(e)]*d;break}let h=e-Math.floor(e);return n<=0||s<=0?n*(1-h)+s*h:Math.pow(t,Math.log(n)/Math.log(t)*(1-h)+Math.log(s)/Math.log(t)*h)}layeradd10(t,e=!1){t=o.fromValue_noAlloc(t).toNumber();let r=o.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 n=this.slog(e).toNumber()+t;return n>=0?o.tetrate(e,n,o.dOne,r):Number.isFinite(n)?n>=-1?o.log(o.tetrate(e,n+1,o.dOne,r),e):o.log(o.log(o.tetrate(e,n+2,o.dOne,r),e),e):o.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return o.fromNumber(ue(this.toNumber()));if(this.layer===0)return o.fromNumber(ue(this.sign*this.mag));if(this.layer===1)return fe(this);if(this.layer===2)return fe(this);if(this.layer>=3)return Y(this.sign,this.layer-1,this.mag);throw"Unhandled behavior in lambertw()"}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(o.dInf))return o.dInf;if(!this.isFinite())return o.dNaN;if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return o.fromNumber(t).add(2).pow(this.recip());if(t<=0)return o.dNaN;if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return emr?this.pow(this.recip()):o.dNaN}if(this.eq(1))return o.dOne;if(this.lt(0))return o.dNaN;if(this.lte("1ee-16"))return t%2==1?this:o.dNaN;if(this.gt(1)){let e=o.dTen;this.gte(o.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=o.dZero,i=e.layer,n=e.iteratedlog(10,i,!0),s=n,h=n.div(2),v=!0;for(;v;)h=r.add(n).div(2),o.iteratedexp(10,i,h,!0).tetrate(t,1,!0).gt(this)?n=h:r=h,h.eq(s)?v=!1:s=h;return o.iteratedexp(10,i,h,!0)}else{let e=1,r=D(1,10,1),i=D(1,10,1),n=D(1,10,1),s=D(1,1,-16),h=o.dZero,v=D(1,10,1),d=s.pow10().recip(),f=o.dZero,y=d,l=d,u=Math.ceil(t)%2==0,c=0,p=D(1,10,1),w=!1,I=o.dZero,L=!1;for(;e<4;){if(e==2){if(u)break;n=D(1,10,1),s=r,e=3,v=D(1,10,1),p=D(1,10,1)}for(w=!1;s.neq(n);){if(I=s,s.pow10().recip().tetrate(t,1,!0).eq(1)&&s.pow10().recip().lt(.4))d=s.pow10().recip(),y=s.pow10().recip(),l=s.pow10().recip(),f=o.dZero,c=-1,e==3&&(p=s);else if(s.pow10().recip().tetrate(t,1,!0).eq(s.pow10().recip())&&!u&&s.pow10().recip().lt(.4))d=s.pow10().recip(),y=s.pow10().recip(),l=s.pow10().recip(),f=o.dZero,c=0;else if(s.pow10().recip().tetrate(t,1,!0).eq(s.pow10().recip().mul(2).tetrate(t,1,!0)))d=s.pow10().recip(),y=o.dZero,l=d.mul(2),f=d,u?c=-1:c=0;else{for(h=s.mul(12e-17),d=s.pow10().recip(),y=s.add(h).pow10().recip(),f=d.sub(y),l=d.add(f);y.tetrate(t,1,!0).eq(d.tetrate(t,1,!0))||l.tetrate(t,1,!0).eq(d.tetrate(t,1,!0))||y.gte(d)||l.lte(d);)h=h.mul(2),y=s.add(h).pow10().recip(),f=d.sub(y),l=d.add(f);if((e==1&&l.tetrate(t,1,!0).gt(d.tetrate(t,1,!0))&&y.tetrate(t,1,!0).gt(d.tetrate(t,1,!0))||e==3&&l.tetrate(t,1,!0).lt(d.tetrate(t,1,!0))&&y.tetrate(t,1,!0).lt(d.tetrate(t,1,!0)))&&(p=s),l.tetrate(t,1,!0).lt(d.tetrate(t,1,!0)))c=-1;else if(u)c=1;else if(e==3&&s.gt_tolerance(r,1e-8))c=0;else{for(;y.tetrate(t,1,!0).eq_tolerance(d.tetrate(t,1,!0),1e-8)||l.tetrate(t,1,!0).eq_tolerance(d.tetrate(t,1,!0),1e-8)||y.gte(d)||l.lte(d);)h=h.mul(2),y=s.add(h).pow10().recip(),f=d.sub(y),l=d.add(f);l.tetrate(t,1,!0).sub(d.tetrate(t,1,!0)).lt(d.tetrate(t,1,!0).sub(y.tetrate(t,1,!0)))?c=0:c=1}}if(c==-1&&(L=!0),e==1&&c==1||e==3&&c!=0)if(n.eq(D(1,10,1)))s=s.mul(2);else{let m=!1;if(w&&(c==1&&e==1||c==-1&&e==3)&&(m=!0),s=s.add(n).div(2),m)break}else if(n.eq(D(1,10,1)))n=s,s=s.div(2);else{let m=!1;if(w&&(c==1&&e==1||c==-1&&e==3)&&(m=!0),n=n.sub(v),s=s.sub(v),m)break}if(n.sub(s).div(2).abs().gt(v.mul(1.5))&&(w=!0),v=n.sub(s).div(2).abs(),s.gt("1e18")||s.eq(I))break}if(s.gt("1e18")||!L||p==D(1,10,1))break;e==1?r=p:e==3&&(i=p),e++}n=r,s=D(1,1,-18);let F=s,a=o.dZero,S=!0;for(;S;)if(n.eq(D(1,10,1))?a=s.mul(2):a=n.add(s).div(2),o.pow(10,a).recip().tetrate(t,1,!0).gt(this)?s=a:n=a,a.eq(F)?S=!1:F=a,s.gt("1e18"))return o.dNaN;if(a.eq_tolerance(r,1e-15)){if(i.eq(D(1,10,1)))return o.dNaN;for(n=D(1,10,1),s=i,F=s,a=o.dZero,S=!0;S;)if(n.eq(D(1,10,1))?a=s.mul(2):a=n.add(s).div(2),o.pow(10,a).recip().tetrate(t,1,!0).gt(this)?s=a:n=a,a.eq(F)?S=!1:F=a,s.gt("1e18"))return o.dNaN;return a.pow10().recip()}else return a.pow10().recip()}}pentate(t=2,e=Y(1,0,1),r=!1){e=N(e);let i=t;t=Math.trunc(t);let n=i-t;n!==0&&(e.eq(o.dOne)?(++t,e=o.fromNumber(n)):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let s=0;s10)return e}return e}sin(){return this.mag<0?this:this.layer===0?o.fromNumber(Math.sin(this.sign*this.mag)):Y(0,0,0)}cos(){return this.mag<0?o.dOne:this.layer===0?o.fromNumber(Math.cos(this.sign*this.mag)):Y(0,0,0)}tan(){return this.mag<0?this:this.layer===0?o.fromNumber(Math.tan(this.sign*this.mag)):Y(0,0,0)}asin(){return this.mag<0?this:this.layer===0?o.fromNumber(Math.asin(this.sign*this.mag)):Y(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?o.fromNumber(Math.acos(this.toNumber())):this.layer===0?o.fromNumber(Math.acos(this.sign*this.mag)):Y(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?o.fromNumber(Math.atan(this.sign*this.mag)):o.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 o.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return o.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?Y(Number.NaN,Number.NaN,Number.NaN):o.ln(this.add(1).div(o.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?this:this.root(o.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 o(t).add(new o(e).minus(new o(t)).times(new o(r)).times(new o(i)))}clone(){return this}static clone(t){return o.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 o(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new o(t),e=new o(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):o.pow(e,n.sub(t)).mul(t))),n}static scale(t,e,r,i,n=!1){return new o(t).scale(e,r,i,n)}format(t=2,e=9,r="mixed_sc"){return pt.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return pt.format(new o(t),e,r,i)}formatST(t=2,e=9,r="st"){return pt.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return pt.format(new o(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return pt.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,n){return pt.formatGain(new o(t),e,r,i,n)}toRoman(t=5e3){t=new o(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 s of Object.keys(i)){let h=Math.floor(r/i[s]);r-=h*i[s],n+=s.repeat(h)}return n}static toRoman(t,e){return new o(t).toRoman(e)}static random(t=0,e=1){return t=new o(t),e=new o(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new o(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new o(Math.random()).lt(t)}};o.dZero=Y(0,0,0),o.dOne=Y(1,0,1),o.dNegOne=Y(-1,0,1),o.dTwo=Y(1,0,2),o.dTen=Y(1,0,10),o.dNaN=Y(Number.NaN,Number.NaN,Number.NaN),o.dInf=Y(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),o.dNegInf=Y(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),o.dNumberMax=D(1,0,Number.MAX_VALUE),o.dNumberMin=D(1,0,Number.MIN_VALUE),o.fromStringCache=new jt(ur),ft([Tt()],o.prototype,"sign",2),ft([Tt()],o.prototype,"mag",2),ft([Tt()],o.prototype,"layer",2),o=ft([tr()],o);var{formats:pt,FORMATS:pr}=rr(o);o.formats=pt;var k=(()=>{let t=e=>new o(e);return Object.getOwnPropertyNames(o).filter(e=>!Object.getOwnPropertyNames(class{}).includes(e)).forEach(e=>{t[e]=o[e]}),t})(),Nt=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.value=t.value,this.order=t.order??99}},zt=class{constructor(t=1,e){this.addBoost=this.setBoost.bind(this),e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=k(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new Nt(r))})}getBoosts(t,e){let r=[],i=[];for(let n=0;nl),f=n,y=this.getBoosts(s,!0);y[0][0]?this.boostArray[y[1][0]]=new Nt({id:s,name:h,description:v,value:d,order:f}):this.boostArray.push(new Nt({id:s,name:h,description:v,value:d,order:f}))}else{t=Array.isArray(t)?t:[t];for(let s of t){let h=this.getBoosts(s.id,!0);h[0][0]?this.boostArray[h[1][0]]=new Nt(s):this.boostArray.push(new Nt(s))}}}calculate(t=this.baseEffect){let e=k(t),r=this.boostArray;r=r.sort((i,n)=>i.order-n.order);for(let i of r)e=i.value(e);return e}},Ur=ot(ct()),xt=35;function Yt(t,e,r="geometric",i=xt){let n=k(1),s=k(e);if(t(s).eq(0))return{value:k(0),lowerBound:k(0),upperBound:k(0)};if(t(s).lt(e))return console.warn("The function is not monotonically increasing. (f(n) < n)"),{value:s,lowerBound:s,upperBound:s};for(let v=0;ve.cost(p.add(r)),u=k.min(i,Yt(l,t,n,s).value.floor()),c=k(0);return[u,c]}let d=Yt(l=>Zt(e.cost,l,r),t,n,s).value.floor().min(r.add(v).sub(1)),f=Zt(e.cost,d,r);return[d.sub(r).add(1).max(0),f]}function kt(t){return t=k(t),`${t.sign}/${t.mag}/${t.layer}`}function de(t,e){return`sum/${kt(t)}/${kt(e)}}`}function Ht(t){return`el/${kt(t)}`}var vt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?k(t.level):k(1)}};ft([Tt()],vt.prototype,"id",2),ft([Ft(()=>o)],vt.prototype,"level",2);var ge=class De{static{this.cacheSize=63}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn()}get level(){return((this??{data:{level:k(1)}}).data??{level:k(1)}).level}set level(e){this.data.level=k(e)}constructor(e,r,i){let n=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>n,this.cache=new jt(i??De.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??k(1)}getCached(e,r,i){return e==="sum"?this.cache.get(de(r,i??k(0))):this.cache.get(Ht(r))}setCached(e,r,i,n){let s=e==="sum"?{id:this.id,el:!1,start:k(r),end:k(i),cost:k(n)}:{id:this.id,el:!0,level:k(r),cost:k(i)};return e==="sum"?this.cache.set(de(r,i),s):this.cache.set(Ht(r),s),s}},$r=ot(ct()),yt=class{constructor(){this.value=k(0),this.upgrades={}}};ft([Ft(()=>o)],yt.prototype,"value",2),ft([Ft(()=>vt)],yt.prototype,"upgrades",2);var me=class{get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}constructor(t=new yt,e,r={defaultVal:k(0),defaultBoost:k(1)}){this.defaultVal=r.defaultVal,this.defaultBoost=r.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new zt(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e)}onLoadData(){for(let t of Object.values(this.upgrades))t.effect?.(t.level,t)}reset(t=!0,e=!0,r=!0){if(t&&(this.value=this.defaultVal),e)for(let i of Object.values(this.upgrades))i.level=k(i.defaultLevel),r&&i.effect?.(i.level,i)}gain(t=1e3){let e=this.boost.calculate().mul(k(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new vt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r={};for(let i of t){let n=this.pointerAddUpgrade(i),s=new ge(i,()=>this.pointerGetUpgrade(i.id));s.effect&&e&&s.effect(s.level,s),r[i.id]=s,this.upgrades[i.id]=s}return Object.values(r)}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&(r.name=e.name??r.name,r.cost=e.cost??r.cost,r.maxLevel=e.maxLevel??r.maxLevel,r.effect=e.effect??r.effect)}calculateUpgrade(t,e,r,i){let n=this.getUpgrade(t);return n===null?(console.warn(`Upgrade "${t}" not found.`),[k(0),k(0)]):he(this.value,n,n.level,e?n.level.add(e):void 0,r,i)}getNextCost(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),k(0);let s=this.calculateUpgrade(t,e,r,i)[0];return n.cost(n.level.add(s))}getNextCostMax(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),k(0);let s=this.calculateUpgrade(t,e,r,i);return n.cost(n.level.add(s[0])).add(s[1])}buyUpgrade(t,e,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),!1;let[s,h]=this.calculateUpgrade(t,e,r,i);return s.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(h),n.level=n.level.add(s),n.effect?.(n.level,n),!0)}},zr=ot(ct()),Lt=class{constructor(t=0){this.value=k(t)}};ft([Ft(()=>o)],Lt.prototype,"value",2);var pe=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=k(r),t??=new Lt(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new zt(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}},ve=class{constructor(t,e,r){this.x=t,this.y=e,this.properties=r??{}}setValue(t,e){return this.properties[t]=e,e}getValue(t){return this.properties[t]}},yr=class{constructor(t,e,r){this.xSize=t,this.ySize=e,this.cells=[];for(let i=0;iPt,DataManager:()=>_e,EventManager:()=>Me,EventTypes:()=>we,Game:()=>Nr,GameAttribute:()=>Ae,GameCurrency:()=>Se,GameReset:()=>Oe,KeyManager:()=>be,gameDefaultConfig:()=>Ie,keys:()=>wr});var Yr=ot(ct()),Pt=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}},br={autoAddInterval:!0,fps:30,pixiApp:void 0},wr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ".split("").concat(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),be=class Re{constructor(e){if(this.addKeys=this.addKey.bind(this),this.keysPressed=[],this.binds=[],this.tickers=[],this.config=Re.configManager.parse(e),this.config.autoAddInterval)if(this.config.pixiApp)this.config.pixiApp.ticker.add(r=>{for(let i of this.tickers)i(r)});else{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 Pt(br)}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)):this.config.pixiApp&&(this.config.pixiApp.ticker.maxFPS=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 s=this.getBind(n.id);if(s){Object.assign(s,n);continue}this.binds.push(n)}}},we=(t=>(t.interval="interval",t.timeout="timeout",t))(we||{}),Mr={autoAddInterval:!0,fps:30,pixiApp:void 0},Me=class je{constructor(e){if(this.addEvent=this.setEvent.bind(this),this.config=je.configManager.parse(e),this.events={},this.config.autoAddInterval)if(this.config.pixiApp)this.config.pixiApp.ticker.add(()=>{this.tickerFunction()});else{let r=this.config.fps??30;this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/r)}}static{this.configManager=new Pt(Mr)}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.callbackFn(i),r.intervalLast=e}break;case"timeout":{let i=e-r.timeCreated;e-r.timeCreated>=r.delay&&(r.callbackFn(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)):this.config.pixiApp&&(this.config.pixiApp.ticker.maxFPS=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(),callbackFn:n,timeCreated:Date.now(),intervalLast:Date.now()};case"timeout":default:return{name:e,type:r,delay:typeof i=="number"?i:i.toNumber(),callbackFn:n,timeCreated:Date.now()}}})()}removeEvent(e){delete this.events[e]}},Zr=ot(ct()),Ne=ot(Ye()),Vt=ot(Ve()),_e=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 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 this.static[t]}init(){this.normalData=this.data,this.normalDataPlain=Gt(this.data)}compileDataRaw(t=this.data){let e=Gt(t),r=(0,Vt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(e)}`),i;try{i="8.2.0"}catch{i="8.2.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,Ne.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,Ne.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,Vt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`)===e;let i=e.hash,n=(0,Vt.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(!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)}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(y){return typeof y=="object"&&y?.constructor===Object}let n=(y,l)=>Object.prototype.hasOwnProperty.call(y,l);function s(y,l,u){if(!y||!l||!u)throw new Error("dataManager.deepMerge(): Missing arguments.");let c=u;for(let p in y)if(n(y,p)&&!n(u,p)&&(c[p]=y[p]),l[p]instanceof yt){let w=y[p],I=u[p];if(Array.isArray(I.upgrades)){let L=I.upgrades;I.upgrades={};for(let F of L)I.upgrades[F.id]=F}I.upgrades={...w.upgrades,...I.upgrades},c[p]=I}else i(y[p])&&i(u[p])&&(c[p]=s(y[p],l[p],u[p]));return c}let h=e?s(this.normalDataPlain,this.normalData,r):r,v=Object.getOwnPropertyNames(new vt({id:"",level:k(0)}));function d(y,l){let u=se(y,l);if(u instanceof yt)for(let c in u.upgrades){let p=u.upgrades[c];if(!p||!v.every(w=>Object.getOwnPropertyNames(p).includes(w))){delete u.upgrades[c];continue}u.upgrades[c]=se(vt,p)}if(!u)throw new Error(`Failed to convert ${y.name} to class instance.`);return u}function f(y,l){if(!y||!l)throw new Error("dataManager.plainToInstanceRecursive(): Missing arguments.");let u=l;for(let c in y){if(l[c]===void 0){console.warn(`Missing property "${c}" in loaded data.`);continue}if(!i(l[c]))continue;let p=y[c].constructor;if(p===Object){u[c]=f(y[c],l[c]);continue}u[c]=d(p,l[c])}return u}return h=f(this.normalData,h),h}loadData(t=this.decompileData()){if(t=typeof t=="string"?this.decompileData(t):t,!t)return null;let e=this.validateData([t[0],Gt(t[1])]),r=this.parseData(t);if(!r)return null;this.data=r;for(let i of this.eventsOnLoad)i();return e}},Se=class{get data(){return this.dataPointer()}get static(){return this.staticPointer()}constructor(t,e,r,i){this.dataPointer=typeof t=="function"?t:()=>t,this.staticPointer=typeof e=="function"?e:()=>e,this.game=r,this.name=i,this.game.dataManager.addEventOnLoad(()=>{this.static.onLoadData()})}get value(){return this.data.value}},Ae=class{constructor(t,e,r){this.data=typeof t=="function"?t():t,this.static=typeof e=="function"?e():e,this.game=r}get value(){return this.static.value}set value(t){this.data.value=t}},Oe=class{constructor(t,e){this.currenciesToReset=Array.isArray(t)?t:[t],this.extender=Array.isArray(e)?e:e?[e]:[],this.id=Symbol()}reset(){this.onReset?.(),this.currenciesToReset.forEach(t=>{t.static.reset()}),this.extender.forEach(t=>{t.id!==this.id&&t.reset()})}},Ie={mode:"production",name:{title:"",id:"",version:"0.0.0"},settings:{framerate:30},initIntervalBasedManagers:!0},Nr=class Ge{static{this.configManager=new Pt(Ie)}constructor(e){this.config=Ge.configManager.parse(e),this.dataManager=new _e(this),this.keyManager=new be({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.eventManager=new Me({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=[]){return this.dataManager.setData(e,{currency:new yt}),this.dataManager.setStatic(e,{currency:new me(()=>this.dataManager.getData(e).currency,r)}),new Se(()=>this.dataManager.getData(e).currency,()=>this.dataManager.getStatic(e).currency,this,e)}addAttribute(e,r=!0,i=0){let n=this.dataManager.setData(e,new Lt(i)),s=this.dataManager.setStatic(e,new pe(this.dataManager.getData(e),r,i));return new Ae(this.dataManager.getData(e),this.dataManager.getStatic(e),this)}addReset(e,r){return new Oe(e,r)}},_r={...ee,...ye};if(typeof at.exports=="object"&&typeof At=="object"){var Sr=(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};at.exports=Sr(at.exports,At)}return at.exports}); /*! Bundled license information: reflect-metadata/Reflect.js: diff --git a/dist/game/eMath.game.mjs b/dist/game/eMath.game.mjs index ab53ea0c..b0f99071 100644 --- a/dist/game/eMath.game.mjs +++ b/dist/game/eMath.game.mjs @@ -6997,20 +6997,22 @@ var Game = class _Game { * Adds a new currency section to the game. {@link GameCurrency} is the class. * It automatically adds the currency and currencyStatic objects to the data and static objects for saving and loading. * @template N - The name + * @template U - The upgrade names for the currency. See {@link CurrencyStatic} for more information. * @param name - The name of the currency section. This is also the name of the data and static objects, so it must be unique. + * @param upgrades - The upgrades for the currency. * @returns A new instance of the gameCurrency class. * @example * const currency = game.addCurrency("currency"); * currency.static.gain(); * console.log(currency.value); // E(1) */ - addCurrency(name) { + addCurrency(name, upgrades = []) { this.dataManager.setData(name, { currency: new Currency() }); this.dataManager.setStatic(name, { // @ts-expect-error - fix this - currency: new CurrencyStatic(() => this.dataManager.getData(name).currency) + currency: new CurrencyStatic(() => this.dataManager.getData(name).currency, upgrades) // attributes: {}, }); const classInstance = new GameCurrency(() => this.dataManager.getData(name).currency, () => this.dataManager.getStatic(name).currency, this, name); diff --git a/dist/pixiGame/eMath.pixiGame.js b/dist/pixiGame/eMath.pixiGame.js index d1ac0369..039ac2bb 100644 --- a/dist/pixiGame/eMath.pixiGame.js +++ b/dist/pixiGame/eMath.pixiGame.js @@ -7029,20 +7029,22 @@ var Game = class _Game { * Adds a new currency section to the game. {@link GameCurrency} is the class. * It automatically adds the currency and currencyStatic objects to the data and static objects for saving and loading. * @template N - The name + * @template U - The upgrade names for the currency. See {@link CurrencyStatic} for more information. * @param name - The name of the currency section. This is also the name of the data and static objects, so it must be unique. + * @param upgrades - The upgrades for the currency. * @returns A new instance of the gameCurrency class. * @example * const currency = game.addCurrency("currency"); * currency.static.gain(); * console.log(currency.value); // E(1) */ - addCurrency(name) { + addCurrency(name, upgrades = []) { this.dataManager.setData(name, { currency: new Currency() }); this.dataManager.setStatic(name, { // @ts-expect-error - fix this - currency: new CurrencyStatic(() => this.dataManager.getData(name).currency) + currency: new CurrencyStatic(() => this.dataManager.getData(name).currency, upgrades) // attributes: {}, }); const classInstance = new GameCurrency(() => this.dataManager.getData(name).currency, () => this.dataManager.getStatic(name).currency, this, name); diff --git a/dist/pixiGame/eMath.pixiGame.mjs b/dist/pixiGame/eMath.pixiGame.mjs index 5e600504..925b90ed 100644 --- a/dist/pixiGame/eMath.pixiGame.mjs +++ b/dist/pixiGame/eMath.pixiGame.mjs @@ -7001,20 +7001,22 @@ var Game = class _Game { * Adds a new currency section to the game. {@link GameCurrency} is the class. * It automatically adds the currency and currencyStatic objects to the data and static objects for saving and loading. * @template N - The name + * @template U - The upgrade names for the currency. See {@link CurrencyStatic} for more information. * @param name - The name of the currency section. This is also the name of the data and static objects, so it must be unique. + * @param upgrades - The upgrades for the currency. * @returns A new instance of the gameCurrency class. * @example * const currency = game.addCurrency("currency"); * currency.static.gain(); * console.log(currency.value); // E(1) */ - addCurrency(name) { + addCurrency(name, upgrades = []) { this.dataManager.setData(name, { currency: new Currency() }); this.dataManager.setStatic(name, { // @ts-expect-error - fix this - currency: new CurrencyStatic(() => this.dataManager.getData(name).currency) + currency: new CurrencyStatic(() => this.dataManager.getData(name).currency, upgrades) // attributes: {}, }); const classInstance = new GameCurrency(() => this.dataManager.getData(name).currency, () => this.dataManager.getStatic(name).currency, this, name); diff --git a/dist/types/classes/Attribute.d.ts b/dist/types/classes/Attribute.d.ts index bfbe9cda..71e0f469 100644 --- a/dist/types/classes/Attribute.d.ts +++ b/dist/types/classes/Attribute.d.ts @@ -20,6 +20,9 @@ declare class Attribute { } /** * Represents a static attribute, which is number that can affected by boosts. + * + * Note: This class is essentially a wrapper around {@link Boost}, and if you choose not to use boosts, you can use {@link Decimal} directly. + * It may be marked as deprecated in the future. * @template B - Indicates whether the boost is enabled. Defaults to true. * @example * const health = new AttributeStatic(undefined, true, 100); // AttributeStatic diff --git a/dist/types/classes/Currency.d.ts b/dist/types/classes/Currency.d.ts index 7b412f9a..c7104853 100644 --- a/dist/types/classes/Currency.d.ts +++ b/dist/types/classes/Currency.d.ts @@ -16,7 +16,7 @@ import { UpgradeData, UpgradeStatic, UpgradeInit } from "./Upgrade"; * IsPrimitiveString<"asdf">; // false * IsPrimitiveString; // false */ -type IsPrimitiveString = "" & T extends "random string that no one should ever get randomly" ? false : true; +type IsPrimitiveString = "random string that no one should ever get randomly" & T extends "" ? false : true; /** * Represents the frontend READONLY for a currency. Useful for saving / data management. * Note: This class is created by default when creating a {@link CurrencyStatic} class. Use that instead as there are no methods here. diff --git a/dist/types/game/Game.d.ts b/dist/types/game/Game.d.ts index d25ae066..d5512f50 100644 --- a/dist/types/game/Game.d.ts +++ b/dist/types/game/Game.d.ts @@ -85,14 +85,16 @@ declare class Game { * Adds a new currency section to the game. {@link GameCurrency} is the class. * It automatically adds the currency and currencyStatic objects to the data and static objects for saving and loading. * @template N - The name + * @template U - The upgrade names for the currency. See {@link CurrencyStatic} for more information. * @param name - The name of the currency section. This is also the name of the data and static objects, so it must be unique. + * @param upgrades - The upgrades for the currency. * @returns A new instance of the gameCurrency class. * @example * const currency = game.addCurrency("currency"); * currency.static.gain(); * console.log(currency.value); // E(1) */ - addCurrency(name: N): GameCurrency; + addCurrency(name: N, upgrades?: U): GameCurrency; /** * Adds a new attribute to the game. {@link GameAttribute} is the class. * It automatically adds the attribute and attributeStatic objects to the data and static objects for saving and loading. @@ -103,7 +105,7 @@ declare class Game { * @example * const myAttribute = game.addAttribute("myAttribute"); */ - addAttribute(name: string, useBoost?: boolean, initial?: ESource): GameAttribute; + addAttribute(name: string, useBoost?: B, initial?: ESource): GameAttribute; /** * Creates a new game reset object with the specified currencies to reset. * @param currenciesToReset - The currencies to reset. diff --git a/src/classes/Attribute.ts b/src/classes/Attribute.ts index 547ba476..195f08f1 100644 --- a/src/classes/Attribute.ts +++ b/src/classes/Attribute.ts @@ -28,6 +28,9 @@ class Attribute { /** * Represents a static attribute, which is number that can affected by boosts. + * + * Note: This class is essentially a wrapper around {@link Boost}, and if you choose not to use boosts, you can use {@link Decimal} directly. + * It may be marked as deprecated in the future. * @template B - Indicates whether the boost is enabled. Defaults to true. * @example * const health = new AttributeStatic(undefined, true, 100); // AttributeStatic diff --git a/src/classes/Currency.ts b/src/classes/Currency.ts index fcbc7656..128cd241 100644 --- a/src/classes/Currency.ts +++ b/src/classes/Currency.ts @@ -19,8 +19,7 @@ import { UpgradeData, UpgradeStatic, UpgradeInit, calculateUpgrade } from "./Upg * IsPrimitiveString<"asdf">; // false * IsPrimitiveString; // false */ -type IsPrimitiveString = "" & T extends "random string that no one should ever get randomly" ? false : true; - +type IsPrimitiveString = "random string that no one should ever get randomly" & T extends "" ? false : true; /** * Represents the frontend READONLY for a currency. Useful for saving / data management. diff --git a/src/game/Game.ts b/src/game/Game.ts index 22c5fd02..c49951e6 100644 --- a/src/game/Game.ts +++ b/src/game/Game.ts @@ -132,25 +132,27 @@ class Game { * Adds a new currency section to the game. {@link GameCurrency} is the class. * It automatically adds the currency and currencyStatic objects to the data and static objects for saving and loading. * @template N - The name + * @template U - The upgrade names for the currency. See {@link CurrencyStatic} for more information. * @param name - The name of the currency section. This is also the name of the data and static objects, so it must be unique. + * @param upgrades - The upgrades for the currency. * @returns A new instance of the gameCurrency class. * @example * const currency = game.addCurrency("currency"); * currency.static.gain(); * console.log(currency.value); // E(1) */ - public addCurrency (name: N): GameCurrency { + public addCurrency (name: N, upgrades: U = [] as unknown as U): GameCurrency { this.dataManager.setData(name, { currency: new Currency(), }); this.dataManager.setStatic(name, { // @ts-expect-error - fix this - currency: new CurrencyStatic(() => this.dataManager.getData(name).currency as Currency), + currency: new CurrencyStatic(() => this.dataManager.getData(name).currency as Currency, upgrades), // attributes: {}, }); // @ts-expect-error - fix this - const classInstance = new GameCurrency(() => this.dataManager.getData(name).currency as Currency, () => this.dataManager.getStatic(name).currency as Currency, this, name); + const classInstance = new GameCurrency(() => this.dataManager.getData(name).currency as Currency, () => this.dataManager.getStatic(name).currency as CurrencyStatic, this, name); // const dataRef = this.dataManager.setData(name, { @@ -173,16 +175,12 @@ class Game { * @example * const myAttribute = game.addAttribute("myAttribute"); */ - public addAttribute (name: string, useBoost = true, initial: ESource = 0): GameAttribute { - // eslint-disable-next-line @typescript-eslint/no-unused-vars + public addAttribute (name: string, useBoost: B = true as B, initial: ESource = 0): GameAttribute { const dataRef = this.dataManager.setData(name, new Attribute(initial)); - // @ts-expect-error - fix this - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const staticRef = this.dataManager.setStatic(name, new AttributeStatic(this.dataManager.getData(name), useBoost, initial)); + const staticRef = this.dataManager.setStatic(name, new AttributeStatic(this.dataManager.getData(name) as Attribute, useBoost, initial)); // const staticRef = this.dataManager.setStatic(name, new attributeStatic(dataRef, useBoost, initial)); - // @ts-expect-error - fix this - const classInstance = new GameAttribute(this.dataManager.getData(name), this.dataManager.getStatic(name), this); + const classInstance = new GameAttribute(this.dataManager.getData(name) as Attribute, this.dataManager.getStatic(name) as AttributeStatic, this); // const classInstance = new gameAttribute(() => dataRef as attribute, () => staticRef as attributeStatic, this); return classInstance; }