// Copyright (c) 2009-2026 SAP SE, All Rights Reserved
/**
 * @fileOverview NWBCInterface for NWBC client
 *
 * @version 1.148.1
 */
sap.ui.define([
    "sap/ushell/appIntegration/KeepAliveApps",
    "sap/ushell/EventHub",
    "sap/ushell/Config"
], (
    KeepAliveApps,
    EventHub,
    Config
) => {
    "use strict";

    /**
     * The SessionInterface provides interfaces for the SAP Business Client to access FLP functionality
     */
    const SessionInterface = {};

    /**
     * Notifies FLP that the user is active in the SAP Business Client application so FLP
     * should client session
     *
     * @private
     * @since 1.76.0
     */
    SessionInterface.notifyUserActivity = function () {
        EventHub.emit("nwbcUserIsActive", Date.now());
    };

    /**
     * Provides FLP session timeout value
     *
     * @returns {int} session time out in minutes
     *
     * @private
     * @since 1.80.0
     */
    SessionInterface.getSessionTimeoutMinutes = function () {
        let sessionTimeoutMinutes = 0;
        if (Config.last("/core/shell/sessionTimeoutIntervalInMinutes") > 0) {
            sessionTimeoutMinutes = Config.last("/core/shell/sessionTimeoutIntervalInMinutes");
        }
        return sessionTimeoutMinutes;
    };

    /**
     * Provides indication if there is currently a kept alive app in FLP
     *
     * @returns {Promise} boolean value of true or false is such app exists
     *
     * @private
     * @since 1.103.0
     */
    SessionInterface.isAnyAppKeptAlive = async function () {
        return KeepAliveApps.length() > 0;
    };

    return SessionInterface;
});
