<commit_before>"use strict";

class gsuiDAW extends HTMLElement {
	#cmps = new Map()
	#currentActionInd = -1
	#actions = null
	#dispatch = GSUI.dispatchEvent.bind( null, this, "gsuiDAW" )
	#children = GSUI.getTemplate( "gsui-daw" )
	#elements = GSUI.findElements( this.#children, {
		bpm: ".gsuiDAW-tempo-bpm",
		bPM: ".gsuiDAW-tempo-beatsPerMeasure",
		sPB: ".gsuiDAW-tempo-stepsPerBeat",
		cmpName: ".gsuiDAW-currCmp-name",
		cmpSave: ".gsuiDAW-currCmp-saveBtn",
		cmpIcon: ".gsuiDAW-currCmp-localIcon",
		cmpDuration: ".gsuiDAW-currCmp-dur",
		vers: ".gsuiDAW-version-num",
		clock: "gsui-clock",
		spectrum: "gsui-spectrum",
		volume: ".gsuiDAW-volume gsui-slider",
		currentTime: ".gsuiDAW-areaTime gsui-slider",
		userAvatar: ".gsuiDAW-btn[data-action='profile']",
		cmpsLocalList: ".gsuiDAW-dropdown-list[data-list='local']",
		cmpsCloudList: ".gsuiDAW-dropdown-list[data-list='cloud']",
		historyList: ".gsuiDAW-history .gsuiDAW-dropdown-list",
		winBtns: {
			blocks: "[data-win='blocks']",
			mixer: "[data-win='mixer']",
			main: "[data-win='main']",
			synth: "[data-win='synth']",
			drums: "[data-win='drums']",
			piano: "[data-win='piano']",
			slicer: "[data-win='slicer']",
			effects: "[data-win='effects']",
		},
	} )
	#popups = {
		about: GSUI.getTemplate( "gsui-daw-popup-about" ),
		export: GSUI.getTemplate( "gsui-daw-popup-export" ),
		shortcuts: GSUI.getTemplate( "gsui-daw-popup-shortcuts" ),
		cookies: GSUI.getTemplate( "gsui-daw-popup-cookies" ),
		settings: GSUI.findElements( GSUI.getTemplate( "gsui-daw-popup-settings" ), {
			root: ".gsuiDAW-popup-settings",
			sampleRate: "[name='sampleRate']",
			uiRateRadio: {
				auto: "[name='uiRate'][value='auto']",
				manual: "[name='uiRate'][value='manual']",
			},
			uiRateManualFPS: "[name='uiRate'][value='manual'] + .gsuiDAW-uiRateFps",
			uiRateManualRange: "[name='uiRateFPS']",
			windowsLowGraphics: "[name='windowsLowGraphics']",
			timelineNumbering: "[name='timelineNumbering']",
		} ),
	}

	constructor() {
		super();
		Object.seal( this );

		this.#actions = this.#elements.historyList.getElementsByClassName( "gsuiDAW-history-action" );
		this.onclick = this.#onclick.bind( this );
		this.#popups.settings.uiRateManualRange.onmousedown = () => this.#popups.settings.uiRateRadio.manual.checked = true;
		this.#popups.settings.uiRateManualRange.oninput = e => {
			this.#popups.settings.uiRateManualFPS.textContent =
				e.target.value.padStart( 2, "0" );
		};
		this.#elements.spectrum.setResolution( 140 );
		GSUI.listenEvents( this, {
			gsuiSlider: {
				input: ( d, tar ) => this.#dispatch( tar.dataset.action, d.args[ 0 ] ),
				inputStart: GSUI.noop,
				inputEnd: GSUI.noop,
				change: GSUI.noop,
			},
		} );
	}

	// .........................................................................
	connectedCallback() {
		if ( this.#children ) {
			this.append( ...this.#children );
			this.#children = null;
			GSUI.recallAttributes( this, {
				saved: true,
				uirate: "auto",
				windowslowgraphics: false,
				timelinenumbering: 0,
				samplerate: 24000,
				bpm: 60,
				name: "",
				duration: 10,
				location: "local",
				timedivision: "1/1",
				currenttime: 0,
				maxtime: 1,
				volume: 1,
				version: "0.0.0",
			} );
		}
	}
	disconnectedCallback() {
	}
	static get observedAttributes() {
		return [
			"bpm",
			"currentcomposition",
			"currenttime",
			"duration",
			"location",
			"maxtime",
			"name",
			"samplerate",
			"timedivision",
			"timelinenumbering",
			"uirate",
			"useravatar",
			"version",
			"volume",
			"windowslowgraphics",
		];
	}
	attributeChangedCallback( prop, prev, val ) {
		if ( !this.#children && prev !== val ) {
			switch ( prop ) {
				case "currentcomposition":
					this.#loadComposition( val );
					break;
				case "name":
					this.#elements.cmpName.textContent = val;
					break;
				case "duration":
					this.#updateDuration();
					break;
				case "samplerate":
					this.#popups.settings.sampleRate.value = val;
					break;
				case "uirate":
					this.#popups.settings.uiRateRadio[ val === "auto" ? val : "manual" ].checked = true;
					if ( val !== "auto" ) {
						this.#popups.settings.uiRateManualFPS.textContent = val;
						this.#popups.settings.uiRateManualRange.value = val;
					}
					break;
				case "windowslowgraphics":
					this.#popups.settings.windowsLowGraphics.checked = val !== null;
					break;
				case "timelinenumbering":
					gsuiClock.numbering( val );<commit_msg>gsuiDAW: attr playing<commit_after>"use strict";

class gsuiDAW extends HTMLElement {
	#cmps = new Map()
	#currentActionInd = -1
	#actions = null
	#dispatch = GSUI.dispatchEvent.bind( null, this, "gsuiDAW" )
	#children = GSUI.getTemplate( "gsui-daw" )
	#elements = GSUI.findElements( this.#children, {
		bpm: ".gsuiDAW-tempo-bpm",
		bPM: ".gsuiDAW-tempo-beatsPerMeasure",
		sPB: ".gsuiDAW-tempo-stepsPerBeat",
		cmpName: ".gsuiDAW-currCmp-name",
		cmpSave: ".gsuiDAW-currCmp-saveBtn",
		cmpIcon: ".gsuiDAW-currCmp-localIcon",
		cmpDuration: ".gsuiDAW-currCmp-dur",
		play: "[data-action='play']",
		vers: ".gsuiDAW-version-num",
		clock: "gsui-clock",
		spectrum: "gsui-spectrum",
		volume: ".gsuiDAW-volume gsui-slider",
		currentTime: ".gsuiDAW-areaTime gsui-slider",
		userAvatar: ".gsuiDAW-btn[data-action='profile']",
		cmpsLocalList: ".gsuiDAW-dropdown-list[data-list='local']",
		cmpsCloudList: ".gsuiDAW-dropdown-list[data-list='cloud']",
		historyList: ".gsuiDAW-history .gsuiDAW-dropdown-list",
		winBtns: {
			blocks: "[data-win='blocks']",
			mixer: "[data-win='mixer']",
			main: "[data-win='main']",
			synth: "[data-win='synth']",
			drums: "[data-win='drums']",
			piano: "[data-win='piano']",
			slicer: "[data-win='slicer']",
			effects: "[data-win='effects']",
		},
	} )
	#popups = {
		about: GSUI.getTemplate( "gsui-daw-popup-about" ),
		export: GSUI.getTemplate( "gsui-daw-popup-export" ),
		shortcuts: GSUI.getTemplate( "gsui-daw-popup-shortcuts" ),
		cookies: GSUI.getTemplate( "gsui-daw-popup-cookies" ),
		settings: GSUI.findElements( GSUI.getTemplate( "gsui-daw-popup-settings" ), {
			root: ".gsuiDAW-popup-settings",
			sampleRate: "[name='sampleRate']",
			uiRateRadio: {
				auto: "[name='uiRate'][value='auto']",
				manual: "[name='uiRate'][value='manual']",
			},
			uiRateManualFPS: "[name='uiRate'][value='manual'] + .gsuiDAW-uiRateFps",
			uiRateManualRange: "[name='uiRateFPS']",
			windowsLowGraphics: "[name='windowsLowGraphics']",
			timelineNumbering: "[name='timelineNumbering']",
		} ),
	}

	constructor() {
		super();
		Object.seal( this );

		this.#actions = this.#elements.historyList.getElementsByClassName( "gsuiDAW-history-action" );
		this.onclick = this.#onclick.bind( this );
		this.#popups.settings.uiRateManualRange.onmousedown = () => this.#popups.settings.uiRateRadio.manual.checked = true;
		this.#popups.settings.uiRateManualRange.oninput = e => {
			this.#popups.settings.uiRateManualFPS.textContent =
				e.target.value.padStart( 2, "0" );
		};
		this.#elements.spectrum.setResolution( 140 );
		GSUI.listenEvents( this, {
			gsuiSlider: {
				input: ( d, tar ) => this.#dispatch( tar.dataset.action, d.args[ 0 ] ),
				inputStart: GSUI.noop,
				inputEnd: GSUI.noop,
				change: GSUI.noop,
			},
		} );
	}

	// .........................................................................
	connectedCallback() {
		if ( this.#children ) {
			this.append( ...this.#children );
			this.#children = null;
			GSUI.recallAttributes( this, {
				saved: true,
				uirate: "auto",
				windowslowgraphics: false,
				timelinenumbering: 0,
				samplerate: 24000,
				bpm: 60,
				name: "",
				duration: 10,
				location: "local",
				timedivision: "1/1",
				currenttime: 0,
				maxtime: 1,
				volume: 1,
				version: "0.0.0",
			} );
		}
	}
	disconnectedCallback() {
	}
	static get observedAttributes() {
		return [
			"bpm",
			"currentcomposition",
			"currenttime",
			"duration",
			"location",
			"maxtime",
			"name",
			"playing",
			"samplerate",
			"timedivision",
			"timelinenumbering",
			"uirate",
			"useravatar",
			"version",
			"volume",
			"windowslowgraphics",
		];
	}
	attributeChangedCallback( prop, prev, val ) {
		if ( !this.#children && prev !== val ) {
			switch ( prop ) {
				case "currentcomposition":
					this.#loadComposition( val );
					break;
				case "name":
					this.#elements.cmpName.textContent = val;
					break;
				case "playing":
					this.#elements.play.dataset.icon = val !== null ? "pause" : "play";
					break;
				case "duration":
					this.#updateDuration();
					break;
				case "samplerate":
					this.#popups.settings.sampleRate.value = val;
					break;
				case "uirate":
					this.#popups.settings.uiRateRadio[ val === "auto" ? val : "manual" ].checked = true;
					if ( val !== "auto" ) {
						this.#popups.settings.uiRateManualFPS.textContent = val;
						this.#popups.settings.uiRateManualRange.value = val;
					}
					break;
				case "windowslowgraphics":
					this.#popups.settings.windowsLowGraphics.checked = val !== null;
					break;
				case "timelinenumbering":
					gsuiClock.numbering( val );
{'fraction_non_alphanumeric': 0.19233741857127085, 'fraction_numerical': 0.005520591807441758, 'mean_word_length': 3.3422818791946307, 'pattern_counts': {'":': 15, '<': 3, '<?xml version=': 0, '>': 9, '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': '1258756', 'n_tokens_mistral': 4010, 'n_tokens_neox': 3440, 'n_words': 533}