import { DeferredRequest, Styles, Task, VisualizerConnectorOptions, VisualizerConnectorRequest, VisualizerConnectorRequests } from '@epam/ai-dial-shared'; interface Subscription { eventType: string; callback: (payload: unknown) => void; } export declare class VisualizerConnector { protected root: HTMLElement; protected subscriptions: Subscription[]; protected iframe: HTMLIFrameElement; protected loader: HTMLElement; protected loaderDisplayCss: string; protected iframeInteraction: Task; protected requests: DeferredRequest[]; protected options: VisualizerConnectorOptions; /** * Creates a VisualizerConnector * @param root {HTMLElement | string} reference or selector to parent container where the iframe should be placed * @param options {VisualizerConnectorOptions} visualizer connector options ( hostDomain, domain etc.) which will be used to create iframe */ constructor(root: HTMLElement | string, options: VisualizerConnectorOptions); /** * Creates iframe add set initial options to it * @returns {HTMLIFrameElement} reference to iframe element */ protected initIframe(): HTMLIFrameElement; /** * Creates loader and add styles * @returns {HTMLElement} reference to loader element */ protected initLoader(styles: Styles, className?: string, loaderInnerHTML?: string): HTMLElement; /** * Shows loader */ private showLoader; /** * Hides loader */ private hideLoader; /** * Displays if iframe ready to interact * @returns {Promise} if the promise resolved -> iframe ready to interact */ ready(): Promise; /** * If user provides reference to container ? returns the container : query the selector and return reference to container * @param {HTMLElement | string} root reference to parent container or selector where iframe should be placed * @returns {HTMLElement} reference to container where iframe would be placed */ protected getRoot(root: HTMLElement | string): HTMLElement; /** * Callback to post message event, contains mapping event to this.requests, mapping event to this.subscriptions * If event.data.type === '{visualizerName}/READY' means that Visualizer ready to receive message -> this.iframeInteraction.complete() * @param event {MessageEvent} post message event */ protected process: (event: MessageEvent) => void; /** * Going through all event callbacks and call it if eventType is the same as in subscription * @param eventType {string} Name of event that DIAL send * @param payload {unknown} Payload of event */ protected processEvent(eventType: string, payload?: unknown): void; /** * Creates DeferredRequests, put into the this.requests * We don't put something into the this.requests until `this.ready()` * @param type Request name * @param payload Request payload * @param waitForReady Is this request should wait for Visualizer ready (default: true) * @returns {Promise} Return promise with response payload when resolved */ send(type: VisualizerConnectorRequests, payload?: unknown, waitForReady?: boolean): Promise; /** * Add callback with eventType to this.subscriptions * @param eventType Event type * @param callback Callback which should associated to the event type * @returns {() => void} Callback which removes event callback from the this.requests */ subscribe(eventType: string, callback: (payload: unknown) => void): () => void; /** * Sets Visualizer options (hostDomain,loaderStyles, etc.) * @param options {VisualizerConnectorOptions} Options that should be set into the Visualizer */ setVisualizerConnectorOptions(options: VisualizerConnectorOptions): void; /** * Destroys Visualizer */ destroy(): void; } export {};