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;gBAC1D,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;gBAC/E,OAAO,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;aACpC;QACH,CAAC;QAED,8DAA8D;QACpD,yBAAS,GAAnB,UAAoB,CAAM;YACxB,IAAI,IAAI,CAAC,eAAe,EAAE;gBACxB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;aACzB;QACH,CAAC;QACH,YAAC;IAAD,CAAC,AApdD,IAodC;IApdY,sBAAK","sourcesContent":["import { getWindow } from './dom/getWindow';\n\ndeclare function setTimeout(cb: Function, delay: number): number;\ndeclare function setInterval(cb: Function, delay: number): number;\n\n/**\n * Bugs often appear in async code when stuff gets disposed, but async operations don't get canceled.\n * This Async helper class solves these issues by tying async code to the lifetime of a disposable object.\n *\n * Usage: Anything class extending from BaseModel can access this helper via this.async. Otherwise create a\n * new instance of the class and remember to call dispose() during your code's dispose handler.\n *\n * @public\n */\nexport class Async {\n private _timeoutIds: { [id: number]: boolean } | null = null;\n private _immediateIds: { [id: number]: boolean } | null = null;\n private _intervalIds: { [id: number]: boolean } | null = null;\n private _animationFrameIds: { [id: number]: boolean } | null = null;\n private _isDisposed: boolean;\n private _parent: object | null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _onErrorHandler: ((e: any) => void) | undefined;\n private _noop: () => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(parent?: object, onError?: (e: any) => void) {\n this._isDisposed = false;\n this._parent = parent || null;\n this._onErrorHandler = onError;\n this._noop = () => {\n /* do nothing */\n };\n }\n\n /**\n * Dispose function, clears all async operations.\n */\n public dispose(): void {\n let id;\n\n this._isDisposed = true;\n this._parent = null;\n\n // Clear timeouts.\n if (this._timeoutIds) {\n for (id in this._timeoutIds) {\n if (this._timeoutIds.hasOwnProperty(id)) {\n this.clearTimeout(parseInt(id, 10));\n }\n }\n\n this._timeoutIds = null;\n }\n\n // Clear immediates.\n if (this._immediateIds) {\n for (id in this._immediateIds) {\n if (this._immediateIds.hasOwnProperty(id)) {\n this.clearImmediate(parseInt(id, 10));\n }\n }\n\n this._immediateIds = null;\n }\n\n // Clear intervals.\n if (this._intervalIds) {\n for (id in this._intervalIds) {\n if (this._intervalIds.hasOwnProperty(id)) {\n this.clearInterval(parseInt(id, 10));\n }\n }\n this._intervalIds = null;\n }\n\n // Clear animation frames.\n if (this._animationFrameIds) {\n for (id in this._animationFrameIds) {\n if (this._animationFrameIds.hasOwnProperty(id)) {\n this.cancelAnimationFrame(parseInt(id, 10));\n }\n }\n\n this._animationFrameIds = null;\n }\n }\n\n /**\n * SetTimeout override, which will auto cancel the timeout during dispose.\n * @param callback - Callback to execute.\n * @param duration - Duration in milliseconds.\n * @returns The setTimeout id.\n */\n public setTimeout(callback: () => void, duration: number): number {\n let timeoutId = 0;\n\n if (!this._isDisposed) {\n if (!this._timeoutIds) {\n this._timeoutIds = {};\n }\n\n timeoutId = setTimeout(() => {\n // Time to execute the timeout, enqueue it as a foreground task to be executed.\n\n try {\n // Now delete the record and call the callback.\n if (this._timeoutIds) {\n delete this._timeoutIds[timeoutId];\n }\n callback.apply(this._parent);\n } catch (e) {\n if (this._onErrorHandler) {\n this._onErrorHandler(e);\n }\n }\n }, duration);\n\n this._timeoutIds[timeoutId] = true;\n }\n\n return timeoutId;\n }\n\n /**\n * Clears the timeout.\n * @param id - Id to cancel.\n */\n public clearTimeout(id: number): void {\n if (this._timeoutIds && this._timeoutIds[id]) {\n clearTimeout(id);\n delete this._timeoutIds[id];\n }\n }\n\n /**\n * SetImmediate override, which will auto cancel the immediate during dispose.\n * @param callback - Callback to execute.\n * @param targetElement - Optional target element to use for identifying the correct window.\n * @returns The setTimeout id.\n */\n public setImmediate(callback: () => void, targetElement?: Element | null): number {\n let immediateId = 0;\n const win = getWindow(targetElement)!;\n\n if (!this._isDisposed) {\n if (!this._immediateIds) {\n this._immediateIds = {};\n }\n\n let setImmediateCallback = () => {\n // Time to execute the timeout, enqueue it as a foreground task to be executed.\n\n try {\n // Now delete the record and call the callback.\n if (this._immediateIds) {\n delete this._immediateIds[immediateId];\n }\n callback.apply(this._parent);\n } catch (e) {\n this._logError(e);\n }\n };\n\n immediateId = win.setTimeout(setImmediateCallback, 0);\n\n this._immediateIds[immediateId] = true;\n }\n\n return immediateId;\n }\n\n /**\n * Clears the immediate.\n * @param id - Id to cancel.\n * @param targetElement - Optional target element to use for identifying the correct window.\n */\n public clearImmediate(id: number, targetElement?: Element | null): void {\n const win = getWindow(targetElement)!;\n\n if (this._immediateIds && this._immediateIds[id]) {\n win.clearTimeout(id);\n delete this._immediateIds[id];\n }\n }\n\n /**\n * SetInterval override, which will auto cancel the timeout during dispose.\n * @param callback - Callback to execute.\n * @param duration - Duration in milliseconds.\n * @returns The setTimeout id.\n */\n public setInterval(callback: () => void, duration: number): number {\n let intervalId = 0;\n\n if (!this._isDisposed) {\n if (!this._intervalIds) {\n this._intervalIds = {};\n }\n\n intervalId = setInterval(() => {\n // Time to execute the interval callback, enqueue it as a foreground task to be executed.\n try {\n callback.apply(this._parent);\n } catch (e) {\n this._logError(e);\n }\n }, duration);\n\n this._intervalIds[intervalId] = true;\n }\n\n return intervalId;\n }\n\n /**\n * Clears the interval.\n * @param id - Id to cancel.\n */\n public clearInterval(id: number): void {\n if (this._intervalIds && this._intervalIds[id]) {\n clearInterval(id);\n delete this._intervalIds[id];\n }\n }\n\n /**\n * Creates a function that, when executed, will only call the func function at most once per\n * every wait milliseconds. Provide an options object to indicate that func should be invoked\n * on the leading and/or trailing edge of the wait timeout. Subsequent calls to the throttled\n * function will return the result of the last func call.\n *\n * Note: If leading and trailing options are true func will be called on the trailing edge of\n * the timeout only if the throttled function is invoked more than once during the wait timeout.\n *\n * @param func - The function to throttle.\n * @param wait - The number of milliseconds to throttle executions to. Defaults to 0.\n * @param options - The options object.\n * @returns The new throttled function.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public throttle<T extends (...args: any[]) => any>(\n func: T,\n wait?: number,\n options?: {\n leading?: boolean;\n trailing?: boolean;\n },\n ): T {\n if (this._isDisposed) {\n return this._noop as T;\n }\n\n let waitMS = wait || 0;\n let leading = true;\n let trailing = true;\n let lastExecuteTime = 0;\n let lastResult: T;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let lastArgs: any[];\n let timeoutId: number | null = null;\n\n if (options && typeof options.leading === 'boolean') {\n leading = options.leading;\n }\n\n if (options && typeof options.trailing === 'boolean') {\n trailing = options.trailing;\n }\n\n let callback = (userCall?: boolean) => {\n let now = Date.now();\n let delta = now - lastExecuteTime;\n let waitLength = leading ? waitMS - delta : waitMS;\n if (delta >= waitMS && (!userCall || leading)) {\n lastExecuteTime = now;\n if (timeoutId) {\n this.clearTimeout(timeoutId);\n timeoutId = null;\n }\n lastResult = func.apply(this._parent, lastArgs);\n } else if (timeoutId === null && trailing) {\n timeoutId = this.setTimeout(callback, waitLength);\n }\n\n return lastResult;\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let resultFunction = ((...args: any[]): any => {\n lastArgs = args;\n return callback(true);\n }) as T;\n\n return resultFunction;\n }\n\n /**\n * Creates a function that will delay the execution of func until after wait milliseconds have\n * elapsed since the last time it was invoked. Provide an options object to indicate that func\n * should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls\n * to the debounced function will return the result of the last func call.\n *\n * Note: If leading and trailing options are true func will be called on the trailing edge of\n * the timeout only if the debounced function is invoked more than once during the wait\n * timeout.\n *\n * @param func - The function to debounce.\n * @param wait - The number of milliseconds to delay.\n * @param options - The options object.\n * @returns The new debounced function.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public debounce<T extends (...args: any[]) => any>(\n func: T,\n wait?: number,\n options?: {\n leading?: boolean;\n maxWait?: number;\n trailing?: boolean;\n },\n ): ICancelable<T> & T {\n if (this._isDisposed) {\n let noOpFunction = (() => {\n /** Do nothing */\n }) as ICancelable<T> & T;\n\n noOpFunction.cancel = () => {\n return;\n };\n noOpFunction.flush = ((() => null) as unknown) as () => ReturnType<T>;\n noOpFunction.pending = () => false;\n\n return noOpFunction;\n }\n\n let waitMS = wait || 0;\n let leading = false;\n let trailing = true;\n let maxWait: number | null = null;\n let lastCallTime = 0;\n let lastExecuteTime = Date.now();\n let lastResult: ReturnType<T>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let lastArgs: any[];\n let timeoutId: number | null = null;\n\n if (options && typeof options.leading === 'boolean') {\n leading = options.leading;\n }\n\n if (options && typeof options.trailing === 'boolean') {\n trailing = options.trailing;\n }\n\n if (options && typeof options.maxWait === 'number' && !isNaN(options.maxWait)) {\n maxWait = options.maxWait;\n }\n\n let markExecuted = (time: number) => {\n if (timeoutId) {\n this.clearTimeout(timeoutId);\n timeoutId = null;\n }\n lastExecuteTime = time;\n };\n\n let invokeFunction = (time: number) => {\n markExecuted(time);\n lastResult = func.apply(this._parent, lastArgs);\n };\n\n let callback = (userCall?: boolean) => {\n let now = Date.now();\n let executeImmediately = false;\n if (userCall) {\n if (leading && now - lastCallTime >= waitMS) {\n executeImmediately = true;\n }\n lastCallTime = now;\n }\n let delta = now - lastCallTime;\n let waitLength = waitMS - delta;\n let maxWaitDelta = now - lastExecuteTime;\n let maxWaitExpired = false;\n\n if (maxWait !== null) {\n // maxWait only matters when there is a pending callback\n if (maxWaitDelta >= maxWait && timeoutId) {\n maxWaitExpired = true;\n } else {\n waitLength = Math.min(waitLength, maxWait - maxWaitDelta);\n }\n }\n\n if (delta >= waitMS || maxWaitExpired || executeImmediately) {\n invokeFunction(now);\n } else if ((timeoutId === null || !userCall) && trailing) {\n timeoutId = this.setTimeout(callback, waitLength);\n }\n\n return lastResult;\n };\n\n let pending = (): boolean => {\n return !!timeoutId;\n };\n\n let cancel = (): void => {\n if (pending()) {\n // Mark the debounced function as having executed\n markExecuted(Date.now());\n }\n };\n\n let flush = () => {\n if (pending()) {\n invokeFunction(Date.now());\n }\n\n return lastResult;\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let resultFunction = ((...args: any[]) => {\n lastArgs = args;\n return callback(true);\n }) as ICancelable<T> & T;\n\n resultFunction.cancel = cancel;\n resultFunction.flush = flush;\n resultFunction.pending = pending;\n\n return resultFunction;\n }\n\n public requestAnimationFrame(callback: () => void, targetElement?: Element | null): number {\n let animationFrameId = 0;\n const win = getWindow(targetElement)!;\n\n if (!this._isDisposed) {\n if (!this._animationFrameIds) {\n this._animationFrameIds = {};\n }\n\n let animationFrameCallback = () => {\n try {\n // Now delete the record and call the callback.\n if (this._animationFrameIds) {\n delete this._animationFrameIds[animationFrameId];\n }\n\n callback.apply(this._parent);\n } catch (e) {\n this._logError(e);\n }\n };\n\n animationFrameId = win.requestAnimationFrame\n ? win.requestAnimationFrame(animationFrameCallback)\n : win.setTimeout(animationFrameCallback, 0);\n\n this._animationFrameIds[animationFrameId] = true;\n }\n\n return animationFrameId;\n }\n\n public cancelAnimationFrame(id: number, targetElement?: Element | null): void {\n const win = getWindow(targetElement)!;\n\n if (this._animationFrameIds && this._animationFrameIds[id]) {\n win.cancelAnimationFrame ? win.cancelAnimationFrame(id) : win.clearTimeout(id);\n delete this._animationFrameIds[id];\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected _logError(e: any): void {\n if (this._onErrorHandler) {\n this._onErrorHandler(e);\n }\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ICancelable<T extends (...args: any[]) => any> = {\n flush: () => ReturnType<T>;\n cancel: () => void;\n pending: () => boolean;\n};\n"]}
\No newline at end of file