{"version":3,"file":"overlayscrollbars.esm.js","sources":["../src/support/cache.ts","../src/support/compatibility/isBrowser.ts","../src/support/utils/alias.ts","../src/support/compatibility/apis.ts","../src/support/utils/types.ts","../src/support/utils/animation.ts","../src/support/utils/array.ts","../src/support/utils/strings.ts","../src/support/utils/equal.ts","../src/support/utils/noop.ts","../src/support/utils/function.ts","../src/support/utils/object.ts","../src/support/utils/math.ts","../src/support/dom/attribute.ts","../src/support/dom/class.ts","../src/support/dom/traversal.ts","../src/support/dom/manipulation.ts","../src/support/dom/create.ts","../src/support/dom/style.ts","../src/support/dom/dimensions.ts","../src/support/dom/events.ts","../src/support/dom/offset.ts","../src/support/dom/scroll.ts","../src/support/eventListeners.ts","../src/options.ts","../src/classnames.ts","../src/plugins/plugins.ts","../src/plugins/optionsValidationPlugin/optionsValidationPlugin.ts","../src/plugins/sizeObserverPlugin/sizeObserverPlugin.ts","../src/setups/structureSetup/structureSetup.utils.ts","../src/plugins/scrollbarsHidingPlugin/scrollbarsHidingPlugin.ts","../src/plugins/clickScrollPlugin/clickScrollPlugin.ts","../src/environment.ts","../src/initialization.ts","../src/instances.ts","../src/observers/domObserver.ts","../src/observers/sizeObserver.ts","../src/observers/trinsicObserver.ts","../src/setups/observersSetup/observersSetup.ts","../src/setups/scrollbarsSetup/scrollbarsSetup.elements.ts","../src/setups/scrollbarsSetup/scrollbarsSetup.events.ts","../src/setups/scrollbarsSetup/scrollbarsSetup.ts","../src/setups/structureSetup/structureSetup.elements.ts","../src/setups/structureSetup/updateSegments/trinsicUpdateSegment.ts","../src/setups/structureSetup/updateSegments/paddingUpdateSegment.ts","../src/setups/structureSetup/updateSegments/overflowUpdateSegment.ts","../src/setups/structureSetup/structureSetup.ts","../src/setups/setups.ts","../src/overlayscrollbars.ts"],"sourcesContent":["export interface CacheOptions {\n // initial value of _value.\n _initialValue: Value;\n // Custom comparison function if shallow compare isn't enough. Returns true if nothing changed.\n _equal?: EqualCachePropFunction;\n // If true always updates _value and _previous, otherwise they update only when they changed.\n _alwaysUpdateValues?: boolean;\n}\n\nexport type CacheValues = [value: T, changed: boolean, previous?: T];\n\nexport type EqualCachePropFunction = (currentVal: Value, newVal: Value) => boolean;\n\nexport type CacheUpdater = (current: Value, previous?: Value) => Value;\n\nexport type UpdateCacheContextual = (newValue: Value, force?: boolean) => CacheValues;\n\nexport type UpdateCache = (force?: boolean) => CacheValues;\n\nexport type GetCurrentCache = (force?: boolean) => CacheValues;\n\nexport type Cache = [UpdateCache, GetCurrentCache];\n\nexport type CacheContextual = [UpdateCacheContextual, GetCurrentCache];\n\ntype CreateCache = {\n (options: CacheOptions): CacheContextual;\n (options: CacheOptions, update: CacheUpdater): Cache;\n (options: CacheOptions, update?: CacheUpdater):\n | CacheContextual\n | Cache;\n};\n\nexport const createCache: CreateCache = (\n options: CacheOptions,\n update?: CacheUpdater\n): CacheContextual | Cache => {\n const { _initialValue, _equal, _alwaysUpdateValues } = options;\n let _value: Value = _initialValue;\n let _previous: Value | undefined;\n\n const cacheUpdateContextual: UpdateCacheContextual = (newValue, force?) => {\n const curr = _value;\n\n const newVal = newValue;\n const changed = force || (_equal ? !_equal(curr, newVal) : curr !== newVal);\n\n if (changed || _alwaysUpdateValues) {\n _value = newVal;\n _previous = curr;\n }\n\n return [_value, changed, _previous];\n };\n const cacheUpdateIsolated: UpdateCache = (force?) =>\n cacheUpdateContextual(update!(_value, _previous), force);\n\n const getCurrentCache: GetCurrentCache = (force?: boolean) => [\n _value,\n !!force, // changed\n _previous,\n ];\n\n return [update ? cacheUpdateIsolated : cacheUpdateContextual, getCurrentCache] as\n | CacheContextual\n | Cache;\n};\n","export const isBrowser =\r\n typeof window !== 'undefined' &&\r\n // deno has the global `window` defined, so additionally check for document\r\n typeof document !== 'undefined';\r\n","import { isBrowser } from '../compatibility/isBrowser';\r\n\r\nexport const wnd = (isBrowser ? window : {}) as typeof window;\r\nexport const mathMax = Math.max;\r\nexport const mathMin = Math.min;\r\nexport const mathRound = Math.round;\r\nexport const mathFloor = Math.floor;\r\nexport const mathCeil = Math.ceil;\r\nexport const mathAbs = Math.abs;\r\nexport const cAF = wnd.cancelAnimationFrame;\r\nexport const rAF = wnd.requestAnimationFrame;\r\nexport const setT = wnd.setTimeout;\r\nexport const clearT = wnd.clearTimeout;\r\n","import { wnd } from '../utils/alias';\r\n\r\nconst getApi = (name: string) =>\r\n (typeof wnd[name as keyof typeof wnd] !== 'undefined'\r\n ? wnd[name as keyof typeof wnd]\r\n : undefined) as T;\r\n\r\nexport const MutationObserverConstructor = getApi('MutationObserver');\r\nexport const IntersectionObserverConstructor =\r\n getApi('IntersectionObserver');\r\nexport const ResizeObserverConstructor = getApi('ResizeObserver');\r\nexport const scrollT = getApi AnimationTimeline>('ScrollTimeline');\r\n","import type { PlainObject } from '~/typings';\r\nimport { isBrowser } from '../compatibility/isBrowser';\r\n\r\nconst ElementNodeType = isBrowser && Node.ELEMENT_NODE;\r\nconst { toString, hasOwnProperty } = Object.prototype;\r\nconst typeRgx = /^\\[object (.+)\\]$/;\r\n\r\nexport const isUndefined = (obj: any): obj is undefined => obj === undefined;\r\n\r\nexport const isNull = (obj: any): obj is null => obj === null;\r\n\r\nexport const type = (obj: any): string =>\r\n isUndefined(obj) || isNull(obj)\r\n ? `${obj}`\r\n : toString.call(obj).replace(typeRgx, '$1').toLowerCase();\r\n\r\nexport const isNumber = (obj: any): obj is number => typeof obj === 'number';\r\n\r\nexport const isString = (obj: any): obj is string => typeof obj === 'string';\r\n\r\nexport const isBoolean = (obj: any): obj is boolean => typeof obj === 'boolean';\r\n\r\nexport const isFunction = (obj: any): obj is (...args: any[]) => any => typeof obj === 'function';\r\n\r\nexport const isArray = (obj: any): obj is Array => Array.isArray(obj);\r\n\r\nexport const isObject = (obj: any): obj is object =>\r\n typeof obj === 'object' && !isArray(obj) && !isNull(obj);\r\n\r\n/**\r\n * Returns true if the given object is array like, false otherwise.\r\n * @param obj The Object\r\n */\r\nexport const isArrayLike = (obj: any): obj is ArrayLike => {\r\n const length = !!obj && obj.length;\r\n const lengthCorrectFormat = isNumber(length) && length > -1 && length % 1 == 0; // eslint-disable-line eqeqeq\r\n\r\n return isArray(obj) || (!isFunction(obj) && lengthCorrectFormat)\r\n ? length > 0 && isObject(obj)\r\n ? length - 1 in obj\r\n : true\r\n : false;\r\n};\r\n\r\n/**\r\n * Returns true if the given object is a \"plain\" (e.g. { key: value }) object, false otherwise.\r\n * @param obj The Object.\r\n */\r\nexport const isPlainObject = (obj: any): obj is PlainObject => {\r\n if (!obj || !isObject(obj) || type(obj) !== 'object') return false;\r\n\r\n let key;\r\n const cstr = 'constructor';\r\n const ctor = obj[cstr];\r\n const ctorProto = ctor && ctor.prototype;\r\n const hasOwnConstructor = hasOwnProperty.call(obj, cstr);\r\n const hasIsPrototypeOf = ctorProto && hasOwnProperty.call(ctorProto, 'isPrototypeOf');\r\n\r\n if (ctor && !hasOwnConstructor && !hasIsPrototypeOf) {\r\n return false;\r\n }\r\n\r\n /* eslint-disable no-restricted-syntax */\r\n for (key in obj) {\r\n /**/\r\n }\r\n /* eslint-enable */\r\n\r\n return isUndefined(key) || hasOwnProperty.call(obj, key);\r\n};\r\n\r\n/**\r\n * Checks whether the given object is a HTMLElement.\r\n * @param obj The object which shall be checked.\r\n */\r\nexport const isHTMLElement = (obj: any): obj is HTMLElement => {\r\n const instanceofObj = HTMLElement;\r\n return obj\r\n ? instanceofObj\r\n ? obj instanceof instanceofObj\r\n : obj.nodeType === ElementNodeType\r\n : false;\r\n};\r\n\r\n/**\r\n * Checks whether the given object is a Element.\r\n * @param obj The object which shall be checked.\r\n */\r\nexport const isElement = (obj: any): obj is Element => {\r\n const instanceofObj = Element;\r\n return obj\r\n ? instanceofObj\r\n ? obj instanceof instanceofObj\r\n : obj.nodeType === ElementNodeType\r\n : false;\r\n};\r\n","import { mathMax, rAF, cAF } from './alias';\r\nimport { isFunction } from './types';\r\n\r\n/**\r\n * percent: current percent (0 - 1),\r\n * time: current time (duration * percent),\r\n * min: start value\r\n * max: end value\r\n * duration: duration in ms\r\n */\r\nexport type EasingFn = (\r\n percent: number,\r\n time: number,\r\n min: number,\r\n max: number,\r\n duration: number\r\n) => number;\r\n\r\nconst animationCurrentTime = () => performance.now();\r\n\r\nexport const animateNumber = (\r\n from: number,\r\n to: number,\r\n duration: number,\r\n onFrame: (progress: number, percent: number, completed: boolean) => any,\r\n easing?: EasingFn | false\r\n): ((complete?: boolean) => void) => {\r\n let animationFrameId = 0;\r\n const timeStart = animationCurrentTime();\r\n const finalDuration = mathMax(0, duration);\r\n const frame = (complete?: boolean) => {\r\n const timeNow = animationCurrentTime();\r\n const timeElapsed = timeNow - timeStart;\r\n const stopAnimation = timeElapsed >= finalDuration;\r\n const percent = complete\r\n ? 1\r\n : 1 - (mathMax(0, timeStart + finalDuration - timeNow) / finalDuration || 0);\r\n const progress =\r\n (to - from) *\r\n (isFunction(easing)\r\n ? easing(percent, percent * finalDuration, 0, 1, finalDuration)\r\n : percent) +\r\n from;\r\n const animationCompleted = stopAnimation || percent === 1;\r\n\r\n onFrame && onFrame(progress, percent, animationCompleted);\r\n\r\n animationFrameId = animationCompleted ? 0 : rAF!(() => frame());\r\n };\r\n frame();\r\n return (complete) => {\r\n cAF!(animationFrameId);\r\n complete && frame(complete);\r\n };\r\n};\r\n","import type { PlainObject } from '~/typings';\r\nimport { isArray, isArrayLike, isString } from './types';\r\n\r\ntype RunEachItem = ((...args: any) => any | any[]) | false | null | undefined;\r\n\r\nexport function each | ReadonlyArray>(\r\n array: T,\r\n callback: (\r\n value: T extends Array | ReadonlyArray ? V : never,\r\n index: number,\r\n source: T\r\n ) => boolean | unknown\r\n): T;\r\nexport function each>(\r\n arrayLikeObject: T,\r\n callback: (\r\n value: T extends ArrayLike ? V : never,\r\n index: number,\r\n source: T\r\n ) => boolean | unknown\r\n): T;\r\nexport function each(\r\n obj: T,\r\n callback: (value: any, key: string, source: T) => boolean | unknown\r\n): T;\r\nexport function each(\r\n source: Array | ArrayLike | ReadonlyArray | PlainObject,\r\n callback: (value: any, indexOrKey: any, source: any) => boolean | unknown\r\n): Array | ArrayLike | ReadonlyArray | Set | PlainObject {\r\n if (isArrayLike(source)) {\r\n for (let i = 0; i < source.length; i++) {\r\n if (callback(source[i], i, source) === false) {\r\n break;\r\n }\r\n }\r\n } else if (source) {\r\n // cant use support func keys here due to circular dep\r\n each(Object.keys(source), (key) => callback(source[key], key, source));\r\n }\r\n return source;\r\n}\r\n\r\n/**\r\n * Returns true when the passed item is in the passed array and false otherwise.\r\n * @param arr The array.\r\n * @param item The item.\r\n * @returns Whether the item is in the array.\r\n */\r\nexport const inArray = (arr: T[], item: T): boolean => arr.indexOf(item) >= 0;\r\n\r\n/**\r\n * Concats two arrays and returns an new array without modifying any of the passed arrays.\r\n * @param a Array A.\r\n * @param b Array B.\r\n * @returns A new array which has the entries of both arrays.\r\n */\r\nexport const concat = (a: T[] | ReadonlyArray, b: T[] | ReadonlyArray): T[] => a.concat(b);\r\n\r\n/**\r\n * Pushesh all given items into the given array and returns it.\r\n * @param array The array the items shall be pushed into.\r\n * @param items The items which shall be pushed into the array.\r\n */\r\nexport const push = (array: T[], items: T | ArrayLike, arrayIsSingleItem?: boolean): T[] => {\r\n !arrayIsSingleItem && !isString(items) && isArrayLike(items)\r\n ? Array.prototype.push.apply(array, items as T[])\r\n : array.push(items as T);\r\n return array;\r\n};\r\n\r\n/**\r\n * Creates a shallow-copied Array instance from an array-like or iterable object.\r\n * @param arr The object from which the array instance shall be created.\r\n */\r\nexport const from = (arr?: ArrayLike | Set) => Array.from(arr || []);\r\n\r\n/**\r\n * Creates an array if the passed value is not an array, or returns the value if it is.\r\n * @param value The value.\r\n * @returns An array which represents the passed value(s).\r\n */\r\nexport const createOrKeepArray = (value: T | T[]): T[] => (isArray(value) ? value : [value]);\r\n\r\n/**\r\n * Check whether the passed array is empty.\r\n * @param array The array which shall be checked.\r\n */\r\nexport const isEmptyArray = (array: any[] | null | undefined): boolean => !!array && !array.length;\r\n\r\n/**\r\n * Deduplicates all items of the array.\r\n * @param array The array to be deduplicated.\r\n * @returns The deduplicated array.\r\n */\r\nexport const deduplicateArray = (array: T): T => from(new Set(array)) as T;\r\n\r\n/**\r\n * Calls all functions in the passed array/set of functions.\r\n * @param arr The array filled with function which shall be called.\r\n * @param args The args with which each function is called.\r\n * @param keep True when the Set / array should not be cleared afterwards, false otherwise.\r\n */\r\nexport const runEachAndClear = (arr: RunEachItem[], args?: any[], keep?: boolean): void => {\r\n // eslint-disable-next-line prefer-spread\r\n const runFn = (fn: RunEachItem) => fn && fn.apply(undefined, args || []);\r\n each(arr, runFn);\r\n !keep && ((arr as any[]).length = 0);\r\n};\r\n","export const strPaddingTop = 'paddingTop';\r\nexport const strPaddingRight = 'paddingRight';\r\nexport const strPaddingLeft = 'paddingLeft';\r\nexport const strPaddingBottom = 'paddingBottom';\r\nexport const strMarginLeft = 'marginLeft';\r\nexport const strMarginRight = 'marginRight';\r\nexport const strMarginBottom = 'marginBottom';\r\nexport const strOverflowX = 'overflowX';\r\nexport const strOverflowY = 'overflowY';\r\nexport const strWidth = 'width';\r\nexport const strHeight = 'height';\r\nexport const strHidden = 'hidden';\r\nexport const strVisible = 'visible';\r\n","import type { WH } from '../dom/dimensions';\r\nimport type { XY } from '../dom/offset';\r\nimport type { TRBL } from '../dom/style';\r\nimport type { PlainObject } from '~/typings';\r\nimport { each } from './array';\r\nimport { mathRound } from './alias';\r\nimport { strHeight, strWidth } from './strings';\r\n\r\n/**\r\n * Compares two objects and returns true if all values of the passed prop names are identical, false otherwise or if one of the two object is falsy.\r\n * @param a Object a.\r\n * @param b Object b.\r\n * @param props The props which shall be compared.\r\n */\r\nexport const equal = (\r\n a: T | undefined,\r\n b: T | undefined,\r\n props: Array,\r\n propMutation?: ((value: any) => any) | null | false\r\n): boolean => {\r\n if (a && b) {\r\n let result = true;\r\n each(props, (prop) => {\r\n const compareA = propMutation ? propMutation(a[prop]) : a[prop];\r\n const compareB = propMutation ? propMutation(b[prop]) : b[prop];\r\n if (compareA !== compareB) {\r\n result = false;\r\n }\r\n });\r\n return result;\r\n }\r\n return false;\r\n};\r\n\r\n/**\r\n * Compares object a with object b and returns true if both have the same property values, false otherwise.\r\n * Also returns false if one of the objects is undefined or null.\r\n * @param a Object a.\r\n * @param b Object b.\r\n */\r\nexport const equalWH = (a?: WH, b?: WH) => equal>(a, b, ['w', 'h']);\r\n\r\n/**\r\n * Compares object a with object b and returns true if both have the same property values, false otherwise.\r\n * Also returns false if one of the objects is undefined or null.\r\n * @param a Object a.\r\n * @param b Object b.\r\n */\r\nexport const equalXY = (a?: XY, b?: XY) => equal>(a, b, ['x', 'y']);\r\n\r\n/**\r\n * Compares object a with object b and returns true if both have the same property values, false otherwise.\r\n * Also returns false if one of the objects is undefined or null.\r\n * @param a Object a.\r\n * @param b Object b.\r\n */\r\nexport const equalTRBL = (a?: TRBL, b?: TRBL) => equal(a, b, ['t', 'r', 'b', 'l']);\r\n\r\n/**\r\n * Compares two DOM Rects for their equality of their width and height properties\r\n * Also returns false if one of the DOM Rects is undefined or null.\r\n * @param a DOM Rect a.\r\n * @param b DOM Rect b.\r\n * @param round Whether the values should be rounded.\r\n */\r\nexport const equalBCRWH = (a?: DOMRect, b?: DOMRect, round?: boolean) =>\r\n equal(a, b, [strWidth, strHeight], round && ((value) => mathRound(value)));\r\n","export const noop = () => {}; // eslint-disable-line\r\n","import { isNumber, isFunction } from './types';\r\nimport { from } from './array';\r\nimport { rAF, cAF, setT, clearT } from './alias';\r\nimport { noop } from './noop';\r\n\r\ntype DebounceTiming = number | false | null | undefined;\r\n\r\nexport interface DebounceOptions any> {\r\n /**\r\n * The timeout for debouncing. If null, no debounce is applied.\r\n */\r\n _timeout?: DebounceTiming | (() => DebounceTiming);\r\n /**\r\n * A maximum amount of ms. before the function will be called even with debounce.\r\n */\r\n _maxDelay?: DebounceTiming | (() => DebounceTiming);\r\n /**\r\n * Function which merges parameters for each canceled debounce.\r\n * If parameters can't be merged the function will return null, otherwise it returns the merged parameters.\r\n */\r\n _mergeParams?: (\r\n prev: Parameters,\r\n curr: Parameters\r\n ) => Parameters | false | null | undefined;\r\n}\r\n\r\nexport interface Debounced any> {\r\n (...args: Parameters): ReturnType;\r\n _flush(): void;\r\n}\r\n\r\nexport const bind = (\r\n fn: (...args: [...A, ...B]) => R,\r\n ...args: A\r\n): ((...args: B) => R) => fn.bind(0, ...args);\r\n\r\n/**\r\n * Creates a timeout and cleartimeout tuple. The timeout function always clears the previously created timeout before it runs.\r\n * @param timeout The timeout in ms. If no timeout (or 0) is passed requestAnimationFrame is used instead of setTimeout.\r\n * @returns A tuple with the timeout function as the first value and the clearTimeout function as the second value.\r\n */\r\nexport const selfClearTimeout = (timeout?: number | (() => number)) => {\r\n let id: number;\r\n const setTFn = timeout ? setT : rAF!;\r\n const clearTFn = timeout ? clearT : cAF!;\r\n return [\r\n (callback: () => any) => {\r\n clearTFn(id);\r\n // @ts-ignore\r\n id = setTFn(callback, isFunction(timeout) ? timeout() : timeout);\r\n },\r\n () => clearTFn(id),\r\n ] as [timeout: (callback: () => any) => void, clear: () => void];\r\n};\r\n\r\n/**\r\n * Debounces the given function either with a timeout or a animation frame.\r\n * @param functionToDebounce The function which shall be debounced.\r\n * @param options Options for debouncing.\r\n */\r\nexport const debounce = any>(\r\n functionToDebounce: FunctionToDebounce,\r\n options?: DebounceOptions\r\n): Debounced => {\r\n let maxTimeoutId: number | undefined;\r\n let prevArguments: Parameters | null | undefined;\r\n let latestArguments: Parameters | null | undefined;\r\n let clear = noop;\r\n const { _timeout, _maxDelay, _mergeParams } = options || {};\r\n\r\n const invokeFunctionToDebounce = function (args: IArguments) {\r\n clear();\r\n clearT(maxTimeoutId);\r\n maxTimeoutId = prevArguments = undefined;\r\n clear = noop;\r\n // eslint-disable-next-line\r\n // @ts-ignore\r\n functionToDebounce.apply(this, args);\r\n };\r\n\r\n const mergeParms = (\r\n curr: Parameters\r\n ): Parameters | false | null | undefined =>\r\n _mergeParams && prevArguments ? _mergeParams(prevArguments, curr) : curr;\r\n\r\n const flush = () => {\r\n /* istanbul ignore next */\r\n if (clear !== noop) {\r\n invokeFunctionToDebounce(mergeParms(latestArguments!) || latestArguments!);\r\n }\r\n };\r\n\r\n const debouncedFn = function () {\r\n // eslint-disable-next-line prefer-rest-params\r\n const args: Parameters = from(arguments) as Parameters;\r\n const finalTimeout = isFunction(_timeout) ? _timeout() : _timeout;\r\n const hasTimeout = isNumber(finalTimeout) && finalTimeout >= 0;\r\n\r\n if (hasTimeout) {\r\n const finalMaxWait = isFunction(_maxDelay) ? _maxDelay() : _maxDelay;\r\n const hasMaxWait = isNumber(finalMaxWait) && finalMaxWait >= 0;\r\n const setTimeoutFn = finalTimeout > 0 ? setT : rAF!;\r\n const clearTimeoutFn = finalTimeout > 0 ? clearT : cAF!;\r\n const mergeParamsResult = mergeParms(args);\r\n const invokedArgs = mergeParamsResult || args;\r\n const boundInvoke = invokeFunctionToDebounce.bind(0, invokedArgs);\r\n\r\n // if (!mergeParamsResult) {\r\n // invokeFunctionToDebounce(prevArguments || args);\r\n // }\r\n\r\n clear();\r\n // @ts-ignore\r\n const timeoutId = setTimeoutFn(boundInvoke, finalTimeout);\r\n clear = () => clearTimeoutFn(timeoutId);\r\n\r\n if (hasMaxWait && !maxTimeoutId) {\r\n maxTimeoutId = setT(flush, finalMaxWait as number);\r\n }\r\n\r\n prevArguments = latestArguments = invokedArgs;\r\n } else {\r\n invokeFunctionToDebounce(args);\r\n }\r\n };\r\n debouncedFn._flush = flush;\r\n\r\n return debouncedFn as Debounced;\r\n};\r\n","import type { PlainObject } from '~/typings';\r\nimport { isArray, isFunction, isPlainObject, isNull } from './types';\r\nimport { each } from './array';\r\n\r\n/**\r\n * Determines whether the passed object has a property with the passed name.\r\n * @param obj The object.\r\n * @param prop The name of the property.\r\n */\r\nexport const hasOwnProperty = (obj: any, prop: string | number | symbol): boolean =>\r\n Object.prototype.hasOwnProperty.call(obj, prop);\r\n\r\n/**\r\n * Returns the names of the enumerable string properties and methods of an object.\r\n * @param obj The object of which the properties shall be returned.\r\n */\r\nexport const keys = (obj: any): Array => (obj ? Object.keys(obj) : []);\r\n\r\ntype AssignDeep = {\r\n (target: T, object1: U): T & U;\r\n (target: T, object1: U, object2: V): T & U & V;\r\n (target: T, object1: U, object2: V, object3: W): T & U & V & W;\r\n (target: T, object1: U, object2: V, object3: W, object4: X): T & U & V & W & X;\r\n (target: T, object1: U, object2: V, object3: W, object4: X, object5: Y): T &\r\n U &\r\n V &\r\n W &\r\n X &\r\n Y;\r\n (\r\n target: T,\r\n object1?: U,\r\n object2?: V,\r\n object3?: W,\r\n object4?: X,\r\n object5?: Y,\r\n object6?: Z\r\n ): T & U & V & W & X & Y & Z;\r\n};\r\n\r\n// https://github.com/jquery/jquery/blob/master/src/core.js#L116\r\nexport const assignDeep: AssignDeep = (\r\n target: T,\r\n object1?: U,\r\n object2?: V,\r\n object3?: W,\r\n object4?: X,\r\n object5?: Y,\r\n object6?: Z\r\n): T & U & V & W & X & Y & Z => {\r\n const sources: Array = [object1, object2, object3, object4, object5, object6];\r\n\r\n // Handle case when target is a string or something (possible in deep copy)\r\n if ((typeof target !== 'object' || isNull(target)) && !isFunction(target)) {\r\n target = {} as T;\r\n }\r\n\r\n each(sources, (source) => {\r\n // Extend the base object\r\n each(source, (_, key) => {\r\n const copy: any = source[key];\r\n\r\n // Prevent Object.prototype pollution\r\n // Prevent never-ending loop\r\n if (target === copy) {\r\n return true;\r\n }\r\n\r\n const copyIsArray = isArray(copy);\r\n\r\n // Recurse if we're merging plain objects or arrays\r\n if (copy && isPlainObject(copy)) {\r\n const src = target[key as keyof T];\r\n let clone: any = src;\r\n\r\n // Ensure proper type for the source value\r\n if (copyIsArray && !isArray(src)) {\r\n clone = [];\r\n } else if (!copyIsArray && !isPlainObject(src)) {\r\n clone = {};\r\n }\r\n\r\n // Never move original objects, clone them\r\n target[key as keyof T] = assignDeep(clone, copy) as any;\r\n } else {\r\n target[key as keyof T] = copyIsArray ? copy.slice() : copy;\r\n }\r\n });\r\n });\r\n\r\n // Return the modified object\r\n return target as any;\r\n};\r\n\r\nexport const removeUndefinedProperties = (target: T, deep?: boolean): T =>\r\n each(assignDeep({}, target), (value, key, copy) => {\r\n if (value === undefined) {\r\n delete copy[key];\r\n } else if (deep && value && isPlainObject(value)) {\r\n copy[key as keyof typeof copy] = removeUndefinedProperties(value, deep) as any;\r\n }\r\n });\r\n\r\n/**\r\n * Returns true if the given object is empty, false otherwise.\r\n * @param obj The Object.\r\n */\r\nexport const isEmptyObject = (obj: any): boolean => {\r\n // eslint-disable-next-line no-restricted-syntax, no-unreachable-loop, guard-for-in\r\n for (const name in obj) return false;\r\n return true;\r\n /* eslint-enable */\r\n};\r\n","import { mathMax, mathMin } from './alias';\r\n\r\n/**\r\n * Caps the passed number between the `min` and `max` bounds.\r\n * @param min The min bound.\r\n * @param max The max bound.\r\n * @param number The number to be capped.\r\n * @returns The capped number between min and max.\r\n */\r\nexport const capNumber = (min: number, max: number, number: number) =>\r\n mathMax(min, mathMin(max, number));\r\n","import type { HTMLElementTarget } from './types';\r\nimport { bind, each, from, isArray } from '../utils';\r\n\r\nexport type AttributeElementTarget = HTMLElementTarget | Element;\r\n\r\nexport type DomTokens = string | string[] | false | null | undefined | void;\r\n\r\nexport const getDomTokensArray = (tokens: DomTokens) =>\r\n from(new Set((isArray(tokens) ? tokens : (tokens || '').split(' ')).filter((token) => token)));\r\n\r\n/**\r\n * Gets a attribute with the given attribute of the given element.\r\n * @param elm The element of which the attribute shall be get.\r\n * @param attrName The attribute name which shall be get.\r\n * @returns The attribute value or `null` when the attribute is not set or `false` if the element is undefined.\r\n */\r\nexport const getAttr = (elm: AttributeElementTarget, attrName: string) =>\r\n elm && elm.getAttribute(attrName);\r\n\r\n/**\r\n * Returns whether the given attribute exists on the given element.\r\n * @param elm The element.\r\n * @param attrName The attribute.\r\n * @returns A Truthy value indicates a present attrubte.\r\n */\r\nexport const hasAttr = (elm: AttributeElementTarget, attrName: string) =>\r\n elm && elm.hasAttribute(attrName);\r\n\r\n/**\r\n * Sets the given attributes to the given element.\r\n * @param elm The element of which the attributes shall be removed.\r\n * @param attrName The attribute names separated by a space.\r\n */\r\nexport const setAttrs = (\r\n elm: AttributeElementTarget,\r\n attrNames: string | string[],\r\n value: string | false | null | undefined\r\n) => {\r\n each(getDomTokensArray(attrNames), (attrName) => {\r\n elm && elm.setAttribute(attrName, value || '');\r\n });\r\n};\r\n\r\n/**\r\n * Removes the given attributes from the given element.\r\n * @param elm The element of which the attribute shall be removed.\r\n * @param attrName The attribute names separated by a space.\r\n */\r\nexport const removeAttrs = (elm: AttributeElementTarget, attrNames: string | string[]): void => {\r\n each(getDomTokensArray(attrNames), (attrName) => elm && elm.removeAttribute(attrName));\r\n};\r\n\r\nexport const domTokenListAttr = (elm: AttributeElementTarget, attrName: string) => {\r\n const initialArr = getDomTokensArray(getAttr(elm, attrName));\r\n const setElmAttr = bind(setAttrs, elm, attrName);\r\n const domTokenListOperation = (operationTokens: DomTokens, operation: 'add' | 'delete') => {\r\n const initialArrSet = new Set(initialArr);\r\n each(getDomTokensArray(operationTokens), (token) => initialArrSet[operation](token));\r\n return from(initialArrSet).join(' ');\r\n };\r\n\r\n return {\r\n _remove: (removeTokens: DomTokens) => setElmAttr(domTokenListOperation(removeTokens, 'delete')),\r\n _add: (addTokens: DomTokens) => setElmAttr(domTokenListOperation(addTokens, 'add')),\r\n _has: (hasTokens: DomTokens) => {\r\n const tokenSet = getDomTokensArray(hasTokens);\r\n return tokenSet.reduce(\r\n (boolean, token) => boolean && initialArr.includes(token),\r\n tokenSet.length > 0\r\n );\r\n },\r\n };\r\n};\r\n\r\n/**\r\n * Treats the given attribute like the \"class\" attribute and removes the given value from it.\r\n * @param elm The element.\r\n * @param attrName The attributeName to which the value shall be removed.\r\n * @param value The value which shall be removed.\r\n */\r\nexport const removeAttrClass = (\r\n elm: AttributeElementTarget,\r\n attrName: string,\r\n value: DomTokens\r\n) => {\r\n domTokenListAttr(elm, attrName)._remove(value);\r\n};\r\n\r\n/**\r\n * Treats the given attribute like the \"class\" attribute and adds value to it.\r\n * @param elm The element.\r\n * @param attrName The attributeName to which the value shall be added.\r\n * @param value The value which shall be added.\r\n */\r\nexport const addAttrClass = (elm: AttributeElementTarget, attrName: string, value: DomTokens) => {\r\n domTokenListAttr(elm, attrName)._add(value);\r\n return bind(removeAttrClass, elm, attrName, value);\r\n};\r\n\r\nexport const addRemoveAttrClass = (\r\n elm: AttributeElementTarget,\r\n attrName: string,\r\n value: DomTokens,\r\n add?: boolean\r\n) => {\r\n (add ? addAttrClass : removeAttrClass)(elm, attrName, value);\r\n};\r\n\r\n/**\r\n * Treats the given attribute like the \"class\" attribute and checks if the given value is in it.\r\n * @param elm The element.\r\n * @param attrName The attributeName from which the content shall be checked.\r\n * @param value The value.\r\n * @returns True if the given attribute has the value in it, false otherwise.\r\n */\r\nexport const hasAttrClass = (\r\n elm: AttributeElementTarget,\r\n attrName: string,\r\n value: DomTokens\r\n): boolean => domTokenListAttr(elm, attrName)._has(value);\r\n","import type { HTMLElementTarget } from './types';\r\nimport type { DomTokens } from './attribute';\r\nimport { each, from } from '../utils/array';\r\nimport { bind } from '../utils/function';\r\nimport { domTokenListAttr } from './attribute';\r\n\r\nconst createDomTokenListClass = (elm: HTMLElementTarget) => domTokenListAttr(elm, 'class');\r\n\r\n/**\r\n * Check whether the given element has the given class name(s).\r\n * @param elm The element.\r\n * @param className The class name(s).\r\n */\r\nexport const hasClass = (elm: HTMLElementTarget, className: DomTokens): boolean =>\r\n createDomTokenListClass(elm)._has(className);\r\n\r\n/**\r\n * Removes the given class name(s) from the given element.\r\n * @param elm The element.\r\n * @param className The class name(s) which shall be removed. (separated by spaces)\r\n */\r\nexport const removeClass = (elm: HTMLElementTarget, className: DomTokens): void => {\r\n createDomTokenListClass(elm)._remove(className);\r\n};\r\n\r\n/**\r\n * Adds the given class name(s) to the given element.\r\n * @param elm The element.\r\n * @param className The class name(s) which shall be added. (separated by spaces)\r\n * @returns A function which removes the added class name(s).\r\n */\r\nexport const addClass = (elm: HTMLElementTarget, className: DomTokens): (() => void) => {\r\n createDomTokenListClass(elm)._add(className);\r\n return bind(removeClass, elm, className);\r\n};\r\n\r\n/**\r\n * Takes two className strings, compares them and returns the difference as array.\r\n * @param classNameA ClassName A.\r\n * @param classNameB ClassName B.\r\n */\r\nexport const diffClass = (classNameA: string, classNameB: string) => {\r\n const set = new Set(classNameA ? classNameA.split(' ') : []);\r\n\r\n each(classNameB ? classNameB.split(' ') : [], (className) => {\r\n set.has(className) ? set.delete(className) : set.add(className);\r\n });\r\n\r\n return from(set);\r\n};\r\n","import { isElement } from '../utils/types';\r\nimport { push, from } from '../utils/array';\r\n\r\ntype InputElementType = Node | Element | false | null | undefined;\r\ntype OutputElementType = Node | Element | false | null | undefined;\r\n\r\n/**\r\n * Find all elements with the passed selector, outgoing (and including) the passed element or the document if no element was provided.\r\n * @param selector The selector which has to be searched by.\r\n * @param elm The element from which the search shall be outgoing.\r\n */\r\nconst find = (selector: string, elm?: InputElementType): Element[] => {\r\n const arr: Array = [];\r\n const rootElm = elm ? isElement(elm) && elm : document;\r\n\r\n return rootElm ? push(arr, rootElm.querySelectorAll(selector)) : arr;\r\n};\r\n\r\n/**\r\n * Find the first element with the passed selector, outgoing (and including) the passed element or the document if no element was provided.\r\n * @param selector The selector which has to be searched by.\r\n * @param elm The element from which the search shall be outgoing.\r\n */\r\nconst findFirst = (selector: string, elm?: InputElementType): OutputElementType => {\r\n const rootElm = elm ? isElement(elm) && elm : document;\r\n\r\n return rootElm ? rootElm.querySelector(selector) : null;\r\n};\r\n\r\n/**\r\n * Determines whether the passed element is matching with the passed selector.\r\n * @param elm The element which has to be compared with the passed selector.\r\n * @param selector The selector which has to be compared with the passed element. Additional selectors: ':visible' and ':hidden'.\r\n */\r\nconst is = (elm: InputElementType, selector: string): boolean => {\r\n if (isElement(elm)) {\r\n return elm.matches(selector);\r\n }\r\n return false;\r\n};\r\n\r\nconst isBodyElement = (elm: InputElementType) => is(elm, 'body'); // don't do targetElement === ownerDocument.body in case initialization happens in memory\r\n\r\n/**\r\n * Returns the children (no text-nodes or comments) of the passed element which are matching the passed selector. An empty array is returned if the passed element is null.\r\n * @param elm The element of which the children shall be returned.\r\n * @param selector The selector which must match with the children elements.\r\n */\r\nconst children = (elm: InputElementType, selector?: string): ReadonlyArray => {\r\n const childs: Array = [];\r\n\r\n return isElement(elm)\r\n ? push(\r\n childs,\r\n from(elm.children).filter((child) => (selector ? is(child, selector) : child))\r\n )\r\n : childs;\r\n};\r\n\r\n/**\r\n * Returns the childNodes (incl. text-nodes or comments etc.) of the passed element. An empty array is returned if the passed element is null.\r\n * @param elm The element of which the childNodes shall be returned.\r\n */\r\nconst contents = (elm: InputElementType): ReadonlyArray =>\r\n elm ? from(elm.childNodes) : [];\r\n\r\n/**\r\n * Returns the parent element of the passed element, or null if the passed element is null.\r\n * @param elm The element of which the parent element shall be returned.\r\n */\r\nconst parent = (elm: InputElementType): OutputElementType => elm && elm.parentElement;\r\n\r\n/**\r\n * Returns the closest element to the passed element which matches the given selector.\r\n * @param elm The element.\r\n * @param selector The selector.\r\n * @returns The closest element to the passed element which matches the given selector.\r\n */\r\nconst closest = (elm: InputElementType, selector: string): OutputElementType =>\r\n isElement(elm) && elm.closest(selector);\r\n\r\n/**\r\n * Gets the focused element of the passed or default document.\r\n * @returns The focused element of the passed document.\r\n */\r\nconst getFocusedElement = (doc?: Document) => (doc || document).activeElement;\r\n\r\n/**\r\n * Determines whether the given element lies between two selectors in the DOM.\r\n * @param elm The element.\r\n * @param highBoundarySelector The high boundary selector.\r\n * @param deepBoundarySelector The deep boundary selector.\r\n */\r\nconst liesBetween = (\r\n elm: InputElementType,\r\n highBoundarySelector: string,\r\n deepBoundarySelector: string\r\n): boolean => {\r\n const closestHighBoundaryElm = closest(elm, highBoundarySelector);\r\n const closestDeepBoundaryElm = elm && findFirst(deepBoundarySelector, closestHighBoundaryElm);\r\n const deepBoundaryIsValid =\r\n closest(closestDeepBoundaryElm, highBoundarySelector) === closestHighBoundaryElm;\r\n\r\n return closestHighBoundaryElm && closestDeepBoundaryElm\r\n ? closestHighBoundaryElm === elm ||\r\n closestDeepBoundaryElm === elm ||\r\n (deepBoundaryIsValid &&\r\n closest(closest(elm, deepBoundarySelector), highBoundarySelector) !==\r\n closestHighBoundaryElm)\r\n : false;\r\n};\r\n\r\nexport {\r\n find,\r\n findFirst,\r\n is,\r\n isBodyElement,\r\n children,\r\n contents,\r\n parent,\r\n liesBetween,\r\n closest,\r\n getFocusedElement,\r\n};\r\n","import { isArrayLike } from '../utils/types';\r\nimport { each, from } from '../utils/array';\r\nimport { noop } from '../utils/noop';\r\nimport { parent } from './traversal';\r\n\r\ntype ManipulationTarget = Node | false | null | undefined;\r\ntype NodeCollection = ArrayLike | ManipulationTarget;\r\n\r\n/**\r\n * Removes the given Nodes from their parent.\r\n * @param nodes The Nodes which shall be removed.\r\n */\r\nexport const removeElements = (nodes: NodeCollection): void => {\r\n if (isArrayLike(nodes)) {\r\n each(from(nodes), (e) => removeElements(e));\r\n } else if (nodes) {\r\n const parentElm = parent(nodes);\r\n parentElm && parentElm.removeChild(nodes);\r\n }\r\n};\r\n\r\n/**\r\n * Inserts Nodes before the given preferredAnchor element.\r\n * @param parentElm The parent of the preferredAnchor element or the element which shall be the parent of the inserted Nodes.\r\n * @param preferredAnchor The element before which the Nodes shall be inserted or null if the elements shall be appended at the end.\r\n * @param insertedElms The Nodes which shall be inserted.\r\n * @returns A function which removes the inserted nodes.\r\n */\r\nconst before = (\r\n parentElm: ManipulationTarget,\r\n preferredAnchor: ManipulationTarget,\r\n insertedElms: NodeCollection\r\n): (() => void) => {\r\n if (insertedElms && parentElm) {\r\n let anchor: ManipulationTarget = preferredAnchor;\r\n let fragment: DocumentFragment | Node | null | undefined;\r\n\r\n if (isArrayLike(insertedElms)) {\r\n fragment = document.createDocumentFragment();\r\n\r\n // append all insertedElms to the fragment and if one of these is the anchor, change the anchor\r\n each(insertedElms, (insertedElm) => {\r\n if (insertedElm === anchor) {\r\n anchor = insertedElm.previousSibling;\r\n }\r\n fragment!.appendChild(insertedElm);\r\n });\r\n } else {\r\n fragment = insertedElms;\r\n }\r\n\r\n // if the preferred anchor isn't null set it to a valid anchor\r\n if (preferredAnchor) {\r\n if (!anchor) {\r\n anchor = parentElm.firstChild;\r\n } else if (anchor !== preferredAnchor) {\r\n anchor = anchor.nextSibling;\r\n }\r\n }\r\n\r\n parentElm.insertBefore(fragment, anchor || null);\r\n return () => removeElements(insertedElms);\r\n }\r\n return noop;\r\n};\r\n\r\n/**\r\n * Appends the given children at the end of the given Node.\r\n * @param node The Node to which the children shall be appended.\r\n * @param children The Nodes which shall be appended.\r\n * @returns A function which removes the inserted nodes.\r\n */\r\nexport const appendChildren = (node: ManipulationTarget, children: NodeCollection) =>\r\n before(node, null, children);\r\n\r\n/**\r\n * Prepends the given children at the start of the given Node.\r\n * @param node The Node to which the children shall be prepended.\r\n * @param children The Nodes which shall be prepended.\r\n * @returns A function which removes the inserted nodes.\r\n */\r\nexport const prependChildren = (node: ManipulationTarget, children: NodeCollection) =>\r\n before(node, node && node.firstChild, children);\r\n\r\n/**\r\n * Inserts the given Nodes before the given Node.\r\n * @param node The Node before which the given Nodes shall be inserted.\r\n * @param insertedNodes The Nodes which shall be inserted.\r\n * @returns A function which removes the inserted nodes.\r\n */\r\nexport const insertBefore = (node: ManipulationTarget, insertedNodes: NodeCollection) =>\r\n before(parent(node), node, insertedNodes);\r\n\r\n/**\r\n * Inserts the given Nodes after the given Node.\r\n * @param node The Node after which the given Nodes shall be inserted.\r\n * @param insertedNodes The Nodes which shall be inserted.\r\n * @returns A function which removes the inserted nodes.\r\n */\r\nexport const insertAfter = (node: ManipulationTarget, insertedNodes: NodeCollection) =>\r\n before(parent(node), node && node.nextSibling, insertedNodes);\r\n","import { each } from '../utils/array';\r\nimport { setAttrs } from './attribute';\r\nimport { contents } from './traversal';\r\nimport { removeElements } from './manipulation';\r\n\r\n/**\r\n * Creates a div DOM node.\r\n */\r\nexport const createDiv = (classNames?: string): HTMLDivElement => {\r\n const div = document.createElement('div');\r\n setAttrs(div, 'class', classNames);\r\n return div;\r\n};\r\n\r\n/**\r\n * Creates DOM nodes modeled after the passed html string and returns the root dom nodes as a array.\r\n * @param html The html string after which the DOM nodes shall be created.\r\n */\r\nexport const createDOM = (html: string): ReadonlyArray => {\r\n const createdDiv = createDiv();\r\n createdDiv.innerHTML = html.trim();\r\n\r\n return each(contents(createdDiv), (elm) => removeElements(elm));\r\n};\r\n","import type { PlainObject, StyleObject, StyleObjectKey, StyleObjectValue } from '~/typings';\r\nimport type { XY } from './offset';\r\nimport type { HTMLElementTarget } from './types';\r\nimport { wnd } from '../utils/alias';\r\nimport { each } from '../utils/array';\r\nimport { isString, isNumber, isObject } from '../utils/types';\r\n\r\nexport interface TRBL {\r\n t: number;\r\n r: number;\r\n b: number;\r\n l: number;\r\n}\r\n\r\nconst customCssPropRegex = /^--/;\r\n\r\nconst getCSSVal = (computedStyle: CSSStyleDeclaration, prop: StyleObjectKey): string =>\r\n computedStyle.getPropertyValue(prop) || computedStyle[prop as any] || '';\r\n\r\nconst validFiniteNumber = (number: number) => {\r\n const notNaN = number || 0;\r\n return isFinite(notNaN) ? notNaN : 0;\r\n};\r\n\r\nconst parseToZeroOrNumber = (value?: string): number => validFiniteNumber(parseFloat(value || ''));\r\n\r\nexport const ratioToCssPercent = (ratio: number) =>\r\n `${(validFiniteNumber(ratio) * 100).toFixed(3)}%`;\r\n\r\nexport const numberToCssPx = (number: number) => `${validFiniteNumber(number)}px`;\r\n\r\nexport function setStyles(elm: HTMLElementTarget, styles: StyleObject): void {\r\n elm &&\r\n each(styles, (rawValue: StyleObjectValue, name) => {\r\n try {\r\n const elmStyle = elm.style;\r\n const value = isNumber(rawValue) ? numberToCssPx(rawValue) : (rawValue || '') + '';\r\n\r\n if (customCssPropRegex.test(name)) {\r\n elmStyle.setProperty(name, value);\r\n } else {\r\n elmStyle[name as any] = value;\r\n }\r\n } catch {}\r\n });\r\n}\r\n\r\nexport function getStyles(\r\n elm: HTMLElementTarget,\r\n styles: Array,\r\n pseudoElm?: string | null | undefined\r\n): Partial>;\r\nexport function getStyles(\r\n elm: HTMLElementTarget,\r\n styles: StyleObjectKey,\r\n pseudoElm?: string | null | undefined\r\n): string;\r\nexport function getStyles(\r\n elm: HTMLElementTarget,\r\n styles: Array | StyleObjectKey,\r\n pseudoElm?: string | null | undefined\r\n): Partial> | string {\r\n const getSingleStyle = isString(styles);\r\n let getStylesResult: string | PlainObject = getSingleStyle ? '' : {};\r\n\r\n if (elm) {\r\n const computedStyle = wnd.getComputedStyle(elm, pseudoElm) || elm.style;\r\n getStylesResult = getSingleStyle\r\n ? getCSSVal(computedStyle, styles)\r\n : styles.reduce((result, key) => {\r\n result[key] = getCSSVal(computedStyle, key);\r\n return result;\r\n }, getStylesResult as PlainObject);\r\n }\r\n return getStylesResult;\r\n}\r\n\r\nexport const getDirectionIsRTL = (elm: HTMLElementTarget): boolean =>\r\n getStyles(elm, 'direction') === 'rtl';\r\n\r\n/**\r\n * Returns the top right bottom left values of the passed css property.\r\n * @param elm The element of which the values shall be returned.\r\n * @param propertyPrefix The css property prefix. (e.g. \"border\")\r\n * @param propertySuffix The css property suffix. (e.g. \"width\")\r\n */\r\nexport const topRightBottomLeft = (\r\n elm?: HTMLElementTarget,\r\n propertyPrefix?: string,\r\n propertySuffix?: string\r\n): TRBL => {\r\n const finalPrefix = propertyPrefix ? `${propertyPrefix}-` : '';\r\n const finalSuffix = propertySuffix ? `-${propertySuffix}` : '';\r\n const top = `${finalPrefix}top${finalSuffix}` as StyleObjectKey;\r\n const right = `${finalPrefix}right${finalSuffix}` as StyleObjectKey;\r\n const bottom = `${finalPrefix}bottom${finalSuffix}` as StyleObjectKey;\r\n const left = `${finalPrefix}left${finalSuffix}` as StyleObjectKey;\r\n const result = getStyles(elm, [top, right, bottom, left]);\r\n return {\r\n t: parseToZeroOrNumber(result[top]),\r\n r: parseToZeroOrNumber(result[right]),\r\n b: parseToZeroOrNumber(result[bottom]),\r\n l: parseToZeroOrNumber(result[left]),\r\n };\r\n};\r\n\r\nexport const getTrasformTranslateValue = (\r\n value: string | number | XY,\r\n isHorizontal?: boolean\r\n) =>\r\n `translate${\r\n isObject(value) ? `(${value.x},${value.y})` : `${isHorizontal ? 'X' : 'Y'}(${value})`\r\n }`;\r\n","import type { HTMLElementTarget } from './types';\r\nimport { getStyles } from './style';\r\nimport { mathRound, wnd } from '../utils/alias';\r\nimport { bind } from '../utils/function';\r\nimport { strHeight, strWidth } from '../utils/strings';\r\n\r\nexport interface WH {\r\n w: T;\r\n h: T;\r\n}\r\n\r\nconst elementHasDimensions = (elm: HTMLElement): boolean =>\r\n !!(elm.offsetWidth || elm.offsetHeight || elm.getClientRects().length);\r\nconst zeroObj: WH = {\r\n w: 0,\r\n h: 0,\r\n};\r\n\r\nconst getElmWidthHeightProperty = (\r\n property: E extends HTMLElement ? 'client' | 'offset' | 'scroll' : 'inner',\r\n elm: E | false | null | undefined\r\n): Readonly =>\r\n elm\r\n ? {\r\n w: (elm as any)[`${property}Width`],\r\n h: (elm as any)[`${property}Height`],\r\n }\r\n : zeroObj;\r\n\r\n/**\r\n * Returns the window inner- width and height.\r\n */\r\nexport const windowSize = (customWnd?: Window): Readonly =>\r\n getElmWidthHeightProperty('inner', customWnd || wnd);\r\n\r\n/**\r\n * Returns the scroll- width and height of the passed element. If the element is null the width and height values are 0.\r\n * @param elm The element of which the scroll- width and height shall be returned.\r\n */\r\nexport const offsetSize = bind(getElmWidthHeightProperty, 'offset') satisfies (\r\n elm: HTMLElementTarget\r\n) => Readonly;\r\n\r\n/**\r\n * Returns the client- width and height of the passed element. If the element is null the width and height values are 0.\r\n * @param elm The element of which the client- width and height shall be returned.\r\n */\r\nexport const clientSize = bind(getElmWidthHeightProperty, 'client') satisfies (\r\n elm: HTMLElementTarget\r\n) => Readonly;\r\n\r\n/**\r\n * Returns the client- width and height of the passed element. If the element is null the width and height values are 0.\r\n * @param elm The element of which the client- width and height shall be returned.\r\n */\r\nexport const scrollSize = bind(getElmWidthHeightProperty, 'scroll') satisfies (\r\n elm: HTMLElementTarget\r\n) => Readonly;\r\n\r\n/**\r\n * Returns the fractional- width and height of the passed element. If the element is null the width and height values are 0.\r\n * @param elm The element of which the fractional- width and height shall be returned.\r\n */\r\nexport const fractionalSize = (elm: HTMLElementTarget): Readonly => {\r\n const cssWidth = parseFloat(getStyles(elm, strWidth)) || 0;\r\n const cssHeight = parseFloat(getStyles(elm, strHeight)) || 0;\r\n return {\r\n w: cssWidth - mathRound(cssWidth),\r\n h: cssHeight - mathRound(cssHeight),\r\n };\r\n};\r\n\r\n/**\r\n * Returns the BoundingClientRect of the passed element.\r\n * @param elm The element of which the BoundingClientRect shall be returned.\r\n */\r\nexport const getBoundingClientRect = (elm: HTMLElement): DOMRect => elm.getBoundingClientRect();\r\n\r\n/**\r\n * Determines whether the passed element has any dimensions.\r\n * @param elm The element.\r\n */\r\nexport const hasDimensions = (elm: HTMLElementTarget): boolean =>\r\n !!elm && elementHasDimensions(elm);\r\n\r\n/**\r\n * Determines whether the passed DOM Rect has any dimensions.\r\n */\r\nexport const domRectHasDimensions = (rect?: DOMRectReadOnly | false | null) =>\r\n !!(rect && (rect[strHeight] || rect[strWidth]));\r\n\r\n/**\r\n * Determines whether current DOM Rect has appeared according the the previous dom rect..\r\n * @param currContentRect The current DOM Rect.\r\n * @param prevContentRect The previous DOM Rect.\r\n * @returns Whether the dom rect appeared.\r\n */\r\nexport const domRectAppeared = (\r\n currContentRect: DOMRectReadOnly | false | null | undefined,\r\n prevContentRect: DOMRectReadOnly | false | null | undefined\r\n) => {\r\n const rectHasDimensions = domRectHasDimensions(currContentRect);\r\n const rectHadDimensions = domRectHasDimensions(prevContentRect);\r\n return !rectHadDimensions && rectHasDimensions;\r\n};\r\n","import type { DomTokens } from './attribute';\r\nimport { each, runEachAndClear } from '../utils/array';\r\nimport { bind } from '../utils/function';\r\nimport { keys } from '../utils';\r\nimport { getDomTokensArray } from './attribute';\r\n\r\nexport interface EventListenerOptions {\r\n _capture?: boolean;\r\n _passive?: boolean;\r\n _once?: boolean;\r\n}\r\n\r\nexport type EventListenerMap = {\r\n [eventNames: string]: (event: Event) => any;\r\n};\r\n\r\n/**\r\n * Removes the passed event listener for the passed event names with the passed options.\r\n * @param target The element from which the listener shall be removed.\r\n * @param eventNames The eventsnames for which the listener shall be removed.\r\n * @param listener The listener which shall be removed.\r\n * @param capture The options of the removed listener.\r\n */\r\nexport const removeEventListener = (\r\n target: EventTarget,\r\n eventNames: DomTokens,\r\n listener: (event: T) => any,\r\n capture?: boolean\r\n): void => {\r\n each(getDomTokensArray(eventNames), (eventName) => {\r\n target.removeEventListener(eventName, listener as EventListener, capture);\r\n });\r\n};\r\n\r\n/**\r\n * Adds the passed event listener for the passed event names with the passed options.\r\n * @param target The element to which the listener shall be added.\r\n * @param eventNames The eventsnames for which the listener shall be called.\r\n * @param listener The listener which is called on the eventnames.\r\n * @param options The options of the added listener.\r\n */\r\nexport const addEventListener = (\r\n target: EventTarget,\r\n eventNames: DomTokens,\r\n listener: (event: T) => any,\r\n options?: EventListenerOptions\r\n): (() => void) => {\r\n const passive = (options && options._passive) ?? true;\r\n const capture = (options && options._capture) || false;\r\n const once = (options && options._once) || false;\r\n const nativeOptions: AddEventListenerOptions = {\r\n passive,\r\n capture,\r\n };\r\n\r\n return bind(\r\n runEachAndClear,\r\n getDomTokensArray(eventNames).map((eventName) => {\r\n const finalListener = (\r\n once\r\n ? (evt: T) => {\r\n removeEventListener(target, eventName, finalListener, capture);\r\n listener(evt);\r\n }\r\n : listener\r\n ) as EventListener;\r\n\r\n target.addEventListener(eventName, finalListener, nativeOptions);\r\n return bind(removeEventListener, target, eventName, finalListener, capture);\r\n })\r\n );\r\n};\r\n\r\n/**\r\n * Adds the passed event listeners for the passed event names with the passed options.\r\n * @param target The element to which the listener shall be added.\r\n * @param eventListenerMap A map which descirbes the event names and event listeners to be added.\r\n * @param options The options of the added listeners.\r\n */\r\nexport const addEventListeners = (\r\n target: EventTarget,\r\n eventListenerMap: EventListenerMap,\r\n options?: EventListenerOptions\r\n): (() => void) =>\r\n bind(\r\n runEachAndClear,\r\n keys(eventListenerMap).map((eventNames) =>\r\n addEventListener(target, eventNames, eventListenerMap[eventNames], options)\r\n )\r\n );\r\n\r\n/**\r\n * Shorthand for the stopPropagation event Method.\r\n * @param evt The event of which the stopPropagation method shall be called.\r\n */\r\nexport const stopPropagation = (evt: Event): void => evt.stopPropagation();\r\n\r\n/**\r\n * Shorthand for the preventDefault event Method.\r\n * @param evt The event of which the preventDefault method shall be called.\r\n */\r\nexport const preventDefault = (evt: Event): void => evt.preventDefault();\r\n\r\n/**\r\n * Shorthand for the stopPropagation and preventDefault event Method.\r\n * @param evt The event of which the stopPropagation and preventDefault methods shall be called.\r\n */\r\nexport const stopAndPrevent = (evt: Event): void =>\r\n (stopPropagation(evt) as undefined) || (preventDefault(evt) as undefined);\r\n","import type { HTMLElementTarget } from './types';\r\nimport { getBoundingClientRect } from './dimensions';\r\nimport { wnd } from '../utils/alias';\r\n\r\nexport interface XY {\r\n x: T;\r\n y: T;\r\n}\r\n\r\nconst zeroObj: XY = {\r\n x: 0,\r\n y: 0,\r\n};\r\n\r\n/**\r\n * Returns the offset- left and top coordinates of the passed element relative to the document. If the element is null the top and left values are 0.\r\n * @param elm The element of which the offset- top and left coordinates shall be returned.\r\n */\r\nexport const absoluteCoordinates = (elm: HTMLElementTarget): Readonly => {\r\n const rect = elm && getBoundingClientRect(elm);\r\n return rect\r\n ? {\r\n x: rect.left + wnd.scrollX,\r\n y: rect.top + wnd.scrollY,\r\n }\r\n : zeroObj;\r\n};\r\n\r\n/**\r\n * Returns the offset- left and top coordinates of the passed element. If the element is null the top and left values are 0.\r\n * @param elm The element of which the offset- top and left coordinates shall be returned.\r\n */\r\nexport const offsetCoordinates = (elm: HTMLElementTarget): Readonly =>\r\n elm\r\n ? {\r\n x: elm.offsetLeft,\r\n y: elm.offsetTop,\r\n }\r\n : zeroObj;\r\n","import type { Env } from '~/environment';\r\nimport type { XY } from './offset';\r\nimport { capNumber, isNumber } from '../utils';\r\n\r\nexport type RTLScrollBehavior = Env['_rtlScrollBehavior'] | false | null | undefined;\r\n\r\n/**\r\n * Transforms a normalized scroll position to a RTL compatilbe scroll position value or vice versa (depending on the input format).\r\n * @param scrollPosition The scroll position value.\r\n * @param overflowAmount The (normalized) overflow amount value.\r\n * @param rtlScrollBehavior The RTL scroll behavior or `falsy` if the rtl scroll behavior doesn't apply.\r\n * @returns The input scroll position, just converted.\r\n * If the input `scrollPosition` is normalized the raw (RTL Compatible) format is returned.\r\n * If the input `scrollPosition` is raw (RTL Compatible) the normalized format is returned.\r\n */\r\nexport const convertScrollPosition = (\r\n scrollPosition: number,\r\n overflowAmount: number,\r\n rtlScrollBehavior?: RTLScrollBehavior\r\n) =>\r\n rtlScrollBehavior\r\n ? rtlScrollBehavior.n\r\n ? -scrollPosition + 0 // +0 avoids negative zero (-0) as a result\r\n : rtlScrollBehavior.i\r\n ? overflowAmount - scrollPosition\r\n : scrollPosition\r\n : scrollPosition;\r\n\r\n/**\r\n * Gets the raw (RTL compatilbe) scroll boundaries from the normalized overflow amount.\r\n * @param overflowAmount The normalzed overflow amount value.\r\n * @param rtlScrollBehavior The RTL scroll behavior or `falsy` if the rtl scroll behavior doesn't apply.\r\n * @returns The raw (RTL compatible) scroll boundaries. (min value will scroll to start (0%) and max will scroll to end (100%))\r\n */\r\nexport const getRawScrollBounds = (\r\n overflowAmount: number,\r\n rtlScrollBehavior?: RTLScrollBehavior\r\n): [min: number, max: number] => [\r\n convertScrollPosition(0, overflowAmount, rtlScrollBehavior),\r\n convertScrollPosition(overflowAmount, overflowAmount, rtlScrollBehavior),\r\n];\r\n\r\n/**\r\n * Gets the scroll ratio of the current raw (RTL compatilbe) scroll position.\r\n * @param rawScrollPosition The raw (RTL compatible) scroll position.\r\n * @param overflowAmount The normalized overflow amount.\r\n * @param rtlScrollBehavior The RTL scroll behavior or `falsy` if the rtl scroll behavior doesn't apply.\r\n * @returns The scroll ratio of the current scroll position 0..1.\r\n */\r\nexport const getRawScrollRatio = (\r\n rawScrollPosition: number,\r\n overflowAmount: number,\r\n rtlScrollBehavior?: RTLScrollBehavior\r\n) =>\r\n capNumber(\r\n 0,\r\n 1,\r\n convertScrollPosition(rawScrollPosition, overflowAmount, rtlScrollBehavior) / overflowAmount ||\r\n 0\r\n );\r\n\r\n/**\r\n * Scroll the passed element to the passed position.\r\n * @param elm The element to be scrolled.\r\n * @param position The scroll position.\r\n */\r\nexport const scrollElementTo = (\r\n elm: HTMLElement,\r\n position: Partial | number | false | null | undefined\r\n): void => {\r\n const { x, y } = isNumber(position) ? { x: position, y: position } : position || {};\r\n isNumber(x) && (elm.scrollLeft = x);\r\n isNumber(y) && (elm.scrollTop = y);\r\n};\r\n\r\n/**\r\n * Scroll the passed element to the passed position.\r\n * @param elm The element to be scrolled.\r\n * @param position The scroll position.\r\n */\r\nexport const getElmentScroll = (elm: HTMLElement): Readonly => ({\r\n x: elm.scrollLeft,\r\n y: elm.scrollTop,\r\n});\r\n","import { isBoolean, isFunction, isString } from './utils/types';\r\nimport { keys } from './utils/object';\r\nimport { each, push, from, isEmptyArray, runEachAndClear, createOrKeepArray } from './utils/array';\r\nimport { bind } from './utils/function';\r\n\r\nexport type EventListener, N extends keyof EventArgs> = (\r\n ...args: EventArgs[N]\r\n) => void;\r\n\r\nexport type EventListeners> = {\r\n [K in keyof EventArgs]?: EventListener | EventListener[] | null;\r\n};\r\n\r\nexport type RemoveEvent> = {\r\n (name?: N, listener?: EventListener): void;\r\n (name?: N, listener?: EventListener[]): void;\r\n (\r\n name?: N,\r\n listener?: EventListener | EventListener[]\r\n ): void;\r\n};\r\n\r\nexport type AddEvent> = {\r\n (eventListeners: EventListeners, pure?: boolean): () => void;\r\n (name: N, listener: EventListener): () => void;\r\n (name: N, listener: EventListener[]): () => void;\r\n (\r\n nameOrEventListeners: N | EventListeners,\r\n listener?: EventListener | EventListener[] | boolean\r\n ): () => void;\r\n};\r\n\r\nexport type TriggerEvent> = {\r\n (name: N, args: EventArgs[N]): void;\r\n};\r\n\r\nexport type EventListenerHub> = [\r\n AddEvent,\r\n RemoveEvent,\r\n TriggerEvent\r\n];\r\n\r\nconst manageListener = , N extends keyof EventArgs>(\r\n callback: (listener?: EventListener) => void,\r\n listener?: EventListener | EventListener[]\r\n) => {\r\n each(createOrKeepArray(listener), callback);\r\n};\r\n\r\nexport const createEventListenerHub = >(\r\n initialEventListeners?: EventListeners\r\n): EventListenerHub => {\r\n const events = new Map>>();\r\n\r\n const removeEvent: RemoveEvent = (name, listener) => {\r\n if (name) {\r\n const eventSet = events.get(name);\r\n manageListener((currListener) => {\r\n if (eventSet) {\r\n eventSet[currListener ? 'delete' : 'clear'](currListener! as any);\r\n }\r\n }, listener);\r\n } else {\r\n events.forEach((eventSet) => {\r\n eventSet.clear();\r\n });\r\n events.clear();\r\n }\r\n };\r\n\r\n const addEvent: AddEvent = (\r\n nameOrEventListeners: keyof EventArgs | EventListeners,\r\n listenerOrPure?:\r\n | EventListener\r\n | EventListener[]\r\n | boolean\r\n ) => {\r\n if (isString(nameOrEventListeners)) {\r\n const eventSet = events.get(nameOrEventListeners) || new Set();\r\n events.set(nameOrEventListeners, eventSet);\r\n\r\n manageListener((currListener) => {\r\n isFunction(currListener) && eventSet.add(currListener);\r\n }, listenerOrPure as Exclude);\r\n\r\n return bind(\r\n removeEvent,\r\n nameOrEventListeners,\r\n listenerOrPure as Exclude\r\n );\r\n }\r\n if (isBoolean(listenerOrPure) && listenerOrPure) {\r\n removeEvent();\r\n }\r\n\r\n const eventListenerKeys = keys(nameOrEventListeners) as (keyof EventListeners)[];\r\n const offFns: (() => void)[] = [];\r\n each(eventListenerKeys, (key) => {\r\n const eventListener = (nameOrEventListeners as EventListeners)[key];\r\n eventListener && push(offFns, addEvent(key, eventListener));\r\n });\r\n\r\n return bind(runEachAndClear, offFns);\r\n };\r\n\r\n const triggerEvent: TriggerEvent = (name, args) => {\r\n each(from(events.get(name)), (event) => {\r\n if (args && !isEmptyArray(args)) {\r\n (event as (...eventArgs: EventArgs[keyof EventArgs]) => void).apply(0, args);\r\n } else {\r\n (event as () => void)();\r\n }\r\n });\r\n };\r\n\r\n addEvent(initialEventListeners || {});\r\n\r\n return [addEvent, removeEvent, triggerEvent];\r\n};\r\n","import {\r\n assignDeep,\r\n each,\r\n isObject,\r\n keys,\r\n isArray,\r\n hasOwnProperty,\r\n isFunction,\r\n isEmptyObject,\r\n concat,\r\n} from '~/support';\r\nimport type { DeepPartial, DeepReadonly } from '~/typings';\r\n\r\nexport type OptionsField = string;\r\n\r\nexport type OptionsPrimitiveValue =\r\n | boolean\r\n | number\r\n | string\r\n | Array\r\n | ReadonlyArray\r\n | [any]\r\n | [any, ...any[]]\r\n | ((this: any, ...args: any[]) => any)\r\n | null;\r\n\r\nexport type OptionsObject = {\r\n [field: OptionsField]: OptionsPrimitiveValue | OptionsObject;\r\n};\r\n\r\ntype OptionsObjectFieldNameTuples = T extends OptionsPrimitiveValue\r\n ? []\r\n : {\r\n [K in Extract]: [K, ...OptionsObjectFieldNameTuples];\r\n }[Extract];\r\n\r\ntype JoinOptionsObjectFieldTuples<\r\n T extends OptionsField[],\r\n IncompletePath extends boolean = false\r\n> = T extends [infer F]\r\n ? F\r\n : T extends [infer F, ...infer R]\r\n ? F extends OptionsField\r\n ?\r\n | (IncompletePath extends true ? F : never)\r\n | `${F}.${JoinOptionsObjectFieldTuples>}`\r\n : never\r\n : OptionsField;\r\n\r\ntype SplitJoinedOptionsObjectFieldTuples = string extends S\r\n ? OptionsField[]\r\n : S extends ''\r\n ? []\r\n : S extends `${infer T}.${infer U}`\r\n ? [T, ...SplitJoinedOptionsObjectFieldTuples]\r\n : [S];\r\n\r\ntype OptionsObjectFieldTuplesType = T extends [infer F]\r\n ? F extends keyof O\r\n ? O[F]\r\n : never\r\n : T extends [infer F, ...infer R]\r\n ? F extends keyof O\r\n ? O[F] extends OptionsPrimitiveValue\r\n ? O[F]\r\n : OptionsObjectFieldTuplesType>\r\n : never\r\n : never;\r\n\r\ntype OptionsObjectFieldPath = JoinOptionsObjectFieldTuples<\r\n OptionsObjectFieldNameTuples,\r\n true\r\n>;\r\n\r\ntype OptionsObjectFieldPathType<\r\n O extends OptionsObject,\r\n P extends string\r\n> = OptionsObjectFieldTuplesType>;\r\n\r\nconst opsStringify = (value: any) =>\r\n JSON.stringify(value, (_, val) => {\r\n if (isFunction(val)) {\r\n throw 0;\r\n }\r\n return val;\r\n });\r\n\r\nconst getPropByPath = (obj: any, path: string): T =>\r\n obj\r\n ? `${path}`\r\n .split('.')\r\n .reduce((o, prop) => (o && hasOwnProperty(o, prop) ? o[prop] : undefined), obj)\r\n : undefined;\r\n\r\n/**\r\n * The overflow behavior of an axis.\r\n */\r\nexport type OverflowBehavior =\r\n /** No scrolling is possible and the content is clipped. */\r\n | 'hidden'\r\n /** No scrolling is possible and the content isn't clipped. */\r\n | 'visible'\r\n /** Scrolling is possible if there is an overflow. */\r\n | 'scroll'\r\n /**\r\n * If the other axis has no overflow the behavior is similar to `visible`.\r\n * If the other axis has overflow the behavior is similar to `hidden`.\r\n */\r\n | 'visible-hidden'\r\n /**\r\n * If the other axis has no overflow the behavior is similar to `visible`.\r\n * If the other axis has overflow the behavior is similar to `scroll`.\r\n */\r\n | 'visible-scroll';\r\n\r\n/**\r\n * The scrollbars visibility behavior.\r\n */\r\nexport type ScrollbarsVisibilityBehavior =\r\n /** The scrollbars are always visible. */\r\n | 'visible'\r\n /** The scrollbars are always hidden. */\r\n | 'hidden'\r\n /** The scrollbars are only visibile if there is overflow. */\r\n | 'auto';\r\n\r\n/**\r\n * The scrollbars auto hide behavior\r\n */\r\nexport type ScrollbarsAutoHideBehavior =\r\n /** The scrollbars are never hidden automatically. */\r\n | 'never'\r\n /** The scrollbars are hidden unless the user scrolls. */\r\n | 'scroll'\r\n /** The scrollbars are hidden unless the pointer moves in the host element or the user scrolls. */\r\n | 'move'\r\n /** The scrollbars are hidden if the pointer leaves the host element or unless the user scrolls. */\r\n | 'leave';\r\n\r\n/**\r\n * The options of a OverlayScrollbars instance.\r\n */\r\nexport type Options = {\r\n /** Whether the padding shall be absolute. */\r\n paddingAbsolute: boolean;\r\n /** Whether to show the native scrollbars. Has only an effect it the native scrollbars are overlaid. */\r\n showNativeOverlaidScrollbars: boolean;\r\n /** Customizes the automatic update behavior. */\r\n update: {\r\n /**\r\n * The given Event(s) from the elements with the given selector(s) will trigger an update.\r\n * Useful for everything the MutationObserver and ResizeObserver can't detect\r\n * e.g.: and Images `load` event or the `transitionend` / `animationend` events.\r\n */\r\n elementEvents: Array<[elementSelector: string, eventNames: string]> | null;\r\n /**\r\n * The debounce which is used to detect content changes.\r\n * If a tuple is provided you can customize the `timeout` and the `maxWait` in milliseconds.\r\n * If a single number customizes only the `timeout`.\r\n *\r\n * If the `timeout` is `0`, a debounce still exists. (its executed via `requestAnimationFrame`).\r\n */\r\n debounce: [timeout: number, maxWait: number] | number | null;\r\n /**\r\n * HTML attributes which will trigger an update if they're changed.\r\n * Basic attributes like `id`, `class`, `style` etc. are always observed and doesn't have to be added explicitly.\r\n */\r\n attributes: string[] | null;\r\n /**\r\n * A function which makes it possible to ignore a content mutation or null if nothing shall be ignored.\r\n * @param mutation The MutationRecord from the MutationObserver.\r\n * @returns A Truthy value if the mutation shall be ignored, a falsy value otherwise.\r\n */\r\n ignoreMutation: ((mutation: MutationRecord) => any) | null;\r\n };\r\n /** Customizes the overflow behavior per axis. */\r\n overflow: {\r\n /** The overflow behavior of the horizontal (x) axis. */\r\n x: OverflowBehavior;\r\n /** The overflow behavior of the vertical (y) axis. */\r\n y: OverflowBehavior;\r\n };\r\n /** Customizes appearance of the scrollbars. */\r\n scrollbars: {\r\n /**\r\n * The scrollbars theme.\r\n * The theme value will be added as `class` to all `scrollbar` elements of the instance.\r\n */\r\n theme: string | null;\r\n /** The scrollbars visibility behavior. */\r\n visibility: ScrollbarsVisibilityBehavior;\r\n /** The scrollbars auto hide behavior. */\r\n autoHide: ScrollbarsAutoHideBehavior;\r\n /** The scrollbars auto hide delay in milliseconds. */\r\n autoHideDelay: number;\r\n /** Whether the scrollbars auto hide behavior is suspended until a scroll happened. */\r\n autoHideSuspend: boolean;\r\n /** Whether its possible to drag the handle of a scrollbar to scroll the viewport. */\r\n dragScroll: boolean;\r\n /** Whether its possible to click the track of a scrollbar to scroll the viewport. */\r\n clickScroll: boolean;\r\n /**\r\n * An array of pointer types which shall be supported.\r\n * Common pointer types are: `mouse`, `pen` and `touch`.\r\n * https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType\r\n */\r\n pointers: string[] | null;\r\n };\r\n};\r\n\r\nexport type ReadonlyOptions = DeepReadonly;\r\n\r\nexport type PartialOptions = DeepPartial;\r\n\r\nexport type OptionsCheckFn =

>(\r\n path: P\r\n) => [value: OptionsObjectFieldPathType, changed: boolean];\r\n\r\nexport const defaultOptions: ReadonlyOptions = {\r\n paddingAbsolute: false,\r\n showNativeOverlaidScrollbars: false,\r\n update: {\r\n elementEvents: [['img', 'load']],\r\n debounce: [0, 33],\r\n attributes: null,\r\n ignoreMutation: null,\r\n },\r\n overflow: {\r\n x: 'scroll',\r\n y: 'scroll',\r\n },\r\n scrollbars: {\r\n theme: 'os-theme-dark',\r\n visibility: 'auto',\r\n autoHide: 'never',\r\n autoHideDelay: 1300,\r\n autoHideSuspend: false,\r\n dragScroll: true,\r\n clickScroll: false,\r\n pointers: ['mouse', 'touch', 'pen'],\r\n },\r\n} satisfies OptionsObject & Options;\r\n\r\nexport const getOptionsDiff = (currOptions: T, newOptions: DeepPartial): DeepPartial => {\r\n const diff: DeepPartial = {};\r\n const optionsKeys = concat(keys(newOptions), keys(currOptions)) as Array<\r\n keyof T & keyof DeepPartial\r\n >;\r\n\r\n each(optionsKeys, (optionKey) => {\r\n const currOptionValue = currOptions[optionKey];\r\n const newOptionValue = newOptions[optionKey];\r\n\r\n if (isObject(currOptionValue) && isObject(newOptionValue)) {\r\n assignDeep((diff[optionKey] = {} as any), getOptionsDiff(currOptionValue, newOptionValue));\r\n // delete empty nested objects\r\n if (isEmptyObject(diff[optionKey])) {\r\n delete diff[optionKey];\r\n }\r\n } else if (hasOwnProperty(newOptions, optionKey) && newOptionValue !== currOptionValue) {\r\n let isDiff = true;\r\n\r\n if (isArray(currOptionValue) || isArray(newOptionValue)) {\r\n try {\r\n if (opsStringify(currOptionValue) === opsStringify(newOptionValue)) {\r\n isDiff = false;\r\n }\r\n } catch {}\r\n }\r\n\r\n if (isDiff) {\r\n diff[optionKey] = newOptionValue;\r\n }\r\n }\r\n });\r\n\r\n return diff;\r\n};\r\n\r\nexport const createOptionCheck =\r\n (\r\n options: T,\r\n changedOptions: DeepPartial,\r\n force?: boolean\r\n ): OptionsCheckFn =>\r\n (path) =>\r\n [getPropByPath(options, path), force || getPropByPath(changedOptions, path) !== undefined];\r\n","const dataAttributePrefix = `data-overlayscrollbars`;\r\n\r\n// environment\r\nexport const classNameEnvironment = 'os-environment';\r\nexport const classNameEnvironmentScrollbarHidden = `${classNameEnvironment}-scrollbar-hidden`;\r\n\r\n// initialize\r\nexport const dataAttributeInitialize = `${dataAttributePrefix}-initialize`;\r\n\r\n// host\r\nexport const dataAttributeHost = dataAttributePrefix;\r\nexport const dataAttributeHostOverflowX = `${dataAttributeHost}-overflow-x`;\r\nexport const dataAttributeHostOverflowY = `${dataAttributeHost}-overflow-y`;\r\nexport const dataValueHostOverflowVisible = 'overflowVisible';\r\nexport const dataValueHostScrollbarHidden = 'scrollbarHidden';\r\nexport const dataValueHostScrollbarPressed = 'scrollbarPressed';\r\nexport const dataValueHostUpdating = 'updating';\r\nexport const dataValueHostHtmlBody = 'body';\r\n\r\n// viewport\r\nexport const dataAttributeViewport = `${dataAttributePrefix}-viewport`;\r\nexport const dataValueViewportArrange = 'arrange';\r\nexport const dataValueViewportScrollbarHidden = 'scrollbarHidden';\r\nexport const dataValueViewportOverflowVisible = dataValueHostOverflowVisible;\r\n\r\n// padding\r\nexport const dataAttributePadding = `${dataAttributePrefix}-padding`;\r\nexport const dataValuePaddingOverflowVisible = dataValueViewportOverflowVisible;\r\n\r\n// content\r\nexport const dataAttributeContent = `${dataAttributePrefix}-content`;\r\n\r\n// size observer\r\nexport const classNameSizeObserver = 'os-size-observer';\r\nexport const classNameSizeObserverAppear = `${classNameSizeObserver}-appear`;\r\nexport const classNameSizeObserverListener = `${classNameSizeObserver}-listener`;\r\nexport const classNameSizeObserverListenerScroll = `${classNameSizeObserverListener}-scroll`;\r\nexport const classNameSizeObserverListenerItem = `${classNameSizeObserverListener}-item`;\r\nexport const classNameSizeObserverListenerItemFinal = `${classNameSizeObserverListenerItem}-final`;\r\n\r\n// trinsic observer\r\nexport const classNameTrinsicObserver = 'os-trinsic-observer';\r\n\r\n// scrollbars\r\nexport const classNameScrollbarThemeNone = 'os-theme-none';\r\nexport const classNameScrollbar = 'os-scrollbar';\r\nexport const classNameScrollbarRtl = `${classNameScrollbar}-rtl`;\r\nexport const classNameScrollbarHorizontal = `${classNameScrollbar}-horizontal`;\r\nexport const classNameScrollbarVertical = `${classNameScrollbar}-vertical`;\r\nexport const classNameScrollbarTrack = `${classNameScrollbar}-track`;\r\nexport const classNameScrollbarHandle = `${classNameScrollbar}-handle`;\r\nexport const classNameScrollbarVisible = `${classNameScrollbar}-visible`;\r\nexport const classNameScrollbarCornerless = `${classNameScrollbar}-cornerless`;\r\nexport const classNameScrollbarTransitionless = `${classNameScrollbar}-transitionless`;\r\nexport const classNameScrollbarInteraction = `${classNameScrollbar}-interaction`;\r\nexport const classNameScrollbarUnusable = `${classNameScrollbar}-unusable`;\r\nexport const classNameScrollbarAutoHide = `${classNameScrollbar}-auto-hide`;\r\nexport const classNameScrollbarAutoHideHidden = `${classNameScrollbarAutoHide}-hidden`;\r\nexport const classNameScrollbarWheel = `${classNameScrollbar}-wheel`;\r\nexport const classNameScrollbarTrackInteractive = `${classNameScrollbarTrack}-interactive`;\r\nexport const classNameScrollbarHandleInteractive = `${classNameScrollbarHandle}-interactive`;\r\n","import { each, keys } from '~/support';\r\nimport type { OverlayScrollbars, OverlayScrollbarsStatic } from '~/overlayscrollbars';\r\nimport type { EventListener, EventListenerArgs, EventListeners } from '..';\r\n\r\nexport type PluginModuleInstance = Record;\r\n\r\nexport type InstancePluginEvent = {\r\n /**\r\n * Adds event listeners to the instance.\r\n * @param eventListeners An object which contains the added listeners.\r\n * @returns Returns a function which removes the added listeners.\r\n */\r\n (eventListeners: EventListeners): () => void;\r\n /**\r\n * Adds a single event listener to the instance.\r\n * @param name The name of the event.\r\n * @param listener The listener which is invoked on that event.\r\n * @returns Returns a function which removes the added listeners.\r\n */\r\n (name: N, listener: EventListener): () => void;\r\n /**\r\n * Adds multiple event listeners to the instance.\r\n * @param name The name of the event.\r\n * @param listener The listeners which are invoked on that event.\r\n * @returns Returns a function which removes the added listeners.\r\n */\r\n (name: N, listener: EventListener[]): () => void;\r\n};\r\n\r\n/**\r\n * Describes a OverlayScrollbars plugin module.\r\n * Plugin modules must be side-effect free and deterministic. (same input produces same output)\r\n */\r\nexport type PluginModule<\r\n S extends PluginModuleInstance | void = PluginModuleInstance | void,\r\n I extends PluginModuleInstance | void = PluginModuleInstance | void\r\n> = (S extends PluginModuleInstance\r\n ? {\r\n /**\r\n * Creates a plugin which is bound to the static object.\r\n * The function will be called once with the static object as soon as the plugin is registered.\r\n * The plugin can add new methods or fields to the passed static object.\r\n * @param osStatic The static object the plugin is bound to.\r\n * @returns The plugins instance object or a falsy value if the plugin doesn't need any instance object.\r\n */\r\n static: (osStatic: OverlayScrollbarsStatic) => S | void;\r\n }\r\n : object) &\r\n (I extends PluginModuleInstance\r\n ? {\r\n /**\r\n * Creates a A plugin which is bound to an instance.\r\n * The function will be called each time a new instance is created.\r\n * The plugin can add new methods or fields to the passed instance object.\r\n * @param osInstance The instance object the plugin is bound to.\r\n * @param event A function which adds events to the instance which can't be removed from outside the plugin. (instance events added with the `on` function can be removed with the optional `pure` parameter)\r\n * @param osStatic The static object the plugin is bound to.\r\n * @returns The plugins instance object or a falsy value if the plugin doesn't need any instance object.\r\n */\r\n instance: (\r\n osInstance: OverlayScrollbars,\r\n event: InstancePluginEvent,\r\n osStatic: OverlayScrollbarsStatic\r\n ) => I | void;\r\n }\r\n : object);\r\n\r\n/**\r\n * Describes a OverlayScrollbar plugin.\r\n */\r\nexport type Plugin<\r\n Name extends string = string,\r\n S extends PluginModuleInstance | void = PluginModuleInstance | void,\r\n I extends PluginModuleInstance | void = PluginModuleInstance | void\r\n> = {\r\n /** The field is the plugins name. Plugin names must be globally unique, please choose wisely. */\r\n [pluginName in Name]: PluginModule;\r\n};\r\n\r\n/**\r\n * Describes a OverlayScrollbar plugin which has only a static module.\r\n */\r\nexport type StaticPlugin<\r\n Name extends string = string,\r\n T extends PluginModuleInstance = PluginModuleInstance\r\n> = Plugin;\r\n\r\n/**\r\n * Describes a OverlayScrollbar plugin which has only a instance module.\r\n */\r\nexport type InstancePlugin<\r\n Name extends string = string,\r\n T extends PluginModuleInstance = PluginModuleInstance\r\n> = Plugin;\r\n\r\n/**\r\n * Infers the type of the static modules instance of the passed plugin.\r\n */\r\nexport type InferStaticPluginModuleInstance = T extends StaticPlugin<\r\n infer Name\r\n>\r\n ? T[Name]['static'] extends (...args: any[]) => any\r\n ? ReturnType\r\n : void\r\n : void;\r\n\r\n/**\r\n * Infers the type of the instance modules instance of the passed plugin.\r\n */\r\nexport type InferInstancePluginModuleInstance = T extends InstancePlugin<\r\n infer Name\r\n>\r\n ? T[Name]['instance'] extends (...args: any[]) => any\r\n ? ReturnType\r\n : void\r\n : void;\r\n\r\n/** All registered plugin modules. */\r\nexport const pluginModules: Record = {};\r\n\r\n/** All static plugin module instances. */\r\nexport const staticPluginModuleInstances: Record = {};\r\n\r\n/**\r\n * Adds plugins.\r\n * @param addedPlugin The plugin(s) to add.\r\n * @returns The added plugin modules of the registered plugins.\r\n */\r\nexport const addPlugins = (addedPlugin: Plugin[]) => {\r\n each(addedPlugin, (plugin) =>\r\n each(plugin, (_, key) => {\r\n pluginModules[key] = plugin[key];\r\n })\r\n );\r\n};\r\n\r\nexport const registerPluginModuleInstances = (\r\n plugin: Plugin,\r\n staticObj: OverlayScrollbarsStatic,\r\n instanceInfo?: [\r\n instanceObj: OverlayScrollbars,\r\n event: InstancePluginEvent,\r\n instancePluginMap?: Record\r\n ]\r\n): Array =>\r\n keys(plugin).map((name) => {\r\n const { static: osStatic, instance: osInstance } = (\r\n plugin as Plugin\r\n )[name];\r\n const [instanceObj, event, instancePluginMap] = instanceInfo || [];\r\n const ctor = instanceInfo ? osInstance : osStatic;\r\n if (ctor) {\r\n const instance = instanceInfo\r\n ? (\r\n ctor as Extract<\r\n typeof ctor,\r\n (\r\n osInstance: OverlayScrollbars,\r\n event: InstancePluginEvent,\r\n osStatic: OverlayScrollbarsStatic\r\n ) => PluginModuleInstance | void\r\n >\r\n )(instanceObj!, event!, staticObj)\r\n : (\r\n ctor as Extract<\r\n typeof ctor,\r\n (osStatic: OverlayScrollbarsStatic) => PluginModuleInstance | void\r\n >\r\n )(staticObj);\r\n return ((instancePluginMap || staticPluginModuleInstances)[name] = instance);\r\n }\r\n });\r\n\r\nexport const getStaticPluginModuleInstance = (\r\n pluginModuleName: T extends StaticPlugin ? N : never\r\n): InferStaticPluginModuleInstance | undefined =>\r\n staticPluginModuleInstances[pluginModuleName] as InferStaticPluginModuleInstance | undefined;\r\n","import type {\r\n Options,\r\n PartialOptions,\r\n OverflowBehavior,\r\n ScrollbarsVisibilityBehavior,\r\n ScrollbarsAutoHideBehavior,\r\n} from '~/options';\r\nimport type { OptionsTemplate, OptionsTemplateValue } from './validation';\r\nimport type { StaticPlugin } from '~/plugins';\r\nimport { validateOptions, optionsTemplateTypes as oTypes } from './validation';\r\n\r\nexport const optionsValidationPluginModuleName = '__osOptionsValidationPlugin';\r\n\r\nexport const OptionsValidationPlugin = /* @__PURE__ */ (() => ({\r\n [optionsValidationPluginModuleName]: {\r\n static: () => {\r\n const numberAllowedValues: OptionsTemplateValue = oTypes.number;\r\n const booleanAllowedValues: OptionsTemplateValue = oTypes.boolean;\r\n const arrayNullValues: OptionsTemplateValue | null> = [\r\n oTypes.array,\r\n oTypes.null,\r\n ];\r\n const overflowAllowedValues: OptionsTemplateValue =\r\n 'hidden scroll visible visible-hidden';\r\n const scrollbarsVisibilityAllowedValues: OptionsTemplateValue =\r\n 'visible hidden auto';\r\n const scrollbarsAutoHideAllowedValues: OptionsTemplateValue =\r\n 'never scroll leavemove';\r\n\r\n const optionsTemplate: OptionsTemplate = {\r\n // resize: resizeAllowedValues, // none || both || horizontal || vertical || n || b ||\r\n paddingAbsolute: booleanAllowedValues, // true || false\r\n showNativeOverlaidScrollbars: booleanAllowedValues, // true || false\r\n update: {\r\n elementEvents: arrayNullValues, // array of tuples || null\r\n attributes: arrayNullValues,\r\n debounce: [oTypes.number, oTypes.array, oTypes.null], // number || number array || null\r\n ignoreMutation: [oTypes.function, oTypes.null], // function || null\r\n },\r\n overflow: {\r\n x: overflowAllowedValues, // visible-hidden || visible-scroll || hidden || scrol\r\n y: overflowAllowedValues, // visible-hidden || visible-scroll || hidden || scrol\r\n },\r\n scrollbars: {\r\n theme: [oTypes.string, oTypes.null], // string || null\r\n visibility: scrollbarsVisibilityAllowedValues, // visible || hidden || auto || v ||\r\n autoHide: scrollbarsAutoHideAllowedValues, // never || scroll || leave || move ||\r\n autoHideDelay: numberAllowedValues, // number\r\n autoHideSuspend: booleanAllowedValues, // true || false\r\n dragScroll: booleanAllowedValues, // true || false\r\n clickScroll: booleanAllowedValues, // true || false\r\n pointers: [oTypes.array, oTypes.null], // string array\r\n },\r\n /*\r\n textarea: {\r\n dynWidth: booleanAllowedValues, // true || false\r\n dynHeight: booleanAllowedValues, // true || false\r\n inheritedAttrs: stringArrayNullAllowedValues, // string || array || nul\r\n },\r\n */\r\n };\r\n return (options: PartialOptions, doWriteErrors?: boolean): PartialOptions => {\r\n const [validated, foreign] = validateOptions(optionsTemplate, options, doWriteErrors);\r\n return { ...foreign, ...validated };\r\n };\r\n },\r\n },\r\n}))() satisfies StaticPlugin;\r\n","import {\r\n createDOM,\r\n appendChildren,\r\n offsetSize,\r\n addEventListener,\r\n addClass,\r\n equalWH,\r\n cAF,\r\n rAF,\r\n stopPropagation,\r\n bind,\r\n scrollElementTo,\r\n strWidth,\r\n strHeight,\r\n setStyles,\r\n} from '~/support';\r\nimport {\r\n classNameSizeObserverListenerScroll,\r\n classNameSizeObserverListenerItem,\r\n classNameSizeObserverListenerItemFinal,\r\n} from '~/classnames';\r\nimport type { StaticPlugin } from '../plugins';\r\n\r\nexport const sizeObserverPluginName = '__osSizeObserverPlugin';\r\n\r\nexport const SizeObserverPlugin = /* @__PURE__ */ (() => ({\r\n [sizeObserverPluginName]: {\r\n static:\r\n () =>\r\n (\r\n listenerElement: HTMLElement,\r\n onSizeChangedCallback: (appear: boolean) => any,\r\n observeAppearChange: boolean | null | undefined\r\n ): [appearCallback: () => void, offFns: (() => any)[]] => {\r\n const scrollAmount = 3333333;\r\n const scrollEventName = 'scroll';\r\n const observerElementChildren = createDOM(\r\n `

`\r\n );\r\n const observerElementChildrenRoot = observerElementChildren[0] as HTMLElement;\r\n const shrinkElement = observerElementChildrenRoot.lastChild as HTMLElement;\r\n const expandElement = observerElementChildrenRoot.firstChild as HTMLElement;\r\n const expandElementChild = expandElement?.firstChild as HTMLElement;\r\n\r\n let cacheSize = offsetSize(observerElementChildrenRoot);\r\n let currSize = cacheSize;\r\n let isDirty = false;\r\n let rAFId: number;\r\n\r\n const reset = () => {\r\n scrollElementTo(expandElement, scrollAmount);\r\n scrollElementTo(shrinkElement, scrollAmount);\r\n };\r\n const onResized = (appear?: unknown) => {\r\n rAFId = 0;\r\n if (isDirty) {\r\n cacheSize = currSize;\r\n onSizeChangedCallback(appear === true);\r\n }\r\n };\r\n const onScroll = (scrollEvent?: Event | false) => {\r\n currSize = offsetSize(observerElementChildrenRoot);\r\n isDirty = !scrollEvent || !equalWH(currSize, cacheSize);\r\n\r\n if (scrollEvent) {\r\n stopPropagation(scrollEvent);\r\n\r\n if (isDirty && !rAFId) {\r\n cAF!(rAFId);\r\n rAFId = rAF!(onResized);\r\n }\r\n } else {\r\n onResized(scrollEvent === false);\r\n }\r\n\r\n reset();\r\n };\r\n const destroyFns = [\r\n appendChildren(listenerElement, observerElementChildren),\r\n addEventListener(expandElement, scrollEventName, onScroll),\r\n addEventListener(shrinkElement, scrollEventName, onScroll),\r\n ];\r\n\r\n addClass(listenerElement, classNameSizeObserverListenerScroll);\r\n\r\n // lets assume that the divs will never be that large and a constant value is enough\r\n setStyles(expandElementChild, {\r\n [strWidth]: scrollAmount,\r\n [strHeight]: scrollAmount,\r\n });\r\n\r\n rAF!(reset);\r\n\r\n return [observeAppearChange ? bind(onScroll, false) : reset, destroyFns];\r\n },\r\n },\r\n}))() satisfies StaticPlugin;\r\n","import { getStyles, strOverflowX, strOverflowY, strVisible } from '~/support';\r\nimport type { Env } from '~/environment';\r\nimport type { XY } from '~/support';\r\nimport type { Options, OptionsCheckFn, OverflowBehavior } from '~/options';\r\nimport type { OverflowStyle, StyleObject, StyleObjectKey } from '~/typings';\r\nimport type { StructureSetupElementsObj } from './structureSetup.elements';\r\n\r\nexport interface ViewportOverflowState {\r\n _overflowScroll: XY;\r\n _overflowStyle: XY;\r\n}\r\n\r\nexport const getShowNativeOverlaidScrollbars = (checkOption: OptionsCheckFn, env: Env) => {\r\n const { _nativeScrollbarsOverlaid } = env;\r\n const [showNativeOverlaidScrollbarsOption, showNativeOverlaidScrollbarsChanged] = checkOption(\r\n 'showNativeOverlaidScrollbars'\r\n );\r\n\r\n return [\r\n showNativeOverlaidScrollbarsOption &&\r\n _nativeScrollbarsOverlaid.x &&\r\n _nativeScrollbarsOverlaid.y,\r\n showNativeOverlaidScrollbarsChanged,\r\n ] as const;\r\n};\r\n\r\nexport const overflowIsVisible = (overflowBehavior: string) =>\r\n overflowBehavior.indexOf(strVisible) === 0;\r\n\r\n/**\r\n * Gets the current overflow state of the viewport.\r\n * @param showNativeOverlaidScrollbars Whether native overlaid scrollbars are shown instead of hidden.\r\n * @param viewportStyleObj The viewport style object where the overflow scroll property can be read of, or undefined if shall be determined.\r\n * @returns A object which contains informations about the current overflow state.\r\n */\r\nexport const getViewportOverflowState = (\r\n structureSetupElements: StructureSetupElementsObj,\r\n viewportStyleObj?: StyleObject\r\n): ViewportOverflowState => {\r\n const { _viewport } = structureSetupElements;\r\n const getStatePerAxis = (styleKey: StyleObjectKey) => {\r\n const overflowStyle = getStyles(_viewport, styleKey);\r\n // can't do something like \"viewportStyleObj && viewportStyleObj[styleKey] || overflowStyle\" here!\r\n const objectPrefferedOverflowStyle = viewportStyleObj\r\n ? viewportStyleObj[styleKey]\r\n : overflowStyle;\r\n const overflowScroll = objectPrefferedOverflowStyle === 'scroll';\r\n\r\n return [overflowStyle, overflowScroll] as [\r\n overflowStyle: OverflowStyle,\r\n overflowScroll: boolean\r\n ];\r\n };\r\n\r\n const [xOverflowStyle, xOverflowScroll] = getStatePerAxis(strOverflowX);\r\n const [yOverflowStyle, yOverflowScroll] = getStatePerAxis(strOverflowY);\r\n\r\n return {\r\n _overflowStyle: {\r\n x: xOverflowStyle,\r\n y: yOverflowStyle,\r\n },\r\n _overflowScroll: {\r\n x: xOverflowScroll,\r\n y: yOverflowScroll,\r\n },\r\n };\r\n};\r\n\r\n/**\r\n * Sets the overflow property of the viewport and calculates the a overflow state according to the new parameters.\r\n * @param showNativeOverlaidScrollbars Whether to show natively overlaid scrollbars.\r\n * @param overflowAmount The overflow amount.\r\n * @param overflow The overflow behavior according to the options.\r\n * @param viewportStyleObj The viewport style object to which the overflow style shall be applied.\r\n * @returns A object which represents the newly set overflow state.\r\n */\r\nexport const setViewportOverflowState = (\r\n structureSetupElements: StructureSetupElementsObj,\r\n hasOverflow: XY,\r\n overflowOption: XY,\r\n viewportStyleObj: StyleObject\r\n): ViewportOverflowState => {\r\n const hasAnyOverflow = hasOverflow.x || hasOverflow.y;\r\n\r\n const setAxisOverflowStyle = (behavior: OverflowBehavior, hasOverflowAxis: boolean) => {\r\n const overflowVisible = overflowIsVisible(behavior);\r\n const fallbackVisibilityBehavior = overflowVisible && hasAnyOverflow ? 'hidden' : '';\r\n const overflowVisibleBehavior =\r\n (hasOverflowAxis && overflowVisible && behavior.replace(`${strVisible}-`, '')) ||\r\n fallbackVisibilityBehavior;\r\n\r\n return [\r\n hasOverflowAxis && !overflowVisible ? behavior : '',\r\n overflowIsVisible(overflowVisibleBehavior) ? 'hidden' : overflowVisibleBehavior,\r\n ];\r\n };\r\n\r\n const [overflowX, visibleBehaviorX] = setAxisOverflowStyle(overflowOption.x, hasOverflow.x);\r\n const [overflowY, visibleBehaviorY] = setAxisOverflowStyle(overflowOption.y, hasOverflow.y);\r\n\r\n viewportStyleObj[strOverflowX] = visibleBehaviorX && overflowY ? visibleBehaviorX : overflowX;\r\n viewportStyleObj[strOverflowY] = visibleBehaviorY && overflowX ? visibleBehaviorY : overflowY;\r\n\r\n return getViewportOverflowState(structureSetupElements, viewportStyleObj);\r\n};\r\n","import {\r\n keys,\r\n noop,\r\n each,\r\n assignDeep,\r\n windowSize,\r\n wnd,\r\n mathAbs,\r\n mathRound,\r\n strMarginBottom,\r\n strMarginLeft,\r\n strMarginRight,\r\n strPaddingBottom,\r\n strPaddingLeft,\r\n strPaddingRight,\r\n strPaddingTop,\r\n getStyles,\r\n setStyles,\r\n addAttrClass,\r\n removeAttrClass,\r\n strWidth,\r\n} from '~/support';\r\nimport { dataValueViewportArrange, dataAttributeViewport } from '~/classnames';\r\nimport {\r\n getShowNativeOverlaidScrollbars,\r\n getViewportOverflowState,\r\n} from '~/setups/structureSetup/structureSetup.utils';\r\nimport type { ObserversSetupState } from '~/setups';\r\nimport type { Options, OptionsCheckFn } from '~/options';\r\nimport type { StructureSetupElementsObj } from '~/setups/structureSetup/structureSetup.elements';\r\nimport type { ViewportOverflowState } from '~/setups/structureSetup/structureSetup.utils';\r\nimport type { Env } from '~/environment';\r\nimport type { UpdateCache, WH, XY } from '~/support';\r\nimport type { StyleObject, StyleObjectKey } from '~/typings';\r\nimport type { StructureSetupState } from '~/setups/structureSetup';\r\nimport type { StaticPlugin } from '~/plugins';\r\n\r\nexport const scrollbarsHidingPluginName = '__osScrollbarsHidingPlugin';\r\n\r\nexport const ScrollbarsHidingPlugin = /* @__PURE__ */ (() => ({\r\n [scrollbarsHidingPluginName]: {\r\n static: () => ({\r\n _viewportArrangement: (\r\n structureSetupElements: StructureSetupElementsObj,\r\n structureSetupState: StructureSetupState,\r\n observersSetupState: ObserversSetupState,\r\n env: Env,\r\n checkOptions: OptionsCheckFn\r\n ) => {\r\n const { _viewportIsTarget, _viewport } = structureSetupElements;\r\n const { _nativeScrollbarsHiding, _nativeScrollbarsOverlaid, _nativeScrollbarsSize } = env;\r\n const doViewportArrange =\r\n !_viewportIsTarget &&\r\n !_nativeScrollbarsHiding &&\r\n (_nativeScrollbarsOverlaid.x || _nativeScrollbarsOverlaid.y);\r\n const [showNativeOverlaidScrollbars] = getShowNativeOverlaidScrollbars(checkOptions, env);\r\n\r\n const _getViewportOverflowHideOffset = (viewportOverflowState: ViewportOverflowState) => {\r\n const { _overflowScroll } = viewportOverflowState;\r\n const arrangeHideOffset =\r\n _nativeScrollbarsHiding || showNativeOverlaidScrollbars ? 0 : 42;\r\n\r\n const getHideOffsetPerAxis = (\r\n isOverlaid: boolean,\r\n overflowScroll: boolean,\r\n nativeScrollbarSize: number\r\n ) => {\r\n const nonScrollbarStylingHideOffset = isOverlaid\r\n ? arrangeHideOffset\r\n : nativeScrollbarSize;\r\n const scrollbarsHideOffset =\r\n overflowScroll && !_nativeScrollbarsHiding ? nonScrollbarStylingHideOffset : 0;\r\n const scrollbarsHideOffsetArrange = isOverlaid && !!arrangeHideOffset;\r\n\r\n return [scrollbarsHideOffset, scrollbarsHideOffsetArrange] as const;\r\n };\r\n\r\n const [xScrollbarsHideOffset, xScrollbarsHideOffsetArrange] = getHideOffsetPerAxis(\r\n _nativeScrollbarsOverlaid.x,\r\n _overflowScroll.x,\r\n _nativeScrollbarsSize.x\r\n );\r\n const [yScrollbarsHideOffset, yScrollbarsHideOffsetArrange] = getHideOffsetPerAxis(\r\n _nativeScrollbarsOverlaid.y,\r\n _overflowScroll.y,\r\n _nativeScrollbarsSize.y\r\n );\r\n\r\n return {\r\n _scrollbarsHideOffset: {\r\n x: xScrollbarsHideOffset,\r\n y: yScrollbarsHideOffset,\r\n },\r\n _scrollbarsHideOffsetArrange: {\r\n x: xScrollbarsHideOffsetArrange,\r\n y: yScrollbarsHideOffsetArrange,\r\n },\r\n };\r\n };\r\n\r\n /**\r\n * Hides the native scrollbars according to the passed parameters.\r\n * @param viewportOverflowState The viewport overflow state.\r\n * @param directionIsRTL Whether the direction is RTL or not.\r\n * @param viewportArrange Whether special styles related to the viewport arrange strategy shall be applied.\r\n * @param viewportStyleObj The viewport style object to which the needed styles shall be applied.\r\n */\r\n const _hideNativeScrollbars = (\r\n viewportOverflowState: ViewportOverflowState,\r\n { _directionIsRTL }: ObserversSetupState,\r\n viewportArrange: boolean,\r\n viewportStyleObj: StyleObject\r\n ): void => {\r\n assignDeep(viewportStyleObj, {\r\n [strMarginRight]: 0,\r\n [strMarginBottom]: 0,\r\n [strMarginLeft]: 0,\r\n });\r\n if (!_viewportIsTarget) {\r\n const { _scrollbarsHideOffset, _scrollbarsHideOffsetArrange } =\r\n _getViewportOverflowHideOffset(viewportOverflowState);\r\n const { x: arrangeX, y: arrangeY } = _scrollbarsHideOffsetArrange;\r\n const { x: hideOffsetX, y: hideOffsetY } = _scrollbarsHideOffset;\r\n const { _viewportPaddingStyle } = structureSetupState;\r\n const horizontalMarginKey: keyof StyleObject = _directionIsRTL\r\n ? strMarginLeft\r\n : strMarginRight;\r\n const viewportHorizontalPaddingKey: keyof StyleObject = _directionIsRTL\r\n ? strPaddingLeft\r\n : strPaddingRight;\r\n const horizontalMarginValue = _viewportPaddingStyle[horizontalMarginKey] as number;\r\n const verticalMarginValue = _viewportPaddingStyle[strMarginBottom] as number;\r\n const horizontalPaddingValue = _viewportPaddingStyle[\r\n viewportHorizontalPaddingKey\r\n ] as number;\r\n const verticalPaddingValue = _viewportPaddingStyle[strPaddingBottom] as number;\r\n\r\n // horizontal\r\n viewportStyleObj[strWidth] = `calc(100% + ${\r\n hideOffsetY + horizontalMarginValue * -1\r\n }px)`;\r\n viewportStyleObj[horizontalMarginKey] = -hideOffsetY + horizontalMarginValue;\r\n\r\n // vertical\r\n viewportStyleObj[strMarginBottom] = -hideOffsetX + verticalMarginValue;\r\n\r\n // viewport arrange additional styles\r\n if (viewportArrange) {\r\n viewportStyleObj[viewportHorizontalPaddingKey] =\r\n horizontalPaddingValue + (arrangeY ? hideOffsetY : 0);\r\n viewportStyleObj[strPaddingBottom] =\r\n verticalPaddingValue + (arrangeX ? hideOffsetX : 0);\r\n }\r\n }\r\n };\r\n\r\n /**\r\n * Sets the styles of the viewport arrange element.\r\n * @param viewportOverflowState The viewport overflow state according to which the scrollbars shall be hidden.\r\n * @param viewportScrollSize The content scroll size.\r\n * @param directionIsRTL Whether the direction is RTL or not.\r\n * @returns A boolean which indicates whether the viewport arrange element was adjusted.\r\n */\r\n const _arrangeViewport = (\r\n viewportOverflowState: ViewportOverflowState,\r\n viewportScrollSize: WH,\r\n sizeFraction: WH\r\n ) => {\r\n if (doViewportArrange) {\r\n const { _viewportPaddingStyle } = structureSetupState;\r\n const { _scrollbarsHideOffset, _scrollbarsHideOffsetArrange } =\r\n _getViewportOverflowHideOffset(viewportOverflowState);\r\n const { x: arrangeX, y: arrangeY } = _scrollbarsHideOffsetArrange;\r\n const { x: hideOffsetX, y: hideOffsetY } = _scrollbarsHideOffset;\r\n const { _directionIsRTL } = observersSetupState;\r\n const viewportArrangeHorizontalPaddingKey: keyof StyleObject = _directionIsRTL\r\n ? strPaddingRight\r\n : strPaddingLeft;\r\n const viewportArrangeHorizontalPaddingValue = _viewportPaddingStyle[\r\n viewportArrangeHorizontalPaddingKey\r\n ] as number;\r\n const viewportArrangeVerticalPaddingValue = _viewportPaddingStyle.paddingTop as number;\r\n const fractionalContentWidth = viewportScrollSize.w + sizeFraction.w;\r\n const fractionalContenHeight = viewportScrollSize.h + sizeFraction.h;\r\n const arrangeSize = {\r\n w:\r\n hideOffsetY && arrangeY\r\n ? `${\r\n hideOffsetY + fractionalContentWidth - viewportArrangeHorizontalPaddingValue\r\n }px`\r\n : '',\r\n h:\r\n hideOffsetX && arrangeX\r\n ? `${\r\n hideOffsetX + fractionalContenHeight - viewportArrangeVerticalPaddingValue\r\n }px`\r\n : '',\r\n };\r\n\r\n setStyles(_viewport, {\r\n '--os-vaw': arrangeSize.w,\r\n '--os-vah': arrangeSize.h,\r\n });\r\n }\r\n\r\n return doViewportArrange;\r\n };\r\n\r\n /**\r\n * Removes all styles applied because of the viewport arrange strategy.\r\n * @param showNativeOverlaidScrollbars Whether native overlaid scrollbars are shown instead of hidden.\r\n * @param directionIsRTL Whether the direction is RTL or not.\r\n * @param viewportOverflowState The currentviewport overflow state or undefined if it has to be determined.\r\n * @returns A object with a function which applies all the removed styles and the determined viewport vverflow state.\r\n */\r\n const _undoViewportArrange = (viewportOverflowState?: ViewportOverflowState) => {\r\n if (doViewportArrange) {\r\n const finalViewportOverflowState =\r\n viewportOverflowState || getViewportOverflowState(structureSetupElements);\r\n const { _viewportPaddingStyle: viewportPaddingStyle } = structureSetupState;\r\n const { _scrollbarsHideOffsetArrange } = _getViewportOverflowHideOffset(\r\n finalViewportOverflowState\r\n );\r\n const { x: arrangeX, y: arrangeY } = _scrollbarsHideOffsetArrange;\r\n const finalPaddingStyle: StyleObject = {};\r\n const assignProps = (props: string[]) =>\r\n each(props, (prop) => {\r\n finalPaddingStyle[prop as StyleObjectKey] =\r\n viewportPaddingStyle[prop as StyleObjectKey];\r\n });\r\n\r\n if (arrangeX) {\r\n assignProps([strMarginBottom, strPaddingTop, strPaddingBottom]);\r\n }\r\n\r\n if (arrangeY) {\r\n assignProps([strMarginLeft, strMarginRight, strPaddingLeft, strPaddingRight]);\r\n }\r\n\r\n const prevStyle = getStyles(_viewport, keys(finalPaddingStyle) as StyleObjectKey[]);\r\n removeAttrClass(_viewport, dataAttributeViewport, dataValueViewportArrange);\r\n\r\n setStyles(_viewport, finalPaddingStyle);\r\n\r\n return [\r\n () => {\r\n _hideNativeScrollbars(\r\n finalViewportOverflowState,\r\n observersSetupState,\r\n doViewportArrange,\r\n prevStyle\r\n );\r\n setStyles(_viewport, prevStyle);\r\n addAttrClass(_viewport, dataAttributeViewport, dataValueViewportArrange);\r\n },\r\n finalViewportOverflowState,\r\n ] as const;\r\n }\r\n return [noop] as const;\r\n };\r\n\r\n return {\r\n _getViewportOverflowHideOffset,\r\n _arrangeViewport,\r\n _undoViewportArrange,\r\n _hideNativeScrollbars,\r\n };\r\n },\r\n _envWindowZoom: () => {\r\n let size = { w: 0, h: 0 };\r\n let dpr = 0;\r\n const getWindowDPR = (): number => {\r\n const screen = wnd.screen;\r\n // eslint-disable-next-line\r\n // @ts-ignore\r\n const dDPI = screen.deviceXDPI || 0;\r\n // eslint-disable-next-line\r\n // @ts-ignore\r\n const sDPI = screen.logicalXDPI || 1;\r\n return wnd.devicePixelRatio || dDPI / sDPI;\r\n };\r\n const diffBiggerThanOne = (valOne: number, valTwo: number): boolean => {\r\n const absValOne = mathAbs(valOne);\r\n const absValTwo = mathAbs(valTwo);\r\n return !(\r\n absValOne === absValTwo ||\r\n absValOne + 1 === absValTwo ||\r\n absValOne - 1 === absValTwo\r\n );\r\n };\r\n\r\n return (\r\n envInstance: Env,\r\n updateNativeScrollbarSizeCache: UpdateCache>\r\n ): boolean | undefined => {\r\n const sizeNew = windowSize();\r\n const deltaSize = {\r\n w: sizeNew.w - size.w,\r\n h: sizeNew.h - size.h,\r\n };\r\n\r\n if (deltaSize.w === 0 && deltaSize.h === 0) {\r\n return;\r\n }\r\n\r\n const deltaAbsSize = {\r\n w: mathAbs(deltaSize.w),\r\n h: mathAbs(deltaSize.h),\r\n };\r\n const deltaAbsRatio = {\r\n w: mathAbs(mathRound(sizeNew.w / (size.w / 100.0))),\r\n h: mathAbs(mathRound(sizeNew.h / (size.h / 100.0))),\r\n };\r\n const dprNew = getWindowDPR();\r\n const deltaIsBigger = deltaAbsSize.w > 2 && deltaAbsSize.h > 2;\r\n const difference = !diffBiggerThanOne(deltaAbsRatio.w, deltaAbsRatio.h);\r\n const dprChanged = dprNew !== dpr && dprNew > 0;\r\n const isZoom = deltaIsBigger && difference && dprChanged;\r\n let scrollbarSizeChanged;\r\n let scrollbarSize;\r\n\r\n if (isZoom) {\r\n [scrollbarSize, scrollbarSizeChanged] = updateNativeScrollbarSizeCache();\r\n\r\n assignDeep(envInstance._nativeScrollbarsSize, scrollbarSize); // keep the object same!\r\n }\r\n\r\n size = sizeNew;\r\n dpr = dprNew;\r\n\r\n return scrollbarSizeChanged;\r\n };\r\n },\r\n }),\r\n },\r\n}))() satisfies StaticPlugin;\r\n","import { animateNumber, noop, setT } from '~/support';\r\nimport type { StaticPlugin } from '~/plugins';\r\n\r\nexport const clickScrollPluginModuleName = '__osClickScrollPlugin';\r\n\r\nexport const ClickScrollPlugin = /* @__PURE__ */ (() => ({\r\n [clickScrollPluginModuleName]: {\r\n static:\r\n () =>\r\n (\r\n moveHandleRelative: (deltaMovement: number) => void,\r\n getHandleOffset: (handleRect?: DOMRect, trackRect?: DOMRect) => number,\r\n startOffset: number,\r\n handleLength: number,\r\n relativeTrackPointerOffset: number\r\n ): (() => void) => {\r\n // click scroll animation\r\n let iteration = 0;\r\n let clear = noop;\r\n const animateClickScroll = (clickScrollProgress: number) => {\r\n clear = animateNumber(\r\n clickScrollProgress,\r\n clickScrollProgress + handleLength * Math.sign(startOffset),\r\n 133,\r\n (animationProgress, _, animationCompleted) => {\r\n moveHandleRelative(animationProgress);\r\n const handleStartBound = getHandleOffset();\r\n const handleEndBound = handleStartBound + handleLength;\r\n const mouseBetweenHandleBounds =\r\n relativeTrackPointerOffset >= handleStartBound &&\r\n relativeTrackPointerOffset <= handleEndBound;\r\n\r\n if (animationCompleted && !mouseBetweenHandleBounds) {\r\n if (iteration) {\r\n animateClickScroll(animationProgress);\r\n } else {\r\n const firstIterationPauseTimeout = setT(() => {\r\n animateClickScroll(animationProgress);\r\n }, 222);\r\n clear = () => {\r\n clearTimeout(firstIterationPauseTimeout);\r\n };\r\n }\r\n iteration++;\r\n }\r\n }\r\n );\r\n };\r\n\r\n animateClickScroll(0);\r\n\r\n return () => clear();\r\n },\r\n },\r\n}))() satisfies StaticPlugin;\r\n","import {\r\n createDOM,\r\n addClass,\r\n appendChildren,\r\n fractionalSize,\r\n clientSize,\r\n absoluteCoordinates,\r\n offsetSize,\r\n removeAttrs,\r\n removeElements,\r\n assignDeep,\r\n createCache,\r\n equalXY,\r\n createEventListenerHub,\r\n scrollT,\r\n bind,\r\n wnd,\r\n noop,\r\n scrollElementTo,\r\n strHidden,\r\n strOverflowX,\r\n strOverflowY,\r\n getStyles,\r\n setStyles,\r\n isBodyElement,\r\n} from '~/support';\r\nimport { classNameEnvironment, classNameEnvironmentScrollbarHidden } from '~/classnames';\r\nimport { defaultOptions } from '~/options';\r\nimport { getStaticPluginModuleInstance, scrollbarsHidingPluginName } from '~/plugins';\r\nimport type { XY, EventListener } from '~/support';\r\nimport type { Options, PartialOptions } from '~/options';\r\nimport type { ScrollbarsHidingPlugin } from '~/plugins';\r\nimport type { Initialization, PartialInitialization } from '~/initialization';\r\nimport type { StyleObjectKey } from './typings';\r\n\r\ntype EnvironmentEventArgs = {\r\n r: [scrollbarSizeChanged?: boolean];\r\n};\r\n\r\nexport interface Env {\r\n readonly _nativeScrollbarsSize: XY;\r\n readonly _nativeScrollbarsOverlaid: XY;\r\n readonly _nativeScrollbarsHiding: boolean;\r\n readonly _rtlScrollBehavior: { n: boolean; i: boolean };\r\n readonly _scrollTimeline: boolean;\r\n readonly _staticDefaultInitialization: Initialization;\r\n readonly _staticDefaultOptions: Options;\r\n _addResizeListener(listener: EventListener): () => void;\r\n _getDefaultInitialization(): Initialization;\r\n _setDefaultInitialization(newInitialization: PartialInitialization): Initialization;\r\n _getDefaultOptions(): Options;\r\n _setDefaultOptions(newDefaultOptions: PartialOptions): Options;\r\n}\r\n\r\nlet environmentInstance: Env;\r\n\r\nconst createEnvironment = (): Env => {\r\n const getNativeScrollbarSize = (\r\n measureElm: HTMLElement,\r\n measureElmChild: HTMLElement,\r\n clear?: boolean\r\n ): XY => {\r\n // fix weird safari issue where getComputedStyle returns all empty styles by appending twice\r\n appendChildren(document.body, measureElm);\r\n appendChildren(document.body, measureElm);\r\n\r\n const cSize = clientSize(measureElm);\r\n const oSize = offsetSize(measureElm);\r\n const fSize = fractionalSize(measureElmChild);\r\n\r\n clear && removeElements(measureElm);\r\n\r\n return {\r\n x: oSize.h - cSize.h + fSize.h,\r\n y: oSize.w - cSize.w + fSize.w,\r\n };\r\n };\r\n\r\n const getNativeScrollbarsHiding = (testElm: HTMLElement): boolean => {\r\n let result = false;\r\n const revertClass = addClass(testElm, classNameEnvironmentScrollbarHidden);\r\n try {\r\n result =\r\n getStyles(testElm, 'scrollbar-width' as StyleObjectKey) === 'none' ||\r\n getStyles(testElm, 'display', '::-webkit-scrollbar') === 'none';\r\n } catch {}\r\n revertClass();\r\n return result;\r\n };\r\n\r\n const getRtlScrollBehavior = (\r\n parentElm: HTMLElement,\r\n childElm: HTMLElement\r\n ): { i: boolean; n: boolean } => {\r\n setStyles(parentElm, {\r\n [strOverflowX]: strHidden,\r\n [strOverflowY]: strHidden,\r\n direction: 'rtl',\r\n });\r\n scrollElementTo(parentElm, { x: 0 });\r\n\r\n const parentOffset = absoluteCoordinates(parentElm);\r\n const childOffset = absoluteCoordinates(childElm);\r\n scrollElementTo(parentElm, { x: -999 }); // https://github.com/KingSora/OverlayScrollbars/issues/187\r\n const childOffsetAfterScroll = absoluteCoordinates(childElm);\r\n return {\r\n /**\r\n * origin direction = determines if the zero scroll position is on the left or right side\r\n * 'i' means 'invert' (i === true means that the axis must be inverted to be correct)\r\n * true = on the left side\r\n * false = on the right side\r\n */\r\n i: parentOffset.x === childOffset.x,\r\n /**\r\n * negative = determines if the maximum scroll is positive or negative\r\n * 'n' means 'negate' (n === true means that the axis must be negated to be correct)\r\n * true = negative\r\n * false = positive\r\n */\r\n n: childOffset.x !== childOffsetAfterScroll.x,\r\n };\r\n };\r\n\r\n // changes to this styles need to be reflected in the \"hide native scrollbars\" section of the structure styles\r\n const envStyle = `.${classNameEnvironment}{scroll-behavior:auto!important;position:fixed;opacity:0;visibility:hidden;overflow:scroll;height:200px;width:200px;z-index:-1}.${classNameEnvironment} div{width:200%;height:200%;margin:10px 0}.${classNameEnvironmentScrollbarHidden}{scrollbar-width:none!important}.${classNameEnvironmentScrollbarHidden}::-webkit-scrollbar,.${classNameEnvironmentScrollbarHidden}::-webkit-scrollbar-corner{appearance:none!important;display:none!important;width:0!important;height:0!important}`;\r\n const envDOM = createDOM(\r\n `
`\r\n );\r\n const envElm = envDOM[0] as HTMLElement;\r\n const envChildElm = envElm.firstChild as HTMLElement;\r\n const [addEvent, , triggerEvent] = createEventListenerHub();\r\n const [updateNativeScrollbarSizeCache, getNativeScrollbarSizeCache] = createCache(\r\n {\r\n _initialValue: getNativeScrollbarSize(envElm, envChildElm),\r\n _equal: equalXY,\r\n },\r\n bind(getNativeScrollbarSize, envElm, envChildElm, true)\r\n );\r\n const [nativeScrollbarsSize] = getNativeScrollbarSizeCache();\r\n const nativeScrollbarsHiding = getNativeScrollbarsHiding(envElm);\r\n const nativeScrollbarsOverlaid = {\r\n x: nativeScrollbarsSize.x === 0,\r\n y: nativeScrollbarsSize.y === 0,\r\n };\r\n const staticDefaultInitialization: Initialization = {\r\n elements: {\r\n host: null,\r\n padding: !nativeScrollbarsHiding,\r\n viewport: (target) => nativeScrollbarsHiding && isBodyElement(target) && target,\r\n content: false,\r\n },\r\n scrollbars: {\r\n slot: true,\r\n },\r\n cancel: {\r\n nativeScrollbarsOverlaid: false,\r\n body: null,\r\n },\r\n };\r\n const staticDefaultOptions = assignDeep({}, defaultOptions);\r\n const getDefaultOptions = bind(\r\n assignDeep as typeof assignDeep,\r\n {} as Options,\r\n staticDefaultOptions\r\n );\r\n const getDefaultInitialization = bind(\r\n assignDeep as typeof assignDeep,\r\n {} as Initialization,\r\n staticDefaultInitialization\r\n );\r\n\r\n const env: Env = {\r\n _nativeScrollbarsSize: nativeScrollbarsSize,\r\n _nativeScrollbarsOverlaid: nativeScrollbarsOverlaid,\r\n _nativeScrollbarsHiding: nativeScrollbarsHiding,\r\n _scrollTimeline: !!scrollT,\r\n _rtlScrollBehavior: getRtlScrollBehavior(envElm, envChildElm),\r\n _addResizeListener: bind(addEvent, 'r'),\r\n _getDefaultInitialization: getDefaultInitialization,\r\n _setDefaultInitialization: (newInitializationStrategy) =>\r\n assignDeep(staticDefaultInitialization, newInitializationStrategy) &&\r\n getDefaultInitialization(),\r\n _getDefaultOptions: getDefaultOptions,\r\n _setDefaultOptions: (newDefaultOptions) =>\r\n assignDeep(staticDefaultOptions, newDefaultOptions) && getDefaultOptions(),\r\n _staticDefaultInitialization: assignDeep({}, staticDefaultInitialization),\r\n _staticDefaultOptions: assignDeep({}, staticDefaultOptions),\r\n };\r\n\r\n removeAttrs(envElm, 'style');\r\n removeElements(envElm);\r\n\r\n // needed in case content has css viewport units\r\n wnd.addEventListener('resize', () => {\r\n let scrollbarSizeChanged;\r\n if (!nativeScrollbarsHiding && (!nativeScrollbarsOverlaid.x || !nativeScrollbarsOverlaid.y)) {\r\n const scrollbarsHidingPlugin = getStaticPluginModuleInstance(\r\n scrollbarsHidingPluginName\r\n );\r\n const zoomFn = scrollbarsHidingPlugin ? scrollbarsHidingPlugin._envWindowZoom() : noop;\r\n scrollbarSizeChanged = !!zoomFn(env, updateNativeScrollbarSizeCache);\r\n }\r\n\r\n triggerEvent('r', [scrollbarSizeChanged]);\r\n });\r\n\r\n return env;\r\n};\r\n\r\nconst getEnvironment = (): Env => {\r\n if (!environmentInstance) {\r\n environmentInstance = createEnvironment();\r\n }\r\n return environmentInstance;\r\n};\r\n\r\nexport { getEnvironment };\r\n","import { isFunction, isHTMLElement, isNull, isUndefined } from '~/support';\r\nimport { getEnvironment } from '~/environment';\r\nimport type { DeepPartial } from '~/typings';\r\n\r\ntype FallbackStaticInitializtationElement = Extract<\r\n StaticInitializationElement,\r\n (...args: Args) => any\r\n> extends (...args: infer P) => any\r\n ? (...args: P) => HTMLElement\r\n : never;\r\ntype FallbackDynamicInitializtationElement = Extract<\r\n DynamicInitializationElement,\r\n (...args: Args) => any\r\n> extends (...args: infer P) => any\r\n ? (...args: P) => HTMLElement\r\n : never;\r\n\r\nexport type StaticInitialization = HTMLElement | false | null;\r\nexport type DynamicInitialization = HTMLElement | boolean | null;\r\n\r\n/**\r\n * Static elements are elements which MUST be present in the final DOM.\r\n * If an `HTMLElement` is passed the passed element will be taken as the repsective element.\r\n * With `false`, `null` or `undefined` an appropriate element is generated automatically.\r\n */\r\nexport type StaticInitializationElement =\r\n /** A function which returns the the StaticInitialization value. */\r\n | ((...args: Args) => StaticInitialization)\r\n /** The StaticInitialization value. */\r\n | StaticInitialization;\r\n\r\n/**\r\n * Dynamic elements are elements which CAN be present in the final DOM.\r\n * If an `HTMLElement`is passed the passed element will be taken as the repsective element.\r\n * With `true` an appropriate element is generated automatically.\r\n * With `false`, `null` or `undefined` the element won't be in the DOM.\r\n */\r\nexport type DynamicInitializationElement =\r\n /** A function which returns the the DynamicInitialization value. */\r\n | ((...args: Args) => DynamicInitialization)\r\n /** The DynamicInitialization value. */\r\n | DynamicInitialization;\r\n\r\n/**\r\n * Describes how a OverlayScrollbar instance should initialize.\r\n */\r\nexport type Initialization = {\r\n /**\r\n * Customizes which elements are generated and used.\r\n * If a function is passed to any of the fields, it receives the `target` element as its argument.\r\n * Any passed function should be a \"pure\" function. (same input produces same output)\r\n */\r\n elements: {\r\n /**\r\n * Assign a custom element as the host element.\r\n * Only relevant if the target element is a Textarea.\r\n */\r\n host: StaticInitializationElement<[target: InitializationTargetElement]>;\r\n /** Assign a custom element as the viewport element. */\r\n viewport: StaticInitializationElement<[target: InitializationTargetElement]>;\r\n /** Assign a custom element as the padding element or force the element not to be generated. */\r\n padding: DynamicInitializationElement<[target: InitializationTargetElement]>;\r\n /** Assign a custom element as the content element or force the element not to be generated. */\r\n content: DynamicInitializationElement<[target: InitializationTargetElement]>;\r\n };\r\n /**\r\n * Customizes elements related to the scrollbars.\r\n * If a function is passed, it receives the `target`, `host` and `viewport` element as arguments.\r\n */\r\n scrollbars: {\r\n slot: DynamicInitializationElement<\r\n [target: InitializationTargetElement, host: HTMLElement, viewport: HTMLElement]\r\n >;\r\n };\r\n /**\r\n * Customizes the cancelation behavior.\r\n */\r\n cancel: {\r\n /** Whether the initialization shall be canceled if the native scrollbars are overlaid. */\r\n nativeScrollbarsOverlaid: boolean;\r\n /**\r\n * Whether the initialization shall be canceled if its applied to a body element.\r\n * With `true` an initialization is always canceled, with `false` its never canceled.\r\n * With `null` the initialization will only be canceled when the initialization would affect the browsers functionality. (window.scrollTo, mobile browser behavior etc.)\r\n */\r\n body: boolean | null;\r\n };\r\n};\r\n\r\nexport type PartialInitialization = DeepPartial;\r\n\r\n/** The initialization target element. */\r\nexport type InitializationTargetElement = HTMLElement; // | HTMLTextAreaElement;\r\n\r\n/**\r\n * The initialization target object.\r\n * OverlayScrollbars({ target: myElement }) is equivalent to OverlayScrollbars(myElement).\r\n */\r\nexport type InitializationTargetObject = PartialInitialization & {\r\n target: InitializationTargetElement;\r\n};\r\n\r\n/** The initialization target. */\r\nexport type InitializationTarget = InitializationTargetElement | InitializationTargetObject;\r\n\r\nexport const resolveInitialization = (\r\n args: any,\r\n value: any\r\n): T => (isFunction(value) ? value.apply(0, args) : value);\r\n\r\nexport const staticInitializationElement = (\r\n args: Args,\r\n fallbackStaticInitializationElement: FallbackStaticInitializtationElement,\r\n defaultStaticInitializationElement: StaticInitializationElement,\r\n staticInitializationElementValue?: StaticInitializationElement\r\n): HTMLElement => {\r\n const staticInitialization = isUndefined(staticInitializationElementValue)\r\n ? defaultStaticInitializationElement\r\n : staticInitializationElementValue;\r\n const resolvedInitialization = resolveInitialization(\r\n args,\r\n staticInitialization\r\n );\r\n return resolvedInitialization || fallbackStaticInitializationElement.apply(0, args);\r\n};\r\n\r\nexport const dynamicInitializationElement = (\r\n args: Args,\r\n fallbackDynamicInitializationElement: FallbackDynamicInitializtationElement,\r\n defaultDynamicInitializationElement: DynamicInitializationElement,\r\n dynamicInitializationElementValue?: DynamicInitializationElement\r\n): HTMLElement | false => {\r\n const dynamicInitialization = isUndefined(dynamicInitializationElementValue)\r\n ? defaultDynamicInitializationElement\r\n : dynamicInitializationElementValue;\r\n const resolvedInitialization = resolveInitialization(\r\n args,\r\n dynamicInitialization\r\n );\r\n return (\r\n !!resolvedInitialization &&\r\n (isHTMLElement(resolvedInitialization)\r\n ? resolvedInitialization\r\n : fallbackDynamicInitializationElement.apply(0, args))\r\n );\r\n};\r\n\r\nexport const cancelInitialization = (\r\n isBody: boolean,\r\n cancelInitializationValue?: DeepPartial | false | null | undefined\r\n): boolean => {\r\n const { nativeScrollbarsOverlaid, body } = cancelInitializationValue || {};\r\n const { _nativeScrollbarsOverlaid, _nativeScrollbarsHiding, _getDefaultInitialization } =\r\n getEnvironment();\r\n const { nativeScrollbarsOverlaid: defaultNativeScrollbarsOverlaid, body: defaultbody } =\r\n _getDefaultInitialization().cancel;\r\n\r\n const resolvedNativeScrollbarsOverlaid =\r\n nativeScrollbarsOverlaid ?? defaultNativeScrollbarsOverlaid;\r\n const resolvedDocumentScrollingElement = isUndefined(body) ? defaultbody : body;\r\n\r\n const finalNativeScrollbarsOverlaid =\r\n (_nativeScrollbarsOverlaid.x || _nativeScrollbarsOverlaid.y) &&\r\n resolvedNativeScrollbarsOverlaid;\r\n const finalDocumentScrollingElement =\r\n isBody &&\r\n (isNull(resolvedDocumentScrollingElement)\r\n ? !_nativeScrollbarsHiding\r\n : resolvedDocumentScrollingElement);\r\n\r\n return !!finalNativeScrollbarsOverlaid || !!finalDocumentScrollingElement;\r\n};\r\n","import type { OverlayScrollbars } from '~/overlayscrollbars';\n\nconst targetInstanceMap: WeakMap = new WeakMap();\n\n/**\n * Adds the given OverlayScrollbars instance to the given element.\n * @param target The element which is the target of the OverlayScrollbars instance.\n * @param osInstance The OverlayScrollbars instance.\n */\nexport const addInstance = (target: Element, osInstance: OverlayScrollbars): void => {\n targetInstanceMap.set(target, osInstance);\n};\n\n/**\n * Removes a OverlayScrollbars instance from the given element.\n * @param target The element from which its OverlayScrollbars instance shall be removed.\n */\nexport const removeInstance = (target: Element): void => {\n targetInstanceMap.delete(target);\n};\n\n/**\n * Gets the OverlayScrollbars from the given element or undefined if it doesn't have one.\n * @param target The element of which its OverlayScrollbars instance shall be get.\n */\nexport const getInstance = (target: Element): OverlayScrollbars | undefined =>\n targetInstanceMap.get(target);\n","import {\r\n each,\r\n noop,\r\n debounce,\r\n MutationObserverConstructor,\r\n addEventListener,\r\n is,\r\n find,\r\n push,\r\n runEachAndClear,\r\n bind,\r\n isEmptyArray,\r\n deduplicateArray,\r\n inArray,\r\n concat,\r\n getAttr,\r\n} from '~/support';\r\n\r\ntype DOMContentObserverCallback = (contentChangedThroughEvent: boolean) => any;\r\n\r\ntype DOMTargetObserverCallback = (targetChangedAttrs: string[], targetStyleChanged: boolean) => any;\r\n\r\ninterface DOMObserverOptionsBase {\r\n _attributes?: string[];\r\n /**\r\n * A function which can ignore a changed attribute if it returns true.\r\n * for DOMTargetObserver this applies to the changes to the observed target\r\n * for DOMContentObserver this applies to changes to nested targets -> nested targets are elements which match the \"_nestedTargetSelector\" selector\r\n */\r\n _ignoreTargetChange?: DOMObserverIgnoreTargetChange;\r\n}\r\n\r\ninterface DOMContentObserverOptions extends DOMObserverOptionsBase {\r\n _eventContentChange?: DOMObserverEventContentChange; // [selector, eventname(s) | function returning eventname(s)] -> eventnames divided by whitespaces\r\n _nestedTargetSelector?: string;\r\n _ignoreContentChange?: DOMObserverIgnoreContentChange; // function which will prevent marking certain dom changes as content change if it returns true\r\n}\r\n\r\ninterface DOMTargetObserverOptions extends DOMObserverOptionsBase {\r\n /**\r\n * Marks certain attributes as style changing, should be a subset of the _attributes prop.\r\n * Used to set the \"targetStyleChanged\" param in the DOMTargetObserverCallback.\r\n */\r\n _styleChangingAttributes?: string[];\r\n}\r\n\r\ntype ContentChangeArrayItem = [selector?: string, eventNames?: string] | null | undefined;\r\n\r\nexport type DOMObserverEventContentChange =\r\n | Array\r\n | false\r\n | null\r\n | undefined;\r\n\r\nexport type DOMObserverIgnoreContentChange = (\r\n mutation: MutationRecord,\r\n isNestedTarget: boolean,\r\n domObserverTarget: HTMLElement,\r\n domObserverOptions?: DOMContentObserverOptions\r\n) => boolean;\r\n\r\nexport type DOMObserverIgnoreTargetChange = (\r\n target: Node,\r\n attributeName: string,\r\n oldAttributeValue: string | null,\r\n newAttributeValue: string | null\r\n) => boolean;\r\n\r\nexport type DOMObserverCallback = ContentObserver extends true\r\n ? DOMContentObserverCallback\r\n : DOMTargetObserverCallback;\r\n\r\nexport type DOMObserverOptions = ContentObserver extends true\r\n ? DOMContentObserverOptions\r\n : DOMTargetObserverOptions;\r\n\r\nexport type DOMObserver = [\r\n construct: () => () => void,\r\n update: () => void | false | Parameters>\r\n];\r\n\r\ntype EventContentChangeUpdateElement = (\r\n getElements?: (selector: string) => Node[],\r\n removed?: boolean\r\n) => void;\r\ntype EventContentChange = [destroy: () => void, updateElements: EventContentChangeUpdateElement];\r\n\r\n/**\r\n * Creates a set of helper functions to observe events of elements inside the target element.\r\n * @param target The target element of which the children elements shall be observed. (not only direct children but also nested ones)\r\n * @param eventContentChange The event content change array. (array of tuples: selector and eventname(s))\r\n * @param callback Callback which is called if one of the elements emits the corresponding event.\r\n * @returns A object which contains a set of helper functions to destroy and update the observation of elements.\r\n */\r\nconst createEventContentChange = (\r\n target: HTMLElement,\r\n callback: (...args: any) => any,\r\n eventContentChange?: DOMObserverEventContentChange\r\n): EventContentChange => {\r\n let destroyed = false;\r\n const map = eventContentChange ? new WeakMap any)[]>() : false; // weak map to prevent memory leak for detached elements\r\n const destroy = () => {\r\n destroyed = true;\r\n };\r\n const updateElements: EventContentChangeUpdateElement = (getElements) => {\r\n if (map && eventContentChange) {\r\n const eventElmList = eventContentChange.map((item) => {\r\n const [selector, eventNames] = item || [];\r\n const elements = eventNames && selector ? (getElements || find)(selector, target) : [];\r\n return [elements, eventNames] as const;\r\n });\r\n\r\n each(eventElmList, (item) =>\r\n each(item[0], (elm) => {\r\n const eventNames = item[1];\r\n const entries = map.get(elm) || [];\r\n const isTargetChild = target.contains(elm);\r\n\r\n if (isTargetChild && eventNames) {\r\n const removeListener = addEventListener(elm, eventNames, (event: Event) => {\r\n if (destroyed) {\r\n removeListener();\r\n map.delete(elm);\r\n } else {\r\n callback(event);\r\n }\r\n });\r\n map.set(elm, push(entries, removeListener));\r\n } else {\r\n runEachAndClear(entries);\r\n map.delete(elm);\r\n }\r\n })\r\n );\r\n }\r\n };\r\n\r\n updateElements();\r\n\r\n return [destroy, updateElements];\r\n};\r\n\r\n/**\r\n * Creates a DOM observer which observes DOM changes to either the target element or its children.\r\n * @param target The element which shall be observed.\r\n * @param isContentObserver Whether this observer is just observing the target or just the targets children. (not only direct children but also nested ones)\r\n * @param callback The callback which gets called if a change was detected.\r\n * @param options The options for DOM change detection.\r\n * @returns A object which represents the instance of the DOM observer.\r\n */\r\nexport const createDOMObserver = (\r\n target: HTMLElement,\r\n isContentObserver: ContentObserver,\r\n callback: DOMObserverCallback,\r\n options?: DOMObserverOptions\r\n): DOMObserver => {\r\n let isConnected = false;\r\n const {\r\n _attributes,\r\n _styleChangingAttributes,\r\n _eventContentChange,\r\n _nestedTargetSelector,\r\n _ignoreTargetChange,\r\n _ignoreContentChange,\r\n } = (options as DOMContentObserverOptions & DOMTargetObserverOptions) || {};\r\n const debouncedEventContentChange = debounce(\r\n () => isConnected && (callback as DOMContentObserverCallback)(true),\r\n { _timeout: 33, _maxDelay: 99 }\r\n );\r\n const [destroyEventContentChange, updateEventContentChangeElements] = createEventContentChange(\r\n target,\r\n debouncedEventContentChange,\r\n _eventContentChange\r\n );\r\n\r\n // MutationObserver\r\n const finalAttributes = _attributes || [];\r\n const finalStyleChangingAttributes = _styleChangingAttributes || [];\r\n const observedAttributes = concat(finalAttributes, finalStyleChangingAttributes);\r\n const observerCallback = (\r\n fromRecords: boolean,\r\n mutations: MutationRecord[]\r\n ): void | Parameters> => {\r\n if (!isEmptyArray(mutations)) {\r\n const ignoreTargetChange = _ignoreTargetChange || noop;\r\n const ignoreContentChange = _ignoreContentChange || noop;\r\n const totalChangedNodes: Node[] = [];\r\n const targetChangedAttrs: string[] = [];\r\n let targetStyleChanged: boolean | '' | null | undefined = false;\r\n let contentChanged: boolean | '' | null | undefined = false;\r\n let childListChanged: boolean | '' | null | undefined = false;\r\n\r\n each(mutations, (mutation) => {\r\n const {\r\n attributeName,\r\n target: mutationTarget,\r\n type,\r\n oldValue,\r\n addedNodes,\r\n removedNodes,\r\n } = mutation;\r\n const isAttributesType = type === 'attributes';\r\n const isChildListType = type === 'childList';\r\n const targetIsMutationTarget = target === mutationTarget;\r\n const isAttrChange = isAttributesType && attributeName;\r\n // isAttrChange check needed, otherwise mutationTarget might not be a valid HTMLElement\r\n const attributeValue =\r\n (isAttrChange && getAttr(mutationTarget as HTMLElement, attributeName || '')) || null;\r\n const attributeChanged = isAttrChange && oldValue !== attributeValue;\r\n const styleChangingAttrChanged =\r\n inArray(finalStyleChangingAttributes, attributeName) && attributeChanged;\r\n\r\n // if is content observer and something changed in children\r\n if (isContentObserver && (isChildListType || !targetIsMutationTarget)) {\r\n const contentAttrChanged = isAttributesType && attributeChanged;\r\n const isNestedTarget =\r\n contentAttrChanged &&\r\n _nestedTargetSelector &&\r\n is(mutationTarget, _nestedTargetSelector);\r\n const baseAssertion = isNestedTarget\r\n ? !ignoreTargetChange(mutationTarget, attributeName, oldValue, attributeValue)\r\n : !isAttributesType || contentAttrChanged;\r\n const contentFinalChanged =\r\n baseAssertion && !ignoreContentChange(mutation, !!isNestedTarget, target, options);\r\n\r\n each(addedNodes, (node) => push(totalChangedNodes, node));\r\n each(removedNodes, (node) => push(totalChangedNodes, node));\r\n\r\n contentChanged = contentChanged || contentFinalChanged;\r\n childListChanged = childListChanged || isChildListType;\r\n }\r\n // if is target observer and target attr changed\r\n if (\r\n !isContentObserver &&\r\n targetIsMutationTarget &&\r\n attributeChanged &&\r\n !ignoreTargetChange(mutationTarget, attributeName!, oldValue, attributeValue)\r\n ) {\r\n push(targetChangedAttrs, attributeName);\r\n targetStyleChanged = targetStyleChanged || styleChangingAttrChanged;\r\n }\r\n });\r\n\r\n // adds / removes the new elements from the event content change\r\n updateEventContentChangeElements((selector: string) =>\r\n deduplicateArray(totalChangedNodes).reduce((arr, node) => {\r\n push(arr, find(selector, node));\r\n return is(node, selector) ? push(arr, node) : arr;\r\n }, [])\r\n );\r\n\r\n if (isContentObserver) {\r\n !fromRecords && contentChanged && (callback as DOMContentObserverCallback)(false);\r\n return [false] satisfies Parameters> as Parameters<\r\n DOMObserverCallback\r\n >;\r\n }\r\n\r\n if (!isEmptyArray(targetChangedAttrs) || targetStyleChanged) {\r\n const args = [\r\n deduplicateArray(targetChangedAttrs),\r\n targetStyleChanged,\r\n ] satisfies Parameters & Parameters>;\r\n !fromRecords && (callback as DOMTargetObserverCallback).apply(0, args);\r\n\r\n return args as Parameters>;\r\n }\r\n }\r\n };\r\n const mutationObserver: MutationObserver = new MutationObserverConstructor!(\r\n bind(observerCallback, false)\r\n );\r\n\r\n return [\r\n () => {\r\n mutationObserver.observe(target, {\r\n attributes: true,\r\n attributeOldValue: true,\r\n attributeFilter: observedAttributes,\r\n subtree: isContentObserver,\r\n childList: isContentObserver,\r\n characterData: isContentObserver,\r\n });\r\n isConnected = true;\r\n\r\n return () => {\r\n if (isConnected) {\r\n destroyEventContentChange();\r\n mutationObserver.disconnect();\r\n isConnected = false;\r\n }\r\n };\r\n },\r\n () => {\r\n if (isConnected) {\r\n debouncedEventContentChange._flush();\r\n return observerCallback(true, mutationObserver.takeRecords());\r\n }\r\n },\r\n ];\r\n};\r\n","import {\r\n createCache,\r\n createDOM,\r\n runEachAndClear,\r\n addEventListener,\r\n addClass,\r\n push,\r\n ResizeObserverConstructor,\r\n removeClass,\r\n stopPropagation,\r\n appendChildren,\r\n getDirectionIsRTL,\r\n domRectHasDimensions,\r\n bind,\r\n noop,\r\n isArray,\r\n convertScrollPosition,\r\n scrollElementTo,\r\n domRectAppeared,\r\n concat,\r\n} from '~/support';\r\nimport { getEnvironment } from '~/environment';\r\nimport {\r\n classNameSizeObserver,\r\n classNameSizeObserverAppear,\r\n classNameSizeObserverListener,\r\n} from '~/classnames';\r\nimport { getStaticPluginModuleInstance, sizeObserverPluginName } from '~/plugins';\r\nimport type { CacheValues } from '~/support';\r\nimport type { SizeObserverPlugin } from '~/plugins';\r\n\r\nexport interface SizeObserverOptions {\r\n /** Whether direction changes should be observed. */\r\n _direction?: boolean;\r\n /** Whether appearing should be observed. */\r\n _appear?: boolean;\r\n}\r\n\r\nexport interface SizeObserverCallbackParams {\r\n _sizeChanged: boolean;\r\n _directionIsRTLCache?: CacheValues;\r\n _appear?: boolean;\r\n}\r\n\r\nexport type SizeObserver = () => () => void;\r\n\r\n/**\r\n * Creates a size observer which observes any size, padding, border, margin and box-sizing changes of the target element. Depending on the options also direction and appear can be observed.\r\n * @param target The target element which shall be observed.\r\n * @param onSizeChangedCallback The callback which gets called after a size change was detected.\r\n * @param options The options for size detection, whether to observe also direction and appear.\r\n * @returns A object which represents the instance of the size observer.\r\n */\r\nexport const createSizeObserver = (\r\n target: HTMLElement,\r\n onSizeChangedCallback: (params: SizeObserverCallbackParams) => any,\r\n options?: SizeObserverOptions\r\n): SizeObserver => {\r\n const scrollAmount = 3333333;\r\n const { _direction: observeDirectionChange, _appear: observeAppearChange } = options || {};\r\n const sizeObserverPlugin =\r\n getStaticPluginModuleInstance(sizeObserverPluginName);\r\n const { _rtlScrollBehavior: rtlScrollBehavior } = getEnvironment();\r\n const getIsDirectionRTL = bind(getDirectionIsRTL, target);\r\n const [updateResizeObserverContentRectCache] = createCache({\r\n _initialValue: false,\r\n _alwaysUpdateValues: true,\r\n });\r\n\r\n return () => {\r\n const destroyFns: (() => void)[] = [];\r\n const baseElements = createDOM(\r\n `
`\r\n );\r\n const sizeObserver = baseElements[0] as HTMLElement;\r\n const listenerElement = sizeObserver.firstChild as HTMLElement;\r\n const onSizeChangedCallbackProxy = (\r\n sizeChangedContext?: CacheValues | ResizeObserverEntry | boolean\r\n ) => {\r\n const isResizeObserverCall = sizeChangedContext instanceof ResizeObserverEntry;\r\n const hasDirectionCache = !isResizeObserverCall && isArray(sizeChangedContext);\r\n\r\n let skip = false;\r\n let appear = false;\r\n let doDirectionScroll = true; // always true if sizeChangedContext is Event (appear callback or RO. Polyfill)\r\n\r\n // if triggered from RO.\r\n if (isResizeObserverCall) {\r\n const [currRContentRect, , prevContentRect] = updateResizeObserverContentRectCache(\r\n sizeChangedContext.contentRect\r\n );\r\n const hasDimensions = domRectHasDimensions(currRContentRect);\r\n const appeared = domRectAppeared(currRContentRect, prevContentRect);\r\n const firstCall = !prevContentRect;\r\n appear = firstCall || appeared;\r\n skip = !appear && !hasDimensions; // skip if display is none or when window resize\r\n\r\n doDirectionScroll = !skip; // direction scroll when not skipping\r\n }\r\n // else if its triggered with DirectionCache\r\n else if (hasDirectionCache) {\r\n [, doDirectionScroll] = sizeChangedContext; // direction scroll when DirectionCache changed, false otherwise\r\n }\r\n // else if it triggered with appear from polyfill\r\n else {\r\n appear = sizeChangedContext === true;\r\n }\r\n\r\n if (observeDirectionChange && doDirectionScroll) {\r\n const rtl = hasDirectionCache ? sizeChangedContext[0] : getDirectionIsRTL(sizeObserver);\r\n scrollElementTo(sizeObserver, {\r\n x: convertScrollPosition(scrollAmount, scrollAmount, rtl && rtlScrollBehavior),\r\n y: scrollAmount,\r\n });\r\n }\r\n\r\n if (!skip) {\r\n onSizeChangedCallback({\r\n _directionIsRTLCache: hasDirectionCache ? sizeChangedContext : undefined,\r\n _sizeChanged: !hasDirectionCache,\r\n _appear: appear,\r\n });\r\n }\r\n };\r\n\r\n if (ResizeObserverConstructor) {\r\n const resizeObserverInstance = new ResizeObserverConstructor((entries) =>\r\n onSizeChangedCallbackProxy(entries.pop())\r\n );\r\n resizeObserverInstance.observe(listenerElement);\r\n push(destroyFns, () => {\r\n resizeObserverInstance.disconnect();\r\n });\r\n } else if (sizeObserverPlugin) {\r\n const [pluginAppearCallback, pluginDestroyFns] = sizeObserverPlugin(\r\n listenerElement,\r\n onSizeChangedCallbackProxy,\r\n observeAppearChange\r\n );\r\n push(\r\n destroyFns,\r\n concat(\r\n [\r\n addClass(sizeObserver, classNameSizeObserverAppear),\r\n addEventListener(sizeObserver, 'animationstart', pluginAppearCallback),\r\n ],\r\n pluginDestroyFns\r\n )\r\n );\r\n } else {\r\n return noop;\r\n }\r\n\r\n if (observeDirectionChange) {\r\n const [updateDirectionIsRTLCache] = createCache(\r\n {\r\n _initialValue: undefined,\r\n },\r\n getIsDirectionRTL\r\n );\r\n\r\n push(\r\n destroyFns,\r\n addEventListener(sizeObserver, 'scroll', (event) => {\r\n const directionIsRTLCacheValues = updateDirectionIsRTLCache();\r\n const [directionIsRTLCache, directionIsRTLCacheChanged, directionIsRTLCachePrevious] =\r\n directionIsRTLCacheValues;\r\n if (directionIsRTLCacheChanged) {\r\n removeClass(listenerElement, 'ltr rtl');\r\n addClass(listenerElement, directionIsRTLCache ? 'rtl' : 'ltr');\r\n\r\n onSizeChangedCallbackProxy([\r\n !!directionIsRTLCache,\r\n directionIsRTLCacheChanged,\r\n directionIsRTLCachePrevious,\r\n ]);\r\n }\r\n\r\n stopPropagation(event);\r\n })\r\n );\r\n }\r\n\r\n return bind(runEachAndClear, push(destroyFns, appendChildren(target, sizeObserver)));\r\n };\r\n};\r\n","import {\r\n createDiv,\r\n offsetSize,\r\n runEachAndClear,\r\n createCache,\r\n push,\r\n IntersectionObserverConstructor,\r\n appendChildren,\r\n bind,\r\n} from '~/support';\r\nimport { createSizeObserver } from '~/observers/sizeObserver';\r\nimport { classNameTrinsicObserver } from '~/classnames';\r\nimport type { WH, CacheValues } from '~/support';\r\n\r\nexport type TrinsicObserverCallback = (heightIntrinsic: CacheValues) => any;\r\nexport type TrinsicObserver = [\r\n construct: () => () => void,\r\n update: () => void | false | null | undefined | Parameters\r\n];\r\n\r\n/**\r\n * Creates a trinsic observer which observes changes to intrinsic or extrinsic sizing for the height of the target element.\r\n * @param target The element which shall be observed.\r\n * @param onTrinsicChangedCallback The callback which gets called after a change was detected.\r\n * @returns A object which represents the instance of the trinsic observer.\r\n */\r\nexport const createTrinsicObserver = (\r\n target: HTMLElement,\r\n onTrinsicChangedCallback: TrinsicObserverCallback\r\n): TrinsicObserver => {\r\n let intersectionObserverInstance: undefined | IntersectionObserver;\r\n const isHeightIntrinsic = (ioEntryOrSize: IntersectionObserverEntry | WH): boolean =>\r\n (ioEntryOrSize as WH).h === 0 ||\r\n (ioEntryOrSize as IntersectionObserverEntry).isIntersecting ||\r\n (ioEntryOrSize as IntersectionObserverEntry).intersectionRatio > 0;\r\n const trinsicObserver = createDiv(classNameTrinsicObserver);\r\n const [updateHeightIntrinsicCache] = createCache({\r\n _initialValue: false,\r\n });\r\n const triggerOnTrinsicChangedCallback = (\r\n updateValue: IntersectionObserverEntry | WH | undefined,\r\n fromRecords?: boolean\r\n ): void | Parameters => {\r\n if (updateValue) {\r\n const heightIntrinsic = updateHeightIntrinsicCache(isHeightIntrinsic(updateValue));\r\n const [, heightIntrinsicChanged] = heightIntrinsic;\r\n return (\r\n heightIntrinsicChanged &&\r\n !fromRecords &&\r\n onTrinsicChangedCallback(heightIntrinsic) && [heightIntrinsic]\r\n );\r\n }\r\n };\r\n const intersectionObserverCallback = (\r\n fromRecords: boolean,\r\n entries: IntersectionObserverEntry[]\r\n ) => triggerOnTrinsicChangedCallback(entries.pop(), fromRecords);\r\n\r\n return [\r\n () => {\r\n const destroyFns: (() => void)[] = [];\r\n\r\n if (IntersectionObserverConstructor) {\r\n intersectionObserverInstance = new IntersectionObserverConstructor(\r\n bind(intersectionObserverCallback, false),\r\n { root: target }\r\n );\r\n intersectionObserverInstance.observe(trinsicObserver);\r\n push(destroyFns, () => {\r\n intersectionObserverInstance!.disconnect();\r\n });\r\n } else {\r\n const onSizeChanged = () => {\r\n const newSize = offsetSize(trinsicObserver);\r\n triggerOnTrinsicChangedCallback(newSize);\r\n };\r\n push(destroyFns, createSizeObserver(trinsicObserver, onSizeChanged)());\r\n onSizeChanged();\r\n }\r\n\r\n return bind(runEachAndClear, push(destroyFns, appendChildren(target, trinsicObserver)));\r\n },\r\n () =>\r\n intersectionObserverInstance &&\r\n intersectionObserverCallback(true, intersectionObserverInstance.takeRecords()),\r\n ];\r\n};\r\n","import {\r\n ResizeObserverConstructor,\r\n assignDeep,\r\n closest,\r\n createCache,\r\n debounce,\r\n getDirectionIsRTL,\r\n each,\r\n equalWH,\r\n fractionalSize,\r\n isArray,\r\n isFunction,\r\n isNumber,\r\n isString,\r\n keys,\r\n liesBetween,\r\n removeAttrs,\r\n scrollSize,\r\n getElmentScroll,\r\n scrollElementTo,\r\n inArray,\r\n domRectAppeared,\r\n concat,\r\n getAttr,\r\n setAttrs,\r\n} from '~/support';\r\nimport { createDOMObserver, createSizeObserver, createTrinsicObserver } from '~/observers';\r\nimport { getEnvironment } from '~/environment';\r\nimport {\r\n classNameScrollbar,\r\n dataAttributeHost,\r\n dataAttributeViewport,\r\n dataValueHostUpdating,\r\n dataValueViewportArrange,\r\n dataValueViewportOverflowVisible,\r\n} from '~/classnames';\r\nimport { getStaticPluginModuleInstance, scrollbarsHidingPluginName } from '~/plugins';\r\nimport type { Options, OptionsCheckFn } from '~/options';\r\nimport type { ScrollbarsHidingPlugin } from '~/plugins';\r\nimport type { SizeObserverCallbackParams } from '~/observers';\r\nimport type { StructureSetupElementsObj } from '../structureSetup/structureSetup.elements';\r\nimport type { Setup, SetupUpdateInfo, StructureSetupState } from '~/setups';\r\nimport type { CacheValues, WH } from '~/support';\r\nimport type { PlainObject } from '~/typings';\r\n\r\nexport interface ObserversSetupState {\r\n _heightIntrinsic: boolean;\r\n _directionIsRTL: boolean;\r\n}\r\n\r\nexport interface ObserversSetupUpdateInfo extends SetupUpdateInfo {\r\n _takeRecords?: boolean;\r\n}\r\n\r\nexport type ObserversSetupUpdateHints = {\r\n _sizeChanged?: boolean;\r\n _directionChanged?: boolean;\r\n _heightIntrinsicChanged?: boolean;\r\n _hostMutation?: boolean;\r\n _contentMutation?: boolean;\r\n _appear?: boolean;\r\n _scrollbarSizeChanged?: boolean;\r\n};\r\n\r\nexport type ObserversSetup = Setup<\r\n ObserversSetupUpdateInfo,\r\n ObserversSetupState,\r\n ObserversSetupUpdateHints\r\n>;\r\n\r\nexport const createObserversSetup = (\r\n structureSetupElements: StructureSetupElementsObj,\r\n structureSetupState: StructureSetupState,\r\n getCurrentOption: OptionsCheckFn,\r\n onObserversUpdated: (updateHints: ObserversSetupUpdateHints) => void\r\n): ObserversSetup => {\r\n let debounceTimeout: number | false | undefined;\r\n let debounceMaxDelay: number | false | undefined;\r\n let updateContentMutationObserver: (() => void) | undefined;\r\n let destroyContentMutationObserver: (() => void) | undefined;\r\n let prevContentRect: DOMRectReadOnly | undefined;\r\n let prevDirectionIsRTL: boolean | undefined;\r\n\r\n const { _nativeScrollbarsHiding } = getEnvironment();\r\n\r\n const hostSelector = `[${dataAttributeHost}]`;\r\n\r\n // TODO: observer textarea attrs if textarea\r\n\r\n const viewportSelector = `[${dataAttributeViewport}]`;\r\n const viewportAttrsFromTarget = ['tabindex'];\r\n const baseStyleChangingAttrsTextarea = ['wrap', 'cols', 'rows'];\r\n const baseStyleChangingAttrs = ['id', 'class', 'style', 'open'];\r\n const {\r\n _target,\r\n _host,\r\n _viewport,\r\n _content,\r\n _isTextarea,\r\n _viewportIsTarget,\r\n _viewportHasClass,\r\n _viewportAddRemoveClass,\r\n } = structureSetupElements;\r\n\r\n const state: ObserversSetupState = {\r\n _heightIntrinsic: false,\r\n _directionIsRTL: getDirectionIsRTL(_target),\r\n };\r\n const env = getEnvironment();\r\n const scrollbarsHidingPlugin = getStaticPluginModuleInstance(\r\n scrollbarsHidingPluginName\r\n );\r\n\r\n const [updateContentSizeCache] = createCache>(\r\n {\r\n _equal: equalWH,\r\n _initialValue: { w: 0, h: 0 },\r\n },\r\n () => {\r\n const _undoViewportArrange =\r\n scrollbarsHidingPlugin &&\r\n scrollbarsHidingPlugin._viewportArrangement(\r\n structureSetupElements,\r\n structureSetupState,\r\n state,\r\n env,\r\n getCurrentOption\r\n )._undoViewportArrange;\r\n\r\n const hasOver = _viewportHasClass(dataValueViewportOverflowVisible);\r\n const isArranged = !_viewportIsTarget && _viewportHasClass(dataValueViewportArrange);\r\n const scrollOffset = isArranged && getElmentScroll(_viewport);\r\n\r\n _viewportAddRemoveClass(dataValueViewportOverflowVisible);\r\n _viewportIsTarget && _viewportAddRemoveClass(dataValueHostUpdating, true);\r\n const redoViewportArrange = isArranged && _undoViewportArrange && _undoViewportArrange()[0];\r\n\r\n const contentScroll = scrollSize(_content);\r\n const viewportScroll = scrollSize(_viewport);\r\n const fractional = fractionalSize(_viewport);\r\n\r\n _viewportAddRemoveClass(dataValueViewportOverflowVisible, hasOver);\r\n _viewportIsTarget && _viewportAddRemoveClass(dataValueHostUpdating);\r\n redoViewportArrange && redoViewportArrange();\r\n\r\n scrollElementTo(_viewport, scrollOffset);\r\n\r\n return {\r\n w: viewportScroll.w + contentScroll.w + fractional.w,\r\n h: viewportScroll.h + contentScroll.h + fractional.h,\r\n };\r\n }\r\n );\r\n\r\n const contentMutationObserverAttr = _isTextarea\r\n ? baseStyleChangingAttrsTextarea\r\n : concat(baseStyleChangingAttrs, baseStyleChangingAttrsTextarea);\r\n\r\n const onObserversUpdatedDebounced = debounce(onObserversUpdated, {\r\n _timeout: () => debounceTimeout,\r\n _maxDelay: () => debounceMaxDelay,\r\n _mergeParams(prev, curr) {\r\n const [prevObj] = prev;\r\n const [currObj] = curr;\r\n return [\r\n concat(keys(prevObj), keys(currObj)).reduce((obj, key) => {\r\n obj[key] = prevObj[key as keyof typeof prevObj] || currObj[key as keyof typeof currObj];\r\n return obj;\r\n }, {} as PlainObject),\r\n ] as [Partial];\r\n },\r\n });\r\n\r\n const setDirectionWhenViewportIsTarget = (updateHints: ObserversSetupUpdateHints) => {\r\n if (_viewportIsTarget) {\r\n const newDirectionIsRTL = getDirectionIsRTL(_target);\r\n assignDeep(updateHints, { _directionChanged: prevDirectionIsRTL !== newDirectionIsRTL });\r\n assignDeep(state, { _directionIsRTL: newDirectionIsRTL });\r\n prevDirectionIsRTL = newDirectionIsRTL;\r\n }\r\n };\r\n\r\n const updateViewportAttrsFromHost = (attributes?: string[]) => {\r\n each(attributes || viewportAttrsFromTarget, (attribute) => {\r\n if (inArray(viewportAttrsFromTarget, attribute)) {\r\n const hostAttr = getAttr(_host, attribute);\r\n if (isString(hostAttr)) {\r\n setAttrs(_viewport, attribute, hostAttr);\r\n } else {\r\n removeAttrs(_viewport, attribute);\r\n }\r\n }\r\n });\r\n };\r\n\r\n const onTrinsicChanged = (\r\n heightIntrinsicCache: CacheValues,\r\n fromRecords?: true\r\n ): ObserversSetupUpdateHints => {\r\n const [heightIntrinsic, heightIntrinsicChanged] = heightIntrinsicCache;\r\n const updateHints: ObserversSetupUpdateHints = {\r\n _heightIntrinsicChanged: heightIntrinsicChanged,\r\n };\r\n\r\n assignDeep(state, { _heightIntrinsic: heightIntrinsic });\r\n !fromRecords && onObserversUpdated(updateHints);\r\n\r\n return updateHints;\r\n };\r\n\r\n const onSizeChanged = ({\r\n _sizeChanged,\r\n _directionIsRTLCache,\r\n _appear,\r\n }: SizeObserverCallbackParams) => {\r\n const exclusiveSizeChange = _sizeChanged && !_appear && !_directionIsRTLCache;\r\n const updateFn =\r\n // use debounceed update:\r\n // if native scrollbars hiding is supported\r\n // and if the update is more than just a exclusive sizeChange (e.g. size change + appear, or size change + direction)\r\n !exclusiveSizeChange && _nativeScrollbarsHiding\r\n ? onObserversUpdatedDebounced\r\n : onObserversUpdated;\r\n\r\n const [directionIsRTL, directionIsRTLChanged] = _directionIsRTLCache || [];\r\n const updateHints: ObserversSetupUpdateHints = {\r\n _sizeChanged: _sizeChanged || _appear,\r\n _appear,\r\n _directionChanged: directionIsRTLChanged,\r\n };\r\n\r\n setDirectionWhenViewportIsTarget(updateHints);\r\n\r\n _directionIsRTLCache && assignDeep(state, { _directionIsRTL: directionIsRTL });\r\n\r\n updateFn(updateHints);\r\n };\r\n\r\n const onContentMutation = (\r\n contentChangedThroughEvent: boolean,\r\n fromRecords?: true\r\n ): ObserversSetupUpdateHints => {\r\n const [, _contentMutation] = updateContentSizeCache();\r\n const updateHints: ObserversSetupUpdateHints = {\r\n _contentMutation,\r\n };\r\n\r\n setDirectionWhenViewportIsTarget(updateHints);\r\n\r\n // if contentChangedThroughEvent is true its already debounced\r\n const updateFn = contentChangedThroughEvent ? onObserversUpdated : onObserversUpdatedDebounced;\r\n\r\n _contentMutation && !fromRecords && updateFn(updateHints);\r\n\r\n return updateHints;\r\n };\r\n\r\n const onHostMutation = (\r\n targetChangedAttrs: string[],\r\n targetStyleChanged: boolean,\r\n fromRecords?: true\r\n ): ObserversSetupUpdateHints => {\r\n const updateHints: ObserversSetupUpdateHints = {\r\n _hostMutation: targetStyleChanged,\r\n };\r\n\r\n setDirectionWhenViewportIsTarget(updateHints);\r\n\r\n if (targetStyleChanged && !fromRecords) {\r\n onObserversUpdatedDebounced(updateHints);\r\n } else if (!_viewportIsTarget) {\r\n updateViewportAttrsFromHost(targetChangedAttrs);\r\n }\r\n\r\n return updateHints;\r\n };\r\n\r\n const { _addResizeListener } = env;\r\n const [constructTrinsicObserver, updateTrinsicObserver] = _content\r\n ? createTrinsicObserver(_host, onTrinsicChanged)\r\n : [];\r\n\r\n const constructSizeObserver =\r\n !_viewportIsTarget &&\r\n createSizeObserver(_host, onSizeChanged, {\r\n _appear: true,\r\n _direction: true,\r\n });\r\n\r\n const [constructHostMutationObserver, updateHostMutationObserver] = createDOMObserver(\r\n _host,\r\n false,\r\n onHostMutation,\r\n {\r\n _styleChangingAttributes: baseStyleChangingAttrs,\r\n _attributes: concat(baseStyleChangingAttrs, viewportAttrsFromTarget),\r\n }\r\n );\r\n\r\n const viewportIsTargetResizeObserver =\r\n _viewportIsTarget &&\r\n ResizeObserverConstructor &&\r\n new ResizeObserverConstructor((entries) => {\r\n const currContentRect = entries[entries.length - 1].contentRect;\r\n onSizeChanged({\r\n _sizeChanged: true,\r\n _appear: domRectAppeared(currContentRect, prevContentRect),\r\n });\r\n prevContentRect = currContentRect;\r\n });\r\n\r\n return [\r\n () => {\r\n // order is matter!\r\n updateViewportAttrsFromHost();\r\n viewportIsTargetResizeObserver && viewportIsTargetResizeObserver.observe(_host);\r\n const destroySizeObserver = constructSizeObserver && constructSizeObserver();\r\n const destroyTrinsicObserver = constructTrinsicObserver && constructTrinsicObserver();\r\n const destroyHostMutationObserver = constructHostMutationObserver();\r\n const removeResizeListener = _addResizeListener((_scrollbarSizeChanged) => {\r\n const [, _contentMutation] = updateContentSizeCache();\r\n onObserversUpdatedDebounced({ _scrollbarSizeChanged, _contentMutation });\r\n });\r\n\r\n return () => {\r\n viewportIsTargetResizeObserver && viewportIsTargetResizeObserver.disconnect();\r\n destroySizeObserver && destroySizeObserver();\r\n destroyTrinsicObserver && destroyTrinsicObserver();\r\n destroyContentMutationObserver && destroyContentMutationObserver();\r\n destroyHostMutationObserver();\r\n removeResizeListener();\r\n };\r\n },\r\n ({ _checkOption, _takeRecords, _force }) => {\r\n const updateHints: ObserversSetupUpdateHints = {};\r\n\r\n const [ignoreMutation] = _checkOption('update.ignoreMutation');\r\n const [attributes, attributesChanged] = _checkOption('update.attributes');\r\n const [elementEvents, elementEventsChanged] = _checkOption('update.elementEvents');\r\n const [debounceValue, debounceChanged] = _checkOption('update.debounce');\r\n const contentMutationObserverChanged = elementEventsChanged || attributesChanged;\r\n const takeRecords = _takeRecords || _force;\r\n const ignoreMutationFromOptions = (mutation: MutationRecord) =>\r\n isFunction(ignoreMutation) && ignoreMutation(mutation);\r\n\r\n if (contentMutationObserverChanged) {\r\n updateContentMutationObserver && updateContentMutationObserver();\r\n destroyContentMutationObserver && destroyContentMutationObserver();\r\n\r\n const [construct, update] = createDOMObserver(\r\n _content || _viewport,\r\n true,\r\n onContentMutation,\r\n {\r\n _attributes: concat(contentMutationObserverAttr, attributes || []),\r\n _eventContentChange: elementEvents,\r\n _nestedTargetSelector: hostSelector,\r\n _ignoreContentChange: (mutation, isNestedTarget) => {\r\n const { target: mutationTarget, attributeName } = mutation;\r\n const ignore =\r\n !isNestedTarget && attributeName && !_viewportIsTarget\r\n ? liesBetween(mutationTarget, hostSelector, viewportSelector)\r\n : false;\r\n return (\r\n ignore ||\r\n !!closest(mutationTarget, `.${classNameScrollbar}`) || // ignore explicitely all scrollbar elements\r\n !!ignoreMutationFromOptions(mutation)\r\n );\r\n },\r\n }\r\n );\r\n\r\n destroyContentMutationObserver = construct();\r\n updateContentMutationObserver = update;\r\n }\r\n\r\n if (debounceChanged) {\r\n onObserversUpdatedDebounced._flush();\r\n if (isArray(debounceValue)) {\r\n const timeout = debounceValue[0];\r\n const maxWait = debounceValue[1];\r\n debounceTimeout = isNumber(timeout) && timeout;\r\n debounceMaxDelay = isNumber(maxWait) && maxWait;\r\n } else if (isNumber(debounceValue)) {\r\n debounceTimeout = debounceValue;\r\n debounceMaxDelay = false;\r\n } else {\r\n debounceTimeout = false;\r\n debounceMaxDelay = false;\r\n }\r\n }\r\n\r\n if (takeRecords) {\r\n const hostUpdateResult = updateHostMutationObserver();\r\n const trinsicUpdateResult = updateTrinsicObserver && updateTrinsicObserver();\r\n const contentUpdateResult =\r\n updateContentMutationObserver && updateContentMutationObserver();\r\n\r\n hostUpdateResult &&\r\n assignDeep(\r\n updateHints,\r\n onHostMutation(hostUpdateResult[0], hostUpdateResult[1], takeRecords)\r\n );\r\n\r\n trinsicUpdateResult &&\r\n assignDeep(updateHints, onTrinsicChanged(trinsicUpdateResult[0], takeRecords));\r\n\r\n contentUpdateResult &&\r\n assignDeep(updateHints, onContentMutation(contentUpdateResult[0], takeRecords));\r\n }\r\n\r\n setDirectionWhenViewportIsTarget(updateHints);\r\n\r\n return updateHints;\r\n },\r\n state,\r\n ];\r\n};\r\n","import {\r\n addClass,\r\n appendChildren,\r\n createDiv,\r\n getDirectionIsRTL,\r\n each,\r\n getTrasformTranslateValue,\r\n isBoolean,\r\n parent,\r\n push,\r\n removeClass,\r\n removeElements,\r\n runEachAndClear,\r\n scrollT,\r\n bind,\r\n getElmentScroll,\r\n inArray,\r\n strWidth,\r\n strHeight,\r\n concat,\r\n assignDeep,\r\n ratioToCssPercent,\r\n numberToCssPx,\r\n setStyles,\r\n createOrKeepArray,\r\n getRawScrollBounds,\r\n getRawScrollRatio,\r\n getBoundingClientRect,\r\n capNumber,\r\n} from '~/support';\r\nimport {\r\n classNameScrollbar,\r\n classNameScrollbarHorizontal,\r\n classNameScrollbarVertical,\r\n classNameScrollbarTrack,\r\n classNameScrollbarHandle,\r\n} from '~/classnames';\r\nimport { getEnvironment } from '~/environment';\r\nimport { dynamicInitializationElement as generalDynamicInitializationElement } from '~/initialization';\r\nimport type { RTLScrollBehavior } from '~/support';\r\nimport type {\r\n InitializationTarget,\r\n InitializationTargetElement,\r\n InitializationTargetObject,\r\n} from '~/initialization';\r\nimport type { StructureSetupElementsObj } from '../structureSetup/structureSetup.elements';\r\nimport type { ScrollbarsSetupEvents } from './scrollbarsSetup.events';\r\nimport type { StyleObject } from '~/typings';\r\nimport type { StructureSetupState } from '../structureSetup';\r\n\r\nexport interface ScrollbarStructure {\r\n _scrollbar: HTMLElement;\r\n _track: HTMLElement;\r\n _handle: HTMLElement;\r\n}\r\n\r\nexport interface ScrollbarsSetupElement {\r\n _scrollTimeline: AnimationTimeline | undefined;\r\n _scrollbarStructures: ScrollbarStructure[];\r\n _clone: () => ScrollbarStructure;\r\n _style: (\r\n elmStyle: (\r\n scrollbarStructure: ScrollbarStructure\r\n ) => [HTMLElement | false | null | undefined, StyleObject]\r\n ) => void;\r\n}\r\n\r\nexport interface ScrollbarsSetupElementsObj {\r\n _scrollbarsAddRemoveClass: (\r\n classNames: string | false | null | undefined,\r\n add?: boolean,\r\n isHorizontal?: boolean\r\n ) => void;\r\n _refreshScrollbarsHandleLength: () => void;\r\n _refreshScrollbarsHandleOffset: () => void;\r\n _refreshScrollbarsScrollbarOffset: () => void;\r\n _horizontal: ScrollbarsSetupElement;\r\n _vertical: ScrollbarsSetupElement;\r\n}\r\n\r\nexport type ScrollbarsSetupElements = [\r\n elements: ScrollbarsSetupElementsObj,\r\n appendElements: () => () => void\r\n];\r\n\r\ntype PotentialAnimation = Animation | false | null | undefined;\r\n\r\nexport const createScrollbarsSetupElements = (\r\n target: InitializationTarget,\r\n structureSetupElements: StructureSetupElementsObj,\r\n structureSetupState: StructureSetupState,\r\n scrollbarsSetupEvents: ScrollbarsSetupEvents\r\n): ScrollbarsSetupElements => {\r\n const { _getDefaultInitialization, _rtlScrollBehavior } = getEnvironment();\r\n const { scrollbars: defaultInitScrollbars } = _getDefaultInitialization();\r\n const { slot: defaultInitScrollbarsSlot } = defaultInitScrollbars;\r\n const {\r\n _target,\r\n _host,\r\n _viewport,\r\n _targetIsElm,\r\n _scrollOffsetElement,\r\n _isBody,\r\n _viewportIsTarget,\r\n } = structureSetupElements;\r\n const { scrollbars: scrollbarsInit } = (_targetIsElm ? {} : target) as InitializationTargetObject;\r\n const { slot: initScrollbarsSlot } = scrollbarsInit || {};\r\n const elementAnimations = new Map();\r\n const initScrollTimeline = (axis: 'x' | 'y') =>\r\n scrollT &&\r\n new scrollT({\r\n source: _scrollOffsetElement,\r\n axis,\r\n });\r\n const scrollTimelineX = initScrollTimeline('x');\r\n const scrollTimelineY = initScrollTimeline('y');\r\n const evaluatedScrollbarSlot = generalDynamicInitializationElement<\r\n [InitializationTargetElement, HTMLElement, HTMLElement]\r\n >(\r\n [_target, _host, _viewport],\r\n () => (_viewportIsTarget && _isBody ? _target : _host),\r\n defaultInitScrollbarsSlot,\r\n initScrollbarsSlot\r\n );\r\n\r\n /**\r\n * Gets the scrollbar handle length ratio.\r\n * @param isHorizontal Whether the axis is horizontal.\r\n * @param scrollbarStructure The scrollbar structure. Only passed when the length ratio is calculated for the offset ratio (respects handle min. & max. size via. css)\r\n * @returns The scrollbar handle length ratio.\r\n */\r\n const getScrollbarHandleLengthRatio = (\r\n isHorizontal?: boolean,\r\n scrollbarStructure?: ScrollbarStructure\r\n ) => {\r\n if (scrollbarStructure) {\r\n const axis = isHorizontal ? strWidth : strHeight;\r\n const { _track, _handle } = scrollbarStructure;\r\n\r\n const handleSize = getBoundingClientRect(_handle)[axis];\r\n const trackSize = getBoundingClientRect(_track)[axis];\r\n\r\n return capNumber(0, 1, handleSize / trackSize || 0);\r\n }\r\n\r\n const axis = isHorizontal ? 'x' : 'y';\r\n const { _overflowAmount, _overflowEdge } = structureSetupState;\r\n\r\n const viewportSize = _overflowEdge[axis];\r\n const overflowAmount = _overflowAmount[axis];\r\n\r\n return capNumber(0, 1, viewportSize / (viewportSize + overflowAmount) || 0);\r\n };\r\n\r\n /**\r\n * Gets the scrollbar handle offset ratio.\r\n * @param structureSetupState The structure setup state.\r\n * @param scrollbarStructure The scrollbar structure.\r\n * @param scrollPercent The scroll percent 0..1.\r\n * @param isHorizontal Whether the axis is horizontal.\r\n * @returns The scrollbar handle offset ratio.\r\n */\r\n const getScrollbarHandleOffsetRatio = (\r\n scrollbarStructure: ScrollbarStructure,\r\n scrollPercent: number,\r\n isHorizontal?: boolean,\r\n rtlScrollBehavior?: RTLScrollBehavior\r\n ) => {\r\n const lengthRatio = getScrollbarHandleLengthRatio(isHorizontal, scrollbarStructure);\r\n\r\n return (\r\n (1 / lengthRatio) *\r\n (1 - lengthRatio) *\r\n (rtlScrollBehavior ? 1 - scrollPercent : scrollPercent) || 0\r\n );\r\n };\r\n\r\n /**\r\n * Adds additional directional keyframes to the passed keyframes.\r\n * @param keyframes The keyframes.\r\n * @param directionRTL Whether the direction is RTL.\r\n * @returns The passed keyframes with additional directional keyframes.\r\n */\r\n const addDirectionRTLKeyframes = (\r\n keyframes: Keyframe[] | PropertyIndexedKeyframes | null,\r\n directionRTL?: boolean | RTLScrollBehavior\r\n ) =>\r\n assignDeep(\r\n keyframes,\r\n directionRTL\r\n ? {\r\n clear: ['left'], // dummy keyframe for direction rtl animation because of chrome bug\r\n }\r\n : {}\r\n );\r\n\r\n /**\r\n * Cancels the animations of the passed elements or of all elements if no elements are passed.\r\n * @param elements The elements of which the animation shall be canceled.\r\n */\r\n const cancelElementAnimations = (elements?: HTMLElement | HTMLElement[]) => {\r\n elementAnimations.forEach((currAnimations, element) => {\r\n const doCancel = elements ? inArray(createOrKeepArray(elements), element) : true;\r\n if (doCancel) {\r\n each(currAnimations || [], (animation) => {\r\n animation && animation.cancel();\r\n });\r\n elementAnimations.delete(element);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * Sets of overwrites the animation of the passed element.\r\n * @param element The element of which the animation shall be set.\r\n * @param timeline The animation timeline of the animation.\r\n * @param keyframes The keyframes of the animation.\r\n * @param composite The composite information of the animation.\r\n */\r\n const setElementAnimation = (\r\n element: HTMLElement,\r\n timeline: AnimationTimeline,\r\n keyframes: Keyframe[] | PropertyIndexedKeyframes | null,\r\n composite?: CompositeOperation\r\n ) => {\r\n const activeAnimations = elementAnimations.get(element) || [];\r\n const activeAnimation = activeAnimations.find(\r\n (animation) => animation && animation.timeline === timeline\r\n );\r\n\r\n if (activeAnimation) {\r\n activeAnimation.effect = new KeyframeEffect(element, keyframes, { composite });\r\n } else {\r\n elementAnimations.set(\r\n element,\r\n concat(activeAnimations, [\r\n element.animate(keyframes, {\r\n timeline,\r\n composite,\r\n }),\r\n ])\r\n );\r\n }\r\n };\r\n\r\n const scrollbarStructureAddRemoveClass = (\r\n scrollbarStructures: ScrollbarStructure[],\r\n classNames: string | false | null | undefined,\r\n add?: boolean\r\n ) => {\r\n const action = add ? addClass : removeClass;\r\n each(scrollbarStructures, (scrollbarStructure) => {\r\n action(scrollbarStructure._scrollbar, classNames);\r\n });\r\n };\r\n const scrollbarStyle = (\r\n scrollbarStructures: ScrollbarStructure[],\r\n elmStyle: (\r\n scrollbarStructure: ScrollbarStructure\r\n ) => [HTMLElement | false | null | undefined, StyleObject]\r\n ) => {\r\n each(scrollbarStructures, (scrollbarStructure) => {\r\n const [elm, styles] = elmStyle(scrollbarStructure);\r\n setStyles(elm, styles);\r\n });\r\n };\r\n const scrollbarStructureRefreshHandleLength = (\r\n scrollbarStructures: ScrollbarStructure[],\r\n isHorizontal?: boolean\r\n ) => {\r\n scrollbarStyle(scrollbarStructures, (structure) => {\r\n const { _handle } = structure;\r\n return [\r\n _handle,\r\n {\r\n [isHorizontal ? strWidth : strHeight]: ratioToCssPercent(\r\n getScrollbarHandleLengthRatio(isHorizontal)\r\n ),\r\n },\r\n ];\r\n });\r\n };\r\n const scrollbarStructureRefreshHandleOffset = (\r\n scrollbarStructures: ScrollbarStructure[],\r\n isHorizontal?: boolean\r\n ) => {\r\n const { _overflowAmount } = structureSetupState;\r\n const overflowAmount = isHorizontal ? _overflowAmount.x : _overflowAmount.y;\r\n const getTransformValue = (\r\n structure: ScrollbarStructure,\r\n rawScrollPosition: number,\r\n rtlScrollBehavior: RTLScrollBehavior\r\n ) =>\r\n getTrasformTranslateValue(\r\n ratioToCssPercent(\r\n getScrollbarHandleOffsetRatio(\r\n structure,\r\n getRawScrollRatio(rawScrollPosition, overflowAmount, rtlScrollBehavior),\r\n isHorizontal,\r\n rtlScrollBehavior\r\n )\r\n ),\r\n isHorizontal\r\n );\r\n if (scrollTimelineX && scrollTimelineY) {\r\n each(scrollbarStructures, (structure: ScrollbarStructure) => {\r\n const { _scrollbar, _handle } = structure;\r\n const rtlScrollBehavior =\r\n isHorizontal && getDirectionIsRTL(_scrollbar) && _rtlScrollBehavior;\r\n\r\n setElementAnimation(\r\n _handle,\r\n isHorizontal ? scrollTimelineX : scrollTimelineY,\r\n addDirectionRTLKeyframes(\r\n {\r\n transform: getRawScrollBounds(overflowAmount, rtlScrollBehavior).map((bound) =>\r\n getTransformValue(structure, bound, rtlScrollBehavior)\r\n ),\r\n },\r\n rtlScrollBehavior\r\n )\r\n );\r\n });\r\n } else {\r\n const scroll = getElmentScroll(_scrollOffsetElement);\r\n scrollbarStyle(scrollbarStructures, (structure) => {\r\n const { _handle, _scrollbar } = structure;\r\n return [\r\n _handle,\r\n {\r\n transform: getTransformValue(\r\n structure,\r\n isHorizontal ? scroll.x : scroll.y,\r\n isHorizontal && getDirectionIsRTL(_scrollbar) && _rtlScrollBehavior\r\n ),\r\n },\r\n ];\r\n });\r\n }\r\n };\r\n const doRefreshScrollbarOffset = (scrollbar: HTMLElement) =>\r\n _viewportIsTarget && !_isBody && parent(scrollbar) === _viewport;\r\n\r\n const destroyFns: (() => void)[] = [];\r\n const horizontalScrollbars: ScrollbarStructure[] = [];\r\n const verticalScrollbars: ScrollbarStructure[] = [];\r\n\r\n const scrollbarsAddRemoveClass = (\r\n className: string | false | null | undefined,\r\n add?: boolean,\r\n onlyHorizontal?: boolean\r\n ) => {\r\n const singleAxis = isBoolean(onlyHorizontal);\r\n const runHorizontal = singleAxis ? onlyHorizontal : true;\r\n const runVertical = singleAxis ? !onlyHorizontal : true;\r\n runHorizontal && scrollbarStructureAddRemoveClass(horizontalScrollbars, className, add);\r\n runVertical && scrollbarStructureAddRemoveClass(verticalScrollbars, className, add);\r\n };\r\n const refreshScrollbarsHandleLength = () => {\r\n scrollbarStructureRefreshHandleLength(horizontalScrollbars, true);\r\n scrollbarStructureRefreshHandleLength(verticalScrollbars);\r\n };\r\n const refreshScrollbarsHandleOffset = () => {\r\n scrollbarStructureRefreshHandleOffset(horizontalScrollbars, true);\r\n scrollbarStructureRefreshHandleOffset(verticalScrollbars);\r\n };\r\n const refreshScrollbarsScrollbarOffset = () => {\r\n if (_viewportIsTarget) {\r\n const { _overflowAmount } = structureSetupState;\r\n const cushion = 0.5; // otherwise it sometimes happens that scrolling to 100% will cause the scrollbars to disappear\r\n if (scrollTimelineX && scrollTimelineY) {\r\n each(concat(verticalScrollbars, horizontalScrollbars), ({ _scrollbar }) => {\r\n if (doRefreshScrollbarOffset(_scrollbar)) {\r\n const setScrollbarElementAnimation = (\r\n timeline: AnimationTimeline,\r\n overflowAmount: number,\r\n isHorizontal?: boolean\r\n ) => {\r\n const rtlScrollBehavior =\r\n isHorizontal && getDirectionIsRTL(_scrollbar) && _rtlScrollBehavior;\r\n setElementAnimation(\r\n _scrollbar,\r\n timeline,\r\n addDirectionRTLKeyframes(\r\n {\r\n transform: getRawScrollBounds(overflowAmount - cushion, rtlScrollBehavior).map(\r\n (bound) => getTrasformTranslateValue(numberToCssPx(bound), isHorizontal)\r\n ),\r\n },\r\n rtlScrollBehavior\r\n ),\r\n 'add'\r\n );\r\n };\r\n\r\n setScrollbarElementAnimation(scrollTimelineX, _overflowAmount.x, true);\r\n setScrollbarElementAnimation(scrollTimelineY, _overflowAmount.y);\r\n } else {\r\n cancelElementAnimations(_scrollbar);\r\n }\r\n });\r\n } else {\r\n const scroll = getElmentScroll(_scrollOffsetElement);\r\n const styleScrollbarPosition = (structure: ScrollbarStructure) => {\r\n const { _scrollbar } = structure;\r\n const elm = doRefreshScrollbarOffset(_scrollbar) && _scrollbar;\r\n const getTranslateValue = (\r\n axisScroll: number,\r\n axisOverflowAmount: number,\r\n rtlScrollBehavior?: RTLScrollBehavior\r\n ) => {\r\n const percent = getRawScrollRatio(axisScroll, axisOverflowAmount, rtlScrollBehavior);\r\n const px = axisOverflowAmount * percent;\r\n return numberToCssPx(rtlScrollBehavior ? -px : px);\r\n };\r\n\r\n return [\r\n elm,\r\n {\r\n transform: elm\r\n ? getTrasformTranslateValue({\r\n x: getTranslateValue(\r\n scroll.x,\r\n _overflowAmount.x,\r\n getDirectionIsRTL(_scrollbar) && _rtlScrollBehavior\r\n ),\r\n y: getTranslateValue(scroll.y, _overflowAmount.y),\r\n })\r\n : '',\r\n },\r\n ] as [HTMLElement | false, StyleObject];\r\n };\r\n scrollbarStyle(horizontalScrollbars, styleScrollbarPosition);\r\n scrollbarStyle(verticalScrollbars, styleScrollbarPosition);\r\n }\r\n }\r\n };\r\n const generateScrollbarDOM = (isHorizontal?: boolean): ScrollbarStructure => {\r\n const scrollbarClassName = isHorizontal\r\n ? classNameScrollbarHorizontal\r\n : classNameScrollbarVertical;\r\n const scrollbar = createDiv(`${classNameScrollbar} ${scrollbarClassName}`);\r\n const track = createDiv(classNameScrollbarTrack);\r\n const handle = createDiv(classNameScrollbarHandle);\r\n const result = {\r\n _scrollbar: scrollbar,\r\n _track: track,\r\n _handle: handle,\r\n };\r\n\r\n push(isHorizontal ? horizontalScrollbars : verticalScrollbars, result);\r\n push(destroyFns, [\r\n appendChildren(scrollbar, track),\r\n appendChildren(track, handle),\r\n bind(removeElements, scrollbar),\r\n cancelElementAnimations,\r\n scrollbarsSetupEvents(\r\n result,\r\n scrollbarsAddRemoveClass,\r\n scrollbarStructureRefreshHandleOffset,\r\n isHorizontal\r\n ),\r\n ]);\r\n\r\n return result;\r\n };\r\n const generateHorizontalScrollbarStructure = bind(generateScrollbarDOM, true);\r\n const generateVerticalScrollbarStructure = bind(generateScrollbarDOM, false);\r\n const appendElements = () => {\r\n appendChildren(evaluatedScrollbarSlot, horizontalScrollbars[0]._scrollbar);\r\n appendChildren(evaluatedScrollbarSlot, verticalScrollbars[0]._scrollbar);\r\n\r\n return bind(runEachAndClear, destroyFns);\r\n };\r\n\r\n generateHorizontalScrollbarStructure();\r\n generateVerticalScrollbarStructure();\r\n\r\n return [\r\n {\r\n _refreshScrollbarsHandleLength: refreshScrollbarsHandleLength,\r\n _refreshScrollbarsHandleOffset: refreshScrollbarsHandleOffset,\r\n _refreshScrollbarsScrollbarOffset: refreshScrollbarsScrollbarOffset,\r\n _scrollbarsAddRemoveClass: scrollbarsAddRemoveClass,\r\n _horizontal: {\r\n _scrollTimeline: scrollTimelineX,\r\n _scrollbarStructures: horizontalScrollbars,\r\n _clone: generateHorizontalScrollbarStructure,\r\n _style: bind(scrollbarStyle, horizontalScrollbars),\r\n },\r\n _vertical: {\r\n _scrollTimeline: scrollTimelineY,\r\n _scrollbarStructures: verticalScrollbars,\r\n _clone: generateVerticalScrollbarStructure,\r\n _style: bind(scrollbarStyle, verticalScrollbars),\r\n },\r\n },\r\n appendElements,\r\n ];\r\n};\r\n","import {\r\n getBoundingClientRect,\r\n offsetSize,\r\n addEventListener,\r\n preventDefault,\r\n runEachAndClear,\r\n stopPropagation,\r\n selfClearTimeout,\r\n parent,\r\n closest,\r\n push,\r\n bind,\r\n mathRound,\r\n strWidth,\r\n strHeight,\r\n getElmentScroll,\r\n scrollElementTo,\r\n addAttrClass,\r\n getFocusedElement,\r\n setT,\r\n hasAttr,\r\n} from '~/support';\r\nimport { clickScrollPluginModuleName, getStaticPluginModuleInstance } from '~/plugins';\r\nimport {\r\n classNameScrollbarHandle,\r\n classNameScrollbarInteraction,\r\n classNameScrollbarWheel,\r\n dataAttributeHost,\r\n dataAttributeViewport,\r\n dataValueHostScrollbarPressed,\r\n} from '~/classnames';\r\nimport type { ClickScrollPlugin } from '~/plugins';\r\nimport type { ReadonlyOptions } from '~/options';\r\nimport type { StructureSetupState } from '~/setups';\r\nimport type { ScrollbarsSetupElementsObj, ScrollbarStructure } from './scrollbarsSetup.elements';\r\nimport type { StructureSetupElementsObj } from '../structureSetup/structureSetup.elements';\r\n\r\nexport type ScrollbarsSetupEvents = (\r\n scrollbarStructure: ScrollbarStructure,\r\n scrollbarsAddRemoveClass: ScrollbarsSetupElementsObj['_scrollbarsAddRemoveClass'],\r\n refreshScrollbarStructuresHandleOffset: (\r\n scrollbarStructure: ScrollbarStructure[],\r\n isHorizontal?: boolean\r\n ) => void,\r\n isHorizontal?: boolean\r\n) => () => void;\r\n\r\nexport const createScrollbarsSetupEvents = (\r\n options: ReadonlyOptions,\r\n structureSetupElements: StructureSetupElementsObj,\r\n structureSetupState: StructureSetupState,\r\n scrollbarHandlePointerInteraction: (event: PointerEvent) => void\r\n): ScrollbarsSetupEvents => {\r\n const { _host, _viewport, _viewportIsTarget, _scrollOffsetElement, _documentElm } =\r\n structureSetupElements;\r\n\r\n return (\r\n scrollbarStructure,\r\n scrollbarsAddRemoveClass,\r\n refreshScrollbarStructuresHandleOffset,\r\n isHorizontal\r\n ) => {\r\n const { _scrollbar, _track, _handle } = scrollbarStructure;\r\n const [wheelTimeout, clearWheelTimeout] = selfClearTimeout(333);\r\n const [requestHandleTransitionAnimationFrame, cancelHandleTransitionTimeout] =\r\n selfClearTimeout();\r\n const refreshHandleOffsetTransition = bind(\r\n refreshScrollbarStructuresHandleOffset,\r\n [scrollbarStructure],\r\n isHorizontal\r\n );\r\n const scrollByFn = !!_scrollOffsetElement.scrollBy;\r\n\r\n const clientXYKey = `client${isHorizontal ? 'X' : 'Y'}` as 'clientX' | 'clientY';\r\n const widthHeightKey = isHorizontal ? strWidth : strHeight;\r\n const leftTopKey = isHorizontal ? 'left' : 'top';\r\n const whKey = isHorizontal ? 'w' : 'h';\r\n const xyKey = isHorizontal ? 'x' : 'y';\r\n\r\n const isAffectingTransition = (event: TransitionEvent) =>\r\n event.propertyName.indexOf(widthHeightKey) > -1;\r\n\r\n const createInteractiveScrollEvents = () => {\r\n const releasePointerCaptureEvents = 'pointerup pointerleave pointercancel lostpointercapture';\r\n\r\n const createRelativeHandleMove =\r\n (mouseDownScroll: number, invertedScale: number) => (deltaMovement: number) => {\r\n const { _overflowAmount } = structureSetupState;\r\n const handleTrackDiff = offsetSize(_track)[whKey] - offsetSize(_handle)[whKey];\r\n const scrollDeltaPercent = (invertedScale * deltaMovement) / handleTrackDiff;\r\n const scrollDelta = scrollDeltaPercent * _overflowAmount[xyKey];\r\n\r\n scrollElementTo(_scrollOffsetElement, {\r\n [xyKey]: mouseDownScroll + scrollDelta,\r\n });\r\n };\r\n\r\n return addEventListener(_track, 'pointerdown', (pointerDownEvent: PointerEvent) => {\r\n const isDragScroll =\r\n closest(pointerDownEvent.target as Node, `.${classNameScrollbarHandle}`) === _handle;\r\n const pointerCaptureElement = isDragScroll ? _handle : _track;\r\n\r\n const scrollbarOptions = options.scrollbars;\r\n const { button, isPrimary, pointerType } = pointerDownEvent;\r\n const { pointers } = scrollbarOptions;\r\n\r\n const continuePointerDown =\r\n button === 0 &&\r\n isPrimary &&\r\n scrollbarOptions[isDragScroll ? 'dragScroll' : 'clickScroll'] &&\r\n (pointers || []).includes(pointerType);\r\n\r\n if (continuePointerDown) {\r\n const instantClickScroll = !isDragScroll && pointerDownEvent.shiftKey;\r\n const getHandleRect = bind(getBoundingClientRect, _handle);\r\n const getTrackRect = bind(getBoundingClientRect, _track);\r\n const getHandleOffset = (handleRect?: DOMRect, trackRect?: DOMRect) =>\r\n (handleRect || getHandleRect())[leftTopKey] - (trackRect || getTrackRect())[leftTopKey];\r\n const axisScale =\r\n mathRound(getBoundingClientRect(_scrollOffsetElement)[widthHeightKey]) /\r\n offsetSize(_scrollOffsetElement)[whKey] || 1;\r\n const moveHandleRelative = createRelativeHandleMove(\r\n getElmentScroll(_scrollOffsetElement)[xyKey] || 0,\r\n 1 / axisScale\r\n );\r\n const pointerDownOffset = pointerDownEvent[clientXYKey];\r\n const handleRect = getHandleRect();\r\n const trackRect = getTrackRect();\r\n const handleLength = handleRect[widthHeightKey];\r\n const handleCenter = getHandleOffset(handleRect, trackRect) + handleLength / 2;\r\n const relativeTrackPointerOffset = pointerDownOffset - trackRect[leftTopKey];\r\n const startOffset = isDragScroll ? 0 : relativeTrackPointerOffset - handleCenter;\r\n const releasePointerCapture = (pointerUpEvent: PointerEvent) => {\r\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\r\n runEachAndClear(offFns);\r\n pointerCaptureElement.releasePointerCapture(pointerUpEvent.pointerId);\r\n };\r\n const removeAttrClass = addAttrClass(\r\n _host,\r\n dataAttributeHost,\r\n dataValueHostScrollbarPressed\r\n );\r\n\r\n const offFns = [\r\n removeAttrClass,\r\n addEventListener(_documentElm, releasePointerCaptureEvents, releasePointerCapture),\r\n addEventListener(_documentElm, 'selectstart', (event: Event) => preventDefault(event), {\r\n _passive: false,\r\n }),\r\n addEventListener(_track, releasePointerCaptureEvents, releasePointerCapture),\r\n addEventListener(_track, 'pointermove', (pointerMoveEvent: PointerEvent) => {\r\n const relativeMovement = pointerMoveEvent[clientXYKey] - pointerDownOffset;\r\n\r\n if (isDragScroll || instantClickScroll) {\r\n moveHandleRelative(startOffset + relativeMovement);\r\n }\r\n }),\r\n ];\r\n\r\n pointerCaptureElement.setPointerCapture(pointerDownEvent.pointerId);\r\n\r\n if (instantClickScroll) {\r\n moveHandleRelative(startOffset);\r\n } else if (!isDragScroll) {\r\n const animateClickScroll = getStaticPluginModuleInstance(\r\n clickScrollPluginModuleName\r\n );\r\n\r\n animateClickScroll &&\r\n push(\r\n offFns,\r\n animateClickScroll(\r\n moveHandleRelative,\r\n getHandleOffset,\r\n startOffset,\r\n handleLength,\r\n relativeTrackPointerOffset\r\n )\r\n );\r\n }\r\n }\r\n });\r\n };\r\n\r\n let wheelScrollBy = true;\r\n\r\n return bind(runEachAndClear, [\r\n addEventListener(_handle, 'pointermove pointerleave', scrollbarHandlePointerInteraction),\r\n addEventListener(_scrollbar, 'pointerenter', () => {\r\n scrollbarsAddRemoveClass(classNameScrollbarInteraction, true);\r\n }),\r\n addEventListener(_scrollbar, 'pointerleave pointercancel', () => {\r\n scrollbarsAddRemoveClass(classNameScrollbarInteraction, false);\r\n }),\r\n // focus viewport when clicking on a scrollbar\r\n !_viewportIsTarget &&\r\n addEventListener(_scrollbar, 'mousedown', () => {\r\n const focusedElement = getFocusedElement();\r\n if (\r\n hasAttr(focusedElement, dataAttributeViewport) ||\r\n hasAttr(focusedElement, dataAttributeHost) ||\r\n focusedElement === document.body\r\n ) {\r\n setT(() => {\r\n _viewport.focus({ preventScroll: true });\r\n }, 25);\r\n }\r\n }),\r\n // propagate wheel events to viewport when mouse is over scrollbar\r\n addEventListener(\r\n _scrollbar,\r\n 'wheel',\r\n (wheelEvent: WheelEvent) => {\r\n const { deltaX, deltaY, deltaMode } = wheelEvent;\r\n\r\n // the first wheel event is swallowed, simulate scroll to compensate for it\r\n if (scrollByFn && wheelScrollBy && deltaMode === 0 && parent(_scrollbar) === _host) {\r\n _scrollOffsetElement.scrollBy({\r\n left: deltaX,\r\n top: deltaY,\r\n behavior: 'smooth',\r\n });\r\n }\r\n\r\n wheelScrollBy = false;\r\n scrollbarsAddRemoveClass(classNameScrollbarWheel, true);\r\n wheelTimeout(() => {\r\n wheelScrollBy = true;\r\n scrollbarsAddRemoveClass(classNameScrollbarWheel);\r\n });\r\n\r\n preventDefault(wheelEvent);\r\n },\r\n { _passive: false, _capture: true }\r\n ),\r\n // when the handle has a size transition, update the handle offset each frame for the time of the transition\r\n addEventListener(_handle, 'transitionstart', (event: TransitionEvent) => {\r\n if (isAffectingTransition(event)) {\r\n const animateHandleOffset = () => {\r\n refreshHandleOffsetTransition();\r\n requestHandleTransitionAnimationFrame(animateHandleOffset);\r\n };\r\n animateHandleOffset();\r\n }\r\n }),\r\n addEventListener(_handle, 'transitionend transitioncancel', (event: TransitionEvent) => {\r\n if (isAffectingTransition(event)) {\r\n cancelHandleTransitionTimeout();\r\n refreshHandleOffsetTransition();\r\n }\r\n }),\r\n // rootClickStopPropagationEvent\r\n addEventListener(\r\n _scrollbar,\r\n 'mousedown',\r\n bind(addEventListener, _documentElm, 'click', stopPropagation, {\r\n _once: true,\r\n _capture: true,\r\n }),\r\n { _capture: true }\r\n ),\r\n createInteractiveScrollEvents(),\r\n clearWheelTimeout,\r\n cancelHandleTransitionTimeout,\r\n ]);\r\n };\r\n};\r\n","import { bind, noop, addEventListener, push, runEachAndClear, selfClearTimeout } from '~/support';\r\nimport { getEnvironment } from '~/environment';\r\nimport {\r\n classNameScrollbarThemeNone,\r\n classNameScrollbarVisible,\r\n classNameScrollbarUnusable,\r\n classNameScrollbarCornerless,\r\n classNameScrollbarAutoHideHidden,\r\n classNameScrollbarHandleInteractive,\r\n classNameScrollbarTrackInteractive,\r\n classNameScrollbarRtl,\r\n classNameScrollbarAutoHide,\r\n} from '~/classnames';\r\nimport type { OverflowBehavior, ReadonlyOptions } from '~/options';\r\nimport type { ScrollbarsSetupElementsObj } from './scrollbarsSetup.elements';\r\nimport type {\r\n ObserversSetupState,\r\n ObserversSetupUpdateHints,\r\n Setup,\r\n SetupUpdateInfo,\r\n StructureSetupState,\r\n StructureSetupUpdateHints,\r\n} from '~/setups';\r\nimport type { InitializationTarget } from '~/initialization';\r\nimport type { OverflowStyle } from '~/typings';\r\nimport type { StructureSetupElementsObj } from '../structureSetup/structureSetup.elements';\r\nimport { createScrollbarsSetupElements } from './scrollbarsSetup.elements';\r\nimport { createScrollbarsSetupEvents } from './scrollbarsSetup.events';\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\r\nexport interface ScrollbarsSetupState {}\r\n\r\nexport interface ScrollbarsSetupUpdateInfo extends SetupUpdateInfo {\r\n _observersUpdateHints?: ObserversSetupUpdateHints;\r\n _structureUpdateHints?: StructureSetupUpdateHints;\r\n}\r\n\r\nexport type ScrollbarsSetup = [\r\n ...Setup,\r\n /** The elements created by the scrollbars setup. */\r\n ScrollbarsSetupElementsObj\r\n];\r\n\r\nexport const createScrollbarsSetup = (\r\n target: InitializationTarget,\r\n options: ReadonlyOptions,\r\n observersSetupState: ObserversSetupState,\r\n structureSetupState: StructureSetupState,\r\n structureSetupElements: StructureSetupElementsObj,\r\n onScroll: (event: Event) => void\r\n): ScrollbarsSetup => {\r\n let mouseInHost: boolean | undefined;\r\n let autoHideIsMove: boolean | undefined;\r\n let autoHideIsLeave: boolean | undefined;\r\n let autoHideIsNever: boolean | undefined;\r\n let prevTheme: string | null | undefined;\r\n let instanceAutoHideSuspendScrollDestroyFn = noop;\r\n let instanceAutoHideDelay = 0;\r\n\r\n // needed to not fire unnecessary operations for pointer events on safari which will cause side effects: https://github.com/KingSora/OverlayScrollbars/issues/560\r\n const isHoverablePointerType = (event: PointerEvent) => event.pointerType === 'mouse';\r\n\r\n const [requestScrollAnimationFrame, cancelScrollAnimationFrame] = selfClearTimeout();\r\n const [autoHideInstantInteractionTimeout, clearAutoHideInstantInteractionTimeout] =\r\n selfClearTimeout(100);\r\n const [autoHideSuspendTimeout, clearAutoHideSuspendTimeout] = selfClearTimeout(100);\r\n const [auotHideTimeout, clearAutoHideTimeout] = selfClearTimeout(() => instanceAutoHideDelay);\r\n const [elements, appendElements] = createScrollbarsSetupElements(\r\n target,\r\n structureSetupElements,\r\n structureSetupState,\r\n createScrollbarsSetupEvents(\r\n options,\r\n structureSetupElements,\r\n structureSetupState,\r\n (event) =>\r\n isHoverablePointerType(event) &&\r\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\r\n manageScrollbarsAutoHideInstantInteraction()\r\n )\r\n );\r\n const { _host, _scrollEventElement, _isBody } = structureSetupElements;\r\n const {\r\n _scrollbarsAddRemoveClass,\r\n _refreshScrollbarsHandleLength,\r\n _refreshScrollbarsHandleOffset,\r\n _refreshScrollbarsScrollbarOffset,\r\n } = elements;\r\n const manageScrollbarsAutoHide = (removeAutoHide: boolean, delayless?: boolean) => {\r\n clearAutoHideTimeout();\r\n if (removeAutoHide) {\r\n _scrollbarsAddRemoveClass(classNameScrollbarAutoHideHidden);\r\n } else {\r\n const hide = bind(_scrollbarsAddRemoveClass, classNameScrollbarAutoHideHidden, true);\r\n if (instanceAutoHideDelay > 0 && !delayless) {\r\n auotHideTimeout(hide);\r\n } else {\r\n hide();\r\n }\r\n }\r\n };\r\n const manageScrollbarsAutoHideInstantInteraction = () => {\r\n if (autoHideIsLeave ? !mouseInHost : !autoHideIsNever) {\r\n manageScrollbarsAutoHide(true);\r\n autoHideInstantInteractionTimeout(() => {\r\n manageScrollbarsAutoHide(false);\r\n });\r\n }\r\n };\r\n const manageAutoHideSuspension = (add: boolean) => {\r\n _scrollbarsAddRemoveClass(classNameScrollbarAutoHide, add, true);\r\n _scrollbarsAddRemoveClass(classNameScrollbarAutoHide, add, false);\r\n };\r\n const onHostMouseEnter = (event: PointerEvent) => {\r\n if (isHoverablePointerType(event)) {\r\n mouseInHost = autoHideIsLeave;\r\n autoHideIsLeave && manageScrollbarsAutoHide(true);\r\n }\r\n };\r\n const destroyFns: (() => void)[] = [\r\n clearAutoHideTimeout,\r\n clearAutoHideInstantInteractionTimeout,\r\n clearAutoHideSuspendTimeout,\r\n cancelScrollAnimationFrame,\r\n () => instanceAutoHideSuspendScrollDestroyFn(),\r\n\r\n addEventListener(_host, 'pointerover', onHostMouseEnter, { _once: true }),\r\n addEventListener(_host, 'pointerenter', onHostMouseEnter),\r\n addEventListener(_host, 'pointerleave', (event: PointerEvent) => {\r\n if (isHoverablePointerType(event)) {\r\n mouseInHost = false;\r\n autoHideIsLeave && manageScrollbarsAutoHide(false);\r\n }\r\n }),\r\n addEventListener(_host, 'pointermove', (event: PointerEvent) => {\r\n isHoverablePointerType(event) &&\r\n autoHideIsMove &&\r\n manageScrollbarsAutoHideInstantInteraction();\r\n }),\r\n addEventListener(_scrollEventElement, 'scroll', (event) => {\r\n requestScrollAnimationFrame(() => {\r\n _refreshScrollbarsHandleOffset();\r\n manageScrollbarsAutoHideInstantInteraction();\r\n });\r\n\r\n onScroll(event);\r\n\r\n _refreshScrollbarsScrollbarOffset();\r\n }),\r\n ];\r\n\r\n return [\r\n () => bind(runEachAndClear, push(destroyFns, appendElements())),\r\n ({ _checkOption, _force, _observersUpdateHints, _structureUpdateHints }) => {\r\n const { _overflowEdgeChanged, _overflowAmountChanged, _overflowStyleChanged } =\r\n _structureUpdateHints || {};\r\n const { _directionChanged, _appear } = _observersUpdateHints || {};\r\n const { _directionIsRTL } = observersSetupState;\r\n const { _nativeScrollbarsOverlaid } = getEnvironment();\r\n const { _overflowStyle, _hasOverflow } = structureSetupState;\r\n const [showNativeOverlaidScrollbarsOption, showNativeOverlaidScrollbarsChanged] =\r\n _checkOption('showNativeOverlaidScrollbars');\r\n const [theme, themeChanged] = _checkOption('scrollbars.theme');\r\n const [visibility, visibilityChanged] = _checkOption('scrollbars.visibility');\r\n const [autoHide, autoHideChanged] = _checkOption('scrollbars.autoHide');\r\n const [autoHideSuspend, autoHideSuspendChanged] = _checkOption('scrollbars.autoHideSuspend');\r\n const [autoHideDelay] = _checkOption('scrollbars.autoHideDelay');\r\n const [dragScroll, dragScrollChanged] = _checkOption('scrollbars.dragScroll');\r\n const [clickScroll, clickScrollChanged] = _checkOption('scrollbars.clickScroll');\r\n const [overflow, overflowChanged] = _checkOption('overflow');\r\n const trulyAppeared = _appear && !_force;\r\n const hasOverflow = _hasOverflow.x || _hasOverflow.y;\r\n const updateScrollbars =\r\n _overflowEdgeChanged || _overflowAmountChanged || _directionChanged || _force;\r\n const updateVisibility = _overflowStyleChanged || visibilityChanged || overflowChanged;\r\n const showNativeOverlaidScrollbars =\r\n showNativeOverlaidScrollbarsOption &&\r\n _nativeScrollbarsOverlaid.x &&\r\n _nativeScrollbarsOverlaid.y;\r\n\r\n const setScrollbarVisibility = (\r\n overflowBehavior: OverflowBehavior,\r\n overflowStyle: OverflowStyle,\r\n isHorizontal: boolean\r\n ) => {\r\n const isVisible =\r\n overflowBehavior.includes('scroll') &&\r\n (visibility === 'visible' || (visibility === 'auto' && overflowStyle === 'scroll'));\r\n\r\n _scrollbarsAddRemoveClass(classNameScrollbarVisible, isVisible, isHorizontal);\r\n\r\n return isVisible;\r\n };\r\n\r\n instanceAutoHideDelay = autoHideDelay;\r\n\r\n if (trulyAppeared) {\r\n if (autoHideSuspend && hasOverflow) {\r\n manageAutoHideSuspension(false);\r\n instanceAutoHideSuspendScrollDestroyFn();\r\n autoHideSuspendTimeout(() => {\r\n instanceAutoHideSuspendScrollDestroyFn = addEventListener(\r\n _scrollEventElement,\r\n 'scroll',\r\n bind(manageAutoHideSuspension, true),\r\n {\r\n _once: true,\r\n }\r\n );\r\n });\r\n } else {\r\n manageAutoHideSuspension(true);\r\n }\r\n }\r\n\r\n if (showNativeOverlaidScrollbarsChanged) {\r\n _scrollbarsAddRemoveClass(classNameScrollbarThemeNone, showNativeOverlaidScrollbars);\r\n }\r\n\r\n if (themeChanged) {\r\n _scrollbarsAddRemoveClass(prevTheme);\r\n _scrollbarsAddRemoveClass(theme, true);\r\n\r\n prevTheme = theme;\r\n }\r\n\r\n if (autoHideSuspendChanged && !autoHideSuspend) {\r\n manageAutoHideSuspension(true);\r\n }\r\n\r\n if (autoHideChanged) {\r\n autoHideIsMove = autoHide === 'move';\r\n autoHideIsLeave = autoHide === 'leave';\r\n autoHideIsNever = autoHide === 'never';\r\n manageScrollbarsAutoHide(autoHideIsNever, true);\r\n }\r\n\r\n if (dragScrollChanged) {\r\n _scrollbarsAddRemoveClass(classNameScrollbarHandleInteractive, dragScroll);\r\n }\r\n\r\n if (clickScrollChanged) {\r\n _scrollbarsAddRemoveClass(classNameScrollbarTrackInteractive, clickScroll);\r\n }\r\n\r\n if (updateVisibility) {\r\n const xVisible = setScrollbarVisibility(overflow.x, _overflowStyle.x, true);\r\n const yVisible = setScrollbarVisibility(overflow.y, _overflowStyle.y, false);\r\n const hasCorner = xVisible && yVisible;\r\n\r\n _scrollbarsAddRemoveClass(classNameScrollbarCornerless, !hasCorner);\r\n }\r\n\r\n if (updateScrollbars) {\r\n // order is matter! length has to be refreshed before offset\r\n _refreshScrollbarsHandleLength();\r\n _refreshScrollbarsHandleOffset();\r\n _refreshScrollbarsScrollbarOffset();\r\n\r\n _scrollbarsAddRemoveClass(classNameScrollbarUnusable, !_hasOverflow.x, true);\r\n _scrollbarsAddRemoveClass(classNameScrollbarUnusable, !_hasOverflow.y, false);\r\n _scrollbarsAddRemoveClass(classNameScrollbarRtl, _directionIsRTL && !_isBody);\r\n }\r\n },\r\n {},\r\n elements,\r\n ];\r\n};\r\n","import {\r\n isHTMLElement,\r\n appendChildren,\r\n createDiv,\r\n is,\r\n contents,\r\n insertAfter,\r\n parent,\r\n removeElements,\r\n push,\r\n runEachAndClear,\r\n removeAttrs,\r\n hasAttrClass,\r\n addEventListener,\r\n bind,\r\n inArray,\r\n addAttrClass,\r\n addRemoveAttrClass,\r\n setAttrs,\r\n getAttr,\r\n noop,\r\n stopPropagation,\r\n isBodyElement,\r\n getFocusedElement,\r\n wnd,\r\n} from '~/support';\r\nimport {\r\n dataAttributeHost,\r\n dataAttributeInitialize,\r\n dataAttributeHostOverflowX,\r\n dataAttributeHostOverflowY,\r\n dataAttributeViewport,\r\n dataValueViewportScrollbarHidden,\r\n dataAttributePadding,\r\n dataAttributeContent,\r\n dataValueHostHtmlBody,\r\n} from '~/classnames';\r\nimport { getEnvironment } from '~/environment';\r\nimport {\r\n staticInitializationElement as generalStaticInitializationElement,\r\n dynamicInitializationElement as generalDynamicInitializationElement,\r\n} from '~/initialization';\r\nimport type {\r\n InitializationTarget,\r\n InitializationTargetElement,\r\n InitializationTargetObject,\r\n} from '~/initialization';\r\n\r\nexport type StructureSetupElements = [\r\n elements: StructureSetupElementsObj,\r\n appendElements: () => () => void,\r\n canceled: () => void\r\n];\r\n\r\nexport interface StructureSetupElementsObj {\r\n _target: InitializationTargetElement;\r\n _host: HTMLElement;\r\n _viewport: HTMLElement;\r\n _padding: HTMLElement | false;\r\n _content: HTMLElement | false;\r\n _scrollOffsetElement: HTMLElement;\r\n _scrollEventElement: HTMLElement | Document;\r\n _originalScrollOffsetElement: HTMLElement;\r\n // ctx ----\r\n _isTextarea: boolean;\r\n _isBody: boolean;\r\n _documentElm: Document;\r\n _targetIsElm: boolean;\r\n _viewportIsTarget: boolean;\r\n _windowElm: () => Window;\r\n _viewportHasClass: (viewportAttributeClassName: string) => boolean;\r\n _viewportAddRemoveClass: (viewportAttributeClassName: string, add?: boolean) => void;\r\n}\r\n\r\nexport const createStructureSetupElements = (\r\n target: InitializationTarget\r\n): StructureSetupElements => {\r\n const env = getEnvironment();\r\n const { _getDefaultInitialization, _nativeScrollbarsHiding } = env;\r\n const { elements: defaultInitElements } = _getDefaultInitialization();\r\n const {\r\n host: defaultHostInitialization,\r\n padding: defaultPaddingInitialization,\r\n viewport: defaultViewportInitialization,\r\n content: defaultContentInitialization,\r\n } = defaultInitElements;\r\n const targetIsElm = isHTMLElement(target);\r\n const targetStructureInitialization = (targetIsElm ? {} : target) as InitializationTargetObject;\r\n const { elements: initElements } = targetStructureInitialization;\r\n const {\r\n host: hostInitialization,\r\n padding: paddingInitialization,\r\n viewport: viewportInitialization,\r\n content: contentInitialization,\r\n } = initElements || {};\r\n\r\n const targetElement = targetIsElm ? target : targetStructureInitialization.target;\r\n const isBody = isBodyElement(targetElement);\r\n const isTextarea = is(targetElement, 'textarea');\r\n const ownerDocument = targetElement.ownerDocument;\r\n const docElement = ownerDocument.documentElement;\r\n const getDocumentWindow = () => ownerDocument.defaultView || wnd;\r\n const focusElm = (customActiveElm: Element | null) => {\r\n if (customActiveElm && (customActiveElm as HTMLElement).focus) {\r\n (customActiveElm as HTMLElement).focus({ preventScroll: true });\r\n }\r\n };\r\n const staticInitializationElement = bind(generalStaticInitializationElement, [targetElement]);\r\n const dynamicInitializationElement = bind(generalDynamicInitializationElement, [targetElement]);\r\n const createNewDiv = bind(createDiv, '');\r\n const generateViewportElement = bind(\r\n staticInitializationElement,\r\n createNewDiv,\r\n defaultViewportInitialization\r\n );\r\n const generateContentElement = bind(\r\n dynamicInitializationElement,\r\n createNewDiv,\r\n defaultContentInitialization\r\n );\r\n const possibleViewportElement = generateViewportElement(viewportInitialization);\r\n const viewportIsTarget = possibleViewportElement === targetElement;\r\n const viewportIsTargetBody = viewportIsTarget && isBody;\r\n const possibleContentElement = !viewportIsTarget && generateContentElement(contentInitialization);\r\n // edge case if passed viewportElement is contentElement:\r\n // viewport element has higher priority and content element will not be generated\r\n // will act the same way as initialization: `{ elements: { viewport, content: false } }`\r\n const viewportIsContent = !viewportIsTarget && possibleViewportElement === possibleContentElement;\r\n const viewportElement = viewportIsTargetBody ? docElement : possibleViewportElement;\r\n const nonBodyHostElement = isTextarea\r\n ? staticInitializationElement(createNewDiv, defaultHostInitialization, hostInitialization)\r\n : (targetElement as HTMLElement);\r\n const hostElement = viewportIsTargetBody ? viewportElement : nonBodyHostElement;\r\n const paddingElement =\r\n !viewportIsTarget &&\r\n dynamicInitializationElement(createNewDiv, defaultPaddingInitialization, paddingInitialization);\r\n const contentElement = !viewportIsContent && possibleContentElement;\r\n const generatedElements = [contentElement, viewportElement, paddingElement, hostElement].map(\r\n (elm) => isHTMLElement(elm) && !parent(elm) && elm\r\n );\r\n const elementIsGenerated = (elm: HTMLElement | false) => elm && inArray(generatedElements, elm);\r\n const originalNonBodyScrollOffsetElement = elementIsGenerated(viewportElement)\r\n ? targetElement\r\n : viewportElement;\r\n\r\n const evaluatedTargetObj: StructureSetupElementsObj = {\r\n _target: targetElement,\r\n _host: hostElement,\r\n _viewport: viewportElement,\r\n _padding: paddingElement,\r\n _content: contentElement,\r\n _scrollOffsetElement: viewportIsTargetBody ? docElement : viewportElement,\r\n _scrollEventElement: viewportIsTargetBody ? ownerDocument : viewportElement,\r\n _originalScrollOffsetElement: isBody ? docElement : originalNonBodyScrollOffsetElement,\r\n _documentElm: ownerDocument,\r\n _isTextarea: isTextarea,\r\n _isBody: isBody,\r\n _targetIsElm: targetIsElm,\r\n _viewportIsTarget: viewportIsTarget,\r\n _windowElm: getDocumentWindow,\r\n _viewportHasClass: (viewportAttributeClassName: string) =>\r\n hasAttrClass(\r\n viewportElement,\r\n viewportIsTarget ? dataAttributeHost : dataAttributeViewport,\r\n viewportAttributeClassName\r\n ),\r\n _viewportAddRemoveClass: (viewportAttributeClassName: string, add?: boolean) =>\r\n addRemoveAttrClass(\r\n viewportElement,\r\n viewportIsTarget ? dataAttributeHost : dataAttributeViewport,\r\n viewportAttributeClassName,\r\n add\r\n ),\r\n };\r\n const { _target, _host, _padding, _viewport, _content } = evaluatedTargetObj;\r\n const destroyFns: (() => any)[] = [\r\n () => {\r\n // always remove dataAttributeHost & dataAttributeInitialize from host and from element if target is body\r\n removeAttrs(_host, [dataAttributeHost, dataAttributeInitialize]);\r\n removeAttrs(_target, dataAttributeInitialize);\r\n if (isBody) {\r\n removeAttrs(docElement, [dataAttributeInitialize, dataAttributeHost]);\r\n }\r\n },\r\n ];\r\n const isTextareaHostGenerated = isTextarea && elementIsGenerated(_host);\r\n let targetContents = isTextarea\r\n ? _target\r\n : contents(\r\n [_content, _viewport, _padding, _host, _target].find(\r\n (elm) => elm && !elementIsGenerated(elm)\r\n )\r\n );\r\n const contentSlot = viewportIsTargetBody ? _target : _content || _viewport;\r\n const destroy = bind(runEachAndClear, destroyFns);\r\n const appendElements = () => {\r\n const docWnd = getDocumentWindow();\r\n const initActiveElm = getFocusedElement();\r\n const unwrap = (elm: HTMLElement | false | null | undefined) => {\r\n appendChildren(parent(elm), contents(elm));\r\n removeElements(elm);\r\n };\r\n // wrapping / unwrapping will cause the focused element to blur, this should prevent those events to surface\r\n const prepareWrapUnwrapFocus = (activeElement?: Element | null) =>\r\n activeElement\r\n ? addEventListener(\r\n activeElement,\r\n 'focusin focusout focus blur',\r\n (event) => {\r\n stopPropagation(event);\r\n event.stopImmediatePropagation();\r\n },\r\n {\r\n _capture: true,\r\n _passive: false,\r\n }\r\n )\r\n : noop;\r\n const tabIndexStr = 'tabindex';\r\n const ogTabindex = getAttr(_viewport, tabIndexStr);\r\n const undoInitWrapUndwrapFocus = prepareWrapUnwrapFocus(initActiveElm);\r\n setAttrs(_host, dataAttributeHost, viewportIsTarget ? 'viewport' : 'host');\r\n setAttrs(_padding, dataAttributePadding, '');\r\n setAttrs(_content, dataAttributeContent, '');\r\n\r\n if (!viewportIsTarget) {\r\n setAttrs(_viewport, dataAttributeViewport, '');\r\n setAttrs(_viewport, tabIndexStr, ogTabindex || '-1');\r\n isBody && addAttrClass(docElement, dataAttributeHost, dataValueHostHtmlBody);\r\n }\r\n\r\n // only insert host for textarea after target if it was generated\r\n if (isTextareaHostGenerated) {\r\n insertAfter(_target, _host);\r\n\r\n push(destroyFns, () => {\r\n insertAfter(_host, _target);\r\n removeElements(_host);\r\n });\r\n }\r\n\r\n appendChildren(contentSlot, targetContents);\r\n appendChildren(_host, _padding);\r\n appendChildren(_padding || _host, !viewportIsTarget && _viewport);\r\n appendChildren(_viewport, _content);\r\n\r\n push(destroyFns, [\r\n undoInitWrapUndwrapFocus,\r\n () => {\r\n const destroyActiveElm = getFocusedElement();\r\n const undoDestroyWrapUndwrapFocus = prepareWrapUnwrapFocus(destroyActiveElm);\r\n removeAttrs(_padding, dataAttributePadding);\r\n removeAttrs(_content, dataAttributeContent);\r\n removeAttrs(_viewport, [\r\n dataAttributeHostOverflowX,\r\n dataAttributeHostOverflowY,\r\n dataAttributeViewport,\r\n ]);\r\n ogTabindex\r\n ? setAttrs(_viewport, tabIndexStr, ogTabindex)\r\n : removeAttrs(_viewport, tabIndexStr);\r\n\r\n elementIsGenerated(_content) && unwrap(_content);\r\n elementIsGenerated(_viewport) && unwrap(_viewport);\r\n elementIsGenerated(_padding) && unwrap(_padding);\r\n focusElm(destroyActiveElm);\r\n undoDestroyWrapUndwrapFocus();\r\n },\r\n ]);\r\n\r\n if (_nativeScrollbarsHiding && !viewportIsTarget) {\r\n addAttrClass(_viewport, dataAttributeViewport, dataValueViewportScrollbarHidden);\r\n push(destroyFns, bind(removeAttrs, _viewport, dataAttributeViewport));\r\n }\r\n\r\n // focus viewport if previously focused element was target, otherwise focus previously focused element\r\n focusElm(\r\n !viewportIsTarget && initActiveElm === targetElement && docWnd.top === docWnd\r\n ? _viewport\r\n : initActiveElm\r\n );\r\n undoInitWrapUndwrapFocus();\r\n\r\n // @ts-ignore\r\n targetContents = 0;\r\n\r\n return destroy;\r\n };\r\n\r\n return [evaluatedTargetObj, appendElements, destroy];\r\n};\r\n","import { setStyles, strHeight } from '~/support';\r\nimport type { CreateStructureUpdateSegment } from '../structureSetup';\r\n\r\n/**\r\n * Lifecycle with the responsibility to adjust the trinsic behavior of the content element.\r\n * @param structureUpdateHub\r\n * @returns\r\n */\r\nexport const createTrinsicUpdateSegment: CreateStructureUpdateSegment =\r\n ({ _content }) =>\r\n ({ _observersUpdateHints, _observersState, _force }) => {\r\n const { _heightIntrinsicChanged } = _observersUpdateHints || {};\r\n const { _heightIntrinsic } = _observersState;\r\n const heightIntrinsicChanged = _content && (_heightIntrinsicChanged || _force);\r\n\r\n if (heightIntrinsicChanged) {\r\n setStyles(_content, {\r\n [strHeight]: _heightIntrinsic && '100%',\r\n });\r\n }\r\n };\r\n","import {\r\n createCache,\r\n topRightBottomLeft,\r\n equalTRBL,\r\n assignDeep,\r\n bind,\r\n strMarginBottom,\r\n strMarginLeft,\r\n strMarginRight,\r\n strPaddingBottom,\r\n strPaddingLeft,\r\n strPaddingRight,\r\n strPaddingTop,\r\n strWidth,\r\n setStyles,\r\n} from '~/support';\r\nimport { getEnvironment } from '~/environment';\r\nimport type { StyleObject } from '~/typings';\r\nimport type { CreateStructureUpdateSegment } from '../structureSetup';\r\n\r\n/**\r\n * Lifecycle with the responsibility to adjust the padding styling of the padding and viewport element.\r\n * @param structureUpdateHub\r\n * @returns\r\n */\r\nexport const createPaddingUpdateSegment: CreateStructureUpdateSegment = (\r\n { _host, _padding, _viewport, _viewportIsTarget },\r\n state\r\n) => {\r\n const [updatePaddingCache, currentPaddingCache] = createCache(\r\n {\r\n _equal: equalTRBL,\r\n _initialValue: topRightBottomLeft(),\r\n },\r\n bind(topRightBottomLeft, _host, 'padding', '')\r\n );\r\n\r\n return ({ _checkOption, _observersUpdateHints, _observersState, _force }) => {\r\n let [padding, paddingChanged] = currentPaddingCache(_force);\r\n const { _nativeScrollbarsHiding } = getEnvironment();\r\n const { _sizeChanged, _contentMutation, _directionChanged } = _observersUpdateHints || {};\r\n const { _directionIsRTL } = _observersState;\r\n const [paddingAbsolute, paddingAbsoluteChanged] = _checkOption('paddingAbsolute');\r\n const contentMutation = _force || _contentMutation;\r\n\r\n if (_sizeChanged || paddingChanged || contentMutation) {\r\n [padding, paddingChanged] = updatePaddingCache(_force);\r\n }\r\n\r\n const paddingStyleChanged =\r\n !_viewportIsTarget && (paddingAbsoluteChanged || _directionChanged || paddingChanged);\r\n\r\n if (paddingStyleChanged) {\r\n // if there is no padding element and no scrollbar styling, paddingAbsolute isn't supported\r\n const paddingRelative = !paddingAbsolute || (!_padding && !_nativeScrollbarsHiding);\r\n const paddingHorizontal = padding.r + padding.l;\r\n const paddingVertical = padding.t + padding.b;\r\n\r\n const paddingStyle: StyleObject = {\r\n [strMarginRight]: paddingRelative && !_directionIsRTL ? -paddingHorizontal : 0,\r\n [strMarginBottom]: paddingRelative ? -paddingVertical : 0,\r\n [strMarginLeft]: paddingRelative && _directionIsRTL ? -paddingHorizontal : 0,\r\n top: paddingRelative ? -padding.t : 0,\r\n right: paddingRelative ? (_directionIsRTL ? -padding.r : 'auto') : 0,\r\n left: paddingRelative ? (_directionIsRTL ? 'auto' : -padding.l) : 0,\r\n [strWidth]: paddingRelative && `calc(100% + ${paddingHorizontal}px)`,\r\n };\r\n const viewportStyle: StyleObject = {\r\n [strPaddingTop]: paddingRelative ? padding.t : 0,\r\n [strPaddingRight]: paddingRelative ? padding.r : 0,\r\n [strPaddingBottom]: paddingRelative ? padding.b : 0,\r\n [strPaddingLeft]: paddingRelative ? padding.l : 0,\r\n };\r\n\r\n // if there is no padding element apply the style to the viewport element instead\r\n setStyles(_padding || _viewport, paddingStyle);\r\n setStyles(_viewport, viewportStyle);\r\n\r\n assignDeep(state, {\r\n _padding: padding,\r\n _paddingAbsolute: !paddingRelative,\r\n _viewportPaddingStyle: _padding\r\n ? viewportStyle\r\n : assignDeep({}, paddingStyle, viewportStyle),\r\n });\r\n }\r\n\r\n return {\r\n _paddingStyleChanged: paddingStyleChanged,\r\n };\r\n };\r\n};\r\n","import {\r\n createCache,\r\n scrollSize,\r\n fractionalSize,\r\n equalWH,\r\n clientSize,\r\n equalXY,\r\n assignDeep,\r\n bind,\r\n wnd,\r\n mathMax,\r\n windowSize,\r\n strHidden,\r\n strOverflowX,\r\n strOverflowY,\r\n setStyles,\r\n addRemoveAttrClass,\r\n setAttrs,\r\n} from '~/support';\r\nimport { getEnvironment } from '~/environment';\r\nimport {\r\n dataAttributeHost,\r\n dataAttributeHostOverflowX,\r\n dataAttributeHostOverflowY,\r\n dataValueHostOverflowVisible,\r\n dataValueViewportScrollbarHidden,\r\n dataValueViewportOverflowVisible,\r\n dataAttributeViewport,\r\n dataAttributePadding,\r\n dataValuePaddingOverflowVisible,\r\n} from '~/classnames';\r\nimport { getStaticPluginModuleInstance, scrollbarsHidingPluginName } from '~/plugins';\r\nimport type { WH, XY } from '~/support';\r\nimport type { ScrollbarsHidingPlugin } from '~/plugins/scrollbarsHidingPlugin';\r\nimport type { StyleObject, OverflowStyle } from '~/typings';\r\nimport type { CreateStructureUpdateSegment } from '../structureSetup';\r\nimport type { ViewportOverflowState } from '../structureSetup.utils';\r\nimport {\r\n getShowNativeOverlaidScrollbars,\r\n getViewportOverflowState,\r\n overflowIsVisible,\r\n setViewportOverflowState,\r\n} from '../structureSetup.utils';\r\n\r\n/**\r\n * Lifecycle with the responsibility to set the correct overflow and scrollbar hiding styles of the viewport element.\r\n * @param structureUpdateHub\r\n * @returns\r\n */\r\nexport const createOverflowUpdateSegment: CreateStructureUpdateSegment = (\r\n structureSetupElements,\r\n structureSetupState\r\n) => {\r\n const env = getEnvironment();\r\n const {\r\n _host,\r\n _padding,\r\n _viewport,\r\n _viewportIsTarget,\r\n _isBody,\r\n _viewportAddRemoveClass,\r\n _windowElm,\r\n } = structureSetupElements;\r\n const { _nativeScrollbarsHiding } = env;\r\n const viewportIsTargetBody = _isBody && _viewportIsTarget;\r\n const max0 = bind(mathMax, 0);\r\n\r\n const whCacheOptions = {\r\n _equal: equalWH,\r\n _initialValue: { w: 0, h: 0 },\r\n };\r\n const xyCacheOptions = {\r\n _equal: equalXY,\r\n _initialValue: { x: strHidden, y: strHidden } as XY,\r\n };\r\n const getOverflowAmount = (viewportScrollSize: WH, viewportClientSize: WH) => {\r\n const tollerance = wnd.devicePixelRatio % 1 !== 0 ? 1 : 0;\r\n const amount = {\r\n w: max0(viewportScrollSize.w - viewportClientSize.w),\r\n h: max0(viewportScrollSize.h - viewportClientSize.h),\r\n };\r\n\r\n return {\r\n w: amount.w > tollerance ? amount.w : 0,\r\n h: amount.h > tollerance ? amount.h : 0,\r\n };\r\n };\r\n\r\n const [updateSizeFraction, getCurrentSizeFraction] = createCache>(\r\n whCacheOptions,\r\n bind(fractionalSize, _viewport)\r\n );\r\n const [updateViewportScrollSizeCache, getCurrentViewportScrollSizeCache] = createCache<\r\n WH\r\n >(whCacheOptions, bind(scrollSize, _viewport));\r\n const [updateOverflowAmountCache, getCurrentOverflowAmountCache] =\r\n createCache>(whCacheOptions);\r\n const [updateOverflowEdge, getCurrentOverflowEdgeCache] = createCache>(whCacheOptions);\r\n const [updateOverflowStyleCache] = createCache>(xyCacheOptions);\r\n\r\n const scrollbarsHidingPlugin = getStaticPluginModuleInstance(\r\n scrollbarsHidingPluginName\r\n );\r\n\r\n return (\r\n { _checkOption, _observersUpdateHints, _observersState, _force },\r\n { _paddingStyleChanged }\r\n ) => {\r\n const { _sizeChanged, _contentMutation, _directionChanged, _scrollbarSizeChanged } =\r\n _observersUpdateHints || {};\r\n const scrollbarsHidingPluginViewportArrangement =\r\n scrollbarsHidingPlugin &&\r\n scrollbarsHidingPlugin._viewportArrangement(\r\n structureSetupElements,\r\n structureSetupState,\r\n _observersState,\r\n env,\r\n _checkOption\r\n );\r\n\r\n const { _arrangeViewport, _undoViewportArrange, _hideNativeScrollbars } =\r\n scrollbarsHidingPluginViewportArrangement || {};\r\n\r\n const [showNativeOverlaidScrollbars, showNativeOverlaidScrollbarsChanged] =\r\n getShowNativeOverlaidScrollbars(_checkOption, env);\r\n const [overflow, overflowChanged] = _checkOption('overflow');\r\n\r\n const adjustViewportArrange =\r\n _sizeChanged ||\r\n _paddingStyleChanged ||\r\n _contentMutation ||\r\n _directionChanged ||\r\n _scrollbarSizeChanged ||\r\n showNativeOverlaidScrollbarsChanged;\r\n const overflowXVisible = overflowIsVisible(overflow.x);\r\n const overflowYVisible = overflowIsVisible(overflow.y);\r\n const overflowVisible = overflowXVisible || overflowYVisible;\r\n\r\n let sizeFractionCache = getCurrentSizeFraction(_force);\r\n let viewportScrollSizeCache = getCurrentViewportScrollSizeCache(_force);\r\n let overflowAmuntCache = getCurrentOverflowAmountCache(_force);\r\n let overflowEdgeCache = getCurrentOverflowEdgeCache(_force);\r\n\r\n let preMeasureViewportOverflowState: ViewportOverflowState | undefined;\r\n\r\n if (showNativeOverlaidScrollbarsChanged && _nativeScrollbarsHiding) {\r\n _viewportAddRemoveClass(dataValueViewportScrollbarHidden, !showNativeOverlaidScrollbars);\r\n }\r\n\r\n if (adjustViewportArrange) {\r\n if (overflowVisible) {\r\n _viewportAddRemoveClass(dataValueViewportOverflowVisible, false);\r\n }\r\n\r\n const [redoViewportArrange, undoViewportArrangeOverflowState] = _undoViewportArrange\r\n ? _undoViewportArrange(preMeasureViewportOverflowState)\r\n : [];\r\n\r\n const [sizeFraction, sizeFractionChanged] = (sizeFractionCache = updateSizeFraction(_force));\r\n const [viewportScrollSize, viewportScrollSizeChanged] = (viewportScrollSizeCache =\r\n updateViewportScrollSizeCache(_force));\r\n const viewportClientSize = clientSize(_viewport);\r\n const arrangedViewportScrollSize = viewportScrollSize;\r\n const arrangedViewportClientSize = viewportClientSize;\r\n\r\n redoViewportArrange && redoViewportArrange();\r\n\r\n // if re measure is required (only required if content arrange strategy is used)\r\n if (\r\n (viewportScrollSizeChanged || sizeFractionChanged || showNativeOverlaidScrollbarsChanged) &&\r\n undoViewportArrangeOverflowState &&\r\n !showNativeOverlaidScrollbars &&\r\n _arrangeViewport &&\r\n _arrangeViewport(undoViewportArrangeOverflowState, viewportScrollSize, sizeFraction)\r\n ) {\r\n // arrangedViewportClientSize = clientSize(_viewport);\r\n // arrangedViewportScrollSize = scrollSize(_viewport);\r\n }\r\n\r\n const windowInnerSize = windowSize(_windowElm());\r\n const overflowAmountScrollSize = {\r\n w: max0(mathMax(viewportScrollSize.w, arrangedViewportScrollSize.w) + sizeFraction.w),\r\n h: max0(mathMax(viewportScrollSize.h, arrangedViewportScrollSize.h) + sizeFraction.h),\r\n };\r\n\r\n const overflowAmountClientSize = {\r\n w: max0(\r\n (viewportIsTargetBody\r\n ? windowInnerSize.w\r\n : arrangedViewportClientSize.w + max0(viewportClientSize.w - viewportScrollSize.w)) +\r\n sizeFraction.w\r\n ),\r\n h: max0(\r\n (viewportIsTargetBody\r\n ? windowInnerSize.h\r\n : arrangedViewportClientSize.h + max0(viewportClientSize.h - viewportScrollSize.h)) +\r\n sizeFraction.h\r\n ),\r\n };\r\n\r\n overflowEdgeCache = updateOverflowEdge(overflowAmountClientSize);\r\n overflowAmuntCache = updateOverflowAmountCache(\r\n getOverflowAmount(overflowAmountScrollSize, overflowAmountClientSize),\r\n _force\r\n );\r\n }\r\n\r\n const [overflowEdge, overflowEdgeChanged] = overflowEdgeCache;\r\n const [overflowAmount, overflowAmountChanged] = overflowAmuntCache;\r\n const [viewportScrollSize, viewportScrollSizeChanged] = viewportScrollSizeCache;\r\n const [sizeFraction, sizeFractionChanged] = sizeFractionCache;\r\n const hasOverflow = {\r\n x: overflowAmount.w > 0,\r\n y: overflowAmount.h > 0,\r\n };\r\n const removeClipping =\r\n (overflowXVisible && overflowYVisible && (hasOverflow.x || hasOverflow.y)) ||\r\n (overflowXVisible && hasOverflow.x && !hasOverflow.y) ||\r\n (overflowYVisible && hasOverflow.y && !hasOverflow.x);\r\n const adjustViewportStyle =\r\n _paddingStyleChanged ||\r\n _directionChanged ||\r\n _scrollbarSizeChanged ||\r\n sizeFractionChanged ||\r\n viewportScrollSizeChanged ||\r\n overflowEdgeChanged ||\r\n overflowAmountChanged ||\r\n overflowChanged ||\r\n showNativeOverlaidScrollbarsChanged ||\r\n adjustViewportArrange;\r\n\r\n if (adjustViewportStyle) {\r\n const viewportStyle: StyleObject = {};\r\n const viewportOverflowState = setViewportOverflowState(\r\n structureSetupElements,\r\n hasOverflow,\r\n overflow,\r\n viewportStyle\r\n );\r\n\r\n _hideNativeScrollbars &&\r\n _hideNativeScrollbars(\r\n viewportOverflowState,\r\n _observersState,\r\n !!_arrangeViewport &&\r\n _arrangeViewport(viewportOverflowState, viewportScrollSize, sizeFraction),\r\n viewportStyle\r\n );\r\n\r\n if (_viewportIsTarget) {\r\n setAttrs(_host, dataAttributeHostOverflowX, viewportStyle[strOverflowX] as string);\r\n setAttrs(_host, dataAttributeHostOverflowY, viewportStyle[strOverflowY] as string);\r\n } else {\r\n setStyles(_viewport, viewportStyle);\r\n }\r\n }\r\n\r\n addRemoveAttrClass(_host, dataAttributeHost, dataValueHostOverflowVisible, removeClipping);\r\n addRemoveAttrClass(\r\n _padding,\r\n dataAttributePadding,\r\n dataValuePaddingOverflowVisible,\r\n removeClipping\r\n );\r\n if (!_viewportIsTarget) {\r\n addRemoveAttrClass(\r\n _viewport,\r\n dataAttributeViewport,\r\n dataValueViewportOverflowVisible,\r\n overflowVisible\r\n );\r\n }\r\n\r\n const [overflowStyle, overflowStyleChanged] = updateOverflowStyleCache(\r\n getViewportOverflowState(structureSetupElements)._overflowStyle\r\n );\r\n\r\n assignDeep(structureSetupState, {\r\n _overflowStyle: overflowStyle,\r\n _overflowEdge: {\r\n x: overflowEdge.w,\r\n y: overflowEdge.h,\r\n },\r\n _overflowAmount: {\r\n x: overflowAmount.w,\r\n y: overflowAmount.h,\r\n },\r\n _hasOverflow: hasOverflow,\r\n });\r\n\r\n return {\r\n _overflowStyleChanged: overflowStyleChanged,\r\n _overflowEdgeChanged: overflowEdgeChanged,\r\n _overflowAmountChanged: overflowAmountChanged,\r\n };\r\n };\r\n};\r\n","import { getEnvironment } from '~/environment';\r\nimport {\r\n addAttrClass,\r\n assignDeep,\r\n each,\r\n getElmentScroll,\r\n noop,\r\n scrollElementTo,\r\n strHidden,\r\n strMarginBottom,\r\n strMarginLeft,\r\n strMarginRight,\r\n strPaddingBottom,\r\n strPaddingLeft,\r\n strPaddingRight,\r\n strPaddingTop,\r\n type TRBL,\r\n type XY,\r\n} from '~/support';\r\nimport { dataAttributeHost, dataValueHostUpdating } from '~/classnames';\r\nimport type { StructureSetupElementsObj } from './structureSetup.elements';\r\nimport type {\r\n ObserversSetupState,\r\n ObserversSetupUpdateHints,\r\n Setup,\r\n SetupUpdateInfo,\r\n} from '~/setups';\r\nimport type { InitializationTarget } from '~/initialization';\r\nimport type { StyleObject, OverflowStyle } from '~/typings';\r\nimport { createStructureSetupElements } from './structureSetup.elements';\r\nimport {\r\n createOverflowUpdateSegment,\r\n createPaddingUpdateSegment,\r\n createTrinsicUpdateSegment,\r\n} from './updateSegments';\r\n\r\nexport interface StructureSetupState {\r\n _padding: TRBL;\r\n _paddingAbsolute: boolean;\r\n _viewportPaddingStyle: StyleObject;\r\n _overflowEdge: XY;\r\n _overflowAmount: XY;\r\n _overflowStyle: XY;\r\n _hasOverflow: XY;\r\n}\r\n\r\nexport interface StructureSetupUpdateInfo extends SetupUpdateInfo {\r\n _observersState: ObserversSetupState;\r\n _observersUpdateHints?: ObserversSetupUpdateHints;\r\n}\r\n\r\nexport type StructureSetupUpdateHints = {\r\n _overflowEdgeChanged?: boolean;\r\n _overflowAmountChanged?: boolean;\r\n _overflowStyleChanged?: boolean;\r\n _paddingStyleChanged?: boolean;\r\n};\r\n\r\nexport type StructureSetup = [\r\n ...Setup,\r\n /** The elements created by the structure setup. */\r\n StructureSetupElementsObj,\r\n /** Function to be called when the initialization was canceled. */\r\n () => void\r\n];\r\n\r\nexport type StructureUpdateSegment = (\r\n updateInfo: StructureSetupUpdateInfo,\r\n updateHints: Readonly\r\n) => StructureSetupUpdateHints | void;\r\n\r\nexport type CreateStructureUpdateSegment = (\r\n structureSetupElements: StructureSetupElementsObj,\r\n state: StructureSetupState\r\n) => StructureUpdateSegment;\r\n\r\nexport const createStructureSetup = (target: InitializationTarget): StructureSetup => {\r\n const [elements, appendStructureElements, canceled] = createStructureSetupElements(target);\r\n const state: StructureSetupState = {\r\n _padding: {\r\n t: 0,\r\n r: 0,\r\n b: 0,\r\n l: 0,\r\n },\r\n _paddingAbsolute: false,\r\n _viewportPaddingStyle: {\r\n [strMarginRight]: 0,\r\n [strMarginBottom]: 0,\r\n [strMarginLeft]: 0,\r\n [strPaddingTop]: 0,\r\n [strPaddingRight]: 0,\r\n [strPaddingBottom]: 0,\r\n [strPaddingLeft]: 0,\r\n },\r\n _overflowEdge: { x: 0, y: 0 },\r\n _overflowAmount: { x: 0, y: 0 },\r\n _overflowStyle: {\r\n x: strHidden,\r\n y: strHidden,\r\n },\r\n _hasOverflow: {\r\n x: false,\r\n y: false,\r\n },\r\n };\r\n const { _target, _viewport, _viewportIsTarget } = elements;\r\n const { _nativeScrollbarsHiding, _nativeScrollbarsOverlaid } = getEnvironment();\r\n const doViewportArrange =\r\n !_nativeScrollbarsHiding && (_nativeScrollbarsOverlaid.x || _nativeScrollbarsOverlaid.y);\r\n\r\n const updateSegments: StructureUpdateSegment[] = [\r\n createTrinsicUpdateSegment(elements, state),\r\n createPaddingUpdateSegment(elements, state),\r\n createOverflowUpdateSegment(elements, state),\r\n ];\r\n\r\n return [\r\n appendStructureElements,\r\n (updateInfo) => {\r\n const updateHints: StructureSetupUpdateHints = {};\r\n const adjustScrollOffset = doViewportArrange;\r\n const scrollOffset = adjustScrollOffset && getElmentScroll(_viewport);\r\n\r\n const removeAttrClass = _viewportIsTarget\r\n ? addAttrClass(_viewport, dataAttributeHost, dataValueHostUpdating)\r\n : noop;\r\n\r\n each(updateSegments, (updateSegment) => {\r\n assignDeep(updateHints, updateSegment(updateInfo, updateHints) || {});\r\n });\r\n\r\n removeAttrClass();\r\n\r\n scrollElementTo(_viewport, scrollOffset);\r\n !_viewportIsTarget && scrollElementTo(_target, 0);\r\n\r\n return updateHints;\r\n },\r\n state,\r\n elements,\r\n canceled,\r\n ];\r\n};\r\n","import {\r\n assignDeep,\r\n bind,\r\n getElmentScroll,\r\n isEmptyObject,\r\n keys,\r\n runEachAndClear,\r\n scrollElementTo,\r\n} from '~/support';\r\nimport { createOptionCheck } from '~/options';\r\nimport type { OptionsCheckFn, Options, PartialOptions, ReadonlyOptions } from '~/options';\r\nimport type { DeepReadonly } from '~/typings';\r\nimport type { InitializationTarget } from '~/initialization';\r\nimport type { ObserversSetupState, ObserversSetupUpdateHints } from './observersSetup';\r\nimport type { StructureSetupState, StructureSetupUpdateHints } from './structureSetup';\r\nimport type { StructureSetupElementsObj } from './structureSetup/structureSetup.elements';\r\nimport type { ScrollbarsSetupElementsObj } from './scrollbarsSetup/scrollbarsSetup.elements';\r\nimport { createObserversSetup } from './observersSetup';\r\nimport { createScrollbarsSetup } from './scrollbarsSetup';\r\nimport { createStructureSetup } from './structureSetup';\r\n\r\nexport type SetupUpdateHints = Partial>;\r\n\r\nexport type SetupUpdateInfo = {\r\n _checkOption: OptionsCheckFn;\r\n _changedOptions: PartialOptions;\r\n _force: boolean;\r\n};\r\n\r\nexport type Setup<\r\n U extends SetupUpdateInfo,\r\n S extends Readonly>,\r\n H extends SetupUpdateHints | void\r\n> = [\r\n /** The create function which returns the `destroy` function. */\r\n _create: () => () => void,\r\n /** Function which updates the setup and returns the update result. */\r\n _update: (updateInfo: U) => H,\r\n /** Function which returns the current state. */\r\n _state: S\r\n];\r\n\r\nexport interface SetupsUpdateInfo {\r\n /** The options that changed or `undefined` if none changed. */\r\n _changedOptions?: PartialOptions;\r\n /** Whether chache should be ignored. */\r\n _force?: boolean;\r\n /** Whether observers should take their records and thus update as well. */\r\n _takeRecords?: boolean;\r\n /** Whether one or more scrollbars has been cloned. */\r\n _cloneScrollbar?: boolean;\r\n}\r\n\r\nexport interface SetupsUpdateHints {\r\n readonly _observersUpdateHints: DeepReadonly;\r\n readonly _structureUpdateHints: DeepReadonly;\r\n}\r\n\r\nexport interface SetupsState {\r\n readonly _observersSetupState: DeepReadonly;\r\n readonly _structureSetupState: DeepReadonly;\r\n}\r\n\r\nexport interface SetupsElements {\r\n readonly _structureSetupElements: DeepReadonly;\r\n readonly _scrollbarsSetupElements: DeepReadonly;\r\n}\r\n\r\nexport type Setups = [\r\n construct: () => () => void,\r\n update: (updateInfo: SetupsUpdateInfo) => boolean,\r\n getState: () => SetupsState,\r\n elements: SetupsElements,\r\n canceled: () => void\r\n];\r\n\r\nexport const createSetups = (\r\n target: InitializationTarget,\r\n options: ReadonlyOptions,\r\n onUpdated: (updateInfo: SetupsUpdateInfo, updateHints: SetupsUpdateHints) => void,\r\n onScroll: (scrollEvent: Event) => void\r\n): Setups => {\r\n const getCurrentOption = createOptionCheck(options, {});\r\n const [\r\n structureSetupCreate,\r\n structureSetupUpdate,\r\n structureSetupState,\r\n structureSetupElements,\r\n structureSetupCanceled,\r\n ] = createStructureSetup(target);\r\n const [observersSetupCreate, observersSetupUpdate, observersSetupState] = createObserversSetup(\r\n structureSetupElements,\r\n structureSetupState,\r\n getCurrentOption,\r\n (observersUpdateHints) => {\r\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\r\n update({}, observersUpdateHints);\r\n }\r\n );\r\n const [scrollbarsSetupCreate, scrollbarsSetupUpdate, , scrollbarsSetupElements] =\r\n createScrollbarsSetup(\r\n target,\r\n options,\r\n observersSetupState,\r\n structureSetupState,\r\n structureSetupElements,\r\n onScroll\r\n );\r\n\r\n const updateHintsAreTruthy = (hints: SetupUpdateHints) =>\r\n keys(hints).some((key) => !!hints[key as keyof typeof hints]);\r\n\r\n const update = (\r\n updateInfo: SetupsUpdateInfo,\r\n observerUpdateHints?: ObserversSetupUpdateHints\r\n ): boolean => {\r\n const {\r\n _changedOptions: rawChangedOptions,\r\n _force: rawForce,\r\n _takeRecords,\r\n _cloneScrollbar,\r\n } = updateInfo;\r\n const _changedOptions = rawChangedOptions || {};\r\n const _force = !!rawForce;\r\n const baseUpdateInfoObj: SetupUpdateInfo = {\r\n _checkOption: createOptionCheck(options, _changedOptions, _force),\r\n _changedOptions,\r\n _force,\r\n };\r\n\r\n if (_cloneScrollbar) {\r\n scrollbarsSetupUpdate(baseUpdateInfoObj);\r\n return false;\r\n }\r\n\r\n const observersHints =\r\n observerUpdateHints ||\r\n observersSetupUpdate(\r\n assignDeep({}, baseUpdateInfoObj, {\r\n _takeRecords,\r\n })\r\n );\r\n\r\n const structureHints = structureSetupUpdate(\r\n assignDeep({}, baseUpdateInfoObj, {\r\n _observersState: observersSetupState,\r\n _observersUpdateHints: observersHints,\r\n })\r\n );\r\n scrollbarsSetupUpdate(\r\n assignDeep({}, baseUpdateInfoObj, {\r\n _observersUpdateHints: observersHints,\r\n _structureUpdateHints: structureHints,\r\n })\r\n );\r\n\r\n const truthyObserversHints = updateHintsAreTruthy(observersHints);\r\n const truthyStructureHints = updateHintsAreTruthy(structureHints);\r\n const changed =\r\n truthyObserversHints || truthyStructureHints || !isEmptyObject(_changedOptions) || _force;\r\n\r\n changed &&\r\n onUpdated(updateInfo, {\r\n _observersUpdateHints: observersHints,\r\n _structureUpdateHints: structureHints,\r\n });\r\n\r\n return changed;\r\n };\r\n\r\n return [\r\n () => {\r\n const { _originalScrollOffsetElement, _viewport } = structureSetupElements;\r\n const initialScroll = getElmentScroll(_originalScrollOffsetElement);\r\n const destroyFns = [observersSetupCreate(), structureSetupCreate(), scrollbarsSetupCreate()];\r\n\r\n scrollElementTo(_viewport, initialScroll);\r\n\r\n return bind(runEachAndClear, destroyFns);\r\n },\r\n update,\r\n () => ({\r\n _observersSetupState: observersSetupState,\r\n _structureSetupState: structureSetupState,\r\n }),\r\n {\r\n _structureSetupElements: structureSetupElements,\r\n _scrollbarsSetupElements: scrollbarsSetupElements,\r\n },\r\n structureSetupCanceled,\r\n ];\r\n};\r\n","import {\r\n assignDeep,\r\n isEmptyObject,\r\n isFunction,\r\n isHTMLElement,\r\n createEventListenerHub,\r\n isPlainObject,\r\n keys,\r\n isArray,\r\n push,\r\n runEachAndClear,\r\n bind,\r\n removeUndefinedProperties,\r\n} from '~/support';\r\nimport { getOptionsDiff } from '~/options';\r\nimport { getEnvironment } from '~/environment';\r\nimport { cancelInitialization } from '~/initialization';\r\nimport { addInstance, getInstance, removeInstance } from '~/instances';\r\nimport { createSetups } from '~/setups';\r\nimport {\r\n addPlugins,\r\n getStaticPluginModuleInstance,\r\n optionsValidationPluginModuleName,\r\n pluginModules,\r\n registerPluginModuleInstances,\r\n} from '~/plugins';\r\nimport type { XY, TRBL } from '~/support';\r\nimport type { Options, PartialOptions, ReadonlyOptions } from '~/options';\r\nimport type {\r\n InferInstancePluginModuleInstance,\r\n InferStaticPluginModuleInstance,\r\n InstancePlugin,\r\n OptionsValidationPlugin,\r\n Plugin,\r\n PluginModuleInstance,\r\n StaticPlugin,\r\n} from '~/plugins';\r\nimport type { Initialization, InitializationTarget, PartialInitialization } from '~/initialization';\r\nimport type { OverflowStyle } from '~/typings';\r\nimport type { EventListenerArgs, EventListener, EventListeners } from '~/eventListeners';\r\nimport type {\r\n ScrollbarsSetupElement,\r\n ScrollbarStructure,\r\n} from '~/setups/scrollbarsSetup/scrollbarsSetup.elements';\r\n\r\n// Notes:\r\n// Height intrinsic detection use \"content: true\" init strategy - or open ticket for custom height intrinsic observer\r\n\r\n/**\r\n * Describes the OverlayScrollbars environment.\r\n */\r\nexport interface Environment {\r\n /** The native scrollbars size of the browser / system. */\r\n scrollbarsSize: XY;\r\n /** Whether the native scrollbars are overlaid. */\r\n scrollbarsOverlaid: XY;\r\n /** Whether the browser supports native scrollbars hiding. */\r\n scrollbarsHiding: boolean;\r\n /** The rtl scroll behavior of the browser. */\r\n rtlScrollBehavior: { n: boolean; i: boolean };\r\n /** Whether the browser supports the ScrollTimeline API. */\r\n scrollTimeline: boolean;\r\n /** The default Initialization to use if nothing else is specified. */\r\n staticDefaultInitialization: Initialization;\r\n /** The default Options to use if nothing else is specified. */\r\n staticDefaultOptions: Options;\r\n\r\n /** Returns the current default Initialization. */\r\n getDefaultInitialization(): Initialization;\r\n /** Returns the current default Options. */\r\n getDefaultOptions(): Options;\r\n\r\n /**\r\n * Sets a new default Initialization.\r\n * If the new default Initialization is partially filled, its deeply merged with the current default Initialization.\r\n * @param newDefaultInitialization The new default Initialization.\r\n * @returns The current default Initialization.\r\n */\r\n setDefaultInitialization(newDefaultInitialization: PartialInitialization): Initialization;\r\n /**\r\n * Sets new default Options.\r\n * If the new default Options are partially filled, they're deeply merged with the current default Options.\r\n * @param newDefaultOptions The new default Options.\r\n * @returns The current default options.\r\n */\r\n setDefaultOptions(newDefaultOptions: PartialOptions): Options;\r\n}\r\n\r\n/**\r\n * The primary entry point to OverlayScrollbars.\r\n */\r\nexport interface OverlayScrollbarsStatic {\r\n /**\r\n * Returns the current OverlayScrollbars instance if the target already has an instance.\r\n * @param target The initialization target to from which the instance shall be returned.\r\n */\r\n (target: InitializationTarget): OverlayScrollbars | undefined;\r\n /**\r\n * Initializes a new OverlayScrollbars instance to the given target\r\n * or returns the current OverlayScrollbars instance if the target already has an instance.\r\n * @param target The target.\r\n * @param options The options. (Can be just an empty object)\r\n * @param eventListeners Optional event listeners.\r\n */\r\n (\r\n target: InitializationTarget,\r\n options: PartialOptions,\r\n eventListeners?: EventListeners\r\n ): OverlayScrollbars;\r\n\r\n /**\r\n * Adds a single plugin.\r\n * @param plugin The plugin to be added.\r\n * @returns The plugins static modules instance or `void` if no instance was found.\r\n */\r\n plugin

(\r\n plugin: P\r\n ): P extends StaticPlugin ? InferStaticPluginModuleInstance

: void;\r\n /**\r\n * Adds multiple plugins.\r\n * @param plugins The plugins to be added.\r\n * @returns The plugins static modules instances or `void` if no instance was found.\r\n */\r\n plugin

(\r\n plugins: P\r\n ): P extends [Plugin, ...Plugin[]]\r\n ? {\r\n [K in keyof P]: P[K] extends StaticPlugin ? InferStaticPluginModuleInstance : void;\r\n }\r\n : void;\r\n\r\n /**\r\n * Checks whether the passed value is a valid and not destroyed overlayscrollbars instance.\r\n * @param osInstance The value which shall be checked.\r\n */\r\n valid(osInstance: any): osInstance is OverlayScrollbars;\r\n /**\r\n * Gets the environment.\r\n */\r\n env(): Environment;\r\n}\r\n\r\n/**\r\n * Describes a OverlayScrollbars instances state.\r\n */\r\nexport interface State {\r\n /** Describes the current padding in pixel. */\r\n padding: TRBL;\r\n /** Whether the current padding is absolute. */\r\n paddingAbsolute: boolean;\r\n /** The client width (x) & height (y) of the viewport in pixel. */\r\n overflowEdge: XY;\r\n /** The overflow amount in pixel. */\r\n overflowAmount: XY;\r\n /** The css overflow style of the viewport. */\r\n overflowStyle: XY;\r\n /** Whether the viewport has an overflow. */\r\n hasOverflow: XY;\r\n /** Whether the direction is considered rtl. */\r\n directionRTL: boolean;\r\n /** Whether the instance is considered destroyed. */\r\n destroyed: boolean;\r\n}\r\n\r\n/**\r\n * Describes the elements of a scrollbar.\r\n */\r\nexport interface ScrollbarElements {\r\n /**\r\n * The root element of the scrollbar.\r\n * The HTML structure looks like this:\r\n * \r\n * \r\n * \r\n * \r\n * \r\n */\r\n scrollbar: HTMLElement;\r\n /** The track element of the scrollbar. */\r\n track: HTMLElement;\r\n /** The handle element of the scrollbar. */\r\n handle: HTMLElement;\r\n}\r\n\r\n/**\r\n * Describes the elements of a scrollbar and provides the possibility to clone them.\r\n */\r\nexport interface CloneableScrollbarElements extends ScrollbarElements {\r\n /**\r\n * Clones the current scrollbar and returns the cloned elements.\r\n * The returned elements aren't added to the DOM.\r\n */\r\n clone(): ScrollbarElements;\r\n}\r\n\r\n/**\r\n * Describes the elements of a OverlayScrollbars instance.\r\n */\r\nexport interface Elements {\r\n /** The element the instance was applied to. */\r\n target: HTMLElement;\r\n /** The host element. Its the root of all other elements. */\r\n host: HTMLElement;\r\n /**\r\n * The element which is responsible to apply correct paddings.\r\n * Depending on the Initialization it can be the same as the viewport element.\r\n */\r\n padding: HTMLElement;\r\n /** The element which is responsible to do any scrolling. */\r\n viewport: HTMLElement;\r\n /**\r\n * The element which is responsible to hold the content.\r\n * Depending on the Initialization it can be the same as the viewport element.\r\n */\r\n content: HTMLElement;\r\n /**\r\n * The element through which you can get the current `scrollLeft` or `scrollTop` offset.\r\n * Depending on the target element it can be the same as the viewport element.\r\n */\r\n scrollOffsetElement: HTMLElement;\r\n /**\r\n * The element through which you can add `scroll` events.\r\n * Depending on the target element it can be the same as the viewport element.\r\n */\r\n scrollEventElement: HTMLElement | Document;\r\n /** The horizontal scrollbar elements. */\r\n scrollbarHorizontal: CloneableScrollbarElements;\r\n /** The vertical scrollbar elements. */\r\n scrollbarVertical: CloneableScrollbarElements;\r\n}\r\n\r\n/**\r\n * Describes a OverlayScrollbars instance.\r\n */\r\nexport interface OverlayScrollbars {\r\n /** Gets the current options of the instance. */\r\n options(): Options;\r\n /**\r\n * Sets the options of the instance.\r\n * If the new options are partially filled, they're deeply merged with either the current options or the current default options.\r\n * @param newOptions The new options which should be applied.\r\n * @param pure Whether the options should be reset before the new options are added.\r\n * @returns Returns the current options of the instance.\r\n */\r\n options(newOptions: PartialOptions, pure?: boolean): Options;\r\n\r\n /**\r\n * Adds event listeners to the instance.\r\n * @param eventListeners An object which contains the added listeners.\r\n * @param pure Whether all already added event listeners should be removed before the new listeners are added.\r\n * @returns Returns a function which removes the added listeners.\r\n */\r\n on(eventListeners: EventListeners, pure?: boolean): () => void;\r\n /**\r\n * Adds a single event listener to the instance.\r\n * @param name The name of the event.\r\n * @param listener The listener which is invoked on that event.\r\n * @returns Returns a function which removes the added listeners.\r\n */\r\n on(name: N, listener: EventListener): () => void;\r\n /**\r\n * Adds multiple event listeners to the instance.\r\n * @param name The name of the event.\r\n * @param listener The listeners which are invoked on that event.\r\n * @returns Returns a function which removes the added listeners.\r\n */\r\n on(name: N, listener: EventListener[]): () => void;\r\n\r\n /**\r\n * Removes a single event listener from the instance.\r\n * @param name The name of the event.\r\n * @param listener The listener which shall be removed.\r\n */\r\n off(name: N, listener: EventListener): void;\r\n /**\r\n * Removes multiple event listeners from the instance.\r\n * @param name The name of the event.\r\n * @param listener The listeners which shall be removed.\r\n */\r\n off(name: N, listener: EventListener[]): void;\r\n\r\n /**\r\n * Updates the instance.\r\n * @param force Whether the update should force the cache to be invalidated.\r\n * @returns A boolean which indicates whether the `update` event was triggered through this update.\r\n * The update event is only triggered if something changed because of this update.\r\n */\r\n update(force?: boolean): boolean;\r\n /** Returns the state of the instance. */\r\n state(): State;\r\n /** Returns the elements of the instance. */\r\n elements(): Elements;\r\n /** Destroys the instance and removes all added elements. */\r\n destroy(): void;\r\n /** Returns the instance of the passed plugin or `undefined` if no instance was found. */\r\n plugin

(osPlugin: P): InferInstancePluginModuleInstance

| undefined;\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-redeclare\r\nexport const OverlayScrollbars: OverlayScrollbarsStatic = (\r\n target: InitializationTarget,\r\n options?: PartialOptions,\r\n eventListeners?: EventListeners\r\n) => {\r\n const { _getDefaultOptions } = getEnvironment();\r\n const targetIsElement = isHTMLElement(target);\r\n const instanceTarget = targetIsElement ? target : target.target;\r\n const potentialInstance = getInstance(instanceTarget);\r\n if (options && !potentialInstance) {\r\n let destroyed = false;\r\n const destroyFns: (() => void)[] = [];\r\n const instancePluginModuleInstances: Record = {};\r\n const validateOptions = (newOptions: PartialOptions) => {\r\n const newOptionsWithoutUndefined = removeUndefinedProperties(newOptions, true);\r\n const pluginValidate = getStaticPluginModuleInstance(\r\n optionsValidationPluginModuleName\r\n );\r\n return pluginValidate\r\n ? pluginValidate(newOptionsWithoutUndefined, true)\r\n : newOptionsWithoutUndefined;\r\n };\r\n const currentOptions: ReadonlyOptions = assignDeep(\r\n {},\r\n _getDefaultOptions(),\r\n validateOptions(options)\r\n );\r\n const [addPluginEvent, removePluginEvents, triggerPluginEvent] =\r\n createEventListenerHub();\r\n const [addInstanceEvent, removeInstanceEvents, triggerInstanceEvent] =\r\n createEventListenerHub(eventListeners);\r\n const triggerEvent: typeof triggerPluginEvent = (name, args) => {\r\n triggerInstanceEvent(name, args);\r\n triggerPluginEvent(name, args);\r\n };\r\n const [setupsConstruct, setupsUpdate, setupsState, setupsElements, setupsCanceled] =\r\n createSetups(\r\n target,\r\n currentOptions,\r\n ({ _changedOptions, _force }, { _observersUpdateHints, _structureUpdateHints }) => {\r\n const {\r\n _sizeChanged,\r\n _directionChanged,\r\n _heightIntrinsicChanged,\r\n _contentMutation,\r\n _hostMutation,\r\n _appear,\r\n } = _observersUpdateHints;\r\n\r\n const { _overflowEdgeChanged, _overflowAmountChanged, _overflowStyleChanged } =\r\n _structureUpdateHints;\r\n\r\n triggerEvent('updated', [\r\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\r\n instance,\r\n {\r\n updateHints: {\r\n sizeChanged: !!_sizeChanged,\r\n directionChanged: !!_directionChanged,\r\n heightIntrinsicChanged: !!_heightIntrinsicChanged,\r\n overflowEdgeChanged: !!_overflowEdgeChanged,\r\n overflowAmountChanged: !!_overflowAmountChanged,\r\n overflowStyleChanged: !!_overflowStyleChanged,\r\n contentMutation: !!_contentMutation,\r\n hostMutation: !!_hostMutation,\r\n appear: !!_appear,\r\n },\r\n changedOptions: _changedOptions || {},\r\n force: !!_force,\r\n },\r\n ]);\r\n },\r\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\r\n (scrollEvent) => triggerEvent('scroll', [instance, scrollEvent])\r\n );\r\n\r\n const destroy = (canceled: boolean) => {\r\n removeInstance(instanceTarget);\r\n runEachAndClear(destroyFns);\r\n\r\n destroyed = true;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\r\n triggerEvent('destroyed', [instance, canceled]);\r\n removePluginEvents();\r\n removeInstanceEvents();\r\n };\r\n\r\n const instance: OverlayScrollbars = {\r\n options(newOptions?: PartialOptions, pure?: boolean) {\r\n if (newOptions) {\r\n const base = pure ? _getDefaultOptions() : {};\r\n const changedOptions = getOptionsDiff(\r\n currentOptions,\r\n assignDeep(base, validateOptions(newOptions))\r\n );\r\n if (!isEmptyObject(changedOptions)) {\r\n assignDeep(currentOptions, changedOptions);\r\n setupsUpdate({ _changedOptions: changedOptions });\r\n }\r\n }\r\n return assignDeep({}, currentOptions);\r\n },\r\n on: addInstanceEvent,\r\n off: (name, listener) => {\r\n name && listener && removeInstanceEvents(name, listener);\r\n },\r\n state() {\r\n const { _observersSetupState, _structureSetupState } = setupsState();\r\n const { _directionIsRTL } = _observersSetupState;\r\n const {\r\n _overflowEdge,\r\n _overflowAmount,\r\n _overflowStyle,\r\n _hasOverflow,\r\n _padding,\r\n _paddingAbsolute,\r\n } = _structureSetupState;\r\n return assignDeep(\r\n {},\r\n {\r\n overflowEdge: _overflowEdge,\r\n overflowAmount: _overflowAmount,\r\n overflowStyle: _overflowStyle,\r\n hasOverflow: _hasOverflow,\r\n padding: _padding,\r\n paddingAbsolute: _paddingAbsolute,\r\n directionRTL: _directionIsRTL,\r\n destroyed,\r\n }\r\n );\r\n },\r\n elements() {\r\n const {\r\n _target,\r\n _host,\r\n _padding,\r\n _viewport,\r\n _content,\r\n _scrollOffsetElement,\r\n _scrollEventElement,\r\n } = setupsElements._structureSetupElements;\r\n const { _horizontal, _vertical } = setupsElements._scrollbarsSetupElements;\r\n const translateScrollbarStructure = (\r\n scrollbarStructure: ScrollbarStructure\r\n ): ScrollbarElements => {\r\n const { _handle, _track, _scrollbar } = scrollbarStructure;\r\n return {\r\n scrollbar: _scrollbar,\r\n track: _track,\r\n handle: _handle,\r\n };\r\n };\r\n const translateScrollbarsSetupElement = (\r\n scrollbarsSetupElement: ScrollbarsSetupElement\r\n ): CloneableScrollbarElements => {\r\n const { _scrollbarStructures, _clone } = scrollbarsSetupElement;\r\n const translatedStructure = translateScrollbarStructure(_scrollbarStructures[0]);\r\n\r\n return assignDeep({}, translatedStructure, {\r\n clone: () => {\r\n const result = translateScrollbarStructure(_clone());\r\n setupsUpdate({ _cloneScrollbar: true });\r\n return result;\r\n },\r\n });\r\n };\r\n return assignDeep(\r\n {},\r\n {\r\n target: _target,\r\n host: _host,\r\n padding: _padding || _viewport,\r\n viewport: _viewport,\r\n content: _content || _viewport,\r\n scrollOffsetElement: _scrollOffsetElement,\r\n scrollEventElement: _scrollEventElement,\r\n scrollbarHorizontal: translateScrollbarsSetupElement(_horizontal),\r\n scrollbarVertical: translateScrollbarsSetupElement(_vertical),\r\n }\r\n );\r\n },\r\n update: (_force?: boolean) => setupsUpdate({ _force, _takeRecords: true }),\r\n destroy: bind(destroy, false),\r\n plugin:

(plugin: P) =>\r\n instancePluginModuleInstances[keys(plugin)[0]] as\r\n | InferInstancePluginModuleInstance

\r\n | undefined,\r\n };\r\n\r\n push(destroyFns, [setupsCanceled]);\r\n\r\n // valid inside plugins\r\n addInstance(instanceTarget, instance);\r\n\r\n // init plugins\r\n registerPluginModuleInstances(pluginModules, OverlayScrollbars, [\r\n instance,\r\n addPluginEvent,\r\n instancePluginModuleInstances,\r\n ]);\r\n\r\n if (\r\n cancelInitialization(\r\n setupsElements._structureSetupElements._isBody,\r\n !targetIsElement && target.cancel\r\n )\r\n ) {\r\n destroy(true);\r\n return instance;\r\n }\r\n\r\n push(destroyFns, setupsConstruct());\r\n\r\n triggerEvent('initialized', [instance]);\r\n\r\n instance.update(true);\r\n\r\n return instance;\r\n }\r\n return potentialInstance!;\r\n};\r\n\r\nOverlayScrollbars.plugin = (plugins: Plugin | Plugin[]) => {\r\n const isArr = isArray(plugins);\r\n const pluginsToAdd: Plugin[] =\r\n isArr ? plugins : [plugins];\r\n const result = pluginsToAdd.map(\r\n (plugin) => registerPluginModuleInstances(plugin, OverlayScrollbars)[0]\r\n );\r\n addPlugins(pluginsToAdd);\r\n return isArr ? result : (result[0] as any);\r\n};\r\nOverlayScrollbars.valid = (osInstance: any): osInstance is OverlayScrollbars => {\r\n const hasElmsFn = osInstance && (osInstance as OverlayScrollbars).elements;\r\n const elements = isFunction(hasElmsFn) && hasElmsFn();\r\n return isPlainObject(elements) && !!getInstance(elements.target);\r\n};\r\nOverlayScrollbars.env = () => {\r\n const {\r\n _nativeScrollbarsSize,\r\n _nativeScrollbarsOverlaid,\r\n _nativeScrollbarsHiding,\r\n _rtlScrollBehavior,\r\n _scrollTimeline,\r\n _staticDefaultInitialization,\r\n _staticDefaultOptions,\r\n _getDefaultInitialization,\r\n _setDefaultInitialization,\r\n _getDefaultOptions,\r\n _setDefaultOptions,\r\n } = getEnvironment();\r\n return assignDeep(\r\n {},\r\n {\r\n scrollbarsSize: _nativeScrollbarsSize,\r\n scrollbarsOverlaid: _nativeScrollbarsOverlaid,\r\n scrollbarsHiding: _nativeScrollbarsHiding,\r\n rtlScrollBehavior: _rtlScrollBehavior,\r\n scrollTimeline: _scrollTimeline,\r\n staticDefaultInitialization: _staticDefaultInitialization,\r\n staticDefaultOptions: _staticDefaultOptions,\r\n\r\n getDefaultInitialization: _getDefaultInitialization,\r\n setDefaultInitialization: _setDefaultInitialization,\r\n getDefaultOptions: _getDefaultOptions,\r\n setDefaultOptions: _setDefaultOptions,\r\n }\r\n );\r\n};\r\n"],"names":["createCache","options","update","o","_initialValue","u","_equal","_","_alwaysUpdateValues","_value","_previous","cacheUpdateContextual","newValue","force","curr","newVal","changed","cacheUpdateIsolated","getCurrentCache","isBrowser","window","document","wnd","mathMax","Math","max","mathMin","min","mathRound","round","mathAbs","abs","cAF","cancelAnimationFrame","rAF","requestAnimationFrame","setT","setTimeout","clearT","clearTimeout","getApi","name","undefined","MutationObserverConstructor","IntersectionObserverConstructor","ResizeObserverConstructor","scrollT","ElementNodeType","Node","ELEMENT_NODE","toString","hasOwnProperty","Object","prototype","typeRgx","isUndefined","obj","isNull","type","call","replace","toLowerCase","isNumber","isString","isBoolean","isFunction","isArray","Array","isObject","isArrayLike","length","lengthCorrectFormat","isPlainObject","key","cstr","ctor","ctorProto","hasOwnConstructor","hasIsPrototypeOf","isHTMLElement","instanceofObj","HTMLElement","nodeType","isElement","Element","animationCurrentTime","performance","now","animateNumber","from","to","duration","onFrame","easing","animationFrameId","timeStart","finalDuration","frame","complete","timeNow","timeElapsed","stopAnimation","percent","progress","animationCompleted","each","source","callback","i","keys","inArray","arr","item","indexOf","concat","a","b","push","array","items","arrayIsSingleItem","apply","createOrKeepArray","value","isEmptyArray","deduplicateArray","Set","runEachAndClear","args","keep","runFn","fn","strPaddingTop","strPaddingRight","strPaddingLeft","strPaddingBottom","strMarginLeft","strMarginRight","strMarginBottom","strOverflowX","strOverflowY","strWidth","strHeight","strHidden","strVisible","equal","props","propMutation","result","prop","compareA","compareB","equalWH","equalXY","equalTRBL","noop","bind","selfClearTimeout","timeout","id","setTFn","clearTFn","debounce","functionToDebounce","maxTimeoutId","prevArguments","latestArguments","clear","v","_timeout","p","_maxDelay","S","_mergeParams","invokeFunctionToDebounce","this","mergeParms","flush","debouncedFn","arguments","finalTimeout","hasTimeout","finalMaxWait","hasMaxWait","setTimeoutFn","clearTimeoutFn","mergeParamsResult","invokedArgs","boundInvoke","timeoutId","_flush","assignDeep","target","object1","object2","object3","object4","object5","object6","sources","copy","copyIsArray","src","clone","slice","removeUndefinedProperties","deep","isEmptyObject","capNumber","number","getDomTokensArray","tokens","split","filter","token","getAttr","elm","attrName","getAttribute","hasAttr","hasAttribute","setAttrs","attrNames","setAttribute","removeAttrs","removeAttribute","domTokenListAttr","initialArr","setElmAttr","domTokenListOperation","operationTokens","operation","initialArrSet","join","_remove","removeTokens","_add","addTokens","_has","hasTokens","tokenSet","reduce","boolean","includes","removeAttrClass","addAttrClass","addRemoveAttrClass","add","hasAttrClass","createDomTokenListClass","removeClass","className","addClass","find","selector","rootElm","querySelectorAll","findFirst","querySelector","is","matches","isBodyElement","contents","childNodes","parent","parentElement","closest","getFocusedElement","doc","activeElement","liesBetween","highBoundarySelector","deepBoundarySelector","closestHighBoundaryElm","closestDeepBoundaryElm","deepBoundaryIsValid","removeElements","nodes","e","parentElm","removeChild","before","preferredAnchor","insertedElms","anchor","fragment","createDocumentFragment","insertedElm","previousSibling","appendChild","firstChild","nextSibling","insertBefore","appendChildren","node","children","insertAfter","insertedNodes","createDiv","classNames","div","createElement","createDOM","html","createdDiv","innerHTML","trim","customCssPropRegex","getCSSVal","computedStyle","getPropertyValue","validFiniteNumber","notNaN","isFinite","parseToZeroOrNumber","parseFloat","ratioToCssPercent","ratio","toFixed","numberToCssPx","setStyles","styles","rawValue","elmStyle","style","test","setProperty","_unused","getStyles","pseudoElm","getSingleStyle","getStylesResult","getComputedStyle","getDirectionIsRTL","topRightBottomLeft","propertyPrefix","propertySuffix","finalPrefix","finalSuffix","top","right","bottom","left","t","r","l","getTrasformTranslateValue","isHorizontal","x","y","zeroObj","w","h","getElmWidthHeightProperty","property","windowSize","customWnd","offsetSize","clientSize","scrollSize","fractionalSize","cssWidth","cssHeight","getBoundingClientRect","domRectHasDimensions","rect","domRectAppeared","currContentRect","prevContentRect","rectHasDimensions","rectHadDimensions","removeEventListener","eventNames","listener","capture","eventName","addEventListener","_ref","passive","_passive","_capture","once","_once","nativeOptions","map","finalListener","evt","stopPropagation","preventDefault","absoluteCoordinates","scrollX","scrollY","convertScrollPosition","scrollPosition","overflowAmount","rtlScrollBehavior","n","getRawScrollBounds","getRawScrollRatio","rawScrollPosition","scrollElementTo","position","scrollLeft","scrollTop","getElmentScroll","manageListener","createEventListenerHub","initialEventListeners","events","Map","removeEvent","eventSet","get","currListener","forEach","addEvent","nameOrEventListeners","listenerOrPure","set","eventListenerKeys","offFns","eventListener","triggerEvent","event","opsStringify","JSON","stringify","val","getPropByPath","path","defaultOptions","paddingAbsolute","showNativeOverlaidScrollbars","elementEvents","attributes","ignoreMutation","overflow","scrollbars","theme","visibility","autoHide","autoHideDelay","autoHideSuspend","dragScroll","clickScroll","pointers","getOptionsDiff","currOptions","newOptions","diff","optionsKeys","optionKey","currOptionValue","newOptionValue","isDiff","createOptionCheck","changedOptions","dataAttributePrefix","classNameEnvironment","classNameEnvironmentScrollbarHidden","dataAttributeInitialize","dataAttributeHost","dataAttributeHostOverflowX","dataAttributeHostOverflowY","dataValueHostOverflowVisible","dataValueHostScrollbarPressed","dataValueHostUpdating","dataValueHostHtmlBody","dataAttributeViewport","dataValueViewportArrange","dataValueViewportScrollbarHidden","dataValueViewportOverflowVisible","dataAttributePadding","dataValuePaddingOverflowVisible","dataAttributeContent","classNameSizeObserver","classNameSizeObserverAppear","classNameSizeObserverListener","classNameSizeObserverListenerScroll","classNameSizeObserverListenerItem","classNameSizeObserverListenerItemFinal","classNameTrinsicObserver","classNameScrollbarThemeNone","classNameScrollbar","classNameScrollbarRtl","classNameScrollbarHorizontal","classNameScrollbarVertical","classNameScrollbarTrack","classNameScrollbarHandle","classNameScrollbarVisible","classNameScrollbarCornerless","classNameScrollbarInteraction","classNameScrollbarUnusable","classNameScrollbarAutoHide","classNameScrollbarAutoHideHidden","classNameScrollbarWheel","classNameScrollbarTrackInteractive","classNameScrollbarHandleInteractive","pluginModules","staticPluginModuleInstances","addPlugins","addedPlugin","plugin","registerPluginModuleInstances","staticObj","instanceInfo","static","osStatic","instance","osInstance","instanceObj","instancePluginMap","getStaticPluginModuleInstance","pluginModuleName","optionsValidationPluginModuleName","sizeObserverPluginName","SizeObserverPlugin","listenerElement","onSizeChangedCallback","observeAppearChange","scrollAmount","scrollEventName","observerElementChildren","observerElementChildrenRoot","shrinkElement","lastChild","expandElement","expandElementChild","cacheSize","currSize","isDirty","rAFId","reset","onResized","appear","onScroll","scrollEvent","destroyFns","getShowNativeOverlaidScrollbars","checkOption","env","T","_nativeScrollbarsOverlaid","showNativeOverlaidScrollbarsOption","showNativeOverlaidScrollbarsChanged","overflowIsVisible","overflowBehavior","getViewportOverflowState","structureSetupElements","viewportStyleObj","D","_viewport","getStatePerAxis","styleKey","overflowStyle","objectPrefferedOverflowStyle","overflowScroll","xOverflowStyle","xOverflowScroll","yOverflowStyle","yOverflowScroll","_overflowStyle","_overflowScroll","setViewportOverflowState","hasOverflow","overflowOption","hasAnyOverflow","setAxisOverflowStyle","behavior","hasOverflowAxis","overflowVisible","fallbackVisibilityBehavior","overflowVisibleBehavior","overflowX","visibleBehaviorX","overflowY","visibleBehaviorY","scrollbarsHidingPluginName","ScrollbarsHidingPlugin","_viewportArrangement","structureSetupState","observersSetupState","checkOptions","V","_viewportIsTarget","L","_nativeScrollbarsHiding","P","_nativeScrollbarsSize","doViewportArrange","_getViewportOverflowHideOffset","viewportOverflowState","R","arrangeHideOffset","getHideOffsetPerAxis","isOverlaid","nativeScrollbarSize","nonScrollbarStylingHideOffset","scrollbarsHideOffset","scrollbarsHideOffsetArrange","xScrollbarsHideOffset","xScrollbarsHideOffsetArrange","yScrollbarsHideOffset","yScrollbarsHideOffsetArrange","_scrollbarsHideOffset","_scrollbarsHideOffsetArrange","_hideNativeScrollbars","_directionIsRTL","viewportArrange","U","B","arrangeX","arrangeY","hideOffsetX","hideOffsetY","j","_viewportPaddingStyle","horizontalMarginKey","viewportHorizontalPaddingKey","horizontalMarginValue","verticalMarginValue","horizontalPaddingValue","verticalPaddingValue","_arrangeViewport","viewportScrollSize","sizeFraction","N","viewportArrangeHorizontalPaddingKey","viewportArrangeHorizontalPaddingValue","viewportArrangeVerticalPaddingValue","paddingTop","fractionalContentWidth","fractionalContenHeight","arrangeSize","_undoViewportArrange","finalViewportOverflowState","viewportPaddingStyle","finalPaddingStyle","assignProps","prevStyle","_envWindowZoom","size","dpr","getWindowDPR","screen","dDPI","deviceXDPI","sDPI","logicalXDPI","devicePixelRatio","diffBiggerThanOne","valOne","valTwo","absValOne","absValTwo","envInstance","updateNativeScrollbarSizeCache","sizeNew","deltaSize","deltaAbsSize","deltaAbsRatio","dprNew","deltaIsBigger","difference","dprChanged","isZoom","scrollbarSizeChanged","scrollbarSize","clickScrollPluginModuleName","ClickScrollPlugin","moveHandleRelative","getHandleOffset","startOffset","handleLength","relativeTrackPointerOffset","iteration","animateClickScroll","clickScrollProgress","sign","animationProgress","handleStartBound","handleEndBound","mouseBetweenHandleBounds","firstIterationPauseTimeout","environmentInstance","createEnvironment","getNativeScrollbarSize","measureElm","measureElmChild","body","cSize","oSize","fSize","getNativeScrollbarsHiding","testElm","revertClass","getRtlScrollBehavior","childElm","direction","parentOffset","childOffset","childOffsetAfterScroll","envStyle","envDOM","envElm","envChildElm","getNativeScrollbarSizeCache","nativeScrollbarsSize","nativeScrollbarsHiding","nativeScrollbarsOverlaid","staticDefaultInitialization","elements","host","padding","viewport","content","slot","cancel","staticDefaultOptions","getDefaultOptions","getDefaultInitialization","_scrollTimeline","_rtlScrollBehavior","_addResizeListener","_getDefaultInitialization","_setDefaultInitialization","newInitializationStrategy","_getDefaultOptions","_setDefaultOptions","newDefaultOptions","_staticDefaultInitialization","_staticDefaultOptions","scrollbarsHidingPlugin","zoomFn","getEnvironment","resolveInitialization","staticInitializationElement","fallbackStaticInitializationElement","defaultStaticInitializationElement","staticInitializationElementValue","staticInitialization","resolvedInitialization","dynamicInitializationElement","fallbackDynamicInitializationElement","defaultDynamicInitializationElement","dynamicInitializationElementValue","dynamicInitialization","cancelInitialization","isBody","cancelInitializationValue","G","defaultNativeScrollbarsOverlaid","defaultbody","resolvedNativeScrollbarsOverlaid","resolvedDocumentScrollingElement","finalNativeScrollbarsOverlaid","finalDocumentScrollingElement","targetInstanceMap","WeakMap","addInstance","removeInstance","delete","getInstance","createEventContentChange","eventContentChange","destroyed","destroy","updateElements","getElements","eventElmList","entries","isTargetChild","contains","removeListener","createDOMObserver","isContentObserver","isConnected","ct","_attributes","rt","_styleChangingAttributes","lt","_eventContentChange","it","_nestedTargetSelector","ut","_ignoreTargetChange","dt","_ignoreContentChange","debouncedEventContentChange","destroyEventContentChange","updateEventContentChangeElements","finalAttributes","finalStyleChangingAttributes","observedAttributes","observerCallback","fromRecords","mutations","ignoreTargetChange","ignoreContentChange","totalChangedNodes","targetChangedAttrs","targetStyleChanged","contentChanged","mutation","attributeName","mutationTarget","oldValue","addedNodes","removedNodes","isAttributesType","isChildListType","targetIsMutationTarget","isAttrChange","attributeValue","attributeChanged","styleChangingAttrChanged","contentAttrChanged","isNestedTarget","baseAssertion","contentFinalChanged","mutationObserver","observe","attributeOldValue","attributeFilter","subtree","childList","characterData","disconnect","takeRecords","createSizeObserver","_direction","observeDirectionChange","_appear","sizeObserverPlugin","getIsDirectionRTL","updateResizeObserverContentRectCache","baseElements","sizeObserver","onSizeChangedCallbackProxy","sizeChangedContext","isResizeObserverCall","ResizeObserverEntry","hasDirectionCache","skip","doDirectionScroll","currRContentRect","contentRect","hasDimensions","appeared","firstCall","rtl","_directionIsRTLCache","_sizeChanged","resizeObserverInstance","pop","pluginAppearCallback","pluginDestroyFns","updateDirectionIsRTLCache","directionIsRTLCacheValues","directionIsRTLCache","directionIsRTLCacheChanged","directionIsRTLCachePrevious","createTrinsicObserver","onTrinsicChangedCallback","intersectionObserverInstance","isHeightIntrinsic","ioEntryOrSize","isIntersecting","intersectionRatio","trinsicObserver","updateHeightIntrinsicCache","triggerOnTrinsicChangedCallback","updateValue","heightIntrinsic","heightIntrinsicChanged","intersectionObserverCallback","root","onSizeChanged","newSize","createObserversSetup","getCurrentOption","onObserversUpdated","debounceTimeout","debounceMaxDelay","updateContentMutationObserver","destroyContentMutationObserver","prevDirectionIsRTL","hostSelector","viewportSelector","viewportAttrsFromTarget","baseStyleChangingAttrsTextarea","baseStyleChangingAttrs","gt","_target","bt","_host","wt","_content","yt","_isTextarea","St","_viewportHasClass","$t","_viewportAddRemoveClass","state","_heightIntrinsic","updateContentSizeCache","hasOver","isArranged","scrollOffset","redoViewportArrange","contentScroll","viewportScroll","fractional","contentMutationObserverAttr","onObserversUpdatedDebounced","prev","prevObj","currObj","setDirectionWhenViewportIsTarget","updateHints","newDirectionIsRTL","_directionChanged","updateViewportAttrsFromHost","attribute","hostAttr","onTrinsicChanged","heightIntrinsicCache","_heightIntrinsicChanged","exclusiveSizeChange","updateFn","directionIsRTL","directionIsRTLChanged","onContentMutation","contentChangedThroughEvent","_contentMutation","onHostMutation","_hostMutation","Z","constructTrinsicObserver","updateTrinsicObserver","constructSizeObserver","constructHostMutationObserver","updateHostMutationObserver","viewportIsTargetResizeObserver","destroySizeObserver","destroyTrinsicObserver","destroyHostMutationObserver","removeResizeListener","_scrollbarSizeChanged","_checkOption","_takeRecords","_force","attributesChanged","elementEventsChanged","debounceValue","debounceChanged","contentMutationObserverChanged","ignoreMutationFromOptions","construct","ignore","maxWait","hostUpdateResult","trinsicUpdateResult","contentUpdateResult","createScrollbarsSetupElements","scrollbarsSetupEvents","K","defaultInitScrollbars","defaultInitScrollbarsSlot","Dt","_targetIsElm","kt","_scrollOffsetElement","Rt","_isBody","scrollbarsInit","initScrollbarsSlot","elementAnimations","initScrollTimeline","axis","scrollTimelineX","scrollTimelineY","evaluatedScrollbarSlot","generalDynamicInitializationElement","getScrollbarHandleLengthRatio","scrollbarStructure","Mt","_track","Vt","_handle","handleSize","trackSize","Lt","_overflowAmount","Pt","_overflowEdge","viewportSize","getScrollbarHandleOffsetRatio","scrollPercent","lengthRatio","addDirectionRTLKeyframes","keyframes","directionRTL","cancelElementAnimations","currAnimations","element","doCancel","animation","setElementAnimation","timeline","composite","activeAnimations","activeAnimation","effect","KeyframeEffect","animate","scrollbarStructureAddRemoveClass","scrollbarStructures","action","_scrollbar","scrollbarStyle","scrollbarStructureRefreshHandleLength","structure","scrollbarStructureRefreshHandleOffset","getTransformValue","Ut","transform","bound","scroll","doRefreshScrollbarOffset","scrollbar","horizontalScrollbars","verticalScrollbars","scrollbarsAddRemoveClass","onlyHorizontal","singleAxis","runHorizontal","runVertical","refreshScrollbarsHandleLength","refreshScrollbarsHandleOffset","refreshScrollbarsScrollbarOffset","cushion","setScrollbarElementAnimation","styleScrollbarPosition","getTranslateValue","axisScroll","axisOverflowAmount","px","generateScrollbarDOM","scrollbarClassName","track","handle","generateHorizontalScrollbarStructure","generateVerticalScrollbarStructure","appendElements","_refreshScrollbarsHandleLength","_refreshScrollbarsHandleOffset","_refreshScrollbarsScrollbarOffset","_scrollbarsAddRemoveClass","_horizontal","_scrollbarStructures","_clone","_style","_vertical","createScrollbarsSetupEvents","scrollbarHandlePointerInteraction","Kt","_documentElm","refreshScrollbarStructuresHandleOffset","wheelTimeout","clearWheelTimeout","requestHandleTransitionAnimationFrame","cancelHandleTransitionTimeout","refreshHandleOffsetTransition","scrollByFn","scrollBy","clientXYKey","widthHeightKey","leftTopKey","whKey","xyKey","isAffectingTransition","propertyName","createInteractiveScrollEvents","releasePointerCaptureEvents","createRelativeHandleMove","mouseDownScroll","invertedScale","deltaMovement","handleTrackDiff","scrollDeltaPercent","scrollDelta","pointerDownEvent","isDragScroll","pointerCaptureElement","scrollbarOptions","button","isPrimary","pointerType","continuePointerDown","instantClickScroll","shiftKey","getHandleRect","getTrackRect","handleRect","trackRect","axisScale","pointerDownOffset","handleCenter","releasePointerCapture","pointerUpEvent","pointerId","pointerMoveEvent","relativeMovement","setPointerCapture","wheelScrollBy","focusedElement","focus","preventScroll","wheelEvent","deltaX","deltaY","deltaMode","animateHandleOffset","createScrollbarsSetup","mouseInHost","autoHideIsMove","autoHideIsLeave","autoHideIsNever","prevTheme","instanceAutoHideSuspendScrollDestroyFn","instanceAutoHideDelay","isHoverablePointerType","requestScrollAnimationFrame","cancelScrollAnimationFrame","autoHideInstantInteractionTimeout","clearAutoHideInstantInteractionTimeout","autoHideSuspendTimeout","clearAutoHideSuspendTimeout","auotHideTimeout","clearAutoHideTimeout","manageScrollbarsAutoHideInstantInteraction","Zt","_scrollEventElement","Ft","Bt","Nt","jt","manageScrollbarsAutoHide","removeAutoHide","delayless","hide","manageAutoHideSuspension","onHostMouseEnter","_observersUpdateHints","_structureUpdateHints","tn","_overflowEdgeChanged","nn","_overflowAmountChanged","sn","_overflowStyleChanged","Ct","_t","k","en","_hasOverflow","themeChanged","visibilityChanged","autoHideChanged","autoHideSuspendChanged","dragScrollChanged","clickScrollChanged","overflowChanged","trulyAppeared","updateScrollbars","updateVisibility","setScrollbarVisibility","isVisible","xVisible","yVisible","hasCorner","createStructureSetupElements","defaultInitElements","defaultHostInitialization","defaultPaddingInitialization","defaultViewportInitialization","defaultContentInitialization","targetIsElm","targetStructureInitialization","initElements","hostInitialization","paddingInitialization","viewportInitialization","contentInitialization","targetElement","isTextarea","ownerDocument","docElement","documentElement","getDocumentWindow","defaultView","focusElm","customActiveElm","generalStaticInitializationElement","createNewDiv","generateViewportElement","generateContentElement","possibleViewportElement","viewportIsTarget","viewportIsTargetBody","possibleContentElement","viewportIsContent","viewportElement","nonBodyHostElement","hostElement","paddingElement","contentElement","generatedElements","elementIsGenerated","originalNonBodyScrollOffsetElement","evaluatedTargetObj","_padding","_originalScrollOffsetElement","_windowElm","viewportAttributeClassName","cn","isTextareaHostGenerated","targetContents","contentSlot","docWnd","initActiveElm","unwrap","prepareWrapUnwrapFocus","stopImmediatePropagation","tabIndexStr","ogTabindex","undoInitWrapUndwrapFocus","destroyActiveElm","undoDestroyWrapUndwrapFocus","createTrinsicUpdateSegment","_observersState","xt","Ot","createPaddingUpdateSegment","updatePaddingCache","currentPaddingCache","paddingChanged","ht","Ht","paddingAbsoluteChanged","contentMutation","paddingStyleChanged","paddingRelative","paddingHorizontal","paddingVertical","paddingStyle","viewportStyle","_paddingAbsolute","_paddingStyleChanged","createOverflowUpdateSegment","ln","max0","whCacheOptions","xyCacheOptions","getOverflowAmount","viewportClientSize","tollerance","amount","updateSizeFraction","getCurrentSizeFraction","updateViewportScrollSizeCache","getCurrentViewportScrollSizeCache","updateOverflowAmountCache","getCurrentOverflowAmountCache","updateOverflowEdge","getCurrentOverflowEdgeCache","updateOverflowStyleCache","It","scrollbarsHidingPluginViewportArrangement","q","W","X","adjustViewportArrange","overflowXVisible","overflowYVisible","sizeFractionCache","viewportScrollSizeCache","overflowAmuntCache","overflowEdgeCache","preMeasureViewportOverflowState","undoViewportArrangeOverflowState","sizeFractionChanged","viewportScrollSizeChanged","arrangedViewportScrollSize","arrangedViewportClientSize","windowInnerSize","overflowAmountScrollSize","overflowAmountClientSize","overflowEdge","overflowEdgeChanged","overflowAmountChanged","removeClipping","adjustViewportStyle","overflowStyleChanged","createStructureSetup","appendStructureElements","canceled","updateSegments","updateInfo","adjustScrollOffset","updateSegment","createSetups","onUpdated","structureSetupCreate","structureSetupUpdate","structureSetupCanceled","observersSetupCreate","observersSetupUpdate","observersUpdateHints","scrollbarsSetupCreate","scrollbarsSetupUpdate","scrollbarsSetupElements","updateHintsAreTruthy","hints","some","observerUpdateHints","_changedOptions","rawChangedOptions","rawForce","At","_n","_cloneScrollbar","baseUpdateInfoObj","observersHints","structureHints","truthyObserversHints","truthyStructureHints","rn","initialScroll","_observersSetupState","_structureSetupState","_structureSetupElements","_scrollbarsSetupElements","OverlayScrollbars","eventListeners","nt","targetIsElement","instanceTarget","potentialInstance","instancePluginModuleInstances","validateOptions","newOptionsWithoutUndefined","pluginValidate","currentOptions","addPluginEvent","removePluginEvents","triggerPluginEvent","addInstanceEvent","removeInstanceEvents","triggerInstanceEvent","setupsConstruct","setupsUpdate","setupsState","setupsElements","setupsCanceled","zt","sizeChanged","directionChanged","hostMutation","pure","base","on","off","vn","hn","un","qt","Jt","translateScrollbarStructure","translateScrollbarsSetupElement","scrollbarsSetupElement","Wt","Xt","translatedStructure","scrollOffsetElement","scrollEventElement","scrollbarHorizontal","scrollbarVertical","plugins","isArr","pluginsToAdd","valid","hasElmsFn","J","st","et","tt","ot","scrollbarsSize","scrollbarsOverlaid","scrollbarsHiding","scrollTimeline","setDefaultInitialization","setDefaultOptions"],"mappings":";;;;;;;;;AAiCO,MAAMA,cAA2BA,CACtCC,GACAC;EAEA,OAAMC,GAAEC,GAAaC,GAAEC,GAAMC,GAAEC,KAAwBP;EACvD,IAAIQ,IAAgBL;EACpB,IAAIM;EAEJ,MAAMC,wBAAsDA,CAACC,GAAUC;IACrE,MAAMC,IAAOL;IAEb,MAAMM,IAASH;IACf,MAAMI,IAAUH,MAAUP,KAAUA,EAAOQ,GAAMC,KAAUD,MAASC;IAEpE,IAAIC,KAAWR,GAAqB;MAClCC,IAASM;MACTL,IAAYI;AACd;IAEA,OAAO,EAACL,GAAQO,GAASN;AAAU;EAErC,MAAMO,sBAA2CJ,KAC/CF,sBAAsBT,EAAQO,GAAQC,IAAYG;EAEpD,MAAMK,kBAA2CL,KAAoB,EACnEJ,KACEI,GACFH;EAGF,OAAO,EAACR,IAASe,sBAAsBN,uBAAu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