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[]} notes
	 * @param {function(): void} callback
	 * @param {number} cost
	 * @param {string} [existingDesc=""]
	 * @returns {DocumentFragment}
	 */
	function upgrade(name, notes, callback, cost, existingDesc = "") {
		const f = new DocumentFragment();
		r = [];
		if (existingDesc !== "") {
			r.push(existingDesc);
		}
		r.push(makePurchase(name, cost, "capEx", {
			handler: callback,
			notes,
			refresh,
		}));

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

		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.${(!FutureSocieties.isActive('FSDegradationist') ? "" : " 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.${(!FutureSocieties.isActive('FSDegradationist') ? "" : " 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.${!FutureSocieties.isActive('FSDegradationist') ? "" : "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;
};

repo_name: Arkerthan/fc

license: mit


code:
App.Facilities.MasterSuite.masterSuite = class MasterSuite extends App.Facilities.Facility {
	constructor() {
		const masterSuite = App.Entity.facilities.masterSuite;
		const decommissionHandler = () => {
			V.masterSuite = 0;
			V.masterSuiteUpgradeLuxury = 0;
			V.masterSuitePregnancySlaveLuxuries = 0;
			V.masterSuiteDecoration = "standard";
			V.masterSuitePregnancyFertilityDrugs = 0;
			V.masterSuitePregnancyFertilitySupplements = 0;
			V.masterSuiteUpgradePregnancy = 0;
			V.masterSuiteHyperPregnancy = 0;
		};

		super(
			masterSuite,
			decommissionHandler,
		);

		V.nextButton = "Back to Main";
		V.nextLink = "Main";
		App.UI.StoryCaption.encyclopedia = "Master Suite";

		this.pregnantSlaves = 0;
		this.pregnantWithMultiples = 0;
		this.hyperPregnantSlaves = 0;
		this.currentSlaves = App.Utils.sortedEmployees(App.Entity.facilities.masterSuite);

		if (S.Concubine && S.Concubine.pregKnown) {
			this.pregnantSlaves++;

			if (S.Concubine.pregType > 1) {
				this.pregnantWithMultiples++;
			}

			if (S.Concubine.pregType > 1 && S.Concubine.bellyPreg >= 300000) {
				this.hyperPregnantSlaves++;
			}
		}

		for (const slave of this.currentSlaves) {
			if (slave.pregKnown) {
				this.pregnantSlaves++;

				if (slave.pregType > 1) {
					this.pregnantWithMultiples++;
				}

				if (slave.pregType > 1 && slave.bellyPreg >= 300000) {
					this.hyperPregnantSlaves++;
				}
			}
		}
	}

	/** @returns {HTMLDivElement} */
	get slaves() {
		const div = document.createElement("div");
		if (this.facility.manager) {
			div.append(App.UI.SlaveList.displayManager(this.facility));
		}
		div.append(App.UI.SlaveList.listSJFacilitySlaves(this.facility, passage(), true, undefined, App.UI.SlaveList.Decoration.personalAttention));
		return div;
	}

	/** @returns {string} */
	get intro() {
		const text = [];

		const avg = App.Utils.masterSuiteAverages();

		text.push(`${this.facility.nameCaps} is furnished`, this.decorations);

		if (V.masterSuiteUpgradeLuxury === 1) {
			text.push(`It is full of luxuries of all kinds. The slaves here live free of want or worry, and have everything except their freedom. Their only duties are to please you and look after the suite and one another.`);

			if (this.currentSlaves.length > 2) {
				text.push(`It's busy with slaves, so many that they are able to rotate through keeping themselves perfect and ready for your pleasure. The slaves not on call at the moment are beautifying themselves, cleaning, or serving others.`);

				if (this.pregnantSlaves > 2 && this.pregnantWithMultiples < 2) {
					text.push(`Many of the slaves are pregnant, and they walk around proudly displaying their bellies and the new slaves growing inside them.`);
				} else if (this.hyperPregnantSlaves > 2) {
					text.push(`Many of the slaves are heavily pregnant with multiple children, and they waddle around, if capable, proudly displaying their distended bulging bellies and the next generation of slaves growing within them.`);
				} else if (this.pregnantWithMultiples > 2) {
					text.push(`Many of the slaves are pregnant with multiple children, and they walk around proudly displaying their distended bellies and the next generation of slaves growing within them.`);
				}
			} else if (this.currentSlaves.length > 0) {
				text.push(`It's sparsely populated, so that the few slaves here have to work hard and quickly to ensure that an assortment of sex slaves is perfect and ready for your pleasure at any given moment.`);
			} else {
				text.push(`None of your slaves are serving here.`);
			}
		} else if (V.masterSuiteUpgradeLuxury === 2) {
			text.push(`The true focus of the suite is, however, the fuckpit. This stepped depression in the middle of the floor`);

			if (this.currentSlaves.length > 3) {
				text.push(`is filled by cushions and every slave in the suite who isn't sleeping, eating, or bathing.`);

				if (avg.energy > 90) {
					text.push(`They're having energetic group sex; most of them are fucking and being fucked at the same time.`);
				} else if (avg.energy > 60) {
					text.push(`They're having group sex; most of them are in active sexual contact with more than one partner.`);
				} else {
					text.push(`They're having languid group sex; more than one slave is dozing while another plays with their body.`);
				}
				if (avg.energy > 90) {
					text.push(`The pit features automated cleaning systems, which are quite necessary.`);

					if (avg.dick > 4) {
						text.push(`With so many huge cocks in the fuckpit, every hole available is frequently fucked vigorously.`);
					}

					if (avg.cum > 4) {
						text.push(`The slaves' bodies grow more coated with cum, and more of the white stuff drips from their holes, until they take a break for a shower.`);
					}

					if (avg.milk > 4000) {
						text.push(`Most of them cannot tear themselves away (or cannot escape) for a normal machine milking, so their tender, overfull breasts squirt milk whenever anyone touches them. The lowest level of the fuckpit is a pool of milk.`);
					}
				}

				if (this.pregnantSlaves > 2 && this.pregnantWithMultiples < 2) {
					text.push(`Many of the slaves are pregnant, and more than one has her face buried in the cunt directly below a gravid belly while she lovingly massages her own.`);
				} else if (this.hyperPregnantSlaves > 2) {
					text.push(`Many of the slaves are heavily pregnant with multiple children, and more than one has her face buried in the cunt directly below a massively overburdened belly while she lovingly massages her own distended squirming stomach.`);
				} else if (this.pregnantWithMultiples > 2) {
					text.push(`Many of the slaves are pregnant with multiple children, and more than one has her face buried in the cunt directly below a grossly swollen belly while she lovingly massages her own distended stomach.`);
				}
			} else if (this.currentSlaves.length > 0) {
				text.push(`has a few lonely-looking fucktoys in it, badly outnumbered by the cushions.`);
			} else {
				text.push(`is desolate and unpopulated.`);
			}
		} else {
			if (this.currentSlaves.length > 2) {
				text.push(`It's busy with slaves, so many that they are able to rotate through keeping themselves perfect and ready for your pleasure. The slaves not on call at the moment are beautifying themselves, cleaning, or serving others.`);

				if (this.pregnantSlaves > 2 && this.pregnantWithMultiples < 2) {
					text.push(`Many of the slaves are pregnant, and they walk around proudly displaying their bellies and the new slaves growing inside them.`);
				} else if (this.hyperPregnantSlaves > 2) {
					text.push(`Many of the slaves are heavily pregnant with multiple children, and they waddle around, if capable, proudly displaying their distended bulging bellies and the next generation of slaves growing within them.`);
				} else if (this.pregnantWithMultiples > 2) {
					text.push(`Many of the slaves are pregnant with multiple children, and they walk around proudly displaying their distended bellies and the next generation of slaves growing within them.`);
				}
			} else if (this.currentSlaves.length > 0) {
				text.push(`It's sparsely populated, so that the few slaves here have to work hard and quickly to ensure that an assortment of sex slaves is perfect and ready for your pleasure at any given moment.`);
			} else {
				text.push(`None of your slaves are serving here.`);
			}
		}

		return text.join(' ');
	}

	/** @returns {string} */
	get decorations() {
		/** @type {FC.Facilities.Decoration} */
		let FS = null;

		if (V.masterSuiteUpgradeLuxury === 1) {
			FS = {
				"Roman Revivalist": `as a Roman emperor's apartment. There is a small shrine to the old gods the ${properMaster()} favors in a side room, and the flooring is erotic mosaic. Pride of place is given to a set of low couches placed together, capable of accommodating many nude bodies.`,
				"Neo-Imperialist": `as an apartment worthy of a modern-day Emperor. The highest of technology decorates every space, allowing you to remain in constant communication with the rest of the arcology - your fledgling empire - even when in your room. The ${properMaster()}'s suite is an elaborate shrine to your many victories, fitted with many low couches to fit a whole harem inside, and the banners of your house hang around you on every side. The centerpiece of your personal apartment is a massive tapestry, designed in ancient style and depicting the creation of your Arcology from the collapsing Old World, all the way up to the modern day, with you standing over a great cheering crowd in your golden crown. You wonder for a moment if you'll have to commission more tapestries as the Arcology advances further.`,
				"Aztec Revivalist": `as an Aztec cultural, spiritual and military leader of the city you're allowed great leniency. The ${properMaster()}'s room is created to gratify you as a true god of the people.`,
				"Egyptian Revivalist": `after the royal room of an ancient Egyptian palace. There is a small shrine to the old gods the ${properMaster()} favors in a side room, and linen hangings decorate the walls and ceiling. An imposing bed of sandalwood occupies the center of the room.`,
				"Edo Revivalist": `in the spartan style of an Edo period castle's innermost rooms. Rice paper screens partition off many small cubicles around its large central space. There, around a low bed, there are many mats for servants to kneel around their ${properMaster()}.`,
				"Arabian Revivalist": `as a beguiling haze of Arabian decadence. There is a great gilded bed in the center of the space, piled with silk pillows for naked bodies to recline on. Gauzy curtains flutter in the warm, heady breeze.`,
				"Chinese Revivalist": `as though it were the innermost sanctum of the Forbidden City. A massive bed fills the central space. The walls are gorgeous gilded hand-carved screens, and heavy jade statues of favored gods crouch in the corners.`,
				"Antebellum Revivalist": `is furnished with heavy, black oaken furniture intricately carved and inlaid with mother of pearl. A massive canopied bed draped in sheer chiffon curtains is the centerpiece. A cozy sitting area, prominently featuring a royal divan upholstered in a deep purple fabric, lies about a grand fireplace with marble façade. Large windows framed in exotic hardwood imported from North America give a wonderful, top-down view of the arcology below.`,
				"Chattel Religionist": `as a severe place of cold stone and hard wood. A single shaft of sunlight illuminates an enormous stone platform that serves as a bed where penitents give their bodies to their ${properMaster()}.`,
				"Degradationist": `with a gothic grandeur. Blood-red upholstery and hardwood menace crouch in the center of the space in the form of a massive poster bed with curtains of chain mail.`,
				"Repopulationist": `comfortably, with lots of cushions and seats for pregnant slaves to lounge on. Various specialized toys, as well as, lotions and creams are readily available. There's a huge, reinforced, low to the ground bed in the middle of the suite.`,
				"Eugenics": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make fucking slave girls lots of fun. There's a huge bed in the middle of the suite, with hidden compartments containing condoms and spermicides.`,
				"Asset Expansionist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with stacked slaves as fun as possible. There's a huge bed in the middle of the suite, heavily reinforced.`,
				"Transformation Fetishist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with bimbo slaves as fun as possible. There's a huge bed in the middle of the suite, heavily reinforced.`,
				"Gender Radicalist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make fucking slave girls in the butt lots of fun. There's a huge bed in the middle of the suite, with straps to restrain slave girls who don't want to be fucked in the butt, but they're concealed for now.`,
				"Gender Fundamentalist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make fucking slave girls nice and enjoyable. There's a huge bed in the middle of the suite, with straps to restrain slave girls who don't want to be fucked, but they're concealed for now.`,
				"Physical Idealist": `as a shrine to the owner's body. Athletic trophies and photographs of past victories line the walls. There's a huge bed in the middle of the space, and there are mirrors almost everywhere, including on the ceiling over the bed.`,
				"Supremacist": `like the royal bedroom in a palace in the old countries of ${V.arcologies[0].FSSupremacistRace} people. A massive four-poster bed dominates the space.`,
				"Subjugationist": `like the royal bedroom in a palace in the old countries which favored ${V.arcologies[0].FSSubjugationistRace} slaves. A massive four-poster bed dominates the space.`,
				"Paternalist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with slaves mutually enjoyable.`,
				"Pastoralist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants. The space is dominated by a massive, reinforced bed, built in sections so that part of it can be cleaned while cream-squirting cows cavort on the rest.`,
				"Maturity Preferentialist": `comfortably, with elegant sex toys and perfumed lubricants designed to appeal to mature sex slaves. The space is dominated by a broad, soft bed, well supplied with pillows. It's the perfect place to relax with a harem of MILFs.`,
				"Youth Preferentialist": `comfortably, with pastel-colored sex toys and flavored lubricants designed to appeal to eager young sex slaves. The space is dominated by a broad, reinforced bed, without cushions or sheets, which would just get in the way of energetic sex.`,
				"Body Purist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with slaves mutually enjoyable. The space is dominated by a huge bed with soft sheets.`,
				"Slimness Enthusiast": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with slaves mutually enjoyable. The space is dominated by a huge bed with soft sheets.`,
				"Hedonistic": `comfortably, with lots of lounges for a hefty slaves to relax on. ${V.arcologies[0].FSHedonisticDecadenceResearch === 1 ? `Platters of food and treats are readily available throughout the room and are` : `Slave food is readily available for your harem and platters of food for yourself are`} never out of arm's reach. There's a huge, reinforced, low to the ground bed in the middle of the suite.`,
				"Intellectual Dependency": `comfortably, with lots of easy-to-clean leather and plentiful easy-to-use tools, toys, and lubricants to make sex with bimbo slaves as fun and simple as possible. There's a huge bed in the middle of the suite, heavily reinforced.`,
				"Slave Professionalism": `comfortably, with complex sex toys and tools designed to maximize pleasure when used by skilled hands. The space is dominated by a broad, soft bed, well supplied with pillows. The rest is dedicated to perfecting oneself and boosting ${properMaster()}'s status ever higher.`,
				"Petite Admiration": `comfortably, with plentiful tools, toys, lubricants and a bevy of stepping stools to accommodate even the shortest slave. There's a huge, reinforced, low to the ground bed in the middle of the suite.`,
				"Statuesque Glorification": `comfortably, though designed for slaves of the taller variety. Short slaves will find the furniture, and the room's centerpiece, a massive four-poster bed, woefully out of their reach.`,
				"standard": `in a refined, yet practical style. It's dominated by a huge bed in which many slaves could serve their ${properTitle()} and then cuddle afterward.`,
			};
		} else if (V.masterSuiteUpgradeLuxury === 2) {
			FS = {
				"Roman Revivalist": `as a Roman emperor's apartment. There is a small shrine to the old gods the ${properTitle()} favors in a side room, and the flooring is erotic mosaic.`,
				"Neo-Imperialist": `as an apartment worthy of a modern-day Emperor. The highest of technology decorates every space, allowing you to remain in constant communication with the rest of the arcology - your fledgling empire - even when in your room. The ${properMaster()}'s suite is an elaborate shrine to your many victories, fitted with a large bed with hanging golden bedposts, and the banners of your house hang around you on every side. The centerpiece of your personal apartment is a massive tapestry, designed in ancient style and depicting the creation of your Arcology from the collapsing Old World, all the way up to the modern day, with you standing over a great cheering crowd in your golden crown. You wonder for a moment if you'll have to commission more tapestries as the Arcology advances further.`,
				"Aztec Revivalist": `as an Aztec cultural, spiritual and military leader of the city you're allowed great leniency. The ${properTitle()}'s room is created to gratify you as a true god of the people.`,
				"Egyptian Revivalist": `after the royal room of an ancient Egyptian palace. There is a small shrine to the old gods the ${properTitle()} favors in a side room, and linen hangings decorate the walls and ceiling.`,
				"Edo Revivalist": `in the spartan style of an Edo period castle's innermost rooms. Rice paper screens partition off many small cubicles around its large central space.`,
				"Arabian Revivalist": `as a beguiling haze of Arabian decadence. Gauzy curtains flutter in the warm, heady breeze.`,
				"Chinese Revivalist": `as though it were the innermost sanctum of the Forbidden City. The walls are gorgeous gilded hand-carved screens, and heavy jade statues of favored gods crouch in the corners.`,
				"Antebellum Revivalist": `is furnished with heavy, black oaken furniture intricately carved and inlaid with mother of pearl. A cozy sitting area, prominently featuring a royal divan upholstered in a deep purple fabric, lies about a grand fireplace with marble façade. Large windows framed in exotic hardwood imported from North America give a wonderful, top-down view of the arcology below.`,
				"Chattel Religionist": `as a severe place of cold stone and hard wood. A single shaft of sunlight illuminates the central space.`,
				"Degradationist": `with a gothic grandeur. Blood-red upholstery and hardwood menace decorate the walls.`,
				"Repopulationist": `comfortably, with lots of cushions and seats for a pregnant slaves to lounge on. There are various specialized toys, as well as, lotions and creams readily available.`,
				"Eugenics": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make fucking slave girls lots of fun. Condoms and spermicides are readily available throughout the suite.`,
				"Asset Expansionist": `comfortably, with the convenience of massive-breasted slaves in mind. There are lots of handrails, cushions, and low tables, covered with creams, lubricants, and sex toys.`,
				"Transformation Fetishist": `comfortably, with the convenience of bimbos in mind. There are lots of makeup dressers with mirrors, stripper poles, and low tables, covered with creams, lubricants, and sex toys.`,
				"Gender Radicalist": `comfortably, with the convenience of dickgirls in mind. There are lots of makeup dressers with mirrors, stripper poles, and low tables, covered with creams, lubricants, and vibrating butt plugs.`,
				"Gender Fundamentalist": `comfortably, with the convenience and pleasure of slavegirls in mind. There are lots of makeup dressers with mirrors, soft divans, and low tables, covered with creams, lubricants, and vibrators.`,
				"Physical Idealist": `as a shrine to the owner's body. Athletic trophies and photographs of past victories line the walls. The entire area is filled with the heady odors of sweat, metabolites, and sex.`,
				"Supremacist": `like the royal bedroom in a palace in the old countries of ${V.arcologies[0].FSSupremacistRace} people.`,
				"Subjugationist": `like the royal bedroom in a palace in the old countries which favored ${V.arcologies[0].FSSubjugationistRace} slaves.`,
				"Paternalist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with slaves mutually enjoyable.`,
				"Pastoralist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants, with a distinct focus on mammary intercourse.`,
				"Maturity Preferentialist": `comfortably, with elegant sex toys and perfumed lubricants designed to appeal to mature sex slaves.`,
				"Youth Preferentialist": `comfortably, with pastel-colored sex toys and flavored lubricants designed to appeal to eager young sex slaves.`,
				"Body Purist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with slaves mutually enjoyable.`,
				"Slimness Enthusiast": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with slaves mutually enjoyable.`,
				"Hedonistic": `comfortably, with lots of lounges for a hefty slaves to relax on. ${V.arcologies[0].FSHedonisticDecadenceResearch === 1 ? `Platters of food and treats are readily available throughout the room and are` : `Slave food is readily available for your harem and platters of food for yourself are`} never out of arm's reach.`,
				"Intellectual Dependency": `comfortably, with lots of easy-to-clean leather and plentiful easy-to-use tools, toys, and lubricants to make sex with bimbo slaves as fun and simple as possible.`,
				"Slave Professionalism": `comfortably, with complex sex toys and tools designed to maximize pleasure when used by skilled hands. The space is largely dedicated to perfecting oneself and boosting ${properMaster()}'s status ever higher.`,
				"Petite Admiration": `comfortably, with plentiful tools, toys, lubricants and a bevy of stepping stools to accommodate even the shortest slave.`,
				"Statuesque Glorification": `comfortably, though designed for slaves of the taller variety. Short slaves will find the furniture woefully out of their reach.`,
				"standard": `in a refined, yet practical style.`,
			};
		} else {
			FS = {
				"Roman Revivalist": `as a Roman patrician's apartment. There is a small shrine to the old gods the ${properTitle()} favors in a side room, and the flooring is erotic mosaic.`,
				"Neo-Imperialist": `as an apartment worthy of a modern-day King. The highest of technology decorates every space, allowing you to remain in constant communication with the rest of the arcology - your fledgling empire - even when in your room. The ${properMaster()}'s suite is an elaborate shrine to your many victories, fitted with a king-sized pod-bed, and the banners of your house hang around you on every side. The centerpiece of your personal apartment is a massive tapestry, designed in ancient style and depicting the creation of your Arcology from the collapsing Old World, all the way up to the modern day, with you standing over a great cheering crowd in your golden crown. You wonder for a moment if you'll have to commission more tapestries as the Arcology advances further.`,
				"Aztec Revivalist": `as an Aztec cultural, spiritual and military leader of the city you're allowed great leniency. The ${properTitle()}'s room is created to gratify you as a true god of the people.`,
				"Egyptian Revivalist": `after the best room of an ancient Egyptian mansion. There is a small shrine to the old gods the ${properTitle()} favors in a side room, and linen hangings decorate the walls and ceiling.`,
				"Edo Revivalist": `in the spartan style of an Edo period mansion's innermost rooms. Rice paper screens divide it into subsections, each of which contains little more than a low bed.`,
				"Arabian Revivalist": `as a beguiling haze of Arabian decadence. Soft cushions are scattered across the floor and piled against the walls to provide something for dusky, naked bodies to recline on. Gauzy curtains partition the room into a number of cozy dens.`,
				"Chinese Revivalist": `like the mansion of a senior mandarin of ancient China. The walls are gorgeous hand-carved wooden screens, and heavy jade statues of favored gods crouch in the corners.`,
				"Antebellum Revivalist": `after the master bedroom of a palatial plantation house. A cozy sitting area, prominently featuring a royal divan upholstered in a deep purple fabric, lies about a grand fireplace with marble façade. Large windows framed in exotic hardwood imported from North America give a wonderful, top-down view of the arcology below.`,
				"Chattel Religionist": `as a severe place of cold stone and hard wood. A single shaft of sunlight illuminates the bed where penitents give their bodies to their ${properTitle()}.`,
				"Repopulationist": `comfortably, with lots of cushions and seats for a pregnant slaves to lounge on. Various specialized toys, as well as, lotions and creams are readily available.`,
				"Eugenics": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make fucking slave girls lots of fun. Condoms and spermicides are readily available throughout the suite.`,
				"Degradationist": `with a gothic grandeur. Blood-red upholstery and hardwood menace. There are numerous places where resistant slaves can be restrained.`,
				"Asset Expansionist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with stacked slaves as fun as possible.`,
				"Transformation Fetishist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with bimbo slaves as fun as possible.`,
				"Gender Radicalist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make fucking slave girls in the butt lots of fun. The straps to restrain slave girls who don't want to be fucked in the butt are concealed for now.`,
				"Gender Fundamentalist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make fucking slave girls nice and enjoyable. The straps to restrain slave girls who don't want to be fucked are concealed for now.`,
				"Physical Idealist": `as a shrine to the owner's body. Athletic trophies and photographs of past victories line the walls. There are mirrors almost everywhere, including on the ceiling over the bed.`,
				"Supremacist": `like the master bedroom in a mansion in the old countries of ${V.arcologies[0].FSSupremacistRace} people.`,
				"Subjugationist": `like the master bedroom in a mansion in the old countries which favored ${V.arcologies[0].FSSubjugationistRace} slaves.`,
				"Paternalist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with slaves mutually enjoyable.`,
				"Pastoralist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants. Everything that isn't waterproof is covered in plastic, to catch errant milk.`,
				"Maturity Preferentialist": `comfortably, with elegant sex toys and perfumed lubricants designed to appeal to mature sex slaves.`,
				"Youth Preferentialist": `comfortably, with pastel-colored sex toys and flavored lubricants designed to appeal to eager young sex slaves.`,
				"Body Purist": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with slaves mutually enjoyable.`,
				"Slimness Enthusiast": `comfortably, with lots of easy-to-clean leather and plentiful tools, toys, and lubricants to make sex with slaves mutually enjoyable.`,
				"Hedonistic": `comfortably, with lots of lounges for a hefty slaves to relax on. ${V.arcologies[0].FSHedonisticDecadenceResearch === 1 ? `Platters of food and treats are readily available throughout the room and are` : `Slave food is readily available for your harem and platters of food for yourself are`} never out of arm's reach.`,
				"Intellectual Dependency": `comfortably, with lots of easy-to-clean leather and plentiful easy-to-use tools, toys, and lubricants to make sex with bimbo slaves as fun and simple as possible.`,
				"Slave Professionalism": `comfortably, with complex sex toys and tools designed to maximize pleasure when used by skilled hands. The space is largely dedicated to perfecting oneself and boosting ${properMaster()}'s status ever higher.`,
				"Petite Admiration": `comfortably, with plentiful tools, toys, lubricants and a bevy of stepping stools to accommodate even the shortest slave.`,
				"Statuesque Glorification": `comfortably, though designed for slaves of the taller variety. Short slaves will find the furniture woefully out of their reach.`,
				"standard": `comfortably, as a fairly normal luxury suite. It is unusually large, to accommodate as large a stable of sex slaves as strikes your fancy.`,
			};
		}

		const res = FS[V.masterSuiteDecoration];

		if (!res) {
			throw new Error(`Unknown V.masterSuiteDecoration value of '${V.masterSuiteDecoration}' found in decorations().`);
		}

		return res;
	}

	/** @returns {FC.Facilities.Expand} */
	get expand() {
		return {
			amount: 2,
			desc: `${capFirstChar(V.masterSuiteName)} has room for ${numberWithPluralOne(V.masterSuite, "slave")} to live comfortably${V.masterSuiteUpgradeLuxury === 2
				? ` in the moments when they're not in the fuckpit`
				: V.masterSuiteUpgradeLuxury === 1 ? ` on its huge bed` : ``}. There ${this.facility.hostedSlaves() === 1 ? `is ${num(this.facility.hostedSlaves())} slave` : `are ${num(this.facility.hostedSlaves())} slaves`} in ${V.masterSuiteName}.`,
			removeSlave: "please you",
		};
	}

	/** @returns {FC.IUpgrade[]} */
	get upgrades() {
		return [
			{
				property: "masterSuiteUpgradeLuxury",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `The master suite is a fairly standard room, albeit a much larger and more luxurious one.`,
						link: `Refit the suite to the height of traditional opulence`,
						cost: 25000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += .1,
						notes: [`will focus the suite on you`],
					},
					{
						value: 0,
						upgraded: 2,
						text: ``,
						link: `Remodel the suite around a luxurious pit for group sex`,
						cost: 25000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += .1,
						notes: [`will encourage fucktoys to fuck each other`],
					},
					{
						value: 1,
						text: `The large bed in the center of the room has been replaced with one that is nothing short of massive.`,
						upgraded: 2,
						link: `Remodel the suite around a luxurious pit for group sex`,
						cost: 10000 * V.upgradeMultiplierArcology,
						notes: [`will encourage fucktoys to fuck each other`],
					},
					{
						value: 2,
						text: `A large, recessed space has been built in the center of the room where slaves can spend their days fucking each other.`,
						upgraded: 1,
						link: `Refit the suite to the height of traditional opulence`,
						cost: 10000 * V.upgradeMultiplierArcology,
						notes: [`will focus the suite on you`],
					},
				],
			},
			{
				property: "masterSuiteUpgradePregnancy",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `The master suite does not currently have special customizations to support slave pregnancy.`,
						link: `Refit the suite to support and encourage slave pregnancy`,
						cost: 15000 * V.upgradeMultiplierArcology,
						handler: () => {
							V.PC.skill.engineering += .1;

							App.UI.reload();
						},
						prereqs: [
							!!V.seePreg,
						],
					},
					{
						value: 1,
						text: `The master suite has been further upgraded to support fertile slaves and encourage slave pregnancy, providing additional rest areas, better access to amenities, and a dedicated birthing chamber.`,
					},
				],
			},
		];
	}

	/** @returns {FC.Facilities.Rule[]} */
	get rules() {
		return [
			{
				property: "masterSuitePregnancySlaveLuxuries",
				prereqs: [
					V.masterSuiteUpgradePregnancy > 0,
				],
				options: [
					{
						get text() {
							return `Pregnant slaves have no extra luxuries to reduce stress.`;
						},
						link: `Normal duties`,
						value: 0,
					},
					{
						get text() {
							return `Pregnant slaves are being given some luxuries to reduce stress.`;
						},
						link: `Lighter duties`,
						value: 1,
					},
				],
			},
			{
				property: "masterSuitePregnancyFertilityDrugs",
				prereqs: [],
				options: [
					{
						get text() {
							return `Fertile slaves are not being given fertility drugs.`;
						},
						link: `No fertility drugs`,
						value: 0,
					},
					{
						get text() {
							return `Fertile slaves are being given fertility drugs, encouraging impregnation and multiple pregnancy.`;
						},
						link: `Standard fertility drugs`,
						value: 1,
					},
				],
			},
			{
				property: "masterSuiteHyperPregnancy",
				prereqs: [
					V.masterSuitePregnancyFertilityDrugs > 0 || V.masterSuiteHyperPregnancy > 0,
				],
				options: [
					{
						get text() {
							return `Fertile slaves are not being given super fertility drugs.`;
						},
						link: `No super fertility drugs`,
						value: 0,
					},
					{
						get text() {
							return `Fertile slaves are being given super fertility drugs, encouraging impregnation and multiple pregnancy.`;
						},
						link: `Super fertility drugs`,
						value: 1,
					},
				],
			},
			{
				property: "masterSuitePregnancyFertilitySupplements",
				prereqs: [
					V.masterSuitePregnancyFertilityDrugs === 1 || V.masterSuiteHyperPregnancy === 1 || V.masterSuitePregnancyFertilitySupplements > 0,
				],
				options: [
					{
						get text() {
							return `Fertile slaves are not being given fertility drug supplements.`;
						},
						link: `No supplements`,
						value: 0,
					},
					{
						get text() {
							return `Fertile slaves are being given supplements to their fertility drugs, further enhancing the chances of multiple pregnancy.`;
						},
						link: `Fertility supplements`,
						value: 1,
					},
				],
			},
		];
	}
};


code:
/** @type {FC.FacilityFramework} */
App.Data.Facilities.masterSuite = {
	baseName: "masterSuite",
	genericName: "Master Suite",
	jobs: {
		fucktoy: {
			position: "fucktoy",
			assignment: Job.MASTERSUITE,
			publicSexUse: false,
			fuckdollAccepted: false
		}
	},
	defaultJob: "fucktoy",
	manager: {
		position: "concubine",
		positionAbbreviation: "C",
		assignment: Job.CONCUBINE,
		careers: [],
		skill: null,
		publicSexUse: false,
		fuckdollAccepted: false,
		broodmotherAccepted: true,
		shouldWalk: false,
		shouldHold: false,
		shouldSee: false,
		shouldHear: false,
		shouldTalk: false,
		shouldThink: false,
		requiredDevotion: 51
	},
	decorated: true
};

App.Entity.Facilities.MasterSuiteFuckToyJob = class extends App.Entity.Facilities.FacilitySingleJob {
	/**
	 * @override
	 * @returns {string}
	 * */
	get assignment() {
		return this.facility.name;
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @returns {string[]}
	 */
	checkRequirements(slave) {
		let r = super.checkRequirements(slave);
		if (!App.Entity.Facilities.Job._isBrokenEnough(slave, 20, -51, -21, -50)) {
			r.push(`${slave.slaveName} is not sufficiently broken for ${this.facility.name}.`);
		}

		return r;
	}
};

App.Entity.Facilities.ConcubineJob = class extends App.Entity.Facilities.ManagingJob {
	checkRequirements(slave) {
		let r = super.checkRequirements(slave);
		if (isAmputee(slave)) {
			r.push(`${slave.slaveName} can't serve as your Concubine without limbs.`);
		}
		return r;
	}
};

App.Entity.facilities.masterSuite = new App.Entity.Facilities.SingleJobFacility(
	App.Data.Facilities.masterSuite,
	{
		fucktoy: new App.Entity.Facilities.MasterSuiteFuckToyJob()
	},
	new App.Entity.Facilities.ConcubineJob()
);


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

	if (S.Matron) {
		f.append(`${SlaveFullName(S.Matron)} is working as your Matron, managing the nursery. `);
		f.append(App.UI.DOM.link("Remove Matron", () => {
			removeJob(S.Matron, Job.MATRON);
		},
		[], "Nursery"
		));
	} else {
		f.append(`No Matron assigned, appoint one from your devoted slaves.`);
	}

	f.append(App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.nursery, "Nursery"));
	return f;
};


code:
:: AC Dump

<<if (ndef $activeChild) || ($activeChild == 0)>>

	@@.red;ERROR:@@ AC Dump, activeChild invalid, returnTo is '$returnTo', previous passage was '<<print previous()>>'. Please report this.

	<<link "Continue">><<goto $returnTo>><</link>> | [[Go Back|previous()]]

<<else>>

	<<set _CL = $cribs.length, _ID = $activeChild.ID>>

	<<if $i >= 0 && $i < _CL && $cribs[$i].ID == _ID>> /* shortcut if $i is already pointing to this slave */
		<<set $cribs[$i] = $activeChild>>
	<<else>>
		<<set $i = $cribs.findIndex(function(s) { s.ID === _ID; })>> /* find $i if exists */
		<<if $i != -1>> /* not found, so new slave */
			@@.red;ERROR:@@ $activeChild.slaveName not found! Please report this.
		<<else>>
			<<set $cribs[$i] = $activeChild>>
		<</if>>
	<</if>>

	<<goto $returnTo>>

<</if>>


code:
:: Next Child In Line

<<silently>>

<<set $i = $cribs.findIndex(function(c) { return c.ID === $activeChild.ID; })>>
<<set $cribs[$i] = $activeChild>> /* save changes before switching */
<<if $i == $cribs.length - 1>>
	<<set $activeChild = $cribs[0]>>
	<<if $activeChild.actualAge < 3>>
		<<goto "Infant Interact">>
	<<else>>
		<<goto "Child Interact">>
	<</if>>
<<else>>
	<<set $activeChild = $cribs[$i+1]>>
	<<if $activeChild.actualAge < 3>>
		<<goto "Infant Interact">>
	<<else>>
		<<goto "Child Interact">>
	<</if>>
<</if>>

<</silently>>


code:
App.Facilities.Nursery.nursery = class Nursery extends App.Facilities.Facility {
	constructor() {
		const nursery = App.Entity.facilities.nursery;
		const decommissionHandler = () => {
			V.nursery = 0;
			V.nurseryCribs = 0;
			V.nurseryDecoration = "standard";
			V.nannyInfluence = 0;
			V.cribs = [];
		};

		super(
			nursery,
			decommissionHandler,
		);

		V.nextButton = "Back to Main";
		V.nextLink = "Main";
		App.UI.StoryCaption.encyclopedia = "Nursery";
	}

	/** @returns {string} */
	get intro() {
		// TODO: add in effects based on number of children hosted
		const text = [];

		text.push(this.facility.nameCaps, this.decorations);

		if (this.facility.hostedSlaves() > 2) {
			text.push(`${this.facility.nameCaps} is bustling with activity. Nannies are busily moving about, feeding babies and changing diapers.`);
		} else if (this.facility.hostedSlaves() > 0) {
			text.push(`${this.facility.nameCaps} is working steadily. Nannies are moving about, cleaning up and feeding hungry children.`);
		} else if (S.Matron) {
			text.push(`${S.Matron.slaveName} is alone in ${this.facility.name}, and keeps the place clean and looks after the children ${getPronouns(S.Matron).himself}.`);
		} else {
			text.push(`${this.facility.nameCaps} is empty and quiet.`);
		}

		return text.join(' ');
	}

	/** @returns {string} */
	get decorations() {
		/** @type {FC.Facilities.Decoration} */
		const FS = {
			"Roman Revivalist": `is run with the Roman dream in mind, with wide open windows exposing the babies to the elements. The sleek marble halls bring a sense of serenity and duty as wet nurses wander the halls.`,
			"Neo-Imperialist": `is modeled as an ultra high-tech nursing area, with omnipresent advanced machinery monitoring every heartbeat of the babies within, the soft glow of machines pulsating against the banners of your family crest lining the walls.`,
			"Aztec Revivalist": `is lined head to toe in illustrious Aztec gold. Tiny but notable subscripts lay in plaques to honor the mothers who died giving birth, the children of said mothers, alive or dead, are tirelessly watched over to tend to their every need.`,
			"Egyptian Revivalist": `is decorated by sleek, sandstone tablets, golden statues, and even grander Egyptian wall sculptures, many of them depicting the conception, birth, and raising of a child. Each babe is reverently wrapped in linen covers as they drift to sleep to the stories of mighty pharaohs and prosperous palaces.`,
			"Edo Revivalist": `is minimalist in nature, but the errant paintings of cherry blossoms and vibrant Japanese maples give a certain peaceful air as the caretakers do their duties.`,
			"Arabian Revivalist": `is decorated wall to wall with splendorous carvings and religious Hamsas meant to protect the fostering children.`,
			"Chinese Revivalist": `is ripe with Chinese spirit. Depictions of colorful dragons and oriental designs grace the halls, rooms, and cribs of the babies who reside inside.`,
			"Antebellum Revivalist": `is warm and inviting. Carved wooden panels line the lower half of the walls while gentle pastel colored wall paper decorates the upper half; a soft pink for where the girls stay, and a baby blue for the boys. Big windows of frosted glass shine onto a rich walnut floor. Hand-crafted cribs line the walls.`,
			"Chattel Religionist": `is decorated with childish religious cartoons and artistic tapestries of slaves bowing in submission, their themes always subsiding varying degrees of sexual worship. The caretakers that wander the halls obediently wear their habits, and never waste a moment to tenderly lull the children to sleep with stories of their prophet.`,
			"Degradationist": `is bare and sullen. The cries of the neglected children destined for slavery trying to find comfort in their burlap coverings echo the halls, while those that await freedom are raised among luxury and are taught to look down on their less fortunate peers.`,
			"Repopulationist": `is designed to be very open and public; a showing testament to your arcology's repopulation efforts. For those old enough to support them, they are strapped with big, but body warming, empathy bellies as to remind them of their destiny.`,
			"Eugenics": `is of utmost quality without a single pleasantry missing — if the parents are of the elite blood of course. While there are rare stragglers of unworthy genes, the child populace overall is pampered with warm rooms and plentiful small toys.`,
			"Asset Expansionist": `is not so much decorated as it is intelligently staffed. Every passerby, slave or not, burns the image of their jiggling asses and huge, wobbling tits into the minds of the children.`,
			"Transformation Fetishist": `is kept simple and clean. From their toys down to the nursemaids, the babies are exposed to the wonders of body transformation whenever possible.`,
			"Gender Radicalist": `is decorated by cheery cartoon depictions of slaves of many shapes, sizes, and genitals, all of them undeniably feminine. The elated smiles and yips of the nurses getting reamed constantly instill the appreciation of nice, pliable buttholes.`,
			"Gender Fundamentalist": `is simply designed and painted with soft feminine colors. The staff heavily encourage the children to play dress up and house, subtly sculpting their minds to proper gender norms and properly put them in line if they try to do otherwise.`,
			"Physical Idealist": `is furnished with kiddy health books and posters; their caretakers making painstakingly sure that the importance is drilled into their heads at a young age. Their food is often littered with vitamins and supplements to keep the children growing strong.`,
			"Supremacist": `is designed and structured to give those of ${V.arcologies[0].FSSupremacistRace} ethnicity the limelight of the nursery, while the others stay sectioned off and neglected to the world.`,
			"Subjugationist": `is made to foster and raise the young children of ${V.arcologies[0].FSSubjugationistRace} ethnicity. They are reminded of their place with every failure and are encouraged to submissively follow their stereotypes at a ripe young age.`,
			"Paternalist": `is well-stocked and by Paternalistic customs, constantly swaddle the children with love and attention. With the warm colors and sound of child laughter, to the untrained eye, the children actually seem free.`,
			"Pastoralist": `is decorated to make the children grow up thinking that a life focused on breast milk, cum, and other human secretions are part of the norm. The milky tits swaying above their cow-patterned cribs certainly help with that.`,
			"Maturity Preferentialist": `decorations remind the kids to respect those curvy and mature. The older nurserymaids are always flattered whenever the children try to act like adults and take care of the younger toddlers for them.`,
			"Youth Preferentialist": `is making young children the center of attention, their rooms supplied with plenty of toys, blankets, and surrogate mothers at their beck and call.`,
			"Body Purist": `is decorated to be very clean cut and sterilized with perfect corners and curves; symbolic of the human figure. Nursery maids are encouraged to show off their natural assets to show the children what the appropriate body should be.`,
			"Slimness Enthusiast": `constantly encourages the kids to try and keep their slim and cute physiques. They are given perfectly metered meals to make this possible.`,	// TODO: tie this in to food system
			"Hedonistic": `would make any toddler drool in amazement. Meals and naps every other hour, cribs stalked with toys and blankets, and plush slaves carry them to and fro without preamble. A delicious layer of baby fat is the ideal figure of a baby, and they couldn't be happier.`,
			"Intellectual Dependency": `is decorated in some way relating to Intellectual Dependency.`,	// TODO:
			"Slave Professionalism": `is decorated in some way relating to Slave Professionalism.`,	// TODO:
			"Petite Admiration": `has large photos and paintings on the walls depicting small, petite children enjoying ${this.facility.name}'s amenities and having fun together.`,
			"Statuesque Glorification": `has large photos and paintings on the walls depicting tall children enjoying ${this.facility.name}'s amenities and having fun together.`,
			"standard": `is as comfortable and child-friendly as it needs to be. They have everything they need to grow into a proper slave.`,
		};

		const res = FS[V.nurseryDecoration];

		if (!res) {
			throw new Error(`Unknown V.nurseryDecoration value of '${V.nurseryDecoration}' found in decorations().`);
		}

		return res;
	}

	/** @returns {FC.Facilities.Expand} */
	get expand() {
		const slaves = this.facility.hostedSlaves();
		const nannies = numberWithPluralOne(V.nursery, 'nanny', 'nannies');

		return {
			amount: 1,
			desc: `${this.facility.nameCaps} has room to support ${nannies}. There ${slaves === 1 ? `is currently ${num(slaves)} nanny` : `are currently ${num(slaves)} nannies`} taking care of ${numberWithPlural(V.nurseryChildren, 'child', 'children')}.`,
			maximum: 5,
		};
	}

	/** @returns {FC.IUpgrade[]} */
	get upgrades() {
		return [
			{
				property: "nurseryWeight",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `${this.facility.nameCaps} has only the most basic monitoring systems available.`,
						link: `Upgrade the monitoring system`,
						cost: 1000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += 0.1,
						notes: [`will increase upkeep costs`],
					},
					{
						value: 1,
						text: `The monitoring systems have been upgraded and allow for monitoring children's food intakes.`,
					},
				],
			},
			{
				property: "nurseryMuscles",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `There is space in one part of ${this.facility.name} where a playground and different toys and equipment could be installed to keep children fit and healthy.`,
						link: `Install a playground`,
						cost: 1000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += 0.1,
						notes: [`will increase upkeep costs`],
					},
					{
						value: 1,
						text: `A playground and various toys and equipment have been installed in one part of ${this.facility.name}.`,
					},
				],
			},
			{
				property: "nurseryHormones",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `${this.facility.nameCaps} doesn't have any sort of artificial hormones designed for children.`,
						link: `Invest in purpose-built hormones`,
						cost: 1000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += 0.1,
						notes: [`will increase upkeep costs`],
					},
					{
						value: 1,
						text: `Hormones designed specifically for children have been developed for ${this.facility.name}.`,
					},
				],
			},
		];
	}

	/** @returns {FC.Facilities.Rule[]}*/
	get rules() {
		return [
			{
				property: "MatronIgnoresFlaws",
				prereqs: [
					!!S.Matron,
				],
				options: [
					{
						get text() { return `${S.Matron.slaveName} has been instructed to ignore flaws in the nannies serving under ${getPronouns(S.Matron).him}.`; },
						link: `Ignore flaws`,
						value: 1,
					},
					{
						get text() { return `${S.Matron.slaveName} will attempt to fix flaws in nannies serving under ${getPronouns(S.Matron).him}.`; },
						link: `Fix flaws`,
						value: 0,
					},
				],
			},
			{
				property: "nurserySex",
				prereqs: [
					!!V.extremeUnderage,
				],
				options: [
					{
						get text() { return `${capFirstChar(V.nurseryName)} staff are not allowed to molest the children.`; },
						link: `Forbid`,
						value: 0,
					},
					{
						get text() { return `${capFirstChar(V.nurseryName)} staff are allowed to molest the children.`; },
						link: `Allow`,
						value: 1,
					},
				],
			},
			// TODO: really not happy with most of these – rework these
			{
				property: "nurseryWeightSetting",
				prereqs: [
					!!V.nurseryWeight,
				],
				options: [
					{
						get text() { return `Food intake is not being managed; children may end up malnourished.`; },
						link: `Don't manage`,
						value: 0,
					},
					{
						get text() { return `Food intake is being managed; children will be raised at a healthy weight.`; },
						link: `Manage`,
						value: 1,
					},
				],
			},
			{
				property: "nurseryMusclesSetting",
				prereqs: [
					!!V.nurseryMuscles,
				],
				options: [
					{
						get text() { return `Children are not getting any exercise; they may end up quite weak and frail.`; },
						link: `Don't manage`,
						value: 0,
					},
					{
						get text() { return `Exercise is being managed; children will be raised with average fitness.`; },
						link: `Manage`,
						value: 1,
					},
				],
			},
			{
				property: "nurseryHormonesSetting",
				prereqs: [
					!!V.nurseryHormones,
				],
				options: [
					{
						get text() { return `Artificial hormones are not being given; children will undergo normal puberty.`; },
						link: `Don't manage`,
						value: 0,
					},
					{
						get text() { return `Artificial hormone levels are being managed; children may experience precocious puberty.`; },
						link: `Manage`,
						value: 1,
					},
				],
			},
		];
	}

	/** @returns {HTMLDivElement} */
	get mothers() {
		const div = document.createElement("div");

		const text = [];

		let childrenReserved = 0;

		App.Events.addNode(div, text);

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

		return div;

		function content() {
			const div = document.createElement("div");

			div.append(
				// sort(),
				mothers(),
			);

			return div;
		}

		/* function sort() {
			const div = document.createElement("div");

			const sorts = [];
			let sort = 'Unsorted';

			sorts.push(App.UI.DOM.link(`Sort by Name`, () => {
				sort = 'Name';
				sortNurseryPossiblesByName();
			}));
			sorts.push(App.UI.DOM.link(`Sort by Reserved Nursery Spots`, () => {
				sort = 'Reserved Nursery Spots';
				sortNurseryPossiblesByReservedSpots();
			}));
			sorts.push(App.UI.DOM.link(`Sort by Pregnancy Week`, () => {
				sort = 'Pregnancy Week';
				sortNurseryPossiblesByPregnancyWeek();
			}));
			sorts.push(App.UI.DOM.link(`Sort by Number of Children`, () => {
				sort = 'Number of Children';
				sortNurseryPossiblesByPregnancyCount();
			}));

			div.append(
				`Sorting: ${sort}`,
				App.UI.DOM.generateLinksStrip(sorts),
			);

			return div;
		}*/ // Was not working

		function mothers() {
			const el = new DocumentFragment();
			let r = [];
			let eligibility = 0;
			let linkArray;
			const reservedChildrenN = FetusGlobalReserveCount('nursery');
			const freeRooms = V.nurseryCribs - V.nurseryChildren;
			const reservedChildrenI = 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 room upon birth. Of ${V.nurseryCribs} rooms, ${numberWithPlural(freeRooms, 'is', 'are')} unoccupied. Of those, ${numberWithPlural(FetusGlobalReserveCount("nursery"), 'room is', 'rooms are')} reserved.`);
			if (V.incubator.capacity > 0) {
				r.push(`Of ${V.incubator.capacity} incubation tanks, ${numberWithPlural(freeTanks, 'is', 'are')} unoccupied. Of those, ${numberWithPlural(FetusGlobalReserveCount("incubator"), 'tank is', 'tanks are')} reserved.`);
			}

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

			const sortingOptions = new Map([
				["Name", "data-name"],
				["Reserved Nursery Spots", "data-reserved-spots-nursery"],
				["Reserved Incubator Spots", "data-reserved-spots-incubator"],
				["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("border-bottom");

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

			const qlNursery = 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 === Job.DAIRY && V.dairyPregSetting > 0) || slave.assignment === Job.AGENT || slave.assignment === Job.AGENTPARTNER;
					if (!reserveDisallowed) {
						const {
							His, his
						} = getPronouns(slave);
						const freeRooms = V.nurseryCribs - V.nurseryChildren;
						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-nursery", reservedNursery.toString());
						momEl.setAttribute("data-reserved-spots-incubator", 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 (reservedNursery > 0) {
							childrenReserved = 1;
							if (WL === 1) {
								r.push(`${His} child`);
							} else if (reservedNursery < WL) {
								r.push(`${reservedNursery} of ${his} children`);
							} else if (WL === 2) {
								r.push(`Both of ${his} children`);
							} else {
								r.push(`All ${reservedNursery} of ${his} children`);
							}
							r.push(`will be placed in ${V.nurseryName}.`);
							if ((reservedIncubator + reservedNursery < WL) && (reservedChildrenN < freeRooms)) {
								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 here`,
										() => {
											WombAddToGenericReserve(slave, 'nursery', 1);
											refresh();
										}
									)
								);
								if (reservedNursery > 0) {
									linkArray.push(
										App.UI.DOM.link(
											`Keep one less child here`,
											() => {
												WombCleanGenericReserve(slave, 'nursery', 1);
												refresh();
											}
										)
									);
								}
								if (reservedNursery > 1) {
									linkArray.push(
										App.UI.DOM.link(
											`Keep none of ${his} children here`,
											() => {
												WombCleanGenericReserve(slave, 'nursery', 9999);
												refresh();
											}
										)
									);
								}
								if ((reservedChildrenN + WL - reservedNursery) <= freeRooms) { // GammaNote Maths Order
									linkArray.push(
										App.UI.DOM.link(
											`Keep the rest of ${his} children here`,
											() => {
												WombAddToGenericReserve(slave, 'nursery', 9999);
												refresh();
											}
										)
									);
								}
							} else if ((reservedNursery === WL) || (reservedChildrenN === freeRooms) || (reservedIncubator + reservedNursery === WL)) {
								if (V.pregnancyMonitoringUpgrade === 1) {
									linkArray.push(
										App.UI.DOM.link(
											`Inspect pregnancy`,
											() => {
												V.AS = slave.ID;
											},
											[],
											`Analyze Pregnancy`
										)
									);
								}
								if (reservedNursery > 0) {
									linkArray.push(
										App.UI.DOM.link(
											`Keep one less child here`,
											() => {
												WombCleanGenericReserve(slave, 'nursery', 1);
												refresh();
											}
										)
									);
								}
								if (reservedNursery > 1) {
									linkArray.push(
										App.UI.DOM.link(
											`Keep none of ${his} children here`,
											() => {
												WombCleanGenericReserve(slave, 'nursery', 9999);
												refresh();
											}
										)
									);
								}
							}
						} else if (reservedIncubator + reservedNursery < WL ) {
							r.push(`You have `);
							if (freeRooms === 1) {
								r.push(`an <span class="lime">available aging room.</span>`);
							} else {
								r.push(`<span class="lime">available aging rooms.</span>`);
							}
							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 here`,
									() => {
										WombAddToGenericReserve(slave, 'nursery', 1);
										refresh();
									}
								)
							);
							if ((WL > 1) && (reservedChildrenN + WL - reservedNursery) <= freeRooms) {
								linkArray.push(
									App.UI.DOM.link(
										`Keep all of ${his} children here`,
										() => {
											WombAddToGenericReserve(slave, 'nursery', 9999);
											refresh();
										}
									)
								);
							}
						}
						if (V.incubator.capacity > 0) {
							if (reservedIncubator > 0) { // GammaNote
								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) && (reservedChildrenI < 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 in ${V.incubator.name}`,
											() => {
												WombAddToGenericReserve(slave, 'incubator', 1);
												refresh();
											}
										)
									);
									if (reservedIncubator > 0) {
										linkArray.push(
											App.UI.DOM.link(
												`Keep one less child in ${V.incubator.name}`,
												() => {
													WombCleanGenericReserve(slave, 'incubator', 1);
													refresh();
												}
											)
										);
									}
									if (reservedIncubator > 1) {
										linkArray.push(
											App.UI.DOM.link(
												`Keep none of ${his} children in ${V.incubator.name}`,
												() => {
													WombCleanGenericReserve(slave, 'incubator', 9999);
													refresh();
												}
											)
										);
									}
									if ((reservedChildrenI + WL - reservedIncubator) <= freeTanks) { // GammaNote maths order?
										linkArray.push(
											App.UI.DOM.link(
												`Keep the rest of ${his} children in ${V.incubator.name}`,
												() => {
													WombAddToGenericReserve(slave, 'incubator', 9999);
													refresh();
												}
											)
										);
									}
								}
							} else if ((reservedIncubator === WL) || (reservedChildrenI === freeTanks) || (reservedIncubator + reservedNursery === WL)) {
								if (V.pregnancyMonitoringUpgrade === 1) {
									linkArray.push(
										App.UI.DOM.link(
											`Inspect pregnancy`,
											() => {
												V.AS = slave.ID;
											},
											[],
											`Analyze Pregnancy`
										)
									);
								}
								if (reservedIncubator > 0) {
									linkArray.push(
										App.UI.DOM.link(
											`Keep one less child in ${V.incubator.name}`,
											() => {
												WombCleanGenericReserve(slave, 'incubator', 1);
												refresh();
											}
										)
									);
								}
								if (reservedIncubator > 1) {
									linkArray.push(
										App.UI.DOM.link(
											`Keep none of ${his} children in ${V.incubator.name}`,
											() => {
												WombCleanGenericReserve(slave, 'incubator', 9999);
												refresh();
											}
										)
									);
								}
							} else if (reservedIncubator + reservedNursery < WL ) {
								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) {
									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 in ${V.incubator.name}`,
										() => {
											WombAddToGenericReserve(slave, 'incubator', 1);
											refresh();
										}
									)
								);
								if ((WL > 1) && (reservedChildrenN + WL - reservedNursery) <= freeRooms) {
									linkArray.push(
										App.UI.DOM.link(
											`Keep all of ${his} children in ${V.incubator.name}`,
											() => {
												WombAddToGenericReserve(slave, 'incubator', 9999);
												refresh();
											}
										)
									);
								}
							}
						}
						eligibility = 1;

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

			if (reservedChildrenN !== 0 || reservedChildrenI !== 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);
								}
								if (WombReserveCount(slave, "nursery") !== 0) {
									WombCleanGenericReserve(slave, 'nursery', 9999);
								}
							}
							WombCleanGenericReserve(V.PC, 'incubator', 9999);
							WombCleanGenericReserve(V.PC, 'nursery', 9999);
							refresh();
						}
					)
				);
			}
			return el;

			function refresh() {
				App.UI.reload();
			}

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

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

	/** @returns {HTMLDivElement} */
	get children() {
		const div = document.createElement("div");

		div.append(App.Facilities.Nursery.childList());

		return div;
	}

	/** @returns {HTMLDivElement} */
	get targetAge() {
		const div = document.createElement("div");

		const links = [
			App.UI.DOM.link(`Minimum Legal Age`, () => {
				V.targetAgeNursery = V.minimumSlaveAge;

				App.UI.reload();
			}, [], '', `Will not be applied to rooms in use.`),
			App.UI.DOM.link(`Average Age of Fertility`, () => {
				V.targetAgeNursery = V.fertilityAge;

				App.UI.reload();
			}, [], '', `Will not be applied to rooms in use.`),
			App.UI.DOM.link(`Average Age of Potency`, () => {
				V.targetAgeNursery = V.potencyAge;

				App.UI.reload();
			}, [], '', `Will not be applied to rooms in use.`),
			App.UI.DOM.link(`Legal Adulthood`, () => {
				V.targetAgeNursery = 18;

				App.UI.reload();
			}, [], '', `Will not be applied to rooms in use.`),
		];

		div.append(
			`Target age for release: `,
			App.UI.DOM.makeTextBox(V.targetAgeNursery, target => {
				V.targetAgeNursery = target;

				App.UI.reload();
			})
		);

		App.UI.DOM.appendNewElement("div", div, App.UI.DOM.generateLinksStrip(links), ['indent']);

		return div;
	}

	/** @returns {HTMLDivElement} */
	get rooms() {
		const div = document.createElement("div");

		const cost = Math.trunc(5000 * V.upgradeMultiplierArcology);
		const links = [];

		div.append(`It can support ${numberWithPlural(V.nurseryCribs, 'child', 'children')}. There ${V.nurseryChildren === 1 ? `is currently` : `are currently`} ${numberWithPlural(V.nurseryChildren, 'room')} in use in ${this.facility.name}.`);

		links.push(App.UI.DOM.link(`Add room for another 5 children`, () => {
			cashX(forceNeg(cost), "nursery");
			V.nurseryCribs += 5;

			App.UI.reload();
		}, [], '', `Costs ${cashFormat(cost)} and will increase upkeep costs.`));

		if (V.nurseryCribs > 1 && FetusGlobalReserveCount("nursery") < V.nurseryCribs - V.nurseryChildren) {
			links.push(App.UI.DOM.link(`Remove a room`, () => {
				cashX(forceNeg(cost / 5), "nursery");
				V.nurseryCribs -= 1;

				App.UI.reload();
			}, [], '', `Costs ${cashFormat(cost / 5)} and will decrease upkeep costs.`));
		}

		App.UI.DOM.appendNewElement("div", div, App.UI.DOM.generateLinksStrip(links), ['indent']);

		return div;
	}

	/** @returns {HTMLDivElement[]} */
	get customNodes() {
		return [
			this.rooms,
			this.mothers,
			this.children,
			this.targetAge,
		];
	}
};