import { Promisable } from "type-fest";

//#region src/enum.d.ts
declare enum Region {
  China = "china",
  World = "world",
}
declare enum PlatformType {
  Figma = "figma",
  MasterGo = "mastergo",
  JSDesign = "jsdesign",
  PixsoChina = "pixso-china",
}
declare enum ImportMode {
  Quick = "quick",
  Interactive = "interactive",
}
//#endregion
//#region src/index.d.ts
interface IAuthorizationPayload {
  accessToken: string;
  appId: string;
}
interface IGeneratePluginDataOptions {
  content: string | string[];
  width?: number;
  height?: number;
  importMode?: ImportMode;
  platform: PlatformType;
  attrs?: Record<string, string>;
  copyInfo?: Record<string, any>;
  topLayerName?: {
    referrer?: false | string;
  };
}
interface IPreparePasteInPluginOptions extends IGeneratePluginDataOptions {}
interface ICopyCommonOption {
  /**
   * copy operation need user focus on the document, triggered when document is not focused
   */
  onWaitingForFocus?: () => any;
  /**
   * triggered when browser can't write clipboard in async function like safari, you should show another user action button to trigger clipboard write
   * @param writeToClipboard - The function to perform actual clipboard write operation
   */
  onUserActionRequired?: (writeToClipboard: () => void) => void;
}
interface ICopyPasteInPluginOptions extends IPreparePasteInPluginOptions, ICopyCommonOption {}
interface IPreparePasteDirectOptions extends Omit<IPreparePasteInPluginOptions, 'platform' | 'importMode'> {
  platform: PlatformType.MasterGo;
}
interface ICopyPasteDirectOptions extends IPreparePasteDirectOptions, ICopyCommonOption {}
interface CopyToDesignOptions {
  region: Region;
  /**
   * `getAuthorizationPayload` is called before each network request to get the latest authorization info, so you have to make cache yourself if needed
   * @returns
   */
  getAuthorizationPayload: () => Promisable<IAuthorizationPayload>;
  /** For internal development use only */
  _server?: (region: Region) => string;
}
declare class CopyToDesign {
  private options;
  private thumbmark;
  private visitorId;
  private socketManager;
  private $fetch;
  constructor(options: CopyToDesignOptions);
  private getAuthorizationPayload;
  private getServerByRegion;
  private getVisitorId;
  private generatePluginReceiveDataForHTML;
  writeToClipboard(clipboardItem: ClipboardItem, options?: ICopyCommonOption): Promise<void>;
  preparePasteInPlugin(options: IPreparePasteInPluginOptions): Promise<ClipboardItem>;
  copyPasteInPlugin(options: ICopyPasteInPluginOptions): Promise<void>;
  /**
   * @deprecated
   * use `copyPasteInPlugin` instead
   */
  copyToClipboardFromHTML(html: string | string[], options: Omit<ICopyPasteInPluginOptions, 'content'>): Promise<void>;
  preparePasteDirect(options: IPreparePasteDirectOptions): Promise<ClipboardItem>;
  copyPasteDirect(options: ICopyPasteDirectOptions): Promise<void>;
}
//#endregion
export { CopyToDesign, CopyToDesignOptions, IAuthorizationPayload, ICopyCommonOption, ICopyPasteDirectOptions, ICopyPasteInPluginOptions, IGeneratePluginDataOptions, IPreparePasteDirectOptions, IPreparePasteInPluginOptions, ImportMode, PlatformType, Region };