<commit_before>part of couclient;

class RockWindow extends Modal {
	String id = 'rockWindow';
	Element rescueButton = querySelector("#rock-rescue");
	Element questsButton = querySelector("#open-quests")..onClick.listen((_) => windowManager.rockWindow.close());
	StreamSubscription rescueClick;
	bool ready = false;

	/**
	 * Prepares a conversation for use. `convo` should not include rwc-,
	 * and userTriggered should be false if there is no UI button.
	 */
	void initConvo(String convo, {bool userTriggered: true}) {
		// Set up the menu button listener
		if (userTriggered) {
			querySelector("#go-" + convo).onClick.listen((_) {
				switchContent("rwc-" + convo);
			});
		}

		// Hide all but the first screen
		querySelectorAll("#rwc-" + convo + " > div").forEach((Element el) => el.hidden = true);
		querySelector("#rwc-" + convo + "-1").hidden = false;

		// Handle screen navigation
		querySelectorAll("#rwc-" + convo + " .rwc-button").onClick.listen((e) {
			String id = e.target.dataset["goto"];
			if (id == querySelector("#rwc-" + convo).dataset["endphrase"]) {
				// Last screen, close and return to the menu
				super.close();
				switchContent("rwc");
				querySelectorAll("#rwc-" + convo + " > div").forEach((Element el) => el.hidden = true);
				querySelector("#rwc-" + convo + "-1").hidden = false;
			} else {
				// Go to the next screen
				querySelectorAll("#rwc-" + convo + " > div").forEach((Element el) => el.hidden = true);
				querySelector("#rwc-" + convo + "-" + id).hidden = false;
				querySelector("#rwc-" + convo).scrollTop = 0;
			}
		});
	}

	/**
	 * Switches the window to the given id (should include rwc-),
	 * but does NOT open the rock window (use open(); afterward)
	 */
	void switchContent(String id) {
		if (!ready) {
			new Service(["rockwindowready"], (_) {
				querySelectorAll("#rwc-holder .rockWindowContent").forEach((Element el) => el.hidden = true);
				querySelector("#" + id).hidden = false;
			});
		} else {
			querySelectorAll("#rwc-holder .rockWindowContent").forEach((Element el) => el.hidden = true);
			querySelector("#" + id).hidden = false;
		}
	}

	/**
	 * Set up the Services that trigger conversations...
	 */
	void setConvoTriggers() {
		/// On death
		new Service(["dead"], (bool dying) {
			// Prevent the screen appearing on every Hell street
			bool deathConvoDone = false,
				reviveConvoDone = false;
			new Service(["streetLoaded"], (_) {
				if (dying && !deathConvoDone) {
					// Start death talk
					switchContent("rwc-dead");
					open();
					// Disable inventory
					_setInventoryEnabled(false);
					// Save state
					deathConvoDone = true;
				}
				if (!dying && !reviveConvoDone) {
					// Start revival talk
					switchContent("rwc-revive");
					open();
					// Enable inventory
					_setInventoryEnabled(true);
					// Save state
					reviveConvoDone = true;
				}
			});
		});

		/// When entering a broken street
		new Service(['streetLoaded'], (_) {
			if (mapData.streetData[currentStreet.label] != null &&
			    mapData.streetData[currentStreet.label]["broken"] == true) {
				switchContent("rwc-badstreet");
				open();
				rescueButton.hidden = false;
				rescueClick = rescueButton.onClick.listen((_) {
					streetService.requestStreet(/*Ilmenskie*/ "LIF102FDNU11314");
					close();
				});
			} else {
				rescueButton.hidden = true;
				if (rescueClick != null) {
					rescueClick.cancel();
				}
			}
		});
	}

	void _setInventoryEnabled(bool enabled) {
		querySelector("#inventory /deep/ #disableinventory").hidden = enabled;
		if(!enabled) {<commit_msg>rescue button goes to Hell One if in Naraka (no free revivals here)<commit_after>part of couclient;

class RockWindow extends Modal {
	String id = 'rockWindow';
	Element rescueButton = querySelector("#rock-rescue");
	Element questsButton = querySelector("#open-quests")..onClick.listen((_) => windowManager.rockWindow.close());
	StreamSubscription rescueClick;
	bool ready = false;

	/**
	 * Prepares a conversation for use. `convo` should not include rwc-,
	 * and userTriggered should be false if there is no UI button.
	 */
	void initConvo(String convo, {bool userTriggered: true}) {
		// Set up the menu button listener
		if (userTriggered) {
			querySelector("#go-" + convo).onClick.listen((_) {
				switchContent("rwc-" + convo);
			});
		}

		// Hide all but the first screen
		querySelectorAll("#rwc-" + convo + " > div").forEach((Element el) => el.hidden = true);
		querySelector("#rwc-" + convo + "-1").hidden = false;

		// Handle screen navigation
		querySelectorAll("#rwc-" + convo + " .rwc-button").onClick.listen((e) {
			String id = e.target.dataset["goto"];
			if (id == querySelector("#rwc-" + convo).dataset["endphrase"]) {
				// Last screen, close and return to the menu
				super.close();
				switchContent("rwc");
				querySelectorAll("#rwc-" + convo + " > div").forEach((Element el) => el.hidden = true);
				querySelector("#rwc-" + convo + "-1").hidden = false;
			} else {
				// Go to the next screen
				querySelectorAll("#rwc-" + convo + " > div").forEach((Element el) => el.hidden = true);
				querySelector("#rwc-" + convo + "-" + id).hidden = false;
				querySelector("#rwc-" + convo).scrollTop = 0;
			}
		});
	}

	/**
	 * Switches the window to the given id (should include rwc-),
	 * but does NOT open the rock window (use open(); afterward)
	 */
	void switchContent(String id) {
		if (!ready) {
			new Service(["rockwindowready"], (_) {
				querySelectorAll("#rwc-holder .rockWindowContent").forEach((Element el) => el.hidden = true);
				querySelector("#" + id).hidden = false;
			});
		} else {
			querySelectorAll("#rwc-holder .rockWindowContent").forEach((Element el) => el.hidden = true);
			querySelector("#" + id).hidden = false;
		}
	}

	/**
	 * Set up the Services that trigger conversations...
	 */
	void setConvoTriggers() {
		/// On death
		new Service(["dead"], (bool dying) {
			// Prevent the screen appearing on every Hell street
			bool deathConvoDone = false,
				reviveConvoDone = false;
			new Service(["streetLoaded"], (_) {
				if (dying && !deathConvoDone) {
					// Start death talk
					switchContent("rwc-dead");
					open();
					// Disable inventory
					_setInventoryEnabled(false);
					// Save state
					deathConvoDone = true;
				}
				if (!dying && !reviveConvoDone) {
					// Start revival talk
					switchContent("rwc-revive");
					open();
					// Enable inventory
					_setInventoryEnabled(true);
					// Save state
					reviveConvoDone = true;
				}
			});
		});

		/// When entering a broken street
		new Service(['streetLoaded'], (_) {
			if (mapData.streetData[currentStreet.label] != null &&
			    mapData.streetData[currentStreet.label]["broken"] == true) {
				switchContent("rwc-badstreet");
				open();
				rescueButton.hidden = false;
				rescueClick = rescueButton.onClick.listen((_) {
					if (currentStreet.hub_id == "40" /* Naraka */) {
						// Dead => Hell One
						streetService.requestStreet("LA5PPFP86NF2FOS");
					} else {
						// Not dead => Ilmenskie
						streetService.requestStreet("LIF102FDNU11314");
					}
					close();
				});
			} else {
				rescueButton.hidden = true;
				if (rescueClick != null) {
					rescueClick.cancel();
				}
			}
		});
	}

	void _setInventoryEnabled(bool enabled) {
		querySelector("#inventory /deep/ #disableinventory").hidden = enabled;
		if(!enabled) {
{'fraction_non_alphanumeric': 0.1590259828594749, 'fraction_numerical': 0.0038090055774724525, 'mean_word_length': 3.1939532230462064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1355165', 'n_tokens_mistral': 2773, 'n_tokens_neox': 2272, 'n_words': 561}