import {wait} from "gs-base";

export async function setInput(input: HTMLInputElement, value: string) {
	if (!input) {
		return;
	}
	input.dispatchEvent(new Event('focus', {bubbles: true, cancelable: true}));
	await wait(50);
	input.value = value;
	await wait(50);
	input.dispatchEvent(new Event("input", {bubbles: true, cancelable: true}));
	input.dispatchEvent(new Event("change", {bubbles: true, cancelable: true}))
	await wait(50);
	input.dispatchEvent(new Event('blur', {bubbles: true, cancelable: true}));
}