@kitten-science/kitten-scientists 2.0.0-beta.11-dev.20250601115514 → 2.0.0-beta.11-nightly.20250605

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/lib/BonfireManager.d.ts +2 -6
  2. package/lib/BonfireManager.d.ts.map +1 -1
  3. package/lib/BonfireManager.js +11 -33
  4. package/lib/BonfireManager.js.map +1 -1
  5. package/lib/Engine.d.ts +7 -2
  6. package/lib/Engine.d.ts.map +1 -1
  7. package/lib/Engine.js +8 -8
  8. package/lib/Engine.js.map +1 -1
  9. package/lib/KittenScientists.d.ts.map +1 -1
  10. package/lib/KittenScientists.js +0 -3
  11. package/lib/KittenScientists.js.map +1 -1
  12. package/lib/ReligionManager.d.ts +3 -5
  13. package/lib/ReligionManager.d.ts.map +1 -1
  14. package/lib/ReligionManager.js +93 -92
  15. package/lib/ReligionManager.js.map +1 -1
  16. package/lib/ScienceManager.d.ts +0 -3
  17. package/lib/ScienceManager.d.ts.map +1 -1
  18. package/lib/ScienceManager.js +2 -8
  19. package/lib/ScienceManager.js.map +1 -1
  20. package/lib/SpaceManager.d.ts +2 -5
  21. package/lib/SpaceManager.d.ts.map +1 -1
  22. package/lib/SpaceManager.js +9 -33
  23. package/lib/SpaceManager.js.map +1 -1
  24. package/lib/TimeControlManager.d.ts +0 -3
  25. package/lib/TimeControlManager.d.ts.map +1 -1
  26. package/lib/TimeControlManager.js +2 -5
  27. package/lib/TimeControlManager.js.map +1 -1
  28. package/lib/TimeManager.d.ts +1 -5
  29. package/lib/TimeManager.d.ts.map +1 -1
  30. package/lib/TimeManager.js +14 -26
  31. package/lib/TimeManager.js.map +1 -1
  32. package/lib/TradeManager.d.ts +1 -10
  33. package/lib/TradeManager.d.ts.map +1 -1
  34. package/lib/TradeManager.js +0 -24
  35. package/lib/TradeManager.js.map +1 -1
  36. package/lib/UpgradeManager.d.ts +0 -2
  37. package/lib/UpgradeManager.d.ts.map +1 -1
  38. package/lib/UpgradeManager.js.map +1 -1
  39. package/lib/VillageManager.d.ts +2 -5
  40. package/lib/VillageManager.d.ts.map +1 -1
  41. package/lib/VillageManager.js +26 -20
  42. package/lib/VillageManager.js.map +1 -1
  43. package/lib/WorkshopManager.d.ts +4 -10
  44. package/lib/WorkshopManager.d.ts.map +1 -1
  45. package/lib/WorkshopManager.js +51 -40
  46. package/lib/WorkshopManager.js.map +1 -1
  47. package/lib/i18n/en-US.json +1 -0
  48. package/lib/settings/EngineSettings.d.ts +6 -1
  49. package/lib/settings/EngineSettings.d.ts.map +1 -1
  50. package/lib/settings/EngineSettings.js +8 -1
  51. package/lib/settings/EngineSettings.js.map +1 -1
  52. package/lib/settings/ResetUpgradeSettings.d.ts +1 -1
  53. package/lib/settings/TechSettings.d.ts +1 -1
  54. package/lib/settings/UpgradeSettings.d.ts +3 -2
  55. package/lib/settings/UpgradeSettings.d.ts.map +1 -1
  56. package/lib/settings/UpgradeSettings.js +1 -0
  57. package/lib/settings/UpgradeSettings.js.map +1 -1
  58. package/lib/types/core.d.ts +4 -4
  59. package/lib/types/core.d.ts.map +1 -1
  60. package/lib/types/game.d.ts +50 -1
  61. package/lib/types/game.d.ts.map +1 -1
  62. package/lib/types/index.d.ts +59 -3
  63. package/lib/types/index.d.ts.map +1 -1
  64. package/lib/types/index.js +15 -0
  65. package/lib/types/index.js.map +1 -1
  66. package/lib/types/time.d.ts +5 -2
  67. package/lib/types/time.d.ts.map +1 -1
  68. package/lib/ui/InternalsUi.d.ts.map +1 -1
  69. package/lib/ui/InternalsUi.js +1 -0
  70. package/lib/ui/InternalsUi.js.map +1 -1
  71. package/output/kitten-scientists-0.0.0-ci.min.user.js +8 -8
  72. package/output/kitten-scientists-0.0.0-ci.min.user.js.map +1 -1
  73. package/output/kitten-scientists-0.0.0-ci.user.js +229 -262
  74. package/output/kitten-scientists-0.0.0-ci.user.js.map +1 -1
  75. package/output/kitten-scientists-loader-0.0.0-ci.min.user.js +1 -1
  76. package/output/kitten-scientists-loader-0.0.0-ci.min.user.js.map +1 -1
  77. package/output/kitten-scientists-loader-0.0.0-ci.user.js +1 -1
  78. package/output/kitten-scientists.inject.js +16890 -15439
  79. package/output/kitten-scientists.inject.js.map +1 -1
  80. package/output/kitten-scientists.min.inject.js +11 -11
  81. package/output/kitten-scientists.min.inject.js.map +1 -1
  82. package/package.json +3 -4
  83. package/lib/TabManager.d.ts +0 -10
  84. package/lib/TabManager.d.ts.map +0 -1
  85. package/lib/TabManager.js +0 -21
  86. package/lib/TabManager.js.map +0 -1
@@ -19,8 +19,8 @@
19
19
  // @version 0.0.0-ci
20
20
  // @grant none
21
21
  // ==/UserScript==
22
- (function(U,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("dojo")):typeof define=="function"&&define.amd?define(["exports","dojo"],R):(U=typeof globalThis<"u"?globalThis:U||self,R(U["kitten-scientists"]=U["kitten-scientists"]||{}))})(this,function(U){"use strict";var Yo=Object.defineProperty;var Os=U=>{throw TypeError(U)};var Qo=(U,R,m)=>R in U?Yo(U,R,{enumerable:!0,configurable:!0,writable:!0,value:m}):U[R]=m;var u=(U,R,m)=>Qo(U,typeof R!="symbol"?R+"":R,m),Us=(U,R,m)=>R.has(U)||Os("Cannot "+m);var I=(U,R,m)=>(Us(U,R,"read from private field"),m?m.call(U):R.get(U)),L=(U,R,m)=>R.has(U)?Os("Cannot add the same private member more than once"):R instanceof WeakSet?R.add(U):R.set(U,m),O=(U,R,m,ve)=>(Us(U,R,"write to private field"),ve?ve.call(U,m):R.set(U,m),m);var Ue,De,Ne,qe,ze,Fe,He,We,Ge,Ze,Ke,Ve,je,Je,Xe,Ye,Qe,et,tt,it,st,nt,at,rt,ot,lt,ct,ht,ut,dt,Is;const R=c=>e=>{c.error(e)};function m(c){return c==null}function ve(c,s){return!m(c)&&c instanceof s}class Ds extends Error{constructor(s="unexpected nil value"){super(s)}}function p(c,s){if(m(c))throw new Ds(s);return c}function ft(c,s){const e=new Array;for(const t of c)m(t)?m(s)||e.push(s):e.push(t);return e}class fe extends Error{constructor(e,t,i){super(t);u(this,"status");u(this,"code");this.code=e,this.name="AbstractError",this.status=i,typeof Error.captureStackTrace<"u"&&Error.captureStackTrace(this,fe)}static isAbstractError(e,t=!0){if(e instanceof fe)return!0;if(t){const i=e;if(Object(e)===e&&"code"in i&&typeof i.code=="string"&&e.code.match(/^ERR_OS_/))return!0}return!1}}class bt extends fe{constructor(s,e=400){super("ERR_OS_INVALID_OPERATION",s,e),this.name="InvalidOperationError",typeof Error.captureStackTrace<"u"&&Error.captureStackTrace(this,bt)}}var qt,Pi;function Ii(){return Pi||(Pi=1,qt=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...s)=>console.error("SEMVER",...s):()=>{}),qt}var zt,$i;function Li(){if($i)return zt;$i=1;const c="2.0.0",s=256,e=Number.MAX_SAFE_INTEGER||9007199254740991,t=16,i=s-6;return zt={MAX_LENGTH:s,MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:i,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:c,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},zt}var pt={exports:{}},Oi;function Ns(){return Oi||(Oi=1,function(c,s){const{MAX_SAFE_COMPONENT_LENGTH:e,MAX_SAFE_BUILD_LENGTH:t,MAX_LENGTH:i}=Li(),n=Ii();s=c.exports={};const a=s.re=[],r=s.safeRe=[],o=s.src=[],l=s.safeSrc=[],h=s.t={};let d=0;const g="[a-zA-Z0-9-]",f=[["\\s",1],["\\d",i],[g,t]],w=k=>{for(const[y,P]of f)k=k.split(`${y}*`).join(`${y}{0,${P}}`).split(`${y}+`).join(`${y}{1,${P}}`);return k},b=(k,y,P)=>{const j=w(y),Q=d++;n(k,Q,y),h[k]=Q,o[Q]=y,l[Q]=j,a[Q]=new RegExp(y,P?"g":void 0),r[Q]=new RegExp(j,P?"g":void 0)};b("NUMERICIDENTIFIER","0|[1-9]\\d*"),b("NUMERICIDENTIFIERLOOSE","\\d+"),b("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${g}*`),b("MAINVERSION",`(${o[h.NUMERICIDENTIFIER]})\\.(${o[h.NUMERICIDENTIFIER]})\\.(${o[h.NUMERICIDENTIFIER]})`),b("MAINVERSIONLOOSE",`(${o[h.NUMERICIDENTIFIERLOOSE]})\\.(${o[h.NUMERICIDENTIFIERLOOSE]})\\.(${o[h.NUMERICIDENTIFIERLOOSE]})`),b("PRERELEASEIDENTIFIER",`(?:${o[h.NONNUMERICIDENTIFIER]}|${o[h.NUMERICIDENTIFIER]})`),b("PRERELEASEIDENTIFIERLOOSE",`(?:${o[h.NONNUMERICIDENTIFIER]}|${o[h.NUMERICIDENTIFIERLOOSE]})`),b("PRERELEASE",`(?:-(${o[h.PRERELEASEIDENTIFIER]}(?:\\.${o[h.PRERELEASEIDENTIFIER]})*))`),b("PRERELEASELOOSE",`(?:-?(${o[h.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[h.PRERELEASEIDENTIFIERLOOSE]})*))`),b("BUILDIDENTIFIER",`${g}+`),b("BUILD",`(?:\\+(${o[h.BUILDIDENTIFIER]}(?:\\.${o[h.BUILDIDENTIFIER]})*))`),b("FULLPLAIN",`v?${o[h.MAINVERSION]}${o[h.PRERELEASE]}?${o[h.BUILD]}?`),b("FULL",`^${o[h.FULLPLAIN]}$`),b("LOOSEPLAIN",`[v=\\s]*${o[h.MAINVERSIONLOOSE]}${o[h.PRERELEASELOOSE]}?${o[h.BUILD]}?`),b("LOOSE",`^${o[h.LOOSEPLAIN]}$`),b("GTLT","((?:<|>)?=?)"),b("XRANGEIDENTIFIERLOOSE",`${o[h.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),b("XRANGEIDENTIFIER",`${o[h.NUMERICIDENTIFIER]}|x|X|\\*`),b("XRANGEPLAIN",`[v=\\s]*(${o[h.XRANGEIDENTIFIER]})(?:\\.(${o[h.XRANGEIDENTIFIER]})(?:\\.(${o[h.XRANGEIDENTIFIER]})(?:${o[h.PRERELEASE]})?${o[h.BUILD]}?)?)?`),b("XRANGEPLAINLOOSE",`[v=\\s]*(${o[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[h.XRANGEIDENTIFIERLOOSE]})(?:${o[h.PRERELEASELOOSE]})?${o[h.BUILD]}?)?)?`),b("XRANGE",`^${o[h.GTLT]}\\s*${o[h.XRANGEPLAIN]}$`),b("XRANGELOOSE",`^${o[h.GTLT]}\\s*${o[h.XRANGEPLAINLOOSE]}$`),b("COERCEPLAIN",`(^|[^\\d])(\\d{1,${e}})(?:\\.(\\d{1,${e}}))?(?:\\.(\\d{1,${e}}))?`),b("COERCE",`${o[h.COERCEPLAIN]}(?:$|[^\\d])`),b("COERCEFULL",o[h.COERCEPLAIN]+`(?:${o[h.PRERELEASE]})?(?:${o[h.BUILD]})?(?:$|[^\\d])`),b("COERCERTL",o[h.COERCE],!0),b("COERCERTLFULL",o[h.COERCEFULL],!0),b("LONETILDE","(?:~>?)"),b("TILDETRIM",`(\\s*)${o[h.LONETILDE]}\\s+`,!0),s.tildeTrimReplace="$1~",b("TILDE",`^${o[h.LONETILDE]}${o[h.XRANGEPLAIN]}$`),b("TILDELOOSE",`^${o[h.LONETILDE]}${o[h.XRANGEPLAINLOOSE]}$`),b("LONECARET","(?:\\^)"),b("CARETTRIM",`(\\s*)${o[h.LONECARET]}\\s+`,!0),s.caretTrimReplace="$1^",b("CARET",`^${o[h.LONECARET]}${o[h.XRANGEPLAIN]}$`),b("CARETLOOSE",`^${o[h.LONECARET]}${o[h.XRANGEPLAINLOOSE]}$`),b("COMPARATORLOOSE",`^${o[h.GTLT]}\\s*(${o[h.LOOSEPLAIN]})$|^$`),b("COMPARATOR",`^${o[h.GTLT]}\\s*(${o[h.FULLPLAIN]})$|^$`),b("COMPARATORTRIM",`(\\s*)${o[h.GTLT]}\\s*(${o[h.LOOSEPLAIN]}|${o[h.XRANGEPLAIN]})`,!0),s.comparatorTrimReplace="$1$2$3",b("HYPHENRANGE",`^\\s*(${o[h.XRANGEPLAIN]})\\s+-\\s+(${o[h.XRANGEPLAIN]})\\s*$`),b("HYPHENRANGELOOSE",`^\\s*(${o[h.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[h.XRANGEPLAINLOOSE]})\\s*$`),b("STAR","(<|>)?=?\\s*\\*"),b("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),b("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(pt,pt.exports)),pt.exports}var Ft,Ui;function qs(){if(Ui)return Ft;Ui=1;const c=Object.freeze({loose:!0}),s=Object.freeze({});return Ft=t=>t?typeof t!="object"?c:t:s,Ft}var Ht,Di;function zs(){if(Di)return Ht;Di=1;const c=/^[0-9]+$/,s=(t,i)=>{const n=c.test(t),a=c.test(i);return n&&a&&(t=+t,i=+i),t===i?0:n&&!a?-1:a&&!n?1:t<i?-1:1};return Ht={compareIdentifiers:s,rcompareIdentifiers:(t,i)=>s(i,t)},Ht}var Wt,Ni;function Fs(){if(Ni)return Wt;Ni=1;const c=Ii(),{MAX_LENGTH:s,MAX_SAFE_INTEGER:e}=Li(),{safeRe:t,t:i}=Ns(),n=qs(),{compareIdentifiers:a}=zs();class r{constructor(l,h){if(h=n(h),l instanceof r){if(l.loose===!!h.loose&&l.includePrerelease===!!h.includePrerelease)return l;l=l.version}else if(typeof l!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof l}".`);if(l.length>s)throw new TypeError(`version is longer than ${s} characters`);c("SemVer",l,h),this.options=h,this.loose=!!h.loose,this.includePrerelease=!!h.includePrerelease;const d=l.trim().match(h.loose?t[i.LOOSE]:t[i.FULL]);if(!d)throw new TypeError(`Invalid Version: ${l}`);if(this.raw=l,this.major=+d[1],this.minor=+d[2],this.patch=+d[3],this.major>e||this.major<0)throw new TypeError("Invalid major version");if(this.minor>e||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>e||this.patch<0)throw new TypeError("Invalid patch version");d[4]?this.prerelease=d[4].split(".").map(g=>{if(/^[0-9]+$/.test(g)){const f=+g;if(f>=0&&f<e)return f}return g}):this.prerelease=[],this.build=d[5]?d[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(l){if(c("SemVer.compare",this.version,this.options,l),!(l instanceof r)){if(typeof l=="string"&&l===this.version)return 0;l=new r(l,this.options)}return l.version===this.version?0:this.compareMain(l)||this.comparePre(l)}compareMain(l){return l instanceof r||(l=new r(l,this.options)),a(this.major,l.major)||a(this.minor,l.minor)||a(this.patch,l.patch)}comparePre(l){if(l instanceof r||(l=new r(l,this.options)),this.prerelease.length&&!l.prerelease.length)return-1;if(!this.prerelease.length&&l.prerelease.length)return 1;if(!this.prerelease.length&&!l.prerelease.length)return 0;let h=0;do{const d=this.prerelease[h],g=l.prerelease[h];if(c("prerelease compare",h,d,g),d===void 0&&g===void 0)return 0;if(g===void 0)return 1;if(d===void 0)return-1;if(d===g)continue;return a(d,g)}while(++h)}compareBuild(l){l instanceof r||(l=new r(l,this.options));let h=0;do{const d=this.build[h],g=l.build[h];if(c("build compare",h,d,g),d===void 0&&g===void 0)return 0;if(g===void 0)return 1;if(d===void 0)return-1;if(d===g)continue;return a(d,g)}while(++h)}inc(l,h,d){if(l.startsWith("pre")){if(!h&&d===!1)throw new Error("invalid increment argument: identifier is empty");if(h){const g=`-${h}`.match(this.options.loose?t[i.PRERELEASELOOSE]:t[i.PRERELEASE]);if(!g||g[1]!==h)throw new Error(`invalid identifier: ${h}`)}}switch(l){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",h,d);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",h,d);break;case"prepatch":this.prerelease.length=0,this.inc("patch",h,d),this.inc("pre",h,d);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",h,d),this.inc("pre",h,d);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const g=Number(d)?1:0;if(this.prerelease.length===0)this.prerelease=[g];else{let f=this.prerelease.length;for(;--f>=0;)typeof this.prerelease[f]=="number"&&(this.prerelease[f]++,f=-2);if(f===-1){if(h===this.prerelease.join(".")&&d===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(g)}}if(h){let f=[h,g];d===!1&&(f=[h]),a(this.prerelease[0],h)===0?isNaN(this.prerelease[1])&&(this.prerelease=f):this.prerelease=f}break}default:throw new Error(`invalid increment argument: ${l}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return Wt=r,Wt}var Gt,qi;function Hs(){if(qi)return Gt;qi=1;const c=Fs();return Gt=(e,t,i)=>new c(e,i).compare(new c(t,i)),Gt}var Zt,zi;function Ws(){if(zi)return Zt;zi=1;const c=Hs();return Zt=(e,t,i)=>c(e,t,i)>0,Zt}Ws();class Be extends fe{constructor(s,e=500){super("ERR_OS_INTERNAL",s,e),this.name="InternalError",typeof Error.captureStackTrace<"u"&&Error.captureStackTrace(this,Be)}static fromError(s){const e=new Be(s.message);return Object.assign(e,s,new Be(s.message)),e.stack=s.stack,e}}class Kt extends fe{constructor(s,e=500){super("ERR_OS_UNKNOWN",s,e),this.name="UnknownError",typeof Error.captureStackTrace<"u"&&Error.captureStackTrace(this,Kt)}}const Gs=c=>c instanceof Error||Object.prototype.toString.call(c)==="[object Error]",Zs=c=>fe.isAbstractError(c)?c:Gs(c)?Be.fromError(c):new Kt(String(c)),ye=c=>{const s=performance.now();return[c(),performance.now()-s]},vt=async c=>{const s=performance.now();return[await c(),performance.now()-s]},ne=(c,s)=>c.filter(e=>!s.includes(e)),v=(...c)=>["👩‍🔬",...c.filter(s=>s!=="").flatMap(s=>{if(ve(s,Error)){const e=s;return[e.name,e.message,e.stack]}return s})];function z(c){return Object.entries(c)}function F(c,s,e){if(m(s))return console.warn(...v("No source data was provided.")),c;for(const[t,i]of z(c))t in s||console.info(...v(`Entry '${t}' is missing in source. Using default value.`)),e(i,s[t]);for(const[t]of z(s))t in c||console.warn(...v(`Entry '${t}' was found in source, but it is not expected by the subject schema. This entry will be ignored.`));return c}class yt{constructor(s){u(this,"_elem");this._elem=structuredClone(s)}unwrap(){return structuredClone(this._elem)}replace(s){this._elem=structuredClone(s)}toJSON(){return this.unwrap()}}function X(c){return c.charAt(0).toUpperCase()+c.slice(1)}function Ks(c){return Math.round(c*100)/100}function Y(c){return c===-1?Number.POSITIVE_INFINITY:c}class wt{constructor(s,e){u(this,"_host");u(this,"_workshopManager");this._host=s,this._workshopManager=e}bulk(s,e,t,i){const n=[];let a=0;for(const[h,d]of z(s)){const g=re.evaluateSubSectionTrigger(t,d.trigger),f=p(e[h]);if(!d.enabled||g<0||"tHidden"in f&&f.tHidden===!0||"rHidden"in f&&f.rHidden===!0||f.unlocked===!1||!m(d.max)&&-1<d.max&&d.max<=f.val||h==="cryochambers"&&(p(this._host.game.time.getVSU("usedCryochambers")).val>0||this._host.game.bld.getBuildingExt("chronosphere").meta.val<=f.val)||h==="ressourceRetrieval"&&f.val>=100)continue;const w=p(this._isStagedBuild(f)?f.stages[f.stage].prices:f.prices),b=this.getPriceRatio(f,i);if(!this.singleBuildPossible(f,w,b,i))continue;if(w.map(P=>this._workshopManager.getResource(P.name)).filter(P=>0<P.maxValue).filter(P=>P.value/P.maxValue<g).length===0){if(this._isStagedBuild(f)&&typeof d.stage<"u"&&d.stage!==f.stage)continue;const P=[],Q=1-this._host.game.getLimitedDR(this._host.game.getEffect(`${h}CostReduction`),1);for(const le of w){const ee=1-this._host.game.getLimitedDR(this._host.game.getEffect(`${le.name}CostReduction`),1);P.push({name:le.name,val:le.val*Q*ee})}n.push({count:0,id:h,label:d.label,limit:d.max||0,name:d.baseBuilding??d.building,priceRatio:b,prices:P,source:i,spot:a,val:f.val,variant:d.variant}),a++}}if(n.length===0)return[];const r={};for(const h of this._host.game.resPool.resources)r[h.name]=this._workshopManager.getValueAvailable(h.name);let o=0;const l=new Array;for(;o<1e5;){const h=ne(n,l);let d=0;const g=[];let f={...r};for(const w of l)f=this._precalculateBuilds({...w,limit:w.val+w.count},e,f).remainingResources;for(const w of h){const b=w.count+1,k=this._precalculateBuilds({...w,limit:Math.min(Y(w.limit),w.val+b)},e,f);if(k.count<b){g.push(w);continue}w.count=b,f=k.remainingResources,d++}if(l.push(...g),o++,d===0)break}return console.debug(...v(`Took '${o}' iterations to evaluate bulk build request.`)),l}_precalculateBuilds(s,e,t={}){let i=0;const n=Object.assign({},t),a=p(e[s.id]),r=s.prices,o=s.priceRatio,l=s.source;let h=!1;if(r.length===0)return{count:0,remainingResources:n};for(;!h;){for(let d=0;d<r.length;d++){let g=!1,f=!1,w=Number.POSITIVE_INFINITY,b=Number.POSITIVE_INFINITY;if(l==="Space"&&r[d].name==="oil"){g=!0;const k=this._host.game.getEffect("oilReductionRatio");w=r[d].val*(1-this._host.game.getLimitedDR(k,.75))}else if(s.id==="cryochambers"&&r[d].name==="karma"){f=!0;const k=this._host.game.prestige.getBurnedParagonRatio();b=r[d].val*(1-this._host.game.getLimitedDR(.01*k,1))}if(g?h=n.oil<w*1.05**(i+a.val):f?h=n.karma<b*o**(i+a.val):h=n[r[d].name]<r[d].val*o**(i+a.val),h||"noStackable"in a&&a.noStackable&&i+a.val>=1||s.id==="ressourceRetrieval"&&i+a.val>=100||s.id==="cryochambers"&&this._host.game.bld.getBuildingExt("chronosphere").meta.val<=i+a.val){for(let k=0;k<d;k++)if(l==="Space"&&r[k].name==="oil"){const y=this._host.game.getEffect("oilReductionRatio"),P=r[k].val*(1-this._host.game.getLimitedDR(y,.75));n.oil+=P*1.05**(i+a.val)}else if(s.id==="cryochambers"&&r[k].name==="karma"){const y=this._host.game.prestige.getBurnedParagonRatio(),P=r[k].val*(1-this._host.game.getLimitedDR(.01*y,1));n.karma+=P*o**(i+a.val)}else{const y=r[k].val*o**(i+a.val);n[r[k].name]+=r[k].name==="void"?Math.ceil(y):y}return s.limit&&s.limit!==-1&&(i=Math.max(0,Math.min(i,s.limit-s.val))),{count:i,remainingResources:n}}if(g)n.oil-=w*1.05**(i+a.val);else if(f)n.karma-=b*o**(i+a.val);else{const k=r[d].val*o**(i+a.val);n[r[d].name]-=r[d].name==="void"?Math.ceil(k):k}}++i}return{count:i,remainingResources:n}}construct(s,e,t){if(!("name"in s)||!("controller"in s.options)||!("getMetadata"in s.options.controller))return 0;const i=s.metadata;let n=0,a=t;const r=i;if(!m(r.limitBuild)&&r.limitBuild-r.val<a&&(a=r.limitBuild-r.val),s.enabled&&e.hasResources(s)||this._host.game.devMode){for(;e.hasResources(s)&&a>0;)s.prices=e.getPrices(s),e.payPrice(s),e.incrementValue(s),n++,a--;r.breakIronWill&&(this._host.game.ironWill=!1),m(i)||("unlocks"in i&&!m(i.unlocks)&&this._host.game.unlock(i.unlocks),"upgrades"in i&&!m(i.upgrades)&&this._host.game.upgrade(i.upgrades))}return n}_isStagedBuild(s){return"stage"in s&&"stages"in s&&!m(s.stage)&&!m(s.stages)}getPriceRatio(s,e){const t=this._isStagedBuild(s)?s.priceRatio||s.stages[s.stage].priceRatio:s.priceRatio??0;let i=0;return e&&e==="Bonfire"&&(i=this._host.game.getEffect(`${s.name}PriceRatio`)+this._host.game.getEffect("priceRatio")+this._host.game.getEffect("mapPriceReduction"),i=this._host.game.getLimitedDR(i,t-1)),t+i}singleBuildPossible(s,e,t,i){const a=1-this._host.game.getLimitedDR(this._host.game.getEffect(`${s.name}CostReduction`),1);for(const r of e){const l=1-this._host.game.getLimitedDR(this._host.game.getEffect(`${r.name}CostReduction`),1),h=r.val*a*l;if(i&&i==="Space"&&r.name==="oil"){const d=this._host.game.getLimitedDR(this._host.game.getEffect("oilReductionRatio"),.75),g=h*(1-d);if(this._workshopManager.getValueAvailable("oil")<g*1.05**s.val)return!1}else if(s.name==="cryochambers"&&r.name==="karma"){const d=this._host.game.getLimitedDR(.01*this._host.game.prestige.getBurnedParagonRatio(),1),g=h*(1-d);if(this._workshopManager.getValueAvailable("karma")<g*t**s.val)return!1}else if(this._workshopManager.getValueAvailable(r.name)<h*t**s.val)return!1}return!0}}const Fi=["academy","accelerator","aiCore","amphitheatre","aqueduct","barn","biolab","brewery","calciner","chapel","chronosphere","factory","field","harbor","hut","library","logHouse","lumberMill","magneto","mansion","mine","mint","observatory","oilWell","pasture","quarry","reactor","smelter","steamworks","temple","tradepost","unicornPasture","warehouse","workshop","zebraForge","zebraOutpost","zebraWorkshop","ziggurat"],Vt=["broadcasttower","dataCenter","hydroplant","solarfarm","spaceport"],Vs=["autumn","spring","summer","winter"],we=["charon","umbra","yarn","helios","cath","redmoon","dune","piscine","terminus","kairo"],Hi=["alloy","beam","bloodstone","blueprint","compedium","concrate","eludium","gear","kerosene","manuscript","megalith","parchment","plate","scaffold","ship","slab","steel","tanker","tMythril","thorium","wood"],Wi=[...Hi,"alicorn","antimatter","blackcoin","burnedParagon","catnip","coal","culture","elderBox","faith","furs","gflops","gold","hashrates","iron","ivory","karma","kittens","manpower","minerals","necrocorn","oil","paragon","relic","science","sorrow","spice","starchart","tears","temporalFlux","timeCrystal","titanium","unicorns","unobtainium","uranium","void","wrappingPaper","zebras"],Gi=["any","engineer","farmer","geologist","hunter","miner","priest","scholar","woodcutter"],js=["chemist","engineer","manager","metallurgist","merchant","none","scientist","wise"];var W=(c=>(c.Cryptotheology="c",c.OrderOfTheSun="s",c.Ziggurat="z",c.UnicornPasture="zp",c))(W||{});const Zi=["apocripha","basilica","goldenSpire","scholasticism","solarRevolution","solarchant","stainedGlass","sunAltar","templars","transcendence"],Ki=["blackCore","blackLibrary","blackNexus","blackObelisk","blackRadiance","blazar","darkNova","holyGenocide","mausoleum","singularity"],Vi=["blackPyramid","ivoryCitadel","ivoryTower","marker","skyPalace","sunspire","unicornGraveyard","unicornNecropolis","unicornTomb","unicornUtopia"],ji=["dragons","griffins","nagas","leviathans","lizards","sharks","spiders","zebras"],Js=["authocracy","bigStickPolicy","carnivale","cityOnAHill","clearCutting","communism","conservation","cryochamberExtraction","culturalExchange","diplomacy","dragonRelationsAstrologers","dragonRelationsDynamicists","dragonRelationsPhysicists","environmentalism","epicurianism","expansionism","extravagance","fascism","frugality","fullIndustrialization","griffinRelationsMachinists","griffinRelationsMetallurgists","griffinRelationsScouts","isolationism","knowledgeSharing","liberalism","liberty","lizardRelationsDiplomats","lizardRelationsEcologists","lizardRelationsPriests","militarizeSpace","monarchy","mysticism","nagaRelationsArchitects","nagaRelationsCultists","nagaRelationsMasons","necrocracy","openWoodlands","outerSpaceTreaty","radicalXenophobia","rationality","rationing","republic","scientificCommunism","sharkRelationsBotanists","sharkRelationsMerchants","sharkRelationsScribes","siphoning","socialism","spiderRelationsChemists","spiderRelationsGeologists","spiderRelationsPaleontologists","stoicism","stripMining","sustainability","technocracy","terraformingInsight","theocracy","tradition","transkittenism","zebraRelationsAppeasement","zebraRelationsBellicosity"],Ji=["brewery"],Xs=["acoustics","advExogeology","agriculture","ai","animal","antimatter","archeology","archery","architecture","artificialGravity","astronomy","biochemistry","biology","blackchain","calendar","chemistry","chronophysics","civil","combustion","construction","cryptotheology","currency","dimensionalPhysics","drama","ecology","electricity","electronics","engineering","exogeology","exogeophysics","genetics","hydroponics","industrialization","machinery","math","mechanization","metal","metalurgy","metaphysics","mining","nanotechnology","navigation","nuclearFission","oilProcessing","orbitalEngineering","paradoxalKnowledge","particlePhysics","philosophy","physics","quantumCryptography","robotics","rocketry","sattelites","steel","superconductors","tachyonTheory","terraformation","theology","thorium","voidSpace","writing"],Ys=["centaurusSystemMission","charonMission","duneMission","furthestRingMission","heliosMission","kairoMission","moonMission","orbitalLaunch","piscineMission","rorschachMission","terminusMission","umbraMission","yarnMission"],Xi=["containmentChamber","cryostation","entangler","heatsink","hrHarvester","hydrofracturer","hydroponics","moltenCore","moonBase","moonOutpost","orbitalArray","planetCracker","researchVessel","sattelite","spaceBeacon","spaceElevator","spaceStation","spiceRefinery","sunforge","sunlifter","tectonic","terraformingStation"],Yi=["blastFurnace","ressourceRetrieval","temporalAccelerator","temporalBattery","temporalImpedance","temporalPress","timeBoiler"],Qi=["cryochambers","usedCryochambers","voidHoover","voidRift","chronocontrol","voidResonator"],es=["advancedAutomation","advancedRefinement","aiBases","aiEngineers","alloyArmor","alloyAxe","alloyBarns","alloySaw","alloyWarehouses","amBases","amDrive","amFission","amReactors","amReactorsMK2","assistance","astrolabe","astrophysicists","augumentation","automatedPlants","barges","biofuel","bolas","cadSystems","caravanserai","carbonSequestration","cargoShips","celestialMechanics","chronoEngineers","chronoforge","coalFurnace","coldFusion","combustionEngine","compositeBow","concreteBarns","concreteHuts","concreteWarehouses","crossbow","cryocomputing","darkEnergy","deepMining","distorsion","electrolyticSmelting","eludiumCracker","eludiumHuts","eludiumReflectors","energyRifts","enrichedThorium","enrichedUranium","factoryAutomation","factoryLogistics","factoryOptimization","factoryProcessing","factoryRobotics","fluidizedReactors","fluxCondensator","fuelInjectors","geodesy","gmo","goldOre","hubbleTelescope","huntingArmor","hydroPlantTurbines","internet","invisibleBlackHand","ironAxes","ironHoes","ironwood","lhc","logistics","longRangeSpaceships","machineLearning","mineralAxes","mineralHoes","miningDrill","mWReactor","nanosuits","neuralNetworks","nuclearPlants","nuclearSmelters","offsetPress","oilDistillation","oilRefinery","orbitalGeodesy","oxidation","photolithography","photovoltaic","pneumaticPress","printingPress","pumpjack","pyrolysis","qdot","railgun","reactorVessel","refrigeration","register","reinforcedBarns","reinforcedSaw","reinforcedWarehouses","relicStation","rotaryKiln","satelliteRadio","satnav","seti","silos","solarSatellites","spaceEngineers","spaceManufacturing","spiceNavigation","starlink","stasisChambers","steelArmor","steelAxe","steelPlants","steelSaw","stoneBarns","storageBunkers","strenghtenBuild","tachyonAccelerators","thinFilm","thoriumEngine","thoriumReactors","titaniumAxe","titaniumBarns","titaniumMirrors","titaniumSaw","titaniumWarehouses","turnSmoothly","unicornSelection","unobtainiumAxe","unobtainiumDrill","unobtainiumHuts","unobtainiumReflectors","unobtainiumSaw","uplink","voidAspiration","voidEnergy","voidReactors"];var ce=(c=>(c.Chronoforge="chrono",c.VoidSpace="void",c))(ce||{});const kt=["ivoryCitadel","ivoryTower","skyPalace","sunspire","unicornPasture","unicornTomb","unicornUtopia"],Qs=["sacrificeUnicorns","sacrificeAlicorns","refineTears","refineTimeCrystals","transcend","adore","autoPraise"];class _{constructor(s=!1){u(this,"enabled");this.enabled=s}load(s){m(s)||(this.enabled=s.enabled??this.enabled)}serialize(){return this}}class ts extends _{constructor(e=!1,t=!1){super(e);u(this,"limited");this.limited=t}load(e){m(e)||(super.load(e),this.limited=e.limited??this.limited)}}class V extends _{constructor(e=!1,t=-1){super(e);u(this,"trigger");this.trigger=t}load(e){m(e)||(super.load(e),this.trigger=e.trigger??this.trigger)}}class ae extends _{constructor(e=!1,t=1){super(e);u(this,"trigger");this.trigger=t}load(e){m(e)||(super.load(e),this.trigger=e.trigger??this.trigger)}}class is extends _{constructor(e=!1,t=0){super(e);u(this,"max");this.max=t}load(e){m(e)||(super.load(e),this.max=e.max??this.max)}}class en extends ts{constructor(e=!1,t=!1,i=0){super(e,t);u(this,"max");this.max=i}load(e){m(e)||(super.load(e),this.max=e.max??this.max)}}class tn extends en{constructor(e=!1,t=!1,i=0,n=-1){super(e,t,i);u(this,"trigger");this.trigger=n}load(e){m(e)||(super.load(e),this.trigger=e.trigger??this.trigger)}}class sn extends ts{constructor(e=!1,t=!1,i=-1){super(e,t);u(this,"trigger");this.trigger=i}load(e){m(e)||(super.load(e),this.trigger=e.trigger??this.trigger)}}class _t extends V{constructor(e=!1,t=-1,i=0){super(e,t);u(this,"max");this.max=i}load(e){m(e)||(super.load(e),this.max=e.max??this.max)}}class nn extends ae{constructor(e=!1,t=1,i=0){super(e,t);u(this,"max");this.max=i}load(e){m(e)||(super.load(e),this.max=e.max??this.max)}}class jt{constructor(s,e=new Array){L(this,Ue);u(this,"selected");if(m(e.find(t=>t.value===s)))throw new Error("Provided selected value is not in provided options.");this.selected=s,O(this,Ue,e)}get options(){return I(this,Ue)}load(s){m(s)||(this.selected=s.selected??this.selected)}}Ue=new WeakMap;class an extends ae{constructor(e=!1,t=950,i=1e3,n=1){super(e,n);u(this,"buy");u(this,"sell");this.buy=t,this.sell=i}load(e){m(e)||(super.load(e),this.buy=e.buy??this.buy,this.sell=e.sell??this.sell)}}class rn extends _{constructor(e,t=!1){super(t);L(this,De);O(this,De,e)}get upgrade(){return I(this,De)}}De=new WeakMap;class on extends _{constructor(e=!1){super(e);u(this,"buildings");this.buildings=this.initBuildings()}initBuildings(){const e={};for(const t of Vt)e[t]=new rn(t);return e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}))}}class Jt extends _t{constructor(e,t=!1,i=-1,n=0,a){super(t,i,n);L(this,Ne);L(this,qe);L(this,ze,0);O(this,qe,e),a&&(O(this,ze,1),O(this,Ne,a))}get baseBuilding(){return I(this,Ne)}get building(){return I(this,qe)}get stage(){return I(this,ze)}}Ne=new WeakMap,qe=new WeakMap,ze=new WeakMap;class Xt extends V{constructor(e=!1,t=-1,i=new _,n=new _,a=new _,r=new _,o=new on){super(e,t);u(this,"buildings");u(this,"gatherCatnip");u(this,"turnOnMagnetos");u(this,"turnOnSteamworks");u(this,"turnOnReactors");u(this,"upgradeBuildings");this.buildings=this.initBuildings(),this.gatherCatnip=i,this.turnOnSteamworks=n,this.turnOnMagnetos=a,this.turnOnReactors=r,this.upgradeBuildings=o}initBuildings(){const e={broadcasttower:"amphitheatre",dataCenter:"library",hydroplant:"aqueduct",solarfarm:"pasture",spaceport:"warehouse"},t={};for(const i of Fi)i!=="unicornPasture"&&(t[i]=new Jt(i));for(const i of Vt)t[i]=new Jt(i,!1,-1,0,e[i]);return t}load(e){var t,i,n,a;m(e)||(super.load(e),F(this.buildings,e.buildings,(r,o)=>{r.enabled=(o==null?void 0:o.enabled)??r.enabled,r.max=(o==null?void 0:o.max)??r.max,r.trigger=(o==null?void 0:o.trigger)??r.trigger}),this.gatherCatnip.enabled=((t=e.gatherCatnip)==null?void 0:t.enabled)??this.gatherCatnip.enabled,this.turnOnSteamworks.enabled=((i=e.turnOnSteamworks)==null?void 0:i.enabled)??this.turnOnSteamworks.enabled,this.turnOnMagnetos.enabled=((n=e.turnOnMagnetos)==null?void 0:n.enabled)??this.turnOnMagnetos.enabled,this.turnOnReactors.enabled=((a=e.turnOnReactors)==null?void 0:a.enabled)??this.turnOnReactors.enabled,this.upgradeBuildings.load(e.upgradeBuildings))}}class ge{constructor(s,e){u(this,"_host");u(this,"tab");this._host=s;const t=this._host.game.tabs.find(i=>i.tabId===e);if(m(t))throw new Error(`Unable to find tab ${e}`);this.tab=t,this.render()}render(){return this._host.game.ui.activeTabId!==this.tab.tabId&&this.tab.render(),this}}class ln{constructor(s,e,t=new Xt){u(this,"_host");u(this,"settings");u(this,"manager");u(this,"_bulkManager");u(this,"_workshopManager");this._host=s,this.settings=t,this.manager=new ge(this._host,"Bonfire"),this._workshopManager=e,this._bulkManager=new wt(this._host,this._workshopManager)}tick(s){this.settings.enabled&&(this.manager.render(),this.autoBuild(s),this.autoMisc(s))}autoBuild(s,e=this.settings.buildings){const t=this._bulkManager,i={};for(const r of Object.values(e))i[r.building]=this.getBuild(r.baseBuilding??r.building).meta;const n=this.settings.trigger,a=t.bulk(e,i,n,"Bonfire");for(const r of a.filter(o=>0<o.count))this.build(r.name||r.id,r.stage,r.count),s.requestGameUiRefresh=!0}autoUpgrade(s){var l,h,d,g,f,w,b;const e=this._host.game.bld.getBuildingExt("pasture").meta.stage===0?this._host.game.bld.getBuildingExt("pasture").meta.val:0,t=this._host.game.bld.getBuildingExt("aqueduct").meta.stage===0?this._host.game.bld.getBuildingExt("aqueduct").meta.val:0,i=this._host.game.bld.getBuildingExt("pasture").meta;if(this.settings.upgradeBuildings.buildings.solarfarm.enabled&&i.unlocked&&i.stage===0&&p(i.stages)[1].stageUnlocked&&this._workshopManager.getPotentialCatnip(!0,0,t)>0){const k=p(i.stages)[1].prices;if(this._bulkManager.singleBuildPossible(i,k,1)){const y=this.getBuildButton("pasture",0);m(y==null?void 0:y.model)||(y.controller.sellInternal(y.model,0,!1),i.on=0,i.val=0,i.stage=1,this._host.engine.iactivity("upgrade.building.pasture",[],"ks-upgrade"),(l=this._host.game.ui)==null||l.render(),this.build("pasture",1,1),s.requestGameUiRefresh=!0)}}const n=this._host.game.bld.getBuildingExt("aqueduct").meta;if(this.settings.upgradeBuildings.buildings.hydroplant.enabled&&n.unlocked&&n.stage===0&&p(n.stages)[1].stageUnlocked&&this._workshopManager.getPotentialCatnip(!0,e,0)>0){const k=p(n.stages)[1].prices;if(this._bulkManager.singleBuildPossible(n,k,1)){const y=this.getBuildButton("aqueduct",0);m(y==null?void 0:y.model)||(y.controller.sellInternal(y.model,0,!1),n.on=0,n.val=0,n.stage=1,(h=n.calculateEffects)==null||h.call(n,n,this._host.game),this._host.engine.iactivity("upgrade.building.aqueduct",[],"ks-upgrade"),(d=this._host.game.ui)==null||d.render(),this.build("aqueduct",1,1),s.requestGameUiRefresh=!0)}}const a=this._host.game.bld.getBuildingExt("library").meta;if(this.settings.upgradeBuildings.buildings.dataCenter.enabled&&a.unlocked&&a.stage===0&&p(a.stages)[1].stageUnlocked){let k=this._host.game.workshop.get("cryocomputing").researched?1:2;this._host.game.challenges.currentChallenge==="energy"&&(k*=2);let y=3;if(this._host.game.workshop.get("uplink").researched&&(y*=1+this._host.game.bld.getBuildingExt("biolab").meta.val*this._host.game.getEffect("uplinkDCRatio")),this._host.game.workshop.get("machineLearning").researched&&(y*=1+this._host.game.bld.getBuildingExt("aiCore").meta.on*this._host.game.getEffect("dataCenterAIRatio")),this._host.game.resPool.energyProd>=this._host.game.resPool.energyCons+k*a.val/y){const P=p(a.stages)[1].prices;if(this._bulkManager.singleBuildPossible(a,P,1)){const j=p(this.getBuildButton("library",0));if(m(j.model))return;j.controller.sellInternal(j.model,0,!1),a.on=0,a.val=0,a.stage=1,(g=a.calculateEffects)==null||g.call(a,a,this._host.game),this._host.engine.iactivity("upgrade.building.library",[],"ks-upgrade"),(f=this._host.game.ui)==null||f.render(),this.build("library",1,1),s.requestGameUiRefresh=!0;return}}}const r=this._host.game.bld.getBuildingExt("warehouse").meta;if(this.settings.upgradeBuildings.buildings.spaceport.enabled&&r.unlocked&&r.stage===0&&p(r.stages)[1].stageUnlocked){const k=p(r.stages)[1].prices;if(this._bulkManager.singleBuildPossible(r,k,1)){const y=this.getBuildButton("warehouse",0);if(!m(y==null?void 0:y.model)){y.controller.sellInternal(y.model,0,!1),r.on=0,r.val=0,r.stage=1,this._host.engine.iactivity("upgrade.building.warehouse",[],"ks-upgrade"),(w=this._host.game.ui)==null||w.render(),this.build("warehouse",1,1),s.requestGameUiRefresh=!0;return}}}const o=this._host.game.bld.getBuildingExt("amphitheatre").meta;if(this.settings.upgradeBuildings.buildings.broadcasttower.enabled&&o.unlocked&&o.stage===0&&p(o.stages)[1].stageUnlocked){const k=p(o.stages)[1].prices;if(this._bulkManager.singleBuildPossible(o,k,1)){const y=this.getBuildButton("amphitheatre",0);m(y==null?void 0:y.model)||(y.controller.sellInternal(y.model,0,!1),o.on=0,o.val=0,o.stage=1,this._host.engine.iactivity("upgrade.building.amphitheatre",[],"ks-upgrade"),(b=this._host.game.ui)==null||b.render(),this.build("amphitheatre",1,1),s.requestGameUiRefresh=!0)}}}autoMisc(s){if(this.settings.turnOnSteamworks.enabled){const e=this._host.game.bld.getBuildingExt("steamworks");if(e.meta.val&&e.meta.on===0){const t=p(this.getBuildButton("steamworks"));if(m(t.model))return;t.controller.onAll(t.model)}}if(this.settings.turnOnMagnetos.enabled){const e=this._host.game.bld.getBuildingExt("magneto");if(e.meta.val&&e.meta.on<e.meta.val){const t=p(this.getBuildButton("magneto"));if(m(t.model))return;t.controller.onAll(t.model)}}if(this.settings.turnOnReactors.enabled){const e=this._host.game.bld.getBuildingExt("reactor");if(e.meta.val&&e.meta.on<e.meta.val){const t=p(this.getBuildButton("reactor"));if(m(t.model))return;t.controller.onAll(t.model)}}this.settings.upgradeBuildings.enabled&&this.autoUpgrade(s),this.settings.gatherCatnip.enabled&&this.autoGather()}autoGather(){const s=new classes.game.ui.GatherCatnipButtonController(this._host.game);for(let e=0;e<Math.floor(this._host.engine.settings.interval/20);++e)s.buyItem(void 0,null)}build(s,e,t){let i=t;const n=i;let a;const r=game.getUnlockByName(s,"buildings"),o=new classes.BuildingMeta(r).getMeta();if("stages"in o){const l=new classes.ui.btn.StagingBldBtnController(this._host.game),h=l.fetchModel({building:s,controller:l,description:p(o.description),name:p(o.label),twoRow:!1});i=this._bulkManager.construct(h,l,i),a=o.label??""}else{const l=new classes.ui.btn.BuildingBtnModernController(this._host.game),h=l.fetchModel({building:s,controller:l,description:p(o.description),name:p(o.label),twoRow:!1});i=this._bulkManager.construct(h,l,i),a=o.label??""}i!==n&&(console.warn(...v(`${a} Amount ordered: ${n} Amount Constructed: ${i}`)),i===0)||(this._host.engine.storeForSummary(a,i,"build"),i===1?this._host.engine.iactivity("act.build",[a],"ks-build"):this._host.engine.iactivity("act.builds",[a,this._host.renderAbsolute(i)],"ks-build"))}_getBuildLabel(s,e){return s.stages&&!m(e)?s.stages[e].label:p(s.label)}getBuild(s){return this._host.game.bld.getBuildingExt(s)}getBuildButton(s,e=0){const t=game.bld.get(s),i=new classes.BuildingMeta(t).getMeta(),n=m(i.stages)?t:i.stages[e],a="stages"in n?new classes.ui.btn.StagingBldBtnController(this._host.game):new classes.ui.btn.BuildingBtnModernController(this._host.game),r=a.fetchModel({building:s,description:n.description,key:s,name:n.label});return{controller:a,model:r}}}class cn{constructor(s){u(this,"_host");u(this,"_lastday");u(this,"_lastyear");u(this,"_sections",new Map);this._host=s,this.resetActivity()}resetActivity(){this._sections=new Map,this._lastday=this._host.game.calendar.day,this._lastyear=this._host.game.calendar.year}storeActivity(s,e=1,t="other"){this._sections.has(t)||this._sections.set(t,new Map);const i=p(this._sections.get(t));i.has(s)||i.set(s,0),i.set(s,p(i.get(s))+e)}renderSummary(){const s=new Array;if(this._sections.has("other")&&p(this._sections.get("other")).forEach((t,i)=>s.push(this._host.engine.i18n(`summary.${i}`,[this._host.game.getDisplayValueExt(t)]))),this._sections.has("research")&&p(this._sections.get("research")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.tech",[X(i)]))}),this._sections.has("upgrade")&&p(this._sections.get("upgrade")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.upgrade",[X(i)]))}),this._sections.has("build")&&p(this._sections.get("build")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.building",[this._host.game.getDisplayValueExt(t),X(i)]))}),this._sections.has("refine")&&p(this._sections.get("refine")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.refine",[this._host.game.getDisplayValueExt(t),X(i)]))}),this._sections.has("faith")&&p(this._sections.get("faith")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.sun",[this._host.game.getDisplayValueExt(t),X(i)]))}),this._sections.has("craft")&&p(this._sections.get("craft")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.craft",[this._host.game.getDisplayValueExt(t),X(i)]))}),this._sections.has("trade")&&p(this._sections.get("trade")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.trade",[this._host.game.getDisplayValueExt(t),X(i)]))}),this._lastday&&this._lastyear){let e=this._host.game.calendar.year-this._lastyear,t=this._host.game.calendar.day-this._lastday;t<0&&(e-=1,t+=400);let i="";e>0&&(i+=`${e} `,i+=e===1?this._host.engine.i18n("summary.year"):this._host.engine.i18n("summary.years")),t>=0&&(e>0&&(i+=this._host.engine.i18n("summary.separator")),i+=`${Ks(t)} `,i+=t===1?this._host.engine.i18n("summary.day"):this._host.engine.i18n("summary.days")),s.push(this._host.engine.i18n("summary.head",[i]))}return s}}const hn={"act.accelerate":"Accelerate time!","act.adore":"Adore the galaxy! Accumulated {0} worship to {1} epiphany","act.blackcoin.buy":"Kittens sold your Relics and bought {0} Blackcoins","act.blackcoin.sell":"Kittens sold your Blackcoins and bought {0} Relics","act.build":"Kittens have built a new {0}","act.builds":"Kittens have built a new {0} {1} times","act.craft":"Kittens have crafted {0} {1}","act.distribute":"Distributed a kitten to {0}","act.elect":"Kittens have elected a new leader.","act.feed":"Kittens fed the Elders. The elders are pleased","act.fix.cry":"Kittens fixed {0} Cryochambers","act.hunt":"Sent kittens on {0} hunts","act.observe":"Kitten Scientists have observed a star","act.praise":"Praised the sun! Accumulated {0} faith to {1} worship","act.promote":"Kittens' leader has been promoted to rank {0}","act.refineTCs":"Refined {0} time crystals","act.refineTears":"Refined {0} tears into BLS","act.sacrificeAlicorns":"Sacrificed {0} alicorns","act.sacrificeUnicorns":"Sacrificed {0} unicorns","act.sun.discover":"Kittens have discovered {0}","act.sun.discovers":"Kittens have discovered {0} {1} times","act.time.activeHeatTransferEnd":"End active Heat Transfer","act.time.activeHeatTransferStart":"Start active Heat Transfer","act.time.getTemporalFlux":"Burn crystals to obtain time flux to maintain time acceleration","act.time.skip":"Kittens combust a time crystal, {0} years skipped!","act.trade":"Kittens have traded {0} times with {1}","act.transcend":"Spent {0} epiphany, Transcended to T-level: {1}","blackcoin.buy":"Buy Limit: {0}","blackcoin.buy.prompt":"Enter at which price you want to stop buying blackcoins.","blackcoin.buy.promptExplainer":"Blackcoin price always rises from 800 to 1100 (roughly), then it crashes. You usually want to buy until shortly before you sell.","blackcoin.buy.promptTitle":"Buy Limit for Blackcoins (Current: {0})","blackcoin.buy.title":"Buy Blackcoins until price reaches {0}","blackcoin.buy.trigger":"buying Blackcoins (in relics)","blackcoin.sell":"Sell Order: {0}","blackcoin.sell.prompt":"Enter at which price you want to sell all your blackcoins.","blackcoin.sell.promptExplainer":"Blackcoin price always rises from 800 to 1100 (roughly), then it crashes. You usually want to sell close to the highest possible price.","blackcoin.sell.promptTitle":"Sell Order for Blackcoins (Current: {0})","blackcoin.sell.title":"Sell Blackcoins when price reaches {0}","build.embassies":"Built {0} embassies for {1}","build.embassy":"Built {0} embassy for {1}",copy:"Copy","craft.limited":"Crafting {0}: limited to be proportional to cost ratio","craft.unlimited":"Crafting {0}: unlimited",delete:"Delete","dispose.necrocorn":"Kittens disposed of inefficient necrocorns","festival.extend":"Kittens extend the festival","festival.hold":"Kittens begin holding a festival","filter.accelerate":"Tempus Fugit","filter.adore":"Adoring","filter.allKG":"All KG log entries.","filter.build":"Building","filter.craft":"Crafting","filter.disable":"Disabled {0} log messages","filter.distribute":"Distribute","filter.enable":"Enabled {0} log messages","filter.explainer":"Disabled items are hidden from the log.","filter.faith":"Order of the Sun","filter.festival":"Festivals","filter.hunt":"Hunting","filter.misc":"Miscellaneous","filter.praise":"Praising","filter.promote":"Promote leader","filter.research":"Researching","filter.star":"Astronomical Events","filter.timeSkip":"Time Skip","filter.trade":"Trading","filter.transcend":"Transcend","filter.upgrade":"Upgrading","option.accelerate":"Tempus Fugit","option.autofeed":"Feed Leviathans","option.catnip":"Gather Catnip","option.crypto":"Trade Blackcoin","option.elect":"Elect leader","option.elect.job":"Job","option.elect.job.any":"Any","option.elect.trait":"Trait","option.embassies":"Build Embassies","option.faith.adore":"Adore the Galaxy","option.faith.autoPraise":"Praise the Sun","option.faith.best.unicorn":"Automate Build Order","option.faith.refineTears":"Refine Tears","option.faith.refineTimeCrystals":"Refine TCs","option.faith.sacrificeAlicorns":"Sacrifice Alicorns","option.faith.sacrificeUnicorns":"Sacrifice Unicorns","option.faith.transcend":"Transcend","option.festival":"Hold festivals","option.fix.cry":"Fix Cryochamber","option.hunt":"Hunt","option.magnetos":"Turn on Magnetos","option.observe":"Observe Astro Events","option.praise":"Praise the Sun","option.promote":"Promote leader","option.promotekittens":"Promote kittens","option.reactors":"Turn on Reactors","option.shipOverride":"Force Ships to 243","option.steamworks":"Turn on Steamworks","option.time.activeHeatTransfer":"Active Heat Transfer","option.time.reset":"Reset Timeline (Danger!)","option.time.skip":"Time Skip","option.time.skip.ignoreOverheat":"Ignore overheat",reset:"Reset","reset.after":"Nice to meet you, the cute Kitten Scientists will serve you","reset.cancel.activity":"Meoston, We Have a Problem","reset.cancel.message":"Timeline Reset canceled","reset.check":"Trigger for {0}: {1}, you have {2}","reset.checked":"All conditions are met, the timeline will restart in the next few seconds!","reset.countdown.0":"0 - Temporal rifts opened!","reset.countdown.1":"1 - Time engine start","reset.countdown.2":"2 - Boosting the chronoforge","reset.countdown.3":"3 - Opening temporal rifts","reset.countdown.4":"4 - Turning off satellite","reset.countdown.5":"5 - Melting blackcoins","reset.countdown.6":"6 - Starting time engines","reset.countdown.7":"7 - Disassembling railguns","reset.countdown.8":"8 - Releasing lizards","reset.countdown.9":"9 - Sacrificing unicorns","reset.countdown.10":"10 - Harvesting catnip","reset.last.message":"See you next poincaré recurrence","reset.tip":'You can cancel this reset by disabling "Enable Kitten Scientists" at the top of the settings.',"resources.consume":"Consume: {0}","resources.consume.prompt":"Enter how much of the resource you want automations to consume as a percentage between 0.0 and 100.0.","resources.consume.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","resources.consume.promptTitle":"Consumption Share for {0} (Current: {1})","resources.consume.set":"Consume rate for {0}","resources.consume.title":"Consuming {0} of {1}","resources.consume.titleZero":"Not consuming {0}","resources.stock.prompt":"Enter how much of the resource you always want to keep in stock.","resources.stock.promptExplainer":"All notations that the game supports are accepted. If you submit an empty value, or a negative value, the limit will be set to infinity. If you set the limit to 0, this option will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","resources.stock.promptTitle":"Stock value for {0} (Current: {1})","resources.stock.title":"Keeping {0} {1} in stock","resources.stock.titleInfinite":"Keeping all {0} in stock","resources.stock.titleZero":"Not keeping any {0} in stock","state.compress":"Compress copied Kittens Game saves","state.confirmDestruction":"Are you sure?","state.copied.game":"Save '{0}' copied to clipboard.","state.copied.gameCurrent":"Current save copied to clipboard.","state.copied.state":"State '{0}' copied to clipboard.","state.copied.stateCurrent":"Current state copied to clipboard.","state.copy.game":"Copy this save to the clipboard.","state.copy.gameCurrent":"Copy the entire Kittens Game save (includes KS settings) to the clipboard.","state.copy.state":"Copy these settings to the clipboard.","state.copy.stateCurrent":"Copy the current Kitten Scientists settings to the clipboard.","state.delete.game":"Delete this save.","state.delete.state":"Delete these settings.","state.deleted.game":"Save '{0}' deleted.","state.deleted.state":"State '{0}' deleted.","state.edit.game":"Change the name of this save.","state.edit.state":"Change the name of these settings.","state.exportAll":"Backup","state.exportAllTitle":"Stores all local states in a single file and downloads it.","state.import":"Import settings/saves","state.imported.game":"Save imported.","state.imported.state":"State imported.","state.importedState":"Imported state {0}","state.importTitle":`Paste a save or settings from your clipboard.
23
- Contents will be automatically detected and handled accordingly.`,"state.loaded.game":"Save '{0}' loaded.","state.loaded.state":"State '{0}' loaded.","state.loadPrompt":"Paste your (un/compressed) save or settings here:","state.local":"Local storage management","state.localGames":"Kittens Game Saves","state.localStates":"Kitten Scientists Settings","state.new":"New","state.noConfirm":"Don't ask for confirmation","state.store":"Store","state.stored.game":"Save stored.","state.stored.state":"State stored.","state.storeFactory":"Create a new state from factory defaults.","state.storeGame":"Create a new save from the current game.","state.storeGame.prompt":"Provide a label for this save:","state.storeState":"Create a new state from current settings.","state.storeState.prompt":"Provide a label for this state:","state.title":"State Management","state.unlabeledGame":"unlabeled save","state.unlabeledState":"unlabeled state","state.update.game":"Save the current game into this slot.","state.update.state":"Save the current settings into this slot.","state.updated.game":"Save '{0}' updated.","state.updated.state":"State '{0}' updated.","status.auto.disable":"Disabled Auto {0}","status.auto.enable":"Enabled Auto {0}","status.ks.disable":"Disabling the Kitten Scientists!","status.ks.enable":"Enabling the Kitten Scientists!","status.ks.init":"Kitten Scientists initialized.","status.ks.upgrade":"Kitten Scientists {0} (ours is {1}) is available at {2}.","status.reset.check.disable":"Disabled check {0} before Reset Timeline","status.reset.check.enable":"Enabled check {0} before Reset Timeline","status.resource.disable":"Disabled {0} resource management","status.resource.enable":"Enabled {0} resource management","status.sub.disable":"Disabled {0}","status.sub.enable":"Enabled {0}","summary.accelerate":"Accelerated time {0} times","summary.adore":"Accumulated {0} epiphany by adoring the galaxy","summary.building":"Built {0} {1}","summary.craft":"Crafted {0} {1}","summary.day":"day","summary.days":"days","summary.distribute":"Helped {0} kittens find a job","summary.embassy":"Built {0} embassies","summary.feed":"Fed the elders {0} necrocorns","summary.festival":"Held {0} festivals","summary.fix.cry":"Fixed {0} cryochambers","summary.head":"Summary of the last {0}","summary.hunt":"Sent adorable kitten hunters on {0} hunts","summary.praise":"Accumulated {0} worship by praising the sun","summary.promote":"Promoted our leader {0} times","summary.refine":"Refined {0} {1}","summary.separator":" and ","summary.show":"Show activity","summary.stars":"Observed {0} stars","summary.sun":"Discovered {0} {1}","summary.tech":"Researched {0}","summary.time.activeHeatTransferStart":"Active Heat Transfer {0} times","summary.time.getTemporalFlux":"Burn crystal to gain time flux {0} times","summary.time.reset.content":"Gained {0} Karma.<br>Gained {1} Paragon","summary.time.reset.title":"Summary of the last {0} timelines","summary.time.skip":"Skipped {0} years","summary.trade":"Traded {0} times with {1}","summary.transcend":"Transcended {0} times","summary.upgrade":"Upgraded {0}","summary.year":"year","summary.years":"years","time.heatTransfer.cycle.disable":"Disabled active heat transfer in cycle {0}","time.heatTransfer.cycle.enable":"Enabled active heat transfer in cycle {0}","time.skip.cycle.disable":"Disabled time skip in cycle {0} and disallow skip over this cycle","time.skip.cycle.enable":"Enabled time skip in cycle {0} and allow skip over this cycle","time.skip.season.disable":"Disabled time skip in the {0}","time.skip.season.enable":"Enabled time skip in the {0}","trade.limited":"Trading with {0}: limited to only occur when profitable based off relative production time","trade.season.disable":"Disabled trading with {0} in the {1}","trade.season.enable":"Enabled trading with {0} in the {1}","trade.seasons":"seasons","trade.unlimited":"Trading with {0}: unlimited","ui.additional":"Additional options","ui.build":"Bonfire","ui.close":"close","ui.craft":"Workshop","ui.craft.resources":"Resources","ui.cycles":"cycles","ui.disable.all":"Disable all options in this list.","ui.distribute":"Village","ui.enable.all":"Enable all options in this list.","ui.engine":"Enable Kitten Scientists","ui.faith":"Religion","ui.filter":"Log Filters","ui.infinity":"∞","ui.internals":"Internals","ui.internals.interval":"Interval: {0}","ui.internals.interval.prompt":"Enter the new amount of milliseconds as an absolute value between 0 and Infinity.","ui.internals.interval.promptExplainer":"All notations that the game supports are accepted. If you set the limit to 0, Kitten Scientists will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.internals.interval.promptTitle":"Kitten Scientists Execution Interval (Current: {0})","ui.itemsHide":"Collapse section","ui.itemsShow":"Expand section","ui.ksColumn":"Display KS in fourth column in UI","ui.language":"Language","ui.limit":"Limited","ui.limited.off":"Unlimited","ui.limited.on":"Eco Mode","ui.max":"Max: {0}","ui.max.build.prompt":"Limit for {0} (Current: {1})","ui.max.build.promptExplainer":"All notations that the game supports are accepted. If you submit an empty value, or a negative value, the limit will be set to infinity. If you set the limit to 0, this option will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.max.build.title":"Build {0} {1}","ui.max.build.titleInfinite":"Never stop building {0}","ui.max.build.titleZero":"Don't build {0}","ui.max.craft.prompt":"Enter the new limit of how many {0} to craft as an absolute value between 0 and Infinity.","ui.max.craft.promptExplainer":"All notations that the game supports are accepted. If you submit an empty value, or a negative value, the limit will be set to infinity. If you set the limit to 0, this option will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.max.craft.promptTitle":"Limit for Crafting {0} (Current: {1})","ui.max.craft.title":"Craft {0} {1}","ui.max.craft.titleInfinite":"Never stop crafting {0}","ui.max.craft.titleZero":"Don't craft {0}","ui.max.distribute.prompt":"Enter the new amount of kittens to assign as {0} as an absolute value between 0 and Infinity.","ui.max.distribute.promptExplainer":"All notations that the game supports are accepted. If you submit an empty value, or a negative value, the limit will be set to infinity. If you set the limit to 0, this option will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.max.distribute.promptTitle":"Assign Max. Kittens as {0} (Current: {1})","ui.max.distribute.title":"Assign {0} kittens as {1}","ui.max.distribute.titleInfinite":"Assign as many kittens as possible as {0}","ui.max.distribute.titleZero":"Don't assign any kittens as {0}","ui.max.embassy.title":"Build {0} embassy for {1}","ui.max.embassy.titleInfinite":"Never stop building embassies for {0}","ui.max.embassy.titleZero":"Don't build embassies for {0}","ui.max.prompt.absolute":"Enter the new limit as an absolute value between 0 and Infinity.","ui.max.prompt.float":"Enter the new limit as an absolute value between 0.0 and Infinity.","ui.max.set":"Maximum for {0}","ui.max.timeSkip.prompt":"Enter the new amount of years as an absolute value between 0 and Infinity.","ui.max.timeSkip.promptExplainer":"All notations that the game supports are accepted. If you submit an empty value, or a negative value, the limit will be set to infinity. If you set the limit to 0, this option will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.max.timeSkip.promptTitle":"Max. Years to skip (Current: {0})","ui.max.timeSkip.title":"Skip {0} years at once","ui.max.timeSkip.titleInfinite":"Skip as many years as possible","ui.max.timeSkip.titleZero":"Don't skip time","ui.maximum":"Maximum","ui.min":"Min: {0}","ui.options":"Options","ui.reset":"Reset list options to default configuration.","ui.resources":"Resource Control","ui.space":"Space","ui.time":"Time","ui.timeCtrl":"Time Control","ui.trade":"Trade","ui.trigger":"Trigger: {0}","ui.trigger.accelerateTime.prompt":"Enter the new temporal flux storage level at which to enable Tempus Fugit as a percentage between 0.0 and 100.0.","ui.trigger.accelerateTime.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.accelerateTime.promptTitle":"Trigger to Accelerate Time (Current: {0})","ui.trigger.activeHeatTransfer.prompt":"Enter the new temporal heat storage level at which to enable heat transfer as a percentage between 0.0 and 100.0.","ui.trigger.activeHeatTransfer.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.activeHeatTransfer.promptTitle":"Trigger for Heat Transfer (Current: {0})","ui.trigger.build.blocked":`∞
22
+ (function(U,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("dojo")):typeof define=="function"&&define.amd?define(["exports","dojo"],R):(U=typeof globalThis<"u"?globalThis:U||self,R(U["kitten-scientists"]=U["kitten-scientists"]||{}))})(this,function(U){"use strict";var Yo=Object.defineProperty;var Os=U=>{throw TypeError(U)};var Qo=(U,R,m)=>R in U?Yo(U,R,{enumerable:!0,configurable:!0,writable:!0,value:m}):U[R]=m;var u=(U,R,m)=>Qo(U,typeof R!="symbol"?R+"":R,m),Us=(U,R,m)=>R.has(U)||Os("Cannot "+m);var B=(U,R,m)=>(Us(U,R,"read from private field"),m?m.call(U):R.get(U)),I=(U,R,m)=>R.has(U)?Os("Cannot add the same private member more than once"):R instanceof WeakSet?R.add(U):R.set(U,m),L=(U,R,m,be)=>(Us(U,R,"write to private field"),be?be.call(U,m):R.set(U,m),m);var Oe,Ue,De,Ne,qe,ze,Fe,He,We,Ge,Ze,Ke,Ve,je,Je,Xe,Ye,Qe,et,tt,it,st,nt,at,rt,ot,lt,ct,ht,ut,Is;const R=c=>e=>{c.error(e)};function m(c){return c==null}function be(c,s){return!m(c)&&c instanceof s}class Ds extends Error{constructor(s="unexpected nil value"){super(s)}}function v(c,s){if(m(c))throw new Ds(s);return c}function mt(c,s){const e=new Array;for(const t of c)m(t)?m(s)||e.push(s):e.push(t);return e}class me extends Error{constructor(e,t,i){super(t);u(this,"status");u(this,"code");this.code=e,this.name="AbstractError",this.status=i,typeof Error.captureStackTrace<"u"&&Error.captureStackTrace(this,me)}static isAbstractError(e,t=!0){if(e instanceof me)return!0;if(t){const i=e;if(Object(e)===e&&"code"in i&&typeof i.code=="string"&&e.code.match(/^ERR_OS_/))return!0}return!1}}class ft extends me{constructor(s,e=400){super("ERR_OS_INVALID_OPERATION",s,e),this.name="InvalidOperationError",typeof Error.captureStackTrace<"u"&&Error.captureStackTrace(this,ft)}}var qt,Bi;function Ii(){return Bi||(Bi=1,qt=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...s)=>console.error("SEMVER",...s):()=>{}),qt}var zt,$i;function Li(){if($i)return zt;$i=1;const c="2.0.0",s=256,e=Number.MAX_SAFE_INTEGER||9007199254740991,t=16,i=s-6;return zt={MAX_LENGTH:s,MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:i,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:c,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},zt}var bt={exports:{}},Oi;function Ns(){return Oi||(Oi=1,function(c,s){const{MAX_SAFE_COMPONENT_LENGTH:e,MAX_SAFE_BUILD_LENGTH:t,MAX_LENGTH:i}=Li(),n=Ii();s=c.exports={};const r=s.re=[],a=s.safeRe=[],o=s.src=[],l=s.safeSrc=[],h=s.t={};let d=0;const g="[a-zA-Z0-9-]",f=[["\\s",1],["\\d",i],[g,t]],p=k=>{for(const[w,O]of f)k=k.split(`${w}*`).join(`${w}{0,${O}}`).split(`${w}+`).join(`${w}{1,${O}}`);return k},b=(k,w,O)=>{const ee=p(w),Y=d++;n(k,Y,w),h[k]=Y,o[Y]=w,l[Y]=ee,r[Y]=new RegExp(w,O?"g":void 0),a[Y]=new RegExp(ee,O?"g":void 0)};b("NUMERICIDENTIFIER","0|[1-9]\\d*"),b("NUMERICIDENTIFIERLOOSE","\\d+"),b("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${g}*`),b("MAINVERSION",`(${o[h.NUMERICIDENTIFIER]})\\.(${o[h.NUMERICIDENTIFIER]})\\.(${o[h.NUMERICIDENTIFIER]})`),b("MAINVERSIONLOOSE",`(${o[h.NUMERICIDENTIFIERLOOSE]})\\.(${o[h.NUMERICIDENTIFIERLOOSE]})\\.(${o[h.NUMERICIDENTIFIERLOOSE]})`),b("PRERELEASEIDENTIFIER",`(?:${o[h.NONNUMERICIDENTIFIER]}|${o[h.NUMERICIDENTIFIER]})`),b("PRERELEASEIDENTIFIERLOOSE",`(?:${o[h.NONNUMERICIDENTIFIER]}|${o[h.NUMERICIDENTIFIERLOOSE]})`),b("PRERELEASE",`(?:-(${o[h.PRERELEASEIDENTIFIER]}(?:\\.${o[h.PRERELEASEIDENTIFIER]})*))`),b("PRERELEASELOOSE",`(?:-?(${o[h.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[h.PRERELEASEIDENTIFIERLOOSE]})*))`),b("BUILDIDENTIFIER",`${g}+`),b("BUILD",`(?:\\+(${o[h.BUILDIDENTIFIER]}(?:\\.${o[h.BUILDIDENTIFIER]})*))`),b("FULLPLAIN",`v?${o[h.MAINVERSION]}${o[h.PRERELEASE]}?${o[h.BUILD]}?`),b("FULL",`^${o[h.FULLPLAIN]}$`),b("LOOSEPLAIN",`[v=\\s]*${o[h.MAINVERSIONLOOSE]}${o[h.PRERELEASELOOSE]}?${o[h.BUILD]}?`),b("LOOSE",`^${o[h.LOOSEPLAIN]}$`),b("GTLT","((?:<|>)?=?)"),b("XRANGEIDENTIFIERLOOSE",`${o[h.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),b("XRANGEIDENTIFIER",`${o[h.NUMERICIDENTIFIER]}|x|X|\\*`),b("XRANGEPLAIN",`[v=\\s]*(${o[h.XRANGEIDENTIFIER]})(?:\\.(${o[h.XRANGEIDENTIFIER]})(?:\\.(${o[h.XRANGEIDENTIFIER]})(?:${o[h.PRERELEASE]})?${o[h.BUILD]}?)?)?`),b("XRANGEPLAINLOOSE",`[v=\\s]*(${o[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[h.XRANGEIDENTIFIERLOOSE]})(?:${o[h.PRERELEASELOOSE]})?${o[h.BUILD]}?)?)?`),b("XRANGE",`^${o[h.GTLT]}\\s*${o[h.XRANGEPLAIN]}$`),b("XRANGELOOSE",`^${o[h.GTLT]}\\s*${o[h.XRANGEPLAINLOOSE]}$`),b("COERCEPLAIN",`(^|[^\\d])(\\d{1,${e}})(?:\\.(\\d{1,${e}}))?(?:\\.(\\d{1,${e}}))?`),b("COERCE",`${o[h.COERCEPLAIN]}(?:$|[^\\d])`),b("COERCEFULL",o[h.COERCEPLAIN]+`(?:${o[h.PRERELEASE]})?(?:${o[h.BUILD]})?(?:$|[^\\d])`),b("COERCERTL",o[h.COERCE],!0),b("COERCERTLFULL",o[h.COERCEFULL],!0),b("LONETILDE","(?:~>?)"),b("TILDETRIM",`(\\s*)${o[h.LONETILDE]}\\s+`,!0),s.tildeTrimReplace="$1~",b("TILDE",`^${o[h.LONETILDE]}${o[h.XRANGEPLAIN]}$`),b("TILDELOOSE",`^${o[h.LONETILDE]}${o[h.XRANGEPLAINLOOSE]}$`),b("LONECARET","(?:\\^)"),b("CARETTRIM",`(\\s*)${o[h.LONECARET]}\\s+`,!0),s.caretTrimReplace="$1^",b("CARET",`^${o[h.LONECARET]}${o[h.XRANGEPLAIN]}$`),b("CARETLOOSE",`^${o[h.LONECARET]}${o[h.XRANGEPLAINLOOSE]}$`),b("COMPARATORLOOSE",`^${o[h.GTLT]}\\s*(${o[h.LOOSEPLAIN]})$|^$`),b("COMPARATOR",`^${o[h.GTLT]}\\s*(${o[h.FULLPLAIN]})$|^$`),b("COMPARATORTRIM",`(\\s*)${o[h.GTLT]}\\s*(${o[h.LOOSEPLAIN]}|${o[h.XRANGEPLAIN]})`,!0),s.comparatorTrimReplace="$1$2$3",b("HYPHENRANGE",`^\\s*(${o[h.XRANGEPLAIN]})\\s+-\\s+(${o[h.XRANGEPLAIN]})\\s*$`),b("HYPHENRANGELOOSE",`^\\s*(${o[h.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[h.XRANGEPLAINLOOSE]})\\s*$`),b("STAR","(<|>)?=?\\s*\\*"),b("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),b("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(bt,bt.exports)),bt.exports}var Ft,Ui;function qs(){if(Ui)return Ft;Ui=1;const c=Object.freeze({loose:!0}),s=Object.freeze({});return Ft=t=>t?typeof t!="object"?c:t:s,Ft}var Ht,Di;function zs(){if(Di)return Ht;Di=1;const c=/^[0-9]+$/,s=(t,i)=>{const n=c.test(t),r=c.test(i);return n&&r&&(t=+t,i=+i),t===i?0:n&&!r?-1:r&&!n?1:t<i?-1:1};return Ht={compareIdentifiers:s,rcompareIdentifiers:(t,i)=>s(i,t)},Ht}var Wt,Ni;function Fs(){if(Ni)return Wt;Ni=1;const c=Ii(),{MAX_LENGTH:s,MAX_SAFE_INTEGER:e}=Li(),{safeRe:t,t:i}=Ns(),n=qs(),{compareIdentifiers:r}=zs();class a{constructor(l,h){if(h=n(h),l instanceof a){if(l.loose===!!h.loose&&l.includePrerelease===!!h.includePrerelease)return l;l=l.version}else if(typeof l!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof l}".`);if(l.length>s)throw new TypeError(`version is longer than ${s} characters`);c("SemVer",l,h),this.options=h,this.loose=!!h.loose,this.includePrerelease=!!h.includePrerelease;const d=l.trim().match(h.loose?t[i.LOOSE]:t[i.FULL]);if(!d)throw new TypeError(`Invalid Version: ${l}`);if(this.raw=l,this.major=+d[1],this.minor=+d[2],this.patch=+d[3],this.major>e||this.major<0)throw new TypeError("Invalid major version");if(this.minor>e||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>e||this.patch<0)throw new TypeError("Invalid patch version");d[4]?this.prerelease=d[4].split(".").map(g=>{if(/^[0-9]+$/.test(g)){const f=+g;if(f>=0&&f<e)return f}return g}):this.prerelease=[],this.build=d[5]?d[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(l){if(c("SemVer.compare",this.version,this.options,l),!(l instanceof a)){if(typeof l=="string"&&l===this.version)return 0;l=new a(l,this.options)}return l.version===this.version?0:this.compareMain(l)||this.comparePre(l)}compareMain(l){return l instanceof a||(l=new a(l,this.options)),r(this.major,l.major)||r(this.minor,l.minor)||r(this.patch,l.patch)}comparePre(l){if(l instanceof a||(l=new a(l,this.options)),this.prerelease.length&&!l.prerelease.length)return-1;if(!this.prerelease.length&&l.prerelease.length)return 1;if(!this.prerelease.length&&!l.prerelease.length)return 0;let h=0;do{const d=this.prerelease[h],g=l.prerelease[h];if(c("prerelease compare",h,d,g),d===void 0&&g===void 0)return 0;if(g===void 0)return 1;if(d===void 0)return-1;if(d===g)continue;return r(d,g)}while(++h)}compareBuild(l){l instanceof a||(l=new a(l,this.options));let h=0;do{const d=this.build[h],g=l.build[h];if(c("build compare",h,d,g),d===void 0&&g===void 0)return 0;if(g===void 0)return 1;if(d===void 0)return-1;if(d===g)continue;return r(d,g)}while(++h)}inc(l,h,d){if(l.startsWith("pre")){if(!h&&d===!1)throw new Error("invalid increment argument: identifier is empty");if(h){const g=`-${h}`.match(this.options.loose?t[i.PRERELEASELOOSE]:t[i.PRERELEASE]);if(!g||g[1]!==h)throw new Error(`invalid identifier: ${h}`)}}switch(l){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",h,d);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",h,d);break;case"prepatch":this.prerelease.length=0,this.inc("patch",h,d),this.inc("pre",h,d);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",h,d),this.inc("pre",h,d);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const g=Number(d)?1:0;if(this.prerelease.length===0)this.prerelease=[g];else{let f=this.prerelease.length;for(;--f>=0;)typeof this.prerelease[f]=="number"&&(this.prerelease[f]++,f=-2);if(f===-1){if(h===this.prerelease.join(".")&&d===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(g)}}if(h){let f=[h,g];d===!1&&(f=[h]),r(this.prerelease[0],h)===0?isNaN(this.prerelease[1])&&(this.prerelease=f):this.prerelease=f}break}default:throw new Error(`invalid increment argument: ${l}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return Wt=a,Wt}var Gt,qi;function Hs(){if(qi)return Gt;qi=1;const c=Fs();return Gt=(e,t,i)=>new c(e,i).compare(new c(t,i)),Gt}var Zt,zi;function Ws(){if(zi)return Zt;zi=1;const c=Hs();return Zt=(e,t,i)=>c(e,t,i)>0,Zt}Ws();class Me extends me{constructor(s,e=500){super("ERR_OS_INTERNAL",s,e),this.name="InternalError",typeof Error.captureStackTrace<"u"&&Error.captureStackTrace(this,Me)}static fromError(s){const e=new Me(s.message);return Object.assign(e,s,new Me(s.message)),e.stack=s.stack,e}}class Kt extends me{constructor(s,e=500){super("ERR_OS_UNKNOWN",s,e),this.name="UnknownError",typeof Error.captureStackTrace<"u"&&Error.captureStackTrace(this,Kt)}}const Gs=c=>c instanceof Error||Object.prototype.toString.call(c)==="[object Error]",Zs=c=>me.isAbstractError(c)?c:Gs(c)?Me.fromError(c):new Kt(String(c)),pe=c=>{const s=performance.now();return[c(),performance.now()-s]},pt=async c=>{const s=performance.now();return[await c(),performance.now()-s]},ne=(c,s)=>c.filter(e=>!s.includes(e)),y=(...c)=>["👩‍🔬",...c.filter(s=>s!=="").flatMap(s=>{if(be(s,Error)){const e=s;return[e.name,e.message,e.stack]}return s})];function z(c){return Object.entries(c)}function F(c,s,e){if(m(s))return console.warn(...y("No source data was provided.")),c;for(const[t,i]of z(c))t in s||console.info(...y(`Entry '${t}' is missing in source. Using default value.`)),e(i,s[t]);for(const[t]of z(s))t in c||console.warn(...y(`Entry '${t}' was found in source, but it is not expected by the subject schema. This entry will be ignored.`));return c}class vt{constructor(s){u(this,"_elem");this._elem=structuredClone(s)}unwrap(){return structuredClone(this._elem)}replace(s){this._elem=structuredClone(s)}toJSON(){return this.unwrap()}}function J(c){return c.charAt(0).toUpperCase()+c.slice(1)}function Ks(c){return Math.round(c*100)/100}function X(c){return c===-1?Number.POSITIVE_INFINITY:c}class yt{constructor(s,e){u(this,"_host");u(this,"_workshopManager");this._host=s,this._workshopManager=e}bulk(s,e,t,i){const n=[];let r=0;for(const[h,d]of z(s)){const g=re.evaluateSubSectionTrigger(t,d.trigger),f=v(e[h]);if(!d.enabled||g<0||"tHidden"in f&&f.tHidden===!0||"rHidden"in f&&f.rHidden===!0||f.unlocked===!1||!m(d.max)&&-1<d.max&&d.max<=f.val||h==="cryochambers"&&(v(this._host.game.time.getVSU("usedCryochambers")).val>0||this._host.game.bld.getBuildingExt("chronosphere").meta.val<=f.val)||h==="ressourceRetrieval"&&f.val>=100)continue;const p=v(this._isStagedBuild(f)?f.stages[f.stage].prices:f.prices),b=this.getPriceRatio(f,i);if(!this.singleBuildPossible(f,p,b,i))continue;if(p.map(O=>this._workshopManager.getResource(O.name)).filter(O=>0<O.maxValue).filter(O=>O.value/O.maxValue<g).length===0){if(this._isStagedBuild(f)&&typeof d.stage<"u"&&d.stage!==f.stage)continue;const O=[],Y=1-this._host.game.getLimitedDR(this._host.game.getEffect(`${h}CostReduction`),1);for(const le of p){const te=1-this._host.game.getLimitedDR(this._host.game.getEffect(`${le.name}CostReduction`),1);O.push({name:le.name,val:le.val*Y*te})}n.push({count:0,id:h,label:d.label,limit:d.max||0,name:d.baseBuilding??d.building,priceRatio:b,prices:O,source:i,spot:r,val:f.val,variant:d.variant}),r++}}if(n.length===0)return[];const a={};for(const h of this._host.game.resPool.resources)a[h.name]=this._workshopManager.getValueAvailable(h.name);let o=0;const l=new Array;for(;o<1e5;){const h=ne(n,l);let d=0;const g=[];let f={...a};for(const p of l)f=this._precalculateBuilds({...p,limit:p.val+p.count},e,f).remainingResources;for(const p of h){const b=p.count+1,k=this._precalculateBuilds({...p,limit:Math.min(X(p.limit),p.val+b)},e,f);if(k.count<b){g.push(p);continue}p.count=b,f=k.remainingResources,d++}if(l.push(...g),o++,d===0)break}return console.debug(...y(`Took '${o}' iterations to evaluate bulk build request.`)),l}_precalculateBuilds(s,e,t={}){let i=0;const n=Object.assign({},t),r=v(e[s.id]),a=s.prices,o=s.priceRatio,l=s.source;let h=!1;if(a.length===0)return{count:0,remainingResources:n};for(;!h;){for(let d=0;d<a.length;d++){let g=!1,f=!1,p=Number.POSITIVE_INFINITY,b=Number.POSITIVE_INFINITY;if(l==="Space"&&a[d].name==="oil"){g=!0;const k=this._host.game.getEffect("oilReductionRatio");p=a[d].val*(1-this._host.game.getLimitedDR(k,.75))}else if(s.id==="cryochambers"&&a[d].name==="karma"){f=!0;const k=this._host.game.prestige.getBurnedParagonRatio();b=a[d].val*(1-this._host.game.getLimitedDR(.01*k,1))}if(g?h=n.oil<p*1.05**(i+r.val):f?h=n.karma<b*o**(i+r.val):h=n[a[d].name]<a[d].val*o**(i+r.val),h||"noStackable"in r&&r.noStackable&&i+r.val>=1||s.id==="ressourceRetrieval"&&i+r.val>=100||s.id==="cryochambers"&&this._host.game.bld.getBuildingExt("chronosphere").meta.val<=i+r.val){for(let k=0;k<d;k++)if(l==="Space"&&a[k].name==="oil"){const w=this._host.game.getEffect("oilReductionRatio"),O=a[k].val*(1-this._host.game.getLimitedDR(w,.75));n.oil+=O*1.05**(i+r.val)}else if(s.id==="cryochambers"&&a[k].name==="karma"){const w=this._host.game.prestige.getBurnedParagonRatio(),O=a[k].val*(1-this._host.game.getLimitedDR(.01*w,1));n.karma+=O*o**(i+r.val)}else{const w=a[k].val*o**(i+r.val);n[a[k].name]+=a[k].name==="void"?Math.ceil(w):w}return s.limit&&s.limit!==-1&&(i=Math.max(0,Math.min(i,s.limit-s.val))),{count:i,remainingResources:n}}if(g)n.oil-=p*1.05**(i+r.val);else if(f)n.karma-=b*o**(i+r.val);else{const k=a[d].val*o**(i+r.val);n[a[d].name]-=a[d].name==="void"?Math.ceil(k):k}}++i}return{count:i,remainingResources:n}}construct(s,e,t){if(!("name"in s)||!("controller"in s.options)||!("getMetadata"in s.options.controller))return 0;const i=s.metadata;let n=0,r=t;const a=i;if(!m(a.limitBuild)&&a.limitBuild-a.val<r&&(r=a.limitBuild-a.val),s.enabled&&e.hasResources(s)||this._host.game.devMode){for(;e.hasResources(s)&&r>0;)s.prices=e.getPrices(s),e.payPrice(s),e.incrementValue(s),n++,r--;a.breakIronWill&&(this._host.game.ironWill=!1),m(i)||("unlocks"in i&&!m(i.unlocks)&&this._host.game.unlock(i.unlocks),"upgrades"in i&&!m(i.upgrades)&&this._host.game.upgrade(i.upgrades))}return n}_isStagedBuild(s){return"stage"in s&&"stages"in s&&!m(s.stage)&&!m(s.stages)}getPriceRatio(s,e){const t=this._isStagedBuild(s)?s.priceRatio||s.stages[s.stage].priceRatio:s.priceRatio??0;let i=0;return e&&e==="Bonfire"&&(i=this._host.game.getEffect(`${s.name}PriceRatio`)+this._host.game.getEffect("priceRatio")+this._host.game.getEffect("mapPriceReduction"),i=this._host.game.getLimitedDR(i,t-1)),t+i}singleBuildPossible(s,e,t,i){const r=1-this._host.game.getLimitedDR(this._host.game.getEffect(`${s.name}CostReduction`),1);for(const a of e){const l=1-this._host.game.getLimitedDR(this._host.game.getEffect(`${a.name}CostReduction`),1),h=a.val*r*l;if(i&&i==="Space"&&a.name==="oil"){const d=this._host.game.getLimitedDR(this._host.game.getEffect("oilReductionRatio"),.75),g=h*(1-d);if(this._workshopManager.getValueAvailable("oil")<g*1.05**s.val)return!1}else if(s.name==="cryochambers"&&a.name==="karma"){const d=this._host.game.getLimitedDR(.01*this._host.game.prestige.getBurnedParagonRatio(),1),g=h*(1-d);if(this._workshopManager.getValueAvailable("karma")<g*t**s.val)return!1}else if(this._workshopManager.getValueAvailable(a.name)<h*t**s.val)return!1}return!0}}const Fi=["academy","accelerator","aiCore","amphitheatre","aqueduct","barn","biolab","brewery","calciner","chapel","chronosphere","factory","field","harbor","hut","library","logHouse","lumberMill","magneto","mansion","mine","mint","observatory","oilWell","pasture","quarry","reactor","smelter","steamworks","temple","tradepost","unicornPasture","warehouse","workshop","zebraForge","zebraOutpost","zebraWorkshop","ziggurat"],Vt=["broadcasttower","dataCenter","hydroplant","solarfarm","spaceport"],Vs=["autumn","spring","summer","winter"],ve=["charon","umbra","yarn","helios","cath","redmoon","dune","piscine","terminus","kairo"],Hi=["alloy","beam","bloodstone","blueprint","compedium","concrate","eludium","gear","kerosene","manuscript","megalith","parchment","plate","scaffold","ship","slab","steel","tanker","tMythril","thorium","wood"],Wi=[...Hi,"alicorn","antimatter","blackcoin","burnedParagon","catnip","coal","culture","elderBox","faith","furs","gflops","gold","hashrates","iron","ivory","karma","kittens","manpower","minerals","necrocorn","oil","paragon","relic","science","sorrow","spice","starchart","tears","temporalFlux","timeCrystal","titanium","unicorns","unobtainium","uranium","void","wrappingPaper","zebras"],Gi=["any","engineer","farmer","geologist","hunter","miner","priest","scholar","woodcutter"],js=["chemist","engineer","manager","metallurgist","merchant","none","scientist","wise"];var H=(c=>(c.Cryptotheology="c",c.OrderOfTheSun="s",c.Ziggurat="z",c.UnicornPasture="zp",c))(H||{});const Zi=["apocripha","basilica","goldenSpire","scholasticism","solarRevolution","solarchant","stainedGlass","sunAltar","templars","transcendence"],Ki=["blackCore","blackLibrary","blackNexus","blackObelisk","blackRadiance","blazar","darkNova","holyGenocide","mausoleum","singularity"],Vi=["blackPyramid","ivoryCitadel","ivoryTower","marker","skyPalace","sunspire","unicornGraveyard","unicornNecropolis","unicornTomb","unicornUtopia"],ji=["dragons","griffins","nagas","leviathans","lizards","sharks","spiders","zebras"],Js=["authocracy","bigStickPolicy","carnivale","cityOnAHill","clearCutting","communism","conservation","cryochamberExtraction","culturalExchange","diplomacy","dragonRelationsAstrologers","dragonRelationsDynamicists","dragonRelationsPhysicists","environmentalism","epicurianism","expansionism","extravagance","fascism","frugality","fullIndustrialization","griffinRelationsMachinists","griffinRelationsMetallurgists","griffinRelationsScouts","isolationism","knowledgeSharing","liberalism","liberty","lizardRelationsDiplomats","lizardRelationsEcologists","lizardRelationsPriests","militarizeSpace","monarchy","mysticism","nagaRelationsArchitects","nagaRelationsCultists","nagaRelationsMasons","necrocracy","openWoodlands","outerSpaceTreaty","radicalXenophobia","rationality","rationing","republic","scientificCommunism","sharkRelationsBotanists","sharkRelationsMerchants","sharkRelationsScribes","siphoning","socialism","spiderRelationsChemists","spiderRelationsGeologists","spiderRelationsPaleontologists","stoicism","stripMining","sustainability","technocracy","terraformingInsight","theocracy","tradition","transkittenism","zebraRelationsAppeasement","zebraRelationsBellicosity"],Ji=["brewery"],Xs=["acoustics","advExogeology","agriculture","ai","animal","antimatter","archeology","archery","architecture","artificialGravity","astronomy","biochemistry","biology","blackchain","calendar","chemistry","chronophysics","civil","combustion","construction","cryptotheology","currency","dimensionalPhysics","drama","ecology","electricity","electronics","engineering","exogeology","exogeophysics","genetics","hydroponics","industrialization","machinery","math","mechanization","metal","metalurgy","metaphysics","mining","nanotechnology","navigation","nuclearFission","oilProcessing","orbitalEngineering","paradoxalKnowledge","particlePhysics","philosophy","physics","quantumCryptography","robotics","rocketry","sattelites","steel","superconductors","tachyonTheory","terraformation","theology","thorium","voidSpace","writing"],Ys=["centaurusSystemMission","charonMission","duneMission","furthestRingMission","heliosMission","kairoMission","moonMission","orbitalLaunch","piscineMission","rorschachMission","terminusMission","umbraMission","yarnMission"],Xi=["containmentChamber","cryostation","entangler","heatsink","hrHarvester","hydrofracturer","hydroponics","moltenCore","moonBase","moonOutpost","orbitalArray","planetCracker","researchVessel","sattelite","spaceBeacon","spaceElevator","spaceStation","spiceRefinery","sunforge","sunlifter","tectonic","terraformingStation"],Yi=["blastFurnace","ressourceRetrieval","temporalAccelerator","temporalBattery","temporalImpedance","temporalPress","timeBoiler"],Qi=["cryochambers","usedCryochambers","voidHoover","voidRift","chronocontrol","voidResonator"],es=["advancedAutomation","advancedRefinement","aiBases","aiEngineers","alloyArmor","alloyAxe","alloyBarns","alloySaw","alloyWarehouses","amBases","amDrive","amFission","amReactors","amReactorsMK2","assistance","astrolabe","astrophysicists","augumentation","automatedPlants","barges","biofuel","bolas","cadSystems","caravanserai","carbonSequestration","cargoShips","celestialMechanics","chronoEngineers","chronoforge","coalFurnace","coldFusion","combustionEngine","compositeBow","concreteBarns","concreteHuts","concreteWarehouses","crossbow","cryocomputing","darkEnergy","deepMining","distorsion","electrolyticSmelting","eludiumCracker","eludiumHuts","eludiumReflectors","energyRifts","enrichedThorium","enrichedUranium","factoryAutomation","factoryLogistics","factoryOptimization","factoryProcessing","factoryRobotics","fluidizedReactors","fluxCondensator","fuelInjectors","geodesy","gmo","goldOre","hubbleTelescope","huntingArmor","hydroPlantTurbines","internet","invisibleBlackHand","ironAxes","ironHoes","ironwood","lhc","logistics","longRangeSpaceships","machineLearning","mineralAxes","mineralHoes","miningDrill","mWReactor","nanosuits","neuralNetworks","nuclearPlants","nuclearSmelters","offsetPress","oilDistillation","oilRefinery","orbitalGeodesy","oxidation","photolithography","photovoltaic","pneumaticPress","printingPress","pumpjack","pyrolysis","qdot","railgun","reactorVessel","refrigeration","register","reinforcedBarns","reinforcedSaw","reinforcedWarehouses","relicStation","rotaryKiln","satelliteRadio","satnav","seti","silos","solarSatellites","spaceEngineers","spaceManufacturing","spiceNavigation","starlink","stasisChambers","steelArmor","steelAxe","steelPlants","steelSaw","stoneBarns","storageBunkers","strenghtenBuild","tachyonAccelerators","thinFilm","thoriumEngine","thoriumReactors","titaniumAxe","titaniumBarns","titaniumMirrors","titaniumSaw","titaniumWarehouses","turnSmoothly","unicornSelection","unobtainiumAxe","unobtainiumDrill","unobtainiumHuts","unobtainiumReflectors","unobtainiumSaw","uplink","voidAspiration","voidEnergy","voidReactors"];var ce=(c=>(c.Chronoforge="chrono",c.VoidSpace="void",c))(ce||{});const wt=["ivoryCitadel","ivoryTower","skyPalace","sunspire","unicornPasture","unicornTomb","unicornUtopia"],Qs=["sacrificeUnicorns","sacrificeAlicorns","refineTears","refineTimeCrystals","transcend","adore","autoPraise"];class _{constructor(s=!1){u(this,"enabled");this.enabled=s}load(s){m(s)||(this.enabled=s.enabled??this.enabled)}serialize(){return this}}class ts extends _{constructor(e=!1,t=!1){super(e);u(this,"limited");this.limited=t}load(e){m(e)||(super.load(e),this.limited=e.limited??this.limited)}}class V extends _{constructor(e=!1,t=-1){super(e);u(this,"trigger");this.trigger=t}load(e){m(e)||(super.load(e),this.trigger=e.trigger??this.trigger)}}class ae extends _{constructor(e=!1,t=1){super(e);u(this,"trigger");this.trigger=t}load(e){m(e)||(super.load(e),this.trigger=e.trigger??this.trigger)}}class is extends _{constructor(e=!1,t=0){super(e);u(this,"max");this.max=t}load(e){m(e)||(super.load(e),this.max=e.max??this.max)}}class en extends ts{constructor(e=!1,t=!1,i=0){super(e,t);u(this,"max");this.max=i}load(e){m(e)||(super.load(e),this.max=e.max??this.max)}}class tn extends en{constructor(e=!1,t=!1,i=0,n=-1){super(e,t,i);u(this,"trigger");this.trigger=n}load(e){m(e)||(super.load(e),this.trigger=e.trigger??this.trigger)}}class sn extends ts{constructor(e=!1,t=!1,i=-1){super(e,t);u(this,"trigger");this.trigger=i}load(e){m(e)||(super.load(e),this.trigger=e.trigger??this.trigger)}}class kt extends V{constructor(e=!1,t=-1,i=0){super(e,t);u(this,"max");this.max=i}load(e){m(e)||(super.load(e),this.max=e.max??this.max)}}class nn extends ae{constructor(e=!1,t=1,i=0){super(e,t);u(this,"max");this.max=i}load(e){m(e)||(super.load(e),this.max=e.max??this.max)}}class jt{constructor(s,e=new Array){I(this,Oe);u(this,"selected");if(m(e.find(t=>t.value===s)))throw new Error("Provided selected value is not in provided options.");this.selected=s,L(this,Oe,e)}get options(){return B(this,Oe)}load(s){m(s)||(this.selected=s.selected??this.selected)}}Oe=new WeakMap;class an extends ae{constructor(e=!1,t=950,i=1e3,n=1){super(e,n);u(this,"buy");u(this,"sell");this.buy=t,this.sell=i}load(e){m(e)||(super.load(e),this.buy=e.buy??this.buy,this.sell=e.sell??this.sell)}}class rn extends _{constructor(e,t=!1){super(t);I(this,Ue);L(this,Ue,e)}get upgrade(){return B(this,Ue)}}Ue=new WeakMap;class on extends _{constructor(e=!1){super(e);u(this,"buildings");this.buildings=this.initBuildings()}initBuildings(){const e={};for(const t of Vt)e[t]=new rn(t);return e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}))}}class Jt extends kt{constructor(e,t=!1,i=-1,n=0,r){super(t,i,n);I(this,De);I(this,Ne);I(this,qe,0);L(this,Ne,e),r&&(L(this,qe,1),L(this,De,r))}get baseBuilding(){return B(this,De)}get building(){return B(this,Ne)}get stage(){return B(this,qe)}}De=new WeakMap,Ne=new WeakMap,qe=new WeakMap;class Xt extends V{constructor(e=!1,t=-1,i=new _,n=new _,r=new _,a=new _,o=new on){super(e,t);u(this,"buildings");u(this,"gatherCatnip");u(this,"turnOnMagnetos");u(this,"turnOnSteamworks");u(this,"turnOnReactors");u(this,"upgradeBuildings");this.buildings=this.initBuildings(),this.gatherCatnip=i,this.turnOnSteamworks=n,this.turnOnMagnetos=r,this.turnOnReactors=a,this.upgradeBuildings=o}initBuildings(){const e={broadcasttower:"amphitheatre",dataCenter:"library",hydroplant:"aqueduct",solarfarm:"pasture",spaceport:"warehouse"},t={};for(const i of Fi)i!=="unicornPasture"&&(t[i]=new Jt(i));for(const i of Vt)t[i]=new Jt(i,!1,-1,0,e[i]);return t}load(e){var t,i,n,r;m(e)||(super.load(e),F(this.buildings,e.buildings,(a,o)=>{a.enabled=(o==null?void 0:o.enabled)??a.enabled,a.max=(o==null?void 0:o.max)??a.max,a.trigger=(o==null?void 0:o.trigger)??a.trigger}),this.gatherCatnip.enabled=((t=e.gatherCatnip)==null?void 0:t.enabled)??this.gatherCatnip.enabled,this.turnOnSteamworks.enabled=((i=e.turnOnSteamworks)==null?void 0:i.enabled)??this.turnOnSteamworks.enabled,this.turnOnMagnetos.enabled=((n=e.turnOnMagnetos)==null?void 0:n.enabled)??this.turnOnMagnetos.enabled,this.turnOnReactors.enabled=((r=e.turnOnReactors)==null?void 0:r.enabled)??this.turnOnReactors.enabled,this.upgradeBuildings.load(e.upgradeBuildings))}}class ln{constructor(s,e,t=new Xt){u(this,"_host");u(this,"settings");u(this,"_bulkManager");u(this,"_workshopManager");this._host=s,this.settings=t,this._workshopManager=e,this._bulkManager=new yt(this._host,this._workshopManager)}tick(s){this.settings.enabled&&(this.autoBuild(s),this.autoMisc(s))}autoBuild(s,e=this.settings.buildings){const t=this._bulkManager,i={};for(const a of Object.values(e))i[a.building]=this._host.game.bld.getBuildingExt(a.baseBuilding??a.building).meta;const n=this.settings.trigger,r=t.bulk(e,i,n,"Bonfire");for(const a of r.filter(o=>0<o.count))this.build(a.name||a.id,a.stage,a.count),s.requestGameUiRefresh=!0}autoUpgrade(s){var l,h,d,g,f,p,b;const e=this._host.game.bld.getBuildingExt("pasture").meta.stage===0?this._host.game.bld.getBuildingExt("pasture").meta.val:0,t=this._host.game.bld.getBuildingExt("aqueduct").meta.stage===0?this._host.game.bld.getBuildingExt("aqueduct").meta.val:0,i=this._host.game.bld.getBuildingExt("pasture").meta;if(this.settings.upgradeBuildings.buildings.solarfarm.enabled&&i.unlocked&&i.stage===0&&v(i.stages)[1].stageUnlocked&&this._workshopManager.getPotentialCatnip(!0,0,t)>0){const k=v(i.stages)[1].prices;if(this._bulkManager.singleBuildPossible(i,k,1)){const w=this.getBuild("pasture",0);m(w==null?void 0:w.model)||(w.controller.sellInternal(w.model,0,!1),i.on=0,i.val=0,i.stage=1,this._host.engine.iactivity("upgrade.building.pasture",[],"ks-upgrade"),(l=this._host.game.ui)==null||l.render(),this.build("pasture",1,1),s.requestGameUiRefresh=!0)}}const n=this._host.game.bld.getBuildingExt("aqueduct").meta;if(this.settings.upgradeBuildings.buildings.hydroplant.enabled&&n.unlocked&&n.stage===0&&v(n.stages)[1].stageUnlocked&&this._workshopManager.getPotentialCatnip(!0,e,0)>0){const k=v(n.stages)[1].prices;if(this._bulkManager.singleBuildPossible(n,k,1)){const w=this.getBuild("aqueduct",0);m(w==null?void 0:w.model)||(w.controller.sellInternal(w.model,0,!1),n.on=0,n.val=0,n.stage=1,(h=n.calculateEffects)==null||h.call(n,n,this._host.game),this._host.engine.iactivity("upgrade.building.aqueduct",[],"ks-upgrade"),(d=this._host.game.ui)==null||d.render(),this.build("aqueduct",1,1),s.requestGameUiRefresh=!0)}}const r=this._host.game.bld.getBuildingExt("library").meta;if(this.settings.upgradeBuildings.buildings.dataCenter.enabled&&r.unlocked&&r.stage===0&&v(r.stages)[1].stageUnlocked){let k=this._host.game.workshop.get("cryocomputing").researched?1:2;this._host.game.challenges.currentChallenge==="energy"&&(k*=2);let w=3;if(this._host.game.workshop.get("uplink").researched&&(w*=1+this._host.game.bld.getBuildingExt("biolab").meta.val*this._host.game.getEffect("uplinkDCRatio")),this._host.game.workshop.get("machineLearning").researched&&(w*=1+this._host.game.bld.getBuildingExt("aiCore").meta.on*this._host.game.getEffect("dataCenterAIRatio")),this._host.game.resPool.energyProd>=this._host.game.resPool.energyCons+k*r.val/w){const O=v(r.stages)[1].prices;if(this._bulkManager.singleBuildPossible(r,O,1)){const ee=v(this.getBuild("library",0));if(m(ee.model))return;ee.controller.sellInternal(ee.model,0,!1),r.on=0,r.val=0,r.stage=1,(g=r.calculateEffects)==null||g.call(r,r,this._host.game),this._host.engine.iactivity("upgrade.building.library",[],"ks-upgrade"),(f=this._host.game.ui)==null||f.render(),this.build("library",1,1),s.requestGameUiRefresh=!0;return}}}const a=this._host.game.bld.getBuildingExt("warehouse").meta;if(this.settings.upgradeBuildings.buildings.spaceport.enabled&&a.unlocked&&a.stage===0&&v(a.stages)[1].stageUnlocked){const k=v(a.stages)[1].prices;if(this._bulkManager.singleBuildPossible(a,k,1)){const w=this.getBuild("warehouse",0);if(!m(w==null?void 0:w.model)){w.controller.sellInternal(w.model,0,!1),a.on=0,a.val=0,a.stage=1,this._host.engine.iactivity("upgrade.building.warehouse",[],"ks-upgrade"),(p=this._host.game.ui)==null||p.render(),this.build("warehouse",1,1),s.requestGameUiRefresh=!0;return}}}const o=this._host.game.bld.getBuildingExt("amphitheatre").meta;if(this.settings.upgradeBuildings.buildings.broadcasttower.enabled&&o.unlocked&&o.stage===0&&v(o.stages)[1].stageUnlocked){const k=v(o.stages)[1].prices;if(this._bulkManager.singleBuildPossible(o,k,1)){const w=this.getBuild("amphitheatre",0);m(w==null?void 0:w.model)||(w.controller.sellInternal(w.model,0,!1),o.on=0,o.val=0,o.stage=1,this._host.engine.iactivity("upgrade.building.amphitheatre",[],"ks-upgrade"),(b=this._host.game.ui)==null||b.render(),this.build("amphitheatre",1,1),s.requestGameUiRefresh=!0)}}}autoMisc(s){if(this.settings.turnOnSteamworks.enabled){const e=this._host.game.bld.getBuildingExt("steamworks");if(e.meta.val&&e.meta.on===0){const t=this.getBuild("steamworks");t.controller.onAll(t.model)}}if(this.settings.turnOnMagnetos.enabled){const e=this._host.game.bld.getBuildingExt("magneto");if(e.meta.val&&e.meta.on<e.meta.val){const t=this.getBuild("magneto");t.controller.onAll(t.model)}}if(this.settings.turnOnReactors.enabled){const e=this._host.game.bld.getBuildingExt("reactor");if(e.meta.val&&e.meta.on<e.meta.val){const t=this.getBuild("reactor");t.controller.onAll(t.model)}}this.settings.upgradeBuildings.enabled&&this.autoUpgrade(s),this.settings.gatherCatnip.enabled&&this.autoGather()}autoGather(){for(let s=0;s<Math.floor(this._host.engine.settings.interval/20);++s)this._host.game.bld.gatherCatnip()}build(s,e,t){let i=t;const n=i;let r;const a=game.getUnlockByName(s,"buildings"),o=new classes.BuildingMeta(a).getMeta();if("stages"in o){const l=new classes.ui.btn.StagingBldBtnController(this._host.game),h=l.fetchModel({building:s,controller:l,description:v(o.description),name:v(o.label),twoRow:!1});i=this._bulkManager.construct(h,l,i),r=o.label??""}else{const l=new classes.ui.btn.BuildingBtnModernController(this._host.game),h=l.fetchModel({building:s,controller:l,description:v(o.description),name:v(o.label),twoRow:!1});i=this._bulkManager.construct(h,l,i),r=o.label??""}i!==n&&(console.warn(...y(`${r} Amount ordered: ${n} Amount Constructed: ${i}`)),i===0)||(this._host.engine.storeForSummary(r,i,"build"),i===1?this._host.engine.iactivity("act.build",[r],"ks-build"):this._host.engine.iactivity("act.builds",[r,this._host.renderAbsolute(i)],"ks-build"))}getBuild(s,e=0){const t=game.bld.get(s),i=new classes.BuildingMeta(t).getMeta(),n=m(i.stages)?t:i.stages[e],r="stages"in n?new classes.ui.btn.StagingBldBtnController(this._host.game):new classes.ui.btn.BuildingBtnModernController(this._host.game),a=r.fetchModel({building:s,description:n.description,key:s,name:n.label});return{controller:r,model:a}}}class cn{constructor(s){u(this,"_host");u(this,"_lastday");u(this,"_lastyear");u(this,"_sections",new Map);this._host=s,this.resetActivity()}resetActivity(){this._sections=new Map,this._lastday=this._host.game.calendar.day,this._lastyear=this._host.game.calendar.year}storeActivity(s,e=1,t="other"){this._sections.has(t)||this._sections.set(t,new Map);const i=v(this._sections.get(t));i.has(s)||i.set(s,0),i.set(s,v(i.get(s))+e)}renderSummary(){const s=new Array;if(this._sections.has("other")&&v(this._sections.get("other")).forEach((t,i)=>s.push(this._host.engine.i18n(`summary.${i}`,[this._host.game.getDisplayValueExt(t)]))),this._sections.has("research")&&v(this._sections.get("research")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.tech",[J(i)]))}),this._sections.has("upgrade")&&v(this._sections.get("upgrade")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.upgrade",[J(i)]))}),this._sections.has("build")&&v(this._sections.get("build")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.building",[this._host.game.getDisplayValueExt(t),J(i)]))}),this._sections.has("refine")&&v(this._sections.get("refine")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.refine",[this._host.game.getDisplayValueExt(t),J(i)]))}),this._sections.has("faith")&&v(this._sections.get("faith")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.sun",[this._host.game.getDisplayValueExt(t),J(i)]))}),this._sections.has("craft")&&v(this._sections.get("craft")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.craft",[this._host.game.getDisplayValueExt(t),J(i)]))}),this._sections.has("trade")&&v(this._sections.get("trade")).forEach((t,i)=>{s.push(this._host.engine.i18n("summary.trade",[this._host.game.getDisplayValueExt(t),J(i)]))}),this._lastday&&this._lastyear){let e=this._host.game.calendar.year-this._lastyear,t=this._host.game.calendar.day-this._lastday;t<0&&(e-=1,t+=400);let i="";e>0&&(i+=`${e} `,i+=e===1?this._host.engine.i18n("summary.year"):this._host.engine.i18n("summary.years")),t>=0&&(e>0&&(i+=this._host.engine.i18n("summary.separator")),i+=`${Ks(t)} `,i+=t===1?this._host.engine.i18n("summary.day"):this._host.engine.i18n("summary.days")),s.push(this._host.engine.i18n("summary.head",[i]))}return s}}const hn={"act.accelerate":"Accelerate time!","act.adore":"Adore the galaxy! Accumulated {0} worship to {1} epiphany","act.blackcoin.buy":"Kittens sold your Relics and bought {0} Blackcoins","act.blackcoin.sell":"Kittens sold your Blackcoins and bought {0} Relics","act.build":"Kittens have built a new {0}","act.builds":"Kittens have built a new {0} {1} times","act.craft":"Kittens have crafted {0} {1}","act.distribute":"Distributed a kitten to {0}","act.elect":"Kittens have elected a new leader.","act.feed":"Kittens fed the Elders. The elders are pleased","act.fix.cry":"Kittens fixed {0} Cryochambers","act.hunt":"Sent kittens on {0} hunts","act.observe":"Kitten Scientists have observed a star","act.praise":"Praised the sun! Accumulated {0} faith to {1} worship","act.promote":"Kittens' leader has been promoted to rank {0}","act.refineTCs":"Refined {0} time crystals","act.refineTears":"Refined {0} tears into BLS","act.sacrificeAlicorns":"Sacrificed {0} alicorns","act.sacrificeUnicorns":"Sacrificed {0} unicorns","act.sun.discover":"Kittens have discovered {0}","act.sun.discovers":"Kittens have discovered {0} {1} times","act.time.activeHeatTransferEnd":"End active Heat Transfer","act.time.activeHeatTransferStart":"Start active Heat Transfer","act.time.getTemporalFlux":"Burn crystals to obtain time flux to maintain time acceleration","act.time.skip":"Kittens combust a time crystal, {0} years skipped!","act.trade":"Kittens have traded {0} times with {1}","act.transcend":"Spent {0} epiphany, Transcended to T-level: {1}","blackcoin.buy":"Buy Limit: {0}","blackcoin.buy.prompt":"Enter at which price you want to stop buying blackcoins.","blackcoin.buy.promptExplainer":"Blackcoin price always rises from 800 to 1100 (roughly), then it crashes. You usually want to buy until shortly before you sell.","blackcoin.buy.promptTitle":"Buy Limit for Blackcoins (Current: {0})","blackcoin.buy.title":"Buy Blackcoins until price reaches {0}","blackcoin.buy.trigger":"buying Blackcoins (in relics)","blackcoin.sell":"Sell Order: {0}","blackcoin.sell.prompt":"Enter at which price you want to sell all your blackcoins.","blackcoin.sell.promptExplainer":"Blackcoin price always rises from 800 to 1100 (roughly), then it crashes. You usually want to sell close to the highest possible price.","blackcoin.sell.promptTitle":"Sell Order for Blackcoins (Current: {0})","blackcoin.sell.title":"Sell Blackcoins when price reaches {0}","build.embassies":"Built {0} embassies for {1}","build.embassy":"Built {0} embassy for {1}",copy:"Copy","craft.limited":"Crafting {0}: limited to be proportional to cost ratio","craft.unlimited":"Crafting {0}: unlimited",delete:"Delete","dispose.necrocorn":"Kittens disposed of inefficient necrocorns","festival.extend":"Kittens extend the festival","festival.hold":"Kittens begin holding a festival","filter.accelerate":"Tempus Fugit","filter.adore":"Adoring","filter.allKG":"All KG log entries.","filter.build":"Building","filter.craft":"Crafting","filter.disable":"Disabled {0} log messages","filter.distribute":"Distribute","filter.enable":"Enabled {0} log messages","filter.explainer":"Disabled items are hidden from the log.","filter.faith":"Order of the Sun","filter.festival":"Festivals","filter.hunt":"Hunting","filter.misc":"Miscellaneous","filter.praise":"Praising","filter.promote":"Promote leader","filter.research":"Researching","filter.star":"Astronomical Events","filter.timeSkip":"Time Skip","filter.trade":"Trading","filter.transcend":"Transcend","filter.upgrade":"Upgrading","option.accelerate":"Tempus Fugit","option.autofeed":"Feed Leviathans","option.catnip":"Gather Catnip","option.crypto":"Trade Blackcoin","option.elect":"Elect leader","option.elect.job":"Job","option.elect.job.any":"Any","option.elect.trait":"Trait","option.embassies":"Build Embassies","option.faith.adore":"Adore the Galaxy","option.faith.autoPraise":"Praise the Sun","option.faith.best.unicorn":"Automate Build Order","option.faith.refineTears":"Refine Tears","option.faith.refineTimeCrystals":"Refine TCs","option.faith.sacrificeAlicorns":"Sacrifice Alicorns","option.faith.sacrificeUnicorns":"Sacrifice Unicorns","option.faith.transcend":"Transcend","option.festival":"Hold festivals","option.fix.cry":"Fix Cryochamber","option.hunt":"Hunt","option.magnetos":"Turn on Magnetos","option.observe":"Observe Astro Events","option.praise":"Praise the Sun","option.promote":"Promote leader","option.promotekittens":"Promote kittens","option.reactors":"Turn on Reactors","option.shipOverride":"Force Ships to 243","option.steamworks":"Turn on Steamworks","option.time.activeHeatTransfer":"Active Heat Transfer","option.time.reset":"Reset Timeline (Danger!)","option.time.skip":"Time Skip","option.time.skip.ignoreOverheat":"Ignore overheat",reset:"Reset","reset.after":"Nice to meet you, the cute Kitten Scientists will serve you","reset.cancel.activity":"Meoston, We Have a Problem","reset.cancel.message":"Timeline Reset canceled","reset.check":"Trigger for {0}: {1}, you have {2}","reset.checked":"All conditions are met, the timeline will restart in the next few seconds!","reset.countdown.0":"0 - Temporal rifts opened!","reset.countdown.1":"1 - Time engine start","reset.countdown.2":"2 - Boosting the chronoforge","reset.countdown.3":"3 - Opening temporal rifts","reset.countdown.4":"4 - Turning off satellite","reset.countdown.5":"5 - Melting blackcoins","reset.countdown.6":"6 - Starting time engines","reset.countdown.7":"7 - Disassembling railguns","reset.countdown.8":"8 - Releasing lizards","reset.countdown.9":"9 - Sacrificing unicorns","reset.countdown.10":"10 - Harvesting catnip","reset.last.message":"See you next poincaré recurrence","reset.tip":'You can cancel this reset by disabling "Enable Kitten Scientists" at the top of the settings.',"resources.consume":"Consume: {0}","resources.consume.prompt":"Enter how much of the resource you want automations to consume as a percentage between 0.0 and 100.0.","resources.consume.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","resources.consume.promptTitle":"Consumption Share for {0} (Current: {1})","resources.consume.set":"Consume rate for {0}","resources.consume.title":"Consuming {0} of {1}","resources.consume.titleZero":"Not consuming {0}","resources.stock.prompt":"Enter how much of the resource you always want to keep in stock.","resources.stock.promptExplainer":"All notations that the game supports are accepted. If you submit an empty value, or a negative value, the limit will be set to infinity. If you set the limit to 0, this option will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","resources.stock.promptTitle":"Stock value for {0} (Current: {1})","resources.stock.title":"Keeping {0} {1} in stock","resources.stock.titleInfinite":"Keeping all {0} in stock","resources.stock.titleZero":"Not keeping any {0} in stock","state.compress":"Compress copied Kittens Game saves","state.confirmDestruction":"Are you sure?","state.copied.game":"Save '{0}' copied to clipboard.","state.copied.gameCurrent":"Current save copied to clipboard.","state.copied.state":"State '{0}' copied to clipboard.","state.copied.stateCurrent":"Current state copied to clipboard.","state.copy.game":"Copy this save to the clipboard.","state.copy.gameCurrent":"Copy the entire Kittens Game save (includes KS settings) to the clipboard.","state.copy.state":"Copy these settings to the clipboard.","state.copy.stateCurrent":"Copy the current Kitten Scientists settings to the clipboard.","state.delete.game":"Delete this save.","state.delete.state":"Delete these settings.","state.deleted.game":"Save '{0}' deleted.","state.deleted.state":"State '{0}' deleted.","state.edit.game":"Change the name of this save.","state.edit.state":"Change the name of these settings.","state.exportAll":"Backup","state.exportAllTitle":"Stores all local states in a single file and downloads it.","state.import":"Import settings/saves","state.imported.game":"Save imported.","state.imported.state":"State imported.","state.importedState":"Imported state {0}","state.importTitle":`Paste a save or settings from your clipboard.
23
+ Contents will be automatically detected and handled accordingly.`,"state.loaded.game":"Save '{0}' loaded.","state.loaded.state":"State '{0}' loaded.","state.loadPrompt":"Paste your (un/compressed) save or settings here:","state.local":"Local storage management","state.localGames":"Kittens Game Saves","state.localStates":"Kitten Scientists Settings","state.new":"New","state.noConfirm":"Don't ask for confirmation","state.store":"Store","state.stored.game":"Save stored.","state.stored.state":"State stored.","state.storeFactory":"Create a new state from factory defaults.","state.storeGame":"Create a new save from the current game.","state.storeGame.prompt":"Provide a label for this save:","state.storeState":"Create a new state from current settings.","state.storeState.prompt":"Provide a label for this state:","state.title":"State Management","state.unlabeledGame":"unlabeled save","state.unlabeledState":"unlabeled state","state.update.game":"Save the current game into this slot.","state.update.state":"Save the current settings into this slot.","state.updated.game":"Save '{0}' updated.","state.updated.state":"State '{0}' updated.","status.auto.disable":"Disabled Auto {0}","status.auto.enable":"Enabled Auto {0}","status.ks.disable":"Disabling the Kitten Scientists!","status.ks.enable":"Enabling the Kitten Scientists!","status.ks.init":"Kitten Scientists initialized.","status.ks.upgrade":"Kitten Scientists {0} (ours is {1}) is available at {2}.","status.reset.check.disable":"Disabled check {0} before Reset Timeline","status.reset.check.enable":"Enabled check {0} before Reset Timeline","status.resource.disable":"Disabled {0} resource management","status.resource.enable":"Enabled {0} resource management","status.sub.disable":"Disabled {0}","status.sub.enable":"Enabled {0}","summary.accelerate":"Accelerated time {0} times","summary.adore":"Accumulated {0} epiphany by adoring the galaxy","summary.building":"Built {0} {1}","summary.craft":"Crafted {0} {1}","summary.day":"day","summary.days":"days","summary.distribute":"Helped {0} kittens find a job","summary.embassy":"Built {0} embassies","summary.feed":"Fed the elders {0} necrocorns","summary.festival":"Held {0} festivals","summary.fix.cry":"Fixed {0} cryochambers","summary.head":"Summary of the last {0}","summary.hunt":"Sent adorable kitten hunters on {0} hunts","summary.praise":"Accumulated {0} worship by praising the sun","summary.promote":"Promoted our leader {0} times","summary.refine":"Refined {0} {1}","summary.separator":" and ","summary.show":"Show activity","summary.stars":"Observed {0} stars","summary.sun":"Discovered {0} {1}","summary.tech":"Researched {0}","summary.time.activeHeatTransferStart":"Active Heat Transfer {0} times","summary.time.getTemporalFlux":"Burn crystal to gain time flux {0} times","summary.time.reset.content":"Gained {0} Karma.<br>Gained {1} Paragon","summary.time.reset.title":"Summary of the last {0} timelines","summary.time.skip":"Skipped {0} years","summary.trade":"Traded {0} times with {1}","summary.transcend":"Transcended {0} times","summary.upgrade":"Upgraded {0}","summary.year":"year","summary.years":"years","time.heatTransfer.cycle.disable":"Disabled active heat transfer in cycle {0}","time.heatTransfer.cycle.enable":"Enabled active heat transfer in cycle {0}","time.skip.cycle.disable":"Disabled time skip in cycle {0} and disallow skip over this cycle","time.skip.cycle.enable":"Enabled time skip in cycle {0} and allow skip over this cycle","time.skip.season.disable":"Disabled time skip in the {0}","time.skip.season.enable":"Enabled time skip in the {0}","trade.limited":"Trading with {0}: limited to only occur when profitable based off relative production time","trade.season.disable":"Disabled trading with {0} in the {1}","trade.season.enable":"Enabled trading with {0} in the {1}","trade.seasons":"seasons","trade.unlimited":"Trading with {0}: unlimited","ui.additional":"Additional options","ui.build":"Bonfire","ui.close":"close","ui.craft":"Workshop","ui.craft.resources":"Resources","ui.cycles":"cycles","ui.disable.all":"Disable all options in this list.","ui.distribute":"Village","ui.enable.all":"Enable all options in this list.","ui.engine":"Enable Kitten Scientists","ui.faith":"Religion","ui.filter":"Log Filters","ui.highlightStock":"Highlight resource stock","ui.infinity":"∞","ui.internals":"Internals","ui.internals.interval":"Interval: {0}","ui.internals.interval.prompt":"Enter the new amount of milliseconds as an absolute value between 0 and Infinity.","ui.internals.interval.promptExplainer":"All notations that the game supports are accepted. If you set the limit to 0, Kitten Scientists will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.internals.interval.promptTitle":"Kitten Scientists Execution Interval (Current: {0})","ui.itemsHide":"Collapse section","ui.itemsShow":"Expand section","ui.ksColumn":"Display KS in fourth column in UI","ui.language":"Language","ui.limit":"Limited","ui.limited.off":"Unlimited","ui.limited.on":"Eco Mode","ui.max":"Max: {0}","ui.max.build.prompt":"Limit for {0} (Current: {1})","ui.max.build.promptExplainer":"All notations that the game supports are accepted. If you submit an empty value, or a negative value, the limit will be set to infinity. If you set the limit to 0, this option will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.max.build.title":"Build {0} {1}","ui.max.build.titleInfinite":"Never stop building {0}","ui.max.build.titleZero":"Don't build {0}","ui.max.craft.prompt":"Enter the new limit of how many {0} to craft as an absolute value between 0 and Infinity.","ui.max.craft.promptExplainer":"All notations that the game supports are accepted. If you submit an empty value, or a negative value, the limit will be set to infinity. If you set the limit to 0, this option will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.max.craft.promptTitle":"Limit for Crafting {0} (Current: {1})","ui.max.craft.title":"Craft {0} {1}","ui.max.craft.titleInfinite":"Never stop crafting {0}","ui.max.craft.titleZero":"Don't craft {0}","ui.max.distribute.prompt":"Enter the new amount of kittens to assign as {0} as an absolute value between 0 and Infinity.","ui.max.distribute.promptExplainer":"All notations that the game supports are accepted. If you submit an empty value, or a negative value, the limit will be set to infinity. If you set the limit to 0, this option will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.max.distribute.promptTitle":"Assign Max. Kittens as {0} (Current: {1})","ui.max.distribute.title":"Assign {0} kittens as {1}","ui.max.distribute.titleInfinite":"Assign as many kittens as possible as {0}","ui.max.distribute.titleZero":"Don't assign any kittens as {0}","ui.max.embassy.title":"Build {0} embassy for {1}","ui.max.embassy.titleInfinite":"Never stop building embassies for {0}","ui.max.embassy.titleZero":"Don't build embassies for {0}","ui.max.prompt.absolute":"Enter the new limit as an absolute value between 0 and Infinity.","ui.max.prompt.float":"Enter the new limit as an absolute value between 0.0 and Infinity.","ui.max.set":"Maximum for {0}","ui.max.timeSkip.prompt":"Enter the new amount of years as an absolute value between 0 and Infinity.","ui.max.timeSkip.promptExplainer":"All notations that the game supports are accepted. If you submit an empty value, or a negative value, the limit will be set to infinity. If you set the limit to 0, this option will be automatically disabled. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.max.timeSkip.promptTitle":"Max. Years to skip (Current: {0})","ui.max.timeSkip.title":"Skip {0} years at once","ui.max.timeSkip.titleInfinite":"Skip as many years as possible","ui.max.timeSkip.titleZero":"Don't skip time","ui.maximum":"Maximum","ui.min":"Min: {0}","ui.options":"Options","ui.reset":"Reset list options to default configuration.","ui.resources":"Resource Control","ui.space":"Space","ui.time":"Time","ui.timeCtrl":"Time Control","ui.trade":"Trade","ui.trigger":"Trigger: {0}","ui.trigger.accelerateTime.prompt":"Enter the new temporal flux storage level at which to enable Tempus Fugit as a percentage between 0.0 and 100.0.","ui.trigger.accelerateTime.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.accelerateTime.promptTitle":"Trigger to Accelerate Time (Current: {0})","ui.trigger.activeHeatTransfer.prompt":"Enter the new temporal heat storage level at which to enable heat transfer as a percentage between 0.0 and 100.0.","ui.trigger.activeHeatTransfer.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.activeHeatTransfer.promptTitle":"Trigger for Heat Transfer (Current: {0})","ui.trigger.build.blocked":`∞
24
24
  🛈 The {0} section has no trigger set. This build will not be triggered!`,"ui.trigger.build.inherited":"inherited from section","ui.trigger.build.prompt":"Trigger for {0} (Current: {1})","ui.trigger.build.promptExplainer":"If you submit an empty value, or a negative value, the section trigger is used instead. If you submit an invalid value, it will be treated as if you hit Cancel.","ui.trigger.crypto.prompt":"Enter the new relic storage level at which to trade blackcoin as an absolute value between 0.0 and Infinity.","ui.trigger.crypto.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.crypto.promptTitle":"Trigger to Trade Blackcoin (Current: {0})","ui.trigger.embassies.prompt":"Enter the new culture storage level at which to build embassies as a percentage between 0.0 and 100.0.","ui.trigger.embassies.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.embassies.promptTitle":"Trigger to Build Embassies (Current: {0})","ui.trigger.hunt.prompt":"Trigger for Hunting (Current: {0})","ui.trigger.hunt.promptExplainer":"If you submit a negative value, hunting will be disabled. If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.inactive":"inactive","ui.trigger.promoteKittens.prompt":"Enter the new gold storage level at which to promote kittens as a percentage between 0.0 and 100.0.","ui.trigger.promoteKittens.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.promoteKittens.promptTitle":"Trigger to Promote Kittens (Current: {0})","ui.trigger.prompt.absolute":"Enter the new trigger value as an absolute value between 0 and Infinity.","ui.trigger.prompt.float":"Enter the new trigger value as an absolute value between 0.0 and Infinity.","ui.trigger.prompt.percentage":"Enter the new trigger value as a percentage between 0.0 and 100.0.","ui.trigger.reset.promptExplainer":"If you submit a negative value, the item will be disabled. If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.section":"Section default trigger: {0}","ui.trigger.section.blocked":`∞
25
25
  🛈 The {0} section has no trigger set. This automation will not be triggered!`,"ui.trigger.section.inactive":"∞ (nothing is triggered automatically)","ui.trigger.section.inherited":"inherited from section","ui.trigger.section.prompt":"Trigger for section {0} (Current: {1})","ui.trigger.section.promptExplainer":`If you submit an empty value, or a negative value, the section trigger will be set to infinity (∞). Individual automations in this section need to have their own trigger set to be activated.
26
26
  If you submit an invalid value, it will be treated as if you hit Cancel.`,"ui.trigger.setinteger":"Enter a new trigger value for {0}. Should be in the range from 0 up to any number. -1 means infinity.","ui.trigger.setinteger.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.setpercentage":"Enter a new trigger value for {0}. Should be in the range from 0 to 100.","ui.trigger.setpercentage.promptExplainer":"If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.timeSkip.prompt":"Enter the new amount of Time Crystals at which to skip time as an absolute value between 1 and Infinity.","ui.trigger.timeSkip.promptExplainer":"If you submit a negative value, time skipping will be disabled. If you submit an empty value, or an invalid value, it will be treated as if you hit Cancel.","ui.trigger.timeSkip.promptTitle":"Trigger for Time Skip (Current: {0})","ui.upgrade":"Science","ui.upgrade.buildings":"Upgrade buildings","ui.upgrade.missions":"Start missions","ui.upgrade.policies":"Research policies","ui.upgrade.races":"Explore new races","ui.upgrade.techs":"Research technologies","ui.upgrade.upgrades":"Research upgrades","ui.upgrades":"Upgrades",update:"Update","upgrade.building.amphitheatre":"Upgraded amphitheatres to broadcast towers!","upgrade.building.aqueduct":"Upgraded aqueducts to hydro plants!","upgrade.building.library":"Upgraded libraries to data centers!","upgrade.building.pasture":"Upgraded pastures to solar farms!","upgrade.building.warehouse":"Upgraded warehouses to spaceports!","upgrade.policy":"Kittens have passed {0}","upgrade.race":"Kittens met the {0}","upgrade.space":"Kittens conducted a {0}","upgrade.space.mission":"Kittens conducted a mission to {0}","upgrade.tech":"Kittens have bought the tech {0}","upgrade.upgrade":"Kittens have bought the upgrade {0}"},un={"act.accelerate":"Zeit beschleunigen!","act.adore":"Verehre die Galaxie! Kumulierte {0} Anbetung zu {1} Offenbarung","act.blackcoin.buy":"Kätzchen haben deine Relikte verkauft und {0} Blackcoins gekauft","act.blackcoin.sell":"Kätzchen haben deine Blackcoins verkauft und {0} Relikte gekauft","act.build":"Kätzchen haben ein neues {0} gebaut","act.builds":"Kätzchen haben ein neues {0} {1} Mal gebaut","act.craft":"Kätzchen haben {0} {1} hergestellt","act.distribute":"Ein Kätzchen an {0} verteilt","act.elect":"Kätzchen haben einen neuen Anführer gewählt.","act.feed":"Kätzchen haben die Ältesten gefüttert. Die Ältesten sind zufrieden","act.fix.cry":"Kätzchen haben {0} Kryokammern repariert","act.hunt":"Kätzchen auf {0} Jagden entsendet","act.observe":"Kitten Scientists haben einen Stern beobachtet","act.praise":"Die Sonne gelobt! {0} Glaube zu {1} Anbetung kumuliert","act.promote":"Der Anführer der Kätzchen wurde zum Rang {0} befördert","act.refineTCs":"{0} Zeit-Kristalle verfeinert","act.refineTears":"{0} Tränen zu STF verfeinert","act.sacrificeAlicorns":"{0} Alihörner geopfert","act.sacrificeUnicorns":"{0} Einhörner geopfert","act.sun.discover":"Kätzchen haben {0} entdeckt","act.sun.discovers":"Kätzchen haben {0} {1} mal entdeckt","act.time.activeHeatTransferEnd":"Aktiver Wärmetransfer beendet","act.time.activeHeatTransferStart":"Starte aktiven Wärmetransfer","act.time.getTemporalFlux":"Verbrennt Kristalle, um Flux zur Erhaltung der Zeitbeschleunigung zu bekommen","act.time.skip":"Kätzchen verbrennen einen Zeit-Kristall, {0} Jahre übersprungen!","act.trade":"Kätzchen haben {0} mal mit {1} gehandelt","act.transcend":"{0} Offenbarung ausgegeben, auf T-Level {1} aufgestiegen","blackcoin.buy":"Kauf-Limit: {0}","blackcoin.buy.prompt":"Gib den Preis ein, ab welchem du keine Blackcoins mehr kaufen möchtest.","blackcoin.buy.promptExplainer":"Der Blackcoin-Preis steigt immer von 800 auf 1100 (ungefähr), dann stürzt er ab. Du möchtest normalerweise bis kurz vor dem Verkauf einkaufen.","blackcoin.buy.promptTitle":"Kauf-Limit für Blackcoins (Aktuell: {0})","blackcoin.buy.title":"Blackcoins kaufen bis der Preis {0} erreicht","blackcoin.buy.trigger":"kaufe Blackcoins (in Relikten)","blackcoin.sell":"Verkauf-Order: {0}","blackcoin.sell.prompt":"Gib den Preis ein, zu welchem du deine Blackcoins verkaufen möchtest.","blackcoin.sell.promptExplainer":"Der Blackcoin-Preis steigt immer von 800 auf 1100 (ungefähr), dann stürzt er ab. Du möchtest normalerweise nahe dem höchstmöglichen Preis verkaufen.","blackcoin.sell.promptTitle":"Verkauf-Order für Blackcoins (Aktuell: {0})","blackcoin.sell.title":"Blackcoins verkaufen, wenn der Preis {0} erreicht","build.embassies":"{0} Botschaften für {1} gebaut","build.embassy":"{0} Botschaft für {1} gebaut",copy:"Kopieren","craft.limited":"Herstellen von {0}: im Verhältnis zum Kostenverhältnis begrenzt","craft.unlimited":"Herstellung von {0}: unbegrenzt",delete:"Löschen","dispose.necrocorn":"Kätzchen haben ineffiziente Necrocorns entsorgt","festival.extend":"Kätzchen haben das Festival verlängert","festival.hold":"Kätzchen fangen an, ein Festival abzuhalten","filter.accelerate":"Tempus Fugit","filter.adore":"Bewundern","filter.allKG":"Alle KG Protokollnachrichten.","filter.build":"Bauen","filter.craft":"Herstellen","filter.disable":"{0} Protokollnachrichten deaktiviert","filter.distribute":"Verteilen","filter.enable":"{0} Protokollnachrichten aktiviert","filter.explainer":"Deaktivierte Nachrichtentypen erscheinen nicht im Protokoll.","filter.faith":"Orden der Sonne","filter.festival":"Festivals","filter.hunt":"Jagen","filter.misc":"Diverses","filter.praise":"Bewundern","filter.promote":"Anführer befördern","filter.research":"Erforschen","filter.star":"Astronomische Ereignisse","filter.timeSkip":"Zeitsprung","filter.trade":"Handeln","filter.transcend":"Transzendenz","filter.upgrade":"Verbesserungen","option.accelerate":"Tempus Fugit","option.autofeed":"Leviathane füttern","option.catnip":"Katzenminze sammeln","option.crypto":"Blackcoin handeln","option.elect":"Anführer benennen","option.elect.job":"Beruf","option.elect.job.any":"Beliebig","option.elect.trait":"Eigenschaft","option.embassies":"Botschaften bauen","option.faith.adore":"Bewundere die Galaxie","option.faith.autoPraise":"Lobe die Sonne","option.faith.best.unicorn":"Reihenfolge automatisch optimieren","option.faith.refineTears":"Tränen verfeinern","option.faith.refineTimeCrystals":"ZKs verfeinern","option.faith.sacrificeAlicorns":"Alihörner opfern","option.faith.sacrificeUnicorns":"Einhörner opfern","option.faith.transcend":"Transzendenz","option.festival":"Festivals veranstalten","option.fix.cry":"Kryokammern reparieren","option.hunt":"Jagen","option.magnetos":"Magnetos einschalten","option.observe":"Astro-Ereignisse beobachten","option.praise":"Lobe die Sonne","option.promote":"Anführer befördern","option.promotekittens":"Kätzchen befördern","option.reactors":"Reaktoren einschalten","option.shipOverride":"Erzwinge 243 Schiffe","option.steamworks":"Dampfmaschinen einschalten","option.time.activeHeatTransfer":"Aktiver Wärmetransfer","option.time.reset":"Zeitleiste zurücksetzen (Gefahr!)","option.time.skip":"Zeitsprung","option.time.skip.ignoreOverheat":"Überhitzen ignorieren",reset:"Zurücksetzen","reset.after":"Schön, dich kennenzulernen, die niedlichen Kitten Scientists werden dir dienen","reset.cancel.activity":"Miauston, wir haben ein Problem","reset.cancel.message":"Zeitleiste zurücksetzen abgebrochen","reset.check":"Auslöser für {0}: {1}, du hast {2}","reset.checked":"Alle Bedingungen sind erfüllt, die Zeitlinie wird in den nächsten Sekunden neu gestartet!","reset.countdown.0":"0 - Temporale Risse geöffnet!","reset.countdown.1":"1 - Start der Zeitmaschine","reset.countdown.2":"2 - Chronoschmiede wird beschleunigt","reset.countdown.3":"3 - Zeit-Risse werden geöffnet","reset.countdown.4":"4 - Satellit wird ausgeschaltet","reset.countdown.5":"5 - Schmelze Blackcoins","reset.countdown.6":"6 - Zeit-Motoren werden gestartet","reset.countdown.7":"7 - Strahlenkanonen werden demontiert","reset.countdown.8":"8 - Freisetzung von Echsen","reset.countdown.9":"9 - Opfere Einhörner","reset.countdown.10":"10 - Katzenminzeernte","reset.last.message":"Wir sehen uns bei der nächsten poincaréschen Wiederkehr","reset.tip":'Du kannst diesen Neustart abbrechen, indem du "Kitten Scientists aktivieren" oben in den Einstellungen deaktivierst.',"resources.consume":"Verbrauch: {0}","resources.consume.prompt":"Gib ein wie viel von der Ressource von Automatisierungen verbraucht werden darf. Der Wert sollte zwischen 0,0 und 100,0 liegen.","resources.consume.promptExplainer":"Wenn du einen leeren oder einen ungültigen Wert eingibst, wird das so behandelt, als ob du Abbrechen gedrückt hättest.","resources.consume.promptTitle":"Verbrauchsanteil für {0} (Aktuell: {1})","resources.consume.set":"Verbrauchs-Rate für {0}","resources.consume.title":"Verbraucht {0} von {1}","resources.consume.titleZero":"{0} werden nicht verbraucht","resources.stock.prompt":"Gib ein wie viel von der Ressource jederzeit im Lager bleiben soll.","resources.stock.promptExplainer":"Alle Notationen, die das Spiel unterstützt werden, akzeptiert. Wenn du gar nichts, oder einen negativen Wert eingibst, wird die Grenze auf unendlich gesetzt. Wenn du die Grenze auf 0 setzt, wird Zeit Überspringen deaktiviert. Wenn du einen ungültigen Wert eingibst, wird das genauso behandelt als ob du Abbrechen gedrückt hättest.","resources.stock.promptTitle":"Mindest-Lagerbestand von {0} (Aktuell: {1})","resources.stock.title":"{0} {1} werden auf Lager gehalten","resources.stock.titleInfinite":"Alle {0} werden auf Lager gehalten","resources.stock.titleZero":"{0} werden nicht auf Lager gehalten","state.compress":"Kopierte Kittens Game Spielstände komprimieren","state.confirmDestruction":"Bist du sicher?","state.copied.game":"Spielstand '{0}' in die Zwischenablage kopiert.","state.copied.gameCurrent":"Aktueller Spielstand in Zwischenablage kopiert.","state.copied.state":"Zustand '{0}' in Zwischenablage kopiert.","state.copied.stateCurrent":"Aktueller Zustand wurde in die Zwischenablage kopiert.","state.copy.game":"Diesen Spielstand in die Zwischenablage kopieren.","state.copy.gameCurrent":"Kopiere den gesamten Kittens Game Spielstand (inklusive KS-Einstellungen) in die Zwischenablage.","state.copy.state":"Diese Einstellungen in die Zwischenablage kopieren.","state.copy.stateCurrent":"Kopiere die aktuellen Kitten Scientists Einstellungen in die Zwischenablage.","state.delete.game":"Diesen Spielstand löschen.","state.delete.state":"Diese Einstellungen löschen.","state.deleted.game":"Spielstand '{0}' gelöscht.","state.deleted.state":"Zustand '{0}' gelöscht.","state.edit.game":"Ändere den Namen von diesem Spielstand.","state.edit.state":"Ändere den Namen von diesen Einstellungen.","state.exportAll":"Export","state.exportAllTitle":"Speichert alle lokalen Zustände in einer Datei und lädt sie herunter.","state.import":"Einstellungen/Spielstände importieren","state.imported.game":"Spielstand importiert.","state.imported.state":"Zustand importiert.","state.importedState":"Importierter Stand {0}","state.importTitle":`Füge ein Spielstand oder Einstellungen aus deiner Zwischenablage ein.
@@ -35,9 +35,9 @@ If you submit an invalid value, it will be treated as if you hit Cancel.`,"ui.tr
35
35
  内容将被自动检测并进行相应处理。`,"state.loaded.game":"已加载保存“{0}”。","state.loaded.state":"已加载状态“{0}”。","state.loadPrompt":"在此处粘贴您的 (未压缩的) 保存或设置:","state.local":"本地状态","state.localGames":"小猫游戏保存","state.localStates":"小猫科学家设置","state.new":"新的","state.noConfirm":"不要求确认","state.store":"储存","state.stored.game":"保存储存。","state.stored.state":"状态储存。","state.storeFactory":"根据出厂默认设置创建新状态。","state.storeGame":"从当前游戏中创建一个新的保存。","state.storeGame.prompt":"为此次保存提供标签:","state.storeState":"根据当前设置创建一个新状态。","state.storeState.prompt":"为该状态提供标签:","state.title":"状态管理器","state.unlabeledGame":"未标记的保存","state.unlabeledState":"未标记状态","state.update.game":"将当前游戏保存到此位置。","state.update.state":"将当前设置保存到此槽中。","state.updated.game":"保存'{0}'已更新。","state.updated.state":"状态“{0}”已更新。","status.auto.disable":"禁用自动化 {0}","status.auto.enable":"启用自动化 {0}","status.ks.disable":"太敬业了,该歇了","status.ks.enable":"神说,要有猫猫珂学家!","status.ks.init":"小猫珂学家已初始化。","status.ks.upgrade":"小猫珂学家 (当前版本:{1}) {0} 可在这里获取:{2} 。","status.reset.check.disable":"在重启时间线前不检查 {0}","status.reset.check.enable":"在重启时间线前检查 {0}","status.resource.disable":"禁用 {0} 资源管理","status.resource.enable":"启用 {0} 资源管理","status.sub.disable":"禁用 {0}","status.sub.enable":"启用 {0}","summary.accelerate":"加速时间 {0} 次","summary.adore":"通过赞美群星积累了 {0} 顿悟","summary.building":"建造了 {0} 个 {1}","summary.craft":"制作了 {0} 个 {1}","summary.day":"天","summary.days":"天","summary.distribute":"帮助 {0} 只猫猫找到工作","summary.embassy":"设立了 {0} 个大使馆","summary.feed":"向上古神献祭 {0} 只死灵兽","summary.festival":"举办了 {0} 次节日","summary.fix.cry":"修复了 {0} 个冷冻仓","summary.head":"过去 {0} 的总结","summary.hunt":"派出了 {0} 批可爱的小猫猎人","summary.praise":"通过赞美太阳积累了 {0} 虔诚","summary.promote":"提拔领袖 {0} 次","summary.refine":"已精炼 {0} {1}","summary.separator":" ","summary.show":"总结","summary.stars":"观测了 {0} 颗流星","summary.sun":"在 {1} 方面顿悟 {0} 次","summary.tech":"掌握了 {0}","summary.time.activeHeatTransferStart":"主动散热 {0} 次","summary.time.getTemporalFlux":"烧水晶获取时间通量 {0} 次","summary.time.reset.content":"获得 {0} 业.<br>获得 {1} 领导力","summary.time.reset.title":"过去 {0} 个时间线的总结","summary.time.skip":"跳过 {0} 年","summary.trade":"与 {1} 贸易了 {0} 次","summary.transcend":"超越了 {0} 次","summary.upgrade":"发明了 {0}","summary.year":"年","summary.years":"年","time.heatTransfer.cycle.disable":"停止在 {0} 主动散热","time.heatTransfer.cycle.enable":"启用在 {0} 主动散热","time.skip.cycle.disable":"停止在 {0} 跳转时间并禁止跳过该周期","time.skip.cycle.enable":"启用在 {0} 跳转时间并允许跳过该周期","time.skip.season.disable":"停止在 {0} 跳转时间","time.skip.season.enable":"启用在 {0} 跳转时间","trade.limited":"与 {0} 的交易限制为比产量更优时才会触发","trade.season.disable":"停止在 {1} 与 {0} 的交易","trade.season.enable":"启用在 {1} 与 {0} 的交易","trade.seasons":"季节","trade.unlimited":"取消与 {0} 交易的限制","ui.additional":"附加选项","ui.build":"营火","ui.close":"关闭","ui.craft":"工艺","ui.craft.resources":"资源","ui.cycles":"周期","ui.disable.all":"全部禁用","ui.distribute":"猫力资源","ui.enable.all":"全部启用","ui.engine":"启用小猫珂学家","ui.faith":"宗教","ui.filter":"日志过滤","ui.infinity":"∞","ui.internals":"小喵设置","ui.internals.interval":"运行间隔(ms): {0}","ui.internals.interval.prompt":"输入新的毫秒数作为 0 到无穷大之间的绝对值。","ui.internals.interval.promptExplainer":"游戏支持的所有符号均可接受。如果您将限制设置为 0,Kitten Scientists 将自动禁用。如果您提交了无效值,则将被视为您点击了“取消”。","ui.internals.interval.promptTitle":"小猫科学家执行间隔 (当前:{0})","ui.itemsHide":"隐藏选项","ui.itemsShow":"显示选项","ui.ksColumn":"显示在第四栏","ui.language":"语言","ui.limit":"限制","ui.limited.off":"无限","ui.limited.on":"环保模式","ui.max":"最大值:{0}","ui.max.build.prompt":"{0} 的限制 (当前:{1})","ui.max.build.promptExplainer":"游戏支持的所有符号均可接受。如果您提交空值或负值,限制将设置为无穷大。如果您将限制设置为 0,此选项将自动禁用。如果您提交无效值,将被视为您点击了“取消”。","ui.max.build.title":"构建 {0} {1}","ui.max.build.titleInfinite":"永不停止建设{0}","ui.max.build.titleZero":"不要构建{0}","ui.max.craft.prompt":"输入要制作的 {0} 数量的新限制,以 0 到无穷大之间的绝对值表示。","ui.max.craft.promptExplainer":"游戏支持的所有符号均可接受。如果您提交空值或负值,限制将设置为无穷大。如果您将限制设置为 0,此选项将自动禁用。如果您提交无效值,将被视为您点击了“取消”。","ui.max.craft.promptTitle":"制作限制 {0} (当前:{1})","ui.max.craft.title":"制造 {0} {1}","ui.max.craft.titleInfinite":"永不停止创造{0}","ui.max.craft.titleZero":"不要制造 {0}","ui.max.distribute.prompt":"输入要分配的新小猫数量 {0},作为 0 到无穷大之间的绝对值。","ui.max.distribute.promptExplainer":"游戏支持的所有符号均可接受。如果您提交空值或负值,限制将设置为无穷大。如果您将限制设置为 0,此选项将自动禁用。如果您提交无效值,将被视为您点击了“取消”。","ui.max.distribute.promptTitle":"将最大小猫数量指定为 {0} (当前:{1})","ui.max.distribute.title":"将 {0} 只小猫指定为 {1}","ui.max.distribute.titleInfinite":"分配尽可能多的小猫作为{0}","ui.max.distribute.titleZero":"不将任何小猫指定为{0}","ui.max.embassy.title":"为{1}建造{0}大使馆","ui.max.embassy.titleInfinite":"永不停止为{0}修建大使馆","ui.max.embassy.titleZero":"不要为{0}建造大使馆","ui.max.prompt.absolute":"输入新的限制作为 0 到无穷大之间的绝对值。","ui.max.prompt.float":"输入新的限制作为 0.0 和无穷大之间的绝对值。","ui.max.set":"设置 {0} 的最大值","ui.max.timeSkip.prompt":"输入新的年数作为 0 至无穷大之间的绝对值。","ui.max.timeSkip.promptExplainer":"游戏支持的所有符号均可接受。如果您提交空值或负值,限制将设置为无穷大。如果您将限制设置为 0,此选项将自动禁用。如果您提交无效值,将被视为您点击了“取消”。","ui.max.timeSkip.promptTitle":"最多跳过年份 (当前:{0})","ui.max.timeSkip.title":"一次跳过 {0} 年","ui.max.timeSkip.titleInfinite":"跳过尽可能多的年份","ui.max.timeSkip.titleZero":"不要跳过时间","ui.maximum":"上限","ui.min":"最小值 {0}","ui.options":"选项","ui.reset":"恢复至默认","ui.resources":"资源控制","ui.space":"太空","ui.time":"时间","ui.timeCtrl":"时间操纵","ui.trade":"贸易","ui.trigger":"触发值:{0}","ui.trigger.accelerateTime.prompt":"输入启用 Tempus Fugit 的新时间通量存储级别,以 0.0 至 100.0 之间的百分比表示。","ui.trigger.accelerateTime.promptExplainer":"如果您提交一个空值或者一个无效值,则被视为您点击了取消。","ui.trigger.accelerateTime.promptTitle":"加速时间的触发值 (当前:{0})","ui.trigger.activeHeatTransfer.prompt":"输入新的启用热传递的时间热存储量,以 0.0 到 100.0 之间的百分比表示。","ui.trigger.activeHeatTransfer.promptExplainer":"如果您提交一个空值或者一个无效值,则被视为您点击了取消。","ui.trigger.activeHeatTransfer.promptTitle":"热传递触发值 (当前:{0})","ui.trigger.build.blocked":`∞
36
36
  🛈 {0} 部分未设置触发值。此构建不会被触发!`,"ui.trigger.build.inherited":"继承自部分","ui.trigger.build.prompt":"{0} 的触发值 (当前:{1})","ui.trigger.build.promptExplainer":"如果您提交了空值或负值,则将使用部分触发值。如果您提交了无效值,则将被视为您点击了“取消”。","ui.trigger.crypto.prompt":"输入交易黑币的新文物存储级别,以 0.0 到 Infinity 之间的绝对值表示。","ui.trigger.crypto.promptExplainer":"如果您提交一个空值或者一个无效值,则被视为您点击了取消。","ui.trigger.crypto.promptTitle":"触发黑币交易 (当前:{0})","ui.trigger.embassies.prompt":"以 0.0 至 100.0 之间的百分比输入建造大使馆的新文化存储级别。","ui.trigger.embassies.promptExplainer":"如果您提交一个空值或者一个无效值,则被视为您点击了取消。","ui.trigger.embassies.promptTitle":"建立大使馆的触发值 (当前:{0})","ui.trigger.hunt.prompt":"狩猎触发值 (当前:{0})","ui.trigger.hunt.promptExplainer":"如果您提交了负值,则搜索将被禁用。如果您提交了空值或无效值,则将被视为您点击了“取消”。","ui.trigger.inactive":"不活跃","ui.trigger.promoteKittens.prompt":"输入新的可用于升级小猫的黄金库存量,以 0.0 到 100.0 之间的百分比表示。","ui.trigger.promoteKittens.promptExplainer":"如果您提交一个空值或者一个无效值,则被视为您点击了取消。","ui.trigger.promoteKittens.promptTitle":"小猫促销触发值 (当前:{0})","ui.trigger.prompt.absolute":"输入新的触发值作为 0 到无穷大之间的绝对值。","ui.trigger.prompt.float":"输入新的触发值作为 0.0 到无穷大之间的绝对值。","ui.trigger.prompt.percentage":"以 0.0 至 100.0 之间的百分比形式输入新的触发值。","ui.trigger.reset.promptExplainer":"如果您提交了负值,则该项目将被禁用。如果您提交了空值或无效值,则将被视为您点击了“取消”。","ui.trigger.section":"部分默认触发值:{0}","ui.trigger.section.blocked":`∞
37
37
  🛈 The {0} section has no trigger set. This automation will not be triggered!`,"ui.trigger.section.inactive":"∞ (nothing is triggered automatically)","ui.trigger.section.inherited":"继承自部分","ui.trigger.section.prompt":"{0} 部分的触发值 (当前:{1})","ui.trigger.section.promptExplainer":`If you submit an empty value, or a negative value, the section trigger will be set to infinity (∞). Individual automations in this section need to have their own trigger set to be activated.
38
- If you submit an invalid value, it will be treated as if you hit Cancel.`,"ui.trigger.setinteger":"输入 {0} 的新触发值。范围应在 0 到任意数字之间。-1表示无穷大。","ui.trigger.setinteger.promptExplainer":"如果您提交一个空值或者一个无效值,则被视为您点击了取消。","ui.trigger.setpercentage":"输入新的 {0} 触发值,取值范围为 0 到 100 的小数。","ui.trigger.setpercentage.promptExplainer":"如果您提交一个空值或者一个无效值,则被视为您点击了取消。","ui.trigger.timeSkip.prompt":"输入跳过时间所需的时间水晶的新数量,以 1 到无穷大之间的绝对值表示。","ui.trigger.timeSkip.promptExplainer":"如果您提交了负值,时间跳过将被禁用。如果您提交了空值或无效值,它将被视为您点击了“取消”。","ui.trigger.timeSkip.promptTitle":"时间跳跃触发值 (当前:{0})","ui.upgrade":"升级","ui.upgrade.buildings":"升级建筑","ui.upgrade.missions":"探索星球","ui.upgrade.policies":"政策","ui.upgrade.races":"探险队出发!","ui.upgrade.techs":"科技","ui.upgrade.upgrades":"升级","ui.upgrades":"升级",update:"更新","upgrade.building.amphitheatre":"剧场 升级为 广播塔!","upgrade.building.aqueduct":"水渠 升级为 水电站!","upgrade.building.library":"图书馆 升级为 数据中心!","upgrade.building.pasture":"牧场 升级为 太阳能发电站!","upgrade.building.warehouse":"已将仓库升级为太空港!","upgrade.policy":"小猫通过了 {0} 法案","upgrade.race":"小猫遇到了 {0}","upgrade.space":"小猫执行了 {0}","upgrade.space.mission":"小猫执行了 {0} 的任务","upgrade.tech":"小猫掌握了 {0}","upgrade.upgrade":"小猫发明了 {0}"};class Ct extends _t{constructor(e,t,i=!1){super(i);L(this,Fe);L(this,He);O(this,Fe,e),O(this,He,t)}get building(){return I(this,Fe)}get variant(){return I(this,He)}}Fe=new WeakMap,He=new WeakMap;class Yt extends V{constructor(e=!1,t=-1,i=new _,n=new ae(!1,-1),a=new ae(!1,-1),r=new ae(!1,-1),o=new ae(!1,-1),l=new V(!1,1),h=new V(!1,1),d=new _){super(e,t);u(this,"buildings");u(this,"bestUnicornBuilding");u(this,"bestUnicornBuildingCurrent");u(this,"sacrificeAlicorns");u(this,"sacrificeUnicorns");u(this,"refineTears");u(this,"refineTimeCrystals");u(this,"autoPraise");u(this,"adore");u(this,"transcend");this.buildings=this.initBuildings(),this.bestUnicornBuilding=i,this.sacrificeAlicorns=n,this.sacrificeUnicorns=a,this.refineTears=r,this.refineTimeCrystals=o,this.autoPraise=l,this.adore=h,this.transcend=d,this.bestUnicornBuildingCurrent=null}initBuildings(){const e={};for(const t of Zi)e[t]=new Ct(t,W.OrderOfTheSun);for(const t of Ki)e[t]=new Ct(t,W.Cryptotheology);for(const t of Vi)e[t]=new Ct(t,W.Ziggurat);return e.unicornPasture=new Ct("unicornPasture",W.UnicornPasture),e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.max=(i==null?void 0:i.max)??t.max,t.trigger=(i==null?void 0:i.trigger)??t.trigger}),this.bestUnicornBuilding.load(e.bestUnicornBuilding),this.sacrificeAlicorns.load(e.sacrificeAlicorns),this.sacrificeUnicorns.load(e.sacrificeUnicorns),this.refineTears.load(e.refineTears),this.refineTimeCrystals.load(e.refineTimeCrystals),this.autoPraise.load(e.autoPraise),this.adore.load(e.adore),this.transcend.load(e.transcend),this.bestUnicornBuildingCurrent=e.bestUnicornBuildingCurrent??this.bestUnicornBuildingCurrent)}}class mn{constructor(s,e,t,i=new Yt){u(this,"_host");u(this,"settings");u(this,"manager");u(this,"_bulkManager");u(this,"_bonfireManager");u(this,"_workshopManager");this._host=s,this.settings=i,this.manager=new ge(this._host,"Religion"),this._workshopManager=t,this._bulkManager=new wt(this._host,this._workshopManager),this._bonfireManager=e}async tick(s){this.settings.enabled&&(this.manager.render(),this._autoBuild(s),this.settings.sacrificeUnicorns.enabled&&await this._autoSacrificeUnicorns(),this.settings.sacrificeAlicorns.enabled&&await this._autoSacrificeAlicorns(s),this.settings.refineTears.enabled&&this._autoTears(s),this.settings.refineTimeCrystals.enabled&&await this._autoTCs(s),this._autoTAP())}_autoBuild(s){if(this.settings.bestUnicornBuilding.enabled)this._buildBestUnicornBuilding(),this._buildNonUnicornBuildings(s);else{const e=Object.fromEntries(Object.entries(this.settings.buildings).filter(([,n])=>n.variant!==W.UnicornPasture)),t=Y(this.settings.buildings.unicornPasture.max),i=this._host.game.bld.getBuildingExt("unicornPasture").meta;this.settings.buildings.unicornPasture.enabled&&i.val<t&&this._bonfireManager.autoBuild(s,{unicornPasture:new Jt("unicornPasture",this.settings.buildings.unicornPasture.enabled,this.settings.buildings.unicornPasture.trigger,this.settings.buildings.unicornPasture.max)}),this._buildReligionBuildings(s,e)}}_buildBestUnicornBuilding(){var t,i;const s=this.getBestUnicornBuilding();if(this.settings.bestUnicornBuildingCurrent!==s&&(this.settings.bestUnicornBuildingCurrent=s,this._host.refreshEntireUserInterface()),this.settings.bestUnicornBuildingCurrent===null)return;const e=this.settings.trigger;if(this.settings.bestUnicornBuildingCurrent==="unicornPasture")this._bonfireManager.build(this.settings.bestUnicornBuildingCurrent,0,1);else{const n=this._getBuildButton(this.settings.bestUnicornBuildingCurrent,W.Ziggurat);if(m(n==null?void 0:n.model))return;let a=0;const r=p(n.model.prices).find(d=>d.name==="tears");m(r)||(a=r.val);const o=this._workshopManager.getValue("tears")-this._workshopManager.getStock("tears");if(!m(this._host.game.religionTab.sacrificeBtn)&&o<a){const d=Math.floor((this._workshopManager.getValue("unicorns")-this._workshopManager.getStock("unicorns"))/2500),g=Math.ceil((a-o)/this._host.game.bld.getBuildingExt("ziggurat").meta.on);if(g<d&&!m(this._host.game.religionTab.sacrificeBtn.model))(i=(t=this._host.game.religionTab.sacrificeBtn)==null?void 0:t.controller)==null||i._transform(this._host.game.religionTab.sacrificeBtn.model,g);else return}const l={[this.settings.bestUnicornBuildingCurrent]:this.settings.buildings[this.settings.bestUnicornBuildingCurrent]},h=this._bulkManager.bulk(l,this.getBuildMetaData(l),e,"Religion");0<h.length&&0<h[0].count&&this.build(this.settings.bestUnicornBuildingCurrent,W.Ziggurat,1)}}_buildNonUnicornBuildings(s){const e=[...kt],t=Object.fromEntries(Object.entries(this.settings.buildings).filter(([,i])=>!e.includes(i.building)));this._buildReligionBuildings(s,t)}_buildReligionBuildings(s,e){this.manager.render();const t=this.getBuildMetaData(e),i=this.settings.trigger,n=this._bulkManager.bulk(e,t,i,"Religion");for(const a of n)0<a.count&&(this.build(a.id,p(a.variant),a.count),s.requestGameUiRefresh=!0)}getBestUnicornBuilding(){var le,be;const s=this._bonfireManager.getBuildButton("unicornPasture");if(s===null)return null;const e=[...kt].filter(ee=>ee!=="unicornPasture"),t=this._host.game.getEffect("unicornsPerTickBase")*this._host.game.getTicksPerSecondUI(),i=this._host.game.getEffect("unicornsGlobalRatio")+1,n=this._host.game.getEffect("unicornsRatioReligion")+1,a=this._host.game.prestige.getParagonProductionRatio()+1,r=this._host.game.religion.getSolarRevolutionRatio()+1,o=this._host.game.calendar.cycle,l=this._host.game.calendar.cycles[o];let h=1;l.festivalEffects.unicorns!==void 0&&this._host.game.prestige.getPerk("numeromancy").researched&&this._host.game.calendar.festivalDays&&(h=l.festivalEffects.unicorns);const d=t*i*n*a*r*h,g=Math.max(this._host.game.bld.getBuildingExt("ziggurat").meta.on,1),f=500*(1+this._host.game.getEffect("unicornsRatioReligion")*.1);let w=1;this._host.game.prestige.getPerk("unicornmancy").researched&&(w*=1.1);const b=this._host.game.getEffect("riftChance")*w/(1e4*2)*f;let k=Number.POSITIVE_INFINITY,y=null;const j=p((le=this._host.game.bld.getBuildingExt("unicornPasture").meta.effects)==null?void 0:le.unicornsPerTickBase)*this._host.game.getTicksPerSecondUI()*i*n*a*r*h,Q=p((be=s.model)==null?void 0:be.prices)[0].val/j;Q<k&&(k=Q,y="unicornPasture");for(const ee of this.manager.tab.zgUpgradeButtons)if(e.includes(ee.id)&&ee.model.visible){let pe=0;for(const Se of p(ee.model.prices))Se.name==="unicorns"&&(pe+=Se.val),Se.name==="tears"&&(pe+=Se.val*2500/g);const mt=p(this._host.game.religion.getZU(ee.id));let Me=n,$s=this._host.game.getEffect("riftChance");for(const Se in mt.effects)Se==="unicornsRatioReligion"&&(Me+=p(mt.effects.unicornsRatioReligion)),Se==="riftChance"&&($s+=p(mt.effects.riftChance));const Xo=500*((Me-1)*.1+1);let Bi=$s*w/(1e4*2)*Xo;Bi-=b;let Ai=t*i*Me*a*r*h;Ai-=d,Ai+=Bi;const Ls=pe/Ai;Ls<k&&(0<Bi||n<Me&&0<pe)&&(k=Ls,y=ee.id)}return y}build(s,e,t){let i=t;const n=i;let a;if(e===W.Cryptotheology){const r=game.getUnlockByName(s,"transcendenceUpgrades"),o=new classes.ui.TranscendenceBtnController(this._host.game),l=o.fetchModel({controller:o,id:r.name});i=this._bulkManager.construct(l,o,i),a=r.label}else if(e===W.OrderOfTheSun){const r=game.getUnlockByName(s,"religion"),o=new com.nuclearunicorn.game.ui.ReligionBtnController(this._host.game),l=o.fetchModel({controller:o,id:r.name});i=this._bulkManager.construct(l,o,i),a=r.label}else if(e===W.Ziggurat){const r=game.getUnlockByName(s,"zigguratUpgrades"),o=new com.nuclearunicorn.game.ui.ZigguratBtnController(this._host.game),l=o.fetchModel({controller:o,id:r.name});i=this._bulkManager.construct(l,o,i),a=r.label}else throw new bt("unsupported");i!==n&&(console.warn(...v(`${a} Amount ordered: ${n} Amount Constructed: ${i}`)),i===0)||(e===W.OrderOfTheSun?(this._host.engine.storeForSummary(a,i,"faith"),i===1?this._host.engine.iactivity("act.sun.discover",[a],"ks-faith"):this._host.engine.iactivity("act.sun.discovers",[a,this._host.renderAbsolute(i)],"ks-faith")):(this._host.engine.storeForSummary(a,i,"build"),i===1?this._host.engine.iactivity("act.build",[a],"ks-build"):this._host.engine.iactivity("act.builds",[a,this._host.renderAbsolute(i)],"ks-build")))}getBuildMetaData(s){const e={};for(const t of Object.values(s)){const i=this.getBuild(t.building,t.variant);if(i===null)continue;e[t.building]=i;const n=p(e[t.building]);if(!this._getBuildButton(t.building,t.variant))n.rHidden=!0;else{const a=p(this._getBuildButton(t.building,t.variant)).model,r=t.variant===W.Cryptotheology?this._host.game.science.get("cryptotheology").researched:!0;n.rHidden=!(a!=null&&a.visible&&a.enabled&&r)}}return e}getBuild(s,e){switch(e){case W.Ziggurat:return this._host.game.religion.getZU(s)??null;case W.OrderOfTheSun:return this._host.game.religion.getRU(s)??null;case W.Cryptotheology:return this._host.game.religion.getTU(s)??null}throw new Error(`Unknown build: ${s} (${e})`)}_getBuildButton(s,e){let t;switch(e){case W.Ziggurat:t=this.manager.tab.zgUpgradeButtons;break;case W.OrderOfTheSun:t=this.manager.tab.rUpgradeButtons;break;case W.Cryptotheology:t=this.manager.tab.children[0].children[0].children;break;default:throw new Error(`Invalid variant '${e}'`)}if(t.length===0)return null;const i=t.find(n=>n.id===s)??null;return i===null&&console.debug(...v(`Couldn't find button for ${s}! This will likely create problems.`)),i}_transformBtnSacrificeHelper(s,e,t,i){const a=1/(s/e),o=new classes.ui.religion.TransformBtnController(game,t.controllerOpts)._newLink(i,a);return new Promise(l=>{o.handler(new Event("decoy"),l)})}async _autoSacrificeUnicorns(){const s=this._workshopManager.getResource("unicorns"),e=this._workshopManager.getValueAvailable("unicorns");if(!m(this._host.game.religionTab.sacrificeBtn)&&Y(this.settings.sacrificeUnicorns.trigger)<=e&&Y(this.settings.sacrificeUnicorns.trigger)<=s.value){const t=this._host.game.religionTab.sacrificeBtn.controller,i=this._host.game.religionTab.sacrificeBtn.model;if(m(i))return;await this._transformBtnSacrificeHelper(e,s.value,t,i);const n=this._workshopManager.getValueAvailable("unicorns"),a=e-n;this._host.engine.iactivity("act.sacrificeUnicorns",[this._host.game.getDisplayValueExt(a)],"ks-faith"),this._host.engine.storeForSummary(this._host.engine.i18n("$resources.unicorns.title"),a,"refine")}}async _autoSacrificeAlicorns(s){const e=this._workshopManager.getResource("alicorn"),t=this._workshopManager.getValueAvailable("alicorn");if(!m(this._host.game.religionTab.sacrificeAlicornsBtn)&&Y(this.settings.sacrificeAlicorns.trigger)<=t&&Y(this.settings.sacrificeAlicorns.trigger)<=e.value){this._host.game.religionTab.sacrificeAlicornsBtn.render();const i=this._host.game.religionTab.sacrificeAlicornsBtn.controller,n=this._host.game.religionTab.sacrificeAlicornsBtn.model;if(m(n)){s.requestGameUiRefresh=!0;return}await this._transformBtnSacrificeHelper(t,e.value,i,n);const a=this._workshopManager.getValueAvailable("alicorn"),r=t-a;this._host.engine.iactivity("act.sacrificeAlicorns",[this._host.game.getDisplayValueExt(r)],"ks-faith"),this._host.engine.storeForSummary(this._host.engine.i18n("$resources.alicorn.title"),r,"refine")}}_autoTears(s){const e=this._workshopManager.getResource("tears"),t=this._workshopManager.getValueAvailable("tears"),i=this._workshopManager.getResource("sorrow");if(!m(this._host.game.religionTab.refineBtn)&&Y(this.settings.refineTears.trigger)<=t&&Y(this.settings.refineTears.trigger)<=e.value&&i.value<i.maxValue){const n=t-this.settings.refineTears.trigger;if(n<1e4)return;const a=this._host.game.religionTab.refineBtn.controller,r=this._host.game.religionTab.refineBtn.model;if(m(r)){s.requestGameUiRefresh=!0;return}a.buyItem(r,new Event("decoy"),n);const o=this._workshopManager.getValueAvailable("tears"),l=t-o;this._host.engine.iactivity("act.refineTears",[this._host.game.getDisplayValueExt(l)],"ks-faith"),this._host.engine.storeForSummary(this._host.engine.i18n("$resources.tears.title"),l,"refine")}}async _autoTCs(s){const e=this._workshopManager.getResource("timeCrystal"),t=this._workshopManager.getValueAvailable("timeCrystal");if(!m(this._host.game.religionTab.refineTCBtn)&&Y(this.settings.refineTimeCrystals.trigger)<=t&&Y(this.settings.refineTimeCrystals.trigger)<=e.value){const i=this._host.game.religionTab.refineTCBtn.controller,n=this._host.game.religionTab.refineTCBtn.model;if(m(n)){s.requestGameUiRefresh=!0;return}await this._transformBtnSacrificeHelper(t,e.value,i,n);const a=this._workshopManager.getValueAvailable("timeCrystal"),r=t-a;this._host.engine.iactivity("act.refineTCs",[this._host.game.getDisplayValueExt(r)],"ks-faith"),this._host.engine.storeForSummary(this._host.engine.i18n("$resources.timeCrystal.title"),r,"refine")}}_autoTAP(){const s=this._workshopManager.getResource("faith"),e=s.value/s.maxValue;this.settings.transcend.enabled&&this.settings.autoPraise.trigger-.02<=e&&this._autoTranscend(),this.settings.autoPraise.trigger<=e&&(this.settings.adore.enabled&&p(this._host.game.religion.getRU("apocripha")).on&&this._autoAdore(this.settings.adore.trigger),this.settings.autoPraise.enabled&&this._autoPraise())}_autoAdore(s){const e=this._workshopManager.getResource("faith"),t=this._host.game.religion.faith,i=this._host.game.religion.faithRatio,a=p(this._host.game.religion.getRU("transcendence")).on?this._host.game.religion.transcendenceTier:0,r=10+this._host.game.getEffect("solarRevolutionLimit"),o=r*s,l=t/1e6*a*a*1.01,h=i+l,d=.01+e.value*(1+this._host.game.getUnlimitedDR(h,.1)*.1),g=this._host.game.getLimitedDR(this._host.game.getUnlimitedDR(d,1e3)/100,r);o<=g&&(this._host.game.religion._resetFaithInternal(1.01),this._host.engine.iactivity("act.adore",[this._host.game.getDisplayValueExt(t),this._host.game.getDisplayValueExt(l)],"ks-adore"),this._host.engine.storeForSummary("adore",l))}_autoTranscend(){var i,n;let s=this._host.game.religion.faithRatio;const e=p(this._host.game.religion.getRU("transcendence")).on;let t=e?this._host.game.religion.transcendenceTier:0;if(e){const a=((t+2)/(t+1))**2,r=this._host.game.religion._getTranscendTotalPrice(t+1)-this._host.game.religion._getTranscendTotalPrice(t),o=r,l=a;if((1-l+Math.sqrt(80*(l*l-1)*o+(l-1)*(l-1)))*l/(40*(l+1)*(l+1)*(l-1))+o+o/(l*l-1)<=s){this._host.game.religion.faithRatio-=r,this._host.game.religion.tcratio+=r,this._host.game.religion.transcendenceTier+=1;const d=p(this._host.game.challenges.getChallenge("atheism"));(i=d.calculateEffects)==null||i.call(d,d,this._host.game);const g=p(this._host.game.religion.getTU("blackObelisk"));(n=g.calculateEffects)==null||n.call(g,g,this._host.game),this._host.game.msg(this._host.engine.i18n("$religion.transcend.msg.success",[this._host.game.religion.transcendenceTier])),s=this._host.game.religion.faithRatio,t=this._host.game.religion.transcendenceTier,this._host.engine.iactivity("act.transcend",[this._host.game.getDisplayValueExt(r),t],"ks-transcend"),this._host.engine.storeForSummary("transcend",1)}}}_autoPraise(){const s=this._workshopManager.getResource("faith"),e=this._host.game.religion.getApocryphaBonus(),t=s.value*(1+e);this._host.engine.storeForSummary("praise",t),this._host.engine.iactivity("act.praise",[this._host.game.getDisplayValueExt(s.value),this._host.game.getDisplayValueExt(t)],"ks-praise"),this._host.game.religion.praise()}}class fn extends _{constructor(e,t=!1){super(t);L(this,We);O(this,We,e)}get policy(){return I(this,We)}}We=new WeakMap;class ss extends _{constructor(e=!1){super(e);u(this,"policies");this.policies=this.initPolicies()}initPolicies(){const e={};for(const t of Js)e[t]=new fn(t);return e}static validateGame(e,t){const i=Object.keys(t.policies),n=e.science.policies.map(o=>o.name),a=ne(n,i),r=ne(i,n);for(const o of a)console.warn(...v(`The policy '${o}' is not tracked in Kitten Scientists!`));for(const o of r)console.warn(...v(`The policy '${o}' is not a policy in Kittens Game!`))}load(e){m(e)||(super.load(e),F(this.policies,e.policies,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}))}}class bn extends V{constructor(e,t=!1){super(t,-1);L(this,Ge);O(this,Ge,e)}get tech(){return I(this,Ge)}}Ge=new WeakMap;class ns extends V{constructor(e=!1){super(e,-1);u(this,"techs");this.techs=this.initTechs()}initTechs(){const e={};for(const t of Xs)e[t]=new bn(t);return e}static validateGame(e,t){const i=Object.keys(t.techs),n=e.science.techs.map(o=>o.name),a=ne(n,i),r=ne(i,n);for(const o of a)Ji.includes(o)||console.warn(...v(`The technology '${o}' is not tracked in Kitten Scientists!`));for(const o of r){if(Ji.includes(o)){console.info(...v(`The technology '${o}' is a technology in Kittens Game, but it's no longer used.`));continue}console.warn(...v(`The technology '${o}' is not a technology in Kittens Game!`))}}load(e){m(e)||(super.load(e),F(this.techs,e.techs,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class Qt extends _{constructor(e=!1,t=new ss,i=new ns,n=new _){super(e);u(this,"policies");u(this,"techs");u(this,"observe");this.policies=t,this.techs=i,this.observe=n}static validateGame(e,t){ss.validateGame(e,t.policies),ns.validateGame(e,t.techs)}load(e){var t;m(e)||(super.load(e),this.policies.load(e.policies),this.techs.load(e.techs),this.observe.enabled=((t=e.observe)==null?void 0:t.enabled)??this.observe.enabled)}}class xe{constructor(s){u(this,"_host");this._host=s}upgrade(s,e){let t=!1;if(e==="policy"){const n=game.getUnlockByName(s.name,"policies"),a=new classes.ui.PolicyBtnController(this._host.game),r=a.fetchModel({controller:a,id:n.name});t=xe.skipConfirm(()=>a.buyItem(r)).itemBought}else if(e==="science"){const n=game.getUnlockByName(s.name,"tech"),a=new com.nuclearunicorn.game.ui.TechButtonController(this._host.game),r=a.fetchModel({controller:a,id:n.name});t=xe.skipConfirm(()=>a.buyItem(r)).itemBought}else{const n=game.getUnlockByName(s.name,"upgrades"),a=new com.nuclearunicorn.game.ui.UpgradeButtonController(this._host.game),r=a.fetchModel({controller:a,id:n.name});t=xe.skipConfirm(()=>a.buyItem(r)).itemBought}if(!t)return!1;const i=s.label;return e==="workshop"?(this._host.engine.storeForSummary(i,1,"upgrade"),this._host.engine.iactivity("upgrade.upgrade",[i],"ks-upgrade")):e==="policy"?this._host.engine.iactivity("upgrade.policy",[i]):e==="science"&&(this._host.engine.storeForSummary(i,1,"research"),this._host.engine.iactivity("upgrade.tech",[i],"ks-research")),!0}static async skipConfirmAsync(s){const e=game.ui.confirm;try{return game.ui.confirm=()=>!0,await s()}finally{game.ui.confirm=e}}static skipConfirm(s){const e=game.ui.confirm;try{return game.ui.confirm=()=>!0,s()}finally{game.ui.confirm=e}}}const pn=c=>new Promise(s=>setTimeout(s,c)),Te="en-US",vn=2*60*1e3,yn="localStorage"in globalThis&&!m(localStorage["ks.timeout"])?Number(localStorage["ks.timeout"]):void 0;class T{constructor(){u(this,"_gameStartSignal");u(this,"_gameStartSignalResolver");u(this,"_possibleEngineState")}static tryEngineStateFromSaveData(s,e){const t=e;if(!(s in t)){console.debug(...v(`Failed: \`${s}\` not found in save data.`));return}const i=t.ks;if(!("state"in i)){console.debug(...v(`Failed: \`${s}.state\` not found in save data.`));return}const n=i.state;if(!Array.isArray(n)){console.debug(...v(`Failed: \`${s}.state\` not \`Array\`.`));return}return n[0]}async waitForGame(s,e,t=yn??vn){if(T._isGameLoaded()){const n=p(T.window.game),a=p(T.window.$I),r=localStorage["com.nuclearunicorn.kittengame.language"];return new s(n,a,r,this._possibleEngineState)}const i=[pn(2e3)];if(m(this._gameStartSignal)&&typeof T.window.dojo<"u"){this._gameStartSignal=new Promise(a=>{this._gameStartSignalResolver=a});const n=T.window.dojo.subscribe("game/start",()=>{console.debug(...v(`'game/start' signal caught. Fast-tracking script load for '${e}'...`)),p(this._gameStartSignalResolver)(!0),T.window.dojo.unsubscribe(n)});if(e!==void 0){const a=T.window.dojo.subscribe("server/load",r=>{console.info(...v(`'server/load' signal caught. Looking for script state with key '${e}' in save data...`));const o=T.tryEngineStateFromSaveData(e,r);if(!o){console.info(...v(`The Kittens Game save data did not contain a script state for '${e}'.`));return}console.info(...v(`Found key '${e}'! Provided save data will be used as seed for next script instance.`)),this._possibleEngineState=o,T.window.dojo.unsubscribe(a)})}}if(m(this._gameStartSignal)||i.push(this._gameStartSignal),t<0)throw new Error("Unable to find game. Giving up. Maybe the game is not exported at `window.game`?");return console.debug(...v(`Waiting for game... (timeout: ${Math.round(t/1e3)}s)`)),await Promise.race(i),this.waitForGame(s,e,t-2e3)}static _isGameLoaded(){var s;return!m(T.window.game)&&(((s=T.window.document.getElementById("game"))==null?void 0:s.checkVisibility())??!1)&&!m(T.window.$I)}static get window(){try{return p(unsafeWindow)}catch{return window}}}class wn extends xe{constructor(e,t,i=new Qt){super(e);u(this,"manager");u(this,"settings");u(this,"_workshopManager");this.settings=i,this.manager=new ge(this._host,"Science"),this._workshopManager=t}async tick(e){this.settings.enabled&&(this.manager.render(),this.settings.techs.enabled&&this._host.game.tabs[2].visible&&await this.autoUnlock(),this.settings.policies.enabled&&this._host.game.tabs[2].visible&&await this.autoPolicy(),this.settings.observe.enabled&&this.observeStars())}async autoUnlock(){const e=this._host.game.science.techs,t=new Array;e:for(const i of Object.values(this.settings.techs.techs)){if(!i.enabled)continue;const n=e.find(r=>r.name===i.tech);if(m(n)){console.error(...v(`Tech '${i.tech}' not found in game!`));continue}if(n.researched||!n.unlocked)continue;let a=T.window.dojo.clone(n.prices);a=this._host.game.village.getEffectLeader("scientist",a);for(const r of a){const o=this._workshopManager.getValueAvailable(r.name),l=this._workshopManager.getResource(r.name),h=re.evaluateSubSectionTrigger(this.settings.techs.trigger,i.trigger);if(h<0||o<l.maxValue*h||o<r.val)continue e}t.push(n)}for(const i of t)await this.upgrade(i,"science")}async autoPolicy(){const e=this._host.game.science.policies,t=new Array;for(const i of Object.values(this.settings.policies.policies)){if(!i.enabled)continue;const n=e.find(a=>a.name===i.policy);if(m(n)){console.error(...v(`Policy '${i.policy}' not found in game!`));continue}!n.researched&&!n.blocked&&n.unlocked&&(n.requiredLeaderJob===void 0||this._host.game.village.leader!==null&&this._host.game.village.leader.job===n.requiredLeaderJob)&&t.push(n)}for(const i of t)await this.upgrade(i,"policy")}observeStars(){this._host.game.calendar.observeBtn!==null&&(this._host.game.calendar.observeHandler(),this._host.engine.iactivity("act.observe",[],"ks-star"),this._host.engine.storeForSummary("stars",1))}}class kn extends _{constructor(e,t=!1){super(t);L(this,Ze);O(this,Ze,e)}get mission(){return I(this,Ze)}}Ze=new WeakMap;class as extends _{constructor(e=!1){super(e);u(this,"missions");this.missions=this.initMissions()}initMissions(){const e={};for(const t of Ys)e[t]=new kn(t);return e}static validateGame(e,t){const i=Object.keys(t.missions),n=e.space.programs.map(o=>o.name),a=ne(n,i),r=ne(i,n);for(const o of a)console.warn(...v(`The space mission '${o}' is not tracked in Kitten Scientists!`));for(const o of r)console.warn(...v(`The space mission '${o}' is not a space mission in Kittens Game!`))}load(e){m(e)||(super.load(e),F(this.missions,e.missions,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}))}}class _n extends _t{constructor(e){super(!1,-1,0);L(this,Ke);O(this,Ke,e)}get building(){return I(this,Ke)}}Ke=new WeakMap;class St extends V{constructor(e=!1,t=-1,i=new as){super(e,t);u(this,"buildings");u(this,"unlockMissions");this.buildings=this.initBuildings(),this.unlockMissions=i}initBuildings(){const e={};for(const t of Xi)e[t]=new _n(t);return e}static validateGame(e,t){as.validateGame(e,t.unlockMissions)}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.max=(i==null?void 0:i.max)??t.max,t.trigger=(i==null?void 0:i.trigger)??t.trigger}),this.unlockMissions.load(e.unlockMissions))}}class Cn{constructor(s,e,t=new St){u(this,"_host");u(this,"settings");u(this,"manager");u(this,"_bulkManager");u(this,"_workshopManager");this._host=s,this.settings=t,this.manager=new ge(this._host,"Space"),this._workshopManager=e,this._bulkManager=new wt(this._host,this._workshopManager)}tick(s){this.settings.enabled&&(this.manager.render(),this.autoBuild(s),this.settings.unlockMissions.enabled&&this.autoUnlock(s))}autoBuild(s,e=this.settings.buildings){const t=this._bulkManager,i=this.settings.trigger,n={};for(const r of Object.values(e))n[r.building]=this.getBuild(r.building);const a=t.bulk(e,n,i,"Space");for(const r of a)r.count<=0||this.build(r.id,r.count)!==0&&(s.requestGameUiRefresh=!0)}autoUnlock(s){var t,i;if(!this._host.game.tabs[6].visible)return;const e=this._host.game.space.meta[0].meta;e:for(let n=0;n<e.length;n++){if(0<e[n].val||!e[n].unlocked||!this.settings.unlockMissions.missions[e[n].name].enabled)continue;const a=(t=this.manager.tab.GCPanel)==null?void 0:t.children[n];if(m(a))return;const r=p((i=a.model)==null?void 0:i.prices);for(const o of r)if(this._workshopManager.getValueAvailable(o.name)<o.val)continue e;a.domNode.click(),s.requestGameUiRefresh=!0,n===7||n===12?this._host.engine.iactivity("upgrade.space.mission",[e[n].label],"ks-upgrade"):this._host.engine.iactivity("upgrade.space",[e[n].label],"ks-upgrade")}}build(s,e){let t=e;const i=t;let n;const a=game.getUnlockByName(s,"spaceBuilding"),r=new classes.ui.space.PlanetBuildingBtnController(this._host.game),o=r.fetchModel({controller:r,id:a.name});return t=this._bulkManager.construct(o,r,t),n=a.label,t!==i&&(console.warn(...v(`${n} Amount ordered: ${i} Amount Constructed: ${t}`)),t===0)?0:(this._host.engine.storeForSummary(n,t,"build"),t===1?this._host.engine.iactivity("act.build",[n],"ks-build"):this._host.engine.iactivity("act.builds",[n,this._host.renderAbsolute(t)],"ks-build"),t)}getBuild(s){return this._host.game.space.getBuilding(s)}_getBuildButton(s){const e=this.manager.tab.planetPanels;if(m(e))return null;let t=null;for(const i of e)if(t=i.children.find(n=>n.id===s)??null,!m(t))return t;if(t===null)throw new Error(`Couldn't find button for ${s}!`)}}var rs=(c=>(c.build="ks-activity type_ks-build",c.craft="ks-activity type_ks-craft",c.upgrade="ks-activity type_ks-upgrade",c.research="ks-activity type_ks-research",c.trade="ks-activity type_ks-trade",c.hunt="ks-activity type_ks-hunt",c.praise="ks-activity type_ks-praise",c.adore="ks-activity type_ks-adore",c.transcend="ks-activity type_ks-transcend",c.faith="ks-activity type_ks-faith",c.accelerate="ks-activity type_ks-accelerate",c.timeSkip="ks-activity type_ks-timeSkip",c.festival="ks-activity type_ks-festival",c.star="ks-activity type_ks-star",c.distribute="ks-activity type_ks-distribute",c.promote="ks-activity type_ks-promote",c.misc="ks-activity",c))(rs||{});const os=["accelerate","adore","build","craft","distribute","faith","festival","hunt","misc","praise","promote","research","star","timeSkip","trade","transcend","upgrade"];class Sn extends _{constructor(e){super(!0);L(this,Ve);O(this,Ve,e)}get variant(){return I(this,Ve)}}Ve=new WeakMap;class xn extends _{constructor(e=!1,t=new _(!0)){super(e);u(this,"filters");u(this,"disableKGLog");this.filters=this.initFilters(),this.disableKGLog=t}initFilters(){const e={};for(const t of os)e[t]=new Sn(rs[t]);return e}load(e){var t;m(e)||(super.load(e),F(this.filters,e.filters,(i,n)=>{i.enabled=(n==null?void 0:n.enabled)??i.enabled}),this.disableKGLog.enabled=((t=e.disableKGLog)==null?void 0:t.enabled)??this.disableKGLog.enabled)}}class Tn extends V{constructor(e,t=!1){super(t,-1);L(this,je);O(this,je,e)}get upgrade(){return I(this,je)}}je=new WeakMap;class ls extends V{constructor(e=!1){super(e,-1);u(this,"upgrades");this.upgrades=this.initUpgrades()}initUpgrades(){const e={};for(const t of es)e[t]=new Tn(t);return e}static validateGame(e,t){const i=Object.keys(t.upgrades),n=e.workshop.upgrades.map(o=>o.name),a=ne(n,i),r=ne(i,n);for(const o of a)console.warn(...v(`The workshop upgrade '${o}' is not tracked in Kitten Scientists!`));for(const o of r)console.warn(...v(`The workshop upgrade '${o}' is not an upgrade in Kittens Game!`))}load(e){m(e)||(super.load(e),F(this.upgrades,e.upgrades,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class En extends tn{constructor(e,t=!1,i=!0){super(t,i);L(this,Je);O(this,Je,e)}get resource(){return I(this,Je)}}Je=new WeakMap;class xt extends V{constructor(e=!1,t=-1,i=new ls,n=new _){super(e,t);u(this,"resources");u(this,"shipOverride");u(this,"unlockUpgrades");this.resources=this.initResources(),this.shipOverride=n,this.unlockUpgrades=i}initResources(){const e={};for(const t of Hi)e[t]=new En(t);return e}static validateGame(e,t){const i=Object.keys(t.resources),n=e.workshop.crafts.map(o=>o.name),a=ne(n,i),r=ne(i,n);for(const o of a)console.warn(...v(`The workshop craft '${o}' is not tracked in Kitten Scientists!`));for(const o of r)console.warn(...v(`The workshop craft '${o}' is not an upgrade in Kittens Game!`));ls.validateGame(e,t.unlockUpgrades)}load(e){var t;m(e)||(super.load(e),F(this.resources,e.resources,(i,n)=>{i.enabled=(n==null?void 0:n.enabled)??i.enabled,i.limited=(n==null?void 0:n.limited)??i.limited,i.max=(n==null?void 0:n.max)??i.max,i.trigger=(n==null?void 0:n.trigger)??i.trigger}),this.unlockUpgrades.load(e.unlockUpgrades),this.shipOverride.enabled=((t=e.shipOverride)==null?void 0:t.enabled)??this.shipOverride.enabled)}}class ei extends xe{constructor(e,t=new xt){super(e);u(this,"settings");u(this,"manager");this.settings=t,this.manager=new ge(this._host,"Workshop")}tick(e){return this.settings.enabled?(this.autoCraft(),this.refreshStock(),this.settings.unlockUpgrades.enabled?(this.manager.render(),this.autoUnlock()):Promise.resolve()):Promise.resolve()}async autoUnlock(){if(!this._host.game.workshopTab.visible)return;const e=this._host.game.workshop.upgrades,t=new Array;e:for(const i of Object.values(this.settings.unlockUpgrades.upgrades)){if(!i.enabled)continue;const n=e.find(r=>r.name===i.upgrade);if(m(n)){console.error(...v(`Upgrade '${i.upgrade}' not found in game!`));continue}if(n.researched||!n.unlocked)continue;let a=T.window.dojo.clone(n.prices);a=this._host.game.village.getEffectLeader("scientist",a);for(const r of a){const o=this.getValueAvailable(r.name),l=this.getResource(r.name),h=re.evaluateSubSectionTrigger(this.settings.unlockUpgrades.trigger,i.trigger);if(h<0||0<h&&o<l.maxValue*h||o<r.val)continue e}t.push(n)}for(const i of t)await this.upgrade(i,"workshop")}autoCraft(e=this.settings.resources){const t=new Map,i=this.settings.trigger;for(const a of Object.values(e)){const r=re.evaluateSubSectionTrigger(i,a.trigger);if(r<0||!a.enabled)continue;const o=a.max?this.getResource(a.resource):!1,l=Y(a.max);if(o&&l<o.value||!this.singleCraftPossible(a.resource))continue;const h=Object.keys(this.getMaterials(a.resource));h.map(f=>this.getResource(f)).filter(f=>0<f.maxValue).filter(f=>f.value/f.maxValue<r).length===0&&t.set(a,{countRequested:1,materials:h.map(f=>({consume:0,resource:f}))})}if(t.size<1)return;const n=new Map;for(const[a,r]of t)for(const o of r.materials)n.has(o.resource)||n.set(o.resource,new Array),p(n.get(o.resource)).push(a.resource);for(const[,a]of t)for(const r of a.materials){const o=this.getValueAvailable(r.resource);r.consume=o/p(n.get(r.resource)).length}for(const[a,r]of t){const o=this.getMaterials(a.resource);let l=Number.MAX_VALUE;for(const f of r.materials){const w=p(o[f.resource]),b=this.getResource(f.resource);if(!a.limited||a.resource==="ship"&&this.settings.shipOverride.enabled&&this.getResource("ship").value<243){l=Math.min(l,f.consume/w);continue}const k=this._host.game.getResCraftRatio(a.resource),y=this.getValueAvailable(f.resource)/p(n.get(f.resource)).length,P=this.getValueAvailable(a.resource),j=w,Q=1+k,le=y/j,be=P/Q,ee=Math.max(0,Math.floor(Math.log(be)/Math.LN10+1e-9));l=Math.min(l,Math.min(le-(0<b.maxValue&&b.maxValue<=b.value?0:be),10**(ee+1)),f.consume/w)}const h=this.getValueAvailable(a.resource),d=1+this._host.game.getResCraftRatio(a.resource),g=Number.MAX_VALUE/d-h/d;l=Math.min(l,g),r.countRequested=Math.max(0,a.max===-1?l:Math.min(l,(a.max-h)/d))}for(const[a,r]of t)r.countRequested<1||this.craft(a.resource,r.countRequested)}craft(e,t){let i=Math.floor(t);if(i<1||!this._canCraft(e,i))return;const n=this.getCraft(e),a=this._host.game.getResCraftRatio(n.name);this._host.game.craft(n.name,i);const r=p(this._host.game.resPool.get(e)).title;i=Number.parseFloat((i*(1+a)).toFixed(2)),this._host.engine.storeForSummary(r,i,"craft"),this._host.engine.iactivity("act.craft",[this._host.game.getDisplayValueExt(i),r],"ks-craft")}_canCraft(e,t){if(!this._host.game.workshopTab.visible&&e!=="wood")return!1;const i=this.getCraft(e),n=p(this.settings.resources[e]).enabled;let a=!1;if(i.unlocked&&n){a=!0;const r=this._host.game.workshop.getCraftPrice(i);for(const o of r)this.getValueAvailable(o.name)<o.val*t&&(a=!1)}return a}getCraft(e){const t=this._host.game.workshop.getCraft(e);if(!t)throw new Error(`Unable to find craft '${e}'`);return t}singleCraftPossible(e){if(!this._host.game.workshopTab.visible&&e!=="wood")return!1;const t=this.getMaterials(e);for(const[i,n]of z(t))if(this.getValueAvailable(i)<n)return!1;return!0}getMaterials(e){const t={},i=this.getCraft(e),n=this._host.game.workshop.getCraftPrice(i);for(const a of n)t[a.name]=a.val;return t}getTickVal(e,t,i=void 0){let n=this._host.game.getResourcePerTick(e.name,!0);if(e.craftable){let a=Number.MAX_VALUE;const r=this.getMaterials(e.name);for(const[o,l]of z(r)){const h=(1+this._host.game.getResCraftRatio(e.name))/l,d=this.getTickVal(this.getResource(o));d!=="ignore"&&(a=Math.min(d*h,a))}n+=a!==Number.MAX_VALUE?a:0}return n<=0&&(e.name==="spice"||e.name==="blueprint")?"ignore":(!i&&!m(t)&&(n+=t.getResValue(e.name)),n)}getAverageHunt(){const e={},t=this._host.game.getEffect("hunterRatio")+this._host.game.village.getEffectLeader("manager",0);return e.furs=40+32.5*t,e.ivory=50*Math.min(.225+.01*t,.5)+40*t*Math.min(.225+.01*t,.5),e.unicorns=.05,this.getValue("zebras")>=10&&(e.bloodstone=this.getValue("bloodstone")===0?.05:5e-4),this._host.game.ironWill&&this._host.game.workshop.get("goldOre").researched&&(e.gold=.625+.625*t),e}getResource(e){const t=this._host.game.resPool.get(e);if(m(t))throw new Error(`Unable to find resource ${e}`);return t}getValue(e){return this.getResource(e).value??0}getStock(e){const t=this._host.engine.settings.resources.resources[e];return t.enabled?t.stock:0}getConsume(e){const t=this._host.engine.settings.resources.resources[e];return t.enabled?t.consume:1}getValueAvailable(e){let t=this.getStock(e);if(e==="catnip"){const a=this._host.game.bld.getBuildingExt("pasture").meta,r=this._host.game.bld.getBuildingExt("aqueduct").meta,o=a.stage===0?a.val:0,l=r.stage===0?r.val:0,h=this.getPotentialCatnip(!0,o,l);h<0&&(t-=h*202*5)}let i=this.getValue(e);i=Math.max(i-t,0);const n=this.getConsume(e);return i*n}getPotentialCatnip(e,t,i){let n=this._host.game.getEffect("catnipPerTickBase");e?(n*=.1,n*=1+this._host.game.getLimitedDR(this._host.game.getEffect("coldHarshness"),1)):n*=this._host.game.calendar.getWeatherMod({name:"catnip"})+this._host.game.calendar.getCurSeason().modifiers.catnip,this._host.game.science.getPolicy("communism").researched&&(n=0);const a=this._host.game.village.getResProduction(),r=a.catnip?a.catnip*(1+this._host.game.getEffect("catnipJobRatio")):0;let o=n+r,l=this._host.game.space.getBuilding("hydroponics").val;this._host.game.prestige.meta[0].meta[21].researched&&(this._host.game.calendar.cycle===2&&(l*=2),this._host.game.calendar.cycle===7&&(l*=.5)),o*=1+.03*i+.025*l;const d=this._host.game.challenges.currentChallenge==="winterIsComing"?0:this._host.game.prestige.getParagonProductionRatio();o*=1+d,o*=1+this._host.game.religion.getSolarRevolutionRatio(),this._host.game.opts.disableCMBR||(o*=1+this._host.game.getCMBRBonus()),o=p(this._host.game.calendar.cycleEffectsFestival({catnip:o}).catnip);let g=this._host.game.village.getResConsumption().catnip;const f=this._host.game.bld.getBuildingExt("unicornPasture").meta.val;if(g*=1+this._host.game.getLimitedDR(t*-.005+f*-.0015,1),this._host.game.village.sim.kittens.length>0&&this._host.game.village.happiness>1){const w=this._host.game.village.happiness-1,b=this._host.game.getEffect("catnipDemandWorkerRatioGlobal");this._host.game.challenges.currentChallenge==="anarchy"?g*=1+w*(1+b):g*=1+w*(1+b)*(1-this._host.game.village.getFreeKittens()/this._host.game.village.sim.kittens.length)}return o+=g,o+=this._host.game.getResourcePerTickConvertion("catnip"),o}refreshStock(){for(const[e,t]of z(this._host.engine.settings.resources.resources)){const i=[...$(`#game .res-row.resource_${e} .res-cell.resAmount`),...$(`#game .res-row.resource_${e} .res-cell.resource-value`)];if(!t.enabled||t.stock===0){for(const a of i)a.classList.remove("ks-stock-above","ks-stock-below");continue}const n=this._host.game.resPool.get(e).value<t.stock;for(const a of i)a.classList.add(n?"ks-stock-below":"ks-stock-above"),a.classList.remove(n?"ks-stock-above":"ks-stock-below")}}}u(ei,"DEFAULT_CONSUME_RATE",1);class Rn extends _{constructor(e,t=!1,i=ei.DEFAULT_CONSUME_RATE,n=0){super(t);L(this,Xe);u(this,"consume");u(this,"stock",0);O(this,Xe,e),this.consume=i,this.stock=n}get resource(){return I(this,Xe)}}Xe=new WeakMap;class Mn extends _{constructor(e=!1){super(e);u(this,"resources");this.resources=this.initResources()}initResources(){const e={};for(const t of Wi)e[t]=new Rn(t);return e}load(e){m(e)||(super.load(e),F(this.resources,e.resources,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.consume=(i==null?void 0:i.consume)??t.consume,t.stock=(i==null?void 0:i.stock)??t.stock}))}}class Bn extends _{constructor(e=new _,t=new _(!0)){super(!0);u(this,"noConfirm");u(this,"compress");this.noConfirm=e,this.compress=t}load(e){m(e)||(super.load(e),this.noConfirm.load(e.noConfirm),this.compress.load(e.compress))}}class cs extends _{constructor(e=!1,t=new xn,i=new Mn,n=new Bn,a=Te,r=new _){super(e);u(this,"interval",2e3);u(this,"locale");u(this,"ksColumn");u(this,"filters");u(this,"resources");u(this,"states");this.filters=t,this.resources=i,this.states=n,this.locale=new jt(a,[{label:"Deutsch",value:"de-DE"},{label:"English",value:"en-US"},{label:"עִברִית",value:"he-IL"},{label:"中文",value:"zh-CN"}]),this.ksColumn=r}load(e,t=!1){m(e)||(super.load(e),t||(this.interval=e.interval??this.interval,this.states.load(e.states),this.locale.load(e.locale),this.ksColumn.load(e.ksColumn)),this.filters.load(e.filters),this.resources.load(e.resources))}}class hs extends ae{constructor(e,t=!1,i=-1,n){super(t,i);L(this,Ye);L(this,Qe);L(this,et,0);O(this,Qe,e),n&&(O(this,et,1),O(this,Ye,n))}get baseBuilding(){return I(this,Ye)}get building(){return I(this,Qe)}get stage(){return I(this,et)}}Ye=new WeakMap,Qe=new WeakMap,et=new WeakMap;class An extends _{constructor(e=!1){super(e);u(this,"buildings");this.buildings=this.initBuildings()}initBuildings(){const e={broadcasttower:"amphitheatre",dataCenter:"library",hydroplant:"aqueduct",solarfarm:"pasture",spaceport:"warehouse"},t={};for(const i of Fi)i!=="unicornPasture"&&(t[i]=new hs(i));for(const i of Vt)t[i]=new hs(i,!1,-1,e[i]);return t}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class Tt extends ae{constructor(e,t,i=!1,n=-1){super(i,n);L(this,tt);L(this,it);O(this,tt,e),O(this,it,t)}get building(){return I(this,tt)}get variant(){return I(this,it)}}tt=new WeakMap,it=new WeakMap;class Pn extends _{constructor(e=!1){super(e);u(this,"buildings");this.buildings=this.initBuildings()}initBuildings(){const e={};for(const t of Zi)e[t]=new Tt(t,W.OrderOfTheSun);for(const t of Ki)e[t]=new Tt(t,W.Cryptotheology);for(const t of Vi)e[t]=new Tt(t,W.Ziggurat);return e.unicornPasture=new Tt("unicornPasture",W.UnicornPasture),e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class In extends ae{constructor(e,t=!1,i=-1){super(t,i);L(this,st);O(this,st,e)}get resource(){return I(this,st)}}st=new WeakMap;class $n extends _{constructor(e=!1){super(e);u(this,"resources");this.resources=this.initResources()}initResources(){const e={};for(const t of Wi)e[t]=new In(t);return e}load(e){m(e)||(super.load(e),F(this.resources,e.resources,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class Ln extends ae{constructor(e,t=!1,i=-1){super(t,i);L(this,nt);O(this,nt,e)}get building(){return I(this,nt)}}nt=new WeakMap;class On extends _{constructor(e=!1){super(e);u(this,"buildings");this.buildings=this.initBuildings()}initBuildings(){const e={};for(const t of Xi)e[t]=new Ln(t);return e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class us extends ae{constructor(e,t,i=!1,n=-1){super(i,n);L(this,at);L(this,rt);O(this,at,e),O(this,rt,t)}get building(){return I(this,at)}get variant(){return I(this,rt)}}at=new WeakMap,rt=new WeakMap;class Un extends _{constructor(e=!1){super(e);u(this,"buildings");this.buildings=this.initBuildings()}initBuildings(){const e={};for(const t of Yi)e[t]=new us(t,ce.Chronoforge);for(const t of Qi)t!=="usedCryochambers"&&(e[t]=new us(t,ce.VoidSpace));return e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class Dn extends _{constructor(e,t=!1){super(t);L(this,ot);O(this,ot,e)}get upgrade(){return I(this,ot)}}ot=new WeakMap;class Nn extends _{constructor(e=!1){super(e);u(this,"upgrades");this.upgrades=this.initUpgrades()}initUpgrades(){const e={};for(const t of es)e[t]=new Dn(t);return e}load(e){m(e)||(super.load(e),F(this.upgrades,e.upgrades,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}))}}class qn extends _{constructor(e=!1,t=new An,i=new Pn,n=new $n,a=new On,r=new Un,o=new Nn){super(e);u(this,"bonfire");u(this,"religion");u(this,"resources");u(this,"space");u(this,"time");u(this,"upgrades");this.bonfire=t,this.religion=i,this.resources=n,this.space=a,this.time=r,this.upgrades=o}load(e){m(e)||(super.load(e),this.bonfire.load(e.bonfire),this.religion.load(e.religion),this.resources.load(e.resources),this.space.load(e.space),this.time.load(e.time),this.upgrades.load(e.upgrades))}}class zn extends V{constructor(e=new _){super(!1,1);u(this,"cycles");u(this,"activeHeatTransferStatus");this.cycles=this.initCycles(),this.activeHeatTransferStatus=e}initCycles(){const e={};for(const t of we)e[t]=new _;return e}load(e){m(e)||(super.load(e),F(this.cycles,e.cycles,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}),this.activeHeatTransferStatus.load(e.activeHeatTransferStatus))}}class Fn extends nn{constructor(e=new _,t=new zn){super(!1,5);u(this,"cycles");u(this,"seasons");u(this,"activeHeatTransfer");u(this,"ignoreOverheat");this.cycles=this.initCycles(),this.seasons=this.initSeason(),this.activeHeatTransfer=t,this.ignoreOverheat=e}initCycles(){const e={};for(const t of we)e[t]=new _;return e}initSeason(){const e={};for(const t of Vs)e[t]=new _;return e}load(e){m(e)||(super.load(e),F(this.cycles,e.cycles,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}),F(this.seasons,e.seasons,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}),this.ignoreOverheat.load(e.ignoreOverheat),this.activeHeatTransfer.load(e.activeHeatTransfer))}}class ds extends _{constructor(e=!1,t=new V(!1,1),i=new qn,n=new Fn){super(e);u(this,"accelerateTime");u(this,"timeSkip");u(this,"reset");this.accelerateTime=t,this.reset=i,this.timeSkip=n}load(e){m(e)||(super.load(e),this.accelerateTime.load(e.accelerateTime),this.reset.load(e.reset),this.timeSkip.load(e.timeSkip))}}class gs extends _t{constructor(e,t,i=!1){super(i,-1,0);L(this,lt);L(this,ct);O(this,lt,e),O(this,ct,t)}get building(){return I(this,lt)}get variant(){return I(this,ct)}}lt=new WeakMap,ct=new WeakMap;class ms extends V{constructor(e=!1,t=-1,i=new _){super(e,t);u(this,"buildings");u(this,"fixCryochambers");this.buildings=this.initBuildings(),this.fixCryochambers=i}initBuildings(){const e={};for(const t of Yi)e[t]=new gs(t,ce.Chronoforge);for(const t of Qi)t!=="usedCryochambers"&&(e[t]=new gs(t,ce.VoidSpace));return e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.max=(i==null?void 0:i.max)??t.max,t.trigger=(i==null?void 0:i.trigger)??t.trigger}),this.fixCryochambers.load(e.fixCryochambers))}}class Hn extends is{constructor(e,t=!1){super(t);L(this,ht);O(this,ht,e)}get race(){return I(this,ht)}}ht=new WeakMap;class Wn extends V{constructor(e=!1){super(e);u(this,"races");this.races=this.initRaces()}initRaces(){const e={};for(const t of ji)t!=="leviathans"&&(e[t]=new Hn(t));return e}load(e){m(e)||(super.load(e),F(this.races,e.races,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.max=(i==null?void 0:i.max)??t.max}))}}class Gn extends sn{constructor(e,t,i,n,a,r,o,l=!1){super(t,i);L(this,ut);u(this,"seasons");L(this,dt);O(this,ut,e),this.seasons={autumn:new _(a),spring:new _(o),summer:new _(n),winter:new _(r)},O(this,dt,l)}get race(){return I(this,ut)}get require(){return I(this,dt)}}ut=new WeakMap,dt=new WeakMap;class fs extends V{constructor(e=!1,t=-1,i=new Wn,n=new _,a=new an(!1,1090,1095,1e4),r=new _){super(e,t);u(this,"races");u(this,"feedLeviathans");u(this,"buildEmbassies");u(this,"tradeBlackcoin");u(this,"unlockRaces");this.races=this.initRaces(),this.buildEmbassies=i,this.feedLeviathans=n,this.tradeBlackcoin=a,this.unlockRaces=r}initRaces(){const e={dragons:"titanium",griffins:"wood",leviathans:"unobtainium",lizards:"minerals",sharks:"iron"},t={};for(const i of ji){const n=e[i]??!1;t[i]=new Gn(i,!1,!1,!1,!1,!1,!1,n)}return t}load(e){m(e)||(super.load(e),F(this.races,e.races,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.limited=(i==null?void 0:i.limited)??t.limited,t.trigger=(i==null?void 0:i.trigger)??t.trigger,t.seasons.autumn.enabled=(i==null?void 0:i.seasons.autumn.enabled)??t.seasons.autumn.enabled,t.seasons.spring.enabled=(i==null?void 0:i.seasons.spring.enabled)??t.seasons.spring.enabled,t.seasons.summer.enabled=(i==null?void 0:i.seasons.summer.enabled)??t.seasons.summer.enabled,t.seasons.winter.enabled=(i==null?void 0:i.seasons.winter.enabled)??t.seasons.winter.enabled}),this.buildEmbassies.load(e.buildEmbassies),this.feedLeviathans.load(e.feedLeviathans),this.tradeBlackcoin.load(e.tradeBlackcoin),this.unlockRaces.load(e.unlockRaces))}}class Zn extends _{constructor(e=!1,t=new jt("any",Gi.map(n=>({label:"",value:n}))),i=new jt("none",js.map(n=>({label:"",value:n})))){super(e);u(this,"job");u(this,"trait");this.job=t,this.trait=i}load(e){m(e)||(super.load(e),this.job.load(e.job),this.trait.load(e.trait))}}class bs extends _{constructor(e=!1,t=new _,i=new V(!1,.98),n=new V(!1,1),a=new _,r=new Zn){super(e);u(this,"jobs");u(this,"holdFestivals");u(this,"hunt");u(this,"promoteKittens");u(this,"promoteLeader");u(this,"electLeader");this.jobs=this.initJobs(),this.holdFestivals=t,this.hunt=i,this.promoteKittens=n,this.promoteLeader=a,this.electLeader=r}initJobs(){const e={};for(const t of Gi)e[t]=new is(!1,0);return e}load(e){var t,i,n;m(e)||(super.load(e),F(this.jobs,e.jobs,(a,r)=>{a.enabled=(r==null?void 0:r.enabled)??a.enabled,a.max=(r==null?void 0:r.max)??a.max}),this.holdFestivals.enabled=((t=e.holdFestivals)==null?void 0:t.enabled)??this.holdFestivals.enabled,this.hunt.load(e.hunt),this.promoteKittens.enabled=((i=e.promoteKittens)==null?void 0:i.enabled)??this.promoteKittens.enabled,this.promoteLeader.enabled=((n=e.promoteLeader)==null?void 0:n.enabled)??this.promoteLeader.enabled,this.electLeader.load(e.electLeader))}}class Kn{constructor(s,e,t,i,n,a=new ds){u(this,"_host");u(this,"settings");u(this,"manager");u(this,"_bonfireManager");u(this,"_religionManager");u(this,"_spaceManager");u(this,"_workshopManager");this._host=s,this.settings=a,this.manager=new ge(this._host,"Time"),this._bonfireManager=e,this._religionManager=t,this._spaceManager=i,this._workshopManager=n}async tick(s){this.settings.enabled&&(this.settings.accelerateTime.enabled&&this.accelerateTime(),this.settings.timeSkip.enabled&&this.timeSkip(),this.settings.reset.enabled&&await this.autoReset(this._host.engine))}async autoReset(s){if(this._host.game.challenges.currentChallenge)return;const e=[],t=[],i=r=>{if(t.length!==0)for(const o of r){if(m(o.model))continue;const l=o.model,h=l.metadata.name,d=t.indexOf(h);if(d!==-1&&(t.splice(d,1),this._host.game.resPool.hasRes(p(l.prices))))return!0}return!1};for(const[r,o]of z(this.settings.reset.bonfire.buildings)){if(!o.enabled)continue;if(o.trigger<0)return;let l;try{l=this._host.game.bld.getBuildingExt(r)}catch{l=null}if(!m(l))if(e.push({name:l.meta.label??p(l.meta.stages)[p(l.meta.stage)].label,trigger:o.trigger,val:l.meta.val}),0<o.trigger){if(l.meta.val<o.trigger)return}else t.push(r)}const n=this.settings.reset.religion.buildings.unicornPasture;if(n.enabled){if(n.trigger<0)return;const r=this._host.game.bld.getBuildingExt("unicornPasture");if(e.push({name:p(r.meta.label),trigger:n.trigger,val:r.meta.val}),0<n.trigger){if(r.meta.val<n.trigger)return}else t.push("unicornPasture")}if(i(this._bonfireManager.manager.tab.children)||t.length)return;for(const[r,o]of z(this.settings.reset.space.buildings)){if(!o.enabled)continue;if(o.trigger<0)return;const l=this._host.game.space.getBuilding(r);if(e.push({name:l.label,trigger:o.trigger,val:l.val}),0<o.trigger){if(l.val<o.trigger)return}else t.push(r)}if(t.length===0){const r=p(this._spaceManager.manager.tab.planetPanels);for(const o of r)for(const l of o.children){const h=p(l.model),d=h.metadata.name,g=t.indexOf(d);if(g!==-1&&(t.splice(g,1),this._host.game.resPool.hasRes(p(h.prices))))break}}if(t.length)return;for(const[r,o]of z(this.settings.reset.religion.buildings)){if(!o.enabled)continue;if(o.trigger<0)return;const l=p(this._religionManager.getBuild(r,o.variant));if(e.push({name:l.label,trigger:o.trigger,val:l.val}),0<o.trigger){if(l.val<o.trigger)return}else t.push(r)}if(i(this._religionManager.manager.tab.zgUpgradeButtons)||i(this._religionManager.manager.tab.rUpgradeButtons)||i(this._religionManager.manager.tab.ctPanel.children[0].children)||t.length)return;for(const[r,o]of z(this.settings.reset.time.buildings)){if(!o.enabled)continue;if(o.trigger<0)return;const l=p(this.getBuild(r,o.variant));if(e.push({name:l.label,trigger:o.trigger,val:l.val}),0<o.trigger){if(l.val<o.trigger)return}else t.push(r)}if(i(this.manager.tab.cfPanel.children[0].children)||i(this.manager.tab.vsPanel.children[0].children)||t.length)return;for(const[r,o]of z(this.settings.reset.resources.resources)){if(!o.enabled)continue;if(o.trigger<0)return;const l=p(this._host.game.resPool.get(r));if(e.push({name:this._host.engine.i18n(`$resources.${o.resource}.title`),trigger:o.trigger,val:l.value}),l.value<o.trigger)return}for(const[,r]of z(this.settings.reset.upgrades.upgrades))if(r.enabled){const o=p(this._host.game.workshop.upgrades.find(l=>l.name===r.upgrade));if(e.push({name:o.label,trigger:1,val:o.researched?1:0}),!o.researched)return}s.stop(!1);const a=async(r=1500)=>new Promise((o,l)=>{if(!this._host.engine.settings.enabled){l(new Error("canceled by player"));return}setTimeout(o,r)});try{for(const r of e)await a(500),this._host.engine.imessage("reset.check",[r.name,this._host.game.getDisplayValueExt(r.trigger),this._host.game.getDisplayValueExt(r.val)]);await a(0),this._host.engine.imessage("reset.checked"),await a(),this._host.engine.iactivity("reset.tip"),await a(),this._host.engine.imessage("reset.countdown.10"),await a(2e3),this._host.engine.imessage("reset.countdown.9"),await a(),this._host.engine.imessage("reset.countdown.8"),await a(),this._host.engine.imessage("reset.countdown.7"),await a(),this._host.engine.imessage("reset.countdown.6"),await a(),this._host.engine.imessage("reset.countdown.5"),await a(),this._host.engine.imessage("reset.countdown.4"),await a(),this._host.engine.imessage("reset.countdown.3"),await a(),this._host.engine.imessage("reset.countdown.2"),await a(),this._host.engine.imessage("reset.countdown.1"),await a(),this._host.engine.imessage("reset.countdown.0"),await a(),this._host.engine.iactivity("reset.last.message"),await a()}catch{this._host.engine.imessage("reset.cancel.message"),this._host.engine.iactivity("reset.cancel.activity");return}for(let r=0;r<this._host.game.challenges.challenges.length;r++)this._host.game.challenges.challenges[r].pending=!1;this._host.game.resetAutomatic()}accelerateTime(){if(this._workshopManager.getValueAvailable("temporalFlux")<=0){this._host.game.time.isAccelerated&&(this._host.game.time.isAccelerated=!1);return}if(this._host.game.time.isAccelerated)return;const e=this._host.game.resPool.get("temporalFlux");e.maxValue*this.settings.accelerateTime.trigger<=e.value&&(this._host.game.time.isAccelerated=!0,this._host.engine.iactivity("act.accelerate",[],"ks-accelerate"),this._host.engine.storeForSummary("accelerate",1))}timeSkip(){if(!this._host.game.workshop.get("chronoforge").researched||this._host.game.calendar.day<0)return;const s=this._host.game.getEffect("shatterCostIncreaseChallenge"),e=this._workshopManager.getValueAvailable("timeCrystal");if(e<this.settings.timeSkip.trigger||e<1+s)return;const t=this._host.game.getEffect("shatterVoidCost"),i=this._workshopManager.getValueAvailable("void");if(i<t)return;const n=this._host.game.calendar.season;if(!this.settings.timeSkip.seasons[this._host.game.calendar.seasons[n].name].enabled)return;const a=this._host.game.calendar.cycle;if(!this.settings.timeSkip.cycles[we[a]].enabled)return;const r=this._host.game.getEffect("heatMax"),o=this._host.game.time.heat;if(!this.settings.timeSkip.ignoreOverheat.enabled&&r<=o)return;const l=this._host.game.challenges.getChallenge("1000Years").researched?5:10;let h=Number.POSITIVE_INFINITY;if(!this.settings.timeSkip.ignoreOverheat.enabled&&this.settings.timeSkip.activeHeatTransfer.enabled){const y=this._host.game.getEffect("heatPerTick"),P=this._host.game.ticksPerSecond;if(this.settings.timeSkip.activeHeatTransfer.activeHeatTransferStatus.enabled){o<=r*this.settings.timeSkip.activeHeatTransfer.trigger&&(this.settings.timeSkip.activeHeatTransfer.activeHeatTransferStatus.enabled=!1,this._host.refreshEntireUserInterface(),this._host.engine.iactivity("act.time.activeHeatTransferEnd",[],"ks-timeSkip"));const j=this._host.game.getEffect("temporalFluxProduction"),Q=(this._host.game.calendar.daysPerSeason+10+this._host.game.getEffect("temporalParadoxDay"))*this._host.game.calendar.seasonsPerYear,le=this._host.game.calendar.ticksPerDay,be=(1+this._host.game.timeAccelerationRatio())/le,ee=Q/be,pe=this._host.game.resPool.get("temporalFlux"),mt=pe.maxValue>ee,Me=pe.value<ee;if(!n&&this._host.game.calendar.day<10&&j>l/y&&this.settings.accelerateTime.enabled&&mt&&Me)h=Math.ceil((ee+le*10-pe.value)/j),this._host.engine.iactivity("act.time.getTemporalFlux",[],"ks-timeSkip"),this._host.engine.storeForSummary("time.getTemporalFlux",1);else{if(this.settings.timeSkip.activeHeatTransfer.cycles[we[a]].enabled)return;h=this._host.game.calendar.yearsPerCycle-this._host.game.calendar.cycleYear}}else o>=r-y*P*10&&(this.settings.timeSkip.activeHeatTransfer.activeHeatTransferStatus.enabled=!0,this._host.refreshEntireUserInterface(),this._host.engine.iactivity("act.time.activeHeatTransferStart",[],"ks-timeSkip"),this._host.engine.storeForSummary("time.activeHeatTransferStart",1))}const d=Y(this.settings.timeSkip.max);let g=Math.floor(Math.min(this.settings.timeSkip.ignoreOverheat.enabled?Number.POSITIVE_INFINITY:(r-o)/l,d,h,e/(1+s),0<t?i/t:Number.POSITIVE_INFINITY)),f=0;const w=this._host.game.calendar.yearsPerCycle,b=w-this._host.game.calendar.cycleYear,k=this._host.game.calendar.cyclesPerEra;if(g<b)f=g;else{f+=b,g-=b;let y=1;for(;w<g&&this.settings.timeSkip.cycles[we[(a+y)%k]].enabled;)f+=w,g-=w,y+=1;this.settings.timeSkip.cycles[we[(a+y)%k]].enabled&&0<g&&(f+=g)}if(0<f){const y=this._host.game.timeTab.cfPanel.children[0].children[0];if(m(y.model))return;this._host.engine.iactivity("act.time.skip",[f],"ks-timeSkip"),y.controller.doShatterAmt(y.model,f),this._host.engine.storeForSummary("time.skip",f)}}getBuild(s,e){return e===ce.Chronoforge?this._host.game.time.getCFU(s):this._host.game.time.getVSU(s)}}class Vn{constructor(s,e,t=new ms){u(this,"_host");u(this,"settings");u(this,"manager");u(this,"_bulkManager");u(this,"_workshopManager");this._host=s,this.settings=t,this.manager=new ge(this._host,"Time"),this._bulkManager=new wt(this._host,e),this._workshopManager=e}tick(s){this.settings.enabled&&(this.manager.render(),this.autoBuild(s),this.settings.fixCryochambers.enabled&&this.fixCryochambers())}autoBuild(s,e=this.settings.buildings){const t=this._bulkManager,i=this.settings.trigger,n={};for(const r of Object.values(e)){const o=this.getBuild(r.building,r.variant);n[r.building]=p(o);const l=r.variant===ce.Chronoforge?this._getBuildButtonCF(r.building):this._getBuildButtonVS(r.building);if(m(l))continue;const h=l.model,d=r.variant===ce.Chronoforge?this.manager.tab.cfPanel:this.manager.tab.vsPanel,g=p(n[r.building]);g.tHidden=!(h!=null&&h.visible)||!h.enabled||!d.visible}const a=t.bulk(e,n,i,"Time");for(const r of a)r.count>0&&(this.build(r.id,r.variant,r.count),s.requestGameUiRefresh=!0)}build(s,e,t){let i=t,n;const a=i;if(e===ce.Chronoforge){const r=game.getUnlockByName(s,"chronoforge"),o=new classes.ui.time.ChronoforgeBtnController(this._host.game),l=o.fetchModel({controller:o,id:r.name});i=this._bulkManager.construct(l,o,i),n=r.label}else{const r=game.getUnlockByName(s,"voidSpace"),o=new classes.ui.time.VoidSpaceBtnController(this._host.game),l=o.fetchModel({controller:o,id:r.name});i=this._bulkManager.construct(l,o,i),n=r.label}i!==a&&(console.warn(...v(`${n} Amount ordered: ${a} Amount Constructed: ${i}`)),i===0)||(this._host.engine.storeForSummary(n,i,"build"),i===1?this._host.engine.iactivity("act.build",[n],"ks-build"):this._host.engine.iactivity("act.builds",[n,this._host.renderAbsolute(i)],"ks-build"))}getBuild(s,e){return e===ce.Chronoforge?this._host.game.time.getCFU(s):this._host.game.time.getVSU(s)}_getBuildButtonCF(s){return this.manager.tab.children[2].children[0].children.find(e=>e.id===s)??null}_getBuildButtonVS(s){return this.manager.tab.children[3].children[0].children.find(e=>e.id===s)??null}fixCryochambers(){if(this._host.game.time.getVSU("usedCryochambers").val<1)return;const s=p(this._host.game.time.getVSU("usedCryochambers").fixPrices);for(const n of s)if(this._workshopManager.getValueAvailable(n.name)<n.val)return;const e=this.manager.tab.vsPanel.children[0].children[0];let t=0,i;do i=!1,i=e.controller.buyItem(p(e.model),new MouseEvent("click")).itemBought,t+=i?1:0;while(i);0<t&&(this._host.engine.iactivity("act.fix.cry",[this._host.renderAbsolute(t)],"ks-fixCry"),this._host.engine.storeForSummary("fix.cry",t))}}class jn{constructor(s,e,t=new fs){u(this,"_host");u(this,"settings");u(this,"manager");u(this,"_workshopManager");this._host=s,this.settings=t,this.manager=new ge(this._host,"Trade"),this._workshopManager=e}tick(s){this.settings.enabled&&(this.manager.render(),this.autoTrade(),this.settings.unlockRaces.enabled&&this.autoUnlock(s),this.settings.buildEmbassies.enabled&&this.autoBuildEmbassies(s),this.settings.feedLeviathans.enabled&&this.autoFeedElders(),this.settings.tradeBlackcoin.enabled&&this.autoTradeBlackcoin())}autoTrade(s){var d;const e=this._workshopManager.getResource("manpower"),t=this._workshopManager.getResource("gold"),i=this.settings.trigger,n=[],a=this._host.game.calendar.getCurSeason().name;for(const g of Object.values(this.settings.races)){const f=this.getRace(g.race),w=re.evaluateSubSectionTrigger(i,g.trigger);if(w<0||!g.enabled||!g.seasons[a].enabled||!f.unlocked||!this.singleTradePossible(i,e,t,g))continue;const b=this.getTradeButton(f.name);if(!((d=b==null?void 0:b.model)!=null&&d.enabled))continue;const k=g.require?this._workshopManager.getResource(g.require):!1,y=this.getProfitability(g.race);(g.limited&&y||!k||w<=k.value/k.maxValue)&&n.push(g.race)}if(n.length===0)return;let r=this.getLowestTradeAmount(null,!0,!1);if(r<1)return;const o=[];for(let g=0;g<n.length;g++){const f=n[g],w=this.settings.races[f],b=w.require?this._workshopManager.getResource(w.require):!1,k=re.evaluateSubSectionTrigger(i,w.trigger),y=(!b||k<=b.value/b.maxValue)&&k<=t.value/t.maxValue,P=this.getLowestTradeAmount(f,w.limited,y);if(P<1){n.splice(g,1),g--;continue}o.push(P)}if(n.length===0)return;const l={};for(;0<n.length&&1<=r;){if(r<n.length){const b=Math.floor(Math.random()*n.length),k=n[b];m(l[k])&&(l[k]=0),l[k]+=1,r-=1,n.splice(b,1),o.splice(b,1);continue}let g=Math.floor(r/n.length),f=0;const w=n[f];for(let b=0;b<n.length;++b)o[b]<g&&(g=o[b],f=b);m(l[w])&&(l[w]=0),l[w]+=g,r-=g,n.splice(f,1),o.splice(f,1)}if(Object.values(l).length===0)return;const h={};for(const[g,f]of z(l)){const w=this.getRace(g),b=this.getMaterials(g);for(const[y,P]of z(b))h[y]||(h[y]=0),h[y]-=P*f;const k=this.getAverageTrade(w);for(const[y,P]of z(k)){const j=this._workshopManager.getResource(y);h[y]||(h[y]=0),h[y]+=j.maxValue>0?Math.min(p(k[y])*p(l[g]),Math.max(j.maxValue-j.value,0)):P*p(l[g])}}m(s)||s.pushToCache({materials:h,timeStamp:this._host.game.timer.ticksTotal});for(const[g,f]of z(l))0<f&&this.trade(g,f)}autoBuildEmbassies(s){var o;if(!this._host.game.diplomacy.races[0].embassyPrices)return;const e=this._workshopManager.getResource("culture");let t=0;const i=this.settings.buildEmbassies.trigger;if(e.value/e.maxValue<Y(i))return;const n=this._host.game.diplomacyTab.racePanels;t=this._workshopManager.getValueAvailable("culture");const a={},r=[];for(let l=0;l<n.length;l++){if(!n[l].embassyButton)continue;const h=n[l].race.name,d=this._host.game.diplomacy.get(h),g=Y(this.settings.buildEmbassies.races[h].max);!this.settings.buildEmbassies.races[h].enabled||g<=d.embassyLevel||!d.unlocked||(a[h]={basePrice:p((o=d.embassyPrices)==null?void 0:o[0]).val,currentEm:d.embassyLevel,max:g,priceSum:0,race:d,val:0},r.push(h))}if(r.length!==0){for(;r.length>0;)for(let l=0;l<r.length;l++){const h=r[l],d=p(a[h]);if(d.max<=d.currentEm+d.val){r.splice(l,1),--l;continue}const g=d.basePrice*1.15**(d.currentEm+d.val);g<=t?(t-=g,d.priceSum+=g,d.val+=1,s.requestGameUiRefresh=!0):(r.splice(l,1),--l)}for(const[,l]of z(a))l.val!==0&&(t=this._workshopManager.getValueAvailable("culture"),t<l.priceSum&&console.warn(...v("Something has gone horribly wrong.",l.priceSum,t)),this._workshopManager.getResource("culture").value-=l.priceSum,l.race.embassyLevel+=l.val,this._host.engine.storeForSummary("embassy",l.val),l.val!==1?this._host.engine.iactivity("build.embassies",[l.val,l.race.title],"ks-build"):this._host.engine.iactivity("build.embassy",[l.val,l.race.title],"ks-build"))}}autoFeedElders(){const s=this._host.game.diplomacy.get("leviathans"),e=this._host.game.resPool.get("necrocorn");!s.unlocked||e.value===0||(1<=e.value?s.energy<this._host.game.diplomacy.getMarkerCap()&&(this._host.game.diplomacy.feedElders(),this._host.engine.iactivity("act.feed"),this._host.engine.storeForSummary("feed",1)):.25*(1+this._host.game.getEffect("corruptionBoostRatio"))<1&&(this._host.engine.storeForSummary("feed",e.value),this._host.game.diplomacy.feedElders(),this._host.engine.iactivity("dispose.necrocorn")))}autoUnlock(s){if(!this._host.game.tabs[4].visible)return;const e=this._host.game.diplomacy.get("leviathans").unlocked?8:7;if(this._host.game.diplomacyTab.racePanels.length<e){let t=this._workshopManager.getValueAvailable("manpower");if(!this._host.game.diplomacy.get("lizards").unlocked&&t>=1e3){this._host.game.resPool.get("manpower").value-=1e3;const i=p(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("sharks").unlocked&&t>=1e3){this._host.game.resPool.get("manpower").value-=1e3;const i=p(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("griffins").unlocked&&t>=1e3){this._host.game.resPool.get("manpower").value-=1e3;const i=p(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("nagas").unlocked&&this._host.game.resPool.get("culture").value>=1500&&t>=1e3){this._host.game.resPool.get("manpower").value-=1e3;const i=p(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("zebras").unlocked&&this._host.game.resPool.get("ship").value>=1&&t>=1e3){this._host.game.resPool.get("manpower").value-=1e3;const i=p(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("spiders").unlocked&&p(this._host.game.resPool.get("ship")).value>=100&&p(this._host.game.resPool.get("science")).maxValue>125e3&&t>=1e3){p(this._host.game.resPool.get("manpower")).value-=1e3;const i=p(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("dragons").unlocked&&this._host.game.science.get("nuclearFission").researched&&t>=1e3){p(this._host.game.resPool.get("manpower")).value-=1e3;const i=p(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}}}autoTradeBlackcoin(){const s=this._host.game.calendar.cryptoPrice,e=this._host.game.resPool.get("relic").value,t=this._host.game.resPool.get("blackcoin").value;let i=0,n=0;if(s<this.settings.tradeBlackcoin.buy&&this.settings.tradeBlackcoin.trigger<e){this._host.game.diplomacy.buyBcoin();const a=this._host.game.resPool.get("blackcoin").value;i=Math.round(a-t),this._host.engine.iactivity("act.blackcoin.buy",[this._host.renderAbsolute(i)])}else if(s>this.settings.tradeBlackcoin.sell&&0<this._host.game.resPool.get("blackcoin").value){this._host.game.diplomacy.sellBcoin();const a=p(this._host.game.resPool.get("relic")).value;n=Math.round(a-e),this._host.engine.iactivity("act.blackcoin.sell",[this._host.renderAbsolute(n)])}}trade(s,e){var n;const t=this.getRace(s),i=this.getTradeButton(t.name);(!((n=i==null?void 0:i.model)!=null&&n.enabled)||!this.settings.races[s].enabled)&&console.warn(...v("KS trade checks are not functioning properly, please create an issue on the github page.")),this._host.game.diplomacy.tradeMultiple(t,e),this._host.engine.storeForSummary(t.title,e,"trade"),this._host.engine.iactivity("act.trade",[this._host.renderAbsolute(e),X(t.title)],"ks-trade")}getProfitability(s){const e=this.getRace(s);let t=0;const i=this.getMaterials(s);for(const[r,o]of z(i)){const l=this._workshopManager.getTickVal(this._workshopManager.getResource(r));if(l!=="ignore"){if(l<=0)return!1;t+=o/l}}let n=0;const a=this.getAverageTrade(e);for(const[r,o]of z(a)){const l=this._workshopManager.getResource(r),h=this._workshopManager.getTickVal(l);if(h!=="ignore"){if(h<=0)return!0;n+=0<l.maxValue?Math.min(o,Math.max(l.maxValue-l.value,0))/h:o/h}}return t<=n}getAverageTrade(s){const e=this._host.game.getEffect("standingRatio")+this._host.game.diplomacy.calculateStandingFromPolicies(s.name,this._host.game),t=1+s.energy*.02,i=1+this._host.game.diplomacy.getTradeRatio()+this._host.game.diplomacy.calculateTradeBonusFromPolicies(s.name,this._host.game),n=s.standing<0?s.standing+e:0,a=0<n?1+n:1,r=0<s.standing?Math.min(s.standing+e/2,1):0,o={};for(const d of s.sells){if(!this._isValidTrade(d,s)){o[d.name]=0;continue}let g=0;const f=s.embassyPrices?d.chance*(1+this._host.game.getLimitedDR(.01*s.embassyLevel,.75)):d.chance;if(s.name==="zebras"&&d.name==="titanium"){const w=this._host.game.resPool.get("ship").value,b=Math.min(.15+w*.0035,1);g=1.5*(1+w/50)*(a*b)}else{const w=d.seasons?1+d.seasons[this._host.game.calendar.getCurSeason().name]:1,b=(a-r)*Math.min(f/100,1),k=r*Math.min(f/100,1);g=(b+1.25*k)*d.value*t*w*i}o[d.name]=g}const l=s.embassyPrices?.35*(1+.01*s.embassyLevel):.35,h=a*Math.min(l,1);return o.spice=25*h+50*h*i/2,o.blueprint=.1*a,o}_isValidTrade(s,e){return!(s.minLevel&&e.embassyLevel<s.minLevel)&&(this._host.game.resPool.get(s.name).unlocked||s.name==="titanium"||s.name==="uranium"||e.name==="leviathans")}getLowestTradeAmount(s,e,t){let i;const n=this.getMaterials(s);let a;for(const[h,d]of z(n)){if(h==="manpower"){let g=d;this._host.game.challenges.isActive("postApocalypse")&&(g=d*(1+this._host.game.bld.getPollutionLevel())),a=this._workshopManager.getValueAvailable(h)/g}else if(h==="gold"){let g=d;this._host.game.challenges.isActive("postApocalypse")&&(g=d*(1+this._host.game.bld.getPollutionLevel())),a=this._workshopManager.getValueAvailable(h)/g}else a=this._workshopManager.getValueAvailable(h)/d;i=i===void 0||a<i?a:i}if(i=Math.floor(i??0),i===0)return 0;if(s===null||s==="leviathans")return i;const r=this.getRace(s);let o=0;const l=this.getAverageTrade(r);for(const h of r.sells){const d=this._workshopManager.getResource(h.name);let g=0;if(!d.maxValue)continue;g=p(l[h.name]);const f=Math.max((d.maxValue-d.value)/g,0);o=f<o?o:f}return o=Math.ceil(o),o===0?0:(i=o<i?Math.max(o-1,1):i,Math.floor(i))}getMaterials(s=null){const e={gold:15-this._host.game.getEffect("tradeGoldDiscount"),manpower:50-this._host.game.getEffect("tradeCatpowerDiscount")};if(m(s))return e;const t=this.getRace(s).buys;for(const i of t)e[i.name]=i.val;return e}getRace(s){const e=this._host.game.diplomacy.get(s);if(m(e))throw new Error(`Unable to retrieve race '${s}'`);return e}getTradeButton(s){const e=this.manager.tab.racePanels.find(t=>t.race.name===s);return(e==null?void 0:e.tradeBtn)??null}singleTradePossible(s,e,t,i){const n=i?re.evaluateSubSectionTrigger(s,i.trigger):s;if(n<0&&i===void 0)return!0;if(n<0&&i!==void 0||e.value/e.maxValue<n||t.value/t.maxValue<n)return!1;const a=this.getMaterials(i==null?void 0:i.race);for(const[r,o]of z(a))if(this._workshopManager.getValueAvailable(r)<o)return!1;return!0}}class Jn{constructor(s){u(this,"_host");u(this,"_cache",new Array);u(this,"_cacheSum",{});this._host=s}pushToCache(s){this._cache.push(s);for(const[e,t]of z(s.materials))this._cacheSum[e]||(this._cacheSum[e]=0),this._cacheSum[e]+=t;for(let e=0;e<this._cache.length;++e){const t=this._cache[e];if(this._cache.length>1e4){const i=t.materials;for(const[n,a]of z(i))this._cacheSum[n]||(this._cacheSum[n]=0),this._cacheSum[n]-=a;this._cache.shift(),e--}else return}}getResValue(s){if(this._cache.length===0||!this._cacheSum[s])return 0;const e=this._host.game.timer.ticksTotal,t=this._cache[0].timeStamp;return this._cacheSum[s]/(e-t)}}class Xn{constructor(s,e,t=new bs){u(this,"_host");u(this,"settings");u(this,"manager");u(this,"_cacheManager");u(this,"_workshopManager");this._host=s,this.settings=t,this.manager=new ge(this._host,"Village"),this._cacheManager=new Jn(this._host),this._workshopManager=e}tick(s){this.settings.enabled&&(this.autoDistributeKittens(),this.settings.hunt.enabled&&this.autoHunt(this._cacheManager),this.settings.holdFestivals.enabled&&this.autoFestival(this._cacheManager),this.settings.electLeader.enabled&&this.autoElect(),this.settings.promoteLeader.enabled&&this.autoPromoteLeader(),this.settings.promoteKittens.enabled&&this.autoPromoteKittens())}autoDistributeKittens(){const s=this._host.game.village.getFreeKittens();if(s){for(let e=0;e<s;++e){const t=new Array;for(const a of this._host.game.village.jobs){const r=this.settings.jobs[a.name].enabled,o=a.unlocked;if(!r||!o)continue;const l=this._host.game.village.getJobLimit(a.name),h=Y(this.settings.jobs[a.name].max),d=a.value;d<l&&d<h&&t.push({count:d,job:a,toCap:l-d})}if(!t.length)return;const i=!m(t.find(a=>a.job.name==="farmer"&&a.count===0));t.sort((a,r)=>a.count-r.count);const n=i?"farmer":t[0].job.name;this._host.game.village.assignJob(this._host.game.village.getJob(n),1),this.manager.render(),this._host.engine.iactivity("act.distribute",[this._host.engine.i18n(`$village.job.${n}`)],"ks-distribute")}this._host.engine.storeForSummary("distribute",s)}}autoElect(){if(this._host.game.challenges.isActive("anarchy"))return;const s=this._host.game.village.sim.kittens,e=this._host.game.village.leader,t=this.settings.electLeader.job.selected,i=this.settings.electLeader.trait.selected,n=s.filter(r=>(r.job===t||t==="any")&&r.trait.name===i);if(n.length===0)return;n.sort((r,o)=>o.rank-r.rank);const a=n[0];!m(e)&&e.trait.name===i&&(e.job===t||t==="any")&&a.rank<=e.rank||(this._host.game.village.makeLeader(a),this._host.engine.iactivity("act.elect"))}autoPromoteKittens(){const s=this._workshopManager.getResource("gold");if(!(this.settings.promoteKittens.trigger<s.value/s.maxValue))for(let e=0;e<this._host.game.village.sim.kittens.length;e++){let t=-1;const i=this._host.game.village.sim.kittens[e].engineerSpeciality;if(!m(i)&&(t=p(this._host.game.workshop.getCraft(i)).tier,!(t<=this._host.game.village.sim.kittens[e].rank))){this._host.game.village.promoteKittens();return}}}autoPromoteLeader(){var s,e;if(this._host.game.science.get("civil").researched&&this._host.game.village.leader!==null){const t=this._host.game.village.leader,i=t.rank,n=this._workshopManager.getResource("gold"),a=this._workshopManager.getStock("gold");this._host.game.village.sim.goldToPromote(i,i+1,n.value-a)[0]&&this._host.game.village.sim.promote(t,i+1)===1&&(this._host.engine.iactivity("act.promote",[i+1],"ks-promote"),(s=this._host.game.villageTab.censusPanel)==null||s.census.renderGovernment(this._host.game.villageTab.censusPanel.census.container),(e=this._host.game.villageTab.censusPanel)==null||e.census.update(),this._host.engine.storeForSummary("promote",1))}}autoHunt(s){const e=this._workshopManager.getResource("manpower"),t=this.settings.hunt.trigger;if(!(e.value<100||this._host.game.challenges.isActive("pacifism"))&&t<=e.value/e.maxValue&&100<=e.value){const i=Math.floor(e.value/100);this._host.engine.storeForSummary("hunt",i),this._host.engine.iactivity("act.hunt",[this._host.renderAbsolute(i)],"ks-hunt");const n=this._workshopManager.getAverageHunt(),a={};for(const[r,o]of z(n)){const l=this._workshopManager.getResource(r);a[r]=0<l.maxValue?Math.min(o*i,Math.max(l.maxValue-l.value,0)):o*i}m(s)||s.pushToCache({materials:a,timeStamp:this._host.game.timer.ticksTotal}),this._host.game.village.huntAll()}}autoFestival(s){if(!this._host.game.science.get("drama").researched||400<this._host.game.calendar.festivalDays||!this._host.game.prestige.getPerk("carnivals").researched&&0<this._host.game.calendar.festivalDays)return;const e=this._workshopManager;if(e.getValueAvailable("manpower")<1500||e.getValueAvailable("culture")<5e3||e.getValueAvailable("parchment")<2500)return;const t=4e3*e.getTickVal(e.getResource("manpower"),s,!0)>1500,i=4e3*e.getTickVal(e.getResource("culture"),s,!0)>5e3,n=4e3*e.getTickVal(e.getResource("parchment"),s,!0)>2500;if(!(!t&&!i&&!n)&&(this.manager.render(),this._host.game.villageTab.festivalBtn.model.enabled)){const a=this._host.game.calendar.festivalDays;this._host.game.villageTab.festivalBtn.onClick(),this._host.engine.storeForSummary("festival"),a>0?this._host.engine.iactivity("festival.extend",[],"ks-festival"):this._host.engine.iactivity("festival.hold",[],"ks-festival")}}}const ps={"de-DE":un,"en-US":hn,"he-IL":dn,"zh-CN":gn};class re{constructor(s,e){u(this,"_i18nData");u(this,"_isLoaded",!1);u(this,"_host");u(this,"settings");u(this,"bonfireManager");u(this,"religionManager");u(this,"scienceManager");u(this,"spaceManager");u(this,"timeControlManager");u(this,"timeManager");u(this,"tradeManager");u(this,"villageManager");u(this,"workshopManager");u(this,"_activitySummary");u(this,"_timeoutMainLoop");this.settings=new cs,this._i18nData=ps,this.setLanguage(e,!1),this._host=s,this._activitySummary=new cn(this._host),this.workshopManager=new ei(this._host),this.bonfireManager=new ln(this._host,this.workshopManager),this.religionManager=new mn(this._host,this.bonfireManager,this.workshopManager),this.scienceManager=new wn(this._host,this.workshopManager),this.spaceManager=new Cn(this._host,this.workshopManager),this.timeControlManager=new Kn(this._host,this.bonfireManager,this.religionManager,this.spaceManager,this.workshopManager),this.timeManager=new Vn(this._host,this.workshopManager),this.tradeManager=new jn(this._host,this.workshopManager),this.villageManager=new Xn(this._host,this.workshopManager)}get isLoaded(){return this._isLoaded}isLanguageSupported(s){return Object.keys(this._i18nData).some(e=>e.startsWith(`${s}-`))}isLocaleSupported(s){return s in this._i18nData}localeSupportsFirstLetterSplits(s=this.settings.locale.selected){return s!=="zh-CN"}localeForLanguage(s){return Object.keys(this._i18nData).find(e=>e.startsWith(`${s}-`))}setLanguage(s,e=!0){const t=this.settings.locale.selected;if(!this.isLanguageSupported(s))console.warn(...v(`Requested language '${s}' is not available. Falling back to '${Te}'.`)),this.settings.locale.selected=Te;else{const i=p(this.localeForLanguage(s));console.info(...v(`Selecting language '${i}'.`)),this.settings.locale.selected=i}t!==this.settings.locale.selected&&e&&this._host.rebuildUi()}setLocale(s,e=!0){const t=this.settings.locale.selected;this.isLocaleSupported(s)?(console.info(...v(`Selecting language '${s}'.`)),this.settings.locale.selected=s):(console.warn(...v(`Requested language '${s}' is not available. Falling back to '${Te}'.`)),this.settings.locale.selected=Te),t!==this.settings.locale.selected&&e&&this._host.rebuildUi()}stateLoad(s,e=!1){this._isLoaded=!0,this.stop(!1);const t=Oe();s.v!==t&&console.warn(...v(`Attempting to load engine state with version tag '${s.v}' when engine is at version '${t}'!`));const i=(n,a)=>{try{n()}catch(r){console.error(...v(`Failed load of ${a} settings.`,r))}};i(()=>{this.settings.load(s.engine,e)},"engine"),i(()=>{this.bonfireManager.settings.load(s.bonfire)},"bonfire"),i(()=>{this.religionManager.settings.load(s.religion)},"religion"),i(()=>{this.scienceManager.settings.load(s.science)},"science"),i(()=>{this.spaceManager.settings.load(s.space)},"space"),i(()=>{this.timeControlManager.settings.load(s.timeControl)},"time control"),i(()=>{this.timeManager.settings.load(s.time)},"time"),i(()=>{this.tradeManager.settings.load(s.trade)},"trade"),i(()=>{this.villageManager.settings.load(s.village)},"village"),i(()=>{this.workshopManager.settings.load(s.workshop)},"workshop"),this.setLocale(this.settings.locale.selected),this.settings.enabled?this.start(!1):this.stop(!1)}static get DEFAULT_STATE(){return{bonfire:new Xt,engine:new cs,religion:new Yt,science:new Qt,space:new St,time:new ms,timeControl:new ds,trade:new fs,v:Oe(),village:new bs,workshop:new xt}}stateReset(){this.stateLoad(re.DEFAULT_STATE)}stateSerialize(){return{bonfire:this.bonfireManager.settings,engine:this.settings,religion:this.religionManager.settings,science:this.scienceManager.settings,space:this.spaceManager.settings,time:this.timeManager.settings,timeControl:this.timeControlManager.settings,trade:this.tradeManager.settings,v:Oe(),village:this.villageManager.settings,workshop:this.workshopManager.settings}}start(s=!0){if(this._timeoutMainLoop)return;const e=()=>{const t={entry:Date.now(),exit:0,measurements:{},requestGameUiRefresh:!1};this._iterate(t).then(()=>{t.exit=Date.now();const i=t.exit-t.entry;document.dispatchEvent(new CustomEvent("ks.reportFrame",{detail:t})),this._timeoutMainLoop!==void 0&&(this._timeoutMainLoop=T.window.setTimeout(e,Math.max(10,this._host.engine.settings.interval-i)))}).catch(i=>{console.warn(...v(Zs(i)))})};this._timeoutMainLoop=T.window.setTimeout(e,this._host.engine.settings.interval),s&&this._host.engine.imessage("status.ks.enable")}stop(s=!0){this._timeoutMainLoop&&(clearTimeout(this._timeoutMainLoop),this._timeoutMainLoop=void 0,s&&this._host.engine.imessage("status.ks.disable"))}async _iterate(s){this.settings.filters.disableKGLog.enabled||this._maintainKGLogFilters();let[,e]=await vt(()=>this.scienceManager.tick(s));s.measurements.scienceManager=e,[,e]=ye(()=>{this.bonfireManager.tick(s)}),s.measurements.bonfireManager=e,[,e]=ye(()=>{this.spaceManager.tick(s)}),s.measurements.spaceManager=e,[,e]=await vt(()=>this.workshopManager.tick(s)),s.measurements.workshopManager=e,[,e]=ye(()=>{this.tradeManager.tick(s)}),s.measurements.tradeManager=e,[,e]=await vt(()=>this.religionManager.tick(s)),s.measurements.religionManager=e,[,e]=ye(()=>{this.timeManager.tick(s)}),s.measurements.timeManager=e,[,e]=ye(()=>{this.villageManager.tick(s)}),s.measurements.villageManager=e,[,e]=await vt(()=>this.timeControlManager.tick(s)),s.measurements.timeControlManager=e,[,e]=ye(()=>{s.requestGameUiRefresh&&this._host.game.ui.render()}),s.measurements.gameUiRefresh=e}_maintainKGLogFilters(){for(const e of Object.values(this._host.game.console.filters))e.enabled=!1;const s=T.window.document.querySelectorAll("[id^=filter-]");for(const e of s)e.checked=!1}symbolForCycle(s){var e;return((e=this._host.game.calendar.cycles.find(t=>t.name===s))==null?void 0:e.uglyph)??""}labelForCycle(s){const e=this.symbolForCycle(s),t=this._host.engine.i18n(`$space.planet.${s==="redmoon"?"moon":s}.label`);return`${e} ${t}`}labelForPlanet(s){const e=s==="moon"?"redmoon":s,t=we.includes(e)?e:void 0,i=this._host.engine.i18n(`$space.planet.${s}.label`);return t===void 0?i:`${this.symbolForCycle(t)} ${i}`}i18n(s,e=[]){let t;if(s.startsWith("$")&&(t=this._host.i18nEngine(s.slice(1))),t=t??this._i18nData[this.settings.locale.selected][s],m(t)){if(t=ps[Te][s],!t)return console.warn(...v(`i18n key '${s}' not found in default language.`)),`$${s}`;console.warn(...v(`i18n key '${s}' not found in selected language.`))}for(let n=0;n<e.length;++n)t=t.replace(`{${n}}`,`${e[n]}`);return t}iactivity(s,e=[],t){const i=this.i18n(s,e);if(t){const n=`type_${t}`;this._printOutput(`ks-activity ${n}`,"#e65C00",i)}else this._printOutput("ks-activity","#e65C00",i)}imessage(s,e=[]){this._printOutput("ks-default","#aa50fe",this.i18n(s,e))}storeForSummary(s,e=1,t="other"){this._activitySummary.storeActivity(s,e,t)}getSummary(){return this._activitySummary.renderSummary()}displayActivitySummary(){const s=this.getSummary();for(const e of s)this._printOutput("ks-summary","#009933",e);this.resetActivitySummary()}resetActivitySummary(){this._activitySummary.resetActivity()}_printOutput(s,e,t){if(this.settings.filters.enabled){for(const n of Object.values(this.settings.filters.filters))if(n.variant===s&&!n.enabled)return}const i=this._host.game.msg(t,s);$(i.span).css("color",e),console.debug(...v(t))}static evaluateSubSectionTrigger(s,e){return s<0?e:e<0?s:e}}const vs=c=>Number.isFinite(c)?c:0,Yn=c=>({days:Math.trunc(c/864e5),hours:Math.trunc(c/36e5%24),minutes:Math.trunc(c/6e4%60),seconds:Math.trunc(c/1e3%60),milliseconds:Math.trunc(c%1e3),microseconds:Math.trunc(vs(c*1e3)%1e3),nanoseconds:Math.trunc(vs(c*1e6)%1e3)}),Qn=c=>({days:c/86400000n,hours:c/3600000n%24n,minutes:c/60000n%60n,seconds:c/1000n%60n,milliseconds:c%1000n,microseconds:0n,nanoseconds:0n}),ea=c=>{switch(typeof c){case"number":{if(Number.isFinite(c))return Yn(c);break}case"bigint":return Qn(c)}throw new TypeError("Expected a finite number or bigint")},ta=c=>c===0||c===0n,ia=(c,s)=>s===1||s===1n?c:`${c}s`,sa=1e-7,na=24n*60n*60n*1000n,aa=(c,s={colonNotation:!1,compact:!1,formatSubMilliseconds:!1,keepDecimalsOnWholeSeconds:!1,millisecondsDecimalDigits:0,secondsDecimalDigits:1,separateMilliseconds:!1,unitCount:1/0,verbose:!1})=>{const e=typeof c=="bigint";if(!e&&!Number.isFinite(c))throw new TypeError("Expected a finite number or bigint");const t={...s};t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let i=[];const n=(h,d)=>{const g=Math.floor(h*10**d+sa);return(Math.round(g)/10**d).toFixed(d)},a=(h,d,g,f)=>{if(!((i.length===0||!t.colonNotation)&&ta(h)&&!(t.colonNotation&&g==="m"))){if(f??(f=String(h)),t.colonNotation){const w=f.includes(".")?f.split(".")[0].length:f.length,b=i.length>0?2:1;f="0".repeat(Math.max(0,b-w))+f}else f+=t.verbose?" "+ia(d,h):g;i.push(f)}},r=ea(c),o=BigInt(r.days);if(a(o/365n,"year","y"),a(o%365n,"day","d"),a(Number(r.hours),"hour","h"),a(Number(r.minutes),"minute","m"),t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&c<1e3){const h=Number(r.seconds),d=Number(r.milliseconds),g=Number(r.microseconds),f=Number(r.nanoseconds);if(a(h,"second","s"),t.formatSubMilliseconds)a(d,"millisecond","ms"),a(g,"microsecond","µs"),a(f,"nanosecond","ns");else{const w=d+g/1e3+f/1e6,b=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,k=w>=1?Math.round(w):Math.ceil(w),y=b?w.toFixed(b):k.toString();a(Number.parseFloat(y),"millisecond","ms",y)}}else{const h=(e?Number(c%na):c)/1e3%60,d=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,g=n(h,d),f=t.keepDecimalsOnWholeSeconds?g:g.replace(/\.0+$/,"");a(Number.parseFloat(f),"second","s",f)}if(i.length===0)return"0"+(t.verbose?" milliseconds":"ms");const l=t.colonNotation?":":" ";return typeof t.unitCount=="number"&&(i=i.slice(0,Math.max(t.unitCount,1))),i.join(l)},A={Bonfire:"M80-80v-183l363-491-67-90 49-35 55 75 56-75 48 35-66 90 362 491v183H80Zm400-623L140-243v103h145l195-273 195 273h145v-103L480-703ZM359-140h242L480-310 359-140Zm121-273 195 273-195-273-195 273 195-273Z",CheckboxCheck:"m419-321 289-289-43-43-246 246-119-119-43 43 162 162ZM120-120v-720h720v720H120Zm60-60h600v-600H180v600Zm0 0v-600 600Z",CheckboxUnCheck:"M120-120v-720h720v720H120Zm60-60h600v-600H180v600Z",Copy:"M240-200v-680h560v680H240Zm60-60h440v-560H300v560ZM120-80v-680h60v620h500v60H120Zm180-180v-560 560Z",Cycles:"M120-80v-740h125v-60h65v60h340v-60h65v60h125v360h-60v-110H180v430h324v60H120ZM760 0q-73 0-127.5-45.5T564-160h62q13 44 49.5 72T760-60q58 0 99-41t41-99q0-58-41-99t-99-41q-29 0-54 10.5T662-300h58v60H560v-160h60v57q27-26 63-41.5t77-15.5q83 0 141.5 58.5T960-200q0 83-58.5 141.5T760 0ZM180-630h600v-130H180v130Zm0 0v-130 130Z",DataUsage:"M480-80q-82 0-155-31.5T197.5-197q-54.5-54-86-127T80-479q0-158 106.5-272T451-877v102q-115 11-192 95.5T182-479q0 124 87 210.5T480-182q72 0 136-32.5T725-306l88 51q-58 83-145.5 129T480-80Zm362-229-88-49q12-31 18-61.5t6-60.5q0-116-76.5-201T511-776v-102q157 11 263 124.5T880-484q0 45-9.5 88.5T842-309Z",Delete:"M201-120v-630h-41v-60h188v-30h264v30h188v60h-41v630H201Zm60-60h438v-570H261v570Zm106-86h60v-399h-60v399Zm166 0h60v-399h-60v399ZM261-750v570-570Z",Draft:"M160-80v-800h421l219 219v581H160Zm391-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z",Eco:"M213-175q-43.59-45-68.3-104Q120-338 120-400q0-73 25.5-133.5T222-645q35-35 87-59t122.5-37.5Q502-755 591-758.5t198 3.5q8 108 5.5 197.5t-16 160.75q-13.5 71.25-38 124.56Q716-218.87 680-183q-51 51-110 77T444-80q-69 0-126.5-23.5T213-175Zm103 0q25 17 58 26t69.92 9Q497-140 547-162t91-64q27-27 46-70.5t31-103Q727-459 731-534t0-165q-94-2-168.5 2.5T431-680q-57 12-98 30.5T266-604q-42 43-64 91t-22 98q0 48 20.5 100.5T251-230q53-98 127-176t157-123q-87 75-141 162.5T316-175Zm0 0Zm0 0Z",Edit:"M180-180h44l472-471-44-44-472 471v44Zm-60 60v-128l617-616 128 128-617 616H120Zm659-617-41-41 41 41Zm-105 64-22-22 44 44-22-22Z",ExpandCircleDown:"m480-351 173-173-43-42-130 130-130-130-43 42 173 173Zm0 271q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 31.5-156t86-127Q252-817 325-848.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82-31.5 155T763-197.5q-54 54.5-127 86T480-80Zm0-60q142 0 241-99.5T820-480q0-142-99-241t-241-99q-141 0-240.5 99T140-480q0 141 99.5 240.5T480-140Zm0-340Z",ExpandCircleUp:"m350-394 130-130 130 130 43-42-173-173-173 173 43 42ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-155.5t85.5-127q54-54.5 127-86T480-880q83 0 155.5 31.5t127 86q54.5 54.5 86 127T880-480q0 83-31.5 156t-86 127q-54.5 54-127 85.5T480-80Zm0-60q141 0 240.5-99T820-480q0-141-99.5-240.5T480-820q-142 0-241 99.5T140-480q0 142 99 241t241 99Zm0-340Z",Import:"M450-160v-371L330-411l-43-43 193-193 193 193-43 43-120-120v371h-60ZM160-597v-203h640v203h-60v-143H220v143h-60Z",Religion:"M40-120v-560q0-45.83 32.12-77.92 32.12-32.08 78-32.08T228-757.92q32 32.09 32 77.92v31l220-191 220 191v-31q0-45.83 32.12-77.92 32.12-32.08 78-32.08T888-757.92q32 32.09 32 77.92v560H530v-250H430v250H40Zm720-510h100v-49.82q0-21.18-14.32-35.68-14.33-14.5-35.5-14.5-21.18 0-35.68 14.37Q760-701.25 760-680v50Zm-660 0h100v-49.82q0-21.18-14.32-35.68-14.33-14.5-35.5-14.5-21.18 0-35.68 14.37Q100-701.25 100-680v50Zm0 450h100v-390H100v390Zm160 0h110v-250h220v250h110v-390L480-761 260-570v390Zm500 0h100v-390H760v390ZM479.94-505Q457-505 441-521.06q-16-16.06-16-39T441.06-599q16.06-16 39-16T519-598.94q16 16.06 16 39T518.94-521q-16.06 16-39 16Z",Reset:"M480-160q-133 0-226.5-93.5T160-480q0-133 93.5-226.5T480-800q85 0 149 34.5T740-671v-129h60v254H546v-60h168q-38-60-97-97t-137-37q-109 0-184.5 75.5T220-480q0 109 75.5 184.5T480-220q83 0 152-47.5T728-393h62q-29 105-115 169t-195 64Z",Resources:"M120-40v-880h60v80h600v-80h60v880h-60v-80H180v80h-60Zm60-469h110v-160h220v160h270v-271H180v271Zm0 329h270v-160h220v160h110v-269H180v269Zm170-329h100v-100H350v100Zm160 329h100v-100H510v100ZM350-509h100-100Zm160 329h100-100Z",Save:"M840-683v563H120v-720h563l157 157Zm-60 27L656-780H180v600h600v-476ZM479.76-245q43.24 0 73.74-30.26 30.5-30.27 30.5-73.5 0-43.24-30.26-73.74-30.27-30.5-73.5-30.5-43.24 0-73.74 30.26-30.5 30.27-30.5 73.5 0 43.24 30.26 73.74 30.27 30.5 73.5 30.5ZM233-584h358v-143H233v143Zm-53-72v476-600 124Z",SaveAs:"M120-120v-720h563l157 157v117l-60 60v-150L656-780H180v600h280v60H120Zm60-660v600-600ZM520-40v-123l263-262 122 122L643-40H520Zm300-263-37-37 37 37ZM580-100h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19ZM233-584h358v-143H233v143Zm247 339q14 0 27-3t24-10l39-40q7-11 10.5-24t3.5-27q0-43.33-30.26-73.67Q523.47-453 480.24-453q-43.24 0-73.74 30.26-30.5 30.27-30.5 73.5 0 43.24 30.33 73.74Q436.67-245 480-245Z",Seasons:"M306-394q-17 0-28.5-11.5T266-434q0-17 11.5-28.5T306-474q17 0 28.5 11.5T346-434q0 17-11.5 28.5T306-394Zm177 0q-17 0-28.5-11.5T443-434q0-17 11.5-28.5T483-474q17 0 28.5 11.5T523-434q0 17-11.5 28.5T483-394Zm170 0q-17 0-28.5-11.5T613-434q0-17 11.5-28.5T653-474q17 0 28.5 11.5T693-434q0 17-11.5 28.5T653-394ZM120-80v-740h125v-60h65v60h340v-60h65v60h125v740H120Zm60-60h600v-430H180v430Zm0-490h600v-130H180v130Zm0 0v-130 130Z",Settings:"m388-80-20-126q-19-7-40-19t-37-25l-118 54-93-164 108-79q-2-9-2.5-20.5T185-480q0-9 .5-20.5T188-521L80-600l93-164 118 54q16-13 37-25t40-18l20-127h184l20 126q19 7 40.5 18.5T669-710l118-54 93 164-108 77q2 10 2.5 21.5t.5 21.5q0 10-.5 21t-2.5 21l108 78-93 164-118-54q-16 13-36.5 25.5T592-206L572-80H388Zm48-60h88l14-112q33-8 62.5-25t53.5-41l106 46 40-72-94-69q4-17 6.5-33.5T715-480q0-17-2-33.5t-7-33.5l94-69-40-72-106 46q-23-26-52-43.5T538-708l-14-112h-88l-14 112q-34 7-63.5 24T306-642l-106-46-40 72 94 69q-4 17-6.5 33.5T245-480q0 17 2.5 33.5T254-413l-94 69 40 72 106-46q24 24 53.5 41t62.5 25l14 112Zm44-210q54 0 92-38t38-92q0-54-38-92t-92-38q-54 0-92 38t-38 92q0 54 38 92t92 38Zm0-130Z",Space:"m187-551 106 45q18-36 38.5-71t43.5-67l-79-16-109 109Zm154 81 133 133q57-26 107-59t81-64q81-81 119-166t41-192q-107 3-192 41T464-658q-31 31-64 81t-59 107Zm229-96q-20-20-20-49.5t20-49.5q20-20 49.5-20t49.5 20q20 20 20 49.5T669-566q-20 20-49.5 20T570-566Zm-15 383 109-109-16-79q-32 23-67 43.5T510-289l45 106Zm326-694q9 136-34 248T705-418l-2 2-2 2 22 110q3 15-1.5 29T706-250L535-78l-85-198-170-170-198-85 172-171q11-11 25-15.5t29-1.5l110 22q1-1 2-1.5t2-1.5q99-99 211-142.5T881-877ZM149-325q35-35 85.5-35.5T320-326q35 35 34.5 85.5T319-155q-26 26-80.5 43T75-80q15-109 31.5-164t42.5-81Zm42 43q-14 15-25 47t-19 82q50-8 82-19t47-25q19-17 19.5-42.5T278-284q-19-18-44.5-17.5T191-282Z",State:"M820-240v-480h60v480h-60Zm-340 1-43-42 169-169H80v-60h526L438-679l42-42 241 241-241 241Z",Summary:"M279-621h60v-60h-60v60Zm0 171h60v-60h-60v60Zm0 171h60v-60h-60v60ZM120-120v-720h522l198 198v522H120Zm60-60h600v-429H609v-171H180v600Zm0-600v171.43V-780v600-600Z",Sync:"M167-160v-60h130l-15-12q-64-51-93-111t-29-134q0-106 62.5-190.5T387-784v62q-75 29-121 96.5T220-477q0 63 23.5 109.5T307-287l30 21v-124h60v230H167Zm407-15v-63q76-29 121-96.5T740-483q0-48-23.5-97.5T655-668l-29-26v124h-60v-230h230v60H665l15 14q60 56 90 120t30 123q0 106-62 191T574-175Z",Time:"m627-287 45-45-159-160v-201h-60v225l174 181ZM480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-82 31.5-155t86-127.5Q252-817 325-848.5T480-880q82 0 155 31.5t127.5 86Q817-708 848.5-635T880-480q0 82-31.5 155t-86 127.5Q708-143 635-111.5T480-80Zm0-400Zm0 340q140 0 240-100t100-240q0-140-100-240T480-820q-140 0-240 100T140-480q0 140 100 240t240 100Z",Trigger:"m393-165 279-335H492l36-286-253 366h154l-36 255Zm-73 85 40-280H160l360-520h80l-40 320h240L400-80h-80Zm154-396Z",Workshop:"M768-120 517-371l57-57 251 251-57 57Zm-581 0-57-57 290-290-107-107-23 23-44-44v85l-24 24-122-122 24-24h86l-48-48 131-131q17-17 37-23t44-6q24 0 44 8.5t37 25.5L348-699l48 48-24 24 104 104 122-122q-8-13-12.5-30t-4.5-36q0-53 38.5-91.5T711-841q15 0 25.5 3t17.5 8l-85 85 75 75 85-85q5 8 8.5 19.5T841-709q0 53-38.5 91.5T711-579q-18 0-31-2.5t-24-7.5L187-120Z"},gt=class gt{constructor(s,e){u(this,"componentId");u(this,"host");u(this,"parent");u(this,"options");u(this,"_element");u(this,"children",new Set);u(this,"_needsRefresh");this.componentId=gt.nextComponentId++,this.host=s.host,this.options=e,this.parent=s instanceof gt?s:null,this._needsRefresh=!1}set element(s){this._element=s,this._element[0].id=`KS${Object.getPrototypeOf(this).constructor.name}#${this.componentId}`}get element(){return p(this._element)}requestRefresh(s=!1,e=0,t=!1){var i,n,a;if(t&&console.debug(...v(e<0?"⤒".repeat(e*-1):" ".repeat(e),this.toString(),"requestRefresh()")),(n=(i=this.options)==null?void 0:i.onRefreshRequest)==null||n.call(this),this.parent!==this&&!s&&((a=this.parent)==null||a.requestRefresh(!1,e-1,t)),this._needsRefresh&&t&&console.debug(...v(e<0?"⤒".repeat(e*-1):" ".repeat(e),this.toString(),"requestRefresh() <already pending>")),this._needsRefresh=!0,s){t&&console.debug(...v(e<0?"⤒".repeat(e*-1):" ".repeat(e),this.toString(),"requestRefresh()",`+ ${this.children.size} children`));for(const r of this.children)r.requestRefresh(!0,e+1,t)}else t&&console.debug(...v(e<0?"⤒".repeat(e*-1):" ".repeat(e),this.toString(),"requestRefresh()","<queued>"))}refresh(s=!1,e=0){var t,i;if(!s&&!this._needsRefresh){e===0&&console.debug(...v(this.toString(),"refresh() received and ignored."));return}(i=(t=this.options)==null?void 0:t.onRefresh)==null||i.call(this);for(const n of this.children)n.refresh(s,e+1);this._needsRefresh=!1}addChild(s){return s.parent=this,this.children.add(s),this.element.append(s.element),this}addChildren(s){for(const e of s??[])this.addChild(e);return this}removeChild(s){this.children.has(s)&&(s.element.remove(),this.children.delete(s))}removeChildren(s){for(const e of s)this.removeChild(e)}};u(gt,"nextComponentId",0);let G=gt;class M extends G{constructor(s,e){super(s,{...e}),this.element=$("<div/>");for(const t of(e==null?void 0:e.classes)??[])this.element.addClass(t)}toString(){return`[${M.name}#${this.componentId}]`}}const B={label:"_label_1nlev_1",splitter:"_splitter_1nlev_16",iconLabel:"_iconLabel_1nlev_20",fillSpace:"_fillSpace_1nlev_26"},ke={delimiter:"_delimiter_16hnh_1"};class he extends G{constructor(s,e){super(s,{...e}),this.element=$("<li/>");for(const t of(e==null?void 0:e.classes)??[])this.element.addClass(t);(e==null?void 0:e.delimiter)===!0&&this.element.addClass(ke.delimiter)}toString(){return`[${he.name}#${this.componentId}]`}}const Et={head:"_head_wr1pj_1"};class ue extends he{constructor(e,t,i){super(e,i);u(this,"head");u(this,"elementLabel");if(this.head=new M(e),this.head.element.addClass(Et.head),this.addChild(this.head),this.elementLabel=$("<label/>",{text:`${(i==null?void 0:i.upgradeIndicator)===!0?"⮤ ":""}${t}`}).addClass(B.label).addClass(Et.label),this.head.element.append(this.elementLabel),i!=null&&i.icon){const n=$("<div/>",{html:`<svg style="width: 15px; height: 15px;" viewBox="0 -960 960 960" fill="currentColor"><path d="${i.icon}"/></svg>`}).addClass(B.iconLabel);this.elementLabel.prepend(n)}}toString(){return`[${ue.name}#${this.componentId}]: '${this.elementLabel.text()}'`}addChildHead(e){return this.head.addChild(e),this}addChildrenHead(e){for(const t of e??[])this.head.addChild(t);return this}}const D={setting:"_setting_1ndg5_1",checkbox:"_checkbox_1ndg5_6",panelContent:"_panelContent_1ndg5_10",hidden:"_hidden_1ndg5_17",checked:"_checked_1ndg5_22",expanded:"_expanded_1ndg5_26",readonly:"_readonly_1ndg5_34"};class S extends ue{constructor(e,t,i,n){super(e,i,{...n,onRefresh:()=>{var o;this.setting.enabled?this.element.addClass(D.checked):this.element.removeClass(D.checked),this.readOnly?this.element.addClass(D.readonly):this.element.removeClass(D.readonly),m(this.checkbox)||(this.checkbox.prop("checked",this.setting.enabled),this.checkbox.prop("disabled",this.readOnly)),(o=n==null?void 0:n.onRefresh)==null||o.call(n)}});u(this,"setting");u(this,"checkbox");u(this,"readOnly");this.element.addClass(D.setting);const a=`ks-setting${this.componentId}`,r=$("<input/>",{id:a,type:"checkbox"}).addClass(D.checkbox);this.readOnly=(n==null?void 0:n.readOnly)??!1,r.prop("disabled",this.readOnly),r.on("change",o=>{r.is(":checked")&&!t.enabled?this.check().catch(R(console)):!r.is(":checked")&&t.enabled&&this.uncheck().catch(R(console))}),this.elementLabel.before(r),this.elementLabel.prop("for",a),this.checkbox=r,this.setting=t}toString(){return`[${S.name}#${this.componentId}]: '${this.elementLabel.text()}'`}async check(e=!1){var t,i;this.setting.enabled=!0,await((i=(t=this.options)==null?void 0:t.onCheck)==null?void 0:i.call(e)),this.requestRefresh()}async uncheck(e=!1){var t;this.setting.enabled=!1,await((t=this.options.onUnCheck)==null?void 0:t.call(e)),this.requestRefresh()}}const C={iconButton:"_iconButton_q7zpt_17",inactive:"_inactive_q7zpt_29",ineffective:"_ineffective_q7zpt_37",button:"_button_q7zpt_43",readonly:"_readonly_q7zpt_67",buttonIcon:"_buttonIcon_q7zpt_72",alignRight:"_alignRight_q7zpt_77",large:"_large_q7zpt_81",bordered:"_bordered_q7zpt_85",headAction:"_headAction_q7zpt_97",lastHeadAction:"_lastHeadAction_q7zpt_100",consumeButton:"_consumeButton_q7zpt_104",stockButton:"_stockButton_q7zpt_107"};class ie extends G{constructor(e,t,i,n){super(e,{...n,onRefresh:()=>{var a;this.readOnly?this.element.addClass(C.readonly):this.element.removeClass(C.readonly),this.inactive?this.element.addClass(C.inactive):this.element.removeClass(C.inactive),(a=n==null?void 0:n.onRefresh)==null||a.call(n)}});u(this,"readOnly");u(this,"inactive");this.element=$("<div/>",{html:`<svg style="width: 18px; height: 18px;" viewBox="0 -960 960 960" fill="currentColor"><path d="${t}"/></svg>`,title:i}).addClass(C.iconButton),this.readOnly=(n==null?void 0:n.readOnly)??!1,this.inactive=(n==null?void 0:n.inactive)??!1,this.element.on("click",()=>{this.readOnly||this.click().catch(R(console))})}toString(){return`[${ie.name}#${this.componentId}]`}async click(){var e,t;this.readOnly||(await((t=(e=this.options)==null?void 0:e.onClick)==null?void 0:t.call(this)),this.requestRefresh())}}const Rt={listContainer:"_listContainer_1kxbq_1",itemsList:"_itemsList_1kxbq_5",list:"_list_1kxbq_1",listTools:"_listTools_1kxbq_9"};class x extends G{constructor(e,t){super(e,{...t});u(this,"list");u(this,"disableAllButton");u(this,"enableAllButton");u(this,"resetButton");const i={hasDisableAll:!0,hasEnableAll:!0,...t},n=i.hasDisableAll||i.hasEnableAll||!m(i.onReset);if(this.element=$("<div/>").addClass(Rt.listContainer),this.list=$("<ul/>").addClass(Rt.list).addClass(Rt.itemsList),this.element.append(this.list),n){const a=new M(this,{classes:[Rt.listTools]});i.hasEnableAll&&(this.enableAllButton=new ie(e,A.CheckboxCheck,e.host.engine.i18n("ui.enable.all"),{onClick:async()=>{var l;const o=new Event("enableAll",{cancelable:!0});if(this.element[0].dispatchEvent(o),!o.defaultPrevented){for(const h of this.children)ve(h,S)&&await h.check(!0);(l=t==null?void 0:t.onEnableAll)==null||l.call(this)}}}),a.addChild(this.enableAllButton)),i.hasDisableAll&&(this.disableAllButton=new ie(e,A.CheckboxUnCheck,e.host.engine.i18n("ui.disable.all"),{onClick:async()=>{var l;const o=new Event("disableAll",{cancelable:!0});if(this.element[0].dispatchEvent(o),!o.defaultPrevented){for(const h of this.children)ve(h,S)&&await h.uncheck(!0);(l=t==null?void 0:t.onDisableAll)==null||l.call(this)}}}),a.addChild(this.disableAllButton));const r=i.onReset;m(r)||(this.resetButton=new ie(e,A.Reset,e.host.engine.i18n("ui.reset"),{onClick:()=>{r()}}),a.addChild(this.resetButton)),super.addChild(a)}}toString(){return`[${x.name}#${this.componentId}]`}addChild(e){return e.parent=this,this.children.add(e),this.list.append(e.element),this}}const Ae={expandoButton:"_expandoButton_l1ukp_1",expanded:"_expanded_l1ukp_1",up:"_up_l1ukp_1",down:"_down_l1ukp_4"};class Mt extends G{constructor(e,t){super(e,{...t,onRefresh:()=>{var i;this.ineffective?this.element.addClass(C.ineffective):this.element.removeClass(C.ineffective),(i=t==null?void 0:t.onRefresh)==null||i.call(t)}});u(this,"readOnly");u(this,"inactive");u(this,"ineffective");this.element=$("<div/>",{html:`
39
- <svg style="width: 18px; height: 18px;" viewBox="0 -960 960 960" fill="currentColor" class="${Ae.down}"><path d="${A.ExpandCircleDown}"/></svg>
40
- <svg style="width: 18px; height: 18px;" viewBox="0 -960 960 960" fill="currentColor" class="${Ae.up}"><path d="${A.ExpandCircleUp}"/></svg>
41
- `,title:e.host.engine.i18n("ui.itemsShow")}).addClass(C.iconButton).addClass(Ae.expandoButton),this.element.on("click",()=>{this.readOnly||this.click().catch(R(console))}),this.readOnly=(t==null?void 0:t.readOnly)??!1,this.inactive=(t==null?void 0:t.inactive)??!1,this.ineffective=!1}toString(){return`[${Mt.name}#${this.componentId}]`}setCollapsed(){this.element.removeClass(Ae.expanded),this.element.prop("title",this.host.engine.i18n("ui.itemsShow"))}setExpanded(){this.element.addClass(Ae.expanded),this.element.prop("title",this.host.engine.i18n("ui.itemsHide"))}async click(){var e,t;this.readOnly||(await((t=(e=this.options)==null?void 0:e.onClick)==null?void 0:t.call(this)),this.requestRefresh())}}class _e extends G{constructor(e,t,i){super(e,i);u(this,"container");u(this,"expando");u(this,"head");u(this,"_mainChildVisible");this.head=t,this.container=new M(this),this.container.element.addClass(D.panelContent);const n=new Mt(e,{onClick:()=>this.toggle()});t.head.addChild(n),t.element.append(this.container.element),i!=null&&i.initiallyExpanded?(this.container.element.removeClass(D.hidden),n.setExpanded()):this.container.element.addClass(D.hidden),this._mainChildVisible=(i==null?void 0:i.initiallyExpanded)??!1,this.element=t.element,this.expando=n,this.addChildren([this.head,this.container])}get isExpanded(){return this._mainChildVisible}toString(){return`[${_e.name}#${this.componentId}]`}addChildHead(e){return this.head.addChild(e),this}addChildrenHead(e){for(const t of e??[])this.head.addChild(t);return this}addChildContent(e){return this.container.addChild(e),this}addChildrenContent(e){for(const t of e??[])this.container.addChild(t);return this}toggle(e=void 0,t=!1){const i=e!==void 0?e:!this._mainChildVisible;if(i!==this._mainChildVisible&&(this._mainChildVisible=i,this._mainChildVisible?(this.container.requestRefresh(!0),this.container.element.removeClass(D.hidden),this.expando.setExpanded(),this.head.element.addClass(D.expanded),this.element[0].dispatchEvent(new CustomEvent("panelShown"))):(this.container.element.addClass(D.hidden),this.expando.setCollapsed(),this.head.element.removeClass(D.expanded),this.element[0].dispatchEvent(new CustomEvent("panelHidden")))),t){const n=a=>{for(const r of a)ve(r,_e)?r.toggle(e,t):n(r.children)};n(this.children)}}}class N extends _e{constructor(e,t,i,n){super(e,i,n);u(this,"setting");u(this,"settingItem");this.element=i.element,this.settingItem=i,this.setting=t}get isExpanded(){return this._mainChildVisible}get elementLabel(){return this.head.element}get readOnly(){return!0}set readOnly(e){}async check(){this.setting.enabled=!0,this.requestRefresh()}async uncheck(){this.setting.enabled=!1,this.requestRefresh()}toString(){return`[${N.name}#${this.componentId}]: '${this.settingItem.elementLabel.text()}'`}}class ra extends N{constructor(s,e,t,i){const n=s.host.engine.i18n("ui.upgrade.buildings");super(s,e,new S(s,e,n,{onCheck:o=>{s.host.engine.imessage("status.auto.enable",[n])},onUnCheck:o=>{s.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(s,{classes:[B.fillSpace]})]),{onRefreshRequest:()=>{this.expando.ineffective=i.enabled&&e.enabled&&!Object.values(e.buildings).some(o=>o.enabled)}});const a=[];for(const o of Object.values(this.setting.buildings)){const l=this.host.engine.i18n(`$buildings.${o.upgrade}.label`),h=new S(this,o,l,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[l])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[l])}});a.push({button:h,label:l})}a.sort((o,l)=>o.label.localeCompare(l.label));const r=new x(this);for(const o of a)r.addChild(o.button);this.addChildContent(r)}}class J extends G{constructor(e,t,i=null,n){super(e,{...n,onRefresh:()=>{var a;this.readOnly?this.element.addClass(C.readonly):this.element.removeClass(C.readonly),this.inactive?this.element.addClass(C.inactive):this.element.removeClass(C.inactive),this.ineffective?this.element.addClass(C.ineffective):this.element.removeClass(C.ineffective),(a=n==null?void 0:n.onRefresh)==null||a.call(n)}});u(this,"_iconElement");u(this,"readOnly");u(this,"inactive");u(this,"ineffective");this.element=$("<div/>",{title:n==null?void 0:n.title}).addClass(C.button).text(t),(n==null?void 0:n.border)!==!1&&this.element.addClass(C.bordered),(n==null?void 0:n.alignment)==="right"&&this.element.addClass(C.alignRight),i!==null&&(this._iconElement=$(`<svg class="${C.buttonIcon}" style="width: 18px; height: 18px;" viewBox="0 -960 960 960" fill="currentColor"><path d="${i}"/></svg>`),(n==null?void 0:n.alignment)==="right"?this.element.append(this._iconElement):this.element.prepend(this._iconElement));for(const a of(n==null?void 0:n.classes)??[])this.element.addClass(a);this.element.on("click",()=>{this.readOnly||this.click().catch(R(console))}),this.readOnly=(n==null?void 0:n.readOnly)??!1,this.inactive=(n==null?void 0:n.inactive)??!1,this.ineffective=!1}toString(){return`[${J.name}#${this.componentId}]`}updateLabel(e){this.element.text(e),this._iconElement!==void 0&&(this.options.alignment==="right"?this.element.append(this._iconElement):this.element.prepend(this._iconElement))}updateTitle(e){this.element.prop("title",e)}async click(){var e,t;this.readOnly||(await((t=(e=this.options)==null?void 0:e.onClick)==null?void 0:t.call(this)),this.requestRefresh())}}class te extends G{constructor(s){super(s,{}),this.element=$("<div/>").addClass(ke.delimiter)}toString(){return`[${te.name}#${this.componentId}]`}}const ys={dialog:"_dialog_1276o_1",close:"_close_1276o_7"},ws={explainer:"_explainer_1idu3_1"},oa={header:"_header_19ql8_1"};class q extends G{get elementLabel(){return this.element}constructor(s,e,t){super(s,{...t}),this.element=$("<li/>",{text:e}).addClass(oa.header)}toString(){return`[${q.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class ti extends G{constructor(s,e){super(s,{...e}),this.element=$('<input type="text"/>').addClass("ks-input");for(const t of(e==null?void 0:e.classes)??[])this.element.addClass(t);e!=null&&e.onChange&&this.element.on("change",()=>{var t;return(t=e.onChange)==null?void 0:t.call(e,this.element[0].value)}),e!=null&&e.value&&(this.element[0].value=e.value),e!=null&&e.selected&&(this.element[0].selectionStart=0,this.element[0].selectionEnd=-1),this.element.on("keyup",t=>{var i,n;switch(t.key){case"Enter":(i=e==null?void 0:e.onEnter)==null||i.call(e,this.element[0].value);break;case"Escape":(n=e==null?void 0:e.onEscape)==null||n.call(e,this.element[0].value);break}})}toString(){return`[${ti.name}#${this.componentId}]`}}class Bt extends G{constructor(s,e,t){super(s,{...t}),this.element=$("<p/>").text(e);for(const i of(t==null?void 0:t.classes)??[])this.element.addClass(i)}toString(){return`[${Bt.name}#${this.componentId}]`}}const ks={toolbar:"_toolbar_1654f_1"};class E extends G{constructor(e,t){super(e,{...t});u(this,"container");u(this,"head");u(this,"returnValue");this.element=$("<dialog/>").addClass("dialog").addClass("help").addClass(ys.dialog),(t==null?void 0:t.hasClose)!==!1&&this.addChild(new J(e,"close",null,{classes:[ys.close],onClick:()=>{var i;this.close(),(i=t==null?void 0:t.onCancel)==null||i.call(t)}})),this.returnValue=(t==null?void 0:t.promptValue)??"",this.head=new M(e),this.container=new M(e),this.addChildren(ft([this.head,t!=null&&t.prompt?new ti(e,{onChange:i=>{this.returnValue=i},onEnter:i=>{var n;this.returnValue=i,this.close(),(n=t.onConfirm)==null||n.call(t,this.returnValue)},onEscape:i=>{var n;this.close(),(n=t.onCancel)==null||n.call(t)},selected:!0,value:t.promptValue}):void 0,this.container,new te(e),new M(e,{classes:[ks.toolbar]}).addChildren(ft([new J(e,"OK",null,{classes:[C.large],onClick:()=>{var i;this.close(),(i=t==null?void 0:t.onConfirm)==null||i.call(t,this.returnValue)}}),t!=null&&t.hasCancel?new J(e,"Cancel",null,{classes:[C.large],onClick:()=>{var i;this.close(),(i=t.onCancel)==null||i.call(t)}}):void 0]))]))}toString(){return`[${E.name}#${this.componentId}]`}addChildHead(e){return this.head.addChild(e),this}addChildrenHead(e){for(const t of e??[])this.head.addChild(t);return this}addChildContent(e){return this.container.addChild(e),this}addChildrenContent(e){for(const t of e??[])this.container.addChild(t);return this}show(){$("#gamePageContainer").append(this.element),this.element[0].show()}showModal(){$("#gamePageContainer").append(this.element),this.element[0].showModal()}close(){this.element[0].close(),this.element.remove()}static async prompt(e,t,i,n,a){return new Promise(r=>{new E(e,{hasCancel:!0,hasClose:!1,onCancel:()=>{r(void 0)},onConfirm:o=>{r(o)},prompt:!0,promptValue:n}).addChildrenHead(ft([i?new q(e,i):void 0,new Bt(e,t)])).addChildrenContent(a?[new M(e,{classes:[ws.explainer]}).addChildren([new Bt(e,a)])]:[]).showModal()})}}const la={maxButton:"_maxButton_133h2_1"};class Pe extends J{constructor(e,t,i){super(e,"",null,{...i,classes:[la.maxButton,...(i==null?void 0:i.classes)??[]]});u(this,"setting");this.setting=t}toString(){return`[${Pe.name}#${this.componentId}]`}}class Ee extends J{constructor(e,t,i,n){super(e,"",A.Trigger,{...n,onRefresh:()=>{var r,o;const a=this.behavior==="integer"?this.host.renderAbsolute(this.setting.trigger,"invariant"):this.host.renderPercentage(this.setting.trigger,"invariant",!0);this.updateTitle(this.host.engine.i18n("ui.trigger",[a])),(((r=this.options)==null?void 0:r.renderLabel)??!0)&&this.updateLabel(a),this.inactive?this.element.addClass(C.inactive):this.element.removeClass(C.inactive),(o=n==null?void 0:n.onRefresh)==null||o.call(this)}});u(this,"behavior");u(this,"setting");this.behavior=t instanceof V?"percentage":"integer",this.setting=t}toString(){return`[${Ee.name}#${this.componentId}]`}}class At extends S{constructor(e,t,i,n,a){super(e,t,n,a);u(this,"maxButton");u(this,"triggerButton");this.maxButton=new Pe(e,t,{alignment:"right",border:!1,classes:[C.headAction],onClick:async()=>{await a.onSetMax.call(this)},onRefresh:a!=null&&a.onRefreshMax?()=>{var r;return(r=a.onRefreshMax)==null?void 0:r.call(this)}:void 0}),this.triggerButton=new Ee(e,t,i,{border:!1,classes:[C.lastHeadAction],onClick:async()=>{await a.onSetTrigger.call(this)},onRefresh:a!=null&&a.onRefreshTrigger?()=>{var r;return(r=a.onRefreshTrigger)==null?void 0:r.call(this)}:void 0,renderLabel:(a==null?void 0:a.renderLabelTrigger)??!0}),this.addChildrenHead([new M(e,{classes:[B.fillSpace]}),this.maxButton,this.triggerButton])}toString(){return`[${At.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}const oe={getBuildOption:(c,s,e,t,i,n,a)=>{const r=async()=>{const l=await E.prompt(c,c.host.engine.i18n("ui.max.prompt.absolute"),c.host.engine.i18n("ui.max.build.prompt",[i,c.host.renderAbsolute(s.max,e.selected)]),c.host.renderAbsolute(s.max),c.host.engine.i18n("ui.max.build.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){s.max=-1;return}l==="0"&&(s.enabled=!1),s.max=c.host.parseAbsolute(l)??s.max}},o=new At(c,s,e,i,{delimiter:a==null?void 0:a.delimiter,onCheck:async l=>{var h;c.host.engine.imessage("status.sub.enable",[i]),s.max===0&&!l&&await r(),await((h=a==null?void 0:a.onCheck)==null?void 0:h.call(a,l))},onRefreshMax:()=>{o.maxButton.updateLabel(c.host.renderAbsolute(s.max)),o.maxButton.element[0].title=s.max<0?c.host.engine.i18n("ui.max.build.titleInfinite",[i]):s.max===0?c.host.engine.i18n("ui.max.build.titleZero",[i]):c.host.engine.i18n("ui.max.build.title",[c.host.renderAbsolute(s.max),i])},onRefreshRequest:()=>{o.maxButton.inactive=!s.enabled||s.max===-1,o.maxButton.ineffective=t.enabled&&s.enabled&&s.max===0,o.triggerButton.inactive=!s.enabled||s.trigger===-1,o.triggerButton.ineffective=t.enabled&&s.enabled&&t.trigger===-1&&s.trigger===-1},onRefreshTrigger:()=>{o.triggerButton.element[0].title=c.host.engine.i18n("ui.trigger",[s.trigger<0?t.trigger<0?c.host.engine.i18n("ui.trigger.build.blocked",[n]):`${c.host.renderPercentage(t.trigger,e.selected,!0)} (${c.host.engine.i18n("ui.trigger.build.inherited")})`:c.host.renderPercentage(s.trigger,e.selected,!0)])},onSetMax:r,onSetTrigger:async()=>{var h;const l=await E.prompt(c,c.host.engine.i18n("ui.trigger.prompt.percentage"),c.host.engine.i18n("ui.trigger.build.prompt",[i,s.trigger!==-1?c.host.renderPercentage(s.trigger,e.selected,!0):c.host.engine.i18n("ui.trigger.build.inherited")]),s.trigger!==-1?c.host.renderPercentage(s.trigger):"",c.host.engine.i18n("ui.trigger.build.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){s.trigger=-1;return}s.trigger=c.host.parsePercentage(l),await((h=a==null?void 0:a.onSetTrigger)==null?void 0:h.call(void 0))}},onUnCheck:l=>{var h;c.host.engine.imessage("status.sub.disable",[i]),(h=a==null?void 0:a.onUnCheck)==null||h.call(a,l)},renderLabelTrigger:a==null?void 0:a.renderLabelTrigger,upgradeIndicator:a==null?void 0:a.upgradeIndicator});return o}};class H extends S{constructor(e,t,i,n,a){super(e,t,n,a);u(this,"triggerButton");this.triggerButton=new Ee(e,t,i,{alignment:"right",border:!1,onClick:async()=>{await a.onSetTrigger.call(this)},onRefresh:a!=null&&a.onRefreshTrigger?()=>{var r;return(r=a.onRefreshTrigger)==null?void 0:r.call(this)}:void 0,renderLabel:(a==null?void 0:a.renderLabelTrigger)??!0}),this.addChildrenHead([new M(e,{classes:[B.fillSpace]}),this.triggerButton])}toString(){return`[${H.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class ii extends N{constructor(s,e,t){console.debug(...v(`Constructing ${ii.name}`));const i=s.host.engine.i18n("ui.build");super(s,e,new H(s,e,t,i,{onCheck:n=>{s.host.engine.imessage("status.auto.enable",[i])},onRefreshTrigger:()=>{this.settingItem.triggerButton.element[0].title=s.host.engine.i18n("ui.trigger.section",[e.trigger<0?s.host.engine.i18n("ui.trigger.section.inactive"):s.host.renderPercentage(e.trigger,t.selected,!0)])},onSetTrigger:async()=>{const n=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.percentage"),s.host.engine.i18n("ui.trigger.section.prompt",[i,e.trigger!==-1?s.host.renderPercentage(e.trigger,t.selected,!0):s.host.engine.i18n("ui.infinity")]),e.trigger!==-1?s.host.renderPercentage(e.trigger):"",s.host.engine.i18n("ui.trigger.section.promptExplainer"));if(n!==void 0){if(n===""||n.startsWith("-")){e.trigger=-1;return}e.trigger=s.host.parsePercentage(n)}},onUnCheck:n=>{s.host.engine.imessage("status.auto.disable",[i])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled||e.trigger<0,this.settingItem.triggerButton.ineffective=e.enabled&&e.trigger<0&&Object.values(e.buildings).some(n=>n.enabled&&0<n.max&&n.trigger<0),this.expando.ineffective=e.enabled&&Object.values(e.buildings).some(n=>n.enabled&&(n.max===0||n.trigger<0&&e.trigger<0))}}),this.addChildrenContent([new x(this,{onReset:()=>{this.setting.load({buildings:new Xt().buildings})}}).addChildren(ft(this.host.game.bld.buildingGroups.flatMap(n=>[new q(this,n.title),...n.buildings.flatMap(a=>this._getBuildOptions(this,e,t,i,a)),n!==this.host.game.bld.buildingGroups[this.host.game.bld.buildingGroups.length-1]?new te(this):void 0]))),new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new q(this,this.host.engine.i18n("ui.additional")),new S(this,e.gatherCatnip,this.host.engine.i18n("option.catnip"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.catnip")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.catnip")])}}),new S(this,e.turnOnSteamworks,this.host.engine.i18n("option.steamworks"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.steamworks")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.steamworks")])}}),new S(this,e.turnOnMagnetos,this.host.engine.i18n("option.magnetos"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.magnetos")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.magnetos")])}}),new S(this,e.turnOnReactors,this.host.engine.i18n("option.reactors"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.reactors")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.reactors")])}}),new ra(this,e.upgradeBuildings,t,e)])])}_getBuildOptions(s,e,t,i,n){var r;if(n==="unicornPasture"||m(e.buildings[n]))return[];const a=s.host.game.bld.getBuildingExt(n).meta;if(!m(a.stages)){const o=(r=Object.values(e.buildings).find(l=>l.baseBuilding===n))==null?void 0:r.building;return[oe.getBuildOption(s,e.buildings[n],t,e,a.stages[0].label,i,{renderLabelTrigger:!1}),oe.getBuildOption(s,e.buildings[o],t,e,a.stages[1].label,i,{renderLabelTrigger:!1,upgradeIndicator:!0})]}return m(a.label)?[]:[oe.getBuildOption(s,e.buildings[n],t,e,a.label,i,{renderLabelTrigger:!1})]}}class ca extends S{constructor(e,t){const i=X(e.host.engine.i18n("ui.engine"));super(e,t,i,{onCheck:()=>{e.host.engine.start(!0)},onUnCheck:()=>{e.host.engine.stop(!0)}});u(this,"expando");this.expando=new Mt(this),this.addChildrenHead([new M(e,{classes:[B.fillSpace]}),this.expando])}}class si extends he{constructor(e,t,i){super(e,{...i});u(this,"button");this.button=t,this.element.addClass(Et.head),this.element.append(t.element)}}const ha={fieldset:"_fieldset_tfwil_1"};class ni extends G{constructor(s,e,t){super(s,{...t}),this.element=$("<fieldset/>").addClass(ha.fieldset),t!=null&&t.delimiter&&this.element.addClass(ke.delimiter);const i=$("<legend/>").text(e).addClass(B.label);this.element.append(i)}toString(){return`[${ni.name}#${this.componentId}]`}}class ai extends G{constructor(e,t,i,n,a){super(e,{...a,onRefresh:()=>{this.input.prop("disabled",this.readOnly)}});u(this,"setting");u(this,"option");u(this,"elementLabel");u(this,"input");u(this,"readOnly");this.element=$("<div/>"),this.element.addClass(D.setting),(a==null?void 0:a.delimiter)===!0&&this.element.addClass(ke.delimiter),this.elementLabel=$("<label/>",{text:`${a!=null&&a.upgradeIndicator?"⮤ ":""}${i.label}`}).addClass(B.label);const r=$("<input/>",{name:n,type:"radio"}).addClass("ks-radio");this.readOnly=(a==null?void 0:a.readOnly)??!1,r.on("change",()=>{this.setting.selected=i.value,m(a==null?void 0:a.onCheck)||a.onCheck()}),this.elementLabel.prepend(r),this.element.append(this.elementLabel),this.input=r,this.setting=t,this.option=i}toString(){return`[${ai.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class Ie extends G{constructor(e,t,i,n){super(e,{...n,onRefresh:()=>{var a;for(const r of this._items)if(r.option.value===this.setting.selected){r.input.prop("checked",!0);break}(a=n==null?void 0:n.onRefresh)==null||a.call(n)}});u(this,"fieldset");u(this,"setting");u(this,"_items");this.element=$("<li/>"),this.fieldset=new ni(e,t),this.addChild(this.fieldset),this._items=new Array;for(const a of i.options)this._items.push(new ai(e,i,a,t,{onCheck:n==null?void 0:n.onCheck,readOnly:n==null?void 0:n.readOnly}));this.fieldset.addChildren(this._items),this.setting=i}toString(){return`[${Ie.name}#${this.componentId}]`}}const ua={textButton:"_textButton_1mv97_1"};class Ce extends G{constructor(e,t,i){super(e,{...i,onRefresh:()=>{var a;this.readOnly?this.element.addClass(C.readonly):this.element.removeClass(C.readonly),(a=i==null?void 0:i.onRefresh)==null||a.call(this)}});u(this,"readOnly");this.element=$("<div/>").addClass(ua.textButton),t!==void 0&&this.element.text(t);const n=i==null?void 0:i.title;m(n)||this.element.prop("title",n),this.readOnly=!1,this.element.on("click",()=>{this.readOnly||this.click().catch(R(console))})}toString(){return`[${Ce.name}#${this.componentId}]`}async click(){var e,t;this.readOnly||(await((t=(e=this.options)==null?void 0:e.onClick)==null?void 0:t.call(this)),this.requestRefresh())}}class ri extends N{constructor(s,e,t){console.debug(...v(`Constructing ${ri.name}`)),super(s,e,new ue(s,s.host.engine.i18n("ui.internals"),{classes:[D.checked,D.setting],icon:A.Settings}).addChildrenHead([new M(s,{classes:[B.fillSpace]})])),this.addChildrenContent([new x(s,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new si(s,new Ce(s,s.host.engine.i18n("ui.internals.interval",[e.interval]),{onClick:async()=>{const i=await E.prompt(s,s.host.engine.i18n("ui.internals.interval.prompt"),s.host.engine.i18n("ui.internals.interval.promptTitle",[s.host.renderAbsolute(e.interval,t.selected)]),s.host.renderAbsolute(e.interval),s.host.engine.i18n("ui.internals.interval.promptExplainer"));i===void 0||i===""||i.startsWith("-")||(i==="0"&&(e.enabled=!1),e.interval=s.host.parseAbsolute(i)??e.interval)},onRefresh(){this.element.text(s.host.engine.i18n("ui.internals.interval",[e.interval]))}})),new te(s),new S(s,e.ksColumn,s.host.engine.i18n("ui.ksColumn"),{onCheck:()=>{s.host.rebuildUi()},onUnCheck:()=>{s.host.rebuildUi()}}),new te(s),new Ie(s,s.host.engine.i18n("ui.language"),e.locale,{onCheck:()=>{s.host.rebuildUi()}}),new te(s),new ue(s,`Kitten Scientists ${Oe("v")}`)])])}}class oi extends G{constructor(s,e,t){super(s,{...t}),this.element=$("<li/>",{text:s.host.engine.i18n(e)}).addClass(ws.explainer)}toString(){return`[${oi.name}#${this.componentId}]`}}class li extends N{constructor(s,e){console.debug(...v(`Constructing ${li.name}`));const t=s.host.engine.i18n("ui.filter");super(s,e,new S(s,e,t,{onCheck:n=>{s.host.engine.imessage("status.auto.enable",[t])},onUnCheck:n=>{s.host.engine.imessage("status.auto.disable",[t])}}).addChildrenHead([new M(s,{classes:[B.fillSpace]})])),this.addChildContent(new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new S(this,e.disableKGLog,this.host.engine.i18n("filter.allKG"))]));const i=new x(this).addChildren(os.map(n=>({label:this.host.engine.i18n(`filter.${n}`),name:n})).sort((n,a)=>n.label.localeCompare(a.label)).map(n=>new S(this,this.setting.filters[n.name],n.label,{onCheck:()=>{this.host.engine.imessage("filter.enable",[n.label])},onUnCheck:()=>{this.host.engine.imessage("filter.disable",[n.label])}})));this.addChildContent(i),this.addChildContent(new oi(this,"filter.explainer"))}}const Pt={active:"_active_6c09s_16"};class ci extends N{constructor(e,t,i){console.debug(...v(`Constructing ${ci.name}`));const n=e.host.engine.i18n("ui.faith");super(e,t,new H(e,t,i,n,{onCheck:r=>{e.host.engine.imessage("status.auto.enable",[n])},onRefreshTrigger(){this.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger.section",[t.trigger<0?e.host.engine.i18n("ui.trigger.section.inactive"):e.host.renderPercentage(t.trigger,i.selected,!0)])},onSetTrigger:async()=>{const r=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.percentage"),e.host.engine.i18n("ui.trigger.section.prompt",[n,t.trigger!==-1?e.host.renderPercentage(t.trigger,i.selected,!0):e.host.engine.i18n("ui.infinity")]),t.trigger!==-1?e.host.renderPercentage(t.trigger):"",e.host.engine.i18n("ui.trigger.section.promptExplainer"));if(r!==void 0){if(r===""||r.startsWith("-")){t.trigger=-1;return}t.trigger=e.host.parsePercentage(r)}},onUnCheck:r=>{e.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefresh:()=>{for(const[r,o]of this._unicornBuildings.entries())o.elementLabel.attr("data-ks-active-from","❊"),o.elementLabel.attr("data-ks-active-to","✮"),this.setting.bestUnicornBuilding.enabled&&this.setting.bestUnicornBuildingCurrent===r?o.elementLabel.addClass(Pt.active):o.elementLabel.removeClass(Pt.active)},onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!t.enabled||t.trigger===-1,this.settingItem.triggerButton.ineffective=t.enabled&&t.trigger<0&&Object.values(t.buildings).some(r=>r.enabled&&0<r.max&&r.trigger<0),this.expando.ineffective=t.enabled&&Object.values(t.buildings).some(r=>r.enabled&&(r.max===0||r.trigger<0&&t.trigger<0));for(const[r,o]of this._unicornBuildings.entries())o.readOnly=this._bestUnicornBuilding.setting.enabled,o.maxButton.readOnly=this._bestUnicornBuilding.setting.enabled,o.triggerButton.readOnly=this._bestUnicornBuilding.setting.enabled}});u(this,"_unicornBuildings");u(this,"_bestUnicornBuilding");const a=[...kt];this._unicornBuildings=new Map([["unicornPasture",oe.getBuildOption(this,this.setting.buildings.unicornPasture,i,this.setting,this.host.engine.i18n("$buildings.unicornPasture.label"),n,{renderLabelTrigger:!1})],...this.host.game.religion.zigguratUpgrades.filter(r=>a.includes(r.name)&&!m(this.setting.buildings[r.name])).map(r=>[r.name,oe.getBuildOption(this,this.setting.buildings[r.name],i,this.setting,r.label,n,{renderLabelTrigger:!1})])]),this._bestUnicornBuilding=new S(this,this.setting.bestUnicornBuilding,this.host.engine.i18n("option.faith.best.unicorn"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.faith.best.unicorn")]);for(const r of this._unicornBuildings.values())r.setting.enabled=!0,r.setting.max=-1,r.setting.trigger=-1},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.faith.best.unicorn")])},upgradeIndicator:!0}),this.addChildrenContent([new x(this,{onReset:()=>{const r=new Yt;this.setting.load({bestUnicornBuilding:r.bestUnicornBuilding,buildings:r.buildings})}}).addChildren([new q(this,this.host.engine.i18n("$religion.panel.ziggurat.label")),...this._unicornBuildings.values(),this._bestUnicornBuilding,new te(this),...this.host.game.religion.zigguratUpgrades.filter(r=>!a.includes(r.name)&&!m(this.setting.buildings[r.name])).map(r=>oe.getBuildOption(this,this.setting.buildings[r.name],i,this.setting,r.label,n,{renderLabelTrigger:!1})),new te(this),new q(this,this.host.engine.i18n("$religion.panel.orderOfTheSun.label")),...this.host.game.religion.religionUpgrades.filter(r=>!m(this.setting.buildings[r.name])).map(r=>{var o;return oe.getBuildOption(this,this.setting.buildings[r.name],i,this.setting,r.label,n,{delimiter:r.name===((o=this.host.game.religion.religionUpgrades.at(-1))==null?void 0:o.name),renderLabelTrigger:!1})}),new q(this,this.host.engine.i18n("$religion.panel.cryptotheology.label")),...this.host.game.religion.transcendenceUpgrades.filter(r=>!m(this.setting.buildings[r.name])).map(r=>oe.getBuildOption(this,this.setting.buildings[r.name],i,this.setting,r.label,n,{renderLabelTrigger:!1}))]),new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new q(this,this.host.engine.i18n("ui.additional")),...Qs.map(r=>{const o=this.host.engine.i18n(`option.faith.${r}`);if(r==="transcend")return new S(this,this.setting[r],o,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[o])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[o])}});const l=new H(this,this.setting[r],i,o,{classes:[C.lastHeadAction],onCheck:()=>{this.host.engine.imessage("status.sub.enable",[o])},onRefresh:()=>{l.triggerButton.inactive=!this.setting[r].enabled||this.setting[r].trigger===-1},onSetTrigger:async()=>{const h=await E.prompt(this,this.host.engine.i18n(l.triggerButton.behavior==="integer"?"ui.trigger.setinteger":"ui.trigger.setpercentage",[o]),this.host.engine.i18n("ui.trigger.build.prompt",[o,l.triggerButton.behavior==="integer"?this.host.renderAbsolute(this.setting[r].trigger,i.selected):this.host.renderPercentage(this.setting[r].trigger,i.selected,!0)]),l.triggerButton.behavior==="integer"?this.host.renderAbsolute(this.setting[r].trigger):this.host.renderPercentage(this.setting[r].trigger),this.host.engine.i18n(l.triggerButton.behavior==="integer"?"ui.trigger.setinteger.promptExplainer":"ui.trigger.setpercentage.promptExplainer"));h===void 0||h===""||h.startsWith("-")||(this.setting[r].trigger=(l.triggerButton.behavior==="integer"?this.host.parseAbsolute(h):this.host.parsePercentage(h))??this.setting[r].trigger)},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[o])}});return l.triggerButton.element.addClass(C.lastHeadAction),l})])])}}class hi extends J{constructor(e,t,i,n,a){super(e,"",A.DataUsage,{...a,onClick:async()=>{const r=await E.prompt(e,e.host.engine.i18n("resources.consume.prompt"),e.host.engine.i18n("resources.consume.promptTitle",[n,e.host.renderPercentage(t.consume,i.selected,!0)]),e.host.renderPercentage(t.consume),e.host.engine.i18n("resources.consume.promptExplainer"));r!==void 0&&(r===""||r.startsWith("-")||(t.consume=e.host.parsePercentage(r)))},onRefresh:()=>{var l;const r=this.host.renderPercentage(this.setting.consume,this.host.engine.settings.locale.selected,!0),o=this.setting.consume===0?this.host.engine.i18n("resources.consume.titleZero",[this.resourceName]):this.host.engine.i18n("resources.consume.title",[r,this.resourceName]);this.updateTitle(o),(l=a==null?void 0:a.onRefresh)==null||l.call(a)}});u(this,"setting");u(this,"resourceName");this.element.addClass(C.consumeButton),this.resourceName=n,this.setting=t}toString(){return`[${hi.name}#${this.componentId}]`}}class ui extends J{constructor(e,t,i,n,a){super(e,"",null,{...a,onClick:async()=>{const r=await E.prompt(e,e.host.engine.i18n("resources.stock.prompt"),e.host.engine.i18n("resources.stock.promptTitle",[n,e.host.renderAbsolute(t.stock,i.selected)]),e.host.renderAbsolute(t.stock),e.host.engine.i18n("resources.stock.promptExplainer"));if(r!==void 0){if(r===""||r.startsWith("-")){t.stock=-1;return}r==="0"&&(t.enabled=!1),t.stock=e.host.parseAbsolute(r)??t.stock}},onRefresh:()=>{const r=this.host.renderAbsolute(this.setting.stock),o=this.setting.stock<0?this.host.engine.i18n("resources.stock.titleInfinite",[this.resourceName]):this.setting.stock===0?this.host.engine.i18n("resources.stock.titleZero",[this.resourceName]):this.host.engine.i18n("resources.stock.title",[this.host.renderAbsolute(this.setting.stock),this.resourceName]);this.updateTitle(o),this.updateLabel(r)}});u(this,"setting");u(this,"resourceName");this.element.addClass(C.stockButton),this.resourceName=n,this.setting=t}toString(){return`[${ui.name}#${this.componentId}]`}}class di extends N{constructor(s,e,t){console.debug(...v(`Constructing ${di.name}`));const i=s.host.engine.i18n("ui.resources");super(s,e,new ue(s,i,{classes:[D.checked,D.setting],icon:A.Resources}).addChildrenHead([new M(s,{classes:[B.fillSpace]})]));const n=["blackcoin","burnedParagon","elderBox","gflops","hashrates","kittens","paragon","temporalFlux","wrappingPaper","zebras"];this.addChildContent(new x(this).addChildren(this.host.game.resPool.resources.filter(a=>!n.includes(a.name)&&!m(this.setting.resources[a.name])).sort((a,r)=>a.title.localeCompare(r.title,t.selected)).map(a=>[this.setting.resources[a.name],X(a.title)]).map(([a,r])=>this._makeResourceSetting(this,a,t,r))))}_makeResourceSetting(s,e,t,i){const n=new S(s,e,i,{onCheck:()=>{s.host.engine.imessage("status.resource.enable",[i])},onUnCheck:()=>{s.host.engine.imessage("status.resource.disable",[i])}}).addChildrenHead([new M(s,{classes:[B.fillSpace]})]),a=new ui(s,e,t,i,{alignment:"right",border:!1,classes:[C.headAction],onRefreshRequest:()=>{a.inactive=!e.enabled||e.stock===0}});n.head.addChild(a);const r=new hi(s,e,t,i,{border:!1,classes:[C.lastHeadAction],onRefreshRequest:()=>{r.inactive=!e.enabled||e.consume!==100,r.ineffective=e.enabled&&e.consume===0}});return n.head.addChild(r),n}}class da extends N{constructor(s,e,t,i){const n=s.host.engine.i18n("ui.upgrade.policies");super(s,e,new S(s,e,n,{onCheck:l=>{s.host.engine.imessage("status.auto.enable",[n])},onUnCheck:l=>{s.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(s,{classes:[B.fillSpace]})]),{onRefreshRequest:()=>{this.expando.ineffective=i.enabled&&e.enabled&&!Object.values(e.policies).some(l=>l.enabled)}});const a=this.host.game.science.policies.filter(l=>!m(this.setting.policies[l.name])),r=[];let o=a[0].label;for(const l of a.sort((h,d)=>h.label.localeCompare(d.label,t.selected))){const h=this.setting.policies[l.name],d=new S(this,h,l.label,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[l.label])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[l.label])}});this.host.engine.localeSupportsFirstLetterSplits(t.selected)&&o[0]!==l.label[0]&&d.element.addClass(B.splitter),r.push(d),o=l.label}this.addChildContent(new x(this).addChildren(r))}}class ga extends N{constructor(s,e,t,i){const n=s.host.engine.i18n("ui.upgrade.techs");super(s,e,new H(s,e,t,n,{onCheck:l=>{s.host.engine.imessage("status.auto.enable",[n])},onRefreshTrigger(){this.triggerButton.element[0].title=s.host.engine.i18n("ui.trigger",[e.trigger<0?s.host.engine.i18n("ui.trigger.section.inactive"):s.host.renderPercentage(e.trigger,t.selected,!0)])},onSetTrigger:async()=>{const l=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.percentage"),s.host.engine.i18n("ui.trigger.section.prompt",[n,e.trigger!==-1?s.host.renderPercentage(e.trigger,t.selected,!0):s.host.engine.i18n("ui.infinity")]),e.trigger!==-1?s.host.renderPercentage(e.trigger):"",s.host.engine.i18n("ui.trigger.section.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.trigger=-1;return}e.trigger=s.host.parsePercentage(l)}},onUnCheck:l=>{s.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled||e.trigger===-1,this.settingItem.triggerButton.ineffective=i.enabled&&e.enabled&&e.trigger===-1&&!Object.values(e.techs).some(l=>l.enabled&&0<=l.trigger),this.expando.ineffective=i.enabled&&e.enabled&&!Object.values(e.techs).some(l=>l.enabled)}});const a=this.host.game.science.techs.filter(l=>!m(this.setting.techs[l.name])),r=[];let o=a[0].label;for(const l of a.sort((h,d)=>h.label.localeCompare(d.label,t.selected))){const h=this.setting.techs[l.name],d=new H(this,h,t,l.label,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[l.label])},onRefresh:()=>{d.triggerButton.inactive=!h.enabled||h.trigger===-1,d.triggerButton.ineffective=i.enabled&&e.enabled&&h.enabled&&e.trigger===-1&&h.trigger===-1},onRefreshTrigger:()=>{d.triggerButton.element[0].title=this.host.engine.i18n("ui.trigger",[h.trigger<0?e.trigger<0?this.host.engine.i18n("ui.trigger.section.blocked",[n]):`${this.host.renderPercentage(e.trigger,t.selected,!0)} (${this.host.engine.i18n("ui.trigger.section.inherited")})`:this.host.renderPercentage(h.trigger,t.selected,!0)])},onSetTrigger:async()=>{const g=await E.prompt(this,this.host.engine.i18n("ui.trigger.prompt.percentage"),this.host.engine.i18n("ui.trigger.section.prompt",[n,h.trigger!==-1?this.host.renderPercentage(h.trigger,t.selected,!0):this.host.engine.i18n("ui.trigger.section.inherited")]),h.trigger!==-1?this.host.renderPercentage(h.trigger):"",this.host.engine.i18n("ui.trigger.section.promptExplainer"));if(g!==void 0){if(g===""||g.startsWith("-")){h.trigger=-1;return}h.trigger=this.host.parsePercentage(g)}},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[l.label])},renderLabelTrigger:!1});d.triggerButton.element.addClass(C.lastHeadAction),this.host.engine.localeSupportsFirstLetterSplits(t.selected)&&o[0]!==l.label[0]&&d.element.addClass(B.splitter),r.push(d),o=l.label}this.addChildContent(new x(this).addChildren(r))}}class gi extends N{constructor(e,t,i){console.debug(...v(`Constructing ${gi.name}`));const n=e.host.engine.i18n("ui.upgrade");super(e,t,new S(e,t,n,{onCheck:r=>{e.host.engine.imessage("status.auto.enable",[n])},onUnCheck:r=>{e.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(e,{classes:[B.fillSpace]})]),{onRefresh:()=>{this.setting.observe.enabled?$("#observeButton").hide():$("#observeButton").show()},onRefreshRequest:()=>{this.expando.ineffective=t.enabled&&(this.setting.policies.enabled&&this._policiesUi.expando.ineffective||this.setting.techs.enabled&&(this._techsUi.expando.ineffective||this._techsUi.settingItem.triggerButton.ineffective))}});u(this,"_policiesUi");u(this,"_techsUi");u(this,"_observeStars");this._policiesUi=new da(this,t.policies,i,t),this._techsUi=new ga(this,t.techs,i,t),this._observeStars=new S(this,this.setting.observe,this.host.engine.i18n("option.observe"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.observe")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.observe")])}});const a=new x(this,{hasDisableAll:!1,hasEnableAll:!1});a.addChildren([this._techsUi,this._policiesUi,this._observeStars]),this.addChildContent(a)}}class ma extends N{constructor(e,t,i,n){const a=e.host.engine.i18n("ui.upgrade.missions");super(e,t,new S(e,t,a,{onCheck:o=>{e.host.engine.imessage("status.auto.enable",[a])},onRefresh:()=>{this.expando.ineffective=n.enabled&&t.enabled&&!Object.values(t.missions).some(o=>o.enabled)},onUnCheck:o=>{e.host.engine.imessage("status.auto.disable",[a])}}).addChildrenHead([new M(e,{classes:[B.fillSpace]})]));u(this,"_missions");this._missions=this.host.game.space.programs.filter(o=>!m(this.setting.missions[o.name])).map(o=>new S(this,this.setting.missions[o.name],o.label,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[o.label])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[o.label])}}));const r=new x(this).addChildren(this._missions);this.addChildContent(r)}}class mi extends N{constructor(e,t,i){console.debug(...v(`Constructing ${mi.name}`));const n=e.host.engine.i18n("ui.space");super(e,t,new H(e,t,i,n,{onCheck:r=>{e.host.engine.imessage("status.auto.enable",[n])},onRefreshTrigger(){this.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger.section",[t.trigger<0?e.host.engine.i18n("ui.trigger.section.inactive"):e.host.renderPercentage(t.trigger,i.selected,!0)])},onSetTrigger:async()=>{const r=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.percentage"),e.host.engine.i18n("ui.trigger.section.prompt",[n,t.trigger!==-1?e.host.renderPercentage(t.trigger,i.selected,!0):e.host.engine.i18n("ui.infinity")]),t.trigger!==-1?e.host.renderPercentage(t.trigger):"",e.host.engine.i18n("ui.trigger.section.promptExplainer"));if(r!==void 0){if(r===""||r.startsWith("-")){t.trigger=-1;return}t.trigger=e.host.parsePercentage(r)}},onUnCheck:r=>{e.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!t.enabled||t.trigger===-1,this.settingItem.triggerButton.ineffective=t.enabled&&t.trigger<0&&Object.values(t.buildings).some(r=>r.enabled&&0<r.max&&r.trigger<0),this.expando.ineffective=t.enabled&&(Object.values(t.buildings).some(r=>r.enabled&&(r.max===0||r.trigger<0&&t.trigger<0))||!Object.values(t.buildings).some(r=>r.enabled)&&!t.unlockMissions.enabled||this._missionsUi.expando.ineffective)}});u(this,"_missionsUi");this.addChildContent(new x(this,{onReset:()=>{this.setting.load({buildings:new St().buildings})}}).addChildren(this.host.game.space.planets.filter(r=>0<r.buildings.length).flatMap((r,o,l)=>[new q(this,this.host.engine.labelForPlanet(r.name)),...r.buildings.filter(h=>!m(this.setting.buildings[h.name])).map((h,d,g)=>oe.getBuildOption(this,this.setting.buildings[h.name],i,this.setting,h.label,n,{delimiter:o<l.length-1&&d===g.length-1,renderLabelTrigger:!1}))])));const a=new x(this,{hasDisableAll:!1,hasEnableAll:!1});a.addChild(new q(this,this.host.engine.i18n("ui.additional"))),this._missionsUi=new ma(this,this.setting.unlockMissions,i,this.setting),a.addChild(this._missionsUi),this.addChildContent(a)}}class fi extends fe{constructor(s,e=400){super("ERR_OS_INVALID_ARGUMENT",s,e),this.name="InvalidArgumentError",typeof Error.captureStackTrace<"u"&&Error.captureStackTrace(this,fi)}}const It=43200,_s=1440,Cs=Symbol.for("constructDateFrom");function bi(c,s){return typeof c=="function"?c(s):c&&typeof c=="object"&&Cs in c?c[Cs](s):c instanceof Date?new c.constructor(s):new Date(s)}function fa(c){return bi(c,Date.now())}const ba={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},pa=(c,s,e)=>{let t;const i=ba[c];return typeof i=="string"?t=i:s===1?t=i.one:t=i.other.replace("{{count}}",s.toString()),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"in "+t:t+" ago":t};function se(c){return(s={})=>{const e=s.width?String(s.width):c.defaultWidth;return c.formats[e]||c.formats[c.defaultWidth]}}const va={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},ya={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},wa={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ka={date:se({formats:va,defaultWidth:"full"}),time:se({formats:ya,defaultWidth:"full"}),dateTime:se({formats:wa,defaultWidth:"full"})},_a={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ca=(c,s,e,t)=>_a[c];function Z(c){return(s,e)=>{const t=e!=null&&e.context?String(e.context):"standalone";let i;if(t==="formatting"&&c.formattingValues){const a=c.defaultFormattingWidth||c.defaultWidth,r=e!=null&&e.width?String(e.width):a;i=c.formattingValues[r]||c.formattingValues[a]}else{const a=c.defaultWidth,r=e!=null&&e.width?String(e.width):c.defaultWidth;i=c.values[r]||c.values[a]}const n=c.argumentCallback?c.argumentCallback(s):s;return i[n]}}const Sa={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},xa={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Ta={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Ea={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Ra={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Ma={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Ba={ordinalNumber:(c,s)=>{const e=Number(c),t=e%100;if(t>20||t<10)switch(t%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},era:Z({values:Sa,defaultWidth:"wide"}),quarter:Z({values:xa,defaultWidth:"wide",argumentCallback:c=>c-1}),month:Z({values:Ta,defaultWidth:"wide"}),day:Z({values:Ea,defaultWidth:"wide"}),dayPeriod:Z({values:Ra,defaultWidth:"wide",formattingValues:Ma,defaultFormattingWidth:"wide"})};function K(c){return(s,e={})=>{const t=e.width,i=t&&c.matchPatterns[t]||c.matchPatterns[c.defaultMatchWidth],n=s.match(i);if(!n)return null;const a=n[0],r=t&&c.parsePatterns[t]||c.parsePatterns[c.defaultParseWidth],o=Array.isArray(r)?Pa(r,d=>d.test(a)):Aa(r,d=>d.test(a));let l;l=c.valueCallback?c.valueCallback(o):o,l=e.valueCallback?e.valueCallback(l):l;const h=s.slice(a.length);return{value:l,rest:h}}}function Aa(c,s){for(const e in c)if(Object.prototype.hasOwnProperty.call(c,e)&&s(c[e]))return e}function Pa(c,s){for(let e=0;e<c.length;e++)if(s(c[e]))return e}function $t(c){return(s,e={})=>{const t=s.match(c.matchPattern);if(!t)return null;const i=t[0],n=s.match(c.parsePattern);if(!n)return null;let a=c.valueCallback?c.valueCallback(n[0]):n[0];a=e.valueCallback?e.valueCallback(a):a;const r=s.slice(i.length);return{value:a,rest:r}}}const Ia=/^(\d+)(th|st|nd|rd)?/i,$a=/\d+/i,La={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Oa={any:[/^b/i,/^(a|c)/i]},Ua={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Da={any:[/1/i,/2/i,/3/i,/4/i]},Na={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},qa={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},za={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Fa={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ha={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Wa={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ga={ordinalNumber:$t({matchPattern:Ia,parsePattern:$a,valueCallback:c=>parseInt(c,10)}),era:K({matchPatterns:La,defaultMatchWidth:"wide",parsePatterns:Oa,defaultParseWidth:"any"}),quarter:K({matchPatterns:Ua,defaultMatchWidth:"wide",parsePatterns:Da,defaultParseWidth:"any",valueCallback:c=>c+1}),month:K({matchPatterns:Na,defaultMatchWidth:"wide",parsePatterns:qa,defaultParseWidth:"any"}),day:K({matchPatterns:za,defaultMatchWidth:"wide",parsePatterns:Fa,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:Ha,defaultMatchWidth:"any",parsePatterns:Wa,defaultParseWidth:"any"})},Ss={code:"en-US",formatDistance:pa,formatLong:ka,formatRelative:Ca,localize:Ba,match:Ga,options:{weekStartsOn:0,firstWeekContainsDate:1}};let Za={};function xs(){return Za}function me(c,s){return bi(s||c,c)}function Ts(c){const s=me(c),e=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return e.setUTCFullYear(s.getFullYear()),+c-+e}function Lt(c,...s){const e=bi.bind(null,c||s.find(t=>typeof t=="object"));return s.map(e)}function Ot(c,s){const e=+me(c)-+me(s);return e<0?-1:e>0?1:e}function Ka(c,s,e){const[t,i]=Lt(e==null?void 0:e.in,c,s),n=t.getFullYear()-i.getFullYear(),a=t.getMonth()-i.getMonth();return n*12+a}function Va(c,s){const e=me(c,s==null?void 0:s.in);return e.setHours(23,59,59,999),e}function ja(c,s){const e=me(c,s==null?void 0:s.in),t=e.getMonth();return e.setFullYear(e.getFullYear(),t+1,0),e.setHours(23,59,59,999),e}function Ja(c,s){const e=me(c,s==null?void 0:s.in);return+Va(e,s)==+ja(e,s)}function Xa(c,s,e){const[t,i,n]=Lt(e==null?void 0:e.in,c,c,s),a=Ot(i,n),r=Math.abs(Ka(i,n));if(r<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-a*r);let o=Ot(i,n)===-a;Ja(t)&&r===1&&Ot(t,n)===1&&(o=!1);const l=a*(r-+o);return l===0?0:l}function Ya(c){return s=>{const t=(c?Math[c]:Math.trunc)(s);return t===0?0:t}}function Qa(c,s){return+me(c)-+me(s)}function er(c,s,e){const t=Qa(c,s)/1e3;return Ya(e==null?void 0:e.roundingMethod)(t)}function tr(c,s,e){const t=xs(),i=(e==null?void 0:e.locale)??t.locale??Ss,n=2520,a=Ot(c,s);if(isNaN(a))throw new RangeError("Invalid time value");const r=Object.assign({},e,{addSuffix:e==null?void 0:e.addSuffix,comparison:a}),[o,l]=Lt(e==null?void 0:e.in,...a>0?[s,c]:[c,s]),h=er(l,o),d=(Ts(l)-Ts(o))/1e3,g=Math.round((h-d)/60);let f;if(g<2)return e!=null&&e.includeSeconds?h<5?i.formatDistance("lessThanXSeconds",5,r):h<10?i.formatDistance("lessThanXSeconds",10,r):h<20?i.formatDistance("lessThanXSeconds",20,r):h<40?i.formatDistance("halfAMinute",0,r):h<60?i.formatDistance("lessThanXMinutes",1,r):i.formatDistance("xMinutes",1,r):g===0?i.formatDistance("lessThanXMinutes",1,r):i.formatDistance("xMinutes",g,r);if(g<45)return i.formatDistance("xMinutes",g,r);if(g<90)return i.formatDistance("aboutXHours",1,r);if(g<_s){const w=Math.round(g/60);return i.formatDistance("aboutXHours",w,r)}else{if(g<n)return i.formatDistance("xDays",1,r);if(g<It){const w=Math.round(g/_s);return i.formatDistance("xDays",w,r)}else if(g<It*2)return f=Math.round(g/It),i.formatDistance("aboutXMonths",f,r)}if(f=Xa(l,o),f<12){const w=Math.round(g/It);return i.formatDistance("xMonths",w,r)}else{const w=f%12,b=Math.trunc(f/12);return w<3?i.formatDistance("aboutXYears",b,r):w<9?i.formatDistance("overXYears",b,r):i.formatDistance("almostXYears",b+1,r)}}function Es(c,s){return tr(c,fa(c),s)}function Rs(c,s){var r,o,l,h;const e=xs(),t=(s==null?void 0:s.weekStartsOn)??((o=(r=s==null?void 0:s.locale)==null?void 0:r.options)==null?void 0:o.weekStartsOn)??e.weekStartsOn??((h=(l=e.locale)==null?void 0:l.options)==null?void 0:h.weekStartsOn)??0,i=me(c,s==null?void 0:s.in),n=i.getDay(),a=(n<t?7:0)+n-t;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function ir(c,s,e){const[t,i]=Lt(e==null?void 0:e.in,c,s);return+Rs(t,e)==+Rs(i,e)}const Ms={lessThanXSeconds:{standalone:{one:"weniger als 1 Sekunde",other:"weniger als {{count}} Sekunden"},withPreposition:{one:"weniger als 1 Sekunde",other:"weniger als {{count}} Sekunden"}},xSeconds:{standalone:{one:"1 Sekunde",other:"{{count}} Sekunden"},withPreposition:{one:"1 Sekunde",other:"{{count}} Sekunden"}},halfAMinute:{standalone:"eine halbe Minute",withPreposition:"einer halben Minute"},lessThanXMinutes:{standalone:{one:"weniger als 1 Minute",other:"weniger als {{count}} Minuten"},withPreposition:{one:"weniger als 1 Minute",other:"weniger als {{count}} Minuten"}},xMinutes:{standalone:{one:"1 Minute",other:"{{count}} Minuten"},withPreposition:{one:"1 Minute",other:"{{count}} Minuten"}},aboutXHours:{standalone:{one:"etwa 1 Stunde",other:"etwa {{count}} Stunden"},withPreposition:{one:"etwa 1 Stunde",other:"etwa {{count}} Stunden"}},xHours:{standalone:{one:"1 Stunde",other:"{{count}} Stunden"},withPreposition:{one:"1 Stunde",other:"{{count}} Stunden"}},xDays:{standalone:{one:"1 Tag",other:"{{count}} Tage"},withPreposition:{one:"1 Tag",other:"{{count}} Tagen"}},aboutXWeeks:{standalone:{one:"etwa 1 Woche",other:"etwa {{count}} Wochen"},withPreposition:{one:"etwa 1 Woche",other:"etwa {{count}} Wochen"}},xWeeks:{standalone:{one:"1 Woche",other:"{{count}} Wochen"},withPreposition:{one:"1 Woche",other:"{{count}} Wochen"}},aboutXMonths:{standalone:{one:"etwa 1 Monat",other:"etwa {{count}} Monate"},withPreposition:{one:"etwa 1 Monat",other:"etwa {{count}} Monaten"}},xMonths:{standalone:{one:"1 Monat",other:"{{count}} Monate"},withPreposition:{one:"1 Monat",other:"{{count}} Monaten"}},aboutXYears:{standalone:{one:"etwa 1 Jahr",other:"etwa {{count}} Jahre"},withPreposition:{one:"etwa 1 Jahr",other:"etwa {{count}} Jahren"}},xYears:{standalone:{one:"1 Jahr",other:"{{count}} Jahre"},withPreposition:{one:"1 Jahr",other:"{{count}} Jahren"}},overXYears:{standalone:{one:"mehr als 1 Jahr",other:"mehr als {{count}} Jahre"},withPreposition:{one:"mehr als 1 Jahr",other:"mehr als {{count}} Jahren"}},almostXYears:{standalone:{one:"fast 1 Jahr",other:"fast {{count}} Jahre"},withPreposition:{one:"fast 1 Jahr",other:"fast {{count}} Jahren"}}},sr=(c,s,e)=>{let t;const i=e!=null&&e.addSuffix?Ms[c].withPreposition:Ms[c].standalone;return typeof i=="string"?t=i:s===1?t=i.one:t=i.other.replace("{{count}}",String(s)),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"in "+t:"vor "+t:t},nr={full:"EEEE, do MMMM y",long:"do MMMM y",medium:"do MMM y",short:"dd.MM.y"},ar={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},rr={full:"{{date}} 'um' {{time}}",long:"{{date}} 'um' {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},or={date:se({formats:nr,defaultWidth:"full"}),time:se({formats:ar,defaultWidth:"full"}),dateTime:se({formats:rr,defaultWidth:"full"})},lr={lastWeek:"'letzten' eeee 'um' p",yesterday:"'gestern um' p",today:"'heute um' p",tomorrow:"'morgen um' p",nextWeek:"eeee 'um' p",other:"P"},cr=(c,s,e,t)=>lr[c],hr={narrow:["v.Chr.","n.Chr."],abbreviated:["v.Chr.","n.Chr."],wide:["vor Christus","nach Christus"]},ur={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1. Quartal","2. Quartal","3. Quartal","4. Quartal"]},pi={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],wide:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]},dr={narrow:pi.narrow,abbreviated:["Jan.","Feb.","März","Apr.","Mai","Juni","Juli","Aug.","Sep.","Okt.","Nov.","Dez."],wide:pi.wide},gr={narrow:["S","M","D","M","D","F","S"],short:["So","Mo","Di","Mi","Do","Fr","Sa"],abbreviated:["So.","Mo.","Di.","Mi.","Do.","Fr.","Sa."],wide:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]},mr={narrow:{am:"vm.",pm:"nm.",midnight:"Mitternacht",noon:"Mittag",morning:"Morgen",afternoon:"Nachm.",evening:"Abend",night:"Nacht"},abbreviated:{am:"vorm.",pm:"nachm.",midnight:"Mitternacht",noon:"Mittag",morning:"Morgen",afternoon:"Nachmittag",evening:"Abend",night:"Nacht"},wide:{am:"vormittags",pm:"nachmittags",midnight:"Mitternacht",noon:"Mittag",morning:"Morgen",afternoon:"Nachmittag",evening:"Abend",night:"Nacht"}},fr={narrow:{am:"vm.",pm:"nm.",midnight:"Mitternacht",noon:"Mittag",morning:"morgens",afternoon:"nachm.",evening:"abends",night:"nachts"},abbreviated:{am:"vorm.",pm:"nachm.",midnight:"Mitternacht",noon:"Mittag",morning:"morgens",afternoon:"nachmittags",evening:"abends",night:"nachts"},wide:{am:"vormittags",pm:"nachmittags",midnight:"Mitternacht",noon:"Mittag",morning:"morgens",afternoon:"nachmittags",evening:"abends",night:"nachts"}},br={ordinalNumber:c=>Number(c)+".",era:Z({values:hr,defaultWidth:"wide"}),quarter:Z({values:ur,defaultWidth:"wide",argumentCallback:c=>c-1}),month:Z({values:pi,formattingValues:dr,defaultWidth:"wide"}),day:Z({values:gr,defaultWidth:"wide"}),dayPeriod:Z({values:mr,defaultWidth:"wide",formattingValues:fr,defaultFormattingWidth:"wide"})},pr=/^(\d+)(\.)?/i,vr=/\d+/i,yr={narrow:/^(v\.? ?Chr\.?|n\.? ?Chr\.?)/i,abbreviated:/^(v\.? ?Chr\.?|n\.? ?Chr\.?)/i,wide:/^(vor Christus|vor unserer Zeitrechnung|nach Christus|unserer Zeitrechnung)/i},wr={any:[/^v/i,/^n/i]},kr={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](\.)? Quartal/i},_r={any:[/1/i,/2/i,/3/i,/4/i]},Cr={narrow:/^[jfmasond]/i,abbreviated:/^(j[aä]n|feb|mär[z]?|apr|mai|jun[i]?|jul[i]?|aug|sep|okt|nov|dez)\.?/i,wide:/^(januar|februar|märz|april|mai|juni|juli|august|september|oktober|november|dezember)/i},Sr={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^j[aä]/i,/^f/i,/^mär/i,/^ap/i,/^mai/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},xr={narrow:/^[smdmf]/i,short:/^(so|mo|di|mi|do|fr|sa)/i,abbreviated:/^(son?|mon?|die?|mit?|don?|fre?|sam?)\.?/i,wide:/^(sonntag|montag|dienstag|mittwoch|donnerstag|freitag|samstag)/i},Tr={any:[/^so/i,/^mo/i,/^di/i,/^mi/i,/^do/i,/^f/i,/^sa/i]},Er={narrow:/^(vm\.?|nm\.?|Mitternacht|Mittag|morgens|nachm\.?|abends|nachts)/i,abbreviated:/^(vorm\.?|nachm\.?|Mitternacht|Mittag|morgens|nachm\.?|abends|nachts)/i,wide:/^(vormittags|nachmittags|Mitternacht|Mittag|morgens|nachmittags|abends|nachts)/i},Rr={any:{am:/^v/i,pm:/^n/i,midnight:/^Mitte/i,noon:/^Mitta/i,morning:/morgens/i,afternoon:/nachmittags/i,evening:/abends/i,night:/nachts/i}},Mr={ordinalNumber:$t({matchPattern:pr,parsePattern:vr,valueCallback:c=>parseInt(c)}),era:K({matchPatterns:yr,defaultMatchWidth:"wide",parsePatterns:wr,defaultParseWidth:"any"}),quarter:K({matchPatterns:kr,defaultMatchWidth:"wide",parsePatterns:_r,defaultParseWidth:"any",valueCallback:c=>c+1}),month:K({matchPatterns:Cr,defaultMatchWidth:"wide",parsePatterns:Sr,defaultParseWidth:"any"}),day:K({matchPatterns:xr,defaultMatchWidth:"wide",parsePatterns:Tr,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:Er,defaultMatchWidth:"wide",parsePatterns:Rr,defaultParseWidth:"any"})},Br={code:"de",formatDistance:sr,formatLong:or,formatRelative:cr,localize:br,match:Mr,options:{weekStartsOn:1,firstWeekContainsDate:4}},Ar={lessThanXSeconds:{one:"פחות משנייה",two:"פחות משתי שניות",other:"פחות מ־{{count}} שניות"},xSeconds:{one:"שנייה",two:"שתי שניות",other:"{{count}} שניות"},halfAMinute:"חצי דקה",lessThanXMinutes:{one:"פחות מדקה",two:"פחות משתי דקות",other:"פחות מ־{{count}} דקות"},xMinutes:{one:"דקה",two:"שתי דקות",other:"{{count}} דקות"},aboutXHours:{one:"כשעה",two:"כשעתיים",other:"כ־{{count}} שעות"},xHours:{one:"שעה",two:"שעתיים",other:"{{count}} שעות"},xDays:{one:"יום",two:"יומיים",other:"{{count}} ימים"},aboutXWeeks:{one:"כשבוע",two:"כשבועיים",other:"כ־{{count}} שבועות"},xWeeks:{one:"שבוע",two:"שבועיים",other:"{{count}} שבועות"},aboutXMonths:{one:"כחודש",two:"כחודשיים",other:"כ־{{count}} חודשים"},xMonths:{one:"חודש",two:"חודשיים",other:"{{count}} חודשים"},aboutXYears:{one:"כשנה",two:"כשנתיים",other:"כ־{{count}} שנים"},xYears:{one:"שנה",two:"שנתיים",other:"{{count}} שנים"},overXYears:{one:"יותר משנה",two:"יותר משנתיים",other:"יותר מ־{{count}} שנים"},almostXYears:{one:"כמעט שנה",two:"כמעט שנתיים",other:"כמעט {{count}} שנים"}},Pr=(c,s,e)=>{if(c==="xDays"&&(e!=null&&e.addSuffix)&&s<=2)return e.comparison&&e.comparison>0?s===1?"מחר":"מחרתיים":s===1?"אתמול":"שלשום";let t;const i=Ar[c];return typeof i=="string"?t=i:s===1?t=i.one:s===2?t=i.two:t=i.other.replace("{{count}}",String(s)),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"בעוד "+t:"לפני "+t:t},Ir={full:"EEEE, d בMMMM y",long:"d בMMMM y",medium:"d בMMM y",short:"d.M.y"},$r={full:"H:mm:ss zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},Lr={full:"{{date}} 'בשעה' {{time}}",long:"{{date}} 'בשעה' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Or={date:se({formats:Ir,defaultWidth:"full"}),time:se({formats:$r,defaultWidth:"full"}),dateTime:se({formats:Lr,defaultWidth:"full"})},Ur={lastWeek:"eeee 'שעבר בשעה' p",yesterday:"'אתמול בשעה' p",today:"'היום בשעה' p",tomorrow:"'מחר בשעה' p",nextWeek:"eeee 'בשעה' p",other:"P"},Dr=(c,s,e,t)=>Ur[c],Nr={narrow:["לפנה״ס","לספירה"],abbreviated:["לפנה״ס","לספירה"],wide:["לפני הספירה","לספירה"]},qr={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["רבעון 1","רבעון 2","רבעון 3","רבעון 4"]},zr={narrow:["1","2","3","4","5","6","7","8","9","10","11","12"],abbreviated:["ינו׳","פבר׳","מרץ","אפר׳","מאי","יוני","יולי","אוג׳","ספט׳","אוק׳","נוב׳","דצמ׳"],wide:["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"]},Fr={narrow:["א׳","ב׳","ג׳","ד׳","ה׳","ו׳","ש׳"],short:["א׳","ב׳","ג׳","ד׳","ה׳","ו׳","ש׳"],abbreviated:["יום א׳","יום ב׳","יום ג׳","יום ד׳","יום ה׳","יום ו׳","שבת"],wide:["יום ראשון","יום שני","יום שלישי","יום רביעי","יום חמישי","יום שישי","יום שבת"]},Hr={narrow:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בוקר",afternoon:"אחר הצהריים",evening:"ערב",night:"לילה"},abbreviated:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בוקר",afternoon:"אחר הצהריים",evening:"ערב",night:"לילה"},wide:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בוקר",afternoon:"אחר הצהריים",evening:"ערב",night:"לילה"}},Wr={narrow:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בבוקר",afternoon:"בצהריים",evening:"בערב",night:"בלילה"},abbreviated:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בבוקר",afternoon:"אחר הצהריים",evening:"בערב",night:"בלילה"},wide:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בבוקר",afternoon:"אחר הצהריים",evening:"בערב",night:"בלילה"}},Gr={ordinalNumber:(c,s)=>{const e=Number(c);if(e<=0||e>10)return String(e);const t=String(s==null?void 0:s.unit),i=["year","hour","minute","second"].indexOf(t)>=0,n=["ראשון","שני","שלישי","רביעי","חמישי","שישי","שביעי","שמיני","תשיעי","עשירי"],a=["ראשונה","שנייה","שלישית","רביעית","חמישית","שישית","שביעית","שמינית","תשיעית","עשירית"],r=e-1;return i?a[r]:n[r]},era:Z({values:Nr,defaultWidth:"wide"}),quarter:Z({values:qr,defaultWidth:"wide",argumentCallback:c=>c-1}),month:Z({values:zr,defaultWidth:"wide"}),day:Z({values:Fr,defaultWidth:"wide"}),dayPeriod:Z({values:Hr,defaultWidth:"wide",formattingValues:Wr,defaultFormattingWidth:"wide"})},Zr=/^(\d+|(ראשון|שני|שלישי|רביעי|חמישי|שישי|שביעי|שמיני|תשיעי|עשירי|ראשונה|שנייה|שלישית|רביעית|חמישית|שישית|שביעית|שמינית|תשיעית|עשירית))/i,Kr=/^(\d+|רא|שנ|של|רב|ח|שי|שב|שמ|ת|ע)/i,Vr={narrow:/^ל(ספירה|פנה״ס)/i,abbreviated:/^ל(ספירה|פנה״ס)/i,wide:/^ל(פני ה)?ספירה/i},jr={any:[/^לפ/i,/^לס/i]},Jr={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^רבעון [1234]/i},Xr={any:[/1/i,/2/i,/3/i,/4/i]},Yr={narrow:/^\d+/i,abbreviated:/^(ינו|פבר|מרץ|אפר|מאי|יוני|יולי|אוג|ספט|אוק|נוב|דצמ)׳?/i,wide:/^(ינואר|פברואר|מרץ|אפריל|מאי|יוני|יולי|אוגוסט|ספטמבר|אוקטובר|נובמבר|דצמבר)/i},Qr={narrow:[/^1$/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^7/i,/^8/i,/^9/i,/^10/i,/^11/i,/^12/i],any:[/^ינ/i,/^פ/i,/^מר/i,/^אפ/i,/^מא/i,/^יונ/i,/^יול/i,/^אוג/i,/^ס/i,/^אוק/i,/^נ/i,/^ד/i]},eo={narrow:/^[אבגדהוש]׳/i,short:/^[אבגדהוש]׳/i,abbreviated:/^(שבת|יום (א|ב|ג|ד|ה|ו)׳)/i,wide:/^יום (ראשון|שני|שלישי|רביעי|חמישי|שישי|שבת)/i},to={abbreviated:[/א׳$/i,/ב׳$/i,/ג׳$/i,/ד׳$/i,/ה׳$/i,/ו׳$/i,/^ש/i],wide:[/ן$/i,/ני$/i,/לישי$/i,/עי$/i,/מישי$/i,/שישי$/i,/ת$/i],any:[/^א/i,/^ב/i,/^ג/i,/^ד/i,/^ה/i,/^ו/i,/^ש/i]},io={any:/^(אחר ה|ב)?(חצות|צהריים|בוקר|ערב|לילה|אחה״צ|לפנה״צ)/i},so={any:{am:/^לפ/i,pm:/^אחה/i,midnight:/^ח/i,noon:/^צ/i,morning:/בוקר/i,afternoon:/בצ|אחר/i,evening:/ערב/i,night:/לילה/i}},no=["רא","שנ","של","רב","ח","שי","שב","שמ","ת","ע"],ao={ordinalNumber:$t({matchPattern:Zr,parsePattern:Kr,valueCallback:c=>{const s=parseInt(c,10);return isNaN(s)?no.indexOf(c)+1:s}}),era:K({matchPatterns:Vr,defaultMatchWidth:"wide",parsePatterns:jr,defaultParseWidth:"any"}),quarter:K({matchPatterns:Jr,defaultMatchWidth:"wide",parsePatterns:Xr,defaultParseWidth:"any",valueCallback:c=>c+1}),month:K({matchPatterns:Yr,defaultMatchWidth:"wide",parsePatterns:Qr,defaultParseWidth:"any"}),day:K({matchPatterns:eo,defaultMatchWidth:"wide",parsePatterns:to,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:io,defaultMatchWidth:"any",parsePatterns:so,defaultParseWidth:"any"})},ro={code:"he",formatDistance:Pr,formatLong:Or,formatRelative:Dr,localize:Gr,match:ao,options:{weekStartsOn:0,firstWeekContainsDate:1}},oo={lessThanXSeconds:{one:"不到 1 秒",other:"不到 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分钟",lessThanXMinutes:{one:"不到 1 分钟",other:"不到 {{count}} 分钟"},xMinutes:{one:"1 分钟",other:"{{count}} 分钟"},xHours:{one:"1 小时",other:"{{count}} 小时"},aboutXHours:{one:"大约 1 小时",other:"大约 {{count}} 小时"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大约 1 个星期",other:"大约 {{count}} 个星期"},xWeeks:{one:"1 个星期",other:"{{count}} 个星期"},aboutXMonths:{one:"大约 1 个月",other:"大约 {{count}} 个月"},xMonths:{one:"1 个月",other:"{{count}} 个月"},aboutXYears:{one:"大约 1 年",other:"大约 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超过 1 年",other:"超过 {{count}} 年"},almostXYears:{one:"将近 1 年",other:"将近 {{count}} 年"}},lo=(c,s,e)=>{let t;const i=oo[c];return typeof i=="string"?t=i:s===1?t=i.one:t=i.other.replace("{{count}}",String(s)),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?t+"内":t+"前":t},co={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},ho={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},uo={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},go={date:se({formats:co,defaultWidth:"full"}),time:se({formats:ho,defaultWidth:"full"}),dateTime:se({formats:uo,defaultWidth:"full"})};function Bs(c,s,e){const t="eeee p";return ir(c,s,e)?t:c.getTime()>s.getTime()?"'下个'"+t:"'上个'"+t}const mo={lastWeek:Bs,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:Bs,other:"PP p"},fo=(c,s,e,t)=>{const i=mo[c];return typeof i=="function"?i(s,e,t):i},bo={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},po={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},vo={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},yo={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},wo={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},ko={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},_o={ordinalNumber:(c,s)=>{const e=Number(c);switch(s==null?void 0:s.unit){case"date":return e.toString()+"日";case"hour":return e.toString()+"时";case"minute":return e.toString()+"分";case"second":return e.toString()+"秒";default:return"第 "+e.toString()}},era:Z({values:bo,defaultWidth:"wide"}),quarter:Z({values:po,defaultWidth:"wide",argumentCallback:c=>c-1}),month:Z({values:vo,defaultWidth:"wide"}),day:Z({values:yo,defaultWidth:"wide"}),dayPeriod:Z({values:wo,defaultWidth:"wide",formattingValues:ko,defaultFormattingWidth:"wide"})},Co=/^(第\s*)?\d+(日|时|分|秒)?/i,So=/\d+/i,xo={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},To={any:[/^(前)/i,/^(公元)/i]},Eo={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},Ro={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},Mo={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},Bo={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},Ao={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},Po={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},Io={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},$o={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},Lo={ordinalNumber:$t({matchPattern:Co,parsePattern:So,valueCallback:c=>parseInt(c,10)}),era:K({matchPatterns:xo,defaultMatchWidth:"wide",parsePatterns:To,defaultParseWidth:"any"}),quarter:K({matchPatterns:Eo,defaultMatchWidth:"wide",parsePatterns:Ro,defaultParseWidth:"any",valueCallback:c=>c+1}),month:K({matchPatterns:Mo,defaultMatchWidth:"wide",parsePatterns:Bo,defaultParseWidth:"any"}),day:K({matchPatterns:Ao,defaultMatchWidth:"wide",parsePatterns:Po,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:Io,defaultMatchWidth:"any",parsePatterns:$o,defaultParseWidth:"any"})},Oo={code:"zh-CN",formatDistance:lo,formatLong:go,formatRelative:fo,localize:_o,match:Lo,options:{weekStartsOn:1,firstWeekContainsDate:4}};class Uo{constructor(s){u(this,"_game");this._game=s}load(s){return new Promise((e,t)=>{if(s===null){e();return}this._game.saveImportDropboxText(s,i=>{if(i){t(i);return}e()})})}loadRaw(s){const e=this._game.compressLZData(JSON.stringify(s));return this.load(e)}}class $e extends he{constructor(s,e){super(s,e),this.element.addClass(ks.toolbar)}toString(){return`[${$e.name}#${this.componentId}]`}addChild(s){return super.addChild(s)}}class vi extends N{constructor(e,t,i){console.debug(...v(`Constructing ${vi.name}`));const n=e.host.engine.i18n("state.title");super(e,t,new ue(e,n,{classes:[D.checked,D.setting],icon:A.State}).addChildrenHead([new M(e,{classes:[B.fillSpace]})]),{onRefresh:()=>{this._refreshGameList(),this._refreshStateList()}});u(this,"games",new Array);u(this,"states",new Array);u(this,"gameList");u(this,"stateList");u(this,"locale");this.gameList=new x(this,{hasDisableAll:!1,hasEnableAll:!1}),this.stateList=new x(this,{hasDisableAll:!1,hasEnableAll:!1}),this.locale=i.selected==="zh-CN"?Oo:i.selected==="he-IL"?ro:i.selected==="de-DE"?Br:Ss,this.addChildContent(new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new S(this,this.setting.noConfirm,this.host.engine.i18n("state.noConfirm")),new he(this).addChild(new te(this)),new q(this,this.host.engine.i18n("state.local")),new $e(this).addChildren([new J(this,this.host.engine.i18n("state.import"),A.Import,{onClick:()=>{this.import()},title:this.host.engine.i18n("state.importTitle")})]),new he(this).addChild(new te(this)),new q(this,this.host.engine.i18n("state.localStates")),new $e(this).addChildren([new J(this,this.host.engine.i18n("state.store"),A.SaveAs,{onClick:()=>{this.storeState()},title:this.host.engine.i18n("state.storeState")}),new J(this,this.host.engine.i18n("copy"),A.Copy,{onClick:()=>{this.copyState().catch(R(console)),this.host.engine.imessage("state.copied.stateCurrent")},title:this.host.engine.i18n("state.copy.stateCurrent")}),new J(this,this.host.engine.i18n("state.new"),A.Draft,{onClick:()=>{this.storeStateFactoryDefaults(),this.host.engine.imessage("state.stored.state")},title:this.host.engine.i18n("state.storeFactory")}),new J(this,this.host.engine.i18n("state.exportAll"),A.Sync,{onClick:()=>{this.exportStateAll()},title:this.host.engine.i18n("state.exportAllTitle")})]),new he(this).addChild(this.stateList),new he(this).addChild(new te(this)),new q(this,this.host.engine.i18n("state.localGames")),new $e(this).addChildren([new J(this,this.host.engine.i18n("state.store"),A.SaveAs,{onClick:()=>{this.storeGame(),this.host.engine.imessage("state.stored.game")},title:this.host.engine.i18n("state.storeGame")}),new J(this,this.host.engine.i18n("copy"),A.Copy,{onClick:()=>{this.copyGame().catch(R(console)),this.host.engine.imessage("state.copied.gameCurrent")},title:this.host.engine.i18n("state.copy.gameCurrent")})]),new he(this).addChild(this.gameList),new S(this,this.setting.compress,this.host.engine.i18n("state.compress"))])),this._loadGames(),this._loadStates()}_loadGames(){let e=0,t=localStorage.getItem(`ks.game.${e}`);this.games.splice(0);try{for(;!m(t);){const i=JSON.parse(t);this.games.push(new yt(i)),t=localStorage.getItem(`ks.game.${++e}`)}}catch(i){console.error(...v(i))}}_storeGames(){let e=0,t=localStorage.getItem(`ks.game.${e}`);for(;!m(t);)localStorage.removeItem(`ks.game.${e}`),t=localStorage.getItem(`ks.game.${++e}`);e=0;for(const i of this.games)localStorage.setItem(`ks.game.${e++}`,JSON.stringify(i))}_loadStates(){let e=0,t=localStorage.getItem(`ks.state.${e}`);this.states.splice(0);try{for(;!m(t);){const i=JSON.parse(t);de.unknownAsEngineStateOrThrow(i.state),this.states.push(new yt(i)),t=localStorage.getItem(`ks.state.${++e}`)}}catch(i){console.error(...v(i))}}_storeStates(){let e=0,t=localStorage.getItem(`ks.state.${e}`);for(;!m(t);)localStorage.removeItem(`ks.state.${e}`),t=localStorage.getItem(`ks.state.${++e}`);e=0;for(const i of this.states)localStorage.setItem(`ks.state.${e++}`,JSON.stringify(i))}_refreshGameList(){this.gameList.removeChildren(this.gameList.children),this.gameList.addChildren(this.games.sort((e,t)=>new Date(e.unwrap().timestamp).getTime()-new Date(t.unwrap().timestamp).getTime()).map(e=>[e.unwrap(),e]).map(([e,t])=>new si(this,new Ce(this,`${e.label} (${Es(new Date(e.timestamp),{addSuffix:!0,locale:this.locale})})`,{onClick:()=>{this.loadGame(e.game).catch(R(console)),this.host.engine.imessage("state.loaded.game",[e.label])},title:new Date(e.timestamp).toLocaleString()})).addChildren([new M(this,{classes:[B.fillSpace]}),new ie(this,A.Save,this.host.engine.i18n("state.update.game"),{onClick:()=>{this.updateGame(t,this.host.game.save()),this.host.engine.imessage("state.updated.game",[e.label])}}),new ie(this,A.Edit,this.host.engine.i18n("state.edit.game"),{onClick:()=>{this.storeGame(e.game),this.deleteGame(t,!0),this.host.engine.imessage("state.updated.game",[e.label])}}),new ie(this,A.Copy,this.host.engine.i18n("state.copy.game"),{onClick:()=>{this.copyGame(e.game).catch(R(console)),this.host.engine.imessage("state.copied.game",[e.label])}}),new ie(this,A.Delete,this.host.engine.i18n("state.delete.game"),{onClick:()=>{this.deleteGame(t),this.host.engine.imessage("state.deleted.game",[e.label])}})])))}_refreshStateList(){this.stateList.removeChildren(this.stateList.children),this.stateList.addChildren(this.states.sort((e,t)=>new Date(e.unwrap().timestamp).getTime()-new Date(t.unwrap().timestamp).getTime()).map(e=>[e.unwrap(),e]).map(([e,t])=>new si(this,new Ce(this,`${e.label} (${Es(new Date(e.timestamp),{addSuffix:!0,locale:this.locale})})`,{onClick:()=>{this.loadState(e.state),this.host.engine.imessage("state.loaded.state",[e.label])},title:new Date(e.timestamp).toLocaleString()})).addChildren([new M(this,{classes:[B.fillSpace]}),new ie(this,A.Save,this.host.engine.i18n("state.update.state"),{onClick:()=>{this.updateState(t,this.host.engine.stateSerialize()),this.host.engine.imessage("state.updated.state",[e.label])}}),new ie(this,A.Edit,this.host.engine.i18n("state.edit.state"),{onClick:()=>{this.storeState(e.state),this.deleteState(t,!0),this.host.engine.imessage("state.updated.state",[e.label])}}),new ie(this,A.Copy,this.host.engine.i18n("state.copy.state"),{onClick:()=>{this.copyState(e.state).catch(R(console)),this.host.engine.imessage("state.copied.state",[e.label])}}),new ie(this,A.Delete,this.host.engine.i18n("state.delete.state"),{onClick:()=>{this.deleteState(t),this.host.engine.imessage("state.deleted.state",[e.label])}})])))}async copyState(e){await this.host.copySettings(e,!1)}async copyGame(e){const t=e??this.host.game.save(),i=JSON.stringify(t),n=this.setting.compress.enabled?this.host.game.compressLZData(i):i;await T.window.navigator.clipboard.writeText(n)}import(){const e=T.window.prompt(this.host.engine.i18n("state.loadPrompt"));if(m(e))return;const t=new Date().toDateString();let i=1;const n=()=>this.host.engine.i18n("state.importedState",[`${t} #${i++}`]),a=r=>{try{const h=de.decodeSettings(r);this.storeState(h,n()),this.host.engine.imessage("state.imported.state");return}catch{}try{const h=JSON.parse(r),d=de.decodeSettings(h.state);this.storeState(d,h.label),this.host.engine.imessage("state.imported.state");return}catch{}let o;try{o=JSON.parse(r)}catch{const d=this.host.game.decompressLZData(r);try{o=JSON.parse(d)}catch{if(r.match(/\r?\n/))return r.split(/\r?\n/).map(f=>void a(f));throw new fi("The provided input can not be parsed as anything we understand.")}}let l;if(!m(o)&&"ks"in o&&!m(o.ks)){const h=o.ks.state[0];l=this.storeState(h,n())??void 0,this.host.engine.imessage("state.imported.state"),o.ks=void 0}this.storeGame(o,l),this.host.engine.imessage("state.imported.game")};a(e)}storeGame(e,t){let i=t;return m(i)&&(i=T.window.prompt(this.host.engine.i18n("state.storeGame.prompt"))??void 0),m(i)?null:(i=(i===""?void 0:i)??this.host.engine.i18n("state.unlabeledGame"),i=i.substring(0,127),this.games.push(new yt({game:e??this.host.game.save(),label:i,timestamp:new Date().toISOString()})),this._storeGames(),this.requestRefresh(),i)}storeState(e,t){let i=t;return m(i)&&(i=T.window.prompt(this.host.engine.i18n("state.storeState.prompt"))??void 0),m(i)?null:(i=(i===""?void 0:i)??this.host.engine.i18n("state.unlabeledState"),i=i.substring(0,127),this.states.push(new yt({label:i,state:e??this.host.engine.stateSerialize(),timestamp:new Date().toISOString()})),this._storeStates(),this.requestRefresh(),i)}storeStateFactoryDefaults(){this.storeState(re.DEFAULT_STATE)}storeAutoSave(e){const t=this.states.find(i=>i.unwrap().label==="Auto-Save");if(!m(t)){console.info(...v("Updating existing Auto-Save...")),t.replace({...t.unwrap(),state:e,timestamp:new Date().toISOString()}),this._storeStates(),this.requestRefresh();return}console.info(...v("Storing new Auto-Save...")),this.storeState(e,"Auto-Save")}exportStateAll(){const e=this.states.map(a=>a.unwrap()).map(a=>JSON.stringify({label:a.label,state:de.encodeSettings(a.state,!1),timestamp:a.timestamp})).join(`
42
- `),t=document.createElement("a"),i=new Blob([e],{type:"application/x-ndjson"}),n=URL.createObjectURL(i);t.setAttribute("href",n),t.setAttribute("download",`ks-local-states-${Date.now()}.ndjson`),t.click()}async loadGame(e){this._destructiveActionPrevented()||await new Uo(this.host.game).loadRaw(e)}loadState(e){this._destructiveActionPrevented()||(this.host.engine.stateLoad(e,!0),this.host.refreshEntireUserInterface())}loadAutoSave(){if(this.host.engine.isLoaded){console.info(...v("Not attempting to load Auto-Save, because a state is already loaded."));return}const e=this.states.find(t=>t.unwrap().label==="Auto-Save");if(m(e)){console.info(...v("No Auto-Save settings found."));return}console.info(...v("Loading Auto-Save...")),this.host.engine.stateLoad(e.unwrap().state,!1)}updateGame(e,t){if(this._destructiveActionPrevented())return;const i=e.unwrap().label;e.replace({game:t,label:i,timestamp:new Date().toISOString()}),this._storeGames(),this.requestRefresh()}updateState(e,t){if(this._destructiveActionPrevented())return;const i=e.unwrap().label;e.replace({label:i,state:t,timestamp:new Date().toISOString()}),this._storeStates(),this.requestRefresh()}deleteGame(e,t=!1){if(!t&&this._destructiveActionPrevented())return;const i=this.games.indexOf(e);i<0||(this.games.splice(i,1),this._storeGames(),this.requestRefresh())}deleteState(e,t=!1){if(!t&&this._destructiveActionPrevented())return;const i=this.states.indexOf(e);i<0||(this.states.splice(i,1),this._storeStates(),this.requestRefresh())}_destructiveActionPrevented(){return!this.setting.noConfirm.enabled&&!T.window.confirm(this.host.engine.i18n("state.confirmDestruction"))}}class Re extends _e{constructor(e,t,i,n){super(e,new ue(e,t,{classes:[D.checked,D.setting],icon:n==null?void 0:n.icon}).addChildrenHead([new M(e,{classes:[B.fillSpace]})]),n);u(this,"setting");this.setting=i}}class Do extends Re{constructor(e,t,i){var r,o;const n=e.host.engine.i18n("ui.build");super(e,n,t,{icon:A.Bonfire,onRefreshRequest:()=>{this.expando.ineffective=t.enabled&&Object.values(t.buildings).some(l=>l.enabled&&l.trigger<=0)}});u(this,"_buildings");this._buildings=[];for(const l of this.host.game.bld.buildingGroups){this._buildings.push(new q(this,l.title));for(const h of l.buildings){if(h==="unicornPasture"||m(this.setting.buildings[h]))continue;const d=this.host.game.bld.getBuildingExt(h).meta;if(m(d.stages))m(d.label)||this._buildings.push(this._getResetOption(this,this.setting.buildings[h],i,t,d.label));else{const g=(r=Object.values(this.setting.buildings).find(f=>f.baseBuilding===h))==null?void 0:r.building;this._buildings.push(this._getResetOption(this,this.setting.buildings[h],i,t,d.stages[0].label),this._getResetOption(this,this.setting.buildings[g],i,t,d.stages[1].label,!1,!0))}}l!==this.host.game.bld.buildingGroups[this.host.game.bld.buildingGroups.length-1]&&((o=this._buildings.at(-1))==null||o.element.addClass(ke.delimiter))}const a=new x(this);a.addChildren(this._buildings),this.addChildContent(a)}_getResetOption(e,t,i,n,a,r=!1,o=!1){const l=new H(e,t,i,a,{delimiter:r,onCheck:()=>{e.host.engine.imessage("status.reset.check.enable",[a])},onRefreshRequest:()=>{l.triggerButton.inactive=!t.enabled||t.trigger===-1,l.triggerButton.ineffective=n.enabled&&t.enabled&&t.trigger===-1},onSetTrigger:async()=>{const h=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.absolute"),e.host.engine.i18n("ui.trigger.build.prompt",[a,t.trigger!==-1?e.host.renderAbsolute(t.trigger,i.selected):e.host.engine.i18n("ui.trigger.inactive")]),t.trigger!==-1?e.host.renderAbsolute(t.trigger):"",e.host.engine.i18n("ui.trigger.reset.promptExplainer"));if(h!==void 0){if(h===""||h.startsWith("-")){t.trigger=-1,t.enabled=!1;return}t.trigger=Number(h)}},onUnCheck:()=>{e.host.engine.imessage("status.reset.check.disable",[a])},upgradeIndicator:o});return l.triggerButton.element.addClass(C.lastHeadAction),l}}class No extends Re{constructor(s,e,t){const i=s.host.engine.i18n("ui.faith");super(s,i,e,{icon:A.Religion,onRefreshRequest:()=>{this.expando.ineffective=e.enabled&&Object.values(e.buildings).some(a=>a.enabled&&a.trigger<=0)}}),this.addChildrenHead([new M(s,{classes:[B.fillSpace]})]);const n=[...kt];this.addChildContent(new x(this).addChildren([new q(this,this.host.engine.i18n("$religion.panel.ziggurat.label")),this._getResetOption(this,this.setting.buildings.unicornPasture,t,e,this.host.engine.i18n("$buildings.unicornPasture.label")),...this.host.game.religion.zigguratUpgrades.filter(a=>n.includes(a.name)&&!m(this.setting.buildings[a.name])).map(a=>this._getResetOption(this,this.setting.buildings[a.name],t,e,a.label)),new te(this),...this.host.game.religion.zigguratUpgrades.filter(a=>!n.includes(a.name)&&!m(this.setting.buildings[a.name])).map(a=>this._getResetOption(this,this.setting.buildings[a.name],t,e,a.label)),new te(this),new q(this,this.host.engine.i18n("$religion.panel.orderOfTheSun.label")),...this.host.game.religion.religionUpgrades.filter(a=>!m(this.setting.buildings[a.name])).map(a=>{var r;return this._getResetOption(this,this.setting.buildings[a.name],t,e,a.label,a.name===((r=this.host.game.religion.religionUpgrades.at(-1))==null?void 0:r.name))}),new q(this,this.host.engine.i18n("$religion.panel.cryptotheology.label")),...this.host.game.religion.transcendenceUpgrades.filter(a=>!m(this.setting.buildings[a.name])).map(a=>this._getResetOption(this,this.setting.buildings[a.name],t,e,a.label))]))}_getResetOption(s,e,t,i,n,a=!1,r=!1){const o=new H(s,e,t,n,{delimiter:a,onCheck:()=>{s.host.engine.imessage("status.reset.check.enable",[n])},onRefreshRequest:()=>{o.triggerButton.inactive=!e.enabled||e.trigger===-1,o.triggerButton.ineffective=i.enabled&&e.enabled&&e.trigger===-1},onSetTrigger:async()=>{const l=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.absolute"),s.host.engine.i18n("ui.trigger.build.prompt",[n,e.trigger!==-1?s.host.renderAbsolute(e.trigger,t.selected):s.host.engine.i18n("ui.trigger.inactive")]),e.trigger!==-1?s.host.renderAbsolute(e.trigger):"",s.host.engine.i18n("ui.trigger.reset.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.trigger=-1,e.enabled=!1;return}e.trigger=Number(l)}},onUnCheck:()=>{s.host.engine.imessage("status.reset.check.disable",[n])},upgradeIndicator:r});return o.triggerButton.element.addClass(C.lastHeadAction),o}}class qo extends Re{constructor(s,e,t){const i=s.host.engine.i18n("ui.resources");super(s,i,e,{icon:A.Resources,onRefreshRequest:()=>{this.expando.ineffective=e.enabled&&Object.values(e.resources).some(o=>o.enabled&&o.trigger<0)}}),this.addChildrenHead([new M(s,{classes:[B.fillSpace]})]);const n=this.host.game.resPool.resources,a=[];let r=n[0].title;for(const o of[...n].sort((l,h)=>l.title.localeCompare(h.title,t.selected))){const l=this.setting.resources[o.name],h=new H(this,l,t,X(o.title),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[o.title])},onRefreshRequest:()=>{h.triggerButton.inactive=!l.enabled||l.trigger===-1,h.triggerButton.ineffective=e.enabled&&l.enabled&&l.trigger===-1},onSetTrigger:async()=>{const d=await E.prompt(this,this.host.engine.i18n("ui.trigger.prompt.float"),this.host.engine.i18n("ui.trigger.build.prompt",[o.title,l.trigger!==-1?this.host.renderAbsolute(l.trigger,t.selected):this.host.engine.i18n("ui.trigger.inactive")]),l.trigger!==-1?this.host.renderAbsolute(l.trigger):"",this.host.engine.i18n("ui.trigger.reset.promptExplainer"));if(d!==void 0){if(d===""||d.startsWith("-")){l.trigger=-1,l.enabled=!1;return}l.trigger=s.host.parseAbsolute(d)??l.trigger}},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[o.title])}});h.triggerButton.element.addClass(C.lastHeadAction),this.host.engine.localeSupportsFirstLetterSplits(t.selected)&&r[0]!==o.title[0]&&h.element.addClass(B.splitter),a.push(h),r=o.title}this.addChildContent(new x(this).addChildren(a))}}class zo extends Re{constructor(s,e,t){const i=s.host.engine.i18n("ui.space");super(s,i,e,{icon:A.Space,onRefreshRequest:()=>{this.expando.ineffective=e.enabled&&Object.values(e.buildings).some(n=>n.enabled&&n.trigger<=0)}}),this.addChildrenHead([new M(s,{classes:[B.fillSpace]})]),this.addChildContent(new x(this).addChildren(this.host.game.space.planets.filter(n=>0<n.buildings.length).flatMap((n,a,r)=>[new q(this,this.host.engine.labelForPlanet(n.name)),...n.buildings.filter(o=>!m(this.setting.buildings[o.name])).map((o,l,h)=>this._getResetOption(this,this.setting.buildings[o.name],t,e,o.label,a<r.length-1&&l===h.length-1))])))}_getResetOption(s,e,t,i,n,a=!1,r=!1){const o=new H(s,e,t,n,{delimiter:a,onCheck:()=>{s.host.engine.imessage("status.reset.check.enable",[n])},onRefreshRequest:()=>{o.triggerButton.inactive=!e.enabled||e.trigger===-1,o.triggerButton.ineffective=i.enabled&&e.enabled&&e.trigger===-1},onSetTrigger:async()=>{const l=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.absolute"),s.host.engine.i18n("ui.trigger.build.prompt",[n,e.trigger!==-1?s.host.renderAbsolute(e.trigger,t.selected):s.host.engine.i18n("ui.trigger.inactive")]),e.trigger!==-1?s.host.renderAbsolute(e.trigger):"",s.host.engine.i18n("ui.trigger.reset.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.trigger=-1,e.enabled=!1;return}e.trigger=Number(l)}},onUnCheck:()=>{s.host.engine.imessage("status.reset.check.disable",[n])},upgradeIndicator:r});return o.triggerButton.element.addClass(C.lastHeadAction),o}}class Fo extends Re{constructor(s,e,t){const i=s.host.engine.i18n("ui.time");super(s,i,e,{icon:A.Time,onRefreshRequest:()=>{this.expando.ineffective=e.enabled&&Object.values(e.buildings).some(n=>n.enabled&&n.trigger<=0)}}),this.addChildrenHead([new M(s,{classes:[B.fillSpace]})]),this.addChildContent(new x(this).addChildren([new q(this,this.host.engine.i18n("$workshop.chronoforge.label")),...this.host.game.time.chronoforgeUpgrades.filter(n=>!m(this.setting.buildings[n.name])).map(n=>{var a;return this._getResetOption(this,this.setting.buildings[n.name],t,e,n.label,n.name===((a=this.host.game.time.chronoforgeUpgrades.at(-1))==null?void 0:a.name))}),new q(this,this.host.engine.i18n("$science.voidSpace.label")),...this.host.game.time.voidspaceUpgrades.filter(n=>n.name in this.setting.buildings).map(n=>this._getResetOption(this,this.setting.buildings[n.name],t,e,n.label))]))}_getResetOption(s,e,t,i,n,a=!1,r=!1){const o=new H(s,e,t,n,{delimiter:a,onCheck:()=>{s.host.engine.imessage("status.reset.check.enable",[n])},onRefreshRequest:()=>{o.triggerButton.inactive=!e.enabled||e.trigger===-1,o.triggerButton.ineffective=i.enabled&&e.enabled&&e.trigger===-1},onSetTrigger:async()=>{const l=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.absolute"),s.host.engine.i18n("ui.trigger.build.prompt",[n,e.trigger!==-1?s.host.renderAbsolute(e.trigger,t.selected):s.host.engine.i18n("ui.trigger.inactive")]),e.trigger!==-1?s.host.renderAbsolute(e.trigger):"",s.host.engine.i18n("ui.trigger.reset.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.trigger=-1,e.enabled=!1;return}e.trigger=Number(l)}},onUnCheck:()=>{s.host.engine.imessage("status.reset.check.disable",[n])},upgradeIndicator:r});return o.triggerButton.element.addClass(C.lastHeadAction),o}}class Ho extends Re{constructor(s,e,t){const i=s.host.engine.i18n("ui.upgrades");super(s,i,e,{icon:A.Workshop}),this.addChildrenHead([new M(s,{classes:[B.fillSpace]})]);const n=this.host.game.workshop.upgrades.filter(l=>!m(this.setting.upgrades[l.name])),a=[];let r=n[0].label,o;for(const l of n.sort((h,d)=>h.label.localeCompare(d.label,t.selected))){const h=this.setting.upgrades[l.name],d=this._getResetOption(this,h,l.label);this.host.engine.localeSupportsFirstLetterSplits(t.selected)&&r[0]!==l.label[0]&&(m(o)||o.element.addClass(ke.delimiter),d.element.addClass(B.splitter)),o=d,a.push(d),r=l.label}this.addChildContent(new x(this).addChildren(a))}_getResetOption(s,e,t,i=!1,n=!1){return new S(s,e,t,{delimiter:i,onCheck:()=>{s.host.engine.imessage("status.reset.check.enable",[t])},onUnCheck:()=>{s.host.engine.imessage("status.reset.check.disable",[t])},upgradeIndicator:n})}}class Wo extends N{constructor(e,t,i){const n=e.host.engine.i18n("option.time.reset");super(e,t,new S(e,t,n,{onCheck:r=>{e.host.engine.imessage("status.auto.enable",[n])},onUnCheck:r=>{e.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(e,{classes:[B.fillSpace]})]),{onRefreshRequest:()=>{this.expando.ineffective=t.enabled&&[this._bonfireUi,this._religionUi,this._resourcesUi,this._spaceUi,this._timeUi,this._upgradesUi].some(r=>r.expando.ineffective)}});u(this,"_bonfireUi");u(this,"_religionUi");u(this,"_resourcesUi");u(this,"_spaceUi");u(this,"_timeUi");u(this,"_upgradesUi");const a=new x(this,{hasDisableAll:!1,hasEnableAll:!1});this._bonfireUi=new Do(this,this.setting.bonfire,i),this._religionUi=new No(this,this.setting.religion,i),this._resourcesUi=new qo(this,this.setting.resources,i),this._spaceUi=new zo(this,this.setting.space,i),this._timeUi=new Fo(this,this.setting.time,i),this._upgradesUi=new Ho(this,this.setting.upgrades,i),a.addChildren([this._bonfireUi,this._religionUi,this._resourcesUi,this._spaceUi,this._timeUi,this._upgradesUi]),this.addChildContent(a)}}class As extends x{constructor(e,t,i){super(e,i);u(this,"setting");this.setting=t;const n=(r,o)=>{const l=e.host.engine.labelForCycle(r);return new S(e,o,l,{onCheck:h=>{var d;(d=i==null?void 0:i.onCheckCycle)==null||d.call(i,l,o,h)},onUnCheck:h=>{var d;(d=i==null?void 0:i.onUnCheckCycle)==null||d.call(i,l,o,h)}})},a=[n("charon",this.setting.charon),n("umbra",this.setting.umbra),n("yarn",this.setting.yarn),n("helios",this.setting.helios),n("cath",this.setting.cath),n("redmoon",this.setting.redmoon),n("dune",this.setting.dune),n("piscine",this.setting.piscine),n("terminus",this.setting.terminus),n("kairo",this.setting.kairo)];this.addChildren(a),this.element[0].addEventListener("enableAll",()=>{for(const r of a)r.check(!0)}),this.element[0].addEventListener("disableAll",()=>{for(const r of a)r.uncheck(!0)})}}class Ut extends x{constructor(e,t,i){super(e,i);u(this,"setting");u(this,"spring");u(this,"summer");u(this,"autumn");u(this,"winter");this.setting=t;const n=(a,r)=>new S(this,r,a,{onCheck:o=>{var l;(l=i==null?void 0:i.onCheckSeason)==null||l.call(i,a,r,o)},onUnCheck:o=>{var l;(l=i==null?void 0:i.onUnCheckSeason)==null||l.call(i,a,r,o)}});this.spring=n(this.host.engine.i18n("$calendar.season.spring"),this.setting.spring),this.summer=n(this.host.engine.i18n("$calendar.season.summer"),this.setting.summer),this.autumn=n(this.host.engine.i18n("$calendar.season.autumn"),this.setting.autumn),this.winter=n(this.host.engine.i18n("$calendar.season.winter"),this.setting.winter),this.addChildren([this.spring,this.summer,this.autumn,this.winter])}toString(){return`[${Ut.name}#${this.componentId}]`}}class Go extends N{constructor(s,e,t,i,n){const a=s.host.engine.i18n("option.time.activeHeatTransfer");super(s,e,new H(s,e,t,a,{onCheck:r=>{s.host.engine.imessage("status.auto.enable",[a])},onSetTrigger:async()=>{const r=await E.prompt(s,s.host.engine.i18n("ui.trigger.activeHeatTransfer.prompt"),s.host.engine.i18n("ui.trigger.activeHeatTransfer.promptTitle",[s.host.renderPercentage(e.trigger,t.selected,!0)]),s.host.renderPercentage(e.trigger),s.host.engine.i18n("ui.trigger.activeHeatTransfer.promptExplainer"));r===void 0||r===""||r.startsWith("-")||(e.trigger=s.host.parsePercentage(r))},onUnCheck:r=>{s.host.engine.imessage("status.auto.disable",[a]),e.activeHeatTransferStatus.enabled=!1}}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled,this.settingItem.triggerButton.ineffective=n.enabled&&i.enabled&&e.enabled&&e.trigger===-1,this.expando.ineffective=n.enabled&&i.enabled&&e.enabled&&!Object.values(e.cycles).some(r=>r.enabled),e.activeHeatTransferStatus.enabled?(this.head.elementLabel.attr("data-ks-active-from","◎"),this.head.elementLabel.attr("data-ks-active-to","◎"),this.head.elementLabel.addClass(Pt.active)):this.head.elementLabel.removeClass(Pt.active)}}),this.addChildContent(new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new As(this,this.setting.cycles,{onCheckCycle:r=>{this.host.engine.imessage("time.heatTransfer.cycle.enable",[r])},onUnCheckCycle:r=>{this.host.engine.imessage("time.heatTransfer.cycle.disable",[r])}})]))}}class Zo extends N{constructor(e,t,i,n){const a=e.host.engine.i18n("option.time.skip");super(e,t,new At(e,t,i,a,{onCheck:r=>{e.host.engine.imessage("status.auto.enable",[a])},onRefreshMax(){this.maxButton.updateLabel(e.host.renderAbsolute(t.max)),this.maxButton.element[0].title=t.max<0?e.host.engine.i18n("ui.max.timeSkip.titleInfinite",[a]):t.max===0?e.host.engine.i18n("ui.max.timeSkip.titleZero",[a]):e.host.engine.i18n("ui.max.timeSkip.title",[e.host.renderAbsolute(t.max),a])},onRefreshTrigger(){this.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger",[t.trigger<0?e.host.engine.i18n("ui.trigger.section.inactive"):`${e.host.renderFloat(t.trigger,i.selected)} TC`])},onSetMax:async()=>{const r=await E.prompt(e,e.host.engine.i18n("ui.max.timeSkip.prompt"),e.host.engine.i18n("ui.max.timeSkip.promptTitle",[e.host.renderAbsolute(t.max,i.selected)]),e.host.renderAbsolute(t.max),e.host.engine.i18n("ui.max.timeSkip.promptExplainer"));if(r!==void 0){if(r===""||r.startsWith("-")){t.max=-1;return}r==="0"&&(t.enabled=!1),t.max=e.host.parseAbsolute(r)??t.max}},onSetTrigger:async()=>{const r=await E.prompt(e,e.host.engine.i18n("ui.trigger.timeSkip.prompt"),e.host.engine.i18n("ui.trigger.timeSkip.promptTitle",[e.host.renderAbsolute(t.trigger,i.selected)]),e.host.renderAbsolute(t.trigger),e.host.engine.i18n("ui.trigger.timeSkip.promptExplainer"));r===void 0||r===""||r.startsWith("-")||(t.trigger=e.host.parseAbsolute(r)??t.trigger)},onUnCheck:r=>{e.host.engine.imessage("status.auto.disable",[a])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.maxButton.inactive=!t.enabled||t.max===-1,this.settingItem.triggerButton.inactive=!t.enabled||t.trigger===-1,this.settingItem.maxButton.ineffective=n.enabled&&t.enabled&&t.max===0,this._cycles.expando.ineffective=n.enabled&&t.enabled&&!Object.values(t.cycles).some(r=>r.enabled),this._seasons.expando.ineffective=n.enabled&&t.enabled&&!Object.values(t.seasons).some(r=>r.enabled)}});u(this,"_cycles");u(this,"_seasons");u(this,"_activeHeatTransferUI");this.settingItem.triggerButton.element.removeClass(C.lastHeadAction),this._cycles=new _e(this,new ue(this,X(this.host.engine.i18n("ui.cycles")),{classes:[D.checked,D.setting],icon:A.Cycles}).addChildrenHead([new M(this,{classes:[B.fillSpace]})])).addChildrenContent([new As(this,this.setting.cycles,{onCheckCycle:r=>{this.host.engine.imessage("time.skip.cycle.enable",[r])},onUnCheckCycle:r=>{this.host.engine.imessage("time.skip.cycle.disable",[r])}})]),this._seasons=new _e(this,new ue(this,X(this.host.engine.i18n("trade.seasons")),{classes:[D.checked,D.setting],icon:A.Seasons}).addChildrenHead([new M(this,{classes:[B.fillSpace]})])).addChildrenContent([new Ut(this,this.setting.seasons,{onCheckSeason:r=>{this.host.engine.imessage("time.skip.season.enable",[r])},onUnCheckSeason:r=>{this.host.engine.imessage("time.skip.season.disable",[r])}})]),this._activeHeatTransferUI=new Go(this,this.setting.activeHeatTransfer,i,t,n),this.addChildContent(new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([this._cycles,this._seasons,new S(this,this.setting.ignoreOverheat,this.host.engine.i18n("option.time.skip.ignoreOverheat")),this._activeHeatTransferUI]))}}class yi extends N{constructor(e,t,i){console.debug(...v(`Constructing ${yi.name}`));const n=e.host.engine.i18n("ui.timeCtrl");super(e,t,new S(e,t,n,{onCheck:o=>{e.host.engine.imessage("status.auto.enable",[n])},onUnCheck:o=>{e.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(e,{classes:[B.fillSpace]})]),{onRefreshRequest:()=>{this.expando.ineffective=t.enabled&&[this._timeSkipUi,this._resetUi].some(o=>o.expando.ineffective)}});u(this,"_items");u(this,"_accelerateTime");u(this,"_timeSkipUi");u(this,"_resetUi");const a=new x(this,{hasDisableAll:!1,hasEnableAll:!1}),r=this.host.engine.i18n("option.accelerate");this._accelerateTime=new H(this,this.setting.accelerateTime,i,r,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[r])},onRefresh:()=>{this._accelerateTime.triggerButton.inactive=!this.setting.accelerateTime.enabled,this._accelerateTime.triggerButton.ineffective=this.setting.enabled&&this.setting.accelerateTime.enabled&&this.setting.accelerateTime.trigger===-1},onSetTrigger:async()=>{const o=await E.prompt(this,this.host.engine.i18n("ui.trigger.accelerateTime.prompt"),this.host.engine.i18n("ui.trigger.accelerateTime.promptTitle",[this.host.renderPercentage(this.setting.accelerateTime.trigger,i.selected,!0)]),this.host.renderPercentage(this.setting.accelerateTime.trigger),this.host.engine.i18n("ui.trigger.accelerateTime.promptExplainer"));o===void 0||o===""||o.startsWith("-")||(this.setting.accelerateTime.trigger=this.host.parsePercentage(o))},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[r])}}),this._accelerateTime.triggerButton.element.addClass(C.lastHeadAction),this._timeSkipUi=new Zo(this,this.setting.timeSkip,i,t),this._resetUi=new Wo(this,this.setting.reset,i),this._items=[this._accelerateTime,this._timeSkipUi,this._resetUi],a.addChildren(this._items),this.addChildContent(a)}}class wi extends N{constructor(s,e,t){console.debug(...v(`Constructing ${wi.name}`));const i=s.host.engine.i18n("ui.time");super(s,e,new H(s,e,t,i,{onCheck:n=>{s.host.engine.imessage("status.auto.enable",[i])},onRefresh:()=>{this.settingItem.triggerButton.inactive=!e.enabled||e.trigger===-1},onRefreshTrigger(){this.triggerButton.element[0].title=s.host.engine.i18n("ui.trigger.section",[e.trigger<0?s.host.engine.i18n("ui.trigger.section.inactive"):s.host.renderPercentage(e.trigger,t.selected,!0)])},onSetTrigger:async()=>{const n=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.percentage"),s.host.engine.i18n("ui.trigger.section.prompt",[i,e.trigger!==-1?s.host.renderPercentage(e.trigger,t.selected,!0):s.host.engine.i18n("ui.infinity")]),e.trigger!==-1?s.host.renderPercentage(e.trigger):"",s.host.engine.i18n("ui.trigger.section.promptExplainer"));if(n!==void 0){if(n===""||n.startsWith("-")){e.trigger=-1;return}e.trigger=s.host.parsePercentage(n)}},onUnCheck:n=>{s.host.engine.imessage("status.auto.disable",[i])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled||e.trigger<0,this.settingItem.triggerButton.ineffective=e.enabled&&e.trigger<0&&Object.values(e.buildings).some(n=>n.enabled&&0<n.max&&n.trigger<0),this.expando.ineffective=e.enabled&&Object.values(e.buildings).some(n=>n.enabled&&(n.max===0||n.trigger<0&&e.trigger<0))}}),this.addChildrenContent([new x(this).addChildren([new q(this,this.host.engine.i18n("$workshop.chronoforge.label")),...this.host.game.time.chronoforgeUpgrades.filter(n=>!m(this.setting.buildings[n.name])).map(n=>{var a;return oe.getBuildOption(this,this.setting.buildings[n.name],t,this.setting,n.label,i,{delimiter:n.name===((a=this.host.game.time.chronoforgeUpgrades.at(-1))==null?void 0:a.name),renderLabelTrigger:!1})}),new q(this,this.host.engine.i18n("$science.voidSpace.label")),...this.host.game.time.voidspaceUpgrades.filter(n=>n.name in this.setting.buildings).map(n=>oe.getBuildOption(this,this.setting.buildings[n.name],t,this.setting,n.label,i,{renderLabelTrigger:!1}))]),new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new q(this,this.host.engine.i18n("ui.additional")),new S(this,this.setting.fixCryochambers,this.host.engine.i18n("option.fix.cry"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.fix.cry")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.fix.cry")])}})])])}}const Ko={buyButton:"_buyButton_10eul_1"};class ki extends Ce{constructor(e,t,i,n){super(e,void 0,{onClick:async()=>{const a=await E.prompt(e,e.host.engine.i18n("blackcoin.buy.prompt"),e.host.engine.i18n("blackcoin.buy.promptTitle",[e.host.renderAbsolute(t.buy,i.selected)]),e.host.renderAbsolute(t.buy),e.host.engine.i18n("blackcoin.buy.promptExplainer"));if(a!==void 0){if(a===""||a.startsWith("-")){t.buy=-1;return}t.buy=e.host.parseAbsolute(a)??t.buy}},onRefresh:()=>{var a;this.element.prop("title",this.host.engine.i18n("blackcoin.buy.title",[this.host.renderAbsolute(this.setting.buy)])),this.element.text(this.host.engine.i18n("blackcoin.buy",[this.host.renderAbsolute(this.setting.buy)])),(a=n==null?void 0:n.onRefresh)==null||a.call(this)}});u(this,"setting");this.element.addClass(Ko.buyButton),this.setting=t}toString(){return`[${ki.name}#${this.componentId}]`}}const Vo={sellButton:"_sellButton_1tmvd_1"};class _i extends Ce{constructor(e,t,i,n){super(e,void 0,{onClick:async()=>{const a=await E.prompt(e,e.host.engine.i18n("blackcoin.sell.prompt"),e.host.engine.i18n("blackcoin.sell.promptTitle",[e.host.renderAbsolute(t.sell,i.selected)]),e.host.renderAbsolute(t.sell),e.host.engine.i18n("blackcoin.sell.promptExplainer"));if(a!==void 0){if(a===""||a.startsWith("-")){t.sell=-1;return}t.sell=e.host.parseAbsolute(a)??t.sell}},onRefresh:()=>{var a;this.element.prop("title",this.host.engine.i18n("blackcoin.sell.title",[this.host.renderAbsolute(this.setting.sell)])),this.element.text(this.host.engine.i18n("blackcoin.sell",[this.host.renderAbsolute(this.setting.sell)])),(a=n==null?void 0:n.onRefresh)==null||a.call(n)}});u(this,"setting");this.element.addClass(Vo.sellButton),this.setting=t}toString(){return`[${_i.name}#${this.componentId}]`}}class Dt extends J{constructor(e,t,i){super(e,"",A.Eco,{border:!1,classes:[],onClick:()=>{var n,a;this.setting.limited=!this.setting.limited,this.setting.limited?(n=i==null?void 0:i.onLimitedCheck)==null||n.call(this):(a=i==null?void 0:i.onLimitedUnCheck)==null||a.call(this)},onRefresh:()=>{var n;this.updateTitle(this.host.engine.i18n(this.setting.limited?"ui.limited.on":"ui.limited.off")),this.setting.limited&&!this.inactive?this.element.removeClass(C.inactive):this.element.addClass(C.inactive),(n=i==null?void 0:i.onRefresh)==null||n.call(this)}});u(this,"setting");this.setting=t;for(const n of(i==null?void 0:i.classes)??[])this.element.addClass(n)}toString(){return`[${Dt.name}#${this.componentId}]`}}class Ci extends S{constructor(e,t,i,n){super(e,t,i,n);u(this,"limitedButton");this.limitedButton=new Dt(e,t,{border:!1,onLimitedCheck:n!=null&&n.onLimitedCheck?()=>{var a;return(a=n.onLimitedCheck)==null?void 0:a.call(this)}:void 0,onLimitedUnCheck:n!=null&&n.onLimitedUnCheck?()=>{var a;return(a=n.onLimitedUnCheck)==null?void 0:a.call(this)}:void 0}),this.addChildrenHead([new M(e,{classes:[B.fillSpace]}),this.limitedButton])}toString(){return`[${Ci.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class Si extends Ci{constructor(e,t,i,n,a){super(e,t,n,a);u(this,"triggerButton");this.triggerButton=new Ee(e,t,i,{border:!1,onClick:async()=>{await a.onSetTrigger.call(this)},onRefresh:a!=null&&a.onRefreshTrigger?()=>{var r;return(r=a.onRefreshTrigger)==null?void 0:r.call(this)}:void 0,renderLabel:(a==null?void 0:a.renderLabelTrigger)??!0}),this.addChildHead(this.triggerButton)}toString(){return`[${Si.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class Nt extends S{constructor(e,t,i,n){super(e,t,i,n);u(this,"maxButton");this.maxButton=new Pe(e,t,{border:!1,onClick:async()=>{await n.onSetMax.call(this)},onRefresh:n!=null&&n.onRefreshMax?()=>{var a;return(a=n.onRefreshMax)==null?void 0:a.call(this)}:void 0}),this.addChildrenHead([new M(e,{classes:[B.fillSpace]}),this.maxButton])}toString(){return`[${Nt.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class jo extends N{constructor(s,e,t,i){const n=s.host.engine.i18n("option.embassies");super(s,e,new H(s,e,t,n,{onCheck:r=>{s.host.engine.imessage("status.auto.enable",[n])},onSetTrigger:async()=>{const r=await E.prompt(s,s.host.engine.i18n("ui.trigger.embassies.prompt"),s.host.engine.i18n("ui.trigger.embassies.promptTitle",[s.host.renderPercentage(e.trigger,t.selected,!0)]),s.host.renderPercentage(e.trigger),s.host.engine.i18n("ui.trigger.embassies.promptExplainer"));r===void 0||r===""||r.startsWith("-")||(e.trigger=s.host.parsePercentage(r))},onUnCheck:r=>{s.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled,this.settingItem.triggerButton.ineffective=e.enabled&&e.trigger===-1,this.expando.ineffective=i.enabled&&e.enabled&&!Object.values(e.races).some(r=>r.enabled)}});const a=new x(this).addChildren(this.host.game.diplomacy.races.filter(r=>r.name!=="leviathans"&&!m(this.setting.races[r.name])).map(r=>this._makeEmbassySetting(this,this.setting.races[r.name],t.selected,e,r.title)));this.addChildContent(a)}_makeEmbassySetting(s,e,t,i,n){const a=async()=>{const o=await E.prompt(s,s.host.engine.i18n("ui.max.prompt.absolute"),s.host.engine.i18n("ui.max.build.prompt",[n,s.host.renderAbsolute(e.max,t)]),s.host.renderAbsolute(e.max),s.host.engine.i18n("ui.max.build.promptExplainer"));if(o!==void 0){if(o===""||o.startsWith("-")){e.max=-1;return}o==="0"&&(e.enabled=!1),e.max=s.host.parseAbsolute(o)??e.max}},r=new Nt(s,e,n,{onCheck:o=>{if(s.host.engine.imessage("status.sub.enable",[n]),e.max===0&&!o)return a()},onRefresh:()=>{r.maxButton.inactive=!e.enabled||e.max===-1,r.maxButton.ineffective=i.enabled&&e.enabled&&e.max===0},onRefreshMax:()=>{r.maxButton.updateLabel(s.host.renderAbsolute(e.max)),r.maxButton.element[0].title=e.max<0?s.host.engine.i18n("ui.max.embassy.titleInfinite",[n]):e.max===0?s.host.engine.i18n("ui.max.embassy.titleZero",[n]):s.host.engine.i18n("ui.max.embassy.title",[s.host.renderAbsolute(e.max),n])},onSetMax:a,onUnCheck:()=>{s.host.engine.imessage("status.sub.disable",[n])}});return r.maxButton.element.addClass(C.lastHeadAction),r}}class xi extends N{constructor(e,t,i){console.debug(...v(`Constructing ${xi.name}`));const n=e.host.engine.i18n("ui.trade");super(e,t,new H(e,t,i,n,{onCheck:o=>{e.host.engine.imessage("status.auto.enable",[n])},onRefreshTrigger(){this.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger.section",[t.trigger<0?e.host.engine.i18n("ui.trigger.section.inactive"):e.host.renderPercentage(t.trigger,i.selected,!0)])},onSetTrigger:async()=>{const o=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.percentage"),e.host.engine.i18n("ui.trigger.section.prompt",[n,t.trigger!==-1?e.host.renderPercentage(t.trigger,i.selected,!0):e.host.engine.i18n("ui.infinity")]),t.trigger!==-1?e.host.renderPercentage(t.trigger):"",e.host.engine.i18n("ui.trigger.section.promptExplainer"));if(o!==void 0){if(o===""||o.startsWith("-")){t.trigger=-1;return}t.trigger=e.host.parsePercentage(o)}},onUnCheck:o=>{e.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!t.enabled||t.trigger===-1,this.settingItem.triggerButton.ineffective=t.enabled&&t.trigger<0&&Object.values(t.races).some(o=>o.enabled&&o.trigger<0),this.expando.ineffective=t.enabled&&Object.values(this._racePanels).some(o=>o.expando.ineffective||o.settingItem.triggerButton.ineffective)}});u(this,"_racePanels");this._racePanels=this.host.game.diplomacy.races.filter(o=>!m(this.setting.races[o.name])).map(o=>{var l;return this._getTradeOption(this,this.setting.races[o.name],i,t,o.title,n,o.name===((l=this.host.game.diplomacy.races.at(-2))==null?void 0:l.name))});const a=new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren(this._racePanels);a.addChild(new S(this,this.setting.feedLeviathans,this.host.engine.i18n("option.autofeed"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.autofeed")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.autofeed")])}})),a.addChild(new N(this,this.setting.tradeBlackcoin,new H(this,this.setting.tradeBlackcoin,i,this.host.engine.i18n("option.crypto"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.crypto")])},onRefreshRequest(){this.triggerButton.inactive=!this.setting.enabled||this.setting.trigger===-1},onSetTrigger:async()=>{const o=await E.prompt(this,this.host.engine.i18n("ui.trigger.crypto.promptTitle"),this.host.engine.i18n("ui.trigger.crypto.prompt",[this.host.renderAbsolute(this.setting.tradeBlackcoin.trigger,i.selected)]),this.host.renderAbsolute(this.setting.tradeBlackcoin.trigger),this.host.engine.i18n("ui.trigger.crypto.promptExplainer"));o===void 0||o===""||o.startsWith("-")||(this.setting.tradeBlackcoin.trigger=this.host.parseAbsolute(o)??this.setting.tradeBlackcoin.trigger)},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.crypto")])}})).addChildrenContent([new ki(this,this.setting.tradeBlackcoin,i),new _i(this,this.setting.tradeBlackcoin,i)])),this.addChildContent(a);const r=new x(this,{hasDisableAll:!1,hasEnableAll:!1});r.addChild(new q(this,this.host.engine.i18n("ui.additional"))),r.addChild(new jo(this,this.setting.buildEmbassies,i,t)),r.addChild(new S(this,this.setting.unlockRaces,this.host.engine.i18n("ui.upgrade.races"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("ui.upgrade.races")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("ui.upgrade.races")])}})),this.addChildContent(r)}_getTradeOption(e,t,i,n,a,r,o=!1,l=!1){const h=new Si(e,t,i,a,{delimiter:o,onCheck:()=>{e.host.engine.imessage("status.sub.enable",[a])},onLimitedCheck:()=>{e.host.engine.imessage("trade.limited",[a])},onLimitedUnCheck:()=>{e.host.engine.imessage("trade.unlimited",[a])},onRefreshTrigger:()=>{h.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger",[t.trigger<0?n.trigger<0?e.host.engine.i18n("ui.trigger.section.blocked",[r]):`${e.host.renderPercentage(n.trigger,i.selected,!0)} (${e.host.engine.i18n("ui.trigger.section.inherited")})`:e.host.renderPercentage(t.trigger,i.selected,!0)])},onSetTrigger:async()=>{const g=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.percentage"),e.host.engine.i18n("ui.trigger.section.prompt",[a,t.trigger!==-1?e.host.renderPercentage(t.trigger,i.selected,!0):e.host.engine.i18n("ui.trigger.section.inherited")]),t.trigger!==-1?e.host.renderPercentage(t.trigger):"",e.host.engine.i18n("ui.trigger.section.promptExplainer"));if(g!==void 0){if(g===""||g.startsWith("-")){t.trigger=-1;return}t.trigger=e.host.parsePercentage(g)}},onUnCheck:()=>{e.host.engine.imessage("status.sub.disable",[a])},renderLabelTrigger:!1,upgradeIndicator:l}),d=new N(e,t,h,{onRefreshRequest:()=>{h.limitedButton.inactive=!t.enabled||!t.limited,h.triggerButton.inactive=!t.enabled||t.trigger===-1,h.triggerButton.ineffective=n.enabled&&t.enabled&&n.trigger===-1&&t.trigger===-1,d.expando.ineffective=n.enabled&&t.enabled&&!t.seasons.autumn.enabled&&!t.seasons.spring.enabled&&!t.seasons.summer.enabled&&!t.seasons.winter.enabled}}).addChildContent(new Ut(e,t.seasons,{onCheckSeason:g=>{e.host.engine.imessage("trade.season.enable",[X(a),g])},onUnCheckSeason:g=>{e.host.engine.imessage("trade.season.disable",[X(a),g])}}));return d}}const Ti={spacer:"_spacer_auis8_44",ui:"_ui_auis8_49",showActivity:"_showActivity_auis8_66"};class Ei extends N{constructor(e,t,i){console.debug(...v(`Constructing ${Ei.name}`));const n=e.host.engine.i18n("ui.distribute");super(e,t,new S(e,t,n,{onCheck:o=>{e.host.engine.imessage("status.auto.enable",[n])},onUnCheck:o=>{e.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(e,{classes:[B.fillSpace]})]),{onRefreshRequest:()=>{this.expando.ineffective=t.enabled&&Object.values(t.jobs).some(o=>o.enabled&&o.max===0)}});u(this,"_hunt");u(this,"_festivals");u(this,"_promoteKittens");u(this,"_promoteLeader");u(this,"_electLeader");const a=new x(this).addChildren(this.host.game.village.jobs.filter(o=>!m(this.setting.jobs[o.name])).map(o=>this._getDistributeOption(this.setting.jobs[o.name],i.selected,t,o.title)));this.addChildContent(a);const r=new x(this,{hasDisableAll:!1,hasEnableAll:!1});r.addChild(new q(this,this.host.engine.i18n("ui.additional"))),this._hunt=new H(this,this.setting.hunt,i,this.host.engine.i18n("option.hunt"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.hunt")])},onRefreshRequest:()=>{this._hunt.triggerButton.inactive=!this.setting.hunt.enabled,this._hunt.triggerButton.ineffective=this.setting.enabled&&this.setting.hunt.enabled&&this.setting.hunt.trigger===-1},onSetTrigger:async()=>{const o=await E.prompt(this,this.host.engine.i18n("ui.trigger.prompt.percentage"),this.host.engine.i18n("ui.trigger.hunt.prompt",[this.host.renderPercentage(this.setting.hunt.trigger,i.selected,!0)]),this.host.renderPercentage(this.setting.hunt.trigger),this.host.engine.i18n("ui.trigger.hunt.promptExplainer"));o===void 0||o===""||o.startsWith("-")||(this.setting.hunt.trigger=this.host.parsePercentage(o))},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.hunt")])}}),this._hunt.triggerButton.element.addClass(C.lastHeadAction),r.addChild(this._hunt),this._festivals=new S(this,this.setting.holdFestivals,this.host.engine.i18n("option.festival"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.festival")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.festival")])}}),r.addChild(this._festivals),this._promoteKittens=new H(this,this.setting.promoteKittens,i,this.host.engine.i18n("option.promotekittens"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.promotekittens")])},onRefresh:()=>{this._promoteKittens.triggerButton.inactive=!this.setting.promoteKittens.enabled,this._promoteKittens.triggerButton.ineffective=this.setting.enabled&&this.setting.promoteKittens.enabled&&this.setting.promoteKittens.trigger===-1},onSetTrigger:async()=>{const o=await E.prompt(this,this.host.engine.i18n("ui.trigger.promoteKittens.promptTitle"),this.host.engine.i18n("ui.trigger.promoteKittens.prompt",[this.host.renderPercentage(this.setting.promoteKittens.trigger,i.selected,!0)]),this.host.renderPercentage(this.setting.promoteKittens.trigger),this.host.engine.i18n("ui.trigger.promoteKittens.promptExplainer"));o===void 0||o===""||o.startsWith("-")||(this.setting.promoteKittens.trigger=this.host.parsePercentage(o))},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.promotekittens")])}}),this._promoteKittens.triggerButton.element.addClass(C.lastHeadAction),r.addChild(this._promoteKittens),this._promoteLeader=new S(this,this.setting.promoteLeader,this.host.engine.i18n("option.promote"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.promote")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.promote")])}}),r.addChild(this._promoteLeader);for(const o of this.setting.electLeader.job.options)o.value==="any"?o.label=this.host.engine.i18n("option.elect.job.any"):o.label=this.host.engine.i18n(`$village.job.${o.value}`);for(const o of this.setting.electLeader.trait.options)o.label=this.host.engine.i18n(`$village.trait.${o.value}`);this._electLeader=new S(this,this.setting.electLeader,this.host.engine.i18n("option.elect"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.elect")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.elect")])}}).addChildren([new Ie(this,this.host.engine.i18n("option.elect.job"),this.setting.electLeader.job),new Ie(this,this.host.engine.i18n("option.elect.trait"),this.setting.electLeader.trait)]),r.addChild(this._electLeader),this.addChildContent(r)}_getDistributeOption(e,t,i,n,a=!1){const r=async()=>{const l=await E.prompt(this,this.host.engine.i18n("ui.max.distribute.prompt",[n]),this.host.engine.i18n("ui.max.distribute.promptTitle",[n,this.host.renderAbsolute(e.max,t)]),this.host.renderAbsolute(e.max),this.host.engine.i18n("ui.max.distribute.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.max=-1;return}l==="0"&&(e.enabled=!1),e.max=this.host.parseAbsolute(l)??e.max}},o=new Nt(this,e,n,{delimiter:a,onCheck:l=>{if(this.host.engine.imessage("status.sub.enable",[n]),e.max===0&&!l)return r()},onRefresh:()=>{o.maxButton.inactive=!e.enabled||e.max===-1,o.maxButton.ineffective=i.enabled&&e.enabled&&e.max===0},onRefreshMax:()=>{o.maxButton.updateLabel(this.host.renderAbsolute(e.max)),o.maxButton.element[0].title=e.max<0?this.host.engine.i18n("ui.max.distribute.titleInfinite",[n]):e.max===0?this.host.engine.i18n("ui.max.distribute.titleZero",[n]):this.host.engine.i18n("ui.max.distribute.title",[this.host.renderAbsolute(e.max),n])},onSetMax:r,onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[n])}});return o.maxButton.element.addClass(C.lastHeadAction),o}}class Ri extends S{constructor(e,t,i,n,a){super(e,t,n,a);u(this,"limitedButton");u(this,"maxButton");u(this,"triggerButton");this.limitedButton=new Dt(e,t,{...a,classes:[Et.headAction]}),this.maxButton=new Pe(e,t,{alignment:"right",border:!1,classes:[C.headAction],onClick:()=>a.onSetMax.call(this),onRefresh:a!=null&&a.onRefreshMax?()=>{var r;return(r=a.onRefreshMax)==null?void 0:r.call(this)}:void 0}),this.triggerButton=new Ee(e,t,i,{border:!1,classes:[C.lastHeadAction],onClick:async()=>{await a.onSetTrigger.call(this)},onRefresh:a!=null&&a.onRefreshTrigger?()=>{var r;return(r=a.onRefreshTrigger)==null?void 0:r.call(this)}:void 0,renderLabel:(a==null?void 0:a.renderLabelTrigger)??!0}),this.addChildrenHead([new M(e,{classes:[B.fillSpace]}),this.limitedButton,this.maxButton,this.triggerButton])}toString(){return`[${Ri.name}#${this.componentId}]`}}class Jo extends N{constructor(s,e,t){const i=s.host.engine.i18n("ui.upgrade.upgrades");super(s,e,new H(s,e,t,i,{onCheck:l=>{s.host.engine.imessage("status.auto.enable",[i])},onRefreshTrigger(){this.triggerButton.element[0].title=s.host.engine.i18n("ui.trigger",[e.trigger===-1?s.host.engine.i18n("ui.trigger.section.inactive"):s.host.renderPercentage(e.trigger,t.selected,!0)])},onSetTrigger:async()=>{const l=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.percentage"),s.host.engine.i18n("ui.trigger.section.prompt",[i,e.trigger!==-1?s.host.renderPercentage(e.trigger,t.selected,!0):s.host.engine.i18n("ui.infinity")]),e.trigger!==-1?s.host.renderPercentage(e.trigger):"",s.host.engine.i18n("ui.trigger.section.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.trigger=-1;return}e.trigger=s.host.parsePercentage(l)}},onUnCheck:l=>{s.host.engine.imessage("status.auto.disable",[i])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled||e.trigger===-1,this.settingItem.triggerButton.ineffective=e.enabled&&e.trigger<0&&Object.values(e.upgrades).some(l=>l.enabled&&l.trigger<0),this.expando.ineffective=e.enabled&&!Object.values(e.upgrades).some(l=>l.enabled)}});const n=this.host.game.workshop.upgrades.filter(l=>!m(this.setting.upgrades[l.name])),a=[];let r=n[0].label,o;for(const l of n.sort((h,d)=>h.label.localeCompare(d.label,t.selected))){const h=this.setting.upgrades[l.name],d=new H(this,h,t,l.label,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[l.label])},onRefreshRequest:()=>{d.triggerButton.inactive=!h.enabled||h.trigger===-1,d.triggerButton.ineffective=e.enabled&&h.enabled&&e.trigger===-1&&h.trigger===-1},onRefreshTrigger:()=>{d.triggerButton.element[0].title=this.host.engine.i18n("ui.trigger",[h.trigger<0?e.trigger<0?this.host.engine.i18n("ui.trigger.build.blocked",[i]):`${this.host.renderPercentage(e.trigger,t.selected,!0)} (${this.host.engine.i18n("ui.trigger.section.inherited")})`:this.host.renderPercentage(h.trigger,t.selected,!0)])},onSetTrigger:async()=>{const g=await E.prompt(this,this.host.engine.i18n("ui.trigger.prompt.percentage"),this.host.engine.i18n("ui.trigger.section.prompt",[i,h.trigger!==-1?this.host.renderPercentage(h.trigger,t.selected,!0):this.host.engine.i18n("ui.trigger.section.inherited")]),h.trigger!==-1?this.host.renderPercentage(h.trigger):"",this.host.engine.i18n("ui.trigger.section.promptExplainer"));if(g!==void 0){if(g===""||g.startsWith("-")){h.trigger=-1;return}h.trigger=this.host.parsePercentage(g)}},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[l.label])},renderLabelTrigger:!1});d.triggerButton.element.addClass(C.lastHeadAction),this.host.engine.localeSupportsFirstLetterSplits(t.selected)&&r[0]!==l.label[0]&&(m(o)||o.element.addClass(ke.delimiter),d.element.addClass(B.splitter)),o=d,a.push(d),r=l.label}this.addChildContent(new x(this).addChildren(a))}}class Mi extends N{constructor(e,t,i){console.debug(...v(`Constructing ${Mi.name}`));const n=e.host.engine.i18n("ui.craft");super(e,t,new H(e,t,i,n,{onCheck:l=>{e.host.engine.imessage("status.auto.enable",[n])},onRefreshTrigger(){this.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger.section",[t.trigger<0?e.host.engine.i18n("ui.trigger.section.inactive"):e.host.renderPercentage(t.trigger,i.selected,!0)])},onSetTrigger:async()=>{const l=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.percentage"),e.host.engine.i18n("ui.trigger.section.prompt",[n,t.trigger!==-1?e.host.renderPercentage(t.trigger,i.selected,!0):e.host.engine.i18n("ui.infinity")]),t.trigger!==-1?e.host.renderPercentage(t.trigger):"",e.host.engine.i18n("ui.trigger.section.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){t.trigger=-1;return}t.trigger=e.host.parsePercentage(l)}},onUnCheck:l=>{e.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!t.enabled||t.trigger===-1,this.settingItem.triggerButton.ineffective=t.enabled&&t.trigger<0&&Object.values(t.resources).some(l=>l.enabled&&l.max!==0&&l.trigger<0)}});u(this,"_crafts");let a=[];game.challenges.getChallenge("ironWill").active||(this.setting.resources.bloodstone.enabled=!1,this.setting.resources.tMythril.enabled=!1,a=["bloodstone","tMythril"]);const r=this.host.game.workshop.crafts.filter(l=>!a.includes(l.name)&&!m(this.setting.resources[l.name])).map(l=>[this.setting.resources[l.name],X(l.label)]);this._crafts=[];for(const[l,h]of r){const d=async()=>{const f=await E.prompt(this,this.host.engine.i18n("ui.max.craft.prompt",[h]),this.host.engine.i18n("ui.max.craft.promptTitle",[h,this.host.renderAbsolute(l.max,i.selected)]),this.host.renderAbsolute(l.max),this.host.engine.i18n("ui.max.craft.promptExplainer"));if(f!==void 0){if(f===""||f.startsWith("-")){l.max=-1;return}f==="0"&&(l.enabled=!1),l.max=this.host.parseAbsolute(f)??l.max}},g=new Ri(this,l,i,h,{delimiter:l.resource==="kerosene"||l.resource==="blueprint",onCheck:f=>{if(this.host.engine.imessage("status.sub.enable",[h]),l.max===0&&!f)return d()},onLimitedCheck:()=>{this.host.engine.imessage("craft.limited",[h])},onLimitedUnCheck:()=>{this.host.engine.imessage("craft.unlimited",[h])},onRefreshMax:()=>{g.maxButton.updateLabel(this.host.renderAbsolute(l.max)),g.maxButton.element[0].title=l.max<0?this.host.engine.i18n("ui.max.craft.titleInfinite",[h]):l.max===0?this.host.engine.i18n("ui.max.craft.titleZero",[h]):this.host.engine.i18n("ui.max.craft.title",[this.host.renderAbsolute(l.max),h])},onRefreshRequest:()=>{g.limitedButton.inactive=!l.enabled||!l.limited,g.maxButton.inactive=!l.enabled||l.max===-1,g.maxButton.ineffective=t.enabled&&l.enabled&&l.max===0,g.triggerButton.inactive=!l.enabled||l.trigger===-1,g.triggerButton.ineffective=t.enabled&&l.enabled&&t.trigger===-1&&l.trigger===-1},onRefreshTrigger:()=>{g.triggerButton.element[0].title=this.host.engine.i18n("ui.trigger",[l.trigger<0?t.trigger<0?this.host.engine.i18n("ui.trigger.build.blocked",[h]):`${this.host.renderPercentage(t.trigger,i.selected,!0)} (${this.host.engine.i18n("ui.trigger.build.inherited")})`:this.host.renderPercentage(l.trigger,i.selected,!0)])},onSetMax:d,onSetTrigger:async()=>{const f=await E.prompt(this,this.host.engine.i18n("ui.trigger.prompt.percentage"),this.host.engine.i18n("ui.trigger.section.prompt",[h,l.trigger!==-1?this.host.renderPercentage(l.trigger,i.selected,!0):this.host.engine.i18n("ui.trigger.build.inherited")]),l.trigger!==-1?this.host.renderPercentage(l.trigger):"",this.host.engine.i18n("ui.trigger.build.promptExplainer"));if(f!==void 0){if(f===""||f.startsWith("-")){l.trigger=-1;return}l.trigger=this.host.parsePercentage(f)}},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[h])},renderLabelTrigger:!1});this._crafts.push(g),l.resource==="ship"&&this._crafts.push(new S(this,this.setting.shipOverride,this.host.engine.i18n("option.shipOverride"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.shipOverride")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.shipOverride")])},upgradeIndicator:!0}))}const o=new x(this,{onReset:()=>{this.setting.load({resources:new xt().resources})}}).addChildren(this._crafts);this.addChildContent(o),this.addChildContent(new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new Jo(this,this.setting.unlockUpgrades,i)]))}}class Le extends G{constructor(e){console.debug(...v(`Constructing ${Le.name}`));super({host:e},{});u(this,"showActivity");u(this,"_engineUi");u(this,"_sections");u(this,"stateManagementUi");u(this,"_refreshTimeout");const t=e.engine;this._engineUi=new ca(this,t.settings),this.stateManagementUi=new vi(this,t.settings.states,t.settings.locale),this._sections=[new ii(this,t.bonfireManager.settings,t.settings.locale),new Ei(this,t.villageManager.settings,t.settings.locale),new gi(this,t.scienceManager.settings,t.settings.locale),new Mi(this,t.workshopManager.settings,t.settings.locale),new di(this,t.settings.resources,t.settings.locale),new xi(this,t.tradeManager.settings,t.settings.locale),new ci(this,t.religionManager.settings,t.settings.locale),new mi(this,t.spaceManager.settings,t.settings.locale),new wi(this,t.timeManager.settings,t.settings.locale),new yi(this,t.timeControlManager.settings,t.settings.locale),new li(this,t.settings.filters),this.stateManagementUi,new ri(this,t.settings,t.settings.locale)],this.parent=this,this.element=$("<div/>").addClass("kitten-scientists").addClass(Ti.ui);for(const h of[this._engineUi,...this._sections])this.addChild(h);const i=$("<ul/>");i.append(this._engineUi.element);for(const h of this._sections)i.append(h.element);this.element.append(i);const n=this._engineUi.expando;let a=!1;n.element.on("click",()=>{a=!a;for(const h of this._sections)h.toggle(a,!0)});let r=0;for(const h of this._sections)h.element[0].addEventListener("panelHidden",()=>{--r,r===0&&(a=!1),a||n.setCollapsed()}),h.element[0].addEventListener("panelShown",()=>{++r,a=!0,n.setExpanded()});this.showActivity=$("<span/>",{html:`<svg style="width: 18px; height: 18px;" viewBox="0 -960 960 960" fill="currentColor"><path d="${A.Summary}"/></svg>`,title:e.engine.i18n("summary.show")}).addClass(Ti.showActivity),this.showActivity.on("click",()=>{e.engine.displayActivitySummary()}),$("#clearLog").prepend(this.showActivity);const o=t.settings.ksColumn.enabled&&game.colorScheme!=="sleek";o?$("#rightColumn").after(`<div id="ksColumn" class="column"><span class="${Ti.spacer}"></span></div>`):$("#ksColumn").remove();const l=$(o?"#ksColumn":"#rightColumn");if(l.length===0){const h=$("#optionsPage .full-screen-position .page .page-content");h.length===0?console.warn(...v("Unable to find right column to inject UI into. Running headless.")):(h.append(this.element),this.element.attr("style","border-top:1px solid grey; padding:15px"))}else l.prepend(this.element);this.element=this.element,this._needsRefresh=!1}toString(){return`[${Le.name}#${this.componentId}]`}destroy(){this._refreshTimeout!==void 0&&(T.window.clearTimeout(this._refreshTimeout),this._refreshTimeout=void 0),this.showActivity.remove(),this.element.remove()}requestRefresh(e=!0,t=0,i=!1){if(this._needsRefresh){this._refreshTimeout===void 0&&console.error(...v("User interface claims to have a refresh pending, but there isn't."));return}this._refreshTimeout=T.window.setTimeout(()=>{const[n,a]=ye(()=>this.refresh());console.info(...v(`UI refresh took ${aa(a)}.`)),this._refreshTimeout=void 0},0),super.requestRefresh(!0,t,!1)}forceFullRefresh(){console.warn(...v("Forcing refresh on all user interface components...")),this.requestRefresh(),console.warn(...v("Refresh on all user interface components enforced."))}}const Oe=(c="")=>{if(m("0.0.0-ci"))throw Error("Build error: RELEASE_VERSION is not defined.");return`${c}0.0.0-ci`};class de{constructor(s,e,t="en",i){u(this,"game");u(this,"i18nEngine");u(this,"_userInterface");u(this,"engine");u(this,"_gameBeforeSaveHandle");u(this,"_serverLoadHandle");u(this,"_saveManager",{load:s=>{console.info(...v("Looking for Kitten Scientists engine state in save data..."));const e=T.tryEngineStateFromSaveData("ks",s);if(!e){console.info(...v("The Kittens Game save data did not contain a script state."));return}console.info(...v("Found Kitten Scientists engine state in save data.")),this.engine.stateLoad(e),this.refreshEntireUserInterface()},resetState:()=>null,save:s=>{}});var n;console.info(...v(`Kitten Scientists ${Oe("v")} constructed. Checking for previous instances...`)),"kittenScientists"in T.window&&(console.warn(...v("Detected existing KS instance. Trying to unload it...")),(n=T.window.kittenScientists)==null||n.unload()),console.info(...v("You are on the 'fixed' release channel.")),this.game=s,this.i18nEngine=e;try{this.engine=new re(this,t),this._userInterface=new Le(this)}catch(a){throw console.error(...v("Failed to construct core components.",a)),a}m(i)?this._userInterface.stateManagementUi.loadAutoSave():this.setSettings(i)}rebuildUi(){this._userInterface.destroy(),this._userInterface=new Le(this),this._userInterface.forceFullRefresh()}validateGame(){Qt.validateGame(this.game,this.engine.scienceManager.settings),St.validateGame(this.game,this.engine.spaceManager.settings),xt.validateGame(this.game,this.engine.workshopManager.settings)}unload(){console.warn(...v("Unloading Kitten Scientists...")),this.engine.stop(),this._userInterface.destroy(),$("#ks-styles").remove(),this._gameBeforeSaveHandle!==void 0&&(T.window.dojo.unsubscribe(this._gameBeforeSaveHandle),this._gameBeforeSaveHandle=void 0),this._serverLoadHandle!==void 0&&(T.window.dojo.unsubscribe(this._serverLoadHandle),this._gameBeforeSaveHandle=void 0);const s=this.game.managers.indexOf(this._saveManager);-1<s&&this.game.managers.splice(s,1),T.window.kittenScientists=void 0,console.warn(...v("Kitten Scientists have been unloaded!"))}run(){this.game.console.maxMessages=1e3,this.refreshEntireUserInterface(),this.engine.settings.enabled&&this.engine.start(!0),this.engine.imessage("status.ks.init"),this.runUpdateCheck().catch(R(console)),this._gameBeforeSaveHandle!==void 0&&(T.window.dojo.unsubscribe(this._gameBeforeSaveHandle),this._gameBeforeSaveHandle=void 0),this._gameBeforeSaveHandle=T.window.dojo.subscribe("game/beforesave",s=>{console.info(...v("Injecting Kitten Scientists engine state into save data..."));const e=this.getSettings();s.ks={state:[e]},this._userInterface.stateManagementUi.storeAutoSave(e),document.dispatchEvent(new CustomEvent("ks.reportSavegame",{detail:s}))}),this._serverLoadHandle!==void 0&&(T.window.dojo.unsubscribe(this._serverLoadHandle),this._gameBeforeSaveHandle=void 0),this._serverLoadHandle=T.window.dojo.subscribe("server/load",s=>{const e=T.tryEngineStateFromSaveData("ks",s);if(!e){console.info(...v("The Kittens Game save data did not contain a script state. Trying to load Auto-Save settings..."));return}console.info(...v("Found! Loading settings...")),this.engine.stateLoad(e)})}async runUpdateCheck(){{console.debug(...v("No update check on 'fixed' release channel."));return}}refreshEntireUserInterface(){console.info(...v("Requesting entire user interface to be refreshed.")),this._userInterface.forceFullRefresh()}parseFloat(s){if(s===null||s==="")return null;const e=/[KMGTP]$/i.test(s),t=s.substring(0,s.length-(e?1:0));let i=s.includes("e")||e?Number.parseFloat(t):Number.parseInt(t);if(e){const n=s.substring(s.length-1).toUpperCase();i=i*1e3**["","K","M","G","T","P"].indexOf(n)}return(i===Number.POSITIVE_INFINITY||i<0)&&(i=-1),i}parseAbsolute(s){const e=this.parseFloat(s);return e!==null?Math.round(e):null}parsePercentage(s){const e=s.trim().replace(/%$/,"");return Math.max(0,Math.min(1,Number.parseFloat(e)/100))}renderAbsolute(s,e="invariant"){return s<0||s===Number.POSITIVE_INFINITY?"∞":e!=="invariant"&&Math.floor(Math.log10(s))<9?new Intl.NumberFormat(e,{maximumFractionDigits:0,style:"decimal"}).format(s):this.game.getDisplayValueExt(s,!1,!1)}renderPercentage(s,e="invariant",t){return s<0||s===Number.POSITIVE_INFINITY?"∞":e!=="invariant"?new Intl.NumberFormat(e,{style:"percent"}).format(s):`${this.game.getDisplayValueExt(s*100,!1,!1)}${t?"%":""}`}renderFloat(s,e="invariant"){return s<0||s===Number.POSITIVE_INFINITY?"∞":e!=="invariant"?new Intl.NumberFormat(e,{style:"decimal"}).format(s):this.game.getDisplayValueExt(s,!1,!1)}static encodeSettings(s,e=!0){const t=JSON.stringify(s);return e?T.window.LZString.compressToBase64(t):t}static decodeSettings(s){try{const i=JSON.parse(s);return de.unknownAsEngineStateOrThrow(i)}catch{}if(s.match(/\r?\n/))throw new bt("Multi-line non-JSON input can't be decoded.");const e=T.window.LZString.decompressFromBase64(s),t=JSON.parse(e);return de.unknownAsEngineStateOrThrow(t)}getSettings(){return this.engine.stateSerialize()}getSettingsAsJson(){return JSON.stringify(this.getSettings())}setSettings(s){console.info(...v("Loading engine state..."));const e=this.engine.settings.ksColumn.enabled!==s.engine.ksColumn.enabled;this.engine.stateLoad(s),e&&this.rebuildUi(),this._userInterface.refresh(!0)}importSettingsFromString(s){const e=de.decodeSettings(s);this.setSettings(e)}async copySettings(s=this.getSettings(),e=!0){const t=de.encodeSettings(s,e);await T.window.navigator.clipboard.writeText(t)}static unknownAsEngineStateOrThrow(s){const e=s.v;if(!m(e)&&typeof e=="string"&&e.startsWith("2"))return s;throw new Error("Not a valid engine state.")}installSaveManager(){console.info(...v("Installing save game manager...")),this.game.managers.push(this._saveManager)}}const Ps=async()=>{const c=await new T().waitForGame(de,"ks");T.window.kittenScientists=c,c.validateGame(),c.run()};(typeof GM>"u"||((Is=GM==null?void 0:GM.info)==null?void 0:Is.scriptHandler)==="Tampermonkey")&&Ps().catch(R(console)),U.main=Ps,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
43
- (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.id="ks-styles",t.appendChild(document.createTextNode('._label_1nlev_1{align-content:center;display:inline-block;flex:0 1 fit-content;opacity:.8;white-space:nowrap;transition:.3s}._label_1nlev_1:hover{opacity:1}._splitter_1nlev_16 ._label_1nlev_1:first-letter{font-weight:700}._iconLabel_1nlev_20{display:inline-block;margin-right:4px;margin-left:2px;vertical-align:middle}._fillSpace_1nlev_26{flex:1}._delimiter_16hnh_1{margin-bottom:10px}._head_wr1pj_1{display:flex;align-items:stretch;flex-direction:row;justify-content:flex-start;width:100%;transition:.3s}._head_wr1pj_1>._headFlexItem_wr1pj_10{flex:1;margin-right:8px}._setting_1ndg5_1{border-bottom:1px solid transparent;transition:border-bottom .3s}._setting_1ndg5_1 ._checkbox_1ndg5_6{margin:1px 5px 2px 2px}._setting_1ndg5_1 ._panelContent_1ndg5_10{border-left:1px dashed grey;padding-left:16px;margin-left:8px;margin-top:1px;opacity:.5}._setting_1ndg5_1 ._panelContent_1ndg5_10._hidden_1ndg5_17{display:none}._setting_1ndg5_1._checked_1ndg5_22>._panelContent_1ndg5_10{opacity:1}._setting_1ndg5_1._expanded_1ndg5_26{margin-bottom:10px}._setting_1ndg5_1:not(._expanded_1ndg5_26):hover{border-bottom:1px dashed rgba(160,160,160,.2)}._setting_1ndg5_1._readonly_1ndg5_34{cursor:default;pointer-events:none}@keyframes _hail-rainbow_q7zpt_1{0%,to{color:red;text-shadow:0 0 10px red}33%{color:#888;text-shadow:0 0 10px yellow}66%{color:#fff;text-shadow:0 0 10px black}}._iconButton_q7zpt_17{cursor:pointer;display:block;padding-right:3px;line-height:0;opacity:.8;transition:.3s}._iconButton_q7zpt_17:hover{opacity:1}._iconButton_q7zpt_17._inactive_q7zpt_29{opacity:.4}._iconButton_q7zpt_17._inactive_q7zpt_29:hover{opacity:.6}._iconButton_q7zpt_17._ineffective_q7zpt_37{color:red;animation:_hail-rainbow_q7zpt_1 5s linear infinite}._button_q7zpt_43{align-items:end;cursor:pointer;display:flex;opacity:.8;transition:.3s}._button_q7zpt_43:hover{opacity:1}._button_q7zpt_43._inactive_q7zpt_29{opacity:.4}._button_q7zpt_43._inactive_q7zpt_29:hover{opacity:.6}._button_q7zpt_43._ineffective_q7zpt_37{color:red;animation:_hail-rainbow_q7zpt_1 5s linear infinite}._button_q7zpt_43._readonly_q7zpt_67{cursor:default;pointer-events:none}._button_q7zpt_43 ._buttonIcon_q7zpt_72{margin:0 2px 0 0;vertical-align:sub}._button_q7zpt_43._alignRight_q7zpt_77{justify-content:end}._button_q7zpt_43._large_q7zpt_81{padding:5px 10px}._button_q7zpt_43._bordered_q7zpt_85{border:1px solid rgba(180,180,180,.2)}._button_q7zpt_43._bordered_q7zpt_85:not(._large_q7zpt_81){padding:0 2px}._button_q7zpt_43._bordered_q7zpt_85:hover{border:1px solid rgba(180,180,180,1)}._button_q7zpt_43._headAction_q7zpt_97{min-width:50px}._button_q7zpt_43._lastHeadAction_q7zpt_100{padding-right:20px}._button_q7zpt_43._consumeButton_q7zpt_104,._button_q7zpt_43._stockButton_q7zpt_107{border:1px solid transparent}._button_q7zpt_43:not(._bordered_q7zpt_85)+._button_q7zpt_43:not(._bordered_q7zpt_85):before{content:"";display:inline-block;height:1em;border-left:1px solid transparent}._button_q7zpt_43:not(._bordered_q7zpt_85):not(._inactive_q7zpt_29)._alignRight_q7zpt_77+._button_q7zpt_43:not(._bordered_q7zpt_85):not(._inactive_q7zpt_29):before{content:"";display:inline-block;height:1em;border-left:1px solid rgba(180,180,180,.4)}._listContainer_1kxbq_1{margin-bottom:4px}._itemsList_1kxbq_5{-webkit-user-select:none;user-select:none}._list_1kxbq_1~._listTools_1kxbq_9{border-top:1px dotted rgba(128,128,128,.3);margin-left:0;padding-top:2px}._list_1kxbq_1~._listTools_1kxbq_9 *{display:inline-block}._expandoButton_l1ukp_1:not(._expanded_l1ukp_1) ._up_l1ukp_1{display:none}._expandoButton_l1ukp_1:not(._expanded_l1ukp_1) ._down_l1ukp_4{opacity:.6}._expandoButton_l1ukp_1:not(._expanded_l1ukp_1) ._down_l1ukp_4:hover{opacity:1}._expandoButton_l1ukp_1._expanded_l1ukp_1 ._down_l1ukp_4{display:none}#gamePageContainer .dialog.help ._dialog_1276o_1{display:flex;flex-direction:column;height:fit-content!important;box-shadow:none!important}#gamePageContainer .dialog.help ._dialog_1276o_1 ._close_1276o_7{position:absolute;top:10px;right:15px}._explainer_1idu3_1{color:#888;display:inline-block;min-width:100px;-webkit-user-select:none;user-select:none;padding:4px;white-space:break-spaces}._explainer_1idu3_1 p{margin:0}._header_19ql8_1{display:block;margin-bottom:3px;min-width:100px;border-bottom:1px dashed rgba(255,255,255,.1);font-weight:700;-webkit-user-select:none;user-select:none}._toolbar_1654f_1{display:flex;flex-direction:row;padding:0 0 2px;margin:0 0 3px}._toolbar_1654f_1>*{margin:0 3px 0 0}._maxButton_133h2_1{padding-right:5px;padding-top:2px}._fieldset_tfwil_1{border-bottom:none;border-right:none;border-top:none}._textButton_1mv97_1{display:inline-block;white-space:nowrap;opacity:.8;cursor:pointer;-webkit-user-select:none;user-select:none}._textButton_1mv97_1:hover{opacity:1}@keyframes _scale_6c09s_1{0%{scale:.5;opacity:0}50%{scale:1;opacity:1}to{scale:2;opacity:0}}._active_6c09s_16{text-shadow:rgba(128,128,128,.8) 0 0 15px;position:relative}._active_6c09s_16:after,._active_6c09s_16:before{display:inline-block;width:1em;height:100%;position:absolute;right:-1.5em;scale:0;text-align:center;transform-origin:center}._active_6c09s_16:after{content:attr(data-ks-active-from);animation:_scale_6c09s_1 8s linear infinite}._active_6c09s_16:before{content:attr(data-ks-active-to);animation:_scale_6c09s_1 8s linear infinite;animation-delay:4s}._buyButton_10eul_1,._sellButton_1tmvd_1{display:inline-block;padding-right:10px;min-width:86px}#ksColumn{min-width:250px;max-width:440px;vertical-align:top;padding-left:8px;top:20px;position:relative;overflow-y:auto}#footerLinks{display:flex;flex-direction:column;position:fixed;text-align:right;line-height:0;right:-5px!important;margin-bottom:1em}#footerLinks a{line-height:1;padding-right:10px;opacity:.5;transition:.3s;text-decoration:none;text-transform:lowercase}#footerLinks a:hover{opacity:1}#crowdjet-expand-container{position:fixed!important;bottom:10px!important;right:-10px!important;opacity:.5}#crowdjet-expand-container:hover{opacity:1}._spacer_auis8_44{display:block;margin-bottom:100px}._ui_auis8_49{margin:5px 0 10px;padding-right:10px}._ui_auis8_49 ul{list-style:none;margin:0;padding:0}._ui_auis8_49 #_toggle-list-resources_auis8_1 ._stockWarn_auis8_60 *,._ui_auis8_49 #_toggle-reset-list-resources_auis8_1 ._stockWarn_auis8_60 *{color:#dd1e00}._showActivity_auis8_66{cursor:pointer;display:inline-block;vertical-align:middle}#game #rightColumn{overflow-y:auto}#game #rightColumn #rightTabLog{overflow-y:visible}#game #rightColumn #rightTabLog #gameLog{height:auto;min-height:auto;overflow-y:visible}#game .res-row .res-cell.ks-stock-above{color:green}#game .res-row .res-cell.ks-stock-below{color:red}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
38
+ If you submit an invalid value, it will be treated as if you hit Cancel.`,"ui.trigger.setinteger":"输入 {0} 的新触发值。范围应在 0 到任意数字之间。-1表示无穷大。","ui.trigger.setinteger.promptExplainer":"如果您提交一个空值或者一个无效值,则被视为您点击了取消。","ui.trigger.setpercentage":"输入新的 {0} 触发值,取值范围为 0 到 100 的小数。","ui.trigger.setpercentage.promptExplainer":"如果您提交一个空值或者一个无效值,则被视为您点击了取消。","ui.trigger.timeSkip.prompt":"输入跳过时间所需的时间水晶的新数量,以 1 到无穷大之间的绝对值表示。","ui.trigger.timeSkip.promptExplainer":"如果您提交了负值,时间跳过将被禁用。如果您提交了空值或无效值,它将被视为您点击了“取消”。","ui.trigger.timeSkip.promptTitle":"时间跳跃触发值 (当前:{0})","ui.upgrade":"升级","ui.upgrade.buildings":"升级建筑","ui.upgrade.missions":"探索星球","ui.upgrade.policies":"政策","ui.upgrade.races":"探险队出发!","ui.upgrade.techs":"科技","ui.upgrade.upgrades":"升级","ui.upgrades":"升级",update:"更新","upgrade.building.amphitheatre":"剧场 升级为 广播塔!","upgrade.building.aqueduct":"水渠 升级为 水电站!","upgrade.building.library":"图书馆 升级为 数据中心!","upgrade.building.pasture":"牧场 升级为 太阳能发电站!","upgrade.building.warehouse":"已将仓库升级为太空港!","upgrade.policy":"小猫通过了 {0} 法案","upgrade.race":"小猫遇到了 {0}","upgrade.space":"小猫执行了 {0}","upgrade.space.mission":"小猫执行了 {0} 的任务","upgrade.tech":"小猫掌握了 {0}","upgrade.upgrade":"小猫发明了 {0}"};class _t extends kt{constructor(e,t,i=!1){super(i);I(this,ze);I(this,Fe);L(this,ze,e),L(this,Fe,t)}get building(){return B(this,ze)}get variant(){return B(this,Fe)}}ze=new WeakMap,Fe=new WeakMap;class Yt extends V{constructor(e=!1,t=-1,i=new _,n=new ae(!1,-1),r=new ae(!1,-1),a=new ae(!1,-1),o=new ae(!1,-1),l=new V(!1,1),h=new V(!1,1),d=new _){super(e,t);u(this,"buildings");u(this,"bestUnicornBuilding");u(this,"bestUnicornBuildingCurrent");u(this,"sacrificeAlicorns");u(this,"sacrificeUnicorns");u(this,"refineTears");u(this,"refineTimeCrystals");u(this,"autoPraise");u(this,"adore");u(this,"transcend");this.buildings=this.initBuildings(),this.bestUnicornBuilding=i,this.sacrificeAlicorns=n,this.sacrificeUnicorns=r,this.refineTears=a,this.refineTimeCrystals=o,this.autoPraise=l,this.adore=h,this.transcend=d,this.bestUnicornBuildingCurrent=null}initBuildings(){const e={};for(const t of Zi)e[t]=new _t(t,H.OrderOfTheSun);for(const t of Ki)e[t]=new _t(t,H.Cryptotheology);for(const t of Vi)e[t]=new _t(t,H.Ziggurat);return e.unicornPasture=new _t("unicornPasture",H.UnicornPasture),e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.max=(i==null?void 0:i.max)??t.max,t.trigger=(i==null?void 0:i.trigger)??t.trigger}),this.bestUnicornBuilding.load(e.bestUnicornBuilding),this.sacrificeAlicorns.load(e.sacrificeAlicorns),this.sacrificeUnicorns.load(e.sacrificeUnicorns),this.refineTears.load(e.refineTears),this.refineTimeCrystals.load(e.refineTimeCrystals),this.autoPraise.load(e.autoPraise),this.adore.load(e.adore),this.transcend.load(e.transcend),this.bestUnicornBuildingCurrent=e.bestUnicornBuildingCurrent??this.bestUnicornBuildingCurrent)}}class mn{constructor(s,e,t,i=new Yt){u(this,"_host");u(this,"settings");u(this,"_bulkManager");u(this,"_bonfireManager");u(this,"_workshopManager");this._host=s,this.settings=i,this._workshopManager=t,this._bulkManager=new yt(this._host,this._workshopManager),this._bonfireManager=e}async tick(s){this.settings.enabled&&(this._autoBuild(s),this.settings.sacrificeUnicorns.enabled&&await this._autoSacrificeUnicorns(),this.settings.sacrificeAlicorns.enabled&&await this._autoSacrificeAlicorns(s),this.settings.refineTears.enabled&&this._autoTears(s),this.settings.refineTimeCrystals.enabled&&await this._autoTCs(s),this._autoTAP())}_autoBuild(s){if(this.settings.bestUnicornBuilding.enabled)this._buildBestUnicornBuilding(),this._buildNonUnicornBuildings(s);else{const e=Object.fromEntries(Object.entries(this.settings.buildings).filter(([,n])=>n.variant!==H.UnicornPasture)),t=X(this.settings.buildings.unicornPasture.max),i=this._host.game.bld.getBuildingExt("unicornPasture").meta;this.settings.buildings.unicornPasture.enabled&&i.val<t&&this._bonfireManager.autoBuild(s,{unicornPasture:new Jt("unicornPasture",this.settings.buildings.unicornPasture.enabled,this.settings.buildings.unicornPasture.trigger,this.settings.buildings.unicornPasture.max)}),this._buildReligionBuildings(s,e)}}_buildBestUnicornBuilding(){const s=this.getBestUnicornBuilding();if(this.settings.bestUnicornBuildingCurrent!==s&&(this.settings.bestUnicornBuildingCurrent=s,this._host.refreshEntireUserInterface()),this.settings.bestUnicornBuildingCurrent===null)return;const e=this.settings.trigger;if(this.settings.bestUnicornBuildingCurrent==="unicornPasture")this._bonfireManager.build(this.settings.bestUnicornBuildingCurrent,0,1);else{const t=this._getBuild(this.settings.bestUnicornBuildingCurrent,H.Ziggurat);let i=0;const n=v(t.model.prices).find(l=>l.name==="tears");m(n)||(i=n.val);const r=this._workshopManager.getValue("tears")-this._workshopManager.getStock("tears");if(r<i){const l=Math.floor((this._workshopManager.getValue("unicorns")-this._workshopManager.getStock("unicorns"))/2500),h=Math.ceil((i-r)/this._host.game.bld.getBuildingExt("ziggurat").meta.on),d=this._host.game.bld.get("ziggurat").on;if(h<l&&0<d){const g=new classes.ui.religion.TransformBtnController(this._host.game,{applyAtGain:p=>{this._host.game.stats.getStat("unicornsSacrificed").val+=p},gainedResource:"tears",gainMultiplier:()=>this._host.game.bld.get("ziggurat").on,logfilterID:"unicornSacrifice",logTextID:"religion.sacrificeBtn.sacrifice.msg",overcapMsgID:"religion.sacrificeBtn.sacrifice.msg.overcap"}),f=g.fetchModel({controller:g,description:"",name:"",prices:[{name:"unicorns",val:2500}]});g._transform(f,h)}else return}const a={[this.settings.bestUnicornBuildingCurrent]:this.settings.buildings[this.settings.bestUnicornBuildingCurrent]},o=this._bulkManager.bulk(a,this.getBuildMetaData(a),e,"Religion");0<o.length&&0<o[0].count&&this.build(this.settings.bestUnicornBuildingCurrent,H.Ziggurat,1)}}_buildNonUnicornBuildings(s){const e=[...wt],t=Object.fromEntries(Object.entries(this.settings.buildings).filter(([,i])=>!e.includes(i.building)));this._buildReligionBuildings(s,t)}_buildReligionBuildings(s,e){const t=this.getBuildMetaData(e),i=this.settings.trigger,n=this._bulkManager.bulk(e,t,i,"Religion");for(const r of n)0<r.count&&(this.build(r.id,v(r.variant),r.count),s.requestGameUiRefresh=!0)}getBestUnicornBuilding(){var le,_e;const s=this._bonfireManager.getBuild("unicornPasture"),e=[...wt].filter(te=>te!=="unicornPasture"),t=this._host.game.getEffect("unicornsPerTickBase")*this._host.game.getTicksPerSecondUI(),i=this._host.game.getEffect("unicornsGlobalRatio")+1,n=this._host.game.getEffect("unicornsRatioReligion")+1,r=this._host.game.prestige.getParagonProductionRatio()+1,a=this._host.game.religion.getSolarRevolutionRatio()+1,o=this._host.game.calendar.cycle,l=this._host.game.calendar.cycles[o];let h=1;l.festivalEffects.unicorns!==void 0&&this._host.game.prestige.getPerk("numeromancy").researched&&this._host.game.calendar.festivalDays&&(h=l.festivalEffects.unicorns);const d=t*i*n*r*a*h,g=Math.max(this._host.game.bld.getBuildingExt("ziggurat").meta.on,1),f=500*(1+this._host.game.getEffect("unicornsRatioReligion")*.1);let p=1;this._host.game.prestige.getPerk("unicornmancy").researched&&(p*=1.1);const b=this._host.game.getEffect("riftChance")*p/(1e4*2)*f;let k=Number.POSITIVE_INFINITY,w=null;const ee=v((le=this._host.game.bld.getBuildingExt("unicornPasture").meta.effects)==null?void 0:le.unicornsPerTickBase)*this._host.game.getTicksPerSecondUI()*i*n*r*a*h,Y=v((_e=s.model)==null?void 0:_e.prices)[0].val/ee;Y<k&&(k=Y,w="unicornPasture");for(const te of e){const fe=this._getBuild(te,H.Ziggurat);if(!fe.model.metadata.unlocked)continue;let Re=0;for(const Ce of v(fe.model.prices))Ce.name==="unicorns"&&(Re+=Ce.val),Ce.name==="tears"&&(Re+=Ce.val*2500/g);const gt=v(this._host.game.religion.getZU(te));let Nt=n,$s=this._host.game.getEffect("riftChance");for(const Ce in gt.effects)Ce==="unicornsRatioReligion"&&(Nt+=v(gt.effects.unicornsRatioReligion)),Ce==="riftChance"&&($s+=v(gt.effects.riftChance));const Xo=500*((Nt-1)*.1+1);let Ai=$s*p/(1e4*2)*Xo;Ai-=b;let Pi=t*i*Nt*r*a*h;Pi-=d,Pi+=Ai;const Ls=Re/Pi;Ls<k&&(0<Ai||n<Nt&&0<Re)&&(k=Ls,w=te)}return w}build(s,e,t){let i=t;const n=i;let r;if(e===H.Cryptotheology){const a=game.getUnlockByName(s,"transcendenceUpgrades"),o=new classes.ui.TranscendenceBtnController(this._host.game),l=o.fetchModel({controller:o,id:a.name});i=this._bulkManager.construct(l,o,i),r=a.label}else if(e===H.OrderOfTheSun){const a=game.getUnlockByName(s,"religion"),o=new com.nuclearunicorn.game.ui.ReligionBtnController(this._host.game),l=o.fetchModel({controller:o,id:a.name});i=this._bulkManager.construct(l,o,i),r=a.label}else if(e===H.Ziggurat){const a=game.getUnlockByName(s,"zigguratUpgrades"),o=new com.nuclearunicorn.game.ui.ZigguratBtnController(this._host.game),l=o.fetchModel({controller:o,id:a.name});i=this._bulkManager.construct(l,o,i),r=a.label}else throw new ft("unsupported");i!==n&&(console.warn(...y(`${r} Amount ordered: ${n} Amount Constructed: ${i}`)),i===0)||(e===H.OrderOfTheSun?(this._host.engine.storeForSummary(r,i,"faith"),i===1?this._host.engine.iactivity("act.sun.discover",[r],"ks-faith"):this._host.engine.iactivity("act.sun.discovers",[r,this._host.renderAbsolute(i)],"ks-faith")):(this._host.engine.storeForSummary(r,i,"build"),i===1?this._host.engine.iactivity("act.build",[r],"ks-build"):this._host.engine.iactivity("act.builds",[r,this._host.renderAbsolute(i)],"ks-build")))}getBuildMetaData(s){const e={};for(const t of Object.values(s)){const i=this.getUpgradeMeta(t.building,t.variant);if(i===null)continue;e[t.building]=i;const n=v(e[t.building]);if(!this._getBuild(t.building,t.variant))n.rHidden=!0;else{const r=v(this._getBuild(t.building,t.variant)).model,a=t.variant===H.Cryptotheology?this._host.game.science.get("cryptotheology").researched:!0;n.rHidden=!(r!=null&&r.visible&&r.enabled&&a)}}return e}getUpgradeMeta(s,e){switch(e){case H.Ziggurat:return this._host.game.religion.getZU(s)??null;case H.OrderOfTheSun:return this._host.game.religion.getRU(s)??null;case H.Cryptotheology:return this._host.game.religion.getTU(s)??null}throw new Error(`Unknown build: ${s} (${e})`)}_getBuild(s,e){switch(e){case H.Ziggurat:return this._host.game.time.queue.getQueueElementControllerAndModel({name:s,type:"zigguratUpgrades"});case H.OrderOfTheSun:return this._host.game.time.queue.getQueueElementControllerAndModel({name:s,type:"religion"});case H.Cryptotheology:return this._host.game.time.queue.getQueueElementControllerAndModel({name:s,type:"transcendenceUpgrades"});default:throw new Error(`Invalid variant '${e}'`)}}_transformBtnSacrificeHelper(s,e,t,i){const r=1/(s/e),o=new classes.ui.religion.TransformBtnController(game,t.controllerOpts)._newLink(i,r);return new Promise(l=>{o.handler(new Event("decoy"),l)})}async _autoSacrificeUnicorns(){const s=this._workshopManager.getResource("unicorns"),e=this._workshopManager.getValueAvailable("unicorns");if(!m(this._host.game.religionTab.sacrificeBtn)&&X(this.settings.sacrificeUnicorns.trigger)<=e&&X(this.settings.sacrificeUnicorns.trigger)<=s.value){const t=this._host.game.religionTab.sacrificeBtn.controller,i=this._host.game.religionTab.sacrificeBtn.model;if(m(i))return;await this._transformBtnSacrificeHelper(e,s.value,t,i);const n=this._workshopManager.getValueAvailable("unicorns"),r=e-n;this._host.engine.iactivity("act.sacrificeUnicorns",[this._host.game.getDisplayValueExt(r)],"ks-faith"),this._host.engine.storeForSummary(this._host.engine.i18n("$resources.unicorns.title"),r,"refine")}}async _autoSacrificeAlicorns(s){const e=this._workshopManager.getResource("alicorn"),t=this._workshopManager.getValueAvailable("alicorn");if(!m(this._host.game.religionTab.sacrificeAlicornsBtn)&&X(this.settings.sacrificeAlicorns.trigger)<=t&&X(this.settings.sacrificeAlicorns.trigger)<=e.value){this._host.game.religionTab.sacrificeAlicornsBtn.render();const i=this._host.game.religionTab.sacrificeAlicornsBtn.controller,n=this._host.game.religionTab.sacrificeAlicornsBtn.model;if(m(n)){s.requestGameUiRefresh=!0;return}await this._transformBtnSacrificeHelper(t,e.value,i,n);const r=this._workshopManager.getValueAvailable("alicorn"),a=t-r;this._host.engine.iactivity("act.sacrificeAlicorns",[this._host.game.getDisplayValueExt(a)],"ks-faith"),this._host.engine.storeForSummary(this._host.engine.i18n("$resources.alicorn.title"),a,"refine")}}_autoTears(s){const e=this._workshopManager.getResource("tears"),t=this._workshopManager.getValueAvailable("tears"),i=this._workshopManager.getResource("sorrow");if(!m(this._host.game.religionTab.refineBtn)&&X(this.settings.refineTears.trigger)<=t&&X(this.settings.refineTears.trigger)<=e.value&&i.value<i.maxValue){const n=t-this.settings.refineTears.trigger;if(n<1e4)return;const r=this._host.game.religionTab.refineBtn.controller,a=this._host.game.religionTab.refineBtn.model;if(m(a)){s.requestGameUiRefresh=!0;return}r.buyItem(a,new Event("decoy"),n);const o=this._workshopManager.getValueAvailable("tears"),l=t-o;this._host.engine.iactivity("act.refineTears",[this._host.game.getDisplayValueExt(l)],"ks-faith"),this._host.engine.storeForSummary(this._host.engine.i18n("$resources.tears.title"),l,"refine")}}async _autoTCs(s){const e=this._workshopManager.getResource("timeCrystal"),t=this._workshopManager.getValueAvailable("timeCrystal");if(!m(this._host.game.religionTab.refineTCBtn)&&X(this.settings.refineTimeCrystals.trigger)<=t&&X(this.settings.refineTimeCrystals.trigger)<=e.value){const i=this._host.game.religionTab.refineTCBtn.controller,n=this._host.game.religionTab.refineTCBtn.model;if(m(n)){s.requestGameUiRefresh=!0;return}await this._transformBtnSacrificeHelper(t,e.value,i,n);const r=this._workshopManager.getValueAvailable("timeCrystal"),a=t-r;this._host.engine.iactivity("act.refineTCs",[this._host.game.getDisplayValueExt(a)],"ks-faith"),this._host.engine.storeForSummary(this._host.engine.i18n("$resources.timeCrystal.title"),a,"refine")}}_autoTAP(){const s=this._workshopManager.getResource("faith"),e=s.value/s.maxValue;this.settings.transcend.enabled&&this.settings.autoPraise.trigger-.02<=e&&this._autoTranscend(),this.settings.autoPraise.trigger<=e&&(this.settings.adore.enabled&&v(this._host.game.religion.getRU("apocripha")).on&&this._autoAdore(this.settings.adore.trigger),this.settings.autoPraise.enabled&&this._autoPraise())}_autoAdore(s){const e=this._workshopManager.getResource("faith"),t=this._host.game.religion.faith,i=this._host.game.religion.faithRatio,r=v(this._host.game.religion.getRU("transcendence")).on?this._host.game.religion.transcendenceTier:0,a=10+this._host.game.getEffect("solarRevolutionLimit"),o=a*s,l=t/1e6*r*r*1.01,h=i+l,d=.01+e.value*(1+this._host.game.getUnlimitedDR(h,.1)*.1),g=this._host.game.getLimitedDR(this._host.game.getUnlimitedDR(d,1e3)/100,a);o<=g&&(this._host.game.religion._resetFaithInternal(1.01),this._host.engine.iactivity("act.adore",[this._host.game.getDisplayValueExt(t),this._host.game.getDisplayValueExt(l)],"ks-adore"),this._host.engine.storeForSummary("adore",l))}_autoTranscend(){var i,n;let s=this._host.game.religion.faithRatio;const e=v(this._host.game.religion.getRU("transcendence")).on;let t=e?this._host.game.religion.transcendenceTier:0;if(e){const r=((t+2)/(t+1))**2,a=this._host.game.religion._getTranscendTotalPrice(t+1)-this._host.game.religion._getTranscendTotalPrice(t),o=a,l=r;if((1-l+Math.sqrt(80*(l*l-1)*o+(l-1)*(l-1)))*l/(40*(l+1)*(l+1)*(l-1))+o+o/(l*l-1)<=s){this._host.game.religion.faithRatio-=a,this._host.game.religion.tcratio+=a,this._host.game.religion.transcendenceTier+=1;const d=v(this._host.game.challenges.getChallenge("atheism"));(i=d.calculateEffects)==null||i.call(d,d,this._host.game);const g=v(this._host.game.religion.getTU("blackObelisk"));(n=g.calculateEffects)==null||n.call(g,g,this._host.game),this._host.game.msg(this._host.engine.i18n("$religion.transcend.msg.success",[this._host.game.religion.transcendenceTier])),s=this._host.game.religion.faithRatio,t=this._host.game.religion.transcendenceTier,this._host.engine.iactivity("act.transcend",[this._host.game.getDisplayValueExt(a),t],"ks-transcend"),this._host.engine.storeForSummary("transcend",1)}}}_autoPraise(){const s=this._workshopManager.getResource("faith"),e=this._host.game.religion.getApocryphaBonus(),t=s.value*(1+e);this._host.engine.storeForSummary("praise",t),this._host.engine.iactivity("act.praise",[this._host.game.getDisplayValueExt(s.value),this._host.game.getDisplayValueExt(t)],"ks-praise"),this._host.game.religion.praise()}}class fn extends _{constructor(e,t=!1){super(t);I(this,He);L(this,He,e)}get policy(){return B(this,He)}}He=new WeakMap;class ss extends _{constructor(e=!1){super(e);u(this,"policies");this.policies=this.initPolicies()}initPolicies(){const e={};for(const t of Js)e[t]=new fn(t);return e}static validateGame(e,t){const i=Object.keys(t.policies),n=e.science.policies.map(o=>o.name),r=ne(n,i),a=ne(i,n);for(const o of r)console.warn(...y(`The policy '${o}' is not tracked in Kitten Scientists!`));for(const o of a)console.warn(...y(`The policy '${o}' is not a policy in Kittens Game!`))}load(e){m(e)||(super.load(e),F(this.policies,e.policies,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}))}}class bn extends V{constructor(e,t=!1){super(t,-1);I(this,We);L(this,We,e)}get tech(){return B(this,We)}}We=new WeakMap;class ns extends V{constructor(e=!1){super(e,-1);u(this,"techs");this.techs=this.initTechs()}initTechs(){const e={};for(const t of Xs)e[t]=new bn(t);return e}static validateGame(e,t){const i=Object.keys(t.techs),n=e.science.techs.map(o=>o.name),r=ne(n,i),a=ne(i,n);for(const o of r)Ji.includes(o)||console.warn(...y(`The technology '${o}' is not tracked in Kitten Scientists!`));for(const o of a){if(Ji.includes(o)){console.info(...y(`The technology '${o}' is a technology in Kittens Game, but it's no longer used.`));continue}console.warn(...y(`The technology '${o}' is not a technology in Kittens Game!`))}}load(e){m(e)||(super.load(e),F(this.techs,e.techs,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class Qt extends _{constructor(e=!1,t=new ss,i=new ns,n=new _){super(e);u(this,"policies");u(this,"techs");u(this,"observe");this.policies=t,this.techs=i,this.observe=n}static validateGame(e,t){ss.validateGame(e,t.policies),ns.validateGame(e,t.techs)}load(e){var t;m(e)||(super.load(e),this.policies.load(e.policies),this.techs.load(e.techs),this.observe.enabled=((t=e.observe)==null?void 0:t.enabled)??this.observe.enabled)}}class Se{constructor(s){u(this,"_host");this._host=s}upgrade(s,e){let t=!1;if(e==="policy"){const n=game.getUnlockByName(s.name,"policies"),r=new classes.ui.PolicyBtnController(this._host.game),a=r.fetchModel({controller:r,id:n.name});t=Se.skipConfirm(()=>r.buyItem(a)).itemBought}else if(e==="science"){const n=game.getUnlockByName(s.name,"tech"),r=new com.nuclearunicorn.game.ui.TechButtonController(this._host.game),a=r.fetchModel({controller:r,id:n.name});t=Se.skipConfirm(()=>r.buyItem(a)).itemBought}else{const n=game.getUnlockByName(s.name,"upgrades"),r=new com.nuclearunicorn.game.ui.UpgradeButtonController(this._host.game),a=r.fetchModel({controller:r,id:n.name});t=Se.skipConfirm(()=>r.buyItem(a)).itemBought}if(!t)return!1;const i=s.label;return e==="workshop"?(this._host.engine.storeForSummary(i,1,"upgrade"),this._host.engine.iactivity("upgrade.upgrade",[i],"ks-upgrade")):e==="policy"?this._host.engine.iactivity("upgrade.policy",[i]):e==="science"&&(this._host.engine.storeForSummary(i,1,"research"),this._host.engine.iactivity("upgrade.tech",[i],"ks-research")),!0}static async skipConfirmAsync(s){const e=game.ui.confirm;try{return game.ui.confirm=()=>!0,await s()}finally{game.ui.confirm=e}}static skipConfirm(s){const e=game.ui.confirm;try{return game.ui.confirm=()=>!0,s()}finally{game.ui.confirm=e}}}const pn=c=>new Promise(s=>setTimeout(s,c)),xe="en-US",vn=2*60*1e3,yn="localStorage"in globalThis&&!m(localStorage["ks.timeout"])?Number(localStorage["ks.timeout"]):void 0;class T{constructor(){u(this,"_gameStartSignal");u(this,"_gameStartSignalResolver");u(this,"_possibleEngineState")}static tryEngineStateFromSaveData(s,e){const t=e;if(!(s in t)){console.debug(...y(`Failed: \`${s}\` not found in save data.`));return}const i=t.ks;if(!("state"in i)){console.debug(...y(`Failed: \`${s}.state\` not found in save data.`));return}const n=i.state;if(!Array.isArray(n)){console.debug(...y(`Failed: \`${s}.state\` not \`Array\`.`));return}return n[0]}async waitForGame(s,e,t=yn??vn){if(T._isGameLoaded()){const n=v(T.window.game),r=v(T.window.$I),a=localStorage["com.nuclearunicorn.kittengame.language"];return new s(n,r,a,this._possibleEngineState)}const i=[pn(2e3)];if(m(this._gameStartSignal)&&typeof T.window.dojo<"u"){this._gameStartSignal=new Promise(r=>{this._gameStartSignalResolver=r});const n=T.window.dojo.subscribe("game/start",()=>{console.debug(...y(`'game/start' signal caught. Fast-tracking script load for '${e}'...`)),v(this._gameStartSignalResolver)(!0),T.window.dojo.unsubscribe(n)});if(e!==void 0){const r=T.window.dojo.subscribe("server/load",a=>{console.info(...y(`'server/load' signal caught. Looking for script state with key '${e}' in save data...`));const o=T.tryEngineStateFromSaveData(e,a);if(!o){console.info(...y(`The Kittens Game save data did not contain a script state for '${e}'.`));return}console.info(...y(`Found key '${e}'! Provided save data will be used as seed for next script instance.`)),this._possibleEngineState=o,T.window.dojo.unsubscribe(r)})}}if(m(this._gameStartSignal)||i.push(this._gameStartSignal),t<0)throw new Error("Unable to find game. Giving up. Maybe the game is not exported at `window.game`?");return console.debug(...y(`Waiting for game... (timeout: ${Math.round(t/1e3)}s)`)),await Promise.race(i),this.waitForGame(s,e,t-2e3)}static _isGameLoaded(){var s;return!m(T.window.game)&&(((s=T.window.document.getElementById("game"))==null?void 0:s.checkVisibility())??!1)&&!m(T.window.$I)}static get window(){try{return v(unsafeWindow)}catch{return window}}}class wn extends Se{constructor(e,t,i=new Qt){super(e);u(this,"settings");u(this,"_workshopManager");this.settings=i,this._workshopManager=t}async tick(e){this.settings.enabled&&(this.settings.techs.enabled&&this._host.game.libraryTab.visible&&await this.autoUnlock(),this.settings.policies.enabled&&this._host.game.libraryTab.visible&&await this.autoPolicy(),this.settings.observe.enabled&&this.observeStars())}async autoUnlock(){const e=this._host.game.science.techs,t=new Array;e:for(const i of Object.values(this.settings.techs.techs)){if(!i.enabled)continue;const n=e.find(a=>a.name===i.tech);if(m(n)){console.error(...y(`Tech '${i.tech}' not found in game!`));continue}if(n.researched||!n.unlocked)continue;let r=T.window.dojo.clone(n.prices);r=this._host.game.village.getEffectLeader("scientist",r);for(const a of r){const o=this._workshopManager.getValueAvailable(a.name),l=this._workshopManager.getResource(a.name),h=re.evaluateSubSectionTrigger(this.settings.techs.trigger,i.trigger);if(h<0||o<l.maxValue*h||o<a.val)continue e}t.push(n)}for(const i of t)await this.upgrade(i,"science")}async autoPolicy(){const e=this._host.game.science.policies,t=new Array;for(const i of Object.values(this.settings.policies.policies)){if(!i.enabled)continue;const n=e.find(r=>r.name===i.policy);if(m(n)){console.error(...y(`Policy '${i.policy}' not found in game!`));continue}!n.researched&&!n.blocked&&n.unlocked&&(n.requiredLeaderJob===void 0||this._host.game.village.leader!==null&&this._host.game.village.leader.job===n.requiredLeaderJob)&&t.push(n)}for(const i of t)await this.upgrade(i,"policy")}observeStars(){this._host.game.calendar.observeBtn!==null&&(this._host.game.calendar.observeHandler(),this._host.engine.iactivity("act.observe",[],"ks-star"),this._host.engine.storeForSummary("stars",1))}}class kn extends _{constructor(e,t=!1){super(t);I(this,Ge);L(this,Ge,e)}get mission(){return B(this,Ge)}}Ge=new WeakMap;class as extends _{constructor(e=!1){super(e);u(this,"missions");this.missions=this.initMissions()}initMissions(){const e={};for(const t of Ys)e[t]=new kn(t);return e}static validateGame(e,t){const i=Object.keys(t.missions),n=e.space.programs.map(o=>o.name),r=ne(n,i),a=ne(i,n);for(const o of r)console.warn(...y(`The space mission '${o}' is not tracked in Kitten Scientists!`));for(const o of a)console.warn(...y(`The space mission '${o}' is not a space mission in Kittens Game!`))}load(e){m(e)||(super.load(e),F(this.missions,e.missions,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}))}}class _n extends kt{constructor(e){super(!1,-1,0);I(this,Ze);L(this,Ze,e)}get building(){return B(this,Ze)}}Ze=new WeakMap;class Ct extends V{constructor(e=!1,t=-1,i=new as){super(e,t);u(this,"buildings");u(this,"unlockMissions");this.buildings=this.initBuildings(),this.unlockMissions=i}initBuildings(){const e={};for(const t of Xi)e[t]=new _n(t);return e}static validateGame(e,t){as.validateGame(e,t.unlockMissions)}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.max=(i==null?void 0:i.max)??t.max,t.trigger=(i==null?void 0:i.trigger)??t.trigger}),this.unlockMissions.load(e.unlockMissions))}}class Cn{constructor(s,e,t=new Ct){u(this,"_host");u(this,"settings");u(this,"_bulkManager");u(this,"_workshopManager");this._host=s,this.settings=t,this._workshopManager=e,this._bulkManager=new yt(this._host,this._workshopManager)}tick(s){this.settings.enabled&&(this.autoBuild(s),this.settings.unlockMissions.enabled&&this.autoUnlock(s))}autoBuild(s,e=this.settings.buildings){const t=this._bulkManager,i=this.settings.trigger,n={};for(const a of Object.values(e))n[a.building]=this.getBuild(a.building);const r=t.bulk(e,n,i,"Space");for(const a of r)a.count<=0||this.build(a.id,a.count)!==0&&(s.requestGameUiRefresh=!0)}autoUnlock(s){if(!this._host.game.tabs[6].visible)return;const e=this._host.game.space.meta[0].meta;e:for(let t=0;t<e.length;t++){if(0<e[t].val||!e[t].unlocked||!this.settings.unlockMissions.missions[e[t].name].enabled)continue;const i=this._host.game.time.queue.getQueueElementControllerAndModel({name:e[t].name,type:"spaceMission"}),n=v(i.model.prices);for(const r of n)if(this._workshopManager.getValueAvailable(r.name)<r.val)continue e;i.controller.buyItem(i.model),t===7||t===12?this._host.engine.iactivity("upgrade.space.mission",[e[t].label],"ks-upgrade"):this._host.engine.iactivity("upgrade.space",[e[t].label],"ks-upgrade")}}build(s,e){let t=e;const i=t;let n;const r=game.getUnlockByName(s,"spaceBuilding"),a=new classes.ui.space.PlanetBuildingBtnController(this._host.game),o=a.fetchModel({controller:a,id:r.name});return t=this._bulkManager.construct(o,a,t),n=r.label,t!==i&&(console.warn(...y(`${n} Amount ordered: ${i} Amount Constructed: ${t}`)),t===0)?0:(this._host.engine.storeForSummary(n,t,"build"),t===1?this._host.engine.iactivity("act.build",[n],"ks-build"):this._host.engine.iactivity("act.builds",[n,this._host.renderAbsolute(t)],"ks-build"),t)}getBuild(s){return this._host.game.space.getBuilding(s)}}var rs=(c=>(c.build="ks-activity type_ks-build",c.craft="ks-activity type_ks-craft",c.upgrade="ks-activity type_ks-upgrade",c.research="ks-activity type_ks-research",c.trade="ks-activity type_ks-trade",c.hunt="ks-activity type_ks-hunt",c.praise="ks-activity type_ks-praise",c.adore="ks-activity type_ks-adore",c.transcend="ks-activity type_ks-transcend",c.faith="ks-activity type_ks-faith",c.accelerate="ks-activity type_ks-accelerate",c.timeSkip="ks-activity type_ks-timeSkip",c.festival="ks-activity type_ks-festival",c.star="ks-activity type_ks-star",c.distribute="ks-activity type_ks-distribute",c.promote="ks-activity type_ks-promote",c.misc="ks-activity",c))(rs||{});const os=["accelerate","adore","build","craft","distribute","faith","festival","hunt","misc","praise","promote","research","star","timeSkip","trade","transcend","upgrade"];class Sn extends _{constructor(e){super(!0);I(this,Ke);L(this,Ke,e)}get variant(){return B(this,Ke)}}Ke=new WeakMap;class xn extends _{constructor(e=!1,t=new _(!0)){super(e);u(this,"filters");u(this,"disableKGLog");this.filters=this.initFilters(),this.disableKGLog=t}initFilters(){const e={};for(const t of os)e[t]=new Sn(rs[t]);return e}load(e){var t;m(e)||(super.load(e),F(this.filters,e.filters,(i,n)=>{i.enabled=(n==null?void 0:n.enabled)??i.enabled}),this.disableKGLog.enabled=((t=e.disableKGLog)==null?void 0:t.enabled)??this.disableKGLog.enabled)}}class Tn extends V{constructor(e,t=!1){super(t,-1);I(this,Ve);u(this,"$upgrade");L(this,Ve,e)}get upgrade(){return B(this,Ve)}}Ve=new WeakMap;class ls extends V{constructor(e=!1){super(e,-1);u(this,"upgrades");this.upgrades=this.initUpgrades()}initUpgrades(){const e={};for(const t of es)e[t]=new Tn(t);return e}static validateGame(e,t){const i=Object.keys(t.upgrades),n=e.workshop.upgrades.map(o=>o.name),r=ne(n,i),a=ne(i,n);for(const o of r)console.warn(...y(`The workshop upgrade '${o}' is not tracked in Kitten Scientists!`));for(const o of a)console.warn(...y(`The workshop upgrade '${o}' is not an upgrade in Kittens Game!`))}load(e){m(e)||(super.load(e),F(this.upgrades,e.upgrades,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class En extends tn{constructor(e,t=!1,i=!0){super(t,i);I(this,je);L(this,je,e)}get resource(){return B(this,je)}}je=new WeakMap;class St extends V{constructor(e=!1,t=-1,i=new ls,n=new _){super(e,t);u(this,"resources");u(this,"shipOverride");u(this,"unlockUpgrades");this.resources=this.initResources(),this.shipOverride=n,this.unlockUpgrades=i}initResources(){const e={};for(const t of Hi)e[t]=new En(t);return e}static validateGame(e,t){const i=Object.keys(t.resources),n=e.workshop.crafts.map(o=>o.name),r=ne(n,i),a=ne(i,n);for(const o of r)console.warn(...y(`The workshop craft '${o}' is not tracked in Kitten Scientists!`));for(const o of a)console.warn(...y(`The workshop craft '${o}' is not an upgrade in Kittens Game!`));ls.validateGame(e,t.unlockUpgrades)}load(e){var t;m(e)||(super.load(e),F(this.resources,e.resources,(i,n)=>{i.enabled=(n==null?void 0:n.enabled)??i.enabled,i.limited=(n==null?void 0:n.limited)??i.limited,i.max=(n==null?void 0:n.max)??i.max,i.trigger=(n==null?void 0:n.trigger)??i.trigger}),this.unlockUpgrades.load(e.unlockUpgrades),this.shipOverride.enabled=((t=e.shipOverride)==null?void 0:t.enabled)??this.shipOverride.enabled)}}class ei extends Se{constructor(e,t=new St){super(e);u(this,"settings");this.settings=t}tick(e){return this.settings.enabled?(this.autoCraft(),this._host.engine.settings.highlighStock.enabled&&this.refreshStock(),this.settings.unlockUpgrades.enabled?this.autoUnlock():Promise.resolve()):Promise.resolve()}async autoUnlock(){if(!this._host.game.workshopTab.visible)return;const e=this._host.game.workshop.upgrades,t=new Array;e:for(const i of Object.values(this.settings.unlockUpgrades.upgrades)){if(!i.enabled)continue;const n=i.$upgrade??e.find(a=>a.name===i.upgrade);if(m(n)){console.error(...y(`Upgrade '${i.upgrade}' not found in game!`));continue}if(i.$upgrade===void 0&&(i.$upgrade=n),n.researched||!n.unlocked)continue;let r=T.window.dojo.clone(n.prices);r=this._host.game.village.getEffectLeader("scientist",r);for(const a of r){const o=this.getValueAvailable(a.name),l=this.getResource(a.name),h=re.evaluateSubSectionTrigger(this.settings.unlockUpgrades.trigger,i.trigger);if(h<0||0<h&&o<l.maxValue*h||o<a.val)continue e}t.push(n)}for(const i of t)await this.upgrade(i,"workshop")}autoCraft(e=this.settings.resources){const t=new Map,i=this.settings.trigger;for(const a of Object.values(e)){const o=re.evaluateSubSectionTrigger(i,a.trigger);if(o<0||!a.enabled)continue;const l=a.max?this.getResource(a.resource):!1,h=X(a.max);if(l&&h<l.value||!this.singleCraftPossible(a.resource))continue;const d=Object.keys(this.getMaterials(a.resource));d.map(p=>this.getResource(p)).filter(p=>0<p.maxValue).filter(p=>p.value/p.maxValue<o).length===0&&t.set(a,{countRequested:1,materials:d.map(p=>({consume:0,resource:p}))})}if(t.size<1)return;const n=new Map;for(const[a,o]of t)for(const l of o.materials)n.has(l.resource)||n.set(l.resource,new Array),v(n.get(l.resource)).push(a.resource);for(const[,a]of t)for(const o of a.materials){const l=this.getValueAvailable(o.resource);o.consume=l/v(n.get(o.resource)).length}for(const[a,o]of t){const l=this.getMaterials(a.resource);let h=Number.MAX_VALUE;for(const p of o.materials){const b=v(l[p.resource]),k=this.getResource(p.resource);if(!a.limited||a.resource==="ship"&&this.settings.shipOverride.enabled&&this.getResource("ship").value<243){h=Math.min(h,p.consume/b);continue}const w=this._host.game.getResCraftRatio(a.resource),O=this.getValueAvailable(p.resource)/v(n.get(p.resource)).length,ee=this.getValueAvailable(a.resource),Y=b,le=1+w,_e=O/Y,te=ee/le,fe=Math.max(0,Math.floor(Math.log(te)/Math.LN10+1e-9));h=Math.min(h,Math.min(_e-(0<k.maxValue&&k.maxValue<=k.value?0:te),10**(fe+1)),p.consume/b)}const d=this.getValueAvailable(a.resource),g=1+this._host.game.getResCraftRatio(a.resource),f=Number.MAX_VALUE/g-d/g;h=Math.min(h,f),o.countRequested=Math.max(0,a.max===-1?h:Math.min(h,(a.max-d)/g))}const r=new Array;for(const[a,o]of t)o.countRequested<1||r.push({amount:Math.floor(o.countRequested),name:a.resource});0<r.length&&this.craftMultiple(r)}craftMultiple(e){const t=new Array;for(const i of e){const n=this.getCraft(i.name),r=this._host.game.getResCraftRatio(n.name);if(!this._host.game.workshop.craft(n.name,i.amount,!0,!1,!1)){console.error(...y(`Failed trying to craft ${i.amount}x ${i.name}! This is a problem and should be reported.`));continue}const o=v(this._host.game.resPool.get(i.name)).title,l=Number.parseFloat((i.amount*(1+r)).toFixed(2));this._host.engine.storeForSummary(o,l,"craft"),t.push(this._host.engine.i18n("act.craft",[this._host.game.getDisplayValueExt(l),o]))}this._host.game.updateResources();for(const i of t)this._host.engine.printOutput("ks-activity type_ks-craft","#e65C00",i)}_canCraft(e,t){if(!this._host.game.workshopTab.visible&&e!=="wood")return!1;const i=this.getCraft(e),n=v(this.settings.resources[e]).enabled;let r=!1;if(i.unlocked&&n){r=!0;const a=this._host.game.workshop.getCraftPrice(i);for(const o of a)this.getValueAvailable(o.name)<o.val*t&&(r=!1)}return r}getCraft(e){const t=this._host.game.workshop.getCraft(e);if(!t)throw new Error(`Unable to find craft '${e}'`);return t}singleCraftPossible(e){if(!this._host.game.workshopTab.visible&&e!=="wood")return!1;const t=this.getMaterials(e);for(const[i,n]of z(t))if(this.getValueAvailable(i)<n)return!1;return!0}getMaterials(e){const t={},i=this.getCraft(e),n=this._host.game.workshop.getCraftPrice(i);for(const r of n)t[r.name]=r.val;return t}getTickVal(e,t,i=void 0){let n=this._host.game.getResourcePerTick(e.name,!0);if(e.craftable){let r=Number.MAX_VALUE;const a=this.getMaterials(e.name);for(const[o,l]of z(a)){const h=(1+this._host.game.getResCraftRatio(e.name))/l,d=this.getTickVal(this.getResource(o));d!=="ignore"&&(r=Math.min(d*h,r))}n+=r!==Number.MAX_VALUE?r:0}return n<=0&&(e.name==="spice"||e.name==="blueprint")?"ignore":(!i&&!m(t)&&(n+=t.getResValue(e.name)),n)}getAverageHunt(){const e={},t=this._host.game.getEffect("hunterRatio")+this._host.game.village.getEffectLeader("manager",0);return e.furs=40+32.5*t,e.ivory=50*Math.min(.225+.01*t,.5)+40*t*Math.min(.225+.01*t,.5),e.unicorns=.05,this.getValue("zebras")>=10&&(e.bloodstone=this.getValue("bloodstone")===0?.05:5e-4),this._host.game.ironWill&&this._host.game.workshop.get("goldOre").researched&&(e.gold=.625+.625*t),e}getResource(e){const t=this._host.game.resPool.get(e);if(m(t))throw new Error(`Unable to find resource ${e}`);return t}getValue(e){return this.getResource(e).value??0}getStock(e){const t=this._host.engine.settings.resources.resources[e];return t.enabled?t.stock:0}getConsume(e){const t=this._host.engine.settings.resources.resources[e];return t.enabled?t.consume:1}getValueAvailable(e){let t=this.getStock(e);if(e==="catnip"){const r=this._host.game.bld.getBuildingExt("pasture").meta,a=this._host.game.bld.getBuildingExt("aqueduct").meta,o=r.stage===0?r.val:0,l=a.stage===0?a.val:0,h=this.getPotentialCatnip(!0,o,l);h<0&&(t-=h*202*5)}let i=this.getValue(e);i=Math.max(i-t,0);const n=this.getConsume(e);return i*n}getPotentialCatnip(e,t,i){let n=this._host.game.getEffect("catnipPerTickBase");e?(n*=.1,n*=1+this._host.game.getLimitedDR(this._host.game.getEffect("coldHarshness"),1)):n*=this._host.game.calendar.getWeatherMod({name:"catnip"})+this._host.game.calendar.getCurSeason().modifiers.catnip,this._host.game.science.getPolicy("communism").researched&&(n=0);const r=this._host.game.village.getResProduction(),a=r.catnip?r.catnip*(1+this._host.game.getEffect("catnipJobRatio")):0;let o=n+a,l=this._host.game.space.getBuilding("hydroponics").val;this._host.game.prestige.meta[0].meta[21].researched&&(this._host.game.calendar.cycle===2&&(l*=2),this._host.game.calendar.cycle===7&&(l*=.5)),o*=1+.03*i+.025*l;const d=this._host.game.challenges.currentChallenge==="winterIsComing"?0:this._host.game.prestige.getParagonProductionRatio();o*=1+d,o*=1+this._host.game.religion.getSolarRevolutionRatio(),this._host.game.opts.disableCMBR||(o*=1+this._host.game.getCMBRBonus()),o=v(this._host.game.calendar.cycleEffectsFestival({catnip:o}).catnip);let g=this._host.game.village.getResConsumption().catnip;const f=this._host.game.bld.getBuildingExt("unicornPasture").meta.val;if(g*=1+this._host.game.getLimitedDR(t*-.005+f*-.0015,1),this._host.game.village.sim.kittens.length>0&&this._host.game.village.happiness>1){const p=this._host.game.village.happiness-1,b=this._host.game.getEffect("catnipDemandWorkerRatioGlobal");this._host.game.challenges.currentChallenge==="anarchy"?g*=1+p*(1+b):g*=1+p*(1+b)*(1-this._host.game.village.getFreeKittens()/this._host.game.village.sim.kittens.length)}return o+=g,o+=this._host.game.getResourcePerTickConvertion("catnip"),o}refreshStock(){const e=[...document.querySelectorAll("#game .res-row .res-cell.resAmount, #game .res-row .res-cell.resource-value")],t=new Map(e.map(i=>[v([...i.parentNode.classList.entries()].find(([n,r])=>r.startsWith("resource_")))[1].substring(9),i]));for(const[i,n]of z(this._host.engine.settings.resources.resources)){const r=t.get(i);if(!r)continue;if(!n.enabled||n.stock===0){(r.classList.contains("ks-stock-above")||r.classList.contains("ks-stock-below"))&&r.classList.remove("ks-stock-above","ks-stock-below");continue}const a=this._host.game.resPool.get(i).value<n.stock;r.classList.add(a?"ks-stock-below":"ks-stock-above"),r.classList.remove(a?"ks-stock-above":"ks-stock-below")}}}u(ei,"DEFAULT_CONSUME_RATE",1);class Rn extends _{constructor(e,t=!1,i=ei.DEFAULT_CONSUME_RATE,n=0){super(t);I(this,Je);u(this,"consume");u(this,"stock",0);L(this,Je,e),this.consume=i,this.stock=n}get resource(){return B(this,Je)}}Je=new WeakMap;class Mn extends _{constructor(e=!1){super(e);u(this,"resources");this.resources=this.initResources()}initResources(){const e={};for(const t of Wi)e[t]=new Rn(t);return e}load(e){m(e)||(super.load(e),F(this.resources,e.resources,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.consume=(i==null?void 0:i.consume)??t.consume,t.stock=(i==null?void 0:i.stock)??t.stock}))}}class An extends _{constructor(e=new _,t=new _(!0)){super(!0);u(this,"noConfirm");u(this,"compress");this.noConfirm=e,this.compress=t}load(e){m(e)||(super.load(e),this.noConfirm.load(e.noConfirm),this.compress.load(e.compress))}}class cs extends _{constructor(e=!1,t=new xn,i=new Mn,n=new An,r=xe,a=new _,o=new _){super(e);u(this,"interval",2e3);u(this,"locale");u(this,"ksColumn");u(this,"highlighStock");u(this,"filters");u(this,"resources");u(this,"states");this.filters=t,this.resources=i,this.states=n,this.locale=new jt(r,[{label:"Deutsch",value:"de-DE"},{label:"English",value:"en-US"},{label:"עִברִית",value:"he-IL"},{label:"中文",value:"zh-CN"}]),this.ksColumn=a,this.highlighStock=o}load(e,t=!1){m(e)||(super.load(e),t||(this.interval=e.interval??this.interval,this.states.load(e.states),this.locale.load(e.locale),this.ksColumn.load(e.ksColumn),this.highlighStock.load(e.highlighStock)),this.filters.load(e.filters),this.resources.load(e.resources))}}class hs extends ae{constructor(e,t=!1,i=-1,n){super(t,i);I(this,Xe);I(this,Ye);I(this,Qe,0);L(this,Ye,e),n&&(L(this,Qe,1),L(this,Xe,n))}get baseBuilding(){return B(this,Xe)}get building(){return B(this,Ye)}get stage(){return B(this,Qe)}}Xe=new WeakMap,Ye=new WeakMap,Qe=new WeakMap;class Pn extends _{constructor(e=!1){super(e);u(this,"buildings");this.buildings=this.initBuildings()}initBuildings(){const e={broadcasttower:"amphitheatre",dataCenter:"library",hydroplant:"aqueduct",solarfarm:"pasture",spaceport:"warehouse"},t={};for(const i of Fi)i!=="unicornPasture"&&(t[i]=new hs(i));for(const i of Vt)t[i]=new hs(i,!1,-1,e[i]);return t}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class xt extends ae{constructor(e,t,i=!1,n=-1){super(i,n);I(this,et);I(this,tt);L(this,et,e),L(this,tt,t)}get building(){return B(this,et)}get variant(){return B(this,tt)}}et=new WeakMap,tt=new WeakMap;class Bn extends _{constructor(e=!1){super(e);u(this,"buildings");this.buildings=this.initBuildings()}initBuildings(){const e={};for(const t of Zi)e[t]=new xt(t,H.OrderOfTheSun);for(const t of Ki)e[t]=new xt(t,H.Cryptotheology);for(const t of Vi)e[t]=new xt(t,H.Ziggurat);return e.unicornPasture=new xt("unicornPasture",H.UnicornPasture),e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class In extends ae{constructor(e,t=!1,i=-1){super(t,i);I(this,it);L(this,it,e)}get resource(){return B(this,it)}}it=new WeakMap;class $n extends _{constructor(e=!1){super(e);u(this,"resources");this.resources=this.initResources()}initResources(){const e={};for(const t of Wi)e[t]=new In(t);return e}load(e){m(e)||(super.load(e),F(this.resources,e.resources,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class Ln extends ae{constructor(e,t=!1,i=-1){super(t,i);I(this,st);L(this,st,e)}get building(){return B(this,st)}}st=new WeakMap;class On extends _{constructor(e=!1){super(e);u(this,"buildings");this.buildings=this.initBuildings()}initBuildings(){const e={};for(const t of Xi)e[t]=new Ln(t);return e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class us extends ae{constructor(e,t,i=!1,n=-1){super(i,n);I(this,nt);I(this,at);L(this,nt,e),L(this,at,t)}get building(){return B(this,nt)}get variant(){return B(this,at)}}nt=new WeakMap,at=new WeakMap;class Un extends _{constructor(e=!1){super(e);u(this,"buildings");this.buildings=this.initBuildings()}initBuildings(){const e={};for(const t of Yi)e[t]=new us(t,ce.Chronoforge);for(const t of Qi)t!=="usedCryochambers"&&(e[t]=new us(t,ce.VoidSpace));return e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.trigger=(i==null?void 0:i.trigger)??t.trigger}))}}class Dn extends _{constructor(e,t=!1){super(t);I(this,rt);L(this,rt,e)}get upgrade(){return B(this,rt)}}rt=new WeakMap;class Nn extends _{constructor(e=!1){super(e);u(this,"upgrades");this.upgrades=this.initUpgrades()}initUpgrades(){const e={};for(const t of es)e[t]=new Dn(t);return e}load(e){m(e)||(super.load(e),F(this.upgrades,e.upgrades,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}))}}class qn extends _{constructor(e=!1,t=new Pn,i=new Bn,n=new $n,r=new On,a=new Un,o=new Nn){super(e);u(this,"bonfire");u(this,"religion");u(this,"resources");u(this,"space");u(this,"time");u(this,"upgrades");this.bonfire=t,this.religion=i,this.resources=n,this.space=r,this.time=a,this.upgrades=o}load(e){m(e)||(super.load(e),this.bonfire.load(e.bonfire),this.religion.load(e.religion),this.resources.load(e.resources),this.space.load(e.space),this.time.load(e.time),this.upgrades.load(e.upgrades))}}class zn extends V{constructor(e=new _){super(!1,1);u(this,"cycles");u(this,"activeHeatTransferStatus");this.cycles=this.initCycles(),this.activeHeatTransferStatus=e}initCycles(){const e={};for(const t of ve)e[t]=new _;return e}load(e){m(e)||(super.load(e),F(this.cycles,e.cycles,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}),this.activeHeatTransferStatus.load(e.activeHeatTransferStatus))}}class Fn extends nn{constructor(e=new _,t=new zn){super(!1,5);u(this,"cycles");u(this,"seasons");u(this,"activeHeatTransfer");u(this,"ignoreOverheat");this.cycles=this.initCycles(),this.seasons=this.initSeason(),this.activeHeatTransfer=t,this.ignoreOverheat=e}initCycles(){const e={};for(const t of ve)e[t]=new _;return e}initSeason(){const e={};for(const t of Vs)e[t]=new _;return e}load(e){m(e)||(super.load(e),F(this.cycles,e.cycles,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}),F(this.seasons,e.seasons,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled}),this.ignoreOverheat.load(e.ignoreOverheat),this.activeHeatTransfer.load(e.activeHeatTransfer))}}class ds extends _{constructor(e=!1,t=new V(!1,1),i=new qn,n=new Fn){super(e);u(this,"accelerateTime");u(this,"timeSkip");u(this,"reset");this.accelerateTime=t,this.reset=i,this.timeSkip=n}load(e){m(e)||(super.load(e),this.accelerateTime.load(e.accelerateTime),this.reset.load(e.reset),this.timeSkip.load(e.timeSkip))}}class gs extends kt{constructor(e,t,i=!1){super(i,-1,0);I(this,ot);I(this,lt);L(this,ot,e),L(this,lt,t)}get building(){return B(this,ot)}get variant(){return B(this,lt)}}ot=new WeakMap,lt=new WeakMap;class ms extends V{constructor(e=!1,t=-1,i=new _){super(e,t);u(this,"buildings");u(this,"fixCryochambers");this.buildings=this.initBuildings(),this.fixCryochambers=i}initBuildings(){const e={};for(const t of Yi)e[t]=new gs(t,ce.Chronoforge);for(const t of Qi)t!=="usedCryochambers"&&(e[t]=new gs(t,ce.VoidSpace));return e}load(e){m(e)||(super.load(e),F(this.buildings,e.buildings,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.max=(i==null?void 0:i.max)??t.max,t.trigger=(i==null?void 0:i.trigger)??t.trigger}),this.fixCryochambers.load(e.fixCryochambers))}}class Hn extends is{constructor(e,t=!1){super(t);I(this,ct);L(this,ct,e)}get race(){return B(this,ct)}}ct=new WeakMap;class Wn extends V{constructor(e=!1){super(e);u(this,"races");this.races=this.initRaces()}initRaces(){const e={};for(const t of ji)t!=="leviathans"&&(e[t]=new Hn(t));return e}load(e){m(e)||(super.load(e),F(this.races,e.races,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.max=(i==null?void 0:i.max)??t.max}))}}class Gn extends sn{constructor(e,t,i,n,r,a,o,l=!1){super(t,i);I(this,ht);u(this,"seasons");I(this,ut);L(this,ht,e),this.seasons={autumn:new _(r),spring:new _(o),summer:new _(n),winter:new _(a)},L(this,ut,l)}get race(){return B(this,ht)}get require(){return B(this,ut)}}ht=new WeakMap,ut=new WeakMap;class fs extends V{constructor(e=!1,t=-1,i=new Wn,n=new _,r=new an(!1,1090,1095,1e4),a=new _){super(e,t);u(this,"races");u(this,"feedLeviathans");u(this,"buildEmbassies");u(this,"tradeBlackcoin");u(this,"unlockRaces");this.races=this.initRaces(),this.buildEmbassies=i,this.feedLeviathans=n,this.tradeBlackcoin=r,this.unlockRaces=a}initRaces(){const e={dragons:"titanium",griffins:"wood",leviathans:"unobtainium",lizards:"minerals",sharks:"iron"},t={};for(const i of ji){const n=e[i]??!1;t[i]=new Gn(i,!1,!1,!1,!1,!1,!1,n)}return t}load(e){m(e)||(super.load(e),F(this.races,e.races,(t,i)=>{t.enabled=(i==null?void 0:i.enabled)??t.enabled,t.limited=(i==null?void 0:i.limited)??t.limited,t.trigger=(i==null?void 0:i.trigger)??t.trigger,t.seasons.autumn.enabled=(i==null?void 0:i.seasons.autumn.enabled)??t.seasons.autumn.enabled,t.seasons.spring.enabled=(i==null?void 0:i.seasons.spring.enabled)??t.seasons.spring.enabled,t.seasons.summer.enabled=(i==null?void 0:i.seasons.summer.enabled)??t.seasons.summer.enabled,t.seasons.winter.enabled=(i==null?void 0:i.seasons.winter.enabled)??t.seasons.winter.enabled}),this.buildEmbassies.load(e.buildEmbassies),this.feedLeviathans.load(e.feedLeviathans),this.tradeBlackcoin.load(e.tradeBlackcoin),this.unlockRaces.load(e.unlockRaces))}}class Zn extends _{constructor(e=!1,t=new jt("any",Gi.map(n=>({label:"",value:n}))),i=new jt("none",js.map(n=>({label:"",value:n})))){super(e);u(this,"job");u(this,"trait");this.job=t,this.trait=i}load(e){m(e)||(super.load(e),this.job.load(e.job),this.trait.load(e.trait))}}class bs extends _{constructor(e=!1,t=new _,i=new V(!1,.98),n=new V(!1,1),r=new _,a=new Zn){super(e);u(this,"jobs");u(this,"holdFestivals");u(this,"hunt");u(this,"promoteKittens");u(this,"promoteLeader");u(this,"electLeader");this.jobs=this.initJobs(),this.holdFestivals=t,this.hunt=i,this.promoteKittens=n,this.promoteLeader=r,this.electLeader=a}initJobs(){const e={};for(const t of Gi)e[t]=new is(!1,0);return e}load(e){var t,i,n;m(e)||(super.load(e),F(this.jobs,e.jobs,(r,a)=>{r.enabled=(a==null?void 0:a.enabled)??r.enabled,r.max=(a==null?void 0:a.max)??r.max}),this.holdFestivals.enabled=((t=e.holdFestivals)==null?void 0:t.enabled)??this.holdFestivals.enabled,this.hunt.load(e.hunt),this.promoteKittens.enabled=((i=e.promoteKittens)==null?void 0:i.enabled)??this.promoteKittens.enabled,this.promoteLeader.enabled=((n=e.promoteLeader)==null?void 0:n.enabled)??this.promoteLeader.enabled,this.electLeader.load(e.electLeader))}}class Kn{constructor(s,e,t,i,n,r=new ds){u(this,"_host");u(this,"settings");u(this,"_bonfireManager");u(this,"_religionManager");u(this,"_spaceManager");u(this,"_workshopManager");this._host=s,this.settings=r,this._bonfireManager=e,this._religionManager=t,this._spaceManager=i,this._workshopManager=n}async tick(s){this.settings.enabled&&(this.settings.accelerateTime.enabled&&this.accelerateTime(),this.settings.timeSkip.enabled&&this.timeSkip(),this.settings.reset.enabled&&await this.autoReset(this._host.engine))}async autoReset(s){if(this._host.game.challenges.currentChallenge)return;const e=[],t=[],i=a=>{if(t.length!==0)for(const o of a){if(m(o.model))continue;const l=o.model,h=l.metadata.name,d=t.indexOf(h);if(d!==-1&&(t.splice(d,1),this._host.game.resPool.hasRes(v(l.prices))))return!0}return!1};for(const[a,o]of z(this.settings.reset.bonfire.buildings)){if(!o.enabled)continue;if(o.trigger<0)return;let l;try{l=this._host.game.bld.getBuildingExt(a)}catch{l=null}if(!m(l))if(e.push({name:l.meta.label??v(l.meta.stages)[v(l.meta.stage)].label,trigger:o.trigger,val:l.meta.val}),0<o.trigger){if(l.meta.val<o.trigger)return}else t.push(a)}const n=this.settings.reset.religion.buildings.unicornPasture;if(n.enabled){if(n.trigger<0)return;const a=this._host.game.bld.getBuildingExt("unicornPasture");if(e.push({name:v(a.meta.label),trigger:n.trigger,val:a.meta.val}),0<n.trigger){if(a.meta.val<n.trigger)return}else t.push("unicornPasture")}if(i(this._bonfireManager.manager.tab.children)||t.length)return;for(const[a,o]of z(this.settings.reset.space.buildings)){if(!o.enabled)continue;if(o.trigger<0)return;const l=this._host.game.space.getBuilding(a);if(e.push({name:l.label,trigger:o.trigger,val:l.val}),0<o.trigger){if(l.val<o.trigger)return}else t.push(a)}if(t.length===0){const a=v(this._host.game.spaceTab.planetPanels);for(const o of a)for(const l of o.children){const h=v(l.model),d=h.metadata.name,g=t.indexOf(d);if(g!==-1&&(t.splice(g,1),this._host.game.resPool.hasRes(v(h.prices))))break}}if(t.length)return;for(const[a,o]of z(this.settings.reset.religion.buildings)){if(!o.enabled)continue;if(o.trigger<0)return;const l=v(this._religionManager.getUpgradeMeta(a,o.variant));if(e.push({name:l.label,trigger:o.trigger,val:l.val}),0<o.trigger){if(l.val<o.trigger)return}else t.push(a)}if(i(this._religionManager.manager.tab.zgUpgradeButtons)||i(this._religionManager.manager.tab.rUpgradeButtons)||i(this._religionManager.manager.tab.ctPanel.children[0].children)||t.length)return;for(const[a,o]of z(this.settings.reset.time.buildings)){if(!o.enabled)continue;if(o.trigger<0)return;const l=v(this.getBuild(a,o.variant));if(e.push({name:l.label,trigger:o.trigger,val:l.val}),0<o.trigger){if(l.val<o.trigger)return}else t.push(a)}if(i(this.manager.tab.cfPanel.children[0].children)||i(this.manager.tab.vsPanel.children[0].children)||t.length)return;for(const[a,o]of z(this.settings.reset.resources.resources)){if(!o.enabled)continue;if(o.trigger<0)return;const l=v(this._host.game.resPool.get(a));if(e.push({name:this._host.engine.i18n(`$resources.${o.resource}.title`),trigger:o.trigger,val:l.value}),l.value<o.trigger)return}for(const[,a]of z(this.settings.reset.upgrades.upgrades))if(a.enabled){const o=v(this._host.game.workshop.upgrades.find(l=>l.name===a.upgrade));if(e.push({name:o.label,trigger:1,val:o.researched?1:0}),!o.researched)return}s.stop(!1);const r=async(a=1500)=>new Promise((o,l)=>{if(!this._host.engine.settings.enabled){l(new Error("canceled by player"));return}setTimeout(o,a)});try{for(const a of e)await r(500),this._host.engine.imessage("reset.check",[a.name,this._host.game.getDisplayValueExt(a.trigger),this._host.game.getDisplayValueExt(a.val)]);await r(0),this._host.engine.imessage("reset.checked"),await r(),this._host.engine.iactivity("reset.tip"),await r(),this._host.engine.imessage("reset.countdown.10"),await r(2e3),this._host.engine.imessage("reset.countdown.9"),await r(),this._host.engine.imessage("reset.countdown.8"),await r(),this._host.engine.imessage("reset.countdown.7"),await r(),this._host.engine.imessage("reset.countdown.6"),await r(),this._host.engine.imessage("reset.countdown.5"),await r(),this._host.engine.imessage("reset.countdown.4"),await r(),this._host.engine.imessage("reset.countdown.3"),await r(),this._host.engine.imessage("reset.countdown.2"),await r(),this._host.engine.imessage("reset.countdown.1"),await r(),this._host.engine.imessage("reset.countdown.0"),await r(),this._host.engine.iactivity("reset.last.message"),await r()}catch{this._host.engine.imessage("reset.cancel.message"),this._host.engine.iactivity("reset.cancel.activity");return}for(let a=0;a<this._host.game.challenges.challenges.length;a++)this._host.game.challenges.challenges[a].pending=!1;this._host.game.resetAutomatic()}accelerateTime(){if(this._workshopManager.getValueAvailable("temporalFlux")<=0){this._host.game.time.isAccelerated&&(this._host.game.time.isAccelerated=!1);return}if(this._host.game.time.isAccelerated)return;const e=this._host.game.resPool.get("temporalFlux");e.maxValue*this.settings.accelerateTime.trigger<=e.value&&(this._host.game.time.isAccelerated=!0,this._host.engine.iactivity("act.accelerate",[],"ks-accelerate"),this._host.engine.storeForSummary("accelerate",1))}timeSkip(){if(!this._host.game.workshop.get("chronoforge").researched||this._host.game.calendar.day<0)return;const s=this._host.game.getEffect("shatterCostIncreaseChallenge"),e=this._workshopManager.getValueAvailable("timeCrystal");if(e<this.settings.timeSkip.trigger||e<1+s)return;const t=this._host.game.getEffect("shatterVoidCost"),i=this._workshopManager.getValueAvailable("void");if(i<t)return;const n=this._host.game.calendar.season;if(!this.settings.timeSkip.seasons[this._host.game.calendar.seasons[n].name].enabled)return;const r=this._host.game.calendar.cycle;if(!this.settings.timeSkip.cycles[ve[r]].enabled)return;const a=this._host.game.getEffect("heatMax"),o=this._host.game.time.heat;if(!this.settings.timeSkip.ignoreOverheat.enabled&&a<=o)return;const l=this._host.game.challenges.getChallenge("1000Years").researched?5:10;let h=Number.POSITIVE_INFINITY;if(!this.settings.timeSkip.ignoreOverheat.enabled&&this.settings.timeSkip.activeHeatTransfer.enabled){const w=this._host.game.getEffect("heatPerTick"),O=this._host.game.ticksPerSecond;if(this.settings.timeSkip.activeHeatTransfer.activeHeatTransferStatus.enabled){o<=a*this.settings.timeSkip.activeHeatTransfer.trigger&&(this.settings.timeSkip.activeHeatTransfer.activeHeatTransferStatus.enabled=!1,this._host.refreshEntireUserInterface(),this._host.engine.iactivity("act.time.activeHeatTransferEnd",[],"ks-timeSkip"));const ee=this._host.game.getEffect("temporalFluxProduction"),Y=(this._host.game.calendar.daysPerSeason+10+this._host.game.getEffect("temporalParadoxDay"))*this._host.game.calendar.seasonsPerYear,le=this._host.game.calendar.ticksPerDay,_e=(1+this._host.game.timeAccelerationRatio())/le,te=Y/_e,fe=this._host.game.resPool.get("temporalFlux"),Re=fe.maxValue>te,gt=fe.value<te;if(!n&&this._host.game.calendar.day<10&&ee>l/w&&this.settings.accelerateTime.enabled&&Re&&gt)h=Math.ceil((te+le*10-fe.value)/ee),this._host.engine.iactivity("act.time.getTemporalFlux",[],"ks-timeSkip"),this._host.engine.storeForSummary("time.getTemporalFlux",1);else{if(this.settings.timeSkip.activeHeatTransfer.cycles[ve[r]].enabled)return;h=this._host.game.calendar.yearsPerCycle-this._host.game.calendar.cycleYear}}else o>=a-w*O*10&&(this.settings.timeSkip.activeHeatTransfer.activeHeatTransferStatus.enabled=!0,this._host.refreshEntireUserInterface(),this._host.engine.iactivity("act.time.activeHeatTransferStart",[],"ks-timeSkip"),this._host.engine.storeForSummary("time.activeHeatTransferStart",1))}const d=X(this.settings.timeSkip.max);let g=Math.floor(Math.min(this.settings.timeSkip.ignoreOverheat.enabled?Number.POSITIVE_INFINITY:(a-o)/l,d,h,e/(1+s),0<t?i/t:Number.POSITIVE_INFINITY)),f=0;const p=this._host.game.calendar.yearsPerCycle,b=p-this._host.game.calendar.cycleYear,k=this._host.game.calendar.cyclesPerEra;if(g<b)f=g;else{f+=b,g-=b;let w=1;for(;p<g&&this.settings.timeSkip.cycles[ve[(r+w)%k]].enabled;)f+=p,g-=p,w+=1;this.settings.timeSkip.cycles[ve[(r+w)%k]].enabled&&0<g&&(f+=g)}if(0<f){const w=this._host.game.timeTab.cfPanel.children[0].children[0];if(m(w.model))return;this._host.engine.iactivity("act.time.skip",[f],"ks-timeSkip"),w.controller.doShatterAmt(w.model,f),this._host.engine.storeForSummary("time.skip",f)}}getBuild(s,e){return e===ce.Chronoforge?this._host.game.time.getCFU(s):this._host.game.time.getVSU(s)}}class Vn{constructor(s,e,t=new ms){u(this,"_host");u(this,"settings");u(this,"_bulkManager");u(this,"_workshopManager");this._host=s,this.settings=t,this._bulkManager=new yt(this._host,e),this._workshopManager=e}tick(s){this.settings.enabled&&(this.autoBuild(s),this.settings.fixCryochambers.enabled&&this.fixCryochambers())}autoBuild(s,e=this.settings.buildings){const t=this._bulkManager,i=this.settings.trigger,n={};for(const a of Object.values(e)){const o=this.getBuild(a.building,a.variant);n[a.building]=v(o);const h=(a.variant===ce.Chronoforge?this._host.game.time.queue.getQueueElementControllerAndModel({name:a.building,type:"chronoforge"}):this._host.game.time.queue.getQueueElementControllerAndModel({name:a.building,type:"voidSpace"})).model,d=a.variant===ce.Chronoforge?this._host.game.timeTab.cfPanel:this._host.game.timeTab.vsPanel,g=v(n[a.building]);g.tHidden=!(h!=null&&h.visible)||!h.enabled||!d.visible}const r=t.bulk(e,n,i,"Time");for(const a of r)a.count>0&&(this.build(a.id,a.variant,a.count),s.requestGameUiRefresh=!0)}build(s,e,t){let i=t,n;const r=i;if(e===ce.Chronoforge){const a=game.getUnlockByName(s,"chronoforge"),o=new classes.ui.time.ChronoforgeBtnController(this._host.game),l=o.fetchModel({controller:o,id:a.name});i=this._bulkManager.construct(l,o,i),n=a.label}else{const a=game.getUnlockByName(s,"voidSpace"),o=new classes.ui.time.VoidSpaceBtnController(this._host.game),l=o.fetchModel({controller:o,id:a.name});i=this._bulkManager.construct(l,o,i),n=a.label}i!==r&&(console.warn(...y(`${n} Amount ordered: ${r} Amount Constructed: ${i}`)),i===0)||(this._host.engine.storeForSummary(n,i,"build"),i===1?this._host.engine.iactivity("act.build",[n],"ks-build"):this._host.engine.iactivity("act.builds",[n,this._host.renderAbsolute(i)],"ks-build"))}getBuild(s,e){return e===ce.Chronoforge?this._host.game.time.getCFU(s):this._host.game.time.getVSU(s)}fixCryochambers(){if(this._host.game.time.getVSU("usedCryochambers").val<1)return;const s=v(this._host.game.time.getVSU("usedCryochambers").fixPrices);for(const r of s)if(this._workshopManager.getValueAvailable(r.name)<r.val)return;const e=new classes.ui.time.FixCryochamberBtnController(this._host.game),t=e.fetchModel({});let i=0,n;do n=!1,n=e.buyItem(t).itemBought,i+=n?1:0;while(n);0<i&&(this._host.engine.iactivity("act.fix.cry",[this._host.renderAbsolute(i)],"ks-fixCry"),this._host.engine.storeForSummary("fix.cry",i))}}class jn{constructor(s,e,t=new fs){u(this,"_host");u(this,"settings");u(this,"_workshopManager");this._host=s,this.settings=t,this._workshopManager=e}tick(s){this.settings.enabled&&(this.autoTrade(),this.settings.unlockRaces.enabled&&this.autoUnlock(s),this.settings.buildEmbassies.enabled&&this.autoBuildEmbassies(s),this.settings.feedLeviathans.enabled&&this.autoFeedElders(),this.settings.tradeBlackcoin.enabled&&this.autoTradeBlackcoin())}autoTrade(s){const e=this._workshopManager.getResource("manpower"),t=this._workshopManager.getResource("gold"),i=this.settings.trigger,n=[],r=this._host.game.calendar.getCurSeason().name;for(const d of Object.values(this.settings.races)){const g=this.getRace(d.race),f=re.evaluateSubSectionTrigger(i,d.trigger);if(f<0||!d.enabled||!d.seasons[r].enabled||!g.unlocked||!this.singleTradePossible(i,e,t,d))continue;const p=d.require?this._workshopManager.getResource(d.require):!1,b=this.getProfitability(d.race);(d.limited&&b||!p||f<=p.value/p.maxValue)&&n.push(d.race)}if(n.length===0)return;let a=this.getLowestTradeAmount(null,!0,!1);if(a<1)return;const o=[];for(let d=0;d<n.length;d++){const g=n[d],f=this.settings.races[g],p=f.require?this._workshopManager.getResource(f.require):!1,b=re.evaluateSubSectionTrigger(i,f.trigger),k=(!p||b<=p.value/p.maxValue)&&b<=t.value/t.maxValue,w=this.getLowestTradeAmount(g,f.limited,k);if(w<1){n.splice(d,1),d--;continue}o.push(w)}if(n.length===0)return;const l={};for(;0<n.length&&1<=a;){if(a<n.length){const p=Math.floor(Math.random()*n.length),b=n[p];m(l[b])&&(l[b]=0),l[b]+=1,a-=1,n.splice(p,1),o.splice(p,1);continue}let d=Math.floor(a/n.length),g=0;const f=n[g];for(let p=0;p<n.length;++p)o[p]<d&&(d=o[p],g=p);m(l[f])&&(l[f]=0),l[f]+=d,a-=d,n.splice(g,1),o.splice(g,1)}if(Object.values(l).length===0)return;const h={};for(const[d,g]of z(l)){const f=this.getRace(d),p=this.getMaterials(d);for(const[k,w]of z(p))h[k]||(h[k]=0),h[k]-=w*g;const b=this.getAverageTrade(f);for(const[k,w]of z(b)){const O=this._workshopManager.getResource(k);h[k]||(h[k]=0),h[k]+=O.maxValue>0?Math.min(v(b[k])*v(l[d]),Math.max(O.maxValue-O.value,0)):w*v(l[d])}}m(s)||s.pushToCache({materials:h,timeStamp:this._host.game.timer.ticksTotal});for(const[d,g]of z(l))0<g&&this.trade(d,g)}autoBuildEmbassies(s){var o;if(!this._host.game.diplomacy.races[0].embassyPrices)return;const e=this._workshopManager.getResource("culture");let t=0;const i=this.settings.buildEmbassies.trigger;if(e.value/e.maxValue<X(i))return;const n=this._host.game.diplomacyTab.racePanels;t=this._workshopManager.getValueAvailable("culture");const r={},a=[];for(let l=0;l<n.length;l++){if(!n[l].embassyButton)continue;const h=n[l].race.name,d=this._host.game.diplomacy.get(h),g=X(this.settings.buildEmbassies.races[h].max);!this.settings.buildEmbassies.races[h].enabled||g<=d.embassyLevel||!d.unlocked||(r[h]={basePrice:v((o=d.embassyPrices)==null?void 0:o[0]).val,currentEm:d.embassyLevel,max:g,priceSum:0,race:d,val:0},a.push(h))}if(a.length!==0){for(;a.length>0;)for(let l=0;l<a.length;l++){const h=a[l],d=v(r[h]);if(d.max<=d.currentEm+d.val){a.splice(l,1),--l;continue}const g=d.basePrice*1.15**(d.currentEm+d.val);g<=t?(t-=g,d.priceSum+=g,d.val+=1,s.requestGameUiRefresh=!0):(a.splice(l,1),--l)}for(const[,l]of z(r))l.val!==0&&(t=this._workshopManager.getValueAvailable("culture"),t<l.priceSum&&console.warn(...y("Something has gone horribly wrong.",l.priceSum,t)),this._workshopManager.getResource("culture").value-=l.priceSum,l.race.embassyLevel+=l.val,this._host.engine.storeForSummary("embassy",l.val),l.val!==1?this._host.engine.iactivity("build.embassies",[l.val,l.race.title],"ks-build"):this._host.engine.iactivity("build.embassy",[l.val,l.race.title],"ks-build"))}}autoFeedElders(){const s=this._host.game.diplomacy.get("leviathans"),e=this._host.game.resPool.get("necrocorn");!s.unlocked||e.value===0||(1<=e.value?s.energy<this._host.game.diplomacy.getMarkerCap()&&(this._host.game.diplomacy.feedElders(),this._host.engine.iactivity("act.feed"),this._host.engine.storeForSummary("feed",1)):.25*(1+this._host.game.getEffect("corruptionBoostRatio"))<1&&(this._host.engine.storeForSummary("feed",e.value),this._host.game.diplomacy.feedElders(),this._host.engine.iactivity("dispose.necrocorn")))}autoUnlock(s){if(!this._host.game.tabs[4].visible)return;const e=this._host.game.diplomacy.get("leviathans").unlocked?8:7;if(this._host.game.diplomacyTab.racePanels.length<e){let t=this._workshopManager.getValueAvailable("manpower");if(!this._host.game.diplomacy.get("lizards").unlocked&&t>=1e3){this._host.game.resPool.get("manpower").value-=1e3;const i=v(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("sharks").unlocked&&t>=1e3){this._host.game.resPool.get("manpower").value-=1e3;const i=v(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("griffins").unlocked&&t>=1e3){this._host.game.resPool.get("manpower").value-=1e3;const i=v(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("nagas").unlocked&&this._host.game.resPool.get("culture").value>=1500&&t>=1e3){this._host.game.resPool.get("manpower").value-=1e3;const i=v(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("zebras").unlocked&&this._host.game.resPool.get("ship").value>=1&&t>=1e3){this._host.game.resPool.get("manpower").value-=1e3;const i=v(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("spiders").unlocked&&v(this._host.game.resPool.get("ship")).value>=100&&v(this._host.game.resPool.get("science")).maxValue>125e3&&t>=1e3){v(this._host.game.resPool.get("manpower")).value-=1e3;const i=v(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}if(!this._host.game.diplomacy.get("dragons").unlocked&&this._host.game.science.get("nuclearFission").researched&&t>=1e3){v(this._host.game.resPool.get("manpower")).value-=1e3;const i=v(this._host.game.diplomacy.unlockRandomRace());this._host.engine.iactivity("upgrade.race",[i.title],"ks-upgrade"),t-=1e3,s.requestGameUiRefresh=!0}}}autoTradeBlackcoin(){const s=this._host.game.calendar.cryptoPrice,e=this._host.game.resPool.get("relic").value,t=this._host.game.resPool.get("blackcoin").value;let i=0,n=0;if(s<this.settings.tradeBlackcoin.buy&&this.settings.tradeBlackcoin.trigger<e){this._host.game.diplomacy.buyBcoin();const r=this._host.game.resPool.get("blackcoin").value;i=Math.round(r-t),this._host.engine.iactivity("act.blackcoin.buy",[this._host.renderAbsolute(i)])}else if(s>this.settings.tradeBlackcoin.sell&&0<this._host.game.resPool.get("blackcoin").value){this._host.game.diplomacy.sellBcoin();const r=v(this._host.game.resPool.get("relic")).value;n=Math.round(r-e),this._host.engine.iactivity("act.blackcoin.sell",[this._host.renderAbsolute(n)])}}trade(s,e){const t=this.getRace(s);this._host.game.diplomacy.tradeMultiple(t,e),this._host.engine.storeForSummary(t.title,e,"trade"),this._host.engine.iactivity("act.trade",[this._host.renderAbsolute(e),J(t.title)],"ks-trade")}getProfitability(s){const e=this.getRace(s);let t=0;const i=this.getMaterials(s);for(const[a,o]of z(i)){const l=this._workshopManager.getTickVal(this._workshopManager.getResource(a));if(l!=="ignore"){if(l<=0)return!1;t+=o/l}}let n=0;const r=this.getAverageTrade(e);for(const[a,o]of z(r)){const l=this._workshopManager.getResource(a),h=this._workshopManager.getTickVal(l);if(h!=="ignore"){if(h<=0)return!0;n+=0<l.maxValue?Math.min(o,Math.max(l.maxValue-l.value,0))/h:o/h}}return t<=n}getAverageTrade(s){const e=this._host.game.getEffect("standingRatio")+this._host.game.diplomacy.calculateStandingFromPolicies(s.name,this._host.game),t=1+s.energy*.02,i=1+this._host.game.diplomacy.getTradeRatio()+this._host.game.diplomacy.calculateTradeBonusFromPolicies(s.name,this._host.game),n=s.standing<0?s.standing+e:0,r=0<n?1+n:1,a=0<s.standing?Math.min(s.standing+e/2,1):0,o={};for(const d of s.sells){if(!this._isValidTrade(d,s)){o[d.name]=0;continue}let g=0;const f=s.embassyPrices?d.chance*(1+this._host.game.getLimitedDR(.01*s.embassyLevel,.75)):d.chance;if(s.name==="zebras"&&d.name==="titanium"){const p=this._host.game.resPool.get("ship").value,b=Math.min(.15+p*.0035,1);g=1.5*(1+p/50)*(r*b)}else{const p=d.seasons?1+d.seasons[this._host.game.calendar.getCurSeason().name]:1,b=(r-a)*Math.min(f/100,1),k=a*Math.min(f/100,1);g=(b+1.25*k)*d.value*t*p*i}o[d.name]=g}const l=s.embassyPrices?.35*(1+.01*s.embassyLevel):.35,h=r*Math.min(l,1);return o.spice=25*h+50*h*i/2,o.blueprint=.1*r,o}_isValidTrade(s,e){return!(s.minLevel&&e.embassyLevel<s.minLevel)&&(this._host.game.resPool.get(s.name).unlocked||s.name==="titanium"||s.name==="uranium"||e.name==="leviathans")}getLowestTradeAmount(s,e,t){let i;const n=this.getMaterials(s);let r;for(const[h,d]of z(n)){if(h==="manpower"){let g=d;this._host.game.challenges.isActive("postApocalypse")&&(g=d*(1+this._host.game.bld.getPollutionLevel())),r=this._workshopManager.getValueAvailable(h)/g}else if(h==="gold"){let g=d;this._host.game.challenges.isActive("postApocalypse")&&(g=d*(1+this._host.game.bld.getPollutionLevel())),r=this._workshopManager.getValueAvailable(h)/g}else r=this._workshopManager.getValueAvailable(h)/d;i=i===void 0||r<i?r:i}if(i=Math.floor(i??0),i===0)return 0;if(s===null||s==="leviathans")return i;const a=this.getRace(s);let o=0;const l=this.getAverageTrade(a);for(const h of a.sells){const d=this._workshopManager.getResource(h.name);let g=0;if(!d.maxValue)continue;g=v(l[h.name]);const f=Math.max((d.maxValue-d.value)/g,0);o=f<o?o:f}return o=Math.ceil(o),o===0?0:(i=o<i?Math.max(o-1,1):i,Math.floor(i))}getMaterials(s=null){const e={gold:15-this._host.game.getEffect("tradeGoldDiscount"),manpower:50-this._host.game.getEffect("tradeCatpowerDiscount")};if(m(s))return e;const t=this.getRace(s).buys;for(const i of t)e[i.name]=i.val;return e}getRace(s){const e=this._host.game.diplomacy.get(s);if(m(e))throw new Error(`Unable to retrieve race '${s}'`);return e}singleTradePossible(s,e,t,i){const n=i?re.evaluateSubSectionTrigger(s,i.trigger):s;if(n<0&&i===void 0)return!0;if(n<0&&i!==void 0||e.value/e.maxValue<n||t.value/t.maxValue<n)return!1;const r=this.getMaterials(i==null?void 0:i.race);for(const[a,o]of z(r))if(this._workshopManager.getValueAvailable(a)<o)return!1;return!0}}class Jn{constructor(s){u(this,"_host");u(this,"_cache",new Array);u(this,"_cacheSum",{});this._host=s}pushToCache(s){this._cache.push(s);for(const[e,t]of z(s.materials))this._cacheSum[e]||(this._cacheSum[e]=0),this._cacheSum[e]+=t;for(let e=0;e<this._cache.length;++e){const t=this._cache[e];if(this._cache.length>1e4){const i=t.materials;for(const[n,r]of z(i))this._cacheSum[n]||(this._cacheSum[n]=0),this._cacheSum[n]-=r;this._cache.shift(),e--}else return}}getResValue(s){if(this._cache.length===0||!this._cacheSum[s])return 0;const e=this._host.game.timer.ticksTotal,t=this._cache[0].timeStamp;return this._cacheSum[s]/(e-t)}}class Xn{constructor(s,e,t=new bs){u(this,"_host");u(this,"settings");u(this,"_cacheManager");u(this,"_workshopManager");this._host=s,this.settings=t,this._cacheManager=new Jn(this._host),this._workshopManager=e}tick(s){this.settings.enabled&&(this.autoDistributeKittens(s),this.settings.hunt.enabled&&this.autoHunt(this._cacheManager),this.settings.holdFestivals.enabled&&this.autoFestival(this._cacheManager),this.settings.electLeader.enabled&&this.autoElect(),this.settings.promoteLeader.enabled&&this.autoPromoteLeader(),this.settings.promoteKittens.enabled&&this.autoPromoteKittens())}autoDistributeKittens(s){const e=this._host.game.village.getFreeKittens();if(e){for(let t=0;t<e;++t){const i=new Array;for(const a of this._host.game.village.jobs){const o=this.settings.jobs[a.name].enabled,l=a.unlocked;if(!o||!l)continue;const h=this._host.game.village.getJobLimit(a.name),d=X(this.settings.jobs[a.name].max),g=a.value;g<h&&g<d&&i.push({count:g,job:a,toCap:h-g})}if(!i.length)return;const n=!m(i.find(a=>a.job.name==="farmer"&&a.count===0));i.sort((a,o)=>a.count-o.count);const r=n?"farmer":i[0].job.name;this._host.game.village.assignJob(this._host.game.village.getJob(r),1),s.requestGameUiRefresh=!0,this._host.engine.iactivity("act.distribute",[this._host.engine.i18n(`$village.job.${r}`)],"ks-distribute")}this._host.engine.storeForSummary("distribute",e)}}autoElect(){if(this._host.game.challenges.isActive("anarchy"))return;const s=this._host.game.village.sim.kittens,e=this._host.game.village.leader,t=this.settings.electLeader.job.selected,i=this.settings.electLeader.trait.selected,n=s.filter(a=>(a.job===t||t==="any")&&a.trait.name===i);if(n.length===0)return;n.sort((a,o)=>o.rank-a.rank);const r=n[0];!m(e)&&e.trait.name===i&&(e.job===t||t==="any")&&r.rank<=e.rank||(this._host.game.village.makeLeader(r),this._host.engine.iactivity("act.elect"))}autoPromoteKittens(){const s=this._workshopManager.getResource("gold");if(!(this.settings.promoteKittens.trigger<s.value/s.maxValue))for(let e=0;e<this._host.game.village.sim.kittens.length;e++){let t=-1;const i=this._host.game.village.sim.kittens[e].engineerSpeciality;if(!m(i)&&(t=v(this._host.game.workshop.getCraft(i)).tier,!(t<=this._host.game.village.sim.kittens[e].rank))){this._host.game.village.promoteKittens();return}}}autoPromoteLeader(){var s,e;if(this._host.game.science.get("civil").researched&&this._host.game.village.leader!==null){const t=this._host.game.village.leader,i=t.rank,n=this._workshopManager.getResource("gold"),r=this._workshopManager.getStock("gold");this._host.game.village.sim.goldToPromote(i,i+1,n.value-r)[0]&&this._host.game.village.sim.promote(t,i+1)===1&&(this._host.engine.iactivity("act.promote",[i+1],"ks-promote"),(s=this._host.game.villageTab.censusPanel)==null||s.census.renderGovernment(this._host.game.villageTab.censusPanel.census.container),(e=this._host.game.villageTab.censusPanel)==null||e.census.update(),this._host.engine.storeForSummary("promote",1))}}autoHunt(s){const e=this._workshopManager.getResource("manpower"),t=this.settings.hunt.trigger;if(!(e.value<100||this._host.game.challenges.isActive("pacifism"))&&t<=e.value/e.maxValue&&100<=e.value){const i=Math.floor(e.value/100);this._host.engine.storeForSummary("hunt",i),this._host.engine.iactivity("act.hunt",[this._host.renderAbsolute(i)],"ks-hunt");const n=this._workshopManager.getAverageHunt(),r={};for(const[a,o]of z(n)){const l=this._workshopManager.getResource(a);r[a]=0<l.maxValue?Math.min(o*i,Math.max(l.maxValue-l.value,0)):o*i}m(s)||s.pushToCache({materials:r,timeStamp:this._host.game.timer.ticksTotal}),this._host.game.village.huntAll()}}autoFestival(s){if(!this._host.game.science.get("drama").researched||400<this._host.game.calendar.festivalDays||!this._host.game.prestige.getPerk("carnivals").researched&&0<this._host.game.calendar.festivalDays)return;const e=this._workshopManager;if(e.getValueAvailable("manpower")<1500||e.getValueAvailable("culture")<5e3||e.getValueAvailable("parchment")<2500)return;const t=4e3*e.getTickVal(e.getResource("manpower"),s,!0)>1500,i=4e3*e.getTickVal(e.getResource("culture"),s,!0)>5e3,n=4e3*e.getTickVal(e.getResource("parchment"),s,!0)>2500;if(!t&&!i&&!n)return;const r=this._host.game.calendar.festivalDays,a=new classes.village.ui.FestivalButtonController(this._host.game),o=a.fetchModel({controller:a,description:"",handler:()=>{this._host.game.village.holdFestival(1)},name:"",prices:[{name:"manpower",val:1500},{name:"culture",val:5e3},{name:"parchment",val:2500}]});a.buyItem(o),this._host.engine.storeForSummary("festival"),r>0?this._host.engine.iactivity("festival.extend",[],"ks-festival"):this._host.engine.iactivity("festival.hold",[],"ks-festival")}}const ps={"de-DE":un,"en-US":hn,"he-IL":dn,"zh-CN":gn};class re{constructor(s,e){u(this,"_i18nData");u(this,"_isLoaded",!1);u(this,"_host");u(this,"settings");u(this,"bonfireManager");u(this,"religionManager");u(this,"scienceManager");u(this,"spaceManager");u(this,"timeControlManager");u(this,"timeManager");u(this,"tradeManager");u(this,"villageManager");u(this,"workshopManager");u(this,"_activitySummary");u(this,"_timeoutMainLoop");this.settings=new cs,this._i18nData=ps,this.setLanguage(e,!1),this._host=s,this._activitySummary=new cn(this._host),this.workshopManager=new ei(this._host),this.bonfireManager=new ln(this._host,this.workshopManager),this.religionManager=new mn(this._host,this.bonfireManager,this.workshopManager),this.scienceManager=new wn(this._host,this.workshopManager),this.spaceManager=new Cn(this._host,this.workshopManager),this.timeControlManager=new Kn(this._host,this.bonfireManager,this.religionManager,this.spaceManager,this.workshopManager),this.timeManager=new Vn(this._host,this.workshopManager),this.tradeManager=new jn(this._host,this.workshopManager),this.villageManager=new Xn(this._host,this.workshopManager)}get isLoaded(){return this._isLoaded}isLanguageSupported(s){return Object.keys(this._i18nData).some(e=>e.startsWith(`${s}-`))}isLocaleSupported(s){return s in this._i18nData}localeSupportsFirstLetterSplits(s=this.settings.locale.selected){return s!=="zh-CN"}localeForLanguage(s){return Object.keys(this._i18nData).find(e=>e.startsWith(`${s}-`))}setLanguage(s,e=!0){const t=this.settings.locale.selected;if(!this.isLanguageSupported(s))console.warn(...y(`Requested language '${s}' is not available. Falling back to '${xe}'.`)),this.settings.locale.selected=xe;else{const i=v(this.localeForLanguage(s));console.info(...y(`Selecting language '${i}'.`)),this.settings.locale.selected=i}t!==this.settings.locale.selected&&e&&this._host.rebuildUi()}setLocale(s,e=!0){const t=this.settings.locale.selected;this.isLocaleSupported(s)?(console.info(...y(`Selecting language '${s}'.`)),this.settings.locale.selected=s):(console.warn(...y(`Requested language '${s}' is not available. Falling back to '${xe}'.`)),this.settings.locale.selected=xe),t!==this.settings.locale.selected&&e&&this._host.rebuildUi()}stateLoad(s,e=!1){this._isLoaded=!0,this.stop(!1);const t=Le();s.v!==t&&console.warn(...y(`Attempting to load engine state with version tag '${s.v}' when engine is at version '${t}'!`));const i=(n,r)=>{try{n()}catch(a){console.error(...y(`Failed load of ${r} settings.`,a))}};i(()=>{this.settings.load(s.engine,e)},"engine"),i(()=>{this.bonfireManager.settings.load(s.bonfire)},"bonfire"),i(()=>{this.religionManager.settings.load(s.religion)},"religion"),i(()=>{this.scienceManager.settings.load(s.science)},"science"),i(()=>{this.spaceManager.settings.load(s.space)},"space"),i(()=>{this.timeControlManager.settings.load(s.timeControl)},"time control"),i(()=>{this.timeManager.settings.load(s.time)},"time"),i(()=>{this.tradeManager.settings.load(s.trade)},"trade"),i(()=>{this.villageManager.settings.load(s.village)},"village"),i(()=>{this.workshopManager.settings.load(s.workshop)},"workshop"),this.setLocale(this.settings.locale.selected),this.settings.enabled?this.start(!1):this.stop(!1)}static get DEFAULT_STATE(){return{bonfire:new Xt,engine:new cs,religion:new Yt,science:new Qt,space:new Ct,time:new ms,timeControl:new ds,trade:new fs,v:Le(),village:new bs,workshop:new St}}stateReset(){this.stateLoad(re.DEFAULT_STATE)}stateSerialize(){return{bonfire:this.bonfireManager.settings,engine:this.settings,religion:this.religionManager.settings,science:this.scienceManager.settings,space:this.spaceManager.settings,time:this.timeManager.settings,timeControl:this.timeControlManager.settings,trade:this.tradeManager.settings,v:Le(),village:this.villageManager.settings,workshop:this.workshopManager.settings}}start(s=!0){if(this._timeoutMainLoop)return;const e=()=>{const t={entry:Date.now(),exit:0,measurements:{},purchaseOrders:[],requestGameUiRefresh:!1};this._iterate(t).then(()=>{t.exit=Date.now();const i=t.exit-t.entry;document.dispatchEvent(new CustomEvent("ks.reportFrame",{detail:t})),this._timeoutMainLoop!==void 0&&(this._timeoutMainLoop=T.window.setTimeout(e,Math.max(10,this._host.engine.settings.interval-i)))}).catch(i=>{console.warn(...y(Zs(i)))})};this._timeoutMainLoop=T.window.setTimeout(e,this._host.engine.settings.interval),s&&this._host.engine.imessage("status.ks.enable")}stop(s=!0){this._timeoutMainLoop&&(clearTimeout(this._timeoutMainLoop),this._timeoutMainLoop=void 0,s&&this._host.engine.imessage("status.ks.disable"))}async _iterate(s){this.settings.filters.disableKGLog.enabled||this._maintainKGLogFilters();let[,e]=await pt(()=>this.scienceManager.tick(s));s.measurements.scienceManager=e,[,e]=pe(()=>{this.bonfireManager.tick(s)}),s.measurements.bonfireManager=e,[,e]=pe(()=>{this.spaceManager.tick(s)}),s.measurements.spaceManager=e,[,e]=await pt(()=>this.workshopManager.tick(s)),s.measurements.workshopManager=e,[,e]=pe(()=>{this.tradeManager.tick(s)}),s.measurements.tradeManager=e,[,e]=await pt(()=>this.religionManager.tick(s)),s.measurements.religionManager=e,[,e]=pe(()=>{this.timeManager.tick(s)}),s.measurements.timeManager=e,[,e]=pe(()=>{this.villageManager.tick(s)}),s.measurements.villageManager=e,[,e]=await pt(()=>this.timeControlManager.tick(s)),s.measurements.timeControlManager=e,[,e]=pe(()=>{s.requestGameUiRefresh&&!document.hidden&&this._host.game.ui.render()}),s.measurements.gameUiRefresh=e}_maintainKGLogFilters(){for(const e of Object.values(this._host.game.console.filters))e.enabled=!1;const s=T.window.document.querySelectorAll("[id^=filter-]");for(const e of s)e.checked=!1}symbolForCycle(s){var e;return((e=this._host.game.calendar.cycles.find(t=>t.name===s))==null?void 0:e.uglyph)??""}labelForCycle(s){const e=this.symbolForCycle(s),t=this._host.engine.i18n(`$space.planet.${s==="redmoon"?"moon":s}.label`);return`${e} ${t}`}labelForPlanet(s){const e=s==="moon"?"redmoon":s,t=ve.includes(e)?e:void 0,i=this._host.engine.i18n(`$space.planet.${s}.label`);return t===void 0?i:`${this.symbolForCycle(t)} ${i}`}i18n(s,e=[]){let t;if(s.startsWith("$")&&(t=this._host.i18nEngine(s.slice(1))),t=t??this._i18nData[this.settings.locale.selected][s],m(t)){if(t=ps[xe][s],!t)return console.warn(...y(`i18n key '${s}' not found in default language.`)),`$${s}`;console.warn(...y(`i18n key '${s}' not found in selected language.`))}for(let n=0;n<e.length;++n)t=t.replace(`{${n}}`,`${e[n]}`);return t}iactivity(s,e=[],t){const i=this.i18n(s,e);if(t){const n=`type_${t}`;this.printOutput(`ks-activity ${n}`,"#e65C00",i)}else this.printOutput("ks-activity","#e65C00",i)}imessage(s,e=[]){this.printOutput("ks-default","#aa50fe",this.i18n(s,e))}storeForSummary(s,e=1,t="other"){this._activitySummary.storeActivity(s,e,t)}getSummary(){return this._activitySummary.renderSummary()}displayActivitySummary(){const s=this.getSummary();for(const e of s)this.printOutput("ks-summary","#009933",e);this.resetActivitySummary()}resetActivitySummary(){this._activitySummary.resetActivity()}printOutput(s,e,t){if(this.settings.filters.enabled){for(const n of Object.values(this.settings.filters.filters))if(n.variant===s&&!n.enabled)return}const i=this._host.game.msg(t,s);$(i.span).css("color",e)}static evaluateSubSectionTrigger(s,e){return s<0?e:e<0?s:e}}const vs=c=>Number.isFinite(c)?c:0,Yn=c=>({days:Math.trunc(c/864e5),hours:Math.trunc(c/36e5%24),minutes:Math.trunc(c/6e4%60),seconds:Math.trunc(c/1e3%60),milliseconds:Math.trunc(c%1e3),microseconds:Math.trunc(vs(c*1e3)%1e3),nanoseconds:Math.trunc(vs(c*1e6)%1e3)}),Qn=c=>({days:c/86400000n,hours:c/3600000n%24n,minutes:c/60000n%60n,seconds:c/1000n%60n,milliseconds:c%1000n,microseconds:0n,nanoseconds:0n}),ea=c=>{switch(typeof c){case"number":{if(Number.isFinite(c))return Yn(c);break}case"bigint":return Qn(c)}throw new TypeError("Expected a finite number or bigint")},ta=c=>c===0||c===0n,ia=(c,s)=>s===1||s===1n?c:`${c}s`,sa=1e-7,na=24n*60n*60n*1000n,aa=(c,s={colonNotation:!1,compact:!1,formatSubMilliseconds:!1,keepDecimalsOnWholeSeconds:!1,millisecondsDecimalDigits:0,secondsDecimalDigits:1,separateMilliseconds:!1,unitCount:1/0,verbose:!1})=>{const e=typeof c=="bigint";if(!e&&!Number.isFinite(c))throw new TypeError("Expected a finite number or bigint");const t={...s};t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let i=[];const n=(h,d)=>{const g=Math.floor(h*10**d+sa);return(Math.round(g)/10**d).toFixed(d)},r=(h,d,g,f)=>{if(!((i.length===0||!t.colonNotation)&&ta(h)&&!(t.colonNotation&&g==="m"))){if(f??(f=String(h)),t.colonNotation){const p=f.includes(".")?f.split(".")[0].length:f.length,b=i.length>0?2:1;f="0".repeat(Math.max(0,b-p))+f}else f+=t.verbose?" "+ia(d,h):g;i.push(f)}},a=ea(c),o=BigInt(a.days);if(r(o/365n,"year","y"),r(o%365n,"day","d"),r(Number(a.hours),"hour","h"),r(Number(a.minutes),"minute","m"),t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&c<1e3){const h=Number(a.seconds),d=Number(a.milliseconds),g=Number(a.microseconds),f=Number(a.nanoseconds);if(r(h,"second","s"),t.formatSubMilliseconds)r(d,"millisecond","ms"),r(g,"microsecond","µs"),r(f,"nanosecond","ns");else{const p=d+g/1e3+f/1e6,b=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,k=p>=1?Math.round(p):Math.ceil(p),w=b?p.toFixed(b):k.toString();r(Number.parseFloat(w),"millisecond","ms",w)}}else{const h=(e?Number(c%na):c)/1e3%60,d=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,g=n(h,d),f=t.keepDecimalsOnWholeSeconds?g:g.replace(/\.0+$/,"");r(Number.parseFloat(f),"second","s",f)}if(i.length===0)return"0"+(t.verbose?" milliseconds":"ms");const l=t.colonNotation?":":" ";return typeof t.unitCount=="number"&&(i=i.slice(0,Math.max(t.unitCount,1))),i.join(l)},P={Bonfire:"M80-80v-183l363-491-67-90 49-35 55 75 56-75 48 35-66 90 362 491v183H80Zm400-623L140-243v103h145l195-273 195 273h145v-103L480-703ZM359-140h242L480-310 359-140Zm121-273 195 273-195-273-195 273 195-273Z",CheckboxCheck:"m419-321 289-289-43-43-246 246-119-119-43 43 162 162ZM120-120v-720h720v720H120Zm60-60h600v-600H180v600Zm0 0v-600 600Z",CheckboxUnCheck:"M120-120v-720h720v720H120Zm60-60h600v-600H180v600Z",Copy:"M240-200v-680h560v680H240Zm60-60h440v-560H300v560ZM120-80v-680h60v620h500v60H120Zm180-180v-560 560Z",Cycles:"M120-80v-740h125v-60h65v60h340v-60h65v60h125v360h-60v-110H180v430h324v60H120ZM760 0q-73 0-127.5-45.5T564-160h62q13 44 49.5 72T760-60q58 0 99-41t41-99q0-58-41-99t-99-41q-29 0-54 10.5T662-300h58v60H560v-160h60v57q27-26 63-41.5t77-15.5q83 0 141.5 58.5T960-200q0 83-58.5 141.5T760 0ZM180-630h600v-130H180v130Zm0 0v-130 130Z",DataUsage:"M480-80q-82 0-155-31.5T197.5-197q-54.5-54-86-127T80-479q0-158 106.5-272T451-877v102q-115 11-192 95.5T182-479q0 124 87 210.5T480-182q72 0 136-32.5T725-306l88 51q-58 83-145.5 129T480-80Zm362-229-88-49q12-31 18-61.5t6-60.5q0-116-76.5-201T511-776v-102q157 11 263 124.5T880-484q0 45-9.5 88.5T842-309Z",Delete:"M201-120v-630h-41v-60h188v-30h264v30h188v60h-41v630H201Zm60-60h438v-570H261v570Zm106-86h60v-399h-60v399Zm166 0h60v-399h-60v399ZM261-750v570-570Z",Draft:"M160-80v-800h421l219 219v581H160Zm391-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z",Eco:"M213-175q-43.59-45-68.3-104Q120-338 120-400q0-73 25.5-133.5T222-645q35-35 87-59t122.5-37.5Q502-755 591-758.5t198 3.5q8 108 5.5 197.5t-16 160.75q-13.5 71.25-38 124.56Q716-218.87 680-183q-51 51-110 77T444-80q-69 0-126.5-23.5T213-175Zm103 0q25 17 58 26t69.92 9Q497-140 547-162t91-64q27-27 46-70.5t31-103Q727-459 731-534t0-165q-94-2-168.5 2.5T431-680q-57 12-98 30.5T266-604q-42 43-64 91t-22 98q0 48 20.5 100.5T251-230q53-98 127-176t157-123q-87 75-141 162.5T316-175Zm0 0Zm0 0Z",Edit:"M180-180h44l472-471-44-44-472 471v44Zm-60 60v-128l617-616 128 128-617 616H120Zm659-617-41-41 41 41Zm-105 64-22-22 44 44-22-22Z",ExpandCircleDown:"m480-351 173-173-43-42-130 130-130-130-43 42 173 173Zm0 271q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 31.5-156t86-127Q252-817 325-848.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82-31.5 155T763-197.5q-54 54.5-127 86T480-80Zm0-60q142 0 241-99.5T820-480q0-142-99-241t-241-99q-141 0-240.5 99T140-480q0 141 99.5 240.5T480-140Zm0-340Z",ExpandCircleUp:"m350-394 130-130 130 130 43-42-173-173-173 173 43 42ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-155.5t85.5-127q54-54.5 127-86T480-880q83 0 155.5 31.5t127 86q54.5 54.5 86 127T880-480q0 83-31.5 156t-86 127q-54.5 54-127 85.5T480-80Zm0-60q141 0 240.5-99T820-480q0-141-99.5-240.5T480-820q-142 0-241 99.5T140-480q0 142 99 241t241 99Zm0-340Z",Import:"M450-160v-371L330-411l-43-43 193-193 193 193-43 43-120-120v371h-60ZM160-597v-203h640v203h-60v-143H220v143h-60Z",Religion:"M40-120v-560q0-45.83 32.12-77.92 32.12-32.08 78-32.08T228-757.92q32 32.09 32 77.92v31l220-191 220 191v-31q0-45.83 32.12-77.92 32.12-32.08 78-32.08T888-757.92q32 32.09 32 77.92v560H530v-250H430v250H40Zm720-510h100v-49.82q0-21.18-14.32-35.68-14.33-14.5-35.5-14.5-21.18 0-35.68 14.37Q760-701.25 760-680v50Zm-660 0h100v-49.82q0-21.18-14.32-35.68-14.33-14.5-35.5-14.5-21.18 0-35.68 14.37Q100-701.25 100-680v50Zm0 450h100v-390H100v390Zm160 0h110v-250h220v250h110v-390L480-761 260-570v390Zm500 0h100v-390H760v390ZM479.94-505Q457-505 441-521.06q-16-16.06-16-39T441.06-599q16.06-16 39-16T519-598.94q16 16.06 16 39T518.94-521q-16.06 16-39 16Z",Reset:"M480-160q-133 0-226.5-93.5T160-480q0-133 93.5-226.5T480-800q85 0 149 34.5T740-671v-129h60v254H546v-60h168q-38-60-97-97t-137-37q-109 0-184.5 75.5T220-480q0 109 75.5 184.5T480-220q83 0 152-47.5T728-393h62q-29 105-115 169t-195 64Z",Resources:"M120-40v-880h60v80h600v-80h60v880h-60v-80H180v80h-60Zm60-469h110v-160h220v160h270v-271H180v271Zm0 329h270v-160h220v160h110v-269H180v269Zm170-329h100v-100H350v100Zm160 329h100v-100H510v100ZM350-509h100-100Zm160 329h100-100Z",Save:"M840-683v563H120v-720h563l157 157Zm-60 27L656-780H180v600h600v-476ZM479.76-245q43.24 0 73.74-30.26 30.5-30.27 30.5-73.5 0-43.24-30.26-73.74-30.27-30.5-73.5-30.5-43.24 0-73.74 30.26-30.5 30.27-30.5 73.5 0 43.24 30.26 73.74 30.27 30.5 73.5 30.5ZM233-584h358v-143H233v143Zm-53-72v476-600 124Z",SaveAs:"M120-120v-720h563l157 157v117l-60 60v-150L656-780H180v600h280v60H120Zm60-660v600-600ZM520-40v-123l263-262 122 122L643-40H520Zm300-263-37-37 37 37ZM580-100h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19ZM233-584h358v-143H233v143Zm247 339q14 0 27-3t24-10l39-40q7-11 10.5-24t3.5-27q0-43.33-30.26-73.67Q523.47-453 480.24-453q-43.24 0-73.74 30.26-30.5 30.27-30.5 73.5 0 43.24 30.33 73.74Q436.67-245 480-245Z",Seasons:"M306-394q-17 0-28.5-11.5T266-434q0-17 11.5-28.5T306-474q17 0 28.5 11.5T346-434q0 17-11.5 28.5T306-394Zm177 0q-17 0-28.5-11.5T443-434q0-17 11.5-28.5T483-474q17 0 28.5 11.5T523-434q0 17-11.5 28.5T483-394Zm170 0q-17 0-28.5-11.5T613-434q0-17 11.5-28.5T653-474q17 0 28.5 11.5T693-434q0 17-11.5 28.5T653-394ZM120-80v-740h125v-60h65v60h340v-60h65v60h125v740H120Zm60-60h600v-430H180v430Zm0-490h600v-130H180v130Zm0 0v-130 130Z",Settings:"m388-80-20-126q-19-7-40-19t-37-25l-118 54-93-164 108-79q-2-9-2.5-20.5T185-480q0-9 .5-20.5T188-521L80-600l93-164 118 54q16-13 37-25t40-18l20-127h184l20 126q19 7 40.5 18.5T669-710l118-54 93 164-108 77q2 10 2.5 21.5t.5 21.5q0 10-.5 21t-2.5 21l108 78-93 164-118-54q-16 13-36.5 25.5T592-206L572-80H388Zm48-60h88l14-112q33-8 62.5-25t53.5-41l106 46 40-72-94-69q4-17 6.5-33.5T715-480q0-17-2-33.5t-7-33.5l94-69-40-72-106 46q-23-26-52-43.5T538-708l-14-112h-88l-14 112q-34 7-63.5 24T306-642l-106-46-40 72 94 69q-4 17-6.5 33.5T245-480q0 17 2.5 33.5T254-413l-94 69 40 72 106-46q24 24 53.5 41t62.5 25l14 112Zm44-210q54 0 92-38t38-92q0-54-38-92t-92-38q-54 0-92 38t-38 92q0 54 38 92t92 38Zm0-130Z",Space:"m187-551 106 45q18-36 38.5-71t43.5-67l-79-16-109 109Zm154 81 133 133q57-26 107-59t81-64q81-81 119-166t41-192q-107 3-192 41T464-658q-31 31-64 81t-59 107Zm229-96q-20-20-20-49.5t20-49.5q20-20 49.5-20t49.5 20q20 20 20 49.5T669-566q-20 20-49.5 20T570-566Zm-15 383 109-109-16-79q-32 23-67 43.5T510-289l45 106Zm326-694q9 136-34 248T705-418l-2 2-2 2 22 110q3 15-1.5 29T706-250L535-78l-85-198-170-170-198-85 172-171q11-11 25-15.5t29-1.5l110 22q1-1 2-1.5t2-1.5q99-99 211-142.5T881-877ZM149-325q35-35 85.5-35.5T320-326q35 35 34.5 85.5T319-155q-26 26-80.5 43T75-80q15-109 31.5-164t42.5-81Zm42 43q-14 15-25 47t-19 82q50-8 82-19t47-25q19-17 19.5-42.5T278-284q-19-18-44.5-17.5T191-282Z",State:"M820-240v-480h60v480h-60Zm-340 1-43-42 169-169H80v-60h526L438-679l42-42 241 241-241 241Z",Summary:"M279-621h60v-60h-60v60Zm0 171h60v-60h-60v60Zm0 171h60v-60h-60v60ZM120-120v-720h522l198 198v522H120Zm60-60h600v-429H609v-171H180v600Zm0-600v171.43V-780v600-600Z",Sync:"M167-160v-60h130l-15-12q-64-51-93-111t-29-134q0-106 62.5-190.5T387-784v62q-75 29-121 96.5T220-477q0 63 23.5 109.5T307-287l30 21v-124h60v230H167Zm407-15v-63q76-29 121-96.5T740-483q0-48-23.5-97.5T655-668l-29-26v124h-60v-230h230v60H665l15 14q60 56 90 120t30 123q0 106-62 191T574-175Z",Time:"m627-287 45-45-159-160v-201h-60v225l174 181ZM480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-82 31.5-155t86-127.5Q252-817 325-848.5T480-880q82 0 155 31.5t127.5 86Q817-708 848.5-635T880-480q0 82-31.5 155t-86 127.5Q708-143 635-111.5T480-80Zm0-400Zm0 340q140 0 240-100t100-240q0-140-100-240T480-820q-140 0-240 100T140-480q0 140 100 240t240 100Z",Trigger:"m393-165 279-335H492l36-286-253 366h154l-36 255Zm-73 85 40-280H160l360-520h80l-40 320h240L400-80h-80Zm154-396Z",Workshop:"M768-120 517-371l57-57 251 251-57 57Zm-581 0-57-57 290-290-107-107-23 23-44-44v85l-24 24-122-122 24-24h86l-48-48 131-131q17-17 37-23t44-6q24 0 44 8.5t37 25.5L348-699l48 48-24 24 104 104 122-122q-8-13-12.5-30t-4.5-36q0-53 38.5-91.5T711-841q15 0 25.5 3t17.5 8l-85 85 75 75 85-85q5 8 8.5 19.5T841-709q0 53-38.5 91.5T711-579q-18 0-31-2.5t-24-7.5L187-120Z"},dt=class dt{constructor(s,e){u(this,"componentId");u(this,"host");u(this,"parent");u(this,"options");u(this,"_element");u(this,"children",new Set);u(this,"_needsRefresh");this.componentId=dt.nextComponentId++,this.host=s.host,this.options=e,this.parent=s instanceof dt?s:null,this._needsRefresh=!1}set element(s){this._element=s,this._element[0].id=`KS${Object.getPrototypeOf(this).constructor.name}#${this.componentId}`}get element(){return v(this._element)}requestRefresh(s=!1,e=0,t=!1){var i,n,r;if(t&&console.debug(...y(e<0?"⤒".repeat(e*-1):" ".repeat(e),this.toString(),"requestRefresh()")),(n=(i=this.options)==null?void 0:i.onRefreshRequest)==null||n.call(this),this.parent!==this&&!s&&((r=this.parent)==null||r.requestRefresh(!1,e-1,t)),this._needsRefresh&&t&&console.debug(...y(e<0?"⤒".repeat(e*-1):" ".repeat(e),this.toString(),"requestRefresh() <already pending>")),this._needsRefresh=!0,s){t&&console.debug(...y(e<0?"⤒".repeat(e*-1):" ".repeat(e),this.toString(),"requestRefresh()",`+ ${this.children.size} children`));for(const a of this.children)a.requestRefresh(!0,e+1,t)}else t&&console.debug(...y(e<0?"⤒".repeat(e*-1):" ".repeat(e),this.toString(),"requestRefresh()","<queued>"))}refresh(s=!1,e=0){var t,i;if(!s&&!this._needsRefresh){e===0&&console.debug(...y(this.toString(),"refresh() received and ignored."));return}(i=(t=this.options)==null?void 0:t.onRefresh)==null||i.call(this);for(const n of this.children)n.refresh(s,e+1);this._needsRefresh=!1}addChild(s){return s.parent=this,this.children.add(s),this.element.append(s.element),this}addChildren(s){for(const e of s??[])this.addChild(e);return this}removeChild(s){this.children.has(s)&&(s.element.remove(),this.children.delete(s))}removeChildren(s){for(const e of s)this.removeChild(e)}};u(dt,"nextComponentId",0);let G=dt;class M extends G{constructor(s,e){super(s,{...e}),this.element=$("<div/>");for(const t of(e==null?void 0:e.classes)??[])this.element.addClass(t)}toString(){return`[${M.name}#${this.componentId}]`}}const A={label:"_label_1nlev_1",splitter:"_splitter_1nlev_16",iconLabel:"_iconLabel_1nlev_20",fillSpace:"_fillSpace_1nlev_26"},ye={delimiter:"_delimiter_16hnh_1"};class he extends G{constructor(s,e){super(s,{...e}),this.element=$("<li/>");for(const t of(e==null?void 0:e.classes)??[])this.element.addClass(t);(e==null?void 0:e.delimiter)===!0&&this.element.addClass(ye.delimiter)}toString(){return`[${he.name}#${this.componentId}]`}}const Tt={head:"_head_wr1pj_1"};class ue extends he{constructor(e,t,i){super(e,i);u(this,"head");u(this,"elementLabel");if(this.head=new M(e),this.head.element.addClass(Tt.head),this.addChild(this.head),this.elementLabel=$("<label/>",{text:`${(i==null?void 0:i.upgradeIndicator)===!0?"⮤ ":""}${t}`}).addClass(A.label).addClass(Tt.label),this.head.element.append(this.elementLabel),i!=null&&i.icon){const n=$("<div/>",{html:`<svg style="width: 15px; height: 15px;" viewBox="0 -960 960 960" fill="currentColor"><path d="${i.icon}"/></svg>`}).addClass(A.iconLabel);this.elementLabel.prepend(n)}}toString(){return`[${ue.name}#${this.componentId}]: '${this.elementLabel.text()}'`}addChildHead(e){return this.head.addChild(e),this}addChildrenHead(e){for(const t of e??[])this.head.addChild(t);return this}}const D={setting:"_setting_1ndg5_1",checkbox:"_checkbox_1ndg5_6",panelContent:"_panelContent_1ndg5_10",hidden:"_hidden_1ndg5_17",checked:"_checked_1ndg5_22",expanded:"_expanded_1ndg5_26",readonly:"_readonly_1ndg5_34"};class S extends ue{constructor(e,t,i,n){super(e,i,{...n,onRefresh:()=>{var o;this.setting.enabled?this.element.addClass(D.checked):this.element.removeClass(D.checked),this.readOnly?this.element.addClass(D.readonly):this.element.removeClass(D.readonly),m(this.checkbox)||(this.checkbox.prop("checked",this.setting.enabled),this.checkbox.prop("disabled",this.readOnly)),(o=n==null?void 0:n.onRefresh)==null||o.call(n)}});u(this,"setting");u(this,"checkbox");u(this,"readOnly");this.element.addClass(D.setting);const r=`ks-setting${this.componentId}`,a=$("<input/>",{id:r,type:"checkbox"}).addClass(D.checkbox);this.readOnly=(n==null?void 0:n.readOnly)??!1,a.prop("disabled",this.readOnly),a.on("change",o=>{a.is(":checked")&&!t.enabled?this.check().catch(R(console)):!a.is(":checked")&&t.enabled&&this.uncheck().catch(R(console))}),this.elementLabel.before(a),this.elementLabel.prop("for",r),this.checkbox=a,this.setting=t}toString(){return`[${S.name}#${this.componentId}]: '${this.elementLabel.text()}'`}async check(e=!1){var t,i;this.setting.enabled=!0,await((i=(t=this.options)==null?void 0:t.onCheck)==null?void 0:i.call(e)),this.requestRefresh()}async uncheck(e=!1){var t;this.setting.enabled=!1,await((t=this.options.onUnCheck)==null?void 0:t.call(e)),this.requestRefresh()}}const C={iconButton:"_iconButton_q7zpt_17",inactive:"_inactive_q7zpt_29",ineffective:"_ineffective_q7zpt_37",button:"_button_q7zpt_43",readonly:"_readonly_q7zpt_67",buttonIcon:"_buttonIcon_q7zpt_72",alignRight:"_alignRight_q7zpt_77",large:"_large_q7zpt_81",bordered:"_bordered_q7zpt_85",headAction:"_headAction_q7zpt_97",lastHeadAction:"_lastHeadAction_q7zpt_100",consumeButton:"_consumeButton_q7zpt_104",stockButton:"_stockButton_q7zpt_107"};class ie extends G{constructor(e,t,i,n){super(e,{...n,onRefresh:()=>{var r;this.readOnly?this.element.addClass(C.readonly):this.element.removeClass(C.readonly),this.inactive?this.element.addClass(C.inactive):this.element.removeClass(C.inactive),(r=n==null?void 0:n.onRefresh)==null||r.call(n)}});u(this,"readOnly");u(this,"inactive");this.element=$("<div/>",{html:`<svg style="width: 18px; height: 18px;" viewBox="0 -960 960 960" fill="currentColor"><path d="${t}"/></svg>`,title:i}).addClass(C.iconButton),this.readOnly=(n==null?void 0:n.readOnly)??!1,this.inactive=(n==null?void 0:n.inactive)??!1,this.element.on("click",()=>{this.readOnly||this.click().catch(R(console))})}toString(){return`[${ie.name}#${this.componentId}]`}async click(){var e,t;this.readOnly||(await((t=(e=this.options)==null?void 0:e.onClick)==null?void 0:t.call(this)),this.requestRefresh())}}const Et={listContainer:"_listContainer_1kxbq_1",itemsList:"_itemsList_1kxbq_5",list:"_list_1kxbq_1",listTools:"_listTools_1kxbq_9"};class x extends G{constructor(e,t){super(e,{...t});u(this,"list");u(this,"disableAllButton");u(this,"enableAllButton");u(this,"resetButton");const i={hasDisableAll:!0,hasEnableAll:!0,...t},n=i.hasDisableAll||i.hasEnableAll||!m(i.onReset);if(this.element=$("<div/>").addClass(Et.listContainer),this.list=$("<ul/>").addClass(Et.list).addClass(Et.itemsList),this.element.append(this.list),n){const r=new M(this,{classes:[Et.listTools]});i.hasEnableAll&&(this.enableAllButton=new ie(e,P.CheckboxCheck,e.host.engine.i18n("ui.enable.all"),{onClick:async()=>{var l;const o=new Event("enableAll",{cancelable:!0});if(this.element[0].dispatchEvent(o),!o.defaultPrevented){for(const h of this.children)be(h,S)&&await h.check(!0);(l=t==null?void 0:t.onEnableAll)==null||l.call(this)}}}),r.addChild(this.enableAllButton)),i.hasDisableAll&&(this.disableAllButton=new ie(e,P.CheckboxUnCheck,e.host.engine.i18n("ui.disable.all"),{onClick:async()=>{var l;const o=new Event("disableAll",{cancelable:!0});if(this.element[0].dispatchEvent(o),!o.defaultPrevented){for(const h of this.children)be(h,S)&&await h.uncheck(!0);(l=t==null?void 0:t.onDisableAll)==null||l.call(this)}}}),r.addChild(this.disableAllButton));const a=i.onReset;m(a)||(this.resetButton=new ie(e,P.Reset,e.host.engine.i18n("ui.reset"),{onClick:()=>{a()}}),r.addChild(this.resetButton)),super.addChild(r)}}toString(){return`[${x.name}#${this.componentId}]`}addChild(e){return e.parent=this,this.children.add(e),this.list.append(e.element),this}}const Ae={expandoButton:"_expandoButton_l1ukp_1",expanded:"_expanded_l1ukp_1",up:"_up_l1ukp_1",down:"_down_l1ukp_4"};class Rt extends G{constructor(e,t){super(e,{...t,onRefresh:()=>{var i;this.ineffective?this.element.addClass(C.ineffective):this.element.removeClass(C.ineffective),(i=t==null?void 0:t.onRefresh)==null||i.call(t)}});u(this,"readOnly");u(this,"inactive");u(this,"ineffective");this.element=$("<div/>",{html:`
39
+ <svg style="width: 18px; height: 18px;" viewBox="0 -960 960 960" fill="currentColor" class="${Ae.down}"><path d="${P.ExpandCircleDown}"/></svg>
40
+ <svg style="width: 18px; height: 18px;" viewBox="0 -960 960 960" fill="currentColor" class="${Ae.up}"><path d="${P.ExpandCircleUp}"/></svg>
41
+ `,title:e.host.engine.i18n("ui.itemsShow")}).addClass(C.iconButton).addClass(Ae.expandoButton),this.element.on("click",()=>{this.readOnly||this.click().catch(R(console))}),this.readOnly=(t==null?void 0:t.readOnly)??!1,this.inactive=(t==null?void 0:t.inactive)??!1,this.ineffective=!1}toString(){return`[${Rt.name}#${this.componentId}]`}setCollapsed(){this.element.removeClass(Ae.expanded),this.element.prop("title",this.host.engine.i18n("ui.itemsShow"))}setExpanded(){this.element.addClass(Ae.expanded),this.element.prop("title",this.host.engine.i18n("ui.itemsHide"))}async click(){var e,t;this.readOnly||(await((t=(e=this.options)==null?void 0:e.onClick)==null?void 0:t.call(this)),this.requestRefresh())}}class we extends G{constructor(e,t,i){super(e,i);u(this,"container");u(this,"expando");u(this,"head");u(this,"_mainChildVisible");this.head=t,this.container=new M(this),this.container.element.addClass(D.panelContent);const n=new Rt(e,{onClick:()=>this.toggle()});t.head.addChild(n),t.element.append(this.container.element),i!=null&&i.initiallyExpanded?(this.container.element.removeClass(D.hidden),n.setExpanded()):this.container.element.addClass(D.hidden),this._mainChildVisible=(i==null?void 0:i.initiallyExpanded)??!1,this.element=t.element,this.expando=n,this.addChildren([this.head,this.container])}get isExpanded(){return this._mainChildVisible}toString(){return`[${we.name}#${this.componentId}]`}addChildHead(e){return this.head.addChild(e),this}addChildrenHead(e){for(const t of e??[])this.head.addChild(t);return this}addChildContent(e){return this.container.addChild(e),this}addChildrenContent(e){for(const t of e??[])this.container.addChild(t);return this}toggle(e=void 0,t=!1){const i=e!==void 0?e:!this._mainChildVisible;if(i!==this._mainChildVisible&&(this._mainChildVisible=i,this._mainChildVisible?(this.container.requestRefresh(!0),this.container.element.removeClass(D.hidden),this.expando.setExpanded(),this.head.element.addClass(D.expanded),this.element[0].dispatchEvent(new CustomEvent("panelShown"))):(this.container.element.addClass(D.hidden),this.expando.setCollapsed(),this.head.element.removeClass(D.expanded),this.element[0].dispatchEvent(new CustomEvent("panelHidden")))),t){const n=r=>{for(const a of r)be(a,we)?a.toggle(e,t):n(a.children)};n(this.children)}}}class N extends we{constructor(e,t,i,n){super(e,i,n);u(this,"setting");u(this,"settingItem");this.element=i.element,this.settingItem=i,this.setting=t}get isExpanded(){return this._mainChildVisible}get elementLabel(){return this.head.element}get readOnly(){return!0}set readOnly(e){}async check(){this.setting.enabled=!0,this.requestRefresh()}async uncheck(){this.setting.enabled=!1,this.requestRefresh()}toString(){return`[${N.name}#${this.componentId}]: '${this.settingItem.elementLabel.text()}'`}}class ra extends N{constructor(s,e,t,i){const n=s.host.engine.i18n("ui.upgrade.buildings");super(s,e,new S(s,e,n,{onCheck:o=>{s.host.engine.imessage("status.auto.enable",[n])},onUnCheck:o=>{s.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(s,{classes:[A.fillSpace]})]),{onRefreshRequest:()=>{this.expando.ineffective=i.enabled&&e.enabled&&!Object.values(e.buildings).some(o=>o.enabled)}});const r=[];for(const o of Object.values(this.setting.buildings)){const l=this.host.engine.i18n(`$buildings.${o.upgrade}.label`),h=new S(this,o,l,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[l])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[l])}});r.push({button:h,label:l})}r.sort((o,l)=>o.label.localeCompare(l.label));const a=new x(this);for(const o of r)a.addChild(o.button);this.addChildContent(a)}}class j extends G{constructor(e,t,i=null,n){super(e,{...n,onRefresh:()=>{var r;this.readOnly?this.element.addClass(C.readonly):this.element.removeClass(C.readonly),this.inactive?this.element.addClass(C.inactive):this.element.removeClass(C.inactive),this.ineffective?this.element.addClass(C.ineffective):this.element.removeClass(C.ineffective),(r=n==null?void 0:n.onRefresh)==null||r.call(n)}});u(this,"_iconElement");u(this,"readOnly");u(this,"inactive");u(this,"ineffective");this.element=$("<div/>",{title:n==null?void 0:n.title}).addClass(C.button).text(t),(n==null?void 0:n.border)!==!1&&this.element.addClass(C.bordered),(n==null?void 0:n.alignment)==="right"&&this.element.addClass(C.alignRight),i!==null&&(this._iconElement=$(`<svg class="${C.buttonIcon}" style="width: 18px; height: 18px;" viewBox="0 -960 960 960" fill="currentColor"><path d="${i}"/></svg>`),(n==null?void 0:n.alignment)==="right"?this.element.append(this._iconElement):this.element.prepend(this._iconElement));for(const r of(n==null?void 0:n.classes)??[])this.element.addClass(r);this.element.on("click",()=>{this.readOnly||this.click().catch(R(console))}),this.readOnly=(n==null?void 0:n.readOnly)??!1,this.inactive=(n==null?void 0:n.inactive)??!1,this.ineffective=!1}toString(){return`[${j.name}#${this.componentId}]`}updateLabel(e){this.element.text(e),this._iconElement!==void 0&&(this.options.alignment==="right"?this.element.append(this._iconElement):this.element.prepend(this._iconElement))}updateTitle(e){this.element.prop("title",e)}async click(){var e,t;this.readOnly||(await((t=(e=this.options)==null?void 0:e.onClick)==null?void 0:t.call(this)),this.requestRefresh())}}class Q extends G{constructor(s){super(s,{}),this.element=$("<div/>").addClass(ye.delimiter)}toString(){return`[${Q.name}#${this.componentId}]`}}const ys={dialog:"_dialog_b4vj0_1",close:"_close_b4vj0_7"},ws={explainer:"_explainer_1idu3_1"},oa={header:"_header_19ql8_1"};class q extends G{get elementLabel(){return this.element}constructor(s,e,t){super(s,{...t}),this.element=$("<li/>",{text:e}).addClass(oa.header)}toString(){return`[${q.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class ti extends G{constructor(s,e){super(s,{...e}),this.element=$('<input type="text"/>').addClass("ks-input");for(const t of(e==null?void 0:e.classes)??[])this.element.addClass(t);e!=null&&e.onChange&&this.element.on("change",()=>{var t;return(t=e.onChange)==null?void 0:t.call(e,this.element[0].value)}),e!=null&&e.value&&(this.element[0].value=e.value),e!=null&&e.selected&&(this.element[0].selectionStart=0,this.element[0].selectionEnd=-1),this.element.on("keyup",t=>{var i,n;switch(t.key){case"Enter":(i=e==null?void 0:e.onEnter)==null||i.call(e,this.element[0].value);break;case"Escape":(n=e==null?void 0:e.onEscape)==null||n.call(e,this.element[0].value);break}})}toString(){return`[${ti.name}#${this.componentId}]`}}class Mt extends G{constructor(s,e,t){super(s,{...t}),this.element=$("<p/>").text(e);for(const i of(t==null?void 0:t.classes)??[])this.element.addClass(i)}toString(){return`[${Mt.name}#${this.componentId}]`}}const ks={toolbar:"_toolbar_1654f_1"};class E extends G{constructor(e,t){super(e,{...t});u(this,"container");u(this,"head");u(this,"returnValue");this.element=$("<dialog/>").addClass("dialog").addClass("help").addClass(ys.dialog),(t==null?void 0:t.hasClose)!==!1&&this.addChild(new j(e,"close",null,{classes:[ys.close],onClick:()=>{var i;this.close(),(i=t==null?void 0:t.onCancel)==null||i.call(t)}})),this.returnValue=(t==null?void 0:t.promptValue)??"",this.head=new M(e),this.container=new M(e),this.addChildren(mt([this.head,t!=null&&t.prompt?new ti(e,{onChange:i=>{this.returnValue=i},onEnter:i=>{var n;this.returnValue=i,this.close(),(n=t.onConfirm)==null||n.call(t,this.returnValue)},onEscape:i=>{var n;this.close(),(n=t.onCancel)==null||n.call(t)},selected:!0,value:t.promptValue}):void 0,this.container,new Q(e),new M(e,{classes:[ks.toolbar]}).addChildren(mt([new j(e,"OK",null,{classes:[C.large],onClick:()=>{var i;this.close(),(i=t==null?void 0:t.onConfirm)==null||i.call(t,this.returnValue)}}),t!=null&&t.hasCancel?new j(e,"Cancel",null,{classes:[C.large],onClick:()=>{var i;this.close(),(i=t.onCancel)==null||i.call(t)}}):void 0]))]))}toString(){return`[${E.name}#${this.componentId}]`}addChildHead(e){return this.head.addChild(e),this}addChildrenHead(e){for(const t of e??[])this.head.addChild(t);return this}addChildContent(e){return this.container.addChild(e),this}addChildrenContent(e){for(const t of e??[])this.container.addChild(t);return this}show(){$("#gamePageContainer").append(this.element),this.element[0].show()}showModal(){$("#gamePageContainer").append(this.element),this.element[0].showModal()}close(){this.element[0].close(),this.element.remove()}static async prompt(e,t,i,n,r){return new Promise(a=>{new E(e,{hasCancel:!0,hasClose:!1,onCancel:()=>{a(void 0)},onConfirm:o=>{a(o)},prompt:!0,promptValue:n}).addChildrenHead(mt([i?new q(e,i):void 0,new Mt(e,t)])).addChildrenContent(r?[new M(e,{classes:[ws.explainer]}).addChildren([new Mt(e,r)])]:[]).showModal()})}}const la={maxButton:"_maxButton_133h2_1"};class Pe extends j{constructor(e,t,i){super(e,"",null,{...i,classes:[la.maxButton,...(i==null?void 0:i.classes)??[]]});u(this,"setting");this.setting=t}toString(){return`[${Pe.name}#${this.componentId}]`}}class Te extends j{constructor(e,t,i,n){super(e,"",P.Trigger,{...n,onRefresh:()=>{var a,o;const r=this.behavior==="integer"?this.host.renderAbsolute(this.setting.trigger,"invariant"):this.host.renderPercentage(this.setting.trigger,"invariant",!0);this.updateTitle(this.host.engine.i18n("ui.trigger",[r])),(((a=this.options)==null?void 0:a.renderLabel)??!0)&&this.updateLabel(r),this.inactive?this.element.addClass(C.inactive):this.element.removeClass(C.inactive),(o=n==null?void 0:n.onRefresh)==null||o.call(this)}});u(this,"behavior");u(this,"setting");this.behavior=t instanceof V?"percentage":"integer",this.setting=t}toString(){return`[${Te.name}#${this.componentId}]`}}class At extends S{constructor(e,t,i,n,r){super(e,t,n,r);u(this,"maxButton");u(this,"triggerButton");this.maxButton=new Pe(e,t,{alignment:"right",border:!1,classes:[C.headAction],onClick:async()=>{await r.onSetMax.call(this)},onRefresh:r!=null&&r.onRefreshMax?()=>{var a;return(a=r.onRefreshMax)==null?void 0:a.call(this)}:void 0}),this.triggerButton=new Te(e,t,i,{border:!1,classes:[C.lastHeadAction],onClick:async()=>{await r.onSetTrigger.call(this)},onRefresh:r!=null&&r.onRefreshTrigger?()=>{var a;return(a=r.onRefreshTrigger)==null?void 0:a.call(this)}:void 0,renderLabel:(r==null?void 0:r.renderLabelTrigger)??!0}),this.addChildrenHead([new M(e,{classes:[A.fillSpace]}),this.maxButton,this.triggerButton])}toString(){return`[${At.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}const oe={getBuildOption:(c,s,e,t,i,n,r)=>{const a=async()=>{const l=await E.prompt(c,c.host.engine.i18n("ui.max.prompt.absolute"),c.host.engine.i18n("ui.max.build.prompt",[i,c.host.renderAbsolute(s.max,e.selected)]),c.host.renderAbsolute(s.max),c.host.engine.i18n("ui.max.build.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){s.max=-1;return}l==="0"&&(s.enabled=!1),s.max=c.host.parseAbsolute(l)??s.max}},o=new At(c,s,e,i,{delimiter:r==null?void 0:r.delimiter,onCheck:async l=>{var h;c.host.engine.imessage("status.sub.enable",[i]),s.max===0&&!l&&await a(),await((h=r==null?void 0:r.onCheck)==null?void 0:h.call(r,l))},onRefreshMax:()=>{o.maxButton.updateLabel(c.host.renderAbsolute(s.max)),o.maxButton.element[0].title=s.max<0?c.host.engine.i18n("ui.max.build.titleInfinite",[i]):s.max===0?c.host.engine.i18n("ui.max.build.titleZero",[i]):c.host.engine.i18n("ui.max.build.title",[c.host.renderAbsolute(s.max),i])},onRefreshRequest:()=>{o.maxButton.inactive=!s.enabled||s.max===-1,o.maxButton.ineffective=t.enabled&&s.enabled&&s.max===0,o.triggerButton.inactive=!s.enabled||s.trigger===-1,o.triggerButton.ineffective=t.enabled&&s.enabled&&t.trigger===-1&&s.trigger===-1},onRefreshTrigger:()=>{o.triggerButton.element[0].title=c.host.engine.i18n("ui.trigger",[s.trigger<0?t.trigger<0?c.host.engine.i18n("ui.trigger.build.blocked",[n]):`${c.host.renderPercentage(t.trigger,e.selected,!0)} (${c.host.engine.i18n("ui.trigger.build.inherited")})`:c.host.renderPercentage(s.trigger,e.selected,!0)])},onSetMax:a,onSetTrigger:async()=>{var h;const l=await E.prompt(c,c.host.engine.i18n("ui.trigger.prompt.percentage"),c.host.engine.i18n("ui.trigger.build.prompt",[i,s.trigger!==-1?c.host.renderPercentage(s.trigger,e.selected,!0):c.host.engine.i18n("ui.trigger.build.inherited")]),s.trigger!==-1?c.host.renderPercentage(s.trigger):"",c.host.engine.i18n("ui.trigger.build.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){s.trigger=-1;return}s.trigger=c.host.parsePercentage(l),await((h=r==null?void 0:r.onSetTrigger)==null?void 0:h.call(void 0))}},onUnCheck:l=>{var h;c.host.engine.imessage("status.sub.disable",[i]),(h=r==null?void 0:r.onUnCheck)==null||h.call(r,l)},renderLabelTrigger:r==null?void 0:r.renderLabelTrigger,upgradeIndicator:r==null?void 0:r.upgradeIndicator});return o}};class W extends S{constructor(e,t,i,n,r){super(e,t,n,r);u(this,"triggerButton");this.triggerButton=new Te(e,t,i,{alignment:"right",border:!1,onClick:async()=>{await r.onSetTrigger.call(this)},onRefresh:r!=null&&r.onRefreshTrigger?()=>{var a;return(a=r.onRefreshTrigger)==null?void 0:a.call(this)}:void 0,renderLabel:(r==null?void 0:r.renderLabelTrigger)??!0}),this.addChildrenHead([new M(e,{classes:[A.fillSpace]}),this.triggerButton])}toString(){return`[${W.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class ii extends N{constructor(s,e,t){console.debug(...y(`Constructing ${ii.name}`));const i=s.host.engine.i18n("ui.build");super(s,e,new W(s,e,t,i,{onCheck:n=>{s.host.engine.imessage("status.auto.enable",[i])},onRefreshTrigger:()=>{this.settingItem.triggerButton.element[0].title=s.host.engine.i18n("ui.trigger.section",[e.trigger<0?s.host.engine.i18n("ui.trigger.section.inactive"):s.host.renderPercentage(e.trigger,t.selected,!0)])},onSetTrigger:async()=>{const n=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.percentage"),s.host.engine.i18n("ui.trigger.section.prompt",[i,e.trigger!==-1?s.host.renderPercentage(e.trigger,t.selected,!0):s.host.engine.i18n("ui.infinity")]),e.trigger!==-1?s.host.renderPercentage(e.trigger):"",s.host.engine.i18n("ui.trigger.section.promptExplainer"));if(n!==void 0){if(n===""||n.startsWith("-")){e.trigger=-1;return}e.trigger=s.host.parsePercentage(n)}},onUnCheck:n=>{s.host.engine.imessage("status.auto.disable",[i])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled||e.trigger<0,this.settingItem.triggerButton.ineffective=e.enabled&&e.trigger<0&&Object.values(e.buildings).some(n=>n.enabled&&0<n.max&&n.trigger<0),this.expando.ineffective=e.enabled&&Object.values(e.buildings).some(n=>n.enabled&&(n.max===0||n.trigger<0&&e.trigger<0))}}),this.addChildrenContent([new x(this,{onReset:()=>{this.setting.load({buildings:new Xt().buildings})}}).addChildren(mt(this.host.game.bld.buildingGroups.flatMap(n=>[new q(this,n.title),...n.buildings.flatMap(r=>this._getBuildOptions(this,e,t,i,r)),n!==this.host.game.bld.buildingGroups[this.host.game.bld.buildingGroups.length-1]?new Q(this):void 0]))),new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new q(this,this.host.engine.i18n("ui.additional")),new S(this,e.gatherCatnip,this.host.engine.i18n("option.catnip"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.catnip")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.catnip")])}}),new S(this,e.turnOnSteamworks,this.host.engine.i18n("option.steamworks"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.steamworks")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.steamworks")])}}),new S(this,e.turnOnMagnetos,this.host.engine.i18n("option.magnetos"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.magnetos")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.magnetos")])}}),new S(this,e.turnOnReactors,this.host.engine.i18n("option.reactors"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.reactors")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.reactors")])}}),new ra(this,e.upgradeBuildings,t,e)])])}_getBuildOptions(s,e,t,i,n){var a;if(n==="unicornPasture"||m(e.buildings[n]))return[];const r=s.host.game.bld.getBuildingExt(n).meta;if(!m(r.stages)){const o=(a=Object.values(e.buildings).find(l=>l.baseBuilding===n))==null?void 0:a.building;return[oe.getBuildOption(s,e.buildings[n],t,e,r.stages[0].label,i,{renderLabelTrigger:!1}),oe.getBuildOption(s,e.buildings[o],t,e,r.stages[1].label,i,{renderLabelTrigger:!1,upgradeIndicator:!0})]}return m(r.label)?[]:[oe.getBuildOption(s,e.buildings[n],t,e,r.label,i,{renderLabelTrigger:!1})]}}class ca extends S{constructor(e,t){const i=J(e.host.engine.i18n("ui.engine"));super(e,t,i,{onCheck:()=>{e.host.engine.start(!0)},onUnCheck:()=>{e.host.engine.stop(!0)}});u(this,"expando");this.expando=new Rt(this),this.addChildrenHead([new M(e,{classes:[A.fillSpace]}),this.expando])}}class si extends he{constructor(e,t,i){super(e,{...i});u(this,"button");this.button=t,this.element.addClass(Tt.head),this.element.append(t.element)}}const ha={fieldset:"_fieldset_tfwil_1"};class ni extends G{constructor(s,e,t){super(s,{...t}),this.element=$("<fieldset/>").addClass(ha.fieldset),t!=null&&t.delimiter&&this.element.addClass(ye.delimiter);const i=$("<legend/>").text(e).addClass(A.label);this.element.append(i)}toString(){return`[${ni.name}#${this.componentId}]`}}class ai extends G{constructor(e,t,i,n,r){super(e,{...r,onRefresh:()=>{this.input.prop("disabled",this.readOnly)}});u(this,"setting");u(this,"option");u(this,"elementLabel");u(this,"input");u(this,"readOnly");this.element=$("<div/>"),this.element.addClass(D.setting),(r==null?void 0:r.delimiter)===!0&&this.element.addClass(ye.delimiter),this.elementLabel=$("<label/>",{text:`${r!=null&&r.upgradeIndicator?"⮤ ":""}${i.label}`}).addClass(A.label);const a=$("<input/>",{name:n,type:"radio"}).addClass("ks-radio");this.readOnly=(r==null?void 0:r.readOnly)??!1,a.on("change",()=>{this.setting.selected=i.value,m(r==null?void 0:r.onCheck)||r.onCheck()}),this.elementLabel.prepend(a),this.element.append(this.elementLabel),this.input=a,this.setting=t,this.option=i}toString(){return`[${ai.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class Be extends G{constructor(e,t,i,n){super(e,{...n,onRefresh:()=>{var r;for(const a of this._items)if(a.option.value===this.setting.selected){a.input.prop("checked",!0);break}(r=n==null?void 0:n.onRefresh)==null||r.call(n)}});u(this,"fieldset");u(this,"setting");u(this,"_items");this.element=$("<li/>"),this.fieldset=new ni(e,t),this.addChild(this.fieldset),this._items=new Array;for(const r of i.options)this._items.push(new ai(e,i,r,t,{onCheck:n==null?void 0:n.onCheck,readOnly:n==null?void 0:n.readOnly}));this.fieldset.addChildren(this._items),this.setting=i}toString(){return`[${Be.name}#${this.componentId}]`}}const ua={textButton:"_textButton_1mv97_1"};class ke extends G{constructor(e,t,i){super(e,{...i,onRefresh:()=>{var r;this.readOnly?this.element.addClass(C.readonly):this.element.removeClass(C.readonly),(r=i==null?void 0:i.onRefresh)==null||r.call(this)}});u(this,"readOnly");this.element=$("<div/>").addClass(ua.textButton),t!==void 0&&this.element.text(t);const n=i==null?void 0:i.title;m(n)||this.element.prop("title",n),this.readOnly=!1,this.element.on("click",()=>{this.readOnly||this.click().catch(R(console))})}toString(){return`[${ke.name}#${this.componentId}]`}async click(){var e,t;this.readOnly||(await((t=(e=this.options)==null?void 0:e.onClick)==null?void 0:t.call(this)),this.requestRefresh())}}class ri extends N{constructor(s,e,t){console.debug(...y(`Constructing ${ri.name}`)),super(s,e,new ue(s,s.host.engine.i18n("ui.internals"),{classes:[D.checked,D.setting],icon:P.Settings}).addChildrenHead([new M(s,{classes:[A.fillSpace]})])),this.addChildrenContent([new x(s,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new si(s,new ke(s,s.host.engine.i18n("ui.internals.interval",[e.interval]),{onClick:async()=>{const i=await E.prompt(s,s.host.engine.i18n("ui.internals.interval.prompt"),s.host.engine.i18n("ui.internals.interval.promptTitle",[s.host.renderAbsolute(e.interval,t.selected)]),s.host.renderAbsolute(e.interval),s.host.engine.i18n("ui.internals.interval.promptExplainer"));i===void 0||i===""||i.startsWith("-")||(i==="0"&&(e.enabled=!1),e.interval=s.host.parseAbsolute(i)??e.interval)},onRefresh(){this.element.text(s.host.engine.i18n("ui.internals.interval",[e.interval]))}})),new Q(s),new S(s,e.ksColumn,s.host.engine.i18n("ui.ksColumn"),{onCheck:()=>{s.host.rebuildUi()},onUnCheck:()=>{s.host.rebuildUi()}}),new S(s,e.highlighStock,s.host.engine.i18n("ui.highlightStock")),new Q(s),new Be(s,s.host.engine.i18n("ui.language"),e.locale,{onCheck:()=>{s.host.rebuildUi()}}),new Q(s),new ue(s,`Kitten Scientists ${Le("v")}`)])])}}class oi extends G{constructor(s,e,t){super(s,{...t}),this.element=$("<li/>",{text:s.host.engine.i18n(e)}).addClass(ws.explainer)}toString(){return`[${oi.name}#${this.componentId}]`}}class li extends N{constructor(s,e){console.debug(...y(`Constructing ${li.name}`));const t=s.host.engine.i18n("ui.filter");super(s,e,new S(s,e,t,{onCheck:n=>{s.host.engine.imessage("status.auto.enable",[t])},onUnCheck:n=>{s.host.engine.imessage("status.auto.disable",[t])}}).addChildrenHead([new M(s,{classes:[A.fillSpace]})])),this.addChildContent(new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new S(this,e.disableKGLog,this.host.engine.i18n("filter.allKG"))]));const i=new x(this).addChildren(os.map(n=>({label:this.host.engine.i18n(`filter.${n}`),name:n})).sort((n,r)=>n.label.localeCompare(r.label)).map(n=>new S(this,this.setting.filters[n.name],n.label,{onCheck:()=>{this.host.engine.imessage("filter.enable",[n.label])},onUnCheck:()=>{this.host.engine.imessage("filter.disable",[n.label])}})));this.addChildContent(i),this.addChildContent(new oi(this,"filter.explainer"))}}const Pt={active:"_active_6c09s_16"};class ci extends N{constructor(e,t,i){console.debug(...y(`Constructing ${ci.name}`));const n=e.host.engine.i18n("ui.faith");super(e,t,new W(e,t,i,n,{onCheck:a=>{e.host.engine.imessage("status.auto.enable",[n])},onRefreshTrigger(){this.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger.section",[t.trigger<0?e.host.engine.i18n("ui.trigger.section.inactive"):e.host.renderPercentage(t.trigger,i.selected,!0)])},onSetTrigger:async()=>{const a=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.percentage"),e.host.engine.i18n("ui.trigger.section.prompt",[n,t.trigger!==-1?e.host.renderPercentage(t.trigger,i.selected,!0):e.host.engine.i18n("ui.infinity")]),t.trigger!==-1?e.host.renderPercentage(t.trigger):"",e.host.engine.i18n("ui.trigger.section.promptExplainer"));if(a!==void 0){if(a===""||a.startsWith("-")){t.trigger=-1;return}t.trigger=e.host.parsePercentage(a)}},onUnCheck:a=>{e.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefresh:()=>{for(const[a,o]of this._unicornBuildings.entries())o.elementLabel.attr("data-ks-active-from","❊"),o.elementLabel.attr("data-ks-active-to","✮"),this.setting.bestUnicornBuilding.enabled&&this.setting.bestUnicornBuildingCurrent===a?o.elementLabel.addClass(Pt.active):o.elementLabel.removeClass(Pt.active)},onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!t.enabled||t.trigger===-1,this.settingItem.triggerButton.ineffective=t.enabled&&t.trigger<0&&Object.values(t.buildings).some(a=>a.enabled&&0<a.max&&a.trigger<0),this.expando.ineffective=t.enabled&&Object.values(t.buildings).some(a=>a.enabled&&(a.max===0||a.trigger<0&&t.trigger<0));for(const[a,o]of this._unicornBuildings.entries())o.readOnly=this._bestUnicornBuilding.setting.enabled,o.maxButton.readOnly=this._bestUnicornBuilding.setting.enabled,o.triggerButton.readOnly=this._bestUnicornBuilding.setting.enabled}});u(this,"_unicornBuildings");u(this,"_bestUnicornBuilding");const r=[...wt];this._unicornBuildings=new Map([["unicornPasture",oe.getBuildOption(this,this.setting.buildings.unicornPasture,i,this.setting,this.host.engine.i18n("$buildings.unicornPasture.label"),n,{renderLabelTrigger:!1})],...this.host.game.religion.zigguratUpgrades.filter(a=>r.includes(a.name)&&!m(this.setting.buildings[a.name])).map(a=>[a.name,oe.getBuildOption(this,this.setting.buildings[a.name],i,this.setting,a.label,n,{renderLabelTrigger:!1})])]),this._bestUnicornBuilding=new S(this,this.setting.bestUnicornBuilding,this.host.engine.i18n("option.faith.best.unicorn"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.faith.best.unicorn")]);for(const a of this._unicornBuildings.values())a.setting.enabled=!0,a.setting.max=-1,a.setting.trigger=-1},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.faith.best.unicorn")])},upgradeIndicator:!0}),this.addChildrenContent([new x(this,{onReset:()=>{const a=new Yt;this.setting.load({bestUnicornBuilding:a.bestUnicornBuilding,buildings:a.buildings})}}).addChildren([new q(this,this.host.engine.i18n("$religion.panel.ziggurat.label")),...this._unicornBuildings.values(),this._bestUnicornBuilding,new Q(this),...this.host.game.religion.zigguratUpgrades.filter(a=>!r.includes(a.name)&&!m(this.setting.buildings[a.name])).map(a=>oe.getBuildOption(this,this.setting.buildings[a.name],i,this.setting,a.label,n,{renderLabelTrigger:!1})),new Q(this),new q(this,this.host.engine.i18n("$religion.panel.orderOfTheSun.label")),...this.host.game.religion.religionUpgrades.filter(a=>!m(this.setting.buildings[a.name])).map(a=>{var o;return oe.getBuildOption(this,this.setting.buildings[a.name],i,this.setting,a.label,n,{delimiter:a.name===((o=this.host.game.religion.religionUpgrades.at(-1))==null?void 0:o.name),renderLabelTrigger:!1})}),new q(this,this.host.engine.i18n("$religion.panel.cryptotheology.label")),...this.host.game.religion.transcendenceUpgrades.filter(a=>!m(this.setting.buildings[a.name])).map(a=>oe.getBuildOption(this,this.setting.buildings[a.name],i,this.setting,a.label,n,{renderLabelTrigger:!1}))]),new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new q(this,this.host.engine.i18n("ui.additional")),...Qs.map(a=>{const o=this.host.engine.i18n(`option.faith.${a}`);if(a==="transcend")return new S(this,this.setting[a],o,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[o])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[o])}});const l=new W(this,this.setting[a],i,o,{classes:[C.lastHeadAction],onCheck:()=>{this.host.engine.imessage("status.sub.enable",[o])},onRefresh:()=>{l.triggerButton.inactive=!this.setting[a].enabled||this.setting[a].trigger===-1},onSetTrigger:async()=>{const h=await E.prompt(this,this.host.engine.i18n(l.triggerButton.behavior==="integer"?"ui.trigger.setinteger":"ui.trigger.setpercentage",[o]),this.host.engine.i18n("ui.trigger.build.prompt",[o,l.triggerButton.behavior==="integer"?this.host.renderAbsolute(this.setting[a].trigger,i.selected):this.host.renderPercentage(this.setting[a].trigger,i.selected,!0)]),l.triggerButton.behavior==="integer"?this.host.renderAbsolute(this.setting[a].trigger):this.host.renderPercentage(this.setting[a].trigger),this.host.engine.i18n(l.triggerButton.behavior==="integer"?"ui.trigger.setinteger.promptExplainer":"ui.trigger.setpercentage.promptExplainer"));h===void 0||h===""||h.startsWith("-")||(this.setting[a].trigger=(l.triggerButton.behavior==="integer"?this.host.parseAbsolute(h):this.host.parsePercentage(h))??this.setting[a].trigger)},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[o])}});return l.triggerButton.element.addClass(C.lastHeadAction),l})])])}}class hi extends j{constructor(e,t,i,n,r){super(e,"",P.DataUsage,{...r,onClick:async()=>{const a=await E.prompt(e,e.host.engine.i18n("resources.consume.prompt"),e.host.engine.i18n("resources.consume.promptTitle",[n,e.host.renderPercentage(t.consume,i.selected,!0)]),e.host.renderPercentage(t.consume),e.host.engine.i18n("resources.consume.promptExplainer"));a!==void 0&&(a===""||a.startsWith("-")||(t.consume=e.host.parsePercentage(a)))},onRefresh:()=>{var l;const a=this.host.renderPercentage(this.setting.consume,this.host.engine.settings.locale.selected,!0),o=this.setting.consume===0?this.host.engine.i18n("resources.consume.titleZero",[this.resourceName]):this.host.engine.i18n("resources.consume.title",[a,this.resourceName]);this.updateTitle(o),(l=r==null?void 0:r.onRefresh)==null||l.call(r)}});u(this,"setting");u(this,"resourceName");this.element.addClass(C.consumeButton),this.resourceName=n,this.setting=t}toString(){return`[${hi.name}#${this.componentId}]`}}class ui extends j{constructor(e,t,i,n,r){super(e,"",null,{...r,onClick:async()=>{const a=await E.prompt(e,e.host.engine.i18n("resources.stock.prompt"),e.host.engine.i18n("resources.stock.promptTitle",[n,e.host.renderAbsolute(t.stock,i.selected)]),e.host.renderAbsolute(t.stock),e.host.engine.i18n("resources.stock.promptExplainer"));if(a!==void 0){if(a===""||a.startsWith("-")){t.stock=-1;return}a==="0"&&(t.enabled=!1),t.stock=e.host.parseAbsolute(a)??t.stock}},onRefresh:()=>{const a=this.host.renderAbsolute(this.setting.stock),o=this.setting.stock<0?this.host.engine.i18n("resources.stock.titleInfinite",[this.resourceName]):this.setting.stock===0?this.host.engine.i18n("resources.stock.titleZero",[this.resourceName]):this.host.engine.i18n("resources.stock.title",[this.host.renderAbsolute(this.setting.stock),this.resourceName]);this.updateTitle(o),this.updateLabel(a)}});u(this,"setting");u(this,"resourceName");this.element.addClass(C.stockButton),this.resourceName=n,this.setting=t}toString(){return`[${ui.name}#${this.componentId}]`}}class di extends N{constructor(s,e,t){console.debug(...y(`Constructing ${di.name}`));const i=s.host.engine.i18n("ui.resources");super(s,e,new ue(s,i,{classes:[D.checked,D.setting],icon:P.Resources}).addChildrenHead([new M(s,{classes:[A.fillSpace]})]));const n=["blackcoin","burnedParagon","elderBox","gflops","hashrates","kittens","paragon","temporalFlux","wrappingPaper","zebras"];this.addChildContent(new x(this).addChildren(this.host.game.resPool.resources.filter(r=>!n.includes(r.name)&&!m(this.setting.resources[r.name])).sort((r,a)=>r.title.localeCompare(a.title,t.selected)).map(r=>[this.setting.resources[r.name],J(r.title)]).map(([r,a])=>this._makeResourceSetting(this,r,t,a))))}_makeResourceSetting(s,e,t,i){const n=new S(s,e,i,{onCheck:()=>{s.host.engine.imessage("status.resource.enable",[i])},onUnCheck:()=>{s.host.engine.imessage("status.resource.disable",[i])}}).addChildrenHead([new M(s,{classes:[A.fillSpace]})]),r=new ui(s,e,t,i,{alignment:"right",border:!1,classes:[C.headAction],onRefreshRequest:()=>{r.inactive=!e.enabled||e.stock===0}});n.head.addChild(r);const a=new hi(s,e,t,i,{border:!1,classes:[C.lastHeadAction],onRefreshRequest:()=>{a.inactive=!e.enabled||e.consume!==100,a.ineffective=e.enabled&&e.consume===0}});return n.head.addChild(a),n}}class da extends N{constructor(s,e,t,i){const n=s.host.engine.i18n("ui.upgrade.policies");super(s,e,new S(s,e,n,{onCheck:l=>{s.host.engine.imessage("status.auto.enable",[n])},onUnCheck:l=>{s.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(s,{classes:[A.fillSpace]})]),{onRefreshRequest:()=>{this.expando.ineffective=i.enabled&&e.enabled&&!Object.values(e.policies).some(l=>l.enabled)}});const r=this.host.game.science.policies.filter(l=>!m(this.setting.policies[l.name])),a=[];let o=r[0].label;for(const l of r.sort((h,d)=>h.label.localeCompare(d.label,t.selected))){const h=this.setting.policies[l.name],d=new S(this,h,l.label,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[l.label])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[l.label])}});this.host.engine.localeSupportsFirstLetterSplits(t.selected)&&o[0]!==l.label[0]&&d.element.addClass(A.splitter),a.push(d),o=l.label}this.addChildContent(new x(this).addChildren(a))}}class ga extends N{constructor(s,e,t,i){const n=s.host.engine.i18n("ui.upgrade.techs");super(s,e,new W(s,e,t,n,{onCheck:l=>{s.host.engine.imessage("status.auto.enable",[n])},onRefreshTrigger(){this.triggerButton.element[0].title=s.host.engine.i18n("ui.trigger",[e.trigger<0?s.host.engine.i18n("ui.trigger.section.inactive"):s.host.renderPercentage(e.trigger,t.selected,!0)])},onSetTrigger:async()=>{const l=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.percentage"),s.host.engine.i18n("ui.trigger.section.prompt",[n,e.trigger!==-1?s.host.renderPercentage(e.trigger,t.selected,!0):s.host.engine.i18n("ui.infinity")]),e.trigger!==-1?s.host.renderPercentage(e.trigger):"",s.host.engine.i18n("ui.trigger.section.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.trigger=-1;return}e.trigger=s.host.parsePercentage(l)}},onUnCheck:l=>{s.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled||e.trigger===-1,this.settingItem.triggerButton.ineffective=i.enabled&&e.enabled&&e.trigger===-1&&!Object.values(e.techs).some(l=>l.enabled&&0<=l.trigger),this.expando.ineffective=i.enabled&&e.enabled&&!Object.values(e.techs).some(l=>l.enabled)}});const r=this.host.game.science.techs.filter(l=>!m(this.setting.techs[l.name])),a=[];let o=r[0].label;for(const l of r.sort((h,d)=>h.label.localeCompare(d.label,t.selected))){const h=this.setting.techs[l.name],d=new W(this,h,t,l.label,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[l.label])},onRefresh:()=>{d.triggerButton.inactive=!h.enabled||h.trigger===-1,d.triggerButton.ineffective=i.enabled&&e.enabled&&h.enabled&&e.trigger===-1&&h.trigger===-1},onRefreshTrigger:()=>{d.triggerButton.element[0].title=this.host.engine.i18n("ui.trigger",[h.trigger<0?e.trigger<0?this.host.engine.i18n("ui.trigger.section.blocked",[n]):`${this.host.renderPercentage(e.trigger,t.selected,!0)} (${this.host.engine.i18n("ui.trigger.section.inherited")})`:this.host.renderPercentage(h.trigger,t.selected,!0)])},onSetTrigger:async()=>{const g=await E.prompt(this,this.host.engine.i18n("ui.trigger.prompt.percentage"),this.host.engine.i18n("ui.trigger.section.prompt",[n,h.trigger!==-1?this.host.renderPercentage(h.trigger,t.selected,!0):this.host.engine.i18n("ui.trigger.section.inherited")]),h.trigger!==-1?this.host.renderPercentage(h.trigger):"",this.host.engine.i18n("ui.trigger.section.promptExplainer"));if(g!==void 0){if(g===""||g.startsWith("-")){h.trigger=-1;return}h.trigger=this.host.parsePercentage(g)}},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[l.label])},renderLabelTrigger:!1});d.triggerButton.element.addClass(C.lastHeadAction),this.host.engine.localeSupportsFirstLetterSplits(t.selected)&&o[0]!==l.label[0]&&d.element.addClass(A.splitter),a.push(d),o=l.label}this.addChildContent(new x(this).addChildren(a))}}class gi extends N{constructor(e,t,i){console.debug(...y(`Constructing ${gi.name}`));const n=e.host.engine.i18n("ui.upgrade");super(e,t,new S(e,t,n,{onCheck:a=>{e.host.engine.imessage("status.auto.enable",[n])},onUnCheck:a=>{e.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(e,{classes:[A.fillSpace]})]),{onRefresh:()=>{this.setting.observe.enabled?$("#observeButton").hide():$("#observeButton").show()},onRefreshRequest:()=>{this.expando.ineffective=t.enabled&&(this.setting.policies.enabled&&this._policiesUi.expando.ineffective||this.setting.techs.enabled&&(this._techsUi.expando.ineffective||this._techsUi.settingItem.triggerButton.ineffective))}});u(this,"_policiesUi");u(this,"_techsUi");u(this,"_observeStars");this._policiesUi=new da(this,t.policies,i,t),this._techsUi=new ga(this,t.techs,i,t),this._observeStars=new S(this,this.setting.observe,this.host.engine.i18n("option.observe"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.observe")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.observe")])}});const r=new x(this,{hasDisableAll:!1,hasEnableAll:!1});r.addChildren([this._techsUi,this._policiesUi,this._observeStars]),this.addChildContent(r)}}class ma extends N{constructor(e,t,i,n){const r=e.host.engine.i18n("ui.upgrade.missions");super(e,t,new S(e,t,r,{onCheck:o=>{e.host.engine.imessage("status.auto.enable",[r])},onRefresh:()=>{this.expando.ineffective=n.enabled&&t.enabled&&!Object.values(t.missions).some(o=>o.enabled)},onUnCheck:o=>{e.host.engine.imessage("status.auto.disable",[r])}}).addChildrenHead([new M(e,{classes:[A.fillSpace]})]));u(this,"_missions");this._missions=this.host.game.space.programs.filter(o=>!m(this.setting.missions[o.name])).map(o=>new S(this,this.setting.missions[o.name],o.label,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[o.label])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[o.label])}}));const a=new x(this).addChildren(this._missions);this.addChildContent(a)}}class mi extends N{constructor(e,t,i){console.debug(...y(`Constructing ${mi.name}`));const n=e.host.engine.i18n("ui.space");super(e,t,new W(e,t,i,n,{onCheck:a=>{e.host.engine.imessage("status.auto.enable",[n])},onRefreshTrigger(){this.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger.section",[t.trigger<0?e.host.engine.i18n("ui.trigger.section.inactive"):e.host.renderPercentage(t.trigger,i.selected,!0)])},onSetTrigger:async()=>{const a=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.percentage"),e.host.engine.i18n("ui.trigger.section.prompt",[n,t.trigger!==-1?e.host.renderPercentage(t.trigger,i.selected,!0):e.host.engine.i18n("ui.infinity")]),t.trigger!==-1?e.host.renderPercentage(t.trigger):"",e.host.engine.i18n("ui.trigger.section.promptExplainer"));if(a!==void 0){if(a===""||a.startsWith("-")){t.trigger=-1;return}t.trigger=e.host.parsePercentage(a)}},onUnCheck:a=>{e.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!t.enabled||t.trigger===-1,this.settingItem.triggerButton.ineffective=t.enabled&&t.trigger<0&&Object.values(t.buildings).some(a=>a.enabled&&0<a.max&&a.trigger<0),this.expando.ineffective=t.enabled&&(Object.values(t.buildings).some(a=>a.enabled&&(a.max===0||a.trigger<0&&t.trigger<0))||!Object.values(t.buildings).some(a=>a.enabled)&&!t.unlockMissions.enabled||this._missionsUi.expando.ineffective)}});u(this,"_missionsUi");this.addChildContent(new x(this,{onReset:()=>{this.setting.load({buildings:new Ct().buildings})}}).addChildren(this.host.game.space.planets.filter(a=>0<a.buildings.length).flatMap((a,o,l)=>[new q(this,this.host.engine.labelForPlanet(a.name)),...a.buildings.filter(h=>!m(this.setting.buildings[h.name])).map((h,d,g)=>oe.getBuildOption(this,this.setting.buildings[h.name],i,this.setting,h.label,n,{delimiter:o<l.length-1&&d===g.length-1,renderLabelTrigger:!1}))])));const r=new x(this,{hasDisableAll:!1,hasEnableAll:!1});r.addChild(new q(this,this.host.engine.i18n("ui.additional"))),this._missionsUi=new ma(this,this.setting.unlockMissions,i,this.setting),r.addChild(this._missionsUi),this.addChildContent(r)}}class fi extends me{constructor(s,e=400){super("ERR_OS_INVALID_ARGUMENT",s,e),this.name="InvalidArgumentError",typeof Error.captureStackTrace<"u"&&Error.captureStackTrace(this,fi)}}const Bt=43200,_s=1440,Cs=Symbol.for("constructDateFrom");function bi(c,s){return typeof c=="function"?c(s):c&&typeof c=="object"&&Cs in c?c[Cs](s):c instanceof Date?new c.constructor(s):new Date(s)}function fa(c){return bi(c,Date.now())}const ba={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},pa=(c,s,e)=>{let t;const i=ba[c];return typeof i=="string"?t=i:s===1?t=i.one:t=i.other.replace("{{count}}",s.toString()),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"in "+t:t+" ago":t};function se(c){return(s={})=>{const e=s.width?String(s.width):c.defaultWidth;return c.formats[e]||c.formats[c.defaultWidth]}}const va={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},ya={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},wa={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ka={date:se({formats:va,defaultWidth:"full"}),time:se({formats:ya,defaultWidth:"full"}),dateTime:se({formats:wa,defaultWidth:"full"})},_a={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ca=(c,s,e,t)=>_a[c];function Z(c){return(s,e)=>{const t=e!=null&&e.context?String(e.context):"standalone";let i;if(t==="formatting"&&c.formattingValues){const r=c.defaultFormattingWidth||c.defaultWidth,a=e!=null&&e.width?String(e.width):r;i=c.formattingValues[a]||c.formattingValues[r]}else{const r=c.defaultWidth,a=e!=null&&e.width?String(e.width):c.defaultWidth;i=c.values[a]||c.values[r]}const n=c.argumentCallback?c.argumentCallback(s):s;return i[n]}}const Sa={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},xa={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Ta={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Ea={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Ra={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Ma={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Aa={ordinalNumber:(c,s)=>{const e=Number(c),t=e%100;if(t>20||t<10)switch(t%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},era:Z({values:Sa,defaultWidth:"wide"}),quarter:Z({values:xa,defaultWidth:"wide",argumentCallback:c=>c-1}),month:Z({values:Ta,defaultWidth:"wide"}),day:Z({values:Ea,defaultWidth:"wide"}),dayPeriod:Z({values:Ra,defaultWidth:"wide",formattingValues:Ma,defaultFormattingWidth:"wide"})};function K(c){return(s,e={})=>{const t=e.width,i=t&&c.matchPatterns[t]||c.matchPatterns[c.defaultMatchWidth],n=s.match(i);if(!n)return null;const r=n[0],a=t&&c.parsePatterns[t]||c.parsePatterns[c.defaultParseWidth],o=Array.isArray(a)?Ba(a,d=>d.test(r)):Pa(a,d=>d.test(r));let l;l=c.valueCallback?c.valueCallback(o):o,l=e.valueCallback?e.valueCallback(l):l;const h=s.slice(r.length);return{value:l,rest:h}}}function Pa(c,s){for(const e in c)if(Object.prototype.hasOwnProperty.call(c,e)&&s(c[e]))return e}function Ba(c,s){for(let e=0;e<c.length;e++)if(s(c[e]))return e}function It(c){return(s,e={})=>{const t=s.match(c.matchPattern);if(!t)return null;const i=t[0],n=s.match(c.parsePattern);if(!n)return null;let r=c.valueCallback?c.valueCallback(n[0]):n[0];r=e.valueCallback?e.valueCallback(r):r;const a=s.slice(i.length);return{value:r,rest:a}}}const Ia=/^(\d+)(th|st|nd|rd)?/i,$a=/\d+/i,La={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Oa={any:[/^b/i,/^(a|c)/i]},Ua={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Da={any:[/1/i,/2/i,/3/i,/4/i]},Na={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},qa={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},za={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Fa={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ha={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Wa={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ga={ordinalNumber:It({matchPattern:Ia,parsePattern:$a,valueCallback:c=>parseInt(c,10)}),era:K({matchPatterns:La,defaultMatchWidth:"wide",parsePatterns:Oa,defaultParseWidth:"any"}),quarter:K({matchPatterns:Ua,defaultMatchWidth:"wide",parsePatterns:Da,defaultParseWidth:"any",valueCallback:c=>c+1}),month:K({matchPatterns:Na,defaultMatchWidth:"wide",parsePatterns:qa,defaultParseWidth:"any"}),day:K({matchPatterns:za,defaultMatchWidth:"wide",parsePatterns:Fa,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:Ha,defaultMatchWidth:"any",parsePatterns:Wa,defaultParseWidth:"any"})},Ss={code:"en-US",formatDistance:pa,formatLong:ka,formatRelative:Ca,localize:Aa,match:Ga,options:{weekStartsOn:0,firstWeekContainsDate:1}};let Za={};function xs(){return Za}function ge(c,s){return bi(s||c,c)}function Ts(c){const s=ge(c),e=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return e.setUTCFullYear(s.getFullYear()),+c-+e}function $t(c,...s){const e=bi.bind(null,c||s.find(t=>typeof t=="object"));return s.map(e)}function Lt(c,s){const e=+ge(c)-+ge(s);return e<0?-1:e>0?1:e}function Ka(c,s,e){const[t,i]=$t(e==null?void 0:e.in,c,s),n=t.getFullYear()-i.getFullYear(),r=t.getMonth()-i.getMonth();return n*12+r}function Va(c,s){const e=ge(c,s==null?void 0:s.in);return e.setHours(23,59,59,999),e}function ja(c,s){const e=ge(c,s==null?void 0:s.in),t=e.getMonth();return e.setFullYear(e.getFullYear(),t+1,0),e.setHours(23,59,59,999),e}function Ja(c,s){const e=ge(c,s==null?void 0:s.in);return+Va(e,s)==+ja(e,s)}function Xa(c,s,e){const[t,i,n]=$t(e==null?void 0:e.in,c,c,s),r=Lt(i,n),a=Math.abs(Ka(i,n));if(a<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-r*a);let o=Lt(i,n)===-r;Ja(t)&&a===1&&Lt(t,n)===1&&(o=!1);const l=r*(a-+o);return l===0?0:l}function Ya(c){return s=>{const t=(c?Math[c]:Math.trunc)(s);return t===0?0:t}}function Qa(c,s){return+ge(c)-+ge(s)}function er(c,s,e){const t=Qa(c,s)/1e3;return Ya(e==null?void 0:e.roundingMethod)(t)}function tr(c,s,e){const t=xs(),i=(e==null?void 0:e.locale)??t.locale??Ss,n=2520,r=Lt(c,s);if(isNaN(r))throw new RangeError("Invalid time value");const a=Object.assign({},e,{addSuffix:e==null?void 0:e.addSuffix,comparison:r}),[o,l]=$t(e==null?void 0:e.in,...r>0?[s,c]:[c,s]),h=er(l,o),d=(Ts(l)-Ts(o))/1e3,g=Math.round((h-d)/60);let f;if(g<2)return e!=null&&e.includeSeconds?h<5?i.formatDistance("lessThanXSeconds",5,a):h<10?i.formatDistance("lessThanXSeconds",10,a):h<20?i.formatDistance("lessThanXSeconds",20,a):h<40?i.formatDistance("halfAMinute",0,a):h<60?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",1,a):g===0?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",g,a);if(g<45)return i.formatDistance("xMinutes",g,a);if(g<90)return i.formatDistance("aboutXHours",1,a);if(g<_s){const p=Math.round(g/60);return i.formatDistance("aboutXHours",p,a)}else{if(g<n)return i.formatDistance("xDays",1,a);if(g<Bt){const p=Math.round(g/_s);return i.formatDistance("xDays",p,a)}else if(g<Bt*2)return f=Math.round(g/Bt),i.formatDistance("aboutXMonths",f,a)}if(f=Xa(l,o),f<12){const p=Math.round(g/Bt);return i.formatDistance("xMonths",p,a)}else{const p=f%12,b=Math.trunc(f/12);return p<3?i.formatDistance("aboutXYears",b,a):p<9?i.formatDistance("overXYears",b,a):i.formatDistance("almostXYears",b+1,a)}}function Es(c,s){return tr(c,fa(c),s)}function Rs(c,s){var a,o,l,h;const e=xs(),t=(s==null?void 0:s.weekStartsOn)??((o=(a=s==null?void 0:s.locale)==null?void 0:a.options)==null?void 0:o.weekStartsOn)??e.weekStartsOn??((h=(l=e.locale)==null?void 0:l.options)==null?void 0:h.weekStartsOn)??0,i=ge(c,s==null?void 0:s.in),n=i.getDay(),r=(n<t?7:0)+n-t;return i.setDate(i.getDate()-r),i.setHours(0,0,0,0),i}function ir(c,s,e){const[t,i]=$t(e==null?void 0:e.in,c,s);return+Rs(t,e)==+Rs(i,e)}const Ms={lessThanXSeconds:{standalone:{one:"weniger als 1 Sekunde",other:"weniger als {{count}} Sekunden"},withPreposition:{one:"weniger als 1 Sekunde",other:"weniger als {{count}} Sekunden"}},xSeconds:{standalone:{one:"1 Sekunde",other:"{{count}} Sekunden"},withPreposition:{one:"1 Sekunde",other:"{{count}} Sekunden"}},halfAMinute:{standalone:"eine halbe Minute",withPreposition:"einer halben Minute"},lessThanXMinutes:{standalone:{one:"weniger als 1 Minute",other:"weniger als {{count}} Minuten"},withPreposition:{one:"weniger als 1 Minute",other:"weniger als {{count}} Minuten"}},xMinutes:{standalone:{one:"1 Minute",other:"{{count}} Minuten"},withPreposition:{one:"1 Minute",other:"{{count}} Minuten"}},aboutXHours:{standalone:{one:"etwa 1 Stunde",other:"etwa {{count}} Stunden"},withPreposition:{one:"etwa 1 Stunde",other:"etwa {{count}} Stunden"}},xHours:{standalone:{one:"1 Stunde",other:"{{count}} Stunden"},withPreposition:{one:"1 Stunde",other:"{{count}} Stunden"}},xDays:{standalone:{one:"1 Tag",other:"{{count}} Tage"},withPreposition:{one:"1 Tag",other:"{{count}} Tagen"}},aboutXWeeks:{standalone:{one:"etwa 1 Woche",other:"etwa {{count}} Wochen"},withPreposition:{one:"etwa 1 Woche",other:"etwa {{count}} Wochen"}},xWeeks:{standalone:{one:"1 Woche",other:"{{count}} Wochen"},withPreposition:{one:"1 Woche",other:"{{count}} Wochen"}},aboutXMonths:{standalone:{one:"etwa 1 Monat",other:"etwa {{count}} Monate"},withPreposition:{one:"etwa 1 Monat",other:"etwa {{count}} Monaten"}},xMonths:{standalone:{one:"1 Monat",other:"{{count}} Monate"},withPreposition:{one:"1 Monat",other:"{{count}} Monaten"}},aboutXYears:{standalone:{one:"etwa 1 Jahr",other:"etwa {{count}} Jahre"},withPreposition:{one:"etwa 1 Jahr",other:"etwa {{count}} Jahren"}},xYears:{standalone:{one:"1 Jahr",other:"{{count}} Jahre"},withPreposition:{one:"1 Jahr",other:"{{count}} Jahren"}},overXYears:{standalone:{one:"mehr als 1 Jahr",other:"mehr als {{count}} Jahre"},withPreposition:{one:"mehr als 1 Jahr",other:"mehr als {{count}} Jahren"}},almostXYears:{standalone:{one:"fast 1 Jahr",other:"fast {{count}} Jahre"},withPreposition:{one:"fast 1 Jahr",other:"fast {{count}} Jahren"}}},sr=(c,s,e)=>{let t;const i=e!=null&&e.addSuffix?Ms[c].withPreposition:Ms[c].standalone;return typeof i=="string"?t=i:s===1?t=i.one:t=i.other.replace("{{count}}",String(s)),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"in "+t:"vor "+t:t},nr={full:"EEEE, do MMMM y",long:"do MMMM y",medium:"do MMM y",short:"dd.MM.y"},ar={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},rr={full:"{{date}} 'um' {{time}}",long:"{{date}} 'um' {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},or={date:se({formats:nr,defaultWidth:"full"}),time:se({formats:ar,defaultWidth:"full"}),dateTime:se({formats:rr,defaultWidth:"full"})},lr={lastWeek:"'letzten' eeee 'um' p",yesterday:"'gestern um' p",today:"'heute um' p",tomorrow:"'morgen um' p",nextWeek:"eeee 'um' p",other:"P"},cr=(c,s,e,t)=>lr[c],hr={narrow:["v.Chr.","n.Chr."],abbreviated:["v.Chr.","n.Chr."],wide:["vor Christus","nach Christus"]},ur={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1. Quartal","2. Quartal","3. Quartal","4. Quartal"]},pi={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],wide:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]},dr={narrow:pi.narrow,abbreviated:["Jan.","Feb.","März","Apr.","Mai","Juni","Juli","Aug.","Sep.","Okt.","Nov.","Dez."],wide:pi.wide},gr={narrow:["S","M","D","M","D","F","S"],short:["So","Mo","Di","Mi","Do","Fr","Sa"],abbreviated:["So.","Mo.","Di.","Mi.","Do.","Fr.","Sa."],wide:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]},mr={narrow:{am:"vm.",pm:"nm.",midnight:"Mitternacht",noon:"Mittag",morning:"Morgen",afternoon:"Nachm.",evening:"Abend",night:"Nacht"},abbreviated:{am:"vorm.",pm:"nachm.",midnight:"Mitternacht",noon:"Mittag",morning:"Morgen",afternoon:"Nachmittag",evening:"Abend",night:"Nacht"},wide:{am:"vormittags",pm:"nachmittags",midnight:"Mitternacht",noon:"Mittag",morning:"Morgen",afternoon:"Nachmittag",evening:"Abend",night:"Nacht"}},fr={narrow:{am:"vm.",pm:"nm.",midnight:"Mitternacht",noon:"Mittag",morning:"morgens",afternoon:"nachm.",evening:"abends",night:"nachts"},abbreviated:{am:"vorm.",pm:"nachm.",midnight:"Mitternacht",noon:"Mittag",morning:"morgens",afternoon:"nachmittags",evening:"abends",night:"nachts"},wide:{am:"vormittags",pm:"nachmittags",midnight:"Mitternacht",noon:"Mittag",morning:"morgens",afternoon:"nachmittags",evening:"abends",night:"nachts"}},br={ordinalNumber:c=>Number(c)+".",era:Z({values:hr,defaultWidth:"wide"}),quarter:Z({values:ur,defaultWidth:"wide",argumentCallback:c=>c-1}),month:Z({values:pi,formattingValues:dr,defaultWidth:"wide"}),day:Z({values:gr,defaultWidth:"wide"}),dayPeriod:Z({values:mr,defaultWidth:"wide",formattingValues:fr,defaultFormattingWidth:"wide"})},pr=/^(\d+)(\.)?/i,vr=/\d+/i,yr={narrow:/^(v\.? ?Chr\.?|n\.? ?Chr\.?)/i,abbreviated:/^(v\.? ?Chr\.?|n\.? ?Chr\.?)/i,wide:/^(vor Christus|vor unserer Zeitrechnung|nach Christus|unserer Zeitrechnung)/i},wr={any:[/^v/i,/^n/i]},kr={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](\.)? Quartal/i},_r={any:[/1/i,/2/i,/3/i,/4/i]},Cr={narrow:/^[jfmasond]/i,abbreviated:/^(j[aä]n|feb|mär[z]?|apr|mai|jun[i]?|jul[i]?|aug|sep|okt|nov|dez)\.?/i,wide:/^(januar|februar|märz|april|mai|juni|juli|august|september|oktober|november|dezember)/i},Sr={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^j[aä]/i,/^f/i,/^mär/i,/^ap/i,/^mai/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},xr={narrow:/^[smdmf]/i,short:/^(so|mo|di|mi|do|fr|sa)/i,abbreviated:/^(son?|mon?|die?|mit?|don?|fre?|sam?)\.?/i,wide:/^(sonntag|montag|dienstag|mittwoch|donnerstag|freitag|samstag)/i},Tr={any:[/^so/i,/^mo/i,/^di/i,/^mi/i,/^do/i,/^f/i,/^sa/i]},Er={narrow:/^(vm\.?|nm\.?|Mitternacht|Mittag|morgens|nachm\.?|abends|nachts)/i,abbreviated:/^(vorm\.?|nachm\.?|Mitternacht|Mittag|morgens|nachm\.?|abends|nachts)/i,wide:/^(vormittags|nachmittags|Mitternacht|Mittag|morgens|nachmittags|abends|nachts)/i},Rr={any:{am:/^v/i,pm:/^n/i,midnight:/^Mitte/i,noon:/^Mitta/i,morning:/morgens/i,afternoon:/nachmittags/i,evening:/abends/i,night:/nachts/i}},Mr={ordinalNumber:It({matchPattern:pr,parsePattern:vr,valueCallback:c=>parseInt(c)}),era:K({matchPatterns:yr,defaultMatchWidth:"wide",parsePatterns:wr,defaultParseWidth:"any"}),quarter:K({matchPatterns:kr,defaultMatchWidth:"wide",parsePatterns:_r,defaultParseWidth:"any",valueCallback:c=>c+1}),month:K({matchPatterns:Cr,defaultMatchWidth:"wide",parsePatterns:Sr,defaultParseWidth:"any"}),day:K({matchPatterns:xr,defaultMatchWidth:"wide",parsePatterns:Tr,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:Er,defaultMatchWidth:"wide",parsePatterns:Rr,defaultParseWidth:"any"})},Ar={code:"de",formatDistance:sr,formatLong:or,formatRelative:cr,localize:br,match:Mr,options:{weekStartsOn:1,firstWeekContainsDate:4}},Pr={lessThanXSeconds:{one:"פחות משנייה",two:"פחות משתי שניות",other:"פחות מ־{{count}} שניות"},xSeconds:{one:"שנייה",two:"שתי שניות",other:"{{count}} שניות"},halfAMinute:"חצי דקה",lessThanXMinutes:{one:"פחות מדקה",two:"פחות משתי דקות",other:"פחות מ־{{count}} דקות"},xMinutes:{one:"דקה",two:"שתי דקות",other:"{{count}} דקות"},aboutXHours:{one:"כשעה",two:"כשעתיים",other:"כ־{{count}} שעות"},xHours:{one:"שעה",two:"שעתיים",other:"{{count}} שעות"},xDays:{one:"יום",two:"יומיים",other:"{{count}} ימים"},aboutXWeeks:{one:"כשבוע",two:"כשבועיים",other:"כ־{{count}} שבועות"},xWeeks:{one:"שבוע",two:"שבועיים",other:"{{count}} שבועות"},aboutXMonths:{one:"כחודש",two:"כחודשיים",other:"כ־{{count}} חודשים"},xMonths:{one:"חודש",two:"חודשיים",other:"{{count}} חודשים"},aboutXYears:{one:"כשנה",two:"כשנתיים",other:"כ־{{count}} שנים"},xYears:{one:"שנה",two:"שנתיים",other:"{{count}} שנים"},overXYears:{one:"יותר משנה",two:"יותר משנתיים",other:"יותר מ־{{count}} שנים"},almostXYears:{one:"כמעט שנה",two:"כמעט שנתיים",other:"כמעט {{count}} שנים"}},Br=(c,s,e)=>{if(c==="xDays"&&(e!=null&&e.addSuffix)&&s<=2)return e.comparison&&e.comparison>0?s===1?"מחר":"מחרתיים":s===1?"אתמול":"שלשום";let t;const i=Pr[c];return typeof i=="string"?t=i:s===1?t=i.one:s===2?t=i.two:t=i.other.replace("{{count}}",String(s)),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"בעוד "+t:"לפני "+t:t},Ir={full:"EEEE, d בMMMM y",long:"d בMMMM y",medium:"d בMMM y",short:"d.M.y"},$r={full:"H:mm:ss zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},Lr={full:"{{date}} 'בשעה' {{time}}",long:"{{date}} 'בשעה' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Or={date:se({formats:Ir,defaultWidth:"full"}),time:se({formats:$r,defaultWidth:"full"}),dateTime:se({formats:Lr,defaultWidth:"full"})},Ur={lastWeek:"eeee 'שעבר בשעה' p",yesterday:"'אתמול בשעה' p",today:"'היום בשעה' p",tomorrow:"'מחר בשעה' p",nextWeek:"eeee 'בשעה' p",other:"P"},Dr=(c,s,e,t)=>Ur[c],Nr={narrow:["לפנה״ס","לספירה"],abbreviated:["לפנה״ס","לספירה"],wide:["לפני הספירה","לספירה"]},qr={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["רבעון 1","רבעון 2","רבעון 3","רבעון 4"]},zr={narrow:["1","2","3","4","5","6","7","8","9","10","11","12"],abbreviated:["ינו׳","פבר׳","מרץ","אפר׳","מאי","יוני","יולי","אוג׳","ספט׳","אוק׳","נוב׳","דצמ׳"],wide:["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"]},Fr={narrow:["א׳","ב׳","ג׳","ד׳","ה׳","ו׳","ש׳"],short:["א׳","ב׳","ג׳","ד׳","ה׳","ו׳","ש׳"],abbreviated:["יום א׳","יום ב׳","יום ג׳","יום ד׳","יום ה׳","יום ו׳","שבת"],wide:["יום ראשון","יום שני","יום שלישי","יום רביעי","יום חמישי","יום שישי","יום שבת"]},Hr={narrow:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בוקר",afternoon:"אחר הצהריים",evening:"ערב",night:"לילה"},abbreviated:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בוקר",afternoon:"אחר הצהריים",evening:"ערב",night:"לילה"},wide:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בוקר",afternoon:"אחר הצהריים",evening:"ערב",night:"לילה"}},Wr={narrow:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בבוקר",afternoon:"בצהריים",evening:"בערב",night:"בלילה"},abbreviated:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בבוקר",afternoon:"אחר הצהריים",evening:"בערב",night:"בלילה"},wide:{am:"לפנה״צ",pm:"אחה״צ",midnight:"חצות",noon:"צהריים",morning:"בבוקר",afternoon:"אחר הצהריים",evening:"בערב",night:"בלילה"}},Gr={ordinalNumber:(c,s)=>{const e=Number(c);if(e<=0||e>10)return String(e);const t=String(s==null?void 0:s.unit),i=["year","hour","minute","second"].indexOf(t)>=0,n=["ראשון","שני","שלישי","רביעי","חמישי","שישי","שביעי","שמיני","תשיעי","עשירי"],r=["ראשונה","שנייה","שלישית","רביעית","חמישית","שישית","שביעית","שמינית","תשיעית","עשירית"],a=e-1;return i?r[a]:n[a]},era:Z({values:Nr,defaultWidth:"wide"}),quarter:Z({values:qr,defaultWidth:"wide",argumentCallback:c=>c-1}),month:Z({values:zr,defaultWidth:"wide"}),day:Z({values:Fr,defaultWidth:"wide"}),dayPeriod:Z({values:Hr,defaultWidth:"wide",formattingValues:Wr,defaultFormattingWidth:"wide"})},Zr=/^(\d+|(ראשון|שני|שלישי|רביעי|חמישי|שישי|שביעי|שמיני|תשיעי|עשירי|ראשונה|שנייה|שלישית|רביעית|חמישית|שישית|שביעית|שמינית|תשיעית|עשירית))/i,Kr=/^(\d+|רא|שנ|של|רב|ח|שי|שב|שמ|ת|ע)/i,Vr={narrow:/^ל(ספירה|פנה״ס)/i,abbreviated:/^ל(ספירה|פנה״ס)/i,wide:/^ל(פני ה)?ספירה/i},jr={any:[/^לפ/i,/^לס/i]},Jr={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^רבעון [1234]/i},Xr={any:[/1/i,/2/i,/3/i,/4/i]},Yr={narrow:/^\d+/i,abbreviated:/^(ינו|פבר|מרץ|אפר|מאי|יוני|יולי|אוג|ספט|אוק|נוב|דצמ)׳?/i,wide:/^(ינואר|פברואר|מרץ|אפריל|מאי|יוני|יולי|אוגוסט|ספטמבר|אוקטובר|נובמבר|דצמבר)/i},Qr={narrow:[/^1$/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^7/i,/^8/i,/^9/i,/^10/i,/^11/i,/^12/i],any:[/^ינ/i,/^פ/i,/^מר/i,/^אפ/i,/^מא/i,/^יונ/i,/^יול/i,/^אוג/i,/^ס/i,/^אוק/i,/^נ/i,/^ד/i]},eo={narrow:/^[אבגדהוש]׳/i,short:/^[אבגדהוש]׳/i,abbreviated:/^(שבת|יום (א|ב|ג|ד|ה|ו)׳)/i,wide:/^יום (ראשון|שני|שלישי|רביעי|חמישי|שישי|שבת)/i},to={abbreviated:[/א׳$/i,/ב׳$/i,/ג׳$/i,/ד׳$/i,/ה׳$/i,/ו׳$/i,/^ש/i],wide:[/ן$/i,/ני$/i,/לישי$/i,/עי$/i,/מישי$/i,/שישי$/i,/ת$/i],any:[/^א/i,/^ב/i,/^ג/i,/^ד/i,/^ה/i,/^ו/i,/^ש/i]},io={any:/^(אחר ה|ב)?(חצות|צהריים|בוקר|ערב|לילה|אחה״צ|לפנה״צ)/i},so={any:{am:/^לפ/i,pm:/^אחה/i,midnight:/^ח/i,noon:/^צ/i,morning:/בוקר/i,afternoon:/בצ|אחר/i,evening:/ערב/i,night:/לילה/i}},no=["רא","שנ","של","רב","ח","שי","שב","שמ","ת","ע"],ao={ordinalNumber:It({matchPattern:Zr,parsePattern:Kr,valueCallback:c=>{const s=parseInt(c,10);return isNaN(s)?no.indexOf(c)+1:s}}),era:K({matchPatterns:Vr,defaultMatchWidth:"wide",parsePatterns:jr,defaultParseWidth:"any"}),quarter:K({matchPatterns:Jr,defaultMatchWidth:"wide",parsePatterns:Xr,defaultParseWidth:"any",valueCallback:c=>c+1}),month:K({matchPatterns:Yr,defaultMatchWidth:"wide",parsePatterns:Qr,defaultParseWidth:"any"}),day:K({matchPatterns:eo,defaultMatchWidth:"wide",parsePatterns:to,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:io,defaultMatchWidth:"any",parsePatterns:so,defaultParseWidth:"any"})},ro={code:"he",formatDistance:Br,formatLong:Or,formatRelative:Dr,localize:Gr,match:ao,options:{weekStartsOn:0,firstWeekContainsDate:1}},oo={lessThanXSeconds:{one:"不到 1 秒",other:"不到 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分钟",lessThanXMinutes:{one:"不到 1 分钟",other:"不到 {{count}} 分钟"},xMinutes:{one:"1 分钟",other:"{{count}} 分钟"},xHours:{one:"1 小时",other:"{{count}} 小时"},aboutXHours:{one:"大约 1 小时",other:"大约 {{count}} 小时"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大约 1 个星期",other:"大约 {{count}} 个星期"},xWeeks:{one:"1 个星期",other:"{{count}} 个星期"},aboutXMonths:{one:"大约 1 个月",other:"大约 {{count}} 个月"},xMonths:{one:"1 个月",other:"{{count}} 个月"},aboutXYears:{one:"大约 1 年",other:"大约 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超过 1 年",other:"超过 {{count}} 年"},almostXYears:{one:"将近 1 年",other:"将近 {{count}} 年"}},lo=(c,s,e)=>{let t;const i=oo[c];return typeof i=="string"?t=i:s===1?t=i.one:t=i.other.replace("{{count}}",String(s)),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?t+"内":t+"前":t},co={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},ho={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},uo={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},go={date:se({formats:co,defaultWidth:"full"}),time:se({formats:ho,defaultWidth:"full"}),dateTime:se({formats:uo,defaultWidth:"full"})};function As(c,s,e){const t="eeee p";return ir(c,s,e)?t:c.getTime()>s.getTime()?"'下个'"+t:"'上个'"+t}const mo={lastWeek:As,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:As,other:"PP p"},fo=(c,s,e,t)=>{const i=mo[c];return typeof i=="function"?i(s,e,t):i},bo={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},po={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},vo={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},yo={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},wo={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},ko={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},_o={ordinalNumber:(c,s)=>{const e=Number(c);switch(s==null?void 0:s.unit){case"date":return e.toString()+"日";case"hour":return e.toString()+"时";case"minute":return e.toString()+"分";case"second":return e.toString()+"秒";default:return"第 "+e.toString()}},era:Z({values:bo,defaultWidth:"wide"}),quarter:Z({values:po,defaultWidth:"wide",argumentCallback:c=>c-1}),month:Z({values:vo,defaultWidth:"wide"}),day:Z({values:yo,defaultWidth:"wide"}),dayPeriod:Z({values:wo,defaultWidth:"wide",formattingValues:ko,defaultFormattingWidth:"wide"})},Co=/^(第\s*)?\d+(日|时|分|秒)?/i,So=/\d+/i,xo={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},To={any:[/^(前)/i,/^(公元)/i]},Eo={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},Ro={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},Mo={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},Ao={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},Po={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},Bo={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},Io={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},$o={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},Lo={ordinalNumber:It({matchPattern:Co,parsePattern:So,valueCallback:c=>parseInt(c,10)}),era:K({matchPatterns:xo,defaultMatchWidth:"wide",parsePatterns:To,defaultParseWidth:"any"}),quarter:K({matchPatterns:Eo,defaultMatchWidth:"wide",parsePatterns:Ro,defaultParseWidth:"any",valueCallback:c=>c+1}),month:K({matchPatterns:Mo,defaultMatchWidth:"wide",parsePatterns:Ao,defaultParseWidth:"any"}),day:K({matchPatterns:Po,defaultMatchWidth:"wide",parsePatterns:Bo,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:Io,defaultMatchWidth:"any",parsePatterns:$o,defaultParseWidth:"any"})},Oo={code:"zh-CN",formatDistance:lo,formatLong:go,formatRelative:fo,localize:_o,match:Lo,options:{weekStartsOn:1,firstWeekContainsDate:4}};class Uo{constructor(s){u(this,"_game");this._game=s}load(s){return new Promise((e,t)=>{if(s===null){e();return}this._game.saveImportDropboxText(s,i=>{if(i){t(i);return}e()})})}loadRaw(s){const e=this._game.compressLZData(JSON.stringify(s));return this.load(e)}}class Ie extends he{constructor(s,e){super(s,e),this.element.addClass(ks.toolbar)}toString(){return`[${Ie.name}#${this.componentId}]`}addChild(s){return super.addChild(s)}}class vi extends N{constructor(e,t,i){console.debug(...y(`Constructing ${vi.name}`));const n=e.host.engine.i18n("state.title");super(e,t,new ue(e,n,{classes:[D.checked,D.setting],icon:P.State}).addChildrenHead([new M(e,{classes:[A.fillSpace]})]),{onRefresh:()=>{this._refreshGameList(),this._refreshStateList()}});u(this,"games",new Array);u(this,"states",new Array);u(this,"gameList");u(this,"stateList");u(this,"locale");this.gameList=new x(this,{hasDisableAll:!1,hasEnableAll:!1}),this.stateList=new x(this,{hasDisableAll:!1,hasEnableAll:!1}),this.locale=i.selected==="zh-CN"?Oo:i.selected==="he-IL"?ro:i.selected==="de-DE"?Ar:Ss,this.addChildContent(new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new S(this,this.setting.noConfirm,this.host.engine.i18n("state.noConfirm")),new he(this).addChild(new Q(this)),new q(this,this.host.engine.i18n("state.local")),new Ie(this).addChildren([new j(this,this.host.engine.i18n("state.import"),P.Import,{onClick:()=>{this.import()},title:this.host.engine.i18n("state.importTitle")})]),new he(this).addChild(new Q(this)),new q(this,this.host.engine.i18n("state.localStates")),new Ie(this).addChildren([new j(this,this.host.engine.i18n("state.store"),P.SaveAs,{onClick:()=>{this.storeState()},title:this.host.engine.i18n("state.storeState")}),new j(this,this.host.engine.i18n("copy"),P.Copy,{onClick:()=>{this.copyState().catch(R(console)),this.host.engine.imessage("state.copied.stateCurrent")},title:this.host.engine.i18n("state.copy.stateCurrent")}),new j(this,this.host.engine.i18n("state.new"),P.Draft,{onClick:()=>{this.storeStateFactoryDefaults(),this.host.engine.imessage("state.stored.state")},title:this.host.engine.i18n("state.storeFactory")}),new j(this,this.host.engine.i18n("state.exportAll"),P.Sync,{onClick:()=>{this.exportStateAll()},title:this.host.engine.i18n("state.exportAllTitle")})]),new he(this).addChild(this.stateList),new he(this).addChild(new Q(this)),new q(this,this.host.engine.i18n("state.localGames")),new Ie(this).addChildren([new j(this,this.host.engine.i18n("state.store"),P.SaveAs,{onClick:()=>{this.storeGame(),this.host.engine.imessage("state.stored.game")},title:this.host.engine.i18n("state.storeGame")}),new j(this,this.host.engine.i18n("copy"),P.Copy,{onClick:()=>{this.copyGame().catch(R(console)),this.host.engine.imessage("state.copied.gameCurrent")},title:this.host.engine.i18n("state.copy.gameCurrent")})]),new he(this).addChild(this.gameList),new S(this,this.setting.compress,this.host.engine.i18n("state.compress"))])),this._loadGames(),this._loadStates()}_loadGames(){let e=0,t=localStorage.getItem(`ks.game.${e}`);this.games.splice(0);try{for(;!m(t);){const i=JSON.parse(t);this.games.push(new vt(i)),t=localStorage.getItem(`ks.game.${++e}`)}}catch(i){console.error(...y(i))}}_storeGames(){let e=0,t=localStorage.getItem(`ks.game.${e}`);for(;!m(t);)localStorage.removeItem(`ks.game.${e}`),t=localStorage.getItem(`ks.game.${++e}`);e=0;for(const i of this.games)localStorage.setItem(`ks.game.${e++}`,JSON.stringify(i))}_loadStates(){let e=0,t=localStorage.getItem(`ks.state.${e}`);this.states.splice(0);try{for(;!m(t);){const i=JSON.parse(t);de.unknownAsEngineStateOrThrow(i.state),this.states.push(new vt(i)),t=localStorage.getItem(`ks.state.${++e}`)}}catch(i){console.error(...y(i))}}_storeStates(){let e=0,t=localStorage.getItem(`ks.state.${e}`);for(;!m(t);)localStorage.removeItem(`ks.state.${e}`),t=localStorage.getItem(`ks.state.${++e}`);e=0;for(const i of this.states)localStorage.setItem(`ks.state.${e++}`,JSON.stringify(i))}_refreshGameList(){this.gameList.removeChildren(this.gameList.children),this.gameList.addChildren(this.games.sort((e,t)=>new Date(e.unwrap().timestamp).getTime()-new Date(t.unwrap().timestamp).getTime()).map(e=>[e.unwrap(),e]).map(([e,t])=>new si(this,new ke(this,`${e.label} (${Es(new Date(e.timestamp),{addSuffix:!0,locale:this.locale})})`,{onClick:()=>{this.loadGame(e.game).catch(R(console)),this.host.engine.imessage("state.loaded.game",[e.label])},title:new Date(e.timestamp).toLocaleString()})).addChildren([new M(this,{classes:[A.fillSpace]}),new ie(this,P.Save,this.host.engine.i18n("state.update.game"),{onClick:()=>{this.updateGame(t,this.host.game.save()),this.host.engine.imessage("state.updated.game",[e.label])}}),new ie(this,P.Edit,this.host.engine.i18n("state.edit.game"),{onClick:()=>{this.storeGame(e.game),this.deleteGame(t,!0),this.host.engine.imessage("state.updated.game",[e.label])}}),new ie(this,P.Copy,this.host.engine.i18n("state.copy.game"),{onClick:()=>{this.copyGame(e.game).catch(R(console)),this.host.engine.imessage("state.copied.game",[e.label])}}),new ie(this,P.Delete,this.host.engine.i18n("state.delete.game"),{onClick:()=>{this.deleteGame(t),this.host.engine.imessage("state.deleted.game",[e.label])}})])))}_refreshStateList(){this.stateList.removeChildren(this.stateList.children),this.stateList.addChildren(this.states.sort((e,t)=>new Date(e.unwrap().timestamp).getTime()-new Date(t.unwrap().timestamp).getTime()).map(e=>[e.unwrap(),e]).map(([e,t])=>new si(this,new ke(this,`${e.label} (${Es(new Date(e.timestamp),{addSuffix:!0,locale:this.locale})})`,{onClick:()=>{this.loadState(e.state),this.host.engine.imessage("state.loaded.state",[e.label])},title:new Date(e.timestamp).toLocaleString()})).addChildren([new M(this,{classes:[A.fillSpace]}),new ie(this,P.Save,this.host.engine.i18n("state.update.state"),{onClick:()=>{this.updateState(t,this.host.engine.stateSerialize()),this.host.engine.imessage("state.updated.state",[e.label])}}),new ie(this,P.Edit,this.host.engine.i18n("state.edit.state"),{onClick:()=>{this.storeState(e.state),this.deleteState(t,!0),this.host.engine.imessage("state.updated.state",[e.label])}}),new ie(this,P.Copy,this.host.engine.i18n("state.copy.state"),{onClick:()=>{this.copyState(e.state).catch(R(console)),this.host.engine.imessage("state.copied.state",[e.label])}}),new ie(this,P.Delete,this.host.engine.i18n("state.delete.state"),{onClick:()=>{this.deleteState(t),this.host.engine.imessage("state.deleted.state",[e.label])}})])))}async copyState(e){await this.host.copySettings(e,!1)}async copyGame(e){const t=e??this.host.game.save(),i=JSON.stringify(t),n=this.setting.compress.enabled?this.host.game.compressLZData(i):i;await T.window.navigator.clipboard.writeText(n)}import(){const e=T.window.prompt(this.host.engine.i18n("state.loadPrompt"));if(m(e))return;const t=new Date().toDateString();let i=1;const n=()=>this.host.engine.i18n("state.importedState",[`${t} #${i++}`]),r=a=>{try{const h=de.decodeSettings(a);this.storeState(h,n()),this.host.engine.imessage("state.imported.state");return}catch{}try{const h=JSON.parse(a),d=de.decodeSettings(h.state);this.storeState(d,h.label),this.host.engine.imessage("state.imported.state");return}catch{}let o;try{o=JSON.parse(a)}catch{const d=this.host.game.decompressLZData(a);try{o=JSON.parse(d)}catch{if(a.match(/\r?\n/))return a.split(/\r?\n/).map(f=>void r(f));throw new fi("The provided input can not be parsed as anything we understand.")}}let l;if(!m(o)&&"ks"in o&&!m(o.ks)){const h=o.ks.state[0];l=this.storeState(h,n())??void 0,this.host.engine.imessage("state.imported.state"),o.ks=void 0}this.storeGame(o,l),this.host.engine.imessage("state.imported.game")};r(e)}storeGame(e,t){let i=t;return m(i)&&(i=T.window.prompt(this.host.engine.i18n("state.storeGame.prompt"))??void 0),m(i)?null:(i=(i===""?void 0:i)??this.host.engine.i18n("state.unlabeledGame"),i=i.substring(0,127),this.games.push(new vt({game:e??this.host.game.save(),label:i,timestamp:new Date().toISOString()})),this._storeGames(),this.requestRefresh(),i)}storeState(e,t){let i=t;return m(i)&&(i=T.window.prompt(this.host.engine.i18n("state.storeState.prompt"))??void 0),m(i)?null:(i=(i===""?void 0:i)??this.host.engine.i18n("state.unlabeledState"),i=i.substring(0,127),this.states.push(new vt({label:i,state:e??this.host.engine.stateSerialize(),timestamp:new Date().toISOString()})),this._storeStates(),this.requestRefresh(),i)}storeStateFactoryDefaults(){this.storeState(re.DEFAULT_STATE)}storeAutoSave(e){const t=this.states.find(i=>i.unwrap().label==="Auto-Save");if(!m(t)){console.info(...y("Updating existing Auto-Save...")),t.replace({...t.unwrap(),state:e,timestamp:new Date().toISOString()}),this._storeStates(),this.requestRefresh();return}console.info(...y("Storing new Auto-Save...")),this.storeState(e,"Auto-Save")}exportStateAll(){const e=this.states.map(r=>r.unwrap()).map(r=>JSON.stringify({label:r.label,state:de.encodeSettings(r.state,!1),timestamp:r.timestamp})).join(`
42
+ `),t=document.createElement("a"),i=new Blob([e],{type:"application/x-ndjson"}),n=URL.createObjectURL(i);t.setAttribute("href",n),t.setAttribute("download",`ks-local-states-${Date.now()}.ndjson`),t.click()}async loadGame(e){this._destructiveActionPrevented()||await new Uo(this.host.game).loadRaw(e)}loadState(e){this._destructiveActionPrevented()||(this.host.engine.stateLoad(e,!0),this.host.refreshEntireUserInterface())}loadAutoSave(){if(this.host.engine.isLoaded){console.info(...y("Not attempting to load Auto-Save, because a state is already loaded."));return}const e=this.states.find(t=>t.unwrap().label==="Auto-Save");if(m(e)){console.info(...y("No Auto-Save settings found."));return}console.info(...y("Loading Auto-Save...")),this.host.engine.stateLoad(e.unwrap().state,!1)}updateGame(e,t){if(this._destructiveActionPrevented())return;const i=e.unwrap().label;e.replace({game:t,label:i,timestamp:new Date().toISOString()}),this._storeGames(),this.requestRefresh()}updateState(e,t){if(this._destructiveActionPrevented())return;const i=e.unwrap().label;e.replace({label:i,state:t,timestamp:new Date().toISOString()}),this._storeStates(),this.requestRefresh()}deleteGame(e,t=!1){if(!t&&this._destructiveActionPrevented())return;const i=this.games.indexOf(e);i<0||(this.games.splice(i,1),this._storeGames(),this.requestRefresh())}deleteState(e,t=!1){if(!t&&this._destructiveActionPrevented())return;const i=this.states.indexOf(e);i<0||(this.states.splice(i,1),this._storeStates(),this.requestRefresh())}_destructiveActionPrevented(){return!this.setting.noConfirm.enabled&&!T.window.confirm(this.host.engine.i18n("state.confirmDestruction"))}}class Ee extends we{constructor(e,t,i,n){super(e,new ue(e,t,{classes:[D.checked,D.setting],icon:n==null?void 0:n.icon}).addChildrenHead([new M(e,{classes:[A.fillSpace]})]),n);u(this,"setting");this.setting=i}}class Do extends Ee{constructor(e,t,i){var a,o;const n=e.host.engine.i18n("ui.build");super(e,n,t,{icon:P.Bonfire,onRefreshRequest:()=>{this.expando.ineffective=t.enabled&&Object.values(t.buildings).some(l=>l.enabled&&l.trigger<=0)}});u(this,"_buildings");this._buildings=[];for(const l of this.host.game.bld.buildingGroups){this._buildings.push(new q(this,l.title));for(const h of l.buildings){if(h==="unicornPasture"||m(this.setting.buildings[h]))continue;const d=this.host.game.bld.getBuildingExt(h).meta;if(m(d.stages))m(d.label)||this._buildings.push(this._getResetOption(this,this.setting.buildings[h],i,t,d.label));else{const g=(a=Object.values(this.setting.buildings).find(f=>f.baseBuilding===h))==null?void 0:a.building;this._buildings.push(this._getResetOption(this,this.setting.buildings[h],i,t,d.stages[0].label),this._getResetOption(this,this.setting.buildings[g],i,t,d.stages[1].label,!1,!0))}}l!==this.host.game.bld.buildingGroups[this.host.game.bld.buildingGroups.length-1]&&((o=this._buildings.at(-1))==null||o.element.addClass(ye.delimiter))}const r=new x(this);r.addChildren(this._buildings),this.addChildContent(r)}_getResetOption(e,t,i,n,r,a=!1,o=!1){const l=new W(e,t,i,r,{delimiter:a,onCheck:()=>{e.host.engine.imessage("status.reset.check.enable",[r])},onRefreshRequest:()=>{l.triggerButton.inactive=!t.enabled||t.trigger===-1,l.triggerButton.ineffective=n.enabled&&t.enabled&&t.trigger===-1},onSetTrigger:async()=>{const h=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.absolute"),e.host.engine.i18n("ui.trigger.build.prompt",[r,t.trigger!==-1?e.host.renderAbsolute(t.trigger,i.selected):e.host.engine.i18n("ui.trigger.inactive")]),t.trigger!==-1?e.host.renderAbsolute(t.trigger):"",e.host.engine.i18n("ui.trigger.reset.promptExplainer"));if(h!==void 0){if(h===""||h.startsWith("-")){t.trigger=-1,t.enabled=!1;return}t.trigger=Number(h)}},onUnCheck:()=>{e.host.engine.imessage("status.reset.check.disable",[r])},upgradeIndicator:o});return l.triggerButton.element.addClass(C.lastHeadAction),l}}class No extends Ee{constructor(s,e,t){const i=s.host.engine.i18n("ui.faith");super(s,i,e,{icon:P.Religion,onRefreshRequest:()=>{this.expando.ineffective=e.enabled&&Object.values(e.buildings).some(r=>r.enabled&&r.trigger<=0)}}),this.addChildrenHead([new M(s,{classes:[A.fillSpace]})]);const n=[...wt];this.addChildContent(new x(this).addChildren([new q(this,this.host.engine.i18n("$religion.panel.ziggurat.label")),this._getResetOption(this,this.setting.buildings.unicornPasture,t,e,this.host.engine.i18n("$buildings.unicornPasture.label")),...this.host.game.religion.zigguratUpgrades.filter(r=>n.includes(r.name)&&!m(this.setting.buildings[r.name])).map(r=>this._getResetOption(this,this.setting.buildings[r.name],t,e,r.label)),new Q(this),...this.host.game.religion.zigguratUpgrades.filter(r=>!n.includes(r.name)&&!m(this.setting.buildings[r.name])).map(r=>this._getResetOption(this,this.setting.buildings[r.name],t,e,r.label)),new Q(this),new q(this,this.host.engine.i18n("$religion.panel.orderOfTheSun.label")),...this.host.game.religion.religionUpgrades.filter(r=>!m(this.setting.buildings[r.name])).map(r=>{var a;return this._getResetOption(this,this.setting.buildings[r.name],t,e,r.label,r.name===((a=this.host.game.religion.religionUpgrades.at(-1))==null?void 0:a.name))}),new q(this,this.host.engine.i18n("$religion.panel.cryptotheology.label")),...this.host.game.religion.transcendenceUpgrades.filter(r=>!m(this.setting.buildings[r.name])).map(r=>this._getResetOption(this,this.setting.buildings[r.name],t,e,r.label))]))}_getResetOption(s,e,t,i,n,r=!1,a=!1){const o=new W(s,e,t,n,{delimiter:r,onCheck:()=>{s.host.engine.imessage("status.reset.check.enable",[n])},onRefreshRequest:()=>{o.triggerButton.inactive=!e.enabled||e.trigger===-1,o.triggerButton.ineffective=i.enabled&&e.enabled&&e.trigger===-1},onSetTrigger:async()=>{const l=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.absolute"),s.host.engine.i18n("ui.trigger.build.prompt",[n,e.trigger!==-1?s.host.renderAbsolute(e.trigger,t.selected):s.host.engine.i18n("ui.trigger.inactive")]),e.trigger!==-1?s.host.renderAbsolute(e.trigger):"",s.host.engine.i18n("ui.trigger.reset.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.trigger=-1,e.enabled=!1;return}e.trigger=Number(l)}},onUnCheck:()=>{s.host.engine.imessage("status.reset.check.disable",[n])},upgradeIndicator:a});return o.triggerButton.element.addClass(C.lastHeadAction),o}}class qo extends Ee{constructor(s,e,t){const i=s.host.engine.i18n("ui.resources");super(s,i,e,{icon:P.Resources,onRefreshRequest:()=>{this.expando.ineffective=e.enabled&&Object.values(e.resources).some(o=>o.enabled&&o.trigger<0)}}),this.addChildrenHead([new M(s,{classes:[A.fillSpace]})]);const n=this.host.game.resPool.resources,r=[];let a=n[0].title;for(const o of[...n].sort((l,h)=>l.title.localeCompare(h.title,t.selected))){const l=this.setting.resources[o.name],h=new W(this,l,t,J(o.title),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[o.title])},onRefreshRequest:()=>{h.triggerButton.inactive=!l.enabled||l.trigger===-1,h.triggerButton.ineffective=e.enabled&&l.enabled&&l.trigger===-1},onSetTrigger:async()=>{const d=await E.prompt(this,this.host.engine.i18n("ui.trigger.prompt.float"),this.host.engine.i18n("ui.trigger.build.prompt",[o.title,l.trigger!==-1?this.host.renderAbsolute(l.trigger,t.selected):this.host.engine.i18n("ui.trigger.inactive")]),l.trigger!==-1?this.host.renderAbsolute(l.trigger):"",this.host.engine.i18n("ui.trigger.reset.promptExplainer"));if(d!==void 0){if(d===""||d.startsWith("-")){l.trigger=-1,l.enabled=!1;return}l.trigger=s.host.parseAbsolute(d)??l.trigger}},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[o.title])}});h.triggerButton.element.addClass(C.lastHeadAction),this.host.engine.localeSupportsFirstLetterSplits(t.selected)&&a[0]!==o.title[0]&&h.element.addClass(A.splitter),r.push(h),a=o.title}this.addChildContent(new x(this).addChildren(r))}}class zo extends Ee{constructor(s,e,t){const i=s.host.engine.i18n("ui.space");super(s,i,e,{icon:P.Space,onRefreshRequest:()=>{this.expando.ineffective=e.enabled&&Object.values(e.buildings).some(n=>n.enabled&&n.trigger<=0)}}),this.addChildrenHead([new M(s,{classes:[A.fillSpace]})]),this.addChildContent(new x(this).addChildren(this.host.game.space.planets.filter(n=>0<n.buildings.length).flatMap((n,r,a)=>[new q(this,this.host.engine.labelForPlanet(n.name)),...n.buildings.filter(o=>!m(this.setting.buildings[o.name])).map((o,l,h)=>this._getResetOption(this,this.setting.buildings[o.name],t,e,o.label,r<a.length-1&&l===h.length-1))])))}_getResetOption(s,e,t,i,n,r=!1,a=!1){const o=new W(s,e,t,n,{delimiter:r,onCheck:()=>{s.host.engine.imessage("status.reset.check.enable",[n])},onRefreshRequest:()=>{o.triggerButton.inactive=!e.enabled||e.trigger===-1,o.triggerButton.ineffective=i.enabled&&e.enabled&&e.trigger===-1},onSetTrigger:async()=>{const l=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.absolute"),s.host.engine.i18n("ui.trigger.build.prompt",[n,e.trigger!==-1?s.host.renderAbsolute(e.trigger,t.selected):s.host.engine.i18n("ui.trigger.inactive")]),e.trigger!==-1?s.host.renderAbsolute(e.trigger):"",s.host.engine.i18n("ui.trigger.reset.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.trigger=-1,e.enabled=!1;return}e.trigger=Number(l)}},onUnCheck:()=>{s.host.engine.imessage("status.reset.check.disable",[n])},upgradeIndicator:a});return o.triggerButton.element.addClass(C.lastHeadAction),o}}class Fo extends Ee{constructor(s,e,t){const i=s.host.engine.i18n("ui.time");super(s,i,e,{icon:P.Time,onRefreshRequest:()=>{this.expando.ineffective=e.enabled&&Object.values(e.buildings).some(n=>n.enabled&&n.trigger<=0)}}),this.addChildrenHead([new M(s,{classes:[A.fillSpace]})]),this.addChildContent(new x(this).addChildren([new q(this,this.host.engine.i18n("$workshop.chronoforge.label")),...this.host.game.time.chronoforgeUpgrades.filter(n=>!m(this.setting.buildings[n.name])).map(n=>{var r;return this._getResetOption(this,this.setting.buildings[n.name],t,e,n.label,n.name===((r=this.host.game.time.chronoforgeUpgrades.at(-1))==null?void 0:r.name))}),new q(this,this.host.engine.i18n("$science.voidSpace.label")),...this.host.game.time.voidspaceUpgrades.filter(n=>n.name in this.setting.buildings).map(n=>this._getResetOption(this,this.setting.buildings[n.name],t,e,n.label))]))}_getResetOption(s,e,t,i,n,r=!1,a=!1){const o=new W(s,e,t,n,{delimiter:r,onCheck:()=>{s.host.engine.imessage("status.reset.check.enable",[n])},onRefreshRequest:()=>{o.triggerButton.inactive=!e.enabled||e.trigger===-1,o.triggerButton.ineffective=i.enabled&&e.enabled&&e.trigger===-1},onSetTrigger:async()=>{const l=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.absolute"),s.host.engine.i18n("ui.trigger.build.prompt",[n,e.trigger!==-1?s.host.renderAbsolute(e.trigger,t.selected):s.host.engine.i18n("ui.trigger.inactive")]),e.trigger!==-1?s.host.renderAbsolute(e.trigger):"",s.host.engine.i18n("ui.trigger.reset.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.trigger=-1,e.enabled=!1;return}e.trigger=Number(l)}},onUnCheck:()=>{s.host.engine.imessage("status.reset.check.disable",[n])},upgradeIndicator:a});return o.triggerButton.element.addClass(C.lastHeadAction),o}}class Ho extends Ee{constructor(s,e,t){const i=s.host.engine.i18n("ui.upgrades");super(s,i,e,{icon:P.Workshop}),this.addChildrenHead([new M(s,{classes:[A.fillSpace]})]);const n=this.host.game.workshop.upgrades.filter(l=>!m(this.setting.upgrades[l.name])),r=[];let a=n[0].label,o;for(const l of n.sort((h,d)=>h.label.localeCompare(d.label,t.selected))){const h=this.setting.upgrades[l.name],d=this._getResetOption(this,h,l.label);this.host.engine.localeSupportsFirstLetterSplits(t.selected)&&a[0]!==l.label[0]&&(m(o)||o.element.addClass(ye.delimiter),d.element.addClass(A.splitter)),o=d,r.push(d),a=l.label}this.addChildContent(new x(this).addChildren(r))}_getResetOption(s,e,t,i=!1,n=!1){return new S(s,e,t,{delimiter:i,onCheck:()=>{s.host.engine.imessage("status.reset.check.enable",[t])},onUnCheck:()=>{s.host.engine.imessage("status.reset.check.disable",[t])},upgradeIndicator:n})}}class Wo extends N{constructor(e,t,i){const n=e.host.engine.i18n("option.time.reset");super(e,t,new S(e,t,n,{onCheck:a=>{e.host.engine.imessage("status.auto.enable",[n])},onUnCheck:a=>{e.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(e,{classes:[A.fillSpace]})]),{onRefreshRequest:()=>{this.expando.ineffective=t.enabled&&[this._bonfireUi,this._religionUi,this._resourcesUi,this._spaceUi,this._timeUi,this._upgradesUi].some(a=>a.expando.ineffective)}});u(this,"_bonfireUi");u(this,"_religionUi");u(this,"_resourcesUi");u(this,"_spaceUi");u(this,"_timeUi");u(this,"_upgradesUi");const r=new x(this,{hasDisableAll:!1,hasEnableAll:!1});this._bonfireUi=new Do(this,this.setting.bonfire,i),this._religionUi=new No(this,this.setting.religion,i),this._resourcesUi=new qo(this,this.setting.resources,i),this._spaceUi=new zo(this,this.setting.space,i),this._timeUi=new Fo(this,this.setting.time,i),this._upgradesUi=new Ho(this,this.setting.upgrades,i),r.addChildren([this._bonfireUi,this._religionUi,this._resourcesUi,this._spaceUi,this._timeUi,this._upgradesUi]),this.addChildContent(r)}}class Ps extends x{constructor(e,t,i){super(e,i);u(this,"setting");this.setting=t;const n=(a,o)=>{const l=e.host.engine.labelForCycle(a);return new S(e,o,l,{onCheck:h=>{var d;(d=i==null?void 0:i.onCheckCycle)==null||d.call(i,l,o,h)},onUnCheck:h=>{var d;(d=i==null?void 0:i.onUnCheckCycle)==null||d.call(i,l,o,h)}})},r=[n("charon",this.setting.charon),n("umbra",this.setting.umbra),n("yarn",this.setting.yarn),n("helios",this.setting.helios),n("cath",this.setting.cath),n("redmoon",this.setting.redmoon),n("dune",this.setting.dune),n("piscine",this.setting.piscine),n("terminus",this.setting.terminus),n("kairo",this.setting.kairo)];this.addChildren(r),this.element[0].addEventListener("enableAll",()=>{for(const a of r)a.check(!0)}),this.element[0].addEventListener("disableAll",()=>{for(const a of r)a.uncheck(!0)})}}class Ot extends x{constructor(e,t,i){super(e,i);u(this,"setting");u(this,"spring");u(this,"summer");u(this,"autumn");u(this,"winter");this.setting=t;const n=(r,a)=>new S(this,a,r,{onCheck:o=>{var l;(l=i==null?void 0:i.onCheckSeason)==null||l.call(i,r,a,o)},onUnCheck:o=>{var l;(l=i==null?void 0:i.onUnCheckSeason)==null||l.call(i,r,a,o)}});this.spring=n(this.host.engine.i18n("$calendar.season.spring"),this.setting.spring),this.summer=n(this.host.engine.i18n("$calendar.season.summer"),this.setting.summer),this.autumn=n(this.host.engine.i18n("$calendar.season.autumn"),this.setting.autumn),this.winter=n(this.host.engine.i18n("$calendar.season.winter"),this.setting.winter),this.addChildren([this.spring,this.summer,this.autumn,this.winter])}toString(){return`[${Ot.name}#${this.componentId}]`}}class Go extends N{constructor(s,e,t,i,n){const r=s.host.engine.i18n("option.time.activeHeatTransfer");super(s,e,new W(s,e,t,r,{onCheck:a=>{s.host.engine.imessage("status.auto.enable",[r])},onSetTrigger:async()=>{const a=await E.prompt(s,s.host.engine.i18n("ui.trigger.activeHeatTransfer.prompt"),s.host.engine.i18n("ui.trigger.activeHeatTransfer.promptTitle",[s.host.renderPercentage(e.trigger,t.selected,!0)]),s.host.renderPercentage(e.trigger),s.host.engine.i18n("ui.trigger.activeHeatTransfer.promptExplainer"));a===void 0||a===""||a.startsWith("-")||(e.trigger=s.host.parsePercentage(a))},onUnCheck:a=>{s.host.engine.imessage("status.auto.disable",[r]),e.activeHeatTransferStatus.enabled=!1}}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled,this.settingItem.triggerButton.ineffective=n.enabled&&i.enabled&&e.enabled&&e.trigger===-1,this.expando.ineffective=n.enabled&&i.enabled&&e.enabled&&!Object.values(e.cycles).some(a=>a.enabled),e.activeHeatTransferStatus.enabled?(this.head.elementLabel.attr("data-ks-active-from","◎"),this.head.elementLabel.attr("data-ks-active-to","◎"),this.head.elementLabel.addClass(Pt.active)):this.head.elementLabel.removeClass(Pt.active)}}),this.addChildContent(new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new Ps(this,this.setting.cycles,{onCheckCycle:a=>{this.host.engine.imessage("time.heatTransfer.cycle.enable",[a])},onUnCheckCycle:a=>{this.host.engine.imessage("time.heatTransfer.cycle.disable",[a])}})]))}}class Zo extends N{constructor(e,t,i,n){const r=e.host.engine.i18n("option.time.skip");super(e,t,new At(e,t,i,r,{onCheck:a=>{e.host.engine.imessage("status.auto.enable",[r])},onRefreshMax(){this.maxButton.updateLabel(e.host.renderAbsolute(t.max)),this.maxButton.element[0].title=t.max<0?e.host.engine.i18n("ui.max.timeSkip.titleInfinite",[r]):t.max===0?e.host.engine.i18n("ui.max.timeSkip.titleZero",[r]):e.host.engine.i18n("ui.max.timeSkip.title",[e.host.renderAbsolute(t.max),r])},onRefreshTrigger(){this.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger",[t.trigger<0?e.host.engine.i18n("ui.trigger.section.inactive"):`${e.host.renderFloat(t.trigger,i.selected)} TC`])},onSetMax:async()=>{const a=await E.prompt(e,e.host.engine.i18n("ui.max.timeSkip.prompt"),e.host.engine.i18n("ui.max.timeSkip.promptTitle",[e.host.renderAbsolute(t.max,i.selected)]),e.host.renderAbsolute(t.max),e.host.engine.i18n("ui.max.timeSkip.promptExplainer"));if(a!==void 0){if(a===""||a.startsWith("-")){t.max=-1;return}a==="0"&&(t.enabled=!1),t.max=e.host.parseAbsolute(a)??t.max}},onSetTrigger:async()=>{const a=await E.prompt(e,e.host.engine.i18n("ui.trigger.timeSkip.prompt"),e.host.engine.i18n("ui.trigger.timeSkip.promptTitle",[e.host.renderAbsolute(t.trigger,i.selected)]),e.host.renderAbsolute(t.trigger),e.host.engine.i18n("ui.trigger.timeSkip.promptExplainer"));a===void 0||a===""||a.startsWith("-")||(t.trigger=e.host.parseAbsolute(a)??t.trigger)},onUnCheck:a=>{e.host.engine.imessage("status.auto.disable",[r])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.maxButton.inactive=!t.enabled||t.max===-1,this.settingItem.triggerButton.inactive=!t.enabled||t.trigger===-1,this.settingItem.maxButton.ineffective=n.enabled&&t.enabled&&t.max===0,this._cycles.expando.ineffective=n.enabled&&t.enabled&&!Object.values(t.cycles).some(a=>a.enabled),this._seasons.expando.ineffective=n.enabled&&t.enabled&&!Object.values(t.seasons).some(a=>a.enabled)}});u(this,"_cycles");u(this,"_seasons");u(this,"_activeHeatTransferUI");this.settingItem.triggerButton.element.removeClass(C.lastHeadAction),this._cycles=new we(this,new ue(this,J(this.host.engine.i18n("ui.cycles")),{classes:[D.checked,D.setting],icon:P.Cycles}).addChildrenHead([new M(this,{classes:[A.fillSpace]})])).addChildrenContent([new Ps(this,this.setting.cycles,{onCheckCycle:a=>{this.host.engine.imessage("time.skip.cycle.enable",[a])},onUnCheckCycle:a=>{this.host.engine.imessage("time.skip.cycle.disable",[a])}})]),this._seasons=new we(this,new ue(this,J(this.host.engine.i18n("trade.seasons")),{classes:[D.checked,D.setting],icon:P.Seasons}).addChildrenHead([new M(this,{classes:[A.fillSpace]})])).addChildrenContent([new Ot(this,this.setting.seasons,{onCheckSeason:a=>{this.host.engine.imessage("time.skip.season.enable",[a])},onUnCheckSeason:a=>{this.host.engine.imessage("time.skip.season.disable",[a])}})]),this._activeHeatTransferUI=new Go(this,this.setting.activeHeatTransfer,i,t,n),this.addChildContent(new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([this._cycles,this._seasons,new S(this,this.setting.ignoreOverheat,this.host.engine.i18n("option.time.skip.ignoreOverheat")),this._activeHeatTransferUI]))}}class yi extends N{constructor(e,t,i){console.debug(...y(`Constructing ${yi.name}`));const n=e.host.engine.i18n("ui.timeCtrl");super(e,t,new S(e,t,n,{onCheck:o=>{e.host.engine.imessage("status.auto.enable",[n])},onUnCheck:o=>{e.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(e,{classes:[A.fillSpace]})]),{onRefreshRequest:()=>{this.expando.ineffective=t.enabled&&[this._timeSkipUi,this._resetUi].some(o=>o.expando.ineffective)}});u(this,"_items");u(this,"_accelerateTime");u(this,"_timeSkipUi");u(this,"_resetUi");const r=new x(this,{hasDisableAll:!1,hasEnableAll:!1}),a=this.host.engine.i18n("option.accelerate");this._accelerateTime=new W(this,this.setting.accelerateTime,i,a,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[a])},onRefresh:()=>{this._accelerateTime.triggerButton.inactive=!this.setting.accelerateTime.enabled,this._accelerateTime.triggerButton.ineffective=this.setting.enabled&&this.setting.accelerateTime.enabled&&this.setting.accelerateTime.trigger===-1},onSetTrigger:async()=>{const o=await E.prompt(this,this.host.engine.i18n("ui.trigger.accelerateTime.prompt"),this.host.engine.i18n("ui.trigger.accelerateTime.promptTitle",[this.host.renderPercentage(this.setting.accelerateTime.trigger,i.selected,!0)]),this.host.renderPercentage(this.setting.accelerateTime.trigger),this.host.engine.i18n("ui.trigger.accelerateTime.promptExplainer"));o===void 0||o===""||o.startsWith("-")||(this.setting.accelerateTime.trigger=this.host.parsePercentage(o))},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[a])}}),this._accelerateTime.triggerButton.element.addClass(C.lastHeadAction),this._timeSkipUi=new Zo(this,this.setting.timeSkip,i,t),this._resetUi=new Wo(this,this.setting.reset,i),this._items=[this._accelerateTime,this._timeSkipUi,this._resetUi],r.addChildren(this._items),this.addChildContent(r)}}class wi extends N{constructor(s,e,t){console.debug(...y(`Constructing ${wi.name}`));const i=s.host.engine.i18n("ui.time");super(s,e,new W(s,e,t,i,{onCheck:n=>{s.host.engine.imessage("status.auto.enable",[i])},onRefresh:()=>{this.settingItem.triggerButton.inactive=!e.enabled||e.trigger===-1},onRefreshTrigger(){this.triggerButton.element[0].title=s.host.engine.i18n("ui.trigger.section",[e.trigger<0?s.host.engine.i18n("ui.trigger.section.inactive"):s.host.renderPercentage(e.trigger,t.selected,!0)])},onSetTrigger:async()=>{const n=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.percentage"),s.host.engine.i18n("ui.trigger.section.prompt",[i,e.trigger!==-1?s.host.renderPercentage(e.trigger,t.selected,!0):s.host.engine.i18n("ui.infinity")]),e.trigger!==-1?s.host.renderPercentage(e.trigger):"",s.host.engine.i18n("ui.trigger.section.promptExplainer"));if(n!==void 0){if(n===""||n.startsWith("-")){e.trigger=-1;return}e.trigger=s.host.parsePercentage(n)}},onUnCheck:n=>{s.host.engine.imessage("status.auto.disable",[i])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled||e.trigger<0,this.settingItem.triggerButton.ineffective=e.enabled&&e.trigger<0&&Object.values(e.buildings).some(n=>n.enabled&&0<n.max&&n.trigger<0),this.expando.ineffective=e.enabled&&Object.values(e.buildings).some(n=>n.enabled&&(n.max===0||n.trigger<0&&e.trigger<0))}}),this.addChildrenContent([new x(this).addChildren([new q(this,this.host.engine.i18n("$workshop.chronoforge.label")),...this.host.game.time.chronoforgeUpgrades.filter(n=>!m(this.setting.buildings[n.name])).map(n=>{var r;return oe.getBuildOption(this,this.setting.buildings[n.name],t,this.setting,n.label,i,{delimiter:n.name===((r=this.host.game.time.chronoforgeUpgrades.at(-1))==null?void 0:r.name),renderLabelTrigger:!1})}),new q(this,this.host.engine.i18n("$science.voidSpace.label")),...this.host.game.time.voidspaceUpgrades.filter(n=>n.name in this.setting.buildings).map(n=>oe.getBuildOption(this,this.setting.buildings[n.name],t,this.setting,n.label,i,{renderLabelTrigger:!1}))]),new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new q(this,this.host.engine.i18n("ui.additional")),new S(this,this.setting.fixCryochambers,this.host.engine.i18n("option.fix.cry"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.fix.cry")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.fix.cry")])}})])])}}const Ko={buyButton:"_buyButton_10eul_1"};class ki extends ke{constructor(e,t,i,n){super(e,void 0,{onClick:async()=>{const r=await E.prompt(e,e.host.engine.i18n("blackcoin.buy.prompt"),e.host.engine.i18n("blackcoin.buy.promptTitle",[e.host.renderAbsolute(t.buy,i.selected)]),e.host.renderAbsolute(t.buy),e.host.engine.i18n("blackcoin.buy.promptExplainer"));if(r!==void 0){if(r===""||r.startsWith("-")){t.buy=-1;return}t.buy=e.host.parseAbsolute(r)??t.buy}},onRefresh:()=>{var r;this.element.prop("title",this.host.engine.i18n("blackcoin.buy.title",[this.host.renderAbsolute(this.setting.buy)])),this.element.text(this.host.engine.i18n("blackcoin.buy",[this.host.renderAbsolute(this.setting.buy)])),(r=n==null?void 0:n.onRefresh)==null||r.call(this)}});u(this,"setting");this.element.addClass(Ko.buyButton),this.setting=t}toString(){return`[${ki.name}#${this.componentId}]`}}const Vo={sellButton:"_sellButton_1tmvd_1"};class _i extends ke{constructor(e,t,i,n){super(e,void 0,{onClick:async()=>{const r=await E.prompt(e,e.host.engine.i18n("blackcoin.sell.prompt"),e.host.engine.i18n("blackcoin.sell.promptTitle",[e.host.renderAbsolute(t.sell,i.selected)]),e.host.renderAbsolute(t.sell),e.host.engine.i18n("blackcoin.sell.promptExplainer"));if(r!==void 0){if(r===""||r.startsWith("-")){t.sell=-1;return}t.sell=e.host.parseAbsolute(r)??t.sell}},onRefresh:()=>{var r;this.element.prop("title",this.host.engine.i18n("blackcoin.sell.title",[this.host.renderAbsolute(this.setting.sell)])),this.element.text(this.host.engine.i18n("blackcoin.sell",[this.host.renderAbsolute(this.setting.sell)])),(r=n==null?void 0:n.onRefresh)==null||r.call(n)}});u(this,"setting");this.element.addClass(Vo.sellButton),this.setting=t}toString(){return`[${_i.name}#${this.componentId}]`}}class Ut extends j{constructor(e,t,i){super(e,"",P.Eco,{border:!1,classes:[],onClick:()=>{var n,r;this.setting.limited=!this.setting.limited,this.setting.limited?(n=i==null?void 0:i.onLimitedCheck)==null||n.call(this):(r=i==null?void 0:i.onLimitedUnCheck)==null||r.call(this)},onRefresh:()=>{var n;this.updateTitle(this.host.engine.i18n(this.setting.limited?"ui.limited.on":"ui.limited.off")),this.setting.limited&&!this.inactive?this.element.removeClass(C.inactive):this.element.addClass(C.inactive),(n=i==null?void 0:i.onRefresh)==null||n.call(this)}});u(this,"setting");this.setting=t;for(const n of(i==null?void 0:i.classes)??[])this.element.addClass(n)}toString(){return`[${Ut.name}#${this.componentId}]`}}class Ci extends S{constructor(e,t,i,n){super(e,t,i,n);u(this,"limitedButton");this.limitedButton=new Ut(e,t,{border:!1,onLimitedCheck:n!=null&&n.onLimitedCheck?()=>{var r;return(r=n.onLimitedCheck)==null?void 0:r.call(this)}:void 0,onLimitedUnCheck:n!=null&&n.onLimitedUnCheck?()=>{var r;return(r=n.onLimitedUnCheck)==null?void 0:r.call(this)}:void 0}),this.addChildrenHead([new M(e,{classes:[A.fillSpace]}),this.limitedButton])}toString(){return`[${Ci.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class Si extends Ci{constructor(e,t,i,n,r){super(e,t,n,r);u(this,"triggerButton");this.triggerButton=new Te(e,t,i,{border:!1,onClick:async()=>{await r.onSetTrigger.call(this)},onRefresh:r!=null&&r.onRefreshTrigger?()=>{var a;return(a=r.onRefreshTrigger)==null?void 0:a.call(this)}:void 0,renderLabel:(r==null?void 0:r.renderLabelTrigger)??!0}),this.addChildHead(this.triggerButton)}toString(){return`[${Si.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class Dt extends S{constructor(e,t,i,n){super(e,t,i,n);u(this,"maxButton");this.maxButton=new Pe(e,t,{border:!1,onClick:async()=>{await n.onSetMax.call(this)},onRefresh:n!=null&&n.onRefreshMax?()=>{var r;return(r=n.onRefreshMax)==null?void 0:r.call(this)}:void 0}),this.addChildrenHead([new M(e,{classes:[A.fillSpace]}),this.maxButton])}toString(){return`[${Dt.name}#${this.componentId}]: '${this.elementLabel.text()}'`}}class jo extends N{constructor(s,e,t,i){const n=s.host.engine.i18n("option.embassies");super(s,e,new W(s,e,t,n,{onCheck:a=>{s.host.engine.imessage("status.auto.enable",[n])},onSetTrigger:async()=>{const a=await E.prompt(s,s.host.engine.i18n("ui.trigger.embassies.prompt"),s.host.engine.i18n("ui.trigger.embassies.promptTitle",[s.host.renderPercentage(e.trigger,t.selected,!0)]),s.host.renderPercentage(e.trigger),s.host.engine.i18n("ui.trigger.embassies.promptExplainer"));a===void 0||a===""||a.startsWith("-")||(e.trigger=s.host.parsePercentage(a))},onUnCheck:a=>{s.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled,this.settingItem.triggerButton.ineffective=e.enabled&&e.trigger===-1,this.expando.ineffective=i.enabled&&e.enabled&&!Object.values(e.races).some(a=>a.enabled)}});const r=new x(this).addChildren(this.host.game.diplomacy.races.filter(a=>a.name!=="leviathans"&&!m(this.setting.races[a.name])).map(a=>this._makeEmbassySetting(this,this.setting.races[a.name],t.selected,e,a.title)));this.addChildContent(r)}_makeEmbassySetting(s,e,t,i,n){const r=async()=>{const o=await E.prompt(s,s.host.engine.i18n("ui.max.prompt.absolute"),s.host.engine.i18n("ui.max.build.prompt",[n,s.host.renderAbsolute(e.max,t)]),s.host.renderAbsolute(e.max),s.host.engine.i18n("ui.max.build.promptExplainer"));if(o!==void 0){if(o===""||o.startsWith("-")){e.max=-1;return}o==="0"&&(e.enabled=!1),e.max=s.host.parseAbsolute(o)??e.max}},a=new Dt(s,e,n,{onCheck:o=>{if(s.host.engine.imessage("status.sub.enable",[n]),e.max===0&&!o)return r()},onRefresh:()=>{a.maxButton.inactive=!e.enabled||e.max===-1,a.maxButton.ineffective=i.enabled&&e.enabled&&e.max===0},onRefreshMax:()=>{a.maxButton.updateLabel(s.host.renderAbsolute(e.max)),a.maxButton.element[0].title=e.max<0?s.host.engine.i18n("ui.max.embassy.titleInfinite",[n]):e.max===0?s.host.engine.i18n("ui.max.embassy.titleZero",[n]):s.host.engine.i18n("ui.max.embassy.title",[s.host.renderAbsolute(e.max),n])},onSetMax:r,onUnCheck:()=>{s.host.engine.imessage("status.sub.disable",[n])}});return a.maxButton.element.addClass(C.lastHeadAction),a}}class xi extends N{constructor(e,t,i){console.debug(...y(`Constructing ${xi.name}`));const n=e.host.engine.i18n("ui.trade");super(e,t,new W(e,t,i,n,{onCheck:o=>{e.host.engine.imessage("status.auto.enable",[n])},onRefreshTrigger(){this.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger.section",[t.trigger<0?e.host.engine.i18n("ui.trigger.section.inactive"):e.host.renderPercentage(t.trigger,i.selected,!0)])},onSetTrigger:async()=>{const o=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.percentage"),e.host.engine.i18n("ui.trigger.section.prompt",[n,t.trigger!==-1?e.host.renderPercentage(t.trigger,i.selected,!0):e.host.engine.i18n("ui.infinity")]),t.trigger!==-1?e.host.renderPercentage(t.trigger):"",e.host.engine.i18n("ui.trigger.section.promptExplainer"));if(o!==void 0){if(o===""||o.startsWith("-")){t.trigger=-1;return}t.trigger=e.host.parsePercentage(o)}},onUnCheck:o=>{e.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!t.enabled||t.trigger===-1,this.settingItem.triggerButton.ineffective=t.enabled&&t.trigger<0&&Object.values(t.races).some(o=>o.enabled&&o.trigger<0),this.expando.ineffective=t.enabled&&Object.values(this._racePanels).some(o=>o.expando.ineffective||o.settingItem.triggerButton.ineffective)}});u(this,"_racePanels");this._racePanels=this.host.game.diplomacy.races.filter(o=>!m(this.setting.races[o.name])).map(o=>{var l;return this._getTradeOption(this,this.setting.races[o.name],i,t,o.title,n,o.name===((l=this.host.game.diplomacy.races.at(-2))==null?void 0:l.name))});const r=new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren(this._racePanels);r.addChild(new S(this,this.setting.feedLeviathans,this.host.engine.i18n("option.autofeed"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.autofeed")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.autofeed")])}})),r.addChild(new N(this,this.setting.tradeBlackcoin,new W(this,this.setting.tradeBlackcoin,i,this.host.engine.i18n("option.crypto"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.crypto")])},onRefreshRequest(){this.triggerButton.inactive=!this.setting.enabled||this.setting.trigger===-1},onSetTrigger:async()=>{const o=await E.prompt(this,this.host.engine.i18n("ui.trigger.crypto.promptTitle"),this.host.engine.i18n("ui.trigger.crypto.prompt",[this.host.renderAbsolute(this.setting.tradeBlackcoin.trigger,i.selected)]),this.host.renderAbsolute(this.setting.tradeBlackcoin.trigger),this.host.engine.i18n("ui.trigger.crypto.promptExplainer"));o===void 0||o===""||o.startsWith("-")||(this.setting.tradeBlackcoin.trigger=this.host.parseAbsolute(o)??this.setting.tradeBlackcoin.trigger)},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.crypto")])}})).addChildrenContent([new ki(this,this.setting.tradeBlackcoin,i),new _i(this,this.setting.tradeBlackcoin,i)])),this.addChildContent(r);const a=new x(this,{hasDisableAll:!1,hasEnableAll:!1});a.addChild(new q(this,this.host.engine.i18n("ui.additional"))),a.addChild(new jo(this,this.setting.buildEmbassies,i,t)),a.addChild(new S(this,this.setting.unlockRaces,this.host.engine.i18n("ui.upgrade.races"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("ui.upgrade.races")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("ui.upgrade.races")])}})),this.addChildContent(a)}_getTradeOption(e,t,i,n,r,a,o=!1,l=!1){const h=new Si(e,t,i,r,{delimiter:o,onCheck:()=>{e.host.engine.imessage("status.sub.enable",[r])},onLimitedCheck:()=>{e.host.engine.imessage("trade.limited",[r])},onLimitedUnCheck:()=>{e.host.engine.imessage("trade.unlimited",[r])},onRefreshTrigger:()=>{h.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger",[t.trigger<0?n.trigger<0?e.host.engine.i18n("ui.trigger.section.blocked",[a]):`${e.host.renderPercentage(n.trigger,i.selected,!0)} (${e.host.engine.i18n("ui.trigger.section.inherited")})`:e.host.renderPercentage(t.trigger,i.selected,!0)])},onSetTrigger:async()=>{const g=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.percentage"),e.host.engine.i18n("ui.trigger.section.prompt",[r,t.trigger!==-1?e.host.renderPercentage(t.trigger,i.selected,!0):e.host.engine.i18n("ui.trigger.section.inherited")]),t.trigger!==-1?e.host.renderPercentage(t.trigger):"",e.host.engine.i18n("ui.trigger.section.promptExplainer"));if(g!==void 0){if(g===""||g.startsWith("-")){t.trigger=-1;return}t.trigger=e.host.parsePercentage(g)}},onUnCheck:()=>{e.host.engine.imessage("status.sub.disable",[r])},renderLabelTrigger:!1,upgradeIndicator:l}),d=new N(e,t,h,{onRefreshRequest:()=>{h.limitedButton.inactive=!t.enabled||!t.limited,h.triggerButton.inactive=!t.enabled||t.trigger===-1,h.triggerButton.ineffective=n.enabled&&t.enabled&&n.trigger===-1&&t.trigger===-1,d.expando.ineffective=n.enabled&&t.enabled&&!t.seasons.autumn.enabled&&!t.seasons.spring.enabled&&!t.seasons.summer.enabled&&!t.seasons.winter.enabled}}).addChildContent(new Ot(e,t.seasons,{onCheckSeason:g=>{e.host.engine.imessage("trade.season.enable",[J(r),g])},onUnCheckSeason:g=>{e.host.engine.imessage("trade.season.disable",[J(r),g])}}));return d}}const Ti={spacer:"_spacer_auis8_44",ui:"_ui_auis8_49",showActivity:"_showActivity_auis8_66"};class Ei extends N{constructor(e,t,i){console.debug(...y(`Constructing ${Ei.name}`));const n=e.host.engine.i18n("ui.distribute");super(e,t,new S(e,t,n,{onCheck:o=>{e.host.engine.imessage("status.auto.enable",[n])},onUnCheck:o=>{e.host.engine.imessage("status.auto.disable",[n])}}).addChildrenHead([new M(e,{classes:[A.fillSpace]})]),{onRefreshRequest:()=>{this.expando.ineffective=t.enabled&&Object.values(t.jobs).some(o=>o.enabled&&o.max===0)}});u(this,"_hunt");u(this,"_festivals");u(this,"_promoteKittens");u(this,"_promoteLeader");u(this,"_electLeader");const r=new x(this).addChildren(this.host.game.village.jobs.filter(o=>!m(this.setting.jobs[o.name])).map(o=>this._getDistributeOption(this.setting.jobs[o.name],i.selected,t,o.title)));this.addChildContent(r);const a=new x(this,{hasDisableAll:!1,hasEnableAll:!1});a.addChild(new q(this,this.host.engine.i18n("ui.additional"))),this._hunt=new W(this,this.setting.hunt,i,this.host.engine.i18n("option.hunt"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.hunt")])},onRefreshRequest:()=>{this._hunt.triggerButton.inactive=!this.setting.hunt.enabled,this._hunt.triggerButton.ineffective=this.setting.enabled&&this.setting.hunt.enabled&&this.setting.hunt.trigger===-1},onSetTrigger:async()=>{const o=await E.prompt(this,this.host.engine.i18n("ui.trigger.prompt.percentage"),this.host.engine.i18n("ui.trigger.hunt.prompt",[this.host.renderPercentage(this.setting.hunt.trigger,i.selected,!0)]),this.host.renderPercentage(this.setting.hunt.trigger),this.host.engine.i18n("ui.trigger.hunt.promptExplainer"));o===void 0||o===""||o.startsWith("-")||(this.setting.hunt.trigger=this.host.parsePercentage(o))},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.hunt")])}}),this._hunt.triggerButton.element.addClass(C.lastHeadAction),a.addChild(this._hunt),this._festivals=new S(this,this.setting.holdFestivals,this.host.engine.i18n("option.festival"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.festival")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.festival")])}}),a.addChild(this._festivals),this._promoteKittens=new W(this,this.setting.promoteKittens,i,this.host.engine.i18n("option.promotekittens"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.promotekittens")])},onRefresh:()=>{this._promoteKittens.triggerButton.inactive=!this.setting.promoteKittens.enabled,this._promoteKittens.triggerButton.ineffective=this.setting.enabled&&this.setting.promoteKittens.enabled&&this.setting.promoteKittens.trigger===-1},onSetTrigger:async()=>{const o=await E.prompt(this,this.host.engine.i18n("ui.trigger.promoteKittens.promptTitle"),this.host.engine.i18n("ui.trigger.promoteKittens.prompt",[this.host.renderPercentage(this.setting.promoteKittens.trigger,i.selected,!0)]),this.host.renderPercentage(this.setting.promoteKittens.trigger),this.host.engine.i18n("ui.trigger.promoteKittens.promptExplainer"));o===void 0||o===""||o.startsWith("-")||(this.setting.promoteKittens.trigger=this.host.parsePercentage(o))},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.promotekittens")])}}),this._promoteKittens.triggerButton.element.addClass(C.lastHeadAction),a.addChild(this._promoteKittens),this._promoteLeader=new S(this,this.setting.promoteLeader,this.host.engine.i18n("option.promote"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.promote")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.promote")])}}),a.addChild(this._promoteLeader);for(const o of this.setting.electLeader.job.options)o.value==="any"?o.label=this.host.engine.i18n("option.elect.job.any"):o.label=this.host.engine.i18n(`$village.job.${o.value}`);for(const o of this.setting.electLeader.trait.options)o.label=this.host.engine.i18n(`$village.trait.${o.value}`);this._electLeader=new S(this,this.setting.electLeader,this.host.engine.i18n("option.elect"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.elect")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.elect")])}}).addChildren([new Be(this,this.host.engine.i18n("option.elect.job"),this.setting.electLeader.job),new Be(this,this.host.engine.i18n("option.elect.trait"),this.setting.electLeader.trait)]),a.addChild(this._electLeader),this.addChildContent(a)}_getDistributeOption(e,t,i,n,r=!1){const a=async()=>{const l=await E.prompt(this,this.host.engine.i18n("ui.max.distribute.prompt",[n]),this.host.engine.i18n("ui.max.distribute.promptTitle",[n,this.host.renderAbsolute(e.max,t)]),this.host.renderAbsolute(e.max),this.host.engine.i18n("ui.max.distribute.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.max=-1;return}l==="0"&&(e.enabled=!1),e.max=this.host.parseAbsolute(l)??e.max}},o=new Dt(this,e,n,{delimiter:r,onCheck:l=>{if(this.host.engine.imessage("status.sub.enable",[n]),e.max===0&&!l)return a()},onRefresh:()=>{o.maxButton.inactive=!e.enabled||e.max===-1,o.maxButton.ineffective=i.enabled&&e.enabled&&e.max===0},onRefreshMax:()=>{o.maxButton.updateLabel(this.host.renderAbsolute(e.max)),o.maxButton.element[0].title=e.max<0?this.host.engine.i18n("ui.max.distribute.titleInfinite",[n]):e.max===0?this.host.engine.i18n("ui.max.distribute.titleZero",[n]):this.host.engine.i18n("ui.max.distribute.title",[this.host.renderAbsolute(e.max),n])},onSetMax:a,onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[n])}});return o.maxButton.element.addClass(C.lastHeadAction),o}}class Ri extends S{constructor(e,t,i,n,r){super(e,t,n,r);u(this,"limitedButton");u(this,"maxButton");u(this,"triggerButton");this.limitedButton=new Ut(e,t,{...r,classes:[Tt.headAction]}),this.maxButton=new Pe(e,t,{alignment:"right",border:!1,classes:[C.headAction],onClick:()=>r.onSetMax.call(this),onRefresh:r!=null&&r.onRefreshMax?()=>{var a;return(a=r.onRefreshMax)==null?void 0:a.call(this)}:void 0}),this.triggerButton=new Te(e,t,i,{border:!1,classes:[C.lastHeadAction],onClick:async()=>{await r.onSetTrigger.call(this)},onRefresh:r!=null&&r.onRefreshTrigger?()=>{var a;return(a=r.onRefreshTrigger)==null?void 0:a.call(this)}:void 0,renderLabel:(r==null?void 0:r.renderLabelTrigger)??!0}),this.addChildrenHead([new M(e,{classes:[A.fillSpace]}),this.limitedButton,this.maxButton,this.triggerButton])}toString(){return`[${Ri.name}#${this.componentId}]`}}class Jo extends N{constructor(s,e,t){const i=s.host.engine.i18n("ui.upgrade.upgrades");super(s,e,new W(s,e,t,i,{onCheck:l=>{s.host.engine.imessage("status.auto.enable",[i])},onRefreshTrigger(){this.triggerButton.element[0].title=s.host.engine.i18n("ui.trigger",[e.trigger===-1?s.host.engine.i18n("ui.trigger.section.inactive"):s.host.renderPercentage(e.trigger,t.selected,!0)])},onSetTrigger:async()=>{const l=await E.prompt(s,s.host.engine.i18n("ui.trigger.prompt.percentage"),s.host.engine.i18n("ui.trigger.section.prompt",[i,e.trigger!==-1?s.host.renderPercentage(e.trigger,t.selected,!0):s.host.engine.i18n("ui.infinity")]),e.trigger!==-1?s.host.renderPercentage(e.trigger):"",s.host.engine.i18n("ui.trigger.section.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){e.trigger=-1;return}e.trigger=s.host.parsePercentage(l)}},onUnCheck:l=>{s.host.engine.imessage("status.auto.disable",[i])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!e.enabled||e.trigger===-1,this.settingItem.triggerButton.ineffective=e.enabled&&e.trigger<0&&Object.values(e.upgrades).some(l=>l.enabled&&l.trigger<0),this.expando.ineffective=e.enabled&&!Object.values(e.upgrades).some(l=>l.enabled)}});const n=this.host.game.workshop.upgrades.filter(l=>!m(this.setting.upgrades[l.name])),r=[];let a=n[0].label,o;for(const l of n.sort((h,d)=>h.label.localeCompare(d.label,t.selected))){const h=this.setting.upgrades[l.name],d=new W(this,h,t,l.label,{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[l.label])},onRefreshRequest:()=>{d.triggerButton.inactive=!h.enabled||h.trigger===-1,d.triggerButton.ineffective=e.enabled&&h.enabled&&e.trigger===-1&&h.trigger===-1},onRefreshTrigger:()=>{d.triggerButton.element[0].title=this.host.engine.i18n("ui.trigger",[h.trigger<0?e.trigger<0?this.host.engine.i18n("ui.trigger.build.blocked",[i]):`${this.host.renderPercentage(e.trigger,t.selected,!0)} (${this.host.engine.i18n("ui.trigger.section.inherited")})`:this.host.renderPercentage(h.trigger,t.selected,!0)])},onSetTrigger:async()=>{const g=await E.prompt(this,this.host.engine.i18n("ui.trigger.prompt.percentage"),this.host.engine.i18n("ui.trigger.section.prompt",[i,h.trigger!==-1?this.host.renderPercentage(h.trigger,t.selected,!0):this.host.engine.i18n("ui.trigger.section.inherited")]),h.trigger!==-1?this.host.renderPercentage(h.trigger):"",this.host.engine.i18n("ui.trigger.section.promptExplainer"));if(g!==void 0){if(g===""||g.startsWith("-")){h.trigger=-1;return}h.trigger=this.host.parsePercentage(g)}},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[l.label])},renderLabelTrigger:!1});d.triggerButton.element.addClass(C.lastHeadAction),this.host.engine.localeSupportsFirstLetterSplits(t.selected)&&a[0]!==l.label[0]&&(m(o)||o.element.addClass(ye.delimiter),d.element.addClass(A.splitter)),o=d,r.push(d),a=l.label}this.addChildContent(new x(this).addChildren(r))}}class Mi extends N{constructor(e,t,i){console.debug(...y(`Constructing ${Mi.name}`));const n=e.host.engine.i18n("ui.craft");super(e,t,new W(e,t,i,n,{onCheck:l=>{e.host.engine.imessage("status.auto.enable",[n])},onRefreshTrigger(){this.triggerButton.element[0].title=e.host.engine.i18n("ui.trigger.section",[t.trigger<0?e.host.engine.i18n("ui.trigger.section.inactive"):e.host.renderPercentage(t.trigger,i.selected,!0)])},onSetTrigger:async()=>{const l=await E.prompt(e,e.host.engine.i18n("ui.trigger.prompt.percentage"),e.host.engine.i18n("ui.trigger.section.prompt",[n,t.trigger!==-1?e.host.renderPercentage(t.trigger,i.selected,!0):e.host.engine.i18n("ui.infinity")]),t.trigger!==-1?e.host.renderPercentage(t.trigger):"",e.host.engine.i18n("ui.trigger.section.promptExplainer"));if(l!==void 0){if(l===""||l.startsWith("-")){t.trigger=-1;return}t.trigger=e.host.parsePercentage(l)}},onUnCheck:l=>{e.host.engine.imessage("status.auto.disable",[n])},renderLabelTrigger:!1}),{onRefreshRequest:()=>{this.settingItem.triggerButton.inactive=!t.enabled||t.trigger===-1,this.settingItem.triggerButton.ineffective=t.enabled&&t.trigger<0&&Object.values(t.resources).some(l=>l.enabled&&l.max!==0&&l.trigger<0)}});u(this,"_crafts");let r=[];game.challenges.getChallenge("ironWill").active||(this.setting.resources.bloodstone.enabled=!1,this.setting.resources.tMythril.enabled=!1,r=["bloodstone","tMythril"]);const a=this.host.game.workshop.crafts.filter(l=>!r.includes(l.name)&&!m(this.setting.resources[l.name])).map(l=>[this.setting.resources[l.name],J(l.label)]);this._crafts=[];for(const[l,h]of a){const d=async()=>{const f=await E.prompt(this,this.host.engine.i18n("ui.max.craft.prompt",[h]),this.host.engine.i18n("ui.max.craft.promptTitle",[h,this.host.renderAbsolute(l.max,i.selected)]),this.host.renderAbsolute(l.max),this.host.engine.i18n("ui.max.craft.promptExplainer"));if(f!==void 0){if(f===""||f.startsWith("-")){l.max=-1;return}f==="0"&&(l.enabled=!1),l.max=this.host.parseAbsolute(f)??l.max}},g=new Ri(this,l,i,h,{delimiter:l.resource==="kerosene"||l.resource==="blueprint",onCheck:f=>{if(this.host.engine.imessage("status.sub.enable",[h]),l.max===0&&!f)return d()},onLimitedCheck:()=>{this.host.engine.imessage("craft.limited",[h])},onLimitedUnCheck:()=>{this.host.engine.imessage("craft.unlimited",[h])},onRefreshMax:()=>{g.maxButton.updateLabel(this.host.renderAbsolute(l.max)),g.maxButton.element[0].title=l.max<0?this.host.engine.i18n("ui.max.craft.titleInfinite",[h]):l.max===0?this.host.engine.i18n("ui.max.craft.titleZero",[h]):this.host.engine.i18n("ui.max.craft.title",[this.host.renderAbsolute(l.max),h])},onRefreshRequest:()=>{g.limitedButton.inactive=!l.enabled||!l.limited,g.maxButton.inactive=!l.enabled||l.max===-1,g.maxButton.ineffective=t.enabled&&l.enabled&&l.max===0,g.triggerButton.inactive=!l.enabled||l.trigger===-1,g.triggerButton.ineffective=t.enabled&&l.enabled&&t.trigger===-1&&l.trigger===-1},onRefreshTrigger:()=>{g.triggerButton.element[0].title=this.host.engine.i18n("ui.trigger",[l.trigger<0?t.trigger<0?this.host.engine.i18n("ui.trigger.build.blocked",[h]):`${this.host.renderPercentage(t.trigger,i.selected,!0)} (${this.host.engine.i18n("ui.trigger.build.inherited")})`:this.host.renderPercentage(l.trigger,i.selected,!0)])},onSetMax:d,onSetTrigger:async()=>{const f=await E.prompt(this,this.host.engine.i18n("ui.trigger.prompt.percentage"),this.host.engine.i18n("ui.trigger.section.prompt",[h,l.trigger!==-1?this.host.renderPercentage(l.trigger,i.selected,!0):this.host.engine.i18n("ui.trigger.build.inherited")]),l.trigger!==-1?this.host.renderPercentage(l.trigger):"",this.host.engine.i18n("ui.trigger.build.promptExplainer"));if(f!==void 0){if(f===""||f.startsWith("-")){l.trigger=-1;return}l.trigger=this.host.parsePercentage(f)}},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[h])},renderLabelTrigger:!1});this._crafts.push(g),l.resource==="ship"&&this._crafts.push(new S(this,this.setting.shipOverride,this.host.engine.i18n("option.shipOverride"),{onCheck:()=>{this.host.engine.imessage("status.sub.enable",[this.host.engine.i18n("option.shipOverride")])},onUnCheck:()=>{this.host.engine.imessage("status.sub.disable",[this.host.engine.i18n("option.shipOverride")])},upgradeIndicator:!0}))}const o=new x(this,{onReset:()=>{this.setting.load({resources:new St().resources})}}).addChildren(this._crafts);this.addChildContent(o),this.addChildContent(new x(this,{hasDisableAll:!1,hasEnableAll:!1}).addChildren([new Jo(this,this.setting.unlockUpgrades,i)]))}}class $e extends G{constructor(e){console.debug(...y(`Constructing ${$e.name}`));super({host:e},{});u(this,"showActivity");u(this,"_engineUi");u(this,"_sections");u(this,"stateManagementUi");u(this,"_refreshTimeout");const t=e.engine;this._engineUi=new ca(this,t.settings),this.stateManagementUi=new vi(this,t.settings.states,t.settings.locale),this._sections=[new ii(this,t.bonfireManager.settings,t.settings.locale),new Ei(this,t.villageManager.settings,t.settings.locale),new gi(this,t.scienceManager.settings,t.settings.locale),new Mi(this,t.workshopManager.settings,t.settings.locale),new di(this,t.settings.resources,t.settings.locale),new xi(this,t.tradeManager.settings,t.settings.locale),new ci(this,t.religionManager.settings,t.settings.locale),new mi(this,t.spaceManager.settings,t.settings.locale),new wi(this,t.timeManager.settings,t.settings.locale),new yi(this,t.timeControlManager.settings,t.settings.locale),new li(this,t.settings.filters),this.stateManagementUi,new ri(this,t.settings,t.settings.locale)],this.parent=this,this.element=$("<div/>").addClass("kitten-scientists").addClass(Ti.ui);for(const h of[this._engineUi,...this._sections])this.addChild(h);const i=$("<ul/>");i.append(this._engineUi.element);for(const h of this._sections)i.append(h.element);this.element.append(i);const n=this._engineUi.expando;let r=!1;n.element.on("click",()=>{r=!r;for(const h of this._sections)h.toggle(r,!0)});let a=0;for(const h of this._sections)h.element[0].addEventListener("panelHidden",()=>{--a,a===0&&(r=!1),r||n.setCollapsed()}),h.element[0].addEventListener("panelShown",()=>{++a,r=!0,n.setExpanded()});this.showActivity=$("<span/>",{html:`<svg style="width: 18px; height: 18px;" viewBox="0 -960 960 960" fill="currentColor"><path d="${P.Summary}"/></svg>`,title:e.engine.i18n("summary.show")}).addClass(Ti.showActivity),this.showActivity.on("click",()=>{e.engine.displayActivitySummary()}),$("#clearLog").prepend(this.showActivity);const o=t.settings.ksColumn.enabled&&game.colorScheme!=="sleek";o?$("#rightColumn").after(`<div id="ksColumn" class="column"><span class="${Ti.spacer}"></span></div>`):$("#ksColumn").remove();const l=$(o?"#ksColumn":"#rightColumn");if(l.length===0){const h=$("#optionsPage .full-screen-position .page .page-content");h.length===0?console.warn(...y("Unable to find right column to inject UI into. Running headless.")):(h.append(this.element),this.element.attr("style","border-top:1px solid grey; padding:15px"))}else l.prepend(this.element);this.element=this.element,this._needsRefresh=!1}toString(){return`[${$e.name}#${this.componentId}]`}destroy(){this._refreshTimeout!==void 0&&(T.window.clearTimeout(this._refreshTimeout),this._refreshTimeout=void 0),this.showActivity.remove(),this.element.remove()}requestRefresh(e=!0,t=0,i=!1){if(this._needsRefresh){this._refreshTimeout===void 0&&console.error(...y("User interface claims to have a refresh pending, but there isn't."));return}this._refreshTimeout=T.window.setTimeout(()=>{const[n,r]=pe(()=>this.refresh());console.info(...y(`UI refresh took ${aa(r)}.`)),this._refreshTimeout=void 0},0),super.requestRefresh(!0,t,!1)}forceFullRefresh(){console.warn(...y("Forcing refresh on all user interface components...")),this.requestRefresh(),console.warn(...y("Refresh on all user interface components enforced."))}}const Le=(c="")=>{if(m("0.0.0-ci"))throw Error("Build error: RELEASE_VERSION is not defined.");return`${c}0.0.0-ci`};class de{constructor(s,e,t="en",i){u(this,"game");u(this,"i18nEngine");u(this,"_userInterface");u(this,"engine");u(this,"_gameBeforeSaveHandle");u(this,"_serverLoadHandle");u(this,"_saveManager",{load:s=>{console.info(...y("Looking for Kitten Scientists engine state in save data..."));const e=T.tryEngineStateFromSaveData("ks",s);if(!e){console.info(...y("The Kittens Game save data did not contain a script state."));return}console.info(...y("Found Kitten Scientists engine state in save data.")),this.engine.stateLoad(e),this.refreshEntireUserInterface()},resetState:()=>null,save:s=>{}});var n;console.info(...y(`Kitten Scientists ${Le("v")} constructed. Checking for previous instances...`)),"kittenScientists"in T.window&&(console.warn(...y("Detected existing KS instance. Trying to unload it...")),(n=T.window.kittenScientists)==null||n.unload()),console.info(...y("You are on the 'fixed' release channel.")),this.game=s,this.i18nEngine=e;try{this.engine=new re(this,t),this._userInterface=new $e(this)}catch(r){throw console.error(...y("Failed to construct core components.",r)),r}m(i)?this._userInterface.stateManagementUi.loadAutoSave():this.setSettings(i)}rebuildUi(){this._userInterface.destroy(),this._userInterface=new $e(this),this._userInterface.forceFullRefresh()}validateGame(){Qt.validateGame(this.game,this.engine.scienceManager.settings),Ct.validateGame(this.game,this.engine.spaceManager.settings),St.validateGame(this.game,this.engine.workshopManager.settings)}unload(){console.warn(...y("Unloading Kitten Scientists...")),this.engine.stop(),this._userInterface.destroy(),$("#ks-styles").remove(),this._gameBeforeSaveHandle!==void 0&&(T.window.dojo.unsubscribe(this._gameBeforeSaveHandle),this._gameBeforeSaveHandle=void 0),this._serverLoadHandle!==void 0&&(T.window.dojo.unsubscribe(this._serverLoadHandle),this._gameBeforeSaveHandle=void 0);const s=this.game.managers.indexOf(this._saveManager);-1<s&&this.game.managers.splice(s,1),T.window.kittenScientists=void 0,console.warn(...y("Kitten Scientists have been unloaded!"))}run(){this.refreshEntireUserInterface(),this.engine.settings.enabled&&this.engine.start(!0),this.engine.imessage("status.ks.init"),this.runUpdateCheck().catch(R(console)),this._gameBeforeSaveHandle!==void 0&&(T.window.dojo.unsubscribe(this._gameBeforeSaveHandle),this._gameBeforeSaveHandle=void 0),this._gameBeforeSaveHandle=T.window.dojo.subscribe("game/beforesave",s=>{console.info(...y("Injecting Kitten Scientists engine state into save data..."));const e=this.getSettings();s.ks={state:[e]},this._userInterface.stateManagementUi.storeAutoSave(e),document.dispatchEvent(new CustomEvent("ks.reportSavegame",{detail:s}))}),this._serverLoadHandle!==void 0&&(T.window.dojo.unsubscribe(this._serverLoadHandle),this._gameBeforeSaveHandle=void 0),this._serverLoadHandle=T.window.dojo.subscribe("server/load",s=>{const e=T.tryEngineStateFromSaveData("ks",s);if(!e){console.info(...y("The Kittens Game save data did not contain a script state. Trying to load Auto-Save settings..."));return}console.info(...y("Found! Loading settings...")),this.engine.stateLoad(e)})}async runUpdateCheck(){{console.debug(...y("No update check on 'fixed' release channel."));return}}refreshEntireUserInterface(){console.info(...y("Requesting entire user interface to be refreshed.")),this._userInterface.forceFullRefresh()}parseFloat(s){if(s===null||s==="")return null;const e=/[KMGTP]$/i.test(s),t=s.substring(0,s.length-(e?1:0));let i=s.includes("e")||e?Number.parseFloat(t):Number.parseInt(t);if(e){const n=s.substring(s.length-1).toUpperCase();i=i*1e3**["","K","M","G","T","P"].indexOf(n)}return(i===Number.POSITIVE_INFINITY||i<0)&&(i=-1),i}parseAbsolute(s){const e=this.parseFloat(s);return e!==null?Math.round(e):null}parsePercentage(s){const e=s.trim().replace(/%$/,"");return Math.max(0,Math.min(1,Number.parseFloat(e)/100))}renderAbsolute(s,e="invariant"){return s<0||s===Number.POSITIVE_INFINITY?"∞":e!=="invariant"&&Math.floor(Math.log10(s))<9?new Intl.NumberFormat(e,{maximumFractionDigits:0,style:"decimal"}).format(s):this.game.getDisplayValueExt(s,!1,!1)}renderPercentage(s,e="invariant",t){return s<0||s===Number.POSITIVE_INFINITY?"∞":e!=="invariant"?new Intl.NumberFormat(e,{style:"percent"}).format(s):`${this.game.getDisplayValueExt(s*100,!1,!1)}${t?"%":""}`}renderFloat(s,e="invariant"){return s<0||s===Number.POSITIVE_INFINITY?"∞":e!=="invariant"?new Intl.NumberFormat(e,{style:"decimal"}).format(s):this.game.getDisplayValueExt(s,!1,!1)}static encodeSettings(s,e=!0){const t=JSON.stringify(s);return e?T.window.LZString.compressToBase64(t):t}static decodeSettings(s){try{const i=JSON.parse(s);return de.unknownAsEngineStateOrThrow(i)}catch{}if(s.match(/\r?\n/))throw new ft("Multi-line non-JSON input can't be decoded.");const e=T.window.LZString.decompressFromBase64(s),t=JSON.parse(e);return de.unknownAsEngineStateOrThrow(t)}getSettings(){return this.engine.stateSerialize()}getSettingsAsJson(){return JSON.stringify(this.getSettings())}setSettings(s){console.info(...y("Loading engine state..."));const e=this.engine.settings.ksColumn.enabled!==s.engine.ksColumn.enabled;this.engine.stateLoad(s),e&&this.rebuildUi(),this._userInterface.refresh(!0)}importSettingsFromString(s){const e=de.decodeSettings(s);this.setSettings(e)}async copySettings(s=this.getSettings(),e=!0){const t=de.encodeSettings(s,e);await T.window.navigator.clipboard.writeText(t)}static unknownAsEngineStateOrThrow(s){const e=s.v;if(!m(e)&&typeof e=="string"&&e.startsWith("2"))return s;throw new Error("Not a valid engine state.")}installSaveManager(){console.info(...y("Installing save game manager...")),this.game.managers.push(this._saveManager)}}const Bs=async()=>{const c=await new T().waitForGame(de,"ks");T.window.kittenScientists=c,c.validateGame(),c.run()};(typeof GM>"u"||((Is=GM==null?void 0:GM.info)==null?void 0:Is.scriptHandler)==="Tampermonkey")&&Bs().catch(R(console)),U.main=Bs,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
43
+ (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.id="ks-styles",t.appendChild(document.createTextNode('._label_1nlev_1{align-content:center;display:inline-block;flex:0 1 fit-content;opacity:.8;white-space:nowrap;transition:.3s}._label_1nlev_1:hover{opacity:1}._splitter_1nlev_16 ._label_1nlev_1:first-letter{font-weight:700}._iconLabel_1nlev_20{display:inline-block;margin-right:4px;margin-left:2px;vertical-align:middle}._fillSpace_1nlev_26{flex:1}._delimiter_16hnh_1{margin-bottom:10px}._head_wr1pj_1{display:flex;align-items:stretch;flex-direction:row;justify-content:flex-start;width:100%;transition:.3s}._head_wr1pj_1>._headFlexItem_wr1pj_10{flex:1;margin-right:8px}._setting_1ndg5_1{border-bottom:1px solid transparent;transition:border-bottom .3s}._setting_1ndg5_1 ._checkbox_1ndg5_6{margin:1px 5px 2px 2px}._setting_1ndg5_1 ._panelContent_1ndg5_10{border-left:1px dashed grey;padding-left:16px;margin-left:8px;margin-top:1px;opacity:.5}._setting_1ndg5_1 ._panelContent_1ndg5_10._hidden_1ndg5_17{display:none}._setting_1ndg5_1._checked_1ndg5_22>._panelContent_1ndg5_10{opacity:1}._setting_1ndg5_1._expanded_1ndg5_26{margin-bottom:10px}._setting_1ndg5_1:not(._expanded_1ndg5_26):hover{border-bottom:1px dashed rgba(160,160,160,.2)}._setting_1ndg5_1._readonly_1ndg5_34{cursor:default;pointer-events:none}@keyframes _hail-rainbow_q7zpt_1{0%,to{color:red;text-shadow:0 0 10px red}33%{color:#888;text-shadow:0 0 10px yellow}66%{color:#fff;text-shadow:0 0 10px black}}._iconButton_q7zpt_17{cursor:pointer;display:block;padding-right:3px;line-height:0;opacity:.8;transition:.3s}._iconButton_q7zpt_17:hover{opacity:1}._iconButton_q7zpt_17._inactive_q7zpt_29{opacity:.4}._iconButton_q7zpt_17._inactive_q7zpt_29:hover{opacity:.6}._iconButton_q7zpt_17._ineffective_q7zpt_37{color:red;animation:_hail-rainbow_q7zpt_1 5s linear infinite}._button_q7zpt_43{align-items:end;cursor:pointer;display:flex;opacity:.8;transition:.3s}._button_q7zpt_43:hover{opacity:1}._button_q7zpt_43._inactive_q7zpt_29{opacity:.4}._button_q7zpt_43._inactive_q7zpt_29:hover{opacity:.6}._button_q7zpt_43._ineffective_q7zpt_37{color:red;animation:_hail-rainbow_q7zpt_1 5s linear infinite}._button_q7zpt_43._readonly_q7zpt_67{cursor:default;pointer-events:none}._button_q7zpt_43 ._buttonIcon_q7zpt_72{margin:0 2px 0 0;vertical-align:sub}._button_q7zpt_43._alignRight_q7zpt_77{justify-content:end}._button_q7zpt_43._large_q7zpt_81{padding:5px 10px}._button_q7zpt_43._bordered_q7zpt_85{border:1px solid rgba(180,180,180,.2)}._button_q7zpt_43._bordered_q7zpt_85:not(._large_q7zpt_81){padding:0 2px}._button_q7zpt_43._bordered_q7zpt_85:hover{border:1px solid rgba(180,180,180,1)}._button_q7zpt_43._headAction_q7zpt_97{min-width:50px}._button_q7zpt_43._lastHeadAction_q7zpt_100{padding-right:20px}._button_q7zpt_43._consumeButton_q7zpt_104,._button_q7zpt_43._stockButton_q7zpt_107{border:1px solid transparent}._button_q7zpt_43:not(._bordered_q7zpt_85)+._button_q7zpt_43:not(._bordered_q7zpt_85):before{content:"";display:inline-block;height:1em;border-left:1px solid transparent}._button_q7zpt_43:not(._bordered_q7zpt_85):not(._inactive_q7zpt_29)._alignRight_q7zpt_77+._button_q7zpt_43:not(._bordered_q7zpt_85):not(._inactive_q7zpt_29):before{content:"";display:inline-block;height:1em;border-left:1px solid rgba(180,180,180,.4)}._listContainer_1kxbq_1{margin-bottom:4px}._itemsList_1kxbq_5{-webkit-user-select:none;user-select:none}._list_1kxbq_1~._listTools_1kxbq_9{border-top:1px dotted rgba(128,128,128,.3);margin-left:0;padding-top:2px}._list_1kxbq_1~._listTools_1kxbq_9 *{display:inline-block}._expandoButton_l1ukp_1:not(._expanded_l1ukp_1) ._up_l1ukp_1{display:none}._expandoButton_l1ukp_1:not(._expanded_l1ukp_1) ._down_l1ukp_4{opacity:.6}._expandoButton_l1ukp_1:not(._expanded_l1ukp_1) ._down_l1ukp_4:hover{opacity:1}._expandoButton_l1ukp_1._expanded_l1ukp_1 ._down_l1ukp_4{display:none}#gamePageContainer .dialog.help._dialog_b4vj0_1{display:flex;flex-direction:column;height:fit-content!important;box-shadow:none!important}#gamePageContainer .dialog.help._dialog_b4vj0_1 ._close_b4vj0_7{position:absolute;top:10px;right:15px}._explainer_1idu3_1{color:#888;display:inline-block;min-width:100px;-webkit-user-select:none;user-select:none;padding:4px;white-space:break-spaces}._explainer_1idu3_1 p{margin:0}._header_19ql8_1{display:block;margin-bottom:3px;min-width:100px;border-bottom:1px dashed rgba(255,255,255,.1);font-weight:700;-webkit-user-select:none;user-select:none}._toolbar_1654f_1{display:flex;flex-direction:row;padding:0 0 2px;margin:0 0 3px}._toolbar_1654f_1>*{margin:0 3px 0 0}._maxButton_133h2_1{padding-right:5px;padding-top:2px}._fieldset_tfwil_1{border-bottom:none;border-right:none;border-top:none}._textButton_1mv97_1{display:inline-block;white-space:nowrap;opacity:.8;cursor:pointer;-webkit-user-select:none;user-select:none}._textButton_1mv97_1:hover{opacity:1}@keyframes _scale_6c09s_1{0%{scale:.5;opacity:0}50%{scale:1;opacity:1}to{scale:2;opacity:0}}._active_6c09s_16{text-shadow:rgba(128,128,128,.8) 0 0 15px;position:relative}._active_6c09s_16:after,._active_6c09s_16:before{display:inline-block;width:1em;height:100%;position:absolute;right:-1.5em;scale:0;text-align:center;transform-origin:center}._active_6c09s_16:after{content:attr(data-ks-active-from);animation:_scale_6c09s_1 8s linear infinite}._active_6c09s_16:before{content:attr(data-ks-active-to);animation:_scale_6c09s_1 8s linear infinite;animation-delay:4s}._buyButton_10eul_1,._sellButton_1tmvd_1{display:inline-block;padding-right:10px;min-width:86px}#ksColumn{min-width:250px;max-width:440px;vertical-align:top;padding-left:8px;top:20px;position:relative;overflow-y:auto}#footerLinks{display:flex;flex-direction:column;position:fixed;text-align:right;line-height:0;right:-5px!important;margin-bottom:1em}#footerLinks a{line-height:1;padding-right:10px;opacity:.5;transition:.3s;text-decoration:none;text-transform:lowercase}#footerLinks a:hover{opacity:1}#crowdjet-expand-container{position:fixed!important;bottom:10px!important;right:-10px!important;opacity:.5}#crowdjet-expand-container:hover{opacity:1}._spacer_auis8_44{display:block;margin-bottom:100px}._ui_auis8_49{margin:5px 0 10px;padding-right:10px}._ui_auis8_49 ul{list-style:none;margin:0;padding:0}._ui_auis8_49 #_toggle-list-resources_auis8_1 ._stockWarn_auis8_60 *,._ui_auis8_49 #_toggle-reset-list-resources_auis8_1 ._stockWarn_auis8_60 *{color:#dd1e00}._showActivity_auis8_66{cursor:pointer;display:inline-block;vertical-align:middle}#game #rightColumn{overflow-y:auto}#game #rightColumn #rightTabLog{overflow-y:visible}#game #rightColumn #rightTabLog #gameLog{height:auto;min-height:auto;overflow-y:visible}#game .res-row .res-cell.ks-stock-above{color:green}#game .res-row .res-cell.ks-stock-below{color:red}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();