```ts
/**
 * Splits a string into tokens separated by runs of spaces and tabs.
 * Handles quoted sections, escape sequences, and edge cases.
 * @param input The string to tokenize.
 * @returns An array of tokens.
 */
export function tokenize(input: string): string[] {
  if (input === "") {
    return [];
  }

  const tokens: string[] = [];
  let currentToken = "";
  let inQuotes = false;
  let i = 0;

  while (i < input.length) {
    const char = input[i];

    if (char === "\\") {
      // Escape sequence
      if (i + 1 >= input.length) {
        throw new Error("trailing backslash");
      }
      currentToken += input[i + 1];
      i += 2;
      continue;
    }

    if (char === '"') {
      inQuotes = !inQuotes;
      i++;
      continue;
    }

    if (inQuotes) {
      currentToken += char;
      i++;
      continue;
    }

    // Not in quotes
    if (char === " " || char === "\t") {
      if (currentToken !== "") {
        tokens.push(currentToken);
        currentToken = "";
      }
      // Skip all consecutive spaces and tabs
      while (i < input.length && (input[i] === " " || input[i] === "\t")) {
        i++;
      }
      continue;
    }

    currentToken += char;
    i++;
  }

  if (inQuotes) {
    throw new Error("unterminated quote");
  }

  if (currentToken !== "") {
    tokens.push(currentToken);
  }

  return tokens;
}
```