import { info } from './LogManager.js';
import { Spinner } from './Spinner.js';
export async function withProgress(startMessage, completionMessage, operation) {
    const isTTY = process.stdout.isTTY === true;
    if (!isTTY) {
        info(startMessage);
        const result = await operation();
        const message = typeof completionMessage === 'function'
            ? completionMessage(result)
            : completionMessage;
        info(message);
        return result;
    }
    const spinner = new Spinner(startMessage);
    spinner.start();
    try {
        const result = await operation();
        const message = typeof completionMessage === 'function'
            ? completionMessage(result)
            : completionMessage;
        spinner.stop();
        info(message);
        return result;
    }
    catch (err) {
        spinner.stop();
        throw err;
    }
}
//# sourceMappingURL=Progress.js.map