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

sap.ui.define([
    "sap/ui/core/Component",
    "sap/ushell/modules/ProductSwitch/ProductSwitchProvider"
], (
    Component,
    ProductSwitchProvider
) => {
    "use strict";

    /**
     * Default ProductSwitch component for the Fiori Launchpad.
     *
     * @since 1.144.0
     * @private
     */
    class ProductSwitch extends ProductSwitchProvider {
        /**
         * @type {Promise<sap.ui.core.Component>} A promise that resolves to the component instance.
         */
        #pComponent;
        /**
         * Loads the product switch component and initializes the product switch functionality.
         *
         * @param {sap.ushell.modules.ProductSwitch.ProductSwitchAPI} oProductSwitchAPI The product switch API object.
         *
         * @since 1.144.0
         * @private
         */
        constructor (oProductSwitchAPI) {
            super(oProductSwitchAPI);
            this.init(oProductSwitchAPI);
        }

        async init (oProductSwitchAPI) {
            this.#pComponent = Component.create({
                name: "sap.ushell.components.shell.ProductSwitch",
                manifest: false,
                componentData: {
                    productSwitchAPI: oProductSwitchAPI
                }
            });
        }

        /**
         * Cleans up the component instance.
         *
         * @returns {Promise} A promise that resolves when the component is destroyed.
         * @since 1.144.0
         * @private
         * @override
         */
        async exit () {
            (await this.#pComponent).exit();
        }
    }
    return ProductSwitch;
});
