```ts
export function scanPairs(input: string): string[][] {
  if (typeof input !== 'string' || input === '') {
    throw new Error('Invalid input');
  }

  const pairs: string[][] = [];
  let keySet = new Set<string>();

  for (const segment of input.split(/(?<!\\);/)) {
    try {
      const [key, value] = parseOption(segment);
      if (keySet.has(key)) {
        throw new Error('Repeated key');
      }
      pairs.push([key, value]);
      keySet.add(key);
    } catch (error) {
      throw new Error(`Invalid segment: ${segment}`);
    }
  }

  return pairs;
}

export function parseOption(segment: string): string[] {
  const match = segment.match(/^([^=]+)=(.*)$/);
  if (!match || !/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(match[1])) {
    throw new Error('Invalid key');
  }

  let value = match[2];
  if (value.startsWith('"') && value.endsWith('"')) {
    value = value.slice(1, -1).replace(/\\"/g, '"');
  } else if (value.startsWith('"')) {
    throw new Error('Unterminated quote');
  }

  return [match[1], value];
}
```