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

/* eslint-disable no-inner-declarations */
/* eslint-disable no-constant-condition */

/**
 * @fileOverview The Unified Shell's bootstrap code for development sandbox scenarios.
 *
 * This module provides a boot task that integrates the sandbox configuration provider
 * into the UI5 configuration system. It is used for UI5 1.x compatibility where the
 * boot task mechanism is required to inject configuration before the framework fully
 * initializes.
 *
 * For UI5 2.x, the preferred approach is to use the manifest-based configuration via
 * `sandboxManifest.json`.
 *
 * Usage:
 * Include this script before the UI5 bootstrap script to register the sandbox
 * configuration provider via the `xx-bootTask` mechanism.
 *
 * @example
 * <script src="sap/ushell/sandbox/sandboxBootTask.js"></script>
 * <script src="resources/sap-ui-core.js" ...></script>
 *
 * @namespace sap.ushell.sandbox.SandboxBootTask
 * @alias module:sap/ushell/sandbox/SandboxBootTask
 * @version 1.147.1
 * @since 1.136
 * @public
 * @deprecated since 1.136 - Use sandboxManifest.json with manifest-based boot configuration instead
 */

(function () {
    "use strict";

    /**
     * Registers the sandbox configuration provider via the UI5 boot task mechanism.
     *
     * The boot task waits for the sandbox configuration to be loaded from
     * `fioriSandboxAppConfig.json`, then registers the SandboxConfigurationProvider
     * with the UI5 base configuration system before continuing the bootstrap.
     */
    globalThis["sap-ui-config"] = {
        "xx-bootTask": function (fnCallback) {
            sap.ui.require([
                "sap/base/config",
                "sap/ushell/sandbox/ConfigurationProvider"
            ], (
                BaseConfig,
                SandboxConfigurationProvider
            ) => {
                SandboxConfigurationProvider.loaded().then(() => {
                    BaseConfig.registerProvider(SandboxConfigurationProvider);
                    fnCallback();
                });
            });
        }
    };

    return;
}());
