code:
:: Nursery [nobr jump-to-safe jump-from-safe]

<<set $nextButton = "Back to Main", $nextLink = "Main", $returnTo = "Nursery", $encyclopedia = "Nursery">>
<<set $targetAgeNursery = Number($targetAgeNursery) || $minimumSlaveAge>>
<<set $targetAgeNursery = Math.clamp($targetAgeNursery, $minimumSlaveAge, 42)>>

<<if $nurseryName != "the Nursery">>
	<<set $nurseryNameCaps = $nurseryName.replace("the ", "The ")>>
<</if>>

<<set $readyChildren = 0, $nurseryBabies = $cribs.length, $freeCribs = $nursery - $nurseryBabies, _NL = App.Entity.facilities.nursery.employeesIDs().size, _SL = $slaves.length, _eligibility = 0, $reservedChildren = FetusGlobalReserveCount("incubator"), $reservedChildrenNursery = FetusGlobalReserveCount("nursery")>>

	$nurseryNameCaps
	<<switch $nurseryDecoration>>
		<<case "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.
		<<case "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.
		<<case "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.
		<<case "Edo Revivalist">>
			is minimalistic in nature, but the errant paintings of cherry blossoms and vibrant Japanese maples give a certain peaceful air as the caretakers do their duties.
		<<case "Arabian Revivalist">>
			is decorated wall to wall with splendorous carvings and religious Hamsas meant to protect the fostering children.
		<<case "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.
		<<case "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.
		<<case "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.
		<<case "Repopulation Focus">>
			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.
		<<case "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.
		<<case "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.
		<<case "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.
		<<case "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.
		<<case "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.
		<<case "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.
		<<case "Supremacist">>
			is designed and structured to give those of $arcologies[0].FSSupremacistRace ethnicity the limelight of the nursery, while the others stay sectioned off and neglected to the world.
		<<case "Subjugationist">>
			is made to foster and raise the young children of $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.
		<<case "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.
		<<case "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.
		<<case "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.
		<<case "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.
		<<case "Body Purist">>
			is decorated to be very clean cut and sterilized with perfect corners and curves; symbolic of the human figure. Nurserymaids are encouraged to show off their natural assets to show the children what the appropriate body should be.
		<<case "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 */
		<<case "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.
		<<case "Intellectual Dependency">>
			/* TODO: */
		<<case "Slave Professionalism">>
			/* TODO: */
		<<case "Petite Admiration">>
			has large photos and paintings on the walls depicting small, petite children enjoying $nurseryName's amenities and having fun together.
		<<case "Statuesque Glorification">>
			has large photos and paintings on the walls depicting tall children enjoying $nurseryName's amenities and having fun together.	/* TODO: rewrite so it's not so similar? */
		<<default>>
			is as comfortable and child-friendly as it needs to be. They have everything they need to grow into a proper slave.
	<</switch>>

	<<if $Matron>>
		<<setLocalPronouns $Matron>>
	<</if>>

	<<if _NL > 2>>
		$nurseryNameCaps is bustling with activity. Nannies are busily moving about, feeding babies and changing diapers.
	<<elseif _NL > 0>>
		$nurseryNameCaps is working steadily. Nannies are moving about, cleaning up and feeding hungry children.
		<<set $nannyInfluence = 1>>
	<<elseif $Matron>>
		$Matron.slaveName is alone in $nurseryName, and keeps the place clean and looks after the children $himself.
		<<set $MatronInfluence = 1>>
	<<elseif (_NL <= 0) && ($nurseryBabies <= 0)>>
		$nurseryNameCaps is empty and quiet.

			<<link "Decommission the Nursery" "Main">>
				<<set $nursery = 0, $nurseryNannies = 0, $nannyInfluence = 0, $nurseryDecoration = "standard", $cribs = [], $reservedChildrenNursery = 0>>
				<<for _i = 0; _i < $slaves.length; _i++>>
					<<run WombCleanGenericReserve($slaves[_i], "nursery", 9999)>>
				<</for>>
			<</link>>

	<</if>>

<<set _Tmult0 = Math.trunc($nurseryNannies*1000*$upgradeMultiplierArcology)>>

It can support $nurseryNannies nann<<if $nurseryNannies != 1>>ies<<else>>y<</if>>.
There <<if _NL == 1>>is<<else>>are<</if>> _NL nann<<if _NL != 1>>ies<<else>>y<</if>> in $nurseryName.
<<if $nurseryBabies > 0 && _NL < 1 && (!$Matron)>>

		You must have a Matron or at least one nanny to be able to influence the children's upbringing

<</if>>
<<if $nurseryNannies < 5>>

		[[Expand the nursery|Nursery][cashX(forceNeg(_Tmult0), "capEx"), $nurseryNannies += 1, $PC.skill.engineering += .1]]

			Costs <<print cashFormat(_Tmult0)>> and will increase upkeep costs

<<else>>

		$nurseryNameCaps can support a maximum of 5 slaves

<</if>>

	<<if _NL > 0>>
		<<removeFacilityWorkers "nursery" "rest" "rest">>
	<</if>>

	<<if $Matron>>
		<<if $MatronIgnoresFlaws != 1>>
			$Matron.slaveName will attempt to fix flaws in nannies serving under $him.

				[[Ignore flaws|Nursery][$MatronIgnoresFlaws = 1]]

		<<else>>
			$Matron.slaveName has been instructed to ignore flaws in the nannies serving under $him.

				[[Fix flaws|Nursery][$MatronIgnoresFlaws = 0]]

		<</if>>
	<</if>>

	<<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.nursery)>>

It can support $nursery child<<if $nursery != 1>>ren<</if>>. There <<if $nurseryBabies == 1>>is<<else>>are<</if>> currently $nurseryBabies room<<if $nurseryBabies != 1>>s<</if>> in use in $nurseryName.
<<if $nursery < 50>>

		[[Add another room|Nursery][cashX(forceNeg(Math.trunc(5000*$upgradeMultiplierArcology)), "nursery"), $nursery += 5]]

			Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology))>> and will increase upkeep costs

		<<if $freeCribs == 0>>
			All of the rooms are currently occupied by growing children.
		<</if>>

<<else>>

		$nurseryNameCaps can support a maximum of 50 children

<</if>>

<<if $nursery > 1 && $reservedChildrenNursery < $freeCribs>>

		[[Remove a room|Nursery][cashX(forceNeg(Math.trunc(1000*$upgradeMultiplierArcology)), "nursery"), $nursery -= 5]]

			Costs <<print cashFormat(Math.trunc(1000*$upgradeMultiplierArcology))>> and will reduce upkeep costs

<</if>>

Reserve an eligible mother-to-be's child to be placed in a room upon birth. Of $nursery rooms, <<print $freeCribs>> <<if $freeCribs == 1>>is<<else>>are<</if>> unoccupied. Of those, $reservedChildrenNursery room<<if $reservedChildrenNursery == 1>> is<<else>>s are<</if>> reserved.

<<if (0 < _SL)>>
	<<set $sortNurseryList = $sortNurseryList || 'Unsorted'>>

		Sorting:

	''$sortNurseryList.''
	<<link "Sort by Name">>
		<<set $sortNurseryList = 'Name'>>
		<<replace "#qlNurserySort">>$sortNurseryList<</replace>>
		<>
	<</link>> |
	<<link "Sort by Reserved Nursery Spots">>
		<<set $sortNurseryList = 'Reserved Nursery Spots'>>
		<<replace "#qlNurserySort">>$sortNurseryList<</replace>>
		<>
	<</link>> |
	<<link "Sort by Pregnancy Week">>
		<<set $sortNurseryList = 'Pregnancy Week'>>
		<<replace "#qlNurserySort">>$sortNurseryList<</replace>>
		<>
	<</link>> |
	<<link "Sort by Number of Children">>
		<<set $sortNurseryList = 'Number of Children'>>
		<<replace "#qlNurserySort">>$sortNurseryList<</replace>>
		<>
	<</link>>

<</if>>

	<<for _u = 0; _u < _SL; _u++>>
		<<setLocalPronouns $slaves[_u]>>
		<<if $slaves[_u].preg > 0 && $slaves[_u].broodmother == 0 && $slaves[_u].pregKnown == 1 && $slaves[_u].eggType == "human">>
			<<if $slaves[_u].assignment == "work in the dairy" && $dairyPregSetting > 0>>
			<<else>>
				<<set _slaveId = "slave-" + $slaves[_u].ID>>
				<<set _WL = $slaves[_u].womb.length>>
				<<set _reservedNursery = WombReserveCount($slaves[_u], "nursery")>>
				<<set _reservedIncubator = WombReserveCount($slaves[_u], "incubator")>>
				<<set _pregWeek = $slaves[_u].pregWeek>>
				<<set _slaveName = SlaveFullName($slaves[_u])>>

				<<print "[[_slaveName|Long Slave Description][$activeSlave = $slaves[" + _u + "], $nextLink = passage()]]">> is <<= numberWithPluralOne($slaves[_u].pregWeek, "week")>> pregnant with
				<<if $slaves[_u].pregSource == 0 || $slaves[_u].preg <= 5>>someone's<<if $slaves[_u].preg <= 5>>, though it is too early to tell whose,<</if>>
				<<elseif $slaves[_u].pregSource == -1>>your
				<<elseif $slaves[_u].pregSource == -2>>a citizen's
				<<elseif $slaves[_u].pregSource == -3>>your Master's
				<<elseif $slaves[_u].pregSource == -4>>another arcology owner's
				<<elseif $slaves[_u].pregSource == -5>>your client's
				<<elseif $slaves[_u].pregSource == -6>>the Societal Elite's
				<<elseif $slaves[_u].pregSource == -7>>the lab's
				<<elseif $slaves[_u].pregSource == -9>>the Futanari Sisters'
				<<else>>
					<<set _t = $slaveIndices[$slaves[_u].pregSource]>>
					<<if def _t>>
						<<print $slaves[_t].slaveName>>'s
					<</if>>
				<</if>>
				<<if _WL > 1>>_WL babies<<else>>baby<</if>>.
				<<if _reservedNursery > 0>>
					<<set _childrenReservedNursery = 1>>
					<<if _WL == 1>>
						$His child will be placed in $nurseryName.
					<<elseif _reservedNursery < _WL>>
						_reservedNursery of $his children will be placed in $nurseryName.
					<<elseif _WL == 2>>
						Both of $his children will be placed in $nurseryName.
					<<else>>
						All _reservedNursery of $his children will be placed in $nurseryName.
					<</if>>
					<<if (_reservedIncubator + _reservedNursery < _WL) && ($reservedChildrenNursery < $freeCribs)>>

						<<print "[[Keep another child|Nursery][WombAddToGenericReserve($slaves[" + _u + "], 'nursery', 1)]]">>
						<<if _reservedNursery > 0>>
							| <<print "[[Keep one less child|Nursery][WombCleanGenericReserve($slaves[" + _u + "], 'nursery', 1)]]">>
						<</if>>
						<<if _reservedNursery > 1>>
							| <<print "[[Keep none of " + $his + " children|Nursery][WombCleanGenericReserve($slaves[" + _u + "], 'nursery', 9999)]]">>
						<</if>>
						<<if ($reservedChildrenNursery + _WL - _reservedNursery) <= $freeCribs>>
							| <<print "[[Keep the rest of " + $his + " children|Nursery][WombAddToGenericReserve($slaves[" + _u + "], 'nursery', 9999)]]">>
						<</if>>
					<<elseif (_reservedNursery == _WL) || ($reservedChildrenNursery == $freeCribs) || (_reservedIncubator + _reservedNursery == _WL)>>

						<<print "[[Keep one less child|Nursery][WombCleanGenericReserve($slaves[" + _u + "], 'nursery', 1)]]">>
						<<if _reservedNursery > 1>>
							| <<print "[[Keep none of " + $his + " children|Nursery][WombCleanGenericReserve($slaves[" + _u + "], 'nursery', 9999)]]">>
						<</if>>
					<</if>>
				<<elseif ($reservedChildrenNursery < $freeCribs) && ($freeCribs > _WL)>>
					<<if _WL - _reservedIncubator == 0>>

							$His children are already reserved for $incubatorName

						<<print "[[Keep " + $his + " " + ((_WL > 1) ? "children" : "child") + " here instead|Nursery][WombChangeReserveType($slaves[" + _u + "], 'incubator', 'nursery')]]">>
					<<else>>
						You have <<if $freeCribs == 1>>an<</if>> @@.lime;available room<<if $freeCribs > 1>>s<</if>>.@@

						<<print "[[Keep "+ ((_WL > 1) ? "a" : "the") +" child|Nursery][WombAddToGenericReserve($slaves[" + _u + "], 'nursery', 1)]]">>
						<<if (_WL > 1) && ($reservedChildrenNursery + _WL - _reservedNursery) <= $freeCribs>>
							| <<print "[[Keep all of " + $his + " children|Nursery][WombAddToGenericReserve($slaves[" + _u + "], 'nursery', 9999)]]">>
						<</if>>
					<</if>>
				<<elseif $reservedChildrenNursery == $freeCribs>>

					You have @@.red;no room for $his offspring.@@
				<</if>>
				<<set _eligibility = 1>>

			<</if>>
		<</if>>
	<</for>>

<>
<<if _eligibility == 0>>

		You have no pregnant slaves bearing eligible children.

<</if>>
<<if $PC.pregKnown == 1 && ($arcologies[0].FSRestart == "unset" || $eugenicsFullControl == 1 || ($PC.pregSource != -1 && $PC.pregSource != -6))>>
	<<set _WL = $PC.womb.length>>
	<<set _reservedIncubator = WombReserveCount($PC, "incubator")>>
	<<set _reservedNursery = WombReserveCount($PC, "nursery")>>

''@@.pink;You're pregnant@@'' and going to have
		<<if _WL == 1>>
			a baby.
		<<else>>
			<<print pregNumberName(_WL, 1)>>
		<</if>>
	<<if _reservedNursery > 0>>
		<<set _childrenReservedNursery = 1>>
		<<if _WL == 1>>
			Your child will be placed in $nurseryName.
		<<elseif _reservedNursery < _WL>>
			_reservedNursery of your children will be placed in $nurseryName.
		<<elseif _WL == 2>>
			Both of your children will be placed in $nurseryName.
		<<else>>
			All _reservedNursery of your children will be placed in $nurseryName.
		<</if>>
		<<if (_reservedNursery < _WL) && ($reservedChildrenNursery < $freeCribs) && (_reservedNursery - _reservedIncubator > 0)>>

			<<print "[[Keep another child|Nursery][WombAddToGenericReserve($PC, 'nursery', 1)]]">>
			<<if _reservedNursery > 0>>
				| <<print "[[Keep one less child|Nursery][WombCleanGenericReserve($PC, 'nursery', 1)]]">>
			<</if>>
			<<if _reservedNursery > 1>>
				| <<print "[[Keep none of your children|Nursery][WombCleanGenericReserve($PC, 'nursery', 9999)]]">>
			<</if>>
			<<if ($reservedChildrenNursery + _WL - _reservedNursery) <= $freeCribs>>
				| <<print "[[Keep the rest of your children|Nursery][WombAddGenericReserve($PC, 'nursery', 9999)]]">>
			<</if>>
		<<elseif (_reservedNursery == _WL) || ($reservedChildrenNursery == $freeCribs) || (_reservedNursery - _reservedIncubator >= 0)>>

			<<print "[[Keep one less child|Nursery][WombCleanGenericReserve($PC, 'nursery', 1)]]">>
			<<if _reservedNursery > 1>>
				| <<print "[[Keep none of your children|Nursery][WombCleanGenericReserve($PC, 'nursery', 9999)]]">>
			<</if>>
		<</if>>
	<<elseif $reservedChildrenNursery < $freeCribs>>
		<<if _WL - _reservedIncubator == 0>>

				Your child<<if _WL > 0>>ren are<<else>>is<</if>> already reserved for $incubatorName

			<<print "[[Keep your "+ ((_WL > 1) ? "children" : "child") +" here instead|Nursery][WombChangeReserveType($PC, 'incubator', 'nursery')]]">>
		<<else>>
			You have <<if $freeCribs == 1>>an<</if>> @@.lime;available room<<if $freeCribs > 1>>s<</if>>.@@

			<<print "[[Keep "+ ((_WL > 1) ? "a" : "your") +" child|Nursery][WombAddToGenericReserve($PC, 'nursery', 1)]]">>
			<<if (_WL > 1) && ($reservedChildrenNursery + _WL - _reservedNursery) <= $freeCribs>>
				| [[Keep all of your children|Nursery][WombAddToGenericReserve($PC, 'nursery', 9999)]]
			<</if>>
		<</if>>
	<<elseif $reservedChildrenNursery == $freeCribs>>

		You have @@.red;no room for your offspring.@@
	<</if>>
<</if>>
<<if $reservedChildrenNursery || _childrenReservedNursery == 1>> /* the oops I made it go negative somehow button */

	<<link "Clear all reserved children">>
		<<for _u = 0; _u < _SL; _u++>>
			<<run WombCleanGenericReserve($slaves[_u], "nursery", 9999)>>
		<</for>>
		<<run WombCleanGenericReserve($PC, "nursery", 9999)>>
		<<goto "Nursery">>
	<</link>>
<</if>>

	Target age for release: <<textbox "$targetAgeNursery" $targetAgeNursery "Nursery">>
	[[Minimum Legal Age|Nursery][$targetAgeNursery = $minimumSlaveAge]] |
	[[Average Age of Fertility|Nursery][$targetAgeNursery = $fertilityAge]] |
	[[Average Age of Potency|Nursery][$targetAgeNursery = $potencyAge]] |
	[[Legal Adulthood|Nursery][$targetAgeNursery = 18]]

		Setting will not be applied to rooms in use.

Rules

<<if $extremeUnderage>>
	<<if $nurserySex>>
		$nurseryNameCaps staff are ''allowed'' to molest the children. [[Forbid|Nursery][$nurserySex = 0]]
	<<else>>
		$nurseryNameCaps staff are ''not allowed'' to molest the children. [[Allow|Nursery][$nurserySex = 1]]
	<</if>>
<</if>>

<<if $nurseryWeight>>
	<<if $nurseryWeightSetting>>
		Food intake ''is'' being managed; children will be raised at a healthy weight.
		[[End managing|Nursery][$nurseryWeightSetting = 0]]
	<<else>>
		Food intake ''is not'' being managed; children may end up malnourished.
		[[Begin managing|Nursery][$nurseryWeightSetting = 1]]
	<</if>>
<<else>>
	The amount of food the children eat ''is not'' being monitored, meaning they may end up becoming malnourished.
	[[Monitor the amount of food the children eat|Nursery][cashX(forceNeg(Math.trunc(1000*$upgradeMultiplierArcology)), "nursery"), $nurseryWeight = 1]]

		Requires a Matron or at least one nanny and costs <<print cashFormat(Math.trunc(1000*$upgradeMultiplierArcology))>> and will increase upkeep costs

<</if>>

<<if $nurseryMuscles>>
	<<if $nurseryMusclesSetting>>
		Exercise ''is'' being managed; children will be raised with average fitness.
		[[End managing|Nursery][$nurseryMusclesSetting = 0]]
	<<else>>
		Children ''are not'' getting any exercise; they may end up quite weak and frail.
		[[Begin managing|Nursery][$nurseryMusclesSetting = 1]]
	<</if>>
<<else>>
	The children ''are not'' getting any exercise, meaning they will likely end up becoming fairly weak and frail.
	[[Allow the children to remain active|Nursery][cashX(forceNeg(Math.trunc(1000*$upgradeMultiplierArcology)), "nursery"), $nurseryMuscles = 1]]

		Requires a Matron or at least one nanny and costs <<print cashFormat(Math.trunc(1000*$upgradeMultiplierArcology))>> and will increase upkeep costs

<</if>>

<<if $nurseryUpgradeHormones>>
	<<if $nurseryHormonesSetting>>
		Artificial hormone levels ''are'' being managed; children may experience precocious puberty.
		[[Disable|Nursery][$nurseryHormonesSetting = 0]]
	<<else>>
		Artificial hormones ''are not'' being given; children will undergo normal puberty.
		[[Activate|Nursery][$nurseryHormonesSetting = 1]]
	<</if>>
<<else>>
	The children ''are not'' being given any artificial hormones.
	[[Give the children growth hormones|Nursery][cashX(forceNeg(Math.trunc(1000*$upgradeMultiplierArcology)), "nursery"), $nurseryUpgradeHormones = 1, $nurseryHormonesSetting = 0]]

		Requires a Matron or at least one nanny and costs <<print cashFormat(Math.trunc(1000*$upgradeMultiplierArcology))>> and will increase upkeep costs

<</if>>

<<if $nurseryBabies > 0>>

		Children in $nurseryName

	<<= App.Facilities.Nursery.childList()>>
<</if>>

/*
FIXME: not sure if this works
<<set $newSlavePool = []>>
<<for _nur = 0; _nur < $cribs.length; _nur++>>
	<<if $cribs[_nur].growTime <= 0>>
		<<set $nurseryOldID = $cribs[_nur].ID>> /* single slave case *//*
		<<set _tempObject = {object: $cribs[_nur], ID: $cribs[_nur].ID}>>
		<<set $newSlavePool.push(clone(_tempObject))>>
		<<run $cribs.splice(_nur, 1)>>
		<<set _nur-->>
	<</if>>
<</for>>
<<if $newSlavePool.length == 1>>
	<<set $readySlave = $newSlavePool[0].object>>
	<<set $newSlavePool = 0>>
<</if>>
*/

	Rename $nurseryName: <<textbox "$nurseryName" $nurseryName "Nursery">>

		Use a noun or similar short phrase

<<run App.UI.SlaveList.ScrollPosition.restore()>>


code:
App.Facilities.Nursery.ChildDatatypeCleanup = function(child) {
	childAgeDatatypeCleanup(child);
	childPhysicalDatatypeCleanup(child);
	childFaceDatatypeCleanup(child);
	childHairDatatypeCleanup(child);
	childBoobsDatatypeCleanup(child);
	childButtDatatypeCleanup(child);
	childPregnancyDatatypeCleanup(child);
	childBellyDatatypeCleanup(child);
	childGenitaliaDatatypeCleanup(child);
	childImplantsDatatypeCleanup(child);
	childPiercingsDatatypeCleanup(child);
	childTattooDatatypeCleanup(child);
	childCosmeticsDatatypeCleanup(child);
	childDietDatatypeCleanup(child);
	childPornDatatypeCleanup(child);
	childRelationDatatypeCleanup(child);
	childSkillsDatatypeCleanup(child);
	childStatCountDatatypeCleanup(child);
	childPreferencesDatatypeCleanup(child);
	childRulesDatatypeCleanup(child);
	childCustomStatsDatatypeCleanup(child);
	childMiscellaneousDatatypeCleanup(child);
	generatePronouns(child);

	function childAgeDatatypeCleanup(child) {

		child.birthWeek = Math.clamp(+child.birthWeek, 0, 51) || 0;
		if (child.age > 0) {
			child.actualAge = Math.clamp(+child.actualAge, V.minimumChildAge, Infinity) || child.age; /* if undefined, this sets to child.age */
			delete child.age;
		} else {
			child.actualAge = Math.clamp(+child.actualAge, V.minimumChildAge, Infinity) || 3;
		}
		child.visualAge = Math.max(+child.visualAge, 0) || child.actualAge;
		child.physicalAge = Math.max(+child.physicalAge, 0) || child.actualAge;
		child.ovaryAge = Math.max(+child.ovaryAge, 0) || child.physicalAge;
		child.pubertyAgeXX = Math.max(+child.pubertyAgeXX, 0) || V.fertilityAge;
		child.pubertyAgeXY = Math.max(+child.pubertyAgeXY, 0) || V.potencyAge;
	}

	function childPhysicalDatatypeCleanup(child) {
		if (typeof child.nationality !== "string") {
			child.nationality = "child";
		}
		if (typeof child.race !== "string") {
			nationalityToRace(child);
		}
		if (typeof child.origRace !== "string") {
			child.origRace = child.race;
		}
		if (typeof child.skin !== "string") {
			child.skin = "light";
		}
		if (typeof child.origSkin !== "string") {
			child.origSkin = child.skin;
		}
		if (typeof child.minorInjury !== "string") {
			child.minorInjury = 0;
		}
		if (typeof child.health === "number") {
			const condition = child.health;
			child.health = {};
			child.health.condition = condition;
		}
		child.health.condition = Math.clamp(+child.health.condition, -100, 100) || 0;
		child.health.shortDamage = Math.max(+child.health.shortDamage, 0) || 0;
		child.health.longDamage = Math.max(+child.health.longDamage, 0) || 0;
		child.health.illness = Math.max(+child.health.illness, 0) || 0;
		child.health.tired = Math.clamp(+child.health.tired, 0, 100) || 0;
		child.muscles = Math.clamp(+child.muscles, -100, 100) || 0;
		child.weight = Math.clamp(+child.weight, -100, 200) || 0;
		child.waist = Math.clamp(+child.waist, -100, 100) || 0;
		child.height = Math.round(Math.max(+child.height, 0)) || Math.round(Height.mean(child));
		child.shoulders = Math.clamp(+child.shoulders, -2, 2) || 0;
		child.hips = Math.clamp(+child.hips, -2, 3) || 0;
	}

	function childFaceDatatypeCleanup(child) {
		child.face = Math.clamp(+child.face, -100, 100) || 0;
		if (typeof child.faceShape !== "string") {
			child.faceShape = "normal";
		}
		if (child.lips !== 0) {
			child.lips = Math.clamp(+child.lips, 0, 100) || 15;
		}
	}

	function childHairDatatypeCleanup(child) {
		if (typeof child.hColor !== "string") {
			child.hColor = "brown";
		}
		if (typeof child.origHColor !== "string") {
			child.origHColor = child.hColor;
		}
		if (child.hLength !== 0) {
			child.hLength = Math.clamp(+child.hLength, 0, 300) || 60;
		}
		if (typeof child.hStyle !== "string") {
			child.hStyle = "long";
		}
		child.haircuts = Math.clamp(+child.haircuts, 0, 1) || 0;
		child.bald = Math.clamp(+child.bald, 0, 1) || 0;
		if (typeof child.pubicHColor !== "string") {
			child.pubicHColor = child.hColor;
		}
		if (typeof child.pubicHStyle !== "string") {
			child.pubicHStyle = "neat";
		}
		if (typeof child.underArmHColor !== "string") {
			child.underArmHColor = child.hColor;
		}
		if (typeof child.underArmHStyle !== "string") {
			child.underArmHStyle = "waxed";
		}
		if (typeof child.eyebrowHColor !== "string") {
			child.eyebrowHColor = child.hColor;
		}
		if (typeof child.eyebrowHStyle !== "string") {
			child.eyebrowHStyle = "natural";
		}
		if (typeof child.eyebrowFullness !== "string") {
			child.eyebrowFullness = "natural";
		}
	}

	function childBoobsDatatypeCleanup(child) {
		child.boobs = Math.max(+child.boobs, 100) || 200;
		if (typeof child.boobShape !== "string") {
			child.boobShape = "normal";
		}
		if (typeof child.nipples !== "string") {
			child.nipples = "cute";
		}
		if (typeof child.nipplesAccessory !== "string") {
			child.nipplesAccessory = "none";
		}
		child.areolae = Math.clamp(+child.areolae, 0, 4) || 0;
		if (typeof child.areolaeShape !== "string") {
			child.areolaeShape = "circle";
		}
		child.lactation = Math.clamp(+child.lactation, 0, 2) || 0;
		child.lactationAdaptation = Math.clamp(+child.lactationAdaptation, 0, 100) || 0;
	}

	function childButtDatatypeCleanup(child) {
		if (child.butt !== 0) {
			child.butt = Math.clamp(+child.butt, 0, 20) || 1;
		}
		child.anus = Math.clamp(+child.anus, 0, 4) || 0;
		child.analArea = Math.max(+child.analArea, 0) || 0;
	}

	function childPregnancyDatatypeCleanup(child) {
		child.induce = Math.clamp(+child.induce, 0, 1) || 0;
		child.labor = Math.clamp(+child.labor, 0, 1) || 0;
		if (child.hasOwnProperyty("cSec")) {
			if (child.cSec > 0) {
				App.Medicine.Modification.addScar(child, "belly", "c-section");
			}
			delete child.cSec;
		}
		child.prematureBirth = Math.clamp(+child.prematureBirth, 0, 1) || 0;
		child.ovaries = Math.clamp(+child.ovaries, 0, 1) || 0;
		child.vasectomy = Math.clamp(+child.vasectomy, 0, 1) || 0;
		child.mpreg = Math.clamp(+child.mpreg, 0, 1) || 0;
		if (child.pregAdaptation !== 0) {
			child.pregAdaptation = Math.max(+child.pregAdaptation, 0) || 50;
		}
		child.pregSource = +child.pregSource || 0;
		if (typeof child.pregControl !== "string") {
			child.pregControl = "none";
		}
		child.fertPeak = Math.clamp(+child.fertPeak, 0, 4) || 0;
		WombNormalizePreg(child);
	}

	function childBellyDatatypeCleanup(child) {
		child.bellySag = Math.max(+child.bellySag, 0) || 0;
		child.bellySagPreg = Math.max(+child.bellySagPreg, 0) || child.bellySag;
		SetBellySize(child);
	}

	function childGenitaliaDatatypeCleanup(child) {
		child.vagina = Math.clamp(+child.vagina, -1, 10) || 0;
		child.vaginaLube = Math.clamp(+child.vaginaLube, 0, 2) || 0;
		child.labia = Math.clamp(+child.labia, 0, 3) || 0;
		child.clit = Math.clamp(+child.clit, 0, 5) || 0;
		child.foreskin = Math.max(+child.foreskin, 0) || 0;
		child.dick = Math.max(+child.dick, 0) || 0;
		if (child.dick && child.prostate !== 0) {
			child.prostate = Math.clamp(+child.prostate, 0, 3) || 1;
		} else {
			child.prostate = Math.clamp(+child.prostate, 0, 3) || 0;
		}
		child.balls = Math.max(+child.balls, 0) || 0;
		if (child.scrotum !== 0) {
			child.scrotum = Math.max(+child.scrotum, 0) || child.balls;
		}
	}

	function childImplantsDatatypeCleanup(child) {
		child.ageImplant = Math.clamp(+child.ageImplant, 0, 1) || 0;
		child.faceImplant = Math.clamp(+child.faceImplant, 0, 100) || 0;
		child.lipsImplant = Math.clamp(+child.lipsImplant, 0, 100) || 0;
		child.voiceImplant = Math.clamp(+child.voiceImplant, -1, 1) || 0;
		child.boobsImplant = Math.max(+child.boobsImplant, 0) || 0;
		if (child.boobsImplant === 0) {
			child.boobsImplantType = "none";
		} else if (child.boobsImplantType === "none") {
			child.boobsImplantType = "normal";
		}
		child.breastMesh = Math.clamp(+child.breastMesh, 0, 1) || 0;
		child.buttImplant = Math.clamp(+child.buttImplant, 0, 3) || 0;
		if (child.buttImplant === 0) {
			child.buttImplantType = "none";
		} else if (child.buttImplantType === "none") {
			child.buttImplantType = "normal";
		}
		child.earImplant = Math.clamp(+child.earImplant, 0, 1) || 0;
	}

	function childPiercingsDatatypeCleanup(child) {
		child.earPiercing = Math.clamp(+child.earPiercing, 0, 2) || 0;
		child.nosePiercing = Math.clamp(+child.nosePiercing, 0, 2) || 0;
		child.eyebrowPiercing = Math.clamp(+child.eyebrowPiercing, 0, 2) || 0;
		child.lipsPiercing = Math.clamp(+child.lipsPiercing, 0, 2) || 0;
		child.tonguePiercing = Math.clamp(+child.tonguePiercing, 0, 2) || 0;
		child.nipplesPiercing = Math.clamp(+child.nipplesPiercing, 0, 2) || 0;
		child.areolaePiercing = Math.clamp(+child.areolaePiercing, 0, 2) || 0;
		child.corsetPiercing = Math.clamp(+child.corsetPiercing, 0, 1) || 0;
		child.navelPiercing = Math.clamp(+child.navelPiercing, 0, 2) || 0;
		child.clitPiercing = Math.clamp(+child.clitPiercing, 0, 3) || 0;
		child.vaginaPiercing = Math.clamp(+child.vaginaPiercing, 0, 2) || 0;
		child.dickPiercing = Math.clamp(+child.dickPiercing, 0, 2) || 0;
		child.anusPiercing = Math.clamp(+child.anusPiercing, 0, 2) || 0;
	}

	function childTattooDatatypeCleanup(child) {
		if (typeof child.shouldersTat !== "string") {
			child.shouldersTat = 0;
		}
		if (typeof child.lipsTat !== "string") {
			child.lipsTat = 0;
		}
		if (typeof child.boobsTat !== "string") {
			child.boobsTat = 0;
		}
		if (typeof child.armsTat !== "string") {
			child.armsTat = 0;
		}
		if (typeof child.backTat !== "string") {
			child.backTat = 0;
		}
		if (typeof child.stampTat !== "string") {
			child.stampTat = 0;
		}
		if (typeof child.buttTat !== "string") {
			child.buttTat = 0;
		}
		if (typeof child.vaginaTat !== "string") {
			child.vaginaTat = 0;
		}
		if (typeof child.dickTat !== "string") {
			child.dickTat = 0;
		}
		if (typeof child.anusTat !== "string") {
			child.anusTat = 0;
		}
		if (typeof child.legsTat !== "string") {
			child.legsTat = 0;
		}
		if (typeof child.bellyTat !== "string") {
			child.bellyTat = 0;
		}
		if (typeof child.custom.tattoo !== "string") {
			child.custom.tattoo = "";
		}
	}

	function childCosmeticsDatatypeCleanup(child) {
		child.makeup = Math.clamp(+child.makeup, 0, 8) || 0;
		child.nails = Math.clamp(+child.nails, 0, 9) || 0;
		child.scars = Math.clamp(+child.scars, 0, 6) || 0;
		child.chastityAnus = Math.clamp(+child.chastityAnus, 0, 1) || 0;
		child.chastityPenis = Math.clamp(+child.chastityPenis, 0, 1) || 0;
		child.chastityVagina = Math.clamp(+child.chastityVagina, 0, 1) || 0;
		child.choosesOwnClothes = Math.clamp(+child.choosesOwnClothes, 0, 1) || 0;
		if (typeof child.clothes !== "string") {
			child.clothes = "no clothing";
		}
		if (typeof child.collar !== "string") {
			child.collar = "none";
		}
		if (typeof child.shoes !== "string") {
			child.shoes = "none";
		}
		if (typeof child.eyewear !== "string") {
			child.eyewear = "none";
		}
		if (typeof child.brand !== "object") {
			let brand = {};
			if (child.brand !== 0) {
				brand["left buttock"] = child.brand;
			}
			child.brand = brand;
		} else if (typeof child.brand === "object") { // Make sure key and value are strings
			for (let [key, value] of Object.entries(child.brand)) {
				if (typeof key !== "string" || typeof value !== "string") {
					delete child.brand[key];
				}
			}
		}
		if (typeof child.markings !== "string") {
			child.markings = "none";
		}
		if (typeof child.bellyAccessory !== "string") {
			child.bellyAccessory = "none";
		}
		if (typeof child.vaginalAccessory !== "string") {
			child.vaginalAccessory = "none";
		}
		if (typeof child.vaginalAttachment !== "string") {
			child.vaginalAttachment = "none";
		}
		if (typeof child.dickAccessory !== "string") {
			child.dickAccessory = "none";
		}
		if (typeof child.legAccessory !== "string") {
			child.legAccessory = "none";
		}
		if (typeof child.buttplug !== "string") {
			child.buttplug = "none";
		}
		if (typeof child.buttplugAttachment !== "string") {
			child.buttplugAttachment = "none";
		}
		if (typeof child.headAccessory !== "string") {
			child.headAccessory = "none";
		}
		if (typeof child.rearAccessory !== "string") {
			child.rearAccessory = "none";
		}
		if (typeof child.backAccessory !== "string") {
			child.backAccessory = "none";
		}
		if (typeof slave.faceAccessory !== "string") {
			slave.faceAccessory = "none";
		}
		if (typeof slave.mouthAccessory !== "string") {
			slave.mouthAccessory = "none";
		}
		switch(slave.collar) {
			case "porcelain mask":
				slave.faceAccessory = slave.collar;
				slave.collar = "none";
				break;
			case "bit gag":
			case "dildo gag":
			case "massive dildo gag":
			case "ball gag":
			case "ring gag":
				slave.mouthAccessory = slave.collar;
				slave.collar = "none";
				break;
		}
	}

	function childDietDatatypeCleanup(child) {
		if (typeof child.diet !== "string") {
			child.diet = "healthy";
		}
		child.dietCum = Math.clamp(+child.dietCum, 0, 2) || 0;
		child.dietMilk = Math.clamp(+child.dietMilk, 0, 2) || 0;
		child.onDiet = Math.clamp(+child.onDiet, 0, 1) || 0;
		child.hormones = Math.clamp(+child.hormones, -2, 2) || 0;
		child.hormoneBalance = Math.clamp(+child.hormoneBalance, -400, 400) || 0;
		if (typeof child.drugs !== "string") {
			child.drugs = "no drugs";
		}
		child.aphrodisiacs = Math.clamp(+child.aphrodisiacs, 0, 2) || 0;
		child.curatives = Math.clamp(+child.curatives, 0, 2) || 0;
	}

	function childPornDatatypeCleanup(child) {
		child.porn.feed = Math.clamp(+child.porn.feed, 0, 1) || 0;
		child.porn.viewerCount = Math.max(+child.porn.viewerCount, 0) || 0;
		child.porn.spending = Math.max(+child.porn.spending, 0) || 0;
		child.porn.prestige = Math.clamp(+child.porn.prestige, 0, 3) || 0;
		if (typeof child.porn.prestigeDesc !== "string") {
			child.porn.prestigeDesc = 0;
		}
		if (typeof child.porn.fameType !== "string") {
			child.porn.fameType = "none";
		}
		if (typeof child.porn.focus !== "string") {
			child.porn.focus = "none";
		}
		for (const genre of App.Porn.getAllGenres()) {
			child.porn.fame[genre.fameVar] = Math.max(+child.porn.fame[genre.fameVar], 0) || 0;
		}
	}

	function childRelationDatatypeCleanup(child) {
		child.mother = +child.mother || 0;
		child.father = +child.father || 0;
		child.canRecruit = Math.clamp(+child.canRecruit, 0, 1) || 0;
		child.relationship = Math.clamp(+child.relationship, -3, 5) || 0;
		child.relationshipTarget = Math.max(+child.relationshipTarget, 0) || 0;
		child.rivalryTarget = Math.max(+child.rivalryTarget, 0) || 0;
		child.rivalry = Math.clamp(+child.rivalry, 0, 3) || 0;
	}

	function childSkillsDatatypeCleanup(child) {
		child.skill.oral = Math.clamp(+child.skill.oral, 0, 100) || 0;
		child.skill.vaginal = Math.clamp(+child.skill.vaginal, 0, 100) || 0;
		child.skill.anal = Math.clamp(+child.skill.anal, 0, 100) || 0;
		child.skill.whoring = Math.clamp(+child.skill.whoring, 0, 100) || 0;
		child.skill.entertainment = Math.clamp(+child.skill.entertainment, 0, 100) || 0;
		child.skill.combat = Math.clamp(+child.skill.combat, 0, 1) || 0;
		child.skill.headGirl = Math.clamp(+child.skill.headGirl, 0, 200) || 0;
		child.skill.recruiter = Math.clamp(+child.skill.recruiter, 0, 200) || 0;
		child.skill.bodyguard = Math.clamp(+child.skill.bodyguard, 0, 200) || 0;
		child.skill.madam = Math.clamp(+child.skill.madam, 0, 200) || 0;
		child.skill.DJ = Math.clamp(+child.skill.DJ, 0, 200) || 0;
		child.skill.nurse = Math.clamp(+child.skill.nurse, 0, 200) || 0;
		child.skill.teacher = Math.clamp(+child.skill.teacher, 0, 200) || 0;
		child.skill.attendant = Math.clamp(+child.skill.attendant, 0, 200) || 0;
		child.skill.matron = Math.clamp(+child.skill.matron, 0, 200) || 0;
		child.skill.stewardess = Math.clamp(+child.skill.stewardess, 0, 200) || 0;
		child.skill.milkmaid = Math.clamp(+child.skill.milkmaid, 0, 200) || 0;
		child.skill.farmer = Math.clamp(+child.skill.farmer, 0, 200) || 0;
		child.skill.wardeness = Math.clamp(+child.skill.wardeness, 0, 200) || 0;
		child.skill.servant = Math.clamp(+child.skill.servant, 0, 200) || 0;
		child.skill.entertainer = Math.clamp(+child.skill.entertainer, 0, 200) || 0;
		child.skill.whore = Math.clamp(+child.skill.whore, 0, 200) || 0;
	}

	function childStatCountDatatypeCleanup(child) {
		child.counter.oral = Math.max(+child.counter.oral, 0) || 0;
		child.counter.vaginal = Math.max(+child.counter.vaginal, 0) || 0;
		child.counter.anal = Math.max(+child.counter.anal, 0) || 0;
		child.counter.publicUse = Math.max(+child.counter.publicUse, 0) || 0;
		child.counter.mammary = Math.max(+child.counter.mammary, 0) || 0;
		child.counter.penetrative = Math.max(+child.counter.penetrative, 0) || 0;
		child.counter.pitKills = Math.max(+child.counter.pitKills, 0) || 0;
		child.counter.milk = Math.max(+child.counter.milk, 0) || 0;
		child.counter.cum = Math.max(+child.counter.cum, 0) || 0;
		child.counter.births = Math.max(+child.counter.births, 0) || 0;
		child.counter.birthsTotal = Math.max(+child.counter.birthsTotal, 0) || child.counter.births;
		child.counter.laborCount = Math.max(+child.counter.laborCount, 0) || child.counter.birthsTotal;
		child.childsFathered = Math.max(+child.childsFathered, 0) || 0;
		child.counter.PCChildrenFathered = Math.max(+child.counter.PCChildrenFathered, 0) || 0;
		child.childsKnockedUp = Math.max(+child.childsKnockedUp, 0) || 0;
		child.counter.PCKnockedUp = Math.max(+child.counter.PCKnockedUp, 0) || 0;
		child.bodySwap = Math.max(+child.bodySwap, 0) || 0;
	}

	function childPreferencesDatatypeCleanup(child) {
		child.energy = Math.clamp(+child.energy, 0, 100) || 0;
		child.need = Math.max(+child.need, 0) || 0;
		child.attrXY = Math.clamp(+child.attrXY, 0, 100) || 0;
		child.attrXX = Math.clamp(+child.attrXX, 0, 100) || 0;
		child.attrKnown = Math.clamp(+child.attrKnown, 0, 1) || 0;
		child.fetishStrength = Math.clamp(+child.fetishStrength, 0, 100) || 0;
		child.fetishKnown = Math.clamp(+child.fetishKnown, 0, 1) || 0;
	}

	function childRulesDatatypeCleanup(child) {
		child.breedingMark = Math.clamp(+child.breedingMark, 0, 1) || 0;
		child.rudeTitle = Math.clamp(+child.rudeTitle, 0, 1) || 0;
	}

	function childCustomStatsDatatypeCleanup(child) {
		if (typeof child.custom.label !== "string") {
			child.custom.label = "";
		}
		if (typeof child.custom.desc !== "string") {
			child.custom.desc = "";
		}
		if (typeof child.custom.title !== "string") {
			child.custom.title = "";
		}
		if (typeof child.custom.titleLisp !== "string") {
			child.custom.titleLisp = "";
		}
		if (child.custom.image !== null) {
			if (typeof child.custom.image.filename !== "string") {
				child.custom.image = null;
			}
		}
	}

	function childMiscellaneousDatatypeCleanup(child) {
		child.weekAcquired = Math.max(+child.weekAcquired, 0) || 0;
		child.prestige = Math.clamp(+child.prestige, 0, 3) || 0;
		child.devotion = Math.clamp(+child.devotion, -100, 100) || 0;
		child.oldDevotion = Math.clamp(+child.oldDevotion, -100, 100) || 0;
		child.trust = Math.clamp(+child.trust, -100, 100) || 0;
		child.oldTrust = Math.clamp(+child.oldTrust, -100, 100) || 0;
		child.chem = Math.max(+child.chem, 0) || 0;
		child.addict = Math.max(+child.addict, 0) || 0;
		child.intelligence = Math.clamp(+child.intelligence, -100, 100) || 0;
		child.intelligenceImplant = Math.clamp(+child.intelligenceImplant, 0, 30) || 0;
		child.premature = Math.clamp(+child.premature, 0, 1) || 0;
		child.training = Math.clamp(+child.training, 0, 150) || 0;
		child.hears = Math.clamp(+child.hears, -2, 0) || 0;
		child.smells = Math.clamp(+child.smells, -1, 0) || 0;
		child.tastes = Math.clamp(+child.tastes, -1, 0) || 0;
		if (typeof child.earwear !== "string") {
			child.earwear = "none";
		}
		if (child.voice !== 0) {
			child.voice = Math.clamp(+child.voice, 0, 3) || 1;
		}
		child.electrolarynx = Math.clamp(+child.electrolarynx, 0, 1) || 0;
		child.accent = Math.clamp(+child.accent, 0, 3) || 0;
	}
};

App.Facilities.Nursery.InfantDatatypeCleanup = function(child) {
	"use strict";

	ageDatatypeCleanup(child);
	physicalDatatypeCleanup(child);
	faceDatatypeCleanup(child);
	hairDatatypeCleanup(child);
	relationDatatypeCleanup(child);
	originDatatypeCleanup(child);
	generatePronouns(child);

	// old versions of FC assign overlapping IDs to infants and other slaves, which needs to be fixed
	// deconflict IDs between infants and older children/tank babies/adults by reassigning the infant's ID
	if (V.cribs.find((s) => s.ID === child.ID && (s.birthWeek !== child.birthWeek || s.actualAge !== child.actualAge)) !== undefined
	 || V.slaves.find((s) => s.ID === child.ID) !== undefined || V.tanks.find((s) => s.ID === child.ID) !== undefined) {
		child.ID = generateSlaveID();
	}

	function ageDatatypeCleanup(child) {
		child.birthWeek = Math.clamp(+child.birthWeek, 0, 51) || 0;
		child.actualAge = Math.clamp(+child.actualAge, V.minimumChildAge, Infinity) || 0;
	}

	function physicalDatatypeCleanup(child) {
		if (typeof child.nationality !== "string") {
			child.nationality = "child";
		}
		if (typeof child.race !== "string") {
			nationalityToRace(child);
		}
		if (typeof child.skin !== "string") {
			child.skin = "light";
		}
		child.weight = Math.clamp(+child.weight, -100, 200) || 0;
	}

	function faceDatatypeCleanup(child) {
		child.face = Math.clamp(+child.face, -100, 100) || 0;
		if (typeof child.faceShape !== "string") {
			child.faceShape = "normal";
		}
	}

	function hairDatatypeCleanup(child) {
		if (typeof child.hColor !== "string") {
			child.hColor = "brown";
		}
		if (typeof child.pubicHStyle !== "string") {
			child.pubicHStyle = "neat";
		}
		if (typeof child.eyebrowHColor !== "string") {
			child.eyebrowHColor = child.hColor;
		}
	}

	function relationDatatypeCleanup(child) {
		child.mother = +child.mother || 0;
		child.father = +child.father || 0;
	}

	function originDatatypeCleanup(child) {
		if (typeof child.origin !== "string") {
			child.origin = `${capFirstChar(child.pronoun)} was born and raised in your arcology. `;
		}
	}
};

repo_name: KnightBoulegard/fc

license: mit


code:
:: Nursery Discard Workaround [nobr]

$activeSlave.slaveName has been given away to another arcology to be raised, never to be seen again.

<<set $returnTo = "Main">>


code:
App.Data.Facilities.nursery = {
	baseName: "nursery",
	genericName: null,
	jobs: {
		nanny: {
			position: "nanny",
			assignment: Job.NURSERY,
			publicSexUse: false,
			fuckdollAccepted: false,
			description: {
				rulesAssistant: {
					assigned:()=> `work in ${V.nurseryName}`
				}
			}
		}
	},
	defaultJob: "nanny",
	manager: {
		position: "matron",
		assignment: Job.MATRON,
		careers: App.Data.misc.matronCareers,
		skill: "matron",
		publicSexUse: false,
		fuckdollAccepted: false,
		broodmotherAccepted: false,
		shouldWalk: true,
		shouldHold: true,
		shouldSee: true,
		shouldHear: true,
		shouldTalk: true,
		shouldThink: true,
		requiredDevotion: 51
	}
};

App.Entity.Facilities.NurseryNannyJob = class extends App.Entity.Facilities.FacilitySingleJob {
	/**
	 * @param {App.Entity.SlaveState} slave
	 * @returns {string[]}
	 */
	checkRequirements(slave) {
		let r = super.checkRequirements(slave);

		if (!App.Entity.Facilities.Job._isBrokenEnough(slave, 51, 21, -20, -95)) {
			r.push(App.Entity.Facilities.Job._stdBreakageMessage(slave));
		}

		return r;
	}
};

App.Entity.Facilities.Nursery = class extends App.Entity.Facilities.SingleJobFacility {
	constructor() {
		super(App.Data.Facilities.nursery,
			{
				nanny: new App.Entity.Facilities.NurseryNannyJob()
			});
	}

	// get capacity() {
	// 	return State.Variables.nurseryNannies;
	// }

	/** @override */
	occupancyReport(long) {
		return long
			? `${V.nurseryBabies}/${V.nursery} babies, ${this.hostedSlaves}/${V.nurseryNannies} nannies${this.manager.currentEmployee ? `, ${this.manager.desc.position}` : ""}`
			: `${V.nurseryBabies}/${V.nursery}, ${this.hostedSlaves}/${V.nurseryNannies}${this.manager.currentEmployee ? ", L" : ""}`;
	}
};

App.Entity.facilities.nursery = new App.Entity.Facilities.Nursery();


code:
:: Nursery Report [nobr]

<<print App.Facilities.Nursery.nurseryReport()>>


code:
:: Nursery Retrieval Workaround [nobr]

$readySlave.slaveName has been discharged from $nurseryName and is ready to become your slave.

<<set $activeSlave = $readySlave>>
<<set $saleDescription = 0, $applyLaw = 0>>
<<set $nurseryBabies-->>
<<include "Long Slave Description">>
<<run newSlave($activeSlave)>>
<<set $slaves.push($activeSlave)>>
<<set $nextLink = "AS Dump">>
<<set $returnTo = "Main">>
/*
<<if $nurseryOrgans.length > 0>>
	<<for _i = 0; _i < $nurseryOrgans.length; _i++>>
		<<if $nurseryOrgans[_i].ID == $nurseryOldID>>
			<<set _newOrgan = {type: $nurseryOrgans[_i].type, weeksToCompletion: $nurseryOrgans[_i].weeksToCompletion, ID: $activeSlave.ID}>>
			<<if _newOrgan.weeksToCompletion <= 0>>
				<<set $completedOrgans.push($nurseryOrgans[_i])>>
			<<else>>
				<<set $organs.push(_newOrgan)>>
			<</if>>
			<<set $nurseryOrgans.deleteAt(_i), _i-->>
		<</if>>
	<</for>>
<</if>>
*/
/*<<include "New Child Nursery">>*/


code:
:: Nursery Workaround [nobr]

<<if $cribs.length < $nursery>>
	<<run App.Facilities.Nursery.newChild($activeChild)>>
	/*<<= App.Facilities.Nursery.nameChild($activeChild)>>*/
<</if>>


code:
:: Previous 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 == 0>>
	<<set $activeChild = $cribs[$cribs.length - 1]>>
	<<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:
:: Rename Child [nobr]

<<set $nextButton = "Back", $nextLink = "Slave Interact">>

<<if $activeChild.slaveName === $oldName && $activeChild.slaveSurname === $oldSurname>>
	<<goto "Slave Interact">>
<<else>>
/* First time renaming reaction */
<<if $activeChild.slaveName === "" || ndef $activeChild.slaveName>>
	$oldName needs to be called something on the records, so $oldName $he stays.
	<<set $activeChild.slaveName = $oldName>>
<<elseif $activeChild.fetish == "mindbroken">>
	$activeChild.slaveName doesn't even recognize that $he's been renamed. It simply does not register.
<<elseif ($oldName != $activeChild.birthName && $oldSurname != $activeChild.birthSurname) && ($activeChild.slaveName == $activeChild.birthName || $activeChild.slaveSurname == $activeChild.birthSurname)>>
	$activeChild.slaveName
	<<if $activeChild.devotion > 50>>
		cheerfully accepts $his old name back.
	<<elseif $activeChild.devotion >= -20>>
		obediently accepts $his old name back.
	<<elseif $activeChild.devotion >= -50>>
		happily accepts $his original name.
	<<elseif $activeChild.trust > 20>>
		scoffs at the notion that $he was ever anything other than <<= SlaveFullBirthName($activeChild)>>, @@.orangered;weakening your control over $him.@@
		<<set $activeChild.trust += 5>>
	<<else>>
		cautiously accepts the return of $his name.
	<</if>>
<<elseif $oldName == $activeChild.birthName || $oldSurname == $activeChild.birthSurname>>
	$activeChild.slaveName
	<<if $activeChild.devotion > 50>>
		accepts $his new name cheerfully. This attachment to you @@.hotpink; increases $his devotion.@@
		<<set $activeChild.devotion += 4>>
	<<elseif $activeChild.devotion >= -20>>
		obediently accepts $his new name. This surrender to you @@.hotpink; increases $his obedience.@@
		<<set $activeChild.devotion += 4>>
	<<elseif $activeChild.devotion >= -50>>
		reluctantly accepts $his new name.
	<<else>>
		angrily tries to resist $his new name, insisting that $his name is <<= SlaveFullBirthName($activeChild)>>. This resistance @@.mediumorchid; increases $his rebelliousness.@@
		<<set $activeChild.devotion -= 5>>
	<</if>>
<<else>>
	Since $activeChild.slaveName has already had a new name <<if $activeChild.devotion > 20>>given to<<else>>forced on<</if>> $him before, the mere fact of having it changed again doesn't really affect $him.
<</if>>

<<set _insultingName = 0>>
<<if $oldName != $activeChild.slaveName && typeof $activeChild.slaveName == "string">>
	<<set _toSearch = $activeChild.slaveName.toLowerCase()>>
	<<for $i = 0; $i < setup.badWords.length; $i++>>
		<<if _toSearch.indexOf(setup.badWords[$i]) != -1>>
			<<set _insultingName = 1>>
			<<break>>
		<</if>>
	<</for>>
<</if>>
<<if !_insultingName>>
	<<if $oldSurname != $activeChild.slaveSurname && typeof $activeChild.slaveSurname == "string">>
		<<set _toSearch = $activeChild.slaveSurname.toLowerCase()>>
		<<for $i = 0; $i < setup.badWords.length; $i++>>
			<<if _toSearch.indexOf(setup.badWords[$i]) != -1>>
				<<set _insultingName = 1>>
				<<break>>
			<</if>>
		<</for>>
	<</if>>
<</if>>
<<if _insultingName == 1>>
	<<if $activeChild.fetish == "mindbroken">>
		$His new name would be insulting to a normal $girl, but $he dully accepts that it is an accurate description and goes about $his duties.
	<<elseif $activeChild.devotion < -50>>
		Being given such a degrading name @@.mediumorchid;further increases $his hatred@@ of you.
		<<set $activeChild.devotion -= 5>>
	<<elseif $activeChild.devotion <= 50>>
		Being given such a degrading name @@.gold;terrifies $him,@@ since $he thinks it's fair warning for what $he'll suffer in the future.
		<<set $activeChild.trust -= 5>>
	<</if>>
<</if>>

/* Wife's surname reaction */
<<if $oldSurname != $activeChild.slaveSurname>>
	<<if $activeChild.relationship >= 5>>
		<<set _i = $slaveIndices[$activeChild.relationshipTarget]>>
		<<if ndef _i>>@@.red;Error, relationshipTarget not found.@@<</if>>
			<<if $slaves[_i].slaveSurname>>
			<<if $activeChild.slaveSurname == $slaves[_i].slaveSurname>>
				$He's touched that $he now shares a surname with $his wife $slaves[_i].slaveName $slaves[_i].slaveSurname, and is @@.mediumaquamarine;more confident than ever@@ that you intend to keep them together in marital bliss.
				<<set $activeChild.trust += 5>>
			<<elseif $oldSurname == $slaves[_i].slaveSurname>>
				$He's concerned that $he no longer shares a surname with $his wife $slaves[_i].slaveName $slaves[_i].slaveSurname, and is @@.gold;very worried@@ that you might be considering splitting them up.
				<<set $activeChild.trust -= 5>>
			<</if>>
		<</if>>
	<</if>>
<</if>>

/* PC's surname reaction */
<<if $oldSurname != $activeChild.slaveSurname>>
	<<if $activeChild.relationship == -3>>
		<<if $PC.slaveSurname>>
			<<if $activeChild.fetish == "mindbroken">>
				Names are meaningless to $him and it is unlikely $he'll remember it.
			<<elseif $activeChild.devotion+$activeChild.trust >= 175>>
				<<if $activeChild.slaveSurname == $PC.slaveSurname>>
					<<if hasAnyArms($activeChild)>>
						When you tell $him that $he's to be known as $activeChild.slaveName $activeChild.slaveSurname now, $he starts to cry. $He tries to get $himself under control and thank you as best $he can, wiping at the tears running down $his $activeChild.skin cheeks, but $he can't seem to stop weeping as $he thanks you over and over. $He's a sex slave, your property, and it's understandable that some doubts about the permanence of $his place as your slave wife. This has @@.mediumaquamarine;helped reassure $him,@@ and explains the strength of $his emotional reaction. The next time you make love to $him, $he @@.hotpink;presses $himself as close to you as $he can,@@ eager to drink in as much of your presence as $he can get.
					<<else>>
						$He's @@.hotpink;deeply touched@@ that $he now shares a surname with you, and has @@.mediumaquamarine;an additional source of confidence@@ that $he'll remain your amputee slave wife.
					<</if>>
					<<set $activeChild.devotion += 5, $activeChild.trust += 5>>
				<<elseif $oldSurname == $PC.slaveSurname>>
					$He's devastated that you'd rename $him something other than your name. $He's @@.gold;terrified@@ that you intend to discard $him as your slave wife, and @@.mediumorchid;saddened@@ that you would take away something that was precious to $him.
					<<set $activeChild.devotion -= 5, $activeChild.trust -= 5>>
				<</if>>
			<<elseif $activeChild.devotion < -20 && $activeChild.trust > 20>>
				<<if $activeChild.slaveSurname == $PC.slaveSurname>>
					When you tell $him that $he's to be known as $activeChild.slaveName $activeChild.slaveSurname now, $he shows no reaction. You already took everything from $him, what's a name at this point?
				<<elseif $oldSurname == $PC.slaveSurname>>
					$He doesn't care about losing your surname at first, but it quickly sets in that $he may have @@.gold;pushed $his position too far.@@
					<<set $activeChild.trust -= 20>>
				<</if>>
			<<elseif $activeChild.devotion < -20>>
				<<if $activeChild.slaveSurname == $PC.slaveSurname>>
					When you tell $him that $he's to be known as $activeChild.slaveName $activeChild.slaveSurname now, $he pleads with you not to steal $his name. It matters little to you, and $he is forced to @@.hotpink;accept your will.@@
					<<set $activeChild.devotion += 5>>
				<<elseif $oldSurname == $PC.slaveSurname>>
					$He's @@.mediumorchid;happy@@ to no longer have to share a name with $his tormentor, but the bliss doesn't last long as @@.gold;dread@@ quickly sets in about what this may mean.
					<<set $activeChild.devotion += 5, $activeChild.trust -= 10>>
				<</if>>
			<<else>>
				<<if $activeChild.slaveSurname == $PC.slaveSurname>>
					When you tell $him that $he's to be known as $activeChild.slaveName $activeChild.slaveSurname now, $he nods with approval feeling @@.mediumaquamarine;that $he may hold at least some value in your eyes.@@
					<<set $activeChild.trust += 5>>
				<<elseif $oldSurname == $PC.slaveSurname>>
					$He accepts that you'd rename $him something other than your name. $He's @@.gold;a little scared@@ that you intend to discard $him as your slave wife, or worse, but realizes this was not only a possibility, but likely.
					<<set $activeChild.trust -= 5>>
				<</if>>
			<</if>>
		<</if>>
	<</if>>
<</if>>

<</if>> /* close new name check */


code:
App.Facilities.Nursery.fChildOral = function fChildOral(child) {
	"use strict";

	let r = ``;

	actX(child, "oral");// TODO: will this counts towards the total count?

	// TODO: all of this

	return r;
};

App.Facilities.Nursery.fChildVaginal = function fChildVaginal(child) {
	"use strict";

	let r = ``;

	actX(child, "vaginal");// TODO: will this counts towards the total count?

	// TODO: all of this

	return r;
};

App.Facilities.Nursery.fChildAnal = function fChildAnal(child) {
	"use strict";

	let r = ``;

	actX(child, "anal");

	// TODO: all of this

	return r;
};

App.Facilities.Nursery.fChildImpreg = function fChildImpreg(child) {
	"use strict";
	const
		bonus = jsRandom(6, 20);

	let r = ``;

	if (child.mpreg) {
		actX(child, "anal", (bonus + 1));
	} else {
		actX(child, "vaginal", (bonus + 1));
	}

	// TODO: all of this

	return r;
};