"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ora_1 = __importDefault(require("ora"));
const chalk_1 = __importDefault(require("chalk"));
const spinner = ora_1.default();
let lastMsg = null;
const logWithSpinner = (symbol, msg) => {
    if (!msg) {
        msg = symbol;
        symbol = chalk_1.default.green('✔');
    }
    if (lastMsg) {
        spinner.stopAndPersist({
            symbol: lastMsg.symbol,
            text: lastMsg.text,
        });
    }
    spinner.text = ` ${msg}`;
    lastMsg = {
        symbol: `${symbol} `,
        text: msg,
    };
    spinner.start();
};
exports.logWithSpinner = logWithSpinner;
const stopSpinner = (persist) => {
    if (lastMsg && persist !== false) {
        spinner.stopAndPersist({
            symbol: lastMsg.symbol,
            text: lastMsg.text,
        });
    }
    else {
        spinner.stop();
    }
    lastMsg = null;
};
exports.stopSpinner = stopSpinner;
const pauseSpinner = () => {
    spinner.stop();
};
exports.pauseSpinner = pauseSpinner;
const resumeSpinner = () => {
    spinner.start();
};
exports.resumeSpinner = resumeSpinner;
//# sourceMappingURL=spinner.js.map