// Copyright (c) 2009-2026 SAP SE, All Rights Reserved

/**
 * @file Stage helper class for StagedLogger.
 * @version 1.148.1
 */
sap.ui.define([], () => {
    "use strict";

    /**
     * @alias sap.ushell.utils.StagedLogger.Stage
     * @class
     * @classdesc Provides log methods for a specific stage within a StagedLogger.
     *
     * @hideconstructor
     * @since 1.145.0
     * @private
     */
    class Stage {
        #fnLog;
        #fnEnd;

        /**
         * @param {function} fnLog Bound log function from the parent StagedLogger
         * @param {function} fnEnd Bound end function from the parent StagedLogger
         *
         * @since 1.145.0
         * @private
         */
        constructor (fnLog, fnEnd) {
            this.#fnLog = fnLog;
            this.#fnEnd = fnEnd;
        }

        /**
         * Logs a single message for this stage.
         *
         * @param {string} sMessage A single line message to log
         * @param {string} [sPrefix] Optional prefix for the line
         *
         * @since 1.145.0
         * @private
         */
        log (sMessage, sPrefix) {
            this.#fnLog(sMessage, undefined, sPrefix, false);
        }

        /**
         * Logs a message with detail lines for this stage.
         *
         * @param {string} sMessage A single line message to log (can be empty string for no heading)
         * @param {string[]|function():string[]} vDetails Multiple detail lines to log or a callback function that returns them
         * @param {string} [sPrefix] Optional prefix for the lines
         * @param {boolean} [bNumberLines] If true, numbers the lines (1-, 2-, etc.)
         *
         * @since 1.145.0
         * @private
         */
        logLines (sMessage, vDetails, sPrefix, bNumberLines) {
            this.#fnLog(sMessage, vDetails, sPrefix, bNumberLines);
        }

        /**
         * Ends the logging session of the parent StagedLogger instance.
         *
         * @since 1.145.0
         * @private
         */
        end () {
            this.#fnEnd();
        }
    }

    return Stage;
});
