* @typedef WaitForElementOptions Options that modify wait for element functions behavior.
* @prop {string} [id] Select element by id.
* @prop {string | string[]} selector Selector that matches target element. If `selector` is `string[]`, then `multiple` option is forced enabled.
* @prop {ParentNode} [parent] Parent element to start query select from. By default, it will query select from `document`.
* @prop {AbortSignal} [abortSignal] Abort signal to abort element querying.
* @prop {boolean} [multiple] Query multiple elements instead of a single one.
* @prop {number} [timeout] Set timeout for element querying. Reaching timeout will throw `WaitForElementTimeoutError`. If `undefined`, then timeout will be disabled.
* @prop {number} [maxTries] Set how many attempts function can do element querying. Reaching max tries will throw `WaitForElementMaxTriesError`.
* @prop {boolean} [ensureDomContentLoaded] Wait for `DOMContentLoad` event before execution, or if event already fired, it will be immediately executed.
* @prop {MutationObserverInit} [observerOptions] Set options for `MutationObserver` used in wait for element functions.
* @prop {boolean} [throwError] Throw error in certain situation except for not finding an element, instead of returning `null`. By default, its set to `true`.
*/
/**
* @typedef {Promise<Element[] | Element | null>} WaitForElementReturnValue
* Query element asyncronously until the element is available on the page. This function immediately accepts `parent` as its first parameter. `parent` parameter will specify element to start query select from.
* Query element asyncronously until the element is available on the page. This function immediately accepts `WaitForElementOptions` as its first parameter.
* @param {WaitForElementOptions} options
* @returns {WaitForElementReturnValue}
*/
function waitForElementOptions(
{ id,
selector,
parent = document.documentElement,
abortSignal,// abort controller signal
multiple =false,
timeout =5000,
maxTries =Infinity,
ensureDomContentLoaded =true,
observerOptions ={},
filter,
transform,
throwError }={}){
/**
* function that apply filter and transform for multiple elements
* filter will always be applied first before transforming element