```ts
/**
 * Splits a line of CSV into its fields on commas.
 * Handles quoted fields with embedded commas and doubled quotes.
 * Throws an Error for unclosed quoted fields.
 * @param line - The CSV line to parse.
 * @returns An array of field strings.
 */
export function parseCsvLine(line: string): string[] {
    const result: string[] = [];
    let currentField = '';
    let inQuotes = false;

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

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

    if (inQuotes) {
        throw new Error('Unclosed quoted field');
    }

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