{"version":3,"file":"core.mjs","names":[],"sources":["../src/core.ts"],"sourcesContent":["// main\nimport { FixedLengthArray, valuesOf } from '@transcend-io/type-utils';\n// external\nimport * as t from 'io-ts';\n\n// local\nimport { SpecialTrackingPurpose, ViewState } from './enums/index.js';\n\n/* eslint-disable max-lines */\n\n/** Transcend logger items */\nexport type LogItem = {\n  /** Log item content */\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  content: any;\n  /** Log item styles */\n  styles: string[];\n};\n\n/** Transcend logger entry tag */\nexport type LogTag = LogItem & {\n  /** Log tag content must be a string */\n  content: string;\n  /** Log tags must have only one style */\n  styles: string[1];\n};\n\n/** Transcend logger entry message */\nexport type LogMessage = LogItem;\n\n/** Console-safe log levels */\nexport const ConsoleSafeLogLevel = t.keyof({\n  info: null,\n  log: null,\n  warn: null,\n  debug: null,\n  error: null,\n  trace: null,\n  // meta-levels:\n  group: null,\n  groupCollapsed: null,\n  groupEnd: null,\n});\n\n/** Override type */\nexport type ConsoleSafeLogLevel = t.TypeOf<typeof ConsoleSafeLogLevel>;\n\n/** Airgap log levels */\nexport const LogLevel = t.union([ConsoleSafeLogLevel, t.literal('fatal')]);\n/** Override type */\nexport type LogLevel = t.TypeOf<typeof LogLevel>;\n\n/** Airgap logger entry types */\nexport type LogEntryType = LogLevel;\n\n/** Airgap logger entries */\nexport type LogEntry = {\n  /** Log entry tag */\n  tag: LogTag;\n  /** Log entry message */\n  message: LogMessage;\n};\n\n/**\n * Log emitter function\n */\nexport type LogEmitter = {\n  /** Styled log emitter function */\n  styled(styles?: null | string | string[], ...entries: any[]): void; // eslint-disable-line @typescript-eslint/no-explicit-any,max-len\n} & ((...entries: any[]) => void); // eslint-disable-line @typescript-eslint/no-explicit-any\n\n/** Transcend Logger API */\nexport type Logger = {\n  /**\n   * Set log tag during callback execution or from\n   * this point on if no callback is provided.\n   */\n  tag(logTag: string, callback?: () => any): void; // eslint-disable-line @typescript-eslint/no-explicit-any\n} & {\n  /** Log emitter (e.g. `logger.log()`) */\n  [method in LogLevel]: LogEmitter;\n};\n\n/** AirgapAuth auth options */\nexport type AirgapAuthMap = {\n  /** A `load` event from a just-loaded airgap.js script element (which implies auth by being loaded before airgap.js) */\n  load?: Event;\n  /** A user-initiated interaction event that was just dispatched. */\n  interaction?: Event;\n  /** Automatically reload the page if needed to remove CSP. `false` by default. */\n  autoReload?: boolean;\n  /**\n   * Additional authorization key automatically conferred by airgap.js via setAuth() API for UI modules.\n   * Required when optional strict authorization mode is enabled.\n   */\n  key?: symbol;\n};\n\n/** Airgap authorization proof */\nexport type AirgapAuth =\n  | null\n  | AirgapAuthMap\n  /**\n   * A user-initiated interaction event that was just dispatched, or\n   * a `load` event from a just-loaded airgap.js script element (which implies auth by being loaded before airgap.js).\n   */\n  | Event;\n\n/** A boolean value represented as either `'on'` or `'off'` */\nexport const BooleanString = t.keyof({\n  on: null,\n  off: null,\n});\n/** Type override */\nexport type BooleanString = t.TypeOf<typeof BooleanString>;\n\n/** Data privacy legal regimes */\nexport type PrivacyRegime = string;\n\nexport interface GetPurposeTypesOptions {\n  /** Regimes to include */\n  regimes?: PrivacyRegime[];\n  /** Privacy signals to include */\n  signals?: UserPrivacySignal[];\n}\n\n/**\n * Regime to purpose scope map\n */\nexport type RegimeToPurposeScopes = [PrivacyRegime[], TrackingPurpose[]][];\n\n/** Reserved metadata, currently used for airgap module data syncing */\nexport interface ReservedMetadata {\n  /** Top-level key to avoid polluting the metadata key space */\n  tcmp?: Record<string, unknown>;\n}\n\n/**\n * Extra metadata to be synced along with consent\n */\nexport type Metadata = Record<string, unknown>;\n\n/** setConsent() options */\nexport interface ConsentOptions {\n  /** Was consent confirmed by the user? */\n  confirmed?: boolean;\n  /**\n   * Was the UI shown to the user?\n   * @deprecated It was discovered that this value was not being set reliably in some versions, and was not being used.\n   */\n  prompted?: boolean;\n  /**\n   * Extra metadata to be synced along with consent\n   *\n   * Special values:\n   * - `null` - Do not change metadata\n   * - `false` - Clear metadata\n   */\n  metadata?: (Metadata & ReservedMetadata) | null | false;\n  /** Last updated for metadata */\n  metadataTimestamp?: string;\n  /** Whether or not to return a Promise so that the caller can wait for sync to complete. By default, we do not wait for sync */\n  waitForSync?: boolean;\n  /** Last updated */\n  timestamp?: string;\n}\n\n/** airgap.toggle() options */\nexport type AirgapToggleOptions =\n  /** Protection state */\n  | boolean\n  | {\n      /** Protection state */\n      protection?: boolean;\n    };\n\n/** airgap.status format */\nexport interface AirgapSystemStatus {\n  /** Protection system active state */\n  protection: boolean;\n  /** Have any CSPs been activated? */\n  csp: boolean;\n  /** Monitoring system active state */\n  monitoring: boolean;\n  /** Telemetry system active state */\n  telemetry: boolean;\n}\n\n/**\n * Request override config\n */\nexport interface RequestOverride {\n  /** Optional tracking purposes to gate the override with lack of consent */\n  unconsented?: TrackingPurpose[];\n  /**\n   * Optional request matcher. This is a RegExp object (or string input\n   * for the RegExp constructor). Overrides apply to all requests\n   * when this is undefined.\n   */\n  matcher?: RegExp | string;\n  /** Override executor function or replacement string */\n  override: string | ((request: IPendingEvent, matcher?: RegExp) => void);\n  /** Name */\n  name?: string;\n  /** Note */\n  note?: string;\n  /** Description */\n  description?: string;\n}\n\n/** Airgap watcher */\nexport type AirgapWatcher = (request: IPendingEvent) => void;\n\n/**\n * Cookie override handler. This function can modify attempted cookie mutations.\n */\nexport type CookieOverride = (event: IPendingCookieMutation) => void;\n\n/**\n * Passive cookie watcher. This function can view attempted cookie mutations in a read-only state.\n */\nexport type CookieWatcher = (event: IPendingCookieMutation) => void;\n\n/** Event types (for purpose resolution) */\nexport type TrackingEventType = 'request' | 'cookie';\n\n/** Airgap sync types */\nexport type AirgapSyncType = 'consent' | 'quarantine';\n\n/** airgap.sync() options */\nexport interface SyncOptions {\n  /** types of data to sync */\n  sync?: AirgapSyncType[];\n  /** reset synchronized data (default: false) */\n  reset?: boolean;\n  /** sync locally (i.e. XDI) */\n  local?: boolean;\n  /** sync with remote endpoint */\n  backend?: boolean;\n  /** signed authentication token to link consent with encrypted identifier */\n  auth?: string;\n}\n\n/** airgap.js API */\nexport type AirgapAPI = Readonly<{\n  /** Embedded request watchers */\n  watchers?: AirgapWatcher[];\n  /** Embedded request overrides (must specify pre-init) */\n  overrides?: RequestOverride[];\n  /** Embedded request overrides (must specify pre-init) */\n  cookieOverrides?: CookieOverride[];\n  /** Airgap ready event subscriber */\n  ready(callback: (airgap: AirgapAPI) => void): void;\n  /** Queue of callbacks to dispatch once airgap is ready */\n  readyQueue?: ((airgap: AirgapAPI) => void)[];\n  /** Enqueue cross-domain data sync across all airgap bundle domains */\n  sync(options?: SyncOptions): Promise<void>;\n  /**\n   * Resolve URL input reserialization post-regulation.\n   * @param resolveOverrides - Resolve overrides. Defaults to true.\n   */\n  resolve(url: Stringifiable, resolveOverrides?: boolean): Stringifiable;\n  /**\n   * Resolve consent status for given tracking purposes. Essential purposes override opted out unessential purposes.\n   *\n   * If `use` is not provided, consent is resolved for both request and cookie tracking event types.\n   * @param trackingPurposes - Tracking purposes to resolve\n   * @param use - Optional event type to use for tracking purpose resolution\n   * @returns `true` if the applicable tracking purposes are consented.\n   */\n  isConsented(trackingPurposes: TrackingPurposes, use?: TrackingEventType): boolean;\n  /** Get tracking consent */\n  getConsent(): TrackingConsentDetails;\n  /** Set tracking consent */\n  setConsent(\n    /** Airgap auth proof */\n    auth: AirgapAuth,\n    /** The tracking consent options. */\n    consent: TrackingConsent,\n    /** Consent options */\n    options?: ConsentOptions,\n  ): Promise<boolean> | boolean;\n  /**\n   * Sets whether or not the Consent UI has been shown to the user\n   * @deprecated It was discovered that this function was not working reliably in some versions, and that the value it set was not being used.\n   */\n  setPrompted(state: boolean): Promise<void>;\n  /** Consents the user to all tracking purposes (requires recent UI interaction) */\n  optIn(\n    /** Airgap auth proof */\n    auth: AirgapAuth,\n  ): boolean;\n  /** Revokes consent for all tracking purposes (requires recent UI interaction) */\n  optOut(\n    /** Airgap auth proof */\n    auth: AirgapAuth,\n  ): boolean;\n  /** Returns true if the user is fully-opted in to all first-order tracking purposes */\n  isOptedIn(): boolean;\n  /** Returns true if the user is fully-opted out to all first-order tracking purposes */\n  isOptedOut(): boolean;\n  /** Resolve regime tracking purposes. If no regimes are provided, then the user's detected regimes are used */\n  getRegimePurposes(regimes?: Set<PrivacyRegime>): Set<TrackingPurpose>;\n  /** Get initialized tracking purposes config */\n  getPurposeTypes(): TrackingPurposesTypes;\n  /** Override pending requests */\n  override(auth: AirgapAuth, ...overrides: RequestOverride[]): Removable;\n  /** Override cookies */\n  overrideCookies(auth: AirgapAuth, handler: (event: IPendingCookieMutation) => void): Removable;\n  /** Listen to pending requests passively */\n  watch(watcher: AirgapWatcher): Removable;\n  /** Listen to cookies passively */\n  watchCookies(watcher: CookieWatcher): Removable;\n  /** Clear airgap queue & caches. Returns `true` on success. */\n  clear(auth: AirgapAuth): boolean;\n  /** Reset airgap queue and consent. Returns `true` on success. */\n  reset(\n    /** An airgap auth proof */\n    auth: AirgapAuth,\n    /** Automatically reload the page if needed to remove CSP. */\n    autoReload?: boolean,\n  ): boolean;\n  /** Check whether a URL is allowed to be loaded */\n  isAllowed(\n    /** URL to evaluate */\n    url: Stringifiable,\n    /** Should overrides be resolved? true by default */\n    resolveOverrides?: boolean,\n  ): Promise<boolean>;\n  /** Check whether a cookie is allowed to be set */\n  isCookieAllowed(\n    /** IPendingCookieMutation-like object to evaluate */\n    cookie: string | IPendingCookieMutation | PendingCookieMutationInit,\n    /** Should overrides be resolved? true by default */\n    resolveOverrides?: boolean,\n  ): Promise<boolean>;\n  /** Check whether a IPendingRequest is allowed to be loaded */\n  isRequestAllowed(\n    /** IPendingEvent to inspect */\n    request: IPendingEvent,\n    /** Should overrides be resolved? true by default */\n    resolveOverrides?: boolean,\n  ): Promise<boolean>;\n  /** Get purposes of URL */\n  getPurposes(\n    /** URL to evaluate */\n    url: Stringifiable,\n    /** Should overrides be resolved? true by default */\n    resolveOverrides?: boolean,\n  ): Promise<TrackingPurposes>;\n  /** Get purposes of IPendingRequest */\n  getRequestPurposes(\n    /** IPendingEvent-like object to inspect */\n    request: string | IPendingEvent | PendingRequestInit,\n    /** Should overrides be resolved? true by default */\n    resolveOverrides?: boolean,\n  ): Promise<TrackingPurposes>;\n  /** Get purposes of a cookie */\n  getCookiePurposes(\n    /** IPendingCookieMutation-like object to evaluate */\n    cookie: string | IPendingCookieMutation | PendingCookieMutationInit,\n    /** Should overrides be resolved? true by default */\n    resolveOverrides?: boolean,\n  ): Promise<TrackingPurposes>;\n  /** Export queues */\n  export(options?: AirgapExportOptions): AirgapQueues;\n  /** Get a list of legal regimes that are potentially applicable to the user */\n  getRegimes(): Set<PrivacyRegime>;\n  /** Get a list of detected active user agent privacy signals */\n  getPrivacySignals(): Set<UserPrivacySignal>;\n  /** Toggle all airgap.js protections. Auth must be a pre-airgap.js or airgap.js script 'load' event. Returns success status */\n  toggle(auth: AirgapAuth, options?: AirgapToggleOptions): boolean;\n  /** Current airgap.js system flags */\n  status: AirgapSystemStatus;\n  /** airgap.js version number */\n  version: string;\n  /** override the event listener signature for consent change events */\n  addEventListener: (\n    type: AirgapConsentEventType,\n    callback: ((evt: ConsentChangeEventPayload) => void) | null,\n    options?: boolean | AddEventListenerOptions | undefined,\n  ) => void;\n}> &\n  EventTarget;\n\n/** airgap.export() options */\nexport interface AirgapExportOptions {\n  /** Send output to web endpoint */\n  endpoint?: string;\n  /** JSON pretty-print indentation (default: 0) */\n  space?: number;\n  /** Save output to disk (default: off) */\n  save?: boolean;\n  /** Filename for saving to disk */\n  filename?: string;\n}\n\n/** Exported airgap queues & consent */\nexport type AirgapQueues = Readonly<{\n  /** airgap.js version number */\n  version: string;\n  /** Current user consent details */\n  consent: TrackingConsentDetails;\n  /** Navigation page URL */\n  url: Stringifiable;\n  /** Pending requests */\n  requests: PendingRequestDescriptor[];\n  /** Pending mutations (same-session-only replay) */\n  mutations: PendingMutationDescriptor[];\n  /** Pending cookies */\n  cookies: PendingCookieMutationDescriptor[];\n  /** Pending cookies (same-session-only replay) */\n  cookieMutations: PendingCookieMutationDescriptor[];\n  /** Sent requests */\n  sentRequests?: PendingRequestDescriptor[];\n  /** Set cookies */\n  setCookies?: PendingCookieMutationDescriptor[];\n}>;\n\n/**\n * Airgap event types that send the ConsentChangeEventDetails object with them\n */\nexport type AirgapConsentEventType = 'consent-change' | 'sync' | 'consent-resolution';\n\n/**\n * airgap.js event type\n */\nexport type AirgapEventType = AirgapConsentEventType | 'purpose-map-load';\n\nexport interface ConsentChangeEventPayload {\n  /** consent change event details */\n  detail: ConsentChangeEventDetails;\n}\n\n/** 'consent-change' custom event details */\nexport type ConsentChangeEventDetails = {\n  /** The old tracking consent */\n  oldConsent: TrackingConsentDetails | null;\n  /** The new tracking consent */\n  consent: TrackingConsentDetails | null;\n  /** The tracking consent diff (what's changed in the new consent) */\n  changes: Record<string, boolean> | null;\n  /** Applicable privacy signals contributing to this consent change event */\n  signals?: Set<UserPrivacySignal> | null;\n};\n\n/** Removable process (can remove watchers, overrides, and protections) */\nexport type Removable = {\n  /** Remove/revoke process */\n  remove(): void;\n};\n\n/** Any value which implements `toString()` */\nexport type Stringifiable =\n  | string\n  | (string & {\n      toString(): string;\n    });\n\n/** Special `defaultConsent` automatic opt-out value for any potential reason */\nexport const AutoOptOut = t.literal('Auto');\n/** Type override */\nexport type AutoOptOut = t.TypeOf<typeof AutoOptOut>;\n\n/** Special `defaultConsent` automatic opt-out value for GDPR-protected users */\nexport const AutoOptOutForGDPR = t.literal('AutoGDPR');\n/** Type override */\nexport type AutoOptOutForGDPR = t.TypeOf<typeof AutoOptOutForGDPR>;\n\n/**\n * Special `defaultConsent` automatic opt-out value for users with DNT enabled.\n * Note that DNT is enabled by default for some browsers.\n */\nexport const AutoOptOutForDNT = t.literal('AutoDNT');\n/** Type override */\nexport type AutoOptOutForDNT = t.TypeOf<typeof AutoOptOutForDNT>;\n\n/**\n * Special `defaultConsent` automatic opt-out value for users with GPC enabled.\n */\nexport const AutoOptOutForGPC = t.literal('AutoGPC');\n/** Type override */\nexport type AutoOptOutForGPC = t.TypeOf<typeof AutoOptOutForGPC>;\n\n/** Potential values for `defaultConsent` config token list */\nexport const DefaultConsentConfigValue = t.union([\n  t.boolean,\n  AutoOptOut,\n  AutoOptOutForGDPR,\n  AutoOptOutForDNT,\n  AutoOptOutForGPC,\n  BooleanString,\n]);\n/** Type override */\nexport type DefaultConsentConfigValue = t.TypeOf<typeof DefaultConsentConfigValue>;\n\n/** User-configurable user agent privacy signal */\nexport const UserPrivacySignal = t.union([\n  /** Global Privacy Control */\n  t.literal('GPC'),\n  /** Do Not Track */\n  t.literal('DNT'),\n]);\n\n/** type overload */\nexport type UserPrivacySignal = t.TypeOf<typeof UserPrivacySignal>;\n\n/** Tracking purpose metadata */\nexport const TrackingPurposeDetails = t.intersection([\n  t.type({\n    /** Tracking purpose name */\n    name: t.string,\n    /** Tracking purpose description (used in Consent Manager UI) */\n    description: t.string,\n    /** Tracking purpose default consent (default: false) */\n    defaultConsent: DefaultConsentConfigValue,\n    /**\n     * Is this a first-order tracking purpose? If false, this is a\n     * second-order tracking purpose that should only be used for\n     * request overrides.\n     *\n     * This parameter previously meant:\n     *   Show tracking purpose in consent manager UI.\n     *\n     * Default value: true\n     */\n    showInConsentManager: t.boolean,\n    /** Allow user to configure their consent for this purpose (default: true) */\n    configurable: t.boolean,\n    /** Is tracking purpose \"essential\" - i.e. consent is mandatory / equivalent to 'essential' permission (default: false) */\n    essential: t.boolean,\n  }),\n  t.partial({\n    /** Tracking type */\n    trackingType: t.string,\n    /** Respected opt-out privacy signals */\n    optOutSignals: t.array(UserPrivacySignal),\n  }),\n]);\n/** Type override */\nexport type TrackingPurposeDetails = t.TypeOf<typeof TrackingPurposeDetails>;\n\n/** Tracking purposes types configuration */\nexport const TrackingPurposesTypes = t.record(t.string, TrackingPurposeDetails);\n/** Type override */\nexport type TrackingPurposesTypes = t.TypeOf<typeof TrackingPurposesTypes>;\n\n/** Fully-resolved `defaultConsent` config */\nexport const DefaultConsentConfig = t.record(t.string, DefaultConsentConfigValue);\n/** Type override */\nexport type DefaultConsentConfig = t.TypeOf<typeof DefaultConsentConfig>;\n\n/** Tracking purposes configuration */\nexport const TrackingPurposesConfig = t.intersection([\n  t.type({\n    /** Inherit default tracking purposes config */\n    useDefault: t.boolean,\n    types: TrackingPurposesTypes,\n  }),\n  t.partial({\n    defaultConsent: t.union([DefaultConsentConfigValue, DefaultConsentConfig]),\n  }),\n]);\n\n/** Type override */\nexport type TrackingPurposesConfig = {\n  /** Inherit default tracking purposes config (Functional, Advertising, Analytics) */\n  useDefault: boolean;\n  /** Tracking purpose types */\n  types: TrackingPurposesTypes;\n  /** Default consent states (takes precedence over `TrackingPurposesTypes[purpose].defaultConsent`) */\n  defaultConsent?: DefaultConsentConfigValue | DefaultConsentConfig;\n};\n\nexport const TrackingConsent = t.intersection([\n  t.partial({\n    Essential: t.literal(true),\n    Unknown: t.literal(false),\n  }),\n  t.record(t.string, t.union([DefaultConsentConfigValue, t.undefined])),\n]);\n/**\n * Type override\n */\nexport type TrackingConsent = t.TypeOf<typeof TrackingConsent>;\n\nexport const TrackingConsentWithNulls = t.record(t.string, t.union([TrackingConsent, t.null]));\n/** Type override */\nexport type TrackingConsentWithNulls = t.TypeOf<typeof TrackingConsentWithNulls>;\n\nconst TCFReservedMetadata = t.partial({\n  tcString: t.string,\n});\n\nconst ReservedMetadataCodec = t.partial({\n  tcmp: t.partial({\n    tcf: TCFReservedMetadata,\n  }),\n});\n\nexport const CoreTrackingConsentDetails = t.intersection([\n  t.type({\n    /**\n     * Was tracking consent confirmed by the user?\n     * If this is false, the consent was resolved from defaults & is not yet confirmed\n     */\n    confirmed: t.boolean,\n    /** Consent resolution/last-modified timestamp (ISO 8601) */\n    timestamp: t.string,\n  }),\n  t.partial({\n    /** Has the consent been updated (including no-change confirmation) since default resolution */\n    updated: t.boolean,\n    /**\n     * Whether or not the UI has been shown to the end-user (undefined in older versions of airgap.js)\n     * @deprecated It was discovered that this value was not being set reliably in some versions, and was not being used.\n     */\n    prompted: t.boolean,\n    /** Arbitrary metadata that customers want to be associated with consent state */\n    metadata: t.intersection([ReservedMetadataCodec, t.UnknownRecord]),\n    /** When the metadata was last updated */\n    metadataTimestamp: t.string,\n  }),\n]);\n\n/** Type override */\nexport type CoreTrackingConsentDetails = t.TypeOf<typeof CoreTrackingConsentDetails>;\n\nexport const TrackingConsentDetails = t.intersection([\n  CoreTrackingConsentDetails,\n  t.type({\n    /** Tracking consent config */\n    purposes: TrackingConsent,\n  }),\n]);\n\n/** Override types. */\nexport type TrackingConsentDetails = t.TypeOf<typeof TrackingConsentDetails>;\n\nexport const TrackingConsentOptionalData = t.partial({\n  /** Transparency Consent (TCF) String */\n  tcf: t.string,\n  /** US Privacy (USP) String */\n  usp: t.string,\n  /** Global Privacy Platform (GPP) String */\n  gpp: t.string,\n  /** Consent Manager View State */\n  viewState: valuesOf(ViewState),\n  /** Airgap Version */\n  airgapVersion: t.string,\n});\n\nexport const FullTrackingConsentDetails = t.intersection([\n  TrackingConsentDetails,\n  TrackingConsentOptionalData,\n]);\n\n/** Override types. */\nexport type FullTrackingConsentDetails = t.TypeOf<typeof FullTrackingConsentDetails>;\n\nexport const FullTrackingConsentDetailsWithNulls = t.intersection([\n  CoreTrackingConsentDetails,\n  TrackingConsentOptionalData,\n  t.type({\n    /** Tracking consent config */\n    purposes: TrackingConsentWithNulls,\n  }),\n]);\n\n/** Override types. */\nexport type FullTrackingConsentDetailsWithNulls = t.TypeOf<\n  typeof FullTrackingConsentDetailsWithNulls\n>;\n\nexport const ConsentPreferencesBody = t.type({\n  /** token containing encrypted identifier */\n  token: t.string,\n  /** consent partition (defaults to bundle id) */\n  partition: t.string,\n  /** user consent */\n  consent: TrackingConsentDetails,\n});\n\n/** Override types. */\nexport type ConsentPreferencesBody = t.TypeOf<typeof ConsentPreferencesBody>;\n\nexport const ConsentTokenPayload = t.intersection([\n  t.type({\n    encryptedIdentifier: t.string,\n  }),\n  t.partial({\n    deprecatedEncryptedIdentifiers: t.array(t.string),\n  }),\n]);\n\n/** Type override */\nexport type ConsentTokenPayload = t.TypeOf<typeof ConsentTokenPayload>;\n\n/** Tracking purpose */\nexport const TrackingPurpose = t.union([t.keyof(SpecialTrackingPurpose), t.string]);\n\n/** Type override */\nexport type TrackingPurpose = t.TypeOf<typeof TrackingPurpose>;\n\n/** Tracking purposes */\nexport type TrackingPurposes = Set<TrackingPurpose>;\n\n/** Tracking consent change diffs */\nexport const ConsentChange = t.record(TrackingPurpose, t.boolean);\n\n/** type overload */\nexport type ConsentChange = t.TypeOf<typeof ConsentChange>;\n\n/** Regime purpose scopes configuration */\nexport const RegimePurposeScopesConfig = t.array(FixedLengthArray(2, 2, t.array(t.string)));\n\n/** Type override */\nexport type RegimePurposeScopesConfig = [\n  /** Regimes */\n  regimes: string[],\n  /** In-scope purposes */\n  purposes: TrackingPurpose[],\n][];\n\n/** Request source types */\nexport type AirgapRequestSource =\n  | 'unknown'\n  | 'airgap.js' // emitted by airgap.isAllowed(), etc.\n  | 'fetch'\n  | 'xhr'\n  | 'websocket'\n  | 'webtransport'\n  | 'service-worker'\n  | 'shared-worker'\n  | 'worker'\n  | 'module-worker'\n  | 'shared-module-worker'\n  | 'eventsource'\n  | 'beacon'\n  | 'CSPV'\n  | 'navigation'\n  | 'open'\n  | 'script'\n  | AirgapDOMRequestSource;\n\n/** DOM-initiated request source types */\nexport type AirgapDOMRequestSource =\n  | 'DOM:style'\n  | 'DOM:image'\n  | 'DOM:media'\n  | 'DOM:video'\n  | 'DOM:audio'\n  | 'DOM:track'\n  | 'DOM:link'\n  | 'DOM:form'\n  | 'DOM:form-action'\n  | 'DOM:view' // iframe {srcdoc, src}, object, embed\n  | 'DOM:ping'\n  | 'DOM:unknown';\n\n/**\n * Airgap pending request descriptor init dictionary\n */\nexport interface PendingRequestInit {\n  /** Request initiator type */\n  type: AirgapRequestSource;\n  /** Request URL */\n  url: Stringifiable;\n  /** Persist request for cross-session replay (false by default) */\n  persist?: boolean;\n  /** Request initialization data */\n  requestInit?: RequestInit;\n  /** Request timestamp (ISO 8601) */\n  timestamp?: Stringifiable;\n  /** Request DOM target */\n  target?: Node | IDynamicNodeReference | null;\n  /** Mutator to apply changes associated with the request */\n  mutator?(): void;\n  /** Serialize request or mutation state back to DOM patcher parser input */\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  serialize?(): any;\n  /** Prevent credentials from being included in request */\n  omitCredentials?(): boolean;\n}\n\n/** Properties that are added to instantiated PendingRequests */\nexport interface InstantiatedPendingRequestProps {\n  /** Primary or first associated request URL input */\n  url: Stringifiable;\n  /** All associated request URL inputs */\n  urls: Stringifiable[];\n  /** Request timestamp (ISO 8601) */\n  timestamp: Stringifiable;\n  /** Serialize request or mutation state back to DOM patcher parser input */\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  serialize(): any;\n\n  /** The following IPendingEvent APIs are only available to overrides: */\n\n  /**\n   * All associated resolved request URLs. null = invalid URL or data: URL (parsing\n   * skipped to optimize performance)\n   */\n  URLs: (URL | null)[];\n  /** Prevent credentials from being included in request */\n  omitCredentials(): boolean;\n  /** Whether or not request is currently allowed */\n  allowed: boolean;\n  /** Bypass our consent logic and force-allow request */\n  allow(): void;\n  /** Bypass our consent logic and force-deny request */\n  deny(): void;\n  /** Bypass our consent logic to force-deny request and also block it from entering the replay quarantine */\n  block(): void;\n  /** Resolved tracking purposes associated with this pending mutation */\n  purposes: Set<TrackingPurpose>;\n}\n\n/**\n * Airgap pending request descriptor with script annotation\n */\nexport type PendingRequestDescriptor = PendingRequestInit & InstantiatedPendingRequestProps;\n\n/** Airgap pending request descriptor init with multiple URLs */\nexport type PendingMutationInit = Omit<PendingRequestInit, 'url'> & {\n  /** Request URLs */\n  urls: Stringifiable[];\n};\n\n/** PendingEvent init input */\nexport type PendingEventInit = PendingRequestInit | PendingMutationInit;\n\n/** Pending mutation descriptor */\nexport type PendingMutationDescriptor = PendingMutationInit & InstantiatedPendingRequestProps;\n\n/** Pending event props that can't or won't be serialized to JSON */\ntype PendingEventUnserializableProps =\n  | 'persist'\n  | 'target'\n  | 'mutator'\n  | 'serialize'\n  | 'URLs'\n  | 'omitCredentials'\n  | 'allow'\n  | 'deny'\n  | 'purposes'\n  | 'allowed'\n  | 'blocked';\n\n/** JSON-safe representation of pending event tracking purposes */\ninterface PendingEventPurposesJSON {\n  /** Tracking purposes list */\n  purposes?: TrackingPurpose[];\n}\n\n/** Pending request subset to JSON-safe properties */\nexport type PendingRequestJSON = Omit<\n  PendingRequestDescriptor,\n  PendingEventUnserializableProps | 'urls'\n> &\n  PendingEventPurposesJSON;\n\n/** Pending mutation subset to JSON-safe properties */\nexport type PendingMutationJSON = Omit<\n  PendingMutationDescriptor,\n  PendingEventUnserializableProps | 'url'\n> &\n  PendingEventPurposesJSON;\n\n/** Airgap pending request interface */\nexport interface IPendingRequest extends PendingRequestDescriptor {\n  /** Convert PendingRequest to JSON-safe representation */\n  toJSON(): PendingRequestJSON;\n}\n\n/** Airgap pending mutation interface */\nexport interface IPendingMutation extends PendingMutationDescriptor {\n  /** Convert PendingRequest to JSON-safe representation */\n  toJSON(): PendingMutationJSON;\n}\n\n/** Pending event descriptor */\nexport type PendingEventDescriptor = PendingRequestDescriptor | PendingMutationDescriptor;\n\n/** Pending request or mutation */\nexport type IPendingEvent = IPendingMutation | IPendingRequest;\n\n/** Unapproved request queue */\nexport type PendingRequestQueue = IPendingRequest[];\n\n/** Unapproved mutation queue */\nexport type PendingMutationQueue = IPendingEvent[];\n\n/** Unapproved event queue */\nexport type PendingEventQueue = IPendingEvent[];\n\n/** Cookie descriptor */\nexport interface Cookie {\n  /** Cookie name */\n  name: Stringifiable;\n  /** Cookie value */\n  value?: Stringifiable;\n  /** Cookie change event timestamp (ISO 8601) */\n  timestamp?: string;\n  /** Expiry date (UTC date string or DOMTimeStamp) */\n  expires?: number | Stringifiable;\n  /** Max cookie age (seconds) */\n  maxAge?: number;\n  /** Optional cookie host scope */\n  domain?: Stringifiable;\n  /** Optional cookie path scope */\n  path?: Stringifiable;\n  /** Should cookie only be sent in secure contexts? */\n  secure?: boolean;\n  /**\n   * Should cookie be restricted to the same site?\n   * Values: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite\n   */\n  sameSite?: Stringifiable;\n  /**\n   * Is the cookie partitioned (e.g. by CHIPS)?\n   * See https://developer.mozilla.org/en-US/docs/Web/Privacy/Partitioned_cookies\n   * and https://developer.mozilla.org/en-US/docs/Web/API/CookieStore/get#:~:text=of%20the%20cookie.-,partitioned,-A%20boolean%20indicating\n   */\n  partitioned?: boolean;\n  /** Target document / node */\n  target?: Node | null;\n}\n\n/**\n * PendingCookieMutation constructor input\n */\nexport interface PendingCookieMutationInit extends Cookie {\n  /** Persist cookie for cross-session replay if quarantined (true by default) */\n  persist?: boolean;\n  /** Mutator to apply cookie mutation */\n  mutator?(): void | Promise<void>;\n}\n\n/** Properties that are added to instantiated PendingCookieMutations */\nexport interface InstantiatedPendingCookieMutationProps {\n  /** Expiry date (DOMTimeStamp) */\n  expires?: number;\n  /** Cookie change event timestamp (Date.now() format) */\n  timestamp: string;\n  /** Whether or not cookie is currently allowed. null = passthrough */\n  allowed?: boolean | null;\n  /** Whether or not cookie is currently disallowed & blocked from entering the quarantine */\n  blocked?: boolean;\n  /** Bypass our consent logic and force-allow cookie */\n  allow(): void;\n  /** Bypass our consent logic and force-deny cookie */\n  deny(): void;\n  /** Bypass our consent logic to force-deny cookie and also block it from entering the quarantine */\n  block(): void;\n  /** Resolved tracking purposes associated with this pending mutation */\n  purposes: Set<TrackingPurpose>;\n  /** Mutator to apply cookie mutation */\n  mutator(): void | Promise<void>;\n}\n\n/** Pending cookie mutation descriptor */\nexport type PendingCookieMutationDescriptor = Omit<PendingCookieMutationInit, 'expires'> &\n  InstantiatedPendingCookieMutationProps;\n\n/** Pending cookie mutation props that can't or won't be serialized to JSON */\ntype PendingCookieMutationUnserializableProps =\n  | 'persist'\n  | 'mutator'\n  | 'allow'\n  | 'deny'\n  | 'purposes'\n  | 'allowed'\n  | 'blocked';\n\n/** JSON-safe representation of pending cookie mutation tracking purposes */\ninterface PendingCookieMutationPurposesJSON {\n  /** Tracking purposes list */\n  purposes?: TrackingPurpose[];\n}\n\n/** Pending request subset to JSON-safe properties */\nexport type PendingCookieMutationJSON = Omit<\n  PendingCookieMutationDescriptor,\n  PendingCookieMutationUnserializableProps\n> &\n  PendingCookieMutationPurposesJSON;\n\n/** Airgap pending cookie mutation interface */\nexport interface IPendingCookieMutation extends PendingCookieMutationDescriptor {\n  /** Convert PendingCookieMutation to JSON-safe representation */\n  toJSON(): PendingCookieMutationJSON;\n}\n\n/** Pending cookie mutation queue */\nexport type PendingCookieQueue = IPendingCookieMutation[];\n\n/** Interface for dynamic node references */\nexport interface IDynamicNodeReference {\n  /**\n   * Current node getter. This should always be used in `handleLiveMutation()`.\n   * @returns current node\n   */\n  getNode(): Element;\n  /**\n   * Live node getter. Use this to apply mutations in `quarantine()`\n   * and `quarantineMutation()` handlers.\n   *\n   * `release()` must always be called after completing\n   * mutations using `getLiveNode()`.\n   * @returns live node\n   */\n  getLiveNode(): Element;\n  /** Release & garbage-collect internal node reference */\n  release(): void;\n}\n\n/* eslint-enable max-lines */\n"],"mappings":";;;;;;AA+BA,MAAa,sBAAsB,EAAE,MAAM;CACzC,MAAM;CACN,KAAK;CACL,MAAM;CACN,OAAO;CACP,OAAO;CACP,OAAO;CAEP,OAAO;CACP,gBAAgB;CAChB,UAAU;CACX,CAAC;;AAMF,MAAa,WAAW,EAAE,MAAM,CAAC,qBAAqB,EAAE,QAAQ,QAAQ,CAAC,CAAC;;AA6D1E,MAAa,gBAAgB,EAAE,MAAM;CACnC,IAAI;CACJ,KAAK;CACN,CAAC;;AA4VF,MAAa,aAAa,EAAE,QAAQ,OAAO;;AAK3C,MAAa,oBAAoB,EAAE,QAAQ,WAAW;;;;;AAQtD,MAAa,mBAAmB,EAAE,QAAQ,UAAU;;;;AAOpD,MAAa,mBAAmB,EAAE,QAAQ,UAAU;;AAKpD,MAAa,4BAA4B,EA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