```ts
/**
 * Returns the run-length encoded representation of the input string.
 *
 * @param input The input string to encode.
 * @returns The encoded string.
 */
export function runLengthEncode(input: string): string {
    if (typeof input !== 'string') {
        throw new Error('Input must be a non-empty string.');
    }

    const charMap: Map<number, string> = new Map();

    let prevChar = '';
    let count = 0;

    for (const char of input) {
        if (char === prevChar) {
            count += 1;
        } else {
            if (prevChar) {
                charMap.set(count, prevChar);
            }
            prevChar = char;
            count = 1;
        }
    }

    if (prevChar) {
        charMap.set(count, prevChar);
    }

    let result = '';

    for (const [count, char] of charMap) {
        if (char.length > 2 || count >= 10) {
            throw new Error(`Run length greater than nine: ${char}${count}`);
        }
        result += char + count.toString();
    }

    return result;
}
```