import { LDClient, LDContext, LDOptions } from "@launchdarkly/js-client-sdk";
import React from "react";
//#region src/index.d.ts
type TFlagName = string;
type TFlagVariation = boolean | string | number | Record<string, unknown> | unknown[];
type TFlag = [flagName: TFlagName, flagVariation: TFlagVariation];
type TFlags = Record<string, TFlagVariation>;
type TUser<TAdditionalUserProperties = Record<string, unknown>> = {
  key?: string;
} & TAdditionalUserProperties;
declare enum AdapterSubscriptionStatus {
  Subscribed = 0,
  Unsubscribed = 1
}
declare enum AdapterConfigurationStatus {
  Unconfigured = 0,
  Configuring = 1,
  Configured = 2
}
declare enum AdapterInitializationStatus {
  Succeeded = 0,
  Failed = 1
}
type TAdapterConfiguration = {
  initializationStatus?: AdapterInitializationStatus;
};
type TAdapterStatus = {
  configurationStatus: AdapterConfigurationStatus;
  subscriptionStatus: AdapterSubscriptionStatus;
};
declare const cacheModes: {
  readonly eager: 'eager';
  readonly lazy: 'lazy';
};
type TCacheModes = (typeof cacheModes)[keyof typeof cacheModes];
type TAdaptersStatus = Record<TAdapterIdentifiers, TAdapterStatus>;
type TAdapterStatusChange = {
  id?: TAdapterIdentifiers;
  status: Partial<TAdapterStatus>;
};
type TFlagsChange = {
  id?: TAdapterIdentifiers;
  flags: TFlags;
};
type TAdapterEventHandlers = {
  onFlagsStateChange: (flagsChange: TFlagsChange) => void;
  onStatusStateChange: (statusChange: TAdapterStatusChange) => void;
};
type TDefaultAdditionalUserProperties = Record<string, unknown>;
type TBaseAdapterArgs<TAdditionalUserProperties = TDefaultAdditionalUserProperties> = {
  user: TUser<TAdditionalUserProperties>;
  cacheIdentifier?: TCacheIdentifiers;
  cacheMode?: TCacheModes;
};
type TLaunchDarklyContextArgs = {
  context: LDContext;
};
type TLaunchDarklyAdapterArgs = TLaunchDarklyContextArgs & {
  sdk: {
    clientSideId: string;
    clientOptions?: LDOptions;
  };
  flags?: TFlags;
  throwOnInitializationFailure?: boolean;
  initializationTimeout?: number;
  flagsUpdateDelayMs?: number;
  cacheIdentifier?: TCacheIdentifiers;
  cacheMode?: TCacheModes;
};
type TGraphQlAdapterArgs<TAdditionalUserProperties = TDefaultAdditionalUserProperties> = TBaseAdapterArgs<TAdditionalUserProperties> & {
  fetcher?: typeof fetch;
  uri: string;
  query: string;
  pollingIntervalMs?: number;
  getQueryVariables?: (adapterArgs: TGraphQlAdapterArgs) => unknown;
  getRequestHeaders?: (adapterArgs: TGraphQlAdapterArgs) => Record<string, string>;
  parseFlags?: <TFetchedFlags = unknown, TParsedFlags = TFlags>(fetchedFlags: TFetchedFlags) => TParsedFlags;
};
type THttpAdapterArgs<TAdditionalUserProperties = TDefaultAdditionalUserProperties> = TBaseAdapterArgs<TAdditionalUserProperties> & {
  execute: <TPassedAdapterArgs extends TBaseAdapterArgs<TAdditionalUserProperties>>(adapterArgs: TPassedAdapterArgs) => Promise<any>;
  pollingIntervalMs?: number;
};
type TLocalStorageAdapterArgs<TAdditionalUserProperties = TDefaultAdditionalUserProperties> = TBaseAdapterArgs<TAdditionalUserProperties> & {
  pollingIntervalMs?: number;
};
type TMemoryAdapterArgs<TAdditionalUserProperties = TDefaultAdditionalUserProperties> = TBaseAdapterArgs<TAdditionalUserProperties>;
type TSplitioAdapterArgs = TBaseAdapterArgs & {
  sdk: {
    authorizationKey: string;
    options?: Record<string, unknown> & {
      core?: Record<string, string>;
    };
    treatmentAttributes?: Record<string, string | number | boolean | (string | number)[]>;
  };
};
type TCombinedAdapterArgs<TAdditionalUserProperties = TDefaultAdditionalUserProperties, TAdditionalHttpUserProperties = TDefaultAdditionalUserProperties, TAdditionalGraphQlUserProperties = TDefaultAdditionalUserProperties, TAdditionalLocalStorageUserProperties = TDefaultAdditionalUserProperties, TAdditionalMemoryUserProperties = TDefaultAdditionalUserProperties> = TBaseAdapterArgs<TAdditionalUserProperties> & {
  launchdarkly?: TLaunchDarklyAdapterArgs;
  localstorage?: TLocalStorageAdapterArgs<TAdditionalLocalStorageUserProperties>;
  memory?: TMemoryAdapterArgs<TAdditionalMemoryUserProperties>;
  splitio?: TSplitioAdapterArgs;
  graphql?: TGraphQlAdapterArgs<TAdditionalGraphQlUserProperties>;
  http?: THttpAdapterArgs<TAdditionalHttpUserProperties>;
};
type TAdapterArgs = TLaunchDarklyAdapterArgs | TLocalStorageAdapterArgs | TMemoryAdapterArgs | TSplitioAdapterArgs | TGraphQlAdapterArgs | THttpAdapterArgs | TCombinedAdapterArgs;
declare const adapterIdentifiers: {
  readonly launchdarkly: 'launchdarkly';
  readonly localstorage: 'localstorage';
  readonly memory: 'memory';
  readonly splitio: 'splitio';
  readonly graphql: 'graphql';
  readonly http: 'http';
  readonly combined: 'combined';
};
type TAdapterIdentifiers = (typeof adapterIdentifiers)[keyof typeof adapterIdentifiers] | string;
type TFlagsContext = Record<TAdapterIdentifiers, TFlags>;
declare const cacheIdentifiers: {
  readonly local: 'local';
  readonly session: 'session';
};
type TCacheIdentifiers = (typeof cacheIdentifiers)[keyof typeof cacheIdentifiers];
type TUpdateFlagsOptions = {
  lockFlags?: boolean;
  unsubscribeFlags?: boolean;
};
type TFlagsUpdateFunction = (flags: TFlags, options?: TUpdateFlagsOptions) => void;
interface TAdapterInterface<Args extends TAdapterArgs> {
  id: TAdapterIdentifiers;
  effectIds?: TAdapterIdentifiers[];
  configure: (adapterArgs: Args, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  reconfigure: (adapterArgs: Args, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  getIsConfigurationStatus: (configurationStatus: AdapterConfigurationStatus) => boolean;
  setConfigurationStatus?: (nextConfigurationStatus: AdapterConfigurationStatus) => void;
  waitUntilConfigured?: () => Promise<unknown>;
  reset?: () => void;
  getFlag?: (flagName: TFlagName) => TFlagVariation | undefined;
  unsubscribe: () => void;
  subscribe: () => void;
  updateFlags: TFlagsUpdateFunction;
  getUser?: () => TUser | undefined;
}
interface TLaunchDarklyAdapterInterface extends TAdapterInterface<TLaunchDarklyAdapterArgs> {
  id: typeof adapterIdentifiers.launchdarkly;
  configure: (adapterArgs: TLaunchDarklyAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  reconfigure: (adapterArgs: TLaunchDarklyAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  getIsConfigurationStatus: (adapterConfigurationStatus: AdapterConfigurationStatus) => boolean;
  getClient: () => LDClient | undefined;
  getFlag: (flagName: TFlagName) => TFlagVariation | undefined;
  updateClientContext: (updatedContextProps: TLaunchDarklyAdapterArgs['context']) => Promise<unknown>;
  unsubscribe: () => void;
  subscribe: () => void;
}
interface TLocalStorageAdapterInterface extends TAdapterInterface<TLocalStorageAdapterArgs> {
  id: typeof adapterIdentifiers.localstorage;
  configure: (adapterArgs: TLocalStorageAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  reconfigure: (adapterArgs: TLocalStorageAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  getIsConfigurationStatus: (adapterConfigurationStatus: AdapterConfigurationStatus) => boolean;
  waitUntilConfigured: () => Promise<unknown>;
  unsubscribe: () => void;
  subscribe: () => void;
}
interface TGraphQlAdapterInterface extends TAdapterInterface<TGraphQlAdapterArgs> {
  id: typeof adapterIdentifiers.graphql;
  configure: (adapterArgs: TGraphQlAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  reconfigure: (adapterArgs: TGraphQlAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  getIsConfigurationStatus: (adapterConfigurationStatus: AdapterConfigurationStatus) => boolean;
  waitUntilConfigured: () => Promise<unknown>;
  unsubscribe: () => void;
  subscribe: () => void;
}
interface THttpAdapterInterface extends TAdapterInterface<THttpAdapterArgs> {
  id: typeof adapterIdentifiers.http;
  configure: (adapterArgs: THttpAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  reconfigure: (adapterArgs: THttpAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  getIsConfigurationStatus: (adapterConfigurationStatus: AdapterConfigurationStatus) => boolean;
  waitUntilConfigured: () => Promise<unknown>;
  unsubscribe: () => void;
  subscribe: () => void;
}
interface TMemoryAdapterInterface extends TAdapterInterface<TMemoryAdapterArgs> {
  id: typeof adapterIdentifiers.memory;
  configure: (adapterArgs: TMemoryAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  reconfigure: (adapterArgs: TMemoryAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  getIsConfigurationStatus: (adapterConfigurationStatus: AdapterConfigurationStatus) => boolean;
  waitUntilConfigured: () => Promise<unknown>;
  reset: () => void;
  updateFlags: TFlagsUpdateFunction;
  unsubscribe: () => void;
  subscribe: () => void;
}
interface TCombinedAdapterInterface extends TAdapterInterface<TCombinedAdapterArgs> {
  id: typeof adapterIdentifiers.combined;
  effectIds?: TAdapterIdentifiers[];
  combine: <TAdapterInstance extends TAdapter>(adapters: TAdapterInstance[]) => void;
  configure: (adapterArgs: TCombinedAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  reconfigure: (adapterArgs: TCombinedAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  getIsConfigurationStatus: (adapterConfigurationStatus: AdapterConfigurationStatus) => boolean;
  waitUntilConfigured: () => Promise<unknown>;
  reset: () => void;
  updateFlags: TFlagsUpdateFunction;
  unsubscribe: () => void;
  subscribe: () => void;
}
interface TSplitioAdapterInterface extends TAdapterInterface<TSplitioAdapterArgs> {
  id: typeof adapterIdentifiers.splitio;
  configure: (adapterArgs: TSplitioAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  reconfigure: (adapterArgs: TSplitioAdapterArgs, adapterEventHandlers: TAdapterEventHandlers) => Promise<TAdapterConfiguration>;
  getIsConfigurationStatus: (adapterConfigurationStatus: AdapterConfigurationStatus) => boolean;
  unsubscribe: () => void;
  subscribe: () => void;
}
type TAdapter = TLaunchDarklyAdapterInterface | TLocalStorageAdapterInterface | TMemoryAdapterInterface | TSplitioAdapterInterface | TGraphQlAdapterInterface | THttpAdapterInterface | TCombinedAdapterInterface;
type TConfigureAdapterArgs<TAdapterInstance extends TAdapter> = TAdapterInstance extends TLaunchDarklyAdapterInterface ? TLaunchDarklyAdapterArgs : TAdapterInstance extends TLocalStorageAdapterInterface ? TLocalStorageAdapterArgs : TAdapterInstance extends TMemoryAdapterInterface ? TMemoryAdapterArgs : TAdapterInstance extends TSplitioAdapterInterface ? TSplitioAdapterArgs : TAdapterInstance extends TGraphQlAdapterInterface ? TGraphQlAdapterArgs : TAdapterInstance extends THttpAdapterInterface ? THttpAdapterArgs : TAdapterInstance extends TCombinedAdapterInterface ? TCombinedAdapterArgs : never;
type TConfigureAdapterProps<TAdapterInstance extends TAdapter> = {
  adapter: TAdapterInstance extends TLaunchDarklyAdapterInterface ? TLaunchDarklyAdapterInterface : TAdapterInstance extends TLocalStorageAdapterInterface ? TLocalStorageAdapterInterface : TAdapterInstance extends TMemoryAdapterInterface ? TMemoryAdapterInterface : TAdapterInstance extends TSplitioAdapterInterface ? TSplitioAdapterInterface : TAdapterInstance extends TGraphQlAdapterInterface ? TGraphQlAdapterInterface : TAdapterInstance extends THttpAdapterInterface ? THttpAdapterInterface : TAdapterInstance extends TCombinedAdapterInterface ? TCombinedAdapterInterface : never;
  adapterArgs: TConfigureAdapterArgs<TAdapterInstance>;
};
type TAdapterReconfigurationOptions = {
  shouldOverwrite?: boolean;
};
type TAdapterReconfiguration = {
  adapterArgs: TAdapterArgs;
  options: TAdapterReconfigurationOptions;
};
type TConfigureAdapterChildrenAsFunctionArgs = {
  isAdapterConfigured: boolean;
};
type TConfigureAdapterChildrenAsFunction = (args: TConfigureAdapterChildrenAsFunctionArgs) => React.ReactNode;
type TConfigureAdapterChildren = TConfigureAdapterChildrenAsFunction | React.ReactNode;
type TReconfigureAdapter = (adapterArgs: TAdapterArgs, options: TAdapterReconfigurationOptions) => void;
type TAdapterContext = {
  adapterEffectIdentifiers: TAdapterIdentifiers[];
  reconfigure: TReconfigureAdapter;
  status?: TAdaptersStatus;
};
type TLaunchDarklyFlopflipGlobal = {
  adapter: TLaunchDarklyAdapterInterface;
  updateFlags: TFlagsUpdateFunction;
};
type TSplitioAdapterGlobal = {
  adapter: TSplitioAdapterInterface;
  updateFlags: TFlagsUpdateFunction;
};
type TMemoryAdapterGlobal = {
  adapter: TMemoryAdapterInterface;
  updateFlags: TFlagsUpdateFunction;
};
type TLocalStorageAdapterGlobal = {
  adapter: TLocalStorageAdapterInterface;
  updateFlags: TFlagsUpdateFunction;
};
type TGraphQlAdapterGlobal = {
  adapter: TLocalStorageAdapterInterface;
  updateFlags: TFlagsUpdateFunction;
};
type THttpAdapterGlobal = {
  adapter: TLocalStorageAdapterInterface;
  updateFlags: TFlagsUpdateFunction;
};
type TCombinedAdapterGlobal = {
  adapter: TCombinedAdapterInterface;
  updateFlags: TFlagsUpdateFunction;
};
type TFlopflipGlobal = {
  [adapterIdentifiers.launchdarkly]?: TLaunchDarklyFlopflipGlobal;
  [adapterIdentifiers.splitio]?: TSplitioAdapterGlobal;
  [adapterIdentifiers.memory]?: TMemoryAdapterGlobal;
  [adapterIdentifiers.localstorage]?: TLocalStorageAdapterGlobal;
  [adapterIdentifiers.graphql]?: TGraphQlAdapterGlobal;
  [adapterIdentifiers.http]?: THttpAdapterGlobal;
  [adapterIdentifiers.combined]?: TCombinedAdapterGlobal;
};
declare global {
  interface Window {
    __flopflip__: TFlopflipGlobal;
  }
}
type TDiff<ExcludedFrom, ToExclude> = Pick<ExcludedFrom, Exclude<keyof ExcludedFrom, keyof ToExclude>>;
type TCache = {
  get: <T = any>(key: string) => T;
  set: (key: string, value: any) => boolean;
  unset: (key: string) => void;
};
type TCacheOptions = {
  prefix: string;
};
//#endregion
export { AdapterConfigurationStatus, AdapterInitializationStatus, AdapterSubscriptionStatus, TAdapter, TAdapterArgs, TAdapterConfiguration, TAdapterContext, TAdapterEventHandlers, TAdapterIdentifiers, TAdapterInterface, TAdapterReconfiguration, TAdapterReconfigurationOptions, TAdapterStatus, TAdapterStatusChange, TAdaptersStatus, TBaseAdapterArgs, TCache, TCacheIdentifiers, TCacheModes, TCacheOptions, TCombinedAdapterArgs, TCombinedAdapterInterface, TConfigureAdapterArgs, TConfigureAdapterChildren, TConfigureAdapterChildrenAsFunction, TConfigureAdapterChildrenAsFunctionArgs, TConfigureAdapterProps, TDiff, TFlag, TFlagName, TFlagVariation, TFlags, TFlagsChange, TFlagsContext, TFlagsUpdateFunction, TFlopflipGlobal, TGraphQlAdapterArgs, TGraphQlAdapterInterface, THttpAdapterArgs, THttpAdapterInterface, TLaunchDarklyAdapterArgs, TLaunchDarklyAdapterInterface, TLaunchDarklyContextArgs, TLocalStorageAdapterArgs, TLocalStorageAdapterInterface, TMemoryAdapterArgs, TMemoryAdapterInterface, TReconfigureAdapter, TSplitioAdapterArgs, TSplitioAdapterInterface, TUpdateFlagsOptions, TUser, adapterIdentifiers, cacheIdentifiers, cacheModes };
//# sourceMappingURL=index.d.cts.map