// Pure logic for a region showing one child at a time (no DOM), imported by // `showing.ts`, the carousel island and its own test. // // It was `islands/carousel.logic.ts` until the library tab strip needed the same // arithmetic (`6b24f2df`). Moved rather than imported across, because core // reaching up into islands is the layering backwards. /** * Wrap `next` into `[0, len)`. Negative values wrap from the end (advancing * "previous" past the first child 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; }