{"version":3,"file":"size-rollup-scroll.js","sources":["../../motion-utils/dist/es/clamp.mjs","../../motion-utils/dist/es/global-config.mjs","../../motion-utils/dist/es/is-object.mjs","../../motion-utils/dist/es/noop.mjs","../../motion-utils/dist/es/progress.mjs","../../motion-dom/dist/es/frameloop/frame-data.mjs","../../motion-dom/dist/es/frameloop/order.mjs","../../motion-dom/dist/es/frameloop/batcher.mjs","../../motion-dom/dist/es/frameloop/render-step.mjs","../../motion-dom/dist/es/frameloop/frame.mjs","../../motion-dom/dist/es/utils/supports/flags.mjs","../../motion-dom/dist/es/utils/supports/memo.mjs","../../motion-utils/dist/es/memo.mjs","../../motion-dom/dist/es/utils/supports/scroll-timeline.mjs","../../motion-dom/dist/es/utils/is-html-element.mjs","../../motion-dom/dist/es/resize/handle-element.mjs","../../motion-dom/dist/es/utils/is-svg-element.mjs","../../motion-dom/dist/es/utils/resolve-elements.mjs","../../motion-dom/dist/es/resize/handle-window.mjs","../../motion-dom/dist/es/resize/index.mjs","../lib/render/dom/scroll/info.js","../../motion-utils/dist/es/velocity-per-second.mjs","../lib/render/dom/scroll/offsets/edge.js","../lib/render/dom/scroll/offsets/offset.js","../lib/render/dom/scroll/offsets/presets.js","../lib/render/dom/scroll/offsets/index.js","../lib/render/dom/scroll/on-scroll-handler.js","../lib/render/dom/scroll/offsets/inset.js","../lib/render/dom/scroll/track.js","../lib/render/dom/scroll/utils/get-timeline.js","../lib/render/dom/scroll/utils/offset-to-range.js","../lib/render/dom/scroll/attach-animation.js","../lib/render/dom/scroll/utils/can-use-native-timeline.js","../lib/render/dom/scroll/index.js"],"sourcesContent":["const clamp = (min, max, v) => {\n if (v > max)\n return max;\n if (v < min)\n return min;\n return v;\n};\n\nexport { clamp };\n//# sourceMappingURL=clamp.mjs.map\n","const MotionGlobalConfig = {};\n\nexport { MotionGlobalConfig };\n//# sourceMappingURL=global-config.mjs.map\n","const isObject = (value) => typeof value === \"object\" && value !== null;\n\nexport { isObject };\n//# sourceMappingURL=is-object.mjs.map\n","/*#__NO_SIDE_EFFECTS__*/\nconst noop = (any) => any;\n\nexport { noop };\n//# sourceMappingURL=noop.mjs.map\n","/*\n Progress within given range\n\n Given a lower limit and an upper limit, we return the progress\n (expressed as a number 0-1) represented by the given value, and\n limit that progress to within 0-1.\n*/\n/*#__NO_SIDE_EFFECTS__*/\nconst progress = (from, to, value) => {\n const range = to - from;\n return range ? (value - from) / range : 1;\n};\n\nexport { progress };\n//# sourceMappingURL=progress.mjs.map\n","/**\n * The frameloop's state, kept apart from the frameloop itself so that\n * reading it doesn't bundle the scheduler.\n */\nconst frameData = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n};\n\nexport { frameData };\n//# sourceMappingURL=frame-data.mjs.map\n","const stepsOrder = [\n \"setup\", // Compute\n \"read\", // Read\n \"resolveKeyframes\", // Write/Read/Write/Read\n \"preUpdate\", // Compute\n \"update\", // Compute\n \"preRender\", // Compute\n \"render\", // Write\n \"postRender\", // Compute\n];\n\nexport { stepsOrder };\n//# sourceMappingURL=order.mjs.map\n","import { MotionGlobalConfig } from 'motion-utils';\nimport { stepsOrder } from './order.mjs';\nimport { createRenderStep } from './render-step.mjs';\n\nconst maxElapsed = 40;\nfunction createRenderBatcher(scheduleNextBatch, allowKeepAlive, state = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n}) {\n let runNextFrame = false;\n let useDefaultElapsed = true;\n const flagRunNextFrame = () => (runNextFrame = true);\n const steps = stepsOrder.reduce((acc, key) => {\n acc[key] = createRenderStep(flagRunNextFrame);\n return acc;\n }, {});\n const { setup, read, resolveKeyframes, preUpdate, update, preRender, render, postRender, } = steps;\n const processBatch = () => {\n const useManualTiming = MotionGlobalConfig.useManualTiming;\n const timestamp = useManualTiming\n ? state.timestamp\n : performance.now();\n runNextFrame = false;\n if (!useManualTiming) {\n state.delta = useDefaultElapsed\n ? 1000 / 60\n : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);\n }\n state.timestamp = timestamp;\n state.isProcessing = true;\n // Unrolled render loop for better per-frame performance\n setup.process(state);\n read.process(state);\n resolveKeyframes.process(state);\n preUpdate.process(state);\n update.process(state);\n preRender.process(state);\n render.process(state);\n postRender.process(state);\n state.isProcessing = false;\n if (runNextFrame && allowKeepAlive) {\n useDefaultElapsed = false;\n scheduleNextBatch(processBatch);\n }\n };\n const wake = () => {\n runNextFrame = true;\n useDefaultElapsed = true;\n if (!state.isProcessing) {\n scheduleNextBatch(processBatch);\n }\n };\n const schedule = stepsOrder.reduce((acc, key) => {\n const step = steps[key];\n acc[key] = (process, keepAlive = false, immediate = false) => {\n if (!runNextFrame)\n wake();\n return step.schedule(process, keepAlive, immediate);\n };\n return acc;\n }, {});\n const cancel = (process) => {\n for (let i = 0; i < stepsOrder.length; i++) {\n steps[stepsOrder[i]].cancel(process);\n }\n };\n return { schedule, cancel, state, steps };\n}\n\nexport { createRenderBatcher };\n//# sourceMappingURL=batcher.mjs.map\n","function createRenderStep(runNextFrame) {\n /**\n * We create and reuse two queues, one to queue jobs for the current frame\n * and one for the next. We reuse to avoid triggering GC after x frames.\n */\n let thisFrame = new Set();\n let nextFrame = new Set();\n /**\n * Track whether we're currently processing jobs in this step. This way\n * we can decide whether to schedule new jobs for this frame or next.\n */\n let isProcessing = false;\n let flushNextFrame = false;\n /**\n * A set of processes which were marked keepAlive when scheduled.\n * A keepAlive process is always also held by a frame queue until\n * it's cancelled, so a Set has the same lifetime semantics as a\n * WeakSet here while being considerably faster to query every frame.\n */\n const toKeepAlive = new Set();\n let latestFrameData = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n };\n function triggerCallback(callback) {\n if (toKeepAlive.has(callback)) {\n nextFrame.add(callback);\n runNextFrame();\n }\n callback(latestFrameData);\n }\n const step = {\n /**\n * Schedule a process to run on the next frame.\n */\n schedule: (callback, keepAlive = false, immediate = false) => {\n const addToCurrentFrame = immediate && isProcessing;\n const queue = addToCurrentFrame ? thisFrame : nextFrame;\n if (keepAlive)\n toKeepAlive.add(callback);\n queue.add(callback);\n return callback;\n },\n /**\n * Cancel the provided callback from running on the next frame.\n */\n cancel: (callback) => {\n nextFrame.delete(callback);\n toKeepAlive.delete(callback);\n },\n /**\n * Execute all schedule callbacks.\n */\n process: (frameData) => {\n latestFrameData = frameData;\n /**\n * If we're already processing we've probably been triggered by a flushSync\n * inside an existing process. Instead of executing, mark flushNextFrame\n * as true and ensure we flush the following frame at the end of this one.\n */\n if (isProcessing) {\n flushNextFrame = true;\n return;\n }\n isProcessing = true;\n // Swap this frame and the next to avoid GC\n const prevFrame = thisFrame;\n thisFrame = nextFrame;\n nextFrame = prevFrame;\n // Execute this frame\n thisFrame.forEach(triggerCallback);\n // Clear the frame so no callbacks remain. This is to avoid\n // memory leaks should this render step not run for a while.\n thisFrame.clear();\n isProcessing = false;\n if (flushNextFrame) {\n flushNextFrame = false;\n step.process(frameData);\n }\n },\n };\n return step;\n}\n\nexport { createRenderStep };\n//# sourceMappingURL=render-step.mjs.map\n","import { noop } from 'motion-utils';\nimport { createRenderBatcher } from './batcher.mjs';\nimport { frameData } from './frame-data.mjs';\n\nconst { schedule: frame, cancel: cancelFrame, steps: frameSteps, } = /* @__PURE__ */ createRenderBatcher(typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : noop, true, frameData);\n\nexport { cancelFrame, frame, frameSteps };\n//# sourceMappingURL=frame.mjs.map\n","/**\n * Add the ability for test suites to manually set support flags\n * to better test more environments.\n */\nconst supportsFlags = {};\n\nexport { supportsFlags };\n//# sourceMappingURL=flags.mjs.map\n","import { memo } from 'motion-utils';\nimport { supportsFlags } from './flags.mjs';\n\nfunction memoSupports(callback, supportsFlag) {\n const memoized = memo(callback);\n return () => supportsFlags[supportsFlag] ?? memoized();\n}\n\nexport { memoSupports };\n//# sourceMappingURL=memo.mjs.map\n","/*#__NO_SIDE_EFFECTS__*/\nfunction memo(callback) {\n let result;\n return () => {\n if (result === undefined)\n result = callback();\n return result;\n };\n}\n\nexport { memo };\n//# sourceMappingURL=memo.mjs.map\n","import { memoSupports } from './memo.mjs';\n\nconst supportsScrollTimeline = /* @__PURE__ */ memoSupports(() => window.ScrollTimeline !== undefined, \"scrollTimeline\");\nconst supportsViewTimeline = /* @__PURE__ */ memoSupports(() => window.ViewTimeline !== undefined, \"viewTimeline\");\n\nexport { supportsScrollTimeline, supportsViewTimeline };\n//# sourceMappingURL=scroll-timeline.mjs.map\n","import { isObject } from 'motion-utils';\n\n/**\n * Checks if an element is an HTML element in a way\n * that works across iframes\n */\nfunction isHTMLElement(element) {\n return (isObject(element) &&\n \"offsetHeight\" in element &&\n !(\"ownerSVGElement\" in element));\n}\n\nexport { isHTMLElement };\n//# sourceMappingURL=is-html-element.mjs.map\n","import { isSVGElement } from '../utils/is-svg-element.mjs';\nimport { resolveElements } from '../utils/resolve-elements.mjs';\n\nconst resizeHandlers = new WeakMap();\nlet observer;\nconst getSize = (borderBoxAxis, svgAxis, htmlAxis) => (target, borderBoxSize) => {\n if (borderBoxSize && borderBoxSize[0]) {\n return borderBoxSize[0][(borderBoxAxis + \"Size\")];\n }\n else if (isSVGElement(target) && \"getBBox\" in target) {\n return target.getBBox()[svgAxis];\n }\n else {\n return target[htmlAxis];\n }\n};\nconst getWidth = /*@__PURE__*/ getSize(\"inline\", \"width\", \"offsetWidth\");\nconst getHeight = /*@__PURE__*/ getSize(\"block\", \"height\", \"offsetHeight\");\nfunction notifyTarget({ target, borderBoxSize }) {\n resizeHandlers.get(target)?.forEach((handler) => {\n handler(target, {\n get width() {\n return getWidth(target, borderBoxSize);\n },\n get height() {\n return getHeight(target, borderBoxSize);\n },\n });\n });\n}\nfunction notifyAll(entries) {\n entries.forEach(notifyTarget);\n}\nfunction createResizeObserver() {\n if (typeof ResizeObserver === \"undefined\")\n return;\n observer = new ResizeObserver(notifyAll);\n}\nfunction resizeElement(target, handler) {\n if (!observer)\n createResizeObserver();\n const elements = resolveElements(target);\n elements.forEach((element) => {\n let elementHandlers = resizeHandlers.get(element);\n if (!elementHandlers) {\n elementHandlers = new Set();\n resizeHandlers.set(element, elementHandlers);\n }\n elementHandlers.add(handler);\n observer?.observe(element);\n });\n return () => {\n elements.forEach((element) => {\n const elementHandlers = resizeHandlers.get(element);\n elementHandlers?.delete(handler);\n if (!elementHandlers?.size) {\n observer?.unobserve(element);\n }\n });\n };\n}\n\nexport { resizeElement };\n//# sourceMappingURL=handle-element.mjs.map\n","import { isObject } from 'motion-utils';\n\n/**\n * Checks if an element is an SVG element in a way\n * that works across iframes\n */\nfunction isSVGElement(element) {\n return isObject(element) && \"ownerSVGElement\" in element;\n}\n\nexport { isSVGElement };\n//# sourceMappingURL=is-svg-element.mjs.map\n","function resolveElements(elementOrSelector, scope, selectorCache) {\n if (elementOrSelector == null) {\n return [];\n }\n if (elementOrSelector instanceof EventTarget) {\n return [elementOrSelector];\n }\n else if (typeof elementOrSelector === \"string\") {\n let root = document;\n if (scope) {\n root = scope.current;\n }\n const elements = selectorCache?.[elementOrSelector] ??\n root.querySelectorAll(elementOrSelector);\n return elements ? Array.from(elements) : [];\n }\n return Array.from(elementOrSelector).filter((element) => element != null);\n}\n\nexport { resolveElements };\n//# sourceMappingURL=resolve-elements.mjs.map\n","const windowCallbacks = new Set();\nlet windowResizeHandler;\nfunction createWindowResizeHandler() {\n windowResizeHandler = () => {\n const info = {\n get width() {\n return window.innerWidth;\n },\n get height() {\n return window.innerHeight;\n },\n };\n windowCallbacks.forEach((callback) => callback(info));\n };\n window.addEventListener(\"resize\", windowResizeHandler);\n}\nfunction resizeWindow(callback) {\n windowCallbacks.add(callback);\n if (!windowResizeHandler)\n createWindowResizeHandler();\n return () => {\n windowCallbacks.delete(callback);\n if (!windowCallbacks.size &&\n typeof windowResizeHandler === \"function\") {\n window.removeEventListener(\"resize\", windowResizeHandler);\n windowResizeHandler = undefined;\n }\n };\n}\n\nexport { resizeWindow };\n//# sourceMappingURL=handle-window.mjs.map\n","import { resizeElement } from './handle-element.mjs';\nimport { resizeWindow } from './handle-window.mjs';\n\nfunction resize(a, b) {\n return typeof a === \"function\" ? resizeWindow(a) : resizeElement(a, b);\n}\n\nexport { resize };\n//# sourceMappingURL=index.mjs.map\n","import { clamp, progress, velocityPerSecond } from \"motion-utils\";\n/**\n * A time in milliseconds, beyond which we consider the scroll velocity to be 0.\n */\nconst maxElapsed = 50;\nconst createAxisInfo = () => ({\n current: 0,\n offset: [],\n progress: 0,\n scrollLength: 0,\n targetOffset: 0,\n targetLength: 0,\n containerLength: 0,\n velocity: 0,\n});\nexport const createScrollInfo = () => ({\n time: 0,\n x: createAxisInfo(),\n y: createAxisInfo(),\n});\n/**\n * Also iterated with for...in as the list of axes.\n */\nexport const axisKeys = {\n x: {\n length: \"Width\",\n position: \"Left\",\n },\n y: {\n length: \"Height\",\n position: \"Top\",\n },\n};\nconst styles = new WeakMap();\n/**\n * Whether an axis scrolls from its end, which browsers report as a scroll\n * position running from 0 to -scrollLength (#3340). This is read from style\n * rather than the sign of the scroll position, as elastic overscroll pushes\n * the position past 0 in either kind of axis (#3791).\n */\nfunction isReversed(element, axisName) {\n /**\n * The viewport takes its writing mode and direction from
, which\n * not every browser reflects in the root element's computed style. It\n * doesn't adopt the root element's flex layout.\n */\n const isRoot = element === document.scrollingElement;\n const source = (isRoot && document.body) || element;\n let style = styles.get(source);\n if (!style)\n styles.set(source, (style = getComputedStyle(source)));\n const { writingMode, flexDirection } = style;\n const isInline = (axisName === \"x\") !== /^[vs]/.test(writingMode);\n return ((isInline\n ? (style.direction === \"rtl\") !== (writingMode === \"sideways-lr\")\n : writingMode.endsWith(\"rl\")) !==\n /**\n * A reversed flex axis flips this. The main axis is the inline axis\n * unless flex-direction is a column.\n */\n (!isRoot &&\n style.display.includes(\"flex\") &&\n (isInline !== (flexDirection[0] === \"c\")\n ? flexDirection\n : style.flexWrap).endsWith(\"reverse\")));\n}\nfunction updateAxisInfo(element, axisName, info, time) {\n const axis = info[axisName];\n const { length, position } = axisKeys[axisName];\n const prev = axis.current;\n const prevTime = info.time;\n const scrollPosition = element[`scroll${position}`];\n axis.current = isReversed(element, axisName)\n ? -scrollPosition || 0 // Avoid -0\n : scrollPosition;\n axis.containerLength = element[`client${length}`];\n axis.targetLength = element[`scroll${length}`];\n axis.scrollLength = axis.targetLength - axis.containerLength;\n axis.offset.length = 0;\n axis.offset[0] = 0;\n axis.offset[1] = axis.scrollLength;\n axis.progress = clamp(0, 1, progress(0, axis.scrollLength, axis.current));\n const elapsed = time - prevTime;\n axis.velocity =\n elapsed > maxElapsed\n ? 0\n : velocityPerSecond(axis.current - prev, elapsed);\n}\n/**\n * Measures a scroll container. Runs once per container per frame; every\n * handler on that container derives its info from the result.\n */\nexport function updateScrollInfo(element, info, time) {\n for (const axis in axisKeys) {\n updateAxisInfo(element, axis, info, time);\n }\n info.time = time;\n}\n//# sourceMappingURL=info.js.map","/*\n Convert velocity into velocity per second\n*/\n/*#__NO_SIDE_EFFECTS__*/\nconst velocityPerSecond = (velocity, frameDuration) => frameDuration ? velocity * (1000 / frameDuration) : 0;\n\nexport { velocityPerSecond };\n//# sourceMappingURL=velocity-per-second.mjs.map\n","export const namedEdges = {\n start: 0,\n center: 0.5,\n end: 1,\n};\nexport function resolveEdge(edge, length, inset = 0) {\n let delta = 0;\n /**\n * If we have this edge defined as a preset, replace the definition\n * with the numerical value.\n */\n if (edge in namedEdges) {\n edge = namedEdges[edge];\n }\n /**\n * Handle unit values\n */\n if (typeof edge === \"string\") {\n const asNumber = parseFloat(edge);\n if (edge.endsWith(\"px\")) {\n delta = asNumber;\n }\n else if (edge.endsWith(\"%\")) {\n edge = asNumber / 100;\n }\n else if (edge.endsWith(\"vw\")) {\n delta = (asNumber / 100) * document.documentElement.clientWidth;\n }\n else if (edge.endsWith(\"vh\")) {\n delta = (asNumber / 100) * document.documentElement.clientHeight;\n }\n else {\n edge = asNumber;\n }\n }\n /**\n * If the edge is defined as a number, handle as a progress value.\n */\n if (typeof edge === \"number\") {\n delta = length * edge;\n }\n return inset + delta;\n}\n//# sourceMappingURL=edge.js.map","import { namedEdges, resolveEdge } from \"./edge\";\nconst defaultOffset = [0, 0];\nexport function resolveOffset(offset, containerLength, targetLength, targetInset) {\n let offsetDefinition = Array.isArray(offset) ? offset : defaultOffset;\n let targetPoint = 0;\n let containerPoint = 0;\n if (typeof offset === \"number\") {\n /**\n * If we're provided offset: [0, 0.5, 1] then each number x should become\n * [x, x], so we default to the behaviour of mapping 0 => 0 of both target\n * and container etc.\n */\n offsetDefinition = [offset, offset];\n }\n else if (typeof offset === \"string\") {\n offset = offset.trim();\n if (offset.includes(\" \")) {\n offsetDefinition = offset.split(\" \");\n }\n else {\n /**\n * If we're provided a definition like \"100px\" then we want to apply\n * that only to the top of the target point, leaving the container at 0.\n * Whereas a named offset like \"end\" should be applied to both.\n */\n offsetDefinition = [offset, namedEdges[offset] ? offset : `0`];\n }\n }\n targetPoint = resolveEdge(offsetDefinition[0], targetLength, targetInset);\n containerPoint = resolveEdge(offsetDefinition[1], containerLength);\n return targetPoint - containerPoint;\n}\n//# sourceMappingURL=offset.js.map","export const ScrollOffset = {\n Enter: [\n [0, 1],\n [1, 1],\n ],\n Exit: [\n [0, 0],\n [1, 0],\n ],\n Any: [\n [1, 0],\n [0, 1],\n ],\n All: [\n [0, 0],\n [1, 1],\n ],\n};\n//# sourceMappingURL=presets.js.map","import { clamp, progress } from \"motion-utils\";\nimport { resolveOffset } from \"./offset\";\nimport { ScrollOffset } from \"./presets\";\n/**\n * Resolved offsets map to evenly spaced progress values, so progress is\n * derived from the segment index rather than building an interpolator.\n */\nfunction offsetsToProgress(offsets, v) {\n const n = offsets.length - 1;\n if (n < 1)\n return 0;\n const reverse = offsets[0] > offsets[n];\n const at = (i) => offsets[reverse ? n - i : i];\n /**\n * Matches interpolate(), which checks for a zero-length first range\n * before reversing descending offsets.\n */\n if (offsets[0] === offsets[1] && v < at(0))\n return reverse ? 1 : 0;\n let i = 0;\n while (i < n - 1 && v >= at(i + 1))\n i++;\n const p = (i + progress(at(i), at(i + 1), v)) / n;\n return reverse ? 1 - p : p;\n}\nexport function resolveOffsets(info, options) {\n const { offset: offsetDefinition = ScrollOffset.All, axis = \"y\" } = options;\n const axisInfo = info[axis];\n /**\n * Reset the length of the resolved offset array rather than creating a new one.\n */\n axisInfo.offset.length = 0;\n /**\n * Populate the offset array by resolving the user's offset definition into\n * a list of pixel scroll offsets.\n */\n const numOffsets = offsetDefinition.length;\n for (let i = 0; i < numOffsets; i++) {\n axisInfo.offset[i] = resolveOffset(offsetDefinition[i], axisInfo.containerLength, axisInfo.targetLength, axisInfo.targetOffset);\n }\n axisInfo.progress = clamp(0, 1, offsetsToProgress(axisInfo.offset, axisInfo.current));\n}\n//# sourceMappingURL=index.js.map","import { warnOnce } from \"motion-utils\";\nimport { axisKeys } from \"./info\";\nimport { resolveOffsets } from \"./offsets/index\";\nimport { calcInset } from \"./offsets/inset\";\nfunction getTargetSize(target) {\n return \"getBBox\" in target && target.tagName !== \"svg\"\n ? target.getBBox()\n : { width: target.clientWidth, height: target.clientHeight };\n}\nexport function createOnScrollHandler(container, onScroll, info, options = {}) {\n const { target } = options;\n /**\n * In development mode ensure scroll containers aren't position: static as this makes\n * it difficult to measure their relative positions. The document scrolling element\n * is exempt: offsetParent measurements naturally resolve relative to the document.\n */\n if (process.env.NODE_ENV !== \"production\") {\n if (target &&\n target !== container &&\n container !== document.documentElement &&\n container !== document.scrollingElement &&\n container !== document.body) {\n warnOnce(getComputedStyle(container).position !== \"static\", \"Please ensure that the container has a non-static position, like 'relative', 'fixed', or 'absolute' to ensure scroll offset is calculated correctly.\");\n }\n }\n /**\n * Handlers without a target or offset are notified with the container's\n * shared info object, so they measure nothing themselves.\n */\n const needsOwnInfo = target || options.offset;\n return {\n measure: (containerInfo) => {\n if (!needsOwnInfo)\n return;\n info.time = containerInfo.time;\n for (const key in axisKeys) {\n const axis = key;\n const { offset } = info[axis];\n Object.assign(info[axis], containerInfo[axis]);\n info[axis].offset = offset;\n }\n if (target && target !== container) {\n const inset = calcInset(target, container);\n const size = getTargetSize(target);\n info.x.targetOffset = inset.x;\n info.y.targetOffset = inset.y;\n info.x.targetLength = size.width;\n info.y.targetLength = size.height;\n }\n resolveOffsets(info, options);\n },\n notify: (containerInfo) => onScroll(needsOwnInfo ? info : containerInfo),\n };\n}\n//# sourceMappingURL=on-scroll-handler.js.map","import { isHTMLElement } from \"motion-dom\";\nexport function calcInset(element, container) {\n const inset = { x: 0, y: 0 };\n let current = element;\n while (current && current !== container) {\n if (isHTMLElement(current)) {\n inset.x += current.offsetLeft;\n inset.y += current.offsetTop;\n current = current.offsetParent;\n }\n else if (current.tagName === \"svg\") {\n /**\n * This isn't an ideal approach to measuring the offset of tags.\n * It would be preferable, given they behave like HTMLElements in most ways\n * to use offsetLeft/Top. But these don't exist on . Likewise we\n * can't use .getBBox() like most SVG elements as these provide the offset\n * relative to the SVG itself, which for is usually 0x0.\n */\n const svgBoundingBox = current.getBoundingClientRect();\n current = current.parentElement;\n const parentBoundingBox = current.getBoundingClientRect();\n inset.x += svgBoundingBox.left - parentBoundingBox.left;\n inset.y += svgBoundingBox.top - parentBoundingBox.top;\n }\n else if (current instanceof SVGGraphicsElement) {\n const { x, y } = current.getBBox();\n inset.x += x;\n inset.y += y;\n let svg = null;\n let parent = current.parentNode;\n while (!svg) {\n if (parent.tagName === \"svg\") {\n svg = parent;\n }\n parent = current.parentNode;\n }\n current = svg;\n }\n else {\n break;\n }\n }\n return inset;\n}\n//# sourceMappingURL=inset.js.map","import { cancelFrame, frame, frameData, resize } from \"motion-dom\";\nimport { noop } from \"motion-utils\";\nimport { createScrollInfo, updateScrollInfo } from \"./info\";\nimport { createOnScrollHandler } from \"./on-scroll-handler\";\nconst scrollListeners = new WeakMap();\nconst resizeListeners = new WeakMap();\nconst onScrollHandlers = new WeakMap();\nconst dimensionCheckProcesses = new WeakMap();\nconst getEventTarget = (element) => element === document.scrollingElement ? window : element;\nexport function scrollInfo(onScroll, { container = document.scrollingElement, trackContentSize = false, ...options } = {}) {\n if (!container)\n return noop;\n let containerHandlers = onScrollHandlers.get(container);\n /**\n * Get the onScroll handlers for this container.\n * If one isn't found, create a new one.\n */\n if (!containerHandlers) {\n containerHandlers = new Set();\n onScrollHandlers.set(container, containerHandlers);\n }\n /**\n * Create a new onScroll handler for the provided callback.\n */\n const info = createScrollInfo();\n const containerHandler = createOnScrollHandler(container, onScroll, info, options);\n containerHandlers.add(containerHandler);\n /**\n * Check if there's a scroll event listener for this container.\n * If not, create one.\n */\n if (!scrollListeners.has(container)) {\n const containerInfo = createScrollInfo();\n const measureAll = () => {\n updateScrollInfo(container, containerInfo, frameData.timestamp);\n for (const handler of containerHandlers) {\n handler.measure(containerInfo);\n }\n frame.preUpdate(notifyAll);\n };\n const notifyAll = () => {\n for (const handler of containerHandlers) {\n handler.notify(containerInfo);\n }\n };\n const listener = () => frame.read(measureAll);\n scrollListeners.set(container, listener);\n const target = getEventTarget(container);\n window.addEventListener(\"resize\", listener);\n if (container !== document.documentElement) {\n resizeListeners.set(container, resize(container, listener));\n }\n target.addEventListener(\"scroll\", listener);\n listener();\n }\n /**\n * Enable content size tracking if requested and not already enabled.\n */\n if (trackContentSize && !dimensionCheckProcesses.has(container)) {\n const listener = scrollListeners.get(container);\n // Store initial scroll dimensions (object is reused to avoid allocation)\n const size = {\n width: container.scrollWidth,\n height: container.scrollHeight,\n };\n // Add frame-based scroll dimension checking to detect content changes\n const checkScrollDimensions = () => {\n const newWidth = container.scrollWidth;\n const newHeight = container.scrollHeight;\n if (size.width !== newWidth || size.height !== newHeight) {\n listener();\n size.width = newWidth;\n size.height = newHeight;\n }\n };\n // Schedule with keepAlive=true to run every frame\n const dimensionCheckProcess = frame.read(checkScrollDimensions, true);\n dimensionCheckProcesses.set(container, dimensionCheckProcess);\n }\n const listener = scrollListeners.get(container);\n frame.read(listener, false, true);\n return () => {\n cancelFrame(listener);\n /**\n * Check if we even have any handlers for this container.\n */\n const currentHandlers = onScrollHandlers.get(container);\n if (!currentHandlers)\n return;\n currentHandlers.delete(containerHandler);\n if (currentHandlers.size)\n return;\n /**\n * If no more handlers, remove the scroll listener too. The handler\n * set goes with it, as a measure still queued from this listener\n * would otherwise notify handlers added by a later scrollInfo call.\n */\n onScrollHandlers.delete(container);\n const scrollListener = scrollListeners.get(container);\n scrollListeners.delete(container);\n if (scrollListener) {\n getEventTarget(container).removeEventListener(\"scroll\", scrollListener);\n resizeListeners.get(container)?.();\n window.removeEventListener(\"resize\", scrollListener);\n }\n // Clean up scroll dimension checking\n const dimensionCheckProcess = dimensionCheckProcesses.get(container);\n if (dimensionCheckProcess) {\n cancelFrame(dimensionCheckProcess);\n dimensionCheckProcesses.delete(container);\n }\n };\n}\n//# sourceMappingURL=track.js.map","const timelineCache = new Map();\n/**\n * Native timelines are only attached to WAAPI animations. Offsets are\n * applied to each animation as a range, so a timeline is shared by every\n * offset.\n */\nexport function getTimeline({ container, target, axis, }) {\n let containerCache = timelineCache.get(container);\n if (!containerCache) {\n containerCache = new Map();\n timelineCache.set(container, containerCache);\n }\n const targetKey = target ?? \"self\";\n let targetCache = containerCache.get(targetKey);\n if (!targetCache) {\n targetCache = {};\n containerCache.set(targetKey, targetCache);\n }\n return (targetCache[axis] || (targetCache[axis] = target\n ? new ViewTimeline({ subject: target, axis })\n : new ScrollTimeline({ source: container, axis })));\n}\n//# sourceMappingURL=get-timeline.js.map","import { resolveOffset } from \"../offsets/offset\";\nimport { ScrollOffset as presets } from \"../offsets/presets\";\n/**\n * Resolved offsets are linear in the target and container lengths, so\n * probing them gives [target progress, container progress, pixels].\n * vw/vh can resolve to 0px, so they're rejected up front.\n */\nconst toIntersection = (o) => {\n if (/v/u.test(o))\n return [];\n const px = resolveOffset(o, 0, 0, 0);\n return [resolveOffset(o, 0, 1, 0) - px, px - resolveOffset(o, 1, 0, 0), px];\n};\nconst toRange = ([t, c, px]) => !px &&\n (c === 0 || c === 1) &&\n `${c ? \"entry\" : \"exit\"}-crossing ${t * 100}%`;\n/**\n * Maps an offset to an equivalent ViewTimeline range. Returns undefined when\n * there isn't one, which signals the caller to fall back to JS-based scroll\n * tracking.\n */\nexport function offsetToViewTimelineRange(offset = presets.All) {\n if (offset.length !== 2)\n return;\n const [start, end] = offset.map(toIntersection);\n const points = [toRange(start), toRange(end)];\n const a = end[0] - start[0];\n const b = start[1] - end[1];\n if (points[0] && points[1] && (a || b)) {\n return {\n points: points,\n a,\n b,\n cover: !start[0] && a === 1 && b === 1,\n };\n }\n}\n//# sourceMappingURL=offset-to-range.js.map","import { resize } from \"motion-dom\";\nimport { scrollInfo } from \"./track\";\nimport { canUseNativeTimeline } from \"./utils/can-use-native-timeline\";\nimport { getTimeline } from \"./utils/get-timeline\";\nimport { offsetToViewTimelineRange } from \"./utils/offset-to-range\";\nexport function attachToAnimation(animation, options) {\n const { target, container, axis } = options;\n const range = target && offsetToViewTimelineRange(options.offset);\n /**\n * Use native timeline when:\n * - No target and no offset: ScrollTimeline\n * - Target with mappable offset: ViewTimeline with named range\n * - Otherwise: fall back to JS observe. A ScrollTimeline has no offset,\n * so page offsets are applied by the JS timeline.\n */\n const native = canUseNativeTimeline(target) && (target ? !!range : !options.offset);\n const animations = new Map();\n const observed = new Set();\n let stopObserving;\n let reverse = false;\n /**\n * When an offset's second point comes first, its range is swapped and\n * the animation played backwards. The range is set after the direction,\n * as that's what realigns a running animation with its timeline. Chrome\n * skips that realignment when the range changes in the frame the\n * animation starts, leaving it offset for good, so it's replayed too.\n */\n const apply = (direction, waapi) => {\n const [start, end] = range.points;\n waapi.effect.updateTiming({\n direction: reverse\n ? direction === \"normal\"\n ? \"reverse\"\n : \"alternate-reverse\"\n : direction,\n });\n Object.assign(waapi, {\n rangeStart: reverse ? end : start,\n rangeEnd: reverse ? start : end,\n });\n waapi.play();\n };\n const stops = [\n animation.attachTimeline({\n /**\n * Read only by WAAPI animations, so values driven from JS don't\n * create a native timeline they won't use.\n */\n get timeline() {\n return native ? getTimeline(options) : undefined;\n },\n onAttach: range &&\n ((waapi) => {\n const direction = waapi.effect.getTiming().direction;\n animations.set(waapi, direction);\n apply(direction, waapi);\n }),\n /**\n * Values driven from JS all track the offset with scrollInfo,\n * which measures once per frame for all of them.\n */\n observe: (valueAnimation) => {\n valueAnimation.pause();\n observed.add(valueAnimation);\n stopObserving || (stopObserving = scrollInfo((info) => {\n observed.forEach((observedAnimation) => {\n observedAnimation.time =\n observedAnimation.iterationDuration *\n info[axis].progress;\n });\n }, options));\n return () => observed.delete(valueAnimation);\n },\n }),\n ];\n if (native && range) {\n const { a, b } = range;\n const length = axis === \"y\" ? \"clientHeight\" : \"clientWidth\";\n /**\n * Offsets like All only run forwards when the target is longer than\n * the container, so their direction is remeasured on resize.\n */\n const update = () => {\n if (reverse !==\n (reverse = a * target[length] + b * container[length] < 0)) {\n animations.forEach(apply);\n }\n };\n update();\n if (a * b < 0) {\n stops.push(resize(update), resize([target, container], update));\n }\n }\n return () => {\n stops.forEach((stop) => stop());\n stopObserving?.();\n };\n}\n//# sourceMappingURL=attach-animation.js.map","import { supportsScrollTimeline, supportsViewTimeline } from \"motion-dom\";\nexport function canUseNativeTimeline(target) {\n if (typeof window === \"undefined\")\n return false;\n return target ? supportsViewTimeline() : supportsScrollTimeline();\n}\n//# sourceMappingURL=can-use-native-timeline.js.map","import { noop } from \"motion-utils\";\nimport { attachToAnimation } from \"./attach-animation\";\nimport { scrollInfo } from \"./track\";\nexport function scroll(onScroll, { axis = \"y\", source, container = document.scrollingElement, ...options } = {}) {\n if (!container)\n return noop;\n const optionsWithDefaults = {\n axis,\n container: source || container,\n ...options,\n };\n return typeof onScroll === \"function\"\n ? scrollInfo((info) => onScroll(info[axis].progress, info), optionsWithDefaults)\n : attachToAnimation(onScroll, optionsWithDefaults);\n}\n//# sourceMappingURL=index.js.map"],"names":["clamp","min","max","v","MotionGlobalConfig","isObject","value","noop","any","progress","from","to","range","frameData","delta","timestamp","isProcessing","stepsOrder","createRenderBatcher","scheduleNextBatch","allowKeepAlive","state","runNextFrame","useDefaultElapsed","flagRunNextFrame","steps","reduce","acc","key","thisFrame","Set","nextFrame","flushNextFrame","toKeepAlive","latestFrameData","triggerCallback","callback","has","add","step","schedule","keepAlive","immediate","queue","cancel","delete","process","prevFrame","forEach","clear","createRenderStep","setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender","processBatch","useManualTiming","performance","now","Math","i","length","frame","cancelFrame","requestAnimationFrame","supportsFlags","memoSupports","supportsFlag","memoized","result","undefined","memo","supportsScrollTimeline","window","ScrollTimeline","supportsViewTimeline","ViewTimeline","isHTMLElement","element","resizeHandlers","WeakMap","observer","getSize","borderBoxAxis","svgAxis","htmlAxis","target","borderBoxSize","getBBox","getWidth","getHeight","notifyTarget","get","handler","width","height","notifyAll","entries","resizeElement","ResizeObserver","elements","elementOrSelector","EventTarget","document","querySelectorAll","Array","filter","resolveElements","elementHandlers","set","observe","size","unobserve","windowCallbacks","windowResizeHandler","resizeWindow","info","innerWidth","innerHeight","addEventListener","removeEventListener","resize","a","b","axisKeys","x","position","y","styles","updateAxisInfo","axisName","time","axis","prev","current","prevTime","scrollPosition","isRoot","scrollingElement","source","body","style","getComputedStyle","writingMode","flexDirection","isInline","test","direction","endsWith","display","includes","flexWrap","isReversed","containerLength","targetLength","scrollLength","offset","elapsed","velocity","frameDuration","namedEdges","start","center","end","resolveEdge","edge","inset","asNumber","parseFloat","documentElement","clientWidth","clientHeight","defaultOffset","resolveOffset","targetInset","offsetDefinition","isArray","targetPoint","containerPoint","trim","split","ScrollOffset","All","resolveOffsets","options","axisInfo","numOffsets","targetOffset","offsets","n","reverse","at","p","offsetsToProgress","createOnScrollHandler","container","onScroll","needsOwnInfo","measure","containerInfo","Object","assign","offsetLeft","offsetTop","offsetParent","tagName","svgBoundingBox","getBoundingClientRect","parentElement","parentBoundingBox","left","top","SVGGraphicsElement","svg","parent","parentNode","calcInset","getTargetSize","notify","scrollListeners","resizeListeners","onScrollHandlers","dimensionCheckProcesses","getEventTarget","scrollInfo","trackContentSize","containerHandlers","containerHandler","measureAll","updateScrollInfo","listener","scrollWidth","scrollHeight","checkScrollDimensions","newWidth","newHeight","dimensionCheckProcess","currentHandlers","scrollListener","timelineCache","Map","toIntersection","o","px","toRange","t","c","attachToAnimation","animation","presets","map","points","cover","offsetToViewTimelineRange","native","canUseNativeTimeline","animations","observed","stopObserving","apply","waapi","effect","updateTiming","rangeStart","rangeEnd","play","stops","attachTimeline","timeline","containerCache","targetKey","targetCache","subject","getTimeline","onAttach","getTiming","valueAnimation","pause","observedAnimation","iterationDuration","push","stop","scroll","optionsWithDefaults"],"mappings":"AAAA,MAAMA,EAAQ,CAACC,EAAKC,EAAKC,IACjBA,EAAID,EACGA,EACPC,EAAIF,EACGA,EACJE,ECLLC,EAAqB,CAAA,ECArBC,EAAYC,GAA2B,iBAAVA,GAAgC,OAAVA,ECCzD,MAAMC,EAAQC,GAAQA,ECOhBC,EAAW,CAACC,EAAMC,EAAIL,KACxB,MAAMM,EAAQD,EAAKD,EACnB,OAAOE,GAASN,EAAQI,GAAQE,EAAQ,GCNtCC,EAAY,CACdC,MAAO,EACPC,UAAW,EACXC,cAAc,GCPZC,EAAa,CACf,QACA,OACA,mBACA,YACA,SACA,YACA,SACA,cCHJ,SAASC,EAAoBC,EAAmBC,EAAgBC,EAAQ,CACpEP,MAAO,EACPC,UAAW,EACXC,cAAc,IAEd,IAAIM,GAAe,EACfC,GAAoB,EACxB,MAAMC,EAAmB,IAAOF,GAAe,EACzCG,EAAQR,EAAWS,OAAO,CAACC,EAAKC,KAClCD,EAAIC,GCdZ,SAA0BN,GAKtB,IAAIO,EAAY,IAAIC,IAChBC,EAAY,IAAID,IAKhBd,GAAe,EACfgB,GAAiB,EAOrB,MAAMC,EAAc,IAAIH,IACxB,IAAII,EAAkB,CAClBpB,MAAO,EACPC,UAAW,EACXC,cAAc,GAElB,SAASmB,EAAgBC,GACjBH,EAAYI,IAAID,KAChBL,EAAUO,IAAIF,GACdd,KAEJc,EAASF,EACb,CACA,MAAMK,EAAO,CAITC,SAAU,CAACJ,EAAUK,GAAY,EAAOC,GAA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