import { Observable } from 'rxjs' ; import { History } from 'history' ; import { RecursiveReadonly } from '@kbn/utility-types' ; import { MountPoint } from '../types' ; import { CoreTheme } from '../theme' ; import { Capabilities } from './capabilities' ; import { PluginOpaqueId } from '../plugins' ; import { AppCategory } from '../../types' ; import { ScopedHistory } from './scoped_history' ; public export enum AppStatus { /**
     * Application is accessible.
     */ accessible = 0 , /**
     * Application is not accessible.
     */ inaccessible = 1 } public export enum AppNavLinkStatus { /**
     * The application navLink will be `visible` if the application's  AppStatus is set to `accessible`
     * and `hidden` if the application status is set to `inaccessible`.
      default = 0 , /**
     * The application navLink is visible and clickable in the navigation bar.
     */ visible = 1 , /**
     * The application navLink is visible but inactive and not clickable in the navigation bar.
     */ disabled = 2 , /**
     * The application navLink does not appear in the navigation bar.
     */ hidden = 3 } /**
 * Defines the list of fields that can be updated via an  AppUpdater .
 *  public export type AppUpdatableFields = Pick < App , 'status' | 'navLinkStatus' | 'searchable' | 'tooltip' | 'defaultPath' | 'deepLinks' > ; public export interface AppNavOptions { /**
     * An ordinal used to sort nav links relative to one another for display.
     */ order ? : number ; /**
     * A tooltip shown when hovering over app link.
     */ tooltip ? : string ; /**
     * A EUI iconType that will be used for the app's icon. This icon
     * takes precedence over the `icon` property.
     */ euiIconType ? : string ; /**
     * A URL to an image file used as an icon. Used as a fallback
     * if `euiIconType` is not provided.
     */ icon ? : string ; } /**
 * Updater for applications.
 * see  ApplicationSetup public export type AppUpdater = ( app : App ) => Partial < AppUpdatableFields > | undefined ; public export interface App < HistoryLocationState = unknown > extends AppNavOptions { /**
     * The unique identifier of the application
     */ id : string ; /**
     * The title of the application.
     */ title : string ; /**
     * The category definition of the product
     * See  AppCategory * See DEFAULT_APP_CATEGORIES for more reference
      category ? : AppCategory ; /**
     * The initial status of the application.
     * Defaulting to `accessible`
     */ status ? : AppStatus ; /**
     * The initial status of the application's navLink.
     * Defaulting to `visible` if `status` is `accessible` and `hidden` if status is `inaccessible`
     * See  AppNavLinkStatus navLinkStatus ? : AppNavLinkStatus ; /**
     * The initial flag to determine if the application is searchable in the global search.
     * Defaulting to `true` if `navLinkStatus` is `visible` or omitted.
     */ searchable ? : boolean ; /**
     * Allow to define the default path a user should be directed to when navigating to the app.
     * When defined, this value will be used as a default for the `path` option when calling  ApplicationStart . navigateToApp `,
     * and will also be appended to the  ChromeNavLink in the navigation bar.
      defaultPath ? : string ; /**
     * An  AppUpdater observable that can be used to update the application  AppUpdatableFields at runtime.
     *
     *  example updater$ ? : Observable < AppUpdater > ; /**
     * Custom capabilities defined by the app.
     */ capabilities ? : Partial < Capabilities > ; /**
     * Hide the UI chrome when the application is mounted. Defaults to `false`.
     * Takes precedence over chrome service visibility settings.
     */ chromeless ? : boolean ; /**
     * A mount function called when the user navigates to this app's route.
     */ mount : AppMount < HistoryLocationState > ; /**
     * Override the application's routing path from `/app/${id}`.
     * Must be unique across registered applications. Should not include the
     * base path from HTTP.
     */ appRoute ? : string ; example exactRoute ? : boolean ; /** Optional keywords to match with in deep links search. Omit if this part of the hierarchy does not have a page URL. */ keywords ? : string [ ] ; example deepLinks ? : AppDeepLink [ ] ; } /**
 * Public information about a registered app's  AppDeepLink public export type PublicAppDeepLinkInfo = Omit < AppDeepLink , 'deepLinks' | 'keywords' | 'navLinkStatus' | 'searchable' > & { deepLinks : PublicAppDeepLinkInfo [ ] ; keywords : string [ ] ; navLinkStatus : AppNavLinkStatus ; searchable : boolean ; } ; public export type AppDeepLink = { /** Identifier to represent this sublink, should be unique for this application */ id : string ; /** Title to label represent this deep link */ title : string ; /** Optional keywords to match with in deep links search. Omit if this part of the hierarchy does not have a page URL. */ keywords ? : string [ ] ; /** Optional status of the chrome navigation, defaults to `hidden` */ navLinkStatus ? : AppNavLinkStatus ; /** Optional flag to determine if the link is searchable in the global search. Defaulting to `true` if `navLinkStatus` is `visible` or omitted */ searchable ? : boolean ; } & AppNavOptions & ( { /** URL path to access this link, relative to the application's appRoute. */ path : string ; /** Optional array of links that are 'underneath' this section in the hierarchy */ deepLinks ? : AppDeepLink [ ] ; } | { /** Optional path to access this section. Omit if this part of the hierarchy does not have a page URL. */ path ? : string ; /** Array links that are 'underneath' this section in this hierarchy. */ deepLinks : AppDeepLink [ ] ; } ) ; /**
 * Public information about a registered  App public export type PublicAppInfo = Omit < App , 'mount' | 'updater$' | 'keywords' | 'deepLinks' | 'searchable' > & { status : AppStatus ; navLinkStatus : AppNavLinkStatus ; appRoute : string ; keywords : string [ ] ; deepLinks : PublicAppDeepLinkInfo [ ] ; searchable : boolean ; } ; param params AppMountParameters returns An unmounting function that will be called to unmount the application. See  AppUnmount .
 *
 *  public export type AppMount < HistoryLocationState = unknown > = ( params : AppMountParameters < HistoryLocationState > ) => AppUnmount | Promise < AppUnmount > ; public export type AppUnmount = ( ) => void ; public export interface AppMountParameters < HistoryLocationState = unknown > { /**
     * The container element to render the application into.
     */ element : HTMLElement ; example history : ScopedHistory < HistoryLocationState > ; deprecated Use  AppMountParameters . history instead.
     *
     *  example appBasePath : string ; example deprecated ScopedHistory . block should be used instead.
      onAppLeave : ( handler : AppLeaveHandler ) => void ; example setHeaderActionMenu : ( menuMount : MountPoint | undefined ) => void ; /**
     * An observable emitting  CoreTheme .
     * Should be used when mounting the application to include theme information.
     *
     *  example theme$ : Observable < CoreTheme > ; } /**
 * A handler that will be executed before leaving the application, either when
 * going to another application or when closing the browser tab or manually changing
 * the url.
 * Should return `confirm` to prompt a message to the user before leaving the page, or `default`
 * to keep the default behavior (doing nothing).
 *
 * See  AppMountParameters for detailed usage examples.
 *
 *  public deprecated AppMountParameters . onAppLeave has been deprecated in favor of  ScopedHistory . block export type AppLeaveHandler = ( factory : AppLeaveActionFactory , nextAppId ? : string ) => AppLeaveAction ; public export enum AppLeaveActionType { confirm = 'confirm' , default = 'default' } /**
 * Action to return from a  AppLeaveHandler to execute the default
 * behaviour when leaving the application.
 *
 * See  AppLeaveActionFactory public export interface AppLeaveDefaultAction { type : AppLeaveActionType . default ; } /**
 * Action to return from a  AppLeaveHandler to show a confirmation
 * message when trying to leave an application.
 *
 * See  AppLeaveActionFactory public export interface AppLeaveConfirmAction { type : AppLeaveActionType . confirm ; text : string ; title ? : string ; callback ? : ( ) => void ; } /**
 * Possible actions to return from a  AppLeaveHandler *
 * See  AppLeaveConfirmAction and  AppLeaveDefaultAction public export type AppLeaveAction = AppLeaveDefaultAction | AppLeaveConfirmAction ; /**
 * Factory provided when invoking a  AppLeaveHandler to retrieve the  AppLeaveAction to execute.
  export interface AppLeaveActionFactory { param text param title param callback confirm ( text , title ? , callback ? ) : AppLeaveConfirmAction ; /**
     * Returns a default action, resulting on executing the default behavior when
     * the user tries to leave an application
     */ default ( ) : AppLeaveDefaultAction ; } internal export interface Mounter { appRoute : string ; appBasePath : string ; deepLinkPaths : Record < string , string > ; mount : AppMount ; exactRoute : boolean ; unmountBeforeMounting ? : boolean ; } internal export interface ParsedAppUrl { app : string ; path ? : string ; } public export interface ApplicationSetup { param app - an  App typeParam HistoryLocationState - shape of the `History` state on  AppMountParameters . history , defaults to `unknown`.
      register < HistoryLocationState = unknown > ( app ) : void ; /**
     * Register an application updater that can be used to change the  AppUpdatableFields fields
     * of all applications at runtime.
     *
     * This is meant to be used by plugins that needs to updates the whole list of applications.
     * To only updates a specific application, use the `updater$` property of the registered application instead.
     *
     *  example registerAppUpdater ( appUpdater$ ) : void ; } internal export interface InternalApplicationSetup extends Pick < ApplicationSetup , 'registerAppUpdater' > { param plugin param app register < HistoryLocationState = unknown > ( plugin , app ) : void ; } /**
 * Options for the  ApplicationStart . navigateToApp public export interface NavigateToAppOptions { /**
     * optional  App . deepLinks id inside the application to navigate to.
     * If an additional  NavigateToAppOptions . path is defined it will be appended to the deep link path.
      deepLinkId ? : string ; /**
     * optional path inside application to deep link to.
     * If undefined, will use  App . defaultPath as default.
      path ? : string ; /**
     * optional state to forward to the application
     */ state ? : unknown ; /**
     * if true, will not create a new history entry when navigating (using `replace` instead of `push`)
     */ replace ? : boolean ; /**
     * if true, will open the app in new tab, will share session information via window.open if base
     */ openInNewTab ? : boolean ; } public export interface ApplicationStart { /**
     * Gets the read-only capabilities.
     */ capabilities : RecursiveReadonly < Capabilities > ; remarks Applications disabled by  Capabilities will not be present in the map. Applications manually disabled from
     * the client-side using an  AppUpdater are present, with their status properly set as `inaccessible`.
      applications$ : Observable < ReadonlyMap < string , PublicAppInfo > > ; param appId param options navigateToApp ( appId , options ? ) : Promise < void > ; example param url navigateToUrl ( url ) : Promise < void > ; param appId param options . path param options . absolute getUrlForApp ( appId , options ? ) : string ; /**
     * An observable that emits the current application id and each subsequent id update.
     */ currentAppId$ : Observable < string | undefined > ; } internal export interface InternalApplicationStart extends ApplicationStart { getComponent ( ) : JSX . Element | null ; internal currentActionMenu$ : Observable < MountPoint | undefined > ; internal history : History < unknown > ; }