import { applySlidesText, applySummaryText, clearSlidesText, createUrlProgressStatusState, } from "./progress-status-state.js";
export function createUrlProgressStatus({ enabled, spinner, oscProgress, now = () => Date.now(), }) {
    const state = createUrlProgressStatusState();
    const render = (text) => {
        if (!enabled || !text)
            return;
        spinner.setText(text);
    };
    const refresh = () => {
        if (!enabled)
            return;
        spinner.refresh?.();
    };
    return {
        setSummary(text, oscLabel) {
            render(applySummaryText(state, text).renderText);
            if (oscLabel) {
                oscProgress.setIndeterminate(oscLabel);
                refresh();
            }
        },
        setSlides(text, percent) {
            render(applySlidesText(state, text, now()).renderText);
            if (typeof percent === "number" && Number.isFinite(percent)) {
                oscProgress.setPercent("Slides", Math.max(0, Math.min(100, percent)));
            }
            else {
                oscProgress.setIndeterminate("Slides");
            }
            refresh();
        },
        clearSlides() {
            const next = clearSlidesText(state);
            if (next.summaryText) {
                render(next.renderText);
                oscProgress.setIndeterminate("Summarizing");
                refresh();
            }
        },
        isSlidesActive() {
            return state.slidesActive;
        },
        getSummaryText() {
            return state.summaryText;
        },
        getSlidesText() {
            return state.slidesText;
        },
    };
}
//# sourceMappingURL=progress-status.js.map