 ```ts
/**
 * Parses a single line of CSV into its fields on commas, handling quoted fields with embedded quotes and surrounding spaces.
 * Throws error for unclosed quoted fields.
 *
 * @param {string} line - The line of CSV to parse.
 * @returns {string[]} An array containing the parsed fields.
 */
export function parseCsvLine(line: string): string[] {
    const result: string[] = [];
    let field = '';
    let inQuote = false;

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

        if (char === '"') {
            if (i > 0 && line[i - 1] === '"') {
                field += char;
            } else {
                inQuote = !inQuote;
            }
        } else if (char === ',' && !inQuote) {
            result.push(field.trim());
            field = '';
        } else {
            field += char;
        }

        if (inQuote && i === line.length - 1) {
            throw new Error('Unclosed quoted field');
        }
    }

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