code:
// @ts-nocheck
App.UI.incubator = function() {
	V.nextButton = "Back to Main";
	V.nextLink = "Main";
	V.returnTo = "Incubator";
	V.encyclopedia = "The Incubation Facility";
	V.readySlave = 0;
	const tankMultiplier = [1, 5, 10, 20, 100, 500];

	const el = new DocumentFragment();
	let childrenReserved;
	const incubatorNameCaps = capFirstChar(V.incubator.name);

	const introDiv = App.UI.DOM.appendNewElement("div", el, intro());

	const showPC = (V.PC.pregKnown === 1
		&& (V.arcologies[0].FSRestart === "unset"
			|| V.eugenicsFullControl === 1
			|| (V.PC.pregSource !== -1 && V.PC.pregSource !== -6)
		));
	const mothersContent = App.UI.DOM.makeElement('span', mothers());
	const pcContent = App.UI.DOM.makeElement('span', PC());
	const tanksContent = App.UI.DOM.makeElement('span', tankBabies());
	const settingsContent = App.UI.DOM.makeElement('span', tankSettings());

	const tabBar = new App.UI.Tabs.TabBar("Incubator");
	tabBar.addTab("Mothers", "mothers", mothersContent);
	if (showPC) {
		tabBar.addTab("You", "pc", pcContent);
	}
	tabBar.addTab("Tanks", "tanks", tanksContent);
	tabBar.addTab("Settings", "settings", settingsContent);
	el.append(tabBar.render());

	introDiv.after(release()); // run me late.

	return el;

	/**
	 * @returns {DocumentFragment}
	 */
	function intro() {
		const el = new DocumentFragment();
		let r = [];
		let tankBulkOptions = [];
		let price;
		const incubatorSlaves = V.incubator.tanks.length;
		const freeTanks = V.incubator.capacity - incubatorSlaves;
		const reservedChildren = FetusGlobalReserveCount("incubator");
		r.push(`${incubatorNameCaps} is a clean, cold hall designed to be lined with tanks and their connected monitoring systems.`);

		if (incubatorSlaves > 2) {
			r.push(`It's well used. The hum of active tanks fills the air.`);
		} else if (incubatorSlaves > 0) {
			r.push(`It's barely used; most of the tanks lie dormant.`);
		} else {
			r.push(`It's empty and quiet.`);
			r.push(
				choice(
					"Decommission the incubator",
					() => {
						App.Facilities.Incubator.init('base');
					},
					"Main"
				)
			);
		}
		App.Events.addNode(el, r, "p");

		const tankP = document.createElement("p");
		r = [];
		r.push(`It can support ${V.incubator.capacity} child${(V.incubator.capacity > 1) ? "ren" : ""} as they age.`);
		if (incubatorSlaves === 1) {
			r.push(`There is currently 1 tank`);
		} else {
			r.push(`There are currently ${incubatorSlaves} tanks`);
		}
		r.push(`in use in ${V.incubator.name}.`);
		App.Events.addNode(tankP, r, "div");

		for (const multiplier of tankMultiplier) {
			const price = Math.trunc((60000 * multiplier) * V.upgradeMultiplierArcology);
			tankBulkOptions.push(
				App.UI.DOM.link(
					`x${multiplier}`,
					() => {
						cashX(-price, "capEx");
						V.incubator.capacity += multiplier;
					},
					[], passage()
				)
			);
		}
		price = Math.trunc(60000 * V.upgradeMultiplierArcology);
		App.UI.DOM.appendNewElement("div", tankP, `Adding a tank costs ${cashFormat(price)} and will increase upkeep. `).append(App.UI.DOM.generateLinksStrip(tankBulkOptions));

		const empty = freeTanks - reservedChildren;
		if (empty > 0) {
			tankBulkOptions = [];
			for (const multiplier of tankMultiplier) {
				const price = Math.trunc((10000 * multiplier) * V.upgradeMultiplierArcology);
				if (empty >= multiplier && V.incubator.capacity - multiplier > 0) {
					tankBulkOptions.push(
						App.UI.DOM.link(
							`x${multiplier}`,
							() => {
								cashX(-price, "capEx");
								V.incubator.capacity -= multiplier;
							},
							[], passage()
						)
					);
				}
			}
			price = Math.trunc(10000 * V.upgradeMultiplierArcology);
			App.UI.DOM.appendNewElement("div", tankP, `Currently ${empty} tanks are empty.${(V.incubator.capacity !== 1) ? ` Removing a tank costs ${cashFormat(price)} and will reduce upkeep.` : ``} `).append(App.UI.DOM.generateLinksStrip(tankBulkOptions));
		}

		if (freeTanks === 0) {
			tankP.append(`All of the tanks are currently occupied by growing children.`);
		}

		el.append(tankP);

		return el;
	}

	function mothers() {
		const el = new DocumentFragment();
		let r = [];
		let eligibility = 0;
		let linkArray;
		const reservedChildren = FetusGlobalReserveCount("incubator");
		const incubatorSlaves = V.incubator.tanks.length;
		const freeTanks = V.incubator.capacity - incubatorSlaves;
		r.push(`Reserve an eligible mother-to-be's child to be placed in a tank upon birth. Of ${V.incubator.capacity} tanks, ${freeTanks}`);
		if (freeTanks === 1) {
			r.push(`is`);
		} else {
			r.push(`are`);
		}
		r.push(`unoccupied. Of those, ${reservedChildren}`);
		if (reservedChildren === 1) {
			r.push(`tank is`);
		} else {
			r.push(`tanks are`);
		}
		r.push(`reserved.`);
		App.Events.addNode(el, r, "div");

		const sortingOptions = new Map([
			["Name", "data-name"],
			["Reserved Incubator Spots", "data-reserved-spots"],
			["Pregnancy Week", "data-preg-week"],
			["Number of Children", "data-preg-count"],
		]);

		if (V.slaves.length > 0) {
			/**
			 * @param {Map<string, string>} sortingOptions
			 */
			const sortingBarFunc = function(sortingOptions) {
				const el = new DocumentFragment();
				App.UI.DOM.appendNewElement("span", el, "Sorting: ", "note");
				const linkArray = [];
				for (const [title, attr] of sortingOptions) {
					if (V.sortIncubatorList === title) {
						linkArray.push(App.UI.DOM.makeElement("span", title, "bold"));
					} else {
						linkArray.push(
							App.UI.DOM.link(
								title,
								() => {
									V.sortIncubatorList = title;
									sortBy(attr);
									jQuery(sortingBar).empty().append(sortingBarFunc(sortingOptions));
								}
							)
						);
					}
				}
				el.append(App.UI.DOM.generateLinksStrip(linkArray));
				return el;
			};

			const sortingBar = document.createElement("div");
			sortingBar.classList.add("incubator-underscore");

			V.sortIncubatorList = V.sortIncubatorList || 'Unsorted';
			sortingBar.append(sortingBarFunc(sortingOptions));
			el.append(sortingBar);
		}

		const qlIncubator = document.createElement("div");
		for (const slave of V.slaves) {
			if (slave.preg > 0 && slave.pregKnown === 1 && slave.eggType === "human") {
				const r = [];
				const reserveDisallowed = (slave.assignment === "work in the dairy" && V.dairyPregSetting > 0) || slave.assignment === "be your agent" || slave.assignment === "live with your agent";
				if (!reserveDisallowed) {
					const {
						His, his
					} = getPronouns(slave);
					const freeTanks = V.incubator.capacity - incubatorSlaves;
					const WL = slave.womb.length;
					const reservedIncubator = WombReserveCount(slave, "incubator");
					const reservedNursery = WombReserveCount(slave, "nursery");
					const momEl = document.createElement("p");
					momEl.id = "slave-" + slave.ID;
					momEl.classList.add("possible");

					momEl.setAttribute("data-preg-count", slave.womb.length.toString());
					momEl.setAttribute("data-reserved-spots", reservedIncubator.toString());
					momEl.setAttribute("data-preg-week", slave.pregWeek.toString());
					momEl.setAttribute("data-name", SlaveFullName(slave));

					linkArray = [];
					const choices = document.createElement("div");
					choices.classList.add("choices");
					r.push(App.UI.DOM.slaveDescriptionDialog(slave));
					r.push(`is ${slave.pregWeek} ${(slave.pregWeek === 1) ? `week` : `weeks`} pregnant with`);
					if (slave.pregSource === 0 || slave.preg <= 5) {
						r.push(`someone's${(slave.preg <= 5) ? `, though it is too early to tell whose,` : ``}`);
					} else if (slave.pregSource === -1) {
						r.push(`your`);
					} else if (slave.pregSource === -2) {
						r.push(`a citizen's`);
					} else if (slave.pregSource === -3) {
						r.push(`your Master's`);
					} else if (slave.pregSource === -4) {
						r.push(`another arcology owner's`);
					} else if (slave.pregSource === -5) {
						r.push(`your client's`);
					} else if (slave.pregSource === -6) {
						r.push(`the Societal Elite's`);
					} else if (slave.pregSource === -7) {
						r.push(`the lab's`);
					} else if (slave.pregSource === -9) {
						r.push(`the Futanari Sisters'`);
					} else {
						const father = getSlave(slave.pregSource);
						if (father) {
							r.push(`${father.slaveName}'s`);
						} else if (WL === 1) {
							r.push("a");
						}
					}
					if (WL > 1) {
						r.push(`${WL} babies.`);
					} else {
						r.push(`baby.`);
					}
					if (reservedIncubator > 0) {
						childrenReserved = 1;
						if (WL === 1) {
							r.push(`${His} child`);
						} else if (reservedIncubator < WL) {
							r.push(`${reservedIncubator} of ${his} children`);
						} else if (WL === 2) {
							r.push(`Both of ${his} children`);
						} else {
							r.push(`All ${reservedIncubator} of ${his} children`);
						}
						r.push(`will be placed in ${V.incubator.name}.`);
						if ((reservedIncubator + reservedNursery < WL) && (reservedChildren < freeTanks)) {
							if (V.pregnancyMonitoringUpgrade === 1) {
								linkArray.push(
									App.UI.DOM.link(
										`Inspect pregnancy`,
										() => {
											V.AS = slave.ID;
										},
										[],
										`Analyze Pregnancy`
									)
								);
							}
							linkArray.push(
								App.UI.DOM.link(
									`Keep another child`,
									() => {
										WombAddToGenericReserve(slave, 'incubator', 1);
										refresh();
									}
								)
							);
							if (reservedIncubator > 0) {
								linkArray.push(
									App.UI.DOM.link(
										`Keep one less child`,
										() => {
											WombCleanGenericReserve(slave, 'incubator', 1);
											refresh();
										}
									)
								);
							}
							if (reservedIncubator > 1) {
								linkArray.push(
									App.UI.DOM.link(
										`Keep none of ${his} children`,
										() => {
											WombCleanGenericReserve(slave, 'incubator', 9999);
											refresh();
										}
									)
								);
							}
							if ((reservedChildren + WL - reservedIncubator) <= freeTanks) {
								linkArray.push(
									App.UI.DOM.link(
										`Keep the rest of ${his} children`,
										() => {
											WombAddToGenericReserve(slave, 'incubator', 9999);
											refresh();
										}
									)
								);
							}
						} else if ((reservedIncubator === WL) || (reservedChildren === freeTanks) || (reservedIncubator + reservedNursery === WL)) {
							if (V.pregnancyMonitoringUpgrade === 1) {
								linkArray.push(
									App.UI.DOM.link(
										`Inspect pregnancy`,
										() => {
											V.AS = slave.ID;
										},
										[],
										`Analyze Pregnancy`
									)
								);
							}
							linkArray.push(
								App.UI.DOM.link(
									`Keep one less child`,
									() => {
										WombCleanGenericReserve(slave, 'incubator', 1);
										refresh();
									}
								)
							);
							if (reservedIncubator > 1) {
								linkArray.push(
									App.UI.DOM.link(
										`Keep none of ${his} children`,
										() => {
											WombCleanGenericReserve(slave, 'incubator', 9999);
											refresh();
										}
									)
								);
							}
						}
					} else if (reservedChildren < freeTanks) {
						if (WL - reservedNursery === 0) {
							r.push(App.UI.DOM.makeElement("span", `${His} children are already reserved for ${V.nurseryName}`, "note"));
							if (V.pregnancyMonitoringUpgrade === 1) {
								linkArray.push(
									App.UI.DOM.link(
										`Inspect pregnancy`,
										() => {
											V.AS = slave.ID;
										},
										[],
										`Analyze Pregnancy`
									)
								);
							}
							linkArray.push(
								App.UI.DOM.link(
									`Keep ${his} ${((WL > 1) ? "children" : "child")} here instead`,
									() => {
										WombChangeReserveType(slave, 'nursery', 'incubator');
										refresh();
									}
								)
							);
						} else {
							r.push(`You have`);
							if (freeTanks === 1) {
								r.push(`an <span class="lime"> available aging tank.</span>`);
							} else {
								r.push(`<span class="lime"> available aging tanks.</span>`);
							}
							if (V.pregnancyMonitoringUpgrade === 1) {
								if (V.pregnancyMonitoringUpgrade === 1) {
									linkArray.push(
										App.UI.DOM.link(
											`Inspect pregnancy`,
											() => {
												V.AS = slave.ID;
											},
											[],
											`Analyze Pregnancy`
										)
									);
								}
							}
							linkArray.push(
								App.UI.DOM.link(
									`Keep ${(WL > 1) ? "a" : "the"} child`,
									() => {
										WombAddToGenericReserve(slave, 'incubator', 1);
										refresh();
									}
								)
							);
							if ((WL > 1) && (reservedChildren + WL - reservedIncubator) <= freeTanks) {
								linkArray.push(
									App.UI.DOM.link(
										`Keep all of ${his} children`,
										() => {
											WombAddToGenericReserve(slave, 'incubator', 9999);
											refresh();
										}
									)
								);
							}
						}
					} else if (reservedChildren === freeTanks) {
						if (V.pregnancyMonitoringUpgrade === 1) {
							linkArray.push(
								App.UI.DOM.link(
									`Inspect pregnancy`,
									() => {
										V.AS = slave.ID;
									},
									[],
									`Analyze Pregnancy`
								)
							);
						}
						const noRoom = new DocumentFragment();
						noRoom.append(`You have `);
						App.UI.DOM.appendNewElement("span", noRoom, `no room for ${his} offspring.`, "red");
						linkArray.push(noRoom);
					}
					eligibility = 1;

					App.Events.addNode(momEl, r, "div");
					choices.append(App.UI.DOM.generateLinksStrip(linkArray));
					momEl.append(choices);
					qlIncubator.append(momEl);
				}
			}
		}
		sortByPreviousSort();
		el.append(qlIncubator);
		if (eligibility === 0) {
			App.UI.DOM.appendNewElement("div", el, `You have no pregnant slaves bearing eligible children.`, "note");
		}

		if (reservedChildren !== 0 || childrenReserved === 1) { // the oops I made it go negative somehow button
			App.UI.DOM.appendNewElement(
				"div",
				el,
				App.UI.DOM.link(
					"Clear all reserved children",
					() => {
						for (const slave of V.slaves) {
							if (WombReserveCount(slave, "incubator") !== 0) {
								WombCleanGenericReserve(slave, 'incubator', 9999);
							}
						}
						WombCleanGenericReserve(V.PC, 'incubator', 9999);
						refresh();
					}
				)
			);
		}
		return el;

		function refresh() {
			jQuery(mothersContent).empty().append(mothers());
			jQuery(introDiv).empty().append(intro());
			jQuery(tanksContent).empty().append(tankBabies());
		}

		function sortBy(attrName) {
			let sortedIncubatorPossibles = $(qlIncubator).children('p.possible').detach();
			sortedIncubatorPossibles = sortDomObjects(sortedIncubatorPossibles, attrName);
			$(sortedIncubatorPossibles).appendTo(qlIncubator);
		}

		function sortByPreviousSort() {
			const sortAttr = sortingOptions.get(V.sortIncubatorList);
			if (sortAttr) {
				sortBy(sortAttr);
			}
		}
	}

	function PC() {
		const el = new DocumentFragment();
		if (!showPC) {
			return el;
		}

		let r = [];
		let linkArray = [];
		const reservedChildren = FetusGlobalReserveCount("incubator");
		const incubatorSlaves = V.incubator.tanks.length;
		const freeTanks = V.incubator.capacity - incubatorSlaves;
		const WL = V.PC.womb.length;
		const reservedIncubator = WombReserveCount(V.PC, "incubator");
		const reservedNursery = WombReserveCount(V.PC, "nursery");
		r.push(App.UI.DOM.makeElement("span", `You're ${V.PC.pregWeek} ${(V.PC.pregWeek === 1) ? `week` : `weeks`} pregnant`, ["pink", "bold"]));
		if (WL === 1) {
			r.push(`with a baby.`);
		} else {
			r.push(`with ${pregNumberName(WL, 2)}.`);
		}

		if (reservedChildren < freeTanks) {
			if (freeTanks === 1) {
				r.push(`and have an <span class="lime">available aging tank.</span>`);
			} else {
				r.push(`and have <span class="lime">${freeTanks - reservedChildren} available aging tanks.</span>`);
			}
		} else if (reservedChildren >= freeTanks) {
			r.push(`and <span class='red'>ran out of room for your offspring.</span>`);
		}

		if (V.pregnancyMonitoringUpgrade === 1) {
			r.push(
				App.UI.DOM.link(
					`Inspect pregnancy`,
					() => { },
					[],
					`Analyze PC Pregnancy`
				)
			);
		}

		App.Events.addNode(el, r, "div");
		r = [];

		let choices = document.createElement("div");
		choices.classList.add("choices");
		if (reservedIncubator > 0) {
			childrenReserved = 1;
			if (WL === 1) {
				r.push(`Your child `);
			} else if (reservedIncubator < WL) {
				r.push(`${reservedIncubator} of your children `);
			} else if (WL === 2) {
				r.push(`Both of your children `);
			} else {
				r.push(`All ${reservedIncubator} of your children `);
			}
		}
		App.Events.addNode(el, r, "div");
		r = [];

		if (reservedChildren < freeTanks) {
			if (WL - reservedNursery === 0) {
				r.push(
					App.UI.DOM.makeElement(
						"span",
						`Your ${(WL === 1) ? `child is` : `children are`} already reserved for ${V.nurseryName}`,
						"note"
					)
				);
				linkArray.push(
					App.UI.DOM.link(
						`Keep your ${(WL === 1) ? `child` : `children`} here instead`,
						() => {
							WombChangeReserveType(V.PC, 'nursery', 'incubator');
							refresh();
						}
					)
				);
			} else {
				linkArray.push(
					App.UI.DOM.link(
						`Keep ${(WL > 1) ? `a` : `your`} child`,
						() => {
							WombAddToGenericReserve(V.PC, 'incubator', 1);
							refresh();
						}
					)
				);

				const availableChildren = reservedChildren + WL - reservedIncubator;
				if (WL > 1 && (availableChildren <= freeTanks)) {
					linkArray.push(
						App.UI.DOM.link(
							`Keep the rest of your children`,
							() => {
								WombAddToGenericReserve(V.PC, 'incubator', 9999);
								refresh();
							}
						)
					);
				}
			}
			choices.append(App.UI.DOM.generateLinksStrip(linkArray));
			el.append(choices);
		}

		App.Events.addNode(el, r, "div");

		choices = document.createElement("div");
		choices.classList.add("choices");
		linkArray = [];
		if (reservedIncubator > 0) {
			linkArray.push(
				App.UI.DOM.link(
					`Keep one less child`,
					() => {
						WombCleanGenericReserve(V.PC, 'incubator', 1);
						refresh();
					}
				)
			);
		}
		if (reservedIncubator > 1) {
			linkArray.push(
				App.UI.DOM.link(
					`Keep none of your children`,
					() => {
						WombCleanGenericReserve(V.PC, 'incubator', 9999);
						refresh();
					}
				)
			);
		}

		choices.append(App.UI.DOM.generateLinksStrip(linkArray));
		el.append(choices);

		return el;

		function refresh() {
			jQuery(pcContent).empty().append(PC());
			jQuery(introDiv).empty().append(intro());
			jQuery(tanksContent).empty().append(tankBabies());
		}
	}

	function tankBabies() {
		const el = new DocumentFragment();
		let row;
		let linkArray;
		const reservedChildren = FetusGlobalReserveCount("incubator");
		const incubatorSlaves = V.incubator.tanks.length;
		if (incubatorSlaves > 0) {
			App.UI.DOM.appendNewElement("h2", el, `Children in ${V.incubator.name}`);

			for (let i = 0; i < incubatorSlaves; i++) {
				const p = document.createElement("p");
				p.classList.add("incubator-tank");
				let r = [];
				const {
					He, His,
					he, him, his
				} = getPronouns(V.incubator.tanks[i]);
				r.push(App.UI.DOM.makeElement("span", SlaveFullName(V.incubator.tanks[i]), "pink"));
				r.push(`occupies this tank.`);
				if (V.geneticMappingUpgrade >= 1) {
					r.push(`${He} is a`);
					if (V.incubator.tanks[i].genes === "XX") {
						r.push(`female`);
					} else {
						r.push(`male`);
					}
					r.push(`of ${V.incubator.tanks[i].race} descent with ${App.Desc.eyesColor(V.incubator.tanks[i])}, ${V.incubator.tanks[i].hColor} hair and ${V.incubator.tanks[i].skin} skin. Given ${his} parentage, ${he} is considered ${V.incubator.tanks[i].nationality}.`);
				} else {
					r.push(`${He} appears to be`);
					if (V.incubator.tanks[i].genes === "XX") {
						r.push(`a natural girl,`);
					} else {
						r.push(`a natural boy,`);
					}
					r.push(`with ${V.incubator.tanks[i].hColor}`);
					if (getBestVision(V.incubator.tanks[i]) !== 0) {
						r.push(`hair and ${App.Desc.eyesColor(V.incubator.tanks[i])}.`);
					} else {
						r.push(`hair. ${He} most likely will be blind.`);
					}
				}
				if (V.incubator.tanks[i].preg > 0) {
					r.push(`<span class="red">Warning! Subject may be pregnant! Unanticipated growth may occur!</span>`);
				}
				r.push(`Statistical projections indicates that once released ${he} will be around ${heightToEitherUnit(V.incubator.tanks[i].height + random(-5, 5))} tall. Most likely ${he} will be`);
				if (V.incubator.tanks[i].weight <= 30 && V.incubator.tanks[i].weight >= -30) {
					r.push(`at a healthy weight and`);
				} else if (V.incubator.tanks[i].weight >= 31 && V.incubator.tanks[i].weight <= 95) {
					r.push(`quite overweight and`);
				} else if (V.incubator.tanks[i].weight >= 96) {
					r.push(`very overweight and`);
				} else if (V.incubator.tanks[i].weight <= -31 && V.incubator.tanks[i].weight >= -95) {
					r.push(`quite thin and`);
				} else if (V.incubator.tanks[i].weight <= -96) {
					r.push(`very thin and`);
				}
				if (V.incubator.tanks[i].muscles <= 5 && V.incubator.tanks[i].muscles >= -5) {
					r.push(`with a normal musculature.`);
				} else if (V.incubator.tanks[i].muscles >= 6 && V.incubator.tanks[i].muscles <= 30) {
					r.push(`quite toned.`);
				} else if (V.incubator.tanks[i].muscles >= 31 && V.incubator.tanks[i].muscles <= 95) {
					r.push(`quite muscular.`);
				} else if (V.incubator.tanks[i].muscles >= 96) {
					r.push(`with a powerful musculature.`);
				} else if (V.incubator.tanks[i].muscles <= -6 && V.incubator.tanks[i].muscles >= -30) {
					r.push(`quite weak.`);
				} else if (V.incubator.tanks[i].muscles <= -31 && V.incubator.tanks[i].muscles >= -95) {
					r.push(`very weak.`);
				} else if (V.incubator.tanks[i].muscles <= -96) {
					r.push(`extremely weak.`);
				}
				r.push(`${His} breasts are projected to be`);
				if (V.incubator.tanks[i].boobs <= 299) {
					r.push(`of small size,`);
				} else if (V.incubator.tanks[i].boobs <= 799) {
					r.push(`of normal size,`);
				} else if (V.incubator.tanks[i].boobs <= 1799) {
					r.push(`of generous size,`);
				} else if (V.incubator.tanks[i].boobs <= 3249) {
					r.push(`of incredible size,`);
				} else {
					r.push(`of humongous size,`);
				}
				r.push(`while ${his} rear will be`);
				if (V.incubator.tanks[i].butt <= 3) {
					r.push(`a healthy size.`);
				} else if (V.incubator.tanks[i].butt <= 6) {
					r.push(`quite impressive.`);
				} else if (V.incubator.tanks[i].butt <= 9) {
					r.push(`very impressive.`);
				} else {
					r.push(`immense.`);
				}
				if (V.incubator.tanks[i].dick > 0) {
					if (V.incubator.tanks[i].dick <= 3) {
						r.push(`The latest analysis reported ${his} dick will end up being around the average`);
					} else if (V.incubator.tanks[i].dick >= 4 && V.incubator.tanks[i].dick <= 6) {
						r.push(`The latest analysis reported ${his} dick will end up being above average`);
					} else if (V.incubator.tanks[i].dick >= 7 && V.incubator.tanks[i].dick <= 9) {
						r.push(`The latest analysis reported ${his} dick will end up being far above the average`);
					} else {
						r.push(`The latest analysis reported ${his} dick will end up being of monstrous size`);
					}
				}
				if (V.incubator.tanks[i].balls > 0) {
					if (V.incubator.tanks[i].balls <= 3) {
						r.push(`and ${his} testicles will reach a normal size.`);
					} else if (V.incubator.tanks[i].balls >= 4 && V.incubator.tanks[i].balls <= 6) {
						r.push(`and ${his} testicles will be of remarkable size.`);
					} else if (V.incubator.tanks[i].balls >= 7 && V.incubator.tanks[i].balls <= 9) {
						r.push(`and ${his} testicles will reach an impressive size.`);
					} else {
						r.push(`and ${his} testicles will reach a monstrous size.`);
					}
				}
				if (V.incubator.tanks[i].pubertyXX === 1 && V.incubator.tanks[i].ovaries === 1) {
					r.push(`Scanners report ${his} womb is fertile.`);
				} else {
					r.push(`Scanners report ${he} is not fertile,`);
					if (V.incubator.tanks[i].pubertyXX === 0) {
						r.push(`as ${he} has not yet entered puberty.`);
					} else {
						r.push(`as it appears ${his} womb is sterile.`);
					}
				}
				if ((V.incubator.setting.pregAdaptation === 1 && V.incubator.tanks[i].genes === "XX") || (V.incubator.setting.pregAdaptation === 2 && V.incubator.tanks[i].genes === "XY") || V.incubator.setting.pregAdaptation === 3) {
					r.push(`There are probes and tubes inserted inside ${his} reproductive organs so ${V.incubator.name} may work on them.`);
					const safeCC = (V.incubator.tanks[i].pregAdaptation - 5) * 2000;
					if (safeCC > 300000) {
						/* Some bigger size descriptions may be unreachable by normal game mechanics, so they are here just in case.*/
						r.push(`${His} bloated form looks more like an overinflated beachball made of the overstretched skin of ${his} belly, with ${his} relative tiny body attached to its side. ${He} is completely dominated by it now. The process has gone too far, so ${his} body can't maintain its form with the belly as part of abdominal cavity. Now ${his} skin, tissues and muscles have stretched enough for ${his} belly to expand outside of any physical boundaries and appear more an attachment to ${his} body, rather than part of it.`);
					} else if (safeCC > 150000) {
						r.push(`${His} body looks almost spherical, having been grotesquely inflated with the stimulator sacs inserted into ${his} internals. The incubator constantly maintains high pressure inside ${him}, forcing the displacement of ${his} organs and stretching skin, tissues, and muscles. Even ${his} chest has been forced to become a part of the top of ${his} belly, having been pushed forward from the overwhelming volume inside.`);
					} else if (safeCC > 75000) {
						r.push(`${His} belly has become so huge that it can be easily compared with belly of a woman ready to birth quintuplets. It pulses from the pressure applied within by the incubator probes.`);
					} else if (safeCC > 45000) {
						r.push(`${His} belly, in its current state, would look normal on a woman who was ready to birth triplets. On ${his} still growing form, it's something completely out of the ordinary.`);
					} else if (safeCC > 30000) {
						r.push(`${His} belly looks like it contains full-sized twins, ready to be birthed.`);
					} else if (safeCC > 15000) {
						r.push(`${His} belly has reached the size of full-term pregnancy.`);
					} else if (safeCC > 10000) {
						r.push(`${His} belly has inflated to the size of late-term pregnancy; its skin shines from the tension.`);
					} else if (safeCC > 5000) {
						r.push(`${His} belly resembles a mid-term pregnancy; it pulses slightly from the expansion and contraction of expandable sacs tipping the incubator probes.`);
					} else if (safeCC > 1500) {
						r.push(`${His} belly slightly bulges and rhythmically expands and contracts to the cycles of ${his} stimulation as the incubator inflates and deflates expandable sacs on its probes within ${his} body cavity. With the correct serums applied, this should allow it to stretch the skin, tissues, and muscles of ${his} belly to better tolerate the displacement of internal organs caused by fetal growth.`);
					}
				}
				App.Events.addNode(p, r, "div");
				if (V.incubator.tanks[i].growTime <= 0) {
					V.incubator.readySlaves = 1;
					appendRow(p, `${He} is ready to be released from ${his} tank.`);
				} else {
					const weekDisplay = Math.ceil(V.incubator.tanks[i].growTime / V.incubator.upgrade.speed);
					appendRow(p, `${His} growth is currently being accelerated. ${He} will be ready for release in about ${weekDisplay} ${(weekDisplay > 1) ? `weeks` : `week`}.`);
				}

				if (V.incubator.tanks[i].tankBaby !== 3) {
					r = [];
					r.push(`The tank is imprinting ${him} with basic life and sexual skills, though ${he} will still be very naïve and inexperienced on release.`);
					if (V.incubator.tanks[i].tankBaby === 2) {
						r.push(`The majority of ${his} indoctrination involves painting the world as a terrible place where only horror awaits ${him} should ${he} not obey ${his} owner.`);
					} else {
						r.push(`The majority of ${his} indoctrination involves painting the world as a wonderful place only if ${he} is unconditionally devoted to, and absolutely trusting of, ${his} owner.`);
					}
					App.Events.addNode(p, r, "div");
				} else {
					appendRow(p, `The tank keeps ${him} a braindead husk on a complete life-support.`);
				}

				if (V.incubator.upgrade.weight === 1) {
					if (V.incubator.setting.weight === 1) {
						appendRow(p, `${His} weight is not being properly managed, saving costs but likely causing excessive weight gain.`);
					} else if (V.incubator.setting.weight === 2) {
						appendRow(p, `${His} weight is being carefully managed; ${he} will be released at a healthy weight.`);
					} else if (V.incubator.setting.weight === 0) {
						appendRow(p, `Weight management systems are offline; ${he} will likely be malnourished.`);
					}
				}
				if (V.incubator.upgrade.muscles === 1) {
					if (V.incubator.setting.muscles === 2) {
						appendRow(p, `${His} strength levels are purposefully set higher than recommended; ${he} is likely to have excessive musculature.`);
					} else if (V.incubator.setting.muscles === 1) {
						appendRow(p, `${His} musculature is being carefully managed; ${he} will be released with near normal strength.`);
					} else if (V.incubator.setting.muscles === 0) {
						appendRow(p, `Strength management systems are offline; ${he} will likely be released extremely weak.`);
					}
				}
				if (V.incubator.upgrade.growthStims === 1) {
					if (V.incubator.setting.growthStims === 2) {
						appendRow(p, `${He} is being injected with higher than recommended doses of stimulants; ${he} is likely to be much taller than expected.`);
					} else if (V.incubator.setting.growthStims === 1) {
						appendRow(p, `${He} is injected with the recommended dosage of stimulants; ${he} will grow to ${his} full expected height.`);
					} else if (V.incubator.setting.growthStims === 0) {
						appendRow(p, `Growth stimulant injection systems are offline; ${he} will develop normally.`);
					}
				}
				if (V.incubator.upgrade.reproduction === 1) {
					if (V.incubator.setting.reproduction === 2) {
						appendRow(p, `${His} hormone levels are purposefully set higher than recommended; ${his} reproductive systems are likely to be over-active.`);
					} else if (V.incubator.setting.reproduction === 1) {
						appendRow(p, `${His} hormone levels are being carefully managed; ${he} will be released with fully functional reproductive organs.`);
					} else if (V.incubator.setting.reproduction === 0) {
						appendRow(p, `Reproduction management systems are offline; ${he} will undergo normal puberty.`);
					}
					if ((V.incubator.setting.pregAdaptation === 1 && V.incubator.tanks[i].genes === "XX") || (V.incubator.setting.pregAdaptation === 2 && V.incubator.tanks[i].genes === "XY") || V.incubator.setting.pregAdaptation === 3) {
						/* Should be visible only after incubator.setting.reproduction is installed and activated*/
						r = [];
						r.push(`${His} reproductive organs are getting`);
						if (V.incubator.setting.pregAdaptationPower === 1) {
							r.push(`an advanced`);
						} else if (V.incubator.setting.pregAdaptationPower === 2) {
							r.push(`an intensive`);
						} else if (V.incubator.setting.pregAdaptationPower === 3) {
							r.push(`an extreme`);
						} else {
							r.push(`a standard`);
						}
						r.push(`course of mechanical and hormonal therapy to become adapted for future use.`);
						App.Events.addNode(p, r, "div");
					}
				}
				r = [];
				r.push(`Rename ${him}:`);
				r.push(
					App.UI.DOM.makeTextBox(
						V.incubator.tanks[i].slaveName,
						(v) => {
							V.incubator.tanks[i].slaveName = v;
							V.incubator.tanks[i].birthName = V.incubator.tanks[i].slaveName;
							refresh();
						}
					)
				);
				r.push(App.UI.DOM.makeElement("span", `Given name only`, `note`));
				App.Events.addNode(p, r, "div");

				if (V.cheatMode === 1) {
					row = document.createElement("div");
					App.UI.DOM.appendNewElement("span", row, `Cheatmode: `, "bold");
					row.append(
						App.UI.DOM.link(
							"Retrieve immediately",
							() => {
								V.readySlave = V.incubator.tanks[i];
								V.incubator.tanks.splice(i, 1);
							},
							[],
							"Incubator Retrieval Workaround"
						)
					);
					p.append(row);
				}
				if ((V.incubator.upgrade.organs === 1) && (V.incubator.tanks[i].tankBaby !== 3)) {
					r = [];
					r.push(`You can extract a sample and prepare a new organ for ${him} to be implanted once ${he} exits ${his} tank.`);
					const tankOrgans = {
						ovaries: 0,
						penis: 0,
						testicles: 0,
						rightEye: 0,
						leftEye: 0,
						voiceBox: 0,
						cochleae: 0
					};
					for (const organ of V.incubator.organs) {
						if (V.incubator.tanks[i].ID === organ.ID) {
							tankOrgans[organ.type] = 1;
						}
					}

					if (V.incubator.tanks[i].genes === "XX") {
						r.push(`Being a natural girl, ${he} possesses a functional vagina and ovaries. You can:`);
					} else {
						r.push(`Being a natural boy, ${he} possesses a functional penis and balls. You can:`);
					}
					App.Events.addNode(p, r, "div");

					linkArray = [];
					if (V.incubator.tanks[i].ovaries === 0) {
						if (tankOrgans.ovaries !== 1) {
							linkArray.push(
								makeLink(
									"Prepare ovaries",
									() => {
										App.Medicine.OrganFarm.growIncubatorOrgan(V.incubator.tanks[i], "ovaries");
									},
									refresh
								)
							);
						} else {
							linkArray.push(App.UI.DOM.makeElement("span", `Ovaries are already prepared.`, "detail"));
						}
					}
					if (V.incubator.tanks[i].dick === 0 && (V.seeDicks > 0 || V.makeDicks > 0)) {
						if (tankOrgans.penis !== 1) {
							linkArray.push(
								makeLink("Prepare penis", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.incubator.tanks[i], "penis"); }, refresh)
							);
						} else {
							linkArray.push(App.UI.DOM.makeElement("span", `A penis is already prepared`, "detail"));
						}
					}
					if (V.incubator.tanks[i].balls === 0) {
						if (tankOrgans.testicles !== 1) {
							linkArray.push(makeLink("Prepare testicles", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.incubator.tanks[i], "testicles"); }, refresh));
						} else {
							linkArray.push(App.UI.DOM.makeElement("span", `Testicles are already prepared.`, "detail"));
						}
					}
					const vision = {
						left: getLeftEyeVision(V.incubator.tanks[i]),
						right: getRightEyeVision(V.incubator.tanks[i])
					};
					if (vision.left === 0 || vision.right === 0) {
						if (vision.left === 0 && vision.right === 0) {
							linkArray.push(App.UI.DOM.makeElement("span", `${He} appears to be blind in both eyes:`));
						} else if (vision.left === 0) {
							linkArray.push(App.UI.DOM.makeElement("span", `${He} appears to be blind in ${his} left eye:`));
						} else {
							linkArray.push(App.UI.DOM.makeElement("span", `${He} appears to be blind in ${his} right eye:`));
						}
						if (vision.left === 0 && tankOrgans.leftEye !== 1) {
							linkArray.push(makeLink("Prepare left eye", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.incubator.tanks[i], "leftEye"); }, refresh));
						}
						if (vision.right === 0 && tankOrgans.rightEye !== 1) {
							linkArray.push(makeLink("Prepare right eye", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.incubator.tanks[i], "rightEye"); }, refresh));
						}
						if (vision.left === 0 && vision.right === 0 && linkArray.length === 2) {
							linkArray.push(
								makeLink(
									"Prepare right eye",
									() => {
										App.Medicine.OrganFarm.growIncubatorOrgan(V.incubator.tanks[i], "rightEye");
										App.Medicine.OrganFarm.growIncubatorOrgan(V.incubator.tanks[i], "leftEye");
									},
									refresh
								)
							);
						}
						if (vision.left === 0 && vision.right === 0 && linkArray.length === 0) {
							linkArray.push(App.UI.DOM.makeElement("span", `Both eyes are already prepared.`, `detail`));
						} else if (tankOrgans.leftEye === 1) {
							linkArray.push(App.UI.DOM.makeElement("span", `A left eye is already prepared.`, `detail`));
						} else if (tankOrgans.rightEye === 1) {
							linkArray.push(App.UI.DOM.makeElement("span", `A right eye is already prepared.`, `detail`));
						}
					}
					App.UI.DOM.appendNewElement("div", p, App.UI.DOM.generateLinksStrip(linkArray));
					if (V.incubator.tanks[i].voice === 0) {
						r = [];
						r.push(`${He} appears to be mute:`);
						if (tankOrgans.voicebox !== 1) {
							r.push(makeLink("Prepare vocal cords", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.incubator.tanks[i], "voicebox"); }, refresh));
						} else {
							r.push(App.UI.DOM.makeElement("span", `Vocal cords are already prepared.`, `detail`));
						}
						App.Events.addNode(p, r, "div");
					}
					if (V.incubator.tanks[i].hears === -2) {
						r = [];
						r.push(`${He} appears to be deaf:`);
						if (tankOrgans.cochleae !== 1) {
							r.push(makeLink("Prepare cochleae", () => { App.Medicine.OrganFarm.growIncubatorOrgan(V.incubator.tanks[i], "cochleae"); }, refresh));
						} else {
							r.push(App.UI.DOM.makeElement("span", `Cochleae are already prepared.`, `detail`));
						}
						App.Events.addNode(p, r, "div");
					}
				}
				el.append(p);
			}
		}

		for (let i = 0; i < reservedChildren; i++) {
			const empty = document.createElement("div");
			empty.classList.add("incubator-tank");
			empty.append("This tank is currently reserved");
			el.append(empty);
		}

		return el;

		function refresh() {
			jQuery(tanksContent).empty().append(tankBabies());
			jQuery(introDiv).empty().append(intro());
		}
	}

	function tankSettings() {
		const el = new DocumentFragment();
		let cost;
		let p;
		let r = [];
		let row;
		let linkArray;
		r.push("Target age for release:");
		r.push(
			App.UI.DOM.makeTextBox(
				V.targetAge,
				(v) => {
					V.targetAge = v || V.minimumSlaveAge;
					V.targetAge = Math.clamp(V.targetAge, V.minimumSlaveAge, V.retirementAge);
					refresh();
				},
				true
			)
		);
		linkArray = [];
		linkArray.push(
			App.UI.DOM.link(
				`Minimum Legal Age`,
				() => {
					V.targetAge = V.minimumSlaveAge;
					refresh();
				}
			)
		);
		linkArray.push(
			App.UI.DOM.link(
				`Average Age of Fertility`,
				() => {
					V.targetAge = V.fertilityAge;
					refresh();
				}
			)
		);
		linkArray.push(
			App.UI.DOM.link(
				`Average Age of Potency`,
				() => {
					V.targetAge = V.potencyAge;
					refresh();
				}
			)
		);
		linkArray.push(
			App.UI.DOM.link(
				`Legal Adulthood`,
				() => {
					V.targetAge = 18;
					refresh();
				}
			)
		);
		r.push(App.UI.DOM.generateLinksStrip(linkArray));
		r.push(App.UI.DOM.makeElement("span", `Setting will not be applied to tanks in use.`, "note"));
		App.Events.addNode(el, r, "p");

		row = document.createElement("p");
		if (V.incubator.setting.bulkRelease === 1) {
			row.append(`Released children will be handled in bulk and not receive personal attention. `);
			row.append(
				App.UI.DOM.link(
					`Individual release`,
					() => {
						V.incubator.setting.bulkRelease = 0;
						refresh();
					}
				)
			);
		} else {
			row.append(`Released children will be seen to personally. `);
			row.append(
				App.UI.DOM.link(
					`Bulk release`,
					() => {
						V.incubator.setting.bulkRelease = 1;
						refresh();
					}
				)
			);
		}
		el.append(row);

		row = document.createElement("p");

		if (V.incubator.upgrade.speed === 52) {
			row.append(`It has been upgraded with perfected growth accelerants; children grow at the rate of 1 week to 1 year.`);
		} else if (V.incubator.upgrade.speed === 18) {
			cost = Math.trunc(500000 * V.upgradeMultiplierArcology);
			row.append(`It has been upgraded with advanced experimental growth accelerants; children grow at the rate of 3 weeks to 1 year. `);
			row.append(
				choice(
					`Fund speculative research into maximizing growth rate`,
					() => {
						cashX(forceNeg(cost), "capEx");
						V.incubator.upgrade.speed = 52;
						refresh();
					},
					"",
					`Costs ${cashFormat(cost)} and will increase upkeep costs`
				)
			);
		} else if (V.incubator.upgrade.speed === 9) {
			cost = Math.trunc(75000 * V.upgradeMultiplierArcology);
			row.append(`It has been upgraded with advanced growth accelerants; children grow at the rate of 6 weeks to 1 year. `);
			row.append(
				choice(
					`Fund research into increasing growth rate even further`,
					() => {
						cashX(forceNeg(cost), "capEx");
						V.incubator.upgrade.speed = 18;
						refresh();
					},
					"",
					`Costs ${cashFormat(cost)} and will increase upkeep costs`
				)
			);
		} else if (V.incubator.upgrade.speed === 6) {
			cost = Math.trunc(30000 * V.upgradeMultiplierArcology);
			row.append(`It has been upgraded with growth accelerants; children grow at the rate of 9 weeks to 1 year. `);
			row.append(
				choice(
					`Further upgrade the incubators with specialized stem cells to speed growth`,
					() => {
						cashX(forceNeg(cost), "capEx");
						V.incubator.upgrade.speed = 9;
						refresh();
					},
					"",
					`Costs ${cashFormat(cost)} and will increase upkeep costs`
				)
			);
		} else if (V.incubator.upgrade.speed === 5) {
			cost = Math.trunc(30000 * V.upgradeMultiplierArcology);
			row.append(`The incubation tanks are basic; children grow at the rate of 12 weeks to 1 year. `);
			row.append(
				choice(
					`Upgrade the incubators with growth accelerating drugs`,
					() => {
						cashX(forceNeg(cost), "capEx");
						V.incubator.upgrade.speed = 6;
						refresh();
					},
					"",
					`Costs ${cashFormat(cost)} and will increase upkeep costs`
				)
			);
		}

		el.append(row);

		p = document.createElement("p");
		row = document.createElement("div");
		if (V.incubator.upgrade.weight === 1) {
			row.append(`Advanced caloric monitoring systems have been installed in the tanks to monitor and maintain a developing child's weight.`);
			p.append(row);
			row = document.createElement("div");
			linkArray = [];
			if (V.incubator.setting.weight === 1) {
				row.append(`Weight is not being properly managed; excessive weight gain is likely. `);
			} else {
				linkArray.push(makeLink(`Estimate only`, () => { V.incubator.setting.weight = 1; }, refresh));
			}

			if (V.incubator.setting.weight === 2) {
				row.append(`Weight is being carefully managed; children will be released at a healthy weight. `);
			} else {
				linkArray.push(makeLink(`Activate`, () => { V.incubator.setting.weight = 2; }, refresh));
			}

			if (V.incubator.setting.weight === 0) {
				row.append(`Weight management systems are offline; children will likely be malnourished. `);
			} else {
				linkArray.push(makeLink(`Disable`, () => { V.incubator.setting.weight = 0; }, refresh));
			}
			row.append(App.UI.DOM.generateLinksStrip(linkArray));
		} else {
			cost = Math.trunc(20000 * V.upgradeMultiplierArcology);
			row.append(`There are no systems in place to control a growing child's weight; they will likely come out emaciated from the rapid growth. `);
			row.append(
				choice(
					`Upgrade the growth tanks with weight monitoring systems`,
					() => {
						cashX(forceNeg(cost), "capEx");
						V.incubator.upgrade.weight = 1;
						refresh();
					},
					"",
					`Costs ${cashFormat(cost)} and will increase upkeep costs`
				)
			);
		}

		p.append(row);
		el.append(p);

		p = document.createElement("p");
		row = document.createElement("div");

		if (V.incubator.upgrade.muscles === 1) {
			row.append(`Advanced monitoring and steroid injection systems have been installed in the tanks to monitor and maintain a developing child's musculature.`);
			p.append(row);
			row = document.createElement("div");
			linkArray = [];
			if (V.incubator.setting.muscles === 2) {
				row.append(`Strength levels are purposefully set higher than recommended; excessive muscle gain is likely. `);
			} else {
				linkArray.push(makeLink(`Overload`, () => { V.incubator.setting.muscles = 2; }, refresh));
			}

			if (V.incubator.setting.muscles === 1) {
				row.append(`Musculature is being carefully managed; children will be released with near normal strength. `);
			} else {
				linkArray.push(makeLink(`Activate`, () => { V.incubator.setting.muscles = 1; }, refresh));
			}

			if (V.incubator.setting.muscles === 0) {
				row.append(`Strength management systems are offline; children will likely be released extremely weak. `);
			} else {
				linkArray.push(makeLink(`Disable`, () => { V.incubator.setting.muscles = 0; }, refresh));
			}

			row.append(App.UI.DOM.generateLinksStrip(linkArray));
		} else {
			cost = Math.trunc(20000 * V.upgradeMultiplierArcology);
			row.append(`There are no systems in place to control a growing child's musculature; they will likely come out frail and weak from the rapid growth. `);
			row.append(
				choice(
					`Upgrade the growth tanks with muscle monitoring systems`,
					() => {
						cashX(forceNeg(cost), "capEx");
						V.incubator.upgrade.muscles = 1;
						refresh();
					},
					"",
					`Costs ${cashFormat(cost)} and will increase upkeep costs`
				)
			);
		}

		p.append(row);
		el.append(p);

		p = document.createElement("p");
		row = document.createElement("div");

		if (V.incubator.upgrade.reproduction === 1) {
			row.append(`Advanced monitoring and hormone injection systems have been installed in the tanks to influence a developing child's reproductive organs.`);
			p.append(row);
			row = document.createElement("div");
			linkArray = [];
			if (V.incubator.setting.reproduction === 2) {
				row.append(`Hormone levels are purposefully set higher than recommended; over-active reproductive systems are likely. `);
			} else {
				linkArray.push(makeLink(`Overload`, () => { V.incubator.setting.reproduction = 2; }, refresh));
			}

			if (V.incubator.setting.reproduction === 1) {
				row.append(`Hormone levels are being carefully managed; children will be released with fully functional reproductive organs. `);
			} else {
				linkArray.push(makeLink(`Limit`, () => { V.incubator.setting.reproduction = 1; }, refresh));
			}

			if (V.incubator.setting.reproduction === 0) {
				row.append(`Reproduction management systems are offline; children will undergo normal puberty. `);
			} else {
				linkArray.push(makeLink(`Disable`, () => { V.incubator.setting.reproduction = 0; }, refresh));
			}
			row.append(App.UI.DOM.generateLinksStrip(linkArray));
			p.append(row);
			el.append(p);

			if (V.incubator.upgrade.pregAdaptation === 1) {
				// Should be visible only after incubator.upgrade.reproduction is installed
				p = document.createElement("p");
				row = document.createElement("div");
				linkArray = [];
				if (V.incubator.setting.pregAdaptation === 3) {
					row.append(`Pregnancy adaptation system online: All. `);
				} else {
					linkArray.push(makeLink(`All`, () => { V.incubator.setting.pregAdaptation = 3; }, refresh));
				}

				if (V.incubator.setting.pregAdaptation === 2) {
					row.append(`Pregnancy adaptation system online: Males only. `);
				} else {
					linkArray.push(makeLink(`Males`, () => { V.incubator.setting.pregAdaptation = 2; }, refresh));
				}

				if (V.incubator.setting.pregAdaptation === 1) {
					row.append(`Pregnancy adaptation system online: Females only. `);
				} else {
					linkArray.push(makeLink(`Females`, () => { V.incubator.setting.pregAdaptation = 1; }, refresh));
				}

				if (V.incubator.setting.pregAdaptation === 0) {
					row.append(`Pregnancy adaptation system offline. `);
				} else {
					linkArray.push(makeLink(`Disable`, () => { V.incubator.setting.pregAdaptation = 0; }, refresh));
				}
				row.append(App.UI.DOM.generateLinksStrip(linkArray));

				if (V.incubator.upgrade.pregAdaptation === 1 && V.incubator.setting.pregAdaptation > 0) {
					// Should be visible only after incubator.upgrade.reproduction is installed and turned on
					p.append(row);
					row = document.createElement("div");
					linkArray = [];
					if (V.incubator.setting.pregAdaptationPower === 1) {
						row.append(`Pregnancy adaptation programmed to advanced procedures. Up to triplet pregnancy should be safe for the subjects. `);
					} else {
						linkArray.push(makeLink(`Advanced`, () => { V.incubator.setting.pregAdaptationPower = 1; }, refresh));
					}

					if (V.incubator.setting.pregAdaptationPower === 2) {
						row.append(`Pregnancy adaptation programmed to intensive procedures. Up to octuplet pregnancy should be possible for the subjects. Warning! Side effects may occur to health and mental condition. `);
					} else {
						linkArray.push(makeLink(`Intensive`, () => { V.incubator.setting.pregAdaptationPower = 2; }, refresh));
					}

					if (V.incubator.setting.pregAdaptationPower === 3) {
						row.append(`Pregnancy adaptation programmed to extreme procedures. Normally unsustainable pregnancies may be possible for some subjects. Actual capacity will vary with genetic and other individual conditions. WARNING! Extreme side effects may occur to health and mental condition! `);
					} else {
						linkArray.push(makeLink(`Extreme`, () => { V.incubator.setting.pregAdaptationPower = 3; }, refresh));
					}

					if (V.incubator.setting.pregAdaptationPower === 0) {
						row.append(`Pregnancy adaptation programmed to standard procedures. Normal pregnancy should be safe for subjects. `);
					} else {
						linkArray.push(makeLink(`Standard`, () => { V.incubator.setting.pregAdaptationPower = 0; }, refresh));
					}
					row.append(App.UI.DOM.generateLinksStrip(linkArray));
					p.append(row);

					row = document.createElement("div");
					App.UI.DOM.appendNewElement("span", row, `Due to the high complexity and steep risks of the procedure, settings will not be changed on tanks in use.`, "note");
				}
			}
			p.append(row);
			el.append(p);
		} else {
			cost = Math.trunc(50000 * V.upgradeMultiplierArcology);
			row.append(`There are no systems in place to control a growing child's reproductive capability. `);
			row.append(
				choice(
					`Upgrade the growth tanks with hormone monitoring systems`,
					() => {
						cashX(forceNeg(cost), "capEx");
						V.incubator.upgrade.reproduction = 1;
						refresh();
					},
					"",
					`Costs ${cashFormat(cost)} and will increase upkeep costs`
				)
			);
			p.append(row);
			el.append(p);
		}

		row = document.createElement("div");

		if (V.incubator.upgrade.organs === 1) {
			row.append(`Surgical tools have been added to the tank to be able to extract tissue samples from the occupant.`);
		} else if (V.organFarmUpgrade >= 1) {
			cost = Math.trunc(10000 * V.upgradeMultiplierArcology);
			row.append(`The tanks lack the ability to extract tissue samples to be used by the organ fabricator. `);
			row.append(
				choice(
					`Upgrade the growth tanks with surgical extraction tools`,
					() => {
						cashX(forceNeg(cost), "capEx");
						V.incubator.upgrade.organs = 1;
						refresh();
					},
					"",
					`Costs ${cashFormat(cost)} and will increase upkeep costs`
				)
			);
		} else {
			row.append(`The tanks lack the ability to extract tissue samples and the dispensary lacks the ability to make use of them to fabricate organs.`);
		}

		el.append(row);

		p = document.createElement("p");
		row = document.createElement("div");

		if (V.incubator.upgrade.growthStims === 1) {
			row.append(`Advanced monitoring and stimulant injection systems have been installed in the tanks to monitor and maintain a developing child's height.`);
			row = document.createElement("div");
			linkArray = [];
			if (V.incubator.setting.growthStims === 2) {
				row.append(`Children are injected with higher than recommended doses of stimulants; exceeding expected final height is likely. `);
			} else {
				linkArray.push(makeLink(`Overload`, () => { V.incubator.setting.growthStims = 2; }, refresh));
			}

			if (V.incubator.setting.growthStims === 1) {
				row.append(`Children are injected with the recommended dosage of stimulants; they will grow to their full expected height. `);
			} else {
				linkArray.push(makeLink(`Limit`, () => { V.incubator.setting.growthStims = 1; }, refresh));
			}

			if (V.incubator.setting.growthStims === 0) {
				row.append(`Growth stimulant injection systems are offline; children will develop normally. `);
			} else {
				linkArray.push(makeLink(`Disable`, () => { V.incubator.setting.growthStims = 0; }, refresh));
			}
			row.append(App.UI.DOM.generateLinksStrip(linkArray));
		} else if (V.growthStim === 1) {
			cost = Math.trunc(20000 * V.upgradeMultiplierArcology);
			row.append(`There are no systems in place to control a growing child's height. `);
			row.append(
				choice(
					`Upgrade the growth tanks with stimulants injection systems`,
					() => {
						cashX(forceNeg(cost), "capEx");
						V.incubator.upgrade.growthStims = 1;
						refresh();
					},
					"",
					`Costs ${cashFormat(cost)} and will increase upkeep costs`
				)
			);
		} else {
			row.append(`There are no systems in place to control a growing child's height and you lack the capability to fabricate growth stimulants.`);
		}
		p.append(row);
		el.append(p);

		if (V.minimumSlaveAge <= 6 && (V.arcologies[0].FSRepopulationFocus >= 60 || V.BlackmarketPregAdaptation === 1)) {
			/* Main prerequisite - stable repopulation FS OR documentation purchased from black market. And age gate. */
			p = document.createElement("p");
			row = document.createElement("div");
			if (V.incubator.upgrade.pregAdaptation === 1) {
				row.append(`The incubators have been upgraded with special set of manipulators, probes, nozzles and syringes coupled together with specific programs to take advantage of the accelerated growth to heighten viable reproductive capacity. These include injections of specialized serums and mechanical manipulation of the reproductive system and associated tissues, organs, muscles and bones.`);
			} else {
				row.append(`The highly controlled environment inside incubation tube coupled with the greatly accelerated growth process is the perfect opportunity to push the boundaries of a body's ability to sustain pregnancy. This will include injections of specialized serums and mechanical manipulation of their reproductive system through a special set of manipulators, probes, nozzles and syringes supervised by a powerful monitoring program. Costly to maintain.`);
				p.append(row);

				row = document.createElement("div");
				if (V.incubator.upgrade.reproduction < 1) {
					/* Now with reports - what is lacking for construction */
					row.append(`${incubatorNameCaps} lacks advanced monitoring and hormone injection systems. Construction not possible.`);
				} else if (V.incubator.upgrade.organs < 1) {
					row.append(`${incubatorNameCaps} lacks the ability to extract tissue samples. Construction not possible.`);
				} else if (V.dispensaryUpgrade < 1) {
					row.append(`${incubatorNameCaps} lacks a connection to an advanced pharmaceutical fabricator. Cutting-edge targeted serums production needed as integral part. Construction not possible.`);
				} else if (V.bellyImplants < 1) {
					row.append(`${incubatorNameCaps} lacks a connection with an implant manufacturing to construct fillable abdominal implants to simulate expansion. Construction not possible.`);
				} else if (V.incubator.upgrade.growthStims < 1) {
					row.append(`${incubatorNameCaps} lacks advanced monitoring and stimulant injection systems. Construction not possible.`);
				} else {
					cost = Math.trunc(2000000 * V.upgradeMultiplierArcology);
					row.append(
						choice(
							`Manufacture and install this subsystem`,
							() => {
								cashX(forceNeg(cost), "capEx");
								V.incubator.upgrade.pregAdaptation = 1;
								refresh();
							},
							"",
							`Costs ${cashFormat(cost)} and will increase upkeep costs`
						)
					);
				}
			}
			p.append(row);
			el.append(p);
		}

		p = document.createElement("p");
		row = document.createElement("div");
		if (V.incubator.setting.imprint === "terror") {
			row.append(`The imprinting system is currently focused on making them devoted but fearful of you. The imprinting cycle is locked upon incubation start. `);
			App.UI.DOM.appendNewElement("span", row, `Only affects new infants`, "note");
			if (V.bodyswapAnnounced === 1) {
				row.append(
					choice(
						`Switch the system to focus on preparation for body-swapping`,
						() => {
							V.incubator.setting.imprint = "husk";
							refresh();
						}
					)
				);
			}
			row.append(
				choice(
					`Switch the system to focus on attachment`,
					() => {
						V.incubator.setting.imprint = "trust";
						refresh();
					}
				)
			);
		} else if (V.incubator.setting.imprint === "trust") {
			row.append(`The imprinting system is currently focused on making them devoted and trusting of you. The imprinting cycle is locked upon incubation start.`);
			if (V.bodyswapAnnounced === 1) {
				row.append(
					choice(
						`Switch the system to focus preparation for body-swapping`,
						() => {
							V.incubator.setting.imprint = "husk";
							refresh();
						}
					)
				);
			}
			row.append(
				choice(
					`Switch the system to focus on dependence`,
					() => {
						V.incubator.setting.imprint = "terror";
						refresh();
					}
				)
			);
		} else {
			row.append(`The imprinting system is currently focused on producing complete vegetables ready to be used as hosts for body swapping. The imprinting cycle is locked upon incubation start.`);
			row.append(
				choice(
					`Switch the system to focus on dependence`,
					() => {
						V.incubator.setting.imprint = "terror";
						refresh();
					}
				)
			);
			row.append(
				choice(
					`Switch the system to focus on attachment`,
					() => {
						V.incubator.setting.imprint = "trust";
						refresh();
					}
				)
			);
		}
		p.append(row);
		el.append(p);

		row = document.createElement("div");
		row.append(App.Facilities.rename(App.Entity.facilities.incubator, () => refresh()));
		el.append(row);

		return el;

		function refresh() {
			jQuery(settingsContent).empty().append(tankSettings());
			jQuery(introDiv).empty().append(intro());
			jQuery(tanksContent).empty().append(tankBabies());
		}
	}

	function release() {
		const multiple = (V.incubator.setting.bulkRelease === 1) && V.incubator.tanks.filter(t => t.growTime <= 0).length > 1;
		const getTanks = () => {
			if (multiple) {
				V.newSlavePool = V.incubator.tanks.deleteWith(t => t.growTime <= 0);
			} else {
				const baby = V.incubator.tanks.find(t => t.growTime <= 0);
				V.incubator.tanks.delete(baby);
				V.readySlave = baby;
			}
		};
		if (V.incubator.readySlaves === 1) {
			return App.UI.DOM.passageLink(`Release ready ${multiple ? "tanks": "tank"}`, "Incubator Retrieval Workaround", getTanks);
		}
		return new DocumentFragment();
	}

	/**
	 *
	 * @param {string} title
	 * @param {function():void} func
	 * @param {function():void} refresh
	 */
	function makeLink(title, func, refresh) {
		return App.UI.DOM.link(
			title,
			() => {
				func();
				refresh();
			}
		);
	}

	/**
	 *
	 * @param {string} title
	 * @param {function():void} func
	 * @param {string} [passage=""]
	 * @param {string} [note]
	 * @returns {HTMLElement}
	 */
	function choice(title, func, passage = "", note) { // TODO: Regular parameters should not come after default parameters.
		const div = document.createElement("div");
		div.classList.add("choices");
		div.append(
			App.UI.DOM.link(
				title,
				func,
				[],
				passage,
				note
			)
		);
		return div;
	}

	function appendRow(node, text) {
		return App.UI.DOM.appendNewElement("div", node, text);
	}
};


code:
// @ts-nocheck
App.UI.incubatorRetrievalWorkaround = function() {
	V.incubator.readySlaves = 0;
	const animalBabyWarning = (slave) => {
		if (slave.father === -8) {
			Dialog.setup("Attention");
			const frag = new DocumentFragment();
			frag.append(`As the Farmyard is currently WIP, animal-fathered children shouldn't be here! Affected slave: ${slave.slaveName}.`);
			App.UI.DOM.appendNewElement("div", frag, "Please either close this dialog, load a previous save and abort the pregnancy, or sell/discard this slave.");
			App.UI.DOM.appendNewElement("div", frag,
				App.UI.DOM.link("Alternatively, remove this slave and try again.", () => {
					if (V.readySlave) {
						V.readySlave = 0;
					} else if (V.newSlavePool) {
						V.newSlavePool.deleteAt(slave);
					}
					if (Dialog.isOpen()) {
						Dialog.close();
					}
				}, [], (V.readySlave ? "Incubator" : "Incubator Retrieval Workaround"))
			);
			$(Dialog.body()).empty().append(frag);
			Dialog.open();
		}
	};

	const parent = (slave, type) => {
		const r = new DocumentFragment();
		const missingTableEntry = V.missingTable[slave[type]];
		const missingSlave = missingTableEntry ? `Your former slave, ${missingTableEntry.slaveName}.` : `Unknown.`;
		animalBabyWarning(slave);
		r.append(`${capFirstChar(type)}: `);
		if (slave[type] > 0) {
			const tempParent = getSlave(slave[type]);
			if (!tempParent) {
				r.append(`Unknown.`);
			} else {
				r.append(`${SlaveFullName(tempParent)}`);
			}
		} else if (slave[type] === -1) {
			r.append(`${PlayerName()}`);
		} else if (type === "father") {
			if (slave.father === -2) {
				r.append(`Unknown citizen.`);
			} else if (slave.father === -3) {
				r.append(`Your former Master.`);
			} else if (slave.father === -4) {
				r.append(`Another arcology's owner.`);
			} else if (slave.father === -5) {
				r.append(`One of your clients.`);
			} else if (slave.father === -6) {
				r.append(`Societal Elite.`);
			} else if (slave.father === -7) {
				r.append(`Lab crafted.`);
			} else if (slave.father === -9) {
				r.append(`Futanari Sister.`);
			} else {
				r.append(`${missingSlave}`);
			}
		} else {
			r.append(`${missingSlave}`);
		}
		return r;
	};

	const checkOrgans = (slave) => {
		if (V.incubator.organs.length > 0) {
			for (const organ of V.incubator.organs.filter(o => o.ID === slave.ID)) {
				const newOrgan = {type: organ.type, weeksToCompletion: organ.weeksToCompletion, ID: slave.ID};
				if (newOrgan.weeksToCompletion <= 0) {
					V.completedOrgans.push(organ);
				} else {
					V.organs.push(newOrgan);
				}
				V.incubator.organs.deleteAt(organ);
			}
		}
	};

	const node = new DocumentFragment();

	if (V.readySlave) {
		const {he, his, him} = getPronouns(V.readySlave);
		animalBabyWarning(V.readySlave);
		App.UI.DOM.appendNewElement("p", node, `${V.readySlave.slaveName} has been discharged from ${V.incubator.name} and is ready for ${his} first ever inspection.`);
		App.UI.DOM.appendNewElement("div", node, App.Desc.longSlave(V.readySlave));
		if (V.readySlave.tankBaby !== -3) {
			checkOrgans(V.readySlave);
			App.UI.DOM.appendNewElement("div", node, App.UI.newChildIntro(V.readySlave));
		} else {
			const price = Math.trunc(slaveCost(V.readySlave)/3);
			V.activeSlave = V.readySlave; // V.activeSlave is used by Husk Slave Swap Workaround
			node.append(`A husk is ready to be used.`);
			App.UI.DOM.appendNewElement("div", node, `As expected, ${he} is a complete vegetable, but that is what you wanted after all. You lack the facilities to care for ${him} in this state, so you should do what you are planning quickly. Or you could sell ${him} to the Flesh Heap.`, "note");
			if (V.cash >= V.surgeryCost) {
				App.UI.DOM.appendNewElement("div", node, App.UI.DOM.passageLink("Contact the bodyswap surgeon.", "Husk Slave Swap Workaround", null, "Will significantly increase the selected slave's upkeep."));
				App.UI.DOM.appendNewElement("div", node, App.UI.DOM.passageLink("Sell the husk to Flesh Heap.", "Main", () => { cashX(price, "slaveTransfer"); }, `This body can be bought by the Flesh Heap for ${cashFormat(price)}.`));
			} else {
				cashX(price, "slaveTransfer");
				App.UI.DOM.appendNewElement("span", node, `You can't sustain ${him} and thus must sell ${him} for ${cashFormat(price)}.`, "note");
			}
		}
	} else if (V.newSlavePool) {
		App.UI.DOM.appendNewElement("p", node, `The following slaves were discharged from ${V.incubator.name}:`);
		for (const slave of V.newSlavePool) {
			App.UI.DOM.appendNewElement("div", node, `Name: ${SlaveFullName(slave)}`);
			App.UI.DOM.appendNewElement("div", node, parent(slave, "mother"));
			App.UI.DOM.appendNewElement("div", node, parent(slave, "father"));
			newSlave(slave);
			checkOrgans(slave);
		}
		delete V.newSlavePool;
	}

	return node;
};

repo_name: Elohiem/fc

license: mit


code:
/**
 * Sends a child to the Incubator if it has room
 * @param {App.Entity.SlaveState} child
 */
App.Facilities.Incubator.newChild = function(child) {
	let fullAdapt;
	child.growTime = Math.trunc(V.targetAge * 52);
	child.incubatorPregAdaptationPower = V.incubator.setting.pregAdaptationPower;
	if (V.incubator.setting.pregAdaptationPower === 1) {
		fullAdapt = 45000 / 2000;
	} else if (V.incubator.setting.pregAdaptationPower === 2) {
		fullAdapt = 100000 / 2000;
	} else if (V.incubator.setting.pregAdaptationPower === 3) {
		fullAdapt = 150000 / 2000;
	} else {
		fullAdapt = 15000 / 2000;
	}
	child.incubatorPregAdaptationInWeek = (fullAdapt - child.pregAdaptation) / child.growTime;
	V.incubator.tanks.push(child);
};

App.Facilities.Incubator.init = function(state) {
	if (state === 'base') {
		return V.incubator = {capacity: 0, tanks: []};
	}

	V.incubator = {
		capacity: 1,
		tanks: [],
		name: "the Incubator",
		organs: [],
		readySlaves: 0,
		upgrade: {
			speed: 5,
			weight: 0,
			muscles: 0,
			growthStims: 0,
			reproduction: 0,
			organs: 0,
			pregAdaptation: 0,
		},
		setting: {
			imprint: "trust",
			weight: 0,
			muscles: 0,
			growthStims: 0,
			reproduction: 0,
			bulkRelease: 0,
			pregAdaptation: 0,
			pregAdaptationPower: 0,
		},
	};
};


code:
App.UI.dispensary = function() {
	const pcSkillCheck = Math.min(V.upgradeMultiplierMedicine, V.HackingSkillMultiplier);

	/**
	 * @type {Array<string|HTMLElement|DocumentFragment>}
	 */
	let r;

	const refreshDiv = document.createElement("div");
	refreshDiv.append(content());
	return refreshDiv;

	function refresh() {
		App.UI.DOM.replace(refreshDiv, content());
	}

	/**
	 * @returns {DocumentFragment}
	 */
	function content() {
		const f = new DocumentFragment();
		f.append(
			intro(),
			hormones(),
			diet(),
			pharma()
		);
		if (V.seePreg !== 0) {
			f.append(fertility());
		}
		f.append(futureSociety());
		return f;
	}

	/**
	 * @param {string} name
	 * @param {string|Node} note
	 * @param {function(): void} callback
	 * @param {number} cost
	 * @param {string} [existingDesc=""]
	 * @returns {DocumentFragment}
	 */
	function upgrade(name, note, callback, cost, existingDesc = "") {
		const f = new DocumentFragment();
		r = [];
		if (existingDesc !== "") {
			r.push(existingDesc);
		}
		r.push(App.UI.DOM.link(name, () => {
			cashX(-cost, "capEx");
			callback();
			refresh();
		}));
		r.push(`<span class="detail">Costs ${cashFormat(cost)}</span>`);
		App.Events.addNode(f, r, "div");

		App.UI.DOM.appendNewElement("div", f, note, ["indent", "note"]);

		return f;
	}

	/**
	 * @returns {DocumentFragment}
	 */
	function intro() {
		const f = new DocumentFragment();
		App.UI.DOM.appendNewElement("h1", f, "The Dispensary");

		let p = document.createElement("p");
		r = [];
		r.push("The pharmaceutical fabricator is running smoothly.");
		if (V.dispensaryUpgrade === 0) {
			r.push("It can cheaply replicate complex medications, and has already cut the cost of drugs for your slaves by a fourth.");
		} else {
			r.push("It can cheaply and quickly replicate complex medications, and has already cut the cost of drugs for your slaves in half.");
		}
		r.push("It can easily produce advanced drugs should you obtain the data necessary to create them.");
		App.Events.addNode(p, r, "div", "scene-intro");

		if (V.dispensaryUpgrade === 0) {
			if (V.rep > 5000) {
				p.append(upgrade("Upgrade the pharmaceutical fabricator", "Will improve production efficiency further decreasing costs.", () => {
					V.dispensaryUpgrade = 1;
					V.drugsCost = (V.drugsCost * 2) / 3;
				}, 30000 * V.upgradeMultiplierArcology));
			} else {
				App.UI.DOM.appendNewElement("div", p, "You lack the reputation to obtain cutting-edge pharmaceutical fabricator upgrades.", "note");
			}
		}
		f.append(p);
		return f;
	}

	/**
	 * @returns {DocumentFragment}
	 */
	function hormones() {
		const f = new DocumentFragment();
		App.UI.DOM.appendNewElement("h2", f, "Hormones Upgrades");

		let p = document.createElement("p");

		let text = "The fabricator is producing";
		if (V.injectionUpgrade === 0) {
			text += " standard growth hormones.";
			if (V.rep > 6000) {
				p.append(upgrade("Purchase data on prototype growth hormone tests",
					"Should improve the reliability of growth injections of all kinds.",
					() => { V.injectionUpgrade = 1; }, 25000 * pcSkillCheck, text));
			} else {
				r = [text];
				r.push(`<span class="note">You lack the reputation to obtain prototype medicines.</span>`);
				App.Events.addNode(p, r, "div", "note");
			}
		} else if (V.injectionUpgrade === 1) {
			text += " prototype growth hormones.";
			if (V.rep > 10000) {
				p.append(upgrade("Upgrade the fabricator to customize each slave's growth hormones",
					"Should improve the reliability of growth injections of all kinds.",
					() => { V.injectionUpgrade = 2; }, 50000 * pcSkillCheck, text));
			} else {
				r = [text];
				r.push(`<span class="note">You lack the reputation to obtain prototype fabricator upgrades.</span>`);
				App.Events.addNode(p, r, "div", "note");
			}
		} else if (V.injectionUpgrade === 2) {
			text += " customized growth hormones.";
			if (V.rep > 14000) {
				p.append(upgrade("Upgrade the fabricator with prototype biomechanical microfactories",
					"Should improve the reliability of growth injections of all kinds.",
					() => { V.injectionUpgrade = 3; }, 100000 * pcSkillCheck, text));
			} else {
				r = [text];
				r.push(`<span class="note">You lack the reputation to obtain prototype biomechanical microfactories.</span>`);
				App.Events.addNode(p, r, "div", "note");
			}
		} else {
			App.Events.addNode(p, [text, "the world's most effective growth hormones."], "div");
		}

		text = "The fabricator is producing";
		if (V.hormoneUpgradeMood === 0) {
			text += " standardized hormone replacement therapies.";
			if (V.rep > 2000) {
				p.append(upgrade("Upgrade for individualized therapy", "Should eliminate the occasional moodiness and sexual disinterest caused by generalized therapy.", () => { V.hormoneUpgradeMood = 1; }, 10000 * pcSkillCheck, text));
			} else {
				r = [text];
				r.push(`<span class="note">You lack the reputation to obtain advanced drug manufacturing components.</span>`);
				App.Events.addNode(p, r, "div", "note");
			}
		} else {
			App.Events.addNode(p, [text, "individualized hormone replacement therapies."], "div");
		}

		text = "The hormone replacement therapies";
		if (V.hormoneUpgradePower === 0) {
			text += " are traditional: they're formulated to mimic natural hormones.";
			if (V.rep > 4000) {
				p.append(upgrade("Purchase data on advanced HRT", "Should increase the power of hormone therapies.", () => { V.hormoneUpgradePower = 1; }, 25000 * pcSkillCheck, text));
			} else {
				r = [text];
				r.push(`<span class="note">You lack the reputation to obtain prototype medicines.</span>`);
				App.Events.addNode(p, r, "div", "note");
			}
		} else {
			App.Events.addNode(p, [text, "are advanced: they're formulated to improve on natural hormones."], "div");
		}

		text = "The hormone replacement therapies";
		if (V.hormoneUpgradeShrinkage === 0) {
			text += " are broad-spectrum.";
			if (V.rep > 4000) {
				p.append(upgrade("Purchase data on targeted HRT", "Should reduce atrophy of organs corresponding to original sex.", () => { V.hormoneUpgradeShrinkage = 1; }, 25000 * pcSkillCheck, text));
			} else {
				r = [text];
				r.push(`<span class="note">You lack the reputation to obtain prototype medicines.</span>`);
				App.Events.addNode(p, r, "div", "note");
			}
		} else {
			App.Events.addNode(p, [text, "are targeted, reducing atrophy of organs corresponding to original sex."], "div");
		}

		if (V.precociousPuberty === 1) {
			if (V.pubertyHormones === 0) {
				if (V.rep > 4500 * pcSkillCheck) {
					p.append(upgrade("Fund research into powerful hormonal injections to jumpstart puberty", "Will allow the production of powerful hormonal drugs designed to force a slave through puberty without regard for side effects.", () => { V.pubertyHormones = 1; }, 30000 * pcSkillCheck));
				} else {
					App.Events.addNode(p, ["You lack the reputation to fund forced puberty drugs"], "div", "note");
				}
			} else {
				App.Events.addNode(p, ["The fabricator is producing extra strong hormonal drugs designed to force a slave through puberty."], "div");
			}
		}

		f.append(p);
		return f;
	}

	/**
	 * @returns {DocumentFragment}
	 */
	function diet() {
		const f = new DocumentFragment();
		App.UI.DOM.appendNewElement("h2", f, "Dietary Upgrades");

		let p = document.createElement("p");

		if (V.feeder === 1) {
			if (V.dietXXY === 0) {
				if (V.rep > 3500 * pcSkillCheck) {
					p.append(upgrade("Fund research into developing hermaphrodite hormone therapies", "Will allow for specially balanced meals to be served in the cafeteria designed to promote both halves of a herm's sexuality.", () => { V.dietXXY = 1; }, 10000 * pcSkillCheck));
				} else {
					App.Events.addNode(p, ["You lack the reputation to fund research into hermaphrodite hormones."], "div", "note");
				}
			} else {
				App.Events.addNode(p, ["The fabricator is producing meals to be served in the cafeteria designed to promote both halves of a herm's sexuality."], "div");
			}
		} else {
			App.Events.addNode(p, ["The feeders are incapable of modifying slave diets well enough to adjust hormones for hermaphrodite meals."], "div");
		}

		if (V.seePreg === 1) {
			if (V.feeder === 1) {
				if (V.reproductionFormula === 0) {
					if (V.rep > 10000 * pcSkillCheck) {
						p.append(upgrade("Purchase reputable breeders' dietary blends", "Will allow for specially refined meals to be served in the cafeteria designed to promote energetic sperm and robust pregnancies. Side effects may include an increased number of twins being conceived.", () => { V.reproductionFormula = 1; }, 25000 * pcSkillCheck));
					} else {
						App.Events.addNode(p, ["You lack the reputation to access breeders' dietary blends."], "div", "note");
					}
				} else {
					App.Events.addNode(p, ["The fabricator is producing meals to be served in the cafeteria that promote energetic sperm and robust pregnancies."], "div");
				}
			} else {
				App.Events.addNode(p, ["The feeders are incapable of modifying slave diets well enough to manage to enhance reproductive ability."], "div");
			}
		}

		if (V.cumProDiet === 0) {
			p.append(upgrade("Purchase recipes to encourage cum production", "Will allow for specially designed meals to be served in the cafeteria to promote cum production.", () => { V.cumProDiet = 1; }, 5000 * pcSkillCheck));
		} else {
			App.Events.addNode(p, ["The fabricator is producing meals to be served in the cafeteria designed to promote cum production."], "div");
		}

		if (V.seePreg === 1) {
			if (V.dietFertility === 0) {
				p.append(upgrade("Purchase recipes to encourage ovulation", "Will allow for specially designed meals to be served in the cafeteria to promote slave fertility.", () => { V.dietFertility = 1; }, 5000 * pcSkillCheck));
			} else if (V.dietFertility === 1) {
				App.Events.addNode(p, ["The fabricator is producing meals to be served in the cafeteria designed to promote slave fertility."], "div");
			}
		}

		if (V.dietCleanse === 0) {
			p.append(upgrade("Purchase cleansing recipes to lessen carcinogen buildup", "Will allow for specially designed meals to be served in the cafeteria to counteract excessive drug use.", () => { V.dietCleanse = 1; }, 10000 * pcSkillCheck));
		} else if (V.dietCleanse === 1) {
			App.Events.addNode(p, ["The fabricator is producing meals to be served in the cafeteria designed to counteract excessive drug use and good health. They smell awful and taste worse than they look, but they're healthy."], "div");
		}
		f.append(p);
		return f;
	}

	/**
	 * @returns {DocumentFragment}
	 */
	function pharma() {
		const f = new DocumentFragment();
		App.UI.DOM.appendNewElement("h2", f, "Pharmacological Upgrades");

		let p = document.createElement("p");

		if (V.curativeUpgrade === 0 && V.rep > 6000 * pcSkillCheck) {
			p.append(upgrade("Purchase data on advanced curatives", "Should improve the effectiveness of curative treatment.", () => { V.curativeUpgrade = 1; }, 25000 * pcSkillCheck));
		} else if (V.curativeUpgrade === 1) {
			App.Events.addNode(p, ["The fabricator is producing highly effective curative cocktails."], "div");
		}

		if (V.growthStim === 0 && V.rep > 6000 * pcSkillCheck) {
			p.append(upgrade("Purchase data on growth stimulants", "Will allow the manufacturing of drugs to encourage growth in slave height.", () => { V.growthStim = 1; }, 20000 * pcSkillCheck));
		} else if (V.growthStim === 1) {
			App.Events.addNode(p, ["The fabricator is able to produce growth stimulants."], "div");
		}

		if (V.aphrodisiacUpgradeRefine === 0 && V.rep > 6000 * pcSkillCheck) {
			p.append(upgrade("Purchase data on refined aphrodisiacs", "Will prevent most physical side effects of aphrodisiacs. Once the formulas are changed they cannot be changed back.", () => { V.aphrodisiacUpgradeRefine = 1; }, 20000 * pcSkillCheck));
		} else if (V.aphrodisiacUpgradeRefine === 1) {
			App.Events.addNode(p, ["The fabricator is producing refined aphrodisiacs with limited hormonal effects."], "div");
		}

		if (V.aphrodisiacUpgrade === 0 && V.rep > 6000 * pcSkillCheck) {
			p.append(upgrade("Purchase data on aphrodisiac withdrawal treatment", "Should prevent most negative effects of withdrawal.", () => { V.aphrodisiacUpgrade = 1; }, 10000 * pcSkillCheck));
		} else if (V.aphrodisiacUpgrade === 1) {
			App.Events.addNode(p, ["The fabricator is producing a substitute that will protect slaves from aphrodisiac withdrawal."], "div");
		}

		if (V.healthyDrugsUpgrade === 0) {
			if (V.injectionUpgrade !== 0 && V.curativeUpgrade === 1 && V.aphrodisiacUpgrade === 1) {
				if (V.rep >= 15000 * pcSkillCheck) {
					p.append(upgrade("Fund research into drug formulations without negative physical side effects", "Will prevent the negative side effects of excessive drug usage on your slaves.", () => { V.healthyDrugsUpgrade = 1; }, 500000 * pcSkillCheck));
				} else {
					App.Events.addNode(p, ["You lack the reputation to access the technology necessary to develop advanced drug formulations."], "div", "note");
				}
			} else {
				App.Events.addNode(p, ["You must purchase all other major upgrades before developing advanced drug formulations."], "div", "note");
			}
		} else {
			App.Events.addNode(p, ["The fabricator has been upgraded to optimize the structures of your other drugs, eliminating their negative side effects."], "div");
		}

		if (V.arcologies[0].FSBodyPuristLaw === 1) {
			App.Events.addNode(p, ["The pharmaceutical fabricator is working with your body purist arcology to reduce long term drug side effects."], "div", "note");
		}

		f.append(p);
		return f;
	}

	/**
	 * @returns {DocumentFragment}
	 */
	function fertility() {
		const f = new DocumentFragment();

		App.UI.DOM.appendNewElement("h2", f, "Fertility Focused Pharmacology");

		let p = document.createElement("p");

		if (V.seeHyperPreg === 1) {
			if (V.pregSpeedControl === 1) {
				App.Events.addNode(p, ["The fabricator is producing extremely complex gestation control agents. They can be used to control gestation speed, and even suppress labor for some time."], "div");
			} else if (V.superFertilityDrugs === 1 && V.rep > 10000 * pcSkillCheck) {
				p.append(upgrade("Fund research pregnancy speed control methods", "Fund underground research labs to develop methods for controlling pregnancy progress.", () => {
					V.pregSpeedControl = 1;
					V.clinicSpeedGestation = 0;
				}, 200000 * pcSkillCheck));
			} else if (V.rep <= 10000 * pcSkillCheck) {
				App.Events.addNode(p, ["You lack the reputation required to contact underground research labs to develop methods for controlling pregnancy progress."], "div", "note");
			}
		} else if (V.birthsTotal > 10) {
			if (V.pregSpeedControl === 1) {
				App.Events.addNode(p, ["The fabricator is producing extremely complex gestation control agents. They can be used to control gestation speed, and even suppress labor for some time."], "div");
			} else if (V.rep > 10000 * pcSkillCheck) {
				p.append(upgrade("Fund research pregnancy speed control methods", "Fund underground research labs to develop methods for controlling pregnancy progress.", () => {
					V.pregSpeedControl = 1;
					V.clinicSpeedGestation = 0;
				}, 200000 * pcSkillCheck));
			} else if (V.rep <= 10000 * pcSkillCheck) {
				App.Events.addNode(p, ["You lack the reputation required to contact underground research labs to develop methods for controlling pregnancy progress."], "div", "note");
			}
		} else {
			App.Events.addNode(p, ["You lack the experience handling pregnant slaves required to convince underground research labs to do business with you in the development of controlled fetal development."], "div", "note");
		}

		if (V.superFertilityDrugs === 0 && V.rep > 2500 * pcSkillCheck && V.seeHyperPreg === 1) {
			p.append(upgrade("Purchase data on powerful fertility drugs", "Should improve the likelihood of conception and multiples.", () => { V.superFertilityDrugs = 1; }, 20000 * pcSkillCheck));
		} else if (V.superFertilityDrugs === 1) {
			App.Events.addNode(p, ["The fabricator is producing highly effective fertility agents. There is a warning present involving overdosing and instances of ten or more children."], "div");
		}

		f.append(p);
		return f;
	}

	function futureSociety() {
		const f = new DocumentFragment();

		App.UI.DOM.appendNewElement("h2", f, "Future Societies Research");
		let p = document.createElement("p");

		if (V.ImplantProductionUpgrade === 1 && V.arcologies[0].FSTransformationFetishistDecoration >= 100) {
			if (V.arcologies[0].FSTransformationFetishistResearch === 0 && V.rep <= 5000 * pcSkillCheck) {
				App.Events.addNode(p, ["You lack the reputation to access experimental gigantic implants and elasticizing filler."], "div", "note");
			} else if (V.arcologies[0].FSTransformationFetishistResearch === 0) {
				p.append(upgrade("Purchase data on gigantic implants and elasticizing filler", "Will allow the fabrication of gigantic implants using the autosurgery and filler capable of overfilling existing fillable implants.", () => { V.arcologies[0].FSTransformationFetishistResearch = 1; }, 20000 * pcSkillCheck));
			} else if (V.arcologies[0].FSTransformationFetishistResearch > 0) {
				App.Events.addNode(p, ["The fabricator is capable of crafting gigantic implants and elasticizing filler designed to overfill existing implants."], "div");
			}
		} else if (V.arcologies[0].FSTransformationFetishistResearch === 1) {
			App.Events.addNode(p, ["The fabricator is capable of crafting gigantic implants and elasticizing filler designed to overfill existing implants."], "div");
		} else {
			App.Events.addNode(p, ["Transformation Fetishist focused research unavailable."], "div", "note");
		}

		if (V.arcologies[0].FSAssetExpansionistResearch === 1) {
			App.Events.addNode(p, ["The fabricator has been upgraded to manufacture extremely powerful growth drugs."], "div");
		} else if (V.arcologies[0].FSAssetExpansionistDecoration === 100) {
			if (V.rep >= 5000 * pcSkillCheck) {
				p.append(upgrade("Fund research into drug formulations for growth without limit", "Will allow creation of drugs to push assets to unthinkable sizes.", () => { V.arcologies[0].FSAssetExpansionistResearch = 1; }, 30000 * pcSkillCheck));
			} else {
				App.Events.addNode(p, ["You lack the reputation to access the research necessary to develop advanced growth drug formulations."], "div", "note");
			}
		} else {
			App.Events.addNode(p, ["Asset Expansionist focused research unavailable."], "div", "note");
		}

		if (V.arcologies[0].FSSlaveProfessionalismResearch === 1) {
			App.Events.addNode(p, ["The fabricator has been upgraded to manufacture a compound that steadily improves intelligence."], "div");
		} else if (V.arcologies[0].FSSlaveProfessionalismDecoration === 100) {
			if (V.rep >= 5000 * pcSkillCheck) {
				p.append(upgrade("Fund research into producing an intelligence boosting compound", "Will allow the creation of a drug that improves mental faculties.", () => { V.arcologies[0].FSSlaveProfessionalismResearch = 1; }, 60000 * pcSkillCheck));
			} else {
				App.Events.addNode(p, ["You lack the reputation to access the research necessary to produce an intelligence boosting compound."], "div", "note");
			}
		} else {
			App.Events.addNode(p, ["Slave Professionalism focused research unavailable."], "div", "note");
		}

		if (V.arcologies[0].FSSlimnessEnthusiastResearch === 1) {
			App.Events.addNode(p, ["The fabricator has been upgraded to manufacture growth reversing drugs."], "div");
		} else if (V.arcologies[0].FSSlimnessEnthusiastDecoration === 100) {
			if (V.rep >= 5000 * pcSkillCheck) {
				p.append(upgrade("Fund research into drug formulations for slimming slaves", "Will allow creation of drugs to shrink assets.", () => { V.arcologies[0].FSSlimnessEnthusiastResearch = 1; }, 30000 * pcSkillCheck));
			} else {
				App.Events.addNode(p, ["You lack the reputation to access the research necessary to develop asset reducing drug formulations."], "div", "note");
			}
		} else {
			App.Events.addNode(p, ["Slimness Enthusiast focused research unavailable."], "div", "note");
		}

		if (V.arcologies[0].FSYouthPreferentialistResearch === 1) {
			App.Events.addNode(p, ["The fabricator has been upgraded to manufacture extremely effective beauty creams designed to combat aging."], "div");
		} else if (V.arcologies[0].FSYouthPreferentialistDecoration === 100) {
			if (V.rep >= 5000 * pcSkillCheck) {
				p.append(upgrade("Fund research into skin care designed to reverse the effects of aging", "Will allow creation of beauty creams designed to make slaves look young again.", () => { V.arcologies[0].FSYouthPreferentialistResearch = 1; }, 30000 * pcSkillCheck));
			} else {
				App.Events.addNode(p, ["You lack the reputation to access the research necessary to develop beauty creams designed to make slaves look young again."], "div", "note");
			}
		} else {
			App.Events.addNode(p, ["Youth Preferentialist focused research unavailable."], "div", "note");
		}

		if (V.arcologies[0].FSHedonisticDecadenceDecoration === 100) {
			if (V.arcologies[0].FSHedonisticDecadenceResearch === 0) {
				if (V.rep >= 5000 * pcSkillCheck) {
					p.append(upgrade("Purchase recipes for concentrated, shaped slave food", `Will allow production of solid slave food in various familiar shapes and flavors. Addictive and a little fatty.${(V.arcologies[0].FSDegradationist === "unset" ? "" : " Since your slaves don't deserve luxuries, a modified recipe formulated to cause severe stomach cramps minutes after ingestion will be developed.")}`, () => { V.arcologies[0].FSHedonisticDecadenceResearch = 1; }, 50000 * pcSkillCheck));
				} else {
					App.Events.addNode(p, ["You lack the reputation to access the research necessary to purchase concentrated, shaped slave food recipes."], "div", "note");
				}
			} else {
				let text = `The fabricator has been upgraded to manufacture tasty, extremely addictive, solid slave food in various familiar shapes and flavors. While they look and taste like real food, their consistency is all wrong. Slaves gorging on them are likely to experience steady weight gain.${(V.arcologies[0].FSDegradationist === "unset" ? "" : " Since your slaves don't deserve luxuries, all food crafted will cause severe stomach cramps minutes after ingestion. Coupled with their addictive nature, it ought to be quite torturous.")}`;
				if (V.arcologies[0].FSSlimnessEnthusiast > 50 && V.arcologies[0].FSHedonisticDecadenceDietResearch === 0) {
					p.append(upgrade("Purchase diet recipes", "Will prevent rampant weight gain from ruining your slim slaves.", () => { V.arcologies[0].FSHedonisticDecadenceDietResearch = 1; }, 10000 * pcSkillCheck, text));
				} else if (V.arcologies[0].FSHedonisticDecadenceDietResearch === 1) {
					App.Events.addNode(p, [text, "A diet recipe is being utilized to prevent unwanted weight gain."], "div");
				}
			}
		} else if (V.arcologies[0].FSHedonisticDecadenceResearch === 1) {
			let text = `The fabricator has been upgraded to manufacture tasty, extremely addictive, solid slave food in various familiar shapes and flavors. While they look and taste like real food, their consistency is all wrong. Slaves gorging on them are likely to experience steady weight gain.${V.arcologies[0].FSDegradationist === "unset" ? "" : "Since your slaves don't deserve luxuries, all food crafted will cause severe stomach cramps minutes after ingestion. Coupled with their addictive nature, it ought to be quite torturous."}`;
			if (V.arcologies[0].FSHedonisticDecadenceDietResearch === 0) {
				p.append(upgrade("Purchase diet recipes", `Will prevent rampant unwanted weight gain from ruining your ${V.arcologies[0].FSSlimnessEnthusiast > 20 ? "slim " : ""}slaves.`, () => { V.arcologies[0].FSHedonisticDecadenceDietResearch = 1; }, 10000 * pcSkillCheck));
			} else if (V.arcologies[0].FSHedonisticDecadenceDietResearch === 1) {
				App.Events.addNode(p, [text, "A diet recipe is being utilized to prevent unwanted weight gain."], "div");
			}

			App.UI.DOM.appendNewElement("div", p, App.UI.DOM.link("Cancel solid slave food production", () => {
				V.arcologies[0].FSHedonisticDecadenceResearch = 0;
				V.merchantFSWares.push("HedonisticDecadenceResearch");
				refresh();
			}), "indent");
			App.Events.addNode(p, ["Will <span class=\"noteworthy\">completely</span> remove this research."]);
		} else {
			App.Events.addNode(p, ["Hedonistic Decadence focused research unavailable."], "div", "note");
		}
		f.append(p);
		return f;
	}
};


code:
App.Facilities.ConcubineSelect = function() {
	const f = document.createDocumentFragment();

	if (S.Concubine) {
		f.append(`${SlaveFullName(S.Concubine)} is your Concubine, taking the lead in seeing to your pleasure. `);
		f.append(App.UI.DOM.link("Remove Concubine", () => {
			removeJob(S.Concubine, Job.CONCUBINE);
		},
		[], "Master Suite"
		));
	} else {
		f.append(`No Concubine assigned, appoint one from your devoted slaves.`);
	}

	f.append(App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.masterSuite, "Master Suite"));
	return f;
};