{"version":3,"file":"start-waapi-animation.mjs","sources":["../../../../src/animation/waapi/start-waapi-animation.ts"],"sourcesContent":["import { activeAnimations } from \"../../stats/animation-count\"\nimport { statsBuffer } from \"../../stats/buffer\"\nimport { ValueKeyframesDefinition, ValueTransition } from \"../types\"\nimport { mapEasingToNativeEasing } from \"./easing/map-easing\"\n\nexport function startWaapiAnimation(\n    element: Element,\n    valueName: string,\n    keyframes: ValueKeyframesDefinition,\n    {\n        delay = 0,\n        duration = 300,\n        repeat = 0,\n        repeatType = \"loop\",\n        ease = \"easeOut\",\n        times,\n    }: ValueTransition = {},\n    pseudoElement: string | undefined = undefined\n) {\n    const keyframeOptions: PropertyIndexedKeyframes = {\n        [valueName]: keyframes as string[],\n    }\n    if (times) keyframeOptions.offset = times\n\n    const easing = mapEasingToNativeEasing(ease, duration)\n\n    /**\n     * If this is an easing array, apply to keyframes, not animation as a whole\n     */\n    if (Array.isArray(easing)) keyframeOptions.easing = easing\n\n    if (statsBuffer.value) {\n        activeAnimations.waapi++\n    }\n\n    const options: KeyframeAnimationOptions = {\n        delay,\n        duration,\n        easing: !Array.isArray(easing) ? easing : \"linear\",\n        fill: \"both\",\n        iterations: repeat + 1,\n        direction: repeatType === \"reverse\" ? \"alternate\" : \"normal\",\n    }\n\n    if (pseudoElement) options.pseudoElement = pseudoElement\n\n    const animation = element.animate(keyframeOptions, options)\n\n    if (statsBuffer.value) {\n        animation.finished.finally(() => {\n            activeAnimations.waapi--\n        })\n    }\n\n    return animation\n}\n"],"names":[],"mappings":";;;;AAKgB,SAAA,mBAAmB,CAC/B,OAAgB,EAChB,SAAiB,EACjB,SAAmC,EACnC,EACI,KAAK,GAAG,CAAC,EACT,QAAQ,GAAG,GAAG,EACd,MAAM,GAAG,CAAC,EACV,UAAU,GAAG,MAAM,EACnB,IAAI,GAAG,SAAS,EAChB,KAAK,GAAA,GACY,EAAE,EACvB,gBAAoC,SAAS,EAAA;AAE7C,IAAA,MAAM,eAAe,GAA6B;QAC9C,CAA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