<commit_before>import { Action } from '../Action';
import { Monogatari } from '../monogatari';
import { $_ } from '@aegis-framework/artemis';
import Typed from 'typed.js';

export class Centered extends Action {

	static canProceed () {
		if (!Monogatari.global ('finishedTyping') && Monogatari.global ('textObject') !== null) {
			const str = Monogatari.global ('textObject').strings [0];
			const element = $_(Monogatari.global ('textObject').el).data ('ui');

			if (element == 'centered') {
				Monogatari.global ('textObject').destroy ();
				$_(`${Monogatari.selector} [data-ui="centered"]`).html (str);
				Monogatari.global ('finishedTyping', true);
			}

			return Promise.reject ();
		} else if (Monogatari.global ('finishedTyping') && $_(`${Monogatari.selector} [data-ui="centered"]`).isVisible ()) {
			$_(`${Monogatari.selector} [data-ui="centered"]`).remove ();
		}
		$_(`${Monogatari.selector} [data-ui="text"]`).show ();
		return Promise.resolve (Monogatari.global ('finishedTyping'));
	}

	static canRevert () {
		if ($_(`${Monogatari.selector} [data-ui="centered"]`).isVisible ()) {
			$_(`${Monogatari.selector} [data-ui="centered"]`).remove ();
			Monogatari.global ('finishedTyping', true);
			Monogatari.global ('textObject').destroy ();
			Monogatari.global ('_CurrentChoice', null);
			$_(`${Monogatari.selector} [data-ui="text"]`).show ();
		}
		return Promise.resolve ();
	}

	static matchString ([ action ]) {
		return action === 'centered';
	}

	static reset () {
		$_(`${Monogatari.selector} [data-ui="centered"]`).remove ();
		return Promise.resolve ();
	}

	static hide () {
		$_(`${Monogatari.selector} [data-ui="centered"]`).remove ();
		$_(`${Monogatari.selector} [data-ui="text"]`).show ();
	}

	constructor ([ action, ...dialog ]) {
		super ();
		this.dialog = dialog.join (' ');
		this.animate = Monogatari.setting ('TypeAnimation') && Monogatari.setting ('CenteredTypeAnimation');
	}

	apply () {
		$_(`${Monogatari.selector} [data-ui="text"]`).hide ();
		$_(`${Monogatari.selector} #game`).append ('<div class="middle align-center" data-ui="centered"></div>');
		if (this.animate) {
			Monogatari.global ('typedConfiguration').strings = [this.dialog];
			Monogatari.global ('textObject', new Typed (`${Monogatari.selector} [data-ui="centered"]`, Monogatari.global ('typedConfiguration')));
		} else {
			$_(`${Monogatari.selector} [data-ui="centered"]`).html (this.dialog);
		}
		return Promise.resolve ();
	}

	revert () {
		this.apply ();
		return Promise.resolve ();
	}
}

Centered.id = 'Centered';

Monogatari.registerAction (Centered);<commit_msg>Prevent showing the text box every time a canProceed is run<commit_after>import { Action } from '../Action';
import { Monogatari } from '../monogatari';
import { $_ } from '@aegis-framework/artemis';
import Typed from 'typed.js';

export class Centered extends Action {

	static canProceed () {
		if (!Monogatari.global ('finishedTyping') && Monogatari.global ('textObject') !== null) {
			const str = Monogatari.global ('textObject').strings [0];
			const element = $_(Monogatari.global ('textObject').el).data ('ui');

			if (element == 'centered') {
				Monogatari.global ('textObject').destroy ();
				$_(`${Monogatari.selector} [data-ui="centered"]`).html (str);
				Monogatari.global ('finishedTyping', true);
			}

			return Promise.reject ();
		} else if (Monogatari.global ('finishedTyping') && $_(`${Monogatari.selector} [data-ui="centered"]`).isVisible ()) {
			$_(`${Monogatari.selector} [data-ui="centered"]`).remove ();
			$_(`${Monogatari.selector} [data-ui="text"]`).show ();
		}
		return Promise.resolve (Monogatari.global ('finishedTyping'));
	}

	static canRevert () {
		if ($_(`${Monogatari.selector} [data-ui="centered"]`).isVisible ()) {
			$_(`${Monogatari.selector} [data-ui="centered"]`).remove ();
			Monogatari.global ('finishedTyping', true);
			Monogatari.global ('textObject').destroy ();
			Monogatari.global ('_CurrentChoice', null);
			$_(`${Monogatari.selector} [data-ui="text"]`).show ();
		}
		return Promise.resolve ();
	}

	static matchString ([ action ]) {
		return action === 'centered';
	}

	static reset () {
		$_(`${Monogatari.selector} [data-ui="centered"]`).remove ();
		return Promise.resolve ();
	}

	static hide () {
		$_(`${Monogatari.selector} [data-ui="centered"]`).remove ();
		$_(`${Monogatari.selector} [data-ui="text"]`).show ();
	}

	constructor ([ action, ...dialog ]) {
		super ();
		this.dialog = dialog.join (' ');
		this.animate = Monogatari.setting ('TypeAnimation') && Monogatari.setting ('CenteredTypeAnimation');
	}

	apply () {
		$_(`${Monogatari.selector} [data-ui="text"]`).hide ();
		$_(`${Monogatari.selector} #game`).append ('<div class="middle align-center" data-ui="centered"></div>');
		if (this.animate) {
			Monogatari.global ('typedConfiguration').strings = [this.dialog];
			Monogatari.global ('textObject', new Typed (`${Monogatari.selector} [data-ui="centered"]`, Monogatari.global ('typedConfiguration')));
		} else {
			$_(`${Monogatari.selector} [data-ui="centered"]`).html (this.dialog);
		}
		return Promise.resolve ();
	}

	revert () {
		this.apply ();
		return Promise.resolve ();
	}
}

Centered.id = 'Centered';

Monogatari.registerAction (Centered);
{'fraction_non_alphanumeric': 0.21304264677758653, 'fraction_numerical': 0.00038248231019315357, 'mean_word_length': 4.722100656455142, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6584863', 'n_tokens_mistral': 1969, 'n_tokens_neox': 1769, 'n_words': 307}