```typescript
/** Tape-measure spans: parse to inches, format canonically, and add. */

const INCHES: Record<string, number> = { yd: 36, ft: 12, in: 1 };
const ORDER = ["yd", "ft", "in"];

export function parseSpan(text: string): number {
  if (typeof text !== 'string' || !text.trim()) {
    throw new Error("Invalid span text");
  }

  const parts = text.split(/\s+/).map(part => part.toLowerCase());
  const unitSet = new Set(parts.filter(part => ORDER.includes(part)));
  const valueParts = parts.filter(part => !unitSet.has(part));

  if (valueParts.length !== 1) {
    throw new Error("Span must contain exactly one value part");
  }

  const value = Number(valueParts[0]);
  if (!Number.isInteger(value) || value < 0) {
    throw new Error("Value must be a non-negative integer");
  }

  return value * INCHES[valueParts[1]];
}

export function formatSpan(inches: number): string {
  if (typeof inches !== 'number' || !Number.isInteger(inches) || inches < 0) {
    throw new Error("Invalid inches value");
  }
  const parts: string[] = [];
  const yards = Math.floor(inches / 36);
  const feet = Math.floor((inches % 36) / 12);
  const rest = inches % 12;
  if (yards > 0) {
    parts.push(`${yards}yd`);
  }
  if (feet > 0) {
    parts.push(`${feet}ft`);
  }
  if (rest > 0) {
    parts.push(`${rest}in`);
  }
  return parts.join(" ");
}

export function addSpans(first: string, second: string): string {
  const total = parseSpan(first) + parseSpan(second);
  return formatSpan(total);
}
```