```ts
/** Firmware build selection within an installed release line. */

export function compareBuilds(a: string, b: string): number {
  const left = a.split(".").map(Number);
  const right = b.split(".").map(Number);
  const width = Math.max(left.length, right.length);
  for (let i = 0; i < width; i += 1) {
    const x = i < left.length ? left[i] : 0;
    const y = i < right.length ? right[i] : 0;
    if (x > y) {
      return 1;
    }
    if (x < y) {
      return -1;
    }
  }
  return 0;
}

export function pickUpgrade(installed: string, offers: string[]): string | null {
  if (typeof installed !== 'string' || !/^\d+(\.\d+)*$/.test(installed)) {
    throw new Error('Invalid installed build format');
  }

  if (!Array.isArray(offers) || offers.some(o => typeof o !== 'string' || !/^\d+(\.\d+)*$/.test(o))) {
    throw new Error('Invalid offers list or offer format');
  }

  let best: string | null = null;
  for (const offer of offers) {
    if (offer.split(".")[0] !== installed.split(".")[0]) {
      continue;
    }
    if (compareBuilds(offer, installed) > 0 && (best === null || compareBuilds(offer, best) > 0)) {
      best = offer;
    }
  }
  return best;
}
```