"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSpinner = createSpinner;
/**
 * Simple spinner UI utility
 */
function createSpinner(text) {
    return new Spinner(text);
}
class Spinner {
    constructor(text) {
        this.interval = null;
        this.spinning = false;
        this.frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
        this.frameIndex = 0;
        this.text = text;
    }
    start() {
        if (this.spinning)
            return this;
        this.spinning = true;
        this.frameIndex = 0;
        this.interval = setInterval(() => {
            process.stdout.write(`\r${this.frames[this.frameIndex]} ${this.text}`);
            this.frameIndex = (this.frameIndex + 1) % this.frames.length;
        }, 80);
        return this;
    }
    stop() {
        if (!this.spinning)
            return this;
        this.spinning = false;
        if (this.interval) {
            clearInterval(this.interval);
            this.interval = null;
        }
        process.stdout.write("\r"); // Clear the line
        return this;
    }
    succeed(text) {
        this.stop();
        console.log(`\r✅ ${text}`);
        return this;
    }
    fail(text) {
        this.stop();
        console.log(`\r❌ ${text}`);
        return this;
    }
    updateText(newText) {
        this.text = newText;
        return this;
    }
}
//# sourceMappingURL=ui.js.map