code:
:: Clothing Shop v2 Widgets [widget]

<<widget "exitclothingshop">>

		<<if $clothes_choice and $shopDefaults.alwaysBackToShopButton is false>>
			<<link "Back">>
				<<unset $clothes_choice>><<updateclotheslist>><</link>>
		<<else>>
			<<link "Back to shop">><<unset $clothes_choice>><<updateclothingshop>><</link>>
		<</if>>

<</widget>>

/*
	args[0] should be "clothing", "forest" or "school"
	args[1] is a slot: "upper", "lower", "under_upper", etc.
	args[2] should be "outfits" or missing. Combination of "over_upper", "upper" or "under_upper" in args[1] with "outfits" provides respective outfits category
*/
<<widget "clothingShopv2">>
	<<exitclothingshop>>
	<<if $args[0]>>
		<<set _shopLocation to $args[0]>>
	<</if>>
	<<if $args[1]>>
		<<set $clothingShopSlot to $args[1]>>
	<</if>>
	<<set _outfits to $args[2] == "outfits" or $args[2] == true>>

	<<if $shopClothingFilter is undefined>>
		<<shopClothingFilterReset>>
	<</if>>
	<<if $shopItemsPerPage is undefined>>
		<<set $shopItemsPerPage = 12>>
	<</if>>

	<<if $shopClothingFilter.active>>
		The filter is currently active!
		<<link "Reset it">>
			<<shopClothingFilterReset>>
			<<updateclotheslist>>
		<</link>>

	<</if>>

		<<shopDetailsv2>>

	<<set _iconName to clothingSlotToIconName($clothingShopSlot, _outfits)>>
	<<shopCategoryTabs _iconName>>

	<<set _items = setup.clothes[$clothingShopSlot].filter(x => x.shop.includes(_shopLocation) and x.outfitSecondary is undefined
		and ((_outfits and x.outfitPrimary isnot undefined and Object.keys(x.outfitPrimary).some(secSlot => secSlot.includes("lower")))
			or
			(!_outfits and (x.outfitPrimary is undefined or Object.keys(x.outfitPrimary).every(secSlot => !secSlot.includes("lower")))))
	)>>
	<<set _items = applyClothingShopFilters(_items)>>
	<<set _maxPage = Math.ceil(_items.length / $shopItemsPerPage)>>

		<<generateshoppage $shopPage>>

		<<timed 0.2s>>
			<<set _ppre = $shopPage - 1>>
			<<repeat 0.1s>>

				<<if _ppre >= 0>>
					<<prepend '#shop-list-pages'>>
						<<generateshoppage _ppre>>
					<</prepend>>
					<<set _ppre-->>
				<<else>>
					<<stop>>
				<</if>>
			<</repeat>>

			<<set _papp = $shopPage + 1>>
			<<repeat 0.1s>>
				<<if _papp < _maxPage>>
					<<append '#shop-list-pages'>>
						<<generateshoppage _papp>>
					<</append>>
					<<set _papp++>>
				<<else>>
					<<stop>>
				<</if>>
			<</repeat>>
		<</timed>>

		<<set _disabled = $shopPage > 0 ? "" : "disabled">>

			<<link "Previous">>
				<<if $shopPage > 0>>
					<<set $shopPage -= 1>>
					<<clothingshopChangePage>>
				<</if>>
			<</link>>

<

			<<for _i = 0; _i < _maxPage; _i++>>
				<<capture _i>>
					<<set _active = _i == $shopPage ? "active" : "">>

						<<link "">>
							<<set $shopPage = _i>>
							<<clothingshopChangePage>>
						<</link>>

				<</capture>>
			<</for>>

			<<print ($shopPage + 1) + " out of " + _maxPage>>

		<<set _disabled = $shopPage < _maxPage - 1 ? "" : "disabled">>

			<<link "Next">>
				<<if $shopPage < _maxPage - 1>>
					<<set $shopPage += 1>>
					<<clothingshopChangePage>>
				<</if>>
			<</link>>

>

	<<run $(window).on('resize', () => {
		let pagination = $('#shop-pagination');
		let pages = $(pagination).find('.shop-pages');
		let buttons = $(pagination).find('.btn-pagination');
		let isEnoughSpace = (pagination.width() - buttons.outerWidth() * 2 - 32) / pages.children().length >= 22;

		pages.toggleClass('hidden', !isEnoughSpace);
		pagination.find('.shop-pages-number').toggleClass('hidden', isEnoughSpace);
	})>>

		<<if $images is 1>>

		<<else>>
			Filters
		<</if>>
		<<link "">>
			<<replace '#filters'>><<loadFiltersMenu>><</replace>>
			<<run linkifyDivs('#filters')>>
			<<toggleclass '#filters' 'hidden'>>
		<</link>>

		<<if $images is 1>>

		<<else>>
			Opt.
		<</if>>
		<<link "">>
			<<replace '#shop-options'>><<loadShopOptions>><</replace>>
			<<run linkifyDivs('#shop-options')>>
			<<toggleclass '#shop-options' 'hidden'>>
		<</link>>

	<<if !$shopDefaults.noHelp>>

			<<if $images is 1>>

			<<else>>
				Help
			<</if>>
			<<link "">>
				<<toggleclass '#shop-legend' 'hidden'>>
				<<toggleclass '.shop-legend-button' 'active'>>
			<</link>>

		<<clothingShopLegend>>
	<</if>>

	<<run linkifyDivs('#clothingShop-div')>>
	<<numberify '#clothingShop-div'>>
	<<run $(() => {
		_maxW = Math.max($('.btn-pagination.next').width(), $('.btn-pagination.prev').width());
		$('.btn-pagination.prev').width(_maxW);
		$('.btn-pagination.next').width(_maxW);
	})>>
<</widget>>

<<widget "clothingshopChangePage">>

	<<run $('#shop-list-pages > div.clothing-shop-page').addClass('hidden no-numberify')>>
	<<run $('#shop-list-pages > div.clothing-shop-page:nth-of-type(' + ($shopPage + 1) + ')').removeClass('hidden no-numberify')>>

	<<run $('#shop-pagination > .shop-pages > div.page').removeClass('active')>>
	<<run $('#shop-pagination > .shop-pages > div.page:nth-of-type(' + ($shopPage + 1) + ')').addClass('active')>>

	<<run $('#shop-pagination > .btn-pagination.prev').toggleClass('disabled', $shopPage <= 0)>>
	<<run $('#shop-pagination > .btn-pagination.next').toggleClass('disabled', $shopPage >= _maxPage - 1)>>

	<<run Links.generateLinkNumbers($('#clothingShop-div'))>>

	<<replace '#shop-pagination > .shop-pages-number'>><<print ($shopPage + 1) + " out of " + _maxPage>><</replace>>
<</widget>>

<<widget "generateshoppage">>
	<<set _page = $args[0]>>
	<<set _itemsOnPage = _items.slice(_page * $shopItemsPerPage, (_page + 1) * $shopItemsPerPage)>>
	<<set _hidden = _page == $shopPage ? "" : " hidden">>
	<<set _compact = $shopDefaults.compactMode ? "compact" : "">>

	<<set _colCustomPrimary = getCustomColourStyle('primary')>>
	<<set _colCustomSecondary = getCustomColourStyle('secondary')>>

		<<for _itemTemp range _itemsOnPage>>
			<<set _item = clone(_itemTemp)>>
			<<set _itemData = setup.clothes[$clothingShopSlot][clothesIndex($clothingShopSlot,_item)]>>
			<<set _locked = $specialClothes[_item.name.replace(/ /g,"")] is "locked">>
			<<set _unlocked = $specialClothes[_item.name.replace(/ /g,"")] is "unlocked">>

					<<if _locked and $images is 1>>

					<<else>>
						<<if _item.colour_options.length > 0>>
							<<if $shopDefaults.colourItems == "random">>
								<<set _item.colour = _item.colour_options[random(_item.colour_options.length - 1)]>>
							<<elseif $shopDefaults.colourItems == "default" and _item.colour_options.includes($shopDefaults.color)>>
								<<set _item.colour = $shopDefaults.color>>
								<<if $shopDefaults.color == "custom">>
									<<set _item.colourCustom = _colCustomPrimary>>
								<</if>>
							<</if>>
						<</if>>
						<<if _item.accessory_colour_options.length > 0>>
							<<if $shopDefaults.colourItems == "random">>
								<<set _item.accessory_colour = _item.accessory_colour_options[random(_item.accessory_colour_options.length - 1)]>>
							<<elseif $shopDefaults.colourItems == "default" and _item.accessory_colour_options.includes($shopDefaults.secColor)>>
								<<set _item.accessory_colour = $shopDefaults.secColor>>
								<<if $shopDefaults.secColor == "custom">>
									<<set _item.accessory_colourCustom = _colCustomSecondary>>
								<</if>>
							<</if>>
						<</if>>
						<<clothingicon _item $clothingShopSlot>>

						<<if _item.gender isnot "n">>

								<<if $shopDefaults.compactMode>>
									<<if _item.gender is "m">>

									<<elseif _item.gender is "f">>

									<</if>>
								<<else>>
									<<if $images is 1>>
										<<if _item.gender is "m">>

										<<elseif _item.gender is "f">>

										<</if>>
									<<else>>
										<<if _item.gender is "m">>
											♂
										<<elseif _item.gender is "f">>
											♀
										<</if>>
									<</if>>
								<</if>>

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

					<<if !$shopDefaults.compactMode>>

					<</if>>

						<<if _locked>>
							_itemData.name_cap | Locked
						<<else>>
							<<set _csslot = $clothingShopSlot>>
							<<capture _item _itemData _shopLocation _csslot _outfits>>
								<<link _itemData.name_cap>>
									<<set $clothes_choice = clothesIndex(_slot,_item)>>
									<<set $clothes_choice_reveal = _item.reveal>>
									<<set $clothes_choice_integrity = _itemData.integrity_max>>
									<<unset $colouraction>>
									<<unset $accessorycolouraction>>
									<<run window.scrollTo(0, 0)>>
									<<updateclotheslist _shopLocation _csslot _outfits>>
								<</link>>
							<</capture>>
							<<if _unlocked>>
								 | Unlocked
							<</if>>
						<</if>>

					<<if _locked>>

							<<specialClothesHint>>
							<<print _specialClothesHint[_item.name.replace(/ /g,"")]>>

					<<else>>

						<<printmoney `getClothingCost(_item,$clothingShopSlot)` true>>

						<<if !$shopDefaults.compactMode>>

								<<if $images is 1>>

								<<else>>
									I.
								<</if>>
								<<set _intInf = getIntegrityInfo(_item.integrity_max)>>
								<<for _i = 0; _i lt 7; _i++>>
									<span @class="'stats-ball ' + (_i < _intInf[0] ? 'bg-' + _intInf[1] : '')">
								<</for>>

								<<if $images is 1>>

								<<else>>
									R.
								<</if>>
								<<set _revInf = getRevealInfo(_item.reveal)>>
								<<for _i = 0; _i lt 7; _i++>>
									<span @class="'stats-ball ' + (_i < _revInf[0] ? 'bg-' + _revInf[1] : '')">
								<</for>>

								<<if $images is 1>>

								<<else>>
									W.
								<</if>>
								<<set _warInf = getWarmthInfo(getTrueWarmth(_item))>>
								<<for _i = 0; _i lt 5; _i++>>
									<span @class="'stats-ball ' + (_i < _warInf[0] ? _warInf[1] : '')">
								<</for>>

						<</if>>
						<<if !$shopDefaults.noTraits>>

								<<for _i, _trait range _item.type>>
									<<clothingtrait _trait>>
								<</for>>

						<</if>>
					<</if>>
					<<if $shopDefaults.compactMode>>

					<</if>>

		<</for>>

		<<for _i = 0; _i < $shopItemsPerPage - _itemsOnPage.length; _i++>>

		<</for>>

		<<run linkifyDivs('#shop-list-pages > .clothing-shop-page.page-' + _page)>>

<</widget>>

<<widget "updateclotheslist">>
	<<set _shop = $args[0] or _shopLocation>>
	<<set _slot = $args[1] or $clothingShopSlot>>
	<<set _outf = $args[2] or _outfits>>
	<<replace "#clothes-list">><<clothingShopv2 _shop _slot _outf>><</replace>>
<</widget>>

<<widget "clothingtrait">>
	<<if $images is 1 and ($args[1] or $args[0] isnot "normal")>>

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

<<widget "shopDetailsv2">>
	<<unset _mannequinGenderOverride>>
	<<if $clothes_choice and setup.clothes[$clothingShopSlot][$clothes_choice] is undefined>>
		<<unset $clothes_choice>>

	<<elseif $clothes_choice>>
		<<set _temp_choice to clone(setup.clothes[$clothingShopSlot][$clothes_choice])>>

		<<if $specialClothes[_temp_choice.name.replace(/ /g,"")] is "unlocked">>
			<<specialClothesHint>>

				Unlocked | <<print _specialClothesHint[_temp_choice.name.replace(/ /g,"")]>>

		<</if>>

		<<if _temp_choice.plural is 1>>
			<<integrity $clothes_choice_integrity "cap">>
		<<else>>
			A <<integrity $clothes_choice_integrity>>
		<</if>>
		and <<reveal $clothes_choice_reveal>> <<print _temp_choice.name>>.
		<<if _temp_choice.gender is "m">>
			For boys.
		<<elseif _temp_choice.gender is "f">>
			For girls.
		<</if>>
		<<print _temp_choice.description>> Costs <<printmoney `getClothingCost(_temp_choice,$clothingShopSlot)`>>.

		<<set _truewarmth = getTrueWarmth(_temp_choice)>>
		<<warmth _truewarmth>>

		<<shoptraits>>
		<<set _slimeSlots to ["over_upper","over_lower","upper","lower","under_upper","under_lower"]>>
		<<if !_slimeSlots.includes($clothingShopSlot) or $willpower gte 800 or _temp_choice.reveal gte 500 or _temp_choice.type.includesAny("school", "event") or $corruption_slime lt 80>>

				<<set _hiddenMannequin = $images is 1 ? "" : "hidden">>

					<<mannequin>>

				<<set _translate = $images is 1 ? "translate-colours-container" : "">>

					<<if _temp_choice.colour_options.length gt 1>>
						<<run _temp_choice.colour_options.pushUnique("random")>>
						There's a range of colours to choose from:

						<<printShopColourOptions>>
					<</if>>
					<<if _temp_choice.accessory_colour_options.length isnot 0>>
						<<run _temp_choice.accessory_colour_options.pushUnique("random")>>

						Secondary colour:

						<<printShopColourOptions "secondary">>
					<</if>>

			<<run attachCustomColourHooks($clothingShopSlot)>>

			<<unset _cursedPrevent>>
			<<set _preventSlots to []>>
			<<if $worn[$clothingShopSlot].cursed is 1>>
				<<set _cursedPrevent to true>>
				<<run _preventSlots.push($clothingShopSlot)>>
			<</if>>
			<<set _wardrobeSlots to [$clothingShopSlot]>>
			<<if _temp_choice.outfitPrimary isnot undefined>>
				<<for _slot, _name range _temp_choice.outfitPrimary>>
					<<run _wardrobeSlots.push(_slot)>>
					<<if $worn[_slot].cursed is 1>>
						<<set _cursedPrevent to true>>
						<<run _preventSlots.push(_slot)>>
					<</if>>
				<</for>>
			<</if>>

			Warmth:
			<<warmthscale>>

				<<warmth_description>>

			<<if $multipleWardrobes is "all">>
				Send items to:

					<<sendItemsTo>>

			<<else>>
				<<set $wardrobes.shopReturn to "wardrobe">>
			<</if>>
			<<shopBuyItemStatus _wardrobeSlots>>
			<<if _spaceLeft < 1>>
				Your wardrobe is full.

			<<elseif $daystate is "night">>
				<<if $clothingShop.stolenClothes lte 20>>
					<<if $worn[$clothingShopSlot].cursed is 1>>
						<<printcursed>>
					<<else>>
						<<link "Steal and wear">>
							<<shopbuyv2 $clothingShopSlot "steal" "wear" $clothes_choice>><<crimeup `getClothingCost(_temp_choice,$clothingShopSlot) / 100`>>
							<<set $clothingShop.stolenClothes++>>
							<<set $clothingShop.totalStolenClothes++>>
							<<if $shopDefaults.disableReturn is false>>
								<<unset $clothes_choice>>
							<</if>>
							<<updateclotheslist>>
							<<updatesidebarimg>>
							<<updatesidebarmoney>>
							<<updatesidebardescription>>
							<<updateallure>>
							<<if $shopDefaults.disableReturn>>
								<<updatewarmthscale>>
								<<updatewarmthdescription>>
							<</if>>
							<<run updateMoment()>>
						<</link>><<crime>>

					<</if>>
					<<link "Steal and take home">>
						<<shopbuyv2 $clothingShopSlot "steal" "send" $clothes_choice>><<crimeup `getClothingCost(_temp_choice,$clothingShopSlot) / 100`>>
						<<set $clothingShop.stolenClothes++>>
						<<set $clothingShop.totalStolenClothes++>>
						<<if $shopDefaults.disableReturn is false>>
							<<unset $clothes_choice>>
						<</if>>
						<<updateclotheslist>>
						<<updatesidebarimg>>
						<<run updateMoment()>>
					<</link>><<crime>>

				<<else>>
					You can't carry any more clothes with you. You should take them to your wardrobe.

				<</if>>
			<<elseif $money >= getClothingCost(_temp_choice,$clothingShopSlot)>>
				<<if _cursedPrevent>>
					<<printcursed>>
				<</if>>

					<<set _cantWear = _cursedPrevent == true ? "disabled" : "div-link">>

							<<if _cursedPrevent>>
								Buy and wear
							<<else>>
								<<link "Buy and wear">>
									<<clothingReset $clothingShopSlot>>
									<<shopbuyv2 $clothingShopSlot "buy" "wear" $clothes_choice>>
									<<set $money -= getClothingCost(_temp_choice,$clothingShopSlot)>>
									<<if $shopDefaults.disableReturn is "false">>
										<<unset $clothes_choice>>
									<</if>>
									<<updateclotheslist>>
									<<exposedcheck>>
									<<updatesidebarimg>>
									<<updatesidebarmoney>>
									<<updatesidebardescription>>
									<<updateallure>>
									<<if $shopDefaults.disableReturn>>
										<<updatewarmthscale>>
										<<updatewarmthdescription>>
									<</if>>
									<<run updateMoment()>>
								<</link>>
								(<<printmoney `getClothingCost(_temp_choice,$clothingShopSlot)`>>)
							<</if>>

					<<if $buyMultiple is undefined>>
						<<set $buyMultiple = 1>>
					<</if>>

						<<printbuysendhome>>

			<<else>>
				You cannot afford this item.

			<</if>>

			<<if _cursedPrevent != true and $tryOn.tryingOn>>

						<<link "Try On">>
							<<shopbuyv2 $clothingShopSlot "try" null $clothes_choice>>
							<<updateclotheslist>>
							<<exposedcheck>>
							<<updatesidebarimg>>
							<<updatesidebardescription>>
							<<updateallure>>
							<<updatewarmthscale>>
							<<updatewarmthdescription>>
							<<run updateMoment()>>
						<</link>>

					<<if $tryOn.tryingOn[$clothingShopSlot] isnot null>>

							<<link "Return">>
								<<shopbuyv2 $clothingShopSlot "return" null $clothes_choice>>
								<<updateclotheslist>>
								<<exposedcheck>>
								<<updatesidebarimg>>
								<<updatesidebardescription>>
								<<updateallure>>
								<<updatewarmthscale>>
								<<updatewarmthdescription>>
								<<run updateMoment()>>
							<</link>>

					<</if>>

			<</if>>
		<<else>>
			The slime in your ear refuses to allow you to try on or buy the _temp_choice.name.

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

<<widget "printbuysendhome">>
	<<set _clothingCost = getClothingCost(_temp_choice, $clothingShopSlot)>>
	<<set _canAfford = ($money >= _clothingCost * $buyMultiple and _spaceLeft >= $buyMultiple) ? "" : "disabled">>

			<<link `'Buy and send home × ' + $buyMultiple`>>
				<<if $money >= _clothingCost * $buyMultiple and _spaceLeft >= $buyMultiple>>
					<<clothingReset $clothingShopSlot>>
					<<shopbuyv2 $clothingShopSlot "buy" "send" $clothes_choice $buyMultiple>>
					<<set $money -= _clothingCost * $buyMultiple>>
					<<if $shopDefaults.disableReturn is false>>
						<<unset $clothes_choice>>
					<</if>>
					<<updateclotheslist>>
					<<updatesidebarimg>>
					<<updatesidebarmoney>>
					<<run updateMoment()>>
				<</if>>
			<</link>>
			(<<printmoney `_clothingCost * $buyMultiple`>>)

			<<numberslider "$buyMultiple" $buyMultiple 1 10 1>>

		<<run $(() => {
			$('#buy-multiple-slider input').on('input change', () => {
				let cost = getClothingCost(_temp_choice, $clothingShopSlot);
				let el = $('#buy-send-home > .buy-button > .buy-button-inner > a');
				let text = el.text().split(' ');
				text.pop();
				text.push($buyMultiple);
				el.text(text.join(' '));

				$('#buy-send-home > .buy-button > .buy-button-inner > span > span').text('£' + cost * $buyMultiple / 100);
				$('#buy-send-home > .buy-button > .buy-button-inner').toggleClass('disabled', $money < cost * $buyMultiple || _spaceLeft < $buyMultiple);
			});
		})>>

<</widget>>

<<widget "updatebuysendhome">>
	<<replace "#buy-send-home">><<printbuysendhome>><</replace>>
	<<run linkifyDivs('#buy-send-home')>>
	<<numberify '#buy-send-home'>>
<</widget>>

<<widget "printShopColourOptions">>
	<<set _colourType = $args[0] == "secondary" ? "accessory_colour_options" : "colour_options">>

	<<if $args[0] == "secondary" and !$accessorycolouraction and setup.clothes[$clothingShopSlot][$clothes_choice][_colourType].includes($shopDefaults.secColor)>>
		<<set $accessorycolouraction = $shopDefaults.secColor>>
	<<elseif !$colouraction and setup.clothes[$clothingShopSlot][$clothes_choice][_colourType].includes($shopDefaults.color)>>
		<<set $colouraction = $shopDefaults.color>>
	<</if>>
	<<set _acc = $args[0] == "secondary" ? "secondary" : "primary">>

	<<set _highContrast = $shopDefaults.highContrast ? "colour-name-span-highcontrast" : "colour-name-span">>

		<<for _buttonName range _temp_choice[_colourType]>>
			<<set _active = (_acc == "primary" ? $colouraction : $accessorycolouraction) == _buttonName ? "active" : "">>

					<<if $images is 1>>
						<<if _buttonName == "custom">>

						<</if>>
						<<if _buttonName == "random">>

						<</if>>
					<</if>>
					_buttonName
					<<capture _buttonName $args[0] _acc $clothingShopSlot>>
						<<link "">>
							<<if _buttonName == "random">>
								<<set _col_array = setup.clothes[$clothingShopSlot][$clothes_choice][_colourType]>>
								<<set _colour = _col_array[Math.floor(Math.random() * _col_array.length)]>>
							<<else>>
								<<set _colour = _buttonName>>
							<</if>>
							<<if $args[0] == "secondary">>
								<<set $accessorycolouraction = _colour>>
							<<else>>
								<<set $colouraction = _colour>>
							<</if>>
							<<if _colour == "custom">>
								<<removeclass `".custom-colour." + _acc` "hidden">>
							<<else>>
								<<addclass `".custom-colour." + _acc` "hidden">>
							<</if>>

							<<run $('.colour-options-div.' + _acc + ' > .colour-button').removeClass('active').find('.bg-' + _colour).parent().addClass('active')>>
							<<updatemannequin>>
						<</link>>
					<</capture>>

		<</for>>

		<<run $(() => { updateCustomColour('primary'); updateCustomColour('secondary'); })>>

		<<if _acc == "primary" and $colouraction is undefined>>
			<<run $(() => { $('.colour-options-div.primary > .colour-button > .bg-' + $shopDefaults.color + ' > a').click(); })>>
		<</if>>
		<<if _acc == "secondary" and $accessorycolouraction is undefined>>
			<<run $(() => { $('.colour-options-div.secondary > .colour-button > .bg-' + $shopDefaults.secColor + ' > a').click(); })>>
		<</if>>

	<<if $args[0] == "secondary">>
		<<set _hidden = $accessorycolouraction == "custom" ? "" : " hidden">>
	<<else>>
		<<set _hidden = $colouraction == "custom" ? "" : " hidden">>
	<</if>>
	<<capture _acc $clothingShopSlot>>

				<<set _varHue = "$customColors.color." + _acc>>
				<<set _varBri = "$customColors.brightness." + _acc>>
				<<set _varSat = "$customColors.saturation." + _acc>>
				<<set _varCon = "$customColors.contrast." + _acc>>

Hue<<numberslider _varHue $customColors.color[_acc] 0 360 1>>

Brightness<<numberslider _varBri $customColors.brightness[_acc] 0 4 0.01>>

Saturation<<numberslider _varSat $customColors.saturation[_acc] 0 4 0.01>>

Contrast<<numberslider _varCon $customColors.contrast[_acc] 0 4 0.01>>

					<<if _preset_choice is undefined>><<set _preset_choice = {}>><</if>>
					<<listbox "_preset_choice[_acc]" autoselect>>

						<<optionsfrom {...{'---': '---'}, ...Object.keys($customColors.presets).reduce((acc, val) => ({...acc, [($customColors.presets[val].ver >= 2 ? '' : '[L] ') + val]: val }), {})}>>
					<</listbox>>
					<<set _delDisabled = Object.keys($customColors.presets).includes(_preset_choice[_acc]) ? "" : "disabled">>

						<<if $images is 1>><<else>>Del<</if>>
						<<link "">>
							<<if _preset_choice[_acc] and $customColors.presets[_preset_choice[_acc]] and confirm('Delete preset "' + _preset_choice[_acc] + '"?')>>
								<<run delete $customColors.presets[_preset_choice[_acc]]>>
								<<updateclotheslist>>
								<<run updateMoment()>>
							<</if>>
						<</link>>

					<<if $images is 1>><<else>>Save<</if>>
					<<link "">>
						<<run saveCustomColourPreset(_acc)>>
						<<updateclotheslist>>
						<<run updateMoment()>>
					<</link>>

	<</capture>>
<</widget>>

<<widget "printcursed">>
	You can't wear this item without first removing your
	<<set _preventClothes = _preventSlots.map(x => $worn[x].name)>>
	<<if _preventClothes.length > 1>><<print _preventClothes.slice(0, -1).join(', ') + ' and '>><</if>>
	<<print _preventClothes.slice(-1)>>.

<</widget>>

<<widget "shopbuyv2">>
	<<set _slot to $args[0]>>
	<<set _action to $args[1]>>
	<<set _subaction to $args[2]>>
	<<set _choice_index to $args[3]>>
	<<set _amount to $args[4]>>
	<<set $clothes_choice_previous to $clothes_choice>>

	<<if _choice_index isnot undefined>>
		<<set $colouraction2 = $colouraction>>
		<<set $accessorycolouraction2 = $accessorycolouraction>>
	<</if>>

	<<if _action isnot "reset">>
		<<if _slot is "upper" or _slot is "lower">>
			<<ShowUnderEquip "normal">>
		<</if>>
		<<if _slot is "over_upper" or _slot is "over_lower" or _slot is "over_head">>
			<<ShowUnderEquip "over">>
		<</if>>
	<</if>>

	<<if _action is "buy" or _action is "steal">>
		You _action the <<print setup.clothes[_slot][_choice_index].name>>.

		<<if $shopName is "school" and _action is "buy">>
			<<set $schoolShopAction.push("buy")>>
		<</if>>
	<<elseif _action is "try">>
		<<tryOnWear _slot _choice_index>>
		<<if $shopName is "school">>
			<<set $schoolShopAction.push("try")>>
		<</if>>
	<<elseif _action is "return">>
		<<clothingReset _slot>>
		<<if $shopName is "school">>
			<<set $schoolShopAction.push("return")>>
		<</if>>
	<<elseif _action is "reset">>
		<<unset $colouraction>>
		<<unset $colouraction2>>
		<<unset $accessorycolouraction>>
		<<unset $accessorycolouraction2>>
		<<set $shopDefaults.colorSet to null>>
		<<set $shopDefaults.secColorSet to null>>
	<</if>>

	<<if _subaction is "wear">>
		<<generalWear _slot _choice_index $colouraction2 $accessorycolouraction2>>
		<<updateOwned _slot>>
		<<if $shopName is "school">>
			<<set $schoolShopAction.push("wear")>>
		<</if>>
	<<elseif _subaction is "send">>
		<<set _loop to _amount or 1>>
		<<for _s = 0; _s lt _loop; _s++>>
			<<generalSend $wardrobes.shopReturn _slot _choice_index $colouraction2 $accessorycolouraction2>>
		<</for>>
	<</if>>

<</widget>>

<<widget "mannequin">>
	<<if $images is 1>>
		<<set _slot = $args[0] or $clothingShopSlot>>
		<<set _index = $args[1] or $clothes_choice>>
		<<set _item = setup.clothes[_slot][_index]>>

		<<if _item.colour_options.length > 0>>
			<<set _col = $args[2] or $colouraction or (_item.colour_options.includes($shopDefaults.color) ? $shopDefaults.color : _item.colour_options[0])>>
		<<else>>
			<<set _col = "">>
		<</if>>
		<<if _item.accessory_colour_options.length > 0>>
			<<set _acc_col = $args[3] or $accessorycolouraction or (_item.accessory_colour_options.includes($shopDefaults.secColor) ? $shopDefaults.secColor : _item.accessory_colour_options[0])>>
		<<else>>
			<<set _acc_col = "">>
		<</if>>

		<<if _item>>

			<<if _mannequinGenderOverride>>
				<<set _mannequinGender to _mannequinGenderOverride>>
			<<else>>
				<<if $shopDefaults.mannequinGenderFromClothes and _item.gender != "n">>
					<<set _mannequinGender to _item.gender>>
				<<else>>
					<<if $shopDefaults.mannequinGender is "same">>
						<<set _mannequinGender to $player.gender>>
					<<elseif $shopDefaults.mannequinGender is "opposite">>
						<<set _mannequinGender to ($player.gender is "f" ? "m" : "f")>>
					<<else>>
						<<set _mannequinGender to $shopDefaults.mannequinGender.first()>>
					<</if>>
				<</if>>
			<</if>>
			<<set $mannequinHasPenis to (_mannequinGender isnot "f")>>

			<<if _item.type.includes("chest_bind")>>
				<<set _breastImg to 0>>
			<<else>>
				<<set _breastImg to ($mannequinBreastsSize is undefined ? 3 : (_mannequinGender is "m" ? 0 : $mannequinBreastsSize))>>
			<</if>>
			<<set _clothed = (((_slot != "under_upper" and $neverNudeMenus) or (_slot == "under_upper" and !_item.type.includes("naked"))) and _breastImg >= 2) ? "_clothed" : "">>

				<<if $sidebarRenderer isnot "img">>
					<<selectmodel "main" "shop">>
						<<set _modeloptions.mannequin to true>>
						<<set _modeloptions.show_face to false>>
						<<set _modeloptions.show_hair to false>>
						<<set _modeloptions.breasts to _breastImg ? (_clothed ? "cleavage" : "default") : "">>
						<<set _modeloptions.breast_size to _breastImg>>
						<<set _modeloptions.crotch_visible to true>>
						<<if $mannequinHasPenis>>
							<<set _modeloptions.penis to "default">>
						<</if>>
						<<if $neverNudeMenus>>
							<<if _slot != "under_upper" and (_mannequinGender == "f" or _mannequinGender == "h")>>
								<<set _modeloptions.worn_under_upper to 12>>
								<<set _modeloptions.worn_under_upper_colour to "pale white">>
							<</if>>
							<<if _slot != "under_lower" and (_item.set == _slot or _slot != 'under_upper')>>
								<<if $mannequinHasPenis>>
									<<set _modeloptions.worn_under_lower to 0>>
									<<set _modeloptions.worn_under_lower_colour to "pale white">>
								<</if>>
							<</if>>
						<</if>>

						<<set _items_list = [{slot: _slot, item: _item}]>>
						<<if _item.outfitPrimary>>
							<<set _items_list = _items_list.concat(Object.keys(_item.outfitPrimary).map(s => { return {slot: s, item: setup.clothes[s].find(x => x.name == _item.outfitPrimary[s])} }))>>
						<</if>>
						<<for _clothing range _items_list>>
							<<set _item = _clothing.item>>
							<<set _slot = _clothing.slot>>
							<<set _modeloptions['worn_' + _slot] to clothesIndex(_slot,_item)>>
							<<if _col>>
								<<set _modeloptions['worn_' + _slot + '_colour'] to _col>>
								<<if _col is "custom">>
									<<set _modeloptions.filters["worn_" + _slot + "_custom"] =
											getCustomClothesColourCanvasFilter($customColors.color.primary,
												$customColors.saturation.primary,
												$customColors.brightness.primary,
												$customColors.contrast.primary);>>
								<</if>>
							<</if>>
							<<if _acc_col>>
								<<set _modeloptions['worn_' + _slot + '_acc_colour'] to _acc_col>>
								<<if _acc_col is "custom">>
									<<set _modeloptions.filters["worn_" + _slot + "_acc_custom"] =
											getCustomClothesColourCanvasFilter($customColors.color.secondary,
												$customColors.saturation.secondary,
												$customColors.brightness.secondary,
												$customColors.contrast.secondary);>>
								<</if>>
							<</if>>
						<</for>>
						<<if $sidebarRenderer is "both">>
							<<set _item = _items_list[0].item>>
							<<set _slot = _items_list[0].slot>>
						<</if>>
					<<rendermodel "canvas-mannequin">>
				<</if>>

				<<if $sidebarRenderer isnot "canvas">>

					<<if $mannequinHasPenis>>

					<</if>>

					<<if $neverNudeMenus>>

							<<if _slot != "under_upper" and (_mannequinGender == "f" or _mannequinGender == "h")>>

							<</if>>
							<<if _slot != "under_lower" and (_item.set == _slot or _slot != 'under_upper')>>

									<<if $mannequinHasPenis>>

									<</if>>

							<</if>>

					<</if>>

				<</if>>

						<<if $images is 1>>
							<<set _genderIcon = (_mannequinGender == "m" ? "male" : (_mannequinGender == "f" ? "female" : "unisex"))>>

						<<else>>
							_manequinGender[0]
						<</if>>
						<<link "">><<toggleMannequinGender>><</link>>

				<<if $sidebarRenderer isnot "canvas">>

					<<unset _styleP>>
					<<unset _styleS>>

					<<set _items_list = [{slot: _slot, item: _item}]>>
					<<if _item.outfitPrimary>>
						<<set _items_list = _items_list.concat(Object.keys(_item.outfitPrimary).map(s => { return {slot: s, item: setup.clothes[s].find(x => x.name == _item.outfitPrimary[s])} }))>>
					<</if>>
					<<for _clothing range _items_list>>
						<<set _item = _clothing.item>>
						<<set _slot = _clothing.slot>>

						<<if _col is "custom">>
							<<set _styleP = getCustomColourStyle('primary')>>
						<</if>>

							<<if _item.mainImage isnot 0>>

							<</if>>

							<<if setup.clothes[_slot][clothesIndex(_slot,_item)].sleeve_img or _item.leftImage>>

							<</if>>
							<<if setup.clothes[_slot][clothesIndex(_slot,_item)].sleeve_img or _item.rightImage>>

							<</if>>

							<<if setup.clothes[_slot][clothesIndex(_slot,_item)].breast_img>>

							<</if>>

							<<if _item.penis_img and $mannequinHasPenis>>

							<</if>>

						<<if _acc_col is "custom">>
							<<set _styleS = getCustomColourStyle('secondary')>>
						<</if>>

							<<if _item.accessory and _slot != "hands">>

							<</if>>
							<<if _item.breast_acc_img>>

							<</if>>
							<<if _item.leftImage and _item.accessory>>

							<</if>>
							<<if _item.rightImage and _item.accessory>>

							<</if>>

						<<if _item.back_img is 1>>
							<<set _back_col = _item.back_img_colour is 'secondary' ? _acc_col.replace(/ /g, '-') : _col.replace(/ /g, '-')>>

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

				<</if>>

				Toggle gender
				<<link "">><<toggleMannequinGender>><</link>>

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

<<widget "toggleMannequinGender">>
	<<if _mannequinGender is "f">>
		<<set _mannequinGenderOverride to "m">>
	<<else>>
		<<if $player.gender is "h" and _mannequinGender is "m">> /* if player is herm, toggle mannequin through herm gender */
			<<set _mannequinGenderOverride to "h">>
		<<else>>
			<<set _mannequinGenderOverride to "f">>
		<</if>>
	<</if>>
	<<updatemannequin>>
<</widget>>

<<widget "updatemannequin">>
	<<replace "#mannequin">><<mannequin $args[0] $args[1]>><</replace>>
	<<run linkifyDivs('#mannequin')>>
<</widget>>

<<widget "updatesidebardescription">>
	<<replace '#sidebar-look-description'>><<sidebarlookdescription>><</replace>>
<</widget>>

<<widget "updatesidebarmoney">>
	<<if $images>>
		<<replace #stats>><<statsCaption>><</replace>>
	<<else>>
		<<replace #money-noimg>><<statsMoneyNoImg>><</replace>>
	<</if>>
<</widget>>

<<widget "loadFiltersMenu">>

				<<link "Apply and Close">>
					<<set $shopClothingFilter.active = true>>
					<<set $shopPage to 0>>
					<<addclass '#filters' 'hidden'>>
					<<updateclotheslist>>
					<<run updateMoment()>>
				<</link>>

				<<link "Reset All and Close">>
					<<shopClothingFilterReset>>
					<<updateclotheslist>>
					<<run updateMoment()>>
				<</link>>

				<<link "Select / Deselect All Traits">>
					<<run toggleAllTraitsFilter()>>
				<</link>>

				<<if typeof $shopClothingFilter.gender isnot "object">>
					<<set $shopClothingFilter.gender = { female: true, neutral: true, male: true }>>
				<</if>>

				Gender
				<<checkbox "$shopClothingFilter.gender.female" false true autocheck>> Female
				<<checkbox "$shopClothingFilter.gender.neutral" false true autocheck>> Unisex
				<<checkbox "$shopClothingFilter.gender.male" false true autocheck>> Male

				<<filterreveal>>

				<<if $shopClothingFilter.warmth is undefined>>
					<<set $shopClothingFilter.warmth = { from: 0, to: 200 }>>
				<</if>>

				Warmth

					from <<numberbox "$shopClothingFilter.warmth.from" $shopClothingFilter.warmth.from>>
					to <<numberbox "$shopClothingFilter.warmth.to" $shopClothingFilter.warmth.to>>

				Traits

					<<set _traitsInThisShop = [...new Set(Object.keys(setup.clothes).flatMap(x => setup.clothes[x]).filter(x => x.shop.includes(_shopLocation)).flatMap(x => x.type))]>>
					<<for _trait range _traitsInThisShop>>

								<<set _checked = $shopClothingFilter.traits.includes(_trait) ? 'checked="checked"' : ''>>
								<<print '<input type="checkbox" @id="_trait" @value="_trait" ' + _checked + ' onclick="window.shopClothingFilterToggleTrait(this.value)">'>>
								<<clothingtrait _trait 'display_normal'>>
								<<print _trait.replace('_', ' ')>>

					<</for>>

<</widget>>

<<widget "filterreveal">>
	<<if $shopClothingFilter.reveal.from is undefined>>
		<<set $shopClothingFilter.reveal.from = 0>>
	<</if>>
	<<if $shopClothingFilter.reveal.to is undefined>>
		<<set $shopClothingFilter.reveal.to = 9999>>
	<</if>>
	Reveal

		from <<listbox "$shopClothingFilter.reveal.from" autoselect>><<optionsfrom getFilterRevealOptions('from')>><</listbox>>
		to <<listbox "$shopClothingFilter.reveal.to" autoselect>><<optionsfrom getFilterRevealOptions('to')>><</listbox>>

	<<run $(() => { $('#filter-reveal select').on('change', (e) => { new Wikifier(null, "<<replace '#filter-reveal'>><<filterreveal>><</replace>>"); }) })>>
<</widget>>

<<widget "loadShopOptions">>

				<<link "Save and Close">>
					<<addclass '#shop-options' 'hidden'>>
					<<updateclotheslist>>
					<<run updateMoment()>>
				<</link>>

			<<set _colorOptions to ["black", "blue", "brown", "green", "pink", "purple", "red", "tangerine", "teal", "white", "yellow", "custom", "random"]>>

			Default primary colour:

			<<for _col range _colorOptions>>

					<<radiobutton "$shopDefaults.color" _col autocheck>>
					_col

				|
			<</for>>

			Default secondary colour:

			<<for _col range _colorOptions>>

					<<radiobutton "$shopDefaults.secColor" _col autocheck>>
					_col

				|
			<</for>>

				<<checkbox "$shopDefaults.disableReturn" false true autocheck>>
				Don't return to catalogue after buying an item.

				<<checkbox "$shopDefaults.alwaysBackToShopButton" false true autocheck>>
				Always show "Back to shop" button.

			<<if $shopDefaults.colourItems is undefined>>
				<<set $shopDefaults.colourItems = "random">>
			<</if>>

				Colour items in catalogue:
				<<listbox "$shopDefaults.colourItems" autoselect>>
					<<option "Disable" "disable">>
					<<option "Use random colours" "random">>
					<<option "Use default colour" "default">>
				<</listbox>>

				Amount of items on each page of catalogue:
				<<listbox "$shopItemsPerPage" autoselect>>
					<<optionsfrom [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]>>
				<</listbox>>

					<<checkbox "$shopDefaults.highContrast" false true autocheck>>
					Use high contrast text on colour buttons.

				  Example:

pink

				 vs

pink

				<<checkbox "$shopDefaults.mannequinGenderFromClothes" false true autocheck>>
				Set mannequin's gender to that of a clothing item (fallback to setting below for unisex).

				Gender of the mannequin:
				<<listbox "$shopDefaults.mannequinGender" autoselect>>
					<<option "Same as player" "same">>
					<<option "Opposite of player" "opposite">>
					<<option "Always male" "male">>
					<<option "Always female" "female">>
				<</listbox>>

				Mannequin chest size:
				<<listbox "$mannequinBreastsSize" autoselect>>
					<<optionsfrom {"Flat": 0 , "Tiny": 1, "Small": 2, "Full": 3, "Large": 4, "Huge": 5}>>
				<</listbox>>

				<<checkbox "$shopDefaults.compactMode" false true autocheck>>
				Display less information to make catalogue more compact.

				<<checkbox "$shopDefaults.noTraits" false true autocheck>>
				Hide clothing trait icons.

				<<checkbox "$shopDefaults.noHelp" false true autocheck>>
				Don't show help / legend button in catalogue.

<</widget>>

<<widget "clothingShopLegend">>

Legend

		<<if $images is 1>>

				Integrity rating. How hard it is to tear clothing into scraps.

				Reveal rating. How alluring clothing makes you.

				Warmth rating. How good clothing protects you from cold.

				Clothing shop options.

				Clothing shop filters.

		<<else>>
			I - Integrity rating. How hard it is to tear clothing into scraps.

			R - Reveal rating. How alluring clothing makes you.

			W - Warmth rating. How good clothing protects you from cold.
		<</if>>

				<<warmthscale $warmth+25>>

			Warmth indicator.

			Displays comfortable temperature range, depends on weather.

 - you will be too cold at this temperature

 - you will be a bit chilly at this temperature

 - perfect temperature

 - you will be a bit too warm at this temperature

 - you will be way too hot at this temperature

 - your warmth with your current clothes on

 - warmth you'd have would you put other clothing on instead

<</widget>>

<<widget "warmthscale">>

		<<warmthscale-internal $args[0]>>

<</widget>>

<<widget "updatewarmthscale">>
	<<temperature>>
	<<replace '.warmth-scale-container'>><<warmthscale-internal>><</replace>>
<</widget>>

<<widget "updatewarmthdescription">>
	<<replace '#warmth-description'>><<warmth_description>><</replace>>
<</widget>>

<<widget "warmthscale-internal">>
	<<if $args[0]>>
		<<set _newWarmth = $args[0]>>
	<<elseif $clothes_choice>>
		<<set _newWarmth = getWarmthWithOtherClothing($clothingShopSlot, $clothes_choice)>>
	<</if>>
	<<set _warmthData = getWarmthScaleData(_newWarmth)>>

		<<if $clothes_choice or $args[0]>>

		<</if>>

	<<if $clothes_choice or $args[0]>>

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

<<widget "sendItemsTo">>

	<<for _label, _value range $wardrobes>>
		<<if _value.unlocked and _value.shopSend>>
			<<if $wardrobes.shopReturn is _label>>

					<<print _value.name>>

			<<else>>

					<<capture _label>>
						<<link _value.name>>
							<<set $wardrobes.shopReturn to _label>>
							<<updateclotheslist>>
							<<updatesidebardescription>>
							<<updatewarmthscale>>
							<<updatewarmthdescription>>
							<<run updateMoment()>>
						<</link>>
					<</capture>>

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

<</widget>>

<<widget "sendItemsToDropdown">>
<<if $multipleWardrobes is "all">>
	Send to:
	<<set _options to {}>>
	<<for _label, _value range $wardrobes>>
		<<if _value.unlocked and !$wardrobes[_label].isolated>>
			<<set _options[_value.name] to _label>>
		<</if>>
	<</for>>
	<<listbox '$wardrobes.shopReturn' autoselect>>
		<<optionsfrom _options>>
	<</listbox>>

<<else>>
	<<set $wardrobes.shopReturn to "wardrobe">>
<</if>>
<</widget>>


code:
:: Clothing Shop

	<<clothingShop-main>>

:: Clothing Shop Widgets [widget]

<<widget "clothingShop-main">>
	<<if $tryOn.autoReset isnot false>><<tryOnReset>><</if>><<unset $tempDisable>>
	<<set $outside to 0>><<set $location to "shopping_centre">><<effects>>
	<<set $shopName = "clothing">>

	You are in the clothing shop. It has a large selection of ordinary clothes, but you'll need to go elsewhere if you're looking for something exotic.

	<<if $stress gte $stressmax>>
	<<passoutshop>>
	<<else>>
		<<if $hour is 21>>
			It's closing time. Security is herding everyone outside. <<if $exposed gte 1>>Panic swells within you as you realise how exposed you'll be should security find you in this state of dress.<</if>>

			<<if $exposed lte 0>>
				<<link [[Go outside|High Street]]>><</link>>

			<<else>>
				<<link [[Hide until it's over (1:00)|Clothing Shop]]>><<pass 1 hour>><</link>>
			<</if>>
		<<else>>

<<tryOnStats>>

			<<unset $shopListStartCount>>
			<<unset $clothes_choice>>
			<<set $shopPage = 0>>

			<<if $daystate is "night">>
				You are alone in the darkness.

			<<elseif $exposed gte 1>>
				You are hiding within a clothing stand to protect your dignity.

			<</if>>

			Warmth:
			<<warmthscale>>

				<<warmth_description>>

			<<if $debug is 1>>
				<<clothingcategoryicon "overoutfit">>
				<<link "View over outfits">><<replace "#clothingShop-div">><<OverOutfitShop>><</replace>><</link>>

			<</if>>
			<<clothingcategoryicon "outfit">>
			<<link "View outfits">><<replace "#clothingShop-div">><<OutfitShop>><</replace>><</link>>

			<<clothingcategoryicon "upper">>
			<<link "View tops">><<replace "#clothingShop-div">><<TopShop>><</replace>><</link>>

			<<clothingcategoryicon "lower">>
			<<link "View bottoms">><<replace "#clothingShop-div">><<BottomShop>><</replace>><</link>>

			<<clothingcategoryicon "underoutfit">>
			<<link "View under outfits">><<replace "#clothingShop-div">><<UnderOutfitShop>><</replace>><</link>>

			<<clothingcategoryicon "underupper">>
			<<link "View under tops">><<replace "#clothingShop-div">><<UnderTopShop>><</replace>><</link>>

			<<clothingcategoryicon "underlower">>
			<<link "View under bottoms">><<replace "#clothingShop-div">><<UnderBottomShop>><</replace>><</link>>

			<<clothingcategoryicon "head">>
			<<link "View Head Accessories">><<replace "#clothingShop-div">><<HeadShop>><</replace>><</link>>

			<<clothingcategoryicon "face">>
			<<link "View Face Accessories">><<replace "#clothingShop-div">><<FaceShop>><</replace>><</link>>

			<<clothingcategoryicon "neck">>
			<<link "View Neck Accessories">><<replace "#clothingShop-div">><<NeckShop>><</replace>><</link>>

			<<clothingcategoryicon "hand">>
			<<link "View Hand Accessories">><<replace "#clothingShop-div">><<HandsShop>><</replace>><</link>>

			<<clothingcategoryicon "legs">>
			<<link "View Legwear">><<replace "#clothingShop-div">><<LegsShop>><</replace>><</link>>

			<<clothingcategoryicon "feet">>
			<<link "View Shoes">><<replace "#clothingShop-div">><<FeetShop>><</replace>><</link>>

			<<run linkifyDivs('.button-back-to-shop')>>

			<<if $clothingrebuy is 1>>
				[[Disable automatic clothing rebuy|Rebuy Shop]]

			<<else>>
				[[Enable automatic clothing rebuy|Rebuy Shop]]

			<</if>>

			<<if $daystate is "night" and $hour isnot $closinghour and $clothingshoptheft isnot 1>>
				<<link [[Examine the cash register|Clothing Shop Register]]>><</link>>

			<</if>>

			<<if $daystate is "night" or $tryOn.value is 0>>
				<<if $daystate is "night" and $clothingShop.spotted is true and $clothingShop.stolenClothes gt 0>>
					<<link[[Leave|Clothing Shop Night Guard Found]]>>
						<<shopClothingFilterReset>>
						<<ShowUnderEquip "normal">>
						<<ShowUnderEquip "over">>
						<<set $tryOn.autoReset to true>>
						<<crimeup `$tryOn.value / 100`>>
					<</link>>
				<<else>>
					<<link[[Leave|Shopping Centre Top]]>>
						<<shopClothingFilterReset>>
						<<ShowUnderEquip "normal">>
						<<ShowUnderEquip "over">>
						<<set $tryOn.autoReset to true>>
						<<crimeup `$tryOn.value / 100`>>
					<</link>>
				<</if>>
				<<if $tryOn.value gt 0>>
					<<crime>>
				<</if>>

			<<elseif $tryOn.value gt 0>>
				<<link "Return clothes">><<clothingReset>>
					<<updatesidebarimg>>
					<<updatesidebardescription>>
					<<updateallure>>
					<<updatewarmthscale>>
					<<updatewarmthdescription>>
					<<updateclothingshop>>
					<<run updateMoment()>>
				<</link>>

				<<if $tryOn.value lt $money>>
					<<sendItemsToDropdown>>
					<<link "Buy clothes">><<buyTryOnClothes "wear">><<updateclothingshop>><</link>>

					<<link "Buy clothes and send to wardrobe">>
						<<buyTryOnClothes "wardrobe">>
						<<updatesidebarmoney>>
						<<updatesidebarimg>>
						<<updatesidebardescription>>
						<<updateallure>>
						<<updatewarmthscale>>
						<<updatewarmthdescription>>
						<<updateclothingshop>>
						<<run updateMoment()>>
					<</link>>

				<</if>>
				<<link [[Leave with stolen clothes|Stolen Clothing Shop Result]]>><<shopClothingFilterReset>><</link>>

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

<<widget "clothingcategoryicon">>
	<<if $images is 1>><</if>>
<</widget>>

:: Clothing Shop Sneak
<<set $outside to 0>><<effects>><<set $lock to 0>>

	<<if $skulduggery gte $lock>>
	The lock looks easy to pick.

	<<link [[Pick it (0:10)|Clothing Shop]]>>
		<<pass 10>><<crimeup 1>>
		<<if $clothingShop.ban gt 0 or $crime gte 50000 or $clothingShop.rng gte $skulduggery>>
			<<set $clothingShop.spotted to true>>
		<</if>>
		<<set $clothingShop.rng to random(0,1000)>>
	<</link>><<crime>>

	<<else>>
	The lock looks beyond your ability to pick.
	<<skulduggeryrequired>>

	<</if>>

<<link [[Leave|Shopping Centre Top]]>><</link>>

:: Rebuy Shop
<<set $outside to 0>><<effects>>

<<if $clothingrebuy is 1>>

Disabling clothing rebuy will deactivate the chips in all your clothing. They will no longer attempt to buy replacements when destroyed, and will not charge you anything.

Would you like to disable automatic clothing rebuy?

<<link [[Yes|Clothing Shop]]>><<set $clothingrebuy to 0>><</link>>

<<else>>

Enabling clothing rebuy will activate chips in all your clothing. When damaged beyond repair, the clothes automatically order a replacement. The cost is the price of the garment, plus an additional 50% service fee. This will not work if you don't have enough money, which will be deducted immediately.

Would you like to enable this?

<<link [[Yes|Clothing Shop]]>><<set $clothingrebuy to 1>><</link>>

<</if>>
<<link [[No|Clothing Shop]]>><</link>>

repo_name: Area/degrees

license: mit


code:
:: Clothing Shop Categories [widget]

<<widget "updateclothingshop">>
	<<run new Wikifier(null, '<<replace "#clothingShop-div">><<' + $shopName + "Shop-main>><</replace>>")>>
	<<numberify '#clothingShop-div'>>
<</widget>>

<<widget "OverOutfitShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "over_upper">>
		<<else>>
			<<shopbuyv2 "over_upper" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "over_upper" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "over_upper" "outfits">>

<</widget>>

<<widget "OutfitShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "upper">>
		<<else>>
			<<shopbuyv2 "upper" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "upper" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "upper" "outfits">>

<</widget>>

<<widget "TopShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "upper">>
		<<else>>
			<<shopbuyv2 "upper" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "upper" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "upper" "non-outfits">>

<</widget>>

<<widget "BottomShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "lower">>
		<<else>>
			<<shopbuyv2 "lower" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "lower" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "lower">>

<</widget>>

<<widget "UnderOutfitShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "under_upper">>
		<<else>>
			<<shopbuyv2 "under_upper" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "under_upper" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "under_upper" "outfits">>

<</widget>>

<<widget "UnderTopShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "under_upper">>
		<<else>>
			<<shopbuyv2 "under_upper" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "under_upper" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "under_upper" "non-outfits">>

<</widget>>

<<widget "UnderBottomShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "under_lower">>
		<<else>>
			<<shopbuyv2 "under_lower" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "under_lower" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "under_lower">>

<</widget>>

<<widget "HeadShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "head">>
		<<else>>
			<<shopbuyv2 "head" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "head" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "head">>

<</widget>>

<<widget "FaceShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "face">>
		<<else>>
			<<shopbuyv2 "face" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "face" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "face">>

<</widget>>

<<widget "NeckShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "neck">>
		<<else>>
			<<shopbuyv2 "neck" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "neck" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "neck">>

<</widget>>

<<widget "HandsShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "hands">>
		<<else>>
			<<shopbuyv2 "hands" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "hands" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "hands">>

<</widget>>

<<widget "LegsShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "legs">>
		<<else>>
			<<shopbuyv2 "legs" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "legs" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "legs">>

<</widget>>

<<widget "FeetShop">>
	<<set $outside to 0>><<effects>>

	<<if $clothes_choice and $clothes_choice_previous>>
		<<if $clothes_choice is $clothes_choice_previous>>
			<<shopbuyv2 "feet">>
		<<else>>
			<<shopbuyv2 "feet" "reset">>
		<</if>>
	<<else>>
		<<shopbuyv2 "feet" "reset">>
	<</if>>

		<<clothingShopv2 $shopName "feet">>

<</widget>>

<<widget "shopCategoryTabs">>

		<<if $dev is 1>>

				<<set _active = $args[0] == "overoutfit" ? "active" : "">>

					<<if $images is 1>>
						<<clothingcategoryicon "overoutfit">>
					<<else>>

OO

					<</if>>
					<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<OverOutfitShop>><</replace>><</link>>

		<</if>>

			<<if $shopName isnot "school">>
				<<set _active = $args[0] == "outfit" ? "active" : "">>

					<<if $images is 1>>
						<<clothingcategoryicon "outfit">>
					<<else>>

O

					<</if>>
					<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<OutfitShop>><</replace>><</link>>

			<</if>>
			<<set _active = $args[0] == "upper" ? "active" : "">>

				<<if $images is 1>>
					<<clothingcategoryicon "upper">>
				<<else>>

U

				<</if>>
				<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<TopShop>><</replace>><</link>>

			<<set _active = $args[0] == "lower" ? "active" : "">>

				<<if $images is 1>>
					<<clothingcategoryicon "lower">>
				<<else>>

L

				<</if>>
				<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<BottomShop>><</replace>><</link>>

			<<set _active = $args[0] == "underoutfit" ? "active" : "">>

				<<if $images is 1>>
					<<clothingcategoryicon "underoutfit">>
				<<else>>

UO

				<</if>>
				<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<UnderOutfitShop>><</replace>><</link>>

			<<set _active = $args[0] == "underupper" ? "active" : "">>

				<<if $images is 1>>
					<<clothingcategoryicon "underupper">>
				<<else>>

UU

				<</if>>
				<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<UnderTopShop>><</replace>><</link>>

			<<set _active = $args[0] == "underlower" ? "active" : "">>

				<<if $images is 1>>
					<<clothingcategoryicon "underlower">>
				<<else>>

UL

				<</if>>
				<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<UnderBottomShop>><</replace>><</link>>

			<<set _active = $args[0] == "head" ? "active" : "">>

				<<if $images is 1>>
					<<clothingcategoryicon "head">>
				<<else>>

He

				<</if>>
				<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<HeadShop>><</replace>><</link>>

			<<set _active = $args[0] == "face" ? "active" : "">>

				<<if $images is 1>>
					<<clothingcategoryicon "face">>
				<<else>>

Fa

				<</if>>
				<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<FaceShop>><</replace>><</link>>

			<<if $shopName isnot "school">>
				<<set _active = $args[0] == "neck" ? "active" : "">>

					<<if $images is 1>>
						<<clothingcategoryicon "neck">>
					<<else>>

Ne

					<</if>>
					<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<NeckShop>><</replace>><</link>>

			<</if>>
			<<set _active = $args[0] == "hands" ? "active" : "">>

				<<if $images is 1>>
					<<clothingcategoryicon "hand">>
				<<else>>

Ha

				<</if>>
				<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<HandsShop>><</replace>><</link>>

			<<set _active = $args[0] == "legs" ? "active" : "">>

				<<if $images is 1>>
					<<clothingcategoryicon "legs">>
				<<else>>

Le

				<</if>>
				<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<LegsShop>><</replace>><</link>>

			<<set _active = $args[0] == "feet" ? "active" : "">>

				<<if $images is 1>>
					<<clothingcategoryicon "feet">>
				<<else>>

Fe

				<</if>>
				<<link "">><<set $shopPage = 0>><<unset $clothes_choice>><<replace "#clothingShop-div">><<FeetShop>><</replace>><</link>>

	<<run linkifyDivs('#shopCategories')>>
<</widget>>


code:
:: Cosmetics Lock

<<set $outside to 0>><<effects>><<set $lock to 0>>

<<if $skulduggery gte $lock>>
	The lock looks easy to pick.

	<<link [[Pick it (0:10)|Cosmetics Store]]>><<pass 10>><<crimeup 1>><</link>><<crime>>

<<else>>
	The lock looks beyond your ability to pick.
	<<skulduggeryrequired>>

<</if>>

<<link [[Leave|Shopping Centre Top]]>><</link>>

:: Cosmetics Store
<<set $outside to 0>><<set $location to "shopping_centre">><<effects>>

You are in the cosmetics store. Several shelvings stand before you, filled with all kinds of colourful tubes, jars and boxes.

<<link [[Look at lipsticks|Cosmetics Lipstick]]>><</link>>

<<link [[Look at eye shadows|Cosmetics Eyeshadow]]>><</link>>

<<link [[Look at mascaras|Cosmetics Mascara]]>><</link>>

<<link [[Look at hair dyes|Cosmetics Dyes]]>><</link>>

<<link [[Leave|Shopping Centre Top]]>><</link>>

:: Cosmetics Lipstick
<<CosmeticsGenericDepartment "lipstick" "lipstick" "lipsticks" "lipstick" "" "#FF0000" 1000 "Cosmetics Lipstick" "A bunch of colourful lipsticks stand on a shelf." true true 20 `setup.colours.lipstick.map(c=>c.variable)`>>

:: Cosmetics Eyeshadow
<<CosmeticsGenericDepartment "eyeshadow" "eyeshadow" "eyeshadows" "eyeshadow" "" "#FF0000" 1500 "Cosmetics Eyeshadow" "Small boxes with sparkly eye shadows lay before you." true true 20 `setup.colours.eyeshadow.map(c=>c.variable)`>>

:: Cosmetics Mascara
<<CosmeticsGenericDepartment "mascara" "mascara" "mascaras" "mascara" "" "#FF0000" 1500 "Cosmetics Mascara" "There's a dozen mascaras laying before you. They're all black though." true true 20 `setup.colours.mascara.map(c=>c.variable)`>>

:: Cosmetics Dyes
<<CosmeticsGenericDepartment "hairdye" "hair dye" "hair dyes" "hair" "colour-hair" "#FD6064" 4000 "Cosmetics Dyes" "You come to the shelf with hair dyes." false true 1 `setup.colours.hair.filter(c=>c.dye).map(c=>c.variable)`>>

:: Cosmetics Store Widgets [widget]
<<widget "CosmeticsGenericDepartment">>
<<if $args.length < 13>>

Error in passage "Cosmetics Generic Department". Missing arguments.
<<print $args>>

<</if>>

<<set _itemType = $args[0]>>
<<set _itemSingular = $args[1]>>
<<set _itemPlural = $args[2]>>
<<set _cssClassOuter = $args[3]>>
<<set _cssClassInner = $args[4]>>
<<set _baseColour = $args[5]>>
<<set _price = $args[6]>>
<<set _passageCurrent = $args[7]>>
<<set _textIntro = $args[8]>>
<<set _canUseNow = $args[9]>>
<<set _isConsumable = $args[10]>>
<<set _usesPerBuy = $args[11]>>
<<set _availableColours = $args.slice(12)>>
<<if _availableColours.length === 1 && Array.isArray(_availableColours)>>
	<<set _availableColours = _availableColours[0]>>
<</if>>

_textIntro
<<if _isConsumable isnot true>>
	<<if $makeup.owned[_itemType].length > 0>>

		You already own _itemPlural of the following colours:
		<<for _i, _colour range $makeup.owned[_itemType]>>
			<<print setup.colourName(_colour)>>
			<<if _i < $makeup.owned[_itemType].length - 1>>, <</if>>
		<</for>>.
	<</if>>
<<else>>
	<<set _owned = $makeup.owned[_itemType].filter(x => x.count > 0)>>
	<<if _owned.length > 0>>

		You already own _itemPlural of the following colours:
		<<for _i, _item range _owned>>
			<<if _item.count > 0>>
				<<print setup.colourName(_item.colour)>>
				 × _item.count
				<<if _i < _owned.length - 1>>, <</if>>
			<</if>>
		<</for>>.
	<</if>>
<</if>>

<<if _isConsumable == false>>
	<<set _availableColours = _availableColours.filter(x => !$makeup.owned[_itemType].includes(x))>>
<</if>>
<<if _availableColours.length == 0>>
	You have collected all available colours of _itemPlural, there's nothing left for you to buy.

<<else>>
	Each _itemSingular costs <<printmoney _price>><<if _usesPerBuy > 1>> and has _usesPerBuy uses<</if>>.

	<<if $cosmeticsChoice is undefined>>
		<<set $cosmeticsChoice = _availableColours[0]>>
	<</if>>
	<<for _i, _colour range _availableColours>>
		<<print setup.colourName(_colour)>> <<print '<<radiobutton "$cosmeticsChoice" "'+_colour+'" ' + ($cosmeticsChoice is _colour ? "checked" : "") + '>>'>> |
	<</for>>

	<<if $money gte _price or $daystate is "night">>
		<<set _buy = $daystate == "night" ? "Steal" : "Buy">>
		<<if _isConsumable == true>>
			<<set _usesText = _usesPerBuy > 1 ? " ("+_usesPerBuy+" uses)" : "">>
			<<link [[_buy+_usesText|_passageCurrent]]>><<addConsumableCosmetics _itemType $cosmeticsChoice _usesPerBuy>><<if $daystate is "night">><<crimeup _price/100>><<else>><<set $money -= _price>><</if>><</link>><<if $daystate is "night">><<crime>><</if>>

			<<if _canUseNow == true>>
				<<link [[_buy+_usesText+" and apply"+(_usesPerBuy > 1 ? " one" : "")+" right now"|_passageCurrent]]>><<addConsumableCosmetics _itemType $cosmeticsChoice _usesPerBuy-1>><<set $makeup[_itemType] = $cosmeticsChoice>><<if $daystate is "night">><<crimeup _price/100>><<else>><<set $money -= _price>><</if>><</link>><<if $daystate is "night">><<crime>><</if>>

			<</if>>
		<<else>>
			<<link [[_buy+" and send home"|_passageCurrent]]>><<set $makeup.owned[_itemType].push($cosmeticsChoice)>><<if $daystate is "night">><<crimeup _price/100>><<else>><<set $money -= _price>><</if>><</link>><<if $daystate is "night">><<crime>><</if>>

			<<if _canUseNow == true>>
				<<link [[_buy+" and use right now"|_passageCurrent]]>><<set $makeup.owned[_itemType].push($cosmeticsChoice)>><<set $makeup[_itemType] = $cosmeticsChoice>><<if $daystate is "night">><<crimeup _price/100>><<else>><<set $money -= _price>><</if>><</link>><<if $daystate is "night">><<crime>><</if>>

			<</if>>
		<</if>>
	<<else>>
		You can't afford the purchase.

	<</if>>
<</if>>
<<link [[Go back|Cosmetics Store]]>><<unset $cosmeticsChoice>><</link>>
<</widget>>

<<widget addConsumableCosmetics>><><</widget>>


code:
:: Hairdressers Lock

<<set $outside to 0>><<effects>><<set $lock to 0>>
<<if $skulduggery gte $lock>>
	The lock looks easy to pick.

	<<link [[Pick it (0:10)|Hairdressers]]>><<pass 10>><<crimeup 1>><</link>><<crime>>

<<else>>
	The lock looks beyond your ability to pick.
	<<skulduggeryrequired>>

<</if>>
<<link [[Leave|Shopping Centre]]>><</link>>

:: Hairdressers

<<set $outside to 0>><<set $location to "shopping_centre">><<effects>>
You are in the hairdressers. Here you can have your hair cut or dyed.
<<if $daystate is "night">>
	You are alone in the darkness.
<<elseif $exposed gte 1>>
	You hide in a cupboard to protect your dignity.
<<else>>
	There's a seat available.
<</if>>

<<if $stress gte $stressmax>>
	<<passoutshop>>
<<else>>
	<<if $hour is 21>>
		It's closing time. Security is herding everyone outside.
		<<if $exposed gte 1>>
			Panic swells within you as you realise how exposed you'll be should security find you in this state of dress.
		<</if>>

		<<if $exposed lte 0>>
			<<link [[Go outside|High Street]]>><</link>>

		<<else>>
			<<link [[Hide until it's over (1:00)|Hairdressers]]>><<pass 1 hour>><</link>>
		<</if>>
	<<else>>
		<<if $daystate is "night" and $hour isnot $closinghour and $hairdresserstheft isnot 1>>
			<<link [[Examine the cash register|Hairdressers Register]]>><</link>>

		<</if>>
		<<if $exposed lte 1 and $daystate isnot "night" and $hour isnot 21>>
			[[Take a seat|Hairdressers Seat]]

		<</if>>
		[[Leave|Shopping Centre]]

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

:: Hairdressers Seat

<<generate1>><<person1>>You take a seat, and a hairdresser soon appears behind you. "What'll it be hun?" A sign by the mirror reads:

"Hair cut: £30

Hair dye: £60

Eyebrows dye: £20"

<<set $hairOption to $hairlength>>
<<set $fringeOption to $fringelength>>
<<set $dyeOption to "noChange">>
<<set $browsDyeOption to "noChange">>

	To pay: £0

	<<hairDressersOptions>>

<<hairdressersReset>>

:: Hairdressers Session

You hand over the money and <<he>> gets to work.

<<set _pass to 0>>
<<if $hairOption isnot $hairlength>>
	The hairdresser starts snipping away, locks floating to the ground all around you. After a short while, <<he>> stands back while brandishing a mirror for you to examine <<his>> handiwork.

	<<set $hairlength to clone($hairOption)>>
	<<set _pass += 15>>
	<<unset $hairOption>>
<</if>>

<<if $fringeOption isnot $fringelength>>
	<<if _pass gt 0>>
		<<He>> continues snipping away, and locks continue floating to the ground all around you. After a short while, <<he>> again stands back while brandishing a mirror for you to examine <<his>> handiwork further.
	<<else>>
		The hairdresser starts snipping away, locks floating to the ground all around you. After a short while, <<he>> stands back while brandishing a mirror for you to examine <<his>> handiwork.
	<</if>>

	<<set $fringelength to clone($fringeOption)>>
	<<set _pass += 15>>
	<<unset $fringeOption>>
<</if>>

<<if $browsDyeOption is "removeDye">>
	<<if _pass gt 0>>
		Then <<he>> asks you to tilt your head back. <<He>> applies a liquid smelling of artificial chemicals to your eyebrows. The hairdresser finishes the procedure by wiping your brows with soapy tissue and washing your face.
		<<He>> brings up a mirror for you to see your eyebrows back in its natural $naturalhaircolour colour.
	<<else>>
		<<He>> applies a liquid smelling of artificial chemicals to your eyebrows. The hairdresser finishes the procedure by wiping your brows with soapy tissue and washing your face.
		<<He>> brings up a mirror for you to see your eyebrows back in its natural $naturalhaircolour colour.
	<</if>>

	<<set $makeup.browscolour to clone($naturalhaircolour)>>
	<<set _pass += 10>>
	<<unset $browsDyeOption>>
<<elseif $browsDyeOption isnot "noChange">>
	<<set $makeup.browscolour to clone($browsDyeOption)>>
	<<if _pass gt 0>>
		Then <<he>> asks you to tilt your head back. <<He>> applies selected eyebrow tint to a small brush and then brushes your eyebrows for a few minutes.
		Soon <<he>> brings up a mirror for you to see your newly <<haircolourtext $makeup.browscolour>> eyebrows.
	<<else>>
		The hairdresser begins to apply selected eyebrow tint to a small brush and then brushes your eyebrows for a few minutes.
		Soon <<he>> brings up a mirror for you to see your newly <<haircolourtext $makeup.browscolour>> eyebrows.
	<</if>>

	<<set _pass += 10>>
	<<unset $browsDyeOption>>
<</if>>

<<if $dyeOption is "removeDye">>
	<<if _pass gt 0>>
		<<He>> finishes your requests by asking you to tilt your head back. <<He>> applies a liquid smelling of artificial chemicals to your hair, then begins rinsing it out in a small basin.
		<<He>> is soon blowing you dry and brandishing a mirror for you to see your hair back in its natural $naturalhaircolour colour.
	<<else>>
		The hairdresser asks you to tilt your head back. <<He>> applies a liquid smelling of artificial chemicals to your hair, then begins rinsing it out in a small basin.
		<<He>> is soon blowing you dry and brandishing a mirror for you to see your hair back in its natural $naturalhaircolour colour.
	<</if>>

	<<set $haircolour to clone($naturalhaircolour)>>
	<<set _pass += 15>>
	<<unset $dyeOption>>
<<elseif $dyeOption isnot "noChange">>
	<<set $haircolour to clone($dyeOption)>>
	<<if _pass gt 0>>
		<<He>> finishes your requests by carefully applying your chosen colour. It's not long before <<he>> brandishes a mirror for you to see your newly <<haircolourtext>> hair from all angles.
	<<else>>
		The hairdresser begins carefully applying your chosen colour. It's not long before <<he>> brandishes a mirror for you to see your newly <<haircolourtext>> hair from all angles.
	<</if>>

	<<set _pass += 30>>
	<<unset $dyeOption>>
<</if>>

<<calchairlengthstage>>

<<pass _pass>>

<<link [[Leave|Hairdressers]]>><<endevent>><</link>>

:: Hairdressers Widgets [widget]

<<widget "hairDressersOptions">>
<<set _currentCost to 0>>
<<if ($money gte _currentCost + 3000 or $hairOption isnot $hairlength) and $hairlength gt 100>>
	<<if $hairOption isnot $hairlength>>
		<<set _currentCost += 3000>>
	<</if>>
	Have your sides cut to your:

	<<set _hairNames to ["Ears", "Chin", "Shoulders", "Upper chest", "Middle chest", "Upper stomach", "Navel", "Thighs", "Knees", "Ankles"]>>
	<<set _start to Math.clamp(($hairlength - ($hairlength % 100) - 200)/100,0,9)>>
	<<set _hairOptions to {"Don't cut":$hairlength}>>
	<<for _i to _start; _i gte 0; _i-->>
		<<set _hairOptions[_hairNames[_i]] to (_i * 100) + 100>>
	<</for>>
	<<listbox "$hairOption" autoselect>>
		<<optionsfrom _hairOptions>>
	<</listbox>>

<<elseif $hairlength gt 100>>
	You don't have enough money to cut your hair.

<</if>>

<<if ($money gte _currentCost + 3000 or $fringeOption isnot $fringelength) and $fringelength gte 100>>
	<<if $fringeOption isnot $fringelength>>
		<<set _currentCost += 3000>>
	<</if>>
	Have your fringe cut until it's:

	<<set _fringeNames to ["Very short", "Short", "Standard", "Long"]>>
	<<set _start to Math.clamp(($fringelength - ($fringelength % 200))/200,0,3)>>
	<<set _fringeOptions to {"Don't cut":$fringelength}>>
	<<for _i to _start; _i gte 0; _i-->>
		<<set _fringeOptions[_fringeNames[_i]] to (_i * 200) + 100>>
	<</for>>
	<<listbox "$fringeOption" autoselect>>
		<<optionsfrom _fringeOptions>>
	<</listbox>>

<<elseif $fringelength gte 100>>
	You don't have enough money to cut your fringe.

<</if>>

<<set _dyeNames to ["Red","Jet black", "Black", "Blond", "Soft Blond", "Platinum blond", "Golden", "Ashy blond", "Strawberry blond", "Dark Brown", "Brown", "Soft brown", "Light brown", "Burnt Orange", "Ginger", "Blood Orange", "Blue", "Deep Blue", "Neon Blue", "Green", "Dark Lime", "Toxic Green", "Teal", "Pink", "Bright Pink", "Hot pink", "Soft pink", "Crimson", "Purple", "Medium Purple", "Bright Purple", "White", "Snow white"]>>
<<set $hairdressersHairColour to ["red","jetblack", "black", "blond", "softblond", "platinumblond", "golden", "ashyblond", "strawberryblond", "darkbrown", "brown", "softbrown", "lightbrown", "burntorange", "ginger", "bloodorange", "blue", "deepblue", "neonblue", "green", "darklime", "toxicgreen", "teal", "pink", "brightpink", "hotpink", "softpink", "crimson", "purple", "mediumpurple", "brightpurple", "white", "snowwhite"]>>

<<if $money gte _currentCost + 3000 or $dyeOption isnot "noChange">>
	<<if $dyeOption is "removeDye">>
		<<set _currentCost += 3000>>
	<<elseif $dyeOption isnot "noChange">>
		<<set _currentCost += 6000>>
	<</if>>
	Have your hair dyed<<if $haircolour isnot $naturalhaircolour>> or cleared of hair dye<</if>>:

	<<set _dyeOptions to {"Don't dye":"noChange"}>>
	<<if $haircolour isnot $naturalhaircolour>>
		<<set _dyeOptions["Remove dye"] to "removeDye">>
	<</if>>
	<<if $money gte _currentCost + 6000 or ($dyeOption isnot "noChange" and $dyeOption isnot "removeDye")>>
		<<for _i to 0; _i lt _dyeNames.length; _i++>>
			<<if $haircolour is $hairdressersHairColour[_i] or $naturalhaircolour is $hairdressersHairColour[_i]>>
				<<continue>>
			<</if>>
			<<set _dyeOptions[_dyeNames[_i]] to $hairdressersHairColour[_i]>>
		<</for>>
	<</if>>
	<<listbox "$dyeOption" autoselect>>
		<<optionsfrom _dyeOptions>>
	<</listbox>>
	<<if $dyeOption isnot "noChange"and $dyeOption isnot "removeDye">>

	<<else>>

	<</if>>
<<else>>
	You don't have enough money to dye your hair.

<</if>>

<<if $money gte _currentCost + 1000 or $browsDyeOption isnot "noChange">>
	<<if $browsDyeOption is "removeDye">>
		<<set _currentCost += 1000>>
	<<elseif $browsDyeOption isnot "noChange">>
		<<set _currentCost += 2000>>
	<</if>>
	Have your eyebrows dyed<<if $makeup.browscolour isnot $naturalhaircolour>> or cleared of hair dye<</if>>:

	<<set _browsDyeOptions to {"Don't dye":"noChange"}>>
	<<if $makeup.browscolour isnot $naturalhaircolour>>
		<<set _browsDyeOptions["Remove dye"] to "removeDye">>
	<</if>>
	<<if $money gte _currentCost + 2000 or ($browsDyeOption isnot "noChange" and $browsDyeOption isnot "removeDye")>>
		<<for _i to 0; _i lt _dyeNames.length; _i++>>
			<<if $makeup.browscolour is $hairdressersHairColour[_i] or $naturalhaircolour is $hairdressersHairColour[_i]>>
				<<continue>>
			<</if>>
			<<set _browsDyeOptions[_dyeNames[_i]] to $hairdressersHairColour[_i]>>
		<</for>>
	<</if>>
	<<listbox "$browsDyeOption" autoselect>>
		<<optionsfrom _browsDyeOptions>>
	<</listbox>>
	<<if $browsDyeOption isnot "noChange"and $browsDyeOption isnot "removeDye">>

	<<else>>

	<</if>>
<<else>>
	You don't have enough money to dye your brow.

<</if>>

<<if _sydney>>
	<<if (!_cancel or _currentCost gt 0) and $money gte _currentCost>>
		<<link [[Continue|Sydney Hairdressers Session]]>>
			<<set $money -= _currentCost>>
		<</link>>
	<<elseif $money lt _currentCost>>
		You don't have enough money to pay the hairdresser.

		<<link [[Continue|Sydney Hairdressers Session]]>><</link>>

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

		<<link [[Leave|Sydney Hairdressers Cancel]]>><<endevent>><</link>>
	<</if>>
<<else>>
	<<if _currentCost gt 0 and $money gte _currentCost>>
		<<link [[Pay hairdresser|Hairdressers Session]]>>
			<<set $money -= _currentCost>>
		<</link>>
	<<elseif $money lt _currentCost>>
		You don't have enough money to pay the hairdresser.
	<</if>>

	<<link [[Leave|Hairdressers]]>><<endevent>><</link>>
<</if>>
<</widget>>

<<widget "hairDressersOptionsSydney">>
<<set _currentCost to 0>>
Encourage Sydney to have <<his>> hair styled:

<<if ($money gte _currentCost + 3000 or $sydneyHairOption isnot $sydney.hair)>>
	<<if $sydneyHairOption isnot $sydney.hair>>
		<<set _currentCost += 3000>>
	<</if>>
	<<set _hairOptions to {"As it is":$sydney.hair}>>
	<<if $sydney.hair is "ponytail">>
		<<set _hairOptions["Loose"] to "loose">>
	<<else>>
		<<set _hairOptions["In a ponytail"] to "ponytail">>
	<</if>>
	<<cycle "$sydneyHairOption" autoselect>>
		<<optionsfrom _hairOptions>>
	<</cycle>>
	(Click to change)

	Current style: $sydney.hair

<</if>>

<<if $money gte _currentCost + 3000 or $dyeOption isnot "noChange">>
	<<if $dyeOption is "removeDye">>
		<<set _currentCost += 3000>>
	<<elseif $dyeOption isnot "noChange">>
		<<set _currentCost += 6000>>
	<</if>>
	Encourage Sydney to dye <<his>> hair<<if $NPCName[$NPCNameList.indexOf("Sydney")].hairColour isnot "strawberryblond">> or cleared of hair dye<</if>>:

	<<set _dyeOptions to {"Don't dye":"noChange"}>>
	<<if $NPCName[$NPCNameList.indexOf("Sydney")].hairColour isnot "strawberryblond">>
		<<set _dyeOptions["Remove dye"] to "removeDye">>
	<<else>>
		<<set _dyeOptions["Black"] to "black">>
	<</if>>
	<<cycle "$dyeOption" autoselect>>
		<<optionsfrom _dyeOptions>>
	<</cycle>>
	(Click to change)

	Current Colour: <<npcHairColour "Sydney">><<if _text_output is "strawberry blond">> (natural)<</if>>
<<else>>
	You don't have enough money to dye Sydney's hair.
<</if>>

<</widget>>