UNPKG

rrweb

Version:
1,267 lines (1,235 loc) 143 kB
var rrwebReplay = (function (exports) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } var NodeType; (function (NodeType) { NodeType[NodeType["Document"] = 0] = "Document"; NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; NodeType[NodeType["Element"] = 2] = "Element"; NodeType[NodeType["Text"] = 3] = "Text"; NodeType[NodeType["CDATA"] = 4] = "CDATA"; NodeType[NodeType["Comment"] = 5] = "Comment"; })(NodeType || (NodeType = {})); var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; function parse(css, options) { if (options === void 0) { options = {}; } var lineno = 1; var column = 1; function updatePosition(str) { var lines = str.match(/\n/g); if (lines) { lineno += lines.length; } var i = str.lastIndexOf('\n'); column = i === -1 ? column + str.length : str.length - i; } function position() { var start = { line: lineno, column: column }; return function (node) { node.position = new Position(start); whitespace(); return node; }; } var Position = (function () { function Position(start) { this.start = start; this.end = { line: lineno, column: column }; this.source = options.source; } return Position; }()); Position.prototype.content = css; var errorsList = []; function error(msg) { var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg); err.reason = msg; err.filename = options.source; err.line = lineno; err.column = column; err.source = css; if (options.silent) { errorsList.push(err); } else { throw err; } } function stylesheet() { var rulesList = rules(); return { type: 'stylesheet', stylesheet: { source: options.source, rules: rulesList, parsingErrors: errorsList, }, }; } function open() { return match(/^{\s*/); } function close() { return match(/^}/); } function rules() { var node; var rules = []; whitespace(); comments(rules); while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) { if (node !== false) { rules.push(node); comments(rules); } } return rules; } function match(re) { var m = re.exec(css); if (!m) { return; } var str = m[0]; updatePosition(str); css = css.slice(str.length); return m; } function whitespace() { match(/^\s*/); } function comments(rules) { if (rules === void 0) { rules = []; } var c; while ((c = comment())) { if (c !== false) { rules.push(c); } c = comment(); } return rules; } function comment() { var pos = position(); if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) { return; } var i = 2; while ('' !== css.charAt(i) && ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) { ++i; } i += 2; if ('' === css.charAt(i - 1)) { return error('End of comment missing'); } var str = css.slice(2, i - 2); column += 2; updatePosition(str); css = css.slice(i); column += 2; return pos({ type: 'comment', comment: str, }); } function selector() { var m = match(/^([^{]+)/); if (!m) { return; } return trim(m[0]) .replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '') .replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) { return m.replace(/,/g, '\u200C'); }) .split(/\s*(?![^(]*\)),\s*/) .map(function (s) { return s.replace(/\u200C/g, ','); }); } function declaration() { var pos = position(); var propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/); if (!propMatch) { return; } var prop = trim(propMatch[0]); if (!match(/^:\s*/)) { return error("property missing ':'"); } var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); var ret = pos({ type: 'declaration', property: prop.replace(commentre, ''), value: val ? trim(val[0]).replace(commentre, '') : '', }); match(/^[;\s]*/); return ret; } function declarations() { var decls = []; if (!open()) { return error("missing '{'"); } comments(decls); var decl; while ((decl = declaration())) { if (decl !== false) { decls.push(decl); comments(decls); } decl = declaration(); } if (!close()) { return error("missing '}'"); } return decls; } function keyframe() { var m; var vals = []; var pos = position(); while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) { vals.push(m[1]); match(/^,\s*/); } if (!vals.length) { return; } return pos({ type: 'keyframe', values: vals, declarations: declarations(), }); } function atkeyframes() { var pos = position(); var m = match(/^@([-\w]+)?keyframes\s*/); if (!m) { return; } var vendor = m[1]; m = match(/^([-\w]+)\s*/); if (!m) { return error('@keyframes missing name'); } var name = m[1]; if (!open()) { return error("@keyframes missing '{'"); } var frame; var frames = comments(); while ((frame = keyframe())) { frames.push(frame); frames = frames.concat(comments()); } if (!close()) { return error("@keyframes missing '}'"); } return pos({ type: 'keyframes', name: name, vendor: vendor, keyframes: frames, }); } function atsupports() { var pos = position(); var m = match(/^@supports *([^{]+)/); if (!m) { return; } var supports = trim(m[1]); if (!open()) { return error("@supports missing '{'"); } var style = comments().concat(rules()); if (!close()) { return error("@supports missing '}'"); } return pos({ type: 'supports', supports: supports, rules: style, }); } function athost() { var pos = position(); var m = match(/^@host\s*/); if (!m) { return; } if (!open()) { return error("@host missing '{'"); } var style = comments().concat(rules()); if (!close()) { return error("@host missing '}'"); } return pos({ type: 'host', rules: style, }); } function atmedia() { var pos = position(); var m = match(/^@media *([^{]+)/); if (!m) { return; } var media = trim(m[1]); if (!open()) { return error("@media missing '{'"); } var style = comments().concat(rules()); if (!close()) { return error("@media missing '}'"); } return pos({ type: 'media', media: media, rules: style, }); } function atcustommedia() { var pos = position(); var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/); if (!m) { return; } return pos({ type: 'custom-media', name: trim(m[1]), media: trim(m[2]), }); } function atpage() { var pos = position(); var m = match(/^@page */); if (!m) { return; } var sel = selector() || []; if (!open()) { return error("@page missing '{'"); } var decls = comments(); var decl; while ((decl = declaration())) { decls.push(decl); decls = decls.concat(comments()); } if (!close()) { return error("@page missing '}'"); } return pos({ type: 'page', selectors: sel, declarations: decls, }); } function atdocument() { var pos = position(); var m = match(/^@([-\w]+)?document *([^{]+)/); if (!m) { return; } var vendor = trim(m[1]); var doc = trim(m[2]); if (!open()) { return error("@document missing '{'"); } var style = comments().concat(rules()); if (!close()) { return error("@document missing '}'"); } return pos({ type: 'document', document: doc, vendor: vendor, rules: style, }); } function atfontface() { var pos = position(); var m = match(/^@font-face\s*/); if (!m) { return; } if (!open()) { return error("@font-face missing '{'"); } var decls = comments(); var decl; while ((decl = declaration())) { decls.push(decl); decls = decls.concat(comments()); } if (!close()) { return error("@font-face missing '}'"); } return pos({ type: 'font-face', declarations: decls, }); } var atimport = _compileAtrule('import'); var atcharset = _compileAtrule('charset'); var atnamespace = _compileAtrule('namespace'); function _compileAtrule(name) { var re = new RegExp('^@' + name + '\\s*([^;]+);'); return function () { var pos = position(); var m = match(re); if (!m) { return; } var ret = { type: name }; ret[name] = m[1].trim(); return pos(ret); }; } function atrule() { if (css[0] !== '@') { return; } return (atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface()); } function rule() { var pos = position(); var sel = selector(); if (!sel) { return error('selector missing'); } comments(); return pos({ type: 'rule', selectors: sel, declarations: declarations(), }); } return addParent(stylesheet()); } function trim(str) { return str ? str.replace(/^\s+|\s+$/g, '') : ''; } function addParent(obj, parent) { var isNode = obj && typeof obj.type === 'string'; var childParent = isNode ? obj : parent; for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) { var k = _a[_i]; var value = obj[k]; if (Array.isArray(value)) { value.forEach(function (v) { addParent(v, childParent); }); } else if (value && typeof value === 'object') { addParent(value, childParent); } } if (isNode) { Object.defineProperty(obj, 'parent', { configurable: true, writable: true, enumerable: false, value: parent || null, }); } return obj; } var tagMap = { script: 'noscript', altglyph: 'altGlyph', altglyphdef: 'altGlyphDef', altglyphitem: 'altGlyphItem', animatecolor: 'animateColor', animatemotion: 'animateMotion', animatetransform: 'animateTransform', clippath: 'clipPath', feblend: 'feBlend', fecolormatrix: 'feColorMatrix', fecomponenttransfer: 'feComponentTransfer', fecomposite: 'feComposite', feconvolvematrix: 'feConvolveMatrix', fediffuselighting: 'feDiffuseLighting', fedisplacementmap: 'feDisplacementMap', fedistantlight: 'feDistantLight', fedropshadow: 'feDropShadow', feflood: 'feFlood', fefunca: 'feFuncA', fefuncb: 'feFuncB', fefuncg: 'feFuncG', fefuncr: 'feFuncR', fegaussianblur: 'feGaussianBlur', feimage: 'feImage', femerge: 'feMerge', femergenode: 'feMergeNode', femorphology: 'feMorphology', feoffset: 'feOffset', fepointlight: 'fePointLight', fespecularlighting: 'feSpecularLighting', fespotlight: 'feSpotLight', fetile: 'feTile', feturbulence: 'feTurbulence', foreignobject: 'foreignObject', glyphref: 'glyphRef', lineargradient: 'linearGradient', radialgradient: 'radialGradient', }; function getTagName(n) { var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName; if (tagName === 'link' && n.attributes._cssText) { tagName = 'style'; } return tagName; } var HOVER_SELECTOR = /([^\\]):hover/g; function addHoverClass(cssText) { var ast = parse(cssText, { silent: true }); if (!ast.stylesheet) { return cssText; } ast.stylesheet.rules.forEach(function (rule) { if ('selectors' in rule) { (rule.selectors || []).forEach(function (selector) { if (HOVER_SELECTOR.test(selector)) { var newSelector = selector.replace(HOVER_SELECTOR, '$1.\\:hover'); cssText = cssText.replace(selector, selector + ", " + newSelector); } }); } }); return cssText; } function buildNode(n, options) { var doc = options.doc, hackCss = options.hackCss; switch (n.type) { case NodeType.Document: return doc.implementation.createDocument(null, '', null); case NodeType.DocumentType: return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId); case NodeType.Element: var tagName = getTagName(n); var node_1; if (n.isSVG) { node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName); } else { node_1 = doc.createElement(tagName); } var _loop_1 = function (name) { if (!n.attributes.hasOwnProperty(name)) { return "continue"; } var value = n.attributes[name]; value = typeof value === 'boolean' || typeof value === 'number' ? '' : value; if (!name.startsWith('rr_')) { var isTextarea = tagName === 'textarea' && name === 'value'; var isRemoteOrDynamicCss = tagName === 'style' && name === '_cssText'; if (isRemoteOrDynamicCss && hackCss) { value = addHoverClass(value); } if (isTextarea || isRemoteOrDynamicCss) { var child = doc.createTextNode(value); for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) { var c = _a[_i]; if (c.nodeType === node_1.TEXT_NODE) { node_1.removeChild(c); } } node_1.appendChild(child); return "continue"; } if (tagName === 'iframe' && name === 'src') { return "continue"; } try { if (n.isSVG && name === 'xlink:href') { node_1.setAttributeNS('http://www.w3.org/1999/xlink', name, value); } else if (name === 'onload' || name === 'onclick' || name.substring(0, 7) === 'onmouse') { node_1.setAttribute('_' + name, value); } else { node_1.setAttribute(name, value); } } catch (error) { } } else { if (tagName === 'canvas' && name === 'rr_dataURL') { var image_1 = document.createElement('img'); image_1.src = value; image_1.onload = function () { var ctx = node_1.getContext('2d'); if (ctx) { ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height); } }; } if (name === 'rr_width') { node_1.style.width = value; } if (name === 'rr_height') { node_1.style.height = value; } if (name === 'rr_mediaState') { switch (value) { case 'played': node_1.play(); case 'paused': node_1.pause(); break; } } } }; for (var name in n.attributes) { _loop_1(name); } return node_1; case NodeType.Text: return doc.createTextNode(n.isStyle && hackCss ? addHoverClass(n.textContent) : n.textContent); case NodeType.CDATA: return doc.createCDATASection(n.textContent); case NodeType.Comment: return doc.createComment(n.textContent); default: return null; } } function buildNodeWithSN(n, options) { var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b; var node = buildNode(n, { doc: doc, hackCss: hackCss }); if (!node) { return null; } if (n.type === NodeType.Document) { doc.close(); doc.open(); node = doc; } node.__sn = n; map[n.id] = node; if ((n.type === NodeType.Document || n.type === NodeType.Element) && !skipChild) { for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) { var childN = _c[_i]; var childNode = buildNodeWithSN(childN, { doc: doc, map: map, skipChild: false, hackCss: hackCss, }); if (!childNode) { console.warn('Failed to rebuild', childN); } else { node.appendChild(childNode); } } } return node; } function visit(idNodeMap, onVisit) { function walk(node) { onVisit(node); } for (var key in idNodeMap) { if (idNodeMap[key]) { walk(idNodeMap[key]); } } } function handleScroll(node) { var n = node.__sn; if (n.type !== NodeType.Element) { return; } var el = node; for (var name in n.attributes) { if (!(n.attributes.hasOwnProperty(name) && name.startsWith('rr_'))) { continue; } var value = n.attributes[name]; if (name === 'rr_scrollLeft') { el.scrollLeft = value; } if (name === 'rr_scrollTop') { el.scrollTop = value; } } } function rebuild(n, options) { var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a; var idNodeMap = {}; var node = buildNodeWithSN(n, { doc: doc, map: idNodeMap, skipChild: false, hackCss: hackCss, }); visit(idNodeMap, function (visitedNode) { if (onVisit) { onVisit(visitedNode); } handleScroll(visitedNode); }); return [node, idNodeMap]; } // // An event handler can take an optional event argument // and should not return a value // An array of all currently registered event handlers for a type // A map of event types and their corresponding event handlers. /** Mitt: Tiny (~200b) functional event emitter / pubsub. * @name mitt * @returns {Mitt} */ function mitt(all ) { all = all || Object.create(null); return { /** * Register an event handler for the given type. * * @param {String} type Type of event to listen for, or `"*"` for all events * @param {Function} handler Function to call in response to given event * @memberOf mitt */ on: function on(type , handler ) { (all[type] || (all[type] = [])).push(handler); }, /** * Remove an event handler for the given type. * * @param {String} type Type of event to unregister `handler` from, or `"*"` * @param {Function} handler Handler function to remove * @memberOf mitt */ off: function off(type , handler ) { if (all[type]) { all[type].splice(all[type].indexOf(handler) >>> 0, 1); } }, /** * Invoke all handlers for the given type. * If present, `"*"` handlers are invoked after type-matched handlers. * * @param {String} type The event type to invoke * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler * @memberOf mitt */ emit: function emit(type , evt ) { (all[type] || []).slice().map(function (handler) { handler(evt); }); (all['*'] || []).slice().map(function (handler) { handler(type, evt); }); } }; } var mittProxy = /*#__PURE__*/Object.freeze({ __proto__: null, 'default': mitt }); function polyfill(w, d) { if (w === void 0) { w = window; } if (d === void 0) { d = document; } if ('scrollBehavior' in d.documentElement.style && w.__forceSmoothScrollPolyfill__ !== true) { return; } var Element = w.HTMLElement || w.Element; var SCROLL_TIME = 468; var original = { scroll: w.scroll || w.scrollTo, scrollBy: w.scrollBy, elementScroll: Element.prototype.scroll || scrollElement, scrollIntoView: Element.prototype.scrollIntoView, }; var now = w.performance && w.performance.now ? w.performance.now.bind(w.performance) : Date.now; function isMicrosoftBrowser(userAgent) { var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/']; return new RegExp(userAgentPatterns.join('|')).test(userAgent); } var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0; function scrollElement(x, y) { this.scrollLeft = x; this.scrollTop = y; } function ease(k) { return 0.5 * (1 - Math.cos(Math.PI * k)); } function shouldBailOut(firstArg) { if (firstArg === null || typeof firstArg !== 'object' || firstArg.behavior === undefined || firstArg.behavior === 'auto' || firstArg.behavior === 'instant') { return true; } if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') { return false; } throw new TypeError('behavior member of ScrollOptions ' + firstArg.behavior + ' is not a valid value for enumeration ScrollBehavior.'); } function hasScrollableSpace(el, axis) { if (axis === 'Y') { return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight; } if (axis === 'X') { return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth; } } function canOverflow(el, axis) { var overflowValue = w.getComputedStyle(el, null)['overflow' + axis]; return overflowValue === 'auto' || overflowValue === 'scroll'; } function isScrollable(el) { var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y'); var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X'); return isScrollableY || isScrollableX; } function findScrollableParent(el) { while (el !== d.body && isScrollable(el) === false) { el = el.parentNode || el.host; } return el; } function step(context) { var time = now(); var value; var currentX; var currentY; var elapsed = (time - context.startTime) / SCROLL_TIME; elapsed = elapsed > 1 ? 1 : elapsed; value = ease(elapsed); currentX = context.startX + (context.x - context.startX) * value; currentY = context.startY + (context.y - context.startY) * value; context.method.call(context.scrollable, currentX, currentY); if (currentX !== context.x || currentY !== context.y) { w.requestAnimationFrame(step.bind(w, context)); } } function smoothScroll(el, x, y) { var scrollable; var startX; var startY; var method; var startTime = now(); if (el === d.body) { scrollable = w; startX = w.scrollX || w.pageXOffset; startY = w.scrollY || w.pageYOffset; method = original.scroll; } else { scrollable = el; startX = el.scrollLeft; startY = el.scrollTop; method = scrollElement; } step({ scrollable: scrollable, method: method, startTime: startTime, startX: startX, startY: startY, x: x, y: y, }); } w.scroll = w.scrollTo = function () { if (arguments[0] === undefined) { return; } if (shouldBailOut(arguments[0]) === true) { original.scroll.call(w, arguments[0].left !== undefined ? arguments[0].left : typeof arguments[0] !== 'object' ? arguments[0] : w.scrollX || w.pageXOffset, arguments[0].top !== undefined ? arguments[0].top : arguments[1] !== undefined ? arguments[1] : w.scrollY || w.pageYOffset); return; } smoothScroll.call(w, d.body, arguments[0].left !== undefined ? ~~arguments[0].left : w.scrollX || w.pageXOffset, arguments[0].top !== undefined ? ~~arguments[0].top : w.scrollY || w.pageYOffset); }; w.scrollBy = function () { if (arguments[0] === undefined) { return; } if (shouldBailOut(arguments[0])) { original.scrollBy.call(w, arguments[0].left !== undefined ? arguments[0].left : typeof arguments[0] !== 'object' ? arguments[0] : 0, arguments[0].top !== undefined ? arguments[0].top : arguments[1] !== undefined ? arguments[1] : 0); return; } smoothScroll.call(w, d.body, ~~arguments[0].left + (w.scrollX || w.pageXOffset), ~~arguments[0].top + (w.scrollY || w.pageYOffset)); }; Element.prototype.scroll = Element.prototype.scrollTo = function () { if (arguments[0] === undefined) { return; } if (shouldBailOut(arguments[0]) === true) { if (typeof arguments[0] === 'number' && arguments[1] === undefined) { throw new SyntaxError('Value could not be converted'); } original.elementScroll.call(this, arguments[0].left !== undefined ? ~~arguments[0].left : typeof arguments[0] !== 'object' ? ~~arguments[0] : this.scrollLeft, arguments[0].top !== undefined ? ~~arguments[0].top : arguments[1] !== undefined ? ~~arguments[1] : this.scrollTop); return; } var left = arguments[0].left; var top = arguments[0].top; smoothScroll.call(this, this, typeof left === 'undefined' ? this.scrollLeft : ~~left, typeof top === 'undefined' ? this.scrollTop : ~~top); }; Element.prototype.scrollBy = function () { if (arguments[0] === undefined) { return; } if (shouldBailOut(arguments[0]) === true) { original.elementScroll.call(this, arguments[0].left !== undefined ? ~~arguments[0].left + this.scrollLeft : ~~arguments[0] + this.scrollLeft, arguments[0].top !== undefined ? ~~arguments[0].top + this.scrollTop : ~~arguments[1] + this.scrollTop); return; } this.scroll({ left: ~~arguments[0].left + this.scrollLeft, top: ~~arguments[0].top + this.scrollTop, behavior: arguments[0].behavior, }); }; Element.prototype.scrollIntoView = function () { if (shouldBailOut(arguments[0]) === true) { original.scrollIntoView.call(this, arguments[0] === undefined ? true : arguments[0]); return; } var scrollableParent = findScrollableParent(this); var parentRects = scrollableParent.getBoundingClientRect(); var clientRects = this.getBoundingClientRect(); if (scrollableParent !== d.body) { smoothScroll.call(this, scrollableParent, scrollableParent.scrollLeft + clientRects.left - parentRects.left, scrollableParent.scrollTop + clientRects.top - parentRects.top); if (w.getComputedStyle(scrollableParent).position !== 'fixed') { w.scrollBy({ left: parentRects.left, top: parentRects.top, behavior: 'smooth', }); } } else { w.scrollBy({ left: clientRects.left, top: clientRects.top, behavior: 'smooth', }); } }; } var EventType; (function (EventType) { EventType[EventType["DomContentLoaded"] = 0] = "DomContentLoaded"; EventType[EventType["Load"] = 1] = "Load"; EventType[EventType["FullSnapshot"] = 2] = "FullSnapshot"; EventType[EventType["IncrementalSnapshot"] = 3] = "IncrementalSnapshot"; EventType[EventType["Meta"] = 4] = "Meta"; EventType[EventType["Custom"] = 5] = "Custom"; })(EventType || (EventType = {})); var IncrementalSource; (function (IncrementalSource) { IncrementalSource[IncrementalSource["Mutation"] = 0] = "Mutation"; IncrementalSource[IncrementalSource["MouseMove"] = 1] = "MouseMove"; IncrementalSource[IncrementalSource["MouseInteraction"] = 2] = "MouseInteraction"; IncrementalSource[IncrementalSource["Scroll"] = 3] = "Scroll"; IncrementalSource[IncrementalSource["ViewportResize"] = 4] = "ViewportResize"; IncrementalSource[IncrementalSource["Input"] = 5] = "Input"; IncrementalSource[IncrementalSource["TouchMove"] = 6] = "TouchMove"; IncrementalSource[IncrementalSource["MediaInteraction"] = 7] = "MediaInteraction"; IncrementalSource[IncrementalSource["StyleSheetRule"] = 8] = "StyleSheetRule"; IncrementalSource[IncrementalSource["CanvasMutation"] = 9] = "CanvasMutation"; IncrementalSource[IncrementalSource["Font"] = 10] = "Font"; IncrementalSource[IncrementalSource["Log"] = 11] = "Log"; })(IncrementalSource || (IncrementalSource = {})); var MouseInteractions; (function (MouseInteractions) { MouseInteractions[MouseInteractions["MouseUp"] = 0] = "MouseUp"; MouseInteractions[MouseInteractions["MouseDown"] = 1] = "MouseDown"; MouseInteractions[MouseInteractions["Click"] = 2] = "Click"; MouseInteractions[MouseInteractions["ContextMenu"] = 3] = "ContextMenu"; MouseInteractions[MouseInteractions["DblClick"] = 4] = "DblClick"; MouseInteractions[MouseInteractions["Focus"] = 5] = "Focus"; MouseInteractions[MouseInteractions["Blur"] = 6] = "Blur"; MouseInteractions[MouseInteractions["TouchStart"] = 7] = "TouchStart"; MouseInteractions[MouseInteractions["TouchMove_Departed"] = 8] = "TouchMove_Departed"; MouseInteractions[MouseInteractions["TouchEnd"] = 9] = "TouchEnd"; })(MouseInteractions || (MouseInteractions = {})); var MediaInteractions; (function (MediaInteractions) { MediaInteractions[MediaInteractions["Play"] = 0] = "Play"; MediaInteractions[MediaInteractions["Pause"] = 1] = "Pause"; })(MediaInteractions || (MediaInteractions = {})); var ReplayerEvents; (function (ReplayerEvents) { ReplayerEvents["Start"] = "start"; ReplayerEvents["Pause"] = "pause"; ReplayerEvents["Resume"] = "resume"; ReplayerEvents["Resize"] = "resize"; ReplayerEvents["Finish"] = "finish"; ReplayerEvents["FullsnapshotRebuilded"] = "fullsnapshot-rebuilded"; ReplayerEvents["LoadStylesheetStart"] = "load-stylesheet-start"; ReplayerEvents["LoadStylesheetEnd"] = "load-stylesheet-end"; ReplayerEvents["SkipStart"] = "skip-start"; ReplayerEvents["SkipEnd"] = "skip-end"; ReplayerEvents["MouseInteraction"] = "mouse-interaction"; ReplayerEvents["EventCast"] = "event-cast"; ReplayerEvents["CustomEvent"] = "custom-event"; ReplayerEvents["Flush"] = "flush"; ReplayerEvents["StateChange"] = "state-change"; })(ReplayerEvents || (ReplayerEvents = {})); var Timer = (function () { function Timer(actions, speed) { if (actions === void 0) { actions = []; } this.timeOffset = 0; this.raf = null; this.actions = actions; this.speed = speed; } Timer.prototype.addAction = function (action) { var index = this.findActionIndex(action); this.actions.splice(index, 0, action); }; Timer.prototype.addActions = function (actions) { var _a; (_a = this.actions).push.apply(_a, __spread(actions)); }; Timer.prototype.start = function () { this.actions.sort(function (a1, a2) { return a1.delay - a2.delay; }); this.timeOffset = 0; var lastTimestamp = performance.now(); var actions = this.actions; var self = this; function check() { var time = performance.now(); self.timeOffset += (time - lastTimestamp) * self.speed; lastTimestamp = time; while (actions.length) { var action = actions[0]; if (self.timeOffset >= action.delay) { actions.shift(); action.doAction(); } else { break; } } if (actions.length > 0 || self.liveMode) { self.raf = requestAnimationFrame(check); } } this.raf = requestAnimationFrame(check); }; Timer.prototype.clear = function () { if (this.raf) { cancelAnimationFrame(this.raf); this.raf = null; } this.actions.length = 0; }; Timer.prototype.setSpeed = function (speed) { this.speed = speed; }; Timer.prototype.toggleLiveMode = function (mode) { this.liveMode = mode; }; Timer.prototype.isActive = function () { return this.raf !== null; }; Timer.prototype.findActionIndex = function (action) { var start = 0; var end = this.actions.length - 1; while (start <= end) { var mid = Math.floor((start + end) / 2); if (this.actions[mid].delay < action.delay) { start = mid + 1; } else if (this.actions[mid].delay > action.delay) { end = mid - 1; } else { return mid; } } return start; }; return Timer; }()); function addDelay(event, baselineTime) { if (event.type === EventType.IncrementalSnapshot && event.data.source === IncrementalSource.MouseMove) { var firstOffset = event.data.positions[0].timeOffset; var firstTimestamp = event.timestamp + firstOffset; event.delay = firstTimestamp - baselineTime; return firstTimestamp - baselineTime; } event.delay = event.timestamp - baselineTime; return event.delay; } /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ var t;!function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped";}(t||(t={}));var n={type:"xstate.init"};function e(t){return void 0===t?[]:[].concat(t)}function r(t){return {type:"xstate.assign",assignment:t}}function i(t,n){return "string"==typeof(t="string"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:"function"==typeof t?{type:t.name,exec:t}:t}function o(t){return function(n){return t===n}}function a(t){return "string"==typeof t?{type:t}:t}function u(t,n){return {value:t,context:n,actions:[],changed:!1,matches:o(t)}}function c(t,n){void 0===n&&(n={});var r={config:t,_options:n,initialState:{value:t.initial,actions:e(t.states[t.initial].entry).map((function(t){return i(t,n.actions)})),context:t.context,matches:o(t.initial)},transition:function(n,c){var s,f,v="string"==typeof n?{value:n,context:t.context}:n,l=v.value,p=v.context,g=a(c),y=t.states[l];if(y.on){var d=e(y.on[g.type]),x=function(n){if(void 0===n)return {value:u(l,p)};var e="string"==typeof n?{target:n}:n,a=e.target,c=void 0===a?l:a,s=e.actions,f=void 0===s?[]:s,v=e.cond,d=p;if((void 0===v?function(){return !0}:v)(p,g)){var x=t.states[c],m=!1,h=[].concat(y.exit,f,x.entry).filter((function(t){return t})).map((function(t){return i(t,r._options.actions)})).filter((function(t){if("xstate.assign"===t.type){m=!0;var n=Object.assign({},d);return "function"==typeof t.assignment?n=t.assignment(d,g):Object.keys(t.assignment).forEach((function(e){n[e]="function"==typeof t.assignment[e]?t.assignment[e](d,g):t.assignment[e];})),d=n,!1}return !0}));return {value:{value:c,context:d,actions:h,changed:c!==l||h.length>0||m,matches:o(c)}}}};try{for(var m=function(t){var n="function"==typeof Symbol&&t[Symbol.iterator],e=0;return n?n.call(t):{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}}}(d),h=m.next();!h.done;h=m.next()){var S=x(h.value);if("object"==typeof S)return S.value}}catch(t){s={error:t};}finally{try{h&&!h.done&&(f=m.return)&&f.call(m);}finally{if(s)throw s.error}}}return u(l,p)}};return r}var s=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function f(e){var r=e.initialState,i=t.NotStarted,u=new Set,c={_machine:e,send:function(n){i===t.Running&&(r=e.transition(r,n),s(r,a(n)),u.forEach((function(t){return t(r)})));},subscribe:function(t){return u.add(t),t(r),{unsubscribe:function(){return u.delete(t)}}},start:function(a){if(a){var u="object"==typeof a?a:{context:e.config.context,value:a};r={value:u.value,actions:[],context:u.context,matches:o(u.value)};}return i=t.Running,s(r,n),c},stop:function(){return i=t.Stopped,u.clear(),c},get state(){return r},get status(){return i}};return c} var mirror = { map: {}, getId: function (n) { if (!n.__sn) { return -1; } return n.__sn.id; }, getNode: function (id) { return mirror.map[id] || null; }, removeNodeFromMap: function (n) { var id = n.__sn && n.__sn.id; delete mirror.map[id]; if (n.childNodes) { n.childNodes.forEach(function (child) { return mirror.removeNodeFromMap(child); }); } }, has: function (id) { return mirror.map.hasOwnProperty(id); }, }; function polyfill$1(win) { if (win === void 0) { win = window; } if ('NodeList' in win && !win.NodeList.prototype.forEach) { win.NodeList.prototype.forEach = Array.prototype .forEach; } if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) { win.DOMTokenList.prototype.forEach = Array.prototype .forEach; } } function needCastInSyncMode(event) { switch (event.type) { case EventType.DomContentLoaded: case EventType.Load: case EventType.Custom: return false; case EventType.FullSnapshot: case EventType.Meta: return true; } switch (event.data.source) { case IncrementalSource.MouseMove: case IncrementalSource.MouseInteraction: case IncrementalSource.TouchMove: case IncrementalSource.MediaInteraction: return false; case IncrementalSource.ViewportResize: case IncrementalSource.StyleSheetRule: case IncrementalSource.Scroll: case Increm