/*
 * Copyright 2022-2025 VMware, Inc. All rights reserved. VMware Confidential
 */

import { THEME_MODE } from "../../../../lib-interfaces";
import { ExtensionNavRegistration } from "../../models/extension";
import { HyperPluginEntityActionExtensionMenuEntryCollection } from "../entity-action/entity-action-extension.component";
import { ExtensionComponentRegistration } from "../extension-component.registry";
import { EntityActionComponentContainer } from "../extension-components.directive";
import { INTERENAL_EXTENSION_POINT_TYPE } from "../extension-point-orchestrator/extension-point-events";

export const CORE_UI_CUSTOM_EVENTS = {
    INJECT_PLUGIN: "onInjectPlugin",
    PLUGIN_INJECTED: "onPluginInjected",
    COMPONENT_CREATED: "onComponentCreated",
    PLUGINS_MENUES: "onPluginMenues",
    WIZARD_MODAL_FORM_VALIDITY: "onWizardModalFormValid",
    VM_VAPP_ACTION_COMPONENT_CHANGE: "onComponentsChange",
    FORCE_CORE_UI_ROUTER_NAVIGATION: "onForceCoreUIRouterNavigation",
    TRIGGER_DETECT_CHANGES: "triggerDetectChanges",
    GET_EXTENSION_ACTION_ITEMS: "getExtensionActionItems",
    GET_EXTENSION_ACTION_ITEMS_RETURN: "getExtensionActionItemsReturn",
    ON_PLUGIN_DESTROYED: "onPluginDestroyed",
    ON_PLUGIN_CAN_DEACTIVATE: "onPluginCanDeactivate",
    ON_HYPER_PLUGIN_THEME_CHANGE: "onHyperPluginThemeChange",
    ON_JWT_CHANGE: "onJwtTokenChange",
};

export interface InjectPluginEventDetails {
    hostingSelector: string;
    route?: string;
    extensions?: ExtensionComponentRegistration[];
    /**
     * Identifies specifc extension container by its unique id,
     * Hyper Plugin search for this exact extension container by its id and
     * renders only the Extension Points explicityl specifed by the
     * extension container.
     */
    id?: string;
    internalExtensionPointType: INTERENAL_EXTENSION_POINT_TYPE;
    scope: string;
    theme: THEME_MODE;
    fullHeight?: boolean;
}

export interface PluginInjectEventDetails {
    componentSelector: string;
    hyperPluginUrn: string;
}

export interface ComponentCreatedEventDetails {
    data: any;
}

export interface PluginsMenuesEventDetails {
    pluginMenus: ExtensionNavRegistration[];
}

export interface WizardModalValidityEventDetails {
    allExtensionsAreValid: boolean;
}

export interface VMvAppActionComponentChangeEventDetails {
    components: EntityActionComponentContainer[];
    scope: string;
}

export interface ForceCoreUIRouterNavigationEventDetails {
    url: string;
}

export interface GetExtensionItemsEventDetails {
    entityUrn: string;
    entityActionExtensionContainers: EntityActionComponentContainer[];
}

export interface GetExtensionItemsReturnEventDetails {
    entityActionExtensionMenuEntries: HyperPluginEntityActionExtensionMenuEntryCollection[];
    scope: string;
}

export interface PluginDestroyedEventDetails {
    pluginRoute: string;
    hostingSelector: string;
    /**
     * Identifies specifc extension container by its unique id,
     * Hyper Plugin search for this exact extension container by its id and
     * destroys it.
     */
    id?: string;
    scope: string;
    navigateAwayTo: string;
}

export interface HasId {
    id?: string;
}

export interface PluginCanDeactivateEventDetails {
    canDeactivate: boolean;
}

export interface ThemeChange {
    theme: THEME_MODE;
}