import { Flatfile } from '@flatfile/api';
export { FlatfileClient, default as api } from '@flatfile/api';
import { FlatfileListener } from '@flatfile/listener';
export { FlatfileListener } from '@flatfile/listener';
import * as pluginRecordHook from '@flatfile/plugin-record-hook';
export { pluginRecordHook as RecordHookPlugin };
import { SimpleOnboarding, ISpace, IThemeConfig, ISidebarConfig, IUserInfo, NewSpaceFromPublishableKey } from '@flatfile/embedded-utils';

declare function createIframe(mountElement: string, displayAsModal: boolean, spaceId?: string, token?: string, spacesUrl?: string, isReusingSpace?: boolean): HTMLElement | null;

declare function startFlatfile(options: SimpleOnboarding | ISpace): Promise<{
    spaceId: any;
} | undefined>;

interface UpdateSpaceInfo {
    apiUrl: string;
    publishableKey?: string;
    workbook?: Flatfile.CreateWorkbookConfig;
    spaceId: string;
    environmentId?: string;
    mountElement: string;
    errorTitle: string;
    themeConfig?: IThemeConfig;
    document?: Flatfile.DocumentConfig;
    sidebarConfig?: ISidebarConfig;
    userInfo?: Partial<IUserInfo>;
    spaceInfo?: Partial<IUserInfo>;
    accessToken: string;
    spaceBody?: any;
}

interface SimpleListenerType extends Pick<SimpleOnboarding, 'onRecordHook' | 'onSubmit' | 'submitSettings'> {
    slug: string;
}
type InitSpaceType = ISpace & {
    isAutoConfig: boolean;
};

/**
 * Add a listener to handle postMessage events
 *
 * @param accessToken
 * @param apiUrl
 * @param listener
 * @param closeSpace
 * @param onClose
 * @returns Promise<() => void>
 */
declare function createListener(accessToken: string, apiUrl: string, listener: FlatfileListener, closeSpace: NewSpaceFromPublishableKey['closeSpace'], onClose: () => void, onInit: (data: {
    localTranslations: Record<string, any>;
}) => void): Promise<() => void>;
declare const createSimpleListener: ({ onRecordHook, onSubmit, slug, submitSettings, }: SimpleListenerType) => FlatfileListener;

declare const initializeFlatfile: typeof startFlatfile;

export { type InitSpaceType, type SimpleListenerType, type UpdateSpaceInfo, createIframe, createListener, createSimpleListener, initializeFlatfile, startFlatfile };
