```ts
/**
 * The free stretches of a working window, given its busy intervals.
 */
export function freeWindows(
  windowStart: number,
  windowEnd: number,
  busy: number[][],
): number[][] {
  if (windowStart >= windowEnd) {
    throw new Error('Window start must precede window end');
  }

  for (const [start, end] of busy) {
    if (start >= end || !Number.isInteger(start) || !Number.isInteger(end)) {
      throw new Error('Invalid busy interval');
    }
  }

  const gaps: number[][] = [];
  let cursor = windowStart;

  for (const [start, end] of busy) {
    start = Math.max(cursor, start);
    end = Math.min(windowEnd, end);

    if (start < end) {
      gaps.push([cursor, start]);
      cursor = end;
    }
  }

  if (cursor < windowEnd) {
    gaps.push([cursor, windowEnd]);
  }

  return gaps;
}
```