```ts
/**
 * Splits one line of CSV into its fields on commas. Handles quoted fields that may contain commas and doubled quotes.
 * @param line - The CSV line to split.
 * @returns An array of field strings, with unquoted fields trimmed of surrounding spaces.
 */
export function parseCsvLine(line: string): string[] {
    if (line.trim() === '') return [''];

    const result: string[] = [];
    let currentField = '';
    let inQuotes = false;

    for (let i = 0; i < line.length; i++) {
        const char = line[i];

        if (char === '"') {
            if (inQuotes && i + 1 < line.length && line[i + 1] === '"') {
                currentField += char;
                i++; // Skip the next double quote
            } else {
                inQuotes = !inQuotes;
            }
        } else if (char === ',' && !inQuotes) {
            result.push(currentField.trim());
            currentField = '';
        } else {
            currentField += char;
        }

        if (i === line.length - 1 && inQuotes) {
            throw new Error('Quoted field never closed');
        }
    }

    result.push(currentField.trim());
    return result;
}
```