// Pure carousel logic (no DOM) — imported by both the element and its test. /** * Wrap `next` into `[0, len)`. Negative values wrap from the end (advancing * "previous" past the first frame lands on the last), matching the original * `(next + len) % len` but correct for any negative magnitude. */ export function wrapIndex(next: number, len: number): number { return ((next % len) + len) % len; }