@pendo/agent 2.275.1 → 2.277.0

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.
@@ -430,15 +430,6 @@ function getPolicy(pendo) {
430
430
  return policy;
431
431
  }
432
432
 
433
- /*
434
- * NOTE: gulpfile.js line 296 -- actually writes the line of code that uses this
435
- * CODE to the agent. It's presumably done there to guarantee its early position
436
- * in resulting agent code.
437
- *
438
- * If you want to add any libraries for use in the preamble (we currently have
439
- * b64 and sha1 available here now) then you'll need to update `gulpfile.js`
440
- * line 35 for the `eslint` task and `karma.conf.js` line 31.
441
- */
442
433
  var STAGING_SERVER_HASHES = 'stagingServerHashes';
443
434
  var pendo$1;
444
435
  var _pendoConfig = {};
@@ -3891,8 +3882,8 @@ var SERVER = '';
3891
3882
  var ASSET_HOST = '';
3892
3883
  var ASSET_PATH = '';
3893
3884
  var DESIGNER_ENV = '';
3894
- var VERSION = '2.275.1_';
3895
- var PACKAGE_VERSION = '2.275.1';
3885
+ var VERSION = '2.277.0_';
3886
+ var PACKAGE_VERSION = '2.277.0';
3896
3887
  var LOADER = 'xhr';
3897
3888
  /* eslint-enable agent-eslint-rules/no-gulp-env-references */
3898
3889
  /**
@@ -10097,14 +10088,15 @@ function roundOffsetPosition(position) {
10097
10088
  });
10098
10089
  return position;
10099
10090
  }
10100
- function getOffsetPosition(element) {
10091
+ function getOffsetPosition(element, _win) {
10092
+ if (_win === void 0) { _win = window; }
10101
10093
  if (isPositionFixed(element)) {
10102
10094
  var fixedPosition = getScreenPosition(element);
10103
10095
  fixedPosition.fixed = true;
10104
10096
  return roundOffsetPosition(fixedPosition);
10105
10097
  }
10106
10098
  else {
10107
- var absolutePosition = getAbsolutePosition(element, getBody());
10099
+ var absolutePosition = getAbsolutePosition(element, getBody(_win.document), _win);
10108
10100
  return roundOffsetPosition(absolutePosition);
10109
10101
  }
10110
10102
  }
@@ -11185,6 +11177,233 @@ DomQuery.$ = {
11185
11177
  }
11186
11178
  };
11187
11179
 
11180
+ /**
11181
+ * Abstraction on top of Mutation Observer that has a naive polyfill to use setTimeout and look
11182
+ * every half second for changes.
11183
+ *
11184
+ * This observer only attempts to verify changes to `isInDocument` status for all "observed" elements.
11185
+ * The side effect of changing status is left to the element and any code owning said element to handle.
11186
+ */
11187
+ var DomObserver = /** @class */ (function () {
11188
+ function DomObserver(container, config) {
11189
+ if (container === void 0) { container = getBody(); }
11190
+ if (config === void 0) { config = { 'attributes': true, 'childList': true, 'subtree': true }; }
11191
+ var _this = this;
11192
+ this.listeners = [];
11193
+ this._teardown = function () { };
11194
+ if (sniffer.MutationObserver) {
11195
+ var MutationObserver_1 = getZoneSafeMethod('MutationObserver');
11196
+ var observer_1 = new MutationObserver_1(function (mutationList, observer) {
11197
+ _this.signal();
11198
+ });
11199
+ observer_1.observe(container, config);
11200
+ this._teardown = function () { return observer_1.disconnect; };
11201
+ }
11202
+ else {
11203
+ var handle_1 = setTimeout$1(function () {
11204
+ _this.signal();
11205
+ }, 500);
11206
+ this._teardown = function () {
11207
+ clearTimeout(handle_1);
11208
+ };
11209
+ }
11210
+ }
11211
+ DomObserver.prototype.signal = function () {
11212
+ _.each(this.listeners, function (el) {
11213
+ el.get();
11214
+ });
11215
+ };
11216
+ DomObserver.prototype.addObservers = function () {
11217
+ var elements = [];
11218
+ for (var _i = 0; _i < arguments.length; _i++) {
11219
+ elements[_i] = arguments[_i];
11220
+ }
11221
+ this.listeners = [].concat(this.listeners, elements);
11222
+ };
11223
+ DomObserver.prototype.teardown = function () {
11224
+ this._teardown();
11225
+ };
11226
+ return DomObserver;
11227
+ }());
11228
+
11229
+ function WeakRefFactory() {
11230
+ function WeakRef(obj) {
11231
+ this._object = obj;
11232
+ }
11233
+
11234
+ WeakRef.prototype.deref = function() {
11235
+ return this._object;
11236
+ };
11237
+
11238
+ return WeakRef;
11239
+ }
11240
+
11241
+ var WeakRef = (function(global, factory) {
11242
+ var nativeWeakRef = global.WeakRef;
11243
+ if (typeof nativeWeakRef !== 'function' || !/native/.test(nativeWeakRef)) {
11244
+ return factory();
11245
+ }
11246
+
11247
+ return nativeWeakRef;
11248
+ })(window, WeakRefFactory);
11249
+
11250
+ var trimString = function (str, limit) {
11251
+ var len = str.length;
11252
+ if (len <= limit)
11253
+ return str;
11254
+ return trimSurrogate(str.substring(0, limit));
11255
+ };
11256
+ function getTextValue(elem, limit) {
11257
+ if (elem.tagName && ['textarea', 'input'].indexOf(elem.tagName.toLowerCase()) > -1) {
11258
+ return trimString(elem.value, limit);
11259
+ }
11260
+ return getText(elem, limit);
11261
+ }
11262
+ function getText(elem, limit) {
11263
+ if (limit === void 0) { limit = 128; }
11264
+ var ret = '';
11265
+ var nodeType = elem.nodeType;
11266
+ var sub;
11267
+ if (nodeType === TEXT || nodeType === CDATA_SECTION) {
11268
+ return elem.nodeValue;
11269
+ }
11270
+ else if (!isElemBlacklisted(elem) &&
11271
+ (nodeType === ELEMENT ||
11272
+ nodeType === DOCUMENT ||
11273
+ nodeType === DOCUMENT_FRAGMENT)) {
11274
+ // Traverse its children
11275
+ if (!elem.childNodes)
11276
+ return ret;
11277
+ for (var i = 0; i < elem.childNodes.length; ++i) {
11278
+ var child = elem.childNodes[i];
11279
+ sub = getText(child, limit - ret.length);
11280
+ if ((ret + sub).length >= limit) {
11281
+ return ret + trimSurrogate(sub.substring(0, limit - ret.length));
11282
+ }
11283
+ ret += sub;
11284
+ }
11285
+ }
11286
+ return ret;
11287
+ }
11288
+ function isElemBlacklisted(elem) {
11289
+ return !elem.tagName || elem.tagName.toLowerCase() == 'textarea';
11290
+ }
11291
+ /**
11292
+ * Determine if the supplied {codepoint} falls within the "high surrogate" range
11293
+ * of unicode characters.
11294
+ *
11295
+ * @access private
11296
+ * @param {number} codepoint
11297
+ * @returns {boolean}
11298
+ * @see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF
11299
+ */
11300
+ function isHighSurrogate(codepoint) {
11301
+ return (0xD800 <= codepoint && codepoint <= 0xDBFF);
11302
+ }
11303
+ /**
11304
+ * Determine if the supplied {codepoint} falls within the "low surrogate" range
11305
+ * of unicode characters.
11306
+ *
11307
+ * @access private
11308
+ * @param {number} codepoint
11309
+ * @returns {boolean}
11310
+ * @see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF
11311
+ */
11312
+ function isLowSurrogate(codepoint) {
11313
+ return (0xDC00 <= codepoint && codepoint <= 0xDFFF);
11314
+ }
11315
+ /**
11316
+ * Remove "high surrogate" or unmatched "low surrogate" characters from the end
11317
+ * of {s}, indicating a broken unicode glyph. This happens when we truncate the
11318
+ * text of a node in {getText} that ends with a double-byte-encoded unicode glyph
11319
+ * such as emoji.
11320
+ *
11321
+ * @access private
11322
+ * @see https://github.com/pendo-io/pendo-client/pull/12
11323
+ * @param {string} s
11324
+ * @returns {string} s if no trailing surrogates, s-1 otherwise
11325
+ */
11326
+ function trimSurrogate(s) {
11327
+ // If the string is empty, it's definitely _not_ a "lonely surrogate"...
11328
+ if (s.length < 1)
11329
+ return s;
11330
+ var last = s.slice(-1).charCodeAt(0);
11331
+ // We're only interested in the `last` character...
11332
+ if (!isHighSurrogate(last) && !isLowSurrogate(last))
11333
+ return s;
11334
+ // If the string is only 1 character, that surrogate is definitely "lonely"...
11335
+ if (s.length === 1)
11336
+ return s.slice(0, -1);
11337
+ // All "lonely high surrogates" shall be eradicated...
11338
+ if (isHighSurrogate(last))
11339
+ return s.slice(0, -1);
11340
+ // Not sure how "lonely low surrogate" could happen, but let's check!
11341
+ if (isLowSurrogate(last)) {
11342
+ // Per above, the `last` character isn't the _only_ character...
11343
+ var prev = s.slice(-2).charCodeAt(0);
11344
+ // And if the `prev` character isn't a "high surrogate", that "low surrogate" is lonely.
11345
+ if (!isHighSurrogate(prev))
11346
+ return s.slice(0, -1);
11347
+ }
11348
+ return s; // otherwise leave it alone
11349
+ }
11350
+
11351
+ var ElementGetter = /** @class */ (function () {
11352
+ function ElementGetter(cssSelector) {
11353
+ this.listeners = {}; // callbacks to be called when an event of type occurs
11354
+ this.events = []; // event types this element listens for
11355
+ this.cssSelector = cssSelector;
11356
+ }
11357
+ ElementGetter.prototype.get = function () {
11358
+ var _this = this;
11359
+ var el = this.elRef && this.elRef.deref();
11360
+ var isInDoc = isInDocument(el); // is this safe to call if el is null?
11361
+ if (el && isInDoc)
11362
+ return el;
11363
+ if (el && !isInDoc) {
11364
+ return undefined;
11365
+ }
11366
+ el = dom(this.cssSelector)[0];
11367
+ if (!el) {
11368
+ return undefined;
11369
+ }
11370
+ _.each(this.events, function (evtType) {
11371
+ el.addEventListener(evtType, function (e) { return _this.onEvent(e); });
11372
+ });
11373
+ this.elRef = new WeakRef(el);
11374
+ return el;
11375
+ };
11376
+ ElementGetter.prototype.getText = function (limit) {
11377
+ if (limit === void 0) { limit = 1024; }
11378
+ // XXX not sure about size limit
11379
+ return getTextValue(this.get(), limit);
11380
+ };
11381
+ ElementGetter.prototype.addEventListener = function (event, callback) {
11382
+ var _this = this;
11383
+ var el = this.get();
11384
+ if (this.events.indexOf(event) < 0) {
11385
+ this.events.push(event);
11386
+ if (el) {
11387
+ el.addEventListener(event, function (e) { return _this.onEvent(e); });
11388
+ }
11389
+ }
11390
+ this.listeners[event] = this.listeners[event]
11391
+ ? this.listeners[event].push(callback) : [].concat(callback);
11392
+ };
11393
+ ElementGetter.prototype.onEvent = function (evt) {
11394
+ var type = evt.type;
11395
+ _.each(this.listeners[type], function (cb) { return cb(evt); });
11396
+ };
11397
+ ElementGetter.prototype.teardown = function () {
11398
+ var _this = this;
11399
+ var el = this.get();
11400
+ if (el) {
11401
+ _.each(this.events, function (evtType) { return el.removeEventListener(evtType, _this.onEvent); });
11402
+ }
11403
+ };
11404
+ return ElementGetter;
11405
+ }());
11406
+
11188
11407
  _.extend(dom, {
11189
11408
  'data': DomData$1,
11190
11409
  'event': DomEvent,
@@ -11199,6 +11418,8 @@ _.extend(dom, {
11199
11418
  'intersectRect': intersectRect,
11200
11419
  'getScrollParent': getScrollParent,
11201
11420
  'isElementVisible': isElementVisible,
11421
+ 'Observer': DomObserver,
11422
+ 'Element': ElementGetter,
11202
11423
  'scrollIntoView': scrollIntoView,
11203
11424
  'getRootNode': getRootNode
11204
11425
  });
@@ -11217,17 +11438,17 @@ function isTrustedOrigin(host) {
11217
11438
  return true;
11218
11439
  // Domains that Pendo owns
11219
11440
  var patterns = [
11220
- /^https:\/\/(app|via|adopt)(\.eu|\.us|\.jpn|\.hsbc|\.au)?\.pendo\.io$/,
11441
+ /^https:\/\/(app|via|adopt)(\.eu|\.us|\.gov|\.jpn|\.hsbc|\.au)?\.pendo\.io$/,
11221
11442
  /^https:\/\/((adopt\.)?us1\.)?(app|via|adopt)\.pendo\.io$/,
11222
- /^https:\/\/([0-9]{8}t[0-9]{4}-dot-)pendo-(io|eu|us1|jp-prod|hsbc|au)\.appspot\.com$/,
11223
- /^https:\/\/hotfix-(ops|app)-([0-9]+-dot-)pendo-(io|eu|us1|jp-prod|hsbc|au)\.appspot\.com$/,
11224
- /^https:\/\/pendo-(io|eu|us1|jp-prod|hsbc|au)-static\.storage\.googleapis\.com$/,
11225
- /^https:\/\/(us1\.)?cdn(\.eu|\.jpn|\.hsbc|\.au)?\.pendo\.io$/
11443
+ /^https:\/\/([0-9]{8}t[0-9]{4}-dot-)pendo-(io|eu|us1|govramp|jp-prod|hsbc|au)\.appspot\.com$/,
11444
+ /^https:\/\/hotfix-(ops|app)-([0-9]+-dot-)pendo-(io|eu|us1|govramp|jp-prod|hsbc|au)\.appspot\.com$/,
11445
+ /^https:\/\/pendo-(io|eu|us1|govramp|jp-prod|hsbc|au)-static\.storage\.googleapis\.com$/,
11446
+ /^https:\/\/(us1\.)?cdn(\.eu|\.jpn|\.gov|\.hsbc|\.au)?\.pendo\.io$/
11226
11447
  ];
11227
11448
  if (!isProdAgent()) {
11228
11449
  patterns = patterns.concat([
11229
11450
  /^https:\/\/([a-zA-Z0-9-]+\.)*pendo-dev\.com$/,
11230
- /^https:\/\/([a-zA-Z0-9-]+-dot-)?pendo-(dev|test|io|us1|jp-prod|hsbc|au|batman|magic|atlas|wildlings|ionchef|mobile-guides|mobile-hummus|mobile-fbi|mobile-plat|eu|eu-dev|apollo|security|perfserf|freeze|armada|voc|mcfly|calypso|dap|scrum-ops|ml|helix|uat)\.appspot\.com$/,
11451
+ /^https:\/\/([a-zA-Z0-9-]+-dot-)?pendo-(dev|test|io|us1|govramp|jp-prod|hsbc|au|batman|magic|atlas|wildlings|ionchef|mobile-guides|mobile-hummus|mobile-fbi|mobile-plat|eu|eu-dev|apollo|security|perfserf|freeze|armada|voc|mcfly|calypso|dap|scrum-ops|ml|helix|uat)\.appspot\.com$/,
11231
11452
  /^https:\/\/via\.pendo\.local:\d{4}$/,
11232
11453
  /^https:\/\/adopt\.pendo\.local:\d{4}$/,
11233
11454
  /^https:\/\/local\.pendo\.io:\d{4}$/,
@@ -11524,16 +11745,16 @@ function validateModuleURL(moduleURL) {
11524
11745
  allowedPaths['/modules/pendo.designer/plugins/' + file] = 1;
11525
11746
  allowedPaths['/engage-app-ui/assets/classic-designer/plugins/' + file] = 1;
11526
11747
  });
11527
- moduleURL = moduleURL.replace(/^https:\/\//, '');
11528
- var origin = moduleURL.substring(0, moduleURL.indexOf('/'));
11529
- var path = moduleURL.substring(moduleURL.indexOf('/'));
11530
- return isTrustedOrigin('https://' + origin) && !!allowedPaths[path];
11531
- }
11532
- function ensureHttps(moduleURL) {
11533
- return moduleURL.replace(/^[a-zA-Z-:]*\/\//, 'https://');
11748
+ try {
11749
+ var fileUrl = new URL(moduleURL);
11750
+ return isTrustedOrigin(fileUrl.origin) && !!allowedPaths[fileUrl.pathname];
11751
+ }
11752
+ catch (e) {
11753
+ log.debug('Invalid module URL: ' + moduleURL);
11754
+ return false;
11755
+ }
11534
11756
  }
11535
11757
  var moduleLoader = function (moduleURL) {
11536
- moduleURL = ensureHttps(moduleURL);
11537
11758
  if (!validateModuleURL(moduleURL))
11538
11759
  return;
11539
11760
  modulesWaiting.push(moduleURL);
@@ -14561,7 +14782,7 @@ var GuideRuntime = (function (agentEvents) {
14561
14782
  if (_.isFunction(globalScript[scriptProp])) {
14562
14783
  if (_.isFunction(globalScript.test)) {
14563
14784
  try {
14564
- return globalScript.test(step, guide);
14785
+ return globalScript.test(step, guide, pendo$1);
14565
14786
  }
14566
14787
  catch (e) {
14567
14788
  log.critical('Error in global script test code block', { 'error': e });
@@ -14613,7 +14834,7 @@ var GuideRuntime = (function (agentEvents) {
14613
14834
  _.each(getCustomScripts(step, guide), function (script) {
14614
14835
  try {
14615
14836
  var context_1 = GuideRuntime.getContext(step);
14616
- script.call(context_1, step, guide);
14837
+ script.call(context_1, step, guide, pendo$1);
14617
14838
  }
14618
14839
  catch (err) {
14619
14840
  log.critical('Exception thrown running code block for: ' + JSON.stringify({
@@ -16794,10 +17015,10 @@ var FlexboxPolyfill = (function () {
16794
17015
  return classes && classes.indexOf('pendo-mock-flexbox-element') > -1;
16795
17016
  });
16796
17017
  }
16797
- function createFlexContainer(isElementPosAbsolute) {
17018
+ function createFlexContainer(isElementPosAbsolute, useNativeFlexbox) {
16798
17019
  var container = document.createElement('div');
16799
17020
  container.style.display = 'inline-block';
16800
- if (!isElementPosAbsolute) {
17021
+ if (!isElementPosAbsolute && !useNativeFlexbox) {
16801
17022
  container.style.position = 'absolute';
16802
17023
  }
16803
17024
  // Sibling inline-block elements will attempt to align with a common baseline (think about it like a horizontal line)
@@ -17012,19 +17233,33 @@ var FlexboxPolyfill = (function () {
17012
17233
  var computedStyles = getComputedStyle_safe(row);
17013
17234
  return parseInt(width, 10) - parseInt(computedStyles.paddingLeft, 10) - parseInt(computedStyles.paddingRight, 10);
17014
17235
  }
17015
- function initializeFlexRows(row, justifyContent, rowVerticalAlignment) {
17016
- var flexElements = getFlexboxElements(row.children);
17017
- if (flexElements.length === 0)
17018
- return;
17019
- // In the following steps, we remove and add elements to the guide.
17020
- // Therefore we precalculation the rowWidth to ensure it won't change
17021
- // in case of scrollbar will be added or removed from the screen.
17022
- var rowWidth = FlexboxPolyfill.getRowWidth(row);
17023
- var flexRows = FlexboxPolyfill.wrapFlexElementsInFlexRows(flexElements, row, rowWidth);
17024
- // Once we have all the pendo-mock-flexbox-element elements placed in to
17025
- // pendo-mock-flexbox-row rows, loop through each pendo-mock-flexbox-row and set the
17026
- // height and alignment
17027
- FlexboxPolyfill.formatFlexRows(flexRows, row, justifyContent, rowVerticalAlignment, rowWidth);
17236
+ function initializeFlexRows(row, justifyContent, rowVerticalAlignment, useNativeFlexbox) {
17237
+ if (useNativeFlexbox === void 0) { useNativeFlexbox = false; }
17238
+ if (useNativeFlexbox) {
17239
+ var alignments = {
17240
+ 'top': 'flex-start',
17241
+ 'center': 'center',
17242
+ 'bottom': 'flex-end'
17243
+ };
17244
+ row.style.display = 'flex';
17245
+ row.style.flexWrap = 'wrap';
17246
+ row.style.justifyContent = justifyContent;
17247
+ row.style.alignItems = alignments[rowVerticalAlignment] || 'flex-start';
17248
+ }
17249
+ else {
17250
+ var flexElements = getFlexboxElements(row.children);
17251
+ if (flexElements.length === 0)
17252
+ return;
17253
+ // In the following steps, we remove and add elements to the guide.
17254
+ // Therefore we precalculation the rowWidth to ensure it won't change
17255
+ // in case of scrollbar will be added or removed from the screen.
17256
+ var rowWidth = FlexboxPolyfill.getRowWidth(row);
17257
+ var flexRows = FlexboxPolyfill.wrapFlexElementsInFlexRows(flexElements, row, rowWidth);
17258
+ // Once we have all the pendo-mock-flexbox-element elements placed in to
17259
+ // pendo-mock-flexbox-row rows, loop through each pendo-mock-flexbox-row and set the
17260
+ // height and alignment
17261
+ FlexboxPolyfill.formatFlexRows(flexRows, row, justifyContent, rowVerticalAlignment, rowWidth);
17262
+ }
17028
17263
  }
17029
17264
  function wrapFlexElementsInFlexRows(flexElements, row, rowWidthPreCalc) {
17030
17265
  var rowWidth = rowWidthPreCalc || getRowWidth(row);
@@ -17101,21 +17336,24 @@ var FlexboxPolyfill = (function () {
17101
17336
  return true;
17102
17337
  return false;
17103
17338
  }
17104
- function flexElement(ele) {
17339
+ function flexElement(ele, useNativeFlexbox) {
17105
17340
  var rowsToBeFlexed = dom('[data-pendo-display-flex]', ele);
17106
17341
  _.each(rowsToBeFlexed, function (row) {
17107
- var rowWithFlexedElements = FlexboxPolyfill.initializeFlexElements(row);
17342
+ var rowWithFlexedElements = useNativeFlexbox ? row : FlexboxPolyfill.initializeFlexElements(row);
17108
17343
  var horizontalAlignment = row.getAttribute('data-pendo-justify-content');
17109
17344
  var rowVerticalAlignment = row.getAttribute('data-row-vertical-alignment');
17110
- FlexboxPolyfill.initializeFlexRows(rowWithFlexedElements, horizontalAlignment, rowVerticalAlignment);
17345
+ FlexboxPolyfill.initializeFlexRows(rowWithFlexedElements, horizontalAlignment, rowVerticalAlignment, useNativeFlexbox);
17111
17346
  });
17112
17347
  }
17113
- function flexAllThings(containerId, context) {
17348
+ function flexAllThings(containerId, step) {
17349
+ var _a;
17350
+ var useNativeFlexbox = (_a = step === null || step === void 0 ? void 0 : step.attributes) === null || _a === void 0 ? void 0 : _a.useFlexbox;
17351
+ var context = (step === null || step === void 0 ? void 0 : step.guideElement) || document;
17114
17352
  var guideContainer = dom('#' + containerId, context)[0];
17115
17353
  if (!guideContainer)
17116
17354
  return;
17117
17355
  maintainAspectRatios(guideContainer);
17118
- FlexboxPolyfill.flexElement(guideContainer);
17356
+ FlexboxPolyfill.flexElement(guideContainer, useNativeFlexbox);
17119
17357
  }
17120
17358
  function maintainAspectRatios(ele) {
17121
17359
  var dataAspectRatio = 'data-aspect-ratio';
@@ -17370,7 +17608,7 @@ function recalculateGuideHeightOnImgLoad(node, step) {
17370
17608
  if (guideContainer && step.attributes.imgCount <= 0) {
17371
17609
  recalculateGuideWidth(containerId, step.guideElement);
17372
17610
  adjustGuideContentWidth(containerId, step.guideElement);
17373
- FlexboxPolyfill.flexAllThings(containerId, step.guideElement);
17611
+ FlexboxPolyfill.flexAllThings(containerId, step);
17374
17612
  var guide = step.getGuide();
17375
17613
  // calling recalculateGuideHeight with an announcement guide or Announcements Module breaks announcements display
17376
17614
  // in resource center
@@ -17381,7 +17619,7 @@ function recalculateGuideHeightOnImgLoad(node, step) {
17381
17619
  var containerHasOverflow = domContainer && domContainer.style && domContainer.style.overflow === 'auto';
17382
17620
  if (containerHasOverflow) {
17383
17621
  adjustGuideContentWidth(containerId, step.guideElement);
17384
- FlexboxPolyfill.flexAllThings(step.containerId, step.guideElement);
17622
+ FlexboxPolyfill.flexAllThings(step.containerId, step);
17385
17623
  }
17386
17624
  }
17387
17625
  if (step.attributes.calculatedType === 'tooltip') {
@@ -17407,7 +17645,7 @@ function recalculateGuideHeightOnImgLoad(node, step) {
17407
17645
  }
17408
17646
  guideContainer.style.visibility = 'visible';
17409
17647
  guideContainer.parentNode.style.visibility = 'visible';
17410
- FlexboxPolyfill.flexAllThings(step.containerId, step.guideElement);
17648
+ FlexboxPolyfill.flexAllThings(step.containerId, step);
17411
17649
  });
17412
17650
  }
17413
17651
  function bindActionToNode(node, actionObject, step) {
@@ -18130,7 +18368,7 @@ var BuildingBlockResourceCenter = (function () {
18130
18368
  }, []);
18131
18369
  adjustGuideContentWidth(containerIds, step.guideElement);
18132
18370
  _.each(containerIds, function (containerId) {
18133
- FlexboxPolyfill.flexAllThings(containerId, step.guideElement);
18371
+ FlexboxPolyfill.flexAllThings(containerId, step);
18134
18372
  });
18135
18373
  }
18136
18374
  else {
@@ -21264,7 +21502,7 @@ function startPreviewMode(window) {
21264
21502
  function updatePreviewUI() {
21265
21503
  if (store.getters['frames/isFollower']())
21266
21504
  return true;
21267
- updatePreview(document, getActiveGuides(), getLastGuideStepSeen());
21505
+ updatePreview(document, getDisplayableGuides(), getLastGuideStepSeen());
21268
21506
  return true;
21269
21507
  }
21270
21508
  function addPreviewUI(window) {
@@ -21328,7 +21566,7 @@ function previewMessageHandler(e) {
21328
21566
  store.dispatch('frames/stopPreview', { 'preventWindowClose': preventWindowClose });
21329
21567
  }
21330
21568
  else if (type === pendoPreview$1 + '::restart') {
21331
- var lastGuideStepSeen = restartPreview(getActiveGuides(), getLastGuideStepSeen(), e.data.language);
21569
+ var lastGuideStepSeen = restartPreview(getDisplayableGuides(), getLastGuideStepSeen(), e.data.language);
21332
21570
  store.dispatch('guideState/forceExpire');
21333
21571
  store.dispatch('guideState/updateLastGuideStepSeen', lastGuideStepSeen);
21334
21572
  store.dispatch('frames/restartPreview');
@@ -23299,7 +23537,7 @@ function createCrossFrameChannel(store) {
23299
23537
  return createTopFrameRelay(store, window, SingletonMessageHandler);
23300
23538
  }
23301
23539
 
23302
- function onTurbolinksPageLoad(document, onPageLoad) {
23540
+ function onTurbolinksPageLoad(document, onPageLoad, beforeTurboCache) {
23303
23541
  var Turbolinks = window.Turbolinks, Turbo = window.Turbo;
23304
23542
  var turboLinksPageLoad;
23305
23543
  // Special case guide reloading for troublesome Rails component:
@@ -23312,7 +23550,14 @@ function onTurbolinksPageLoad(document, onPageLoad) {
23312
23550
  if (Turbo && Turbo.visit) {
23313
23551
  turboLinksPageLoad = 'turbo:load';
23314
23552
  }
23315
- return turboLinksPageLoad ? attachEventInternal(document, turboLinksPageLoad, onPageLoad) : function () { };
23553
+ if (!turboLinksPageLoad)
23554
+ return function () { };
23555
+ var detachOnPageLoad = attachEventInternal(document, turboLinksPageLoad, onPageLoad);
23556
+ var detachBeforeTurboCache = attachEventInternal(document, 'turbo:before-cache', beforeTurboCache);
23557
+ return function () {
23558
+ detachOnPageLoad();
23559
+ detachBeforeTurboCache();
23560
+ };
23316
23561
  }
23317
23562
 
23318
23563
  var EMPTY_ARRAY_JZB = 'eJwFwIEIAAAAwDDQd3-N1QABFQC5';
@@ -24581,11 +24826,22 @@ var resetPendoUI = function () {
24581
24826
  removeAllBadges();
24582
24827
  flushLater();
24583
24828
  };
24829
+ /**
24830
+ * If a visitor has been marked as "Do Not Process" then this value will be set to true.
24831
+ *
24832
+ * @access public
24833
+ * @name doNotProcess
24834
+ * @type {string}
24835
+ * @category Events
24836
+ * @example
24837
+ * pendo.doNotProcess => true
24838
+ */
24584
24839
  function handleDoNotProcess() {
24585
24840
  stopGuides();
24586
24841
  lockEvents();
24587
24842
  pendo$1.segmentFlags = [];
24588
24843
  pendo$1.doNotProcess = true;
24844
+ store.commit('debugger/doNotProcess', true);
24589
24845
  log.info('not tracking visitor due to 451 response');
24590
24846
  }
24591
24847
  function guidesPayload(guidesJson) {
@@ -24620,16 +24876,6 @@ function isGuideRequestPending() {
24620
24876
  return false;
24621
24877
  }
24622
24878
  var mostRecentGuideRequest;
24623
- /**
24624
- * If a visitor has been marked as "Do Not Process" then this value will be set to true.
24625
- *
24626
- * @access public
24627
- * @name doNotProcess
24628
- * @type {string}
24629
- * @category Events
24630
- * @example
24631
- * pendo.doNotProcess => true
24632
- */
24633
24879
  var loadGuideJs = function (apiKey, params) {
24634
24880
  var isAdoptPartner = treatAsAdoptPartner();
24635
24881
  var guideRequestId = _.uniqueId();
@@ -25172,11 +25418,14 @@ var initGuides = function () {
25172
25418
  var guideIds = event.data[0].guideIds;
25173
25419
  pruneBadges(guideIds);
25174
25420
  });
25175
- teardownFns.push(onTurbolinksPageLoad(document, function () {
25421
+ teardownFns.push(onTurbolinksPageLoad(document, function onPageLoad() {
25176
25422
  if (pendoDotUrl.get() === reloadGuides.lastUrl) {
25177
25423
  // Force a reload if Turbolinks replaces the document body without changing the url
25178
25424
  forceGuideReload();
25179
25425
  }
25426
+ }, function beforeTurboCache() {
25427
+ // Prevent Turbo from caching and re-rendering displayed guides
25428
+ resetPendoUI();
25180
25429
  }));
25181
25430
  // Override tooltip size from options hash
25182
25431
  var arrowSize = ConfigReader.get('guides.tooltip.arrowSize');
@@ -25644,7 +25893,7 @@ var EventRouter = function () {
25644
25893
  containerJSON = findGuideContainerJSON(evt.step.domJson);
25645
25894
  recalculateGuideWidth(containerJSON.props.id, guideElement);
25646
25895
  adjustGuideContentWidth(containerJSON.props.id, guideElement);
25647
- FlexboxPolyfill.flexAllThings(containerJSON.props.id, guideElement);
25896
+ FlexboxPolyfill.flexAllThings(containerJSON.props.id, evt.step);
25648
25897
  recalculateGuideHeight(containerJSON.props.id, guideElement);
25649
25898
  break;
25650
25899
  case actionKeys.hideElements:
@@ -25652,7 +25901,7 @@ var EventRouter = function () {
25652
25901
  containerJSON = findGuideContainerJSON(evt.step.domJson);
25653
25902
  recalculateGuideWidth(containerJSON.props.id, guideElement);
25654
25903
  adjustGuideContentWidth(containerJSON.props.id, guideElement);
25655
- FlexboxPolyfill.flexAllThings(containerJSON.props.id, guideElement);
25904
+ FlexboxPolyfill.flexAllThings(containerJSON.props.id, evt.step);
25656
25905
  recalculateGuideHeight(containerJSON.props.id, guideElement);
25657
25906
  break;
25658
25907
  case actionKeys.slideElement:
@@ -26209,7 +26458,8 @@ var PluginAPI = {
26209
26458
  },
26210
26459
  'agentStorage': agentStorage,
26211
26460
  'analytics': {
26212
- 'ptm': function () { return eventQueue; }
26461
+ 'ptm': function () { return eventQueue; },
26462
+ 'collectEvent': collectEvent
26213
26463
  },
26214
26464
  'attachEvent': attachEvent,
26215
26465
  'ConfigReader': ConfigReader,
@@ -27061,7 +27311,7 @@ var BuildingBlockGuides = (function () {
27061
27311
  // Note: Announcement guides have their own special handling for deferring flexAllThings until
27062
27312
  // all images have loaded. See the if (isResourceCenter) check below
27063
27313
  if ((!hasImageCount && !isResourceCenter)) {
27064
- BuildingBlockGuides.flexAllThings(step.containerId, step.guideElement);
27314
+ BuildingBlockGuides.flexAllThings(step.containerId, step);
27065
27315
  }
27066
27316
  if (!isFullyCustomResourceCenter) {
27067
27317
  BuildingBlockGuides.recalculateGuideHeight(step.containerId, step.guideElement);
@@ -27099,7 +27349,7 @@ var BuildingBlockGuides = (function () {
27099
27349
  announcementModules = [guide.attributes.resourceCenter];
27100
27350
  }
27101
27351
  else {
27102
- BuildingBlockGuides.flexAllThings(step.containerId, step.guideElement);
27352
+ BuildingBlockGuides.flexAllThings(step.containerId, step);
27103
27353
  }
27104
27354
  if (announcementModules.length) {
27105
27355
  _.forEach(announcementModules, function (announcementModule) {
@@ -27117,7 +27367,7 @@ var BuildingBlockGuides = (function () {
27117
27367
  // pendo-g- can actually be the guideId OR the stepId. see fetchAndMigrateGuide in
27118
27368
  // the designer repo
27119
27369
  var containerIdToFlex = dom('#pendo-g-' + stepId).length ? stepId : guideId;
27120
- BuildingBlockGuides.flexAllThings('pendo-g-' + containerIdToFlex, step.guideElement);
27370
+ BuildingBlockGuides.flexAllThings('pendo-g-' + containerIdToFlex, step);
27121
27371
  }
27122
27372
  });
27123
27373
  });
@@ -27499,95 +27749,6 @@ var BuildingBlockGuides = (function () {
27499
27749
  }
27500
27750
  })();
27501
27751
 
27502
- function getText(elem, limit) {
27503
- var ret = '';
27504
- var nodeType = elem.nodeType;
27505
- var sub;
27506
- limit = limit || 128;
27507
- if (nodeType === TEXT || nodeType === CDATA_SECTION) {
27508
- return elem.nodeValue;
27509
- }
27510
- else if (!isElemBlacklisted(elem) &&
27511
- (nodeType === ELEMENT ||
27512
- nodeType === DOCUMENT ||
27513
- nodeType === DOCUMENT_FRAGMENT)) {
27514
- // Traverse its children
27515
- if (!elem.childNodes)
27516
- return ret;
27517
- for (var i = 0; i < elem.childNodes.length; ++i) {
27518
- var child = elem.childNodes[i];
27519
- sub = getText(child, limit - ret.length);
27520
- if ((ret + sub).length >= limit) {
27521
- return ret + trimSurrogate(sub.substring(0, limit - ret.length));
27522
- }
27523
- ret += sub;
27524
- }
27525
- }
27526
- return ret;
27527
- }
27528
- function isElemBlacklisted(elem) {
27529
- return !elem.tagName || elem.tagName.toLowerCase() == 'textarea';
27530
- }
27531
- /**
27532
- * Determine if the supplied {codepoint} falls within the "high surrogate" range
27533
- * of unicode characters.
27534
- *
27535
- * @access private
27536
- * @param {number} codepoint
27537
- * @returns {boolean}
27538
- * @see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF
27539
- */
27540
- function isHighSurrogate(codepoint) {
27541
- return (0xD800 <= codepoint && codepoint <= 0xDBFF);
27542
- }
27543
- /**
27544
- * Determine if the supplied {codepoint} falls within the "low surrogate" range
27545
- * of unicode characters.
27546
- *
27547
- * @access private
27548
- * @param {number} codepoint
27549
- * @returns {boolean}
27550
- * @see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF
27551
- */
27552
- function isLowSurrogate(codepoint) {
27553
- return (0xDC00 <= codepoint && codepoint <= 0xDFFF);
27554
- }
27555
- /**
27556
- * Remove "high surrogate" or unmatched "low surrogate" characters from the end
27557
- * of {s}, indicating a broken unicode glyph. This happens when we truncate the
27558
- * text of a node in {getText} that ends with a double-byte-encoded unicode glyph
27559
- * such as emoji.
27560
- *
27561
- * @access private
27562
- * @see https://github.com/pendo-io/pendo-client/pull/12
27563
- * @param {string} s
27564
- * @returns {string} s if no trailing surrogates, s-1 otherwise
27565
- */
27566
- function trimSurrogate(s) {
27567
- // If the string is empty, it's definitely _not_ a "lonely surrogate"...
27568
- if (s.length < 1)
27569
- return s;
27570
- var last = s.slice(-1).charCodeAt(0);
27571
- // We're only interested in the `last` character...
27572
- if (!isHighSurrogate(last) && !isLowSurrogate(last))
27573
- return s;
27574
- // If the string is only 1 character, that surrogate is definitely "lonely"...
27575
- if (s.length === 1)
27576
- return s.slice(0, -1);
27577
- // All "lonely high surrogates" shall be eradicated...
27578
- if (isHighSurrogate(last))
27579
- return s.slice(0, -1);
27580
- // Not sure how "lonely low surrogate" could happen, but let's check!
27581
- if (isLowSurrogate(last)) {
27582
- // Per above, the `last` character isn't the _only_ character...
27583
- var prev = s.slice(-2).charCodeAt(0);
27584
- // And if the `prev` character isn't a "high surrogate", that "low surrogate" is lonely.
27585
- if (!isHighSurrogate(prev))
27586
- return s.slice(0, -1);
27587
- }
27588
- return s; // otherwise leave it alone
27589
- }
27590
-
27591
27752
  var activeContexts;
27592
27753
  var logOverride;
27593
27754
  var MAX_HISTORY = 100;
@@ -27601,7 +27762,7 @@ var getDefaultLogOverride = function (env) {
27601
27762
  return isEnabledCookie == 'true';
27602
27763
  }
27603
27764
  // add welcome message and list logging status + contexts
27604
- return !_.contains(['prod', 'prod-eu', 'prod-us1', 'prod-jp', 'prod-hsbc', 'prod-au', 'rc'], env);
27765
+ return !_.contains(['prod', 'prod-eu', 'prod-us1', 'prod-jp', 'prod-hsbc', 'prod-au', 'prod-gov', 'rc'], env);
27605
27766
  };
27606
27767
  var getDefaultActiveContexts = function () {
27607
27768
  var ac = agentStorage.read(ACTIVE_CONTEXTS, true);
@@ -30196,7 +30357,7 @@ function GuideStep(guide) {
30196
30357
  // the designer repo
30197
30358
  var containerIdToFlex = dom(guideContainer).find('#pendo-g-' + stepId)[0] ? stepId : guide.id;
30198
30359
  BuildingBlockGuides.adjustGuideContentWidth('pendo-g-' + containerIdToFlex, step.guideElement);
30199
- BuildingBlockGuides.flexAllThings('pendo-g-' + containerIdToFlex, step.guideElement);
30360
+ BuildingBlockGuides.flexAllThings('pendo-g-' + containerIdToFlex, step);
30200
30361
  }
30201
30362
  });
30202
30363
  }
@@ -30205,7 +30366,7 @@ function GuideStep(guide) {
30205
30366
  }
30206
30367
  }
30207
30368
  else {
30208
- BuildingBlockGuides.flexAllThings(containerId, step.guideElement);
30369
+ BuildingBlockGuides.flexAllThings(containerId, step);
30209
30370
  }
30210
30371
  if (!isFullyCustomResourceCenter) {
30211
30372
  BuildingBlockGuides.recalculateGuideHeight(containerId, step.guideElement);
@@ -32118,7 +32279,8 @@ var DebuggerModule = (function () {
32118
32279
  'enableEventLogging': false,
32119
32280
  'eventsCaptured': [],
32120
32281
  'cspErrors': [],
32121
- 'installType': null
32282
+ 'installType': null,
32283
+ 'doNotProcess': false
32122
32284
  };
32123
32285
  var SYNC_TYPES = {
32124
32286
  'TOP_DOWN': 'top-down',
@@ -32317,6 +32479,9 @@ var DebuggerModule = (function () {
32317
32479
  if (state.cspErrors.length > 10) {
32318
32480
  state.cspErrors.pop();
32319
32481
  }
32482
+ },
32483
+ 'doNotProcess': function (state, doNotProcess) {
32484
+ state.doNotProcess = doNotProcess;
32320
32485
  }
32321
32486
  };
32322
32487
  function autoDisplayFn(evt) {
@@ -33070,7 +33235,8 @@ var PromoteMetadata = (function () {
33070
33235
  'hasPromotedMetadataKind': hasPromotedMetadataKind,
33071
33236
  'setSchemaGroup': setSchemaGroup,
33072
33237
  'getSchemaGroup': getSchemaGroup,
33073
- 'resetSchemaGroup': resetSchemaGroup
33238
+ 'resetSchemaGroup': resetSchemaGroup,
33239
+ 'resetCachedSchemaGroup': resetCachedSchemaGroup
33074
33240
  };
33075
33241
  function init(pendo, PluginAPI) {
33076
33242
  pluginApi = PluginAPI;
@@ -33085,13 +33251,13 @@ var PromoteMetadata = (function () {
33085
33251
  * @access public
33086
33252
  * @label SCHEMA_GROUP
33087
33253
  */
33088
- agentStorage.registry.addLocal(SCHEMA_GROUP);
33254
+ pluginApi.agentStorage.registry.addLocal(SCHEMA_GROUP);
33089
33255
  if (shouldPersist()) {
33090
33256
  try {
33091
- cachedSchemaGroup = JSON.parse(agentStorage.read(SCHEMA_GROUP)) || {};
33257
+ cachedSchemaGroup = JSON.parse(pluginApi.agentStorage.read(SCHEMA_GROUP)) || {};
33092
33258
  }
33093
33259
  catch (e) {
33094
- cachedSchemaGroup = {};
33260
+ resetCachedSchemaGroup();
33095
33261
  }
33096
33262
  }
33097
33263
  if (promotedAgentMetadata && promotedAgentMetadata.length) {
@@ -33132,16 +33298,19 @@ var PromoteMetadata = (function () {
33132
33298
  function clearSession(event) {
33133
33299
  var eventData = event.data[0];
33134
33300
  if (_.get(eventData, 'wasCleared')) {
33135
- agentStorage.clear(SCHEMA_GROUP);
33301
+ pluginApi.agentStorage.clear(SCHEMA_GROUP);
33136
33302
  resetSchemaGroup();
33137
33303
  }
33138
33304
  }
33139
33305
  function resetSchemaGroup() {
33140
33306
  schemaGroup = {};
33141
33307
  }
33308
+ function resetCachedSchemaGroup() {
33309
+ cachedSchemaGroup = {};
33310
+ }
33142
33311
  function createSchemaGroup(metadata) {
33143
33312
  if (shouldPersist()) {
33144
- cachedSchemaGroup = JSON.parse(agentStorage.read(SCHEMA_GROUP)) || {};
33313
+ cachedSchemaGroup = JSON.parse(pluginApi.agentStorage.read(SCHEMA_GROUP)) || {};
33145
33314
  cachedSchemaGroup = removePrefixes(cachedSchemaGroup);
33146
33315
  }
33147
33316
  var __sg__ = getSchemaGroup();
@@ -33162,7 +33331,7 @@ var PromoteMetadata = (function () {
33162
33331
  }
33163
33332
  });
33164
33333
  if (shouldPersist()) {
33165
- agentStorage.write(SCHEMA_GROUP, JSON.stringify(__sg__), undefined, false, true);
33334
+ pluginApi.agentStorage.write(SCHEMA_GROUP, JSON.stringify(__sg__), undefined, false, true);
33166
33335
  }
33167
33336
  return __sg__;
33168
33337
  }
@@ -35198,6 +35367,7 @@ var ActionAutomation = (function () {
35198
35367
  'getElement': getElement,
35199
35368
  'getValue': getValue,
35200
35369
  'injectText': injectText,
35370
+ 'simulateClick': simulateClick,
35201
35371
  'isAutomationInQueue': isAutomationInQueue,
35202
35372
  'popQueue': popQueue,
35203
35373
  'setActive': setActive
@@ -35237,7 +35407,9 @@ var ActionAutomation = (function () {
35237
35407
  if (valueDescriptor && typeof valueDescriptor.set === 'function') {
35238
35408
  valueDescriptor.set.call(element, value); // ensures React ≥ 15.6.1 updates value in state
35239
35409
  }
35240
- element.value = value;
35410
+ else {
35411
+ element.value = value;
35412
+ }
35241
35413
  var inputEvent = new InputEvent('input', { 'bubbles': true, 'data': value[value.length - 1] });
35242
35414
  inputEvent.simulated = true; // for React ≤ 15.6.0
35243
35415
  element.dispatchEvent(inputEvent);
@@ -35245,6 +35417,13 @@ var ActionAutomation = (function () {
35245
35417
  changeEvent.simulated = true; // for React ≤ 15.6.0
35246
35418
  element.dispatchEvent(changeEvent);
35247
35419
  }
35420
+ function simulateClick(element) {
35421
+ element.dispatchEvent(new MouseEvent('pointerdown', { 'bubbles': true, 'cancelable': true }));
35422
+ element.dispatchEvent(new MouseEvent('mousedown', { 'bubbles': true, 'cancelable': true }));
35423
+ element.dispatchEvent(new MouseEvent('pointerup', { 'bubbles': true, 'cancelable': true }));
35424
+ element.dispatchEvent(new MouseEvent('mouseup', { 'bubbles': true, 'cancelable': true }));
35425
+ element.click();
35426
+ }
35248
35427
  function isAutomationInQueue(automation) {
35249
35428
  return !!_.find(this.automationQueue, function (item) {
35250
35429
  return automation.id === item.id;
@@ -35310,9 +35489,7 @@ var ActionAutomation = (function () {
35310
35489
  break;
35311
35490
  }
35312
35491
  case 'autoclick':
35313
- element.dispatchEvent(new MouseEvent('mousedown', { 'bubbles': true, 'cancelable': true }));
35314
- element.dispatchEvent(new MouseEvent('mouseup', { 'bubbles': true, 'cancelable': true }));
35315
- element.click();
35492
+ this.simulateClick(element);
35316
35493
  break;
35317
35494
  }
35318
35495
  this.automationQueue.shift();
@@ -36199,7 +36376,44 @@ var FrustrationEvent = (function () {
36199
36376
  // A guide that show nested inside another element.
36200
36377
  // Multiple embedded guides can show at the same time.
36201
36378
  var buildGuideBehaviors = function (_a) {
36202
- var _ = _a._, store = _a.store;
36379
+ var store = _a.store, globalPendo = _a.globalPendo;
36380
+ var _ = globalPendo._;
36381
+ var handleShow = function () {
36382
+ var guide = this;
36383
+ var guideElement = null;
36384
+ var containerSelector = '[id^="pendo-guide-container"]';
36385
+ var selector = _.get(guide, 'attributes.embedConfig.selector');
36386
+ var method = _.get(guide, 'attributes.embedConfig.method');
36387
+ var element = _.first(globalPendo.Sizzle(selector));
36388
+ var isShown = guide.isShownInThisFrame();
36389
+ if (element && isShown) {
36390
+ var guideElementSelector = "#pendo-guide-container-".concat(_.get(this.getActiveStep(), 'id'));
36391
+ guideElement = !!globalPendo.Sizzle(guideElementSelector, element).length;
36392
+ }
36393
+ if (!isShown && !!element && this.shouldAutoDisplay()) {
36394
+ if (method === 'replace' && !!globalPendo.Sizzle(containerSelector, element).length) {
36395
+ return;
36396
+ }
36397
+ guide.show('embed');
36398
+ }
36399
+ else if (isShown && (!element || !guideElement)) {
36400
+ guide.hide();
36401
+ }
36402
+ };
36403
+ var getActiveStep = function () {
36404
+ var guide = this;
36405
+ if (!guide)
36406
+ return null;
36407
+ return _.find(guide.steps, function (step) {
36408
+ return step.isShown();
36409
+ });
36410
+ };
36411
+ var shouldAutoDisplay = function () {
36412
+ var guide = this;
36413
+ return (guide.shouldShowSnoozedGuide() || guide.shouldRepeatGuide() || _.all(guide.steps, function (step) {
36414
+ return step.shouldRepeat() || (!step.isSnoozed() && step.seenState !== 'dismissed');
36415
+ }));
36416
+ };
36203
36417
  var show = function (reason) {
36204
36418
  var guide = this;
36205
36419
  var firstStep = _.first(guide.steps);
@@ -36224,7 +36438,7 @@ var buildGuideBehaviors = function (_a) {
36224
36438
  return step.isRendered() || step.isLocked();
36225
36439
  });
36226
36440
  };
36227
- return { show: show, isShownInThisFrame: isShownInThisFrame };
36441
+ return { show: show, isShownInThisFrame: isShownInThisFrame, getActiveStep: getActiveStep, handleShow: handleShow, shouldAutoDisplay: shouldAutoDisplay };
36228
36442
  };
36229
36443
  var buildStepBehaviors = function (_a) {
36230
36444
  var pluginApi = _a.pluginApi; _a._;
@@ -36265,7 +36479,7 @@ var EmbeddedGuides = (function () {
36265
36479
  globalPendo = pendo;
36266
36480
  _ = globalPendo._;
36267
36481
  exportPublicEmbeddedGuideApi(pendo);
36268
- embeddedGuideBehaviors = buildGuideBehaviors({ _: _, 'store': pluginApi.store, globalPendo: globalPendo });
36482
+ embeddedGuideBehaviors = buildGuideBehaviors({ 'store': pluginApi.store, globalPendo: globalPendo });
36269
36483
  pluginApi.Events.on('deliverablesLoaded', clearEmbeddedGuides);
36270
36484
  pluginApi.Events.on('guideLoopStopped', hideAllEmbeddedGuides);
36271
36485
  pluginApi.Events.on('guideListChanged', initializeEmbeddedGuides);
@@ -36284,24 +36498,11 @@ var EmbeddedGuides = (function () {
36284
36498
  pluginApi.GuideActivity.removeGuideResolver(getGuideObjectFromEvent);
36285
36499
  if (this.removeResizeEvent)
36286
36500
  this.removeResizeEvent();
36501
+ _oldEmbeddedGuides.length = 0;
36287
36502
  }
36288
36503
  function showAllEmbeddedGuides() {
36289
- var Sizzle = globalPendo.Sizzle;
36290
36504
  _.forEach(embeddedGuides, function (guide) {
36291
- var guideElement = null;
36292
- var selector = _.get(guide, 'attributes.embedConfig.selector');
36293
- var element = _.first(Sizzle(selector));
36294
- var isShown = guide.isShownInThisFrame();
36295
- if (element && isShown) {
36296
- var guideElementSelector = "#pendo-guide-container-".concat(_.get(getActiveStep(guide), 'id'));
36297
- guideElement = _.first(Sizzle(guideElementSelector, element));
36298
- }
36299
- if (!isShown && !!element && shouldAutoDisplay(guide)) {
36300
- guide.show('embed');
36301
- }
36302
- else if (isShown && (!element || !guideElement)) {
36303
- guide.hide();
36304
- }
36505
+ guide.handleShow();
36305
36506
  });
36306
36507
  }
36307
36508
  function hideAllEmbeddedGuides() {
@@ -36325,24 +36526,16 @@ var EmbeddedGuides = (function () {
36325
36526
  })) {
36326
36527
  embeddedGuides.push(guide);
36327
36528
  }
36328
- // special case only a single guide is served when in preview mode
36329
- return pluginApi.store.getters['preview/isInPreviewMode']();
36529
+ return false;
36330
36530
  }
36331
36531
  return true;
36332
36532
  }
36333
36533
  function isEmbedded(guide) {
36334
36534
  return !!(guide && guide.launchMethod && guide.launchMethod === 'embed');
36335
36535
  }
36336
- function getActiveStep(guide) {
36337
- if (!guide)
36338
- return null;
36339
- return _.find(guide.steps, function (step) {
36340
- return step.isShown();
36341
- });
36342
- }
36343
36536
  function redrawEmbeddedGuides() {
36344
36537
  _.forEach(embeddedGuides, function (guide) {
36345
- var step = getActiveStep(guide);
36538
+ var step = guide.getActiveStep();
36346
36539
  if (step && !globalPendo.ignoreResize) {
36347
36540
  step.redraw();
36348
36541
  }
@@ -36377,14 +36570,9 @@ var EmbeddedGuides = (function () {
36377
36570
  return !!step;
36378
36571
  });
36379
36572
  if (!guide || !step)
36380
- return;
36573
+ return null;
36381
36574
  return { guide: guide, step: step };
36382
36575
  }
36383
- function shouldAutoDisplay(guide) {
36384
- return (guide.shouldShowSnoozedGuide() || guide.shouldRepeatGuide() || _.all(guide.steps, function (step) {
36385
- return step.shouldRepeat() || (!step.isSnoozed() && step.seenState !== 'dismissed');
36386
- }));
36387
- }
36388
36576
  function initializeEmbeddedGuides() {
36389
36577
  restoreFromPreviouseGuides();
36390
36578
  pluginApi.guides.registerDisplayableGuides('embeddedGuides', embeddedGuides);
@@ -37538,6 +37726,185 @@ var FormValidation = (function () {
37538
37726
  }
37539
37727
  })();
37540
37728
 
37729
+ var DOMPrompt = /** @class */ (function () {
37730
+ function DOMPrompt(pendo, PluginAPI, inputCssSelector, submitCssSelector, config) {
37731
+ var _this = this;
37732
+ this.listeners = [];
37733
+ this.latestPromptValue = '';
37734
+ this.dom = pendo.dom;
37735
+ this._ = pendo._;
37736
+ this.q = PluginAPI.q;
37737
+ this.inputEl = new this.dom.Element(inputCssSelector);
37738
+ this.submitEl = new this.dom.Element(submitCssSelector);
37739
+ this.inputEl.addEventListener('change', function (evt) {
37740
+ // capture value from copy / paste
37741
+ _this.capturePromptValue();
37742
+ }, true);
37743
+ this.inputEl.addEventListener('keydown', function (evt) {
37744
+ var wasEnterKey = evt.code === 'Enter';
37745
+ _this.capturePromptValue(wasEnterKey);
37746
+ if (wasEnterKey) {
37747
+ _this.waitThenCheckForSubmit().then(function (wasSubmitted) {
37748
+ if (wasSubmitted) {
37749
+ _this.submit(_this.latestPromptValue);
37750
+ }
37751
+ });
37752
+ }
37753
+ }, true);
37754
+ this.submitEl.addEventListener('click', function () {
37755
+ _this.waitThenCheckForSubmit().then(function (wasSubmitted) {
37756
+ if (wasSubmitted) {
37757
+ _this.submit(_this.latestPromptValue);
37758
+ }
37759
+ });
37760
+ }, true);
37761
+ this.promptContainer = new this.dom.Observer();
37762
+ this.promptContainer.addObservers(this.inputEl, this.submitEl);
37763
+ }
37764
+ /*
37765
+ * This is my attempt to create a generic way to handle the lack of a reliable `submit` event to listen
37766
+ * for to know when the user is done with their prompt. This waits 1/10th of a second, yielding
37767
+ * the thread such that in theory the input will get cleared as part of the submit process.
37768
+ */
37769
+ DOMPrompt.prototype.waitThenCheckForSubmit = function () {
37770
+ var _this = this;
37771
+ var deferred = this.q.defer();
37772
+ setTimeout$1(function () {
37773
+ deferred.resolve(_this.getPromptValue() === '');
37774
+ }, 100);
37775
+ return deferred.promise;
37776
+ };
37777
+ DOMPrompt.prototype.submit = function (val) {
37778
+ if (!val)
37779
+ return;
37780
+ this._.each(this.listeners, function (cb) { return cb(val); });
37781
+ this.latestPromptValue = '';
37782
+ };
37783
+ /*
37784
+ * Genernally we want to capture the value from "input" but there can be implementation
37785
+ * dependent scenarios where the input's value has already been cleared by the time we
37786
+ * get the event handler is called. So, in that case, we don't want to throw our saved value out.
37787
+ */
37788
+ DOMPrompt.prototype.capturePromptValue = function (onlyUpdateIfNotEmpty) {
37789
+ if (onlyUpdateIfNotEmpty === void 0) { onlyUpdateIfNotEmpty = false; }
37790
+ var tmp = this.getPromptValue();
37791
+ if (tmp || !onlyUpdateIfNotEmpty) {
37792
+ this.latestPromptValue = tmp;
37793
+ }
37794
+ };
37795
+ DOMPrompt.prototype.getPromptValue = function () {
37796
+ return this.inputEl.getText();
37797
+ };
37798
+ DOMPrompt.prototype.onSubmit = function (callback) {
37799
+ this.listeners.push(callback);
37800
+ };
37801
+ DOMPrompt.prototype.teardown = function () {
37802
+ this.promptContainer.teardown();
37803
+ this.inputEl.teardown();
37804
+ this.submitEl.teardown();
37805
+ };
37806
+ return DOMPrompt;
37807
+ }());
37808
+
37809
+ /*
37810
+ * Prompt Analytics Plugin
37811
+ *
37812
+ * Built-in Plugin adding optional support for monitoring a Prompt like a search box or chat text box.
37813
+ */
37814
+ // XXX Consider making an InputElement and SubmitElement type containing a dom.Element
37815
+ // that would each own their respective scenarios for event listeners.
37816
+ // XXX DOMPrompt would then accept the Input and Submit elements and simply provide
37817
+ // them each a callback for what to do when a `submit` occurs.
37818
+ // This would eventually allow a DOMPrompt to support an array of Input / Submit elements
37819
+ // more cleanly without hairy management code. This is not a likely scenario, so not worrying
37820
+ // about it yet, but calling this out as how it can be supported if needed.
37821
+ var PromptPlugin = /** @class */ (function () {
37822
+ function PromptPlugin() {
37823
+ this.name = 'PromptAnalytics';
37824
+ this.configName = 'aiAgents';
37825
+ this.prompts = [];
37826
+ }
37827
+ PromptPlugin.prototype.initialize = function (pendo, PluginAPI) {
37828
+ var _this = this;
37829
+ this.pendo = pendo;
37830
+ this.api = PluginAPI;
37831
+ this._ = this.pendo._;
37832
+ // register config schema
37833
+ this.api.ConfigReader.addOption(this.configName, ['pendoconfig', 'snippet']);
37834
+ this.loadConfig(this.configName)
37835
+ .then(function (config) { return _this.onConfigLoaded(config); })['catch'](function () { });
37836
+ };
37837
+ // a-fake-sync method - puts the api expectation of a promise in place now
37838
+ // making it easier in the future if the config looking becomes a network call
37839
+ PromptPlugin.prototype.loadConfig = function (configName) {
37840
+ var _a = this.api, q = _a.q, ConfigReader = _a.ConfigReader;
37841
+ var deferred = q.defer();
37842
+ var configObj = ConfigReader.get(configName);
37843
+ deferred.resolve(configObj);
37844
+ return deferred.promise;
37845
+ };
37846
+ PromptPlugin.prototype.onConfigLoaded = function (aiAgents) {
37847
+ var _this = this;
37848
+ if (aiAgents === void 0) { aiAgents = []; }
37849
+ if (!aiAgents || !this._.isArray(aiAgents) || aiAgents.length === 0) {
37850
+ return;
37851
+ }
37852
+ this._.each(aiAgents, function (aiAgent) {
37853
+ _this.observePrompt(aiAgent);
37854
+ });
37855
+ };
37856
+ PromptPlugin.prototype.observePrompt = function (config) {
37857
+ var _this = this;
37858
+ var id = config.id; config.containerCssSelector; var cssSelectors = config.cssSelectors, privacyFilters = config.privacyFilters;
37859
+ this.setFilters(privacyFilters);
37860
+ this.agentId = id;
37861
+ var inputCssSelector, submitCssSelector;
37862
+ inputCssSelector = this.parseCssSelector('input', cssSelectors);
37863
+ submitCssSelector = this.parseCssSelector('submit', cssSelectors);
37864
+ var prompt = new DOMPrompt(this.pendo, this.api, inputCssSelector, submitCssSelector);
37865
+ prompt.onSubmit(function (value) {
37866
+ _this.sendEvent(value);
37867
+ });
37868
+ this.prompts.push(prompt);
37869
+ };
37870
+ PromptPlugin.prototype.parseCssSelector = function (type, configs) {
37871
+ return this._.find(configs, function (target) { return target.type === type; }).cssSelector;
37872
+ };
37873
+ PromptPlugin.prototype.setFilters = function (candidateFilter) {
37874
+ if (!candidateFilter) {
37875
+ this.privacyFilters = null;
37876
+ return null;
37877
+ }
37878
+ try {
37879
+ this.privacyFilters = new RegExp(candidateFilter, 'gmi');
37880
+ }
37881
+ catch (e) {
37882
+ this.privacyFilters = null;
37883
+ this.api.log.error(e);
37884
+ }
37885
+ return this.privacyFilters;
37886
+ };
37887
+ PromptPlugin.prototype.sendEvent = function (promptValue) {
37888
+ var prompt = this.applyPrivacyFilter(promptValue);
37889
+ this.api.analytics.collectEvent('prompt', {
37890
+ 'prompt': prompt,
37891
+ 'agentId': this.agentId,
37892
+ 'promptType': 'request',
37893
+ 'privacyFilterApplied': promptValue !== prompt
37894
+ });
37895
+ };
37896
+ PromptPlugin.prototype.applyPrivacyFilter = function (candidateValue) {
37897
+ if (!this.privacyFilters || !this._.isRegExp(this.privacyFilters))
37898
+ return candidateValue;
37899
+ return candidateValue.replace(this.privacyFilters, 'redacted');
37900
+ };
37901
+ PromptPlugin.prototype.teardown = function () {
37902
+ this._.each(this.prompts, function (prompt) { return prompt.teardown(); });
37903
+ };
37904
+ return PromptPlugin;
37905
+ }());
37906
+ var PromptAnalytics = new PromptPlugin();
37907
+
37541
37908
  function registerBuiltInPlugins() {
37542
37909
  registerPlugin(IFrameMonitor);
37543
37910
  registerPlugin(DOMActivation);
@@ -37555,6 +37922,7 @@ function registerBuiltInPlugins() {
37555
37922
  registerPlugin(SegmentFlags$1);
37556
37923
  registerPlugin(WebAnalytics$1);
37557
37924
  registerPlugin(FormValidation);
37925
+ registerPlugin(PromptAnalytics);
37558
37926
  }
37559
37927
 
37560
37928
  /*
@@ -37712,8 +38080,6 @@ function getDefaultExportFromCjs (x) {
37712
38080
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
37713
38081
  }
37714
38082
 
37715
- /* eslint-disable agent-eslint-rules/no-window-pendo */
37716
-
37717
38083
  var substitutionRegex = '\\{(?:\\s?)([^.\\s]?visitor|account|parentAccount)\\.([^|\\s/]*)(?:\\s?\\|\\s?([^}]+|[\\/s]+))?(?:\\s?\\/\\s?){1}\\}';
37718
38084
  var skipStepString = '{skipStep:* *(auto|\\d+)\\/}';
37719
38085
  var goToMiddleString = '(?!0)(\\d+)';
@@ -37730,9 +38096,9 @@ function lookupGuideButtons(domJson, buttons) {
37730
38096
  }
37731
38097
  return buttons;
37732
38098
  }
37733
- function removeMarkdownSyntax(element, textToReplace, replacementText) {
38099
+ function removeMarkdownSyntax(element, textToReplace, replacementText, pendo) {
37734
38100
  var _a;
37735
- if (window.pendo.dom(element).hasClass('_pendo-nps-open-text-poll-question')) {
38101
+ if (pendo.dom(element).hasClass('_pendo-nps-open-text-poll-question')) {
37736
38102
  // This prevents us from removing the message for the conditionally rendered elements
37737
38103
  element.innerHTML = (_a = element.innerHTML) === null || _a === void 0 ? void 0 : _a.replace(textToReplace, replacementText);
37738
38104
  }
@@ -37745,10 +38111,10 @@ function removeMarkdownSyntax(element, textToReplace, replacementText) {
37745
38111
  }
37746
38112
  if (element.children.length > 0)
37747
38113
  return;
37748
- if (window.pendo.dom(element).hasClass('_pendo-simple-text') ||
37749
- window.pendo.dom(element).hasClass('_pendo-text-plain') ||
37750
- window.pendo.dom(element).hasClass('_pendo-text-list-item') ||
37751
- window.pendo.dom(element).hasClass('_pendo-text-link')) {
38114
+ if (pendo.dom(element).hasClass('_pendo-simple-text') ||
38115
+ pendo.dom(element).hasClass('_pendo-text-plain') ||
38116
+ pendo.dom(element).hasClass('_pendo-text-list-item') ||
38117
+ pendo.dom(element).hasClass('_pendo-text-link')) {
37752
38118
  element.textContent = element.textContent.replace(textToReplace, replacementText);
37753
38119
  }
37754
38120
  }
@@ -37761,38 +38127,37 @@ var guideMarkdownUtil = {
37761
38127
  };
37762
38128
 
37763
38129
  // Does not support submit and go to
37764
- /* eslint-disable agent-eslint-rules/no-window-pendo */
37765
38130
  var goToRegex = new RegExp(guideMarkdownUtil.goToString);
37766
38131
  var PollBranching = {
37767
38132
  'name': 'PollBranching',
37768
- 'script': function (step, guide) {
38133
+ 'script': function (step, guide, pendo) {
37769
38134
  var isAdvanceIntercepted = false;
37770
- var branchingQuestions = initialBranchingSetup(step);
38135
+ var branchingQuestions = initialBranchingSetup(step, pendo);
37771
38136
  if (branchingQuestions) {
37772
38137
  // If there are too many branching questions saved, exit and run the guide normally.
37773
- if (window.pendo._.size(branchingQuestions) > 1)
38138
+ if (pendo._.size(branchingQuestions) > 1)
37774
38139
  return;
37775
38140
  this.on('beforeAdvance', function (evt) {
37776
38141
  var noResponseSelected = step.guideElement.find('[branching] .pendo-radio:checked').length === 0;
37777
38142
  var responseLabel = step.guideElement.find('[branching] .pendo-radio:checked + label')[0];
37778
38143
  var noGotoLabel;
37779
38144
  if (responseLabel) {
37780
- noGotoLabel = window.pendo._.isNull(responseLabel.getAttribute('goToStep'));
38145
+ noGotoLabel = pendo._.isNull(responseLabel.getAttribute('goToStep'));
37781
38146
  }
37782
38147
  if (isAdvanceIntercepted || noResponseSelected || noGotoLabel)
37783
38148
  return;
37784
38149
  isAdvanceIntercepted = true;
37785
- branchingGoToStep(evt, step, guide);
38150
+ branchingGoToStep(evt, step, guide, pendo);
37786
38151
  });
37787
38152
  }
37788
38153
  },
37789
- 'test': function (step) {
38154
+ 'test': function (step, guide, pendo) {
37790
38155
  var _a;
37791
38156
  var branchingQuestions = (_a = step.guideElement) === null || _a === void 0 ? void 0 : _a.find('._pendo-multi-choice-poll-question:contains("{branching/}")');
37792
- return !window.pendo._.isUndefined(branchingQuestions) && window.pendo._.size(branchingQuestions);
38157
+ return !pendo._.isUndefined(branchingQuestions) && pendo._.size(branchingQuestions);
37793
38158
  },
37794
- 'designerListener': function () {
37795
- var target = window.pendo.dom.getBody();
38159
+ 'designerListener': function (pendo) {
38160
+ var target = pendo.dom.getBody();
37796
38161
  var config = {
37797
38162
  'attributeFilter': ['data-layout'],
37798
38163
  'attributes': true,
@@ -37805,34 +38170,34 @@ var PollBranching = {
37805
38170
  function applyBranchingIndicators(mutations) {
37806
38171
  mutations.forEach(function (mutation) {
37807
38172
  var _a;
37808
- var nodeHasQuerySelector = window.pendo._.isFunction((_a = mutation.addedNodes[0]) === null || _a === void 0 ? void 0 : _a.querySelector);
38173
+ var nodeHasQuerySelector = pendo._.isFunction((_a = mutation.addedNodes[0]) === null || _a === void 0 ? void 0 : _a.querySelector);
37809
38174
  if (mutation.addedNodes.length && nodeHasQuerySelector) {
37810
38175
  if (mutation.addedNodes[0].querySelector('._pendo-multi-choice-poll-select-border')) {
37811
- if (window.pendo._.size(window.pendo.dom('._pendo-multi-choice-poll-question:contains("{branching/}")'))) {
37812
- window.pendo
38176
+ if (pendo._.size(pendo.dom('._pendo-multi-choice-poll-question:contains("{branching/}")'))) {
38177
+ pendo
37813
38178
  .dom('._pendo-multi-choice-poll-question:contains("{branching/}")')
37814
38179
  .each(function (question, index) {
37815
- window.pendo._.each(window.pendo.dom("#".concat(question.id, " *")), function (element) {
37816
- guideMarkdownUtil.removeMarkdownSyntax(element, '{branching/}', '');
38180
+ pendo._.each(pendo.dom("#".concat(question.id, " *")), function (element) {
38181
+ guideMarkdownUtil.removeMarkdownSyntax(element, '{branching/}', '', pendo);
37817
38182
  });
37818
- window.pendo
38183
+ pendo
37819
38184
  .dom("#".concat(question.id, " p"))
37820
38185
  .css({ 'display': 'inline-block !important' })
37821
38186
  .append(branchingIcon('#999', '20px'))
37822
38187
  .attr({ 'title': 'Custom Branching Added' });
37823
38188
  var dataPendoPollId = question.getAttribute('data-pendo-poll-id');
37824
- if (window.pendo.dom("._pendo-multi-choice-poll-question[data-pendo-poll-id=".concat(dataPendoPollId, "]"))[0]) {
37825
- window.pendo
38189
+ if (pendo.dom("._pendo-multi-choice-poll-question[data-pendo-poll-id=".concat(dataPendoPollId, "]"))[0]) {
38190
+ pendo
37826
38191
  .dom("._pendo-multi-choice-poll-question[data-pendo-poll-id=".concat(dataPendoPollId, "]"))[0]
37827
38192
  .textContent.trim();
37828
38193
  }
37829
- var pollLabels = window.pendo.dom("label[for*=".concat(dataPendoPollId, "]"));
37830
- if (window.pendo._.size(pollLabels)) {
37831
- window.pendo._.forEach(pollLabels, function (label) {
38194
+ var pollLabels = pendo.dom("label[for*=".concat(dataPendoPollId, "]"));
38195
+ if (pendo._.size(pollLabels)) {
38196
+ pendo._.forEach(pollLabels, function (label) {
37832
38197
  if (goToRegex.test(label.textContent)) {
37833
38198
  var labelTitle = goToRegex.exec(label.textContent)[2];
37834
- guideMarkdownUtil.removeMarkdownSyntax(label, goToRegex, '');
37835
- window.pendo
38199
+ guideMarkdownUtil.removeMarkdownSyntax(label, goToRegex, '', pendo);
38200
+ pendo
37836
38201
  .dom(label)
37837
38202
  .append(branchingIcon('#999', '14px'))
37838
38203
  .attr({ 'title': "Branching to step ".concat(labelTitle) });
@@ -37840,11 +38205,11 @@ var PollBranching = {
37840
38205
  });
37841
38206
  }
37842
38207
  if (index > 0) {
37843
- window.pendo
38208
+ pendo
37844
38209
  .dom(question)
37845
38210
  .append(branchingErrorHTML(question.dataset.pendoPollId));
37846
- window.pendo.dom("#".concat(question.id, " #pendo-ps-branching-svg")).remove();
37847
- window.pendo
38211
+ pendo.dom("#".concat(question.id, " #pendo-ps-branching-svg")).remove();
38212
+ pendo
37848
38213
  .dom("#".concat(question.id, " p"))
37849
38214
  .css({ 'display': 'inline-block !important' })
37850
38215
  .append(branchingIcon('red', '20px'))
@@ -37864,31 +38229,31 @@ var PollBranching = {
37864
38229
  }
37865
38230
  }
37866
38231
  };
37867
- function initialBranchingSetup(step) {
38232
+ function initialBranchingSetup(step, pendo) {
37868
38233
  var questions = step.guideElement.find('._pendo-multi-choice-poll-question:contains("{branching/}")');
37869
- window.pendo._.forEach(questions, function (question) {
38234
+ pendo._.forEach(questions, function (question) {
37870
38235
  var dataPendoPollId = question.getAttribute('data-pendo-poll-id');
37871
- window.pendo._.each(step.guideElement.find("#".concat(question.id, " *")), function (element) {
37872
- guideMarkdownUtil.removeMarkdownSyntax(element, '{branching/}', '');
38236
+ pendo._.each(step.guideElement.find("#".concat(question.id, " *")), function (element) {
38237
+ guideMarkdownUtil.removeMarkdownSyntax(element, '{branching/}', '', pendo);
37873
38238
  });
37874
38239
  var pollLabels = step.guideElement.find("label[for*=".concat(dataPendoPollId, "]"));
37875
- window.pendo._.forEach(pollLabels, function (label) {
37876
- if (window.pendo._.isNull(goToRegex.exec(label.textContent))) {
38240
+ pendo._.forEach(pollLabels, function (label) {
38241
+ if (pendo._.isNull(goToRegex.exec(label.textContent))) {
37877
38242
  return;
37878
38243
  }
37879
38244
  var gotoSubstring = goToRegex.exec(label.textContent)[1];
37880
38245
  var gotoIndex = goToRegex.exec(label.textContent)[2];
37881
38246
  label.setAttribute('goToStep', gotoIndex);
37882
- guideMarkdownUtil.removeMarkdownSyntax(label, gotoSubstring, '');
38247
+ guideMarkdownUtil.removeMarkdownSyntax(label, gotoSubstring, '', pendo);
37883
38248
  });
37884
38249
  var pollChoiceContainer = step.guideElement.find("[data-pendo-poll-id=".concat(dataPendoPollId, "]._pendo-multi-choice-poll-select-border"));
37885
- if (pollChoiceContainer) {
38250
+ if (pollChoiceContainer && pollChoiceContainer.length) {
37886
38251
  pollChoiceContainer[0].setAttribute('branching', '');
37887
38252
  }
37888
38253
  });
37889
38254
  return questions;
37890
38255
  }
37891
- function branchingGoToStep(event, step, guide) {
38256
+ function branchingGoToStep(event, step, guide, pendo) {
37892
38257
  var _a;
37893
38258
  var checkedPollInputId = (_a = step.guideElement.find('[branching] input.pendo-radio[data-pendo-poll-id]:checked')[0]) === null || _a === void 0 ? void 0 : _a.id;
37894
38259
  var checkedPollLabel = step.guideElement.find("label[for=\"".concat(checkedPollInputId, "\"]"))[0];
@@ -37899,30 +38264,29 @@ function branchingGoToStep(event, step, guide) {
37899
38264
  var destinationObject = {
37900
38265
  'destinationStepId': guide.steps[pollStepIndex].id
37901
38266
  };
37902
- window.pendo.goToStep(destinationObject);
38267
+ pendo.goToStep(destinationObject);
37903
38268
  event.cancel = true;
37904
38269
  }
37905
38270
 
37906
- /* eslint-disable agent-eslint-rules/no-window-pendo */
37907
38271
  var containerSelector = '[id^="pendo-guide-container"]';
37908
38272
  var MetadataSubstitution = {
37909
38273
  'name': 'MetadataSubstitution',
37910
- 'script': function (step, guide) {
37911
- var placeholderData = findSubstitutableElements();
38274
+ 'script': function (step, guide, pendo) {
38275
+ var placeholderData = findSubstitutableElements(pendo);
37912
38276
  if (step.domJson) {
37913
- findSubstitutableUrlsInJson(step.domJson, placeholderData);
38277
+ findSubstitutableUrlsInJson(step.domJson, placeholderData, pendo);
37914
38278
  }
37915
- if (window.pendo._.size(placeholderData)) {
37916
- window.pendo._.each(placeholderData, function (placeholder) {
37917
- processPlaceholder(placeholder);
38279
+ if (pendo._.size(placeholderData)) {
38280
+ pendo._.each(placeholderData, function (placeholder) {
38281
+ processPlaceholder(placeholder, pendo);
37918
38282
  });
37919
38283
  var containerId = "pendo-g-".concat(step.id);
37920
38284
  var context_1 = step.guideElement;
37921
- updateGuideContainer(containerId, context_1);
38285
+ updateGuideContainer(containerId, context_1, pendo);
37922
38286
  }
37923
38287
  },
37924
- 'designerListener': function () {
37925
- var target = window.pendo.dom.getBody();
38288
+ 'designerListener': function (pendo) {
38289
+ var target = pendo.dom.getBody();
37926
38290
  var config = {
37927
38291
  'attributeFilter': ['data-layout'],
37928
38292
  'attributes': true,
@@ -37937,23 +38301,23 @@ var MetadataSubstitution = {
37937
38301
  var _a;
37938
38302
  if (mutation.addedNodes.length) {
37939
38303
  if (document.querySelector(containerSelector)) {
37940
- var placeholderData = findSubstitutableElements();
37941
- var step = (_a = window.pendo.designerv2.currentlyPreviewedGuide) === null || _a === void 0 ? void 0 : _a.steps[0];
38304
+ var placeholderData = findSubstitutableElements(pendo);
38305
+ var step = (_a = pendo.designerv2.currentlyPreviewedGuide) === null || _a === void 0 ? void 0 : _a.steps[0];
37942
38306
  if (!step)
37943
38307
  return;
37944
38308
  var pendoBlocks = step.buildingBlocks;
37945
- if (!window.pendo._.isUndefined(pendoBlocks)) {
37946
- findSubstitutableUrlsInJson(pendoBlocks, placeholderData);
38309
+ if (!pendo._.isUndefined(pendoBlocks)) {
38310
+ findSubstitutableUrlsInJson(pendoBlocks, placeholderData, pendo);
37947
38311
  }
37948
- if (window.pendo._.size(placeholderData)) {
37949
- window.pendo._.each(placeholderData, function (placeholder) {
37950
- if (window.pendo._.isUndefined(placeholder))
38312
+ if (pendo._.size(placeholderData)) {
38313
+ pendo._.each(placeholderData, function (placeholder) {
38314
+ if (pendo._.isUndefined(placeholder))
37951
38315
  return;
37952
- processPlaceholder(placeholder);
38316
+ processPlaceholder(placeholder, pendo);
37953
38317
  });
37954
38318
  var containerId = "pendo-g-".concat(step.id);
37955
38319
  var context_2 = step.guideElement;
37956
- updateGuideContainer(containerId, context_2);
38320
+ updateGuideContainer(containerId, context_2, pendo);
37957
38321
  }
37958
38322
  }
37959
38323
  }
@@ -37961,13 +38325,13 @@ var MetadataSubstitution = {
37961
38325
  }
37962
38326
  }
37963
38327
  };
37964
- function processPlaceholder(placeholder) {
38328
+ function processPlaceholder(placeholder, pendo) {
37965
38329
  var match;
37966
38330
  var data = placeholder.data, target = placeholder.target;
37967
38331
  var subRegex = new RegExp(guideMarkdownUtil.substitutionRegex);
37968
38332
  while ((match = matchPlaceholder(placeholder, subRegex))) {
37969
38333
  var matched = subRegex.exec(match);
37970
- var mdValue = getSubstitueValue(matched);
38334
+ var mdValue = getSubstituteValue(matched, pendo);
37971
38335
  substituteMetadataByTarget(data, target, mdValue, matched);
37972
38336
  }
37973
38337
  }
@@ -37979,16 +38343,16 @@ function matchPlaceholder(placeholder, regex) {
37979
38343
  return decodeURI(placeholder.data[placeholder.target]).match(regex);
37980
38344
  }
37981
38345
  }
37982
- function getSubstitueValue(match) {
37983
- if (window.pendo._.isUndefined(match[1]) || window.pendo._.isUndefined(match[2]))
38346
+ function getSubstituteValue(match, pendo) {
38347
+ if (pendo._.isUndefined(match[1]) || pendo._.isUndefined(match[2]))
37984
38348
  return;
37985
38349
  var type = match[1];
37986
38350
  var property = match[2];
37987
38351
  var defaultValue = match[3];
37988
- if (window.pendo._.isUndefined(type) || window.pendo._.isUndefined(property)) {
38352
+ if (pendo._.isUndefined(type) || pendo._.isUndefined(property)) {
37989
38353
  return;
37990
38354
  }
37991
- var mdValue = window.pendo._.get(window.pendo.getSerializedMetadata(), "".concat(type, ".").concat(property)) || defaultValue || '';
38355
+ var mdValue = pendo._.get(pendo.getSerializedMetadata(), "".concat(type, ".").concat(property)) || defaultValue || '';
37992
38356
  return mdValue;
37993
38357
  }
37994
38358
  function substituteMetadataByTarget(data, target, mdValue, matched) {
@@ -38001,14 +38365,14 @@ function substituteMetadataByTarget(data, target, mdValue, matched) {
38001
38365
  .replace(matched[0], mdValue);
38002
38366
  }
38003
38367
  }
38004
- function updateGuideContainer(containerId, context) {
38005
- if (window.pendo.designer && !window.pendo._.size(window.pendo.dom('#pendo-ps-substitution-icon'))) {
38006
- window.pendo.dom(containerSelector).append(substitutionIcon('#999', '30px'));
38368
+ function updateGuideContainer(containerId, context, pendo) {
38369
+ if (pendo.designer && !pendo._.size(pendo.dom('#pendo-ps-substitution-icon'))) {
38370
+ pendo.dom(containerSelector).append(substitutionIcon('#999', '30px'));
38007
38371
  }
38008
- window.pendo.flexElement(window.pendo.dom(containerSelector));
38009
- window.pendo.BuildingBlocks.BuildingBlockGuides.recalculateGuideHeight(containerId, context);
38372
+ pendo.flexElement(pendo.dom(containerSelector));
38373
+ pendo.BuildingBlocks.BuildingBlockGuides.recalculateGuideHeight(containerId, context);
38010
38374
  }
38011
- function findSubstitutableUrlsInJson(originalData, placeholderData) {
38375
+ function findSubstitutableUrlsInJson(originalData, placeholderData, pendo) {
38012
38376
  if (placeholderData === void 0) { placeholderData = []; }
38013
38377
  var subRegex = new RegExp(guideMarkdownUtil.substitutionRegex);
38014
38378
  if ((originalData.name === 'url' || originalData.name === 'href') && originalData.value) {
@@ -38020,35 +38384,35 @@ function findSubstitutableUrlsInJson(originalData, placeholderData) {
38020
38384
  }
38021
38385
  }
38022
38386
  if (originalData.properties && originalData.id === 'href_link_block') {
38023
- window.pendo._.each(originalData.properties, function (prop) {
38024
- findSubstitutableUrlsInJson(prop, placeholderData);
38387
+ pendo._.each(originalData.properties, function (prop) {
38388
+ findSubstitutableUrlsInJson(prop, placeholderData, pendo);
38025
38389
  });
38026
38390
  }
38027
38391
  if (originalData.views) {
38028
- window.pendo._.each(originalData.views, function (view) {
38029
- findSubstitutableUrlsInJson(view, placeholderData);
38392
+ pendo._.each(originalData.views, function (view) {
38393
+ findSubstitutableUrlsInJson(view, placeholderData, pendo);
38030
38394
  });
38031
38395
  }
38032
38396
  if (originalData.parameters) {
38033
- window.pendo._.each(originalData.parameters, function (param) {
38034
- findSubstitutableUrlsInJson(param, placeholderData);
38397
+ pendo._.each(originalData.parameters, function (param) {
38398
+ findSubstitutableUrlsInJson(param, placeholderData, pendo);
38035
38399
  });
38036
38400
  }
38037
38401
  if (originalData.actions) {
38038
- window.pendo._.each(originalData.actions, function (action) {
38039
- findSubstitutableUrlsInJson(action, placeholderData);
38402
+ pendo._.each(originalData.actions, function (action) {
38403
+ findSubstitutableUrlsInJson(action, placeholderData, pendo);
38040
38404
  });
38041
38405
  }
38042
38406
  if (originalData.children) {
38043
- window.pendo._.each(originalData.children, function (child) {
38044
- findSubstitutableUrlsInJson(child, placeholderData);
38407
+ pendo._.each(originalData.children, function (child) {
38408
+ findSubstitutableUrlsInJson(child, placeholderData, pendo);
38045
38409
  });
38046
38410
  }
38047
38411
  return placeholderData;
38048
38412
  }
38049
- function findSubstitutableElements() {
38050
- var elements = window.pendo.dom("".concat(containerSelector, " *:not(.pendo-inline-ui)"));
38051
- return window.pendo._.chain(elements)
38413
+ function findSubstitutableElements(pendo) {
38414
+ var elements = pendo.dom("".concat(containerSelector, " *:not(.pendo-inline-ui)"));
38415
+ return pendo._.chain(elements)
38052
38416
  .filter(function (placeholder) {
38053
38417
  var subRegex = new RegExp(guideMarkdownUtil.substitutionRegex);
38054
38418
  if (placeholder.localName === 'a') {
@@ -38062,16 +38426,16 @@ function findSubstitutableElements() {
38062
38426
  }
38063
38427
  if (placeholder.children.length > 0)
38064
38428
  return;
38065
- if (window.pendo.dom(placeholder).hasClass('_pendo-simple-text') ||
38066
- window.pendo.dom(placeholder).hasClass('_pendo-text-plain') ||
38067
- window.pendo.dom(placeholder).hasClass('_pendo-text-list-item') ||
38068
- window.pendo.dom(placeholder).hasClass('_pendo-text-link')) {
38429
+ if (pendo.dom(placeholder).hasClass('_pendo-simple-text') ||
38430
+ pendo.dom(placeholder).hasClass('_pendo-text-plain') ||
38431
+ pendo.dom(placeholder).hasClass('_pendo-text-list-item') ||
38432
+ pendo.dom(placeholder).hasClass('_pendo-text-link')) {
38069
38433
  return subRegex.test(placeholder.textContent);
38070
38434
  }
38071
38435
  return subRegex.test(placeholder.textContent) || subRegex.test(decodeURI(placeholder.href));
38072
38436
  })
38073
38437
  .map(function (placeholder) {
38074
- if (placeholder.localName === 'a' && window.pendo.dom(placeholder).hasClass('_pendo-text-link')) {
38438
+ if (placeholder.localName === 'a' && pendo.dom(placeholder).hasClass('_pendo-text-link')) {
38075
38439
  return [{
38076
38440
  'data': placeholder,
38077
38441
  'target': 'href'
@@ -38092,10 +38456,10 @@ function findSubstitutableElements() {
38092
38456
  'target': 'textContent'
38093
38457
  };
38094
38458
  }
38095
- if (window.pendo.dom(placeholder).hasClass('_pendo-simple-text') ||
38096
- window.pendo.dom(placeholder).hasClass('_pendo-text-plain') ||
38097
- window.pendo.dom(placeholder).hasClass('_pendo-text-list-item') ||
38098
- window.pendo.dom(placeholder).hasClass('_pendo-text-link')) {
38459
+ if (pendo.dom(placeholder).hasClass('_pendo-simple-text') ||
38460
+ pendo.dom(placeholder).hasClass('_pendo-text-plain') ||
38461
+ pendo.dom(placeholder).hasClass('_pendo-text-list-item') ||
38462
+ pendo.dom(placeholder).hasClass('_pendo-text-link')) {
38099
38463
  return {
38100
38464
  'data': placeholder,
38101
38465
  'target': 'textContent'
@@ -38109,11 +38473,10 @@ function substitutionIcon(color, size) {
38109
38473
  return ("<div title=\"Metadata Substitution added\">\n <svg id=\"pendo-ps-substitution-icon\" viewBox=\"0 0 24 24\"\n preserveAspectRatio=\"xMidYMid meet\"\n height=".concat(size, " width=").concat(size, " title=\"Metadata Substitution\"\n style=\"bottom:5px; right:10px; position: absolute;\"\n fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" stroke=\"").concat(color, "\"\n transform=\"matrix(1, 0, 0, 1, 0, 0)rotate(0)\">\n <g stroke-width=\"0\"></g>\n <g stroke-linecap=\"round\" stroke-linejoin=\"round\"\n stroke=\"").concat(color, "\" stroke-width=\"0.528\"></g>\n <g><path fill-rule=\"evenodd\" clip-rule=\"evenodd\"\n d=\"M5 5.5C4.17157 5.5 3.5 6.17157 3.5 7V10C3.5 10.8284\n 4.17157 11.5 5 11.5H8C8.82843 11.5 9.5 10.8284 9.5\n 10V9H17V11C17 11.2761 17.2239 11.5 17.5 11.5C17.7761\n 11.5 18 11.2761 18 11V8.5C18 8.22386 17.7761 8 17.5\n 8H9.5V7C9.5 6.17157 8.82843 5.5 8 5.5H5ZM8.5 7C8.5\n 6.72386 8.27614 6.5 8 6.5H5C4.72386 6.5 4.5 6.72386\n 4.5 7V10C4.5 10.2761 4.72386 10.5 5 10.5H8C8.27614\n 10.5 8.5 10.2761 8.5 10V7Z\" fill=\"").concat(color, "\"></path>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\"\n d=\"M7 13C7 12.7239 6.77614 12.5 6.5 12.5C6.22386 12.5\n 6 12.7239 6 13V15.5C6 15.7761 6.22386 16 6.5\n 16H14.5V17C14.5 17.8284 15.1716 18.5 16 18.5H19C19.8284\n 18.5 20.5 17.8284 20.5 17V14C20.5 13.1716 19.8284 12.5\n 19 12.5H16C15.1716 12.5 14.5 13.1716 14.5\n 14V15H7V13ZM15.5 17C15.5 17.2761 15.7239 17.5 16\n 17.5H19C19.2761 17.5 19.5 17.2761 19.5 17V14C19.5\n 13.7239 19.2761 13.5 19 13.5H16C15.7239 13.5 15.5\n 13.7239 15.5 14V17Z\" fill=\"").concat(color, "\"></path> </g></svg></div>"));
38110
38474
  }
38111
38475
 
38112
- /* eslint-disable agent-eslint-rules/no-window-pendo */
38113
38476
  var requiredElement = '<span class="_pendo-required-indicator" style="color:red; font-style:italic;" title="Question is required"> *</span>';
38114
38477
  var RequiredQuestions = {
38115
38478
  'name': 'RequiredQuestions',
38116
- 'script': function (step, guide) {
38479
+ 'script': function (step, guide, pendo) {
38117
38480
  var _a;
38118
38481
  var requiredPollIds = [];
38119
38482
  var submitButtons = (_a = guideMarkdownUtil.lookupGuideButtons(step.domJson)) === null || _a === void 0 ? void 0 : _a.filter(function (button) {
@@ -38121,7 +38484,7 @@ var RequiredQuestions = {
38121
38484
  });
38122
38485
  var requiredQuestions = processRequiredQuestions();
38123
38486
  if (requiredQuestions) {
38124
- window.pendo._.forEach(requiredQuestions, function (question) {
38487
+ pendo._.forEach(requiredQuestions, function (question) {
38125
38488
  if (question.classList.contains('_pendo-open-text-poll-question')) {
38126
38489
  var pollId = question.dataset.pendoPollId;
38127
38490
  step.attachEvent(step.guideElement.find("[data-pendo-poll-id=".concat(pollId, "]._pendo-open-text-poll-input"))[0], 'input', function () {
@@ -38138,19 +38501,19 @@ var RequiredQuestions = {
38138
38501
  function processRequiredQuestions() {
38139
38502
  var questions = step.guideElement.find('[class*=-poll-question]:contains({required/})');
38140
38503
  if (questions) {
38141
- window.pendo._.forEach(questions, function (question) {
38504
+ pendo._.forEach(questions, function (question) {
38142
38505
  var dataPendoPollId = question.getAttribute('data-pendo-poll-id');
38143
38506
  requiredPollIds.push(dataPendoPollId);
38144
- window.pendo._.each(step.guideElement.find("#".concat(question.id, " *, #").concat(question.id)), function (element) {
38145
- guideMarkdownUtil.removeMarkdownSyntax(element, '{required/}', '');
38507
+ pendo._.each(step.guideElement.find("#".concat(question.id, " *, #").concat(question.id)), function (element) {
38508
+ guideMarkdownUtil.removeMarkdownSyntax(element, '{required/}', '', pendo);
38146
38509
  });
38147
38510
  step.guideElement.find("#".concat(question.id, " p")).append(requiredElement);
38148
38511
  });
38149
38512
  }
38150
- if (window.pendo._.size(requiredPollIds)) {
38513
+ if (pendo._.size(requiredPollIds)) {
38151
38514
  var disabledButtonStyles = "<style type=text/css\n id=_pendo-guide-required-disabled>\n ._pendo-button:disabled, ._pendo-buttons[disabled] {\n border: 1px solid #999999 !important;\n background-color: #cccccc !important;\n color: #666666 !important;\n pointer-events: none !important;\n }\n </style>";
38152
- if (window.pendo.dom('#_pendo-guide-required-disabled').length === 0) {
38153
- window.pendo.dom('head').append(disabledButtonStyles);
38515
+ if (pendo.dom('#_pendo-guide-required-disabled').length === 0) {
38516
+ pendo.dom('head').append(disabledButtonStyles);
38154
38517
  }
38155
38518
  disableEligibleButtons(submitButtons);
38156
38519
  }
@@ -38161,14 +38524,14 @@ var RequiredQuestions = {
38161
38524
  return;
38162
38525
  var allRequiredComplete = true;
38163
38526
  var responses = [];
38164
- responses = responses.concat(window.pendo._.map(questions, function (question) {
38527
+ responses = responses.concat(pendo._.map(questions, function (question) {
38165
38528
  var pollId = question.getAttribute('data-pendo-poll-id');
38166
38529
  var input = step.guideElement.find("\n [data-pendo-poll-id=".concat(pollId, "] textarea,\n [data-pendo-poll-id=").concat(pollId, "] input:text,\n [data-pendo-poll-id=").concat(pollId, "] select,\n [data-pendo-poll-id=").concat(pollId, "] input:radio:checked"));
38167
38530
  if (input && input.length && input[0].value) {
38168
38531
  return input[0].value;
38169
38532
  }
38170
38533
  }));
38171
- if (responses.includes(undefined) || window.pendo._.isEmpty(responses)) {
38534
+ if (responses.includes(undefined) || pendo._.isEmpty(responses)) {
38172
38535
  allRequiredComplete = false;
38173
38536
  }
38174
38537
  if (allRequiredComplete) {
@@ -38195,13 +38558,13 @@ var RequiredQuestions = {
38195
38558
  });
38196
38559
  }
38197
38560
  },
38198
- 'test': function (step) {
38561
+ 'test': function (step, guide, pendo) {
38199
38562
  var _a;
38200
38563
  var requiredQuestions = (_a = step.guideElement) === null || _a === void 0 ? void 0 : _a.find('[class*=-poll-question]:contains({required/})');
38201
- return !window.pendo._.isUndefined(requiredQuestions) && window.pendo._.size(requiredQuestions);
38564
+ return !pendo._.isUndefined(requiredQuestions) && pendo._.size(requiredQuestions);
38202
38565
  },
38203
- 'designerListener': function () {
38204
- var target = window.pendo.dom.getBody();
38566
+ 'designerListener': function (pendo) {
38567
+ var target = pendo.dom.getBody();
38205
38568
  var config = {
38206
38569
  'attributeFilter': ['data-layout'],
38207
38570
  'attributes': true,
@@ -38214,7 +38577,7 @@ var RequiredQuestions = {
38214
38577
  function applyRequiredIndicators(mutations) {
38215
38578
  mutations.forEach(function (mutation) {
38216
38579
  var _a;
38217
- var nodeHasQuerySelector = window.pendo._.isFunction((_a = mutation.addedNodes[0]) === null || _a === void 0 ? void 0 : _a.querySelectorAll);
38580
+ var nodeHasQuerySelector = pendo._.isFunction((_a = mutation.addedNodes[0]) === null || _a === void 0 ? void 0 : _a.querySelectorAll);
38218
38581
  if (mutation.addedNodes.length && nodeHasQuerySelector) {
38219
38582
  var eligiblePolls = mutation.addedNodes[0].querySelectorAll('[class*=-poll-wrapper], [class*=-poll-select-border]');
38220
38583
  if (eligiblePolls) {
@@ -38228,21 +38591,21 @@ var RequiredQuestions = {
38228
38591
  dataPendoPollId = poll.getAttribute('data-pendo-poll-id');
38229
38592
  }
38230
38593
  var questionText;
38231
- if (window.pendo.dom("[class*=\"-poll-question\"][data-pendo-poll-id=".concat(dataPendoPollId, "]"))[0]) {
38232
- questionText = window.pendo.dom("[class*=\"-poll-question\"][data-pendo-poll-id=".concat(dataPendoPollId, "]"))[0].textContent;
38594
+ if (pendo.dom("[class*=\"-poll-question\"][data-pendo-poll-id=".concat(dataPendoPollId, "]"))[0]) {
38595
+ questionText = pendo.dom("[class*=\"-poll-question\"][data-pendo-poll-id=".concat(dataPendoPollId, "]"))[0].textContent;
38233
38596
  }
38234
38597
  if (questionText.includes('{required/}')) {
38235
- window.pendo._.each(window.pendo.dom("[data-pendo-poll-id=".concat(dataPendoPollId, "]:not(.pendo-radio)")), function (element) {
38236
- window.pendo._.each(window.pendo.dom("#".concat(element.id, " *:not(\".pendo-radio\"), #").concat(element.id, ":not(\".pendo-radio\")")), function (item) {
38237
- guideMarkdownUtil.removeMarkdownSyntax(item, '{required/}', '');
38598
+ pendo._.each(pendo.dom("[data-pendo-poll-id=".concat(dataPendoPollId, "]:not(.pendo-radio)")), function (element) {
38599
+ pendo._.each(pendo.dom("#".concat(element.id, " *:not(\".pendo-radio\"), #").concat(element.id, ":not(\".pendo-radio\")")), function (item) {
38600
+ guideMarkdownUtil.removeMarkdownSyntax(item, '{required/}', '', pendo);
38238
38601
  });
38239
38602
  });
38240
- if (window.pendo.dom(".bb-text[data-pendo-poll-id=".concat(dataPendoPollId, "] p")).length !== 0 || window.pendo.dom(".bb-text[data-pendo-poll-id=".concat(dataPendoPollId, "] li")).length !== 0) {
38241
- window.pendo.dom(".bb-text[data-pendo-poll-id=".concat(dataPendoPollId, "] p")).append(requiredElement);
38242
- window.pendo.dom(".bb-text[data-pendo-poll-id=".concat(dataPendoPollId, "] li")).append(requiredElement);
38603
+ if (pendo.dom(".bb-text[data-pendo-poll-id=".concat(dataPendoPollId, "] p")).length !== 0 || pendo.dom(".bb-text[data-pendo-poll-id=".concat(dataPendoPollId, "] li")).length !== 0) {
38604
+ pendo.dom(".bb-text[data-pendo-poll-id=".concat(dataPendoPollId, "] p")).append(requiredElement);
38605
+ pendo.dom(".bb-text[data-pendo-poll-id=".concat(dataPendoPollId, "] li")).append(requiredElement);
38243
38606
  }
38244
38607
  else {
38245
- window.pendo.dom(".bb-text[data-pendo-poll-id=".concat(dataPendoPollId, "]")).append(requiredElement);
38608
+ pendo.dom(".bb-text[data-pendo-poll-id=".concat(dataPendoPollId, "]")).append(requiredElement);
38246
38609
  }
38247
38610
  }
38248
38611
  });
@@ -38253,10 +38616,9 @@ var RequiredQuestions = {
38253
38616
  }
38254
38617
  };
38255
38618
 
38256
- /* eslint-disable agent-eslint-rules/no-window-pendo */
38257
38619
  var skipStepRegex = new RegExp(guideMarkdownUtil.skipStepString);
38258
38620
  var SkipToEligibleStep = {
38259
- 'script': function (step, guide) {
38621
+ 'script': function (step, guide, pendo) {
38260
38622
  var isAdvanceIntercepted = false;
38261
38623
  var isPreviousIntercepted = false;
38262
38624
  var guideContainer = step.guideElement.find('#pendo-guide-container');
@@ -38266,22 +38628,22 @@ var SkipToEligibleStep = {
38266
38628
  guideContainer.attr({ 'aria-label': guideContainer.attr('aria-label').replace(skipStepRegex, '') });
38267
38629
  }
38268
38630
  this.on('beforeAdvance', function (evt) {
38269
- if (guide.getPositionOfStep(step) === guide.steps.length || window.pendo._.isUndefined(stepNumberOrAuto))
38631
+ if (guide.getPositionOfStep(step) === guide.steps.length || pendo._.isUndefined(stepNumberOrAuto))
38270
38632
  return; // exit on the last step of a guide or when we don't have an argument
38271
38633
  var eligibleStep = findEligibleSkipStep(stepNumberOrAuto, 'next');
38272
38634
  if (!isAdvanceIntercepted && stepNumberOrAuto) {
38273
38635
  isAdvanceIntercepted = true;
38274
- window.pendo.goToStep({ 'destinationStepId': eligibleStep.id });
38636
+ pendo.goToStep({ 'destinationStepId': eligibleStep.id });
38275
38637
  evt.cancel = true;
38276
38638
  }
38277
38639
  });
38278
38640
  this.on('beforePrevious', function (evt) {
38279
- if (window.pendo._.isUndefined(stepNumberOrAuto))
38641
+ if (pendo._.isUndefined(stepNumberOrAuto))
38280
38642
  return;
38281
38643
  var eligibleStep = findEligibleSkipStep(stepNumberOrAuto, 'previous');
38282
38644
  if (!isPreviousIntercepted && stepNumberOrAuto) {
38283
38645
  isPreviousIntercepted = true;
38284
- window.pendo.goToStep({ 'destinationStepId': eligibleStep.id });
38646
+ pendo.goToStep({ 'destinationStepId': eligibleStep.id });
38285
38647
  evt.cancel = true;
38286
38648
  }
38287
38649
  });
@@ -38291,15 +38653,15 @@ var SkipToEligibleStep = {
38291
38653
  var skipForwardStep = findStepOnPage(guide.getPositionOfStep(step), 'next', stepNumber);
38292
38654
  var skipPreviousStep = findStepOnPage(guide.getPositionOfStep(step) - 2, 'previous', stepNumber);
38293
38655
  if (skipForwardStep && direction == 'next') {
38294
- window.pendo.goToStep({ 'destinationStepId': skipForwardStep });
38656
+ pendo.goToStep({ 'destinationStepId': skipForwardStep });
38295
38657
  }
38296
38658
  if (skipPreviousStep && direction == 'previous') {
38297
- window.pendo.goToStep({ 'destinationStepId': skipPreviousStep });
38659
+ pendo.goToStep({ 'destinationStepId': skipPreviousStep });
38298
38660
  }
38299
38661
  return direction === 'next' ? skipForwardStep : skipPreviousStep;
38300
38662
  }
38301
38663
  function findStepOnPage(stepIndex, direction, stepNumber) {
38302
- if (window.pendo._.isNaN(stepIndex))
38664
+ if (pendo._.isNaN(stepIndex))
38303
38665
  return;
38304
38666
  var $step = guide.steps[stepIndex];
38305
38667
  if ($step && !$step.canShow()) {
@@ -38318,13 +38680,13 @@ var SkipToEligibleStep = {
38318
38680
  }
38319
38681
  }
38320
38682
  },
38321
- 'test': function (step) {
38683
+ 'test': function (step, guide, pendo) {
38322
38684
  var _a;
38323
38685
  var guideContainerAriaLabel = (_a = step.guideElement) === null || _a === void 0 ? void 0 : _a.find('#pendo-guide-container').attr('aria-label');
38324
- return !window.pendo._.isUndefined(guideContainerAriaLabel) && (guideContainerAriaLabel === null || guideContainerAriaLabel === void 0 ? void 0 : guideContainerAriaLabel.includes('{skipStep'));
38686
+ return !pendo._.isUndefined(guideContainerAriaLabel) && (guideContainerAriaLabel === null || guideContainerAriaLabel === void 0 ? void 0 : guideContainerAriaLabel.includes('{skipStep'));
38325
38687
  },
38326
- 'designerListener': function () {
38327
- var target = window.pendo.dom.getBody();
38688
+ 'designerListener': function (pendo) {
38689
+ var target = pendo.dom.getBody();
38328
38690
  var config = {
38329
38691
  'attributeFilter': ['data-layout'],
38330
38692
  'attributes': true,
@@ -38338,7 +38700,7 @@ var SkipToEligibleStep = {
38338
38700
  function applySkipStepIndicator(mutations) {
38339
38701
  mutations.forEach(function (mutation) {
38340
38702
  var _a, _b;
38341
- var nodeHasQuerySelector = window.pendo._.isFunction((_a = mutation.addedNodes[0]) === null || _a === void 0 ? void 0 : _a.querySelectorAll);
38703
+ var nodeHasQuerySelector = pendo._.isFunction((_a = mutation.addedNodes[0]) === null || _a === void 0 ? void 0 : _a.querySelectorAll);
38342
38704
  if (mutation.addedNodes.length && nodeHasQuerySelector) {
38343
38705
  var guideContainer = mutation.addedNodes[0].querySelectorAll('#pendo-guide-container');
38344
38706
  var guideContainerAriaLabel = (_b = guideContainer[0]) === null || _b === void 0 ? void 0 : _b.getAttribute('aria-label');
@@ -38346,8 +38708,8 @@ var SkipToEligibleStep = {
38346
38708
  if (guideContainerAriaLabel.match(skipStepRegex)) {
38347
38709
  var fullSkipStepString = guideContainerAriaLabel.match(skipStepRegex)[0];
38348
38710
  guideContainerAriaLabel.replace(fullSkipStepString, '');
38349
- if (!window.pendo.dom('#_pendoSkipIcon').length) {
38350
- window.pendo.dom('#pendo-guide-container').append(skipIcon('#999', '30px').trim());
38711
+ if (!pendo.dom('#_pendoSkipIcon').length) {
38712
+ pendo.dom('#pendo-guide-container').append(skipIcon('#999', '30px').trim());
38351
38713
  }
38352
38714
  }
38353
38715
  }
@@ -38363,12 +38725,14 @@ var SkipToEligibleStep = {
38363
38725
  var GuideMarkdown = (function () {
38364
38726
  var guideMarkdown;
38365
38727
  var pluginApi;
38728
+ var globalPendo;
38366
38729
  return {
38367
38730
  'name': 'GuideMarkdown',
38368
38731
  'initialize': init,
38369
38732
  teardown: teardown
38370
38733
  };
38371
38734
  function init(pendo, PluginAPI) {
38735
+ globalPendo = pendo;
38372
38736
  pluginApi = PluginAPI;
38373
38737
  var configReader = PluginAPI.ConfigReader;
38374
38738
  var GUIDEMARKDOWN_CONFIG = 'guideMarkdown';
@@ -38399,7 +38763,7 @@ var GuideMarkdown = (function () {
38399
38763
  function addDesignerListeners(scripts) {
38400
38764
  scripts.forEach(function (script) {
38401
38765
  if (script.designerListener) {
38402
- script.designerListener();
38766
+ script.designerListener(globalPendo, pluginApi);
38403
38767
  }
38404
38768
  });
38405
38769
  }
@@ -44362,7 +44726,7 @@ var _a;
44362
44726
  var __defProp$1 = Object.defineProperty;
44363
44727
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
44364
44728
  var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
44365
- var NodeType$2 = /* @__PURE__ */ ((NodeType2) => {
44729
+ var NodeType$3 = /* @__PURE__ */ ((NodeType2) => {
44366
44730
  NodeType2[NodeType2["Document"] = 0] = "Document";
44367
44731
  NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
44368
44732
  NodeType2[NodeType2["Element"] = 2] = "Element";
@@ -44370,7 +44734,7 @@ var NodeType$2 = /* @__PURE__ */ ((NodeType2) => {
44370
44734
  NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
44371
44735
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
44372
44736
  return NodeType2;
44373
- })(NodeType$2 || {});
44737
+ })(NodeType$3 || {});
44374
44738
  const testableAccessors$1 = {
44375
44739
  Node: ["childNodes", "parentNode", "parentElement", "textContent"],
44376
44740
  ShadowRoot: ["host", "styleSheets"],
@@ -44505,6 +44869,32 @@ function querySelectorAll$1(n2, selectors) {
44505
44869
  function mutationObserverCtor$1() {
44506
44870
  return getUntaintedPrototype$1("MutationObserver").constructor;
44507
44871
  }
44872
+ function patch$1(source, name, replacement) {
44873
+ try {
44874
+ if (!(name in source)) {
44875
+ return () => {
44876
+ };
44877
+ }
44878
+ const original = source[name];
44879
+ const wrapped = replacement(original);
44880
+ if (typeof wrapped === "function") {
44881
+ wrapped.prototype = wrapped.prototype || {};
44882
+ Object.defineProperties(wrapped, {
44883
+ __rrweb_original__: {
44884
+ enumerable: false,
44885
+ value: original
44886
+ }
44887
+ });
44888
+ }
44889
+ source[name] = wrapped;
44890
+ return () => {
44891
+ source[name] = original;
44892
+ };
44893
+ } catch {
44894
+ return () => {
44895
+ };
44896
+ }
44897
+ }
44508
44898
  const index$1 = {
44509
44899
  childNodes: childNodes$1,
44510
44900
  parentNode: parentNode$1,
@@ -44517,7 +44907,8 @@ const index$1 = {
44517
44907
  shadowRoot: shadowRoot$1,
44518
44908
  querySelector: querySelector$1,
44519
44909
  querySelectorAll: querySelectorAll$1,
44520
- mutationObserver: mutationObserverCtor$1
44910
+ mutationObserver: mutationObserverCtor$1,
44911
+ patch: patch$1
44521
44912
  };
44522
44913
  function isElement(n2) {
44523
44914
  return n2.nodeType === n2.ELEMENT_NODE;
@@ -44821,6 +45212,111 @@ function absolutifyURLs(cssText, href) {
44821
45212
  }
44822
45213
  );
44823
45214
  }
45215
+ function normalizeCssString(cssText, _testNoPxNorm = false) {
45216
+ if (_testNoPxNorm) {
45217
+ return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
45218
+ } else {
45219
+ return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
45220
+ }
45221
+ }
45222
+ function splitCssText(cssText, style, _testNoPxNorm = false) {
45223
+ const childNodes2 = Array.from(style.childNodes);
45224
+ const splits = [];
45225
+ let iterCount = 0;
45226
+ if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
45227
+ let cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
45228
+ const normFactor = cssTextNorm.length / cssText.length;
45229
+ for (let i2 = 1; i2 < childNodes2.length; i2++) {
45230
+ if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
45231
+ const textContentNorm = normalizeCssString(
45232
+ childNodes2[i2].textContent,
45233
+ _testNoPxNorm
45234
+ );
45235
+ const jLimit = 100;
45236
+ let j = 3;
45237
+ for (; j < textContentNorm.length; j++) {
45238
+ if (
45239
+ // keep consuming css identifiers (to get a decent chunk more quickly)
45240
+ textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
45241
+ textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1
45242
+ ) {
45243
+ continue;
45244
+ }
45245
+ break;
45246
+ }
45247
+ for (; j < textContentNorm.length; j++) {
45248
+ let startSubstring = textContentNorm.substring(0, j);
45249
+ let cssNormSplits = cssTextNorm.split(startSubstring);
45250
+ let splitNorm = -1;
45251
+ if (cssNormSplits.length === 2) {
45252
+ splitNorm = cssNormSplits[0].length;
45253
+ } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
45254
+ splitNorm = cssTextNorm.indexOf(startSubstring, 1);
45255
+ } else if (cssNormSplits.length === 1) {
45256
+ startSubstring = startSubstring.substring(
45257
+ 0,
45258
+ startSubstring.length - 1
45259
+ );
45260
+ cssNormSplits = cssTextNorm.split(startSubstring);
45261
+ if (cssNormSplits.length <= 1) {
45262
+ splits.push(cssText);
45263
+ return splits;
45264
+ }
45265
+ j = jLimit + 1;
45266
+ } else if (j === textContentNorm.length - 1) {
45267
+ splitNorm = cssTextNorm.indexOf(startSubstring);
45268
+ }
45269
+ if (cssNormSplits.length >= 2 && j > jLimit) {
45270
+ const prevTextContent = childNodes2[i2 - 1].textContent;
45271
+ if (prevTextContent && typeof prevTextContent === "string") {
45272
+ const prevMinLength = normalizeCssString(prevTextContent).length;
45273
+ splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
45274
+ }
45275
+ if (splitNorm === -1) {
45276
+ splitNorm = cssNormSplits[0].length;
45277
+ }
45278
+ }
45279
+ if (splitNorm !== -1) {
45280
+ let k = Math.floor(splitNorm / normFactor);
45281
+ for (; k > 0 && k < cssText.length; ) {
45282
+ iterCount += 1;
45283
+ if (iterCount > 50 * childNodes2.length) {
45284
+ splits.push(cssText);
45285
+ return splits;
45286
+ }
45287
+ const normPart = normalizeCssString(
45288
+ cssText.substring(0, k),
45289
+ _testNoPxNorm
45290
+ );
45291
+ if (normPart.length === splitNorm) {
45292
+ splits.push(cssText.substring(0, k));
45293
+ cssText = cssText.substring(k);
45294
+ cssTextNorm = cssTextNorm.substring(splitNorm);
45295
+ break;
45296
+ } else if (normPart.length < splitNorm) {
45297
+ k += Math.max(
45298
+ 1,
45299
+ Math.floor((splitNorm - normPart.length) / normFactor)
45300
+ );
45301
+ } else {
45302
+ k -= Math.max(
45303
+ 1,
45304
+ Math.floor((normPart.length - splitNorm) * normFactor)
45305
+ );
45306
+ }
45307
+ }
45308
+ break;
45309
+ }
45310
+ }
45311
+ }
45312
+ }
45313
+ }
45314
+ splits.push(cssText);
45315
+ return splits;
45316
+ }
45317
+ function markCssSplits(cssText, style) {
45318
+ return splitCssText(cssText, style).join("/* rr_split */");
45319
+ }
44824
45320
  let _id = 1;
44825
45321
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
44826
45322
  const IGNORED_NODE = -2;
@@ -45081,27 +45577,28 @@ function serializeNode(n2, options) {
45081
45577
  inlineImages,
45082
45578
  recordCanvas,
45083
45579
  keepIframeSrcFn,
45084
- newlyAddedElement = false
45580
+ newlyAddedElement = false,
45581
+ cssCaptured = false
45085
45582
  } = options;
45086
45583
  const rootId = getRootId(doc, mirror2);
45087
45584
  switch (n2.nodeType) {
45088
45585
  case n2.DOCUMENT_NODE:
45089
45586
  if (n2.compatMode !== "CSS1Compat") {
45090
45587
  return {
45091
- type: NodeType$2.Document,
45588
+ type: NodeType$3.Document,
45092
45589
  childNodes: [],
45093
45590
  compatMode: n2.compatMode
45094
45591
  // probably "BackCompat"
45095
45592
  };
45096
45593
  } else {
45097
45594
  return {
45098
- type: NodeType$2.Document,
45595
+ type: NodeType$3.Document,
45099
45596
  childNodes: []
45100
45597
  };
45101
45598
  }
45102
45599
  case n2.DOCUMENT_TYPE_NODE:
45103
45600
  return {
45104
- type: NodeType$2.DocumentType,
45601
+ type: NodeType$3.DocumentType,
45105
45602
  name: n2.name,
45106
45603
  publicId: n2.publicId,
45107
45604
  systemId: n2.systemId,
@@ -45130,17 +45627,18 @@ function serializeNode(n2, options) {
45130
45627
  maskTextFn,
45131
45628
  maskInputOptions,
45132
45629
  maskInputFn,
45133
- rootId
45630
+ rootId,
45631
+ cssCaptured
45134
45632
  });
45135
45633
  case n2.CDATA_SECTION_NODE:
45136
45634
  return {
45137
- type: NodeType$2.CDATA,
45635
+ type: NodeType$3.CDATA,
45138
45636
  textContent: "",
45139
45637
  rootId
45140
45638
  };
45141
45639
  case n2.COMMENT_NODE:
45142
45640
  return {
45143
- type: NodeType$2.Comment,
45641
+ type: NodeType$3.Comment,
45144
45642
  textContent: index$1.textContent(n2) || "",
45145
45643
  rootId
45146
45644
  };
@@ -45155,18 +45653,26 @@ function getRootId(doc, mirror2) {
45155
45653
  }
45156
45654
  function serializeTextNode(n2, options) {
45157
45655
  var _a2;
45158
- const { needsMask, maskTextFn, rootId, maskInputOptions, maskInputFn } = options;
45159
- const parent = index$1.parentNode(n2);
45160
- const parentTagName = parent && parent.tagName;
45161
- let text = index$1.textContent(n2);
45656
+ const {
45657
+ needsMask,
45658
+ maskTextFn,
45659
+ maskInputOptions,
45660
+ maskInputFn,
45661
+ rootId,
45662
+ cssCaptured
45663
+ } = options;
45664
+ const parentTagName = n2.parentNode && n2.parentNode.tagName;
45665
+ let textContent2 = "";
45162
45666
  const isStyle = parentTagName === "STYLE" ? true : void 0;
45163
45667
  const isScript = parentTagName === "SCRIPT" ? true : void 0;
45164
45668
  const isTextarea = parentTagName === "TEXTAREA" ? true : void 0;
45165
- if (isStyle && text) {
45669
+ if (isStyle && textContent2) {
45166
45670
  try {
45167
45671
  if (n2.nextSibling || n2.previousSibling) {
45168
- } else if ((_a2 = parent.sheet) == null ? void 0 : _a2.cssRules) {
45169
- text = stringifyStylesheet(parent.sheet);
45672
+ } else if ((_a2 = n2.parentNode.sheet) == null ? void 0 : _a2.cssRules) {
45673
+ textContent2 = stringifyStylesheet(
45674
+ n2.parentNode.sheet
45675
+ );
45170
45676
  }
45171
45677
  } catch (err) {
45172
45678
  console.warn(
@@ -45174,21 +45680,25 @@ function serializeTextNode(n2, options) {
45174
45680
  n2
45175
45681
  );
45176
45682
  }
45177
- text = absolutifyURLs(text, getHref(options.doc));
45683
+ textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
45178
45684
  }
45179
45685
  if (isScript) {
45180
- text = "SCRIPT_PLACEHOLDER";
45686
+ textContent2 = "SCRIPT_PLACEHOLDER";
45687
+ } else if (!cssCaptured) {
45688
+ textContent2 = index$1.textContent(n2);
45689
+ if (isStyle && textContent2) {
45690
+ textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
45691
+ }
45181
45692
  }
45182
- if (!isStyle && !isScript && text && needsMask) {
45183
- text = maskTextFn ? maskTextFn(text, index$1.parentElement(n2)) : text.replace(/[\S]/g, "*");
45693
+ if (!isStyle && !isScript && textContent2 && needsMask) {
45694
+ textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
45184
45695
  }
45185
- if (isTextarea && text && maskInputOptions.textarea) {
45186
- text = maskInputFn ? maskInputFn(text, n2.parentNode) : text.replace(/[\S]/g, "*");
45696
+ if (isTextarea && textContent2 && maskInputOptions.textarea) {
45697
+ textContent2 = maskInputFn ? maskInputFn(textContent2, n2.parentNode) : textContent2.replace(/[\S]/g, "*");
45187
45698
  }
45188
45699
  return {
45189
- type: NodeType$2.Text,
45190
- textContent: text || "",
45191
- isStyle,
45700
+ type: NodeType$3.Text,
45701
+ textContent: textContent2 || "",
45192
45702
  rootId
45193
45703
  };
45194
45704
  }
@@ -45237,12 +45747,14 @@ function serializeElementNode(n2, options) {
45237
45747
  attributes._cssText = cssText;
45238
45748
  }
45239
45749
  }
45240
- if (tagName === "style" && n2.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
45241
- !(n2.innerText || index$1.textContent(n2) || "").trim().length) {
45242
- const cssText = stringifyStylesheet(
45750
+ if (tagName === "style" && n2.sheet) {
45751
+ let cssText = stringifyStylesheet(
45243
45752
  n2.sheet
45244
45753
  );
45245
45754
  if (cssText) {
45755
+ if (n2.childNodes.length > 1) {
45756
+ cssText = markCssSplits(cssText, n2);
45757
+ }
45246
45758
  attributes._cssText = cssText;
45247
45759
  }
45248
45760
  }
@@ -45373,7 +45885,7 @@ function serializeElementNode(n2, options) {
45373
45885
  } catch (e2) {
45374
45886
  }
45375
45887
  return {
45376
- type: NodeType$2.Element,
45888
+ type: NodeType$3.Element,
45377
45889
  tagName,
45378
45890
  attributes,
45379
45891
  childNodes: [],
@@ -45391,12 +45903,12 @@ function lowerIfExists(maybeAttr) {
45391
45903
  }
45392
45904
  }
45393
45905
  function slimDOMExcluded(sn, slimDOMOptions) {
45394
- if (slimDOMOptions.comment && sn.type === NodeType$2.Comment) {
45906
+ if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
45395
45907
  return true;
45396
- } else if (sn.type === NodeType$2.Element) {
45908
+ } else if (sn.type === NodeType$3.Element) {
45397
45909
  if (slimDOMOptions.script && // script tag
45398
45910
  (sn.tagName === "script" || // (module)preload link
45399
- sn.tagName === "link" && (sn.attributes.rel === "preload" || sn.attributes.rel === "modulepreload") && sn.attributes.as === "script" || // prefetch link
45911
+ sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
45400
45912
  sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
45401
45913
  return true;
45402
45914
  } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
@@ -45445,7 +45957,8 @@ function serializeNodeWithId(n2, options) {
45445
45957
  onStylesheetLoad,
45446
45958
  stylesheetLoadTimeout = 5e3,
45447
45959
  keepIframeSrcFn = () => false,
45448
- newlyAddedElement = false
45960
+ newlyAddedElement = false,
45961
+ cssCaptured = false
45449
45962
  } = options;
45450
45963
  let { needsMask } = options;
45451
45964
  let { preserveWhiteSpace = true } = options;
@@ -45472,7 +45985,8 @@ function serializeNodeWithId(n2, options) {
45472
45985
  inlineImages,
45473
45986
  recordCanvas,
45474
45987
  keepIframeSrcFn,
45475
- newlyAddedElement
45988
+ newlyAddedElement,
45989
+ cssCaptured
45476
45990
  });
45477
45991
  if (!_serializedNode) {
45478
45992
  console.warn(n2, "not serialized");
@@ -45481,7 +45995,7 @@ function serializeNodeWithId(n2, options) {
45481
45995
  let id;
45482
45996
  if (mirror2.hasNode(n2)) {
45483
45997
  id = mirror2.getId(n2);
45484
- } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$2.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
45998
+ } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
45485
45999
  id = IGNORED_NODE;
45486
46000
  } else {
45487
46001
  id = genId();
@@ -45495,15 +46009,15 @@ function serializeNodeWithId(n2, options) {
45495
46009
  onSerialize(n2);
45496
46010
  }
45497
46011
  let recordChild = !skipChild;
45498
- if (serializedNode.type === NodeType$2.Element) {
46012
+ if (serializedNode.type === NodeType$3.Element) {
45499
46013
  recordChild = recordChild && !serializedNode.needBlock;
45500
46014
  delete serializedNode.needBlock;
45501
46015
  const shadowRootEl = index$1.shadowRoot(n2);
45502
46016
  if (shadowRootEl && isNativeShadowDom(shadowRootEl))
45503
46017
  serializedNode.isShadowHost = true;
45504
46018
  }
45505
- if ((serializedNode.type === NodeType$2.Document || serializedNode.type === NodeType$2.Element) && recordChild) {
45506
- if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$2.Element && serializedNode.tagName === "head") {
46019
+ if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
46020
+ if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
45507
46021
  preserveWhiteSpace = false;
45508
46022
  }
45509
46023
  const bypassOptions = {
@@ -45529,10 +46043,14 @@ function serializeNodeWithId(n2, options) {
45529
46043
  iframeLoadTimeout,
45530
46044
  onStylesheetLoad,
45531
46045
  stylesheetLoadTimeout,
45532
- keepIframeSrcFn
46046
+ keepIframeSrcFn,
46047
+ cssCaptured: false
45533
46048
  };
45534
- if (serializedNode.type === NodeType$2.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
46049
+ if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
45535
46050
  else {
46051
+ if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
46052
+ bypassOptions.cssCaptured = true;
46053
+ }
45536
46054
  for (const childN of Array.from(index$1.childNodes(n2))) {
45537
46055
  const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
45538
46056
  if (serializedChildNode) {
@@ -45555,7 +46073,7 @@ function serializeNodeWithId(n2, options) {
45555
46073
  if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
45556
46074
  serializedNode.isShadow = true;
45557
46075
  }
45558
- if (serializedNode.type === NodeType$2.Element && serializedNode.tagName === "iframe") {
46076
+ if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
45559
46077
  onceIframeLoaded(
45560
46078
  n2,
45561
46079
  () => {
@@ -45597,7 +46115,7 @@ function serializeNodeWithId(n2, options) {
45597
46115
  iframeLoadTimeout
45598
46116
  );
45599
46117
  }
45600
- if (serializedNode.type === NodeType$2.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
46118
+ if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
45601
46119
  onceStylesheetLoaded(
45602
46120
  n2,
45603
46121
  () => {
@@ -45932,6 +46450,32 @@ function querySelectorAll(n2, selectors) {
45932
46450
  function mutationObserverCtor() {
45933
46451
  return getUntaintedPrototype("MutationObserver").constructor;
45934
46452
  }
46453
+ function patch(source, name, replacement) {
46454
+ try {
46455
+ if (!(name in source)) {
46456
+ return () => {
46457
+ };
46458
+ }
46459
+ const original = source[name];
46460
+ const wrapped = replacement(original);
46461
+ if (typeof wrapped === "function") {
46462
+ wrapped.prototype = wrapped.prototype || {};
46463
+ Object.defineProperties(wrapped, {
46464
+ __rrweb_original__: {
46465
+ enumerable: false,
46466
+ value: original
46467
+ }
46468
+ });
46469
+ }
46470
+ source[name] = wrapped;
46471
+ return () => {
46472
+ source[name] = original;
46473
+ };
46474
+ } catch {
46475
+ return () => {
46476
+ };
46477
+ }
46478
+ }
45935
46479
  const index = {
45936
46480
  childNodes,
45937
46481
  parentNode,
@@ -45944,7 +46488,8 @@ const index = {
45944
46488
  shadowRoot,
45945
46489
  querySelector,
45946
46490
  querySelectorAll,
45947
- mutationObserver: mutationObserverCtor
46491
+ mutationObserver: mutationObserverCtor,
46492
+ patch
45948
46493
  };
45949
46494
  function getWindow(documentOrWindow) {
45950
46495
  const defaultView = documentOrWindow.defaultView;
@@ -46037,35 +46582,6 @@ function hookSetter(target, key, d, isRevoked, win = window) {
46037
46582
  );
46038
46583
  return () => hookSetter(target, key, original || {}, true);
46039
46584
  }
46040
- function patch(source, name, replacement) {
46041
- try {
46042
- if (!(name in source)) {
46043
- return () => {
46044
- };
46045
- }
46046
- const original = source[name];
46047
- const wrapped = replacement(original);
46048
- if (typeof wrapped === "function") {
46049
- wrapped.toString = function() {
46050
- return original.toString();
46051
- };
46052
- wrapped.prototype = wrapped.prototype || {};
46053
- Object.defineProperties(wrapped, {
46054
- __rrweb_original__: {
46055
- enumerable: false,
46056
- value: original
46057
- }
46058
- });
46059
- }
46060
- source[name] = wrapped;
46061
- return () => {
46062
- source[name] = original;
46063
- };
46064
- } catch {
46065
- return () => {
46066
- };
46067
- }
46068
- }
46069
46585
  let nowTimestamp = Date.now;
46070
46586
  if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
46071
46587
  nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
@@ -46292,6 +46808,15 @@ var MediaInteractions = /* @__PURE__ */ ((MediaInteractions2) => {
46292
46808
  MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
46293
46809
  return MediaInteractions2;
46294
46810
  })(MediaInteractions || {});
46811
+ var NodeType = /* @__PURE__ */ ((NodeType2) => {
46812
+ NodeType2[NodeType2["Document"] = 0] = "Document";
46813
+ NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
46814
+ NodeType2[NodeType2["Element"] = 2] = "Element";
46815
+ NodeType2[NodeType2["Text"] = 3] = "Text";
46816
+ NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
46817
+ NodeType2[NodeType2["Comment"] = 5] = "Comment";
46818
+ return NodeType2;
46819
+ })(NodeType || {});
46295
46820
  function isNodeInLinkedList(n2) {
46296
46821
  return "__ln" in n2;
46297
46822
  }
@@ -46454,9 +46979,18 @@ class MutationBuffer {
46454
46979
  };
46455
46980
  const pushAdd = (n2) => {
46456
46981
  const parent = index.parentNode(n2);
46457
- if (!parent || !inDom(n2) || parent.tagName === "TEXTAREA") {
46982
+ if (!parent || !inDom(n2)) {
46458
46983
  return;
46459
46984
  }
46985
+ let cssCaptured = false;
46986
+ if (n2.nodeType === Node.TEXT_NODE) {
46987
+ const parentTag = parent.tagName;
46988
+ if (parentTag === "TEXTAREA") {
46989
+ return;
46990
+ } else if (parentTag === "STYLE" && this.addedSet.has(parent)) {
46991
+ cssCaptured = true;
46992
+ }
46993
+ }
46460
46994
  const parentId = isShadowRoot(parent) ? this.mirror.getId(getShadowHost(n2)) : this.mirror.getId(parent);
46461
46995
  const nextId = getNextId(n2);
46462
46996
  if (parentId === -1 || nextId === -1) {
@@ -46498,7 +47032,8 @@ class MutationBuffer {
46498
47032
  },
46499
47033
  onStylesheetLoad: (link, childSn) => {
46500
47034
  this.stylesheetManager.attachLinkElement(link, childSn);
46501
- }
47035
+ },
47036
+ cssCaptured
46502
47037
  });
46503
47038
  if (sn) {
46504
47039
  adds.push({
@@ -46636,10 +47171,18 @@ class MutationBuffer {
46636
47171
  this.attributes.push(item);
46637
47172
  this.attributeMap.set(textarea, item);
46638
47173
  }
46639
- item.attributes.value = Array.from(
47174
+ const value = Array.from(
46640
47175
  index.childNodes(textarea),
46641
47176
  (cn) => index.textContent(cn) || ""
46642
47177
  ).join("");
47178
+ item.attributes.value = maskInputValue({
47179
+ element: textarea,
47180
+ maskInputOptions: this.maskInputOptions,
47181
+ tagName: textarea.tagName,
47182
+ type: getInputType(textarea),
47183
+ value,
47184
+ maskInputFn: this.maskInputFn
47185
+ });
46643
47186
  });
46644
47187
  __publicField(this, "processMutation", (m) => {
46645
47188
  if (isIgnored(m.target, this.mirror, this.slimDOMOptions)) {
@@ -48259,7 +48802,7 @@ class IframeManager {
48259
48802
  }
48260
48803
  }
48261
48804
  patchRootIdOnNode(node, rootId) {
48262
- if (node.type !== NodeType$2.Document && !node.rootId) node.rootId = rootId;
48805
+ if (node.type !== NodeType.Document && !node.rootId) node.rootId = rootId;
48263
48806
  if ("childNodes" in node) {
48264
48807
  node.childNodes.forEach((child) => {
48265
48808
  this.patchRootIdOnNode(child, rootId);