Planar-Pioneers/assets/index.d67add67.js

18 lines
218 KiB
JavaScript

/* empty css */import"./vue.c16a309b.js";import{_,C as s,l as Ve,q as hn,t as z,b2 as vt,ab as Y,aF as M,a1 as T,a2 as N,aL as Ft,G as he,aD as kr,w as ht,b3 as Et,a9 as f,O as ee,ap as ma,az as hi,as as Gt,aH as oi,A as Fe,$ as K,b7 as W,b9 as zi,ar as Wt,bv as An,a8 as E,bt as va,bc as Wn,T as ha,u as Ui,j as ba,bw as Rt,aM as It,a0 as j,aO as Xe,J as le,I as je,aI as yn,aG as wn,z as sn,bo as ya,bs as wa,aK as Fn,bd as ur,am as di,H as _a,bx as Na,bf as Ca}from"./@vue.6b211d3c.js";import{c as Mr}from"./nanoevents.1080beb7.js";import{L as nn}from"./lz-string.dccec454.js";import{Y as ka}from"./vue-next-select.ded54c4a.js";import{D as Ma}from"./vuedraggable.1879de79.js";import{p as Sa}from"./vue-textarea-autosize.35804eaf.js";import{P as Ia}from"./vue-panzoom.8ce6f9b1.js";import{s as $a,u as bi}from"./vue-toastification.9c2dad53.js";import"./amator.1e5a40c8.js";import"./bezier-easing.a990b400.js";import"./sortablejs.a0f68e5e.js";import"./panzoom.30c56ba6.js";import"./wheel.f2ae740f.js";import"./ngraph.events.083734c6.js";const xa=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerpolicy&&(a.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?a.credentials="include":r.crossorigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}};xa();const Ea="modulepreload",cr={},Pa="./",Hn=function(t,n){return!n||n.length===0?t():Promise.all(n.map(i=>{if(i=`${Pa}${i}`,i in cr)return;cr[i]=!0;const r=i.endsWith(".css"),a=r?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${a}`))return;const l=document.createElement("link");if(l.rel=r?"stylesheet":Ea,r||(l.as="script",l.crossOrigin=""),l.href=i,document.head.appendChild(l),r)return new Promise((u,c)=>{l.addEventListener("load",u),l.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>t())},Da="./projInfo-schema.json",Ta="Planar Pioneers",Aa="A game about controlling and exploiting planes!",Fa="planar-pioneers",Ra="thepaperpilot",Oa="",qa="",Va="0.0",Ba="Initial Commit",La=!1,ja=!1,za=2,Ua=!0,Ga=null,Wa="",Ha=["main"],Za=3600,Ya=0,Xa=!0,Ja="base64";var me={$schema:Da,title:Ta,description:Aa,id:Fa,author:Ra,discordName:Oa,discordLink:qa,versionNumber:Va,versionTitle:Ba,allowGoBack:La,defaultShowSmall:ja,defaultDecimalsShown:za,useHeader:Ua,banner:Ga,logo:Wa,initialTabs:Ha,maxTickLength:Za,offlineLimit:Ya,enablePausing:Xa,exportEncoding:Ja};class Ka{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){const n=this.map.get(t);if(n!==void 0)return n!==this.first&&(n===this.last?(this.last=n.prev,this.last.next=void 0):(n.prev.next=n.next,n.next.prev=n.prev),n.next=this.first,this.first.prev=n,this.first=n),n.value}set(t,n){if(this.maxSize<1)return;if(this.map.has(t))throw new Error("Cannot update existing keys in the cache");const i=new Qa(t,n);for(this.first===void 0?(this.first=i,this.last=i):(i.next=this.first,this.first.prev=i,this.first=i),this.map.set(t,i);this.map.size>this.maxSize;){const r=this.last;this.map.delete(r.key),this.last=r.prev,this.last.next=void 0}}}class Qa{constructor(t,n){this.next=void 0,this.prev=void 0,this.key=t,this.value=n}}const Di=17,es=9e15,ts=Math.log10(9e15),ns=1/9e15,is=308,rs=-324,dr=5,as=(1<<10)-1,ss=function(){const e=[];for(let n=rs+1;n<=is;n++)e.push(Number("1e"+n));const t=323;return function(n){return e[n+t]}}(),cn=[2,Math.E,3,4,5,6,7,8,9,10],os=[[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]],ls=[[-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]];let k=function(t){return o.fromValue_noAlloc(t)},Z=function(e,t,n){return o.fromComponents(e,t,n)},Q=function(t,n,i){return o.fromComponents_noNormalize(t,n,i)};const Qt=function(t,n){const i=n+1,r=Math.ceil(Math.log10(Math.abs(t))),a=Math.round(t*Math.pow(10,i-r))*Math.pow(10,r-i);return parseFloat(a.toFixed(Math.max(i-r,0)))},Ti=function(e){return Math.sign(e)*Math.log10(Math.abs(e))},us=function(e){if(!isFinite(e))return e;if(e<-50)return e===Math.trunc(e)?Number.NEGATIVE_INFINITY:0;let t=1;for(;e<10;)t=t*e,++e;e-=1;let n=.9189385332046727;n=n+(e+.5)*Math.log(e),n=n-e;const i=e*e;let r=e;return n=n+1/(12*r),r=r*i,n=n+1/(360*r),r=r*i,n=n+1/(1260*r),r=r*i,n=n+1/(1680*r),r=r*i,n=n+1/(1188*r),r=r*i,n=n+691/(360360*r),r=r*i,n=n+7/(1092*r),r=r*i,n=n+3617/(122400*r),Math.exp(n)/t},Sr=.5671432904097838,pr=function(e,t=1e-10){let n,i;if(!Number.isFinite(e)||e===0)return e;if(e===1)return Sr;e<10?n=0:n=Math.log(e)-Math.log(Math.log(e));for(let r=0;r<100;++r){if(i=(e*Math.exp(-n)+n*n)/(n+1),Math.abs(i-n)<t*Math.abs(i))return i;n=i}throw Error(`Iteration failed to converge: ${e.toString()}`)};function fr(e,t=1e-10){let n,i,r,a;if(!Number.isFinite(e.mag)||e.eq(o.dZero))return e;if(e.eq(o.dOne))return o.fromNumber(Sr);n=o.ln(e);for(let l=0;l<100;++l){if(i=n.neg().exp(),r=n.sub(e.mul(i)),a=n.sub(r.div(n.add(1).sub(n.add(2).mul(r).div(o.mul(2,n).add(2))))),o.abs(a.sub(n)).lt(o.abs(a).mul(t)))return a;n=a}throw Error(`Iteration failed to converge: ${e.toString()}`)}const b=class{constructor(e){this.sign=0,this.mag=0,this.layer=0,e instanceof b?this.fromDecimal(e):typeof e=="number"?this.fromNumber(e):typeof e=="string"&&this.fromString(e)}get m(){if(this.sign===0)return 0;if(this.layer===0){const e=Math.floor(Math.log10(this.mag));let t;return this.mag===5e-324?t=5:t=this.mag/ss(e),this.sign*t}else if(this.layer===1){const e=this.mag-Math.floor(this.mag);return this.sign*Math.pow(10,e)}else return this.sign}set m(e){this.layer<=2?this.fromMantissaExponent(e,this.e):(this.sign=Math.sign(e),this.sign===0&&(this.layer=0,this.exponent=0))}get e(){return this.sign===0?0:this.layer===0?Math.floor(Math.log10(this.mag)):this.layer===1?Math.floor(this.mag):this.layer===2?Math.floor(Math.sign(this.mag)*Math.pow(10,Math.abs(this.mag))):this.mag*Number.POSITIVE_INFINITY}set e(e){this.fromMantissaExponent(this.m,e)}get s(){return this.sign}set s(e){e===0?(this.sign=0,this.layer=0,this.mag=0):this.sign=e}get mantissa(){return this.m}set mantissa(e){this.m=e}get exponent(){return this.e}set exponent(e){this.e=e}static fromComponents(e,t,n){return new b().fromComponents(e,t,n)}static fromComponents_noNormalize(e,t,n){return new b().fromComponents_noNormalize(e,t,n)}static fromMantissaExponent(e,t){return new b().fromMantissaExponent(e,t)}static fromMantissaExponent_noNormalize(e,t){return new b().fromMantissaExponent_noNormalize(e,t)}static fromDecimal(e){return new b().fromDecimal(e)}static fromNumber(e){return new b().fromNumber(e)}static fromString(e){return new b().fromString(e)}static fromValue(e){return new b().fromValue(e)}static fromValue_noAlloc(e){if(e instanceof b)return e;if(typeof e=="string"){const t=b.fromStringCache.get(e);return t!==void 0?t:b.fromString(e)}else return typeof e=="number"?b.fromNumber(e):b.dZero}static abs(e){return k(e).abs()}static neg(e){return k(e).neg()}static negate(e){return k(e).neg()}static negated(e){return k(e).neg()}static sign(e){return k(e).sign}static sgn(e){return k(e).sign}static round(e){return k(e).round()}static floor(e){return k(e).floor()}static ceil(e){return k(e).ceil()}static trunc(e){return k(e).trunc()}static add(e,t){return k(e).add(t)}static plus(e,t){return k(e).add(t)}static sub(e,t){return k(e).sub(t)}static subtract(e,t){return k(e).sub(t)}static minus(e,t){return k(e).sub(t)}static mul(e,t){return k(e).mul(t)}static multiply(e,t){return k(e).mul(t)}static times(e,t){return k(e).mul(t)}static div(e,t){return k(e).div(t)}static divide(e,t){return k(e).div(t)}static recip(e){return k(e).recip()}static reciprocal(e){return k(e).recip()}static reciprocate(e){return k(e).reciprocate()}static cmp(e,t){return k(e).cmp(t)}static cmpabs(e,t){return k(e).cmpabs(t)}static compare(e,t){return k(e).cmp(t)}static isNaN(e){return e=k(e),isNaN(e.sign)||isNaN(e.layer)||isNaN(e.mag)}static isFinite(e){return e=k(e),isFinite(e.sign)&&isFinite(e.layer)&&isFinite(e.mag)}static eq(e,t){return k(e).eq(t)}static equals(e,t){return k(e).eq(t)}static neq(e,t){return k(e).neq(t)}static notEquals(e,t){return k(e).notEquals(t)}static lt(e,t){return k(e).lt(t)}static lte(e,t){return k(e).lte(t)}static gt(e,t){return k(e).gt(t)}static gte(e,t){return k(e).gte(t)}static max(e,t){return k(e).max(t)}static min(e,t){return k(e).min(t)}static minabs(e,t){return k(e).minabs(t)}static maxabs(e,t){return k(e).maxabs(t)}static clamp(e,t,n){return k(e).clamp(t,n)}static clampMin(e,t){return k(e).clampMin(t)}static clampMax(e,t){return k(e).clampMax(t)}static cmp_tolerance(e,t,n){return k(e).cmp_tolerance(t,n)}static compare_tolerance(e,t,n){return k(e).cmp_tolerance(t,n)}static eq_tolerance(e,t,n){return k(e).eq_tolerance(t,n)}static equals_tolerance(e,t,n){return k(e).eq_tolerance(t,n)}static neq_tolerance(e,t,n){return k(e).neq_tolerance(t,n)}static notEquals_tolerance(e,t,n){return k(e).notEquals_tolerance(t,n)}static lt_tolerance(e,t,n){return k(e).lt_tolerance(t,n)}static lte_tolerance(e,t,n){return k(e).lte_tolerance(t,n)}static gt_tolerance(e,t,n){return k(e).gt_tolerance(t,n)}static gte_tolerance(e,t,n){return k(e).gte_tolerance(t,n)}static pLog10(e){return k(e).pLog10()}static absLog10(e){return k(e).absLog10()}static log10(e){return k(e).log10()}static log(e,t){return k(e).log(t)}static log2(e){return k(e).log2()}static ln(e){return k(e).ln()}static logarithm(e,t){return k(e).logarithm(t)}static pow(e,t){return k(e).pow(t)}static pow10(e){return k(e).pow10()}static pow_base(e,t){return k(e).pow_base(t)}static root(e,t){return k(e).root(t)}static factorial(e,t){return k(e).factorial()}static gamma(e,t){return k(e).gamma()}static lngamma(e,t){return k(e).lngamma()}static exp(e){return k(e).exp()}static sqr(e){return k(e).sqr()}static sqrt(e){return k(e).sqrt()}static cube(e){return k(e).cube()}static cbrt(e){return k(e).cbrt()}static tetrate(e,t=2,n=Q(1,0,1)){return k(e).tetrate(t,n)}static iteratedexp(e,t=2,n=Q(1,0,1)){return k(e).iteratedexp(t,n)}static iteratedlog(e,t=10,n=1){return k(e).iteratedlog(t,n)}static layeradd10(e,t){return k(e).layeradd10(t)}static layeradd(e,t,n=10){return k(e).layeradd(t,n)}static slog(e,t=10){return k(e).slog(t)}static lambertw(e){return k(e).lambertw()}static ssqrt(e){return k(e).ssqrt()}static pentate(e,t=2,n=Q(1,0,1)){return k(e).pentate(t,n)}static sin(e){return k(e).sin()}static cos(e){return k(e).cos()}static tan(e){return k(e).tan()}static asin(e){return k(e).asin()}static acos(e){return k(e).acos()}static atan(e){return k(e).atan()}static sinh(e){return k(e).sinh()}static cosh(e){return k(e).cosh()}static tanh(e){return k(e).tanh()}static asinh(e){return k(e).asinh()}static acosh(e){return k(e).acosh()}static atanh(e){return k(e).atanh()}static affordGeometricSeries(e,t,n,i){return this.affordGeometricSeries_core(k(e),k(t),k(n),i)}static sumGeometricSeries(e,t,n,i){return this.sumGeometricSeries_core(e,k(t),k(n),i)}static affordArithmeticSeries(e,t,n,i){return this.affordArithmeticSeries_core(k(e),k(t),k(n),k(i))}static sumArithmeticSeries(e,t,n,i){return this.sumArithmeticSeries_core(k(e),k(t),k(n),k(i))}static efficiencyOfPurchase(e,t,n){return this.efficiencyOfPurchase_core(k(e),k(t),k(n))}static randomDecimalForTesting(e){if(Math.random()*20<1)return Q(0,0,0);const t=Math.random()>.5?1:-1;if(Math.random()*20<1)return Q(t,0,1);const n=Math.floor(Math.random()*(e+1));let i=n===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let r=Math.pow(10,i);return Math.random()>.9&&(r=Math.trunc(r)),Z(t,n,r)}static affordGeometricSeries_core(e,t,n,i){const r=t.mul(n.pow(i));return b.floor(e.div(r).mul(n.sub(1)).add(1).log10().div(n.log10()))}static sumGeometricSeries_core(e,t,n,i){return t.mul(n.pow(i)).mul(b.sub(1,n.pow(e))).div(b.sub(1,n))}static affordArithmeticSeries_core(e,t,n,i){const a=t.add(i.mul(n)).sub(n.div(2)),l=a.pow(2);return a.neg().add(l.add(n.mul(e).mul(2)).sqrt()).div(n).floor()}static sumArithmeticSeries_core(e,t,n,i){const r=t.add(i.mul(n));return e.div(2).mul(r.mul(2).plus(e.sub(1).mul(n)))}static efficiencyOfPurchase_core(e,t,n){return e.div(t).add(e.div(n))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0)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.layer===0&&this.mag<ns)return this.layer+=1,this.mag=Math.log10(this.mag),this;let e=Math.abs(this.mag),t=Math.sign(this.mag);if(e>=es)return this.layer+=1,this.mag=t*Math.log10(e),this;for(;e<ts&&this.layer>0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=t*Math.pow(10,e),e=Math.abs(this.mag),t=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)),this}fromComponents(e,t,n){return this.sign=e,this.layer=t,this.mag=n,this.normalize(),this}fromComponents_noNormalize(e,t,n){return this.sign=e,this.layer=t,this.mag=n,this}fromMantissaExponent(e,t){return this.layer=1,this.sign=Math.sign(e),e=Math.abs(e),this.mag=t+Math.log10(e),this.normalize(),this}fromMantissaExponent_noNormalize(e,t){return this.fromMantissaExponent(e,t),this}fromDecimal(e){return this.sign=e.sign,this.layer=e.layer,this.mag=e.mag,this}fromNumber(e){return this.mag=Math.abs(e),this.sign=Math.sign(e),this.layer=0,this.normalize(),this}fromString(e){const t=e,n=b.fromStringCache.get(t);if(n!==void 0)return this.fromDecimal(n);e=e.replace(",","");const i=e.split("^^^");if(i.length===2){const C=parseFloat(i[0]),y=parseFloat(i[1]),I=i[1].split(";");let A=1;if(I.length===2&&(A=parseFloat(I[1]),isFinite(A)||(A=1)),isFinite(C)&&isFinite(y)){const S=b.pentate(C,y,A);return this.sign=S.sign,this.layer=S.layer,this.mag=S.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}}const r=e.split("^^");if(r.length===2){const C=parseFloat(r[0]),y=parseFloat(r[1]),I=r[1].split(";");let A=1;if(I.length===2&&(A=parseFloat(I[1]),isFinite(A)||(A=1)),isFinite(C)&&isFinite(y)){const S=b.tetrate(C,y,A);return this.sign=S.sign,this.layer=S.layer,this.mag=S.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}}const a=e.split("^");if(a.length===2){const C=parseFloat(a[0]),y=parseFloat(a[1]);if(isFinite(C)&&isFinite(y)){const I=b.pow(C,y);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}}e=e.trim().toLowerCase();let l,u,c=e.split("pt");if(c.length===2){l=10,u=parseFloat(c[0]),c[1]=c[1].replace("(",""),c[1]=c[1].replace(")","");let C=parseFloat(c[1]);if(isFinite(C)||(C=1),isFinite(l)&&isFinite(u)){const y=b.tetrate(l,u,C);return this.sign=y.sign,this.layer=y.layer,this.mag=y.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}}if(c=e.split("p"),c.length===2){l=10,u=parseFloat(c[0]),c[1]=c[1].replace("(",""),c[1]=c[1].replace(")","");let C=parseFloat(c[1]);if(isFinite(C)||(C=1),isFinite(l)&&isFinite(u)){const y=b.tetrate(l,u,C);return this.sign=y.sign,this.layer=y.layer,this.mag=y.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}}const d=e.split("e"),h=d.length-1;if(h===0){const C=parseFloat(e);if(isFinite(C))return this.fromNumber(C),b.fromStringCache.size>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}else if(h===1){const C=parseFloat(e);if(isFinite(C)&&C!==0)return this.fromNumber(C),b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}const p=e.split("e^");if(p.length===2){this.sign=1,p[0].charAt(0)=="-"&&(this.sign=-1);let C="";for(let y=0;y<p[1].length;++y){const I=p[1].charCodeAt(y);if(I>=43&&I<=57||I===101)C+=p[1].charAt(y);else return this.layer=parseFloat(C),this.mag=parseFloat(p[1].substr(y+1)),this.normalize(),b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}}if(h<1)return this.sign=0,this.layer=0,this.mag=0,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this;const m=parseFloat(d[0]);if(m===0)return this.sign=0,this.layer=0,this.mag=0,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this;let v=parseFloat(d[d.length-1]);if(h>=2){const C=parseFloat(d[d.length-2]);isFinite(C)&&(v*=Math.sign(C),v+=Ti(C))}if(!isFinite(m))this.sign=d[0]==="-"?-1:1,this.layer=h,this.mag=v;else if(h===1)this.sign=Math.sign(m),this.layer=1,this.mag=v+Math.log10(Math.abs(m));else if(this.sign=Math.sign(m),this.layer=h,h===2){const C=b.mul(Z(1,2,v),k(m));return this.sign=C.sign,this.layer=C.layer,this.mag=C.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}else this.mag=v;return this.normalize(),b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}fromValue(e){return e instanceof b?this.fromDecimal(e):typeof e=="number"?this.fromNumber(e):typeof e=="string"?this.fromString(e):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return 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(e){return isNaN(this.m)?Number.NaN:this.m===0?0:Qt(this.m,e)}magnitudeWithDecimalPlaces(e){return isNaN(this.mag)?Number.NaN:this.mag===0?0:Qt(this.mag,e)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY?this.sign===1?"Infinity":"-Infinity":this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toString():this.m+"e"+this.e:this.layer===1?this.m+"e"+this.e:this.layer<=dr?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(e){return this.layer===0?(this.sign*this.mag).toExponential(e):this.toStringWithDecimalPlaces(e)}toFixed(e){return this.layer===0?(this.sign*this.mag).toFixed(e):this.toStringWithDecimalPlaces(e)}toPrecision(e){return this.e<=-7?this.toExponential(e-1):e>this.e?this.toFixed(e-this.exponent-1):this.toExponential(e-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(e){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(e):Qt(this.m,e)+"e"+Qt(this.e,e):this.layer===1?Qt(this.m,e)+"e"+Qt(this.e,e):this.layer<=dr?(this.sign===-1?"-":"")+"e".repeat(this.layer)+Qt(this.mag,e):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+Qt(this.mag,e)}abs(){return Q(this.sign===0?0:1,this.layer,this.mag)}neg(){return Q(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?b.dZero:this.layer===0?Z(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?b.dZero:this.layer===0?Z(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?b.dZero:this.layer===0?Z(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?b.dZero:this.layer===0?Z(this.sign,0,Math.trunc(this.mag)):this}add(e){const t=k(e);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(t.layer)||this.sign===0)return t;if(t.sign===0)return this;if(this.sign===-t.sign&&this.layer===t.layer&&this.mag===t.mag)return Q(0,0,0);let n,i;if(this.layer>=2||t.layer>=2)return this.maxabs(t);if(b.cmpabs(this,t)>0?(n=this,i=t):(n=t,i=this),n.layer===0&&i.layer===0)return b.fromNumber(n.sign*n.mag+i.sign*i.mag);const r=n.layer*Math.sign(n.mag),a=i.layer*Math.sign(i.mag);if(r-a>=2)return n;if(r===0&&a===-1){if(Math.abs(i.mag-Math.log10(n.mag))>Di)return n;{const l=Math.pow(10,Math.log10(n.mag)-i.mag),u=i.sign+n.sign*l;return Z(Math.sign(u),1,i.mag+Math.log10(Math.abs(u)))}}if(r===1&&a===0){if(Math.abs(n.mag-Math.log10(i.mag))>Di)return n;{const l=Math.pow(10,n.mag-Math.log10(i.mag)),u=i.sign+n.sign*l;return Z(Math.sign(u),1,Math.log10(i.mag)+Math.log10(Math.abs(u)))}}if(Math.abs(n.mag-i.mag)>Di)return n;{const l=Math.pow(10,n.mag-i.mag),u=i.sign+n.sign*l;return Z(Math.sign(u),1,i.mag+Math.log10(Math.abs(u)))}}plus(e){return this.add(e)}sub(e){return this.add(k(e).neg())}subtract(e){return this.sub(e)}minus(e){return this.sub(e)}mul(e){const t=k(e);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(t.layer))return t;if(this.sign===0||t.sign===0)return Q(0,0,0);if(this.layer===t.layer&&this.mag===-t.mag)return Q(this.sign*t.sign,0,1);let n,i;if(this.layer>t.layer||this.layer==t.layer&&Math.abs(this.mag)>Math.abs(t.mag)?(n=this,i=t):(n=t,i=this),n.layer===0&&i.layer===0)return b.fromNumber(n.sign*i.sign*n.mag*i.mag);if(n.layer>=3||n.layer-i.layer>=2)return Z(n.sign*i.sign,n.layer,n.mag);if(n.layer===1&&i.layer===0)return Z(n.sign*i.sign,1,n.mag+Math.log10(i.mag));if(n.layer===1&&i.layer===1)return Z(n.sign*i.sign,1,n.mag+i.mag);if(n.layer===2&&i.layer===1){const r=Z(Math.sign(n.mag),n.layer-1,Math.abs(n.mag)).add(Z(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return Z(n.sign*i.sign,r.layer+1,r.sign*r.mag)}if(n.layer===2&&i.layer===2){const r=Z(Math.sign(n.mag),n.layer-1,Math.abs(n.mag)).add(Z(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return Z(n.sign*i.sign,r.layer+1,r.sign*r.mag)}throw Error("Bad arguments to mul: "+this+", "+e)}multiply(e){return this.mul(e)}times(e){return this.mul(e)}div(e){const t=k(e);return this.mul(t.recip())}divide(e){return this.div(e)}divideBy(e){return this.div(e)}dividedBy(e){return this.div(e)}recip(){return this.mag===0?b.dNaN:this.layer===0?Z(this.sign,0,1/this.mag):Z(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}cmp(e){const t=k(e);return this.sign>t.sign?1:this.sign<t.sign?-1:this.sign*this.cmpabs(e)}cmpabs(e){const t=k(e),n=this.mag>0?this.layer:-this.layer,i=t.mag>0?t.layer:-t.layer;return n>i?1:n<i?-1:this.mag>t.mag?1:this.mag<t.mag?-1:0}compare(e){return this.cmp(e)}isNan(){return isNaN(this.sign)||isNaN(this.layer)||isNaN(this.mag)}isFinite(){return isFinite(this.sign)&&isFinite(this.layer)&&isFinite(this.mag)}eq(e){const t=k(e);return this.sign===t.sign&&this.layer===t.layer&&this.mag===t.mag}equals(e){return this.eq(e)}neq(e){return!this.eq(e)}notEquals(e){return this.neq(e)}lt(e){return this.cmp(e)===-1}lte(e){return!this.gt(e)}gt(e){return this.cmp(e)===1}gte(e){return!this.lt(e)}max(e){const t=k(e);return this.lt(t)?t:this}min(e){const t=k(e);return this.gt(t)?t:this}maxabs(e){const t=k(e);return this.cmpabs(t)<0?t:this}minabs(e){const t=k(e);return this.cmpabs(t)>0?t:this}clamp(e,t){return this.max(e).min(t)}clampMin(e){return this.max(e)}clampMax(e){return this.min(e)}cmp_tolerance(e,t){const n=k(e);return this.eq_tolerance(n,t)?0:this.cmp(n)}compare_tolerance(e,t){return this.cmp_tolerance(e,t)}eq_tolerance(e,t){const n=k(e);if(t==null&&(t=1e-7),this.sign!==n.sign||Math.abs(this.layer-n.layer)>1)return!1;let i=this.mag,r=n.mag;return this.layer>n.layer&&(r=Ti(r)),this.layer<n.layer&&(i=Ti(i)),Math.abs(i-r)<=t*Math.max(Math.abs(i),Math.abs(r))}equals_tolerance(e,t){return this.eq_tolerance(e,t)}neq_tolerance(e,t){return!this.eq_tolerance(e,t)}notEquals_tolerance(e,t){return this.neq_tolerance(e,t)}lt_tolerance(e,t){const n=k(e);return!this.eq_tolerance(n,t)&&this.lt(n)}lte_tolerance(e,t){const n=k(e);return this.eq_tolerance(n,t)||this.lt(n)}gt_tolerance(e,t){const n=k(e);return!this.eq_tolerance(n,t)&&this.gt(n)}gte_tolerance(e,t){const n=k(e);return this.eq_tolerance(n,t)||this.gt(n)}pLog10(){return this.lt(b.dZero)?b.dZero:this.log10()}absLog10(){return this.sign===0?b.dNaN:this.layer>0?Z(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):Z(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?b.dNaN:this.layer>0?Z(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):Z(this.sign,0,Math.log10(this.mag))}log(e){return e=k(e),this.sign<=0||e.sign<=0||e.sign===1&&e.layer===0&&e.mag===1?b.dNaN:this.layer===0&&e.layer===0?Z(this.sign,0,Math.log(this.mag)/Math.log(e.mag)):b.div(this.log10(),e.log10())}log2(){return this.sign<=0?b.dNaN:this.layer===0?Z(this.sign,0,Math.log2(this.mag)):this.layer===1?Z(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?Z(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):Z(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?b.dNaN:this.layer===0?Z(this.sign,0,Math.log(this.mag)):this.layer===1?Z(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?Z(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):Z(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(e){return this.log(e)}pow(e){const t=k(e),n=this,i=t;if(n.sign===0)return i.eq(0)?Q(1,0,1):n;if(n.sign===1&&n.layer===0&&n.mag===1)return n;if(i.sign===0)return Q(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return n;const r=n.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?r.neg():Math.abs(i.toNumber()%2)%2===0?r:b.dNaN:r}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return b.dNaN;let e=this;if(e.layer===0){const t=Math.pow(10,e.sign*e.mag);if(Number.isFinite(t)&&Math.abs(t)>=.1)return Z(1,0,t);if(e.sign===0)return b.dOne;e=Q(e.sign,e.layer+1,Math.log10(e.mag))}return e.sign>0&&e.mag>=0?Z(e.sign,e.layer+1,e.mag):e.sign<0&&e.mag>=0?Z(-e.sign,e.layer+1,-e.mag):b.dOne}pow_base(e){return k(e).pow(this)}root(e){const t=k(e);return this.pow(t.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?b.exp(b.mul(this,b.ln(this).sub(1))):b.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(Q(1,0,24)))return b.fromNumber(us(this.sign*this.mag));const e=this.mag-1;let t=.9189385332046727;t=t+(e+.5)*Math.log(e),t=t-e;const n=e*e;let i=e,r=12*i,a=1/r,l=t+a;if(l===t||(t=l,i=i*n,r=360*i,a=1/r,l=t-a,l===t))return b.exp(t);t=l,i=i*n,r=1260*i;let u=1/r;return t=t+u,i=i*n,r=1680*i,u=1/r,t=t-u,b.exp(t)}else return this.layer===1?b.exp(b.mul(this,b.ln(this).sub(1))):b.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?b.dOne:this.layer===0&&this.mag<=709.7?b.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?Z(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?Z(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):Z(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return b.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return Z(1,2,Math.log10(this.mag)-.3010299956639812);{const e=b.div(Q(this.sign,this.layer-1,this.mag),Q(1,0,2));return e.layer+=1,e.normalize(),e}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(e=2,t=Q(1,0,1)){if(e===1)return b.pow(this,t);if(e===0)return new b(t);if(this.eq(b.dOne))return b.dOne;if(this.eq(-1))return b.pow(this,t);if(e===Number.POSITIVE_INFINITY){const r=this.toNumber();if(r<=1.444667861009766&&r>=.06598803584531254){if(r>1.444667861009099)return b.fromNumber(Math.E);const a=b.ln(this).neg();return a.lambertw().div(a)}else return r>1.444667861009766?b.fromNumber(Number.POSITIVE_INFINITY):b.dNaN}if(this.eq(b.dZero)){let r=Math.abs((e+1)%2);return r>1&&(r=2-r),b.fromNumber(r)}if(e<0)return b.iteratedlog(t,this,-e);t=k(t);const n=e;e=Math.trunc(e);const i=n-e;if(this.gt(b.dZero)&&this.lte(1.444667861009766)){e=Math.min(1e4,e);for(let r=0;r<e;++r){const a=t;if(t=this.pow(t),a.eq(t))return t}if(i!=0){const r=this.pow(t);return t.mul(1-i).add(r.mul(i))}return t}i!==0&&(t.eq(b.dOne)?this.gt(10)?t=this.pow(i):(t=b.fromNumber(b.tetrate_critical(this.toNumber(),i)),this.lt(2)&&(t=t.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?t=t.layeradd10(i):t=t.layeradd(i,this));for(let r=0;r<e;++r){if(t=this.pow(t),!isFinite(t.layer)||!isFinite(t.mag))return t.normalize();if(t.layer-this.layer>3)return Q(t.sign,t.layer+(e-r-1),t.mag);if(r>1e4)return t}return t}iteratedexp(e=2,t=Q(1,0,1)){return this.tetrate(e,t)}iteratedlog(e=10,t=1){if(t<0)return b.tetrate(e,-t,this);e=k(e);let n=b.fromDecimal(this);const i=t;t=Math.trunc(t);const r=i-t;if(n.layer-e.layer>3){const a=Math.min(t,n.layer-e.layer-3);t-=a,n.layer-=a}for(let a=0;a<t;++a){if(n=n.log(e),!isFinite(n.layer)||!isFinite(n.mag))return n.normalize();if(a>1e4)return n}return r>0&&r<1&&(e.eq(10)?n=n.layeradd10(-r):n=n.layeradd(-r,e)),n}slog(e=10,t=100){let n=.001,i=!1,r=!1,a=this.slog_internal(e).toNumber();for(let l=1;l<t;++l){const c=new b(e).tetrate(a).gt(this);if(l>1&&r!=c&&(i=!0),r=c,i?n/=2:n*=2,n=Math.abs(n)*(c?-1:1),a+=n,n===0)break}return b.fromNumber(a)}slog_internal(e=10){if(e=k(e),e.lte(b.dZero)||e.eq(b.dOne))return b.dNaN;if(e.lt(b.dOne))return this.eq(b.dOne)?b.dZero:this.eq(b.dZero)?b.dNegOne:b.dNaN;if(this.mag<0||this.eq(b.dZero))return b.dNegOne;let t=0,n=b.fromDecimal(this);if(n.layer-e.layer>3){const i=n.layer-e.layer-3;t+=i,n.layer-=i}for(let i=0;i<100;++i)if(n.lt(b.dZero))n=b.pow(e,n),t-=1;else{if(n.lte(b.dOne))return b.fromNumber(t+b.slog_critical(e.toNumber(),n.toNumber()));t+=1,n=b.log(n,e)}return b.fromNumber(t)}static slog_critical(e,t){return e>10?t-1:b.critical_section(e,t,ls)}static tetrate_critical(e,t){return b.critical_section(e,t,os)}static critical_section(e,t,n){t*=10,t<0&&(t=0),t>10&&(t=10),e<2&&(e=2),e>10&&(e=10);let i=0,r=0;for(let l=0;l<cn.length;++l)if(cn[l]==e){i=n[l][Math.floor(t)],r=n[l][Math.ceil(t)];break}else if(cn[l]<e&&cn[l+1]>e){const u=(e-cn[l])/(cn[l+1]-cn[l]);i=n[l][Math.floor(t)]*(1-u)+n[l+1][Math.floor(t)]*u,r=n[l][Math.ceil(t)]*(1-u)+n[l+1][Math.ceil(t)]*u;break}const a=t-Math.floor(t);return i<=0||r<=0?i*(1-a)+r*a:Math.pow(e,Math.log(i)/Math.log(e)*(1-a)+Math.log(r)/Math.log(e)*a)}layeradd10(e){e=b.fromValue_noAlloc(e).toNumber();const t=b.fromDecimal(this);if(e>=1){t.mag<0&&t.layer>0?(t.sign=0,t.mag=0,t.layer=0):t.sign===-1&&t.layer==0&&(t.sign=1,t.mag=-t.mag);const n=Math.trunc(e);e-=n,t.layer+=n}if(e<=-1){const n=Math.trunc(e);if(e-=n,t.layer+=n,t.layer<0)for(let i=0;i<100;++i){if(t.layer++,t.mag=Math.log10(t.mag),!isFinite(t.mag))return t.sign===0&&(t.sign=1),t.layer<0&&(t.layer=0),t.normalize();if(t.layer>=0)break}}for(;t.layer<0;)t.layer++,t.mag=Math.log10(t.mag);return t.sign===0&&(t.sign=1,t.mag===0&&t.layer>=1&&(t.layer-=1,t.mag=1)),t.normalize(),e!==0?t.layeradd(e,10):t}layeradd(e,t){const i=this.slog(t).toNumber()+e;return i>=0?b.tetrate(t,i):Number.isFinite(i)?i>=-1?b.log(b.tetrate(t,i+1),t):b.log(b.log(b.tetrate(t,i+2),t),t):b.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return b.fromNumber(pr(this.toNumber()));if(this.layer===0)return b.fromNumber(pr(this.sign*this.mag));if(this.layer===1)return fr(this);if(this.layer===2)return fr(this);if(this.layer>=3)return Q(this.sign,this.layer-1,this.mag);throw new Error("Unhandled behavior in lambertw()")}ssqrt(){if(this.sign==1&&this.layer>=3)return Q(this.sign,this.layer-1,this.mag);const e=this.ln();return e.div(e.lambertw())}pentate(e=2,t=Q(1,0,1)){t=k(t);const n=e;e=Math.trunc(e);const i=n-e;i!==0&&(t.eq(b.dOne)?(++e,t=b.fromNumber(i)):this.eq(10)?t=t.layeradd10(i):t=t.layeradd(i,this));for(let r=0;r<e;++r){if(t=this.tetrate(t.toNumber()),!isFinite(t.layer)||!isFinite(t.mag))return t.normalize();if(r>10)return t}return t}sin(){return this.mag<0?this:this.layer===0?b.fromNumber(Math.sin(this.sign*this.mag)):Q(0,0,0)}cos(){return this.mag<0?b.dOne:this.layer===0?b.fromNumber(Math.cos(this.sign*this.mag)):Q(0,0,0)}tan(){return this.mag<0?this:this.layer===0?b.fromNumber(Math.tan(this.sign*this.mag)):Q(0,0,0)}asin(){return this.mag<0?this:this.layer===0?b.fromNumber(Math.asin(this.sign*this.mag)):Q(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?b.fromNumber(Math.acos(this.toNumber())):this.layer===0?b.fromNumber(Math.acos(this.sign*this.mag)):Q(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?b.fromNumber(Math.atan(this.sign*this.mag)):b.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 b.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return b.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?Q(Number.NaN,Number.NaN,Number.NaN):b.ln(this.add(1).div(b.fromNumber(1).sub(this))).div(2)}ascensionPenalty(e){return e===0?this:this.root(b.pow(10,e))}egg(){return this.add(9)}lessThanOrEqualTo(e){return this.cmp(e)<1}lessThan(e){return this.cmp(e)<0}greaterThanOrEqualTo(e){return this.cmp(e)>-1}greaterThan(e){return this.cmp(e)>0}};let o=b;o.fromStringCache=new Ka(as);o.dZero=Q(0,0,0);o.dOne=Q(1,0,1);o.dNegOne=Q(-1,0,1);o.dTwo=Q(1,0,2);o.dTen=Q(1,0,10);o.dNaN=Q(Number.NaN,Number.NaN,Number.NaN);o.dInf=Q(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);o.dNegInf=Q(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);o.dNumberMax=Z(1,0,Number.MAX_VALUE);o.dNumberMin=Z(1,0,Number.MIN_VALUE);k=o.fromValue_noAlloc;Z=o.fromComponents;Q=o.fromComponents_noNormalize;o.fromMantissaExponent;o.fromMantissaExponent_noNormalize;const cs=new o(1);function jn(e,t,n=!0){let i=o.log10(e).floor(),r=o.div(e,o.pow(10,i));r.toStringWithDecimalPlaces(t)==="10"&&(r=cs,i=i.add(1));const a=i.gte(1e9)?bt(i,Math.max(Math.max(t,3),me.defaultDecimalsShown)):i.gte(1e4)?pi(i,0):i.toStringWithDecimalPlaces(0);return n?r.toStringWithDecimalPlaces(t)+"e"+a:"e"+a}function pi(e,t){if(e==null)return"NaN";if(e=new o(e),e.mag<.001)return 0 .toFixed(t);const i=e.toStringWithDecimalPlaces(t).split(".");return i[0]=i[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,"),i.length==1?i[0]:i[0]+"."+i[1]}function Ir(e,t){return e==null?"NaN":(e=new o(e),e.mag<1e-4?0 .toFixed(t):(e.mag<.1&&t!==0&&(t=Math.max(Math.max(t,e.log10().negate().ceil().toNumber()),me.defaultDecimalsShown)),e.toStringWithDecimalPlaces(t)))}const ds=new o("eeee1000"),ps=new o("e100000"),gr=new o("e1000"),$r=new o(1e9),fs=new o(1e6),gs=new o(1e3),ms=new o(.98),vs=new o(.001),xr=new o(0);function bt(e,t,n){if(t==null&&(t=me.defaultDecimalsShown),n=n!=null?n:me.defaultShowSmall,e=new o(e),isNaN(e.sign)||isNaN(e.layer)||isNaN(e.mag))return"NaN";if(e.sign<0)return"-"+bt(e.neg(),t);if(e.mag===Number.POSITIVE_INFINITY)return"Infinity";if(e.gte(ds)){const i=e.slog();return i.gte(fs)?"F"+bt(i.floor()):o.pow(10,i.sub(i.floor())).toStringWithDecimalPlaces(3)+"F"+pi(i.floor(),0)}else{if(e.gte(ps))return jn(e,0,!1);if(e.gte(gr))return jn(e,0);if(e.gte($r))return jn(e,t);if(e.gte(gs))return pi(e,0);if(e.gte(vs)||!n)return Ir(e,t);if(e.eq(xr))return 0 .toFixed(t)}return e=Pr(e),e.lt(gr)?jn(e,t).replace(/([^(?:e|F)]*)$/,"-$1"):bt(e,t)+"\u207B\xB9"}function Ye(e){return e=new o(e),e.sign<0?"-"+Ye(e.neg()):e.gte($r)||e.lte(ms)&&!e.eq(xr)?bt(e):bt(e,0)}function Er(e){return o.lt(e,0)?"-"+Er(o.neg(e)):o.gt(e,2**51)?bt(o.div(e,31536e3))+"y":(e=new o(e).toNumber(),e<60?bt(e)+"s":e<3600?Ye(Math.floor(e/60))+"m "+bt(e%60)+"s":e<86400?Ye(Math.floor(e/3600))+"h "+Ye(Math.floor(e/60)%60)+"m "+Ye(e%60)+"s":e<31536e3?Ye(Math.floor(e/84600)%365)+"d "+Ye(Math.floor(e/3600)%24)+"h "+Ye(Math.floor(e/60)%60)+"m":Ye(Math.floor(e/31536e3))+"y "+Ye(Math.floor(e/84600)%365)+"d "+Ye(Math.floor(e/3600)%24)+"h")}function hs(e,t,n){e=new o(e);let i=e.toStringWithDecimalPlaces(t);return new o(i).gte(n)&&(i=o.sub(n,Math.pow(.1,t)).toStringWithDecimalPlaces(t)),i}function bs(e,t){return bt(e,t,!0)}function Pr(e){let t=o.log10(e).ceil();const n=o.div(e,o.pow(10,t));return t=t.neg(),e=new o(10).pow(t).times(n),e}var ys=Object.freeze(Object.defineProperty({__proto__:null,default:o,exponentialFormat:jn,commaFormat:pi,regularFormat:Ir,format:bt,formatWhole:Ye,formatTime:Er,toPlaces:hs,formatSmall:bs,invertOOM:Pr},Symbol.toStringTag,{value:"Module"}));const{exponentialFormat:ws,commaFormat:_s,regularFormat:Ns,format:_e,formatWhole:dt,formatTime:yi,toPlaces:Cs,formatSmall:Ut,invertOOM:ks}=ys;window.Decimal=o;window.exponentialFormat=ws;window.commaFormat=_s;window.regularFormat=Ns;window.format=_e;window.formatWhole=dt;window.formatTime=yi;window.toPlaces=Cs;window.formatSmall=Ut;window.invertOOM=ks;function rt(e){let t=e.replace(/([A-Z])/g," $1");return t=t.charAt(0).toUpperCase()+t.slice(1),t}function Zn(e){return typeof e=="function"}var U=(e=>(e.Up="Up",e.Down="Down",e.Left="Left",e.Right="Right",e.Default="Up",e))(U||{});const Yn=Symbol("DoNotCache");function $(e,t){const n=e[t];Zn(n)&&n.length===0&&!n[Yn]?e[t]=_(n.bind(e)):Zn(n)&&(e[t]=n.bind(e),e[t][Yn]=!0)}function ve(e){return Zn(e)&&!e[Yn]&&(e=_(e)),e}const yt=Symbol("Component"),pt=Symbol("GatherProps");let Ms=0;function ln(e="feature-"){return e+Ms++}var Ne=(e=>(e[e.Visible=0]="Visible",e[e.Hidden=1]="Hidden",e[e.None=2]="None",e))(Ne||{});function Ue(e){const t=s(e);return t!==2&&t!==!1}function _n(e){return s(e)===1}function X(e){return e[Yn]=!0,e}function ne(e,t,n){e[t]===void 0&&n!=null&&(e[t]=n)}function Xn(e,...t){const n=[],i=r=>{Object.keys(r).forEach(a=>{const l=r[a];l!=null&&typeof l=="object"&&(t.includes(l.type)?n.push(l):!(l instanceof o)&&!Ve(l)&&i(l))})};return i(e),n}const dn={variables:{"--foreground":"#dfdfdf","--background":"#0f0f0f","--feature-foreground":"#0f0f0f","--tooltip-background":"rgba(0, 0, 0, 0.75)","--raised-background":"#0f0f0f","--points":"#ffffff","--locked":"#bf8f8f","--highlighted":"#333","--bought":"#77bf5f","--danger":"rgb(220, 53, 69)","--link":"#02f2f2","--outline":"#dfdfdf","--accent1":"#627a82","--accent2":"#658262","--accent3":"#7c6282","--border-radius":"15px","--modal-border":"solid 2px var(--color)","--feature-margin":"0px"},floatingTabs:!0,mergeAdjacent:!0,showPin:!0};var Gi=(e=>(e.Classic="classic",e.Paper="paper",e.Nordic="nordic",e.Aqua="aqua",e))(Gi||{}),Mt={classic:dn,paper:{...dn,variables:{...dn.variables,"--background":"#2a323d","--feature-foreground":"#000","--raised-background":"#333c4a","--locked":"#3a3e45","--bought":"#5C8A58","--outline":"#333c4a","--border-radius":"4px","--modal-border":"","--feature-margin":"5px"},floatingTabs:!1},nordic:{...dn,variables:{...dn.variables,"--foreground":"#D8DEE9","--background":"#2E3440","--feature-foreground":"#000","--raised-background":"#3B4252","--points":"#E5E9F0","--locked":"#4c566a","--highlighted":"#434c5e","--bought":"#8FBCBB","--danger":"#D08770","--link":"#88C0D0","--outline":"#3B4252","--accent1":"#B48EAD","--accent2":"#A3BE8C","--accent3":"#EBCB8B","--border-radius":"4px","--modal-border":"solid 2px #3B4252","--feature-margin":"5px"},floatingTabs:!1},aqua:{...dn,variables:{...dn.variables,"--foreground":"#bfdfff","--background":"#001f3f","--tooltip-background":"rgba(0, 15, 31, 0.75)","--raised-background":"#001f3f","--points":"#dfefff","--locked":"#c4a7b3","--outline":"#bfdfff"}}};const Je=Mr();"fonts"in document&&(document.fonts.onloadingdone=()=>Je.emit("fontsLoaded"));var Ss=Object.freeze(Object.defineProperty({__proto__:null,globalBus:Je},Symbol.toStringTag,{value:"Module"}));const Is=hn({id:"",devSpeed:null,name:"",tabs:[],time:-1,autosave:!0,offlineProd:!0,offlineTime:null,timePlayed:0,keepGoing:!1,modID:"",modVersion:"",layers:{}});var J=window.player=Is;function Dr(e){return JSON.stringify(e,(t,n)=>s(n))}function Tr(e={}){return Object.assign({id:`${me.id}-0`,name:"Default Save",tabs:me.initialTabs.slice(),time:Date.now(),autosave:!0,offlineProd:!0,offlineTime:0,timePlayed:0,keepGoing:!1,modID:me.id,modVersion:me.versionNumber,layers:{}},e)}function mt(e){const t=nn.compressToUTF16(Dr(e!=null?e:J));return localStorage.setItem((e!=null?e:J).id,t),t}async function $s(){Ps();try{let e=localStorage.getItem(se.active);if(e==null){await gn(Dn());return}if(e[0]!=="{")if(e[0]==="e")e=decodeURIComponent(escape(atob(e)));else if(e[0]==="\u1BE1")e=nn.decompressFromUTF16(e);else throw"Unable to determine save encoding";const t=JSON.parse(e);if(t.modID!==me.id){await gn(Dn());return}t.id=se.active,await gn(t)}catch(e){console.error(`Failed to load save. Falling back to new save.
`,e),await gn(Dn())}}function Dn(){const e=ci(),t=Tr({id:e});return mt(t),se.saves.push(e),t}function ci(){let e,t=0;do e=`${me.id}-${t++}`;while(localStorage.getItem(e)!=null);return e}const xs=z(!1);async function gn(e){console.info("Loading save",e),xs.value=!0;const{layers:t,removeLayer:n,addLayer:i}=await Hn(()=>Promise.resolve().then(function(){return Qs}),void 0),{fixOldSave:r,getInitialLayers:a}=await Hn(()=>Promise.resolve().then(function(){return kp}),void 0);for(const l in t){const u=t[l];u&&n(u)}a(e).forEach(l=>i(l,e)),e=Tr(e),e.offlineProd&&e.time!=null&&e.time&&e.devSpeed!==0&&(e.offlineTime==null&&(e.offlineTime=0),e.offlineTime+=Math.min(e.offlineTime+(Date.now()-e.time)/1e3,me.offlineLimit*3600)),e.time=Date.now(),e.modVersion!==me.versionNumber&&(r(e.modVersion,e),e.modVersion=me.versionNumber),Object.assign(J,e),se.active=J.id,Je.emit("onLoad")}setInterval(()=>{J.autosave&&mt()},1e3);window.onbeforeunload=()=>{J.autosave&&mt()};window.save=mt;const Es=window.hardReset=async()=>{await gn(Dn())};window.deleteLowerSaves=()=>{const e=Object.values(se.saves).indexOf(J.id)+1;Object.values(se.saves).slice(e).forEach(t=>localStorage.removeItem(t)),se.saves=se.saves.slice(0,e)};const Jn=hn({active:"",saves:[],showTPS:!0,theme:Gi.Nordic,unthrottled:!1,alignUnits:!1});vt(Jn,e=>{const t=nn.compressToUTF16(JSON.stringify(e));localStorage.setItem(me.id,t)},{deep:!0});var se=window.settings=Jn;window.hardResetSettings=()=>{const e={active:"",saves:[],showTPS:!0,theme:Gi.Nordic,alignUnits:!1};Je.emit("loadSettings",e),Object.assign(Jn,e),Es()};function Ps(){try{let e=localStorage.getItem(me.id);if(e!=null&&e!==""){if(e[0]!=="{")if(e[0]==="e")e=decodeURIComponent(escape(atob(e)));else if(e[0]==="\u1BE1")e=nn.decompressFromUTF16(e);else{console.warn("Unable to determine settings encoding",e);return}const t=JSON.parse(e);typeof t=="object"&&Object.assign(Jn,t)}Je.emit("loadSettings",Jn)}catch{}}const Ar=hn([]);function Ds(e){Ar.push(e)}const Ts=hn([]),As=hn([]),Fs={class:"table"},Rs=Y({__name:"Column",setup(e){const t=_(()=>Mt[se.theme].mergeAdjacent);return(n,i)=>(M(),T("div",Fs,[N("div",{class:he(["col",{mergeAdjacent:s(t)}])},[Ft(n.$slots,"default")],2)]))}}),Os={class:"table"},qs=Y({__name:"Row",setup(e){const t=_(()=>Mt[se.theme].mergeAdjacent);return(n,i)=>(M(),T("div",Os,[N("div",{class:he(["row",{mergeAdjacent:s(t)}])},[Ft(n.$slots,"default")],2)]))}});function Fr(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!ma(e)}function ue(e,t="span"){return typeof e=="function"?Y({render:e}):typeof e=="string"?e.length>0?(e=e.trim(),e.charAt(0)!=="<"&&(e=`<${t}>${e}</${t}>`),Y({template:e})):Y({render:()=>({})}):e}function st(e){if(Pt(e))return typeof e=="function"?e():ue(e);const t=e[yt];return f(t,e[pt](),null)}function Ai(...e){let t;return f(qs,null,Fr(t=e.map(st))?t:{default:()=>[t]})}function Vs(...e){let t;return f(Rs,null,Fr(t=e.map(st))?t:{default:()=>[t]})}function St(e){if(Pt(e))return typeof e=="function"?e():typeof e=="string"?f(ee,null,[e]):f(e,null,null);const t=e[yt];return f(t,e[pt](),null)}function mr(e,t){return e.reduce((n,i)=>f(ee,null,[n,t,i]))}function Pt(e){return typeof e=="string"?!0:typeof e=="object"?e==null?!1:"render"in e||"component"in e:typeof e=="function"&&e[Yn]===!0}function Rr(e,t){const n=z(null),i=z(void 0);function r(u){n.value||(n.value=setInterval(l,250)),i.value=u}function a(){n.value&&(clearInterval(n.value),n.value=null)}function l(){t&&t.value?t.value():e&&e.value&&e.value(i.value)}return kr(a),{start:r,stop:a,handleHolding:l}}function Or(e,t="div"){const n=ht();return Et(()=>{n.value=ue(Ee(e),t)}),n}function Rn(e,t="div"){const n=ht(null);return Et(()=>{const i=Ee(e);n.value=i==""||i==null?null:ue(i,t)}),n}function Ee(e){return s(s(e))}function O(...e){return e.includes(Object)||e.push(Object),e}function vr(e){const t=z(!1),n=e[pt].bind(e);return e[pt]=()=>({...n(),onPointerenter:()=>t.value=!0,onPointerleave:()=>t.value=!1}),t}var pe=(e,t)=>{const n=e.__vccOpts||e;for(const[i,r]of t)n[i]=r;return n};const Bs=Y({__name:"Context",emits:["updateNodes"],setup(e,{emit:t}){var h;const n=z({}),i=new ResizeObserver(u),r=z(null);hi(()=>{const p=r.value;p!=null&&i.observe(p)});let a=!0,l=z((h=r.value)==null?void 0:h.getBoundingClientRect());function u(){a&&(a=!1,Gt(()=>{var p;l.value=(p=r.value)==null?void 0:p.getBoundingClientRect(),Object.values(n.value).filter(m=>m).forEach(m=>m.rect=m.element.getBoundingClientRect()),t("updateNodes",n.value),a=!0}))}Je.on("fontsLoaded",u);const c={attributes:!1,childList:!0,subtree:!1};oi(Wi,(p,m)=>{const v=new MutationObserver(()=>d(p));v.observe(m,c),n.value[p]={element:m,observer:v,rect:m.getBoundingClientRect()},u()}),oi(Hi,p=>{var m;(m=n.value[p])==null||m.observer.disconnect(),n.value[p]=void 0,u()}),oi(Zi,n),oi(Yi,l);function d(p){const m=n.value[p];m!=null&&(m.rect=m.element.getBoundingClientRect(),t("updateNodes",n.value))}return(p,m)=>(M(),T(ee,null,[Ft(p.$slots,"default",{},void 0,!0),N("div",{ref_key:"resizeListener",ref:r,class:"resize-listener"},null,512)],64))}});var qr=pe(Bs,[["__scopeId","data-v-2b1dc1bc"]]);const Ls=["onPointerdown"],js={class:"modal-wrapper"},zs={class:"modal-container"},Us={class:"modal-header"},Gs={class:"modal-body"},Ws={class:"modal-footer"},Hs=N("div",{class:"modal-default-flex-grow"},null,-1),Ht=Y({__name:"Modal",props:{modelValue:{type:Boolean}},emits:["update:modelValue"],setup(e,{expose:t,emit:n}){const r=Fe(e),a=_(()=>s(r.modelValue)||u.value);function l(){n("update:modelValue",!1)}const u=z(!1),c=z(null),d=_(()=>{var h,p;return(p=(h=c.value)==null?void 0:h.nodes)!=null?p:null});return t({isOpen:a,nodes:d}),(h,p)=>(M(),K(ha,{to:"#modal-root"},[f(Wn,{name:"modal",onBeforeEnter:p[0]||(p[0]=m=>u.value=!0),onAfterLeave:p[1]||(p[1]=m=>u.value=!1)},{default:W(()=>[zi(N("div",Wt({class:"modal-mask",onPointerdown:An(l,["self"])},h.$attrs),[N("div",js,[N("div",zs,[N("div",Us,[Ft(h.$slots,"header",{shown:s(a)},()=>[E(" default header ")])]),N("div",Gs,[f(qr,{ref_key:"contextRef",ref:c},{default:W(()=>[Ft(h.$slots,"body",{shown:s(a)},()=>[E(" default body ")])]),_:3},512)]),N("div",Ws,[Ft(h.$slots,"footer",{shown:s(a)},()=>[N("div",{class:"modal-default-footer"},[Hs,N("button",{class:"button modal-default-button",onClick:l}," Close ")])])])])])],16,Ls),[[va,e.modelValue]])]),_:3})]))}}),tn=Symbol("ProxyState");function Ke(e,t={}){const n=t;let i=!1;function r(){return i||(Object.assign(n,e.call(n,n)),i=!0),n}return new Proxy(n,{get(a,l){if(l===tn)return r();const u=r()[l];return u!=null&&typeof u=="object"&&At in u?u[At]:u},set(a,l,u){return r()[l]=u,!0},has(a,l){return l===tn?!0:Reflect.has(r(),l)},ownKeys(){return Reflect.ownKeys(r())},getOwnPropertyDescriptor(a,l){return i||(Object.assign(n,e.call(n,n)),i=!0),Object.getOwnPropertyDescriptor(a,l)}})}var ze=window.state=Ui({lastTenTicks:[],hasNaN:!1,NaNPath:[]});const an=Symbol("PersistentState"),on=Symbol("DefaultValue"),fi=Symbol("StackTrace"),gi=Symbol("Deleted"),At=Symbol("NonPersistent"),mn=Symbol("SaveDataPath"),Li=Symbol("SkipPersistence");function Zs(){var e,t;return(t=(e=new Error().stack)==null?void 0:e.split(`
`).slice(3,5).map(n=>n.trim()).join(`
`))!=null?t:""}function hr(e,t){var n;if(o.isNaN(t))throw ze.hasNaN||(J.autosave=!1,ze.hasNaN=!0,ze.NaNPath=e[mn],ze.NaNPersistent=e),console.error("Attempted to save NaN value to",(n=e[mn])==null?void 0:n.join("."),e),new Error("Attempted to set NaN value. See above for details");e[an].value=t}function ct(e,t=!0){const n=Ve(e)?e:z(e);Ve(e)&&(e=e.value);const i=_({get(){return n.value},set(a){t?hr(r,a):r[an].value=a}});i[on]=e;const r={get value(){return n.value},set value(a){t?hr(r,a):r[an].value=a},__v_isRef:!0,[an]:n,[on]:e,[fi]:Zs(),[gi]:!1,[At]:i,[mn]:void 0};return ut.length===0?console.warn("Creating a persistent ref outside of a layer. This is not officially supported",r,`
Created at:
`+r[fi]):vn[ut[ut.length-1]].add(r),r}function Ys(e){return e!=null&&typeof e=="object"&&an in e}function $n(e){return!(tn in e)&&At in e?e[At]:new Proxy(e,{get(t,n){if(n!==an)return n===Li?!0:t[n]},set(t,n,i){return t[n]=i,!0},has(t,n){return n===an?!1:n==Li?!0:Reflect.has(t,n)}})}function Vr(e){ut.length===0?console.warn("Deleting a persistent ref outside of a layer. Ignoring...",e):vn[ut[ut.length-1]].delete(e),e[gi]=!0}Je.on("addLayer",(e,t)=>{const n=[],i=(r,a=[])=>{let l=!1;return Object.keys(r).forEach(u=>{let c=r[u];if(c!=null&&typeof c=="object"){if(c[Li]===!0)return;if(tn in c&&(c=c[tn]),Ys(c)){if(l=!0,c[gi]){console.warn("Deleted persistent ref present in returned object. Ignoring...",c,`
Created at:
`+c[fi]);return}vn[e.id].delete(c);const d=[e.id,...a,u];c[mn]!=null&&JSON.stringify(d)!==JSON.stringify(c[mn])&&console.error(`Persistent ref is being saved to \`${d.join(".")}\` when it's already present at \`${c[mn].join(".")}\`. This can cause unexpected behavior when loading saves between updates.`,c),c[mn]=d;const h=a.reduce((m,v)=>(v in m||(m[v]={}),m[v]),t),p=h[u];h[u]=c[an],ba(h)?p!=null?h[u]=p:h[u]=c[on]:p!=null?h[u].value=p:h[u].value=c[on]}else!(c instanceof o)&&!Ve(c)&&!n.includes(c)&&(typeof c.type=="symbol"&&n.push(c),i(c,[...a,u])&&(Rt(c)&&!Rt(r)?console.warn("Found array that contains persistent values when adding layer. Keep in mind changing the order of elements in the array will mess with existing player saves.",tn in r?r[tn]:r,u):l=!0))}}),l};i(e[tn]),vn[e.id].forEach(r=>{r[gi]||console.error(`Created persistent ref in ${e.id} without registering it to the layer! Make sure to include everything persistent in the returned object`,r,`
Created at:
`+r[fi])}),vn[e.id].clear()});const Wi=Symbol("RegisterNode"),Hi=Symbol("UnregisterNode"),Zi=Symbol("Nodes"),Yi=Symbol("Bounds"),we=Ui({});window.layers=we;const vn={},ut=[];function Xi(e,t){return Ke(()=>{const n={},i=n.emitter=Mr();if(n.on=i.on.bind(i),n.emit=i.emit.bind(i),n.nodes=z({}),n.id=e,ut.push(e),vn[e]=new Set,n.minimized=ct(!1,!1),Object.assign(n,t.call(n,n)),ut[ut.length-1]==null||ut[ut.length-1]!==e)throw`Adding layers stack in invalid state. This should not happen
Stack: ${ut}
Trying to pop ${n.id}`;ut.pop(),$(n,"color"),$(n,"display"),$(n,"classes"),$(n,"style"),$(n,"name"),ne(n,"name",n.id),$(n,"minWidth"),ne(n,"minWidth",600),$(n,"minimizable"),ne(n,"minimizable",!0),$(n,"minimizedDisplay");const r=n.style;return n.style=_(()=>{var l,u;let a=s(n.minWidth);return(typeof a=="number"||!Number.isNaN(parseInt(a)))&&(a=a+"px"),[(l=s(r))!=null?l:"",(u=n.minimized)!=null&&u.value?{flexGrow:"0",flexShrink:"0",width:"60px",minWidth:"",flexBasis:"",margin:"0"}:{flexGrow:"",flexShrink:"",width:"",minWidth:a,flexBasis:a,margin:""}]}),n})}function Ji(e,t){if(console.info("Adding layer",e.id),we[e.id]){console.error("Attempted to add layer with same ID as existing layer",e.id,we[e.id]);return}ne(t,"layers",{}),t.layers[e.id]==null&&(t.layers[e.id]={}),we[e.id]=e,Je.emit("addLayer",e,t.layers[e.id])}function Xs(e){return we[e]}function Br(e){console.info("Removing layer",e.id),Je.emit("removeLayer",e),we[e.id]=void 0}function Js(e){Br(e),Ji(e,J)}function Ks(e){const t=z(!1);return{openModal:()=>t.value=!0,modal:X(()=>f(Ht,{modelValue:t.value,"onUpdate:modelValue":n=>t.value=n},{header:()=>f("h2",null,[s(e.name)]),body:s(e.display)}))}}Je.on("update",function(t){Object.values(we).forEach(n=>{n==null||n.emit("preUpdate",t)}),Object.values(we).forEach(n=>{n==null||n.emit("update",t)}),Object.values(we).forEach(n=>{n==null||n.emit("postUpdate",t)})});var Qs=Object.freeze(Object.defineProperty({__proto__:null,RegisterNodeInjectionKey:Wi,UnregisterNodeInjectionKey:Hi,NodesInjectionKey:Zi,BoundsInjectionKey:Yi,layers:we,persistentRefs:vn,addingLayers:ut,createLayer:Xi,addLayer:Ji,getLayer:Xs,removeLayer:Br,reloadLayer:Js,setupLayerModal:Ks},Symbol.toStringTag,{value:"Module"}));const eo=Y({components:{Context:qr},props:{index:{type:Number,required:!0},display:{type:O(Object,String,Function),required:!0},minimizedDisplay:O(Object,String,Function),minimized:{type:Object,required:!0},name:{type:O(String),required:!0},color:O(String),minimizable:O(Boolean),nodes:{type:Object,required:!0}},emits:["setMinimized"],setup(e){const{display:t,index:n,minimized:i,minimizedDisplay:r}=Fe(e),a=Or(t),l=Rn(r),u=_(()=>me.allowGoBack&&n.value>0&&!Ee(i));function c(){J.tabs.splice(s(e.index),1/0)}function d(h){e.nodes.value=h}return{component:a,minimizedComponent:l,showGoBack:u,updateNodes:d,unref:s,goBack:c}}}),to={key:1};function no(e,t,n,i,r,a){const l=It("Context");return M(),T("div",{class:"layer-container",style:je({"--layer-color":e.unref(e.color)})},[e.showGoBack?(M(),T("button",{key:0,class:"goBack",onClick:t[0]||(t[0]=(...u)=>e.goBack&&e.goBack(...u))},"\u274C")):j("",!0),e.unref(e.minimized)?(M(),T("button",{key:1,class:"layer-tab minimized",onClick:t[1]||(t[1]=u=>e.$emit("setMinimized",!1))},[e.minimizedComponent?(M(),K(Xe(e.minimizedComponent),{key:0})):(M(),T("div",to,le(e.unref(e.name)),1))])):(M(),T("div",{key:2,class:he(["layer-tab",{showGoBack:e.showGoBack}])},[f(l,{onUpdateNodes:e.updateNodes},{default:W(()=>[(M(),K(Xe(e.component)))]),_:1},8,["onUpdateNodes"])],2)),e.unref(e.minimizable)?(M(),T("button",{key:3,class:"minimize",onClick:t[2]||(t[2]=u=>e.$emit("setMinimized",!0))}," \u25BC ")):j("",!0)],4)}var io=pe(eo,[["render",no],["__scopeId","data-v-72dd78b1"]]);const Lr=e=>(yn("data-v-4b4bda40"),e=e(),wn(),e),ro=Lr(()=>N("h2",null,"Changelog",-1)),ao=Lr(()=>N("details",{open:""},[N("summary",null,[E("v0.0 Initial Commit - "),N("time",null,"2021-09-04")]),E(" This is the first release :D "),N("ul",null,[N("li",{class:"feature"},"Did everything"),N("li",{class:"fix"},"Had some fun"),N("li",{class:"breaking"},"Removed everything"),N("li",{class:"balancing"},"Created some bugs to fix later")])],-1)),so=Y({__name:"Changelog",setup(e,{expose:t}){const n=z(!1);return t({open(){n.value=!0}}),(i,r)=>(M(),K(Ht,{modelValue:n.value,"onUpdate:modelValue":r[0]||(r[0]=a=>n.value=a)},{header:W(()=>[ro]),body:W(()=>[ao]),_:1},8,["modelValue"]))}});var oo=pe(so,[["__scopeId","data-v-4b4bda40"]]),lo=Y({props:{element:Object,display:{type:O(Object,String,Function),required:!0},style:O(Object,String,Array),classes:O(Object),direction:O(String),xoffset:O(String),yoffset:O(String),pinned:Object},setup(e){const{element:t,display:n,pinned:i}=Fe(e),r=z(!1),a=_(()=>(Ee(i)||r.value)&&l.value),l=Rn(n),u=ht(ue(X(()=>{const h=Ee(t);return h==null?"":St(h)})));function c(h){const p=i;h.shiftKey&&p&&(p.value=!p.value,h.stopPropagation(),h.preventDefault())}const d=_(()=>Ee(i)&&Mt[se.theme].showPin);return{Direction:U,isHovered:r,isShown:a,comp:l,elementComp:u,unref:s,togglePinned:c,showPin:d}}});const uo={key:0,class:"material-icons pinned"};function co(e,t,n,i,r,a){return M(),T("div",{class:he(["tooltip-container",{shown:e.isShown}]),onMouseenter:t[0]||(t[0]=l=>e.isHovered=!0),onMouseleave:t[1]||(t[1]=l=>e.isHovered=!1),onClickCapture:t[2]||(t[2]=(...l)=>e.togglePinned&&e.togglePinned(...l))},[Ft(e.$slots,"default",{},void 0,!0),e.elementComp?(M(),K(Xe(e.elementComp),{key:0})):j("",!0),f(Wn,{name:"fade"},{default:W(()=>{var l;return[e.isShown?(M(),T("div",{key:0,class:he(["tooltip",{top:e.unref(e.direction)===e.Direction.Up,left:e.unref(e.direction)===e.Direction.Left,right:e.unref(e.direction)===e.Direction.Right,bottom:e.unref(e.direction)===e.Direction.Down,...e.unref(e.classes)}]),style:je([{"--xoffset":e.unref(e.xoffset)||"0px","--yoffset":e.unref(e.yoffset)||"0px"},(l=e.unref(e.style))!=null?l:{}])},[e.showPin?(M(),T("span",uo,"push_pin")):j("",!0),e.comp?(M(),K(Xe(e.comp),{key:1})):j("",!0)],6)):j("",!0)]}),_:1})],34)}var qe=pe(lo,[["render",co],["__scopeId","data-v-6102fa3a"]]);const Nn=e=>(yn("data-v-4f97aa40"),e=e(),wn(),e),po={class:"info-modal-header"},fo=["src","alt"],go={class:"info-modal-title"},mo={key:0},vo={key:0},ho={key:0},bo=Nn(()=>N("div",null," Made in Profectus, by thepaperpilot with inspiration from Acameada and Jacorb ",-1)),yo=Nn(()=>N("br",null,null,-1)),wo=Nn(()=>N("br",null,null,-1)),_o=["href"],No=Nn(()=>N("span",{class:"material-icons info-modal-discord"},"discord",-1)),Co=Nn(()=>N("div",null,[N("a",{href:"https://discord.gg/yJ4fjnjU54",class:"info-modal-discord-link",target:"_blank"},[N("span",{class:"material-icons info-modal-discord"},"discord"),E(" The Paper Pilot Community ")])],-1)),ko=Nn(()=>N("div",null,[N("a",{href:"https://discord.gg/F3xveHV",class:"info-modal-discord-link",target:"_blank"},[N("span",{class:"material-icons info-modal-discord"},"discord"),E(" The Modding Tree ")])],-1)),Mo=Nn(()=>N("br",null,null,-1));var So=Y({__name:"Info",props:{changelog:null},setup(e,{expose:t}){const n=e,{title:i,logo:r,author:a,discordName:l,discordLink:u,versionNumber:c,versionTitle:d}=me,h=Fe(n),p=z(!1),m=_(()=>yi(J.timePlayed)),v=_(()=>ue(X(()=>f(ee,null,[Ts.map(st)]))));t({open(){p.value=!0}});function C(){var y;(y=s(h.changelog))==null||y.open()}return(y,I)=>(M(),K(Ht,{modelValue:p.value,"onUpdate:modelValue":I[0]||(I[0]=A=>p.value=A)},{header:W(()=>[N("div",po,[s(r)?(M(),T("img",{key:0,class:"info-modal-logo",src:s(r),alt:s(i)},null,8,fo)):j("",!0),N("div",go,[N("h2",null,le(s(i)),1),N("h4",null,[E(" v"+le(s(c)),1),s(d)?(M(),T("span",mo,": "+le(s(d)),1)):j("",!0)])])])]),body:W(({shown:A})=>[A?(M(),T("div",vo,[s(a)?(M(),T("div",ho,"By "+le(s(a)),1)):j("",!0),bo,yo,N("div",{class:"link",onClick:C},"Changelog"),wo,N("div",null,[s(u)?(M(),T("a",{key:0,href:s(u),class:"info-modal-discord-link",target:"_blank"},[No,E(" "+le(s(l)),1)],8,_o)):j("",!0)]),Co,ko,Mo,N("div",null,"Time Played: "+le(s(m)),1),(M(),K(Xe(s(v))))])):j("",!0)]),_:1},8,["modelValue"]))}});var Io=pe(So,[["__scopeId","data-v-4f97aa40"]]);const $o={class:"field"},xo={key:0,class:"field-title"},Ki=Y({__name:"Select",props:{title:null,modelValue:null,options:null,placeholder:null,closeOnSelect:{type:Boolean}},emits:["update:modelValue"],setup(e,{emit:t}){var l;const n=e,i=Rn(sn(n,"title"),"span"),r=z((l=n.options.find(u=>u.value===n.modelValue))!=null?l:null);vt(sn(n,"modelValue"),u=>{var c;Ee(r)!==u&&(r.value=(c=n.options.find(d=>d.value===u))!=null?c:null)});function a(u){t("update:modelValue",u.value)}return(u,c)=>(M(),T("div",$o,[s(i)?(M(),T("span",xo,[(M(),K(Xe(s(i))))])):j("",!0),f(s(ka),{options:e.options,modelValue:r.value,"onUpdate:modelValue":[c[0]||(c[0]=d=>r.value=d),a],min:1,"label-by":"label",placeholder:e.placeholder,"close-on-select":e.closeOnSelect},null,8,["options","modelValue","placeholder","close-on-select"])]))}});const Eo={class:"field"},Po=Y({__name:"Toggle",props:{title:null,modelValue:{type:Boolean}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,i=_(()=>{var a;return ue((a=s(n.title))!=null?a:"<span></span>","span")}),r=_({get(){return!!n.modelValue},set(a){t("update:modelValue",a)}});return(a,l)=>(M(),T("label",Eo,[zi(N("input",{type:"checkbox",class:"toggle","onUpdate:modelValue":l[0]||(l[0]=u=>Ve(r)?r.value=u:null)},null,512),[[ya,s(r)]]),(M(),K(Xe(s(i))))]))}});var jt=pe(Po,[["__scopeId","data-v-11046116"]]);const Do=["onClick"],To=Y({__name:"FeedbackButton",props:{left:{type:Boolean}},emits:["click"],setup(e,{emit:t}){const n=z(!1),i=z(null);function r(){t("click"),i.value&&clearTimeout(i.value),n.value=!1,Gt(()=>{n.value=!0,i.value=setTimeout(()=>n.value=!1,500)})}return(a,l)=>(M(),T("button",{onClick:An(r,["stop"]),class:he(["feedback",{activated:n.value,left:e.left}])},[Ft(a.$slots,"default",{},void 0,!0)],10,Do))}});var jr=pe(To,[["__scopeId","data-v-01a1b95c"]]);const Ao={class:"header"},Fo=N("h2",null,"Settings",-1),Ro={class:"option-tabs"},Oo={key:0},qo={key:1};var Vo=Y({__name:"Options",setup(e,{expose:t}){const n=z(!1),i=z("behaviour");function r(re){return re==i.value}function a(re){i.value=re}t({isTab:r,setTab:a,save:mt,open(){n.value=!0}});const l=Object.keys(Mt).map(re=>({label:rt(re),value:re})),u=_(()=>ue(X(()=>f(ee,null,[Ar.map(st)])))),{showTPS:c,theme:d,unthrottled:h,alignUnits:p}=Fe(se),{autosave:m,offlineProd:v}=Fe(J),C=_({get(){return J.devSpeed===0},set(re){J.devSpeed=re?0:null}}),y=X(()=>f("span",{class:"option-title"},[E("Unthrottled"),f("desc",null,[E("Allow the game to run as fast as possible. Not battery friendly.")])])),I=X(()=>f("span",{class:"option-title"},[E("Offline Production"),f(qe,{display:"Save-specific",direction:U.Right},{default:()=>[E("*")]}),f("desc",null,[E("Simulate production that occurs while the game is closed.")])])),A=X(()=>f("span",{class:"option-title"},[E("Autosave"),f(qe,{display:"Save-specific",direction:U.Right},{default:()=>[E("*")]}),f("desc",null,[E("Automatically save the game every second or when the game is closed.")])])),S=X(()=>f("span",{class:"option-title"},[E("Pause game"),f(qe,{display:"Save-specific",direction:U.Right},{default:()=>[E("*")]}),f("desc",null,[E("Stop everything from moving.")])])),P=X(()=>f("span",{class:"option-title"},[E("Theme"),f("desc",null,[E("How the game looks.")])])),B=X(()=>f("span",{class:"option-title"},[E("Show TPS"),f("desc",null,[E("Show TPS meter at the bottom-left corner of the page.")])])),ie=X(()=>f("span",{class:"option-title"},[E("Align modifier units"),f("desc",null,[E("Align numbers to the beginning of the unit in modifier view.")])]));return(re,oe)=>(M(),K(Ht,{modelValue:n.value,"onUpdate:modelValue":oe[10]||(oe[10]=H=>n.value=H)},{header:W(()=>[N("div",Ao,[Fo,N("div",Ro,[N("button",{class:he({selected:r("behaviour")}),onClick:oe[0]||(oe[0]=H=>a("behaviour"))},"Behaviour",2),N("button",{class:he({selected:r("appearance")}),onClick:oe[1]||(oe[1]=H=>a("appearance"))},"Appearance",2)])])]),body:W(()=>[r("behaviour")?(M(),T("div",Oo,[f(jt,{title:s(y),modelValue:s(h),"onUpdate:modelValue":oe[2]||(oe[2]=H=>Ve(h)?h.value=H:null)},null,8,["title","modelValue"]),s(me).enablePausing?(M(),K(jt,{key:0,title:s(S),modelValue:s(C),"onUpdate:modelValue":oe[3]||(oe[3]=H=>Ve(C)?C.value=H:null)},null,8,["title","modelValue"])):j("",!0),f(jt,{title:s(I),modelValue:s(v),"onUpdate:modelValue":oe[4]||(oe[4]=H=>Ve(v)?v.value=H:null)},null,8,["title","modelValue"]),f(jt,{title:s(A),modelValue:s(m),"onUpdate:modelValue":oe[5]||(oe[5]=H=>Ve(m)?m.value=H:null)},null,8,["title","modelValue"]),s(m)?j("",!0):(M(),K(jr,{key:1,class:"button save-button",onClick:oe[6]||(oe[6]=H=>s(mt)())},{default:W(()=>[E("Manually save")]),_:1}))])):j("",!0),r("appearance")?(M(),T("div",qo,[f(Ki,{title:s(P),options:s(l),modelValue:s(d),"onUpdate:modelValue":oe[7]||(oe[7]=H=>Ve(d)?d.value=H:null)},null,8,["title","options","modelValue"]),(M(),K(Xe(s(u)))),f(jt,{title:s(B),modelValue:s(c),"onUpdate:modelValue":oe[8]||(oe[8]=H=>Ve(c)?c.value=H:null)},null,8,["title","modelValue"]),f(jt,{title:s(ie),modelValue:s(p),"onUpdate:modelValue":oe[9]||(oe[9]=H=>Ve(p)?p.value=H:null)},null,8,["title","modelValue"])])):j("",!0)]),_:1},8,["modelValue"]))}});const Bo=["onSubmit"],Lo={class:"field"},jo={key:0,class:"field-title"},zo=["placeholder"],Uo=Y({__name:"Text",props:{title:null,modelValue:null,textArea:{type:Boolean},placeholder:null,maxHeight:null,submitOnBlur:{type:Boolean}},emits:["update:modelValue","submit","cancel"],setup(e,{emit:t}){const n=e,i=Rn(sn(n,"title"),"span"),r=ht(null);hi(()=>{var c;(c=r.value)==null||c.focus()});const a=_({get(){var c;return(c=s(n.modelValue))!=null?c:""},set(c){t("update:modelValue",c)}});function l(){t("submit")}function u(){n.submitOnBlur!==!1?t("submit"):t("cancel")}return(c,d)=>(M(),T("form",{onSubmit:An(l,["prevent"])},[N("div",Lo,[s(i)?(M(),T("span",jo,[(M(),K(Xe(s(i))))])):j("",!0),e.textArea?(M(),K(s(Sa),{key:1,modelValue:s(a),"onUpdate:modelValue":d[0]||(d[0]=h=>Ve(a)?a.value=h:null),placeholder:e.placeholder,maxHeight:e.maxHeight,onBlur:u,ref_key:"field",ref:r},null,8,["modelValue","placeholder","maxHeight"])):zi((M(),T("input",{key:2,type:"text","onUpdate:modelValue":d[1]||(d[1]=h=>Ve(a)?a.value=h:null),placeholder:e.placeholder,class:he({fullWidth:!e.title}),onBlur:u,ref_key:"field",ref:r},null,42,zo)),[[wa,s(a)]])])],40,Bo))}});var zr=pe(Uo,[["__scopeId","data-v-90bd4994"]]);const Go={key:0},Wo=["onClick","disabled"],Ho={key:0},Zo=["onClick"],Yo=Y({__name:"DangerButton",props:{disabled:{type:Boolean},skipConfirm:{type:Boolean}},emits:["click","confirmingChanged"],setup(e,{emit:t}){const i=Fe(e),r=z(!1);vt(r,u=>{t("confirmingChanged",u)});function a(){if(s(i.skipConfirm)){t("click");return}r.value&&t("click"),r.value=!r.value}function l(){r.value=!1}return(u,c)=>(M(),T("span",{class:he(["container",{confirming:r.value}])},[r.value?(M(),T("span",Go,"Are you sure?")):j("",!0),N("button",{onClick:An(a,["stop"]),class:"button danger",disabled:e.disabled},[r.value?(M(),T("span",Ho,"Yes")):Ft(u.$slots,"default",{key:1},void 0,!0)],8,Wo),r.value?(M(),T("button",{key:1,class:"button",onClick:An(l,["stop"])},"No",8,Zo)):j("",!0)],2))}});var Xo=pe(Yo,[["__scopeId","data-v-2f8ef34c"]]);const Zt=e=>(yn("data-v-32313015"),e=e(),wn(),e),Jo=Zt(()=>N("div",{class:"handle material-icons"},"drag_handle",-1)),Ko={key:0,class:"actions"},Qo=Zt(()=>N("span",{class:"material-icons"},"content_paste",-1)),el=Zt(()=>N("span",{class:"material-icons"},"content_copy",-1)),tl=Zt(()=>N("span",{class:"material-icons"},"edit",-1)),nl=Zt(()=>N("span",{class:"material-icons",style:{margin:"-2px"}},"delete",-1)),il={key:1,class:"actions"},rl=Zt(()=>N("span",{class:"material-icons"},"check",-1)),al=Zt(()=>N("span",{class:"material-icons"},"close",-1)),sl={key:2,class:"details"},ol={class:"save-version"},ll=Zt(()=>N("br",null,null,-1)),ul={key:0},cl={key:3,class:"details"},dl={key:4,class:"details error"},pl=Zt(()=>N("br",null,null,-1)),fl=Y({__name:"Save",props:{save:null},emits:["export","open","duplicate","delete","editName"],setup(e,{emit:t}){const n=e,{save:i}=Fe(n),r=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),a=z(!1),l=z(!1),u=z("");vt(a,()=>{var p;return u.value=(p=i.value.name)!=null?p:""});const c=_(()=>i.value!=null&&i.value.id===J.id),d=_(()=>{var p;return c.value?J.time:(p=i.value!=null&&i.value.time)!=null?p:0});function h(){t("editName",u.value),a.value=!1}return(p,m)=>(M(),T("div",{class:he(["save",{active:s(c)}])},[Jo,a.value?(M(),T("div",il,[N("button",{onClick:h,class:"button"},[f(qe,{display:"Save",direction:s(U).Left,class:"info"},{default:W(()=>[rl]),_:1},8,["direction"])]),N("button",{onClick:m[5]||(m[5]=v=>a.value=!a.value),class:"button"},[f(qe,{display:"Cancel",direction:s(U).Left,class:"info"},{default:W(()=>[al]),_:1},8,["direction"])])])):(M(),T("div",Ko,[s(i).error==null&&!l.value?(M(),K(jr,{key:0,onClick:m[0]||(m[0]=v=>t("export")),class:"button",left:""},{default:W(()=>[f(qe,{display:"Export",direction:s(U).Left,class:"info"},{default:W(()=>[Qo]),_:1},8,["direction"])]),_:1})):j("",!0),s(i).error==null&&!l.value?(M(),T("button",{key:1,onClick:m[1]||(m[1]=v=>t("duplicate")),class:"button"},[f(qe,{display:"Duplicate",direction:s(U).Left,class:"info"},{default:W(()=>[el]),_:1},8,["direction"])])):j("",!0),s(i).error==null&&!l.value?(M(),T("button",{key:2,onClick:m[2]||(m[2]=v=>a.value=!a.value),class:"button"},[f(qe,{display:"Edit Name",direction:s(U).Left,class:"info"},{default:W(()=>[tl]),_:1},8,["direction"])])):j("",!0),f(Xo,{disabled:s(c),onClick:m[3]||(m[3]=v=>t("delete")),onConfirmingChanged:m[4]||(m[4]=v=>l.value=v)},{default:W(()=>[f(qe,{display:"Delete",direction:s(U).Left,class:"info"},{default:W(()=>[nl]),_:1},8,["direction"])]),_:1},8,["disabled"])])),s(i).error==null&&!a.value?(M(),T("div",sl,[N("button",{class:"button open",onClick:m[6]||(m[6]=v=>t("open"))},[N("h3",null,le(s(i).name),1)]),N("span",ol,"v"+le(s(i).modVersion),1),ll,s(d)?(M(),T("div",ul,"Last played "+le(s(r).format(s(d))),1)):j("",!0)])):s(i).error==null&&a.value?(M(),T("div",cl,[f(zr,{modelValue:u.value,"onUpdate:modelValue":m[7]||(m[7]=v=>u.value=v),class:"editname",onSubmit:h},null,8,["modelValue"])])):(M(),T("div",dl,[E(" Error: Failed to load save with id "+le(s(i).id),1),pl,E(le(s(i).error),1)]))],2))}});var gl=pe(fl,[["__scopeId","data-v-32313015"]]);const Qi=e=>(yn("data-v-2a4275be"),e=e(),wn(),e),ml=Qi(()=>N("h2",null,"Saves Manager",-1)),vl={class:"modal-footer"},hl={class:"field"},bl=Qi(()=>N("span",{class:"field-title"},"Create Save",-1)),yl={class:"field-buttons"},wl={class:"footer"},_l=Qi(()=>N("div",{style:{"flex-grow":"1"}},null,-1)),Nl=Y({__name:"SavesManager",setup(e,{expose:t}){const n=z(!1),i=z(null);t({open(){n.value=!0}});const r=z(!1),a=z(""),l=z(null);vt(a,S=>{S?Gt(()=>{try{if(S[0]!=="{")if(S[0]==="e")S=decodeURIComponent(escape(atob(S)));else if(S[0]==="\u1BE1")S=nn.decompressFromUTF16(S);else{console.warn("Unable to determine preset encoding",S),r.value=!0;return}const P=JSON.parse(S);if(typeof P!="object"){r.value=!0;return}const B=ci();P.id=B,mt(P),a.value="",r.value=!1,se.saves.push(B)}catch{r.value=!0}}):r.value=!1});let u={},c=z(Object.keys(u).reduce((S,P)=>(S.push({label:P.split("/").slice(-1)[0].slice(0,-4),value:u[P]}),S),[]));const d=Ui({});function h(S){if(d[S]==null){let P=localStorage.getItem(S);if(P==null)d[S]={error:"Save doesn't exist in localStorage",id:S};else if(P==="dW5kZWZpbmVk")d[S]={error:"Save is undefined",id:S};else try{if(P[0]!=="{")if(P[0]==="e")P=decodeURIComponent(escape(atob(P)));else if(P[0]==="\u1BE1")P=nn.decompressFromUTF16(P);else return console.warn("Unable to determine preset encoding",P),r.value=!0,d[S]={error:"Unable to determine preset encoding",id:S},d[S];d[S]={...JSON.parse(P),id:S}}catch(B){d[S]={error:B,id:S},console.warn(`SavesManager: Failed to load info about save with id ${S}:
${B}
${P}`)}}return d[S]}vt(n,S=>{S&&Object.keys(d).forEach(P=>delete d[P])});const p=_(()=>se.saves.reduce((S,P)=>(S[P]=h(P),S),{}));function m(S){let P;switch(J.id===S?P=Dr(J):P=JSON.stringify(p.value[S]),me.exportEncoding){default:console.warn(`Unknown save encoding: ${me.exportEncoding}. Defaulting to lz`);case"lz":P=nn.compressToUTF16(P);break;case"base64":P=btoa(unescape(encodeURIComponent(P)));break;case"plain":break}const B=document.createElement("textarea");B.value=P,document.body.appendChild(B),B.select(),B.setSelectionRange(0,99999),document.execCommand("copy"),document.body.removeChild(B)}function v(S){J.id===S&&mt();const P={...p.value[S],id:ci()};mt(P),se.saves.push(P.id)}function C(S){se.saves=se.saves.filter(P=>P!==S),localStorage.removeItem(S),d[S]=void 0}function y(S){p.value[J.id].time=J.time,mt(),d[J.id]=void 0,gn(p.value[S]),d[S]=void 0}function I(S){if(l.value=S,Gt(()=>{l.value=null}),S[0]!=="{")if(S[0]==="e")S=decodeURIComponent(escape(atob(S)));else if(S[0]==="\u1BE1")S=nn.decompressFromUTF16(S);else{console.warn("Unable to determine preset encoding",S);return}const P=JSON.parse(S);P.id=ci(),mt(P),se.saves.push(P.id),y(P.id)}function A(S,P){const B=p.value[S];B!=null&&(B.name=P,J.id===S?(J.name=P,mt()):(mt(B),d[S]=void 0))}return(S,P)=>(M(),K(Ht,{modelValue:n.value,"onUpdate:modelValue":P[4]||(P[4]=B=>n.value=B),ref_key:"modal",ref:i},{header:W(()=>[ml]),body:W(({shown:B})=>[B?(M(),K(s(Ma),{key:0,list:s(se).saves,handle:".handle",itemKey:ie=>ie},{item:W(({element:ie})=>[f(gl,{save:s(p)[ie],onOpen:re=>y(ie),onExport:re=>m(ie),onEditName:re=>A(ie,re),onDuplicate:re=>v(ie),onDelete:re=>C(ie)},null,8,["save","onOpen","onExport","onEditName","onDuplicate","onDelete"])]),_:1},8,["list","itemKey"])):j("",!0)]),footer:W(()=>[N("div",vl,[f(zr,{modelValue:a.value,"onUpdate:modelValue":P[0]||(P[0]=B=>a.value=B),title:"Import Save",placeholder:"Paste your save here!",class:he({importingFailed:r.value})},null,8,["modelValue","class"]),N("div",hl,[bl,N("div",yl,[N("button",{class:"button",onClick:P[1]||(P[1]=B=>y(s(Dn)().id))},"New Game"),Object.keys(s(c)).length>0?(M(),K(Ki,{key:0,options:s(c),modelValue:l.value,"onUpdate:modelValue":P[2]||(P[2]=B=>I(B)),closeOnSelect:"",placeholder:"Select preset",class:"presets"},null,8,["options","modelValue"])):j("",!0)])]),N("div",wl,[_l,N("button",{class:"button modal-default-button",onClick:P[3]||(P[3]=B=>n.value=!1)}," Close ")])])]),_:1},8,["modelValue"]))}});var Ur=pe(Nl,[["__scopeId","data-v-2a4275be"]]);const wt=e=>(yn("data-v-318a1c31"),e=e(),wn(),e),Cl=["src","alt"],kl={key:1,class:"title"},Ml=wt(()=>N("div",{style:{"flex-grow":"1",cursor:"unset"}},null,-1)),Sl={class:"discord"},Il={class:"discord-links"},$l={key:0},xl=["href"],El=wt(()=>N("li",null,[N("a",{href:"https://discord.gg/yJ4fjnjU54",target:"_blank"},"The Paper Pilot Community")],-1)),Pl=wt(()=>N("li",null,[N("a",{href:"https://discord.gg/F3xveHV",target:"_blank"},"The Modding Tree")],-1)),Dl={href:"https://forums.moddingtree.com/",target:"_blank"},Tl=wt(()=>N("span",{class:"material-icons"},"forum",-1)),Al=wt(()=>N("span",{class:"material-icons"},"info",-1)),Fl=wt(()=>N("span",{class:"material-icons"},"library_books",-1)),Rl=wt(()=>N("span",{class:"material-icons"},"settings",-1)),Ol=wt(()=>N("span",{class:"material-icons"},"library_books",-1)),ql=wt(()=>N("span",{class:"material-icons"},"settings",-1)),Vl=wt(()=>N("span",{class:"material-icons"},"info",-1)),Bl={href:"https://forums.moddingtree.com/",target:"_blank"},Ll=wt(()=>N("span",{class:"material-icons"},"forum",-1)),jl={class:"discord"},zl={class:"discord-links"},Ul={key:0},Gl=["href"],Wl=wt(()=>N("li",null,[N("a",{href:"https://discord.gg/yJ4fjnjU54",target:"_blank"},"The Paper Pilot Community")],-1)),Hl=wt(()=>N("li",null,[N("a",{href:"https://discord.gg/F3xveHV",target:"_blank"},"The Modding Tree")],-1)),Zl=Y({__name:"Nav",setup(e){const t=z(null),n=z(null),i=z(null),r=z(null),{useHeader:a,banner:l,title:u,discordName:c,discordLink:d,versionNumber:h}=me;function p(){window.open(d,"mywindow")}return(m,v)=>(M(),T(ee,null,[s(a)?(M(),T("div",Wt({key:0,class:"nav"},m.$attrs),[s(l)?(M(),T("img",{key:0,src:s(l),class:"banner",alt:s(u)},null,8,Cl)):(M(),T("div",kl,le(s(u)),1)),N("div",{onClick:v[0]||(v[0]=C=>{var y;return(y=r.value)==null?void 0:y.open()}),class:"version-container"},[f(qe,{display:"Changelog",direction:s(U).Down,class:"version"},{default:W(()=>[N("span",null,"v"+le(s(h)),1)]),_:1},8,["direction"])]),Ml,N("div",Sl,[N("span",{onClick:p,class:"material-icons"},"discord"),N("ul",Il,[s(d)?(M(),T("li",$l,[N("a",{href:s(d),target:"_blank"},le(s(c)),9,xl)])):j("",!0),El,Pl])]),N("div",null,[N("a",Dl,[f(qe,{display:"Forums",direction:s(U).Down,yoffset:"5px"},{default:W(()=>[Tl]),_:1},8,["direction"])])]),N("div",{onClick:v[1]||(v[1]=C=>{var y;return(y=t.value)==null?void 0:y.open()})},[f(qe,{display:"Info",direction:s(U).Down,class:"info"},{default:W(()=>[Al]),_:1},8,["direction"])]),N("div",{onClick:v[2]||(v[2]=C=>{var y;return(y=n.value)==null?void 0:y.open()})},[f(qe,{display:"Saves",direction:s(U).Down,xoffset:"-20px"},{default:W(()=>[Fl]),_:1},8,["direction"])]),N("div",{onClick:v[3]||(v[3]=C=>{var y;return(y=i.value)==null?void 0:y.open()})},[f(qe,{display:"Settings",direction:s(U).Down,xoffset:"-66px"},{default:W(()=>[Rl]),_:1},8,["direction"])])],16)):(M(),T("div",Wt({key:1,class:"overlay-nav"},m.$attrs),[N("div",{onClick:v[4]||(v[4]=C=>{var y;return(y=r.value)==null?void 0:y.open()}),class:"version-container"},[f(qe,{display:"Changelog",direction:s(U).Right,xoffset:"25%",class:"version"},{default:W(()=>[N("span",null,"v"+le(s(h)),1)]),_:1},8,["direction"])]),N("div",{onClick:v[5]||(v[5]=C=>{var y;return(y=n.value)==null?void 0:y.open()})},[f(qe,{display:"Saves",direction:s(U).Right},{default:W(()=>[Ol]),_:1},8,["direction"])]),N("div",{onClick:v[6]||(v[6]=C=>{var y;return(y=i.value)==null?void 0:y.open()})},[f(qe,{display:"Settings",direction:s(U).Right},{default:W(()=>[ql]),_:1},8,["direction"])]),N("div",{onClick:v[7]||(v[7]=C=>{var y;return(y=t.value)==null?void 0:y.open()})},[f(qe,{display:"Info",direction:s(U).Right},{default:W(()=>[Vl]),_:1},8,["direction"])]),N("div",null,[N("a",Bl,[f(qe,{display:"Forums",direction:s(U).Right,xoffset:"7px"},{default:W(()=>[Ll]),_:1},8,["direction"])])]),N("div",jl,[N("span",{onClick:p,class:"material-icons"},"discord"),N("ul",zl,[s(d)?(M(),T("li",Ul,[N("a",{href:s(d),target:"_blank"},le(s(c)),9,Gl)])):j("",!0),Wl,Hl])])],16)),f(Io,{ref_key:"info",ref:t,changelog:r.value},null,8,["changelog"]),f(Ur,{ref_key:"savesManager",ref:n},null,512),f(Vo,{ref_key:"options",ref:i},null,512),f(oo,{ref_key:"changelog",ref:r},null,512)],64))}});var Gr=pe(Zl,[["__scopeId","data-v-318a1c31"]]);const Yl={class:"inner-tab"},Xl=Y({__name:"Game",setup(e){const t=sn(J,"tabs"),n=_(()=>Object.keys(we)),i=me.useHeader;function r(a){const{display:l,minimized:u,name:c,color:d,minimizable:h,nodes:p,minimizedDisplay:m}=a;return{display:l,minimized:u,name:c,color:d,minimizable:h,nodes:p,minimizedDisplay:m}}return(a,l)=>(M(),T("div",{class:he(["tabs-container",{useHeader:s(i)}])},[(M(!0),T(ee,null,Fn(s(t),(u,c)=>{var d,h;return M(),T("div",{key:c,class:he(["tab",s((d=s(we)[u])==null?void 0:d.classes)]),style:je(s((h=s(we)[u])==null?void 0:h.style))},[c===0&&!s(i)?(M(),K(Gr,{key:0})):j("",!0),N("div",Yl,[s(n).includes(u)?(M(),K(io,Wt({key:0},r(s(we)[u]),{index:c,onSetMinimized:p=>s(we)[u].minimized.value=p}),null,16,["index","onSetMinimized"])):(M(),K(Xe(u),{key:1,index:c},null,8,["index"]))])],6)}),128))],2))}});var Jl=pe(Xl,[["__scopeId","data-v-dcd207b4"]]);const Kl=Y({__name:"Sticky",setup(e){const t=z("0"),n=new ResizeObserver(r),i=ht(null);function r(){let a=i.value;if(a==null)return;let l=0;for(;a.previousSibling;){const u=a.previousSibling;u.dataset&&"vSticky"in u.dataset&&(l+=u.offsetHeight),a=u}t.value=l+"px"}return Gt(r),document.fonts.ready.then(r),hi(()=>{var l;const a=(l=i.value)==null?void 0:l.parentElement;a&&n.observe(a)}),(a,l)=>(M(),T("div",{class:"sticky",style:je({top:t.value}),ref_key:"element",ref:i,"data-v-sticky":""},[Ft(a.$slots,"default",{},void 0,!0)],4))}});var mi=pe(Kl,[["__scopeId","data-v-cccac690"]]);const Ql=["x1","y1","x2","y2"],eu=Y({__name:"BoardLink",props:{link:null},setup(e){const n=Fe(e),i=_(()=>{const a=n.link.value.startNode.position;return n.link.value.offsetStart&&(a.x+=s(n.link.value.offsetStart).x,a.y+=s(n.link.value.offsetStart).y),a}),r=_(()=>{const a=n.link.value.endNode.position;return n.link.value.offsetEnd&&(a.x+=s(n.link.value.offsetEnd).x,a.y+=s(n.link.value.offsetEnd).y),a});return(a,l)=>(M(),T("line",Wt({class:"link"},e.link,{class:{pulsing:e.link.pulsing},x1:s(i).x,y1:s(i).y,x2:s(r).x,y2:s(r).y}),null,16,Ql))}});var tu=pe(eu,[["__scopeId","data-v-57c4970a"]]);const nu={key:0},iu=["transform","onMousedown","onTouchstart","onMouseup","onTouchend"],ru=["fill","stroke-width","stroke"],au=["fill"],su=Y({__name:"BoardNodeAction",props:{node:null,nodeType:null,actions:null,isSelected:{type:Boolean},selectedAction:null},emits:["clickAction"],setup(e,{emit:t}){const i=Fe(e),r=_(()=>ge(i.nodeType.value.size,s(i.node))),a=_(()=>{var h;return(h=ge(i.nodeType.value.outlineColor,s(i.node)))!=null?h:Mt[se.theme].variables["--outline"]}),l=_(()=>{var h;return(h=ge(i.nodeType.value.titleColor,s(i.node)))!=null?h:Mt[se.theme].variables["--foreground"]}),u=_(()=>ge(i.nodeType.value.actionDistance,s(i.node)));function c(h,p){t("clickAction",p.id),h.preventDefault(),h.stopPropagation()}function d(h,p){var m;((m=s(i.selectedAction))==null?void 0:m.id)===p.id&&(h.preventDefault(),h.stopPropagation())}return(h,p)=>(M(),K(Wn,{name:"actions",appear:""},{default:W(()=>[e.isSelected&&e.actions?(M(),T("g",nu,[(M(!0),T(ee,null,Fn(e.actions,(m,v)=>{var C,y;return M(),T("g",{key:m.id,class:he(["action",{selected:((C=e.selectedAction)==null?void 0:C.id)===m.id}]),transform:`translate(
${(-s(r)-30)*Math.sin(((e.actions.length-1)/2-v)*s(u))},
${(s(r)+30)*Math.cos(((e.actions.length-1)/2-v)*s(u))}
)`,onMousedown:I=>c(I,m),onTouchstart:I=>c(I,m),onMouseup:I=>d(I,m),onTouchend:An(I=>d(I,m),["stop"])},[N("circle",{fill:s(ge)(m.fillColor,e.node),r:"20","stroke-width":((y=e.selectedAction)==null?void 0:y.id)===m.id?4:0,stroke:s(a)},null,8,ru),N("text",{fill:s(l),class:"material-icons"},le(s(ge)(m.icon,e.node)),9,au)],42,iu)}),128))])):j("",!0)]),_:1}))}});var ou=pe(su,[["__scopeId","data-v-9efb2a56"]]);const lu=["transform"],uu={key:0},cu=["r","fill","stroke"],du=["r","fill","stroke"],pu=["r","fill"],fu=["r","stroke-dasharray","stroke-dashoffset","stroke"],gu={key:1,transform:"rotate(45, 0, 0)"},mu=["width","height","transform","fill","stroke"],vu=["width","height","transform","fill","stroke"],hu=["width","height","transform","fill"],bu=["width","height","transform","stroke-dasharray","stroke-dashoffset","stroke"],yu=["fill","y"],wu=["fill"],_u={key:0},Nu=["fill","y"],Cu=["fill","y"],ku=Y({__name:"BoardNode",props:{node:null,nodeType:null,dragging:null,dragged:null,hasDragged:{type:Boolean},receivingNode:{type:Boolean},isSelected:{type:Boolean},selectedAction:null},emits:["mouseDown","endDragging","clickAction"],setup(e,{emit:t}){const n=e,i=Math.sqrt(2),r=Fe(n),a=_(()=>ge(r.nodeType.value.draggable,s(r.node)));vt(a,V=>{const ae=s(r.node);s(r.dragging)===ae&&!V&&t("endDragging",ae)});const l=_(()=>{var ae;const V=s(r.node);return(ae=ge(r.nodeType.value.actions,V))==null?void 0:ae.filter(Re=>Ue(ge(Re.visibility,V)))}),u=_(()=>{var ae;const V=s(r.node);if(ge(r.nodeType.value.draggable,V)&&((ae=s(r.dragging))==null?void 0:ae.id)===V.id&&s(r.dragged)!=null){const{x:Re,y:Ze}=s(r.dragged);return{x:V.position.x+Math.round(Re/25)*25,y:V.position.y+Math.round(Ze/25)*25}}return V.position}),c=_(()=>ge(r.nodeType.value.shape,s(r.node))),d=_(()=>ge(r.nodeType.value.title,s(r.node))),h=_(()=>ge(r.nodeType.value.subtitle,s(r.node))),p=_(()=>{var V;return(V=r.isSelected.value?s(r.selectedAction)&&ge(s(r.selectedAction).tooltip,s(r.node)):null)!=null?V:ge(r.nodeType.value.label,s(r.node))}),m=_(()=>{var V,ae;return ge((ae=(V=s(r.selectedAction))==null?void 0:V.confirmationLabel)!=null?ae:{text:"Tap again to confirm"},s(r.node))}),v=_(()=>ge(r.nodeType.value.size,s(r.node))),C=_(()=>{var V;return(V=ge(r.nodeType.value.progress,s(r.node)))!=null?V:0}),y=_(()=>Mt[se.theme].variables["--background"]),I=_(()=>{var V;return(V=ge(r.nodeType.value.outlineColor,s(r.node)))!=null?V:Mt[se.theme].variables["--outline"]}),A=_(()=>{var V;return(V=ge(r.nodeType.value.fillColor,s(r.node)))!=null?V:Mt[se.theme].variables["--raised-background"]}),S=_(()=>ge(r.nodeType.value.progressColor,s(r.node))),P=_(()=>{var V;return(V=ge(r.nodeType.value.titleColor,s(r.node)))!=null?V:Mt[se.theme].variables["--foreground"]}),B=_(()=>ge(r.nodeType.value.progressDisplay,s(r.node))),ie=_(()=>r.dragging.value!=null&&s(r.hasDragged)&&ge(r.nodeType.value.canAccept,s(r.node),r.dragging.value)),re=_(()=>ge(r.nodeType.value.style,s(r.node))),oe=_(()=>ge(r.nodeType.value.classes,s(r.node)));function H(V){t("mouseDown",V,r.node.value,a.value)}function fe(V){var ae,Re,Ze;(ae=r.hasDragged)!=null&&ae.value||(t("endDragging",r.node.value),(Ze=(Re=r.nodeType.value).onClick)==null||Ze.call(Re,r.node.value),V.stopPropagation())}return(V,ae)=>{var Re,Ze,qt;return M(),T("g",{class:he(["boardnode",{[e.node.type]:!0,isSelected:e.isSelected,isDraggable:s(a),...s(oe)}]),style:je([{opacity:((Re=e.dragging)==null?void 0:Re.id)===e.node.id&&e.hasDragged?.5:1},(Ze=s(re))!=null?Ze:[]]),transform:`translate(${s(u).x},${s(u).y})${e.isSelected?" scale(1.2)":""}`},[f(ou,{actions:(qt=s(l))!=null?qt:[],"is-selected":e.isSelected,node:e.node,"node-type":e.nodeType,"selected-action":e.selectedAction,onClickAction:ae[0]||(ae[0]=ft=>t("clickAction",ft))},null,8,["actions","is-selected","node","node-type","selected-action"]),N("g",{class:"node-container",onMousedown:H,onTouchstartPassive:H,onMouseup:fe,onTouchendPassive:fe},[s(c)===s(Ge).Circle?(M(),T("g",uu,[s(ie)?(M(),T("circle",{key:0,class:"receiver",r:s(v)+8,fill:s(y),stroke:e.receivingNode?"#0F0":"#0F03","stroke-width":2},null,8,cu)):j("",!0),N("circle",{class:"body",r:s(v),fill:s(A),stroke:s(I),"stroke-width":4},null,8,du),s(B)===s(bn).Fill?(M(),T("circle",{key:1,class:"progress progressFill",r:Math.max(s(v)*s(C)-2,0),fill:s(S)},null,8,pu)):(M(),T("circle",{key:2,r:s(v)+4.5,class:"progress progressRing",fill:"transparent","stroke-dasharray":(s(v)+4.5)*2*Math.PI,"stroke-width":5,"stroke-dashoffset":(s(v)+4.5)*2*Math.PI-s(C)*(s(v)+4.5)*2*Math.PI,stroke:s(S)},null,8,fu))])):s(c)===s(Ge).Diamond?(M(),T("g",gu,[s(ie)?(M(),T("rect",{key:0,class:"receiver",width:s(v)*s(i)+16,height:s(v)*s(i)+16,transform:`translate(${-(s(v)*s(i)+16)/2}, ${-(s(v)*s(i)+16)/2})`,fill:s(y),stroke:e.receivingNode?"#0F0":"#0F03","stroke-width":2},null,8,mu)):j("",!0),N("rect",{class:"body",width:s(v)*s(i),height:s(v)*s(i),transform:`translate(${-s(v)*s(i)/2}, ${-s(v)*s(i)/2})`,fill:s(A),stroke:s(I),"stroke-width":4},null,8,vu),s(B)===s(bn).Fill?(M(),T("rect",{key:1,class:"progress progressFill",width:Math.max(s(v)*s(i)*s(C)-2,0),height:Math.max(s(v)*s(i)*s(C)-2,0),transform:`translate(${-Math.max(s(v)*s(i)*s(C)-2,0)/2}, ${-Math.max(s(v)*s(i)*s(C)-2,0)/2})`,fill:s(S)},null,8,hu)):(M(),T("rect",{key:2,class:"progress progressDiamond",width:s(v)*s(i)+9,height:s(v)*s(i)+9,transform:`translate(${-(s(v)*s(i)+9)/2}, ${-(s(v)*s(i)+9)/2})`,fill:"transparent","stroke-dasharray":(s(v)*s(i)+9)*4,"stroke-width":5,"stroke-dashoffset":(s(v)*s(i)+9)*4-s(C)*(s(v)*s(i)+9)*4,stroke:s(S)},null,8,bu))])):j("",!0),N("text",{fill:s(P),class:"node-title",y:s(h)?10:0},le(s(d)),9,yu),s(h)?(M(),T("text",{key:2,fill:s(P),class:"node-subtitle",y:"-15"},le(s(h)),9,wu)):j("",!0)],32),f(Wn,{name:"fade",appear:""},{default:W(()=>{var ft;return[s(p)?(M(),T("g",_u,[N("text",{fill:(ft=s(p).color)!=null?ft:s(P),class:he(["node-title",{pulsing:s(p).pulsing}]),y:-s(v)-20},le(s(p).text),11,Nu)])):j("",!0)]}),_:1}),f(Wn,{name:"fade",appear:""},{default:W(()=>{var ft;return[e.isSelected&&e.selectedAction?(M(),T("text",{key:0,fill:(ft=s(m).color)!=null?ft:s(P),class:he(["node-title",{pulsing:s(m).pulsing}]),y:s(v)+75},le(s(m).text),11,Cu)):j("",!0)]}),_:1})],14,lu)}}});var Mu=pe(ku,[["__scopeId","data-v-518d7a7f"]]);const Su={class:"stage",width:"100%",height:"100%"},Iu={class:"g1"},$u=Y({__name:"Board",props:{nodes:null,types:null,state:null,visibility:null,width:null,height:null,style:null,classes:null,links:null,selectedAction:null,selectedNode:null,draggingNode:null,receivingNode:null,mousePosition:null,setReceivingNode:{type:Function},setDraggingNode:{type:Function}},setup(e){const n=Fe(e),i=z({x:0,y:0}),r=z({x:0,y:0}),a=z(!1),l=z(null),u=_(()=>{const v=n.nodes.value.slice();if(n.selectedNode.value){const C=v.splice(v.indexOf(n.selectedNode.value),1)[0];v.push(C)}if(n.draggingNode.value){const C=v.splice(v.indexOf(n.draggingNode.value),1)[0];v.push(C)}return v});Et(()=>{const v=n.draggingNode.value;if(v==null)return null;const C={x:v.position.x+r.value.x,y:v.position.y+r.value.y};let y=Number.MAX_VALUE;n.setReceivingNode.value(n.nodes.value.reduce((I,A)=>{if(A.id===v.id)return I;const S=n.types.value[A.type];if(!ge(S.canAccept,A,v))return I;const B=Math.pow(C.x-A.position.x,2)+Math.pow(C.y-A.position.y,2);let ie=ge(S.size,A);return B>y||B>ie*ie?I:(y=B,A)},null))});function c(v){v.setTransformOrigin(null),v.moveTo(l.value.$el.clientWidth/2,l.value.$el.clientHeight/2)}function d(v,C=null,y=!1){if(n.draggingNode.value==null){v.preventDefault(),v.stopPropagation();let I,A;if("touches"in v)if(v.touches.length===1)I=v.touches[0].clientX,A=v.touches[0].clientY;else return;else I=v.clientX,A=v.clientY;i.value={x:I,y:A},r.value={x:0,y:0},a.value=!1,y&&n.setDraggingNode.value(C)}C!=null&&(n.state.value.selectedNode=null,n.state.value.selectedAction=null)}function h(v){const{x:C,y,scale:I}=l.value.panZoomInstance.getTransform();let A,S;if("touches"in v)if(v.touches.length===1)A=v.touches[0].clientX,S=v.touches[0].clientY;else{p(n.draggingNode.value),n.mousePosition.value=null;return}else A=v.clientX,S=v.clientY;n.mousePosition.value={x:(A-C)/I,y:(S-y)/I},r.value={x:r.value.x+(A-i.value.x)/I,y:r.value.y+(S-i.value.y)/I},i.value={x:A,y:S},(Math.abs(r.value.x)>10||Math.abs(r.value.y)>10)&&(a.value=!0),n.draggingNode.value!=null&&(v.preventDefault(),v.stopPropagation())}function p(v,C=!1){var y,I;if(n.draggingNode.value!=null&&n.draggingNode.value===v){n.receivingNode.value==null&&(n.draggingNode.value.position.x+=Math.round(r.value.x/25)*25,n.draggingNode.value.position.y+=Math.round(r.value.y/25)*25);const A=n.nodes.value;A.push(A.splice(A.indexOf(n.draggingNode.value),1)[0]),n.receivingNode.value&&((I=(y=n.types.value[n.receivingNode.value.type]).onDrop)==null||I.call(y,n.receivingNode.value,n.draggingNode.value)),n.setDraggingNode.value(null)}else!a.value&&!C&&(n.state.value.selectedNode=null,n.state.value.selectedAction=null)}function m(v,C){n.state.value.selectedAction===C?s(n.selectedAction).onClick(s(n.selectedNode)):n.state.value={...n.state.value,selectedAction:C}}return(v,C)=>{const y=It("panZoom");return s(Ue)(e.visibility)?(M(),K(y,{key:0,style:je([{width:e.width,height:e.height},e.style]),class:he(e.classes),selector:".g1",options:{initialZoom:1,minZoom:.1,maxZoom:10,zoomDoubleClickSpeed:1},ref_key:"stage",ref:l,onInit:c,onMousemove:h,onTouchmove:h,onMousedown:C[0]||(C[0]=I=>d(I)),onTouchstart:C[1]||(C[1]=I=>d(I)),onMouseup:C[2]||(C[2]=()=>p(s(e.draggingNode))),onTouchendPassive:C[3]||(C[3]=()=>p(s(e.draggingNode))),onMouseleave:C[4]||(C[4]=()=>p(s(e.draggingNode),!0))},{default:W(()=>[(M(),T("svg",Su,[N("g",Iu,[f(ur,{name:"link",appear:""},{default:W(()=>[(M(!0),T(ee,null,Fn(s(e.links)||[],I=>(M(),T("g",{key:`${I.startNode.id}-${I.endNode.id}`},[f(tu,{link:I},null,8,["link"])]))),128))]),_:1}),f(ur,{name:"grow",duration:500,appear:""},{default:W(()=>[(M(!0),T(ee,null,Fn(s(u),I=>(M(),T("g",{key:I.id,style:{"transition-duration":"0s"}},[f(Mu,{node:I,nodeType:e.types[I.type],dragging:s(e.draggingNode),dragged:s(e.draggingNode)===I?r.value:void 0,hasDragged:s(e.draggingNode)==null?!1:a.value,receivingNode:s(e.receivingNode)===I,isSelected:s(e.selectedNode)===I,selectedAction:s(e.selectedNode)===I?s(e.selectedAction):null,onMouseDown:d,onEndDragging:p,onClickAction:A=>m(I,A)},null,8,["node","nodeType","dragging","dragged","hasDragged","receivingNode","isSelected","selectedAction","onClickAction"])]))),128))]),_:1})])]))]),_:1},8,["style","class","options"])):j("",!0)}}});Je.on("setupVue",e=>Ia.install(e));const Wr=Symbol("Board");var bn=(e=>(e.Outline="Outline",e.Fill="Fill",e))(bn||{}),Ge=(e=>(e.Circle="Circle",e.Diamond="Triangle",e))(Ge||{});function xu(e){const t=ct({nodes:[],selectedNode:null,selectedAction:null},!1);return Ke(n=>{const i=e.call(n,n);i.id=ln("board-"),i.type=Wr,i[yt]=$u,i.state?(Vr(t),$(i,"state")):(t[on]={nodes:i.startNodes().map((u,c)=>(u.id=c,u)),selectedNode:null,selectedAction:null},i.state=t),i.nodes=_(()=>s(l.state).nodes),i.selectedNode=_({get(){return l.nodes.value.find(u=>u.id===s(l.state).selectedNode)||null},set(u){var c,d;Ve(l.state)?l.state.value={...l.state.value,selectedNode:(c=u==null?void 0:u.id)!=null?c:null}:l.state.selectedNode=(d=u==null?void 0:u.id)!=null?d:null}}),i.selectedAction=_({get(){const u=l.selectedNode.value;if(u==null)return null;const c=l.types[u.type];return c.actions==null?null:c.actions.find(d=>d.id===s(l.state).selectedAction)||null},set(u){var c,d;Ve(l.state)?l.state.value={...l.state.value,selectedAction:(c=u==null?void 0:u.id)!=null?c:null}:l.state.selectedAction=(d=u==null?void 0:u.id)!=null?d:null}}),i.mousePosition=z(null),i.links?$(i,"links"):i.links=_(()=>l.selectedAction.value==null?null:l.selectedAction.value.links&&l.selectedNode.value?ge(l.selectedAction.value.links,l.selectedNode.value):null),i.draggingNode=z(null),i.receivingNode=z(null),$(i,"visibility"),ne(i,"visibility",Ne.Visible),$(i,"width"),ne(i,"width","100%"),$(i,"height"),ne(i,"height","100%"),$(i,"classes"),$(i,"style");for(const u in i.types){const c=i.types[u];if($(c,"title"),$(c,"subtitle"),$(c,"label"),$(c,"size"),ne(c,"size",50),$(c,"style"),$(c,"classes"),$(c,"draggable"),ne(c,"draggable",!1),$(c,"shape"),ne(c,"shape","Circle"),$(c,"canAccept"),ne(c,"canAccept",!1),$(c,"progress"),$(c,"progressDisplay"),ne(c,"progressDisplay","Fill"),$(c,"progressColor"),ne(c,"progressColor","none"),$(c,"fillColor"),$(c,"outlineColor"),$(c,"titleColor"),$(c,"actionDistance"),ne(c,"actionDistance",Math.PI/6),c.nodes=_(()=>s(l.state).nodes.filter(d=>d.type===u)),ne(c,"onClick",function(d){s(l.state).selectedNode=d.id}),c.actions)for(const d of c.actions)$(d,"visibility"),ne(d,"visibility",Ne.Visible),$(d,"icon"),$(d,"fillColor"),$(d,"tooltip"),$(d,"confirmationLabel"),ne(d,"confirmationLabel",{text:"Tap again to confirm"}),$(d,"links")}function r(u){i.draggingNode.value=u}function a(u){i.receivingNode.value=u}i.placeInAvailableSpace=function(u,c=100,d=U.Right){const h=l.nodes.value.slice().filter(p=>p===u||(d===U.Down||d===U.Up)&&Math.abs(p.position.x-u.position.x)>c||(d===U.Left||d===U.Right)&&Math.abs(p.position.y-u.position.y)>c?!1:!(d===U.Right&&p.position.x<u.position.x-c||d===U.Left&&p.position.x>u.position.x+c||d===U.Up&&p.position.y>u.position.y+c||d===U.Down&&p.position.y<u.position.y-c)).sort(d===U.Right?(p,m)=>p.position.x-m.position.x:d===U.Left?(p,m)=>m.position.x-p.position.x:d===U.Up?(p,m)=>m.position.y-p.position.y:(p,m)=>p.position.y-m.position.y);for(let p=0;p<h.length;p++){const m=h[p],v=d===U.Right||d===U.Left?Math.abs(u.position.x-m.position.x):Math.abs(u.position.y-m.position.y);if(v<c)d===U.Right?u.position.x=m.position.x+c:d===U.Left?u.position.x=m.position.x-c:d===U.Up?u.position.y=m.position.y-c:d===U.Down&&(u.position.y=m.position.y+c);else if(p>0&&v>c)break}},i[pt]=function(){const{nodes:u,types:c,state:d,visibility:h,width:p,height:m,style:v,classes:C,links:y,selectedAction:I,selectedNode:A,mousePosition:S,draggingNode:P,receivingNode:B}=this;return{nodes:u,types:c,state:d,visibility:h,width:p,height:m,style:s(v),classes:C,links:y,selectedAction:I,selectedNode:A,mousePosition:S,draggingNode:P,receivingNode:B,setDraggingNode:r,setReceivingNode:a}};const l=i;return l})}function ge(e,t,...n){return Zn(e)?e(t,...n):s(e)}function Kn(e){let t=0;return e.nodes.value.forEach(n=>{n.id>=t&&(t=n.id+1)}),t}const zn={};Je.on("addLayer",e=>{const t=Xn(e,Wr);zn[e.id]=e.on("postUpdate",n=>{t.forEach(i=>{Object.values(i.types).forEach(r=>r.nodes.value.forEach(a=>{var l;return(l=r.update)==null?void 0:l.call(r,a,n)}))})})});Je.on("removeLayer",e=>{var t;(t=zn[e.id])==null||t.call(zn),zn[e.id]=void 0});function En(e,t="points",n=0,i=void 0){const r=Ve(e)?e:ct(e);if(r.displayName=t,r.precision=n,r.small=i,!Ve(e)){const a=r[At];a.displayName=t,a.precision=n,a.small=i}return r}new o("10^^8");new o("1e100");function vi(e,t){const n=t!=null?t:e.value;return o.eq(e.precision,0)?dt(e.small?n:o.floor(n)):_e(n,e.precision,e.small)}Je.on("setupVue",e=>e.use($a));function Eu(e="white",t="8px"){return{transform:"scale(1.05, 1.05)",borderColor:"rgba(0, 0, 0, 0.125)",boxShadow:`-4px -4px 4px rgba(0, 0, 0, 0.25) inset, 0 0 ${t} ${e}`,zIndex:1}}const Pu=Y({props:{visibility:{type:O(Number,Boolean),required:!0},display:{type:O(Object,String,Function),required:!0},style:O(String,Object,Array),classes:O(Object),glowColor:O(String),active:Boolean,floating:Boolean},emits:["selectTab"],setup(e,{emit:t}){const{display:n,glowColor:i,floating:r}=Fe(e),a=Or(n),l=_(()=>{const c=Ee(i);return c==null||c===""?{}:s(r)?Eu(c):{boxShadow:`0px 9px 5px -6px ${c}`}});function u(){t("selectTab")}return{selectTab:u,component:a,glowColorStyle:l,unref:s,Visibility:Ne,isVisible:Ue,isHidden:_n}}});function Du(e,t,n,i,r,a){var l;return e.isVisible(e.visibility)?(M(),T("button",{key:0,onClick:t[0]||(t[0]=(...u)=>e.selectTab&&e.selectTab(...u)),class:he(["tabButton",{active:e.active,...e.unref(e.classes)}]),style:je([{visibility:e.isHidden(e.visibility)?"hidden":void 0},e.glowColorStyle,(l=e.unref(e.style))!=null?l:{}])},[(M(),K(Xe(e.component)))],6)):j("",!0)}var Hr=pe(Pu,[["render",Du],["__scopeId","data-v-21427abb"]]);const Tu=Y({props:{visibility:{type:O(Number,Boolean),required:!0},activeTab:{type:O(Object),required:!0},selected:{type:Object,required:!0},tabs:{type:O(Object),required:!0},style:O(String,Object,Array),classes:O(Object),buttonContainerStyle:O(String,Object,Array),buttonContainerClasses:O(Object)},components:{Sticky:mi,TabButton:Hr},setup(e){const{activeTab:t}=Fe(e),n=_(()=>Mt[se.theme].floatingTabs),i=ht("");Et(()=>{const u=Ee(t);if(u==null){i.value="";return}if(Pt(u)){i.value=ue(u);return}i.value=ue(s(u.display))});const r=_(()=>{const u=Ee(t);return Pt(u)||!u?void 0:s(u.classes)}),a=_(()=>{const u=Ee(t);return Pt(u)||!u?void 0:s(u.style)});function l(u){const{display:c,style:d,classes:h,glowColor:p,visibility:m}=u;return{display:c,style:s(d),classes:h,glowColor:p,visibility:m}}return{floating:n,tabClasses:r,tabStyle:a,Visibility:Ne,component:i,gatherButtonProps:l,unref:s,isVisible:Ue,isHidden:_n}}});function Au(e,t,n,i,r,a){var c,d;const l=It("TabButton"),u=It("Sticky");return e.isVisible(e.visibility)?(M(),T("div",{key:0,class:he(["tab-family-container",{...e.unref(e.classes),...e.tabClasses}]),style:je([{visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:[],(d=e.tabStyle)!=null?d:[]])},[f(u,{class:he(["tab-buttons-container",e.unref(e.buttonContainerClasses)]),style:je(e.unref(e.buttonContainerStyle))},{default:W(()=>[N("div",{class:he(["tab-buttons",{floating:e.floating}])},[(M(!0),T(ee,null,Fn(e.unref(e.tabs),(h,p)=>(M(),K(l,Wt({onSelectTab:m=>e.selected.value=p,floating:e.floating,key:p,active:e.unref(h.tab)===e.unref(e.activeTab)},e.gatherButtonProps(h)),null,16,["onSelectTab","floating","active"]))),128))],2)]),_:1},8,["class","style"]),e.unref(e.activeTab)?(M(),K(Xe(e.unref(e.component)),{key:0})):j("",!0)],6)):j("",!0)}var Fu=pe(Tu,[["render",Au],["__scopeId","data-v-58dbf83a"]]);const Ru=Symbol("TabButton"),Ou=Symbol("TabFamily");function qu(e,t){if(Object.keys(e).length===0)throw console.warn("Cannot create tab family with 0 tabs"),new Error("Cannot create tab family with 0 tabs");const n=ct(Object.keys(e)[0],!1);return Ke(i=>{var l;const r=(l=t==null?void 0:t.call(i,i))!=null?l:{};r.id=ln("tabFamily-"),r.type=Ou,r[yt]=Fu,r.tabs=Object.keys(e).reduce((u,c)=>{const d=e[c]();return d.type=Ru,d[yt]=Hr,$(d,"visibility"),ne(d,"visibility",Ne.Visible),$(d,"tab"),$(d,"display"),$(d,"classes"),$(d,"style"),$(d,"glowColor"),u[c]=d,u},{}),r.selected=n,r.activeTab=_(()=>{const u=s(a.tabs);if(n.value in u&&Ue(u[n.value].visibility))return s(u[n.value].tab);const c=Object.values(u).find(d=>Ue(d.visibility));return c?s(c.tab):null}),$(r,"visibility"),ne(r,"visibility",Ne.Visible),$(r,"classes"),$(r,"style"),$(r,"buttonContainerClasses"),$(r,"buttonContainerStyle"),r[pt]=function(){const{visibility:u,activeTab:c,selected:d,tabs:h,style:p,classes:m,buttonContainerClasses:v,buttonContainerStyle:C}=this;return{visibility:u,activeTab:c,selected:d,tabs:h,style:s(p),classes:m,buttonContainerClasses:v,buttonContainerStyle:C}};const a=r;return a})}const Zr=o.ln(10);function Un(e){return e}function Vu(e,t){if(F(t))return t.invert(o.neg(e));throw new Error("Could not invert due to no input being a variable")}function Bu(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return g.neg(t.getIntegralFormula(e))}throw new Error("Could not integrate due to no input being a variable")}function Lu(e){return g.neg(e)}function ju(e,t,n){if(F(t))return t.invert(o.sub(e,Ce(n)));if(F(n))return n.invert(o.sub(e,Ce(t)));throw new Error("Could not invert due to no input being a variable")}function zu(e,t,n){var i,r;if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const a=t.getIntegralFormula(e);return g.times(n,(i=t.innermostVariable)!=null?i:0).add(a)}else if(F(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const a=n.getIntegralFormula(e);return g.times(t,(r=n.innermostVariable)!=null?r:0).add(a)}throw new Error("Could not integrate due to no input being a variable")}function Uu(e,t,n){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.add(i,n)}else if(F(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e);return g.add(i,t)}throw new Error("Could not integrate due to no input being a variable")}function Gu(e,t,n){if(F(t))return t.invert(o.add(e,Ce(n)));if(F(n))return n.invert(o.sub(Ce(t),e));throw new Error("Could not invert due to no input being a variable")}function Wu(e,t,n){var i,r;if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const a=t.getIntegralFormula(e);return g.sub(a,g.times(n,(i=t.innermostVariable)!=null?i:0))}else if(F(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const a=n.getIntegralFormula(e);return g.times(t,(r=n.innermostVariable)!=null?r:0).sub(a)}throw new Error("Could not integrate due to no input being a variable")}function Hu(e,t,n){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.sub(i,n)}else if(F(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e);return g.sub(i,t)}throw new Error("Could not integrate due to no input being a variable")}function Zu(e,t,n){if(F(t))return t.invert(o.div(e,Ce(n)));if(F(n))return n.invert(o.div(e,Ce(t)));throw new Error("Could not invert due to no input being a variable")}function Yu(e,t,n){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.times(i,n)}else if(F(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e);return g.times(i,t)}throw new Error("Could not integrate due to no input being a variable")}function Xu(e,t,n){if(F(t))return g.div(e,n);if(F(n))return g.div(e,t);throw new Error("Could not apply substitution due to no input being a variable")}function Ju(e,t,n){if(F(t))return t.invert(o.mul(e,Ce(n)));if(F(n))return n.invert(o.div(Ce(t),e));throw new Error("Could not invert due to no input being a variable")}function Ku(e,t,n){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.div(i,n)}else if(F(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e);return g.div(t,i)}throw new Error("Could not integrate due to no input being a variable")}function Qu(e,t,n){if(F(t))return g.mul(e,n);if(F(n))return g.mul(e,t);throw new Error("Could not apply substitution due to no input being a variable")}function ec(e,t){if(F(t))return t.invert(o.recip(e));throw new Error("Could not invert due to no input being a variable")}function tc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.ln(n)}throw new Error("Could not integrate due to no input being a variable")}function nc(e,t){if(F(t))return t.invert(o.pow10(e));throw new Error("Could not invert due to no input being a variable")}function ic(e){return o.ln(e).sub(1).times(e).div(Zr)}function rc(e,t){if(F(t)){const n=Zr.times(e);return t.invert(n.div(n.div(Math.E).lambertw()))}throw new Error("Could not invert due to no input being a variable")}function ac(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e)],evaluate:ic,invert:rc})}throw new Error("Could not integrate due to no input being a variable")}function sc(e,t,n){if(F(t))return t.invert(o.pow(Ce(n),e));if(F(n))return n.invert(o.root(Ce(t),e));throw new Error("Could not invert due to no input being a variable")}function oc(e,t){return o.ln(e).sub(1).times(e).div(o.ln(t))}function lc(e,t,n){if(F(t)){const i=o.ln(Ce(n)).times(e);return t.invert(i.div(i.div(Math.E).lambertw()))}throw new Error("Could not invert due to no input being a variable")}function uc(e,t,n){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e),n],evaluate:oc,invert:lc})}throw new Error("Could not integrate due to no input being a variable")}function cc(e,t){if(F(t))return t.invert(o.pow(2,e));throw new Error("Could not invert due to no input being a variable")}function dc(e){return o.ln(e).sub(1).times(e).div(o.ln(2))}function pc(e,t){if(F(t)){const n=o.ln(2).times(e);return t.invert(n.div(n.div(Math.E).lambertw()))}throw new Error("Could not invert due to no input being a variable")}function fc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e)],evaluate:dc,invert:pc})}throw new Error("Could not integrate due to no input being a variable")}function gc(e,t){if(F(t))return t.invert(o.exp(e));throw new Error("Could not invert due to no input being a variable")}function mc(e){return o.ln(e).sub(1).times(e)}function vc(e,t){if(F(t))return t.invert(o.div(e,o.div(e,Math.E).lambertw()));throw new Error("Could not invert due to no input being a variable")}function hc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e)],evaluate:mc,invert:vc})}throw new Error("Could not integrate due to no input being a variable")}function bc(e,t,n){if(F(t))return t.invert(o.root(e,Ce(n)));if(F(n))return n.invert(o.ln(e).div(o.ln(Ce(t))));throw new Error("Could not invert due to no input being a variable")}function yc(e,t,n){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e),r=g.add(n,1);return g.pow(i,r).div(r)}else if(F(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e);return g.pow(t,i).div(g.ln(t))}throw new Error("Could not integrate due to no input being a variable")}function wc(e,t){if(F(t))return t.invert(o.root(e,10));throw new Error("Could not invert due to no input being a variable")}function _c(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.pow10(n).div(g.ln(10))}throw new Error("Could not integrate due to no input being a variable")}function Nc(e,t,n){if(F(t))return t.invert(o.ln(e).div(o.ln(Ce(n))));if(F(n))return n.invert(o.root(Ce(t),e));throw new Error("Could not invert due to no input being a variable")}function Cc(e,t,n){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.pow(n,i).div(g.ln(n))}else if(F(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e),r=g.add(t,1);return g.pow(i,r).div(r)}throw new Error("Could not integrate due to no input being a variable")}function kc(e,t,n){if(F(t))return t.invert(o.root(e,o.recip(Ce(n))));if(F(n))return n.invert(o.ln(Ce(t)).div(o.ln(e)));throw new Error("Could not invert due to no input being a variable")}function Mc(e,t,n){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.pow(i,g.recip(n).add(1)).times(n).div(g.add(n,1))}throw new Error("Could not integrate due to no input being a variable")}function Sc(e,t){if(F(t))return t.invert(o.ln(e));throw new Error("Could not invert due to no input being a variable")}function Ic(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.exp(n)}throw new Error("Could not integrate due to no input being a variable")}function $c(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){const i=o.minabs(t,1e308).toNumber();return o.tetrate(e,i,n)}function xc(e,t,n,i){if(F(t))return t.invert(o.ssqrt(e));throw new Error("Could not invert due to no input being a variable")}function Ec(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){const i=o.minabs(t,1e308).toNumber();return o.iteratedexp(e,i,new o(n))}function Pc(e,t,n,i){if(F(t))return t.invert(o.iteratedlog(e,Math.E,o.minabs(1e308,Ce(n)).toNumber()));throw new Error("Could not invert due to no input being a variable")}function Dc(e,t=10,n=2){const i=o.minabs(n,1e308).toNumber();return o.iteratedlog(e,t,i)}function Tc(e,t=10){const n=o.minabs(t,1e308).toNumber();return o.slog(e,n)}function Ac(e,t,n){if(F(t))return t.invert(o.tetrate(e,o.minabs(1e308,Ce(n)).toNumber()));throw new Error("Could not invert due to no input being a variable")}function Fc(e,t,n){const i=o.minabs(t,1e308).toNumber();return o.layeradd(e,i,n)}function Rc(e,t,n,i){if(F(t))return t.invert(o.layeradd(e,o.minabs(1e308,Ce(n)).negate().toNumber()));throw new Error("Could not invert due to no input being a variable")}function Oc(e,t){if(F(t))return t.invert(o.pow(Math.E,e).times(e));throw new Error("Could not invert due to no input being a variable")}function qc(e,t){if(F(t))return t.invert(o.tetrate(e,2));throw new Error("Could not invert due to no input being a variable")}function Vc(e,t,n){const i=o.minabs(t,1e308).toNumber();return o.pentate(e,i,n)}function Bc(e,t){if(F(t))return t.invert(o.asin(e));throw new Error("Could not invert due to no input being a variable")}function Lc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.cos(n).neg()}throw new Error("Could not integrate due to no input being a variable")}function jc(e,t){if(F(t))return t.invert(o.acos(e));throw new Error("Could not invert due to no input being a variable")}function zc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.sin(n)}throw new Error("Could not integrate due to no input being a variable")}function Uc(e,t){if(F(t))return t.invert(o.atan(e));throw new Error("Could not invert due to no input being a variable")}function Gc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.cos(n).ln().neg()}throw new Error("Could not integrate due to no input being a variable")}function Wc(e,t){if(F(t))return t.invert(o.sin(e));throw new Error("Could not invert due to no input being a variable")}function Hc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.asin(n).times(n).add(g.sqrt(g.sub(1,g.pow(n,2))))}throw new Error("Could not integrate due to no input being a variable")}function Zc(e,t){if(F(t))return t.invert(o.cos(e));throw new Error("Could not invert due to no input being a variable")}function Yc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.acos(n).times(n).sub(g.sqrt(g.sub(1,g.pow(n,2))))}throw new Error("Could not integrate due to no input being a variable")}function Xc(e,t){if(F(t))return t.invert(o.tan(e));throw new Error("Could not invert due to no input being a variable")}function Jc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.atan(n).times(n).sub(g.ln(g.pow(n,2).add(1)).div(2))}throw new Error("Could not integrate due to no input being a variable")}function Kc(e,t){if(F(t))return t.invert(o.asinh(e));throw new Error("Could not invert due to no input being a variable")}function Qc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.cosh(n)}throw new Error("Could not integrate due to no input being a variable")}function ed(e,t){if(F(t))return t.invert(o.acosh(e));throw new Error("Could not invert due to no input being a variable")}function td(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.sinh(n)}throw new Error("Could not integrate due to no input being a variable")}function nd(e,t){if(F(t))return t.invert(o.atanh(e));throw new Error("Could not invert due to no input being a variable")}function id(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.cosh(n).ln()}throw new Error("Could not integrate due to no input being a variable")}function rd(e,t){if(F(t))return t.invert(o.sinh(e));throw new Error("Could not invert due to no input being a variable")}function ad(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.asinh(n).times(n).sub(g.pow(n,2).add(1).sqrt())}throw new Error("Could not integrate due to no input being a variable")}function sd(e,t){if(F(t))return t.invert(o.cosh(e));throw new Error("Could not invert due to no input being a variable")}function od(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.acosh(n).times(n).sub(g.add(n,1).sqrt().times(g.sub(n,1).sqrt()))}throw new Error("Could not integrate due to no input being a variable")}function ld(e,t){if(F(t))return t.invert(o.tanh(e));throw new Error("Could not invert due to no input being a variable")}function ud(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.atanh(n).times(n).add(g.sub(1,g.pow(n,2)).ln().div(2))}throw new Error("Could not integrate due to no input being a variable")}function On(e){return(t,n)=>new g({inputs:[t,n],evaluate:e,invert:Un})}function F(e){return e instanceof Pe&&e.hasVariable()}function Ce(e,t){return e instanceof Pe?e.evaluate(t):s(e)}function cd(){return g.pow(this,2).div(2)}function dd(){return this}const Be=class{constructor(e){this.negate=this.neg,this.negated=this.neg,this.sgn=this.sign,this.plus=this.add,this.subtract=this.sub,this.minus=this.sub,this.multiply=this.mul,this.times=this.mul,this.divide=this.div,this.divideBy=this.div,this.dividedBy=this.div,this.reciprocal=this.recip,this.reciprocate=this.recip,this.logarithm=this.log;let t;"inputs"in e&&(e.inputs=e.inputs.map(n=>typeof n=="object"&&At in n?n[At]:n)),"variable"in e?(typeof e.variable=="object"&&At in e.variable&&(e.variable=e.variable[At]),t=this.setupVariable(e)):"evaluate"in e?t=this.setupFormula(e):t=this.setupConstant(e),this.inputs=t.inputs,this.internalVariables=t.internalVariables,this.innermostVariable=t.innermostVariable,this.internalEvaluate=t.internalEvaluate,this.internalInvert=t.internalInvert,this.internalIntegrate=t.internalIntegrate,this.internalIntegrateInner=t.internalIntegrateInner,this.applySubstitution=t.applySubstitution}setupVariable({variable:e}){return{inputs:[e],internalVariables:1,innermostVariable:e,internalIntegrate:cd,internalIntegrateInner:dd,applySubstitution:Un}}setupConstant({inputs:e}){if(e.length!==1)throw new Error("Evaluate function is required if inputs is not length 1");return{inputs:e,internalVariables:0}}setupFormula(e){var m,v;const{inputs:t,evaluate:n,invert:i,integrate:r,integrateInner:a,applySubstitution:l}=e,u=t.reduce((C,y)=>C+(y instanceof Be?y.internalVariables:0),0),c=t.find(C=>C instanceof Be&&C.hasVariable()),d=u===1?c==null?void 0:c.innermostVariable:void 0,h=(m=c==null?void 0:c.isInvertible())!=null?m:!1,p=(v=c==null?void 0:c.isIntegrable())!=null?v:!1;return{inputs:t,internalEvaluate:n,internalInvert:h?i:void 0,internalIntegrate:p?r:void 0,internalIntegrateInner:a,applySubstitution:l,innermostVariable:d,internalVariables:u}}isInvertible(){return this.hasVariable()&&(this.internalInvert!=null||this.internalEvaluate==null)}isIntegrable(){return this.hasVariable()&&this.internalIntegrate!=null}isIntegralInvertible(){return this.isIntegrable()?this.getIntegralFormula().isInvertible():!1}hasVariable(){return this.internalVariables===1}evaluate(e){var t,n,i;return(i=(n=(t=this.internalEvaluate)==null?void 0:t.call(this,...this.inputs.map(r=>Ce(r,e))))!=null?n:this.hasVariable()?e:null)!=null?i:Ce(this.inputs[0])}equals(e){return this.inputs.length===e.inputs.length&&this.inputs.every((t,n)=>t instanceof Be&&e.inputs[n]instanceof Be?t.equals(e.inputs[n]):!(t instanceof Be)&&!(e.inputs[n]instanceof Be)&&o.eq(s(t),s(e.inputs[n])))&&this.internalEvaluate===e.internalEvaluate&&this.internalInvert===e.internalInvert&&this.internalIntegrate===e.internalIntegrate&&this.internalVariables===e.internalVariables}static constant(e){return new g({inputs:[e]})}static variable(e){return new g({variable:e})}static step(e,t,n){const i=n(g.variable(0)),r=ve(t);function a(u){return o.lt(u,s(r))?u:o.add(i.evaluate(o.sub(u,s(r))),s(r))}function l(u,c){if(F(c)&&i.isInvertible())return o.gt(u,s(r))&&(u=o.add(i.invert(o.sub(u,s(r))),s(r))),c.invert(u);throw new Error("Could not invert due to no input being a variable")}return new g({inputs:[e],evaluate:a,invert:i.isInvertible()&&i.hasVariable()?l:void 0})}static if(e,t,n,i){const r=z(0),a=g.variable(r),l=n(a),u=i==null?void 0:i(a),c=ve(t);function d(p){return s(c)?(r.value=p,l.evaluate()):u?(r.value=p,u.evaluate()):p}function h(p,m){if(!F(m)||!l.isInvertible()||u!=null&&!u.isInvertible())throw new Error("Could not invert due to no input being a variable");return s(c)?m.invert(l.invert(p)):u?m.invert(u.invert(p)):m.invert(p)}return new g({inputs:[e],evaluate:d,invert:l.isInvertible()&&l.hasVariable()?h:void 0})}static conditional(e,t,n,i){return g.if(e,t,n,i)}static abs(e){return new g({inputs:[e],evaluate:o.abs})}static neg(e){return new g({inputs:[e],evaluate:o.neg,invert:Vu,applySubstitution:Lu,integrate:Bu})}static sign(e){return new g({inputs:[e],evaluate:o.sign})}static round(e){return new g({inputs:[e],evaluate:o.round})}static floor(e){return new g({inputs:[e],evaluate:o.floor})}static ceil(e){return new g({inputs:[e],evaluate:o.ceil})}static trunc(e){return new g({inputs:[e],evaluate:o.trunc})}static add(e,t){return new g({inputs:[e,t],evaluate:o.add,invert:ju,integrate:zu,integrateInner:Uu,applySubstitution:Un})}static sub(e,t){return new g({inputs:[e,t],evaluate:o.sub,invert:Gu,integrate:Wu,integrateInner:Hu,applySubstitution:Un})}static mul(e,t){return new g({inputs:[e,t],evaluate:o.mul,invert:Zu,integrate:Yu,applySubstitution:Xu})}static div(e,t){return new g({inputs:[e,t],evaluate:o.div,invert:Ju,integrate:Ku,applySubstitution:Qu})}static recip(e){return new g({inputs:[e],evaluate:o.recip,invert:ec,integrate:tc})}static clamp(e,t,n){return new g({inputs:[e,t,n],evaluate:o.clamp,invert:Un})}static pLog10(e){return new g({inputs:[e],evaluate:o.pLog10})}static absLog10(e){return new g({inputs:[e],evaluate:o.absLog10})}static log10(e){return new g({inputs:[e],evaluate:o.log10,invert:nc,integrate:ac})}static log(e,t){return new g({inputs:[e,t],evaluate:o.log,invert:sc,integrate:uc})}static log2(e){return new g({inputs:[e],evaluate:o.log2,invert:cc,integrate:fc})}static ln(e){return new g({inputs:[e],evaluate:o.ln,invert:gc,integrate:hc})}static pow(e,t){return new g({inputs:[e,t],evaluate:o.pow,invert:bc,integrate:yc})}static pow10(e){return new g({inputs:[e],evaluate:o.pow10,invert:wc,integrate:_c})}static pow_base(e,t){return new g({inputs:[e,t],evaluate:o.pow_base,invert:Nc,integrate:Cc})}static root(e,t){return new g({inputs:[e,t],evaluate:o.root,invert:kc,integrate:Mc})}static factorial(e){return new g({inputs:[e],evaluate:o.factorial})}static gamma(e){return new g({inputs:[e],evaluate:o.gamma})}static lngamma(e){return new g({inputs:[e],evaluate:o.lngamma})}static exp(e){return new g({inputs:[e],evaluate:o.exp,invert:Sc,integrate:Ic})}static sqr(e){return g.pow(e,2)}static sqrt(e){return g.root(e,2)}static cube(e){return g.pow(e,3)}static cbrt(e){return g.root(e,3)}static tetrate(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){return new g({inputs:[e,t,n],evaluate:$c,invert:xc})}static iteratedexp(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){return new g({inputs:[e,t,n],evaluate:Ec,invert:Pc})}static iteratedlog(e,t=10,n=1){return new g({inputs:[e,t,n],evaluate:Dc})}static slog(e,t=10){return new g({inputs:[e,t],evaluate:Tc,invert:Ac})}static layeradd10(e,t){return new g({inputs:[e,t],evaluate:o.layeradd10})}static layeradd(e,t,n=10){return new g({inputs:[e,t,n],evaluate:Fc,invert:Rc})}static lambertw(e){return new g({inputs:[e],evaluate:o.lambertw,invert:Oc})}static ssqrt(e){return new g({inputs:[e],evaluate:o.ssqrt,invert:qc})}static pentate(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){return new g({inputs:[e,t,n],evaluate:Vc})}static sin(e){return new g({inputs:[e],evaluate:o.sin,invert:Wc,integrate:Lc})}static cos(e){return new g({inputs:[e],evaluate:o.cos,invert:Zc,integrate:zc})}static tan(e){return new g({inputs:[e],evaluate:o.tan,invert:Xc,integrate:Gc})}static asin(e){return new g({inputs:[e],evaluate:o.asin,invert:Bc,integrate:Hc})}static acos(e){return new g({inputs:[e],evaluate:o.acos,invert:jc,integrate:Yc})}static atan(e){return new g({inputs:[e],evaluate:o.atan,invert:Uc,integrate:Jc})}static sinh(e){return new g({inputs:[e],evaluate:o.sinh,invert:rd,integrate:Qc})}static cosh(e){return new g({inputs:[e],evaluate:o.cosh,invert:sd,integrate:td})}static tanh(e){return new g({inputs:[e],evaluate:o.tanh,invert:ld,integrate:id})}static asinh(e){return new g({inputs:[e],evaluate:o.asinh,invert:Kc,integrate:ad})}static acosh(e){return new g({inputs:[e],evaluate:o.acosh,invert:ed,integrate:od})}static atanh(e){return new g({inputs:[e],evaluate:o.atanh,invert:nd,integrate:ud})}step(e,t){return g.step(this,e,t)}if(e,t){return g.if(this,e,t)}conditional(e,t){return g.if(this,e,t)}abs(){return g.abs(this)}neg(){return g.neg(this)}sign(){return g.sign(this)}round(){return g.round(this)}floor(){return g.floor(this)}ceil(){return g.ceil(this)}trunc(){return g.trunc(this)}add(e){return g.add(this,e)}sub(e){return g.sub(this,e)}mul(e){return g.mul(this,e)}div(e){return g.div(this,e)}recip(){return g.recip(this)}max(e){return g.max(this,e)}min(e){return g.min(this,e)}maxabs(e){return g.maxabs(this,e)}minabs(e){return g.minabs(this,e)}clamp(e,t){return g.clamp(this,e,t)}clampMin(e){return g.clampMin(this,e)}clampMax(e){return g.clampMax(this,e)}pLog10(){return g.pLog10(this)}absLog10(){return g.absLog10(this)}log10(){return g.log10(this)}log(e){return g.log(this,e)}log2(){return g.log2(this)}ln(){return g.ln(this)}pow(e){return g.pow(this,e)}pow10(){return g.pow10(this)}pow_base(e){return g.pow_base(this,e)}root(e){return g.root(this,e)}factorial(){return g.factorial(this)}gamma(){return g.gamma(this)}lngamma(){return g.lngamma(this)}exp(){return g.exp(this)}sqr(){return g.pow(this,2)}sqrt(){return g.root(this,2)}cube(){return g.pow(this,3)}cbrt(){return g.root(this,3)}tetrate(e=2,t=o.fromComponents_noNormalize(1,0,1)){return g.tetrate(this,e,t)}iteratedexp(e=2,t=o.fromComponents_noNormalize(1,0,1)){return g.iteratedexp(this,e,t)}iteratedlog(e=10,t=1){return g.iteratedlog(this,e,t)}slog(e=10){return g.slog(this,e)}layeradd10(e){return g.layeradd10(this,e)}layeradd(e,t){return g.layeradd(this,e,t)}lambertw(){return g.lambertw(this)}ssqrt(){return g.ssqrt(this)}pentate(e=2,t=o.fromComponents_noNormalize(1,0,1)){return g.pentate(this,e,t)}sin(){return g.sin(this)}cos(){return g.cos(this)}tan(){return g.tan(this)}asin(){return g.asin(this)}acos(){return g.acos(this)}atan(){return g.atan(this)}sinh(){return g.sinh(this)}cosh(){return g.cosh(this)}tanh(){return g.tanh(this)}asinh(){return g.asinh(this)}acosh(){return g.acosh(this)}atanh(){return g.atanh(this)}};let Pe=Be;Pe.negate=Be.neg;Pe.negated=Be.neg;Pe.sgn=Be.sign;Pe.plus=Be.add;Pe.subtract=Be.sub;Pe.minus=Be.sub;Pe.multiply=Be.mul;Pe.times=Be.mul;Pe.divide=Be.div;Pe.divideBy=Be.div;Pe.dividedBy=Be.div;Pe.reciprocal=Be.recip;Pe.reciprocate=Be.recip;Pe.max=On(o.max);Pe.min=On(o.min);Pe.minabs=On(o.minabs);Pe.maxabs=On(o.maxabs);Pe.clampMin=On(o.clampMin);Pe.clampMax=On(o.clampMax);Pe.logarithm=Be.log;class g extends Pe{invert(t){if(this.internalInvert&&this.hasVariable())return this.internalInvert.call(this,t,...this.inputs);if(this.inputs.length===1&&this.hasVariable())return t;throw new Error("Cannot invert non-invertible formula")}evaluateIntegral(t){if(!this.isIntegrable())throw new Error("Cannot evaluate integral of formula without integral");return this.getIntegralFormula().evaluate(t)}invertIntegral(t){if(!this.isIntegrable()||!this.getIntegralFormula().isInvertible())throw new Error("Cannot invert integral of formula without invertible integral");return this.getIntegralFormula().invert(t)}calculateConstantOfIntegration(){const t=this.getIntegralFormula().evaluate(1),n=o.add(this.evaluate(0),this.evaluate(1)).div(2);return o.sub(n,t)}getIntegralFormula(t){if(this.integralFormula!=null&&t==null)return this.integralFormula;if(t==null){if(this.applySubstitution==null){if(t=[],this.internalIntegrate==null)throw new Error("Cannot integrate formula with non-integrable operation");let n=this.internalIntegrate.call(this,t,...this.inputs);t.forEach(i=>n=i(n)),this.integralFormula=n}else if(this.internalIntegrate)this.integralFormula=this.internalIntegrate.call(this,void 0,...this.inputs);else if(this.inputs.length===1&&this.internalEvaluate==null&&this.hasVariable())this.integralFormula=this;else throw new Error("Cannot integrate formula without variable");return this.integralFormula}else{if(this.applySubstitution==null)throw new Error("Cannot have two complex operations in an integrable formula");if(t.push(n=>this.applySubstitution.call(this,n,...this.inputs)),this.internalIntegrateInner)return this.internalIntegrateInner.call(this,t,...this.inputs);if(this.internalIntegrate)return this.internalIntegrate.call(this,t,...this.inputs);if(this.inputs.length===1&&this.internalEvaluate==null&&this.hasVariable())return this;throw new Error("Cannot integrate formula without variable")}}}function Yr(e,t,n=!0,i,r=o.dInf){const a=ve(n),l=ve(i),u=ve(r);return _(()=>{var m,v,C,y;const c=s(u);if(o.eq(c,1))return o.gte(t.value,e.evaluate())?o.dOne:o.dZero;const d=s(a),h=(m=s(l))!=null?m:d?10:0;let p=0;if(o.gt(c,h)){if(!e.isInvertible())throw new Error("Cannot calculate max affordable of non-invertible formula with more maxBulkAmount than directSum");if(d){if(!e.isIntegralInvertible())throw new Error("Cannot calculate max affordable of formula with non-invertible integral");p=o.floor(e.invertIntegral(o.add(t.value,e.evaluateIntegral()))).sub((v=s(e.innermostVariable))!=null?v:0)}else p=o.floor(e.invert(t.value))}if(p=o.clampMax(p,c),h>0){p=o.sub(p,h).clampMin(0);let I;for(d?I=Tn(e,p,!0,0):I=e.evaluate(o.add((C=s(e.innermostVariable))!=null?C:0,p));o.lt(p,c)&&o.lt(p,Number.MAX_SAFE_INTEGER);){const A=e.evaluate(p.add((y=s(e.innermostVariable))!=null?y:0));if(o.add(I,A).lte(t.value))p=p.add(1),I=o.add(I,A);else break}}return p})}function Tn(e,t,n=!0,i){var c;if(o.eq(t,1))return e.evaluate();const r=(c=s(e.innermostVariable))!=null?c:0;let a=o.add(t,r);const l=a;i!=null||(i=n?10:0),a=a.sub(i).clampMin(r);let u=0;if(o.gt(t,i)){if(!e.isInvertible())throw new Error("Cannot calculate cost with indirect sum of non-invertible formula");if(n){if(!e.isIntegrable())throw new Error("Cannot calculate cost with cumulative cost of non-integrable formula");if(u=o.sub(e.evaluateIntegral(a),e.evaluateIntegral()),l.gt(1e308))return o.add(u,o.sub(l,a).times(e.evaluate(a)))}else if(u=e.evaluate(a),a=a.add(1),l.gt(1e308))return o.sub(l,a).add(1).times(u)}for(let d=a.toNumber();d<l.toNumber();d++)u=o.add(u,e.evaluate(d));return u}function zt(e){return Ke(t=>{const{addend:n,description:i,enabled:r,smallerIsBetter:a}=e.call(t,t),l=ve(n),u=ve(i),c=r==null?void 0:ve(r);return{apply:d=>o.add(d,s(l)),invert:d=>o.sub(d,s(l)),getFormula:d=>g.add(d,l),enabled:c,description:i==null?void 0:X(()=>f("div",{class:"modifier-container"},[s(u)!=null?f("span",{class:"modifier-description"},[St(s(u))]):null,f("span",{class:"modifier-amount",style:(a===!0?o.gt(s(l),0):o.lt(s(l),0))?"color: var(--danger)":""},[o.gte(s(l),0)?"+":"",Ut(s(l))])]))}})}function ke(e){return Ke(t=>{const{multiplier:n,description:i,enabled:r,smallerIsBetter:a}=e.call(t,t),l=ve(n),u=ve(i),c=r==null?void 0:ve(r);return{apply:d=>o.times(d,s(l)),invert:d=>o.div(d,s(l)),getFormula:d=>g.times(d,l),enabled:c,description:i==null?void 0:X(()=>f("div",{class:"modifier-container"},[s(u)!=null?f("span",{class:"modifier-description"},[St(s(u))]):null,f("span",{class:"modifier-amount",style:(a===!0?o.gt(s(l),1):o.lt(s(l),1))?"color: var(--danger)":""},[E("\xD7"),Ut(s(l))])]))}})}function Fi(e){return Ke(t=>{const{exponent:n,description:i,enabled:r,supportLowNumbers:a,smallerIsBetter:l}=e.call(t,t),u=ve(n),c=ve(i),d=r==null?void 0:ve(r);return{apply:h=>{let p=h;return a&&(p=o.add(p,1)),p=o.pow(p,s(u)),a&&(p=o.sub(p,1)),p},invert:h=>{let p=h;return a&&(p=o.add(p,1)),p=o.root(p,s(u)),a&&(p=o.sub(p,1)),p},getFormula:h=>a?g.add(h,1).pow(u).sub(1):g.pow(h,u),enabled:d,description:i==null?void 0:X(()=>f("div",{class:"modifier-container"},[s(c)!=null?f("span",{class:"modifier-description"},[St(s(c)),a?" (+1 effective)":null]):null,f("span",{class:"modifier-amount",style:(l===!0?o.gt(s(u),1):o.lt(s(u),1))?"color: var(--danger)":""},[E("^"),Ut(s(u))])]))}})}function Ct(e){return Ke(()=>{const t=e();return{apply:n=>t.filter(i=>s(i.enabled)!==!1).reduce((i,r)=>r.apply(i),n),invert:t.every(n=>n.invert!=null)?n=>t.filter(i=>s(i.enabled)!==!1).reduceRight((i,r)=>r.invert(i),n):void 0,getFormula:t.every(n=>n.getFormula!=null)?n=>t.filter(i=>s(i.enabled)!==!1).reduce((i,r)=>r.getFormula(i),n):void 0,enabled:t.some(n=>n.enabled!=null)?_(()=>t.filter(n=>s(n.enabled)!==!1).length>0):void 0,description:t.some(n=>n.description!=null)?X(()=>f(ee,null,[t.filter(n=>s(n.enabled)!==!1).map(n=>s(n.description)).filter(n=>n).map(St)])):void 0}})}const ji=g.variable(0).step(100,e=>e.pow(1.5)).step(o.pow(900,1.5).add(100),e=>e.pow(1.5)).pow(1.5),un={id:"deselect",icon:"close",tooltip:e=>({text:"portals"in e.state?"Disconnect portals":"tools"in e.state?"Disconnect tools":"Disconnect resources"}),onClick(e){var t;Array.isArray((t=e.state)==null?void 0:t.data)?e.state={...e.state,data:[]}:"portals"in e.state?e.state={...e.state,portals:[]}:"resources"in e.state?e.state={...e.state,resources:[]}:"tools"in e.state&&(e.state={...e.state,tools:[]}),w.board.selectedAction.value=null,w.board.selectedNode.value=null},visibility:e=>{var t;return Array.isArray((t=e.state)==null?void 0:t.data)?e.state.data.length>0:"portals"in e.state?e.state.portals.length>0:"resources"in e.state?e.state.resources.length>0:"tools"in e.state?e.state.tools.length>0:!1}},Ot={id:"toggle",icon:"bolt",tooltip:e=>({text:e.state.powered?"Turn Off":`Turn On - Always runs for ${dt(w.nextPowerCost.value)} energy/s`}),onClick(e){e.state={...e.state,powered:!e.state.powered},w.board.selectedAction.value=null},fillColor:e=>e.state.powered?"var(--accent1)":"var(--locked)"};function Cn(e,t=1/0){const n=e(g.variable(0));return{id:"moreConnections",icon:"hub",formula:n,tooltip(i){return{text:`Increase Connections - ${dt(n.evaluate(i.state.maxConnections))} energy`}},confirmationLabel:i=>o.gte(w.energy.value,n.evaluate(i.state.maxConnections))?{text:"Tap again to confirm"}:{text:"Cannot afford",color:"var(--danger)"},onClick(i){const r=n.evaluate(i.state.maxConnections);o.gte(w.energy.value,r)&&(w.energy.value=o.sub(w.energy.value,r)),i.state={...i.state,maxConnections:o.add(i.state.maxConnections,1)},w.board.selectedAction.value=null},visibility:i=>o.add(i.state.maxConnections,w.computedBonusConnectionsModifier.value).lt(t)}}function Xr(e,t){var n,i;if(((n=w.board.draggingNode.value)==null?void 0:n.type)==="resource"){const r=((i=w.board.draggingNode.value)==null?void 0:i.state).type,{maxConnections:a,resources:l}=e.state;return l.includes(r)?{text:"Disconnect",color:"var(--accent2)"}:o.add(a,w.computedBonusConnectionsModifier.value).lte(l.length)?{text:"Max connections",color:"var(--danger)"}:{text:t(r),color:"var(--accent2)"}}return null}function pd(e,t){var n,i;if(((n=w.board.draggingNode.value)==null?void 0:n.type)==="passive"){const r=(i=w.board.draggingNode.value)==null?void 0:i.state,{maxConnections:a,tools:l}=e.state;return l.includes(r)?{text:"Disconnect",color:"var(--accent2)"}:o.add(a,w.computedBonusConnectionsModifier.value).lte(l.length)?{text:"Max connections",color:"var(--danger)"}:{text:t(r),color:"var(--accent2)"}}return null}function wi(e,t){var n,i;if(((n=w.board.draggingNode.value)==null?void 0:n.type)==="portal"){const r=((i=w.board.draggingNode.value)==null?void 0:i.state).id,{maxConnections:a,portals:l}=e.state;return l.includes(r)?{text:"Disconnect",color:"var(--accent2)"}:o.add(a,w.computedBonusConnectionsModifier.value).lte(l.length)?{text:"Max connections",color:"var(--danger)"}:{text:t(r),color:"var(--accent2)"}}return null}function Jr(e,t){if(t.type!=="resource")return!1;const n=t.state.type,{maxConnections:i,resources:r}=e.state;return r.includes(n)?!0:!o.add(i,w.computedBonusConnectionsModifier.value).lte(r.length)}function Kr(e,t){if(t.type!=="resource")return;const n=t.state.type,i=e.state.resources;i.includes(n)?e.state={...e.state,resources:i.filter(r=>r!==n)}:e.state={...e.state,resources:[...i,n]},w.board.selectedNode.value=e}function fd(e,t){if(t.type!=="passive")return!1;const n=t.state,{maxConnections:i,tools:r}=e.state;return r.includes(n)?!0:!o.add(i,w.computedBonusConnectionsModifier.value).lte(r.length)}function gd(e,t){if(t.type!=="passive")return;const n=t.state,i=e.state.tools;i.includes(n)?e.state={...e.state,tools:i.filter(r=>r!==n)}:e.state={...e.state,tools:[...i,n]},w.board.selectedNode.value=e}function _i(e,t){if(t.type!=="portal")return!1;const n=t.state.id,{maxConnections:i,portals:r}=e.state;return r.includes(n)?!0:!o.add(i,w.computedBonusConnectionsModifier.value).lte(r.length)}function Ni(e,t){if(t.type!=="portal")return;const n=t.state.id,{portals:i}=e.state;i.includes(n)?e.state={...e.state,portals:i.filter(r=>r!==n)}:e.state={...e.state,portals:[...i,n]},w.board.selectedNode.value=e}function ye(e){return e===w.board.selectedNode.value||e.state.powered}function be(e){return w.empowerer.value!=null&&ye(w.empowerer.value)&&w.empowerer.value.state.tools.includes(e)}function md(e){var a,l,u;const t=(u=(l=(a=w.resourceNodes.value[e])==null?void 0:a.state)==null?void 0:l.amount)!=null?u:0,n=w.resourceLevels.value[e],i=ji.evaluate(n),r=ji.evaluate(o.add(n,1));return o.sub(t,i).max(0).div(o.sub(r,i)).toNumber()}function pn(e,t,n){if(t.value){const i=t.value.state,r=i[n],a=i.maxConnections;o.gt(r.length,o.add(a,e))&&(t.value.state={...t.value.state,[n]:r.slice(0,o.add(a,e).toNumber())})}}const vd={key:0},hd={key:0,class:"mark star"},bd=["src"],yd=Y({__name:"MarkNode",props:{mark:{type:[Boolean,String]}},setup(e){return(t,n)=>e.mark?(M(),T("div",vd,[e.mark===!0?(M(),T("div",hd)):(M(),T("img",{key:1,class:"mark",src:e.mark},null,8,bd))])):j("",!0)}});var Qn=pe(yd,[["__scopeId","data-v-2207999f"]]);const wd=Y({__name:"Node",props:{id:null},setup(e){const n=Fe(e),i=di(Wi,()=>{}),r=di(Hi,()=>{}),a=ht(null),l=_(()=>a.value&&a.value.parentElement);return vt([l,n.id],([u,c],[d,h])=>{d&&r(s(h)),u&&i(c,u)}),kr(()=>r(s(n.id))),(u,c)=>(M(),T("div",{class:"node",ref_key:"node",ref:a},null,512))}});var ei=pe(wd,[["__scopeId","data-v-a48cb382"]]),_d=Y({props:{display:{type:O(Object,String,Function),required:!0},visibility:{type:O(Number,Boolean),required:!0},style:O(Object,String,Array),classes:O(Object),onClick:Function,onHold:Function,canClick:{type:O(Boolean),required:!0},small:Boolean,mark:O(Boolean,String),id:{type:String,required:!0}},components:{Node:ei,MarkNode:Qn},setup(e){const{display:t,onClick:n,onHold:i}=Fe(e),r=ht("");Et(()=>{var h;const u=Ee(t);if(u==null){r.value="";return}if(Pt(u)){r.value=ue(u);return}const c=ue((h=u.title)!=null?h:"","h3"),d=ue(u.description,"div");r.value=ue(X(()=>f("span",null,[u.title!=null?f("div",null,[f(c,null,null)]):null,f(d,null,null)])))});const{start:a,stop:l}=Rr(n,i);return{start:a,stop:l,comp:r,Visibility:Ne,isVisible:Ue,isHidden:_n,unref:s}}});function Nd(e,t,n,i,r,a){var c;const l=It("MarkNode"),u=It("Node");return e.isVisible(e.visibility)?(M(),T("button",{key:0,style:je([{visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:[]]),onClick:t[0]||(t[0]=(...d)=>e.onClick&&e.onClick(...d)),onMousedown:t[1]||(t[1]=(...d)=>e.start&&e.start(...d)),onMouseleave:t[2]||(t[2]=(...d)=>e.stop&&e.stop(...d)),onMouseup:t[3]||(t[3]=(...d)=>e.stop&&e.stop(...d)),onTouchstartPassive:t[4]||(t[4]=(...d)=>e.start&&e.start(...d)),onTouchendPassive:t[5]||(t[5]=(...d)=>e.stop&&e.stop(...d)),onTouchcancelPassive:t[6]||(t[6]=(...d)=>e.stop&&e.stop(...d)),class:he({feature:!0,clickable:!0,can:e.unref(e.canClick),locked:!e.unref(e.canClick),small:e.small,...e.unref(e.classes)})},[e.unref(e.comp)?(M(),K(Xe(e.unref(e.comp)),{key:0})):j("",!0),f(l,{mark:e.unref(e.mark)},null,8,["mark"]),f(u,{id:e.id},null,8,["id"])],38)):j("",!0)}var Qr=pe(_d,[["render",Nd],["__scopeId","data-v-211328c0"]]);const ea=Symbol("Clickable");function Cd(e,...t){const n=t.reduce((i,r)=>{var a;return Object.assign(i,(a=r.getPersistentData)==null?void 0:a.call(r))},{});return Ke(i=>{var l,u,c;const r=(l=e==null?void 0:e.call(i,i))!=null?l:{};r.id=ln("clickable-"),r.type=ea,r[yt]=Qr;for(const d of t)(u=d.preConstruct)==null||u.call(d,r);if(Object.assign(r,n),$(r,"visibility"),ne(r,"visibility",Ne.Visible),$(r,"canClick"),ne(r,"canClick",!0),$(r,"classes"),$(r,"style"),$(r,"mark"),$(r,"display"),r.onClick){const d=r.onClick.bind(r);r.onClick=function(h){s(r.canClick)!==!1&&d(h)}}if(r.onHold){const d=r.onHold.bind(r);r.onHold=function(){s(r.canClick)!==!1&&d()}}for(const d of t)(c=d.postConstruct)==null||c.call(d,r);const a=t.reduce((d,h)=>{var p;return Object.assign(d,(p=h.getGatheredProps)==null?void 0:p.call(h,r))},{});return r[pt]=function(){const{display:d,visibility:h,style:p,classes:m,onClick:v,onHold:C,canClick:y,small:I,mark:A,id:S}=this;return{display:d,visibility:h,style:s(p),classes:m,onClick:v,onHold:C,canClick:y,small:I,mark:A,id:S,...a}},r})}function kd(e,t,n=[]){n=n.length===0?Xn(e,ea):n;const i=typeof t=="function"?_(t):t;return e.on("update",()=>{s(i)&&n.filter(r=>s(r.canClick)).forEach(r=>{var a;return(a=r.onClick)==null?void 0:a.call(r)})})}const Md=["x1","y1","x2","y2"],Sd=Y({__name:"Link",props:{link:null,startNode:null,endNode:null,boundingRect:null},setup(e){const n=Fe(e),i=_(()=>{const a=n.startNode.value.rect,l=n.boundingRect.value,u=l?{x:a.x+a.width/2-l.x,y:a.y+a.height/2-l.y}:{x:0,y:0};return n.link.value.offsetStart&&(u.x+=n.link.value.offsetStart.x,u.y+=n.link.value.offsetStart.y),u}),r=_(()=>{const a=n.endNode.value.rect,l=n.boundingRect.value,u=l?{x:a.x+a.width/2-l.x,y:a.y+a.height/2-l.y}:{x:0,y:0};return n.link.value.offsetEnd&&(u.x+=n.link.value.offsetEnd.x,u.y+=n.link.value.offsetEnd.y),u});return(a,l)=>(M(),T("line",Wt({"stroke-width":"15px",stroke:"white"},e.link,{x1:s(i).x,y1:s(i).y,x2:s(r).x,y2:s(r).y}),null,16,Md))}});const Id=Y({__name:"Links",props:{links:null},setup(e){var c;const n=sn(e,"links"),i=z(null),r=di(Zi,z({})),a=di(Yi,z(void 0)),l=z((c=i.value)==null?void 0:c.getBoundingClientRect());vt(a,()=>{var d;return l.value=(d=i.value)==null?void 0:d.getBoundingClientRect()}),hi(()=>{var d;return l.value=(d=i.value)==null?void 0:d.getBoundingClientRect()});const u=_(()=>{var h,p;const d=r.value;return(p=(h=n.value)==null?void 0:h.filter(m=>{var v,C;return((v=d[m.startNode.id])==null?void 0:v.rect)&&((C=d[m.startNode.id])==null?void 0:C.rect)}))!=null?p:[]});return(d,h)=>(M(),T(ee,null,[s(u)?(M(),T("svg",_a(Wt({key:0},d.$attrs)),[(M(!0),T(ee,null,Fn(s(u),(p,m)=>(M(),K(Sd,{key:m,link:p,boundingRect:l.value,startNode:s(r)[p.startNode.id],endNode:s(r)[p.endNode.id]},null,8,["link","boundingRect","startNode","endNode"]))),128))],16)):j("",!0),N("div",{ref_key:"resizeListener",ref:i,class:"resize-listener"},null,512)],64))}});var $d=pe(Id,[["__scopeId","data-v-063f6d6b"]]);Y({props:{nodes:{type:O(Array),required:!0},leftSideNodes:O(Array),rightSideNodes:O(Array),branches:O(Array)},components:{Links:$d},setup(e){const{nodes:t,leftSideNodes:n,rightSideNodes:i}=Fe(e),r=ht();Et(()=>{const u=Ee(t);r.value=ue(X(()=>f(ee,null,[u.map(c=>f("span",{class:"row tree-row",style:"margin: 50px auto;"},[c.map(St)]))])))});const a=ht();Et(()=>{const u=Ee(n);a.value=u?ue(X(()=>f("span",{class:"left-side-nodes small"},[u.map(St)]))):""});const l=ht();return Et(()=>{const u=Ee(i);l.value=u?ue(X(()=>f("span",{class:"side-nodes small"},[u.map(St)]))):""}),{unref:s,nodesComp:r,leftNodesComp:a,rightNodesComp:l}}});Y({props:{display:O(Object,String,Function),visibility:{type:O(Number,Boolean),required:!0},style:O(String,Object,Array),classes:O(Object),onClick:Function,onHold:Function,color:O(String),glowColor:O(String),canClick:{type:O(Boolean),required:!0},mark:O(Boolean,String),id:{type:String,required:!0}},components:{MarkNode:Qn,Node:ei},setup(e){const{onClick:t,onHold:n,display:i}=Fe(e),r=Rn(i),{start:a,stop:l}=Rr(t,n);return{start:a,stop:l,comp:r,unref:s,Visibility:Ne,isCoercableComponent:Pt,isVisible:Ue,isHidden:_n}}});function Gn(e){const t=[],n={};let i=!1;function r(){return i||(t.push(...e()),n.base=t.map(u=>ve(u.base)),n.baseText=t.map(u=>ve(u.baseText)),n.visible=t.map(u=>ve(u.visible)),n.title=t.map(u=>ve(u.title)),n.subtitle=t.map(u=>ve(u.subtitle)),i=!0),t}const a=ct({},!1);return[X(()=>{const u=r();let c=!0;const d=u.map((h,p)=>{var A,S,P;if(s(n.visible[p])===!1)return null;const m=f("h3",{onClick:()=>a.value[p]=!a.value[p],style:"cursor: pointer"},[f("span",{class:"modifier-toggle"+(s(a.value[p])?" collapsed":"")},[E("\u25BC")]),s(n.title[p]),s(n.subtitle[p])!=null?f("span",{class:"subtitle"},[E(" ("),s(n.subtitle[p]),E(")")]):null]),v=s(a.value[p])?null:f(ee,null,[f("div",{class:"modifier-container"},[f("span",{class:"modifier-description"},[St((A=s(n.baseText[p]))!=null?A:"Base")]),f("span",{class:"modifier-amount"},[_e((S=s(n.base[p]))!=null?S:1),h.unit])]),h.modifier.description==null?null:St(s(h.modifier.description))]),C=!c;c=!1;const y=(P=s(n.base[p]))!=null?P:1,I=h.modifier.apply(y);return f(ee,null,[C?f("br",null,null):null,f("div",{style:{"--unit":se.alignUnits&&h.unit!=null?"'"+h.unit+"'":""}},[m,f("br",null,null),v,f("hr",null,null),f("div",{class:"modifier-container"},[f("span",{class:"modifier-description"},[E("Total")]),f("span",{class:"modifier-amount",style:(h.smallerIsBetter===!0?o.gt(I,y!=null?y:1):o.lt(I,y!=null?y:1))?"color: var(--danger)":""},[Ut(I),h.unit])])])])});return f(ee,null,[d])}),a]}function Ri(e,t,n){const i=ve(t),r=ve(n);return _(()=>{const a=s(i),l=s(r);return o.gte(e.value,l)?"Now":o.lte(a,0)?"Never":yi(o.sub(l,e.value).div(a))})}function fn(e,t,n=1){const i=ve(t),r=ve(n);if(!e.hasVariable())throw new Error("Cannot create formula preview if the formula does not have a variable");return X(()=>{var a;if(s(i)){const l=Ut(e.evaluate()),u=Ut(e.evaluate(o.add(s((a=e.innermostVariable)!=null?a:0),s(r))));return f(ee,null,[f("b",null,[f("i",null,[l,E(" \u2192 "),u])])])}return f(ee,null,[Ut(e.evaluate())])})}const xt={dirt:120,sand:60,gravel:40,wood:30,stone:24,coal:20,copper:15,iron:12,silver:10,gold:8,emerald:6,platinum:5,diamond:4,berylium:3,unobtainium:2,ultimatum:1},en=Object.keys(xt),Le={dirt:{cost:1e3,name:"Pickaxe",type:"passive",state:"dirt"},sand:{cost:1e4,name:"Dowsing Rod",type:"dowsing",state:{resources:[],maxConnections:1,powered:!1}},gravel:{cost:1e5,name:"Ore Processor",type:"passive",state:"gravel"},wood:{cost:1e6,name:"Quarry",type:"quarry",state:{resources:[],maxConnections:1,powered:!1,progress:0}},stone:{cost:1e7,name:"Energizer",type:"passive",state:"stone"},coal:{cost:1e8,name:"Tool Empowerer",type:"empowerer",state:{tools:[],maxConnections:1,powered:!1}},copper:{cost:1e9,name:"Book",type:"passive",state:"copper"},iron:{cost:1e10,name:"Portal Generator",type:"portalGenerator",state:{tier:void 0,influences:[]}},silver:{cost:1e12,name:"Robotics",type:"passive",state:"silver"},gold:{cost:1e15,name:"Booster",type:"booster",state:{portals:[],maxConnections:1,powered:!1,level:1}},emerald:{cost:1e19,name:"Artificial Intelligence",type:"passive",state:"emerald"},platinum:{cost:1e24,name:"Upgrader",type:"upgrader",state:{portals:[],maxConnections:1,powered:!1}},diamond:{cost:1e30,name:"Machine Learning",type:"passive",state:"diamond"},berylium:{cost:1e37,name:"Automator",type:"automator",state:{portals:[],maxConnections:1,powered:!1}},unobtainium:{cost:1e45,name:"National Grid",type:"passive",state:"unobtainium"},ultimatum:{cost:1e54,name:"Investments",type:"investments",state:{portals:[],maxConnections:1,powered:!1}}},rn={dirt:"BOGO Coupon",sand:"Metal Detector",gravel:"Neural Networks",wood:"Mining Laser",stone:"Replicator",coal:"Planar Intelligence",copper:"Efficient Code",iron:"Trade Agreements",silver:"Machine Synergizer",gold:"XP Market",emerald:"Efficient Portals",platinum:"Time Dilation",diamond:"Paypal",berylium:"Tiered Mining",unobtainium:"Overclocked Portals",ultimatum:"Rebates"},xd={dirt:{description:e=>e?"Quadruples mining speed":"Doubles mining speed"},gravel:{description:e=>e?"Quadruples mine ore drops":"Doubles mine ore drops"},stone:{description:e=>e?"Quadruples energy gain":"Doubles energy gain"},copper:{description:e=>e?"Material level is 40% stronger":"Material level is 20% stronger"},silver:{description:e=>e?"Quadruples each plane's resource gain":"Doubles each plane's resource gain"},diamond:{description:e=>e?"+20% plane's resource gain per upgrade bought":"+10% plane's resource gain per upgrade bought"},emerald:{description:e=>e?"+2% plane's resource gain per minute active":"+1% plane's resource gain per minute active"},unobtainium:{description:e=>e?"+2 max connections per machine":"+1 max connections per machine"},dirtRelic:{description:e=>e?"2 free levels for repeatables":"1 free level for repeatables"},sandRelic:{description:e=>e?"Treasure's 2 tiers stronger":"Treasure's 1 tier stronger"},gravelRelic:{description:e=>e?"+2% plane's resource gain per repeatable purchase":"+1% plane's resource gain per repeatable purchase"},woodRelic:{description:e=>e?"(Relics)^2 boost mine speed":"Relics boost mine speed"},stoneRelic:{description:e=>e?"Upgrades apply thrice":"Upgrades apply twice"},coalRelic:{description:e=>e?"(Treasures)^2 boost planar speed":"Treasures boost planar speed"},copperRelic:{description:e=>e?"Power 2 machines free":"Power 1 machine free"},ironRelic:{description:e=>e?"Conversions give triple output":"Conversions give double output"},silverRelic:{description:e=>e?"(Power machines)^2 boost ore dropped":"Power machines boost ore dropped"},goldRelic:{description:e=>e?"Each treasure quadruples XP gain":"Each treasure doubles XP gain"},emeraldRelic:{description:e=>e?"Creating portals costs a third the energy":"Creating portals costs half the energy"},platinumRelic:{description:e=>e?"Triple dimensions' tick rate":"Double dimensions' tick rate"},diamondRelic:{description:e=>e?"Repeatables/dimensions buy max at once":"Repeatables buy max at once"},beryliumRelic:{description:e=>e?"ln(energy) boosts planar speed":"log(energy) boosts planar speed"},unobtainiumRelic:{description:e=>e?"Upgrades/repeatables/dimensions/prestige no longer spend on purchase":"Upgrades/repeatables no longer spend on purchase"}},kt={increaseResources:{display:"+resource",description:e=>{const t=e.data;return t.length===0?"Increase resource odds - Drag a resource to me!":t.length===1?`Increase ${t[0]}'s odds`:`Increase ${t.length} resources' odds`},cost:2,initialData:[]},decreaseResources:{display:"-resource",description:e=>{const t=e.data;return t.length===0?"Decrease resource odds - Drag a resource to me!":t.length===1?`Decrease ${t[0]}'s odds`:`Decrease ${t.length} resources' odds`},cost:2,initialData:[]},increaseLength:{display:"+length",description:"Increase length",cost:100,initialData:void 0},increaseCaches:{display:"+caches",description:"Increase caches odds",cost:10,initialData:void 0},increaseGens:{display:"+gens",description:"Increase generators odds",cost:10,initialData:void 0},increaseInfluences:{display:"+influences",description:"Increase influences odds",cost:10,initialData:void 0},increaseEnergyMults:{display:"+energy mults",description:"Increase energy mults odds",cost:10,initialData:void 0},increaseResourceMults:{display:"+resource mults",description:"Increase resource mults odds",cost:10,initialData:void 0},increaseDiff:{display:"+diff",description:"Increase difficulty/rewards odds",cost:10,initialData:void 0},decreaseDiff:{display:"-diff",description:"Decrease difficulty/rewards odds",cost:10,initialData:void 0},increaseRewards:{display:"+rewards",description:"Increase rewards level",cost:1e4,initialData:void 0},relic:{display:"+relic",description:"Max length/difficulty, add tier-unique relic",cost:1e6,initialData:void 0}},Oi=g.variable(0).add(8).times(2).pow10();const Ed=Y({__name:"Spacer",props:{width:{default:"8px"},height:{default:"17px"}},setup(e){return(t,n)=>(M(),T("div",{style:je({width:e.width,height:e.height})},null,4))}});function Bn(e){return Ke(t=>{var i;const n=e.call(t,t);return n.partialDisplay=r=>f("span",{style:s(n.requirementMet)?"":"color: var(--danger)"},[vi(n.resource,n.cost instanceof g?Tn(n.cost,r!=null?r:1,s(n.cumulativeCost),s(n.directSum)):s(n.cost))," ",n.resource.displayName]),n.display=r=>f("div",null,[s(n.requiresPay)?"Costs: ":"Requires: ",vi(n.resource,n.cost instanceof g?Tn(n.cost,r!=null?r:1,s(n.cumulativeCost),s(n.directSum)):s(n.cost))," ",n.resource.displayName]),$(n,"visibility"),ne(n,"visibility",Ne.Visible),$(n,"cost"),$(n,"requiresPay"),ne(n,"requiresPay",!0),$(n,"cumulativeCost"),ne(n,"cumulativeCost",!0),$(n,"maxBulkAmount"),ne(n,"maxBulkAmount",1),$(n,"directSum"),ne(n,"pay",function(r){const a=n.cost instanceof g?Tn(n.cost,r!=null?r:1,s(n.cumulativeCost),s(n.directSum)):s(n.cost);n.resource.value=o.sub(n.resource.value,a).max(0)}),n.canMaximize=_(()=>{var u;if(!(n.cost instanceof g))return!1;const r=s(n.maxBulkAmount);if(o.lte(r,1))return!1;const a=s(n.cumulativeCost),l=(u=s(n.directSum))!=null?u:a?10:0;return o.lte(r,l)?!0:!(!n.cost.isInvertible()||a===!0&&!n.cost.isIntegrable())}),n.cost instanceof g?n.requirementMet=Yr(n.cost,n.resource,(i=n.cumulativeCost)!=null?i:!0,n.directSum,n.maxBulkAmount):n.requirementMet=_(()=>o.gte(n.resource.value,s(n.cost))),n})}function er(e){return Ke(()=>({requirementMet:_(()=>Ue(e.visibility)),visibility:Ne.None,requiresPay:!1}))}function Pd(e,t){return Ke(()=>({requirementMet:ve(e),partialDisplay:t==null?void 0:X(()=>St(t)),display:t==null?void 0:X(()=>f(ee,null,[E("Req: "),St(t)])),visibility:t==null?Ne.None:Ne.Visible,requiresPay:!1}))}function Ci(e){if(Rt(e))return e.every(Ci);const t=s(e.requirementMet);return typeof t=="boolean"?t:o.gt(t,0)}function ta(e){if(Rt(e))return e.map(ta).reduce(o.min);const t=s(e.requirementMet);return typeof t=="boolean"?t?o.dInf:0:o.gt(t,1)&&s(e.canMaximize)!==!0?1:t}function ki(e,t=1){var n,i;if(Rt(e)&&(e=e.filter(r=>Ue(r.visibility)),e.length===1&&(e=e[0])),Rt(e)){e=e.filter(l=>"partialDisplay"in l);const r=e.filter(l=>s(l.requiresPay)),a=e.filter(l=>!s(l.requiresPay));return f(ee,null,[r.length>0?f("div",null,[E("Costs:")," ",mr(r.map(l=>l.partialDisplay(t)),f(ee,null,[E(", ")]))]):null,a.length>0?f("div",null,[E("Requires:")," ",mr(a.map(l=>l.partialDisplay(t)),f(ee,null,[E(", ")]))]):null])}return(i=(n=e.display)==null?void 0:n.call(e))!=null?i:f(ee,null,null)}function na(e,t=1){var n;Rt(e)?e.filter(i=>s(i.requiresPay)).forEach(i=>{var r;return(r=i.pay)==null?void 0:r.call(i,t)}):s(e.requiresPay)&&((n=e.pay)==null||n.call(e,t))}var Dd=Y({props:{visibility:{type:O(Number,Boolean),required:!0},display:O(Object,String,Function),earned:{type:O(Boolean),required:!0},requirements:O(Object,Array),image:O(String),style:O(String,Object,Array),classes:O(Object),mark:O(Boolean,String),small:O(Boolean),id:{type:String,required:!0}},components:{Node:ei,MarkNode:Qn},setup(e){const{display:t,requirements:n,earned:i}=Fe(e),r=ht("");return Et(()=>{const a=Ee(t);if(a==null){r.value="";return}if(Pt(a)){r.value=ue(a);return}const l=ue(a.requirement?a.requirement:X(()=>{var d;return ki((d=Ee(n))!=null?d:[])}),"h3"),u=ue(a.effectDisplay||"","b"),c=Ee(i)?ue(a.optionsDisplay||"","span"):"";r.value=ue(X(()=>f("span",null,[f(l,null,null),a.effectDisplay!=null?f("div",null,[f(u,null,null)]):null,a.optionsDisplay!=null?f("div",{class:"equal-spaced"},[f(c,null,null)]):null])))}),{comp:r,unref:s,Visibility:Ne,isVisible:Ue,isHidden:_n}}});function Td(e,t,n,i,r,a){var c;const l=It("MarkNode"),u=It("Node");return e.isVisible(e.visibility)?(M(),T("div",{key:0,style:je([{visibility:e.isHidden(e.visibility)?"hidden":void 0,backgroundImage:e.earned&&e.image&&`url(${e.image})`||""},(c=e.unref(e.style))!=null?c:[]]),class:he({feature:!0,achievement:!0,locked:!e.unref(e.earned),done:e.unref(e.earned),small:e.unref(e.small),...e.unref(e.classes)})},[e.comp?(M(),K(Xe(e.comp),{key:0})):j("",!0),f(l,{mark:e.unref(e.mark)},null,8,["mark"]),f(u,{id:e.id},null,8,["id"])],6)):j("",!0)}var Ad=pe(Dd,[["render",Td],["__scopeId","data-v-5673325a"]]);const Fd=bi(),Rd=Symbol("Achievement");let Pn=function(e){return e.All="all",e.Configurable="configurable",e.Incomplete="incomplete",e.None="none",e}({});function Od(e,...t){const n=ct(!1,!1),i=t.reduce((r,a)=>{var l;return Object.assign(r,(l=a.getPersistentData)==null?void 0:l.call(a))},{});return Ke(r=>{var c,d,h;const a=(c=e==null?void 0:e.call(r,r))!=null?c:{};a.id=ln("achievement-"),a.type=Rd,a[yt]=Ad;for(const p of t)(d=p.preConstruct)==null||d.call(p,a);a.earned=n,a.complete=function(){var m,v;n.value=!0;const p=a;if((m=p.onComplete)==null||m.call(p),p.display!=null&&s(p.showPopups)===!0){const C=s(p.display);let y;Pt(C)?y=ue(C):C.requirement!=null?y=ue(C.requirement):y=ki((v=p.requirements)!=null?v:[]),Fd.info(f("div",null,[f("h3",null,[E("Achievement earned!")]),f("div",null,[f(y,null,null)])]))}},Object.assign(a,i),$(a,"visibility"),ne(a,"visibility",Ne.Visible);const l=a.visibility;a.visibility=Na(()=>{const p=s(a.display);switch(se.msDisplay){default:case Pn.All:return s(l);case Pn.Configurable:return s(a.earned)&&!(p!=null&&typeof p=="object"&&"optionsDisplay"in p)?Ne.None:s(l);case Pn.Incomplete:return s(a.earned)?Ne.None:s(l);case Pn.None:return Ne.None}}),$(a,"display"),$(a,"mark"),$(a,"small"),$(a,"image"),$(a,"style"),$(a,"classes"),$(a,"showPopups"),ne(a,"showPopups",!0);for(const p of t)(h=p.postConstruct)==null||h.call(p,a);const u=t.reduce((p,m)=>{var v;return Object.assign(p,(v=m.getGatheredProps)==null?void 0:v.call(m,a))},{});if(a[pt]=function(){const{visibility:p,display:m,requirements:v,earned:C,image:y,style:I,classes:A,mark:S,small:P,id:B}=this;return{visibility:p,display:m,requirements:v,earned:C,image:y,style:s(I),classes:A,mark:S,small:P,id:B,...u}},a.requirements){const p=a,m=[er(p),Pd(()=>!p.earned.value),...Rt(a.requirements)?a.requirements:[a.requirements]];Et(()=>{se.active===J.id&&Ci(m)&&p.complete()})}return a})}Je.on("loadSettings",e=>{ne(e,"msDisplay",Pn.All)});const qd=Object.values(Pn).map(e=>({label:rt(e),value:e}));Ds(X(()=>f(Ki,{title:X(()=>f("span",{class:"option-title"},[E("Show achievements"),f("desc",null,[E("Select which achievements to display based on criterias.")])])),options:qd,"onUpdate:modelValue":e=>se.msDisplay=e,modelValue:se.msDisplay},null)));const Vd=Y({props:{progress:{type:O(String,Object,Number),required:!0},width:{type:O(Number),required:!0},height:{type:O(Number),required:!0},direction:{type:O(String),required:!0},display:O(Object,String,Function),visibility:{type:O(Number,Boolean),required:!0},style:O(Object,String,Array),classes:O(Object),borderStyle:O(Object,String,Array),textStyle:O(Object,String,Array),baseStyle:O(Object,String,Array),fillStyle:O(Object,String,Array),mark:O(Boolean,String),id:{type:String,required:!0}},components:{MarkNode:Qn,Node:ei},setup(e){const{progress:t,width:n,height:i,direction:r,display:a}=Fe(e),l=_(()=>{let d=t.value instanceof o?t.value.toNumber():Number(t.value);return(1-Math.min(Math.max(d,0),1))*100}),u=_(()=>{const d={width:Ee(n)+.5+"px",height:Ee(i)+.5+"px"};switch(s(r)){case U.Up:d.clipPath=`inset(${l.value}% 0% 0% 0%)`,d.width=Ee(n)+1+"px";break;case U.Down:d.clipPath=`inset(0% 0% ${l.value}% 0%)`,d.width=Ee(n)+1+"px";break;case U.Right:d.clipPath=`inset(0% ${l.value}% 0% 0%)`;break;case U.Left:d.clipPath=`inset(0% 0% 0% ${l.value} + '%)`;break;case U.Default:d.clipPath="inset(0% 50% 0% 0%)";break}return d}),c=Rn(a);return{normalizedProgress:l,barStyle:u,component:c,unref:s,Visibility:Ne,isVisible:Ue,isHidden:_n}}});function Bd(e,t,n,i,r,a){var c,d,h,p,m,v,C;const l=It("MarkNode"),u=It("Node");return e.isVisible(e.visibility)?(M(),T("div",{key:0,style:je([{width:e.unref(e.width)+"px",height:e.unref(e.height)+"px",visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:{}]),class:he({bar:!0,...e.unref(e.classes)})},[N("div",{class:"overlayTextContainer border",style:je([{width:e.unref(e.width)+"px",height:e.unref(e.height)+"px"},(d=e.unref(e.borderStyle))!=null?d:{}])},[e.component?(M(),T("span",{key:0,class:"overlayText",style:je(e.unref(e.textStyle))},[(M(),K(Xe(e.component)))],4)):j("",!0)],4),N("div",{class:"border",style:je([{width:e.unref(e.width)+"px",height:e.unref(e.height)+"px"},(h=e.unref(e.style))!=null?h:{},(p=e.unref(e.baseStyle))!=null?p:{},(m=e.unref(e.borderStyle))!=null?m:{}])},[N("div",{class:"fill",style:je([e.barStyle,(v=e.unref(e.style))!=null?v:{},(C=e.unref(e.fillStyle))!=null?C:{}])},null,4)],4),f(l,{mark:e.unref(e.mark)},null,8,["mark"]),f(u,{id:e.id},null,8,["id"])],6)):j("",!0)}var Ld=pe(Vd,[["render",Bd],["__scopeId","data-v-6bd06b56"]]);const jd=Symbol("Bar");function zd(e,...t){const n=t.reduce((i,r)=>{var a;return Object.assign(i,(a=r.getPersistentData)==null?void 0:a.call(r))},{});return Ke(i=>{var l,u;const r=e.call(i,i);r.id=ln("bar-"),r.type=jd,r[yt]=Ld;for(const c of t)(l=c.preConstruct)==null||l.call(c,r);Object.assign(r,n),$(r,"visibility"),ne(r,"visibility",Ne.Visible),$(r,"width"),$(r,"height"),$(r,"direction"),$(r,"style"),$(r,"classes"),$(r,"borderStyle"),$(r,"baseStyle"),$(r,"textStyle"),$(r,"fillStyle"),$(r,"progress"),$(r,"display"),$(r,"mark");for(const c of t)(u=c.postConstruct)==null||u.call(c,r);const a=t.reduce((c,d)=>{var h;return Object.assign(c,(h=d.getGatheredProps)==null?void 0:h.call(d,r))},{});return r[pt]=function(){const{progress:c,width:d,height:h,direction:p,display:m,visibility:v,style:C,classes:y,borderStyle:I,textStyle:A,baseStyle:S,fillStyle:P,mark:B,id:ie}=this;return{progress:c,width:d,height:h,direction:p,display:m,visibility:v,style:s(C),classes:y,borderStyle:I,textStyle:A,baseStyle:S,fillStyle:P,mark:B,id:ie,...a}},r})}function Ud(e,...t){return Ke(n=>{var r,a;const i=e.call(n,n);for(const l of t)(r=l.preConstruct)==null||r.call(l,i);i.formula=i.formula(g.variable(i.baseResource)),i.currentGain==null&&(i.currentGain=_(()=>{let l=o.floor(i.formula.evaluate(i.baseResource.value)).max(0);return s(i.buyMax)===!1&&(l=l.min(1)),l})),i.actualGain==null&&(i.actualGain=i.currentGain),i.currentAt==null&&(i.currentAt=_(()=>i.formula.invert(o.floor(s(i.currentGain))))),i.nextAt==null&&(i.nextAt=_(()=>i.formula.invert(o.floor(s(i.currentGain)).add(1)))),i.convert==null&&(i.convert=function(){var u;const l=s(i.currentGain);i.gainResource.value=o.add(i.gainResource.value,l),i.spend(l),(u=i.onConvert)==null||u.call(i,l)}),i.spend==null&&(i.spend=function(){i.baseResource.value=0}),$(i,"currentGain"),$(i,"actualGain"),$(i,"currentAt"),$(i,"nextAt"),$(i,"buyMax"),ne(i,"buyMax",!0);for(const l of t)(a=l.postConstruct)==null||a.call(l,i);return i})}function Gd(e){return Ud(e)}function Wd(e,t,n=1,i=o.dInf){const r=ve(n),a=ve(i);e.on("preUpdate",l=>{const u=s(r);o.neq(u,0)&&(t.gainResource.value=o.add(t.gainResource.value,o.times(u,l).times(o.ceil(s(t.actualGain)))).min(s(a)).max(t.gainResource.value))})}const Hd={postConstruct(e){e.amount===void 0&&console.error(`Decorated feature ${e.id} does not contain the required 'amount' property"`),$(e,"bonusAmount"),e.totalAmount===void 0&&(e.totalAmount=_(()=>{var t;return o.add(s((t=e.amount)!=null?t:0),s(e.bonusAmount))}))}},ia=Symbol("Repeatable");function br(e,...t){const n=ct(0),i=t.reduce((r,a)=>{var l;return Object.assign(r,(l=a.getPersistentData)==null?void 0:l.call(a))},{});return Ke(r=>{var m,v,C;const a=e.call(r,r);a.id=ln("repeatable-"),a.type=ia,a[yt]=Qr;for(const y of t)(m=y.preConstruct)==null||m.call(y,a);a.amount=n,a.amount[on]=(v=a.initialAmount)!=null?v:0,Object.assign(a,i);const l={requirementMet:_(()=>o.sub(s(a.limit),a.amount.value)),requiresPay:!1,visibility:Ne.None},u=er(a);Rt(a.requirements)?(a.requirements.unshift(u),a.requirements.push(l)):a.requirements=[u,a.requirements,l],a.maxed=_(()=>o.gte(a.amount.value,s(a.limit))),$(a,"classes");const c=a.classes;a.classes=_(()=>{const y=s(c)||{};return a.maxed.value&&(y.bought=!0),y}),a.amountToIncrease=_(()=>o.clampMin(ta(a.requirements),1)),a.canClick=_(()=>Ci(a.requirements));const d=a.onClick;a.onClick=function(y){const I=a;!s(I.canClick)||(na(a.requirements,s(a.amountToIncrease)),I.amount.value=o.add(I.amount.value,1),d==null||d(y))},$(a,"display");const h=a.display;a.display=X(()=>{var I,A,S;const y=s(h);if(Pt(y)){const P=ue(y);return f(P,null,null)}if(y!=null){const P=a,B=ue((I=y.title)!=null?I:"","h3"),ie=ue((A=y.description)!=null?A:""),re=ue((S=y.effectDisplay)!=null?S:"");return f("span",null,[y.title==null?null:f("div",null,[f(B,null,null)]),y.description==null?null:f(ie,null,null),y.showAmount===!1?null:f("div",null,[f("br",null,null),f(ee,null,[E("Amount: "),dt(P.amount.value)]),o.isFinite(s(P.limit))?f(ee,null,[E(" / "),dt(s(P.limit))]):void 0]),y.effectDisplay==null?null:f("div",null,[f("br",null,null),E("Currently: "),f(re,null,null)]),P.maxed.value?null:f("div",null,[f("br",null,null),ki(P.requirements,s(a.amountToIncrease))])])}return""}),$(a,"visibility"),ne(a,"visibility",Ne.Visible),$(a,"limit"),ne(a,"limit",o.dInf),$(a,"style"),$(a,"mark"),$(a,"small");for(const y of t)(C=y.postConstruct)==null||C.call(y,a);const p=t.reduce((y,I)=>{var A;return Object.assign(y,(A=I.getGatheredProps)==null?void 0:A.call(I,a))},{});return a[pt]=function(){const{display:y,visibility:I,style:A,classes:S,onClick:P,canClick:B,small:ie,mark:re,id:oe}=this;return{display:y,visibility:I,style:s(A),classes:S,onClick:P,canClick:B,small:ie,mark:re,id:oe,...p}},a})}const Zd=Symbol("Reset");function Yd(e){return Ke(t=>{const n=e.call(t,t);return n.id=ln("reset-"),n.type=Zd,n.reset=function(){var r;const i=a=>{if(a!=null&&typeof a=="object")if(on in a){const l=a;l.value=l[on]}else!(a instanceof o)&&!Ve(a)&&Object.values(a).forEach(l=>i(l))};s(n.thingsToReset).forEach(i),Je.emit("reset",n),(r=n.onReset)==null||r.call(n)},$(n,"thingsToReset"),n})}const li={};Je.on("removeLayer",e=>{var t;(t=li[e.id])==null||t.call(li),li[e.id]=void 0});function qi(e,t){return $(t,"display"),$(t,"classes"),$(t,"style"),$(t,"direction"),ne(t,"direction",U.Up),$(t,"xoffset"),$(t,"yoffset"),t.pinnable&&(t.pinned=ct(!1,!1)),Gt(()=>{t.pinnable&&("pinned"in e?(console.error("Cannot add pinnable tooltip to element that already has a property called 'pinned'"),t.pinnable=!1,Vr(t.pinned)):e.pinned=t.pinned);const n=e[yt];e[yt]=qe;const i=e[pt].bind(e);e[pt]=function(){const{display:a,classes:l,style:u,direction:c,xoffset:d,yoffset:h,pinned:p}=this;return{element:{[yt]:n,[pt]:i},display:a,classes:l,style:s(u),direction:c,xoffset:d,yoffset:h,pinned:p}}.bind(t)}),t}var Xd=Y({props:{display:{type:O(String,Object,Function),required:!0},visibility:{type:O(Number,Boolean),required:!0},style:O(String,Object,Array),classes:O(Object),requirements:{type:Object,required:!0},canPurchase:{type:O(Boolean),required:!0},bought:{type:O(Boolean),required:!0},mark:O(Boolean,String),id:{type:String,required:!0},purchase:{type:Function,required:!0}},components:{Node:ei,MarkNode:Qn},setup(e){const{display:t,requirements:n,bought:i}=Fe(e),r=ht("");return Et(()=>{const a=Ee(t);if(a==null){r.value="";return}if(Pt(a)){r.value=ue(a);return}const l=ue(a.title||"","h3"),u=ue(a.description,"div"),c=ue(a.effectDisplay||"");r.value=ue(X(()=>f("span",null,[a.title!=null?f("div",null,[f(l,null,null)]):null,f(u,null,null),a.effectDisplay!=null?f("div",null,[E("Currently: "),f(c,null,null)]):null,i.value?null:f(ee,null,[f("br",null,null),ki(n.value)])])))}),{component:r,unref:s,Visibility:Ne,isVisible:Ue,isHidden:_n}}});const Jd=["disabled"];function Kd(e,t,n,i,r,a){var c;const l=It("MarkNode"),u=It("Node");return e.isVisible(e.visibility)?(M(),T("button",{key:0,style:je([{visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:{}]),onClick:t[0]||(t[0]=(...d)=>e.purchase&&e.purchase(...d)),class:he({feature:!0,upgrade:!0,can:e.unref(e.canPurchase),locked:!e.unref(e.canPurchase),bought:e.unref(e.bought),...e.unref(e.classes)}),disabled:!e.unref(e.canPurchase)},[e.unref(e.component)?(M(),K(Xe(e.unref(e.component)),{key:0})):j("",!0),f(l,{mark:e.unref(e.mark)},null,8,["mark"]),f(u,{id:e.id},null,8,["id"])],14,Jd)):j("",!0)}var Qd=pe(Xd,[["render",Kd],["__scopeId","data-v-9be6bac0"]]);const tr=Symbol("Upgrade");function yr(e,...t){const n=ct(!1,!1),i=t.reduce((r,a)=>{var l;return Object.assign(r,(l=a.getPersistentData)==null?void 0:l.call(a))},{});return Ke(r=>{var c,d;const a=e.call(r,r);a.id=ln("upgrade-"),a.type=tr,a[yt]=Qd;for(const h of t)(c=h.preConstruct)==null||c.call(h,a);a.bought=n,Object.assign(a,i),a.canPurchase=_(()=>!n.value&&Ci(a.requirements)),a.purchase=function(){var p;const h=a;!s(h.canPurchase)||(na(a.requirements),n.value=!0,(p=h.onPurchase)==null||p.call(h))};const l=er(a);Rt(a.requirements)?a.requirements.unshift(l):a.requirements=[l,a.requirements],$(a,"visibility"),ne(a,"visibility",Ne.Visible),$(a,"classes"),$(a,"style"),$(a,"display"),$(a,"mark");for(const h of t)(d=h.postConstruct)==null||d.call(h,a);const u=t.reduce((h,p)=>{var m;return Object.assign(h,(m=p.getGatheredProps)==null?void 0:m.call(p,a))},{});return a[pt]=function(){const{display:h,visibility:p,style:m,classes:v,requirements:C,canPurchase:y,bought:I,mark:A,id:S,purchase:P}=this;return{display:h,visibility:p,style:s(m),classes:v,requirements:C,canPurchase:y,bought:I,mark:A,id:S,purchase:P,...u}},a})}function ep(e,t,n=[]){n=n.length===0?Xn(e,tr):n;const i=Zn(t)?_(t):t;e.on("update",()=>{s(i)&&n.forEach(r=>r.purchase())})}function tp(e,t,n,i){return function(){e>>>=0,t>>>=0,n>>>=0,i>>>=0;let r=e+t|0;return e=t^t>>>9,t=n+(n<<3)|0,n=n<<21|n>>>11,i=i+1|0,r=r+i|0,n=n+r|0,(r>>>0)/4294967296}}const np={1:["b","c","d","f","g","h","i","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"],2:["a","e","o","u"],3:["br","cr","dr","fr","gr","pr","str","tr","bl","cl","fl","gl","pl","sl","sc","sk","sm","sn","sp","st","sw","ch","sh","th","wh"],4:["ae","ai","ao","au","a","ay","ea","ei","eo","eu","e","ey","ua","ue","ui","uo","u","uy","ia","ie","iu","io","iy","oa","oe","ou","oi","o","oy"],5:["turn","ter","nus","rus","tania","hiri","hines","gawa","nides","carro","rilia","stea","lia","lea","ria","nov","phus","mia","nerth","wei","ruta","tov","zuno","vis","lara","nia","liv","tera","gantu","yama","tune","ter","nus","cury","bos","pra","thea","nope","tis","clite"],6:["una","ion","iea","iri","illes","ides","agua","olla","inda","eshan","oria","ilia","erth","arth","orth","oth","illon","ichi","ov","arvis","ara","ars","yke","yria","onoe","ippe","osie","one","ore","ade","adus","urn","ypso","ora","iuq","orix","apus","ion","eon","eron","ao","omia"]},wr=[[1,2,5],[2,3,6],[3,4,5],[4,3,6],[3,4,2,5],[2,1,3,6],[3,4,2,5],[4,3,1,6],[3,4,1,4,5],[4,1,4,3,6]];function Vi(e){const t=wr[Math.floor(e()*wr.length)];let n="";for(let i=0;i<t.length;i++){const r=np[t[i]];n+=r[Math.floor(e()*r.length)]}return rt(n)}const ip={1:["a","e","i","o","u"],2:["ph","th","ch","sh","br","cr","dr","fr","gr","pr","tr","str","sc","sk","sm","sn","sp","st","sw"],3:["ae","ai","ao","au","ay","ea","ei","eo","eu","ey","ua","ue","ui","uo","uy","ia","ie","iu","io","iy","oa","oe","ou","oi","oy"],4:["morp","flux","syn","void","rift","dyn","nov","chron","lum","par","ter","psy","phan","man","grav","pyr","cry","hydr","elec","kin","nan","omni"],5:["ance","ation","esis","ergy","tide","al","ism","ity","mancy","urgy","pathy","port","shift","burst","pulse","wave","field","storm","force","blade"]},_r=[[1,2,1,4,5],[1,4,5],[2,1,4,5],[1,2,3,4,5],[3,4,5]];function xn(e){const t=_r[Math.floor(e()*_r.length)];let n="";for(let i=0;i<t.length;i++){const r=ip[t[i]];n+=r[Math.floor(e()*r.length)]}return rt(n)}function Ln(e,t){const[n,i,r]=rp(...e),[a,l,u]=ap(Math.floor(t()*360),i,r);return`rgb(${a*255}, ${l*255}, ${u*255})`}function rp(e,t,n){const i=Math.max(e,t,n),r=i-Math.min(e,t,n),a=r&&(i==e?(t-n)/r:i==t?2+(n-e)/r:4+(e-t)/r);return[60*(a<0?a+6:a),i&&r/i,i]}function ap(e,t,n){const i=(r,a=(r+e/60)%6)=>n-n*t*Math.max(Math.min(a,4-a,1),0);return[i(5),i(3),i(1)]}const Nr=bi();function ra(e,t,n,i){return Xi(e,function(){const r=tp(0,n>>0,n>>32,1);for(let q=0;q<12;q++)r();const a=Vi(r),l=Ln([.64,.75,.55],r),u=Ln([.18,.2,.25],r),c=En(0,Vi(r)),d=ct(0),h=en.indexOf(t);let p=r();const m=i.reduce((q,L)=>(q[L.type]=L.data,q),{});"increaseDiff"in m&&(p=p/2+.5),"decreaseDiff"in m&&(p=p/2),"relic"in m&&(p=1);const v=p+h+1,C=w.toolNodes.value.sandRelic!=null?be("sandRelic")?2:1:0,y=ct(C),I=_(()=>("increaseRewards"in m?v+1:v)+y.value);let A="relic"in m?h+2:Math.ceil(r()*(h+2));"increaseLength"in m&&A++;const S=[],P=Ct(()=>S),B=_(()=>P.apply(0)),ie=[],re={};function oe({feature:q,canClick:L,modifier:Me,cost:et,previewModifier:$t,showETA:tt,previewCost:Xt}){L=ve(L),tt=ve(tt);const Dt=vr(q);ie.push({shouldShowPreview:_(()=>s(L)&&Dt.value),modifier:Ct(()=>{const Bt=S.slice();return Bt.splice(Bt.indexOf(Me),1,$t),Bt}),cost:Xt!=null?Xt:et}),S.push(Me);const Jt=Ri(c,B,()=>Ce(et)),nt=qi(q,{display:tt==null?Jt:()=>s(tt)?Jt.value:"",direction:U.Down});return{isHovering:Dt,eta:Jt,tooltip:nt}}const H=[],fe=z(0);let V=g.variable(fe).times(0);const ae={};let Re=!0;const Ze=_(()=>o.add(v,r()-.5).pow_base(2).times(10).times(V.evaluate())),qt=[];for(let q=0;q<A;q++){const L={upgrades:32,repeatables:q<=1?0:16,conversion:q<=3?0:8,xp:q<=5?0:4,dimensions:q<=7?0:2,prestige:q<=7||q>=A-1?0:1};switch(ui(L,r)){case"upgrades":const ce=[];for(let Se=0;Se<4;Se++){const gt=ui({add:1,mult:q===0&&Se===0?0:1,pow:q===0?0:.5},r),it=Ze.value,at=xn(r);let lt="",Ie,Te;const $e=fe.value;switch(gt){case"add":{const de=o.add(it,10).pow(r()/4+.875);lt=`Gain ${_e(de)} ${c.displayName}/s`,V=V.add(de),Ie=He=>zt(()=>({addend:de,description:at,enabled:He==null?Ae.bought:()=>He()&&Ae.bought.value})),Te=zt(()=>({addend:de}));break}case"mult":{const de=r()*5+1;lt=`Multiply previous ${c.displayName} gain by x${_e(de)}.`,V=V.add(o.sub(de,1).times(ae[$e-1])),Ie=He=>ke(()=>({multiplier:de,description:at,enabled:He==null?Ae.bought:()=>He()&&Ae.bought.value})),Te=ke(()=>({multiplier:de}));break}case"pow":{const de=r()/10+1.05;lt=`Raise previous ${c.displayName} gain to the ^${_e(de)}`,V=V.add(o.pow(ae[$e-1],de)).sub(ae[$e-1]),Ie=He=>Fi(()=>({exponent:de,description:at,enabled:He==null?Ae.bought:()=>He()&&Ae.bought.value})),Te=Fi(()=>({exponent:de}))}}ae[fe.value]=V.evaluate(),fe.value++;const We=Re,Ae=yr(()=>({requirements:Bn(()=>({resource:$n(c),cost:it})),display:{title:at,description:lt},visibility:We}));oe({feature:Ae,canClick:()=>Ae.canPurchase.value,modifier:Ie(),cost:it,showETA:()=>!Ae.bought.value,previewModifier:Te}),S.push(Ie(()=>w.toolNodes.value.stoneRelic!=null)),S.push(Ie(()=>be("stoneRelic"))),ce.push(Ae)}H.push(ce);break;case"repeatables":const te=[];for(let Se=0;Se<3;Se++){const gt=ui({add:1.5,mult:3},r),it=fe.value,at=Ze.value,lt=xn(r);let Ie="",Te,$e,We,Ae;const de=g.variable(_(()=>Oe.amount.value)).times(2);switch(gt){case"add":{const xe=o.add(at,10).times(r()+.5);Ie=`Gain ${_e(xe)} ${c.displayName}/s`,Ae=de.add(1).times(at),V=V.add(_(()=>o.sub(fe.value,it).add(1).times(5).times(xe))),Te=_(()=>_e(o.times(xe,s(Oe.totalAmount)))+"/s"),$e=zt(()=>({addend:()=>o.times(xe,s(Oe.totalAmount)),description:lt,enabled:()=>o.gt(s(Oe.totalAmount),0)})),We=zt(()=>({addend:()=>o.add(s(Oe.totalAmount),1).times(xe)}));break}case"mult":{const xe=r()*.75+1.25;Ie=`Multiply previous ${c.displayName} gain by x${_e(xe)}.`,Ae=de.pow_base(xe).times(at),V=V.add(_(()=>o.sub(fe.value,it).add(1).times(5).pow_base(xe).sub(1).times(ae[it-1]))),Te=_(()=>"x"+_e(o.pow(xe,s(Oe.totalAmount)))),$e=ke(()=>({multiplier:()=>o.pow(xe,s(Oe.totalAmount)),description:lt,enabled:()=>o.gt(s(Oe.totalAmount),0)})),We=ke(()=>({multiplier:()=>o.add(s(Oe.totalAmount),1).pow_base(xe)}));break}}ae[fe.value]=V.evaluate(),fe.value++;const He=Re,Oe=br(()=>({requirements:Bn(()=>({resource:$n(c),cost:Ae})),display:()=>({title:lt,description:`${Ie}<br/><br/>Amount: ${dt(Oe.amount.value)}${o.gt(s(Oe.bonusAmount),0)?` [+${dt(s(Oe.bonusAmount))}]`:""}`,effectDisplay:s(Te),showAmount:!1}),visibility:He,bonusAmount:()=>o.gt(Oe.amount.value,0)?be("dirtRelic")?2:w.toolNodes.value.dirtRelic!=null?1:0:0}),Hd);oe({feature:Oe,canClick:()=>s(Oe.canClick),modifier:$e,cost:Ae,previewModifier:We}),te.push(Oe)}H.push(te);break;case"conversion":const De=En(0,Vi(r)),_t=Ln([.64,.75,.55],r),Lt=Ze.value,Vn=r()/2+.25,ir=r()/2+.25,rr=fe.value;V=V.add(_(()=>o.sub(fe.value,rr).add(1).pow_base(5).pow(ir).times(ae[rr-1])));const Tt=Gd(()=>({baseResource:$n(c),gainResource:De,formula:Se=>Se.div(Lt).pow(Vn),spend(){c.value=0}}));ae[fe.value]=V.evaluate(),fe.value+=2;const aa=Re,ar=xn(r),Ei=g.variable(De).pow(ir).add(1),sa=ke(()=>({multiplier:()=>Ei.evaluate(),description:ar,enabled:()=>o.gt(De.value,0)})),oa=ke(()=>({multiplier:()=>Ei.evaluate(o.add(De.value,Tt.actualGain.value))})),In=Cd(()=>({display:{title:ar,description:X(()=>f("span",null,[E("Reset "),c.displayName,E(" for")," ",vi(De,o.clampMin(Tt.actualGain.value,1))," ",De.displayName,f("br",null,null),f("div",null,[E("Next:")," ",vi(c,o.lt(Tt.actualGain.value,1)?Tt.currentAt.value:Tt.nextAt.value)," ",c.displayName])]))},style:{width:"200px",minHeight:"100px"},canClick:()=>o.gte(Tt.actualGain.value,1),prestigeResource:De,onClick:Tt.convert,visibility:aa})),{isHovering:la}=oe({feature:In,canClick:()=>s(In.canClick),modifier:sa,cost:Lt,previewCost:c,previewModifier:oa}),sr=_(()=>la.value&&In.canClick.value);H.push([In]);const ua=fn(g.variable(De),sr,Tt.actualGain),ca=fn(Ei,sr,Tt.actualGain);re[q*2]=X(()=>f(ee,null,[Ue(In.visibility)?f("div",{style:"margin: 10px"},[E("You have")," ",f("h2",{style:{color:_t,textShadow:`0px 0px 10px ${_t}`}},[ua()])," ",De.displayName,E(","),f("br",null,null),E("providing a "),ca(),E("x multiplier to previous")," ",c.displayName,E(" gain")]):null,Ai(In)])),Wd(this,Tt,()=>Qe.value.length<A&&w.investments.value!=null&&ye(w.investments.value)&&w.investments.value.state.portals.includes(e)?.01:0);break;case"xp":{const Se=En(0),ot=Re,gt=fe.value,it=xn(r),at=o.add(v,r()-.5).pow_base(2).times(10),lt=r()/4+1.125,Ie=r()/2+1.25,Te=g.variable(0).pow(lt).times(at),$e=Yr(Te,Se,!0,10,o.dInf),We=_(()=>Tn(Te,$e.value,!0,10)),Ae=_(()=>Tn(Te,o.add($e.value,1),!0,10)),de=_(()=>o.pow(Ie,$e.value)),He=ke(()=>({multiplier:de,description:it,enabled:()=>Ue(xe.visibility)}));V=V.add(_(()=>o.sub(fe.value,gt).add(1).sqrt().times(3).pow(Ie).times(ae[gt-1]))),ae[fe.value]=V.evaluate(),fe.value+=2;const Oe=Ln([.18,.2,.25],r),xe=zd(()=>({direction:U.Right,width:300,height:20,progress:()=>o.sub(Se.value,We.value).div(o.sub(Ae.value,We.value)).toNumber(),visibility:ot,xp:Se,display:X(()=>f("span",null,[_e(Se.value),E("/"),_e(Ae.value)])),fillStyle:`background-color: ${Oe}`}));this.on("preUpdate",Pi=>{if(Qe.value.length<A&&w.activePortals.value.some(Nt=>Nt.state.id===e)&&Ue(xe.visibility)){const Nt=o.times(Yt.value,Pi);Se.value=o.add(Nt,Se.value)}}),S.push(He),H.push([xe]),re[q*2]=X(()=>f(ee,null,[Ue(xe.visibility)?f("div",{style:"margin: 10px"},[E("You have "),f("h3",null,[it]),E(" Lv. "),dt($e.value),E(","),f("br",null,null),E("providing a "),_e(de.value),E("x multiplier to previous")," ",c.displayName,E(" gain"),f("br",null,null)]):null,Ai(xe)]));break}case"dimensions":{const Se=xn(r),ot=En(0,Se+" energy"),gt=Ln([.64,.75,.55],r),it=fe.value;V=V.add(_(()=>o.sub(fe.value,it).add(1).pow_base(32).add(1).log2().add(1).times(ae[it-1])));const at=_(()=>o.add(ot.value,1).log2().add(1)),lt=ke(()=>({multiplier:at,description:Se,enabled:()=>o.gt(ot.value,0)}));S.push(lt);const Ie=Re,Te=[];for(let $e=0;$e<4;$e++){const We=o.add(v,r()-.5).pow_base(2).times(10).recip(),Ae=Ze.value,de=g.variable(_(()=>Nt.amount.value)),He=de.pow_base(o.pow10($e+1)).times(Ae),Oe=["First","Second","Third","Fourth"][$e]+" "+Se+" Dimension",xe=En(0,Oe),Pi=de.sub(1).pow_base(2).times(We).times(_(()=>o.add(Nt.amount.value,xe.value))),Nt=br(()=>({display:{title:Oe,description:X(()=>f("div",null,[f("div",null,[E("Amount:")," ",_e(o.add(xe.value,Nt.amount.value))," ",E("["),dt(Nt.amount.value),E("]")])])),effectDisplay:X(()=>f("span",null,[fa()," ",$e===0?ot.displayName:["First","Second","Third","Fourth"][$e-1]+" "+Se+" Dimension",E("/s")])),showAmount:!1},style:{width:"400px"},effect:Pi,dimensions:xe,energy:$e===0?ot:void 0,requirements:Bn(()=>({resource:$n(c),cost:He})),visibility:Ie}));Te.push(Nt);const da=vr(Nt),or=_(()=>s(Nt.canClick)&&da.value),pa=new g({inputs:[de],evaluate(lr){return o.sub(lr,1).pow_base(2).times(We).times(o.add(lr,xe.value))}}),fa=fn(pa,or);ie.push({shouldShowPreview:or,cost:He});const ga=Ri(c,B,()=>Ce(He));qi(Nt,{display:ga,direction:U.Down}),ae[fe.value]=V.evaluate(),fe.value++}this.on("preUpdate",$e=>{if(Qe.value.length<A&&w.activePortals.value.some(We=>We.state.id===e)&&Ue(Ie)){const We=o.times(Yt.value,$e),Ae=Te[0].effect.evaluate();ot.value=o.times(Ae,We).add(ot.value);for(let de=1;de<4;de++){const He=Te[de].effect.evaluate();Te[de-1].dimensions.value=o.times(He,We).add(Te[de-1].dimensions.value)}}}),H.push(Te),re[q*2]=X(()=>f(ee,null,[Ue(Ie)?f("div",{style:"margin: 10px"},[E("You have")," ",f("h2",{style:{color:gt,textShadow:`0px 0px 10px ${gt}`}},[_e(ot.value)])," ",ot.displayName,E(","),f("br",null,null),E("providing a "),_e(at.value),E("x multiplier to previous")," ",c.displayName,E(" gain")]):null,Vs(...Te)]));break}case"prestige":{const Se=xn(r),ot=Re,gt=r()/2+1.25,it=Ze.value;V=V.pow(gt);const at=Fi(()=>({exponent:gt,description:Se,enabled:Ie.bought}));ae[fe.value]=V.evaluate(),fe.value++;const lt=Yd(()=>({thingsToReset:H.filter(($e,We)=>We%2===0),onReset(){c.value=0}})),Ie=yr(()=>({display:{title:Se,description:`Reset all previous ${a} content to raise all previous ${c.displayName} gain to the ^${_e(gt)}`},style:{width:"200px",minHeight:"100px"},onPurchase:lt.reset,visibility:ot,requirements:Bn(()=>({resource:$n(c),cost:it}))})),Te=ke(()=>({multiplier:0}));oe({feature:Ie,canClick:()=>s(Ie.canPurchase),modifier:at,cost:it,previewCost:c,previewModifier:Te,showETA:()=>!s(Ie.bought)}),H.push([Ie]);break}}const et={cache:"increaseCaches"in m?10:1,generation:"increaseGens"in m?10:1,resourceMulti:"increaseResourceMults"in m?10:1,energyMulti:"increaseEnergyMults"in m?2.5:.25,influences:Object.keys(w.influenceNodes.value).length+qt.length===Object.keys(kt).length?0:"increaseInfluences"in m?20:2,relic:0};let $t=ui(et,r);q===A-1&&"relic"in m&&($t="relic");let tt="",Xt,Dt,Jt,nt,Bt,Kt;switch($t){case"cache":nt=Bi(r,i),tt=`Gain ${_e(o.div(I.value,12))}x your current ${nt}.`,Dt=()=>{var De,_t,Lt;return w.grantResource(nt,o.times((Lt=(_t=(De=w.resourceNodes.value[nt])==null?void 0:De.state)==null?void 0:_t.amount)!=null?Lt:0,o.div(I.value,12)))};break;case"generation":nt=Bi(r,i);const ce=o.div(I.value,40).times(xt[nt]);tt=`Gain ${_e(ce)} ${nt}/s while plane is active.`,Xt=De=>w.grantResource(nt,o.times(De,ce)),Jt=_(()=>w.resourceNodes.value[nt]);break;case"resourceMulti":Bt=nt=Bi(r,i),Kt=o.div(I.value,10).pow_base(2),tt=`Gain ${_e(Kt)}x ${nt} while plane is active.`;break;case"energyMulti":Bt="energy",Kt=o.div(I.value,8).add(1),tt=`Gain ${_e(Kt)}x energy while plane is active.`;break;case"influences":const te=Object.keys(kt)[Math.floor(r()*Object.keys(kt).length)];qt.push(te),tt=`Gain a new portal influence (${kt[te].display})`,Dt=()=>{if(te in w.influenceNodes.value){Nr.warning(`Error: ignoring duplicate portal influence (${kt[te].display})`);return}const De={id:Kn(w.board),position:{...w.board.types.portal.nodes.value.find(_t=>_t.state.id===e).position},type:"influence",state:{type:te,data:kt[te].initialData}};w.board.placeInAvailableSpace(De),w.board.nodes.value.push(De)};break;case"relic":tt=t==="ultimatum"?"Win the game!":`Gain the ${t}-tier planar relic (${rn[t]})`,Dt=()=>{if(t==="ultimatum"){nr.value=!0;return}if(`${t}Relic`in w.toolNodes.value)Nr.warning(`Error: ignoring duplicate relic (${rn[t]})`);else{const De={id:Kn(w.board),position:{...w.board.types.portal.nodes.value.find(_t=>_t.state.id===e).position},type:"passive",state:`${t}Relic`};w.board.placeInAvailableSpace(De),w.board.nodes.value.push(De)}}}const x=Re,D=Ze.value,R=Od(()=>({requirements:Bn(()=>({resource:$n(c),cost:D})),visibility:x,display:{requirement:`${_e(D)} ${c.displayName}`,effectDisplay:tt},style:"width: 100%",classes:{final:q===A-1},update:Xt,onComplete:Dt,link:Jt,effectedResource:Bt,resourceMulti:Kt})),G=Ri(c,B,D);qi(R,{display:()=>R.earned.value?"":G.value,direction:U.Down}),H.push([R]),Re=R.earned}const ft=Xn(H,tr),kn=Xn(H,ia);S.push(ke(()=>({multiplier:()=>be("silver")?4:2,description:()=>(be("silver")?"Empowered ":"")+Le.silver.name,enabled:()=>w.toolNodes.value.silver!=null})),ke(()=>({multiplier:()=>(be("diamond")?2:1)*ft.filter(q=>q.bought.value).length/10,description:()=>(be("diamond")?"Empowered ":"")+Le.diamond.name,enabled:()=>w.toolNodes.value.diamond!=null})),ke(()=>({multiplier:()=>o.div(d.value,6e3).times(be("emerald")?2:1).add(1),description:()=>(be("emerald")?"Empowered ":"")+Le.emerald.name,enabled:()=>w.toolNodes.value.emerald!=null})),ke(()=>({multiplier:()=>o.div(kn.reduce((q,L)=>q.add(s(L.totalAmount)),o.dZero),100).times(be("gravelRelic")?2:1).add(1),description:()=>(be("gravelRelic")?"Empowered ":"")+rn.gravel,enabled:()=>w.toolNodes.value.gravelRelic!=null})));const qn=Ct(()=>[ke(()=>({multiplier:()=>{var q,L,Me;return o.add((Me=(L=(q=w.board.types.booster.nodes.value[0])==null?void 0:q.state)==null?void 0:L.level)!=null?Me:0,1)},description:"Booster",enabled:()=>{var q,L,Me;return(Me=(L=(q=w.board.types.booster.nodes.value[0])==null?void 0:q.state)==null?void 0:L.portals.includes(e))!=null?Me:!1}})),ke(()=>({multiplier:()=>o.add(1,be("coalRelic")?o.pow(Qe.value.length,2):Qe.value.length),description:()=>(be("coalRelic")?"Empowered ":"")+rn.coal,enabled:()=>w.toolNodes.value.coalRelic!=null}))]),Yt=_(()=>qn.apply(1)),[ni,ii]=Gn(()=>[{title:`${rt(c.displayName)} Gain`,modifier:P,base:0,unit:"/s"},{title:`${rt(c.displayName)} Time Speed`,modifier:qn,base:1,visible:()=>o.gt(Yt.value,1)}]),Mn=z(!1),ri=X(()=>f(Ht,{modelValue:Mn.value,"onUpdate:modelValue":q=>Mn.value=q},{header:()=>f("h2",null,[E("Modifiers")]),body:()=>st(ni)}));this.on("preUpdate",q=>{if(!w.activePortals.value.some(Me=>Me.state.id===e))return;const L=o.times(Yt.value,q);d.value=o.add(d.value,L),Qe.value.length<A&&(c.value=o.times(B.value,L).add(c.value)),Qe.value.forEach(Me=>{var et;(et=Me.update)==null||et.call(Me,L)})}),ep(this,()=>Qe.value.length<A&&w.upgrader.value!=null&&ye(w.upgrader.value)&&w.upgrader.value.state.portals.includes(e),ft),kd(this,()=>Qe.value.length<A&&w.automator.value!=null&&ye(w.automator.value)&&w.automator.value.state.portals.includes(e),kn);const Vt=_(()=>{const q=ie.find(L=>L.shouldShowPreview.value);return q?o.neg(Ce(q.cost)):0}),Sn=_(()=>{const q=ie.find(L=>L.shouldShowPreview.value);return q&&q.modifier?o.sub(q.modifier.apply(0),B.value):0}),ai=fn(g.variable(0).add(c),()=>o.neq(Vt.value,0),Vt),si=fn(g.variable(0).add(B),()=>o.neq(Sn.value,0),Sn),Si=_(()=>{const q=[];return Qe.value.forEach(L=>{L.link&&q.push(L.link)}),q}),Ii=_(()=>{const q={};return Qe.value.forEach(L=>{L.effectedResource!=null&&L.resourceMulti!=null&&(q[L.effectedResource]!=null?q[L.effectedResource]=o.times(q[L.effectedResource],L.resourceMulti):q[L.effectedResource]=L.resourceMulti)}),q}),Qe=_(()=>{const q=[];for(let L=1;L<H.length;L+=2){const Me=H[L][0];Me.earned.value&&q.push(Me)}return q}),$i=_(()=>o.lt(Qe.value.length,A)&&H.some(q=>q.some(L=>"earned"in L&&s(L.earned)||"bought"in L&&s(L.bought)?!1:("canClick"in L&&s(L.canClick)||"canPurchase"in L&&s(L.canPurchase),!0)))),xi=_(()=>{const q=H.findIndex((Me,et)=>et>0&&et%2===0&&!H[et-1][0].earned.value);let L;return q===-1?L=H:L=H.slice(0,q),L.map((Me,et)=>et in re?st(re[et]):Ai(...Me))});return{tier:ct(t),seed:ct(n),influences:ct(i),name:a,color:l,resource:c,background:u,style:{background:u,"--background":u},features:H,resourceTabCollapsed:ii,links:Si,resourceMultis:Ii,earnedTreasures:Qe,showNotif:$i,timeActive:d,bonusRewardsLevel:y,display:X(()=>f(ee,null,[f(mi,{class:"nav-container",style:"z-index: 5"},{default:()=>[f("span",{class:"nav-segment"},[f("h2",null,[a])]),f("span",{class:"nav-segment"},[f("h3",null,[t,E("-tier")])]),i.length===0?null:f("span",{class:"nav-segment"},[f(qe,{display:i.map(q=>{const L=kt[q.type].description;return typeof L=="function"?L(q):L}).join("<br/>"),direction:U.Down,style:"width: 300px"},{default:()=>[f("h3",null,[i.length,E(" influences")])]})]),f("span",{class:"nav-segment"},[f("button",{class:"button",style:"display: inline",onClick:()=>Mn.value=!0},[E("modifiers")])])]}),f(mi,{class:"nav-container"},{default:()=>[f("span",{class:"nav-segment"},[f("h3",{style:`color: ${l}; text-shadow: 0px 0px 10px ${l};`},[st(ai)])," ",c.displayName]),f("span",{class:"nav-segment"},[E("("),f("h3",{style:`color: ${l}; text-shadow: 0px 0px 10px ${l};`},[o.gt(B.value,0)?"+":"",st(si)]),E("/s)")]),o.neq(Yt.value,1)?f("span",{class:"nav-segment"},[E("Speed: "),_e(Yt.value),E("x")]):null]}),f(Ed,{height:"60px"},null),xi.value,st(ri)])),minimizedDisplay:X(()=>f("div",null,[f("span",null,[a]),f("span",{style:"font-size: large; vertical-align: sub;"},[" ",Qe.value.length,E("/"),A,E(" treasures")])]))}})}function Bi(e,t){t=t.filter(u=>u.type==="increaseResources"||u.type==="decreaseResources");const n=Object.keys(xt).reduce((u,c)=>{let d=xt[c];return t.filter(h=>h.data===c).forEach(h=>{h.type==="increaseResources"?d*=1e3:d/=1e3}),u+d},0),i=Object.keys(xt),r=Math.floor(e()*n);let a=0,l;for(let u=0;u<i.length;u++){const c=i[u];if(a+=xt[c],r<a){l=c;break}}return l}function ui(e,t){const n=Object.values(e).reduce((u,c)=>u+c),i=Object.keys(e);let r=0,a=null;const l=t()*n;for(let u=0;u<i.length;u++){const c=i[u];if(r+=e[c],l<r){a=c;break}}if(a==null)throw new Error("Failed to pick random. This should not happen");return a}const sp={shape:Ge.Diamond,size:50,title:"\u{1FAA8}",label:e=>e===w.board.selectedNode.value?{text:"Mining"}:Object.keys(w.resourceNodes.value).length===0?{text:"Click me!"}:null,actionDistance:Math.PI/4,actions:[Ot],progress:e=>ye(e)?new o(e.state.progress).toNumber():0,progressDisplay:bn.Outline,progressColor:"var(--accent2)",classes:e=>({running:ye(e)}),draggable:!0},op={shape:Ge.Diamond,size:50,title:"\u{1F6E0}\uFE0F",label:e=>e===w.board.selectedNode.value?{text:"Broken Forge"}:null,actionDistance:Math.PI/4,actions:[{id:"repair",icon:"build",tooltip:{text:"Repair - 100 energy"},onClick(e){o.gte(w.energy.value,100)&&(e.type="factory",w.energy.value=o.sub(w.energy.value,100))},confirmationLabel:()=>o.gte(w.energy.value,1e3)?{text:"Tap again to confirm"}:{text:"Cannot afford",color:"var(--danger)"}}],draggable:!0},lp={shape:Ge.Diamond,size:50,title:"\u{1F6E0}\uFE0F",label:e=>{var t,n;if(e===w.board.selectedNode.value)return{text:e.state==null?"Forge - Drag a resource to me!":`Forging ${Le[e.state].name}`};if(((t=w.board.draggingNode.value)==null?void 0:t.type)==="resource"){const i=((n=w.board.draggingNode.value)==null?void 0:n.state).type,r=e.state===i?"Disconnect":Le[i].name,a=e.state===i||w.toolNodes.value[i]==null?"var(--accent2)":"var(--danger)";return{text:r,color:a}}return null},actionDistance:Math.PI/4,actions:[{id:"deselect",icon:"close",tooltip:{text:"Disconnect resource"},onClick(e){e.state=void 0,w.board.selectedAction.value=null,w.board.selectedNode.value=null},visibility:e=>e.state!=null},{id:"craft",icon:"done",tooltip:e=>({text:`Forge ${Le[e.state].name} - ${Ye(Le[e.state].cost)} energy`}),onClick(e){const t=Le[e.state];if(o.gte(w.energy.value,t.cost)&&w.toolNodes.value[e.state]==null){w.energy.value=o.sub(w.energy.value,t.cost);const n={id:Kn(w.board),position:{...e.position},type:t.type,state:"state"in t?t.state:void 0};w.board.placeInAvailableSpace(n),w.board.nodes.value.push(n),w.board.selectedAction.value=null,w.board.selectedNode.value=null,e.state=void 0}},fillColor:e=>o.gte(w.energy.value,Le[e.state].cost)&&w.toolNodes.value[e.state]==null?"var(--accent2)":"var(--danger)",visibility:e=>e.state!=null,confirmationLabel:e=>o.gte(w.energy.value,Le[e.state].cost)?w.toolNodes.value[e.state]==null?{text:"Tap again to confirm"}:{text:"Already crafted",color:"var(--danger)"}:{text:"Cannot afford",color:"var(--danger)"}}],progress:e=>e.state==null||w.toolNodes.value[e.state]!=null?0:o.div(o.sqrt(w.energy.value),o.sqrt(Le[e.state].cost)).clampMax(1).toNumber(),progressDisplay:bn.Fill,progressColor:e=>e.state!=null&&o.gte(w.energy.value,Le[e.state].cost)?"var(--accent2)":"var(--foreground)",canAccept(e,t){return t.type==="resource"},onDrop(e,t){const n=t.state.type;e.state===n?e.state=void 0:e.state=n,w.board.selectedNode.value=e},draggable:!0},up={shape:Ge.Circle,size:50,title:e=>rt(e.state.type),subtitle:e=>Ye(e.state.amount),progress:e=>md(e.state.type),onClick(){},progressDisplay:bn.Outline,progressColor:"var(--accent3)",classes:e=>{var t;return{"affected-node":w.dowsing.value!=null&&ye(w.dowsing.value)&&w.dowsing.value.state.resources.includes(e.state.type)||o.neq((t=w.planarMultis.value[e.state.type])!=null?t:1,1)}},draggable:!0},cp={shape:Ge.Circle,size:50,title:e=>{const t=e.state;return t.includes("Relic")?rn[t.slice(0,-5)]:Le[t].name},label:e=>e===w.board.selectedNode.value?{text:xd[e.state].description(be(e.state))}:null,outlineColor:"var(--bought)",classes:e=>({"affected-node":be(e.state)}),draggable:!0},dp={shape:Ge.Diamond,size:50,title:"\u{1F962}",label:e=>e===w.board.selectedNode.value?{text:e.state.resources.length===0?"Dowsing - Drag a resource to me!":`Dowsing (${e.state.resources.length}/${o.add(e.state.maxConnections,w.computedBonusConnectionsModifier.value)})`}:Xr(e,t=>`Double ${t} odds`),actionDistance:Math.PI/4,actions:[un,Cn(e=>e.add(2).pow_base(100),16),Ot],classes:e=>({running:ye(e)}),canAccept:Jr,onDrop:Kr,draggable:!0},pp={shape:Ge.Diamond,size:50,title:"\u26CF\uFE0F",label:e=>e===w.board.selectedNode.value?{text:e.state.resources.length===0?"Quarry - Drag a resource to me!":`Quarrying (${e.state.resources.length}/${o.add(e.state.maxConnections,w.computedBonusConnectionsModifier.value)})`}:Xr(e,t=>`Gather ${bt(o.div(w.dropRates[t].computedModifier.value,100))} ${t}/s`),actionDistance:Math.PI/4,actions:[un,Cn(e=>e.add(2).pow_base(1e4),16),Ot],progress:e=>ye(e)?o.eq(w.quarryProgressRequired.value,0)?0:new o(e.state.progress).div(w.quarryProgressRequired.value).toNumber():0,progressDisplay:bn.Outline,progressColor:"var(--accent2)",canAccept:Jr,onDrop:Kr,classes:e=>({running:ye(e)}),draggable:!0},fp={shape:Ge.Diamond,size:50,title:"\u{1F50C}",label:e=>e===w.board.selectedNode.value?{text:e.state.tools.length===0?"Empowerer - Drag a tool to me!":`Empowering (${e.state.tools.length}/${o.add(e.state.maxConnections,w.computedBonusConnectionsModifier.value)})`}:pd(e,t=>t.includes("Relic")?`Double ${rn[t.slice(0,-5)]}'s effect`:`Double ${Le[t].name}'s effect`),actionDistance:Math.PI/4,actions:[un,Cn(e=>e.add(3).pow_base(1e3),16),Ot],canAccept:fd,onDrop:gd,classes:e=>({running:ye(e)}),draggable:!0},gp={shape:Ge.Diamond,size:50,title:"\u26E9\uFE0F",label:e=>{if(e===w.board.selectedNode.value)return{text:e.state.tier==null?"Portal Spawner - Drag a resource to me!":`Spawning ${e.state.tier}-tier portal`};const t=w.board.draggingNode.value;if((t==null?void 0:t.type)==="resource"){const n=t.state.type;return{text:e.state.tier===n?"Disconnect":`${rt(n)}-tier Portal`,color:"var(--accent2)"}}else if((t==null?void 0:t.type)==="influence"){const n=t.state.type,{influences:i}=e.state;return i.includes(n)?{text:"Disconnect",color:"var(--accent2)"}:{text:"Add influence",color:"var(--accent2)"}}return null},actionDistance:Math.PI/4,actions:[{id:"deselect",icon:"close",tooltip:{text:"Disconnect all"},onClick(e){e.state={...e.state,tier:void 0,influences:[]},w.board.selectedAction.value=null,w.board.selectedNode.value=null},visibility:e=>{const{tier:t,influences:n}=e.state;return t!=null||n.length>0}},{id:"makePortal",icon:"done",tooltip:e=>({text:`Spawn ${e.state.tier}-tier portal - ${Ye(w.computedPortalCost.value)} energy`}),fillColor:()=>o.gte(w.energy.value,w.computedPortalCost.value)?"var(--accent2)":"var(--danger)",confirmationLabel:()=>o.gte(w.energy.value,w.computedPortalCost.value)?{text:"Tap again to confirm"}:{text:"Cannot afford",color:"var(--danger)"},onClick(e){let t=0;for(;`portal-${t}`in we;)t++;w.energy.value=o.sub(w.energy.value,w.computedPortalCost.value);const{tier:n,influences:i}=e.state;Ji(ra(`portal-${t}`,n,Math.floor(Math.random()*4294967296),i.map(a=>w.influenceNodes.value[a].state)),J);const r={id:Kn(w.board),position:{...e.position},type:"portal",state:{id:`portal-${t}`,powered:!1}};w.board.placeInAvailableSpace(r),w.board.nodes.value.push(r),w.board.selectedAction.value=null,w.board.selectedNode.value=null,e.state={tier:void 0,influences:[]}},visibility:e=>e.state.tier!=null}],canAccept(e,t){return t.type==="resource"||t.type==="influence"},onDrop(e,t){if(t.type==="resource"){const n=t.state.type,i=e.state.tier;e.state={...e.state,tier:n===i?void 0:n}}else if(t.type==="influence"){const n=t.state.type,i=e.state.influences;i.includes(n)?e.state={...e.state,influences:i.filter(r=>r!==n)}:e.state={...e.state,influences:[...i,n]}}w.board.selectedNode.value=e},draggable:!0},mp={shape:Ge.Diamond,size:50,title:"\u{1F300}",label:e=>e===w.board.selectedNode.value?{text:`Portal to ${we[e.state.id].name}`,color:we[e.state.id].color}:null,actionDistance:Math.PI/4,actions:[Ot],classes:e=>({running:ye(e),showNotif:we[e.state.id].showNotif.value,"affected-node":w.booster.value!=null&&ye(w.booster.value)&&w.booster.value.state.portals.includes(e.state.id)}),outlineColor:e=>we[e.state.id].background,draggable:!0},vp={shape:e=>e.state.type==="increaseResources"||e.state.type==="decreaseResources"?Ge.Diamond:Ge.Circle,size:50,title:e=>kt[e.state.type].display,label:e=>{if(e===w.board.selectedNode.value){const n=e.state,i=kt[n.type].description;return{text:typeof i=="function"?i(n):i}}const t=w.board.draggingNode.value;if((t==null?void 0:t.type)==="resource"){const n=t.state.type,{type:i,data:r}=e.state;let a;if(Array.isArray(r)&&r.includes(n))a="Disconnect";else if(i==="increaseResources")a=`Increase ${rt(n)} odds`;else if(i==="decreaseResources")a=`Decrease ${rt(n)} odds`;else return null;return{text:a,color:"var(--accent2)"}}return null},actionDistance:Math.PI/4,actions:[un],canAccept:(e,t)=>t.type!=="resource"?!1:Array.isArray(e.state.data),onDrop:(e,t)=>{if(t.type!=="resource")return;const n=t.state.type,i=e.state.data;i!=null&&(i.includes(n)?e.state={...e.state,data:i.filter(r=>r!==n)}:e.state={...e.state,data:[...i,n]},w.board.selectedNode.value=e)},outlineColor:"var(--danger)",draggable:!0},hp={shape:Ge.Diamond,size:50,title:"\u231B",label:e=>e===w.board.selectedNode.value?{text:e.state.portals.length===0?"Booster - Drag a portal to me!":`Boosting by ${Ye(o.add(1,e.state.level))}x (${e.state.portals.length}/${o.add(e.state.maxConnections,w.computedBonusConnectionsModifier.value)})`}:wi(e,t=>`Boost ${we[t].name}'s speed`),actionDistance:Math.PI/4,actions:[un,Cn(e=>e.add(6).pow_base(1e3)),{id:"increaseBoost",icon:"arrow_upward",tooltip(e){return{text:`Increase boost - ${Ye(Oi.evaluate(e.state.level))} energy`}},confirmationLabel(e){return o.gte(w.energy.value,Oi.evaluate(e.state.level))?{text:"Tap again to confirm"}:{text:"Cannot afford",color:"var(--danger)"}},onClick(e){const t=Oi.evaluate(e.state.level);o.gte(w.energy.value,t)&&(w.energy.value=o.sub(w.energy.value,t)),e.state={...e.state,level:o.add(e.state.level,1)},w.board.selectedAction.value=null}},Ot],canAccept:_i,onDrop:Ni,classes:e=>({running:ye(e)}),draggable:!0},bp={shape:Ge.Diamond,size:50,title:"\u{1F916}",label:e=>e===w.board.selectedNode.value?{text:e.state.portals.length===0?"Upgrader - Drag a portal to me!":`Auto-Upgrading (${e.state.portals.length}/${o.add(e.state.maxConnections,w.computedBonusConnectionsModifier.value)})`}:wi(e,t=>`Auto-buy ${we[t].name}'s upgrades and prestiges`),actionDistance:Math.PI/4,actions:[un,Cn(e=>e.add(4).pow_base(1e6)),Ot],canAccept:_i,onDrop:Ni,classes:e=>({running:ye(e)}),draggable:!0},yp={shape:Ge.Diamond,size:50,title:"\u{1F9BE}",label:e=>e===w.board.selectedNode.value?{text:e.state.portals.length===0?"Automator - Drag a portal to me!":`Automatating (${e.state.portals.length}/${o.add(e.state.maxConnections,w.computedBonusConnectionsModifier.value)})`}:wi(e,t=>`Auto-buy ${we[t].name}'s repeatables and dimensions`),actionDistance:Math.PI/4,actions:[un,Cn(e=>e.add(4).pow_base(1e6)),Ot],canAccept:_i,onDrop:Ni,classes:e=>({running:ye(e)}),draggable:!0},wp={shape:Ge.Diamond,size:50,title:"\u{1F4B1}",label:e=>e===w.board.selectedNode.value?{text:e.state.portals.length===0?"Investments - Drag a portal to me!":`Investing (${e.state.portals.length}/${o.add(e.state.maxConnections,w.computedBonusConnectionsModifier.value)})`}:wi(e,t=>`Auto-buy ${we[t].name}'s repeatables and dimensions`),actionDistance:Math.PI/4,actions:[un,Cn(e=>e.add(3).pow_base(1e8)),Ot],canAccept:_i,onDrop:Ni,classes:e=>({running:ye(e)}),draggable:!0},Cr=bi(),_p={mine:sp,brokenFactory:op,factory:lp,resource:up,passive:cp,dowsing:dp,quarry:pp,empowerer:fp,portalGenerator:gp,portal:mp,influence:vp,booster:hp,upgrader:bp,automator:yp,investments:wp},w=Xi("main",function(){const e=En(0,"energy"),t=_(()=>m.types.resource.nodes.value.reduce((x,D)=>(x[D.state.type]=D,x),{})),n=_(()=>({...m.types.passive.nodes.value.reduce((x,D)=>(x[D.state]=D,x),{}),sand:m.types.dowsing.nodes.value[0],wood:m.types.quarry.nodes.value[0],coal:m.types.empowerer.nodes.value[0],iron:m.types.portalGenerator.nodes.value[0],gold:m.types.booster.nodes.value[0],platinum:m.types.upgrader.nodes.value[0],berylium:m.types.automator.nodes.value[0],ultimatum:m.types.investments.nodes.value[0]})),i=_(()=>Object.keys(rn).filter(x=>`${x}Relic`in n.value).length),r=_(()=>({...m.types.influence.nodes.value.reduce((x,D)=>(x[D.state.type]=D,x),{})})),a=_(()=>({...m.types.portal.nodes.value.reduce((x,D)=>(x[D.state.id]=D,x),{})})),l=_(()=>en.reduce((x,D)=>{var G,ce,te;const R=(te=(ce=(G=t.value[D])==null?void 0:G.state)==null?void 0:ce.amount)!=null?te:0;return x[D]=o.floor(ji.invert(R)),x},{})),u=hn({}),c=hn({});Gt(()=>{en.forEach(x=>{vt(()=>l.value[x],(D,R)=>{const G=o.sub(D,R);o.gt(G,0)&&(o.gt(G,1)||o.lt(R,100))&&se.active===J.id&&Cr.info(f("div",null,[f("h3",null,[o.eq(D,1)?`${rt(x)} discovered`:`${rt(x)} is now Level ${dt(D)}`,E("!")]),o.gt(G,1)?f("div",null,[E("Gained "),dt(G),E(" levels")]):null]))})})});const d=_(()=>oe.filter(x=>{var D,R;return(R=(D=x.value)==null?void 0:D.state)==null?void 0:R.powered}).length+m.types.portal.nodes.value.filter(x=>x.state.powered).length),h=_(()=>o.eq(d.value,0)?10:o.add(d.value,1).pow_base(100).div(10).times(.99)),p=_(()=>I.value==null?0:I.value.state.resources.reduce((D,R)=>o.div(100,Vt[R].computedModifier.value).add(D),o.dZero)),m=xu(x=>({startNodes:()=>[{position:{x:0,y:0},type:"mine",state:{progress:0,powered:!1}},{position:{x:0,y:-200},type:"brokenFactory"}],types:_p,style:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden"},links(){const D=[];if(D.push(...Object.keys(u).map(R=>({startNode:v.value,endNode:t.value[R],stroke:"var(--accent3)",strokeWidth:5}))),C.value!=null&&C.value.state!=null&&D.push({startNode:C.value,endNode:t.value[C.value.state],stroke:"var(--foreground)",strokeWidth:4}),y.value!=null&&y.value.state.resources.forEach(R=>{D.push({startNode:y.value,endNode:t.value[R],stroke:ye(y.value)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),I.value!=null&&I.value.state.resources.forEach(R=>{D.push({startNode:I.value,endNode:t.value[R],stroke:"var(--foreground)",strokeWidth:4})}),D.push(...Object.keys(c).map(R=>({startNode:I.value,endNode:t.value[R],stroke:"var(--accent3)",strokeWidth:5}))),A.value!=null&&A.value.state.tools.forEach(R=>{D.push({startNode:A.value,endNode:n.value[R],stroke:ye(A.value)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),S.value!=null){const R=S.value.state;R.tier!=null&&D.push({startNode:S.value,endNode:t.value[R.tier],stroke:"var(--foreground)",strokeWidth:4}),R.influences.forEach(G=>{D.push({startNode:S.value,endNode:r.value[G],stroke:"var(--foreground)",strokeWidth:4})}),x.types.portal.nodes.value.forEach(G=>{const ce=we[G.state.id];return ce.links.value.forEach(te=>{te.value!=null&&D.push({startNode:G,endNode:te.value,stroke:ye(G)?"var(--accent3)":"var(--foreground)",strokeWidth:4})}),Object.keys(ce.resourceMultis.value).forEach(te=>{te!=="energy"&&te in t.value&&D.push({startNode:G,endNode:t.value[te],stroke:ye(G)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),D})}return P.value!=null&&P.value.state.portals.forEach(R=>{D.push({startNode:P.value,endNode:a.value[R],stroke:ye(P.value)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),B.value!=null&&B.value.state.portals.forEach(R=>{D.push({startNode:B.value,endNode:a.value[R],stroke:"var(--foreground)",strokeWidth:4})}),ie.value!=null&&ie.value.state.portals.forEach(R=>{D.push({startNode:ie.value,endNode:a.value[R],stroke:"var(--foreground)",strokeWidth:4})}),re.value!=null&&re.value.state.portals.forEach(R=>{D.push({startNode:re.value,endNode:a.value[R],stroke:"var(--foreground)",strokeWidth:4})}),Object.values(r.value).forEach(R=>{const G=R.state;(G.type==="increaseResources"||G.type==="decreaseResources")&&G.data.forEach(ce=>{D.push({startNode:R,endNode:t.value[ce],stroke:"var(--foreground)",strokeWidth:4})})}),D}})),v=_(()=>m.types.mine.nodes.value[0]),C=_(()=>m.types.factory.nodes.value[0]),y=_(()=>n.value.sand),I=_(()=>n.value.wood),A=_(()=>n.value.coal),S=_(()=>n.value.iron),P=_(()=>n.value.gold),B=_(()=>n.value.platinum),ie=_(()=>n.value.berylium),re=_(()=>n.value.ultimatum),oe=[v,y,I,A,P,B,ie,re];function H(x,D){let R=t.value[x];if(D=o.times(D,Sn[x].computedModifier.value),R==null)R={id:Kn(m),position:{...v.value.position},type:"resource",state:{type:x,amount:D}},m.placeInAvailableSpace(R),m.nodes.value.push(R);else{const G=R.state;R.state={...G,amount:o.add(G.amount,D)}}}const fe=_(()=>Object.keys(xt).reduce((x,D)=>x+new o(Vt[D].computedModifier.value).toNumber(),0)),V=_(()=>{const x={};return m.types.portal.nodes.value.forEach(D=>{if(!ye(D))return;const G=we[D.state.id].resourceMultis.value;Object.keys(G).forEach(ce=>{x[ce]!=null?x[ce]=o.times(x[ce],G[ce]):x[ce]=G[ce]})}),x}),ae=Ct(()=>en.map(x=>zt(()=>({description:()=>rt(x),addend:()=>l.value[x],enabled:()=>o.gt(l.value[x],0)})))),Re=_(()=>ae.apply(0)),Ze=Ct(()=>[zt(()=>({addend:Re,description:"Resource Levels"})),ke(()=>({multiplier:()=>o.pow(ri.value,Re.value),description:()=>`${Ut(ri.value,3)}x per Resource Level`})),ke(()=>({multiplier:()=>be("stone")?4:2,description:()=>(be("stone")?"Empowered ":"")+Le.stone.name,enabled:()=>n.value.stone!=null})),ke(()=>({multiplier:()=>{var x;return(x=V.value.energy)!=null?x:1},description:"Planar Treasures",enabled:()=>{var x;return o.neq((x=V.value.energy)!=null?x:1,1)}})),zt(()=>({addend:()=>o.pow(100,d.value).div(10).neg(),description:"Powered Machines (100^n/10 energy/s)",enabled:()=>o.gt(d.value,0)}))]),qt=_(()=>Ze.apply(0)),ft=Ct(()=>[zt(()=>({addend:()=>be("unobtainium")?2:1,description:()=>(be("unobtainium")?"Empowered ":"")+Le.unobtainium.name,enabled:()=>n.value.unobtainium!=null}))]),kn=_(()=>ft.apply(0)),qn=Ct(()=>[ke(()=>({multiplier:()=>be("dirt")?4:2,description:()=>(be("dirt")?"Empowered ":"")+Le.dirt.name,enabled:()=>n.value.dirt!=null})),ke(()=>({multiplier:()=>o.pow(i.value,be("woodRelic")?2:1),description:()=>(be("woodRelic")?"Empowered ":"")+rn.wood,enabled:()=>n.value.woodRelic!=null}))]),Yt=_(()=>qn.apply(1)),ni=Ct(()=>[ke(()=>({multiplier:()=>be("gravel")?4:2,description:()=>(be("gravel")?"Empowered ":"")+Le.gravel.name,enabled:()=>n.value.gravel!=null}))]),ii=_(()=>ni.apply(1)),Mn=Ct(()=>[zt(()=>({addend:()=>be("copper")?.004:.002,description:()=>(be("copper")?"Empowered ":"")+Le.copper.name,enabled:()=>n.value.copper!=null}))]),ri=_(()=>Mn.apply(1.01)),Vt=Object.keys(xt).reduce((x,D)=>{const R=Ct(()=>[ke(()=>({multiplier:2,description:"Dowsing",enabled:()=>y.value!=null&&ye(y.value)&&y.value.state.resources.includes(D)}))]),G=_(()=>R.apply(xt[D])),ce={title:`${rt(D)} Drop Rate`,modifier:R,base:xt[D]};return x[D]={modifier:R,computedModifier:G,section:ce},x},{}),Sn=Object.keys(xt).reduce((x,D)=>{const R=Ct(()=>[ke(()=>({multiplier:()=>{var te;return(te=V.value[D])!=null?te:1},description:"Planar Treasures",enabled:()=>{var te;return o.neq((te=V.value[D])!=null?te:1,1)}}))]),G=_(()=>R.apply(1)),ce={title:`${rt(D)} Gain`,modifier:R};return x[D]={modifier:R,computedModifier:G,section:ce},x},{}),ai=_(()=>{var D,R,G;const x=en.indexOf((G=(R=(D=S.value)==null?void 0:D.state)==null?void 0:R.tier)!=null?G:"dirt");return o.add(x,1).times(x).div(2).add(9).pow10()}),si=Ct(()=>Object.keys(kt).map(x=>ke(()=>({multiplier:kt[x].cost,description:kt[x].display,enabled:()=>{var D,R,G;return(G=(R=(D=S.value)==null?void 0:D.state)==null?void 0:R.influences.includes(x))!=null?G:!1}})))),Si=_(()=>si.apply(ai.value)),[Ii,Qe]=Gn(()=>[{title:"Resource Levels",modifier:ae,base:0},{title:"Energy Gain",modifier:Ze,base:0,unit:"/s"},{title:"Portal Cost",modifier:si,base:ai,unit:" energy",baseText:()=>{var x,D,R;return`${rt((R=(D=(x=S.value)==null?void 0:x.state)==null?void 0:D.tier)!=null?R:"dirt")}-tier Base Cost`},visible:()=>S.value!=null},{title:"Bonus Connections",modifier:ft,base:0,visible:()=>o.gt(kn.value,0)}]),[$i,xi]=Gn(()=>[{title:"Mining Speed",modifier:qn,base:1,unit:"/s",visible:()=>n.value.dirt!=null},{title:"Ore Dropped",modifier:ni,base:1,visible:()=>n.value.gravel!=null},{title:"Material Level Effect",modifier:Mn,base:1.01,visible:()=>n.value.copper!=null}]),[q,L]=Gn(()=>Object.values(Vt).map(x=>x.section)),[Me,et]=Gn(()=>Object.values(Sn).map(x=>x.section)),$t=qu({general:()=>({display:"General",glowColor(){return $t.activeTab.value===this.tab?"white":""},tab:Ii,energyTabCollapsed:Qe}),mining:()=>({display:"Mine",glowColor(){return $t.activeTab.value===this.tab?"white":""},visibility:()=>Object.keys(n.value).length>0,tab:$i,miningTabCollapsed:xi}),resources:()=>({display:"Mine Rates",glowColor(){return $t.activeTab.value===this.tab?"white":""},visibility:()=>y.value!=null,tab:q,resourcesCollapsed:L}),resourcesGain:()=>({display:"Resource Gain",glowColor(){return $t.activeTab.value===this.tab?"white":""},visibility:()=>Object.values(Sn).some(x=>o.neq(x.computedModifier.value,1)),tab:Me,resourceGainCollapsed:et})}),tt=z(!1),Xt=X(()=>f(Ht,{modelValue:tt.value,"onUpdate:modelValue":x=>tt.value=x},{header:()=>f("h2",null,[E("Modifiers")]),body:()=>st($t)}));this.on("preUpdate",x=>{if(Object.keys(u).forEach(D=>{u[D]-=x,u[D]<=0&&delete u[D]}),Object.keys(c).forEach(D=>{c[D]-=x,c[D]<=0&&delete c[D]}),ye(v.value)){const D=o.add(v.value.state.progress,o.times(Yt.value,x)),R=D.floor();v.value.state={...v.value.state,progress:o.sub(D,R)};const G=R.div(fe.value).floor();G.gt(0)&&en.forEach(te=>{H(te,o.times(new o(Vt[te].computedModifier.value).toNumber(),G).times(ii.value)),u[te]=.3});const ce=o.sub(R,G).toNumber();for(let te=0;te<ce;te++){const De=Math.floor(Math.random()*fe.value);let _t=0;for(let Lt=0;Lt<en.length;Lt++){const Vn=en[Lt];if(_t+=new o(Vt[Vn].computedModifier.value).toNumber(),De<_t){H(Vn,ii.value),u[Vn]=.3;break}}}}if(I.value!=null&&ye(I.value)){const{progress:D,resources:R}=I.value.state;if(R.length>0){let G=o.add(D,x);const ce=o.div(D,p.value).floor();G=o.sub(G,o.times(ce,p.value)),I.value.state={...I.value.state,progress:G},o.gt(ce,0)&&R.forEach(te=>{H(te,ce),c[te]=.3})}}e.value=o.add(e.value,o.times(qt.value,x)),o.lt(e.value,0)&&(e.value=0,v.value.state={...v.value.state,powered:!1},Cr.warning(f("div",null,[f("h3",null,[E("Ran out of energy!")]),f("div",null,[E("All machines have been turned off.")])])))});const Dt=_(()=>{var x,D;return m.selectedAction.value===m.types.brokenFactory.actions[0]?-100:m.selectedAction.value===m.types.factory.actions[1]?o.neg(Le[m.selectedNode.value.state].cost):((x=m.selectedAction.value)==null?void 0:x.id)==="moreConnections"?o.neg(m.selectedAction.value.formula.evaluate(((D=m.selectedNode.value)==null?void 0:D.state).maxConnections)):0}),Jt=fn(g.variable(0).add(e),()=>o.neq(Dt.value,0),Dt),nt=_(()=>{var x;return m.selectedAction.value===Ot?((x=m.selectedNode.value)==null?void 0:x.state).powered?o.eq(d.value,1)?10:o.pow(100,d.value).div(10).times(.99):o.neg(h.value):0}),Bt=fn(g.variable(0).add(qt),()=>o.neq(nt.value,0),nt),Kt=_(()=>m.types.portal.nodes.value.filter(x=>ye(x)));return vt(Kt,x=>{Gt(()=>{J.tabs=["main",...x.map(D=>D.state.id)]})}),vt(kn,(x,D)=>{o.lt(x,D)&&(pn(x,y,"resources"),pn(x,I,"resources"),pn(x,A,"tools"),pn(x,P,"portals"),pn(x,B,"portals"),pn(x,ie,"portals"),pn(x,re,"portals"))}),{name:"World",board:m,energy:e,modifierTabs:$t,resourceNodes:t,toolNodes:n,influenceNodes:r,grantResource:H,activePortals:Kt,nextPowerCost:h,computedBonusConnectionsModifier:kn,quarryProgressRequired:p,dropRates:Vt,dowsing:y,empowerer:A,booster:P,upgrader:B,automator:ie,investments:re,resourceLevels:l,planarMultis:V,computedPortalCost:Si,display:X(()=>f(ee,null,[f(mi,{class:"nav-container"},{default:()=>[f("span",{class:"nav-segment"},[f("h2",{style:"color: white; text-shadow: 0px 0px 10px white;"},[st(Jt)])," ",E("energy")]),f("span",{class:"nav-segment"},[E("("),f("h3",{style:"color: white; text-shadow: 0px 0px 10px white;"},[o.gt(qt.value,0)?"+":"",st(Bt)]),E("/s)")]),o.gt(d.value,0)?f("span",{class:"nav-segment"},[f("h3",{style:"color: var(--accent1); text-shadow: 0px 0px 10px var(--accent1);"},[dt(d.value)])," ",E("machines powered")]):null,f("span",{class:"nav-segment"},[f("button",{class:"button",style:"display: inline",onClick:()=>tt.value=!0},[E("modifiers")])]),J.devSpeed===0?f("span",{class:"nav-segment"},[E("Game Paused")]):J.devSpeed!=null&&J.devSpeed!==1?f("span",{class:"nav-segment"},[E("Dev Speed: "),_e(J.devSpeed),E("x")]):null]}),st(m),st(Xt)]))}}),Np=e=>{var i,r,a,l,u;const t=[w];let n=0;for(;`portal-${n}`in((i=e.layers)!=null?i:{});){const c=(r=e.layers)==null?void 0:r[`portal-${n}`];t.push(ra(`portal-${n}`,(a=c.tier)!=null?a:"dirt",(l=c.seed)!=null?l:Math.floor(Math.random()*4294967296),(u=c.influences)!=null?u:[])),n++}return t},nr=z(!1);function Cp(e,t){}var kp=Object.freeze(Object.defineProperty({__proto__:null,main:w,getInitialLayers:Np,hasWon:nr,fixOldSave:Cp},Symbol.toStringTag,{value:"Module"}));const ti=e=>(yn("data-v-4a50ce42"),e=e(),wn(),e),Mp={class:"game-over-modal-header"},Sp=["src","alt"],Ip={class:"game-over-modal-title"},$p=ti(()=>N("h2",null,"Congratulations!",-1)),xp={key:0},Ep=ti(()=>N("br",null,null,-1)),Pp=ti(()=>N("div",null," Please check the Discord to discuss the game or to check for new content updates! ",-1)),Dp=ti(()=>N("br",null,null,-1)),Tp=["href"],Ap=ti(()=>N("span",{class:"material-icons game-over-modal-discord"},"discord",-1)),Fp=Y({__name:"GameOverScreen",setup(e){const{title:t,logo:n,discordName:i,discordLink:r,versionNumber:a,versionTitle:l}=me,u=_(()=>yi(J.timePlayed)),c=_(()=>nr.value&&!J.keepGoing),d=sn(J,"autosave");function h(){J.keepGoing=!0}function p(){gn(Dn())}return(m,v)=>(M(),K(Ht,{"model-value":s(c)},{header:W(()=>[N("div",Mp,[s(n)?(M(),T("img",{key:0,class:"game-over-modal-logo",src:s(n),alt:s(t)},null,8,Sp)):j("",!0),N("div",Ip,[$p,N("h4",null,"You've beaten "+le(s(t))+" v"+le(s(a))+": "+le(s(l)),1)])])]),body:W(({shown:C})=>[C?(M(),T("div",xp,[N("div",null,"It took you "+le(s(u))+" to beat the game.",1),Ep,Pp,Dp,N("div",null,[N("a",{href:s(r),class:"game-over-modal-discord-link"},[Ap,E(" "+le(s(i)),1)],8,Tp)]),f(jt,{title:"Autosave",modelValue:s(d),"onUpdate:modelValue":v[0]||(v[0]=y=>Ve(d)?d.value=y:null)},null,8,["modelValue"])])):j("",!0)]),footer:W(()=>[N("div",{class:"game-over-footer"},[N("button",{onClick:h,class:"button"},"Keep Going"),N("button",{onClick:p,class:"button danger"},"Play Again")])]),_:1},8,["model-value"]))}});var Rp=pe(Fp,[["__scopeId","data-v-4a50ce42"]]);const Mi=e=>(yn("data-v-2776d67d"),e=e(),wn(),e),Op=Mi(()=>N("div",{class:"nan-modal-header"},[N("h2",null,"NaN value detected!")],-1)),qp={key:0},Vp=Mi(()=>N("br",null,null,-1)),Bp=["href"],Lp=Mi(()=>N("span",{class:"material-icons nan-modal-discord"},"discord",-1)),jp=Mi(()=>N("br",null,null,-1)),zp={class:"nan-footer"},Up=Y({__name:"NaNScreen",setup(e){const{discordName:t,discordLink:n}=me,i=z(!0),r=z(!0),a=sn(ze,"hasNaN"),l=z(null);vt(a,m=>{m?(i.value=J.autosave,r.value=J.devSpeed===0):(J.autosave=i.value,J.devSpeed=r.value?0:null)});const u=_(()=>{var m;return(m=ze.NaNPath)==null?void 0:m.join(".")}),c=_(()=>ze.NaNPersistent!=null?ze.NaNPersistent.value:null);function d(){ze.NaNPersistent!=null&&(ze.NaNPersistent.value=new o(0),ze.hasNaN=!1)}function h(){ze.NaNPersistent&&(ze.NaNPersistent.value=new o(1),ze.hasNaN=!1)}function p(){ze.NaNPersistent&&(ze.NaNPersistent.value=new o(NaN),ze.hasNaN=!1)}return(m,v)=>(M(),T(ee,null,[f(Ht,Wt({modelValue:s(a),"onUpdate:modelValue":v[4]||(v[4]=C=>Ve(a)?a.value=C:null)},m.$attrs),{header:W(()=>[Op]),body:W(()=>[N("div",null,[E(' Attempted to assign "'+le(s(u))+'" to NaN',1),s(c)?(M(),T("span",qp,le(" ")+"(previously "+le(s(_e)(s(c)))+")",1)):j("",!0),E(". Auto-saving has been "+le(i.value?"enabled":"disabled")+". Check the console for more details, and consider sharing it with the developers on discord. ",1)]),Vp,N("div",null,[N("a",{href:s(n)||"https://discord.gg/yJ4fjnjU54",class:"nan-modal-discord-link"},[Lp,E(" "+le(s(t)||"The Paper Pilot Community"),1)],8,Bp)]),jp,f(jt,{title:"Autosave",modelValue:i.value,"onUpdate:modelValue":v[0]||(v[0]=C=>i.value=C)},null,8,["modelValue"]),s(me).enablePausing?(M(),K(jt,{key:0,title:"Pause game",modelValue:r.value,"onUpdate:modelValue":v[1]||(v[1]=C=>r.value=C)},null,8,["modelValue"])):j("",!0)]),footer:W(()=>[N("div",zp,[N("button",{onClick:v[2]||(v[2]=C=>{var y;return(y=l.value)==null?void 0:y.open()}),class:"button"},"Open Saves Manager"),N("button",{onClick:d,class:"button"},"Set to 0"),N("button",{onClick:h,class:"button"},"Set to 1"),s(c)&&s(o).neq(s(c),0)&&s(o).neq(s(c),1)?(M(),T("button",{key:0,onClick:v[3]||(v[3]=C=>a.value=!1),class:"button"}," Set to previous ")):j("",!0),N("button",{onClick:p,class:"button danger"},"Ignore")])]),_:1},16,["modelValue"]),f(Ur,{ref_key:"savesManager",ref:l},null,512)],64))}});var Gp=pe(Up,[["__scopeId","data-v-2776d67d"]]);const Wp={key:0,class:"tpsDisplay"},Hp=Y({__name:"TPS",setup(e){const t=_(()=>o.div(ze.lastTenTicks.length,ze.lastTenTicks.reduce((n,i)=>n+i,0)));return(n,i)=>s(t).isNan()?j("",!0):(M(),T("div",Wp,"TPS: "+le(s(dt)(s(t))),1))}});var Zp=pe(Hp,[["__scopeId","data-v-89b89152"]]);var Yp=Y({__name:"App",setup(e){const t=me.useHeader,n=_(()=>Mt[se.theme].variables),i=sn(se,"showTPS"),r=_(()=>ue(X(()=>f(ee,null,[As.map(st)]))));return(a,l)=>(M(),T(ee,null,[N("div",{id:"modal-root",style:je(s(n))},null,4),N("div",{class:he(["app",{useHeader:s(t)}]),style:je(s(n))},[s(t)?(M(),K(Gr,{key:0})):j("",!0),f(Jl),s(s(i))?(M(),K(Zp,{key:1})):j("",!0),f(Rp),f(Gp),(M(),K(Xe(s(r))))],6)],64))}});var Xp=pe(Yp,[["__scopeId","data-v-41d15e5e"]]);function Jp(e={}){const{immediate:t=!1,onNeedRefresh:n,onOfflineReady:i,onRegistered:r,onRegisteredSW:a,onRegisterError:l}=e;let u,c,d,h;const p=async(v=!0)=>{await d,v&&(u==null||u.addEventListener("controlling",C=>{C.isUpdate&&window.location.reload()})),await(h==null?void 0:h())};async function m(){if("serviceWorker"in navigator){const{Workbox:v,messageSW:C}=await Hn(()=>import("./workbox-window.4a8794bb.js"),[]);h=async()=>{c&&c.waiting&&await C(c.waiting,{type:"SKIP_WAITING"})},u=new v("./sw.js",{scope:"./",type:"classic"}),u.addEventListener("activated",y=>{y.isUpdate||i==null||i()});{const y=()=>{n==null||n()};u.addEventListener("waiting",y),u.addEventListener("externalwaiting",y)}u.register({immediate:t}).then(y=>{c=y,a?a("./sw.js",y):r==null||r(y)}).catch(y=>{l==null||l(y)})}}return d=m(),p}function Kp(e={}){const{immediate:t=!0,onNeedRefresh:n,onOfflineReady:i,onRegistered:r,onRegisteredSW:a,onRegisterError:l}=e,u=z(!1),c=z(!1);return{updateServiceWorker:Jp({immediate:t,onNeedRefresh(){u.value=!0,n==null||n()},onOfflineReady(){c.value=!0,i==null||i()},onRegistered:r,onRegisteredSW:a,onRegisterError:l}),offlineReady:c,needRefresh:u}}document.title=me.title;window.projInfo=me;if(me.id==="")throw new Error("Project ID is empty! Please select a unique ID for this project in /src/data/projInfo.json");requestAnimationFrame(async()=>{console.log(`%cMade in Profectus%c
Learn more at www.moddingtree.com`,"font-weight: bold; font-size: 24px; color: #A3BE8C; background: #2E3440; padding: 4px 8px; border-radius: 8px;","padding: 4px;"),await $s();const{globalBus:e}=await Hn(()=>Promise.resolve().then(function(){return Ss}),void 0),{startGameLoop:t}=await Hn(()=>import("./gameLoop.bc941561.js"),["assets/gameLoop.bc941561.js","assets/@fontsource.f66d05e7.css","assets/vue.c16a309b.js","assets/amator.1e5a40c8.js","assets/bezier-easing.a990b400.js","assets/@vue.6b211d3c.js","assets/nanoevents.1080beb7.js","assets/lz-string.dccec454.js","assets/vue-next-select.ded54c4a.js","assets/vue-next-select.9e6f4164.css","assets/vuedraggable.1879de79.js","assets/sortablejs.a0f68e5e.js","assets/vue-textarea-autosize.35804eaf.js","assets/vue-panzoom.8ce6f9b1.js","assets/panzoom.30c56ba6.js","assets/wheel.f2ae740f.js","assets/ngraph.events.083734c6.js","assets/vue-toastification.9c2dad53.js","assets/vue-toastification.4b5f8ac8.css"]),n=window.vue=Ca(Xp);e.emit("setupVue",n),n.mount("#app"),Gt(()=>{const i=bi(),{updateServiceWorker:r}=Kp({onNeedRefresh(){i.info("New content available, click here to update.",{timeout:!1,closeOnClick:!1,draggable:!1,icon:{iconClass:"material-icons",iconChildren:"refresh",iconTag:"i"},rtl:!1,onClick(){r()}})},onOfflineReady(){i.info("App ready to work offline")},onRegisterError:console.warn,onRegistered(a){a&&setInterval(()=>a.update(),60*60*1e3)}})}),t()});export{o as D,Hn as _,ze as a,me as b,kp as c,Je as g,xs as l,J as p,se as s};