<commit_before>"use strict";

class gsuiSynthesizer extends HTMLElement {
	#env = null
	#lfo = null
	#waveList = []
	#uiOscs = new Map()
	#children = GSUI.getTemplate( "gsui-synthesizer" )
	#elOscList = this.#children[ 3 ]

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

		this.#children[ 3 ].firstChild.onclick = this.#onclickNewOsc.bind( this );
		new gsuiReorder( {
			rootElement: this.#elOscList,
			direction: "column",
			dataTransferType: "oscillator",
			itemSelector: ".gsuiOscillator",
			handleSelector: ".gsuiOscillator-grip",
			parentSelector: ".gsuiSynthesizer-oscList",
			onchange: this.#onchangeReorder.bind( this ),
		} );
	}

	// .........................................................................
	connectedCallback() {
		if ( !this.firstChild ) {
			this.classList.add( "gsuiSynthesizer" );
			this.append( ...this.#children );
			this.querySelector( ".gsuiSynthesizer-env" ).append( this.#env );
			this.querySelector( ".gsuiSynthesizer-lfo" ).append( this.#lfo );
			this.#children = null;
		}
	}

	// .........................................................................
	setEnvelope( env ) {
		this.#env = env;
	}
	setLFO( lfo ) {
		this.#lfo = lfo;
	}
	setWaveList( arr ) {
		this.#waveList = arr;
		this.#uiOscs.forEach( o => o.addWaves( arr ) );
	}
	getOscillator( id ) {
		return this.#uiOscs.get( id );
	}

	// .........................................................................
	addOscillator( id, osc ) {
		const uiOsc = document.createElement( "gsui-oscillator" );

		this.#uiOscs.set( id, uiOsc );
		uiOsc.addWaves( this.#waveList );
		uiOsc.dataset.id = id;
		this.#elOscList.append( uiOsc );
	}
	removeOscillator( id ) {
		const osc = this.#uiOscs.get( id );

		if ( osc ) {
			osc.remove();
			this.#uiOscs.delete( id );
		}
	}
	reorderOscillators( obj ) {
		gsuiReorder.listReorder( this.#elOscList, obj );
	}

	// events:
	// .........................................................................
	#onclickNewOsc() {
		GSUI.dispatchEvent( this, "gsuiSynthesizer", "addOscillator" );
	}
	#onchangeReorder() {
		const oscs = gsuiReorder.listComputeOrderChange( this.#elOscList, {} );

		GSUI.dispatchEvent( this, "gsuiSynthesizer", "reorderOscillator", oscs );
	}
}

customElements.define( "gsui-synthesizer", gsuiSynthesizer );<commit_msg>gsuiSynthesizer: use of findElements<commit_after>"use strict";

class gsuiSynthesizer extends HTMLElement {
	#env = null
	#lfo = null
	#waveList = []
	#uiOscs = new Map()
	#children = GSUI.getTemplate( "gsui-synthesizer" )
	#elements = GSUI.findElements( this.#children, {
		oscList: ".gsuiSynthesizer-oscList",
		newOsc: ".gsuiSynthesizer-newOsc",
	} )

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

		this.#elements.newOsc.onclick = this.#onclickNewOsc.bind( this );
		new gsuiReorder( {
			rootElement: this.#elements.oscList,
			direction: "column",
			dataTransferType: "oscillator",
			itemSelector: ".gsuiOscillator",
			handleSelector: ".gsuiOscillator-grip",
			parentSelector: ".gsuiSynthesizer-oscList",
			onchange: this.#onchangeReorder.bind( this ),
		} );
	}

	// .........................................................................
	connectedCallback() {
		if ( !this.firstChild ) {
			this.classList.add( "gsuiSynthesizer" );
			this.append( ...this.#children );
			this.querySelector( ".gsuiSynthesizer-env" ).append( this.#env );
			this.querySelector( ".gsuiSynthesizer-lfo" ).append( this.#lfo );
			this.#children = null;
		}
	}

	// .........................................................................
	setEnvelope( env ) {
		this.#env = env;
	}
	setLFO( lfo ) {
		this.#lfo = lfo;
	}
	setWaveList( arr ) {
		this.#waveList = arr;
		this.#uiOscs.forEach( o => o.addWaves( arr ) );
	}
	getOscillator( id ) {
		return this.#uiOscs.get( id );
	}

	// .........................................................................
	addOscillator( id, osc ) {
		const uiOsc = document.createElement( "gsui-oscillator" );

		this.#uiOscs.set( id, uiOsc );
		uiOsc.addWaves( this.#waveList );
		uiOsc.dataset.id = id;
		this.#elements.oscList.append( uiOsc );
	}
	removeOscillator( id ) {
		const osc = this.#uiOscs.get( id );

		if ( osc ) {
			osc.remove();
			this.#uiOscs.delete( id );
		}
	}
	reorderOscillators( obj ) {
		gsuiReorder.listReorder( this.#elements.oscList, obj );
	}

	// events:
	// .........................................................................
	#onclickNewOsc() {
		GSUI.dispatchEvent( this, "gsuiSynthesizer", "addOscillator" );
	}
	#onchangeReorder() {
		const oscs = gsuiReorder.listComputeOrderChange( this.#elements.oscList, {} );

		GSUI.dispatchEvent( this, "gsuiSynthesizer", "reorderOscillator", oscs );
	}
}

customElements.define( "gsui-synthesizer", gsuiSynthesizer );
{'fraction_non_alphanumeric': 0.26701791359325605, 'fraction_numerical': 0.00042149631190727084, 'mean_word_length': 2.2067567567567568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1345909', 'n_tokens_mistral': 1842, 'n_tokens_neox': 1740, 'n_words': 275}