{"version":3,"file":"growthbook.mjs","names":[],"sources":["../../../src/types/growthbook.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type {\n  GrowthBook,\n  GrowthBookClient,\n  StickyBucketService,\n  UserScopedGrowthBook,\n} from \"..\";\nimport {\n  AttributePath,\n  ConditionInterface,\n  ParentConditionInterface,\n} from \"./mongrule\";\n\ndeclare global {\n  interface Window {\n    _growthbook?: GrowthBook;\n  }\n}\n\nexport type VariationMeta = {\n  passthrough?: boolean;\n  key?: string;\n  name?: string;\n};\n\nexport type FeatureRule<T = any, A extends Attributes = any> = {\n  id?: string;\n  condition?: ConditionInterface<A>;\n  parentConditions?: ParentConditionInterface[];\n  force?: T;\n  variations?: T[];\n  weights?: number[];\n  key?: string;\n  hashAttribute?: AttributeKey<A>;\n  fallbackAttribute?: AttributeKey<A>;\n  hashVersion?: number;\n  disableStickyBucketing?: boolean;\n  bucketVersion?: number;\n  minBucketVersion?: number;\n  range?: VariationRange;\n  coverage?: number;\n  /** @deprecated */\n  namespace?: [string, number, number];\n  ranges?: VariationRange[];\n  meta?: VariationMeta[];\n  filters?: Filter<A>[];\n  seed?: string;\n  name?: string;\n  phase?: string;\n  tracks?: Array<{\n    experiment: Experiment<T, A>;\n    result: Result<T>;\n  }>;\n  contextualBanditRef?: string;\n  contextualVariations?: T[];\n  metadata?: PayloadMetadata;\n};\n\nexport type ContextualBanditDefinition = {\n  banditVersion?: number;\n  contexts: {\n    leafId: number;\n    condition: Record<string, unknown>;\n    weights: number[];\n  }[];\n};\n\nexport type ContextualBanditDefinitions = Record<\n  string,\n  ContextualBanditDefinition\n>;\n\nexport type InterleavingDefinition<A extends Attributes = any> = {\n  trackingKey: string;\n  // Carried here, not read off the pseudo flag's rule: remote evaluation\n  // replaces rules with a forced defaultValue, so the rule is gone client-side.\n  hashAttribute: AttributeKey<A>;\n  seed: string;\n  variations: { key: string; config: Record<string, unknown> }[];\n};\n\nexport type InterleavingDefinitions<A extends Attributes = any> = Record<\n  string,\n  InterleavingDefinition<A>\n>;\n\nexport interface FeatureDefinition<T = any, A extends Attributes = any> {\n  defaultValue?: T;\n  rules?: FeatureRule<T, A>[];\n  metadata?: PayloadMetadata;\n}\n\n/**\n * Sent when the SDK Connection opts in. A feature in every project has\n * `allProjects` instead of `projects`, and one in no project has neither.\n */\nexport type PayloadMetadata = {\n  projects?: string[];\n  allProjects?: boolean;\n  tags?: string[];\n  customFields?: Record<string, unknown>;\n};\n\nexport type FeatureResultSource =\n  | \"unknownFeature\"\n  | \"defaultValue\"\n  | \"force\"\n  | \"override\"\n  | \"experiment\"\n  | \"prerequisite\"\n  | \"cyclicPrerequisite\";\n\nexport interface FeatureResult<T = any> {\n  value: T | null;\n  source: FeatureResultSource;\n  on: boolean;\n  off: boolean;\n  ruleId: string;\n  experiment?: Experiment<T>;\n  experimentResult?: Result<T>;\n}\n\n/** @deprecated */\nexport type ExperimentStatus = \"draft\" | \"running\" | \"stopped\";\n\nexport type UrlTargetType = \"regex\" | \"simple\";\n\nexport type UrlTarget = {\n  include: boolean;\n  type: UrlTargetType;\n  pattern: string;\n};\n\nexport type Experiment<T, A extends Attributes = any> = {\n  key: string;\n  variations: [T, T, ...T[]];\n  ranges?: VariationRange[];\n  meta?: VariationMeta[];\n  filters?: Filter<A>[];\n  seed?: string;\n  name?: string;\n  phase?: string;\n  urlPatterns?: UrlTarget[];\n  weights?: number[];\n  condition?: ConditionInterface<A>;\n  parentConditions?: ParentConditionInterface[];\n  coverage?: number;\n  include?: () => boolean;\n  /** @deprecated */\n  namespace?: [string, number, number];\n  force?: number;\n  hashAttribute?: AttributeKey<A>;\n  fallbackAttribute?: AttributeKey<A>;\n  hashVersion?: number;\n  disableStickyBucketing?: boolean;\n  bucketVersion?: number;\n  minBucketVersion?: number;\n  active?: boolean;\n  persistQueryString?: boolean;\n  contextualBandit?: CBContext;\n  /** @deprecated */\n  status?: ExperimentStatus;\n  /** @deprecated */\n  url?: RegExp;\n  /** @deprecated */\n  groups?: string[];\n};\n\nexport type AutoExperimentChangeType = \"redirect\" | \"visual\" | \"unknown\";\n\nexport type AutoExperiment<\n  T = AutoExperimentVariation,\n  A extends Attributes = any,\n> = Experiment<T, A> & {\n  changeId?: string;\n  // If true, require the experiment to be manually triggered\n  manual?: boolean;\n  metadata?: PayloadMetadata;\n  contextualBanditRef?: string;\n};\n\nexport type ExperimentOverride = {\n  condition?: ConditionInterface;\n  weights?: number[];\n  active?: boolean;\n  status?: ExperimentStatus;\n  force?: number;\n  coverage?: number;\n  groups?: string[];\n  namespace?: [string, number, number];\n  url?: RegExp | string;\n};\n\nexport interface Result<T> {\n  value: T;\n  variationId: number;\n  key: string;\n  name?: string;\n  bucket?: number;\n  passthrough?: boolean;\n  inExperiment: boolean;\n  hashUsed?: boolean;\n  hashAttribute: string;\n  hashValue: string;\n  featureId: string | null;\n  stickyBucketUsed?: boolean;\n  leafId?: number;\n  variationWeights?: number[];\n  banditVersion?: number;\n}\n\nexport type CBContext = {\n  leafId: number;\n  variationWeights: number[];\n  banditVersion?: number;\n};\n\nexport type Attributes = Record<string, any>;\n// The types below that take attributes default to `any`, not `Attributes`, so\n// that one checked against an app's attributes is still assignable to the\n// unchecked type that `init`, `setPayload` and the rest accept.\n\n// The attributes a user can be hashed on: ones that can hold a string or a\n// number. Unlike conditions, hashing doesn't look inside object attributes.\nexport type AttributeKey<A> = string extends keyof A\n  ? string\n  : {\n      [K in keyof A & string]: unknown extends A[K]\n        ? K\n        : [Extract<A[K], string | number>] extends [never]\n          ? never\n          : K;\n    }[keyof A & string];\n\n/**\n * Register your app's feature and attribute types once and every GrowthBook\n * instance and React hook is typed with no generics:\n *\n *   declare module \"@growthbook/growthbook\" {\n *     interface Register {\n *       features: AppFeatures;\n *       attributes: AppAttributes;\n *     }\n *   }\n *\n * Register `events` (event name -> properties) to check `logEvent` calls:\n *\n *   events: {\n *     start_checkout: { plan: \"pro\" | \"enterprise\" };\n *     button_click: { button: string };\n *   };\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface Register {}\nexport type RegisteredFeatures = Register extends { features: infer F }\n  ? F\n  : Record<string, any>;\nexport type RegisteredAttributes = Register extends { attributes: infer A }\n  ? A\n  : Attributes;\nexport type RegisteredEvents = Register extends { events: infer E }\n  ? E\n  : Record<string, EventProperties>;\n// The arguments after the event name: properties can be left out for an event\n// that has no required ones\nexport type EventArgs<P> =\n  Record<never, never> extends P ? [properties?: P] : [properties: P];\n// Stops an argument from being used to infer T, which would override the\n// registered default (the built-in NoInfer needs TypeScript 5.4+)\nexport type NoInferType<T> = [T][T extends unknown ? 0 : never];\n\n// Loosely typed attributes: callbacks are not tied to one instance's types, so\n// the registered types would be wrong for an instance with its own generics\nexport type TrackingUserContext = Pick<\n  UserContext<Attributes>,\n  \"attributes\" | \"url\"\n>;\n\nexport interface TrackingData {\n  experiment: Experiment<any>;\n  result: Result<any>;\n  user?: TrackingUserContext;\n}\n\nexport interface TrackingDataWithUser {\n  experiment: Experiment<any>;\n  result: Result<any>;\n  user: TrackingUserContext;\n}\n\nexport type TrackingCallback = (\n  experiment: Experiment<any>,\n  result: Result<any>,\n  user?: TrackingUserContext,\n) => Promise<void> | void;\n\nexport type TrackingCallbackWithUser = (\n  experiment: Experiment<any>,\n  result: Result<any>,\n  user: TrackingUserContext,\n) => Promise<void> | void;\n\nexport type FeatureUsageCallback = (\n  key: string,\n  result: FeatureResult<any>,\n) => void;\n\nexport type FeatureUsageCallbackWithUser = (\n  key: string,\n  result: FeatureResult<any>,\n  user: TrackingUserContext,\n) => void;\n\n// Callback types for internal plugin subscriptions (e.g. session replay).\n// Must be synchronous — async callbacks are not awaited and rejected promises won't be caught.\nexport type FeatureUsageSubCallback = (\n  key: string,\n  result: Readonly<FeatureResult<any>>,\n) => void;\n\nexport type CustomEventSubCallback = (\n  eventName: string,\n  properties: Readonly<Record<string, unknown>>,\n) => void;\n\nexport type ExperimentViewedSubCallback = (\n  experiment: Readonly<Experiment<unknown>>,\n  result: Readonly<Result<unknown>>,\n  user: TrackingUserContext,\n) => void;\n\nexport type Plugin = (\n  gb: GrowthBook | UserScopedGrowthBook | GrowthBookClient,\n) => void;\n\nexport type EventProperties = Record<string, unknown>;\nexport type EventLogger = (\n  eventName: string,\n  properties: EventProperties,\n  userContext: TrackingUserContext,\n) => void | Promise<void>;\n\nexport type NavigateCallback = (url: string) => void | Promise<void>;\n\nexport type ApplyDomChangesCallback = (\n  changes: AutoExperimentVariation,\n) => () => void;\n\nexport type RenderFunction = () => void;\n\n// Constructor Options\nexport type Options<AppAttributes extends Attributes = RegisteredAttributes> = {\n  enabled?: boolean;\n  attributes?: AppAttributes;\n  /** The user's remote saved groups; wins over a `__gb_remoteGroupIds` attribute. */\n  remoteGroupIds?: string[];\n  url?: string;\n  features?: Record<string, FeatureDefinition>;\n  experiments?: AutoExperiment[];\n  forcedVariations?: Record<string, number>;\n  forcedFeatureValues?: Map<string, any>;\n  attributeOverrides?: Partial<AppAttributes>;\n  blockedChangeIds?: string[];\n  disableVisualExperiments?: boolean;\n  disableJsInjection?: boolean;\n  jsInjectionNonce?: string;\n  disableUrlRedirectExperiments?: boolean;\n  disableCrossOriginUrlRedirectExperiments?: boolean;\n  disableExperimentsOnLoad?: boolean;\n  stickyBucketAssignmentDocs?: Record<\n    StickyAttributeKey,\n    StickyAssignmentsDocument\n  >;\n  stickyBucketService?: StickyBucketService;\n  debug?: boolean;\n  log?: (msg: string, ctx: any) => void;\n  qaMode?: boolean;\n  /** @deprecated */\n  backgroundSync?: boolean;\n  /** @deprecated */\n  subscribeToChanges?: boolean;\n  /**\n   * The hash version for percentage rollouts and experiments that don't set\n   * their own `hashVersion`. Defaults to 1, which is slightly biased. Changing\n   * it reassigns the users of those rollouts and experiments.\n   */\n  defaultHashVersion?: number;\n  enableDevMode?: boolean;\n  disableCache?: boolean;\n  /** @deprecated */\n  disableDevTools?: boolean;\n  trackingCallback?: TrackingCallback;\n  onFeatureUsage?: FeatureUsageCallback;\n  eventLogger?: EventLogger;\n  cacheKeyAttributes?: (keyof Attributes)[];\n  /** @deprecated */\n  user?: {\n    id?: string;\n    anonId?: string;\n    [key: string]: string | undefined;\n  };\n  /** @deprecated */\n  overrides?: Record<string, ExperimentOverride>;\n  /** @deprecated */\n  groups?: Record<string, boolean>;\n  apiHost?: string;\n  streamingHost?: string;\n  apiHostRequestHeaders?: Record<string, string>;\n  streamingHostRequestHeaders?: Record<string, string>;\n  clientKey?: string;\n  renderer?: null | RenderFunction;\n  decryptionKey?: string;\n  remoteEval?: boolean;\n  navigate?: NavigateCallback;\n  navigateDelay?: number;\n  maxNavigateDelay?: number;\n  /** @deprecated */\n  antiFlicker?: boolean;\n  /** @deprecated */\n  antiFlickerTimeout?: number;\n  applyDomChangesCallback?: ApplyDomChangesCallback;\n  savedGroups?: SavedGroupsPayload;\n  contextualBandits?: ContextualBanditDefinitions;\n  plugins?: Plugin[];\n};\n\nexport type ClientOptions<\n  AppAttributes extends Attributes = RegisteredAttributes,\n> = {\n  enabled?: boolean;\n  debug?: boolean;\n  globalAttributes?: Partial<AppAttributes>;\n  forcedVariations?: Record<string, number>;\n  forcedFeatureValues?: Map<string, any>;\n  log?: (msg: string, ctx: any) => void;\n  qaMode?: boolean;\n  /**\n   * The hash version for percentage rollouts and experiments that don't set\n   * their own `hashVersion`. Defaults to 1, which is slightly biased. Changing\n   * it reassigns the users of those rollouts and experiments.\n   */\n  defaultHashVersion?: number;\n  disableCache?: boolean;\n  trackingCallback?: TrackingCallbackWithUser;\n  onFeatureUsage?: (\n    key: string,\n    result: FeatureResult<any>,\n    user: TrackingUserContext,\n  ) => void;\n  eventLogger?: EventLogger;\n  apiHost?: string;\n  streamingHost?: string;\n  apiHostRequestHeaders?: Record<string, string>;\n  streamingHostRequestHeaders?: Record<string, string>;\n  clientKey?: string;\n  decryptionKey?: string;\n  savedGroups?: SavedGroupsPayload;\n  contextualBandits?: ContextualBanditDefinitions;\n  plugins?: Plugin[];\n};\n\n// Contexts\nexport type GlobalContext = {\n  log: (msg: string, ctx: any) => void;\n  debug?: boolean;\n  features?: FeatureDefinitions;\n  experiments?: AutoExperiment[];\n  enabled?: boolean;\n  qaMode?: boolean;\n  defaultHashVersion?: number;\n  savedGroups?: SavedGroupsPayload;\n  contextualBandits?: ContextualBanditDefinitions;\n  forcedVariations?: Record<string, number>;\n  forcedFeatureValues?: Map<string, any>;\n  trackingCallback?: TrackingCallbackWithUser;\n  onFeatureUsage?: FeatureUsageCallbackWithUser;\n  onExperimentEval?: (experiment: Experiment<any>, result: Result<any>) => void;\n  saveDeferredTrack?: (data: TrackingData) => void;\n  recordChangeId?: (changeId: string) => void;\n  eventLogger?: EventLogger;\n\n  /** @deprecated */\n  overrides?: Record<string, ExperimentOverride>;\n  /** @deprecated */\n  groups?: Record<string, boolean>;\n  /** @deprecated */\n  user?: {\n    id?: string;\n    anonId?: string;\n    [key: string]: string | undefined;\n  };\n};\n\n// Some global fields can be overridden by the user, others are always user-level\nexport type UserContext<\n  AppAttributes extends Attributes = RegisteredAttributes,\n> = {\n  enabled?: boolean;\n  qaMode?: boolean;\n  enableDevMode?: boolean;\n  attributes?: AppAttributes;\n  /** The user's remote saved groups; wins over a `__gb_remoteGroupIds` attribute. */\n  remoteGroupIds?: string[];\n  url?: string;\n  blockedChangeIds?: string[];\n  stickyBucketAssignmentDocs?: Record<\n    StickyAttributeKey,\n    StickyAssignmentsDocument\n  >;\n  saveStickyBucketAssignmentDoc?: (\n    doc: StickyAssignmentsDocument,\n  ) => Promise<unknown>;\n  forcedVariations?: Record<string, number>;\n  forcedFeatureValues?: Map<string, any>;\n  attributeOverrides?: Partial<AppAttributes>;\n  trackingCallback?: TrackingCallback;\n  onFeatureUsage?: FeatureUsageCallback;\n  trackedExperiments?: Set<string>;\n  trackedFeatureUsage?: Record<string, string>;\n  devLogs?: LogUnion[];\n  featureUsageSubs?: Set<FeatureUsageSubCallback>;\n  experimentViewedSubs?: Set<ExperimentViewedSubCallback>;\n};\n\nexport type StackContext = {\n  id?: string;\n  evaluatedFeatures: Set<string>;\n};\n\nexport type EvalContext = {\n  global: GlobalContext;\n  user: UserContext;\n  stack: StackContext;\n};\n\nexport type PrefetchOptions = Pick<\n  Options,\n  | \"decryptionKey\"\n  | \"apiHost\"\n  | \"apiHostRequestHeaders\"\n  | \"streamingHost\"\n  | \"streamingHostRequestHeaders\"\n> & {\n  clientKey: string;\n  streaming?: boolean;\n  skipCache?: boolean;\n};\n\nexport type SubscriptionFunction = (\n  experiment: Experiment<any>,\n  result: Result<any>,\n) => void;\n\nexport type VariationRange = [number, number];\n\nexport interface InitResponse {\n  // If a payload was set\n  success: boolean;\n  // Where the payload came from, if set\n  source: \"init\" | \"cache\" | \"network\" | \"error\" | \"timeout\";\n  // If the payload could not be set (success = false), this will hold the fetch error\n  error?: Error;\n}\n\nexport interface FetchResponse {\n  data: FeatureApiResponse | null;\n  success: boolean;\n  source: \"cache\" | \"network\" | \"error\" | \"timeout\";\n  error?: Error;\n}\n\nexport type JSONValue =\n  | null\n  | number\n  | string\n  | boolean\n  | Array<JSONValue>\n  | Record<string, unknown>\n  | { [key: string]: JSONValue };\n\nexport type WidenPrimitives<T> = T extends string\n  ? string\n  : T extends number\n    ? number\n    : T extends boolean\n      ? boolean\n      : T;\n\n// What `getFeatureValue` returns: the fallback's type, or with a `null`\n// fallback, the feature's type or null\nexport type FeatureValueOrFallback<V, T> = [V] extends [null]\n  ? T | null\n  : WidenPrimitives<V>;\n\nexport type DOMMutation = {\n  selector: string;\n  action: string;\n  attribute: string;\n  value?: string;\n  parentSelector?: string;\n  insertBeforeSelector?: string;\n};\n\nexport type AutoExperimentVariation = {\n  domMutations?: DOMMutation[];\n  css?: string;\n  js?: string;\n  urlRedirect?: string;\n};\n\n// With AppFeatures, a payload written in code is checked against it: unknown\n// keys and values of the wrong type are errors. Features may be left out,\n// since a payload omits the ones that are toggled off. Without AppFeatures\n// (the default) any payload is accepted, as is one typed `FeatureApiResponse`.\nexport type FeatureDefinitions<\n  AppFeatures extends Record<string, any> = Record<string, any>,\n  AppAttributes extends Attributes = any,\n> = string extends keyof AppFeatures\n  ? Record<string, FeatureDefinition<any, AppAttributes>>\n  : {\n      [K in keyof AppFeatures]?: FeatureDefinition<\n        AppFeatures[K],\n        AppAttributes\n      >;\n    };\n\nexport type FeatureApiResponse<\n  AppFeatures extends Record<string, any> = Record<string, any>,\n  AppAttributes extends Attributes = any,\n> = {\n  features?: FeatureDefinitions<AppFeatures, AppAttributes>;\n  dateUpdated?: string;\n  encryptedFeatures?: string;\n  experiments?: AutoExperiment<AutoExperimentVariation, AppAttributes>[];\n  encryptedExperiments?: string;\n  savedGroups?: SavedGroupsPayload<AppAttributes>;\n  encryptedSavedGroups?: string;\n  contextualBandits?: ContextualBanditDefinitions;\n  encryptedContextualBandits?: string;\n  interleavings?: InterleavingDefinitions<AppAttributes>;\n  encryptedInterleavings?: string;\n};\n\n// Alias\nexport type GrowthBookPayload = FeatureApiResponse;\n\n/**\n * A payload written in code, such as the `fallbackPayload` given to `init`,\n * checked against your attributes as well as your features. Targeting\n * conditions, hash attributes and saved groups must use real attributes, with\n * operators and values that fit each attribute's type.\n *\n *   const fallbackPayload: Payload<AppFeatures, AppAttributes> = {...};\n *\n * Uses the registered features and attributes when none are given.\n */\nexport type Payload<\n  AppFeatures extends Record<string, any> = RegisteredFeatures,\n  AppAttributes extends Attributes = RegisteredAttributes,\n> = FeatureApiResponse<AppFeatures, AppAttributes>;\n\n/** A rule in `LocalFeatures`. A percentage rollout needs a `hashAttribute`. */\nexport type LocalFeatureRule<T = any, A extends Attributes = any> = {\n  force: T;\n  condition?: ConditionInterface<A>;\n} & (\n  | {\n      coverage: number;\n      hashAttribute: AttributeKey<A>;\n      /** Hashed with the user instead of the feature key */\n      seed?: string;\n    }\n  | { coverage?: never; hashAttribute?: never; seed?: never }\n);\n\n/**\n * Feature flags hard-coded in a local file and passed to `initSync` as the\n * payload's `features`. Stricter than `Payload`: every feature must be defined\n * with a `defaultValue`, and rules are limited to `force`, `condition` and\n * percentage rollouts. A feature that's optional in your features type may be\n * left out.\n *\n *   export const features: LocalFeatures = {...};\n *   new GrowthBook().initSync({ payload: { features } });\n *\n * Uses the registered features and attributes when none are given.\n */\nexport type LocalFeatures<\n  AppFeatures extends Record<string, any> = RegisteredFeatures,\n  AppAttributes extends Attributes = RegisteredAttributes,\n> = {\n  [K in keyof AppFeatures]: {\n    defaultValue: Exclude<AppFeatures[K], undefined>;\n    rules?: LocalFeatureRule<\n      Exclude<AppFeatures[K], undefined>,\n      AppAttributes\n    >[];\n  };\n};\n\n/** Each filter is an array, and any one of its values is enough */\nexport type PayloadFilters = {\n  projects?: string[];\n  tags?: string[];\n  customFields?: Record<string, unknown[]>;\n};\n\nexport type ReducePayloadOptions = {\n  userContext?: UserContext;\n  /** Keep only the features and auto experiments that match every filter */\n  include?: PayloadFilters;\n  /** Remove the features and auto experiments that match any filter */\n  exclude?: PayloadFilters;\n  /**\n   * \"keep\" (default) sends the prerequisites of what is kept even when the\n   * filters remove them, so the client evaluates the same as the full payload.\n   * \"filter\" applies the filters to them too.\n   */\n  prerequisites?: \"keep\" | \"filter\";\n};\n\n// Polyfills required for non-standard browser environments (ReactNative, Node, etc.)\n// These are typed as `any` since polyfills like `node-fetch` are not 100% compatible with native types\nexport type Polyfills = {\n  fetch: any;\n  SubtleCrypto: any;\n  EventSource: any;\n  localStorage?: LocalStorageCompat;\n};\n\nexport type Helpers = {\n  fetchFeaturesCall: ({\n    host,\n    clientKey,\n    headers,\n  }: {\n    host: string;\n    clientKey: string;\n    headers?: Record<string, string>;\n  }) => Promise<Response>;\n  fetchRemoteEvalCall: ({\n    host,\n    clientKey,\n    payload,\n    headers,\n  }: {\n    host: string;\n    clientKey: string;\n\n    payload: any;\n    headers?: Record<string, string>;\n  }) => Promise<Response>;\n  eventSourceCall: ({\n    host,\n    clientKey,\n    headers,\n  }: {\n    host: string;\n    clientKey: string;\n    headers?: Record<string, string>;\n  }) => EventSource;\n  startIdleListener: () => (() => void) | void;\n  stopIdleListener: () => void;\n};\n\nexport interface LocalStorageCompat {\n  getItem(key: string): string | null | Promise<string | null>;\n  setItem(key: string, value: string): void | Promise<void>;\n}\n\nexport type CacheSettings = {\n  backgroundSync: boolean;\n  cacheKey: string;\n  staleTTL: number;\n  maxAge: number;\n  maxEntries: number;\n  disableIdleStreams: boolean;\n  idleStreamInterval: number;\n  disableCache: boolean;\n};\n\nexport type ApiHost = string;\nexport type ClientKey = string;\n\nexport type InitOptions<\n  AppFeatures extends Record<string, any> = Record<string, any>,\n> = {\n  timeout?: number;\n  skipCache?: boolean;\n  payload?: FeatureApiResponse<AppFeatures>;\n  /** Used when the fetch fails or times out and there is no cached payload, e.g. a copy bundled at build time. */\n  fallbackPayload?: FeatureApiResponse<AppFeatures>;\n  streaming?: boolean;\n  /** Refresh the payload on this interval (ms). Ignored when streaming is active. */\n  pollingInterval?: number;\n  cacheSettings?: CacheSettings;\n};\n\nexport type InitSyncOptions<\n  AppFeatures extends Record<string, any> = Record<string, any>,\n> = {\n  payload: FeatureApiResponse<AppFeatures>;\n  streaming?: boolean;\n  /** Refresh the payload on this interval (ms). Ignored when streaming is active. */\n  pollingInterval?: number;\n};\n\nexport type LoadFeaturesOptions = {\n  /** @deprecated */\n  autoRefresh?: boolean;\n  timeout?: number;\n  skipCache?: boolean;\n};\n\nexport type RefreshFeaturesOptions = {\n  timeout?: number;\n  skipCache?: boolean;\n};\n\nexport type DestroyOptions = {\n  destroyAllStreams?: boolean;\n};\n\nexport interface Filter<A extends Attributes = any> {\n  // Override the hashAttribute used for this filter\n  attribute?: AttributeKey<A>;\n  // The hash seed\n  seed: string;\n  // The hashing version to use\n  hashVersion: number;\n  // Only include these resulting ranges\n  ranges: VariationRange[];\n}\n\nexport type StickyAttributeKey = string; // `${attributeName}||${attributeValue}`\nexport type StickyExperimentKey = string; // `${experimentId}__{version}`\nexport type StickyAssignments = Record<StickyExperimentKey, string>;\nexport interface StickyAssignmentsDocument {\n  attributeName: string;\n  attributeValue: string;\n  assignments: StickyAssignments;\n}\n\n/** The v1 shape: an ID list's values. New code should use SavedGroupsPayload. */\nexport type SavedGroupsValues = Record<string, (string | number)[]>;\n\n/** The savedGroupReferencesV2 shape of one saved group, of any type. */\nexport type SavedGroupPayloadEntry<A extends Attributes = any> =\n  | {\n      type: \"list\";\n      attributeKey: AttributePath<A>;\n      values: (string | number)[];\n    }\n  | { type: \"condition\"; condition: ConditionInterface<A> }\n  // IDs live outside the payload; see `SavedGroupResolver`\n  | {\n      type: \"remote\";\n      attributeKey: AttributePath<A>;\n      /**\n       * Set on a derived group (ID `<group id>:<attribute>`): the remote group\n       * whose IDs `attributeKey`'s value is looked up in.\n       */\n      valuesFrom?: string;\n    };\n\n/** A remote saved group from the payload, as a resolver sees it. */\nexport type RemoteSavedGroup = {\n  id: string;\n  attributeKey: string;\n  /** For a derived group, the remote group whose IDs it checks. */\n  valuesFrom?: string;\n};\n\n/**\n * Looks up which of `groups` a user is in, from their `attributes` (only the\n * ones remote groups use). Returns the group IDs.\n */\nexport type SavedGroupResolver = (args: {\n  attributes: Attributes;\n  groups: RemoteSavedGroup[];\n}) => Promise<string[]>;\n\n/** The `savedGroups` payload field. Entries may use either shape above. */\nexport type SavedGroupsPayload<A extends Attributes = any> = Record<\n  string,\n  (string | number)[] | SavedGroupPayloadEntry<A>\n>;\n\nexport type BaseLog = {\n  timestamp: string;\n};\n\nexport type EventLog = BaseLog & {\n  logType: \"event\";\n  eventName: string;\n  properties?: Record<string, unknown>;\n};\nexport type ExperimentLog<T> = BaseLog & {\n  logType: \"experiment\";\n  experiment: Experiment<T>;\n  result: Result<T>;\n};\nexport type FeatureLog = BaseLog & {\n  logType: \"feature\";\n  featureKey: string;\n  result: FeatureResult;\n};\n\nexport type LogUnion = EventLog | ExperimentLog<any> | FeatureLog;\n"],"mappings":"","ignoreList":[]}