@pendo/agent 2.331.0 → 2.332.1

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.
@@ -648,7 +648,27 @@ function getPendoConfigValue(key) {
648
648
  return config[key];
649
649
  }
650
650
 
651
- var setTimeout = safeBind(window.setTimeout, window);
651
+ // Resolve the global object without relying on a bare `window` identifier.
652
+ // `window` is only a bound global in a normal browser realm; when the agent is
653
+ // loaded via the npm `loadAsModule` path (or inside a Web Worker) the module is
654
+ // evaluated in a realm where `window` is undeclared, so referencing it bare
655
+ // throws a ReferenceError at module-load. `globalThis` resolves in every realm.
656
+ function getGlobalScope() {
657
+ if (typeof globalThis !== 'undefined') {
658
+ return globalThis;
659
+ }
660
+ if (typeof self !== 'undefined') {
661
+ return self;
662
+ }
663
+ if (typeof window !== 'undefined') {
664
+ return window;
665
+ }
666
+ return {};
667
+ }
668
+
669
+ var globalScope = getGlobalScope();
670
+
671
+ var setTimeout = safeBind(globalScope.setTimeout, globalScope);
652
672
 
653
673
  function safeBind(fn, scope) {
654
674
  if (typeof fn.bind === 'function') {
@@ -671,7 +691,7 @@ setTimeout = (function(global) {
671
691
  }
672
692
 
673
693
  return getZoneSafeMethod('setTimeout');
674
- })(window);
694
+ })(globalScope);
675
695
 
676
696
  var setTimeout$1 = setTimeout;
677
697
 
@@ -3569,7 +3589,7 @@ var ConfigReader = (function () {
3569
3589
  * @default false
3570
3590
  * @type {boolean}
3571
3591
  */
3572
- addOption('preventCodeInjection', [PENDO_CONFIG_SRC, SNIPPET_SRC, GLOBAL_SRC], false);
3592
+ addOption('preventCodeInjection', [PENDO_CONFIG_SRC, SNIPPET_SRC, GLOBAL_SRC], false, true);
3573
3593
  addOption('previewModeAssetPath');
3574
3594
  addOption('useAssetHostForDesigner', [SNIPPET_SRC, PENDO_CONFIG_SRC], false);
3575
3595
  addOption('storage.allowKeys', [SNIPPET_SRC], '*');
@@ -3733,7 +3753,6 @@ var ConfigReader = (function () {
3733
3753
  });
3734
3754
  return results;
3735
3755
  }
3736
- /* eslint-disable no-console */
3737
3756
  return {
3738
3757
  audit,
3739
3758
  get(optionName, defaultValue) {
@@ -3774,7 +3793,6 @@ var ConfigReader = (function () {
3774
3793
  console.groupEnd();
3775
3794
  }
3776
3795
  };
3777
- /* eslint-enable no-console */
3778
3796
  })();
3779
3797
 
3780
3798
  const EXTENSION_INSTALL_TYPE = 'extension';
@@ -4010,8 +4028,8 @@ let SERVER = '';
4010
4028
  let ASSET_HOST = '';
4011
4029
  let ASSET_PATH = '';
4012
4030
  let DESIGNER_SERVER = '';
4013
- let VERSION = '2.331.0_';
4014
- let PACKAGE_VERSION = '2.331.0';
4031
+ let VERSION = '2.332.1_';
4032
+ let PACKAGE_VERSION = '2.332.1';
4015
4033
  let LOADER = 'xhr';
4016
4034
  /* eslint-enable web-sdk-eslint-rules/no-gulp-env-references */
4017
4035
  /**
@@ -8962,7 +8980,6 @@ function dom(selection, context) {
8962
8980
  return selection;
8963
8981
  }
8964
8982
  if (!(self instanceof dom)) {
8965
- // eslint-disable-next-line new-cap
8966
8983
  return new dom(selection, context);
8967
8984
  }
8968
8985
  if (!selection) {
@@ -22432,7 +22449,7 @@ function OverPosition() {
22432
22449
  var badgeElem = this.element();
22433
22450
  var target = this.target();
22434
22451
  var elemPos = getOffsetPosition(target);
22435
- var badgeStyleString = 'position:absolute;top:' + elemPos.top + 'px;left:' + elemPos.left + 'px;';
22452
+ var badgeStyleString = 'position:' + (elemPos.fixed ? 'fixed' : 'absolute') + ';top:' + elemPos.top + 'px;left:' + elemPos.left + 'px;';
22436
22453
  badgeStyleString += 'height:' + elemPos.height + 'px;width:' + elemPos.width + 'px;';
22437
22454
  badgeStyleString += 'background-color:transparent;';
22438
22455
  setStyle(badgeElem, badgeStyleString);
@@ -28536,7 +28553,8 @@ const PluginAPI = {
28536
28553
  getAssetHost,
28537
28554
  getAssetUrl,
28538
28555
  getDataHost,
28539
- SERVER
28556
+ SERVER,
28557
+ DESIGNER_SERVER
28540
28558
  },
28541
28559
  NodeSerializer,
28542
28560
  q,
@@ -29174,7 +29192,7 @@ function initialize(options) {
29174
29192
  if (_.isString(options)) { // treat as URL
29175
29193
  return ajax.get(options)
29176
29194
  .then((response) => {
29177
- // eslint-disable-next-line no-global-assign, no-native-reassign
29195
+ // eslint-disable-next-line no-global-assign
29178
29196
  setPendoConfig(PendoConfig = response.data);
29179
29197
  return initialize();
29180
29198
  });
@@ -32565,10 +32583,25 @@ var GuideDisplay = (function () {
32565
32583
  // Ensure RC has completely rendered before replacing RC content
32566
32584
  return showLocal(resourceCenter.steps[0], reason);
32567
32585
  }
32586
+ function showWithDelay(step, reason, showFn) {
32587
+ const delay = step.getGuide().displayDelayMs;
32588
+ if (delay > 0 && (reason === 'auto' || reason === 'repeatGuide')) {
32589
+ step.lock();
32590
+ step._autoDisplayDelayTimer = setTimeout$1(function () {
32591
+ step._autoDisplayDelayTimer = null;
32592
+ step.unlock();
32593
+ showFn();
32594
+ }, delay);
32595
+ return step.isShown();
32596
+ }
32597
+ showFn();
32598
+ return step.isShown();
32599
+ }
32568
32600
  function showLocal(step, reason) {
32569
32601
  if (AsyncContent.hasContent(step) && ContentValidation.valid(step)) {
32570
- step._show(reason);
32571
- return step.isShown();
32602
+ return showWithDelay(step, reason, function () {
32603
+ step._show(reason);
32604
+ });
32572
32605
  }
32573
32606
  if (AsyncContent.hasContent(step) && ContentValidation.invalid(step)) {
32574
32607
  return false;
@@ -32592,8 +32625,9 @@ var GuideDisplay = (function () {
32592
32625
  return false;
32593
32626
  }
32594
32627
  step.unlock();
32595
- step._show(reason);
32596
- return step.isShown();
32628
+ return showWithDelay(step, reason, function () {
32629
+ step._show(reason);
32630
+ });
32597
32631
  });
32598
32632
  }
32599
32633
  function show(step, reason) {
@@ -32749,6 +32783,8 @@ function GuideStep(guide) {
32749
32783
  locked = true;
32750
32784
  };
32751
32785
  this.unlock = function () {
32786
+ clearTimeout(this._autoDisplayDelayTimer);
32787
+ this._autoDisplayDelayTimer = null;
32752
32788
  locked = false;
32753
32789
  };
32754
32790
  this.isTimedOut = function () {
@@ -34758,7 +34794,6 @@ var PreviewModule = (function () {
34758
34794
 
34759
34795
  const DebuggerModule = (() => {
34760
34796
  const state = {
34761
- isTop: undefined,
34762
34797
  isLeader: undefined,
34763
34798
  frameId: null,
34764
34799
  tabId: null,
@@ -34774,7 +34809,7 @@ const DebuggerModule = (() => {
34774
34809
  };
34775
34810
  const SYNC_TYPES = {
34776
34811
  TOP_DOWN: 'top-down',
34777
- BOTTOM_UP: 'bottom-up' // changes in a child frame update values in the frames map
34812
+ BOTTOM_UP: 'bottom-up' // changes in another frame update values in the leader's frames map
34778
34813
  };
34779
34814
  const frameSyncFields = {
34780
34815
  debuggingEnabled: { type: SYNC_TYPES.TOP_DOWN, defaultValue: false },
@@ -34788,10 +34823,8 @@ const DebuggerModule = (() => {
34788
34823
  context.commit('setFrameId', EventTracer.getFrameId());
34789
34824
  context.commit('setTabId', EventTracer.getTabId());
34790
34825
  context.commit('setInstallType', getInstallType());
34791
- const isTop = isLeader() && window.top === window; // only a leader frame that is a top window can launch debugger
34792
- context.commit('setIsTop', isTop);
34793
- context.commit('isLeader', isLeader());
34794
- if (isTop) {
34826
+ context.commit('setIsLeader', isLeader());
34827
+ if (isLeader()) {
34795
34828
  const debugging = getDebuggingStorage();
34796
34829
  context.commit('debuggingEnabled', debugging.enabled === true);
34797
34830
  if (debugging.enableEventLogging) {
@@ -34806,6 +34839,32 @@ const DebuggerModule = (() => {
34806
34839
  }
34807
34840
  _.each(buffer.events, (event) => store.dispatch('debugger/eventCaptured', event));
34808
34841
  },
34842
+ updateLeader: (context) => {
34843
+ const wasLeader = context.state.isLeader;
34844
+ const nowLeader = isLeader();
34845
+ context.commit('setIsLeader', nowLeader);
34846
+ if (nowLeader && getDebuggingStorage().enabled) {
34847
+ // A frame that just became the leader has no history of the other frames' synced
34848
+ // state, so ask them to resend it. Gate on the persisted debug-enabled storage
34849
+ // rather than context.state.debuggingEnabled: updateLeader runs before mount
34850
+ // sets that flag on a newly promoted leader, so it would still be false here.
34851
+ crossFrameChannel.postMessage({
34852
+ action: 'debugger/requestSync',
34853
+ frameId: context.state.frameId
34854
+ });
34855
+ }
34856
+ else if (wasLeader && !nowLeader) {
34857
+ // Was the leader, now a follower: bottom-up fields collected while we were the
34858
+ // leader (e.g. a top frame that briefly led before forcedLeader promoted a child)
34859
+ // were never synced out, so push them to the new leader now.
34860
+ resendBottomUpFields(context.state);
34861
+ }
34862
+ },
34863
+ requestSync: (context, data) => {
34864
+ if (context.state.frameId === data.frameId)
34865
+ return;
34866
+ resendBottomUpFields(context.state);
34867
+ },
34809
34868
  join: (context, data) => {
34810
34869
  if (context.state.frameId === data.frameId)
34811
34870
  return;
@@ -34828,9 +34887,9 @@ const DebuggerModule = (() => {
34828
34887
  if (!frameSyncFields[fieldName])
34829
34888
  return;
34830
34889
  const { type } = frameSyncFields[fieldName];
34831
- if (type === SYNC_TYPES.TOP_DOWN && context.state.isTop)
34890
+ if (type === SYNC_TYPES.TOP_DOWN && context.state.isLeader)
34832
34891
  return;
34833
- if (type === SYNC_TYPES.BOTTOM_UP && !context.state.isTop)
34892
+ if (type === SYNC_TYPES.BOTTOM_UP && !context.state.isLeader)
34834
34893
  return;
34835
34894
  // To handle capturing the state change and recording it
34836
34895
  context.commit(`_sync_${fieldName}`, { value, frameId });
@@ -34842,7 +34901,7 @@ const DebuggerModule = (() => {
34842
34901
  eventCaptured: (context, data) => {
34843
34902
  if (pendo$1.designerEnabled || isInPreviewMode() || isInDesignerPreviewMode())
34844
34903
  return;
34845
- if (!context.state.isTop) {
34904
+ if (!context.state.isLeader) {
34846
34905
  crossFrameChannel.postMessage({
34847
34906
  action: 'debugger/receiveEventCaptured',
34848
34907
  frameId: context.state.frameId,
@@ -34854,7 +34913,7 @@ const DebuggerModule = (() => {
34854
34913
  }
34855
34914
  },
34856
34915
  receiveEventCaptured: (context, data) => {
34857
- if (!context.state.isTop)
34916
+ if (!context.state.isLeader)
34858
34917
  return;
34859
34918
  context.commit('eventsCaptured', data.event);
34860
34919
  },
@@ -34862,7 +34921,7 @@ const DebuggerModule = (() => {
34862
34921
  context.commit('eventsCaptured', []);
34863
34922
  },
34864
34923
  onCspError: (context, data) => {
34865
- if (!context.state.isTop) {
34924
+ if (!context.state.isLeader) {
34866
34925
  crossFrameChannel.postMessage({
34867
34926
  action: 'debugger/recieveCspError',
34868
34927
  frameId: context.state.frameId,
@@ -34874,7 +34933,7 @@ const DebuggerModule = (() => {
34874
34933
  }
34875
34934
  },
34876
34935
  recieveCspError: (context, message) => {
34877
- if (!context.state.isTop)
34936
+ if (!context.state.isLeader)
34878
34937
  return;
34879
34938
  context.commit('cspError', message.data);
34880
34939
  },
@@ -34924,10 +34983,7 @@ const DebuggerModule = (() => {
34924
34983
  setTabId(state, tabId) {
34925
34984
  state.tabId = tabId;
34926
34985
  },
34927
- setIsTop(state, isTop) {
34928
- state.isTop = isTop;
34929
- },
34930
- isLeader(state, isLeader) {
34986
+ setIsLeader(state, isLeader) {
34931
34987
  state.isLeader = isLeader;
34932
34988
  },
34933
34989
  setInstallType(state, installType) {
@@ -34950,7 +35006,7 @@ const DebuggerModule = (() => {
34950
35006
  },
34951
35007
  debuggingEnabled(state, enabled) {
34952
35008
  state.debuggingEnabled = enabled;
34953
- onDebuggingEnabledChange(enabled, state.isTop);
35009
+ onDebuggingEnabledChange(enabled, state.isLeader);
34954
35010
  },
34955
35011
  excludedGuides(state, excludedGuides) {
34956
35012
  state.excludedGuides = excludedGuides;
@@ -35001,6 +35057,17 @@ const DebuggerModule = (() => {
35001
35057
  function eventCapturedFn(evt) {
35002
35058
  store.dispatch('debugger/eventCaptured', evt.data[0]);
35003
35059
  }
35060
+ function resendBottomUpFields(state) {
35061
+ _.each(frameSyncFields, ({ type }, fieldName) => {
35062
+ if (type !== SYNC_TYPES.BOTTOM_UP)
35063
+ return;
35064
+ crossFrameChannel.postMessage({
35065
+ action: 'debugger/sync',
35066
+ frameId: state.frameId,
35067
+ fields: { [fieldName]: state[fieldName] }
35068
+ });
35069
+ });
35070
+ }
35004
35071
  function identityFn(event) {
35005
35072
  store.commit('debugger/identity', {
35006
35073
  visitorId: _.get(event, 'data.0.visitor_id') || pendo$1.get_visitor_id(),
@@ -35019,7 +35086,7 @@ const DebuggerModule = (() => {
35019
35086
  }
35020
35087
  const guideLoopRunning = _.partial(toggleGuideLoopRunning, true);
35021
35088
  const guideLoopStopped = _.partial(toggleGuideLoopRunning, false);
35022
- function onDebuggingEnabledChange(enabled, isTop) {
35089
+ function onDebuggingEnabledChange(enabled, isLeader) {
35023
35090
  if (state.debuggingEnabled === enabled)
35024
35091
  return;
35025
35092
  if (enabled) {
@@ -35031,7 +35098,7 @@ const DebuggerModule = (() => {
35031
35098
  Events.on('eventCaptured', eventCapturedFn);
35032
35099
  Events.on('identify', identityFn);
35033
35100
  Events.on('urlChanged', locationFn);
35034
- if (isTop) {
35101
+ if (isLeader) {
35035
35102
  guidesLoadedFn();
35036
35103
  Events.on('guidesLoaded', guidesLoadedFn);
35037
35104
  }
@@ -35043,7 +35110,7 @@ const DebuggerModule = (() => {
35043
35110
  Events.off('eventCaptured', eventCapturedFn);
35044
35111
  Events.off('identify', identityFn);
35045
35112
  Events.off('urlChanged', locationFn);
35046
- if (isTop) {
35113
+ if (isLeader) {
35047
35114
  Events.off('guidesLoaded', guidesLoadedFn);
35048
35115
  }
35049
35116
  }
@@ -35056,12 +35123,12 @@ const DebuggerModule = (() => {
35056
35123
  // and wrapping it to provide standard logic around edge cases.
35057
35124
  let setter = mutations[fieldName] || ((state, value) => { state[fieldName] = value; });
35058
35125
  mutations[fieldName] = _.wrap(setter, (mutFn, state, value) => {
35059
- // don't save fields to children that are meant to be set via top down
35060
- if (!state.isTop && type === SYNC_TYPES.TOP_DOWN)
35126
+ // don't save top-down fields locally unless we're the leader (source of them)
35127
+ if (!state.isLeader && type === SYNC_TYPES.TOP_DOWN)
35061
35128
  return;
35062
35129
  mutFn(state, value);
35063
- // don't bother syncing fields from TOP if they are bottom up
35064
- if (state.isTop && type === SYNC_TYPES.BOTTOM_UP)
35130
+ // the leader doesn't sync bottom-up fields outward (it's the collector)
35131
+ if (state.isLeader && type === SYNC_TYPES.BOTTOM_UP)
35065
35132
  return;
35066
35133
  crossFrameChannel.postMessage({
35067
35134
  action: 'debugger/sync',
@@ -35078,9 +35145,9 @@ const DebuggerModule = (() => {
35078
35145
  state.frames[frameId][fieldName] = frameSyncFields[fieldName].defaultValue;
35079
35146
  }
35080
35147
  setter(state.frames[frameId], value);
35081
- // Also set as current value if this is a top down sync and this is NOT top
35148
+ // Also set as our own value for a top-down field when we're not the leader
35082
35149
  // conversely, we could make the getter read from the frame object *shrug*
35083
- if (!state.isTop && type === SYNC_TYPES.TOP_DOWN) {
35150
+ if (!state.isLeader && type === SYNC_TYPES.TOP_DOWN) {
35084
35151
  setter(state, value);
35085
35152
  }
35086
35153
  };
@@ -35513,7 +35580,7 @@ function debuggerExports() {
35513
35580
  }
35514
35581
  function startDebuggingModuleIfEnabled() {
35515
35582
  const debugging = getDebuggingStorage();
35516
- if (!debugging.enabled)
35583
+ if (!debugging.enabled || !isLeader())
35517
35584
  return;
35518
35585
  store.commit('debugger/debuggingEnabled', true);
35519
35586
  addDebuggingFunctions();
@@ -35527,7 +35594,7 @@ function startDebuggingModuleIfEnabled() {
35527
35594
  else if (typeof agentDebuggerPluginLoader === 'function') {
35528
35595
  agentDebuggerPluginLoader();
35529
35596
  }
35530
- else {
35597
+ else if (!dom('#pendo-debugger-plugin').length) {
35531
35598
  const script = document.createElement('script');
35532
35599
  script.src = getPolicy(pendo$1).createScriptURL(getAssetUrl('debugger-plugin.min.js'));
35533
35600
  script.setAttribute('id', 'pendo-debugger-plugin');
@@ -35641,6 +35708,12 @@ const DebuggerLauncher = (function () {
35641
35708
  }
35642
35709
  buffer.clear();
35643
35710
  });
35711
+ Events.on('leaderChanged', () => {
35712
+ store.dispatch('debugger/updateLeader');
35713
+ if (store.getters['frames/isLeader']()) {
35714
+ startDebuggingModuleIfEnabled();
35715
+ }
35716
+ });
35644
35717
  registerMessageHandler('pendo-debugger::launch', (data, msg) => {
35645
35718
  if (data.config.apiKey !== pendo.apiKey)
35646
35719
  return;
@@ -36762,7 +36835,7 @@ var validators = {
36762
36835
  if (hasMax && num > max)
36763
36836
  return false;
36764
36837
  if (!allowDecimal && num % 1 !== 0)
36765
- return false; // eslint-disable-line
36838
+ return false;
36766
36839
  return true;
36767
36840
  },
36768
36841
  characterLength(value, options = {}) {
@@ -36776,7 +36849,7 @@ var validators = {
36776
36849
  if (hasMin && value.length < min)
36777
36850
  return false;
36778
36851
  if (hasMax && value.length > max)
36779
- return false; // eslint-disable-line
36852
+ return false;
36780
36853
  return true;
36781
36854
  }
36782
36855
  };
@@ -40248,7 +40321,7 @@ class PromptPlugin {
40248
40321
  this.prompts = [];
40249
40322
  }
40250
40323
  initialize(pendo, PluginAPI) {
40251
- var _a;
40324
+ var _a, _b;
40252
40325
  this.pendo = pendo;
40253
40326
  this.api = PluginAPI;
40254
40327
  this._ = this.pendo._;
@@ -40258,10 +40331,14 @@ class PromptPlugin {
40258
40331
  this.loadConfig(this.configName)
40259
40332
  .then(config => this.onConfigLoaded(config)).catch(() => { });
40260
40333
  // Listen for URL changes to re-evaluate page rules
40261
- // Listening on guidesLoaded since normalizedUrl comes back from the guides playload
40334
+ // guidesLoaded: normalizedUrl comes back from the guides payload
40335
+ // urlChanged: handles SPA navigation where guides may already be cached and guidesLoaded won't re-fire
40262
40336
  (_a = this.api.Events.guidesLoaded) === null || _a === void 0 ? void 0 : _a.on(() => {
40263
40337
  this.reEvaluatePageRules();
40264
40338
  });
40339
+ (_b = this.api.Events.urlChanged) === null || _b === void 0 ? void 0 : _b.on(() => {
40340
+ this.reEvaluatePageRules();
40341
+ });
40265
40342
  }
40266
40343
  // a-fake-sync method - puts the api expectation of a promise in place now
40267
40344
  // making it easier in the future if the config looking becomes a network call
@@ -42105,7 +42182,27 @@ function GuideMarkdown() {
42105
42182
  }
42106
42183
  }
42107
42184
 
42108
- var setTimeout = safeBind(window.setTimeout, window);
42185
+ // Resolve the global object without relying on a bare `window` identifier.
42186
+ // `window` is only a bound global in a normal browser realm; when the agent is
42187
+ // loaded via the npm `loadAsModule` path (or inside a Web Worker) the module is
42188
+ // evaluated in a realm where `window` is undeclared, so referencing it bare
42189
+ // throws a ReferenceError at module-load. `globalThis` resolves in every realm.
42190
+ function getGlobalScope() {
42191
+ if (typeof globalThis !== 'undefined') {
42192
+ return globalThis;
42193
+ }
42194
+ if (typeof self !== 'undefined') {
42195
+ return self;
42196
+ }
42197
+ if (typeof window !== 'undefined') {
42198
+ return window;
42199
+ }
42200
+ return {};
42201
+ }
42202
+
42203
+ var globalScope = getGlobalScope();
42204
+
42205
+ var setTimeout = safeBind(globalScope.setTimeout, globalScope);
42109
42206
 
42110
42207
  function safeBind(fn, scope) {
42111
42208
  if (typeof fn.bind === 'function') {
@@ -42128,7 +42225,7 @@ setTimeout = (function(global) {
42128
42225
  }
42129
42226
 
42130
42227
  return getZoneSafeMethod('setTimeout');
42131
- })(window);
42228
+ })(globalScope);
42132
42229
 
42133
42230
  var setTimeout$1 = setTimeout;
42134
42231
 
@@ -49341,31 +49438,32 @@ var n;
49341
49438
  }(n || (n = {}));
49342
49439
  return record; }
49343
49440
 
49344
- class SessionRecorderBuffer {
49345
- constructor(interval, maxCount = Infinity) {
49441
+ var SessionRecorderBuffer = /** @class */ (function () {
49442
+ function SessionRecorderBuffer(interval, maxCount) {
49443
+ if (maxCount === void 0) { maxCount = Infinity; }
49346
49444
  this.data = [];
49347
49445
  this.sequenceNumber = 0;
49348
49446
  this.interval = interval;
49349
49447
  this.maxCount = maxCount;
49350
49448
  this.doubledMaxCount = maxCount * 2;
49351
49449
  }
49352
- isEmpty() {
49450
+ SessionRecorderBuffer.prototype.isEmpty = function () {
49353
49451
  return this.data.length === 0;
49354
- }
49355
- count() {
49452
+ };
49453
+ SessionRecorderBuffer.prototype.count = function () {
49356
49454
  return this.data.length;
49357
- }
49358
- clear() {
49455
+ };
49456
+ SessionRecorderBuffer.prototype.clear = function () {
49359
49457
  this.data.length = 0;
49360
- }
49361
- clearSequence() {
49458
+ };
49459
+ SessionRecorderBuffer.prototype.clearSequence = function () {
49362
49460
  this.sequenceNumber = 0;
49363
- }
49364
- push(event) {
49461
+ };
49462
+ SessionRecorderBuffer.prototype.push = function (event) {
49365
49463
  this.data.push(event);
49366
49464
  this.checkRateLimit();
49367
- }
49368
- pack(envelope, _) {
49465
+ };
49466
+ SessionRecorderBuffer.prototype.pack = function (envelope, _) {
49369
49467
  var eventsToSend = this.data.splice(0, this.maxCount);
49370
49468
  envelope.recordingPayload = eventsToSend;
49371
49469
  envelope.sequence = this.sequenceNumber;
@@ -49373,8 +49471,8 @@ class SessionRecorderBuffer {
49373
49471
  if (eventsToSend.length) {
49374
49472
  envelope.browserTime = eventsToSend[0].timestamp;
49375
49473
  }
49376
- envelope.recordingPayloadMetadata = _.map(eventsToSend, event => {
49377
- const metadata = _.pick(event, 'type', 'timestamp');
49474
+ envelope.recordingPayloadMetadata = _.map(eventsToSend, function (event) {
49475
+ var metadata = _.pick(event, 'type', 'timestamp');
49378
49476
  if (event.data) {
49379
49477
  metadata.data = _.pick(event.data, 'source', 'type', 'x', 'y', 'id', 'height', 'width', 'href');
49380
49478
  }
@@ -49382,17 +49480,18 @@ class SessionRecorderBuffer {
49382
49480
  });
49383
49481
  this.sequenceNumber += eventsToSend.length;
49384
49482
  return envelope;
49385
- }
49386
- checkRateLimit() {
49387
- const length = this.data.length;
49483
+ };
49484
+ SessionRecorderBuffer.prototype.checkRateLimit = function () {
49485
+ var length = this.data.length;
49388
49486
  if (length >= this.doubledMaxCount && length % this.maxCount === 0) {
49389
- const elapsed = this.data[length - 1].timestamp - this.data[length - this.doubledMaxCount].timestamp;
49487
+ var elapsed = this.data[length - 1].timestamp - this.data[length - this.doubledMaxCount].timestamp;
49390
49488
  if (elapsed <= this.interval && this.onRateLimit) {
49391
49489
  this.onRateLimit();
49392
49490
  }
49393
49491
  }
49394
- }
49395
- }
49492
+ };
49493
+ return SessionRecorderBuffer;
49494
+ }());
49396
49495
 
49397
49496
  function __rest(s, e) {
49398
49497
  var t = {};
@@ -49416,24 +49515,52 @@ function __awaiter(thisArg, _arguments, P, generator) {
49416
49515
  });
49417
49516
  }
49418
49517
 
49518
+ function __generator(thisArg, body) {
49519
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
49520
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
49521
+ function verb(n) { return function (v) { return step([n, v]); }; }
49522
+ function step(op) {
49523
+ if (f) throw new TypeError("Generator is already executing.");
49524
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
49525
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
49526
+ if (y = 0, t) op = [op[0] & 2, t.value];
49527
+ switch (op[0]) {
49528
+ case 0: case 1: t = op; break;
49529
+ case 4: _.label++; return { value: op[1], done: false };
49530
+ case 5: _.label++; y = op[1]; op = [0]; continue;
49531
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
49532
+ default:
49533
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
49534
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
49535
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
49536
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
49537
+ if (t[2]) _.ops.pop();
49538
+ _.trys.pop(); continue;
49539
+ }
49540
+ op = body.call(thisArg, _);
49541
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49542
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49543
+ }
49544
+ }
49545
+
49419
49546
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
49420
49547
  var e = new Error(message);
49421
49548
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
49422
49549
  };
49423
49550
 
49424
- const RECORDING_CONFIG_WORKERURL$1 = 'recording.workerUrl';
49425
- const MAX_SIZE = 2000000;
49426
- const RESOURCE_CACHING$1 = 'resourceCaching';
49427
- class Transport {
49428
- constructor(WorkerClass, pendo, api) {
49551
+ var RECORDING_CONFIG_WORKERURL$1 = 'recording.workerUrl';
49552
+ var MAX_SIZE = 2000000;
49553
+ var RESOURCE_CACHING$1 = 'resourceCaching';
49554
+ var Transport = /** @class */ (function () {
49555
+ function Transport(WorkerClass, pendo, api) {
49429
49556
  this.WorkerClass = WorkerClass;
49430
49557
  this.pendo = pendo;
49431
49558
  this.api = api;
49432
49559
  this.maxSize = MAX_SIZE;
49433
- this.lockID = `worker-lock-${this.pendo.randomString(16)}`;
49560
+ this.lockID = "worker-lock-".concat(this.pendo.randomString(16));
49434
49561
  this.isResourceCachingEnabled = this.api.ConfigReader.get(RESOURCE_CACHING$1);
49435
49562
  }
49436
- start(config) {
49563
+ Transport.prototype.start = function (config) {
49437
49564
  if (config.disableWorker)
49438
49565
  return;
49439
49566
  if (!this.worker) {
@@ -49443,7 +49570,7 @@ class Transport {
49443
49570
  this.worker = config.workerOverride;
49444
49571
  }
49445
49572
  else {
49446
- const workerUrl = this.api.ConfigReader.get(RECORDING_CONFIG_WORKERURL$1);
49573
+ var workerUrl = this.api.ConfigReader.get(RECORDING_CONFIG_WORKERURL$1);
49447
49574
  this.usesSelfHostedWorker = workerUrl != null;
49448
49575
  this.worker = workerUrl ? new Worker(workerUrl) : new this.WorkerClass();
49449
49576
  }
@@ -49457,34 +49584,35 @@ class Transport {
49457
49584
  this.worker = null;
49458
49585
  }
49459
49586
  }
49460
- }
49461
- stop() {
49587
+ };
49588
+ Transport.prototype.stop = function () {
49462
49589
  if (this.worker) {
49463
49590
  this.worker.terminate();
49464
49591
  delete this.worker;
49465
49592
  }
49466
- }
49467
- send(envelope, isUnload, failureCount = 0) {
49468
- let { url } = envelope;
49469
- const { payload } = envelope;
49593
+ };
49594
+ Transport.prototype.send = function (envelope, isUnload, failureCount) {
49595
+ if (failureCount === void 0) { failureCount = 0; }
49596
+ var url = envelope.url;
49597
+ var payload = envelope.payload;
49470
49598
  if (failureCount > 0) {
49471
- url = `${url}&rt=${failureCount}`;
49599
+ url = "".concat(url, "&rt=").concat(failureCount);
49472
49600
  }
49473
49601
  if (this.worker && !isUnload && payload) {
49474
- const deferred = {};
49475
- deferred.promise = new Promise$2((resolve, reject) => {
49476
- deferred.resolve = resolve;
49477
- deferred.reject = reject;
49602
+ var deferred_1 = {};
49603
+ deferred_1.promise = new Promise$2(function (resolve, reject) {
49604
+ deferred_1.resolve = resolve;
49605
+ deferred_1.reject = reject;
49478
49606
  });
49479
- this.workerResponse = deferred;
49480
- this.worker.postMessage({ url, payload, shouldCacheResources: this.isResourceCachingEnabled });
49481
- return deferred.promise;
49607
+ this.workerResponse = deferred_1;
49608
+ this.worker.postMessage({ url: url, payload: payload, shouldCacheResources: this.isResourceCachingEnabled });
49609
+ return deferred_1.promise;
49482
49610
  }
49483
49611
  else {
49484
49612
  if (!envelope.body) {
49485
- const strPayload = JSON.stringify(payload);
49613
+ var strPayload = JSON.stringify(payload);
49486
49614
  if (strPayload.length > this.maxSize) {
49487
- const error = new Error('maximum recording payload size exceeded');
49615
+ var error = new Error('maximum recording payload size exceeded');
49488
49616
  error.reason = 'HEAVY_EVENT';
49489
49617
  error.context = {
49490
49618
  size: strPayload.length,
@@ -49495,14 +49623,14 @@ class Transport {
49495
49623
  envelope.body = this.pendo.compress(strPayload, 'binary');
49496
49624
  delete envelope.payload;
49497
49625
  }
49498
- url = `${url}&ct=${new Date().getTime()}`;
49626
+ url = "".concat(url, "&ct=").concat(new Date().getTime());
49499
49627
  return this.post(url, {
49500
49628
  keepalive: isUnload,
49501
49629
  body: envelope.body
49502
49630
  });
49503
49631
  }
49504
- }
49505
- post(url, options) {
49632
+ };
49633
+ Transport.prototype.post = function (url, options) {
49506
49634
  options.method = 'POST';
49507
49635
  if (options.keepalive && this.api.transmit.fetchKeepalive.supported()) {
49508
49636
  return this.api.transmit.fetchKeepalive(url, options);
@@ -49514,46 +49642,57 @@ class Transport {
49514
49642
  else {
49515
49643
  return this.pendo.ajax.post(url, options.body);
49516
49644
  }
49517
- }
49518
- _onMessage(messageEvent) {
49519
- return __awaiter(this, void 0, void 0, function* () {
49520
- if (messageEvent.data && messageEvent.data.ready && navigator.locks) {
49521
- // When the lock is released, we can assume the worker was terminated or closed
49522
- yield navigator.locks.request(this.lockID, () => { });
49523
- this.onWorkerMessage({ type: 'workerDied' });
49524
- }
49525
- // handle non-POST request responses from worker
49526
- if (messageEvent.data && messageEvent.data.type) {
49527
- this.onWorkerMessage(messageEvent.data);
49528
- return;
49529
- }
49530
- // handle POST request response from worker
49531
- if (messageEvent.data && messageEvent.data.error) {
49532
- if ((messageEvent.data.status && messageEvent.data.status < 500) ||
49533
- messageEvent.data.sequence == null) {
49534
- this.api.log.critical('Failed to send recording data from web worker', { error: messageEvent.data.error });
49535
- }
49536
- if (this.workerResponse) {
49537
- this.workerResponse.reject();
49538
- this.workerResponse = null;
49645
+ };
49646
+ Transport.prototype._onMessage = function (messageEvent) {
49647
+ return __awaiter(this, void 0, void 0, function () {
49648
+ return __generator(this, function (_a) {
49649
+ switch (_a.label) {
49650
+ case 0:
49651
+ if (!(messageEvent.data && messageEvent.data.ready && navigator.locks)) return [3 /*break*/, 2];
49652
+ // When the lock is released, we can assume the worker was terminated or closed
49653
+ return [4 /*yield*/, navigator.locks.request(this.lockID, function () { })];
49654
+ case 1:
49655
+ // When the lock is released, we can assume the worker was terminated or closed
49656
+ _a.sent();
49657
+ this.onWorkerMessage({ type: 'workerDied' });
49658
+ _a.label = 2;
49659
+ case 2:
49660
+ // handle non-POST request responses from worker
49661
+ if (messageEvent.data && messageEvent.data.type) {
49662
+ this.onWorkerMessage(messageEvent.data);
49663
+ return [2 /*return*/];
49664
+ }
49665
+ // handle POST request response from worker
49666
+ if (messageEvent.data && messageEvent.data.error) {
49667
+ if ((messageEvent.data.status && messageEvent.data.status < 500) ||
49668
+ messageEvent.data.sequence == null) {
49669
+ this.api.log.critical('Failed to send recording data from web worker', { error: messageEvent.data.error });
49670
+ }
49671
+ if (this.workerResponse) {
49672
+ this.workerResponse.reject();
49673
+ this.workerResponse = null;
49674
+ }
49675
+ }
49676
+ if (this.workerResponse) {
49677
+ this.workerResponse.resolve();
49678
+ this.workerResponse = null;
49679
+ }
49680
+ return [2 /*return*/];
49539
49681
  }
49540
- }
49541
- if (this.workerResponse) {
49542
- this.workerResponse.resolve();
49543
- this.workerResponse = null;
49544
- }
49682
+ });
49545
49683
  });
49546
- }
49547
- _onError() {
49684
+ };
49685
+ Transport.prototype._onError = function () {
49548
49686
  if (this.onError) {
49549
49687
  this.onError();
49550
49688
  }
49551
- }
49552
- }
49689
+ };
49690
+ return Transport;
49691
+ }());
49553
49692
 
49554
- const ELEMENT_NODE = 1;
49555
- const INPUT_MASK = '*'.repeat(10);
49556
- const NUMBER_INPUT_MASK = '0'.repeat(10);
49693
+ var ELEMENT_NODE = 1;
49694
+ var INPUT_MASK = '*'.repeat(10);
49695
+ var NUMBER_INPUT_MASK = '0'.repeat(10);
49557
49696
  function isElementNode(node) {
49558
49697
  if (!node)
49559
49698
  return false;
@@ -49562,10 +49701,12 @@ function isElementNode(node) {
49562
49701
  return true;
49563
49702
  }
49564
49703
  function getParent(elem) {
49565
- const isElementShadowRoot = typeof window.ShadowRoot !== 'undefined' && elem instanceof window.ShadowRoot && elem.host;
49704
+ var isElementShadowRoot = typeof window.ShadowRoot !== 'undefined' && elem instanceof window.ShadowRoot && elem.host;
49566
49705
  return isElementShadowRoot ? elem.host : elem.parentNode;
49567
49706
  }
49568
- function distanceToMatch(node, selector, limit = Infinity, distance = 0) {
49707
+ function distanceToMatch(node, selector, limit, distance) {
49708
+ if (limit === void 0) { limit = Infinity; }
49709
+ if (distance === void 0) { distance = 0; }
49569
49710
  if (distance > limit)
49570
49711
  return -1;
49571
49712
  if (!node)
@@ -49579,15 +49720,15 @@ function distanceToMatch(node, selector, limit = Infinity, distance = 0) {
49579
49720
  return distanceToMatch(getParent(node), selector, limit, distance + 1);
49580
49721
  }
49581
49722
  function shouldMask(node, options) {
49582
- const { maskAllText, maskTextSelector, unmaskTextSelector } = options;
49723
+ var maskAllText = options.maskAllText, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector;
49583
49724
  try {
49584
- const el = isElementNode(node) ? node : node.parentElement;
49725
+ var el = isElementNode(node) ? node : node.parentElement;
49585
49726
  if (el === null)
49586
49727
  return false;
49587
49728
  if ((el.tagName || '').toUpperCase() === 'STYLE')
49588
49729
  return false;
49589
- let maskDistance = -1;
49590
- let unmaskDistance = -1;
49730
+ var maskDistance = -1;
49731
+ var unmaskDistance = -1;
49591
49732
  if (maskAllText) {
49592
49733
  unmaskDistance = distanceToMatch(el, unmaskTextSelector);
49593
49734
  if (unmaskDistance < 0) {
@@ -49620,8 +49761,8 @@ function isNumberInput(element) {
49620
49761
  }
49621
49762
  function shouldMaskInput(element, maskInputOptions) {
49622
49763
  if (maskInputOptions && isElementNode(element)) {
49623
- const tagName = (element.tagName || '').toLowerCase();
49624
- const type = (element.type || '').toLowerCase();
49764
+ var tagName = (element.tagName || '').toLowerCase();
49765
+ var type = (element.type || '').toLowerCase();
49625
49766
  if (maskInputOptions[tagName] || maskInputOptions[type]) {
49626
49767
  return true;
49627
49768
  }
@@ -50613,7 +50754,27 @@ var WorkerFactory = /*#__PURE__*/createInlineWorkerFactory(/* rollup-plugin-web-
50613
50754
  ((function (exports) {
50614
50755
  '__worker_loader_strict__';
50615
50756
 
50616
- var setTimeout = safeBind(window.setTimeout, window);
50757
+ // Resolve the global object without relying on a bare `window` identifier.
50758
+ // `window` is only a bound global in a normal browser realm; when the agent is
50759
+ // loaded via the npm `loadAsModule` path (or inside a Web Worker) the module is
50760
+ // evaluated in a realm where `window` is undeclared, so referencing it bare
50761
+ // throws a ReferenceError at module-load. `globalThis` resolves in every realm.
50762
+ function getGlobalScope() {
50763
+ if (typeof globalThis !== 'undefined') {
50764
+ return globalThis;
50765
+ }
50766
+ if (typeof self !== 'undefined') {
50767
+ return self;
50768
+ }
50769
+ if (typeof window !== 'undefined') {
50770
+ return window;
50771
+ }
50772
+ return {};
50773
+ }
50774
+
50775
+ var globalScope = getGlobalScope();
50776
+
50777
+ var setTimeout = safeBind(globalScope.setTimeout, globalScope);
50617
50778
 
50618
50779
  function safeBind(fn, scope) {
50619
50780
  if (typeof fn.bind === 'function') {
@@ -50636,7 +50797,7 @@ var WorkerFactory = /*#__PURE__*/createInlineWorkerFactory(/* rollup-plugin-web-
50636
50797
  }
50637
50798
 
50638
50799
  return getZoneSafeMethod('setTimeout');
50639
- })(window);
50800
+ })(globalScope);
50640
50801
 
50641
50802
  var setTimeout$1 = setTimeout;
50642
50803
 
@@ -51115,12 +51276,12 @@ var WorkerFactory = /*#__PURE__*/createInlineWorkerFactory(/* rollup-plugin-web-
51115
51276
  }
51116
51277
  }
51117
51278
 
51118
- const ONE_HUNDRED_MB_IN_BYTES = 100 * 1024 * 1024;
51279
+ var ONE_HUNDRED_MB_IN_BYTES = 100 * 1024 * 1024;
51119
51280
  function matchHostedResources(recordingEvent, stringifiedRecordingPayload) {
51120
- const fontURLRegex = /https:\/\/[^"\\\s]+?\.(woff2?|ttf|otf|eot)(\?[^"\\\s]*)?\b/g;
51121
- const matches = stringifiedRecordingPayload.match(fontURLRegex);
51281
+ var fontURLRegex = /https:\/\/[^"\\\s]+?\.(woff2?|ttf|otf|eot)(\?[^"\\\s]*)?\b/g;
51282
+ var matches = stringifiedRecordingPayload.match(fontURLRegex);
51122
51283
  // de-duplicate matches
51123
- const hostedResources = matches ? Array.from(new Set(matches)) : [];
51284
+ var hostedResources = matches ? Array.from(new Set(matches)) : [];
51124
51285
  return {
51125
51286
  type: 'recording',
51126
51287
  visitorId: recordingEvent.visitorId,
@@ -51135,7 +51296,7 @@ var WorkerFactory = /*#__PURE__*/createInlineWorkerFactory(/* rollup-plugin-web-
51135
51296
  recordingPayloadMetadata: [],
51136
51297
  sequence: 0,
51137
51298
  recordingPayloadCount: 0,
51138
- hostedResources
51299
+ hostedResources: hostedResources
51139
51300
  };
51140
51301
  }
51141
51302
  // keep in mind changes here may need addressing in the extension worker proxy as well
@@ -51143,69 +51304,69 @@ var WorkerFactory = /*#__PURE__*/createInlineWorkerFactory(/* rollup-plugin-web-
51143
51304
  try {
51144
51305
  if (e.data.type === 'init' && e.data.lockID) {
51145
51306
  if (navigator.locks) {
51146
- navigator.locks.request(e.data.lockID, () => {
51307
+ navigator.locks.request(e.data.lockID, function () {
51147
51308
  postMessage({ ready: true });
51148
51309
  // This unresolved promise keeps the lock held with the worker until the worker is
51149
51310
  // terminated at which point the lock is released.
51150
- return new Promise$2(() => { });
51311
+ return new Promise$2(function () { });
51151
51312
  });
51152
51313
  }
51153
51314
  return;
51154
51315
  }
51155
51316
  if (e.data.url && e.data.payload) {
51156
- let { url, payload, shouldCacheResources } = e.data;
51317
+ var _a = e.data, url = _a.url, payload = _a.payload, shouldCacheResources = _a.shouldCacheResources;
51157
51318
  if (Object.keys(payload).length === 0) {
51158
51319
  postMessage({
51159
51320
  type: 'emptyPayload'
51160
51321
  });
51161
51322
  }
51162
- const { sequence } = payload;
51163
- const stringifiedRecordingPayload = JSON.stringify(payload.recordingPayload);
51323
+ var sequence_1 = payload.sequence;
51324
+ var stringifiedRecordingPayload = JSON.stringify(payload.recordingPayload);
51164
51325
  // calculate and post back the recording payload size before the payload is compressed
51165
- const recordingPayloadSize = new TextEncoder().encode(stringifiedRecordingPayload).length;
51166
- const exceedsPayloadSizeLimit = recordingPayloadSize >= ONE_HUNDRED_MB_IN_BYTES;
51326
+ var recordingPayloadSize = new TextEncoder().encode(stringifiedRecordingPayload).length;
51327
+ var exceedsPayloadSizeLimit = recordingPayloadSize >= ONE_HUNDRED_MB_IN_BYTES;
51167
51328
  postMessage({
51168
51329
  type: 'recordingPayloadSize',
51169
- recordingPayloadSize,
51170
- exceedsPayloadSizeLimit
51330
+ recordingPayloadSize: recordingPayloadSize,
51331
+ exceedsPayloadSizeLimit: exceedsPayloadSizeLimit
51171
51332
  });
51172
51333
  // don't attempt to send the payload if it exceeds the allowed limit
51173
51334
  if (exceedsPayloadSizeLimit)
51174
51335
  return;
51175
51336
  if (shouldCacheResources) {
51176
- const hostedResourcesEvent = matchHostedResources(payload, stringifiedRecordingPayload);
51337
+ var hostedResourcesEvent = matchHostedResources(payload, stringifiedRecordingPayload);
51177
51338
  if (hostedResourcesEvent.hostedResources.length) {
51178
51339
  postMessage({
51179
51340
  type: 'hostedResources',
51180
- hostedResourcesEvent
51341
+ hostedResourcesEvent: hostedResourcesEvent
51181
51342
  });
51182
51343
  }
51183
51344
  }
51184
51345
  payload.recordingSize = recordingPayloadSize;
51185
- const body = compress(payload, 'binary');
51346
+ var body = compress(payload, 'binary');
51186
51347
  // we want to calculate ct (current time) as close as we can to the actual POST request
51187
51348
  // so that it's as accurate as possible
51188
- url = `${url}&ct=${new Date().getTime()}`;
51349
+ url = "".concat(url, "&ct=").concat(new Date().getTime());
51189
51350
  fetch(url, {
51190
51351
  method: 'POST',
51191
- body
51352
+ body: body
51192
51353
  }).then(function (response) {
51193
51354
  if (response.status < 200 || response.status >= 300) {
51194
51355
  postMessage({
51195
- error: new Error(`received status code ${response.status}: ${response.statusText}`),
51356
+ error: new Error("received status code ".concat(response.status, ": ").concat(response.statusText)),
51196
51357
  status: response.status,
51197
- sequence
51358
+ sequence: sequence_1
51198
51359
  });
51199
51360
  }
51200
51361
  else {
51201
51362
  postMessage({
51202
- sequence
51363
+ sequence: sequence_1
51203
51364
  });
51204
51365
  }
51205
- }).catch(function (e) {
51366
+ })["catch"](function (e) {
51206
51367
  postMessage({
51207
51368
  error: e,
51208
- sequence
51369
+ sequence: sequence_1
51209
51370
  });
51210
51371
  });
51211
51372
  }
@@ -52587,9 +52748,9 @@ function NetworkCapture() {
52587
52748
  var PREDICT_STEP_REGEX = /\$\$predict\$\$/;
52588
52749
  var DRAG_THRESHOLD = 5;
52589
52750
  var STYLE_ID = 'pendo-predict-plugin-styles';
52590
- var PREDICT_BASE_URL = 'https://predict.pendo.io';
52591
52751
  var GUIDE_BUTTON_IDENTIFIER = 'button:contains("token")';
52592
52752
  var pluginVersion = '1.0.1';
52753
+ var getPredictBaseUrl = function (designerServer) { return designerServer.replace('app', 'predict'); };
52593
52754
  var $ = function (id) { return document.getElementById(id); };
52594
52755
  var createElement = function (tag, attrs, parent) {
52595
52756
  if (attrs === void 0) { attrs = {}; }
@@ -52661,7 +52822,7 @@ var buildQueryParams = function (params) {
52661
52822
  return urlParams.toString();
52662
52823
  };
52663
52824
  // ----- Drag & Drop -----
52664
- var setupDragAndDrop = function (handle, container) {
52825
+ var setupDragAndDrop = function (handle, container, predictBaseUrl) {
52665
52826
  var isDragging = false;
52666
52827
  var hasMoved = false;
52667
52828
  var isCollapsed = false;
@@ -52724,7 +52885,7 @@ var setupDragAndDrop = function (handle, container) {
52724
52885
  document.removeEventListener('mousemove', onMouseMove);
52725
52886
  document.removeEventListener('mouseup', onMouseUp);
52726
52887
  if (!hasMoved && isCollapsed && iframe) {
52727
- (_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage({ type: 'TRIGGER_EXPAND' }, PREDICT_BASE_URL);
52888
+ (_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage({ type: 'TRIGGER_EXPAND' }, predictBaseUrl);
52728
52889
  }
52729
52890
  };
52730
52891
  handle.setCollapsedState = function (collapsed) {
@@ -52744,10 +52905,10 @@ var setupDragAndDrop = function (handle, container) {
52744
52905
  // ----- Explanation Iframe Creation -----
52745
52906
  var createExplanationIframe = function (_a) {
52746
52907
  var _b;
52747
- var analysisId = _a.analysisId, recordId = _a.recordId, configuration = _a.configuration;
52908
+ var analysisId = _a.analysisId, recordId = _a.recordId, configuration = _a.configuration, predictBaseUrl = _a.predictBaseUrl;
52748
52909
  var frameId = "frameExplanation-".concat(analysisId);
52749
52910
  (_b = $(frameId)) === null || _b === void 0 ? void 0 : _b.remove();
52750
- var base = "".concat(PREDICT_BASE_URL, "/external/analysis/").concat(analysisId, "/prediction/drilldown/").concat(recordId);
52911
+ var base = "".concat(predictBaseUrl, "/external/analysis/").concat(analysisId, "/prediction/drilldown/").concat(recordId);
52751
52912
  var params = buildQueryParams(configuration);
52752
52913
  createElement('iframe', {
52753
52914
  id: frameId,
@@ -52762,17 +52923,17 @@ var createExplanationIframe = function (_a) {
52762
52923
  // ----- Floating Modal Creation -----
52763
52924
  var createFloatingModal = function (_a) {
52764
52925
  var _b;
52765
- var recordId = _a.recordId, configuration = _a.configuration;
52926
+ var recordId = _a.recordId, configuration = _a.configuration, predictBaseUrl = _a.predictBaseUrl;
52766
52927
  var flatIds = (_b = configuration.analysisIds) === null || _b === void 0 ? void 0 : _b.flat(Infinity);
52767
52928
  for (var i = 0; i < flatIds.length; i++) {
52768
- createExplanationIframe({ analysisId: flatIds[i], recordId: recordId, configuration: configuration });
52929
+ createExplanationIframe({ analysisId: flatIds[i], recordId: recordId, configuration: configuration, predictBaseUrl: predictBaseUrl });
52769
52930
  }
52770
52931
  var container = createElement('div', { id: 'floatingModalContainer', className: 'floating-modal-container' }, document.body);
52771
52932
  var dragHandle = createElement('div', {
52772
52933
  className: 'floating-modal-drag-handle',
52773
52934
  innerHTML: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\">\n <g fill=\"#EBEBEB\">\n <circle cx=\"3.33\" cy=\"6\" r=\"1.5\"/><circle cx=\"8\" cy=\"6\" r=\"1.5\"/><circle cx=\"12.67\" cy=\"6\" r=\"1.5\"/>\n <circle cx=\"3.33\" cy=\"10\" r=\"1.5\"/><circle cx=\"8\" cy=\"10\" r=\"1.5\"/><circle cx=\"12.67\" cy=\"10\" r=\"1.5\"/>\n </g>\n </svg>"
52774
52935
  }, container);
52775
- var baseUrl = "".concat(PREDICT_BASE_URL, "/external/analysis/prediction/summary/").concat(recordId);
52936
+ var baseUrl = "".concat(predictBaseUrl, "/external/analysis/prediction/summary/").concat(recordId);
52776
52937
  var params = buildQueryParams(configuration);
52777
52938
  createElement('iframe', {
52778
52939
  id: 'frameFloatingModal',
@@ -52783,7 +52944,7 @@ var createFloatingModal = function (_a) {
52783
52944
  title: 'Floating Modal',
52784
52945
  src: "".concat(baseUrl, "?").concat(params)
52785
52946
  }, container);
52786
- container.dragHandle = setupDragAndDrop(dragHandle, container);
52947
+ container.dragHandle = setupDragAndDrop(dragHandle, container, predictBaseUrl);
52787
52948
  return function () {
52788
52949
  var _a, _b;
52789
52950
  (_b = (_a = container.dragHandle) === null || _a === void 0 ? void 0 : _a.cleanup) === null || _b === void 0 ? void 0 : _b.call(_a);
@@ -52796,11 +52957,11 @@ var createFloatingModal = function (_a) {
52796
52957
  };
52797
52958
  };
52798
52959
  var setupMessageListener = function (_a) {
52799
- var token = _a.token, forceAccountId = _a.forceAccountId, cleanup = _a.cleanup, pendo = _a.pendo;
52960
+ var token = _a.token, forceAccountId = _a.forceAccountId, cleanup = _a.cleanup, pendo = _a.pendo, predictBaseUrl = _a.predictBaseUrl;
52800
52961
  var messageHandler = function (_a) {
52801
52962
  var _b;
52802
52963
  var origin = _a.origin, data = _a.data;
52803
- if (origin !== PREDICT_BASE_URL || !data || typeof data !== 'object')
52964
+ if (origin !== predictBaseUrl || !data || typeof data !== 'object')
52804
52965
  return;
52805
52966
  var _c = data, type = _c.type, analysisId = _c.analysisId, height = _c.height, width = _c.width;
52806
52967
  var explanationFrame = $("frameExplanation-".concat(analysisId));
@@ -52833,13 +52994,13 @@ var setupMessageListener = function (_a) {
52833
52994
  }
52834
52995
  var visitorId = (_a = pendo === null || pendo === void 0 ? void 0 : pendo.getVisitorId) === null || _a === void 0 ? void 0 : _a.call(pendo);
52835
52996
  var accountId = forceAccountId !== null && forceAccountId !== void 0 ? forceAccountId : (_b = pendo === null || pendo === void 0 ? void 0 : pendo.getAccountId) === null || _b === void 0 ? void 0 : _b.call(pendo);
52836
- (_c = iframe.contentWindow) === null || _c === void 0 ? void 0 : _c.postMessage({ type: 'TOKEN_RECEIVED', token: token, idToken: idToken, extensionAPIKeys: extensionAPIKeys, visitorId: visitorId, accountId: accountId }, PREDICT_BASE_URL);
52997
+ (_c = iframe.contentWindow) === null || _c === void 0 ? void 0 : _c.postMessage({ type: 'TOKEN_RECEIVED', token: token, idToken: idToken, extensionAPIKeys: extensionAPIKeys, visitorId: visitorId, accountId: accountId }, predictBaseUrl);
52837
52998
  }
52838
52999
  },
52839
53000
  OPEN_EXPLANATION: function () {
52840
53001
  var _a;
52841
53002
  explanationFrame === null || explanationFrame === void 0 ? void 0 : explanationFrame.classList.add('is-visible');
52842
- (_a = explanationFrame === null || explanationFrame === void 0 ? void 0 : explanationFrame.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(data, PREDICT_BASE_URL);
53003
+ (_a = explanationFrame === null || explanationFrame === void 0 ? void 0 : explanationFrame.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(data, predictBaseUrl);
52843
53004
  },
52844
53005
  CLOSE_EXPLANATION: function () { return explanationFrame === null || explanationFrame === void 0 ? void 0 : explanationFrame.classList.remove('is-visible'); },
52845
53006
  AUTH_ERROR_EXPLANATION: function () {
@@ -52883,7 +53044,7 @@ var setupMessageListener = function (_a) {
52883
53044
  };
52884
53045
  var predictGuidesScript = function (_a) {
52885
53046
  var _b;
52886
- var step = _a.step, pendo = _a.pendo, cleanupArray = _a.cleanupArray, cleanup = _a.cleanup, log = _a.log;
53047
+ var step = _a.step, pendo = _a.pendo, cleanupArray = _a.cleanupArray, cleanup = _a.cleanup, log = _a.log, designerServer = _a.designerServer;
52887
53048
  log('[predict] initializing');
52888
53049
  // Before anything else, inject styles so that the guide will be hidden
52889
53050
  var pendoContainerId = step === null || step === void 0 ? void 0 : step.containerId;
@@ -52909,8 +53070,14 @@ var predictGuidesScript = function (_a) {
52909
53070
  log('[predict] no recordId found in URL, aborting');
52910
53071
  return;
52911
53072
  }
52912
- cleanupArray.push(setupMessageListener({ token: token, forceAccountId: configuration === null || configuration === void 0 ? void 0 : configuration.forceAccountId, cleanup: cleanup, pendo: pendo }));
52913
- cleanupArray.push(createFloatingModal({ recordId: recordId, configuration: configuration }));
53073
+ if (!designerServer) {
53074
+ log('[predict] no designerServer found, aborting');
53075
+ return;
53076
+ }
53077
+ var predictBaseUrl = getPredictBaseUrl(designerServer);
53078
+ log("[predict] predictBaseUrl: ".concat(predictBaseUrl));
53079
+ cleanupArray.push(setupMessageListener({ token: token, forceAccountId: configuration === null || configuration === void 0 ? void 0 : configuration.forceAccountId, cleanup: cleanup, pendo: pendo, predictBaseUrl: predictBaseUrl }));
53080
+ cleanupArray.push(createFloatingModal({ recordId: recordId, configuration: configuration, predictBaseUrl: predictBaseUrl }));
52914
53081
  };
52915
53082
 
52916
53083
  const PredictGuides = () => {
@@ -52943,7 +53110,10 @@ const PredictGuides = () => {
52943
53110
  const script = {
52944
53111
  name: 'PredictFrameScript',
52945
53112
  script(step, _guide, pendo) {
52946
- predictGuidesScript({ step, pendo, cleanupArray, cleanup, log });
53113
+ var _a, _b;
53114
+ const designerServer = ((_a = pendo === null || pendo === void 0 ? void 0 : pendo.getConfigValue) === null || _a === void 0 ? void 0 : _a.call(pendo, 'designerServer')) ||
53115
+ ((_b = pendo === null || pendo === void 0 ? void 0 : pendo.getConfigValue) === null || _b === void 0 ? void 0 : _b.call(pendo, 'server'));
53116
+ predictGuidesScript({ step, pendo, cleanupArray, cleanup, log, designerServer });
52947
53117
  this.on('unmounted', (evt) => {
52948
53118
  if (evt.reason !== 'hidden')
52949
53119
  cleanup();
@@ -52970,6 +53140,7 @@ const PredictGuides = () => {
52970
53140
 
52971
53141
  const ASSISTANT_MESSAGE = 'assistantMessage';
52972
53142
  const CONVERSATION_ID_URL_PATTERN = 'conversationIdUrlPattern';
53143
+ const MESSAGE_CONTENT = 'messageContent';
52973
53144
  const MESSAGE_ID_ATTR = 'messageIdAttr';
52974
53145
  const MESSAGE_ID_PATTERN = 'messageIdPattern';
52975
53146
  const MODEL_USED_ATTR = 'modelUsedAttr';
@@ -52990,7 +53161,7 @@ const REQUIRED_SELECTORS = [
52990
53161
  TURN_CONTAINER,
52991
53162
  USER_MESSAGE
52992
53163
  ];
52993
- const SUPPORTED_PRESETS = ['chatgpt-full', 'gemini-full', 'claude-full'];
53164
+ const SUPPORTED_PRESETS = ['chatgpt-full', 'gemini-full', 'claude-full', 'copilot-full'];
52994
53165
  const STREAMING_END_SETTLE_MS = 500;
52995
53166
  const SUBMISSION_START_RETRY_MS = 1000;
52996
53167
  const SUBMISSION_START_MAX_ATTEMPTS = 4;
@@ -53091,8 +53262,14 @@ class DOMConversation {
53091
53262
  const wasPressed = activeSelector && this.Sizzle.matchesSelector(thumb[0], activeSelector);
53092
53263
  const direction = isUp ? 'positive' : 'negative';
53093
53264
  const content = wasPressed ? 'unreact' : direction;
53094
- const assistantNode = thumb.closest(this.findSelector(TURN_CONTAINER))
53095
- .find(this.findSelector(ASSISTANT_MESSAGE));
53265
+ // the thumb may live inside the assistant message (e.g. copilot) or in a separate
53266
+ // turn footer alongside it (e.g. chatgpt/gemini); handle both
53267
+ const assistantSelector = this.findSelector(ASSISTANT_MESSAGE);
53268
+ let assistantNode = thumb.closest(assistantSelector);
53269
+ if (!assistantNode.length) {
53270
+ assistantNode = thumb.closest(this.findSelector(TURN_CONTAINER))
53271
+ .find(assistantSelector);
53272
+ }
53096
53273
  this.emit('user_reaction', {
53097
53274
  agentId: this.id,
53098
53275
  messageId: this.getMessageId(assistantNode),
@@ -53180,13 +53357,22 @@ class DOMConversation {
53180
53357
  }
53181
53358
  }
53182
53359
  extractContent(node) {
53360
+ let source = node;
53361
+ // optional: content inside a descendant
53362
+ const contentSelector = this.findSelector(MESSAGE_CONTENT);
53363
+ if (contentSelector) {
53364
+ const contentNode = node.find(contentSelector);
53365
+ if (contentNode.length) {
53366
+ source = contentNode;
53367
+ }
53368
+ }
53183
53369
  // .text() reads innerText, which is empty for content-visibility:auto / off-screen subtrees
53184
53370
  // (e.g. claude.ai's scrolled-up messages). Keep innerText as the primary source so agents
53185
53371
  // whose content already works are unchanged, and fall back to textContent only when it's empty.
53186
- const primary = node.text().trim();
53372
+ const primary = source.text().trim();
53187
53373
  if (primary)
53188
53374
  return primary;
53189
- return node[0].textContent.trim();
53375
+ return source[0].textContent.trim();
53190
53376
  }
53191
53377
  getMessageId(node) {
53192
53378
  const attr = this.findSelector(MESSAGE_ID_ATTR);