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

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

    /**
     * Default Search component for the Fiori Launchpad.
     *
     * @since 1.142.0
     * @private
     */
    class Search extends SearchProvider {
        /**
         * @type {Promise<sap.ui.core.Component>} A promise that resolves to the component instance.
         */
        #pComponent;
        /**
         * Loads the search component and initializes the search functionality.
         *
         * @param {sap.ushell.modules.Search.SearchAPI} oSearchAPI The search API object.
         *
         * @since 1.142.0
         * @private
         */
        constructor (oSearchAPI) {
            super(oSearchAPI);
            this.init(oSearchAPI);
        }

        async init (oSearchAPI) {
            this.#pComponent = Component.create({
                name: "sap.ushell.components.shell.Search",
                componentData: {
                    searchAPI: oSearchAPI
                }
            });
        }

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