// Data the plugin prints for the block editor (see Editor::boot()).

export interface EditorBoot {
  restPath: string;
  /** Fingerprint of the connection the page was loaded on. */
  connection: string;
  connected: boolean;
  siteIdSet: boolean;
  canManage: boolean;
  isOwner: boolean;
  postTypes: string[];
  preview: { name: string; avatar: string; brand: string };
  urls: { chats: string; sites: string; standins: string; widget: string; overview: string };
}

declare global {
  interface Window {
    standChatEditor?: EditorBoot;
  }
}

export function editorBoot(): EditorBoot {
  return (
    window.standChatEditor ?? {
      restPath: '/stand-chat/v1',
      connection: '',
      connected: false,
      siteIdSet: false,
      canManage: false,
      isOwner: false,
      postTypes: ['page', 'post'],
      preview: { name: '', avatar: '', brand: '' },
      urls: { chats: '', sites: '', standins: '', widget: '', overview: '' },
    }
  );
}
