@amplitude/plugin-session-replay-browser 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,7 +63,7 @@ var SessionReplay = /** @class */ (function () {
63
63
  var _a;
64
64
  return tslib_1.__generator(this, function (_b) {
65
65
  event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), (_a = {}, _a[constants_1.DEFAULT_SESSION_REPLAY_PROPERTY] = true, _a));
66
- if (event.event_type === constants_1.DEFAULT_SESSION_START_EVENT) {
66
+ if (event.event_type === constants_1.DEFAULT_SESSION_START_EVENT && !this.stopRecordingEvents) {
67
67
  this.recordEvents();
68
68
  }
69
69
  else if (event.event_type === constants_1.DEFAULT_SESSION_END_EVENT) {
@@ -105,8 +105,8 @@ var SessionReplay = /** @class */ (function () {
105
105
  currentSessionStoredEvents = this.config.sessionId && storedReplaySessions[this.config.sessionId];
106
106
  this.currentSequenceId = currentSessionStoredEvents ? currentSessionStoredEvents.sequenceId + 1 : 0;
107
107
  void this.storeEventsForSession([], this.currentSequenceId);
108
- this.recordEvents();
109
108
  }
109
+ this.recordEvents();
110
110
  return [2 /*return*/];
111
111
  }
112
112
  });
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;AAAA,4DAA4E;AAC5E,8DAA0E;AAC1E,4DAAwC;AACxC,+BAAqC;AACrC,yCAAsH;AACtH,uCAAsH;AAStH,IAAM,yBAAyB,GAAG,iDAAiD,CAAC;AACpF,IAAM,cAAc,GAAG,UAAG,iCAAgB,mBAAgB,CAAC;AAC3D,IAAM,8CAA8C,GAAG,GAAG,CAAC,CAAC,iEAAiE;AAC7H,IAAM,4BAA4B,GAAG,EAAE,GAAG,OAAO,GAAG,8CAA8C,CAAC;AACnG,IAAM,YAAY,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,WAAW;AAC1C,IAAM,YAAY,GA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,aAAA,EACP,oBAAmB,EAAnB,YAAY,mBAAG,IAAI,KAAA;QAOnB,YAAY,IAAI,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACtF,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACvC;aAAM,IAAI,OAAO,EAAE;YAClB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACzC;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AAlTD,IAkTC;AAEM,IAAM,mBAAmB,GAAwB;IACtD,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B","sourcesContent":["import { AMPLITUDE_PREFIX, BaseTransport } from '@amplitude/analytics-core';\nimport { BrowserConfig, Event, Status } from '@amplitude/analytics-types';\nimport * as IDBKeyVal from 'idb-keyval';\nimport { pack, record } from 'rrweb';\nimport { DEFAULT_SESSION_END_EVENT, DEFAULT_SESSION_REPLAY_PROPERTY, DEFAULT_SESSION_START_EVENT } from './constants';\nimport { MAX_RETRIES_EXCEEDED_MESSAGE, STORAGE_FAILURE, SUCCESS_MESSAGE, UNEXPECTED_ERROR_MESSAGE } from './messages';\nimport {\n Events,\n IDBStore,\n SessionReplayContext,\n SessionReplayEnrichmentPlugin,\n SessionReplayPlugin,\n} from './typings/session-replay';\n\nconst SESSION_REPLAY_SERVER_URL = 'https://api-secure.amplitude.com/sessions/track';\nconst STORAGE_PREFIX = `${AMPLITUDE_PREFIX}_replay_unsent`;\nconst PAYLOAD_ESTIMATED_SIZE_IN_BYTES_WITHOUT_EVENTS = 200; // derived by JSON stringifying an example payload without events\nconst MAX_EVENT_LIST_SIZE_IN_BYTES = 20 * 1000000 - PAYLOAD_ESTIMATED_SIZE_IN_BYTES_WITHOUT_EVENTS;\nconst MIN_INTERVAL = 1 * 1000; // 1 second\nconst MAX_INTERVAL = 10 * 1000; // 10 seconds\n\nclass SessionReplay implements SessionReplayEnrichmentPlugin {\n name = '@amplitude/plugin-session-replay-browser';\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n storageKey = '';\n retryTimeout = 1000;\n events: Events = [];\n currentSequenceId = 0;\n private scheduled: ReturnType<typeof setTimeout> | null = null;\n queue: SessionReplayContext[] = [];\n stopRecordingEvents: ReturnType<typeof record> | null = null;\n maxPersistedEventsSize = MAX_EVENT_LIST_SIZE_IN_BYTES;\n interval = MIN_INTERVAL;\n timeAtLastSend: number | null = null;\n\n async setup(config: BrowserConfig) {\n config.loggerProvider.log('Installing @amplitude/plugin-session-replay.');\n\n this.config = config;\n this.storageKey = `${STORAGE_PREFIX}_${this.config.apiKey.substring(0, 10)}`;\n void this.emptyStoreAndReset();\n }\n\n async execute(event: Event) {\n event.event_properties = {\n ...event.event_properties,\n [DEFAULT_SESSION_REPLAY_PROPERTY]: true,\n };\n if (event.event_type === DEFAULT_SESSION_START_EVENT) {\n this.recordEvents();\n } else if (event.event_type === DEFAULT_SESSION_END_EVENT) {\n if (event.session_id) {\n this.sendEventsList({\n events: this.events,\n sequenceId: this.currentSequenceId,\n sessionId: event.session_id,\n });\n }\n this.stopRecordingEvents && this.stopRecordingEvents();\n this.events = [];\n this.currentSequenceId = 0;\n }\n return Promise.resolve(event);\n }\n\n async emptyStoreAndReset() {\n const storedReplaySessions = await this.getAllSessionEventsFromStore();\n if (storedReplaySessions) {\n for (const sessionId in storedReplaySessions) {\n const storedReplayEvents = storedReplaySessions[sessionId];\n if (storedReplayEvents.events.length) {\n this.sendEventsList({\n events: storedReplayEvents.events,\n sequenceId: storedReplayEvents.sequenceId,\n sessionId: parseInt(sessionId, 10),\n });\n }\n }\n this.events = [];\n const currentSessionStoredEvents = this.config.sessionId && storedReplaySessions[this.config.sessionId];\n this.currentSequenceId = currentSessionStoredEvents ? currentSessionStoredEvents.sequenceId + 1 : 0;\n void this.storeEventsForSession([], this.currentSequenceId);\n this.recordEvents();\n }\n }\n\n recordEvents() {\n this.stopRecordingEvents = record({\n emit: (event) => {\n const eventString = JSON.stringify(event);\n // Send the first two recorded events immediately\n if (this.events.length === 1 && this.currentSequenceId === 0) {\n this.sendEventsList({\n events: this.events.concat(eventString),\n sequenceId: this.currentSequenceId,\n sessionId: this.config.sessionId as number,\n });\n this.events = [];\n this.currentSequenceId++;\n return;\n }\n\n const shouldSplit = this.shouldSplitEventsList(eventString);\n if (shouldSplit) {\n this.sendEventsList({\n events: this.events,\n sequenceId: this.currentSequenceId,\n sessionId: this.config.sessionId as number,\n });\n this.events = [];\n this.currentSequenceId++;\n }\n this.events.push(eventString);\n void this.storeEventsForSession(this.events, this.currentSequenceId);\n },\n packFn: pack,\n maskAllInputs: true,\n });\n }\n\n /**\n * Determines whether to send the events list to the backend and start a new\n * empty events list, based on the size of the list as well as the last time sent\n * @param nextEventString\n * @returns boolean\n */\n shouldSplitEventsList = (nextEventString: string): boolean => {\n const sizeOfNextEvent = new Blob([nextEventString]).size;\n const sizeOfEventsList = new Blob(this.events).size;\n if (sizeOfEventsList + sizeOfNextEvent >= this.maxPersistedEventsSize) {\n return true;\n }\n if (this.timeAtLastSend !== null && Date.now() - this.timeAtLastSend > this.interval) {\n this.interval = Math.min(MAX_INTERVAL, this.interval + MIN_INTERVAL);\n return true;\n }\n return false;\n };\n\n sendEventsList({ events, sequenceId, sessionId }: { events: string[]; sequenceId: number; sessionId: number }) {\n this.addToQueue({\n events,\n sequenceId,\n attempts: 0,\n timeout: 0,\n sessionId,\n });\n }\n\n addToQueue(...list: SessionReplayContext[]) {\n const tryable = list.filter((context) => {\n if (context.attempts < this.config.flushMaxRetries) {\n context.attempts += 1;\n return true;\n }\n this.completeRequest({\n context,\n err: `${MAX_RETRIES_EXCEEDED_MESSAGE}, batch sequence id, ${context.sequenceId}`,\n });\n return false;\n });\n tryable.forEach((context) => {\n this.queue = this.queue.concat(context);\n if (context.timeout === 0) {\n this.schedule(0);\n return;\n }\n\n setTimeout(() => {\n context.timeout = 0;\n this.schedule(0);\n }, context.timeout);\n });\n }\n\n schedule(timeout: number) {\n if (this.scheduled) return;\n this.scheduled = setTimeout(() => {\n void this.flush(true).then(() => {\n if (this.queue.length > 0) {\n this.schedule(timeout);\n }\n });\n }, timeout);\n }\n\n async flush(useRetry = false) {\n const list: SessionReplayContext[] = [];\n const later: SessionReplayContext[] = [];\n this.queue.forEach((context) => (context.timeout === 0 ? list.push(context) : later.push(context)));\n this.queue = later;\n\n if (this.scheduled) {\n clearTimeout(this.scheduled);\n this.scheduled = null;\n }\n\n await Promise.all(list.map((context) => this.send(context, useRetry)));\n }\n\n async send(context: SessionReplayContext, useRetry = true) {\n const payload = {\n api_key: this.config.apiKey,\n device_id: this.config.deviceId,\n session_id: context.sessionId,\n start_timestamp: context.sessionId,\n events_batch: {\n version: 1,\n events: context.events,\n seq_number: context.sequenceId,\n },\n };\n try {\n const options: RequestInit = {\n headers: {\n 'Content-Type': 'application/json',\n Accept: '*/*',\n },\n body: JSON.stringify(payload),\n method: 'POST',\n };\n const res = await fetch(SESSION_REPLAY_SERVER_URL, options);\n if (res === null) {\n this.completeRequest({ context, err: UNEXPECTED_ERROR_MESSAGE, removeEvents: false });\n return;\n }\n if (!useRetry) {\n let responseBody = '';\n try {\n responseBody = JSON.stringify(res.body, null, 2);\n } catch {\n // to avoid crash, but don't care about the error, add comment to avoid empty block lint error\n }\n this.completeRequest({ context, success: `${res.status}: ${responseBody}` });\n } else {\n this.handleReponse(res.status, context);\n }\n } catch (e) {\n this.completeRequest({ context, err: e as string, removeEvents: false });\n }\n }\n\n handleReponse(status: number, context: SessionReplayContext) {\n const parsedStatus = new BaseTransport().buildStatus(status);\n switch (parsedStatus) {\n case Status.Success:\n this.handleSuccessResponse(context);\n break;\n default:\n this.handleOtherResponse(context);\n }\n }\n\n handleSuccessResponse(context: SessionReplayContext) {\n this.completeRequest({ context, success: SUCCESS_MESSAGE });\n }\n\n handleOtherResponse(context: SessionReplayContext) {\n this.addToQueue({\n ...context,\n timeout: context.attempts * this.retryTimeout,\n });\n }\n\n async getAllSessionEventsFromStore() {\n try {\n const storedReplaySessionContexts: IDBStore | undefined = await IDBKeyVal.get(this.storageKey);\n\n return storedReplaySessionContexts;\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n return undefined;\n }\n\n async storeEventsForSession(events: Events, sequenceId: number) {\n try {\n await IDBKeyVal.update(this.storageKey, (sessionMap: IDBStore | undefined): IDBStore => {\n return {\n ...sessionMap,\n ...(this.config.sessionId && {\n [this.config.sessionId]: {\n events: events,\n sequenceId,\n },\n }),\n };\n });\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n }\n\n async removeSessionEventsStore(sessionId: number) {\n try {\n await IDBKeyVal.update(this.storageKey, (sessionMap: IDBStore = {}): IDBStore => {\n delete sessionMap[sessionId];\n return sessionMap;\n });\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n }\n\n completeRequest({\n context,\n err,\n success,\n removeEvents = true,\n }: {\n context: SessionReplayContext;\n err?: string;\n success?: string;\n removeEvents?: boolean;\n }) {\n removeEvents && context.sessionId && this.removeSessionEventsStore(context.sessionId);\n if (err) {\n this.config.loggerProvider.error(err);\n } else if (success) {\n this.timeAtLastSend = Date.now();\n this.config.loggerProvider.log(success);\n }\n }\n}\n\nexport const sessionReplayPlugin: SessionReplayPlugin = () => {\n return new SessionReplay();\n};\n"]}
1
+ {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;AAAA,4DAA4E;AAC5E,8DAA0E;AAC1E,4DAAwC;AACxC,+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AAC,UAAU,EAAE,UAAC,UAAyB;gCAAzB,2BAAA,EAAA,eAAyB;gCAChE,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC;gCAC7B,OAAO,UAAU,CAAC;4BACpB,CAAC,CAAC,EAAA;;wBAHF,SAGE,CAAC;;;;wBAEH,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,UAAG,0BAAe,eAAK,GAAW,CAAE,CAAC,CAAC;;;;;;KAE1E;IAED,uCAAe,GAAf,UAAgB,EAUf;YATC,OAAO,aAAA,EACP,GAAG,SAAA,EACH,OAAO,aAAA,EACP,oBAAmB,EAAnB,YAAY,mBAAG,IAAI,KAAA;QAOnB,YAAY,IAAI,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACtF,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACvC;aAAM,IAAI,OAAO,EAAE;YAClB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACzC;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AAlTD,IAkTC;AAEM,IAAM,mBAAmB,GAAwB;IACtD,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B","sourcesContent":["import { AMPLITUDE_PREFIX, BaseTransport } from '@amplitude/analytics-core';\nimport { BrowserConfig, Event, Status } from '@amplitude/analytics-types';\nimport * as IDBKeyVal from 'idb-keyval';\nimport { pack, record } from 'rrweb';\nimport { DEFAULT_SESSION_END_EVENT, DEFAULT_SESSION_REPLAY_PROPERTY, DEFAULT_SESSION_START_EVENT } from './constants';\nimport { MAX_RETRIES_EXCEEDED_MESSAGE, STORAGE_FAILURE, SUCCESS_MESSAGE, UNEXPECTED_ERROR_MESSAGE } from './messages';\nimport {\n Events,\n IDBStore,\n SessionReplayContext,\n SessionReplayEnrichmentPlugin,\n SessionReplayPlugin,\n} from './typings/session-replay';\n\nconst SESSION_REPLAY_SERVER_URL = 'https://api-secure.amplitude.com/sessions/track';\nconst STORAGE_PREFIX = `${AMPLITUDE_PREFIX}_replay_unsent`;\nconst PAYLOAD_ESTIMATED_SIZE_IN_BYTES_WITHOUT_EVENTS = 200; // derived by JSON stringifying an example payload without events\nconst MAX_EVENT_LIST_SIZE_IN_BYTES = 20 * 1000000 - PAYLOAD_ESTIMATED_SIZE_IN_BYTES_WITHOUT_EVENTS;\nconst MIN_INTERVAL = 1 * 1000; // 1 second\nconst MAX_INTERVAL = 10 * 1000; // 10 seconds\n\nclass SessionReplay implements SessionReplayEnrichmentPlugin {\n name = '@amplitude/plugin-session-replay-browser';\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n storageKey = '';\n retryTimeout = 1000;\n events: Events = [];\n currentSequenceId = 0;\n private scheduled: ReturnType<typeof setTimeout> | null = null;\n queue: SessionReplayContext[] = [];\n stopRecordingEvents: ReturnType<typeof record> | null = null;\n maxPersistedEventsSize = MAX_EVENT_LIST_SIZE_IN_BYTES;\n interval = MIN_INTERVAL;\n timeAtLastSend: number | null = null;\n\n async setup(config: BrowserConfig) {\n config.loggerProvider.log('Installing @amplitude/plugin-session-replay.');\n\n this.config = config;\n this.storageKey = `${STORAGE_PREFIX}_${this.config.apiKey.substring(0, 10)}`;\n void this.emptyStoreAndReset();\n }\n\n async execute(event: Event) {\n event.event_properties = {\n ...event.event_properties,\n [DEFAULT_SESSION_REPLAY_PROPERTY]: true,\n };\n if (event.event_type === DEFAULT_SESSION_START_EVENT && !this.stopRecordingEvents) {\n this.recordEvents();\n } else if (event.event_type === DEFAULT_SESSION_END_EVENT) {\n if (event.session_id) {\n this.sendEventsList({\n events: this.events,\n sequenceId: this.currentSequenceId,\n sessionId: event.session_id,\n });\n }\n this.stopRecordingEvents && this.stopRecordingEvents();\n this.events = [];\n this.currentSequenceId = 0;\n }\n return Promise.resolve(event);\n }\n\n async emptyStoreAndReset() {\n const storedReplaySessions = await this.getAllSessionEventsFromStore();\n if (storedReplaySessions) {\n for (const sessionId in storedReplaySessions) {\n const storedReplayEvents = storedReplaySessions[sessionId];\n if (storedReplayEvents.events.length) {\n this.sendEventsList({\n events: storedReplayEvents.events,\n sequenceId: storedReplayEvents.sequenceId,\n sessionId: parseInt(sessionId, 10),\n });\n }\n }\n this.events = [];\n const currentSessionStoredEvents = this.config.sessionId && storedReplaySessions[this.config.sessionId];\n this.currentSequenceId = currentSessionStoredEvents ? currentSessionStoredEvents.sequenceId + 1 : 0;\n void this.storeEventsForSession([], this.currentSequenceId);\n }\n this.recordEvents();\n }\n\n recordEvents() {\n this.stopRecordingEvents = record({\n emit: (event) => {\n const eventString = JSON.stringify(event);\n // Send the first two recorded events immediately\n if (this.events.length === 1 && this.currentSequenceId === 0) {\n this.sendEventsList({\n events: this.events.concat(eventString),\n sequenceId: this.currentSequenceId,\n sessionId: this.config.sessionId as number,\n });\n this.events = [];\n this.currentSequenceId++;\n return;\n }\n\n const shouldSplit = this.shouldSplitEventsList(eventString);\n if (shouldSplit) {\n this.sendEventsList({\n events: this.events,\n sequenceId: this.currentSequenceId,\n sessionId: this.config.sessionId as number,\n });\n this.events = [];\n this.currentSequenceId++;\n }\n this.events.push(eventString);\n void this.storeEventsForSession(this.events, this.currentSequenceId);\n },\n packFn: pack,\n maskAllInputs: true,\n });\n }\n\n /**\n * Determines whether to send the events list to the backend and start a new\n * empty events list, based on the size of the list as well as the last time sent\n * @param nextEventString\n * @returns boolean\n */\n shouldSplitEventsList = (nextEventString: string): boolean => {\n const sizeOfNextEvent = new Blob([nextEventString]).size;\n const sizeOfEventsList = new Blob(this.events).size;\n if (sizeOfEventsList + sizeOfNextEvent >= this.maxPersistedEventsSize) {\n return true;\n }\n if (this.timeAtLastSend !== null && Date.now() - this.timeAtLastSend > this.interval) {\n this.interval = Math.min(MAX_INTERVAL, this.interval + MIN_INTERVAL);\n return true;\n }\n return false;\n };\n\n sendEventsList({ events, sequenceId, sessionId }: { events: string[]; sequenceId: number; sessionId: number }) {\n this.addToQueue({\n events,\n sequenceId,\n attempts: 0,\n timeout: 0,\n sessionId,\n });\n }\n\n addToQueue(...list: SessionReplayContext[]) {\n const tryable = list.filter((context) => {\n if (context.attempts < this.config.flushMaxRetries) {\n context.attempts += 1;\n return true;\n }\n this.completeRequest({\n context,\n err: `${MAX_RETRIES_EXCEEDED_MESSAGE}, batch sequence id, ${context.sequenceId}`,\n });\n return false;\n });\n tryable.forEach((context) => {\n this.queue = this.queue.concat(context);\n if (context.timeout === 0) {\n this.schedule(0);\n return;\n }\n\n setTimeout(() => {\n context.timeout = 0;\n this.schedule(0);\n }, context.timeout);\n });\n }\n\n schedule(timeout: number) {\n if (this.scheduled) return;\n this.scheduled = setTimeout(() => {\n void this.flush(true).then(() => {\n if (this.queue.length > 0) {\n this.schedule(timeout);\n }\n });\n }, timeout);\n }\n\n async flush(useRetry = false) {\n const list: SessionReplayContext[] = [];\n const later: SessionReplayContext[] = [];\n this.queue.forEach((context) => (context.timeout === 0 ? list.push(context) : later.push(context)));\n this.queue = later;\n\n if (this.scheduled) {\n clearTimeout(this.scheduled);\n this.scheduled = null;\n }\n\n await Promise.all(list.map((context) => this.send(context, useRetry)));\n }\n\n async send(context: SessionReplayContext, useRetry = true) {\n const payload = {\n api_key: this.config.apiKey,\n device_id: this.config.deviceId,\n session_id: context.sessionId,\n start_timestamp: context.sessionId,\n events_batch: {\n version: 1,\n events: context.events,\n seq_number: context.sequenceId,\n },\n };\n try {\n const options: RequestInit = {\n headers: {\n 'Content-Type': 'application/json',\n Accept: '*/*',\n },\n body: JSON.stringify(payload),\n method: 'POST',\n };\n const res = await fetch(SESSION_REPLAY_SERVER_URL, options);\n if (res === null) {\n this.completeRequest({ context, err: UNEXPECTED_ERROR_MESSAGE, removeEvents: false });\n return;\n }\n if (!useRetry) {\n let responseBody = '';\n try {\n responseBody = JSON.stringify(res.body, null, 2);\n } catch {\n // to avoid crash, but don't care about the error, add comment to avoid empty block lint error\n }\n this.completeRequest({ context, success: `${res.status}: ${responseBody}` });\n } else {\n this.handleReponse(res.status, context);\n }\n } catch (e) {\n this.completeRequest({ context, err: e as string, removeEvents: false });\n }\n }\n\n handleReponse(status: number, context: SessionReplayContext) {\n const parsedStatus = new BaseTransport().buildStatus(status);\n switch (parsedStatus) {\n case Status.Success:\n this.handleSuccessResponse(context);\n break;\n default:\n this.handleOtherResponse(context);\n }\n }\n\n handleSuccessResponse(context: SessionReplayContext) {\n this.completeRequest({ context, success: SUCCESS_MESSAGE });\n }\n\n handleOtherResponse(context: SessionReplayContext) {\n this.addToQueue({\n ...context,\n timeout: context.attempts * this.retryTimeout,\n });\n }\n\n async getAllSessionEventsFromStore() {\n try {\n const storedReplaySessionContexts: IDBStore | undefined = await IDBKeyVal.get(this.storageKey);\n\n return storedReplaySessionContexts;\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n return undefined;\n }\n\n async storeEventsForSession(events: Events, sequenceId: number) {\n try {\n await IDBKeyVal.update(this.storageKey, (sessionMap: IDBStore | undefined): IDBStore => {\n return {\n ...sessionMap,\n ...(this.config.sessionId && {\n [this.config.sessionId]: {\n events: events,\n sequenceId,\n },\n }),\n };\n });\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n }\n\n async removeSessionEventsStore(sessionId: number) {\n try {\n await IDBKeyVal.update(this.storageKey, (sessionMap: IDBStore = {}): IDBStore => {\n delete sessionMap[sessionId];\n return sessionMap;\n });\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n }\n\n completeRequest({\n context,\n err,\n success,\n removeEvents = true,\n }: {\n context: SessionReplayContext;\n err?: string;\n success?: string;\n removeEvents?: boolean;\n }) {\n removeEvents && context.sessionId && this.removeSessionEventsStore(context.sessionId);\n if (err) {\n this.config.loggerProvider.error(err);\n } else if (success) {\n this.timeAtLastSend = Date.now();\n this.config.loggerProvider.log(success);\n }\n }\n}\n\nexport const sessionReplayPlugin: SessionReplayPlugin = () => {\n return new SessionReplay();\n};\n"]}
@@ -61,7 +61,7 @@ var SessionReplay = /** @class */ (function () {
61
61
  var _a;
62
62
  return __generator(this, function (_b) {
63
63
  event.event_properties = __assign(__assign({}, event.event_properties), (_a = {}, _a[DEFAULT_SESSION_REPLAY_PROPERTY] = true, _a));
64
- if (event.event_type === DEFAULT_SESSION_START_EVENT) {
64
+ if (event.event_type === DEFAULT_SESSION_START_EVENT && !this.stopRecordingEvents) {
65
65
  this.recordEvents();
66
66
  }
67
67
  else if (event.event_type === DEFAULT_SESSION_END_EVENT) {
@@ -103,8 +103,8 @@ var SessionReplay = /** @class */ (function () {
103
103
  currentSessionStoredEvents = this.config.sessionId && storedReplaySessions[this.config.sessionId];
104
104
  this.currentSequenceId = currentSessionStoredEvents ? currentSessionStoredEvents.sequenceId + 1 : 0;
105
105
  void this.storeEventsForSession([], this.currentSequenceId);
106
- this.recordEvents();
107
106
  }
107
+ this.recordEvents();
108
108
  return [2 /*return*/];
109
109
  }
110
110
  });
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAwB,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC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C,IAAI,CAAC,UAAU,EAAE,UAAC,UAAyB;gCAAzB,2BAAA,EAAA,eAAyB;gCAChE,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC;gCAC7B,OAAO,UAAU,CAAC;4BACpB,CAAC,CAAC,EAAA;;wBAHF,SAGE,CAAC;;;;wBAEH,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,UAAG,eAAe,eAAK,GAAW,CAAE,CAAC,CAAC;;;;;;KAE1E;IAED,uCAAe,GAAf,UAAgB,EAUf;YATC,OAAO,aAAA,EACP,GAAG,SAAA,EACH,OAAO,aAAA,EACP,oBAAmB,EAAnB,YAAY,mBAAG,IAAI,KAAA;QAOnB,YAAY,IAAI,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACtF,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACvC;aAAM,IAAI,OAAO,EAAE;YAClB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACzC;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AAlTD,IAkTC;AAED,MAAM,CAAC,IAAM,mBAAmB,GAAwB;IACtD,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC,CAAC","sourcesContent":["import { AMPLITUDE_PREFIX, BaseTransport } from '@amplitude/analytics-core';\nimport { BrowserConfig, Event, Status } from '@amplitude/analytics-types';\nimport * as IDBKeyVal from 'idb-keyval';\nimport { pack, record } from 'rrweb';\nimport { DEFAULT_SESSION_END_EVENT, DEFAULT_SESSION_REPLAY_PROPERTY, DEFAULT_SESSION_START_EVENT } from './constants';\nimport { MAX_RETRIES_EXCEEDED_MESSAGE, STORAGE_FAILURE, SUCCESS_MESSAGE, UNEXPECTED_ERROR_MESSAGE } from './messages';\nimport {\n Events,\n IDBStore,\n SessionReplayContext,\n SessionReplayEnrichmentPlugin,\n SessionReplayPlugin,\n} from './typings/session-replay';\n\nconst SESSION_REPLAY_SERVER_URL = 'https://api-secure.amplitude.com/sessions/track';\nconst STORAGE_PREFIX = `${AMPLITUDE_PREFIX}_replay_unsent`;\nconst PAYLOAD_ESTIMATED_SIZE_IN_BYTES_WITHOUT_EVENTS = 200; // derived by JSON stringifying an example payload without events\nconst MAX_EVENT_LIST_SIZE_IN_BYTES = 20 * 1000000 - PAYLOAD_ESTIMATED_SIZE_IN_BYTES_WITHOUT_EVENTS;\nconst MIN_INTERVAL = 1 * 1000; // 1 second\nconst MAX_INTERVAL = 10 * 1000; // 10 seconds\n\nclass SessionReplay implements SessionReplayEnrichmentPlugin {\n name = '@amplitude/plugin-session-replay-browser';\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n storageKey = '';\n retryTimeout = 1000;\n events: Events = [];\n currentSequenceId = 0;\n private scheduled: ReturnType<typeof setTimeout> | null = null;\n queue: SessionReplayContext[] = [];\n stopRecordingEvents: ReturnType<typeof record> | null = null;\n maxPersistedEventsSize = MAX_EVENT_LIST_SIZE_IN_BYTES;\n interval = MIN_INTERVAL;\n timeAtLastSend: number | null = null;\n\n async setup(config: BrowserConfig) {\n config.loggerProvider.log('Installing @amplitude/plugin-session-replay.');\n\n this.config = config;\n this.storageKey = `${STORAGE_PREFIX}_${this.config.apiKey.substring(0, 10)}`;\n void this.emptyStoreAndReset();\n }\n\n async execute(event: Event) {\n event.event_properties = {\n ...event.event_properties,\n [DEFAULT_SESSION_REPLAY_PROPERTY]: true,\n };\n if (event.event_type === DEFAULT_SESSION_START_EVENT) {\n this.recordEvents();\n } else if (event.event_type === DEFAULT_SESSION_END_EVENT) {\n if (event.session_id) {\n this.sendEventsList({\n events: this.events,\n sequenceId: this.currentSequenceId,\n sessionId: event.session_id,\n });\n }\n this.stopRecordingEvents && this.stopRecordingEvents();\n this.events = [];\n this.currentSequenceId = 0;\n }\n return Promise.resolve(event);\n }\n\n async emptyStoreAndReset() {\n const storedReplaySessions = await this.getAllSessionEventsFromStore();\n if (storedReplaySessions) {\n for (const sessionId in storedReplaySessions) {\n const storedReplayEvents = storedReplaySessions[sessionId];\n if (storedReplayEvents.events.length) {\n this.sendEventsList({\n events: storedReplayEvents.events,\n sequenceId: storedReplayEvents.sequenceId,\n sessionId: parseInt(sessionId, 10),\n });\n }\n }\n this.events = [];\n const currentSessionStoredEvents = this.config.sessionId && storedReplaySessions[this.config.sessionId];\n this.currentSequenceId = currentSessionStoredEvents ? currentSessionStoredEvents.sequenceId + 1 : 0;\n void this.storeEventsForSession([], this.currentSequenceId);\n this.recordEvents();\n }\n }\n\n recordEvents() {\n this.stopRecordingEvents = record({\n emit: (event) => {\n const eventString = JSON.stringify(event);\n // Send the first two recorded events immediately\n if (this.events.length === 1 && this.currentSequenceId === 0) {\n this.sendEventsList({\n events: this.events.concat(eventString),\n sequenceId: this.currentSequenceId,\n sessionId: this.config.sessionId as number,\n });\n this.events = [];\n this.currentSequenceId++;\n return;\n }\n\n const shouldSplit = this.shouldSplitEventsList(eventString);\n if (shouldSplit) {\n this.sendEventsList({\n events: this.events,\n sequenceId: this.currentSequenceId,\n sessionId: this.config.sessionId as number,\n });\n this.events = [];\n this.currentSequenceId++;\n }\n this.events.push(eventString);\n void this.storeEventsForSession(this.events, this.currentSequenceId);\n },\n packFn: pack,\n maskAllInputs: true,\n });\n }\n\n /**\n * Determines whether to send the events list to the backend and start a new\n * empty events list, based on the size of the list as well as the last time sent\n * @param nextEventString\n * @returns boolean\n */\n shouldSplitEventsList = (nextEventString: string): boolean => {\n const sizeOfNextEvent = new Blob([nextEventString]).size;\n const sizeOfEventsList = new Blob(this.events).size;\n if (sizeOfEventsList + sizeOfNextEvent >= this.maxPersistedEventsSize) {\n return true;\n }\n if (this.timeAtLastSend !== null && Date.now() - this.timeAtLastSend > this.interval) {\n this.interval = Math.min(MAX_INTERVAL, this.interval + MIN_INTERVAL);\n return true;\n }\n return false;\n };\n\n sendEventsList({ events, sequenceId, sessionId }: { events: string[]; sequenceId: number; sessionId: number }) {\n this.addToQueue({\n events,\n sequenceId,\n attempts: 0,\n timeout: 0,\n sessionId,\n });\n }\n\n addToQueue(...list: SessionReplayContext[]) {\n const tryable = list.filter((context) => {\n if (context.attempts < this.config.flushMaxRetries) {\n context.attempts += 1;\n return true;\n }\n this.completeRequest({\n context,\n err: `${MAX_RETRIES_EXCEEDED_MESSAGE}, batch sequence id, ${context.sequenceId}`,\n });\n return false;\n });\n tryable.forEach((context) => {\n this.queue = this.queue.concat(context);\n if (context.timeout === 0) {\n this.schedule(0);\n return;\n }\n\n setTimeout(() => {\n context.timeout = 0;\n this.schedule(0);\n }, context.timeout);\n });\n }\n\n schedule(timeout: number) {\n if (this.scheduled) return;\n this.scheduled = setTimeout(() => {\n void this.flush(true).then(() => {\n if (this.queue.length > 0) {\n this.schedule(timeout);\n }\n });\n }, timeout);\n }\n\n async flush(useRetry = false) {\n const list: SessionReplayContext[] = [];\n const later: SessionReplayContext[] = [];\n this.queue.forEach((context) => (context.timeout === 0 ? list.push(context) : later.push(context)));\n this.queue = later;\n\n if (this.scheduled) {\n clearTimeout(this.scheduled);\n this.scheduled = null;\n }\n\n await Promise.all(list.map((context) => this.send(context, useRetry)));\n }\n\n async send(context: SessionReplayContext, useRetry = true) {\n const payload = {\n api_key: this.config.apiKey,\n device_id: this.config.deviceId,\n session_id: context.sessionId,\n start_timestamp: context.sessionId,\n events_batch: {\n version: 1,\n events: context.events,\n seq_number: context.sequenceId,\n },\n };\n try {\n const options: RequestInit = {\n headers: {\n 'Content-Type': 'application/json',\n Accept: '*/*',\n },\n body: JSON.stringify(payload),\n method: 'POST',\n };\n const res = await fetch(SESSION_REPLAY_SERVER_URL, options);\n if (res === null) {\n this.completeRequest({ context, err: UNEXPECTED_ERROR_MESSAGE, removeEvents: false });\n return;\n }\n if (!useRetry) {\n let responseBody = '';\n try {\n responseBody = JSON.stringify(res.body, null, 2);\n } catch {\n // to avoid crash, but don't care about the error, add comment to avoid empty block lint error\n }\n this.completeRequest({ context, success: `${res.status}: ${responseBody}` });\n } else {\n this.handleReponse(res.status, context);\n }\n } catch (e) {\n this.completeRequest({ context, err: e as string, removeEvents: false });\n }\n }\n\n handleReponse(status: number, context: SessionReplayContext) {\n const parsedStatus = new BaseTransport().buildStatus(status);\n switch (parsedStatus) {\n case Status.Success:\n this.handleSuccessResponse(context);\n break;\n default:\n this.handleOtherResponse(context);\n }\n }\n\n handleSuccessResponse(context: SessionReplayContext) {\n this.completeRequest({ context, success: SUCCESS_MESSAGE });\n }\n\n handleOtherResponse(context: SessionReplayContext) {\n this.addToQueue({\n ...context,\n timeout: context.attempts * this.retryTimeout,\n });\n }\n\n async getAllSessionEventsFromStore() {\n try {\n const storedReplaySessionContexts: IDBStore | undefined = await IDBKeyVal.get(this.storageKey);\n\n return storedReplaySessionContexts;\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n return undefined;\n }\n\n async storeEventsForSession(events: Events, sequenceId: number) {\n try {\n await IDBKeyVal.update(this.storageKey, (sessionMap: IDBStore | undefined): IDBStore => {\n return {\n ...sessionMap,\n ...(this.config.sessionId && {\n [this.config.sessionId]: {\n events: events,\n sequenceId,\n },\n }),\n };\n });\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n }\n\n async removeSessionEventsStore(sessionId: number) {\n try {\n await IDBKeyVal.update(this.storageKey, (sessionMap: IDBStore = {}): IDBStore => {\n delete sessionMap[sessionId];\n return sessionMap;\n });\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n }\n\n completeRequest({\n context,\n err,\n success,\n removeEvents = true,\n }: {\n context: SessionReplayContext;\n err?: string;\n success?: string;\n removeEvents?: boolean;\n }) {\n removeEvents && context.sessionId && this.removeSessionEventsStore(context.sessionId);\n if (err) {\n this.config.loggerProvider.error(err);\n } else if (success) {\n this.timeAtLastSend = Date.now();\n this.config.loggerProvider.log(success);\n }\n }\n}\n\nexport const sessionReplayPlugin: SessionReplayPlugin = () => {\n return new SessionReplay();\n};\n"]}
1
+ {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAwB,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AACtH,OAAO,EAAE,4BAA4B,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAStH,IAAM,yBAAyB,GAAG,iDAAiD,CAAC;AACpF,IAAM,cAAc,GAAG,UAAG,gBAAgB,mBAAgB,CAAC;AAC3D,IAAM,8CAA8C,GAAG,GAAG,CAAC,CAAC,iEAAiE;AAC7H,IAAM,4BAA4B,GAAG,EAAE,GAAG,OAAO,GAAG,8CAA8C,CAAC;AACnG,IAAM,YAAY,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,WAAW;AAC1C,IAAM,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAE7C;IAAA;QAAA,iBAkTC;QAjTC,SAAI,GAAG,0CAA0C,CAAC;QAClD,SAAI,GAAG,YAAqB,CAAC;QAK7B,eAAU,GAAG,EAAE,CAAC;QAChB,iBAAY,GAAG,IAAI,CAAC;QACpB,WAAM,GAAW,EAAE,CAAC;QACpB,sBAAiB,GAAG,C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C,GAAG,CAAC,CAAC;SACvC;aAAM,IAAI,OAAO,EAAE;YAClB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACzC;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AAlTD,IAkTC;AAED,MAAM,CAAC,IAAM,mBAAmB,GAAwB;IACtD,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC,CAAC","sourcesContent":["import { AMPLITUDE_PREFIX, BaseTransport } from '@amplitude/analytics-core';\nimport { BrowserConfig, Event, Status } from '@amplitude/analytics-types';\nimport * as IDBKeyVal from 'idb-keyval';\nimport { pack, record } from 'rrweb';\nimport { DEFAULT_SESSION_END_EVENT, DEFAULT_SESSION_REPLAY_PROPERTY, DEFAULT_SESSION_START_EVENT } from './constants';\nimport { MAX_RETRIES_EXCEEDED_MESSAGE, STORAGE_FAILURE, SUCCESS_MESSAGE, UNEXPECTED_ERROR_MESSAGE } from './messages';\nimport {\n Events,\n IDBStore,\n SessionReplayContext,\n SessionReplayEnrichmentPlugin,\n SessionReplayPlugin,\n} from './typings/session-replay';\n\nconst SESSION_REPLAY_SERVER_URL = 'https://api-secure.amplitude.com/sessions/track';\nconst STORAGE_PREFIX = `${AMPLITUDE_PREFIX}_replay_unsent`;\nconst PAYLOAD_ESTIMATED_SIZE_IN_BYTES_WITHOUT_EVENTS = 200; // derived by JSON stringifying an example payload without events\nconst MAX_EVENT_LIST_SIZE_IN_BYTES = 20 * 1000000 - PAYLOAD_ESTIMATED_SIZE_IN_BYTES_WITHOUT_EVENTS;\nconst MIN_INTERVAL = 1 * 1000; // 1 second\nconst MAX_INTERVAL = 10 * 1000; // 10 seconds\n\nclass SessionReplay implements SessionReplayEnrichmentPlugin {\n name = '@amplitude/plugin-session-replay-browser';\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n storageKey = '';\n retryTimeout = 1000;\n events: Events = [];\n currentSequenceId = 0;\n private scheduled: ReturnType<typeof setTimeout> | null = null;\n queue: SessionReplayContext[] = [];\n stopRecordingEvents: ReturnType<typeof record> | null = null;\n maxPersistedEventsSize = MAX_EVENT_LIST_SIZE_IN_BYTES;\n interval = MIN_INTERVAL;\n timeAtLastSend: number | null = null;\n\n async setup(config: BrowserConfig) {\n config.loggerProvider.log('Installing @amplitude/plugin-session-replay.');\n\n this.config = config;\n this.storageKey = `${STORAGE_PREFIX}_${this.config.apiKey.substring(0, 10)}`;\n void this.emptyStoreAndReset();\n }\n\n async execute(event: Event) {\n event.event_properties = {\n ...event.event_properties,\n [DEFAULT_SESSION_REPLAY_PROPERTY]: true,\n };\n if (event.event_type === DEFAULT_SESSION_START_EVENT && !this.stopRecordingEvents) {\n this.recordEvents();\n } else if (event.event_type === DEFAULT_SESSION_END_EVENT) {\n if (event.session_id) {\n this.sendEventsList({\n events: this.events,\n sequenceId: this.currentSequenceId,\n sessionId: event.session_id,\n });\n }\n this.stopRecordingEvents && this.stopRecordingEvents();\n this.events = [];\n this.currentSequenceId = 0;\n }\n return Promise.resolve(event);\n }\n\n async emptyStoreAndReset() {\n const storedReplaySessions = await this.getAllSessionEventsFromStore();\n if (storedReplaySessions) {\n for (const sessionId in storedReplaySessions) {\n const storedReplayEvents = storedReplaySessions[sessionId];\n if (storedReplayEvents.events.length) {\n this.sendEventsList({\n events: storedReplayEvents.events,\n sequenceId: storedReplayEvents.sequenceId,\n sessionId: parseInt(sessionId, 10),\n });\n }\n }\n this.events = [];\n const currentSessionStoredEvents = this.config.sessionId && storedReplaySessions[this.config.sessionId];\n this.currentSequenceId = currentSessionStoredEvents ? currentSessionStoredEvents.sequenceId + 1 : 0;\n void this.storeEventsForSession([], this.currentSequenceId);\n }\n this.recordEvents();\n }\n\n recordEvents() {\n this.stopRecordingEvents = record({\n emit: (event) => {\n const eventString = JSON.stringify(event);\n // Send the first two recorded events immediately\n if (this.events.length === 1 && this.currentSequenceId === 0) {\n this.sendEventsList({\n events: this.events.concat(eventString),\n sequenceId: this.currentSequenceId,\n sessionId: this.config.sessionId as number,\n });\n this.events = [];\n this.currentSequenceId++;\n return;\n }\n\n const shouldSplit = this.shouldSplitEventsList(eventString);\n if (shouldSplit) {\n this.sendEventsList({\n events: this.events,\n sequenceId: this.currentSequenceId,\n sessionId: this.config.sessionId as number,\n });\n this.events = [];\n this.currentSequenceId++;\n }\n this.events.push(eventString);\n void this.storeEventsForSession(this.events, this.currentSequenceId);\n },\n packFn: pack,\n maskAllInputs: true,\n });\n }\n\n /**\n * Determines whether to send the events list to the backend and start a new\n * empty events list, based on the size of the list as well as the last time sent\n * @param nextEventString\n * @returns boolean\n */\n shouldSplitEventsList = (nextEventString: string): boolean => {\n const sizeOfNextEvent = new Blob([nextEventString]).size;\n const sizeOfEventsList = new Blob(this.events).size;\n if (sizeOfEventsList + sizeOfNextEvent >= this.maxPersistedEventsSize) {\n return true;\n }\n if (this.timeAtLastSend !== null && Date.now() - this.timeAtLastSend > this.interval) {\n this.interval = Math.min(MAX_INTERVAL, this.interval + MIN_INTERVAL);\n return true;\n }\n return false;\n };\n\n sendEventsList({ events, sequenceId, sessionId }: { events: string[]; sequenceId: number; sessionId: number }) {\n this.addToQueue({\n events,\n sequenceId,\n attempts: 0,\n timeout: 0,\n sessionId,\n });\n }\n\n addToQueue(...list: SessionReplayContext[]) {\n const tryable = list.filter((context) => {\n if (context.attempts < this.config.flushMaxRetries) {\n context.attempts += 1;\n return true;\n }\n this.completeRequest({\n context,\n err: `${MAX_RETRIES_EXCEEDED_MESSAGE}, batch sequence id, ${context.sequenceId}`,\n });\n return false;\n });\n tryable.forEach((context) => {\n this.queue = this.queue.concat(context);\n if (context.timeout === 0) {\n this.schedule(0);\n return;\n }\n\n setTimeout(() => {\n context.timeout = 0;\n this.schedule(0);\n }, context.timeout);\n });\n }\n\n schedule(timeout: number) {\n if (this.scheduled) return;\n this.scheduled = setTimeout(() => {\n void this.flush(true).then(() => {\n if (this.queue.length > 0) {\n this.schedule(timeout);\n }\n });\n }, timeout);\n }\n\n async flush(useRetry = false) {\n const list: SessionReplayContext[] = [];\n const later: SessionReplayContext[] = [];\n this.queue.forEach((context) => (context.timeout === 0 ? list.push(context) : later.push(context)));\n this.queue = later;\n\n if (this.scheduled) {\n clearTimeout(this.scheduled);\n this.scheduled = null;\n }\n\n await Promise.all(list.map((context) => this.send(context, useRetry)));\n }\n\n async send(context: SessionReplayContext, useRetry = true) {\n const payload = {\n api_key: this.config.apiKey,\n device_id: this.config.deviceId,\n session_id: context.sessionId,\n start_timestamp: context.sessionId,\n events_batch: {\n version: 1,\n events: context.events,\n seq_number: context.sequenceId,\n },\n };\n try {\n const options: RequestInit = {\n headers: {\n 'Content-Type': 'application/json',\n Accept: '*/*',\n },\n body: JSON.stringify(payload),\n method: 'POST',\n };\n const res = await fetch(SESSION_REPLAY_SERVER_URL, options);\n if (res === null) {\n this.completeRequest({ context, err: UNEXPECTED_ERROR_MESSAGE, removeEvents: false });\n return;\n }\n if (!useRetry) {\n let responseBody = '';\n try {\n responseBody = JSON.stringify(res.body, null, 2);\n } catch {\n // to avoid crash, but don't care about the error, add comment to avoid empty block lint error\n }\n this.completeRequest({ context, success: `${res.status}: ${responseBody}` });\n } else {\n this.handleReponse(res.status, context);\n }\n } catch (e) {\n this.completeRequest({ context, err: e as string, removeEvents: false });\n }\n }\n\n handleReponse(status: number, context: SessionReplayContext) {\n const parsedStatus = new BaseTransport().buildStatus(status);\n switch (parsedStatus) {\n case Status.Success:\n this.handleSuccessResponse(context);\n break;\n default:\n this.handleOtherResponse(context);\n }\n }\n\n handleSuccessResponse(context: SessionReplayContext) {\n this.completeRequest({ context, success: SUCCESS_MESSAGE });\n }\n\n handleOtherResponse(context: SessionReplayContext) {\n this.addToQueue({\n ...context,\n timeout: context.attempts * this.retryTimeout,\n });\n }\n\n async getAllSessionEventsFromStore() {\n try {\n const storedReplaySessionContexts: IDBStore | undefined = await IDBKeyVal.get(this.storageKey);\n\n return storedReplaySessionContexts;\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n return undefined;\n }\n\n async storeEventsForSession(events: Events, sequenceId: number) {\n try {\n await IDBKeyVal.update(this.storageKey, (sessionMap: IDBStore | undefined): IDBStore => {\n return {\n ...sessionMap,\n ...(this.config.sessionId && {\n [this.config.sessionId]: {\n events: events,\n sequenceId,\n },\n }),\n };\n });\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n }\n\n async removeSessionEventsStore(sessionId: number) {\n try {\n await IDBKeyVal.update(this.storageKey, (sessionMap: IDBStore = {}): IDBStore => {\n delete sessionMap[sessionId];\n return sessionMap;\n });\n } catch (e) {\n this.config.loggerProvider.error(`${STORAGE_FAILURE}: ${e as string}`);\n }\n }\n\n completeRequest({\n context,\n err,\n success,\n removeEvents = true,\n }: {\n context: SessionReplayContext;\n err?: string;\n success?: string;\n removeEvents?: boolean;\n }) {\n removeEvents && context.sessionId && this.removeSessionEventsStore(context.sessionId);\n if (err) {\n this.config.loggerProvider.error(err);\n } else if (success) {\n this.timeAtLastSend = Date.now();\n this.config.loggerProvider.log(success);\n }\n }\n}\n\nexport const sessionReplayPlugin: SessionReplayPlugin = () => {\n return new SessionReplay();\n};\n"]}
@@ -1 +1 @@
1
- var sessionReplay=function(e){"use strict";var t,n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(t||(t={}));var s=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var n,r,o,s,i,a,c,l,d,u,h,p,g,m,f,I,C,y,v,S,b,A;if("object"!=typeof e)return null;var w=e.code||0,k=this.buildStatus(w);switch(k){case t.Success:return{status:k,statusCode:w,body:{eventsIngested:null!==(n=e.events_ingested)&&void 0!==n?n:0,payloadSizeBytes:null!==(r=e.payload_size_bytes)&&void 0!==r?r:0,serverUploadTime:null!==(o=e.server_upload_time)&&void 0!==o?o:0}};case t.Invalid:return{status:k,statusCode:w,body:{error:null!==(s=e.error)&&void 0!==s?s:"",missingField:null!==(i=e.missing_field)&&void 0!==i?i:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(c=e.events_with_missing_fields)&&void 0!==c?c:{},eventsWithInvalidIdLengths:null!==(l=e.events_with_invalid_id_lengths)&&void 0!==l?l:{},epsThreshold:null!==(d=e.eps_threshold)&&void 0!==d?d:0,exceededDailyQuotaDevices:null!==(u=e.exceeded_daily_quota_devices)&&void 0!==u?u:{},silencedDevices:null!==(h=e.silenced_devices)&&void 0!==h?h:[],silencedEvents:null!==(p=e.silenced_events)&&void 0!==p?p:[],throttledDevices:null!==(g=e.throttled_devices)&&void 0!==g?g:{},throttledEvents:null!==(m=e.throttled_events)&&void 0!==m?m:[]}};case t.PayloadTooLarge:return{status:k,statusCode:w,body:{error:null!==(f=e.error)&&void 0!==f?f:""}};case t.RateLimit:return{status:k,statusCode:w,body:{error:null!==(I=e.error)&&void 0!==I?I:"",epsThreshold:null!==(C=e.eps_threshold)&&void 0!==C?C:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(v=e.throttled_users)&&void 0!==v?v:{},exceededDailyQuotaDevices:null!==(S=e.exceeded_daily_quota_devices)&&void 0!==S?S:{},exceededDailyQuotaUsers:null!==(b=e.exceeded_daily_quota_users)&&void 0!==b?b:{},throttledEvents:null!==(A=e.throttled_events)&&void 0!==A?A:[]}};case t.Timeout:default:return{status:k,statusCode:w}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?t.Success:429===e?t.RateLimit:413===e?t.PayloadTooLarge:408===e?t.Timeout:e>=400&&e<500?t.Invalid:e>=500?t.Failed:t.Unknown},e}();function i(e){return new Promise(((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}))}let a;function c(){return a||(a=function(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=i(n);return(e,n)=>r.then((r=>n(r.transaction(t,e).objectStore(t))))}("keyval-store","keyval")),a}function l(e,t=c()){return t("readonly",(t=>i(t.get(e))))}function d(e,t,n=c()){return n("readwrite",(n=>new Promise(((r,o)=>{n.get(e).onsuccess=function(){try{n.put(t(this.result),e),r(i(n.transaction))}catch(e){o(e)}}}))))}var u;function h(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function p(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function g(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(m).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function m(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=g(e.styleSheet)||t}catch(e){}return t}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(u||(u={}));var f=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function I(e){var t=e.maskInputOptions,n=e.tagName,r=e.type,o=e.value,s=e.maskInputFn,i=o||"";return(t[n.toLowerCase()]||t[r])&&(i=s?s(i):"*".repeat(i.length)),i}var C="__rrweb_original__";var y,v,S=1,b=new RegExp("[^a-z0-9-_:]");function A(){return S++}var w=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,k=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,M=/^(data:)([^,]*),(.*)/i;function T(e,t){return(e||"").replace(w,(function(e,n,r,o,s,i){var a,c=r||s||i,l=n||o||"";if(!c)return e;if(!k.test(c))return"url(".concat(l).concat(c).concat(l,")");if(M.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var d=t.split("/"),u=c.split("/");d.pop();for(var h=0,p=u;h<p.length;h++){var g=p[h];"."!==g&&(".."===g?d.pop():d.push(g))}return"url(".concat(l).concat(d.join("/")).concat(l,")")}))}var E=/^[^ \t\n\r\u000c]+/,N=/^[, \t\n\r\u000c]+/;function R(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function O(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function D(){var e=document.createElement("a");return e.href="",e.href}function x(e,t,n,r){return"src"===n||"href"===n&&r&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&r&&"#"!==r[0]?R(e,r):"background"!==n||!r||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&r?function(e,t){if(""===t.trim())return t;var n=0;function r(e){var r,o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}for(var o=[];r(N),!(n>=t.length);){var s=r(E);if(","===s.slice(-1))s=R(e,s.substring(0,s.length-1)),o.push(s);else{var i="";s=R(e,s);for(var a=!1;;){var c=t.charAt(n);if(""===c){o.push((s+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,o.push((s+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return o.join(", ")}(e,r):"style"===n&&r?T(r,D()):"object"===t&&"data"===n&&r?R(e,r):r:R(e,r)}function F(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&F(e.parentNode,t,n);for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&F(e.parentNode,t,n)}function L(e,t,n){var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(r.closest(".".concat(t)))return!0}else if(F(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}return!1}function _(e,t){var n=t.doc,r=t.mirror,o=t.blockClass,s=t.blockSelector,i=t.maskTextClass,a=t.maskTextSelector,c=t.inlineStylesheet,l=t.maskInputOptions,d=void 0===l?{}:l,h=t.maskTextFn,p=t.maskInputFn,m=t.dataURLOptions,f=void 0===m?{}:m,S=t.inlineImages,A=t.recordCanvas,w=t.keepIframeSrcFn,k=t.newlyAddedElement,M=void 0!==k&&k,E=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:u.Document,childNodes:[],compatMode:e.compatMode}:{type:u.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:u.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:E};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,r=t.blockClass,o=t.blockSelector,s=t.inlineStylesheet,i=t.maskInputOptions,a=void 0===i?{}:i,c=t.maskInputFn,l=t.dataURLOptions,d=void 0===l?{}:l,h=t.inlineImages,p=t.recordCanvas,m=t.keepIframeSrcFn,f=t.newlyAddedElement,S=void 0!==f&&f,A=t.rootId,w=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&e.matches(n)}(e,r,o),k=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return b.test(t)?"div":t}(e),M={},E=e.attributes.length,N=0;N<E;N++){var R=e.attributes[N];M[R.name]=x(n,k,R.name,R.value)}if("link"===k&&s){var F=Array.from(n.styleSheets).find((function(t){return t.href===e.href})),L=null;F&&(L=g(F)),L&&(delete M.rel,delete M.href,M._cssText=T(L,F.href))}if("style"===k&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(L=g(e.sheet))&&(M._cssText=T(L,D()))}if("input"===k||"textarea"===k||"select"===k){var _=e.value,W=e.checked;"radio"!==M.type&&"checkbox"!==M.type&&"submit"!==M.type&&"button"!==M.type&&_?M.value=I({type:M.type,tagName:k,value:_,maskInputOptions:a,maskInputFn:c}):W&&(M.checked=W)}"option"===k&&(e.selected&&!a.select?M.selected=!0:delete M.selected);if("canvas"===k&&p)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var r=0;r<e.height;r+=50){var o=t.getImageData,s=C in o?o[C]:o;if(new Uint32Array(s.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(M.rr_dataURL=e.toDataURL(d.type,d.quality));else if(!("__context"in e)){var B=e.toDataURL(d.type,d.quality),G=document.createElement("canvas");G.width=e.width,G.height=e.height,B!==G.toDataURL(d.type,d.quality)&&(M.rr_dataURL=B)}if("img"===k&&h){y||(y=n.createElement("canvas"),v=y.getContext("2d"));var U=e,Z=U.crossOrigin;U.crossOrigin="anonymous";var V=function(){try{y.width=U.naturalWidth,y.height=U.naturalHeight,v.drawImage(U,0,0),M.rr_dataURL=y.toDataURL(d.type,d.quality)}catch(e){console.warn("Cannot inline img src=".concat(U.currentSrc,"! Error: ").concat(e))}Z?M.crossOrigin=Z:U.removeAttribute("crossorigin")};U.complete&&0!==U.naturalWidth?V():U.onload=V}"audio"!==k&&"video"!==k||(M.rr_mediaState=e.paused?"paused":"played",M.rr_mediaCurrentTime=e.currentTime);S||(e.scrollLeft&&(M.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(M.rr_scrollTop=e.scrollTop));if(w){var K=e.getBoundingClientRect(),Y=K.width,q=K.height;M={class:M.class,rr_width:"".concat(Y,"px"),rr_height:"".concat(q,"px")}}"iframe"!==k||m(M.src)||(e.contentDocument||(M.rr_src=M.src),delete M.src);return{type:u.Element,tagName:k,attributes:M,childNodes:[],isSVG:O(e)||void 0,needBlock:w,rootId:A}}(e,{doc:n,blockClass:o,blockSelector:s,inlineStylesheet:c,maskInputOptions:d,maskInputFn:p,dataURLOptions:f,inlineImages:S,recordCanvas:A,keepIframeSrcFn:w,newlyAddedElement:M,rootId:E});case e.TEXT_NODE:return function(e,t){var n,r=t.maskTextClass,o=t.maskTextSelector,s=t.maskTextFn,i=t.rootId,a=e.parentNode&&e.parentNode.tagName,c=e.textContent,l="STYLE"===a||void 0,d="SCRIPT"===a||void 0;if(l&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(h=e.parentNode.sheet).cssRules?Array.from(h.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=T(c,D())}var h;d&&(c="SCRIPT_PLACEHOLDER");!l&&!d&&c&&L(e,r,o)&&(c=s?s(c):c.replace(/[\S]/g,"*"));return{type:u.Text,textContent:c||"",isStyle:l,rootId:i}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:h,rootId:E});case e.CDATA_SECTION_NODE:return{type:u.CDATA,textContent:"",rootId:E};case e.COMMENT_NODE:return{type:u.Comment,textContent:e.textContent||"",rootId:E};default:return!1}}function W(e){return void 0===e?"":e.toLowerCase()}function B(e,t){var n,r=t.doc,o=t.mirror,s=t.blockClass,i=t.blockSelector,a=t.maskTextClass,c=t.maskTextSelector,l=t.skipChild,d=void 0!==l&&l,g=t.inlineStylesheet,m=void 0===g||g,f=t.maskInputOptions,I=void 0===f?{}:f,C=t.maskTextFn,y=t.maskInputFn,v=t.slimDOMOptions,S=t.dataURLOptions,b=void 0===S?{}:S,w=t.inlineImages,k=void 0!==w&&w,M=t.recordCanvas,T=void 0!==M&&M,E=t.onSerialize,N=t.onIframeLoad,R=t.iframeLoadTimeout,O=void 0===R?5e3:R,D=t.onStylesheetLoad,x=t.stylesheetLoadTimeout,F=void 0===x?5e3:x,L=t.keepIframeSrcFn,G=void 0===L?function(){return!1}:L,U=t.newlyAddedElement,Z=void 0!==U&&U,V=t.preserveWhiteSpace,K=void 0===V||V,Y=_(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,dataURLOptions:b,inlineImages:k,recordCanvas:T,keepIframeSrcFn:G,newlyAddedElement:Z});if(!Y)return console.warn(e,"not serialized"),null;n=o.hasNode(e)?o.getId(e):!function(e,t){if(t.comment&&e.type===u.Comment)return!0;if(e.type===u.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(W(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===W(e.attributes.name)||"icon"===W(e.attributes.rel)||"apple-touch-icon"===W(e.attributes.rel)||"shortcut icon"===W(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&W(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(W(e.attributes.property).match(/^(og|twitter|fb):/)||W(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===W(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===W(e.attributes.name)||"googlebot"===W(e.attributes.name)||"bingbot"===W(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===W(e.attributes.name)||"generator"===W(e.attributes.name)||"framework"===W(e.attributes.name)||"publisher"===W(e.attributes.name)||"progid"===W(e.attributes.name)||W(e.attributes.property).match(/^article:/)||W(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===W(e.attributes.name)||"yandex-verification"===W(e.attributes.name)||"csrf-token"===W(e.attributes.name)||"p:domain_verify"===W(e.attributes.name)||"verify-v1"===W(e.attributes.name)||"verification"===W(e.attributes.name)||"shopify-checkout-api-token"===W(e.attributes.name)))return!0}}return!1}(Y,v)&&(K||Y.type!==u.Text||Y.isStyle||Y.textContent.replace(/^\s+|\s+$/gm,"").length)?A():-2;var q=Object.assign(Y,{id:n});if(o.add(e,q),-2===n)return null;E&&E(e);var P=!d;if(q.type===u.Element){P=P&&!q.needBlock,delete q.needBlock;var z=e.shadowRoot;z&&p(z)&&(q.isShadowHost=!0)}if((q.type===u.Document||q.type===u.Element)&&P){v.headWhitespace&&q.type===u.Element&&"head"===q.tagName&&(K=!1);for(var Q={doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:d,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G},J=0,j=Array.from(e.childNodes);J<j.length;J++){($=B(j[J],Q))&&q.childNodes.push($)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var H=0,X=Array.from(e.shadowRoot.childNodes);H<X.length;H++){var $;($=B(X[H],Q))&&(p(e.shadowRoot)&&($.isShadow=!0),q.childNodes.push($))}}return e.parentNode&&h(e.parentNode)&&p(e.parentNode)&&(q.isShadow=!0),q.type===u.Element&&"iframe"===q.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var o,s=!1;try{o=r.document.readyState}catch(e){return}if("complete"===o){var i="about:blank";if(r.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout((function(){s||(t(),s=!0)}),n);e.addEventListener("load",(function(){clearTimeout(a),s=!0,t()}))}}}(e,(function(){var t=e.contentDocument;if(t&&N){var n=B(t,{doc:t,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G});n&&N(e,n)}}),O),q.type===u.Element&&"link"===q.tagName&&"stylesheet"===q.attributes.rel&&function(e,t,n){var r,o=!1;try{r=e.sheet}catch(e){return}if(!r){var s=setTimeout((function(){o||(t(),o=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),o=!0,t()}))}}(e,(function(){if(D){var t=B(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G});t&&D(e,t)}}),F),q}function G(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const U="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Z={map:{},getId:()=>(console.error(U),-1),getNode:()=>(console.error(U),null),removeNodeFromMap(){console.error(U)},has:()=>(console.error(U),!1),reset(){console.error(U)}};function V(e,t,n={}){let r=null,o=0;return function(...s){const i=Date.now();o||!1!==n.leading||(o=i);const a=t-(i-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=i,e.apply(c,s)):r||!1===n.trailing||(r=setTimeout((()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,s)}),a))}}function K(e,t,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>K(e,t,s||{},!0)}function Y(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch(e){return()=>{}}}function q(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function P(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function z(e,t,n,r){if(!e)return!1;const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(F(o,t,r))return!0;if(n){if(e.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function Q(e,t){return-2===t.getId(e)}function J(e,t){if(h(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||J(e.parentNode,t))}function j(e){return Boolean(e.changedTouches)}function H(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function X(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function $(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Z=new Proxy(Z,{get:(e,t,n)=>("map"===t&&console.error(U),Reflect.get(e,t,n))}));class ee{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var te=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(te||{}),ne=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(ne||{}),re=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(re||{}),oe=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(oe||{});function se(e){return"__ln"in e}class ie{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&se(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&se(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next&&(t.next.previous=t.previous)):(this.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const ae=(e,t)=>`${e}@${t}`;class ce{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new ie,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},r=r=>{var o,s,i,a;let c=null;(null===(s=null===(o=r.getRootNode)||void 0===o?void 0:o.call(r))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&r.getRootNode().host&&(c=r.getRootNode().host);let l=c;for(;(null===(a=null===(i=null==l?void 0:l.getRootNode)||void 0===i?void 0:i.call(l))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&l.getRootNode().host;)l=l.getRootNode().host;const d=!(this.doc.contains(r)||l&&this.doc.contains(l));if(!r.parentNode||d)return;const u=h(r.parentNode)?this.mirror.getId(c):this.mirror.getId(r.parentNode),p=n(r);if(-1===u||-1===p)return t.addNode(r);const g=B(r,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{H(e,this.mirror)&&this.iframeManager.addIframe(e),X(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),$(r)&&this.shadowDomManager.addShadowRoot(r.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});g&&e.push({parentId:u,nextId:p,node:g})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))de(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||r(e);for(const e of Array.from(this.addedSet.values()))he(this.droppedSet,e)||de(this.removes,e,this.mirror)?he(this.movedSet,e)?r(e):this.droppedSet.add(e):r(e);let o=null;for(;t.length;){let e=null;if(o){const t=this.mirror.getId(o.value.parentNode),r=n(o.value);-1!==t&&-1!==r&&(e=o)}if(!e)for(let r=t.length-1;r>=0;r--){const o=t.get(r);if(o){const t=this.mirror.getId(o.value.parentNode);if(-1===n(o.value))continue;if(-1!==t){e=o;break}{const t=o.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=o;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}o=e.previous,t.removeNode(e.value),r(e.value)}const s={texts:this.texts.map((e=>({id:this.mirror.getId(e.node),value:e.value}))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>({id:this.mirror.getId(e.node),attributes:e.attributes}))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!Q(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;z(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:L(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=I({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),z(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let r=this.attributes.find((t=>t.node===e.target));if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(r||(r={node:e.target,attributes:{}},this.attributes.push(r)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==r.attributes.style&&null!==r.attributes.style||(r.attributes.style={});const o=r.attributes.style;for(const e of Array.from(t.style)){const r=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);r===n.style.getPropertyValue(e)&&s===n.style.getPropertyPriority(e)||(o[e]=""===s?r:[r,s])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(o[e]=!1)}else r.attributes[e.attributeName]=x(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(z(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),r=h(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);z(e.target,this.blockClass,this.blockSelector,!1)||Q(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(le(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||J(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[ae(n,r)]?le(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!h(e.target)||!p(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(Q(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[ae(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);z(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach((e=>this.genAdds(e)))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach((t=>{this[t]=e[t]}))}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function le(e,t){e.delete(t),t.childNodes.forEach((t=>le(e,t)))}function de(e,t,n){return 0!==e.length&&ue(e,t,n)}function ue(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some((e=>e.id===o))||ue(e,r,n)}function he(e,t){return 0!==e.size&&pe(e,t)}function pe(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||pe(e,n))}const ge=[],me="undefined"!=typeof CSSGroupingRule,fe="undefined"!=typeof CSSMediaRule,Ie="undefined"!=typeof CSSSupportsRule,Ce="undefined"!=typeof CSSConditionRule;function ye(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function ve(e,t){var n,r;const o=new ce;ge.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(o.processMutations.bind(o));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function Se({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(re).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{const i=s.toLowerCase(),c=(t=>s=>{const i=ye(s);if(z(i,r,o,!0))return;const a=j(s)?s.changedTouches[0]:s;if(!a)return;const c=n.getId(i),{clientX:l,clientY:d}=a;e({type:re[t],id:c,x:l,y:d})})(s);a.push(G(i,c,t))})),()=>{a.forEach((e=>e()))}}function be({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){return G("scroll",V((s=>{const i=ye(s);if(!i||z(i,r,o,!0))return;const a=n.getId(i);if(i===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})}),s.scroll||100),t)}function Ae(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const we=["INPUT","TEXTAREA","SELECT"],ke=new WeakMap;function Me(e){return function(e,t){if(me&&e.parentRule instanceof CSSGroupingRule||fe&&e.parentRule instanceof CSSMediaRule||Ie&&e.parentRule instanceof CSSSupportsRule||Ce&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function Te(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function Ee({mirror:e,stylesheetManager:t},n){var r,o,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(s=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===s?void 0:s.ShadowRoot,c=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==i&&-1!==i&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return r}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function Ne(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t);const r=ve(e,e.doc),o=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=V((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null}),s),l=V((e=>{const t=ye(e),{clientX:n,clientY:o}=j(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:o,id:r.getId(t),timeOffset:Date.now()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?ne.Drag:e instanceof MouseEvent?ne.MouseMove:ne.TouchMove)}),o,{trailing:!1}),d=[G("mousemove",l,n),G("touchmove",l,n),G("drag",l,n)];return()=>{d.forEach((e=>e()))}}(e),s=Se(e),i=be(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return G("resize",V((()=>{const r=q(),o=P();t===r&&n===o||(e({width:Number(o),height:Number(r)}),t=r,n=o)}),200),window)}(e),c=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:s,maskInputOptions:i,maskInputFn:a,sampling:c,userTriggeredOnInput:l}){function d(e){let n=ye(e);const c=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||we.indexOf(n.tagName)<0||z(n,r,o,!0))return;const d=n.type;if(n.classList.contains(s))return;let h=n.value,p=!1;"radio"===d||"checkbox"===d?p=n.checked:(i[n.tagName.toLowerCase()]||i[d])&&(h=I({maskInputOptions:i,tagName:n.tagName,type:d,value:h,maskInputFn:a})),u(n,Ae({text:h,isChecked:p,userTriggered:c},l));const g=n.name;"radio"===d&&g&&p&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach((e=>{e!==n&&u(e,Ae({text:e.value,isChecked:!p,userTriggered:!1},l))}))}function u(t,r){const o=ke.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){ke.set(t,r);const o=n.getId(t);e(Object.assign(Object.assign({},r),{id:o}))}}const h=("last"===c.input?["change"]:["input","change"]).map((e=>G(e,d,t))),p=t.defaultView;if(!p)return()=>{h.forEach((e=>e()))};const g=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),m=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return g&&g.set&&h.push(...m.map((e=>K(e[0],e[1],{set(){d({target:this})}},!1,p)))),()=>{h.forEach((e=>e()))}}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o}){const s=s=>V((o=>{const i=ye(o);if(!i||z(i,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=i;e({type:s,id:r.getId(i),currentTime:a,volume:c,muted:l,playbackRate:d})}),o.media||500),i=[G("play",s(0)),G("pause",s(1)),G("seeked",s(2)),G("volumechange",s(3)),G("ratechange",s(4))];return()=>{i.forEach((e=>e()))}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=function(r,s){const{id:i,styleId:a}=Te(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:s}]}),o.apply(this,[r,s])};const s=r.CSSStyleSheet.prototype.deleteRule;let i,a;r.CSSStyleSheet.prototype.deleteRule=function(r){const{id:o,styleId:i}=Te(this,t,n.styleMirror);return(o&&-1!==o||i&&-1!==i)&&e({id:o,styleId:i,removes:[{index:r}]}),s.apply(this,[r])},r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=function(r){const{id:o,styleId:s}=Te(this,t,n.styleMirror);return(o&&-1!==o||s&&-1!==s)&&e({id:o,styleId:s,replace:r}),i.apply(this,[r])}),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=function(r){const{id:o,styleId:s}=Te(this,t,n.styleMirror);return(o&&-1!==o||s&&-1!==s)&&e({id:o,styleId:s,replaceSync:r}),a.apply(this,[r])});const c={};me?c.CSSGroupingRule=r.CSSGroupingRule:(fe&&(c.CSSMediaRule=r.CSSMediaRule),Ce&&(c.CSSConditionRule=r.CSSConditionRule),Ie&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach((([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=function(o,s){const{id:i,styleId:a}=Te(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:o,index:[...Me(this),s||0]}]}),l[r].insertRule.apply(this,[o,s])},o.prototype.deleteRule=function(o){const{id:s,styleId:i}=Te(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:[...Me(this),o]}]}),l[r].deleteRule.apply(this,[o])}})),()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=s,i&&(r.CSSStyleSheet.prototype.replace=i),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule}))}}(e,{win:n}),u=Ee(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=function(o,i,a){var c;if(n.has(o))return s.apply(this,[o,i,a]);const{id:l,styleId:d}=Te(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:o,value:i,priority:a},index:Me(this.parentRule)}),s.apply(this,[o,i,a])};const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=function(o){var s;if(n.has(o))return i.apply(this,[o]);const{id:a,styleId:c}=Te(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,t,r.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:o},index:Me(this.parentRule)}),i.apply(this,[o])},()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),p=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const r=new s(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const i=Y(t.fonts,"add",(function(t){return function(n){return setTimeout((()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.apply(this,[n])}}));return r.push((()=>{n.FontFace=s})),r.push(i),()=>{r.forEach((e=>e()))}}(e):()=>{},g=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:s}=e;let i=!0;const a=()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:c,endContainer:l,endOffset:d}=s;z(i,r,o,!0)||z(l,r,o,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(l),endOffset:d})}s({ranges:a})};return a(),G("selectionchange",a)}(e),m=[];for(const t of e.plugins)m.push(t.observer(t.callback,n,t.options));return()=>{ge.forEach((e=>e.reset())),r.disconnect(),o(),s(),i(),a(),c(),l(),d(),u(),h(),p(),g(),m.forEach((e=>e()))}}class Re{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),s=r||this.getRemoteIdToIdMap(e);let i=o.get(t);return i||(i=this.generateIdFn(),o.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,r)))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map((t=>this.getRemoteId(e,t,n)))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class Oe{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Re(A),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Re(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case te.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:te.IncrementalSnapshot,data:{source:ne.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case te.Meta:case te.Load:case te.DomContentLoaded:return!1;case te.Plugin:return t;case te.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case te.IncrementalSnapshot:switch(t.data.source){case ne.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)})),t.data.removes.forEach((t=>{this.replaceIds(t,e,["parentId","id"])})),t.data.attributes.forEach((t=>{this.replaceIds(t,e,["id"])})),t.data.texts.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ne.Drag:case ne.TouchMove:case ne.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ne.ViewportResize:return!1;case ne.MediaInteraction:case ne.MouseInteraction:case ne.Scroll:case ne.CanvasMutation:case ne.Input:return this.replaceIds(t.data,e,["id"]),t;case ne.StyleSheetRule:case ne.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case ne.Font:return t;case ne.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case ne.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach((t=>{this.replaceStyleIds(t,e,["styleId"])})),t}}}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}}class De{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(Y(Element.prototype,"attachShadow",(function(e){return function(n){const r=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),r}})))}addShadowRoot(e,t){p(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ve(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),be(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout((()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),Ee({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)}),0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(Y(e.contentWindow.HTMLElement.prototype,"attachShadow",(function(n){return function(r){const o=n.call(this,r);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),o}})))}}reset(){this.restorePatches.forEach((e=>e())),this.shadowDoms=new WeakSet}}function xe(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}for(var Fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Le="undefined"==typeof Uint8Array?[]:new Uint8Array(256),_e=0;_e<Fe.length;_e++)Le[Fe.charCodeAt(_e)]=_e;const We=new Map;const Be=(e,t,n)=>{if(!e||!Ze(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=We.get(e);return n||(n=new Map,We.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Ge(e,t,n){if(e instanceof Array)return e.map((e=>Ge(e,t,n)));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Fe[n[t]>>2],o+=Fe[(3&n[t])<<4|n[t+1]>>4],o+=Fe[(15&n[t+1])<<2|n[t+2]>>6],o+=Fe[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Ge(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Ge(e.data,t,n),e.width,e.height]}}if(Ze(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Be(e,t,n)}}return e}const Ue=(e,t,n)=>[...e].map((e=>Ge(e,t,n))),Ze=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((e=>"function"==typeof t[e]));return Boolean(n.find((n=>e instanceof t[n])))};function Ve(e,t,n){const r=[];try{const o=Y(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(r,...o){return z(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...o])}}));r.push(o)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{r.forEach((e=>e()))}}function Ke(e,t,n,r,o,s,i){const a=[],c=Object.getOwnPropertyNames(e);for(const s of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const c=Y(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(Be(c,i,this),!z(this.canvas,r,o,!0)){const e=Ue([...a],i,this),r={type:t,property:s,args:e};n(this.canvas,r)}return c}}));a.push(c)}catch(r){const o=K(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(o)}return a}var Ye=null;try{var qe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Ye=qe.Worker}catch(e){}function Pe(e,t,n){var r=void 0===t?null:t,o=function(e,t){return Buffer.from(e,"base64").toString(t?"utf16":"utf8")}(e,void 0!==n&&n),s=o.indexOf("\n",10)+1,i=o.substring(s)+(r?"//# sourceMappingURL="+r:"");return function(e){return new Ye(i,Object.assign({},e,{eval:!0}))}}function ze(e,t,n){var r=void 0===t?null:t,o=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),o=0,s=n.length;o<s;++o)r[o]=n.charCodeAt(o);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(e,void 0!==n&&n),s=o.indexOf("\n",10)+1,i=o.substring(s)+(r?"//# sourceMappingURL="+r:""),a=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(a)}var Qe="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Je,je,He,Xe=(Je="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgew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5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",je=null,He=!1,Qe?Pe(Je,je,He):function(e,t,n){var r;return function(o){return r=r||ze(e,t,n),new Worker(r,o)}}(Je,je,He));class $e{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,r,o),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:i})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,o){const s=Ve(t,n,r),i=new Map,a=new Xe;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:s}=e.data;this.mutationCb({id:t,type:oe["2D"],commands:[{property:"clearRect",args:[0,0,o,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{z(t,n,r,!0)||e.push(t)})),e})().forEach((e=>xe(this,void 0,void 0,(function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ve(e,t,n),o=function(e,t,n,r){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=Y(t.CanvasRenderingContext2D.prototype,i,(function(o){return function(...s){return z(this.canvas,n,r,!0)||setTimeout((()=>{const n=Ue([...s],t,this);e(this.canvas,{type:oe["2D"],property:i,args:n})}),0),o.apply(this,s)}}));o.push(s)}catch(n){const r=K(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:oe["2D"],property:i,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,r,o){const s=[];return s.push(...Ke(t.WebGLRenderingContext.prototype,oe.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...Ke(t.WebGL2RenderingContext.prototype,oe.WebGL2,e,n,r,0,t)),()=>{s.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach(((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)})),requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map((e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t})),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class et{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new ee,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map(((e,t)=>({rule:m(e),index:t})))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function tt(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let nt,rt,ot,st=!1;const it=new f;function at(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:c=null,inlineStylesheet:l=!0,maskAllInputs:d,maskInputOptions:u,slimDOMOptions:h,maskInputFn:p,maskTextFn:g,hooks:m,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:w=!1,inlineImages:k=!1,plugins:M,keepIframeSrcFn:T=(()=>!1),ignoreCSSAttributes:E=new Set([])}=e,N=!b||window.parent===window;let R=!1;if(!N)try{window.parent.document,R=!1}catch(e){R=!0}if(N&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),it.reset();const O=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==u?u:{password:!0},D=!0===h||"all"===h?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===h,headMetaDescKeywords:"all"===h}:h||{};let x;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let F=0;const L=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};nt=(e,o)=>{var s;if(!(null===(s=ge[0])||void 0===s?void 0:s.isFrozen())||e.type===te.FullSnapshot||e.type===te.IncrementalSnapshot&&e.data.source===ne.Mutation||ge.forEach((e=>e.unfreeze())),N)null==t||t(L(e),o);else if(R){const t={type:"rrweb",event:L(e),isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===te.FullSnapshot)x=e,F=0;else if(e.type===te.IncrementalSnapshot){if(e.data.source===ne.Mutation&&e.data.isAttachIframe)return;F++;const t=r&&F>=r,o=n&&e.timestamp-x.timestamp>n;(t||o)&&rt(!0)}};const _=e=>{nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Mutation},e)}))},W=e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Scroll},e)})),U=e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.CanvasMutation},e)})),Z=new et({mutationCb:_,adoptedStyleSheetCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.AdoptedStyleSheet},e)}))}),V=new Oe({mirror:it,mutationCb:_,stylesheetManager:Z,recordCrossOriginIframes:b,wrappedEmit:nt});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:it,crossOriginIframeMirror:V.crossOriginIframeMirror,crossOriginIframeStyleMirror:V.crossOriginIframeStyleMirror});ot=new $e({recordCanvas:S,mutationCb:U,win:window,blockClass:o,blockSelector:s,mirror:it,sampling:C.canvas,dataURLOptions:y});const K=new De({mutationCb:_,scrollCb:W,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskInputOptions:O,dataURLOptions:y,maskTextFn:g,maskInputFn:p,recordCanvas:S,inlineImages:k,sampling:C,slimDOMOptions:D,iframeManager:V,stylesheetManager:Z,canvasManager:ot,keepIframeSrcFn:T},mirror:it});rt=(e=!1)=>{var t,n,r,i,d,u;nt(tt({type:te.Meta,data:{href:window.location.href,width:P(),height:q()}}),e),Z.reset(),ge.forEach((e=>e.lock()));const h=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new f:r,s=n.blockClass,i=void 0===s?"rr-block":s,a=n.blockSelector,c=void 0===a?null:a,l=n.maskTextClass,d=void 0===l?"rr-mask":l,u=n.maskTextSelector,h=void 0===u?null:u,p=n.inlineStylesheet,g=void 0===p||p,m=n.inlineImages,I=void 0!==m&&m,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,w=n.slimDOM,k=void 0!==w&&w,M=n.dataURLOptions,T=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,R=n.iframeLoadTimeout,O=n.onStylesheetLoad,D=n.stylesheetLoadTimeout,x=n.keepIframeSrcFn;return B(e,{doc:e,mirror:o,blockClass:i,blockSelector:c,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:g,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:T,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:R,onStylesheetLoad:O,stylesheetLoadTimeout:D,keepIframeSrcFn:void 0===x?function(){return!1}:x,newlyAddedElement:!1})}(document,{mirror:it,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskAllInputs:O,maskTextFn:g,slimDOM:D,dataURLOptions:y,recordCanvas:S,inlineImages:k,onSerialize:e=>{H(e,it)&&V.addIframe(e),X(e,it)&&Z.trackLinkElement(e),$(e)&&K.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{V.attachIframe(e,t),K.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{Z.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!h)return console.warn("Failed to snapshot the document");nt(tt({type:te.FullSnapshot,data:{node:h,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),ge.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Z.adoptStyleSheets(document.adoptedStyleSheets,it.getId(document))};try{const e=[];e.push(G("DOMContentLoaded",(()=>{nt(tt({type:te.DomContentLoaded,data:{}}))})));const t=e=>{var t;return Ne({mutationCb:_,mousemoveCb:(e,t)=>nt(tt({type:te.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.MouseInteraction},e)})),scrollCb:W,viewportResizeCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.ViewportResize},e)})),inputCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Input},e)})),mediaInteractionCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.MediaInteraction},e)})),styleSheetRuleCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.StyleSheetRule},e)})),styleDeclarationCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.StyleDeclaration},e)})),canvasMutationCb:U,fontCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Font},e)})),selectionCb:e=>{nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Selection},e)}))},blockClass:o,ignoreClass:i,maskTextClass:a,maskTextSelector:c,maskInputOptions:O,inlineStylesheet:l,sampling:C,recordCanvas:S,inlineImages:k,userTriggeredOnInput:A,collectFonts:w,doc:e,maskInputFn:p,maskTextFn:g,keepIframeSrcFn:T,blockSelector:s,slimDOMOptions:D,dataURLOptions:y,mirror:it,iframeManager:V,stylesheetManager:Z,shadowDomManager:K,canvasManager:ot,ignoreCSSAttributes:E,plugins:(null===(t=null==M?void 0:M.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>nt(tt({type:te.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},m)};V.addLoadListener((n=>{e.push(t(n.contentDocument))}));const n=()=>{rt(),e.push(t(document)),st=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(G("load",(()=>{nt(tt({type:te.Load,data:{}})),n()}),window)),()=>{e.forEach((e=>e())),st=!1}}catch(e){console.warn(e)}}var ct,lt;at.addCustomEvent=(e,t)=>{if(!st)throw new Error("please add custom event after start recording");nt(tt({type:te.Custom,data:{tag:e,payload:t}}))},at.freezePage=()=>{ge.forEach((e=>e.freeze()))},at.takeFullSnapshot=e=>{if(!st)throw new Error("please take full snapshot after start recording");rt(e)},at.mirror=it,function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(ct||(ct={})),function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"}(lt||(lt={}));var dt=Uint8Array,ut=Uint16Array,ht=Uint32Array,pt=new dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),gt=new dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),mt=new dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ft=function(e,t){for(var n=new ut(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new ht(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return[n,o]},It=ft(pt,2),Ct=It[0],yt=It[1];Ct[28]=258,yt[258]=28;for(var vt=ft(gt,0)[1],St=new ut(32768),bt=0;bt<32768;++bt){var At=(43690&bt)>>>1|(21845&bt)<<1;At=(61680&(At=(52428&At)>>>2|(13107&At)<<2))>>>4|(3855&At)<<4,St[bt]=((65280&At)>>>8|(255&At)<<8)>>>1}var wt=function(e,t,n){for(var r=e.length,o=0,s=new ut(t);o<r;++o)++s[e[o]-1];var i,a=new ut(t);for(o=0;o<t;++o)a[o]=a[o-1]+s[o-1]<<1;if(n){i=new ut(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],d=t-e[o],u=a[e[o]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)i[St[u]>>>c]=l}else for(i=new ut(r),o=0;o<r;++o)i[o]=St[a[e[o]-1]++]>>>15-e[o];return i},kt=new dt(288);for(bt=0;bt<144;++bt)kt[bt]=8;for(bt=144;bt<256;++bt)kt[bt]=9;for(bt=256;bt<280;++bt)kt[bt]=7;for(bt=280;bt<288;++bt)kt[bt]=8;var Mt=new dt(32);for(bt=0;bt<32;++bt)Mt[bt]=5;var Tt=wt(kt,9,0),Et=wt(Mt,5,0),Nt=function(e){return(e/8>>0)+(7&e&&1)},Rt=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof ut?ut:e instanceof ht?ht:dt)(n-t);return r.set(e.subarray(t,n)),r},Ot=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},Dt=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},xt=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,s=n.slice();if(!o)return[new dt(0),0];if(1==o){var i=new dt(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,u=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=o-1;)a=n[n[l].f<n[u].f?l++:u++],c=n[l!=d&&n[l].f<n[u].f?l++:u++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(r=1;r<o;++r)s[r].s>h&&(h=s[r].s);var p=new ut(h+1),g=Ft(n[d-1],p,0);if(g>t){r=0;var m=0,f=g-t,I=1<<f;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));r<o;++r){var C=s[r].s;if(!(p[C]>t))break;m+=I-(1<<g-p[C]),p[C]=t}for(m>>>=f;m>0;){var y=s[r].s;p[y]<t?m-=1<<t-p[y]++-1:++r}for(;r>=0&&m;--r){var v=s[r].s;p[v]==t&&(--p[v],++m)}g=t}return[new dt(p),g]},Ft=function(e,t,n){return-1==e.s?Math.max(Ft(e.l,t,n+1),Ft(e.r,t,n+1)):t[e.s]=n},Lt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new ut(++t),r=0,o=e[0],s=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)i(32754);s>2&&(i(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(i(o),--s;s>6;s-=6)i(8304);s>2&&(i(s-3<<5|8208),s=0)}for(;s--;)i(o);s=1,o=e[a]}return[n.subarray(0,r),t]},_t=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Wt=function(e,t,n){var r=n.length,o=Nt(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var s=0;s<r;++s)e[o+s+4]=n[s];return 8*(o+4+r)},Bt=function(e,t,n,r,o,s,i,a,c,l,d){Ot(t,d++,n),++o[256];for(var u=xt(o,15),h=u[0],p=u[1],g=xt(s,15),m=g[0],f=g[1],I=Lt(h),C=I[0],y=I[1],v=Lt(m),S=v[0],b=v[1],A=new ut(19),w=0;w<C.length;++w)A[31&C[w]]++;for(w=0;w<S.length;++w)A[31&S[w]]++;for(var k=xt(A,7),M=k[0],T=k[1],E=19;E>4&&!M[mt[E-1]];--E);var N,R,O,D,x=l+5<<3,F=_t(o,kt)+_t(s,Mt)+i,L=_t(o,h)+_t(s,m)+i+14+3*E+_t(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(x<=F&&x<=L)return Wt(t,d,e.subarray(c,c+l));if(Ot(t,d,1+(L<F)),d+=2,L<F){N=wt(h,p,0),R=h,O=wt(m,f,0),D=m;var _=wt(M,T,0);Ot(t,d,y-257),Ot(t,d+5,b-1),Ot(t,d+10,E-4),d+=14;for(w=0;w<E;++w)Ot(t,d+3*w,M[mt[w]]);d+=3*E;for(var W=[C,S],B=0;B<2;++B){var G=W[B];for(w=0;w<G.length;++w){var U=31&G[w];Ot(t,d,_[U]),d+=M[U],U>15&&(Ot(t,d,G[w]>>>5&127),d+=G[w]>>>12)}}}else N=Tt,R=kt,O=Et,D=Mt;for(w=0;w<a;++w)if(r[w]>255){U=r[w]>>>18&31;Dt(t,d,N[U+257]),d+=R[U+257],U>7&&(Ot(t,d,r[w]>>>23&31),d+=pt[U]);var Z=31&r[w];Dt(t,d,O[Z]),d+=D[Z],Z>3&&(Dt(t,d,r[w]>>>5&8191),d+=gt[Z])}else Dt(t,d,N[r[w]]),d+=R[r[w]];return Dt(t,d,N[256]),d+R[256]},Gt=new ht([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ut=new dt(0),Zt=function(e,t,n,r,o){return function(e,t,n,r,o,s){var i=e.length,a=new dt(r+i+5*(1+Math.floor(i/7e3))+o),c=a.subarray(r,a.length-o),l=0;if(!t||i<8)for(var d=0;d<=i;d+=65535){var u=d+65535;u<i?l=Wt(c,l,e.subarray(d,u)):(c[d]=s,l=Wt(c,l,e.subarray(d,i)))}else{for(var h=Gt[t-1],p=h>>>13,g=8191&h,m=(1<<n)-1,f=new ut(32768),I=new ut(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new ht(25e3),b=new ut(288),A=new ut(32),w=0,k=0,M=(d=0,0),T=0,E=0;d<i;++d){var N=v(d),R=32767&d,O=I[N];if(f[R]=O,I[N]=R,T<=d){var D=i-d;if((w>7e3||M>24576)&&D>423){l=Bt(e,c,0,S,b,A,k,M,E,d-E,l),M=w=k=0,E=d;for(var x=0;x<286;++x)b[x]=0;for(x=0;x<30;++x)A[x]=0}var F=2,L=0,_=g,W=R-O&32767;if(D>2&&N==v(d-W))for(var B=Math.min(p,D)-1,G=Math.min(32767,d),U=Math.min(258,D);W<=G&&--_&&R!=O;){if(e[d+F]==e[d+F-W]){for(var Z=0;Z<U&&e[d+Z]==e[d+Z-W];++Z);if(Z>F){if(F=Z,L=W,Z>B)break;var V=Math.min(W,Z-2),K=0;for(x=0;x<V;++x){var Y=d-W+x+32768&32767,q=Y-f[Y]+32768&32767;q>K&&(K=q,O=Y)}}}W+=(R=O)-(O=f[R])+32768&32767}if(L){S[M++]=268435456|yt[F]<<18|vt[L];var P=31&yt[F],z=31&vt[L];k+=pt[P]+gt[z],++b[257+P],++A[z],T=d+F,++w}else S[M++]=e[d],++b[e[d]]}}l=Bt(e,c,s,S,b,A,k,M,E,d-E,l),s||(l=Wt(c,l,Ut))}return Rt(a,0,r+Nt(l)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!o)};function Vt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,s=n.length,i=0;i!=s;){for(var a=Math.min(i+5552,s);i<a;++i)o+=r+=n[i];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r=Zt(e,t,2,4);return function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)}(r,t),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(r,r.length-4,n.d()),r}const Kt=e=>{const t=Object.assign(Object.assign({},e),{v:"v1"});return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var o=e[r++];o<128||t?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((31&o)<<6|63&e[r++]):o<240?n+=String.fromCharCode((15&o)<<12|(63&e[r++])<<6|63&e[r++]):(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}return n}(Vt(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new dt(e.length+(e.length>>>1)),o=0,s=function(e){r[o++]=e},i=0;i<n;++i){if(o+5>r.length){var a=new dt(o+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?s(c):c<2048?(s(192|c>>>6),s(128|63&c)):c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),s(128|c>>>12&63),s(128|c>>>6&63),s(128|63&c)):(s(224|c>>>12),s(128|c>>>6&63),s(128|63&c))}return Rt(r,0,o)}(JSON.stringify(t))),!0)};var Yt,qt;(qt=Yt||(Yt={}))[qt.NotStarted=0]="NotStarted",qt[qt.Running=1]="Running",qt[qt.Stopped=2]="Stopped";var Pt="".concat("[Amplitude]"," Session Recorded"),zt="Session replay event batch rejected due to exceeded retry count",Qt="Failed to store session replay events in IndexedDB",Jt="".concat("AMP","_replay_unsent"),jt=function(){function e(){var e=this;this.name="@amplitude/plugin-session-replay-browser",this.type="enrichment",this.storageKey="",this.retryTimeout=1e3,this.events=[],this.currentSequenceId=0,this.scheduled=null,this.queue=[],this.stopRecordingEvents=null,this.maxPersistedEventsSize=19999800,this.interval=1e3,this.timeAtLastSend=null,this.shouldSplitEventsList=function(t){var n=new Blob([t]).size;return new Blob(e.events).size+n>=e.maxPersistedEventsSize||null!==e.timeAtLastSend&&Date.now()-e.timeAtLastSend>e.interval&&(e.interval=Math.min(1e4,e.interval+1e3),!0)}}return e.prototype.setup=function(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){return e.loggerProvider.log("Installing @amplitude/plugin-session-replay."),this.config=e,this.storageKey="".concat(Jt,"_").concat(this.config.apiKey.substring(0,10)),this.emptyStoreAndReset(),[2]}))}))},e.prototype.execute=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(r){return e.event_properties=n(n({},e.event_properties),((t={})[Pt]=!0,t)),"session_start"===e.event_type?this.recordEvents():"session_end"===e.event_type&&(e.session_id&&this.sendEventsList({events:this.events,sequenceId:this.currentSequenceId,sessionId:e.session_id}),this.stopRecordingEvents&&this.stopRecordingEvents(),this.events=[],this.currentSequenceId=0),[2,Promise.resolve(e)]}))}))},e.prototype.emptyStoreAndReset=function(){return r(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(o){switch(o.label){case 0:return[4,this.getAllSessionEventsFromStore()];case 1:if(e=o.sent()){for(t in e)(n=e[t]).events.length&&this.sendEventsList({events:n.events,sequenceId:n.sequenceId,sessionId:parseInt(t,10)});this.events=[],r=this.config.sessionId&&e[this.config.sessionId],this.currentSequenceId=r?r.sequenceId+1:0,this.storeEventsForSession([],this.currentSequenceId),this.recordEvents()}return[2]}}))}))},e.prototype.recordEvents=function(){var e=this;this.stopRecordingEvents=at({emit:function(t){var n=JSON.stringify(t);if(1===e.events.length&&0===e.currentSequenceId)return e.sendEventsList({events:e.events.concat(n),sequenceId:e.currentSequenceId,sessionId:e.config.sessionId}),e.events=[],void e.currentSequenceId++;e.shouldSplitEventsList(n)&&(e.sendEventsList({events:e.events,sequenceId:e.currentSequenceId,sessionId:e.config.sessionId}),e.events=[],e.currentSequenceId++),e.events.push(n),e.storeEventsForSession(e.events,e.currentSequenceId)},packFn:Kt,maskAllInputs:!0})},e.prototype.sendEventsList=function(e){var t=e.events,n=e.sequenceId,r=e.sessionId;this.addToQueue({events:t,sequenceId:n,attempts:0,timeout:0,sessionId:r})},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.filter((function(t){return t.attempts<e.config.flushMaxRetries?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"".concat(zt,", batch sequence id, ").concat(t.sequenceId)}),!1)}));r.forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(0)}))},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var n,r,s,i,a;return o(this,(function(o){switch(o.label){case 0:n={api_key:this.config.apiKey,device_id:this.config.deviceId,session_id:e.sessionId,start_timestamp:e.sessionId,events_batch:{version:1,events:e.events,seq_number:e.sequenceId}},o.label=1;case 1:return o.trys.push([1,3,,4]),r={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(n),method:"POST"},[4,fetch("https://api-secure.amplitude.com/sessions/track",r)];case 2:if(null===(s=o.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred",removeEvents:!1}),[2];if(t)this.handleReponse(s.status,e);else{i="";try{i=JSON.stringify(s.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(s.status,": ").concat(i)})}return[3,4];case 3:return a=o.sent(),this.completeRequest({context:e,err:a,removeEvents:!1}),[3,4];case 4:return[2]}}))}))},e.prototype.handleReponse=function(e,n){if((new s).buildStatus(e)===t.Success)this.handleSuccessResponse(n);else this.handleOtherResponse(n)},e.prototype.handleSuccessResponse=function(e){this.completeRequest({context:e,success:"Session replay event batch tracked successfully"})},e.prototype.handleOtherResponse=function(e){this.addToQueue(n(n({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.getAllSessionEventsFromStore=function(){return r(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,l(this.storageKey)];case 1:return[2,t.sent()];case 2:return e=t.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(e)),[3,3];case 3:return[2,void 0]}}))}))},e.prototype.storeEventsForSession=function(e,t){return r(this,void 0,void 0,(function(){var r,s=this;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,d(this.storageKey,(function(r){var o;return n(n({},r),s.config.sessionId&&((o={})[s.config.sessionId]={events:e,sequenceId:t},o))}))];case 1:return o.sent(),[3,3];case 2:return r=o.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(r)),[3,3];case 3:return[2]}}))}))},e.prototype.removeSessionEventsStore=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,d(this.storageKey,(function(t){return void 0===t&&(t={}),delete t[e],t}))];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(t)),[3,3];case 3:return[2]}}))}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success,o=e.removeEvents;(void 0===o||o)&&t.sessionId&&this.removeSessionEventsStore(t.sessionId),n?this.config.loggerProvider.error(n):r&&(this.timeAtLastSend=Date.now(),this.config.loggerProvider.log(r))},e}(),Ht=function(){return new jt};return e.plugin=Ht,e.sessionReplayPlugin=Ht,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ var sessionReplay=function(e){"use strict";var t,n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(t||(t={}));var s=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var n,r,o,s,i,a,c,l,d,u,h,p,g,m,f,I,C,y,v,S,b,A;if("object"!=typeof e)return null;var w=e.code||0,k=this.buildStatus(w);switch(k){case t.Success:return{status:k,statusCode:w,body:{eventsIngested:null!==(n=e.events_ingested)&&void 0!==n?n:0,payloadSizeBytes:null!==(r=e.payload_size_bytes)&&void 0!==r?r:0,serverUploadTime:null!==(o=e.server_upload_time)&&void 0!==o?o:0}};case t.Invalid:return{status:k,statusCode:w,body:{error:null!==(s=e.error)&&void 0!==s?s:"",missingField:null!==(i=e.missing_field)&&void 0!==i?i:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(c=e.events_with_missing_fields)&&void 0!==c?c:{},eventsWithInvalidIdLengths:null!==(l=e.events_with_invalid_id_lengths)&&void 0!==l?l:{},epsThreshold:null!==(d=e.eps_threshold)&&void 0!==d?d:0,exceededDailyQuotaDevices:null!==(u=e.exceeded_daily_quota_devices)&&void 0!==u?u:{},silencedDevices:null!==(h=e.silenced_devices)&&void 0!==h?h:[],silencedEvents:null!==(p=e.silenced_events)&&void 0!==p?p:[],throttledDevices:null!==(g=e.throttled_devices)&&void 0!==g?g:{},throttledEvents:null!==(m=e.throttled_events)&&void 0!==m?m:[]}};case t.PayloadTooLarge:return{status:k,statusCode:w,body:{error:null!==(f=e.error)&&void 0!==f?f:""}};case t.RateLimit:return{status:k,statusCode:w,body:{error:null!==(I=e.error)&&void 0!==I?I:"",epsThreshold:null!==(C=e.eps_threshold)&&void 0!==C?C:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(v=e.throttled_users)&&void 0!==v?v:{},exceededDailyQuotaDevices:null!==(S=e.exceeded_daily_quota_devices)&&void 0!==S?S:{},exceededDailyQuotaUsers:null!==(b=e.exceeded_daily_quota_users)&&void 0!==b?b:{},throttledEvents:null!==(A=e.throttled_events)&&void 0!==A?A:[]}};case t.Timeout:default:return{status:k,statusCode:w}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?t.Success:429===e?t.RateLimit:413===e?t.PayloadTooLarge:408===e?t.Timeout:e>=400&&e<500?t.Invalid:e>=500?t.Failed:t.Unknown},e}();function i(e){return new Promise(((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}))}let a;function c(){return a||(a=function(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=i(n);return(e,n)=>r.then((r=>n(r.transaction(t,e).objectStore(t))))}("keyval-store","keyval")),a}function l(e,t=c()){return t("readonly",(t=>i(t.get(e))))}function d(e,t,n=c()){return n("readwrite",(n=>new Promise(((r,o)=>{n.get(e).onsuccess=function(){try{n.put(t(this.result),e),r(i(n.transaction))}catch(e){o(e)}}}))))}var u;function h(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function p(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function g(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(m).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function m(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=g(e.styleSheet)||t}catch(e){}return t}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(u||(u={}));var f=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function I(e){var t=e.maskInputOptions,n=e.tagName,r=e.type,o=e.value,s=e.maskInputFn,i=o||"";return(t[n.toLowerCase()]||t[r])&&(i=s?s(i):"*".repeat(i.length)),i}var C="__rrweb_original__";var y,v,S=1,b=new RegExp("[^a-z0-9-_:]");function A(){return S++}var w=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,k=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,M=/^(data:)([^,]*),(.*)/i;function T(e,t){return(e||"").replace(w,(function(e,n,r,o,s,i){var a,c=r||s||i,l=n||o||"";if(!c)return e;if(!k.test(c))return"url(".concat(l).concat(c).concat(l,")");if(M.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var d=t.split("/"),u=c.split("/");d.pop();for(var h=0,p=u;h<p.length;h++){var g=p[h];"."!==g&&(".."===g?d.pop():d.push(g))}return"url(".concat(l).concat(d.join("/")).concat(l,")")}))}var E=/^[^ \t\n\r\u000c]+/,N=/^[, \t\n\r\u000c]+/;function R(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function O(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function D(){var e=document.createElement("a");return e.href="",e.href}function x(e,t,n,r){return"src"===n||"href"===n&&r&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&r&&"#"!==r[0]?R(e,r):"background"!==n||!r||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&r?function(e,t){if(""===t.trim())return t;var n=0;function r(e){var r,o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}for(var o=[];r(N),!(n>=t.length);){var s=r(E);if(","===s.slice(-1))s=R(e,s.substring(0,s.length-1)),o.push(s);else{var i="";s=R(e,s);for(var a=!1;;){var c=t.charAt(n);if(""===c){o.push((s+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,o.push((s+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return o.join(", ")}(e,r):"style"===n&&r?T(r,D()):"object"===t&&"data"===n&&r?R(e,r):r:R(e,r)}function F(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&F(e.parentNode,t,n);for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&F(e.parentNode,t,n)}function L(e,t,n){var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(r.closest(".".concat(t)))return!0}else if(F(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}return!1}function _(e,t){var n=t.doc,r=t.mirror,o=t.blockClass,s=t.blockSelector,i=t.maskTextClass,a=t.maskTextSelector,c=t.inlineStylesheet,l=t.maskInputOptions,d=void 0===l?{}:l,h=t.maskTextFn,p=t.maskInputFn,m=t.dataURLOptions,f=void 0===m?{}:m,S=t.inlineImages,A=t.recordCanvas,w=t.keepIframeSrcFn,k=t.newlyAddedElement,M=void 0!==k&&k,E=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:u.Document,childNodes:[],compatMode:e.compatMode}:{type:u.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:u.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:E};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,r=t.blockClass,o=t.blockSelector,s=t.inlineStylesheet,i=t.maskInputOptions,a=void 0===i?{}:i,c=t.maskInputFn,l=t.dataURLOptions,d=void 0===l?{}:l,h=t.inlineImages,p=t.recordCanvas,m=t.keepIframeSrcFn,f=t.newlyAddedElement,S=void 0!==f&&f,A=t.rootId,w=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&e.matches(n)}(e,r,o),k=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return b.test(t)?"div":t}(e),M={},E=e.attributes.length,N=0;N<E;N++){var R=e.attributes[N];M[R.name]=x(n,k,R.name,R.value)}if("link"===k&&s){var F=Array.from(n.styleSheets).find((function(t){return t.href===e.href})),L=null;F&&(L=g(F)),L&&(delete M.rel,delete M.href,M._cssText=T(L,F.href))}if("style"===k&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(L=g(e.sheet))&&(M._cssText=T(L,D()))}if("input"===k||"textarea"===k||"select"===k){var _=e.value,W=e.checked;"radio"!==M.type&&"checkbox"!==M.type&&"submit"!==M.type&&"button"!==M.type&&_?M.value=I({type:M.type,tagName:k,value:_,maskInputOptions:a,maskInputFn:c}):W&&(M.checked=W)}"option"===k&&(e.selected&&!a.select?M.selected=!0:delete M.selected);if("canvas"===k&&p)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var r=0;r<e.height;r+=50){var o=t.getImageData,s=C in o?o[C]:o;if(new Uint32Array(s.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(M.rr_dataURL=e.toDataURL(d.type,d.quality));else if(!("__context"in e)){var B=e.toDataURL(d.type,d.quality),G=document.createElement("canvas");G.width=e.width,G.height=e.height,B!==G.toDataURL(d.type,d.quality)&&(M.rr_dataURL=B)}if("img"===k&&h){y||(y=n.createElement("canvas"),v=y.getContext("2d"));var U=e,Z=U.crossOrigin;U.crossOrigin="anonymous";var V=function(){try{y.width=U.naturalWidth,y.height=U.naturalHeight,v.drawImage(U,0,0),M.rr_dataURL=y.toDataURL(d.type,d.quality)}catch(e){console.warn("Cannot inline img src=".concat(U.currentSrc,"! Error: ").concat(e))}Z?M.crossOrigin=Z:U.removeAttribute("crossorigin")};U.complete&&0!==U.naturalWidth?V():U.onload=V}"audio"!==k&&"video"!==k||(M.rr_mediaState=e.paused?"paused":"played",M.rr_mediaCurrentTime=e.currentTime);S||(e.scrollLeft&&(M.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(M.rr_scrollTop=e.scrollTop));if(w){var K=e.getBoundingClientRect(),Y=K.width,q=K.height;M={class:M.class,rr_width:"".concat(Y,"px"),rr_height:"".concat(q,"px")}}"iframe"!==k||m(M.src)||(e.contentDocument||(M.rr_src=M.src),delete M.src);return{type:u.Element,tagName:k,attributes:M,childNodes:[],isSVG:O(e)||void 0,needBlock:w,rootId:A}}(e,{doc:n,blockClass:o,blockSelector:s,inlineStylesheet:c,maskInputOptions:d,maskInputFn:p,dataURLOptions:f,inlineImages:S,recordCanvas:A,keepIframeSrcFn:w,newlyAddedElement:M,rootId:E});case e.TEXT_NODE:return function(e,t){var n,r=t.maskTextClass,o=t.maskTextSelector,s=t.maskTextFn,i=t.rootId,a=e.parentNode&&e.parentNode.tagName,c=e.textContent,l="STYLE"===a||void 0,d="SCRIPT"===a||void 0;if(l&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(h=e.parentNode.sheet).cssRules?Array.from(h.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=T(c,D())}var h;d&&(c="SCRIPT_PLACEHOLDER");!l&&!d&&c&&L(e,r,o)&&(c=s?s(c):c.replace(/[\S]/g,"*"));return{type:u.Text,textContent:c||"",isStyle:l,rootId:i}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:h,rootId:E});case e.CDATA_SECTION_NODE:return{type:u.CDATA,textContent:"",rootId:E};case e.COMMENT_NODE:return{type:u.Comment,textContent:e.textContent||"",rootId:E};default:return!1}}function W(e){return void 0===e?"":e.toLowerCase()}function B(e,t){var n,r=t.doc,o=t.mirror,s=t.blockClass,i=t.blockSelector,a=t.maskTextClass,c=t.maskTextSelector,l=t.skipChild,d=void 0!==l&&l,g=t.inlineStylesheet,m=void 0===g||g,f=t.maskInputOptions,I=void 0===f?{}:f,C=t.maskTextFn,y=t.maskInputFn,v=t.slimDOMOptions,S=t.dataURLOptions,b=void 0===S?{}:S,w=t.inlineImages,k=void 0!==w&&w,M=t.recordCanvas,T=void 0!==M&&M,E=t.onSerialize,N=t.onIframeLoad,R=t.iframeLoadTimeout,O=void 0===R?5e3:R,D=t.onStylesheetLoad,x=t.stylesheetLoadTimeout,F=void 0===x?5e3:x,L=t.keepIframeSrcFn,G=void 0===L?function(){return!1}:L,U=t.newlyAddedElement,Z=void 0!==U&&U,V=t.preserveWhiteSpace,K=void 0===V||V,Y=_(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,dataURLOptions:b,inlineImages:k,recordCanvas:T,keepIframeSrcFn:G,newlyAddedElement:Z});if(!Y)return console.warn(e,"not serialized"),null;n=o.hasNode(e)?o.getId(e):!function(e,t){if(t.comment&&e.type===u.Comment)return!0;if(e.type===u.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(W(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===W(e.attributes.name)||"icon"===W(e.attributes.rel)||"apple-touch-icon"===W(e.attributes.rel)||"shortcut icon"===W(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&W(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(W(e.attributes.property).match(/^(og|twitter|fb):/)||W(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===W(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===W(e.attributes.name)||"googlebot"===W(e.attributes.name)||"bingbot"===W(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===W(e.attributes.name)||"generator"===W(e.attributes.name)||"framework"===W(e.attributes.name)||"publisher"===W(e.attributes.name)||"progid"===W(e.attributes.name)||W(e.attributes.property).match(/^article:/)||W(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===W(e.attributes.name)||"yandex-verification"===W(e.attributes.name)||"csrf-token"===W(e.attributes.name)||"p:domain_verify"===W(e.attributes.name)||"verify-v1"===W(e.attributes.name)||"verification"===W(e.attributes.name)||"shopify-checkout-api-token"===W(e.attributes.name)))return!0}}return!1}(Y,v)&&(K||Y.type!==u.Text||Y.isStyle||Y.textContent.replace(/^\s+|\s+$/gm,"").length)?A():-2;var q=Object.assign(Y,{id:n});if(o.add(e,q),-2===n)return null;E&&E(e);var P=!d;if(q.type===u.Element){P=P&&!q.needBlock,delete q.needBlock;var z=e.shadowRoot;z&&p(z)&&(q.isShadowHost=!0)}if((q.type===u.Document||q.type===u.Element)&&P){v.headWhitespace&&q.type===u.Element&&"head"===q.tagName&&(K=!1);for(var Q={doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:d,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G},J=0,j=Array.from(e.childNodes);J<j.length;J++){($=B(j[J],Q))&&q.childNodes.push($)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var H=0,X=Array.from(e.shadowRoot.childNodes);H<X.length;H++){var $;($=B(X[H],Q))&&(p(e.shadowRoot)&&($.isShadow=!0),q.childNodes.push($))}}return e.parentNode&&h(e.parentNode)&&p(e.parentNode)&&(q.isShadow=!0),q.type===u.Element&&"iframe"===q.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var o,s=!1;try{o=r.document.readyState}catch(e){return}if("complete"===o){var i="about:blank";if(r.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout((function(){s||(t(),s=!0)}),n);e.addEventListener("load",(function(){clearTimeout(a),s=!0,t()}))}}}(e,(function(){var t=e.contentDocument;if(t&&N){var n=B(t,{doc:t,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G});n&&N(e,n)}}),O),q.type===u.Element&&"link"===q.tagName&&"stylesheet"===q.attributes.rel&&function(e,t,n){var r,o=!1;try{r=e.sheet}catch(e){return}if(!r){var s=setTimeout((function(){o||(t(),o=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),o=!0,t()}))}}(e,(function(){if(D){var t=B(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G});t&&D(e,t)}}),F),q}function G(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const U="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Z={map:{},getId:()=>(console.error(U),-1),getNode:()=>(console.error(U),null),removeNodeFromMap(){console.error(U)},has:()=>(console.error(U),!1),reset(){console.error(U)}};function V(e,t,n={}){let r=null,o=0;return function(...s){const i=Date.now();o||!1!==n.leading||(o=i);const a=t-(i-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=i,e.apply(c,s)):r||!1===n.trailing||(r=setTimeout((()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,s)}),a))}}function K(e,t,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>K(e,t,s||{},!0)}function Y(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch(e){return()=>{}}}function q(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function P(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function z(e,t,n,r){if(!e)return!1;const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(F(o,t,r))return!0;if(n){if(e.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function Q(e,t){return-2===t.getId(e)}function J(e,t){if(h(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||J(e.parentNode,t))}function j(e){return Boolean(e.changedTouches)}function H(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function X(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function $(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Z=new Proxy(Z,{get:(e,t,n)=>("map"===t&&console.error(U),Reflect.get(e,t,n))}));class ee{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var te=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(te||{}),ne=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(ne||{}),re=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(re||{}),oe=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(oe||{});function se(e){return"__ln"in e}class ie{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&se(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&se(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next&&(t.next.previous=t.previous)):(this.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const ae=(e,t)=>`${e}@${t}`;class ce{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new ie,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},r=r=>{var o,s,i,a;let c=null;(null===(s=null===(o=r.getRootNode)||void 0===o?void 0:o.call(r))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&r.getRootNode().host&&(c=r.getRootNode().host);let l=c;for(;(null===(a=null===(i=null==l?void 0:l.getRootNode)||void 0===i?void 0:i.call(l))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&l.getRootNode().host;)l=l.getRootNode().host;const d=!(this.doc.contains(r)||l&&this.doc.contains(l));if(!r.parentNode||d)return;const u=h(r.parentNode)?this.mirror.getId(c):this.mirror.getId(r.parentNode),p=n(r);if(-1===u||-1===p)return t.addNode(r);const g=B(r,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{H(e,this.mirror)&&this.iframeManager.addIframe(e),X(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),$(r)&&this.shadowDomManager.addShadowRoot(r.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});g&&e.push({parentId:u,nextId:p,node:g})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))de(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||r(e);for(const e of Array.from(this.addedSet.values()))he(this.droppedSet,e)||de(this.removes,e,this.mirror)?he(this.movedSet,e)?r(e):this.droppedSet.add(e):r(e);let o=null;for(;t.length;){let e=null;if(o){const t=this.mirror.getId(o.value.parentNode),r=n(o.value);-1!==t&&-1!==r&&(e=o)}if(!e)for(let r=t.length-1;r>=0;r--){const o=t.get(r);if(o){const t=this.mirror.getId(o.value.parentNode);if(-1===n(o.value))continue;if(-1!==t){e=o;break}{const t=o.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=o;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}o=e.previous,t.removeNode(e.value),r(e.value)}const s={texts:this.texts.map((e=>({id:this.mirror.getId(e.node),value:e.value}))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>({id:this.mirror.getId(e.node),attributes:e.attributes}))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!Q(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;z(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:L(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=I({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),z(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let r=this.attributes.find((t=>t.node===e.target));if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(r||(r={node:e.target,attributes:{}},this.attributes.push(r)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==r.attributes.style&&null!==r.attributes.style||(r.attributes.style={});const o=r.attributes.style;for(const e of Array.from(t.style)){const r=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);r===n.style.getPropertyValue(e)&&s===n.style.getPropertyPriority(e)||(o[e]=""===s?r:[r,s])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(o[e]=!1)}else r.attributes[e.attributeName]=x(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(z(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),r=h(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);z(e.target,this.blockClass,this.blockSelector,!1)||Q(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(le(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||J(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[ae(n,r)]?le(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!h(e.target)||!p(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(Q(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[ae(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);z(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach((e=>this.genAdds(e)))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach((t=>{this[t]=e[t]}))}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function le(e,t){e.delete(t),t.childNodes.forEach((t=>le(e,t)))}function de(e,t,n){return 0!==e.length&&ue(e,t,n)}function ue(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some((e=>e.id===o))||ue(e,r,n)}function he(e,t){return 0!==e.size&&pe(e,t)}function pe(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||pe(e,n))}const ge=[],me="undefined"!=typeof CSSGroupingRule,fe="undefined"!=typeof CSSMediaRule,Ie="undefined"!=typeof CSSSupportsRule,Ce="undefined"!=typeof CSSConditionRule;function ye(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function ve(e,t){var n,r;const o=new ce;ge.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(o.processMutations.bind(o));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function Se({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(re).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{const i=s.toLowerCase(),c=(t=>s=>{const i=ye(s);if(z(i,r,o,!0))return;const a=j(s)?s.changedTouches[0]:s;if(!a)return;const c=n.getId(i),{clientX:l,clientY:d}=a;e({type:re[t],id:c,x:l,y:d})})(s);a.push(G(i,c,t))})),()=>{a.forEach((e=>e()))}}function be({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){return G("scroll",V((s=>{const i=ye(s);if(!i||z(i,r,o,!0))return;const a=n.getId(i);if(i===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})}),s.scroll||100),t)}function Ae(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const we=["INPUT","TEXTAREA","SELECT"],ke=new WeakMap;function Me(e){return function(e,t){if(me&&e.parentRule instanceof CSSGroupingRule||fe&&e.parentRule instanceof CSSMediaRule||Ie&&e.parentRule instanceof CSSSupportsRule||Ce&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function Te(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function Ee({mirror:e,stylesheetManager:t},n){var r,o,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(s=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===s?void 0:s.ShadowRoot,c=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==i&&-1!==i&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return r}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function Ne(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t);const r=ve(e,e.doc),o=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=V((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null}),s),l=V((e=>{const t=ye(e),{clientX:n,clientY:o}=j(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:o,id:r.getId(t),timeOffset:Date.now()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?ne.Drag:e instanceof MouseEvent?ne.MouseMove:ne.TouchMove)}),o,{trailing:!1}),d=[G("mousemove",l,n),G("touchmove",l,n),G("drag",l,n)];return()=>{d.forEach((e=>e()))}}(e),s=Se(e),i=be(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return G("resize",V((()=>{const r=q(),o=P();t===r&&n===o||(e({width:Number(o),height:Number(r)}),t=r,n=o)}),200),window)}(e),c=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:s,maskInputOptions:i,maskInputFn:a,sampling:c,userTriggeredOnInput:l}){function d(e){let n=ye(e);const c=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||we.indexOf(n.tagName)<0||z(n,r,o,!0))return;const d=n.type;if(n.classList.contains(s))return;let h=n.value,p=!1;"radio"===d||"checkbox"===d?p=n.checked:(i[n.tagName.toLowerCase()]||i[d])&&(h=I({maskInputOptions:i,tagName:n.tagName,type:d,value:h,maskInputFn:a})),u(n,Ae({text:h,isChecked:p,userTriggered:c},l));const g=n.name;"radio"===d&&g&&p&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach((e=>{e!==n&&u(e,Ae({text:e.value,isChecked:!p,userTriggered:!1},l))}))}function u(t,r){const o=ke.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){ke.set(t,r);const o=n.getId(t);e(Object.assign(Object.assign({},r),{id:o}))}}const h=("last"===c.input?["change"]:["input","change"]).map((e=>G(e,d,t))),p=t.defaultView;if(!p)return()=>{h.forEach((e=>e()))};const g=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),m=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return g&&g.set&&h.push(...m.map((e=>K(e[0],e[1],{set(){d({target:this})}},!1,p)))),()=>{h.forEach((e=>e()))}}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o}){const s=s=>V((o=>{const i=ye(o);if(!i||z(i,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=i;e({type:s,id:r.getId(i),currentTime:a,volume:c,muted:l,playbackRate:d})}),o.media||500),i=[G("play",s(0)),G("pause",s(1)),G("seeked",s(2)),G("volumechange",s(3)),G("ratechange",s(4))];return()=>{i.forEach((e=>e()))}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=function(r,s){const{id:i,styleId:a}=Te(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:s}]}),o.apply(this,[r,s])};const s=r.CSSStyleSheet.prototype.deleteRule;let i,a;r.CSSStyleSheet.prototype.deleteRule=function(r){const{id:o,styleId:i}=Te(this,t,n.styleMirror);return(o&&-1!==o||i&&-1!==i)&&e({id:o,styleId:i,removes:[{index:r}]}),s.apply(this,[r])},r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=function(r){const{id:o,styleId:s}=Te(this,t,n.styleMirror);return(o&&-1!==o||s&&-1!==s)&&e({id:o,styleId:s,replace:r}),i.apply(this,[r])}),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=function(r){const{id:o,styleId:s}=Te(this,t,n.styleMirror);return(o&&-1!==o||s&&-1!==s)&&e({id:o,styleId:s,replaceSync:r}),a.apply(this,[r])});const c={};me?c.CSSGroupingRule=r.CSSGroupingRule:(fe&&(c.CSSMediaRule=r.CSSMediaRule),Ce&&(c.CSSConditionRule=r.CSSConditionRule),Ie&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach((([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=function(o,s){const{id:i,styleId:a}=Te(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:o,index:[...Me(this),s||0]}]}),l[r].insertRule.apply(this,[o,s])},o.prototype.deleteRule=function(o){const{id:s,styleId:i}=Te(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:[...Me(this),o]}]}),l[r].deleteRule.apply(this,[o])}})),()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=s,i&&(r.CSSStyleSheet.prototype.replace=i),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule}))}}(e,{win:n}),u=Ee(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=function(o,i,a){var c;if(n.has(o))return s.apply(this,[o,i,a]);const{id:l,styleId:d}=Te(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:o,value:i,priority:a},index:Me(this.parentRule)}),s.apply(this,[o,i,a])};const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=function(o){var s;if(n.has(o))return i.apply(this,[o]);const{id:a,styleId:c}=Te(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,t,r.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:o},index:Me(this.parentRule)}),i.apply(this,[o])},()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),p=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const r=new s(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const i=Y(t.fonts,"add",(function(t){return function(n){return setTimeout((()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.apply(this,[n])}}));return r.push((()=>{n.FontFace=s})),r.push(i),()=>{r.forEach((e=>e()))}}(e):()=>{},g=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:s}=e;let i=!0;const a=()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:c,endContainer:l,endOffset:d}=s;z(i,r,o,!0)||z(l,r,o,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(l),endOffset:d})}s({ranges:a})};return a(),G("selectionchange",a)}(e),m=[];for(const t of e.plugins)m.push(t.observer(t.callback,n,t.options));return()=>{ge.forEach((e=>e.reset())),r.disconnect(),o(),s(),i(),a(),c(),l(),d(),u(),h(),p(),g(),m.forEach((e=>e()))}}class Re{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),s=r||this.getRemoteIdToIdMap(e);let i=o.get(t);return i||(i=this.generateIdFn(),o.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,r)))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map((t=>this.getRemoteId(e,t,n)))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class Oe{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Re(A),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Re(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case te.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:te.IncrementalSnapshot,data:{source:ne.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case te.Meta:case te.Load:case te.DomContentLoaded:return!1;case te.Plugin:return t;case te.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case te.IncrementalSnapshot:switch(t.data.source){case ne.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)})),t.data.removes.forEach((t=>{this.replaceIds(t,e,["parentId","id"])})),t.data.attributes.forEach((t=>{this.replaceIds(t,e,["id"])})),t.data.texts.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ne.Drag:case ne.TouchMove:case ne.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ne.ViewportResize:return!1;case ne.MediaInteraction:case ne.MouseInteraction:case ne.Scroll:case ne.CanvasMutation:case ne.Input:return this.replaceIds(t.data,e,["id"]),t;case ne.StyleSheetRule:case ne.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case ne.Font:return t;case ne.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case ne.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach((t=>{this.replaceStyleIds(t,e,["styleId"])})),t}}}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}}class De{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(Y(Element.prototype,"attachShadow",(function(e){return function(n){const r=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),r}})))}addShadowRoot(e,t){p(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ve(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),be(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout((()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),Ee({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)}),0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(Y(e.contentWindow.HTMLElement.prototype,"attachShadow",(function(n){return function(r){const o=n.call(this,r);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),o}})))}}reset(){this.restorePatches.forEach((e=>e())),this.shadowDoms=new WeakSet}}function xe(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}for(var Fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Le="undefined"==typeof Uint8Array?[]:new Uint8Array(256),_e=0;_e<Fe.length;_e++)Le[Fe.charCodeAt(_e)]=_e;const We=new Map;const Be=(e,t,n)=>{if(!e||!Ze(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=We.get(e);return n||(n=new Map,We.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Ge(e,t,n){if(e instanceof Array)return e.map((e=>Ge(e,t,n)));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Fe[n[t]>>2],o+=Fe[(3&n[t])<<4|n[t+1]>>4],o+=Fe[(15&n[t+1])<<2|n[t+2]>>6],o+=Fe[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Ge(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Ge(e.data,t,n),e.width,e.height]}}if(Ze(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Be(e,t,n)}}return e}const Ue=(e,t,n)=>[...e].map((e=>Ge(e,t,n))),Ze=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((e=>"function"==typeof t[e]));return Boolean(n.find((n=>e instanceof t[n])))};function Ve(e,t,n){const r=[];try{const o=Y(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(r,...o){return z(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...o])}}));r.push(o)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{r.forEach((e=>e()))}}function Ke(e,t,n,r,o,s,i){const a=[],c=Object.getOwnPropertyNames(e);for(const s of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const c=Y(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(Be(c,i,this),!z(this.canvas,r,o,!0)){const e=Ue([...a],i,this),r={type:t,property:s,args:e};n(this.canvas,r)}return c}}));a.push(c)}catch(r){const o=K(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(o)}return a}var Ye=null;try{var qe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Ye=qe.Worker}catch(e){}function Pe(e,t,n){var r=void 0===t?null:t,o=function(e,t){return Buffer.from(e,"base64").toString(t?"utf16":"utf8")}(e,void 0!==n&&n),s=o.indexOf("\n",10)+1,i=o.substring(s)+(r?"//# sourceMappingURL="+r:"");return function(e){return new Ye(i,Object.assign({},e,{eval:!0}))}}function ze(e,t,n){var r=void 0===t?null:t,o=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),o=0,s=n.length;o<s;++o)r[o]=n.charCodeAt(o);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(e,void 0!==n&&n),s=o.indexOf("\n",10)+1,i=o.substring(s)+(r?"//# sourceMappingURL="+r:""),a=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(a)}var Qe="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Je,je,He,Xe=(Je="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2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0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",je=null,He=!1,Qe?Pe(Je,je,He):function(e,t,n){var r;return function(o){return r=r||ze(e,t,n),new Worker(r,o)}}(Je,je,He));class $e{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,r,o),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:i})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,o){const s=Ve(t,n,r),i=new Map,a=new Xe;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:s}=e.data;this.mutationCb({id:t,type:oe["2D"],commands:[{property:"clearRect",args:[0,0,o,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{z(t,n,r,!0)||e.push(t)})),e})().forEach((e=>xe(this,void 0,void 0,(function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ve(e,t,n),o=function(e,t,n,r){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=Y(t.CanvasRenderingContext2D.prototype,i,(function(o){return function(...s){return z(this.canvas,n,r,!0)||setTimeout((()=>{const n=Ue([...s],t,this);e(this.canvas,{type:oe["2D"],property:i,args:n})}),0),o.apply(this,s)}}));o.push(s)}catch(n){const r=K(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:oe["2D"],property:i,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,r,o){const s=[];return s.push(...Ke(t.WebGLRenderingContext.prototype,oe.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...Ke(t.WebGL2RenderingContext.prototype,oe.WebGL2,e,n,r,0,t)),()=>{s.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach(((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)})),requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map((e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t})),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class et{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new ee,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map(((e,t)=>({rule:m(e),index:t})))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function tt(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let nt,rt,ot,st=!1;const it=new f;function at(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:c=null,inlineStylesheet:l=!0,maskAllInputs:d,maskInputOptions:u,slimDOMOptions:h,maskInputFn:p,maskTextFn:g,hooks:m,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:w=!1,inlineImages:k=!1,plugins:M,keepIframeSrcFn:T=(()=>!1),ignoreCSSAttributes:E=new Set([])}=e,N=!b||window.parent===window;let R=!1;if(!N)try{window.parent.document,R=!1}catch(e){R=!0}if(N&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),it.reset();const O=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==u?u:{password:!0},D=!0===h||"all"===h?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===h,headMetaDescKeywords:"all"===h}:h||{};let x;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let F=0;const L=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};nt=(e,o)=>{var s;if(!(null===(s=ge[0])||void 0===s?void 0:s.isFrozen())||e.type===te.FullSnapshot||e.type===te.IncrementalSnapshot&&e.data.source===ne.Mutation||ge.forEach((e=>e.unfreeze())),N)null==t||t(L(e),o);else if(R){const t={type:"rrweb",event:L(e),isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===te.FullSnapshot)x=e,F=0;else if(e.type===te.IncrementalSnapshot){if(e.data.source===ne.Mutation&&e.data.isAttachIframe)return;F++;const t=r&&F>=r,o=n&&e.timestamp-x.timestamp>n;(t||o)&&rt(!0)}};const _=e=>{nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Mutation},e)}))},W=e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Scroll},e)})),U=e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.CanvasMutation},e)})),Z=new et({mutationCb:_,adoptedStyleSheetCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.AdoptedStyleSheet},e)}))}),V=new Oe({mirror:it,mutationCb:_,stylesheetManager:Z,recordCrossOriginIframes:b,wrappedEmit:nt});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:it,crossOriginIframeMirror:V.crossOriginIframeMirror,crossOriginIframeStyleMirror:V.crossOriginIframeStyleMirror});ot=new $e({recordCanvas:S,mutationCb:U,win:window,blockClass:o,blockSelector:s,mirror:it,sampling:C.canvas,dataURLOptions:y});const K=new De({mutationCb:_,scrollCb:W,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskInputOptions:O,dataURLOptions:y,maskTextFn:g,maskInputFn:p,recordCanvas:S,inlineImages:k,sampling:C,slimDOMOptions:D,iframeManager:V,stylesheetManager:Z,canvasManager:ot,keepIframeSrcFn:T},mirror:it});rt=(e=!1)=>{var t,n,r,i,d,u;nt(tt({type:te.Meta,data:{href:window.location.href,width:P(),height:q()}}),e),Z.reset(),ge.forEach((e=>e.lock()));const h=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new f:r,s=n.blockClass,i=void 0===s?"rr-block":s,a=n.blockSelector,c=void 0===a?null:a,l=n.maskTextClass,d=void 0===l?"rr-mask":l,u=n.maskTextSelector,h=void 0===u?null:u,p=n.inlineStylesheet,g=void 0===p||p,m=n.inlineImages,I=void 0!==m&&m,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,w=n.slimDOM,k=void 0!==w&&w,M=n.dataURLOptions,T=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,R=n.iframeLoadTimeout,O=n.onStylesheetLoad,D=n.stylesheetLoadTimeout,x=n.keepIframeSrcFn;return B(e,{doc:e,mirror:o,blockClass:i,blockSelector:c,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:g,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:T,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:R,onStylesheetLoad:O,stylesheetLoadTimeout:D,keepIframeSrcFn:void 0===x?function(){return!1}:x,newlyAddedElement:!1})}(document,{mirror:it,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskAllInputs:O,maskTextFn:g,slimDOM:D,dataURLOptions:y,recordCanvas:S,inlineImages:k,onSerialize:e=>{H(e,it)&&V.addIframe(e),X(e,it)&&Z.trackLinkElement(e),$(e)&&K.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{V.attachIframe(e,t),K.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{Z.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!h)return console.warn("Failed to snapshot the document");nt(tt({type:te.FullSnapshot,data:{node:h,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),ge.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Z.adoptStyleSheets(document.adoptedStyleSheets,it.getId(document))};try{const e=[];e.push(G("DOMContentLoaded",(()=>{nt(tt({type:te.DomContentLoaded,data:{}}))})));const t=e=>{var t;return Ne({mutationCb:_,mousemoveCb:(e,t)=>nt(tt({type:te.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.MouseInteraction},e)})),scrollCb:W,viewportResizeCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.ViewportResize},e)})),inputCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Input},e)})),mediaInteractionCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.MediaInteraction},e)})),styleSheetRuleCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.StyleSheetRule},e)})),styleDeclarationCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.StyleDeclaration},e)})),canvasMutationCb:U,fontCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Font},e)})),selectionCb:e=>{nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Selection},e)}))},blockClass:o,ignoreClass:i,maskTextClass:a,maskTextSelector:c,maskInputOptions:O,inlineStylesheet:l,sampling:C,recordCanvas:S,inlineImages:k,userTriggeredOnInput:A,collectFonts:w,doc:e,maskInputFn:p,maskTextFn:g,keepIframeSrcFn:T,blockSelector:s,slimDOMOptions:D,dataURLOptions:y,mirror:it,iframeManager:V,stylesheetManager:Z,shadowDomManager:K,canvasManager:ot,ignoreCSSAttributes:E,plugins:(null===(t=null==M?void 0:M.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>nt(tt({type:te.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},m)};V.addLoadListener((n=>{e.push(t(n.contentDocument))}));const n=()=>{rt(),e.push(t(document)),st=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(G("load",(()=>{nt(tt({type:te.Load,data:{}})),n()}),window)),()=>{e.forEach((e=>e())),st=!1}}catch(e){console.warn(e)}}var ct,lt;at.addCustomEvent=(e,t)=>{if(!st)throw new Error("please add custom event after start recording");nt(tt({type:te.Custom,data:{tag:e,payload:t}}))},at.freezePage=()=>{ge.forEach((e=>e.freeze()))},at.takeFullSnapshot=e=>{if(!st)throw new Error("please take full snapshot after start recording");rt(e)},at.mirror=it,function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(ct||(ct={})),function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"}(lt||(lt={}));var dt=Uint8Array,ut=Uint16Array,ht=Uint32Array,pt=new dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),gt=new dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),mt=new dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ft=function(e,t){for(var n=new ut(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new ht(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return[n,o]},It=ft(pt,2),Ct=It[0],yt=It[1];Ct[28]=258,yt[258]=28;for(var vt=ft(gt,0)[1],St=new ut(32768),bt=0;bt<32768;++bt){var At=(43690&bt)>>>1|(21845&bt)<<1;At=(61680&(At=(52428&At)>>>2|(13107&At)<<2))>>>4|(3855&At)<<4,St[bt]=((65280&At)>>>8|(255&At)<<8)>>>1}var wt=function(e,t,n){for(var r=e.length,o=0,s=new ut(t);o<r;++o)++s[e[o]-1];var i,a=new ut(t);for(o=0;o<t;++o)a[o]=a[o-1]+s[o-1]<<1;if(n){i=new ut(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],d=t-e[o],u=a[e[o]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)i[St[u]>>>c]=l}else for(i=new ut(r),o=0;o<r;++o)i[o]=St[a[e[o]-1]++]>>>15-e[o];return i},kt=new dt(288);for(bt=0;bt<144;++bt)kt[bt]=8;for(bt=144;bt<256;++bt)kt[bt]=9;for(bt=256;bt<280;++bt)kt[bt]=7;for(bt=280;bt<288;++bt)kt[bt]=8;var Mt=new dt(32);for(bt=0;bt<32;++bt)Mt[bt]=5;var Tt=wt(kt,9,0),Et=wt(Mt,5,0),Nt=function(e){return(e/8>>0)+(7&e&&1)},Rt=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof ut?ut:e instanceof ht?ht:dt)(n-t);return r.set(e.subarray(t,n)),r},Ot=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},Dt=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},xt=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,s=n.slice();if(!o)return[new dt(0),0];if(1==o){var i=new dt(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,u=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=o-1;)a=n[n[l].f<n[u].f?l++:u++],c=n[l!=d&&n[l].f<n[u].f?l++:u++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(r=1;r<o;++r)s[r].s>h&&(h=s[r].s);var p=new ut(h+1),g=Ft(n[d-1],p,0);if(g>t){r=0;var m=0,f=g-t,I=1<<f;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));r<o;++r){var C=s[r].s;if(!(p[C]>t))break;m+=I-(1<<g-p[C]),p[C]=t}for(m>>>=f;m>0;){var y=s[r].s;p[y]<t?m-=1<<t-p[y]++-1:++r}for(;r>=0&&m;--r){var v=s[r].s;p[v]==t&&(--p[v],++m)}g=t}return[new dt(p),g]},Ft=function(e,t,n){return-1==e.s?Math.max(Ft(e.l,t,n+1),Ft(e.r,t,n+1)):t[e.s]=n},Lt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new ut(++t),r=0,o=e[0],s=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)i(32754);s>2&&(i(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(i(o),--s;s>6;s-=6)i(8304);s>2&&(i(s-3<<5|8208),s=0)}for(;s--;)i(o);s=1,o=e[a]}return[n.subarray(0,r),t]},_t=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Wt=function(e,t,n){var r=n.length,o=Nt(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var s=0;s<r;++s)e[o+s+4]=n[s];return 8*(o+4+r)},Bt=function(e,t,n,r,o,s,i,a,c,l,d){Ot(t,d++,n),++o[256];for(var u=xt(o,15),h=u[0],p=u[1],g=xt(s,15),m=g[0],f=g[1],I=Lt(h),C=I[0],y=I[1],v=Lt(m),S=v[0],b=v[1],A=new ut(19),w=0;w<C.length;++w)A[31&C[w]]++;for(w=0;w<S.length;++w)A[31&S[w]]++;for(var k=xt(A,7),M=k[0],T=k[1],E=19;E>4&&!M[mt[E-1]];--E);var N,R,O,D,x=l+5<<3,F=_t(o,kt)+_t(s,Mt)+i,L=_t(o,h)+_t(s,m)+i+14+3*E+_t(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(x<=F&&x<=L)return Wt(t,d,e.subarray(c,c+l));if(Ot(t,d,1+(L<F)),d+=2,L<F){N=wt(h,p,0),R=h,O=wt(m,f,0),D=m;var _=wt(M,T,0);Ot(t,d,y-257),Ot(t,d+5,b-1),Ot(t,d+10,E-4),d+=14;for(w=0;w<E;++w)Ot(t,d+3*w,M[mt[w]]);d+=3*E;for(var W=[C,S],B=0;B<2;++B){var G=W[B];for(w=0;w<G.length;++w){var U=31&G[w];Ot(t,d,_[U]),d+=M[U],U>15&&(Ot(t,d,G[w]>>>5&127),d+=G[w]>>>12)}}}else N=Tt,R=kt,O=Et,D=Mt;for(w=0;w<a;++w)if(r[w]>255){U=r[w]>>>18&31;Dt(t,d,N[U+257]),d+=R[U+257],U>7&&(Ot(t,d,r[w]>>>23&31),d+=pt[U]);var Z=31&r[w];Dt(t,d,O[Z]),d+=D[Z],Z>3&&(Dt(t,d,r[w]>>>5&8191),d+=gt[Z])}else Dt(t,d,N[r[w]]),d+=R[r[w]];return Dt(t,d,N[256]),d+R[256]},Gt=new ht([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ut=new dt(0),Zt=function(e,t,n,r,o){return function(e,t,n,r,o,s){var i=e.length,a=new dt(r+i+5*(1+Math.floor(i/7e3))+o),c=a.subarray(r,a.length-o),l=0;if(!t||i<8)for(var d=0;d<=i;d+=65535){var u=d+65535;u<i?l=Wt(c,l,e.subarray(d,u)):(c[d]=s,l=Wt(c,l,e.subarray(d,i)))}else{for(var h=Gt[t-1],p=h>>>13,g=8191&h,m=(1<<n)-1,f=new ut(32768),I=new ut(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new ht(25e3),b=new ut(288),A=new ut(32),w=0,k=0,M=(d=0,0),T=0,E=0;d<i;++d){var N=v(d),R=32767&d,O=I[N];if(f[R]=O,I[N]=R,T<=d){var D=i-d;if((w>7e3||M>24576)&&D>423){l=Bt(e,c,0,S,b,A,k,M,E,d-E,l),M=w=k=0,E=d;for(var x=0;x<286;++x)b[x]=0;for(x=0;x<30;++x)A[x]=0}var F=2,L=0,_=g,W=R-O&32767;if(D>2&&N==v(d-W))for(var B=Math.min(p,D)-1,G=Math.min(32767,d),U=Math.min(258,D);W<=G&&--_&&R!=O;){if(e[d+F]==e[d+F-W]){for(var Z=0;Z<U&&e[d+Z]==e[d+Z-W];++Z);if(Z>F){if(F=Z,L=W,Z>B)break;var V=Math.min(W,Z-2),K=0;for(x=0;x<V;++x){var Y=d-W+x+32768&32767,q=Y-f[Y]+32768&32767;q>K&&(K=q,O=Y)}}}W+=(R=O)-(O=f[R])+32768&32767}if(L){S[M++]=268435456|yt[F]<<18|vt[L];var P=31&yt[F],z=31&vt[L];k+=pt[P]+gt[z],++b[257+P],++A[z],T=d+F,++w}else S[M++]=e[d],++b[e[d]]}}l=Bt(e,c,s,S,b,A,k,M,E,d-E,l),s||(l=Wt(c,l,Ut))}return Rt(a,0,r+Nt(l)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!o)};function Vt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,s=n.length,i=0;i!=s;){for(var a=Math.min(i+5552,s);i<a;++i)o+=r+=n[i];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r=Zt(e,t,2,4);return function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)}(r,t),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(r,r.length-4,n.d()),r}const Kt=e=>{const t=Object.assign(Object.assign({},e),{v:"v1"});return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var o=e[r++];o<128||t?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((31&o)<<6|63&e[r++]):o<240?n+=String.fromCharCode((15&o)<<12|(63&e[r++])<<6|63&e[r++]):(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}return n}(Vt(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new dt(e.length+(e.length>>>1)),o=0,s=function(e){r[o++]=e},i=0;i<n;++i){if(o+5>r.length){var a=new dt(o+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?s(c):c<2048?(s(192|c>>>6),s(128|63&c)):c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),s(128|c>>>12&63),s(128|c>>>6&63),s(128|63&c)):(s(224|c>>>12),s(128|c>>>6&63),s(128|63&c))}return Rt(r,0,o)}(JSON.stringify(t))),!0)};var Yt,qt;(qt=Yt||(Yt={}))[qt.NotStarted=0]="NotStarted",qt[qt.Running=1]="Running",qt[qt.Stopped=2]="Stopped";var Pt="".concat("[Amplitude]"," Session Recorded"),zt="Session replay event batch rejected due to exceeded retry count",Qt="Failed to store session replay events in IndexedDB",Jt="".concat("AMP","_replay_unsent"),jt=function(){function e(){var e=this;this.name="@amplitude/plugin-session-replay-browser",this.type="enrichment",this.storageKey="",this.retryTimeout=1e3,this.events=[],this.currentSequenceId=0,this.scheduled=null,this.queue=[],this.stopRecordingEvents=null,this.maxPersistedEventsSize=19999800,this.interval=1e3,this.timeAtLastSend=null,this.shouldSplitEventsList=function(t){var n=new Blob([t]).size;return new Blob(e.events).size+n>=e.maxPersistedEventsSize||null!==e.timeAtLastSend&&Date.now()-e.timeAtLastSend>e.interval&&(e.interval=Math.min(1e4,e.interval+1e3),!0)}}return e.prototype.setup=function(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){return e.loggerProvider.log("Installing @amplitude/plugin-session-replay."),this.config=e,this.storageKey="".concat(Jt,"_").concat(this.config.apiKey.substring(0,10)),this.emptyStoreAndReset(),[2]}))}))},e.prototype.execute=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(r){return e.event_properties=n(n({},e.event_properties),((t={})[Pt]=!0,t)),"session_start"!==e.event_type||this.stopRecordingEvents?"session_end"===e.event_type&&(e.session_id&&this.sendEventsList({events:this.events,sequenceId:this.currentSequenceId,sessionId:e.session_id}),this.stopRecordingEvents&&this.stopRecordingEvents(),this.events=[],this.currentSequenceId=0):this.recordEvents(),[2,Promise.resolve(e)]}))}))},e.prototype.emptyStoreAndReset=function(){return r(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(o){switch(o.label){case 0:return[4,this.getAllSessionEventsFromStore()];case 1:if(e=o.sent()){for(t in e)(n=e[t]).events.length&&this.sendEventsList({events:n.events,sequenceId:n.sequenceId,sessionId:parseInt(t,10)});this.events=[],r=this.config.sessionId&&e[this.config.sessionId],this.currentSequenceId=r?r.sequenceId+1:0,this.storeEventsForSession([],this.currentSequenceId)}return this.recordEvents(),[2]}}))}))},e.prototype.recordEvents=function(){var e=this;this.stopRecordingEvents=at({emit:function(t){var n=JSON.stringify(t);if(1===e.events.length&&0===e.currentSequenceId)return e.sendEventsList({events:e.events.concat(n),sequenceId:e.currentSequenceId,sessionId:e.config.sessionId}),e.events=[],void e.currentSequenceId++;e.shouldSplitEventsList(n)&&(e.sendEventsList({events:e.events,sequenceId:e.currentSequenceId,sessionId:e.config.sessionId}),e.events=[],e.currentSequenceId++),e.events.push(n),e.storeEventsForSession(e.events,e.currentSequenceId)},packFn:Kt,maskAllInputs:!0})},e.prototype.sendEventsList=function(e){var t=e.events,n=e.sequenceId,r=e.sessionId;this.addToQueue({events:t,sequenceId:n,attempts:0,timeout:0,sessionId:r})},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.filter((function(t){return t.attempts<e.config.flushMaxRetries?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"".concat(zt,", batch sequence id, ").concat(t.sequenceId)}),!1)}));r.forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(0)}))},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var n,r,s,i,a;return o(this,(function(o){switch(o.label){case 0:n={api_key:this.config.apiKey,device_id:this.config.deviceId,session_id:e.sessionId,start_timestamp:e.sessionId,events_batch:{version:1,events:e.events,seq_number:e.sequenceId}},o.label=1;case 1:return o.trys.push([1,3,,4]),r={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(n),method:"POST"},[4,fetch("https://api-secure.amplitude.com/sessions/track",r)];case 2:if(null===(s=o.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred",removeEvents:!1}),[2];if(t)this.handleReponse(s.status,e);else{i="";try{i=JSON.stringify(s.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(s.status,": ").concat(i)})}return[3,4];case 3:return a=o.sent(),this.completeRequest({context:e,err:a,removeEvents:!1}),[3,4];case 4:return[2]}}))}))},e.prototype.handleReponse=function(e,n){if((new s).buildStatus(e)===t.Success)this.handleSuccessResponse(n);else this.handleOtherResponse(n)},e.prototype.handleSuccessResponse=function(e){this.completeRequest({context:e,success:"Session replay event batch tracked successfully"})},e.prototype.handleOtherResponse=function(e){this.addToQueue(n(n({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.getAllSessionEventsFromStore=function(){return r(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,l(this.storageKey)];case 1:return[2,t.sent()];case 2:return e=t.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(e)),[3,3];case 3:return[2,void 0]}}))}))},e.prototype.storeEventsForSession=function(e,t){return r(this,void 0,void 0,(function(){var r,s=this;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,d(this.storageKey,(function(r){var o;return n(n({},r),s.config.sessionId&&((o={})[s.config.sessionId]={events:e,sequenceId:t},o))}))];case 1:return o.sent(),[3,3];case 2:return r=o.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(r)),[3,3];case 3:return[2]}}))}))},e.prototype.removeSessionEventsStore=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,d(this.storageKey,(function(t){return void 0===t&&(t={}),delete t[e],t}))];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(t)),[3,3];case 3:return[2]}}))}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success,o=e.removeEvents;(void 0===o||o)&&t.sessionId&&this.removeSessionEventsStore(t.sessionId),n?this.config.loggerProvider.error(n):r&&(this.timeAtLastSend=Date.now(),this.config.loggerProvider.log(r))},e}(),Ht=function(){return new jt};return e.plugin=Ht,e.sessionReplayPlugin=Ht,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
Binary file
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).amplitude={})}(this,(function(e){"use strict";var t,n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(t||(t={}));var s=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var n,r,o,s,i,a,c,l,d,u,h,p,g,m,f,I,C,y,v,S,b,A;if("object"!=typeof e)return null;var w=e.code||0,k=this.buildStatus(w);switch(k){case t.Success:return{status:k,statusCode:w,body:{eventsIngested:null!==(n=e.events_ingested)&&void 0!==n?n:0,payloadSizeBytes:null!==(r=e.payload_size_bytes)&&void 0!==r?r:0,serverUploadTime:null!==(o=e.server_upload_time)&&void 0!==o?o:0}};case t.Invalid:return{status:k,statusCode:w,body:{error:null!==(s=e.error)&&void 0!==s?s:"",missingField:null!==(i=e.missing_field)&&void 0!==i?i:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(c=e.events_with_missing_fields)&&void 0!==c?c:{},eventsWithInvalidIdLengths:null!==(l=e.events_with_invalid_id_lengths)&&void 0!==l?l:{},epsThreshold:null!==(d=e.eps_threshold)&&void 0!==d?d:0,exceededDailyQuotaDevices:null!==(u=e.exceeded_daily_quota_devices)&&void 0!==u?u:{},silencedDevices:null!==(h=e.silenced_devices)&&void 0!==h?h:[],silencedEvents:null!==(p=e.silenced_events)&&void 0!==p?p:[],throttledDevices:null!==(g=e.throttled_devices)&&void 0!==g?g:{},throttledEvents:null!==(m=e.throttled_events)&&void 0!==m?m:[]}};case t.PayloadTooLarge:return{status:k,statusCode:w,body:{error:null!==(f=e.error)&&void 0!==f?f:""}};case t.RateLimit:return{status:k,statusCode:w,body:{error:null!==(I=e.error)&&void 0!==I?I:"",epsThreshold:null!==(C=e.eps_threshold)&&void 0!==C?C:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(v=e.throttled_users)&&void 0!==v?v:{},exceededDailyQuotaDevices:null!==(S=e.exceeded_daily_quota_devices)&&void 0!==S?S:{},exceededDailyQuotaUsers:null!==(b=e.exceeded_daily_quota_users)&&void 0!==b?b:{},throttledEvents:null!==(A=e.throttled_events)&&void 0!==A?A:[]}};case t.Timeout:default:return{status:k,statusCode:w}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?t.Success:429===e?t.RateLimit:413===e?t.PayloadTooLarge:408===e?t.Timeout:e>=400&&e<500?t.Invalid:e>=500?t.Failed:t.Unknown},e}();function i(e){return new Promise(((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}))}let a;function c(){return a||(a=function(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=i(n);return(e,n)=>r.then((r=>n(r.transaction(t,e).objectStore(t))))}("keyval-store","keyval")),a}function l(e,t=c()){return t("readonly",(t=>i(t.get(e))))}function d(e,t,n=c()){return n("readwrite",(n=>new Promise(((r,o)=>{n.get(e).onsuccess=function(){try{n.put(t(this.result),e),r(i(n.transaction))}catch(e){o(e)}}}))))}var u;function h(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function p(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function g(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(m).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function m(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=g(e.styleSheet)||t}catch(e){}return t}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(u||(u={}));var f=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function I(e){var t=e.maskInputOptions,n=e.tagName,r=e.type,o=e.value,s=e.maskInputFn,i=o||"";return(t[n.toLowerCase()]||t[r])&&(i=s?s(i):"*".repeat(i.length)),i}var C="__rrweb_original__";var y,v,S=1,b=new RegExp("[^a-z0-9-_:]");function A(){return S++}var w=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,k=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,M=/^(data:)([^,]*),(.*)/i;function T(e,t){return(e||"").replace(w,(function(e,n,r,o,s,i){var a,c=r||s||i,l=n||o||"";if(!c)return e;if(!k.test(c))return"url(".concat(l).concat(c).concat(l,")");if(M.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var d=t.split("/"),u=c.split("/");d.pop();for(var h=0,p=u;h<p.length;h++){var g=p[h];"."!==g&&(".."===g?d.pop():d.push(g))}return"url(".concat(l).concat(d.join("/")).concat(l,")")}))}var E=/^[^ \t\n\r\u000c]+/,N=/^[, \t\n\r\u000c]+/;function R(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function O(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function D(){var e=document.createElement("a");return e.href="",e.href}function x(e,t,n,r){return"src"===n||"href"===n&&r&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&r&&"#"!==r[0]?R(e,r):"background"!==n||!r||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&r?function(e,t){if(""===t.trim())return t;var n=0;function r(e){var r,o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}for(var o=[];r(N),!(n>=t.length);){var s=r(E);if(","===s.slice(-1))s=R(e,s.substring(0,s.length-1)),o.push(s);else{var i="";s=R(e,s);for(var a=!1;;){var c=t.charAt(n);if(""===c){o.push((s+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,o.push((s+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return o.join(", ")}(e,r):"style"===n&&r?T(r,D()):"object"===t&&"data"===n&&r?R(e,r):r:R(e,r)}function F(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&F(e.parentNode,t,n);for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&F(e.parentNode,t,n)}function L(e,t,n){var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(r.closest(".".concat(t)))return!0}else if(F(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}return!1}function _(e,t){var n=t.doc,r=t.mirror,o=t.blockClass,s=t.blockSelector,i=t.maskTextClass,a=t.maskTextSelector,c=t.inlineStylesheet,l=t.maskInputOptions,d=void 0===l?{}:l,h=t.maskTextFn,p=t.maskInputFn,m=t.dataURLOptions,f=void 0===m?{}:m,S=t.inlineImages,A=t.recordCanvas,w=t.keepIframeSrcFn,k=t.newlyAddedElement,M=void 0!==k&&k,E=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:u.Document,childNodes:[],compatMode:e.compatMode}:{type:u.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:u.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:E};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,r=t.blockClass,o=t.blockSelector,s=t.inlineStylesheet,i=t.maskInputOptions,a=void 0===i?{}:i,c=t.maskInputFn,l=t.dataURLOptions,d=void 0===l?{}:l,h=t.inlineImages,p=t.recordCanvas,m=t.keepIframeSrcFn,f=t.newlyAddedElement,S=void 0!==f&&f,A=t.rootId,w=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&e.matches(n)}(e,r,o),k=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return b.test(t)?"div":t}(e),M={},E=e.attributes.length,N=0;N<E;N++){var R=e.attributes[N];M[R.name]=x(n,k,R.name,R.value)}if("link"===k&&s){var F=Array.from(n.styleSheets).find((function(t){return t.href===e.href})),L=null;F&&(L=g(F)),L&&(delete M.rel,delete M.href,M._cssText=T(L,F.href))}if("style"===k&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(L=g(e.sheet))&&(M._cssText=T(L,D()))}if("input"===k||"textarea"===k||"select"===k){var _=e.value,W=e.checked;"radio"!==M.type&&"checkbox"!==M.type&&"submit"!==M.type&&"button"!==M.type&&_?M.value=I({type:M.type,tagName:k,value:_,maskInputOptions:a,maskInputFn:c}):W&&(M.checked=W)}"option"===k&&(e.selected&&!a.select?M.selected=!0:delete M.selected);if("canvas"===k&&p)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var r=0;r<e.height;r+=50){var o=t.getImageData,s=C in o?o[C]:o;if(new Uint32Array(s.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(M.rr_dataURL=e.toDataURL(d.type,d.quality));else if(!("__context"in e)){var B=e.toDataURL(d.type,d.quality),G=document.createElement("canvas");G.width=e.width,G.height=e.height,B!==G.toDataURL(d.type,d.quality)&&(M.rr_dataURL=B)}if("img"===k&&h){y||(y=n.createElement("canvas"),v=y.getContext("2d"));var U=e,Z=U.crossOrigin;U.crossOrigin="anonymous";var V=function(){try{y.width=U.naturalWidth,y.height=U.naturalHeight,v.drawImage(U,0,0),M.rr_dataURL=y.toDataURL(d.type,d.quality)}catch(e){console.warn("Cannot inline img src=".concat(U.currentSrc,"! Error: ").concat(e))}Z?M.crossOrigin=Z:U.removeAttribute("crossorigin")};U.complete&&0!==U.naturalWidth?V():U.onload=V}"audio"!==k&&"video"!==k||(M.rr_mediaState=e.paused?"paused":"played",M.rr_mediaCurrentTime=e.currentTime);S||(e.scrollLeft&&(M.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(M.rr_scrollTop=e.scrollTop));if(w){var K=e.getBoundingClientRect(),Y=K.width,q=K.height;M={class:M.class,rr_width:"".concat(Y,"px"),rr_height:"".concat(q,"px")}}"iframe"!==k||m(M.src)||(e.contentDocument||(M.rr_src=M.src),delete M.src);return{type:u.Element,tagName:k,attributes:M,childNodes:[],isSVG:O(e)||void 0,needBlock:w,rootId:A}}(e,{doc:n,blockClass:o,blockSelector:s,inlineStylesheet:c,maskInputOptions:d,maskInputFn:p,dataURLOptions:f,inlineImages:S,recordCanvas:A,keepIframeSrcFn:w,newlyAddedElement:M,rootId:E});case e.TEXT_NODE:return function(e,t){var n,r=t.maskTextClass,o=t.maskTextSelector,s=t.maskTextFn,i=t.rootId,a=e.parentNode&&e.parentNode.tagName,c=e.textContent,l="STYLE"===a||void 0,d="SCRIPT"===a||void 0;if(l&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(h=e.parentNode.sheet).cssRules?Array.from(h.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=T(c,D())}var h;d&&(c="SCRIPT_PLACEHOLDER");!l&&!d&&c&&L(e,r,o)&&(c=s?s(c):c.replace(/[\S]/g,"*"));return{type:u.Text,textContent:c||"",isStyle:l,rootId:i}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:h,rootId:E});case e.CDATA_SECTION_NODE:return{type:u.CDATA,textContent:"",rootId:E};case e.COMMENT_NODE:return{type:u.Comment,textContent:e.textContent||"",rootId:E};default:return!1}}function W(e){return void 0===e?"":e.toLowerCase()}function B(e,t){var n,r=t.doc,o=t.mirror,s=t.blockClass,i=t.blockSelector,a=t.maskTextClass,c=t.maskTextSelector,l=t.skipChild,d=void 0!==l&&l,g=t.inlineStylesheet,m=void 0===g||g,f=t.maskInputOptions,I=void 0===f?{}:f,C=t.maskTextFn,y=t.maskInputFn,v=t.slimDOMOptions,S=t.dataURLOptions,b=void 0===S?{}:S,w=t.inlineImages,k=void 0!==w&&w,M=t.recordCanvas,T=void 0!==M&&M,E=t.onSerialize,N=t.onIframeLoad,R=t.iframeLoadTimeout,O=void 0===R?5e3:R,D=t.onStylesheetLoad,x=t.stylesheetLoadTimeout,F=void 0===x?5e3:x,L=t.keepIframeSrcFn,G=void 0===L?function(){return!1}:L,U=t.newlyAddedElement,Z=void 0!==U&&U,V=t.preserveWhiteSpace,K=void 0===V||V,Y=_(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,dataURLOptions:b,inlineImages:k,recordCanvas:T,keepIframeSrcFn:G,newlyAddedElement:Z});if(!Y)return console.warn(e,"not serialized"),null;n=o.hasNode(e)?o.getId(e):!function(e,t){if(t.comment&&e.type===u.Comment)return!0;if(e.type===u.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(W(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===W(e.attributes.name)||"icon"===W(e.attributes.rel)||"apple-touch-icon"===W(e.attributes.rel)||"shortcut icon"===W(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&W(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(W(e.attributes.property).match(/^(og|twitter|fb):/)||W(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===W(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===W(e.attributes.name)||"googlebot"===W(e.attributes.name)||"bingbot"===W(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===W(e.attributes.name)||"generator"===W(e.attributes.name)||"framework"===W(e.attributes.name)||"publisher"===W(e.attributes.name)||"progid"===W(e.attributes.name)||W(e.attributes.property).match(/^article:/)||W(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===W(e.attributes.name)||"yandex-verification"===W(e.attributes.name)||"csrf-token"===W(e.attributes.name)||"p:domain_verify"===W(e.attributes.name)||"verify-v1"===W(e.attributes.name)||"verification"===W(e.attributes.name)||"shopify-checkout-api-token"===W(e.attributes.name)))return!0}}return!1}(Y,v)&&(K||Y.type!==u.Text||Y.isStyle||Y.textContent.replace(/^\s+|\s+$/gm,"").length)?A():-2;var q=Object.assign(Y,{id:n});if(o.add(e,q),-2===n)return null;E&&E(e);var P=!d;if(q.type===u.Element){P=P&&!q.needBlock,delete q.needBlock;var z=e.shadowRoot;z&&p(z)&&(q.isShadowHost=!0)}if((q.type===u.Document||q.type===u.Element)&&P){v.headWhitespace&&q.type===u.Element&&"head"===q.tagName&&(K=!1);for(var Q={doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:d,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G},J=0,j=Array.from(e.childNodes);J<j.length;J++){($=B(j[J],Q))&&q.childNodes.push($)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var H=0,X=Array.from(e.shadowRoot.childNodes);H<X.length;H++){var $;($=B(X[H],Q))&&(p(e.shadowRoot)&&($.isShadow=!0),q.childNodes.push($))}}return e.parentNode&&h(e.parentNode)&&p(e.parentNode)&&(q.isShadow=!0),q.type===u.Element&&"iframe"===q.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var o,s=!1;try{o=r.document.readyState}catch(e){return}if("complete"===o){var i="about:blank";if(r.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout((function(){s||(t(),s=!0)}),n);e.addEventListener("load",(function(){clearTimeout(a),s=!0,t()}))}}}(e,(function(){var t=e.contentDocument;if(t&&N){var n=B(t,{doc:t,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G});n&&N(e,n)}}),O),q.type===u.Element&&"link"===q.tagName&&"stylesheet"===q.attributes.rel&&function(e,t,n){var r,o=!1;try{r=e.sheet}catch(e){return}if(!r){var s=setTimeout((function(){o||(t(),o=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),o=!0,t()}))}}(e,(function(){if(D){var t=B(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G});t&&D(e,t)}}),F),q}function G(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const U="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Z={map:{},getId:()=>(console.error(U),-1),getNode:()=>(console.error(U),null),removeNodeFromMap(){console.error(U)},has:()=>(console.error(U),!1),reset(){console.error(U)}};function V(e,t,n={}){let r=null,o=0;return function(...s){const i=Date.now();o||!1!==n.leading||(o=i);const a=t-(i-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=i,e.apply(c,s)):r||!1===n.trailing||(r=setTimeout((()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,s)}),a))}}function K(e,t,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>K(e,t,s||{},!0)}function Y(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch(e){return()=>{}}}function q(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function P(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function z(e,t,n,r){if(!e)return!1;const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(F(o,t,r))return!0;if(n){if(e.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function Q(e,t){return-2===t.getId(e)}function J(e,t){if(h(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||J(e.parentNode,t))}function j(e){return Boolean(e.changedTouches)}function H(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function X(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function $(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Z=new Proxy(Z,{get:(e,t,n)=>("map"===t&&console.error(U),Reflect.get(e,t,n))}));class ee{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var te=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(te||{}),ne=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(ne||{}),re=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(re||{}),oe=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(oe||{});function se(e){return"__ln"in e}class ie{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&se(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&se(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next&&(t.next.previous=t.previous)):(this.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const ae=(e,t)=>`${e}@${t}`;class ce{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new ie,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},r=r=>{var o,s,i,a;let c=null;(null===(s=null===(o=r.getRootNode)||void 0===o?void 0:o.call(r))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&r.getRootNode().host&&(c=r.getRootNode().host);let l=c;for(;(null===(a=null===(i=null==l?void 0:l.getRootNode)||void 0===i?void 0:i.call(l))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&l.getRootNode().host;)l=l.getRootNode().host;const d=!(this.doc.contains(r)||l&&this.doc.contains(l));if(!r.parentNode||d)return;const u=h(r.parentNode)?this.mirror.getId(c):this.mirror.getId(r.parentNode),p=n(r);if(-1===u||-1===p)return t.addNode(r);const g=B(r,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{H(e,this.mirror)&&this.iframeManager.addIframe(e),X(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),$(r)&&this.shadowDomManager.addShadowRoot(r.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});g&&e.push({parentId:u,nextId:p,node:g})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))de(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||r(e);for(const e of Array.from(this.addedSet.values()))he(this.droppedSet,e)||de(this.removes,e,this.mirror)?he(this.movedSet,e)?r(e):this.droppedSet.add(e):r(e);let o=null;for(;t.length;){let e=null;if(o){const t=this.mirror.getId(o.value.parentNode),r=n(o.value);-1!==t&&-1!==r&&(e=o)}if(!e)for(let r=t.length-1;r>=0;r--){const o=t.get(r);if(o){const t=this.mirror.getId(o.value.parentNode);if(-1===n(o.value))continue;if(-1!==t){e=o;break}{const t=o.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=o;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}o=e.previous,t.removeNode(e.value),r(e.value)}const s={texts:this.texts.map((e=>({id:this.mirror.getId(e.node),value:e.value}))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>({id:this.mirror.getId(e.node),attributes:e.attributes}))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!Q(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;z(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:L(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=I({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),z(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let r=this.attributes.find((t=>t.node===e.target));if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(r||(r={node:e.target,attributes:{}},this.attributes.push(r)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==r.attributes.style&&null!==r.attributes.style||(r.attributes.style={});const o=r.attributes.style;for(const e of Array.from(t.style)){const r=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);r===n.style.getPropertyValue(e)&&s===n.style.getPropertyPriority(e)||(o[e]=""===s?r:[r,s])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(o[e]=!1)}else r.attributes[e.attributeName]=x(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(z(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),r=h(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);z(e.target,this.blockClass,this.blockSelector,!1)||Q(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(le(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||J(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[ae(n,r)]?le(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!h(e.target)||!p(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(Q(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[ae(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);z(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach((e=>this.genAdds(e)))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach((t=>{this[t]=e[t]}))}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function le(e,t){e.delete(t),t.childNodes.forEach((t=>le(e,t)))}function de(e,t,n){return 0!==e.length&&ue(e,t,n)}function ue(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some((e=>e.id===o))||ue(e,r,n)}function he(e,t){return 0!==e.size&&pe(e,t)}function pe(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||pe(e,n))}const ge=[],me="undefined"!=typeof CSSGroupingRule,fe="undefined"!=typeof CSSMediaRule,Ie="undefined"!=typeof CSSSupportsRule,Ce="undefined"!=typeof CSSConditionRule;function ye(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function ve(e,t){var n,r;const o=new ce;ge.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(o.processMutations.bind(o));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function Se({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(re).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{const i=s.toLowerCase(),c=(t=>s=>{const i=ye(s);if(z(i,r,o,!0))return;const a=j(s)?s.changedTouches[0]:s;if(!a)return;const c=n.getId(i),{clientX:l,clientY:d}=a;e({type:re[t],id:c,x:l,y:d})})(s);a.push(G(i,c,t))})),()=>{a.forEach((e=>e()))}}function be({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){return G("scroll",V((s=>{const i=ye(s);if(!i||z(i,r,o,!0))return;const a=n.getId(i);if(i===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})}),s.scroll||100),t)}function Ae(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const we=["INPUT","TEXTAREA","SELECT"],ke=new WeakMap;function Me(e){return function(e,t){if(me&&e.parentRule instanceof CSSGroupingRule||fe&&e.parentRule instanceof CSSMediaRule||Ie&&e.parentRule instanceof CSSSupportsRule||Ce&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function Te(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function Ee({mirror:e,stylesheetManager:t},n){var r,o,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(s=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===s?void 0:s.ShadowRoot,c=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==i&&-1!==i&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return r}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function Ne(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t);const r=ve(e,e.doc),o=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=V((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null}),s),l=V((e=>{const t=ye(e),{clientX:n,clientY:o}=j(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:o,id:r.getId(t),timeOffset:Date.now()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?ne.Drag:e instanceof MouseEvent?ne.MouseMove:ne.TouchMove)}),o,{trailing:!1}),d=[G("mousemove",l,n),G("touchmove",l,n),G("drag",l,n)];return()=>{d.forEach((e=>e()))}}(e),s=Se(e),i=be(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return G("resize",V((()=>{const r=q(),o=P();t===r&&n===o||(e({width:Number(o),height:Number(r)}),t=r,n=o)}),200),window)}(e),c=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:s,maskInputOptions:i,maskInputFn:a,sampling:c,userTriggeredOnInput:l}){function d(e){let n=ye(e);const c=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||we.indexOf(n.tagName)<0||z(n,r,o,!0))return;const d=n.type;if(n.classList.contains(s))return;let h=n.value,p=!1;"radio"===d||"checkbox"===d?p=n.checked:(i[n.tagName.toLowerCase()]||i[d])&&(h=I({maskInputOptions:i,tagName:n.tagName,type:d,value:h,maskInputFn:a})),u(n,Ae({text:h,isChecked:p,userTriggered:c},l));const g=n.name;"radio"===d&&g&&p&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach((e=>{e!==n&&u(e,Ae({text:e.value,isChecked:!p,userTriggered:!1},l))}))}function u(t,r){const o=ke.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){ke.set(t,r);const o=n.getId(t);e(Object.assign(Object.assign({},r),{id:o}))}}const h=("last"===c.input?["change"]:["input","change"]).map((e=>G(e,d,t))),p=t.defaultView;if(!p)return()=>{h.forEach((e=>e()))};const g=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),m=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return g&&g.set&&h.push(...m.map((e=>K(e[0],e[1],{set(){d({target:this})}},!1,p)))),()=>{h.forEach((e=>e()))}}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o}){const s=s=>V((o=>{const i=ye(o);if(!i||z(i,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=i;e({type:s,id:r.getId(i),currentTime:a,volume:c,muted:l,playbackRate:d})}),o.media||500),i=[G("play",s(0)),G("pause",s(1)),G("seeked",s(2)),G("volumechange",s(3)),G("ratechange",s(4))];return()=>{i.forEach((e=>e()))}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=function(r,s){const{id:i,styleId:a}=Te(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:s}]}),o.apply(this,[r,s])};const s=r.CSSStyleSheet.prototype.deleteRule;let i,a;r.CSSStyleSheet.prototype.deleteRule=function(r){const{id:o,styleId:i}=Te(this,t,n.styleMirror);return(o&&-1!==o||i&&-1!==i)&&e({id:o,styleId:i,removes:[{index:r}]}),s.apply(this,[r])},r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=function(r){const{id:o,styleId:s}=Te(this,t,n.styleMirror);return(o&&-1!==o||s&&-1!==s)&&e({id:o,styleId:s,replace:r}),i.apply(this,[r])}),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=function(r){const{id:o,styleId:s}=Te(this,t,n.styleMirror);return(o&&-1!==o||s&&-1!==s)&&e({id:o,styleId:s,replaceSync:r}),a.apply(this,[r])});const c={};me?c.CSSGroupingRule=r.CSSGroupingRule:(fe&&(c.CSSMediaRule=r.CSSMediaRule),Ce&&(c.CSSConditionRule=r.CSSConditionRule),Ie&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach((([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=function(o,s){const{id:i,styleId:a}=Te(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:o,index:[...Me(this),s||0]}]}),l[r].insertRule.apply(this,[o,s])},o.prototype.deleteRule=function(o){const{id:s,styleId:i}=Te(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:[...Me(this),o]}]}),l[r].deleteRule.apply(this,[o])}})),()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=s,i&&(r.CSSStyleSheet.prototype.replace=i),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule}))}}(e,{win:n}),u=Ee(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=function(o,i,a){var c;if(n.has(o))return s.apply(this,[o,i,a]);const{id:l,styleId:d}=Te(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:o,value:i,priority:a},index:Me(this.parentRule)}),s.apply(this,[o,i,a])};const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=function(o){var s;if(n.has(o))return i.apply(this,[o]);const{id:a,styleId:c}=Te(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,t,r.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:o},index:Me(this.parentRule)}),i.apply(this,[o])},()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),p=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const r=new s(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const i=Y(t.fonts,"add",(function(t){return function(n){return setTimeout((()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.apply(this,[n])}}));return r.push((()=>{n.FontFace=s})),r.push(i),()=>{r.forEach((e=>e()))}}(e):()=>{},g=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:s}=e;let i=!0;const a=()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:c,endContainer:l,endOffset:d}=s;z(i,r,o,!0)||z(l,r,o,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(l),endOffset:d})}s({ranges:a})};return a(),G("selectionchange",a)}(e),m=[];for(const t of e.plugins)m.push(t.observer(t.callback,n,t.options));return()=>{ge.forEach((e=>e.reset())),r.disconnect(),o(),s(),i(),a(),c(),l(),d(),u(),h(),p(),g(),m.forEach((e=>e()))}}class Re{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),s=r||this.getRemoteIdToIdMap(e);let i=o.get(t);return i||(i=this.generateIdFn(),o.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,r)))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map((t=>this.getRemoteId(e,t,n)))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class Oe{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Re(A),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Re(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case te.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:te.IncrementalSnapshot,data:{source:ne.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case te.Meta:case te.Load:case te.DomContentLoaded:return!1;case te.Plugin:return t;case te.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case te.IncrementalSnapshot:switch(t.data.source){case ne.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)})),t.data.removes.forEach((t=>{this.replaceIds(t,e,["parentId","id"])})),t.data.attributes.forEach((t=>{this.replaceIds(t,e,["id"])})),t.data.texts.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ne.Drag:case ne.TouchMove:case ne.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ne.ViewportResize:return!1;case ne.MediaInteraction:case ne.MouseInteraction:case ne.Scroll:case ne.CanvasMutation:case ne.Input:return this.replaceIds(t.data,e,["id"]),t;case ne.StyleSheetRule:case ne.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case ne.Font:return t;case ne.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case ne.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach((t=>{this.replaceStyleIds(t,e,["styleId"])})),t}}}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}}class De{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(Y(Element.prototype,"attachShadow",(function(e){return function(n){const r=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),r}})))}addShadowRoot(e,t){p(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ve(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),be(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout((()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),Ee({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)}),0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(Y(e.contentWindow.HTMLElement.prototype,"attachShadow",(function(n){return function(r){const o=n.call(this,r);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),o}})))}}reset(){this.restorePatches.forEach((e=>e())),this.shadowDoms=new WeakSet}}function xe(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}for(var Fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Le="undefined"==typeof Uint8Array?[]:new Uint8Array(256),_e=0;_e<Fe.length;_e++)Le[Fe.charCodeAt(_e)]=_e;const We=new Map;const Be=(e,t,n)=>{if(!e||!Ze(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=We.get(e);return n||(n=new Map,We.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Ge(e,t,n){if(e instanceof Array)return e.map((e=>Ge(e,t,n)));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Fe[n[t]>>2],o+=Fe[(3&n[t])<<4|n[t+1]>>4],o+=Fe[(15&n[t+1])<<2|n[t+2]>>6],o+=Fe[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Ge(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Ge(e.data,t,n),e.width,e.height]}}if(Ze(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Be(e,t,n)}}return e}const Ue=(e,t,n)=>[...e].map((e=>Ge(e,t,n))),Ze=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((e=>"function"==typeof t[e]));return Boolean(n.find((n=>e instanceof t[n])))};function Ve(e,t,n){const r=[];try{const o=Y(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(r,...o){return z(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...o])}}));r.push(o)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{r.forEach((e=>e()))}}function Ke(e,t,n,r,o,s,i){const a=[],c=Object.getOwnPropertyNames(e);for(const s of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const c=Y(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(Be(c,i,this),!z(this.canvas,r,o,!0)){const e=Ue([...a],i,this),r={type:t,property:s,args:e};n(this.canvas,r)}return c}}));a.push(c)}catch(r){const o=K(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(o)}return a}var Ye=null;try{var qe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Ye=qe.Worker}catch(e){}function Pe(e,t,n){var r=void 0===t?null:t,o=function(e,t){return Buffer.from(e,"base64").toString(t?"utf16":"utf8")}(e,void 0!==n&&n),s=o.indexOf("\n",10)+1,i=o.substring(s)+(r?"//# sourceMappingURL="+r:"");return function(e){return new Ye(i,Object.assign({},e,{eval:!0}))}}function ze(e,t,n){var r=void 0===t?null:t,o=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),o=0,s=n.length;o<s;++o)r[o]=n.charCodeAt(o);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(e,void 0!==n&&n),s=o.indexOf("\n",10)+1,i=o.substring(s)+(r?"//# sourceMappingURL="+r:""),a=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(a)}var Qe="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Je,je,He,Xe=(Je="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgY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VsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",je=null,He=!1,Qe?Pe(Je,je,He):function(e,t,n){var r;return function(o){return r=r||ze(e,t,n),new Worker(r,o)}}(Je,je,He));class $e{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,r,o),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:i})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,o){const s=Ve(t,n,r),i=new Map,a=new Xe;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:s}=e.data;this.mutationCb({id:t,type:oe["2D"],commands:[{property:"clearRect",args:[0,0,o,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{z(t,n,r,!0)||e.push(t)})),e})().forEach((e=>xe(this,void 0,void 0,(function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ve(e,t,n),o=function(e,t,n,r){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=Y(t.CanvasRenderingContext2D.prototype,i,(function(o){return function(...s){return z(this.canvas,n,r,!0)||setTimeout((()=>{const n=Ue([...s],t,this);e(this.canvas,{type:oe["2D"],property:i,args:n})}),0),o.apply(this,s)}}));o.push(s)}catch(n){const r=K(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:oe["2D"],property:i,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,r,o){const s=[];return s.push(...Ke(t.WebGLRenderingContext.prototype,oe.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...Ke(t.WebGL2RenderingContext.prototype,oe.WebGL2,e,n,r,0,t)),()=>{s.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach(((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)})),requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map((e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t})),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class et{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new ee,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map(((e,t)=>({rule:m(e),index:t})))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function tt(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let nt,rt,ot,st=!1;const it=new f;function at(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:c=null,inlineStylesheet:l=!0,maskAllInputs:d,maskInputOptions:u,slimDOMOptions:h,maskInputFn:p,maskTextFn:g,hooks:m,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:w=!1,inlineImages:k=!1,plugins:M,keepIframeSrcFn:T=(()=>!1),ignoreCSSAttributes:E=new Set([])}=e,N=!b||window.parent===window;let R=!1;if(!N)try{window.parent.document,R=!1}catch(e){R=!0}if(N&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),it.reset();const O=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==u?u:{password:!0},D=!0===h||"all"===h?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===h,headMetaDescKeywords:"all"===h}:h||{};let x;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let F=0;const L=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};nt=(e,o)=>{var s;if(!(null===(s=ge[0])||void 0===s?void 0:s.isFrozen())||e.type===te.FullSnapshot||e.type===te.IncrementalSnapshot&&e.data.source===ne.Mutation||ge.forEach((e=>e.unfreeze())),N)null==t||t(L(e),o);else if(R){const t={type:"rrweb",event:L(e),isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===te.FullSnapshot)x=e,F=0;else if(e.type===te.IncrementalSnapshot){if(e.data.source===ne.Mutation&&e.data.isAttachIframe)return;F++;const t=r&&F>=r,o=n&&e.timestamp-x.timestamp>n;(t||o)&&rt(!0)}};const _=e=>{nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Mutation},e)}))},W=e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Scroll},e)})),U=e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.CanvasMutation},e)})),Z=new et({mutationCb:_,adoptedStyleSheetCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.AdoptedStyleSheet},e)}))}),V=new Oe({mirror:it,mutationCb:_,stylesheetManager:Z,recordCrossOriginIframes:b,wrappedEmit:nt});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:it,crossOriginIframeMirror:V.crossOriginIframeMirror,crossOriginIframeStyleMirror:V.crossOriginIframeStyleMirror});ot=new $e({recordCanvas:S,mutationCb:U,win:window,blockClass:o,blockSelector:s,mirror:it,sampling:C.canvas,dataURLOptions:y});const K=new De({mutationCb:_,scrollCb:W,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskInputOptions:O,dataURLOptions:y,maskTextFn:g,maskInputFn:p,recordCanvas:S,inlineImages:k,sampling:C,slimDOMOptions:D,iframeManager:V,stylesheetManager:Z,canvasManager:ot,keepIframeSrcFn:T},mirror:it});rt=(e=!1)=>{var t,n,r,i,d,u;nt(tt({type:te.Meta,data:{href:window.location.href,width:P(),height:q()}}),e),Z.reset(),ge.forEach((e=>e.lock()));const h=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new f:r,s=n.blockClass,i=void 0===s?"rr-block":s,a=n.blockSelector,c=void 0===a?null:a,l=n.maskTextClass,d=void 0===l?"rr-mask":l,u=n.maskTextSelector,h=void 0===u?null:u,p=n.inlineStylesheet,g=void 0===p||p,m=n.inlineImages,I=void 0!==m&&m,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,w=n.slimDOM,k=void 0!==w&&w,M=n.dataURLOptions,T=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,R=n.iframeLoadTimeout,O=n.onStylesheetLoad,D=n.stylesheetLoadTimeout,x=n.keepIframeSrcFn;return B(e,{doc:e,mirror:o,blockClass:i,blockSelector:c,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:g,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:T,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:R,onStylesheetLoad:O,stylesheetLoadTimeout:D,keepIframeSrcFn:void 0===x?function(){return!1}:x,newlyAddedElement:!1})}(document,{mirror:it,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskAllInputs:O,maskTextFn:g,slimDOM:D,dataURLOptions:y,recordCanvas:S,inlineImages:k,onSerialize:e=>{H(e,it)&&V.addIframe(e),X(e,it)&&Z.trackLinkElement(e),$(e)&&K.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{V.attachIframe(e,t),K.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{Z.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!h)return console.warn("Failed to snapshot the document");nt(tt({type:te.FullSnapshot,data:{node:h,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),ge.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Z.adoptStyleSheets(document.adoptedStyleSheets,it.getId(document))};try{const e=[];e.push(G("DOMContentLoaded",(()=>{nt(tt({type:te.DomContentLoaded,data:{}}))})));const t=e=>{var t;return Ne({mutationCb:_,mousemoveCb:(e,t)=>nt(tt({type:te.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.MouseInteraction},e)})),scrollCb:W,viewportResizeCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.ViewportResize},e)})),inputCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Input},e)})),mediaInteractionCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.MediaInteraction},e)})),styleSheetRuleCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.StyleSheetRule},e)})),styleDeclarationCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.StyleDeclaration},e)})),canvasMutationCb:U,fontCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Font},e)})),selectionCb:e=>{nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Selection},e)}))},blockClass:o,ignoreClass:i,maskTextClass:a,maskTextSelector:c,maskInputOptions:O,inlineStylesheet:l,sampling:C,recordCanvas:S,inlineImages:k,userTriggeredOnInput:A,collectFonts:w,doc:e,maskInputFn:p,maskTextFn:g,keepIframeSrcFn:T,blockSelector:s,slimDOMOptions:D,dataURLOptions:y,mirror:it,iframeManager:V,stylesheetManager:Z,shadowDomManager:K,canvasManager:ot,ignoreCSSAttributes:E,plugins:(null===(t=null==M?void 0:M.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>nt(tt({type:te.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},m)};V.addLoadListener((n=>{e.push(t(n.contentDocument))}));const n=()=>{rt(),e.push(t(document)),st=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(G("load",(()=>{nt(tt({type:te.Load,data:{}})),n()}),window)),()=>{e.forEach((e=>e())),st=!1}}catch(e){console.warn(e)}}var ct,lt;at.addCustomEvent=(e,t)=>{if(!st)throw new Error("please add custom event after start recording");nt(tt({type:te.Custom,data:{tag:e,payload:t}}))},at.freezePage=()=>{ge.forEach((e=>e.freeze()))},at.takeFullSnapshot=e=>{if(!st)throw new Error("please take full snapshot after start recording");rt(e)},at.mirror=it,function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(ct||(ct={})),function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"}(lt||(lt={}));var dt=Uint8Array,ut=Uint16Array,ht=Uint32Array,pt=new dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),gt=new dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),mt=new dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ft=function(e,t){for(var n=new ut(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new ht(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return[n,o]},It=ft(pt,2),Ct=It[0],yt=It[1];Ct[28]=258,yt[258]=28;for(var vt=ft(gt,0)[1],St=new ut(32768),bt=0;bt<32768;++bt){var At=(43690&bt)>>>1|(21845&bt)<<1;At=(61680&(At=(52428&At)>>>2|(13107&At)<<2))>>>4|(3855&At)<<4,St[bt]=((65280&At)>>>8|(255&At)<<8)>>>1}var wt=function(e,t,n){for(var r=e.length,o=0,s=new ut(t);o<r;++o)++s[e[o]-1];var i,a=new ut(t);for(o=0;o<t;++o)a[o]=a[o-1]+s[o-1]<<1;if(n){i=new ut(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],d=t-e[o],u=a[e[o]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)i[St[u]>>>c]=l}else for(i=new ut(r),o=0;o<r;++o)i[o]=St[a[e[o]-1]++]>>>15-e[o];return i},kt=new dt(288);for(bt=0;bt<144;++bt)kt[bt]=8;for(bt=144;bt<256;++bt)kt[bt]=9;for(bt=256;bt<280;++bt)kt[bt]=7;for(bt=280;bt<288;++bt)kt[bt]=8;var Mt=new dt(32);for(bt=0;bt<32;++bt)Mt[bt]=5;var Tt=wt(kt,9,0),Et=wt(Mt,5,0),Nt=function(e){return(e/8>>0)+(7&e&&1)},Rt=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof ut?ut:e instanceof ht?ht:dt)(n-t);return r.set(e.subarray(t,n)),r},Ot=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},Dt=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},xt=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,s=n.slice();if(!o)return[new dt(0),0];if(1==o){var i=new dt(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,u=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=o-1;)a=n[n[l].f<n[u].f?l++:u++],c=n[l!=d&&n[l].f<n[u].f?l++:u++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(r=1;r<o;++r)s[r].s>h&&(h=s[r].s);var p=new ut(h+1),g=Ft(n[d-1],p,0);if(g>t){r=0;var m=0,f=g-t,I=1<<f;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));r<o;++r){var C=s[r].s;if(!(p[C]>t))break;m+=I-(1<<g-p[C]),p[C]=t}for(m>>>=f;m>0;){var y=s[r].s;p[y]<t?m-=1<<t-p[y]++-1:++r}for(;r>=0&&m;--r){var v=s[r].s;p[v]==t&&(--p[v],++m)}g=t}return[new dt(p),g]},Ft=function(e,t,n){return-1==e.s?Math.max(Ft(e.l,t,n+1),Ft(e.r,t,n+1)):t[e.s]=n},Lt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new ut(++t),r=0,o=e[0],s=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)i(32754);s>2&&(i(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(i(o),--s;s>6;s-=6)i(8304);s>2&&(i(s-3<<5|8208),s=0)}for(;s--;)i(o);s=1,o=e[a]}return[n.subarray(0,r),t]},_t=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Wt=function(e,t,n){var r=n.length,o=Nt(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var s=0;s<r;++s)e[o+s+4]=n[s];return 8*(o+4+r)},Bt=function(e,t,n,r,o,s,i,a,c,l,d){Ot(t,d++,n),++o[256];for(var u=xt(o,15),h=u[0],p=u[1],g=xt(s,15),m=g[0],f=g[1],I=Lt(h),C=I[0],y=I[1],v=Lt(m),S=v[0],b=v[1],A=new ut(19),w=0;w<C.length;++w)A[31&C[w]]++;for(w=0;w<S.length;++w)A[31&S[w]]++;for(var k=xt(A,7),M=k[0],T=k[1],E=19;E>4&&!M[mt[E-1]];--E);var N,R,O,D,x=l+5<<3,F=_t(o,kt)+_t(s,Mt)+i,L=_t(o,h)+_t(s,m)+i+14+3*E+_t(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(x<=F&&x<=L)return Wt(t,d,e.subarray(c,c+l));if(Ot(t,d,1+(L<F)),d+=2,L<F){N=wt(h,p,0),R=h,O=wt(m,f,0),D=m;var _=wt(M,T,0);Ot(t,d,y-257),Ot(t,d+5,b-1),Ot(t,d+10,E-4),d+=14;for(w=0;w<E;++w)Ot(t,d+3*w,M[mt[w]]);d+=3*E;for(var W=[C,S],B=0;B<2;++B){var G=W[B];for(w=0;w<G.length;++w){var U=31&G[w];Ot(t,d,_[U]),d+=M[U],U>15&&(Ot(t,d,G[w]>>>5&127),d+=G[w]>>>12)}}}else N=Tt,R=kt,O=Et,D=Mt;for(w=0;w<a;++w)if(r[w]>255){U=r[w]>>>18&31;Dt(t,d,N[U+257]),d+=R[U+257],U>7&&(Ot(t,d,r[w]>>>23&31),d+=pt[U]);var Z=31&r[w];Dt(t,d,O[Z]),d+=D[Z],Z>3&&(Dt(t,d,r[w]>>>5&8191),d+=gt[Z])}else Dt(t,d,N[r[w]]),d+=R[r[w]];return Dt(t,d,N[256]),d+R[256]},Gt=new ht([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ut=new dt(0),Zt=function(e,t,n,r,o){return function(e,t,n,r,o,s){var i=e.length,a=new dt(r+i+5*(1+Math.floor(i/7e3))+o),c=a.subarray(r,a.length-o),l=0;if(!t||i<8)for(var d=0;d<=i;d+=65535){var u=d+65535;u<i?l=Wt(c,l,e.subarray(d,u)):(c[d]=s,l=Wt(c,l,e.subarray(d,i)))}else{for(var h=Gt[t-1],p=h>>>13,g=8191&h,m=(1<<n)-1,f=new ut(32768),I=new ut(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new ht(25e3),b=new ut(288),A=new ut(32),w=0,k=0,M=(d=0,0),T=0,E=0;d<i;++d){var N=v(d),R=32767&d,O=I[N];if(f[R]=O,I[N]=R,T<=d){var D=i-d;if((w>7e3||M>24576)&&D>423){l=Bt(e,c,0,S,b,A,k,M,E,d-E,l),M=w=k=0,E=d;for(var x=0;x<286;++x)b[x]=0;for(x=0;x<30;++x)A[x]=0}var F=2,L=0,_=g,W=R-O&32767;if(D>2&&N==v(d-W))for(var B=Math.min(p,D)-1,G=Math.min(32767,d),U=Math.min(258,D);W<=G&&--_&&R!=O;){if(e[d+F]==e[d+F-W]){for(var Z=0;Z<U&&e[d+Z]==e[d+Z-W];++Z);if(Z>F){if(F=Z,L=W,Z>B)break;var V=Math.min(W,Z-2),K=0;for(x=0;x<V;++x){var Y=d-W+x+32768&32767,q=Y-f[Y]+32768&32767;q>K&&(K=q,O=Y)}}}W+=(R=O)-(O=f[R])+32768&32767}if(L){S[M++]=268435456|yt[F]<<18|vt[L];var P=31&yt[F],z=31&vt[L];k+=pt[P]+gt[z],++b[257+P],++A[z],T=d+F,++w}else S[M++]=e[d],++b[e[d]]}}l=Bt(e,c,s,S,b,A,k,M,E,d-E,l),s||(l=Wt(c,l,Ut))}return Rt(a,0,r+Nt(l)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!o)};function Vt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,s=n.length,i=0;i!=s;){for(var a=Math.min(i+5552,s);i<a;++i)o+=r+=n[i];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r=Zt(e,t,2,4);return function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)}(r,t),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(r,r.length-4,n.d()),r}const Kt=e=>{const t=Object.assign(Object.assign({},e),{v:"v1"});return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var o=e[r++];o<128||t?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((31&o)<<6|63&e[r++]):o<240?n+=String.fromCharCode((15&o)<<12|(63&e[r++])<<6|63&e[r++]):(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}return n}(Vt(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new dt(e.length+(e.length>>>1)),o=0,s=function(e){r[o++]=e},i=0;i<n;++i){if(o+5>r.length){var a=new dt(o+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?s(c):c<2048?(s(192|c>>>6),s(128|63&c)):c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),s(128|c>>>12&63),s(128|c>>>6&63),s(128|63&c)):(s(224|c>>>12),s(128|c>>>6&63),s(128|63&c))}return Rt(r,0,o)}(JSON.stringify(t))),!0)};var Yt,qt;(qt=Yt||(Yt={}))[qt.NotStarted=0]="NotStarted",qt[qt.Running=1]="Running",qt[qt.Stopped=2]="Stopped";var Pt="".concat("[Amplitude]"," Session Recorded"),zt="Session replay event batch rejected due to exceeded retry count",Qt="Failed to store session replay events in IndexedDB",Jt="".concat("AMP","_replay_unsent"),jt=function(){function e(){var e=this;this.name="@amplitude/plugin-session-replay-browser",this.type="enrichment",this.storageKey="",this.retryTimeout=1e3,this.events=[],this.currentSequenceId=0,this.scheduled=null,this.queue=[],this.stopRecordingEvents=null,this.maxPersistedEventsSize=19999800,this.interval=1e3,this.timeAtLastSend=null,this.shouldSplitEventsList=function(t){var n=new Blob([t]).size;return new Blob(e.events).size+n>=e.maxPersistedEventsSize||null!==e.timeAtLastSend&&Date.now()-e.timeAtLastSend>e.interval&&(e.interval=Math.min(1e4,e.interval+1e3),!0)}}return e.prototype.setup=function(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){return e.loggerProvider.log("Installing @amplitude/plugin-session-replay."),this.config=e,this.storageKey="".concat(Jt,"_").concat(this.config.apiKey.substring(0,10)),this.emptyStoreAndReset(),[2]}))}))},e.prototype.execute=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(r){return e.event_properties=n(n({},e.event_properties),((t={})[Pt]=!0,t)),"session_start"===e.event_type?this.recordEvents():"session_end"===e.event_type&&(e.session_id&&this.sendEventsList({events:this.events,sequenceId:this.currentSequenceId,sessionId:e.session_id}),this.stopRecordingEvents&&this.stopRecordingEvents(),this.events=[],this.currentSequenceId=0),[2,Promise.resolve(e)]}))}))},e.prototype.emptyStoreAndReset=function(){return r(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(o){switch(o.label){case 0:return[4,this.getAllSessionEventsFromStore()];case 1:if(e=o.sent()){for(t in e)(n=e[t]).events.length&&this.sendEventsList({events:n.events,sequenceId:n.sequenceId,sessionId:parseInt(t,10)});this.events=[],r=this.config.sessionId&&e[this.config.sessionId],this.currentSequenceId=r?r.sequenceId+1:0,this.storeEventsForSession([],this.currentSequenceId),this.recordEvents()}return[2]}}))}))},e.prototype.recordEvents=function(){var e=this;this.stopRecordingEvents=at({emit:function(t){var n=JSON.stringify(t);if(1===e.events.length&&0===e.currentSequenceId)return e.sendEventsList({events:e.events.concat(n),sequenceId:e.currentSequenceId,sessionId:e.config.sessionId}),e.events=[],void e.currentSequenceId++;e.shouldSplitEventsList(n)&&(e.sendEventsList({events:e.events,sequenceId:e.currentSequenceId,sessionId:e.config.sessionId}),e.events=[],e.currentSequenceId++),e.events.push(n),e.storeEventsForSession(e.events,e.currentSequenceId)},packFn:Kt,maskAllInputs:!0})},e.prototype.sendEventsList=function(e){var t=e.events,n=e.sequenceId,r=e.sessionId;this.addToQueue({events:t,sequenceId:n,attempts:0,timeout:0,sessionId:r})},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.filter((function(t){return t.attempts<e.config.flushMaxRetries?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"".concat(zt,", batch sequence id, ").concat(t.sequenceId)}),!1)}));r.forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(0)}))},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var n,r,s,i,a;return o(this,(function(o){switch(o.label){case 0:n={api_key:this.config.apiKey,device_id:this.config.deviceId,session_id:e.sessionId,start_timestamp:e.sessionId,events_batch:{version:1,events:e.events,seq_number:e.sequenceId}},o.label=1;case 1:return o.trys.push([1,3,,4]),r={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(n),method:"POST"},[4,fetch("https://api-secure.amplitude.com/sessions/track",r)];case 2:if(null===(s=o.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred",removeEvents:!1}),[2];if(t)this.handleReponse(s.status,e);else{i="";try{i=JSON.stringify(s.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(s.status,": ").concat(i)})}return[3,4];case 3:return a=o.sent(),this.completeRequest({context:e,err:a,removeEvents:!1}),[3,4];case 4:return[2]}}))}))},e.prototype.handleReponse=function(e,n){if((new s).buildStatus(e)===t.Success)this.handleSuccessResponse(n);else this.handleOtherResponse(n)},e.prototype.handleSuccessResponse=function(e){this.completeRequest({context:e,success:"Session replay event batch tracked successfully"})},e.prototype.handleOtherResponse=function(e){this.addToQueue(n(n({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.getAllSessionEventsFromStore=function(){return r(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,l(this.storageKey)];case 1:return[2,t.sent()];case 2:return e=t.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(e)),[3,3];case 3:return[2,void 0]}}))}))},e.prototype.storeEventsForSession=function(e,t){return r(this,void 0,void 0,(function(){var r,s=this;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,d(this.storageKey,(function(r){var o;return n(n({},r),s.config.sessionId&&((o={})[s.config.sessionId]={events:e,sequenceId:t},o))}))];case 1:return o.sent(),[3,3];case 2:return r=o.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(r)),[3,3];case 3:return[2]}}))}))},e.prototype.removeSessionEventsStore=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,d(this.storageKey,(function(t){return void 0===t&&(t={}),delete t[e],t}))];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(t)),[3,3];case 3:return[2]}}))}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success,o=e.removeEvents;(void 0===o||o)&&t.sessionId&&this.removeSessionEventsStore(t.sessionId),n?this.config.loggerProvider.error(n):r&&(this.timeAtLastSend=Date.now(),this.config.loggerProvider.log(r))},e}(),Ht=function(){return new jt};e.plugin=Ht,e.sessionReplayPlugin=Ht,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).amplitude={})}(this,(function(e){"use strict";var t,n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(t||(t={}));var s=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var n,r,o,s,i,a,c,l,d,u,h,p,g,m,f,I,C,y,v,S,b,A;if("object"!=typeof e)return null;var w=e.code||0,k=this.buildStatus(w);switch(k){case t.Success:return{status:k,statusCode:w,body:{eventsIngested:null!==(n=e.events_ingested)&&void 0!==n?n:0,payloadSizeBytes:null!==(r=e.payload_size_bytes)&&void 0!==r?r:0,serverUploadTime:null!==(o=e.server_upload_time)&&void 0!==o?o:0}};case t.Invalid:return{status:k,statusCode:w,body:{error:null!==(s=e.error)&&void 0!==s?s:"",missingField:null!==(i=e.missing_field)&&void 0!==i?i:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(c=e.events_with_missing_fields)&&void 0!==c?c:{},eventsWithInvalidIdLengths:null!==(l=e.events_with_invalid_id_lengths)&&void 0!==l?l:{},epsThreshold:null!==(d=e.eps_threshold)&&void 0!==d?d:0,exceededDailyQuotaDevices:null!==(u=e.exceeded_daily_quota_devices)&&void 0!==u?u:{},silencedDevices:null!==(h=e.silenced_devices)&&void 0!==h?h:[],silencedEvents:null!==(p=e.silenced_events)&&void 0!==p?p:[],throttledDevices:null!==(g=e.throttled_devices)&&void 0!==g?g:{},throttledEvents:null!==(m=e.throttled_events)&&void 0!==m?m:[]}};case t.PayloadTooLarge:return{status:k,statusCode:w,body:{error:null!==(f=e.error)&&void 0!==f?f:""}};case t.RateLimit:return{status:k,statusCode:w,body:{error:null!==(I=e.error)&&void 0!==I?I:"",epsThreshold:null!==(C=e.eps_threshold)&&void 0!==C?C:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(v=e.throttled_users)&&void 0!==v?v:{},exceededDailyQuotaDevices:null!==(S=e.exceeded_daily_quota_devices)&&void 0!==S?S:{},exceededDailyQuotaUsers:null!==(b=e.exceeded_daily_quota_users)&&void 0!==b?b:{},throttledEvents:null!==(A=e.throttled_events)&&void 0!==A?A:[]}};case t.Timeout:default:return{status:k,statusCode:w}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?t.Success:429===e?t.RateLimit:413===e?t.PayloadTooLarge:408===e?t.Timeout:e>=400&&e<500?t.Invalid:e>=500?t.Failed:t.Unknown},e}();function i(e){return new Promise(((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}))}let a;function c(){return a||(a=function(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=i(n);return(e,n)=>r.then((r=>n(r.transaction(t,e).objectStore(t))))}("keyval-store","keyval")),a}function l(e,t=c()){return t("readonly",(t=>i(t.get(e))))}function d(e,t,n=c()){return n("readwrite",(n=>new Promise(((r,o)=>{n.get(e).onsuccess=function(){try{n.put(t(this.result),e),r(i(n.transaction))}catch(e){o(e)}}}))))}var u;function h(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function p(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function g(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(m).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function m(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=g(e.styleSheet)||t}catch(e){}return t}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(u||(u={}));var f=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function I(e){var t=e.maskInputOptions,n=e.tagName,r=e.type,o=e.value,s=e.maskInputFn,i=o||"";return(t[n.toLowerCase()]||t[r])&&(i=s?s(i):"*".repeat(i.length)),i}var C="__rrweb_original__";var y,v,S=1,b=new RegExp("[^a-z0-9-_:]");function A(){return S++}var w=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,k=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,M=/^(data:)([^,]*),(.*)/i;function T(e,t){return(e||"").replace(w,(function(e,n,r,o,s,i){var a,c=r||s||i,l=n||o||"";if(!c)return e;if(!k.test(c))return"url(".concat(l).concat(c).concat(l,")");if(M.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var d=t.split("/"),u=c.split("/");d.pop();for(var h=0,p=u;h<p.length;h++){var g=p[h];"."!==g&&(".."===g?d.pop():d.push(g))}return"url(".concat(l).concat(d.join("/")).concat(l,")")}))}var E=/^[^ \t\n\r\u000c]+/,N=/^[, \t\n\r\u000c]+/;function R(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function O(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function D(){var e=document.createElement("a");return e.href="",e.href}function x(e,t,n,r){return"src"===n||"href"===n&&r&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&r&&"#"!==r[0]?R(e,r):"background"!==n||!r||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&r?function(e,t){if(""===t.trim())return t;var n=0;function r(e){var r,o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}for(var o=[];r(N),!(n>=t.length);){var s=r(E);if(","===s.slice(-1))s=R(e,s.substring(0,s.length-1)),o.push(s);else{var i="";s=R(e,s);for(var a=!1;;){var c=t.charAt(n);if(""===c){o.push((s+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,o.push((s+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return o.join(", ")}(e,r):"style"===n&&r?T(r,D()):"object"===t&&"data"===n&&r?R(e,r):r:R(e,r)}function F(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&F(e.parentNode,t,n);for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&F(e.parentNode,t,n)}function L(e,t,n){var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(r.closest(".".concat(t)))return!0}else if(F(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}return!1}function _(e,t){var n=t.doc,r=t.mirror,o=t.blockClass,s=t.blockSelector,i=t.maskTextClass,a=t.maskTextSelector,c=t.inlineStylesheet,l=t.maskInputOptions,d=void 0===l?{}:l,h=t.maskTextFn,p=t.maskInputFn,m=t.dataURLOptions,f=void 0===m?{}:m,S=t.inlineImages,A=t.recordCanvas,w=t.keepIframeSrcFn,k=t.newlyAddedElement,M=void 0!==k&&k,E=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:u.Document,childNodes:[],compatMode:e.compatMode}:{type:u.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:u.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:E};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,r=t.blockClass,o=t.blockSelector,s=t.inlineStylesheet,i=t.maskInputOptions,a=void 0===i?{}:i,c=t.maskInputFn,l=t.dataURLOptions,d=void 0===l?{}:l,h=t.inlineImages,p=t.recordCanvas,m=t.keepIframeSrcFn,f=t.newlyAddedElement,S=void 0!==f&&f,A=t.rootId,w=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&e.matches(n)}(e,r,o),k=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return b.test(t)?"div":t}(e),M={},E=e.attributes.length,N=0;N<E;N++){var R=e.attributes[N];M[R.name]=x(n,k,R.name,R.value)}if("link"===k&&s){var F=Array.from(n.styleSheets).find((function(t){return t.href===e.href})),L=null;F&&(L=g(F)),L&&(delete M.rel,delete M.href,M._cssText=T(L,F.href))}if("style"===k&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(L=g(e.sheet))&&(M._cssText=T(L,D()))}if("input"===k||"textarea"===k||"select"===k){var _=e.value,W=e.checked;"radio"!==M.type&&"checkbox"!==M.type&&"submit"!==M.type&&"button"!==M.type&&_?M.value=I({type:M.type,tagName:k,value:_,maskInputOptions:a,maskInputFn:c}):W&&(M.checked=W)}"option"===k&&(e.selected&&!a.select?M.selected=!0:delete M.selected);if("canvas"===k&&p)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var r=0;r<e.height;r+=50){var o=t.getImageData,s=C in o?o[C]:o;if(new Uint32Array(s.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(M.rr_dataURL=e.toDataURL(d.type,d.quality));else if(!("__context"in e)){var B=e.toDataURL(d.type,d.quality),G=document.createElement("canvas");G.width=e.width,G.height=e.height,B!==G.toDataURL(d.type,d.quality)&&(M.rr_dataURL=B)}if("img"===k&&h){y||(y=n.createElement("canvas"),v=y.getContext("2d"));var U=e,Z=U.crossOrigin;U.crossOrigin="anonymous";var V=function(){try{y.width=U.naturalWidth,y.height=U.naturalHeight,v.drawImage(U,0,0),M.rr_dataURL=y.toDataURL(d.type,d.quality)}catch(e){console.warn("Cannot inline img src=".concat(U.currentSrc,"! Error: ").concat(e))}Z?M.crossOrigin=Z:U.removeAttribute("crossorigin")};U.complete&&0!==U.naturalWidth?V():U.onload=V}"audio"!==k&&"video"!==k||(M.rr_mediaState=e.paused?"paused":"played",M.rr_mediaCurrentTime=e.currentTime);S||(e.scrollLeft&&(M.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(M.rr_scrollTop=e.scrollTop));if(w){var K=e.getBoundingClientRect(),Y=K.width,q=K.height;M={class:M.class,rr_width:"".concat(Y,"px"),rr_height:"".concat(q,"px")}}"iframe"!==k||m(M.src)||(e.contentDocument||(M.rr_src=M.src),delete M.src);return{type:u.Element,tagName:k,attributes:M,childNodes:[],isSVG:O(e)||void 0,needBlock:w,rootId:A}}(e,{doc:n,blockClass:o,blockSelector:s,inlineStylesheet:c,maskInputOptions:d,maskInputFn:p,dataURLOptions:f,inlineImages:S,recordCanvas:A,keepIframeSrcFn:w,newlyAddedElement:M,rootId:E});case e.TEXT_NODE:return function(e,t){var n,r=t.maskTextClass,o=t.maskTextSelector,s=t.maskTextFn,i=t.rootId,a=e.parentNode&&e.parentNode.tagName,c=e.textContent,l="STYLE"===a||void 0,d="SCRIPT"===a||void 0;if(l&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(h=e.parentNode.sheet).cssRules?Array.from(h.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=T(c,D())}var h;d&&(c="SCRIPT_PLACEHOLDER");!l&&!d&&c&&L(e,r,o)&&(c=s?s(c):c.replace(/[\S]/g,"*"));return{type:u.Text,textContent:c||"",isStyle:l,rootId:i}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:h,rootId:E});case e.CDATA_SECTION_NODE:return{type:u.CDATA,textContent:"",rootId:E};case e.COMMENT_NODE:return{type:u.Comment,textContent:e.textContent||"",rootId:E};default:return!1}}function W(e){return void 0===e?"":e.toLowerCase()}function B(e,t){var n,r=t.doc,o=t.mirror,s=t.blockClass,i=t.blockSelector,a=t.maskTextClass,c=t.maskTextSelector,l=t.skipChild,d=void 0!==l&&l,g=t.inlineStylesheet,m=void 0===g||g,f=t.maskInputOptions,I=void 0===f?{}:f,C=t.maskTextFn,y=t.maskInputFn,v=t.slimDOMOptions,S=t.dataURLOptions,b=void 0===S?{}:S,w=t.inlineImages,k=void 0!==w&&w,M=t.recordCanvas,T=void 0!==M&&M,E=t.onSerialize,N=t.onIframeLoad,R=t.iframeLoadTimeout,O=void 0===R?5e3:R,D=t.onStylesheetLoad,x=t.stylesheetLoadTimeout,F=void 0===x?5e3:x,L=t.keepIframeSrcFn,G=void 0===L?function(){return!1}:L,U=t.newlyAddedElement,Z=void 0!==U&&U,V=t.preserveWhiteSpace,K=void 0===V||V,Y=_(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,dataURLOptions:b,inlineImages:k,recordCanvas:T,keepIframeSrcFn:G,newlyAddedElement:Z});if(!Y)return console.warn(e,"not serialized"),null;n=o.hasNode(e)?o.getId(e):!function(e,t){if(t.comment&&e.type===u.Comment)return!0;if(e.type===u.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(W(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===W(e.attributes.name)||"icon"===W(e.attributes.rel)||"apple-touch-icon"===W(e.attributes.rel)||"shortcut icon"===W(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&W(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(W(e.attributes.property).match(/^(og|twitter|fb):/)||W(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===W(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===W(e.attributes.name)||"googlebot"===W(e.attributes.name)||"bingbot"===W(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===W(e.attributes.name)||"generator"===W(e.attributes.name)||"framework"===W(e.attributes.name)||"publisher"===W(e.attributes.name)||"progid"===W(e.attributes.name)||W(e.attributes.property).match(/^article:/)||W(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===W(e.attributes.name)||"yandex-verification"===W(e.attributes.name)||"csrf-token"===W(e.attributes.name)||"p:domain_verify"===W(e.attributes.name)||"verify-v1"===W(e.attributes.name)||"verification"===W(e.attributes.name)||"shopify-checkout-api-token"===W(e.attributes.name)))return!0}}return!1}(Y,v)&&(K||Y.type!==u.Text||Y.isStyle||Y.textContent.replace(/^\s+|\s+$/gm,"").length)?A():-2;var q=Object.assign(Y,{id:n});if(o.add(e,q),-2===n)return null;E&&E(e);var P=!d;if(q.type===u.Element){P=P&&!q.needBlock,delete q.needBlock;var z=e.shadowRoot;z&&p(z)&&(q.isShadowHost=!0)}if((q.type===u.Document||q.type===u.Element)&&P){v.headWhitespace&&q.type===u.Element&&"head"===q.tagName&&(K=!1);for(var Q={doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:d,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G},J=0,j=Array.from(e.childNodes);J<j.length;J++){($=B(j[J],Q))&&q.childNodes.push($)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var H=0,X=Array.from(e.shadowRoot.childNodes);H<X.length;H++){var $;($=B(X[H],Q))&&(p(e.shadowRoot)&&($.isShadow=!0),q.childNodes.push($))}}return e.parentNode&&h(e.parentNode)&&p(e.parentNode)&&(q.isShadow=!0),q.type===u.Element&&"iframe"===q.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var o,s=!1;try{o=r.document.readyState}catch(e){return}if("complete"===o){var i="about:blank";if(r.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout((function(){s||(t(),s=!0)}),n);e.addEventListener("load",(function(){clearTimeout(a),s=!0,t()}))}}}(e,(function(){var t=e.contentDocument;if(t&&N){var n=B(t,{doc:t,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G});n&&N(e,n)}}),O),q.type===u.Element&&"link"===q.tagName&&"stylesheet"===q.attributes.rel&&function(e,t,n){var r,o=!1;try{r=e.sheet}catch(e){return}if(!r){var s=setTimeout((function(){o||(t(),o=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),o=!0,t()}))}}(e,(function(){if(D){var t=B(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:m,maskInputOptions:I,maskTextFn:C,maskInputFn:y,slimDOMOptions:v,dataURLOptions:b,inlineImages:k,recordCanvas:T,preserveWhiteSpace:K,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:O,onStylesheetLoad:D,stylesheetLoadTimeout:F,keepIframeSrcFn:G});t&&D(e,t)}}),F),q}function G(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const U="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Z={map:{},getId:()=>(console.error(U),-1),getNode:()=>(console.error(U),null),removeNodeFromMap(){console.error(U)},has:()=>(console.error(U),!1),reset(){console.error(U)}};function V(e,t,n={}){let r=null,o=0;return function(...s){const i=Date.now();o||!1!==n.leading||(o=i);const a=t-(i-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=i,e.apply(c,s)):r||!1===n.trailing||(r=setTimeout((()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,s)}),a))}}function K(e,t,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>K(e,t,s||{},!0)}function Y(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch(e){return()=>{}}}function q(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function P(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function z(e,t,n,r){if(!e)return!1;const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(F(o,t,r))return!0;if(n){if(e.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function Q(e,t){return-2===t.getId(e)}function J(e,t){if(h(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||J(e.parentNode,t))}function j(e){return Boolean(e.changedTouches)}function H(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function X(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function $(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Z=new Proxy(Z,{get:(e,t,n)=>("map"===t&&console.error(U),Reflect.get(e,t,n))}));class ee{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var te=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(te||{}),ne=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(ne||{}),re=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(re||{}),oe=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(oe||{});function se(e){return"__ln"in e}class ie{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&se(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&se(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next&&(t.next.previous=t.previous)):(this.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const ae=(e,t)=>`${e}@${t}`;class ce{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new ie,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},r=r=>{var o,s,i,a;let c=null;(null===(s=null===(o=r.getRootNode)||void 0===o?void 0:o.call(r))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&r.getRootNode().host&&(c=r.getRootNode().host);let l=c;for(;(null===(a=null===(i=null==l?void 0:l.getRootNode)||void 0===i?void 0:i.call(l))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&l.getRootNode().host;)l=l.getRootNode().host;const d=!(this.doc.contains(r)||l&&this.doc.contains(l));if(!r.parentNode||d)return;const u=h(r.parentNode)?this.mirror.getId(c):this.mirror.getId(r.parentNode),p=n(r);if(-1===u||-1===p)return t.addNode(r);const g=B(r,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{H(e,this.mirror)&&this.iframeManager.addIframe(e),X(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),$(r)&&this.shadowDomManager.addShadowRoot(r.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});g&&e.push({parentId:u,nextId:p,node:g})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))de(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||r(e);for(const e of Array.from(this.addedSet.values()))he(this.droppedSet,e)||de(this.removes,e,this.mirror)?he(this.movedSet,e)?r(e):this.droppedSet.add(e):r(e);let o=null;for(;t.length;){let e=null;if(o){const t=this.mirror.getId(o.value.parentNode),r=n(o.value);-1!==t&&-1!==r&&(e=o)}if(!e)for(let r=t.length-1;r>=0;r--){const o=t.get(r);if(o){const t=this.mirror.getId(o.value.parentNode);if(-1===n(o.value))continue;if(-1!==t){e=o;break}{const t=o.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=o;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}o=e.previous,t.removeNode(e.value),r(e.value)}const s={texts:this.texts.map((e=>({id:this.mirror.getId(e.node),value:e.value}))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>({id:this.mirror.getId(e.node),attributes:e.attributes}))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!Q(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;z(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:L(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=I({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),z(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let r=this.attributes.find((t=>t.node===e.target));if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(r||(r={node:e.target,attributes:{}},this.attributes.push(r)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==r.attributes.style&&null!==r.attributes.style||(r.attributes.style={});const o=r.attributes.style;for(const e of Array.from(t.style)){const r=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);r===n.style.getPropertyValue(e)&&s===n.style.getPropertyPriority(e)||(o[e]=""===s?r:[r,s])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(o[e]=!1)}else r.attributes[e.attributeName]=x(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(z(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),r=h(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);z(e.target,this.blockClass,this.blockSelector,!1)||Q(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(le(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||J(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[ae(n,r)]?le(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!h(e.target)||!p(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(Q(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[ae(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);z(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach((e=>this.genAdds(e)))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach((t=>{this[t]=e[t]}))}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function le(e,t){e.delete(t),t.childNodes.forEach((t=>le(e,t)))}function de(e,t,n){return 0!==e.length&&ue(e,t,n)}function ue(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some((e=>e.id===o))||ue(e,r,n)}function he(e,t){return 0!==e.size&&pe(e,t)}function pe(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||pe(e,n))}const ge=[],me="undefined"!=typeof CSSGroupingRule,fe="undefined"!=typeof CSSMediaRule,Ie="undefined"!=typeof CSSSupportsRule,Ce="undefined"!=typeof CSSConditionRule;function ye(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function ve(e,t){var n,r;const o=new ce;ge.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(o.processMutations.bind(o));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function Se({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(re).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{const i=s.toLowerCase(),c=(t=>s=>{const i=ye(s);if(z(i,r,o,!0))return;const a=j(s)?s.changedTouches[0]:s;if(!a)return;const c=n.getId(i),{clientX:l,clientY:d}=a;e({type:re[t],id:c,x:l,y:d})})(s);a.push(G(i,c,t))})),()=>{a.forEach((e=>e()))}}function be({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){return G("scroll",V((s=>{const i=ye(s);if(!i||z(i,r,o,!0))return;const a=n.getId(i);if(i===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})}),s.scroll||100),t)}function Ae(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const we=["INPUT","TEXTAREA","SELECT"],ke=new WeakMap;function Me(e){return function(e,t){if(me&&e.parentRule instanceof CSSGroupingRule||fe&&e.parentRule instanceof CSSMediaRule||Ie&&e.parentRule instanceof CSSSupportsRule||Ce&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function Te(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function Ee({mirror:e,stylesheetManager:t},n){var r,o,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(s=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===s?void 0:s.ShadowRoot,c=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==i&&-1!==i&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return r}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function Ne(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t);const r=ve(e,e.doc),o=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=V((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null}),s),l=V((e=>{const t=ye(e),{clientX:n,clientY:o}=j(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:o,id:r.getId(t),timeOffset:Date.now()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?ne.Drag:e instanceof MouseEvent?ne.MouseMove:ne.TouchMove)}),o,{trailing:!1}),d=[G("mousemove",l,n),G("touchmove",l,n),G("drag",l,n)];return()=>{d.forEach((e=>e()))}}(e),s=Se(e),i=be(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return G("resize",V((()=>{const r=q(),o=P();t===r&&n===o||(e({width:Number(o),height:Number(r)}),t=r,n=o)}),200),window)}(e),c=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:s,maskInputOptions:i,maskInputFn:a,sampling:c,userTriggeredOnInput:l}){function d(e){let n=ye(e);const c=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||we.indexOf(n.tagName)<0||z(n,r,o,!0))return;const d=n.type;if(n.classList.contains(s))return;let h=n.value,p=!1;"radio"===d||"checkbox"===d?p=n.checked:(i[n.tagName.toLowerCase()]||i[d])&&(h=I({maskInputOptions:i,tagName:n.tagName,type:d,value:h,maskInputFn:a})),u(n,Ae({text:h,isChecked:p,userTriggered:c},l));const g=n.name;"radio"===d&&g&&p&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach((e=>{e!==n&&u(e,Ae({text:e.value,isChecked:!p,userTriggered:!1},l))}))}function u(t,r){const o=ke.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){ke.set(t,r);const o=n.getId(t);e(Object.assign(Object.assign({},r),{id:o}))}}const h=("last"===c.input?["change"]:["input","change"]).map((e=>G(e,d,t))),p=t.defaultView;if(!p)return()=>{h.forEach((e=>e()))};const g=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),m=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return g&&g.set&&h.push(...m.map((e=>K(e[0],e[1],{set(){d({target:this})}},!1,p)))),()=>{h.forEach((e=>e()))}}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o}){const s=s=>V((o=>{const i=ye(o);if(!i||z(i,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=i;e({type:s,id:r.getId(i),currentTime:a,volume:c,muted:l,playbackRate:d})}),o.media||500),i=[G("play",s(0)),G("pause",s(1)),G("seeked",s(2)),G("volumechange",s(3)),G("ratechange",s(4))];return()=>{i.forEach((e=>e()))}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=function(r,s){const{id:i,styleId:a}=Te(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:s}]}),o.apply(this,[r,s])};const s=r.CSSStyleSheet.prototype.deleteRule;let i,a;r.CSSStyleSheet.prototype.deleteRule=function(r){const{id:o,styleId:i}=Te(this,t,n.styleMirror);return(o&&-1!==o||i&&-1!==i)&&e({id:o,styleId:i,removes:[{index:r}]}),s.apply(this,[r])},r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=function(r){const{id:o,styleId:s}=Te(this,t,n.styleMirror);return(o&&-1!==o||s&&-1!==s)&&e({id:o,styleId:s,replace:r}),i.apply(this,[r])}),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=function(r){const{id:o,styleId:s}=Te(this,t,n.styleMirror);return(o&&-1!==o||s&&-1!==s)&&e({id:o,styleId:s,replaceSync:r}),a.apply(this,[r])});const c={};me?c.CSSGroupingRule=r.CSSGroupingRule:(fe&&(c.CSSMediaRule=r.CSSMediaRule),Ce&&(c.CSSConditionRule=r.CSSConditionRule),Ie&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach((([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=function(o,s){const{id:i,styleId:a}=Te(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:o,index:[...Me(this),s||0]}]}),l[r].insertRule.apply(this,[o,s])},o.prototype.deleteRule=function(o){const{id:s,styleId:i}=Te(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:[...Me(this),o]}]}),l[r].deleteRule.apply(this,[o])}})),()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=s,i&&(r.CSSStyleSheet.prototype.replace=i),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule}))}}(e,{win:n}),u=Ee(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=function(o,i,a){var c;if(n.has(o))return s.apply(this,[o,i,a]);const{id:l,styleId:d}=Te(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:o,value:i,priority:a},index:Me(this.parentRule)}),s.apply(this,[o,i,a])};const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=function(o){var s;if(n.has(o))return i.apply(this,[o]);const{id:a,styleId:c}=Te(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,t,r.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:o},index:Me(this.parentRule)}),i.apply(this,[o])},()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),p=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const r=new s(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const i=Y(t.fonts,"add",(function(t){return function(n){return setTimeout((()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.apply(this,[n])}}));return r.push((()=>{n.FontFace=s})),r.push(i),()=>{r.forEach((e=>e()))}}(e):()=>{},g=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:s}=e;let i=!0;const a=()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:c,endContainer:l,endOffset:d}=s;z(i,r,o,!0)||z(l,r,o,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(l),endOffset:d})}s({ranges:a})};return a(),G("selectionchange",a)}(e),m=[];for(const t of e.plugins)m.push(t.observer(t.callback,n,t.options));return()=>{ge.forEach((e=>e.reset())),r.disconnect(),o(),s(),i(),a(),c(),l(),d(),u(),h(),p(),g(),m.forEach((e=>e()))}}class Re{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),s=r||this.getRemoteIdToIdMap(e);let i=o.get(t);return i||(i=this.generateIdFn(),o.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,r)))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map((t=>this.getRemoteId(e,t,n)))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class Oe{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Re(A),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Re(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case te.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:te.IncrementalSnapshot,data:{source:ne.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case te.Meta:case te.Load:case te.DomContentLoaded:return!1;case te.Plugin:return t;case te.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case te.IncrementalSnapshot:switch(t.data.source){case ne.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)})),t.data.removes.forEach((t=>{this.replaceIds(t,e,["parentId","id"])})),t.data.attributes.forEach((t=>{this.replaceIds(t,e,["id"])})),t.data.texts.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ne.Drag:case ne.TouchMove:case ne.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case ne.ViewportResize:return!1;case ne.MediaInteraction:case ne.MouseInteraction:case ne.Scroll:case ne.CanvasMutation:case ne.Input:return this.replaceIds(t.data,e,["id"]),t;case ne.StyleSheetRule:case ne.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case ne.Font:return t;case ne.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case ne.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach((t=>{this.replaceStyleIds(t,e,["styleId"])})),t}}}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}}class De{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(Y(Element.prototype,"attachShadow",(function(e){return function(n){const r=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),r}})))}addShadowRoot(e,t){p(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ve(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),be(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout((()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),Ee({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)}),0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(Y(e.contentWindow.HTMLElement.prototype,"attachShadow",(function(n){return function(r){const o=n.call(this,r);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),o}})))}}reset(){this.restorePatches.forEach((e=>e())),this.shadowDoms=new WeakSet}}function xe(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}for(var Fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Le="undefined"==typeof Uint8Array?[]:new Uint8Array(256),_e=0;_e<Fe.length;_e++)Le[Fe.charCodeAt(_e)]=_e;const We=new Map;const Be=(e,t,n)=>{if(!e||!Ze(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=We.get(e);return n||(n=new Map,We.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Ge(e,t,n){if(e instanceof Array)return e.map((e=>Ge(e,t,n)));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Fe[n[t]>>2],o+=Fe[(3&n[t])<<4|n[t+1]>>4],o+=Fe[(15&n[t+1])<<2|n[t+2]>>6],o+=Fe[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Ge(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Ge(e.data,t,n),e.width,e.height]}}if(Ze(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Be(e,t,n)}}return e}const Ue=(e,t,n)=>[...e].map((e=>Ge(e,t,n))),Ze=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((e=>"function"==typeof t[e]));return Boolean(n.find((n=>e instanceof t[n])))};function Ve(e,t,n){const r=[];try{const o=Y(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(r,...o){return z(this,t,n,!0)||"__context"in this||(this.__context=r),e.apply(this,[r,...o])}}));r.push(o)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{r.forEach((e=>e()))}}function Ke(e,t,n,r,o,s,i){const a=[],c=Object.getOwnPropertyNames(e);for(const s of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const c=Y(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(Be(c,i,this),!z(this.canvas,r,o,!0)){const e=Ue([...a],i,this),r={type:t,property:s,args:e};n(this.canvas,r)}return c}}));a.push(c)}catch(r){const o=K(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(o)}return a}var Ye=null;try{var qe="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");Ye=qe.Worker}catch(e){}function Pe(e,t,n){var r=void 0===t?null:t,o=function(e,t){return Buffer.from(e,"base64").toString(t?"utf16":"utf8")}(e,void 0!==n&&n),s=o.indexOf("\n",10)+1,i=o.substring(s)+(r?"//# sourceMappingURL="+r:"");return function(e){return new Ye(i,Object.assign({},e,{eval:!0}))}}function ze(e,t,n){var r=void 0===t?null:t,o=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),o=0,s=n.length;o<s;++o)r[o]=n.charCodeAt(o);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(e,void 0!==n&&n),s=o.indexOf("\n",10)+1,i=o.substring(s)+(r?"//# sourceMappingURL="+r:""),a=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(a)}var Qe="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Je,je,He,Xe=(Je="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJ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ICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICA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AgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",je=null,He=!1,Qe?Pe(Je,je,He):function(e,t,n){var r;return function(o){return r=r||ze(e,t,n),new Worker(r,o)}}(Je,je,He));class $e{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,r,o),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:i})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,o){const s=Ve(t,n,r),i=new Map,a=new Xe;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:s}=e.data;this.mutationCb({id:t,type:oe["2D"],commands:[{property:"clearRect",args:[0,0,o,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{z(t,n,r,!0)||e.push(t)})),e})().forEach((e=>xe(this,void 0,void 0,(function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Ve(e,t,n),o=function(e,t,n,r){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=Y(t.CanvasRenderingContext2D.prototype,i,(function(o){return function(...s){return z(this.canvas,n,r,!0)||setTimeout((()=>{const n=Ue([...s],t,this);e(this.canvas,{type:oe["2D"],property:i,args:n})}),0),o.apply(this,s)}}));o.push(s)}catch(n){const r=K(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:oe["2D"],property:i,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,r,o){const s=[];return s.push(...Ke(t.WebGLRenderingContext.prototype,oe.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(...Ke(t.WebGL2RenderingContext.prototype,oe.WebGL2,e,n,r,0,t)),()=>{s.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach(((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)})),requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map((e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t})),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class et{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new ee,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map(((e,t)=>({rule:m(e),index:t})))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function tt(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let nt,rt,ot,st=!1;const it=new f;function at(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:c=null,inlineStylesheet:l=!0,maskAllInputs:d,maskInputOptions:u,slimDOMOptions:h,maskInputFn:p,maskTextFn:g,hooks:m,packFn:I,sampling:C={},dataURLOptions:y={},mousemoveWait:v,recordCanvas:S=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:A=!1,collectFonts:w=!1,inlineImages:k=!1,plugins:M,keepIframeSrcFn:T=(()=>!1),ignoreCSSAttributes:E=new Set([])}=e,N=!b||window.parent===window;let R=!1;if(!N)try{window.parent.document,R=!1}catch(e){R=!0}if(N&&!t)throw new Error("emit function is required");void 0!==v&&void 0===C.mousemove&&(C.mousemove=v),it.reset();const O=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==u?u:{password:!0},D=!0===h||"all"===h?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===h,headMetaDescKeywords:"all"===h}:h||{};let x;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let F=0;const L=e=>{for(const t of M||[])t.eventProcessor&&(e=t.eventProcessor(e));return I&&(e=I(e)),e};nt=(e,o)=>{var s;if(!(null===(s=ge[0])||void 0===s?void 0:s.isFrozen())||e.type===te.FullSnapshot||e.type===te.IncrementalSnapshot&&e.data.source===ne.Mutation||ge.forEach((e=>e.unfreeze())),N)null==t||t(L(e),o);else if(R){const t={type:"rrweb",event:L(e),isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===te.FullSnapshot)x=e,F=0;else if(e.type===te.IncrementalSnapshot){if(e.data.source===ne.Mutation&&e.data.isAttachIframe)return;F++;const t=r&&F>=r,o=n&&e.timestamp-x.timestamp>n;(t||o)&&rt(!0)}};const _=e=>{nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Mutation},e)}))},W=e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Scroll},e)})),U=e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.CanvasMutation},e)})),Z=new et({mutationCb:_,adoptedStyleSheetCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.AdoptedStyleSheet},e)}))}),V=new Oe({mirror:it,mutationCb:_,stylesheetManager:Z,recordCrossOriginIframes:b,wrappedEmit:nt});for(const e of M||[])e.getMirror&&e.getMirror({nodeMirror:it,crossOriginIframeMirror:V.crossOriginIframeMirror,crossOriginIframeStyleMirror:V.crossOriginIframeStyleMirror});ot=new $e({recordCanvas:S,mutationCb:U,win:window,blockClass:o,blockSelector:s,mirror:it,sampling:C.canvas,dataURLOptions:y});const K=new De({mutationCb:_,scrollCb:W,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskInputOptions:O,dataURLOptions:y,maskTextFn:g,maskInputFn:p,recordCanvas:S,inlineImages:k,sampling:C,slimDOMOptions:D,iframeManager:V,stylesheetManager:Z,canvasManager:ot,keepIframeSrcFn:T},mirror:it});rt=(e=!1)=>{var t,n,r,i,d,u;nt(tt({type:te.Meta,data:{href:window.location.href,width:P(),height:q()}}),e),Z.reset(),ge.forEach((e=>e.lock()));const h=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new f:r,s=n.blockClass,i=void 0===s?"rr-block":s,a=n.blockSelector,c=void 0===a?null:a,l=n.maskTextClass,d=void 0===l?"rr-mask":l,u=n.maskTextSelector,h=void 0===u?null:u,p=n.inlineStylesheet,g=void 0===p||p,m=n.inlineImages,I=void 0!==m&&m,C=n.recordCanvas,y=void 0!==C&&C,v=n.maskAllInputs,S=void 0!==v&&v,b=n.maskTextFn,A=n.maskInputFn,w=n.slimDOM,k=void 0!==w&&w,M=n.dataURLOptions,T=n.preserveWhiteSpace,E=n.onSerialize,N=n.onIframeLoad,R=n.iframeLoadTimeout,O=n.onStylesheetLoad,D=n.stylesheetLoadTimeout,x=n.keepIframeSrcFn;return B(e,{doc:e,mirror:o,blockClass:i,blockSelector:c,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:g,maskInputOptions:!0===S?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===S?{password:!0}:S,maskTextFn:b,maskInputFn:A,slimDOMOptions:!0===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:M,inlineImages:I,recordCanvas:y,preserveWhiteSpace:T,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:R,onStylesheetLoad:O,stylesheetLoadTimeout:D,keepIframeSrcFn:void 0===x?function(){return!1}:x,newlyAddedElement:!1})}(document,{mirror:it,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskAllInputs:O,maskTextFn:g,slimDOM:D,dataURLOptions:y,recordCanvas:S,inlineImages:k,onSerialize:e=>{H(e,it)&&V.addIframe(e),X(e,it)&&Z.trackLinkElement(e),$(e)&&K.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{V.attachIframe(e,t),K.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{Z.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!h)return console.warn("Failed to snapshot the document");nt(tt({type:te.FullSnapshot,data:{node:h,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null===document||void 0===document?void 0:document.body)||void 0===r?void 0:r.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),ge.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Z.adoptStyleSheets(document.adoptedStyleSheets,it.getId(document))};try{const e=[];e.push(G("DOMContentLoaded",(()=>{nt(tt({type:te.DomContentLoaded,data:{}}))})));const t=e=>{var t;return Ne({mutationCb:_,mousemoveCb:(e,t)=>nt(tt({type:te.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.MouseInteraction},e)})),scrollCb:W,viewportResizeCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.ViewportResize},e)})),inputCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Input},e)})),mediaInteractionCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.MediaInteraction},e)})),styleSheetRuleCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.StyleSheetRule},e)})),styleDeclarationCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.StyleDeclaration},e)})),canvasMutationCb:U,fontCb:e=>nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Font},e)})),selectionCb:e=>{nt(tt({type:te.IncrementalSnapshot,data:Object.assign({source:ne.Selection},e)}))},blockClass:o,ignoreClass:i,maskTextClass:a,maskTextSelector:c,maskInputOptions:O,inlineStylesheet:l,sampling:C,recordCanvas:S,inlineImages:k,userTriggeredOnInput:A,collectFonts:w,doc:e,maskInputFn:p,maskTextFn:g,keepIframeSrcFn:T,blockSelector:s,slimDOMOptions:D,dataURLOptions:y,mirror:it,iframeManager:V,stylesheetManager:Z,shadowDomManager:K,canvasManager:ot,ignoreCSSAttributes:E,plugins:(null===(t=null==M?void 0:M.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>nt(tt({type:te.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},m)};V.addLoadListener((n=>{e.push(t(n.contentDocument))}));const n=()=>{rt(),e.push(t(document)),st=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(G("load",(()=>{nt(tt({type:te.Load,data:{}})),n()}),window)),()=>{e.forEach((e=>e())),st=!1}}catch(e){console.warn(e)}}var ct,lt;at.addCustomEvent=(e,t)=>{if(!st)throw new Error("please add custom event after start recording");nt(tt({type:te.Custom,data:{tag:e,payload:t}}))},at.freezePage=()=>{ge.forEach((e=>e.freeze()))},at.takeFullSnapshot=e=>{if(!st)throw new Error("please take full snapshot after start recording");rt(e)},at.mirror=it,function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(ct||(ct={})),function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"}(lt||(lt={}));var dt=Uint8Array,ut=Uint16Array,ht=Uint32Array,pt=new dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),gt=new dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),mt=new dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ft=function(e,t){for(var n=new ut(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new ht(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return[n,o]},It=ft(pt,2),Ct=It[0],yt=It[1];Ct[28]=258,yt[258]=28;for(var vt=ft(gt,0)[1],St=new ut(32768),bt=0;bt<32768;++bt){var At=(43690&bt)>>>1|(21845&bt)<<1;At=(61680&(At=(52428&At)>>>2|(13107&At)<<2))>>>4|(3855&At)<<4,St[bt]=((65280&At)>>>8|(255&At)<<8)>>>1}var wt=function(e,t,n){for(var r=e.length,o=0,s=new ut(t);o<r;++o)++s[e[o]-1];var i,a=new ut(t);for(o=0;o<t;++o)a[o]=a[o-1]+s[o-1]<<1;if(n){i=new ut(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],d=t-e[o],u=a[e[o]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)i[St[u]>>>c]=l}else for(i=new ut(r),o=0;o<r;++o)i[o]=St[a[e[o]-1]++]>>>15-e[o];return i},kt=new dt(288);for(bt=0;bt<144;++bt)kt[bt]=8;for(bt=144;bt<256;++bt)kt[bt]=9;for(bt=256;bt<280;++bt)kt[bt]=7;for(bt=280;bt<288;++bt)kt[bt]=8;var Mt=new dt(32);for(bt=0;bt<32;++bt)Mt[bt]=5;var Tt=wt(kt,9,0),Et=wt(Mt,5,0),Nt=function(e){return(e/8>>0)+(7&e&&1)},Rt=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof ut?ut:e instanceof ht?ht:dt)(n-t);return r.set(e.subarray(t,n)),r},Ot=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},Dt=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},xt=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,s=n.slice();if(!o)return[new dt(0),0];if(1==o){var i=new dt(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,d=1,u=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};d!=o-1;)a=n[n[l].f<n[u].f?l++:u++],c=n[l!=d&&n[l].f<n[u].f?l++:u++],n[d++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(r=1;r<o;++r)s[r].s>h&&(h=s[r].s);var p=new ut(h+1),g=Ft(n[d-1],p,0);if(g>t){r=0;var m=0,f=g-t,I=1<<f;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));r<o;++r){var C=s[r].s;if(!(p[C]>t))break;m+=I-(1<<g-p[C]),p[C]=t}for(m>>>=f;m>0;){var y=s[r].s;p[y]<t?m-=1<<t-p[y]++-1:++r}for(;r>=0&&m;--r){var v=s[r].s;p[v]==t&&(--p[v],++m)}g=t}return[new dt(p),g]},Ft=function(e,t,n){return-1==e.s?Math.max(Ft(e.l,t,n+1),Ft(e.r,t,n+1)):t[e.s]=n},Lt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new ut(++t),r=0,o=e[0],s=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)i(32754);s>2&&(i(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(i(o),--s;s>6;s-=6)i(8304);s>2&&(i(s-3<<5|8208),s=0)}for(;s--;)i(o);s=1,o=e[a]}return[n.subarray(0,r),t]},_t=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Wt=function(e,t,n){var r=n.length,o=Nt(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var s=0;s<r;++s)e[o+s+4]=n[s];return 8*(o+4+r)},Bt=function(e,t,n,r,o,s,i,a,c,l,d){Ot(t,d++,n),++o[256];for(var u=xt(o,15),h=u[0],p=u[1],g=xt(s,15),m=g[0],f=g[1],I=Lt(h),C=I[0],y=I[1],v=Lt(m),S=v[0],b=v[1],A=new ut(19),w=0;w<C.length;++w)A[31&C[w]]++;for(w=0;w<S.length;++w)A[31&S[w]]++;for(var k=xt(A,7),M=k[0],T=k[1],E=19;E>4&&!M[mt[E-1]];--E);var N,R,O,D,x=l+5<<3,F=_t(o,kt)+_t(s,Mt)+i,L=_t(o,h)+_t(s,m)+i+14+3*E+_t(A,M)+(2*A[16]+3*A[17]+7*A[18]);if(x<=F&&x<=L)return Wt(t,d,e.subarray(c,c+l));if(Ot(t,d,1+(L<F)),d+=2,L<F){N=wt(h,p,0),R=h,O=wt(m,f,0),D=m;var _=wt(M,T,0);Ot(t,d,y-257),Ot(t,d+5,b-1),Ot(t,d+10,E-4),d+=14;for(w=0;w<E;++w)Ot(t,d+3*w,M[mt[w]]);d+=3*E;for(var W=[C,S],B=0;B<2;++B){var G=W[B];for(w=0;w<G.length;++w){var U=31&G[w];Ot(t,d,_[U]),d+=M[U],U>15&&(Ot(t,d,G[w]>>>5&127),d+=G[w]>>>12)}}}else N=Tt,R=kt,O=Et,D=Mt;for(w=0;w<a;++w)if(r[w]>255){U=r[w]>>>18&31;Dt(t,d,N[U+257]),d+=R[U+257],U>7&&(Ot(t,d,r[w]>>>23&31),d+=pt[U]);var Z=31&r[w];Dt(t,d,O[Z]),d+=D[Z],Z>3&&(Dt(t,d,r[w]>>>5&8191),d+=gt[Z])}else Dt(t,d,N[r[w]]),d+=R[r[w]];return Dt(t,d,N[256]),d+R[256]},Gt=new ht([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ut=new dt(0),Zt=function(e,t,n,r,o){return function(e,t,n,r,o,s){var i=e.length,a=new dt(r+i+5*(1+Math.floor(i/7e3))+o),c=a.subarray(r,a.length-o),l=0;if(!t||i<8)for(var d=0;d<=i;d+=65535){var u=d+65535;u<i?l=Wt(c,l,e.subarray(d,u)):(c[d]=s,l=Wt(c,l,e.subarray(d,i)))}else{for(var h=Gt[t-1],p=h>>>13,g=8191&h,m=(1<<n)-1,f=new ut(32768),I=new ut(m+1),C=Math.ceil(n/3),y=2*C,v=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<y)&m},S=new ht(25e3),b=new ut(288),A=new ut(32),w=0,k=0,M=(d=0,0),T=0,E=0;d<i;++d){var N=v(d),R=32767&d,O=I[N];if(f[R]=O,I[N]=R,T<=d){var D=i-d;if((w>7e3||M>24576)&&D>423){l=Bt(e,c,0,S,b,A,k,M,E,d-E,l),M=w=k=0,E=d;for(var x=0;x<286;++x)b[x]=0;for(x=0;x<30;++x)A[x]=0}var F=2,L=0,_=g,W=R-O&32767;if(D>2&&N==v(d-W))for(var B=Math.min(p,D)-1,G=Math.min(32767,d),U=Math.min(258,D);W<=G&&--_&&R!=O;){if(e[d+F]==e[d+F-W]){for(var Z=0;Z<U&&e[d+Z]==e[d+Z-W];++Z);if(Z>F){if(F=Z,L=W,Z>B)break;var V=Math.min(W,Z-2),K=0;for(x=0;x<V;++x){var Y=d-W+x+32768&32767,q=Y-f[Y]+32768&32767;q>K&&(K=q,O=Y)}}}W+=(R=O)-(O=f[R])+32768&32767}if(L){S[M++]=268435456|yt[F]<<18|vt[L];var P=31&yt[F],z=31&vt[L];k+=pt[P]+gt[z],++b[257+P],++A[z],T=d+F,++w}else S[M++]=e[d],++b[e[d]]}}l=Bt(e,c,s,S,b,A,k,M,E,d-E,l),s||(l=Wt(c,l,Ut))}return Rt(a,0,r+Nt(l)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!o)};function Vt(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,s=n.length,i=0;i!=s;){for(var a=Math.min(i+5552,s);i<a;++i)o+=r+=n[i];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r=Zt(e,t,2,4);return function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)}(r,t),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(r,r.length-4,n.d()),r}const Kt=e=>{const t=Object.assign(Object.assign({},e),{v:"v1"});return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var o=e[r++];o<128||t?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((31&o)<<6|63&e[r++]):o<240?n+=String.fromCharCode((15&o)<<12|(63&e[r++])<<6|63&e[r++]):(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}return n}(Vt(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new dt(e.length+(e.length>>>1)),o=0,s=function(e){r[o++]=e},i=0;i<n;++i){if(o+5>r.length){var a=new dt(o+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?s(c):c<2048?(s(192|c>>>6),s(128|63&c)):c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),s(128|c>>>12&63),s(128|c>>>6&63),s(128|63&c)):(s(224|c>>>12),s(128|c>>>6&63),s(128|63&c))}return Rt(r,0,o)}(JSON.stringify(t))),!0)};var Yt,qt;(qt=Yt||(Yt={}))[qt.NotStarted=0]="NotStarted",qt[qt.Running=1]="Running",qt[qt.Stopped=2]="Stopped";var Pt="".concat("[Amplitude]"," Session Recorded"),zt="Session replay event batch rejected due to exceeded retry count",Qt="Failed to store session replay events in IndexedDB",Jt="".concat("AMP","_replay_unsent"),jt=function(){function e(){var e=this;this.name="@amplitude/plugin-session-replay-browser",this.type="enrichment",this.storageKey="",this.retryTimeout=1e3,this.events=[],this.currentSequenceId=0,this.scheduled=null,this.queue=[],this.stopRecordingEvents=null,this.maxPersistedEventsSize=19999800,this.interval=1e3,this.timeAtLastSend=null,this.shouldSplitEventsList=function(t){var n=new Blob([t]).size;return new Blob(e.events).size+n>=e.maxPersistedEventsSize||null!==e.timeAtLastSend&&Date.now()-e.timeAtLastSend>e.interval&&(e.interval=Math.min(1e4,e.interval+1e3),!0)}}return e.prototype.setup=function(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){return e.loggerProvider.log("Installing @amplitude/plugin-session-replay."),this.config=e,this.storageKey="".concat(Jt,"_").concat(this.config.apiKey.substring(0,10)),this.emptyStoreAndReset(),[2]}))}))},e.prototype.execute=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(r){return e.event_properties=n(n({},e.event_properties),((t={})[Pt]=!0,t)),"session_start"!==e.event_type||this.stopRecordingEvents?"session_end"===e.event_type&&(e.session_id&&this.sendEventsList({events:this.events,sequenceId:this.currentSequenceId,sessionId:e.session_id}),this.stopRecordingEvents&&this.stopRecordingEvents(),this.events=[],this.currentSequenceId=0):this.recordEvents(),[2,Promise.resolve(e)]}))}))},e.prototype.emptyStoreAndReset=function(){return r(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(o){switch(o.label){case 0:return[4,this.getAllSessionEventsFromStore()];case 1:if(e=o.sent()){for(t in e)(n=e[t]).events.length&&this.sendEventsList({events:n.events,sequenceId:n.sequenceId,sessionId:parseInt(t,10)});this.events=[],r=this.config.sessionId&&e[this.config.sessionId],this.currentSequenceId=r?r.sequenceId+1:0,this.storeEventsForSession([],this.currentSequenceId)}return this.recordEvents(),[2]}}))}))},e.prototype.recordEvents=function(){var e=this;this.stopRecordingEvents=at({emit:function(t){var n=JSON.stringify(t);if(1===e.events.length&&0===e.currentSequenceId)return e.sendEventsList({events:e.events.concat(n),sequenceId:e.currentSequenceId,sessionId:e.config.sessionId}),e.events=[],void e.currentSequenceId++;e.shouldSplitEventsList(n)&&(e.sendEventsList({events:e.events,sequenceId:e.currentSequenceId,sessionId:e.config.sessionId}),e.events=[],e.currentSequenceId++),e.events.push(n),e.storeEventsForSession(e.events,e.currentSequenceId)},packFn:Kt,maskAllInputs:!0})},e.prototype.sendEventsList=function(e){var t=e.events,n=e.sequenceId,r=e.sessionId;this.addToQueue({events:t,sequenceId:n,attempts:0,timeout:0,sessionId:r})},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.filter((function(t){return t.attempts<e.config.flushMaxRetries?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"".concat(zt,", batch sequence id, ").concat(t.sequenceId)}),!1)}));r.forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(0)}))},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var n,r,s,i,a;return o(this,(function(o){switch(o.label){case 0:n={api_key:this.config.apiKey,device_id:this.config.deviceId,session_id:e.sessionId,start_timestamp:e.sessionId,events_batch:{version:1,events:e.events,seq_number:e.sequenceId}},o.label=1;case 1:return o.trys.push([1,3,,4]),r={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(n),method:"POST"},[4,fetch("https://api-secure.amplitude.com/sessions/track",r)];case 2:if(null===(s=o.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred",removeEvents:!1}),[2];if(t)this.handleReponse(s.status,e);else{i="";try{i=JSON.stringify(s.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(s.status,": ").concat(i)})}return[3,4];case 3:return a=o.sent(),this.completeRequest({context:e,err:a,removeEvents:!1}),[3,4];case 4:return[2]}}))}))},e.prototype.handleReponse=function(e,n){if((new s).buildStatus(e)===t.Success)this.handleSuccessResponse(n);else this.handleOtherResponse(n)},e.prototype.handleSuccessResponse=function(e){this.completeRequest({context:e,success:"Session replay event batch tracked successfully"})},e.prototype.handleOtherResponse=function(e){this.addToQueue(n(n({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.getAllSessionEventsFromStore=function(){return r(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,l(this.storageKey)];case 1:return[2,t.sent()];case 2:return e=t.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(e)),[3,3];case 3:return[2,void 0]}}))}))},e.prototype.storeEventsForSession=function(e,t){return r(this,void 0,void 0,(function(){var r,s=this;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,d(this.storageKey,(function(r){var o;return n(n({},r),s.config.sessionId&&((o={})[s.config.sessionId]={events:e,sequenceId:t},o))}))];case 1:return o.sent(),[3,3];case 2:return r=o.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(r)),[3,3];case 3:return[2]}}))}))},e.prototype.removeSessionEventsStore=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,d(this.storageKey,(function(t){return void 0===t&&(t={}),delete t[e],t}))];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this.config.loggerProvider.error("".concat(Qt,": ").concat(t)),[3,3];case 3:return[2]}}))}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success,o=e.removeEvents;(void 0===o||o)&&t.sessionId&&this.removeSessionEventsStore(t.sessionId),n?this.config.loggerProvider.error(n):r&&(this.timeAtLastSend=Date.now(),this.config.loggerProvider.log(r))},e}(),Ht=function(){return new jt};e.plugin=Ht,e.sessionReplayPlugin=Ht,Object.defineProperty(e,"__esModule",{value:!0})}));
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/plugin-session-replay-browser",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "",
5
5
  "author": "Amplitude Inc",
6
6
  "homepage": "https://github.com/amplitude/Amplitude-TypeScript",
@@ -55,5 +55,5 @@
55
55
  "files": [
56
56
  "lib"
57
57
  ],
58
- "gitHead": "ee064fe94bd1f5c24f106c70b14cbfca2cda1364"
58
+ "gitHead": "392e3d9b080374d805e32d9e8a99f92175ea2218"
59
59
  }