PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.2
Elementor Website Builder – more than just a page builder v3.32.2
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / assets / js / common.js

common.js in Elementor Website Builder – more than just a page builder 3.32.2, at assets/js/common.js

31,825 lines 1.2 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*! elementor - v3.32.0 - 18-09-2025 */
2 /******/ (() => { // webpackBootstrap
3 /******/ var __webpack_modules__ = ({
4
5 /***/ "../assets/dev/js/editor/utils/files-upload-handler.js":
6 /*!*************************************************************!*\
7 !*** ../assets/dev/js/editor/utils/files-upload-handler.js ***!
8 \*************************************************************/
9 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
10
11 "use strict";
12 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
13
14
15 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
16 Object.defineProperty(exports, "__esModule", ({
17 value: true
18 }));
19 exports["default"] = void 0;
20 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
21 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
22 var FilesUploadHandler = exports["default"] = /*#__PURE__*/function () {
23 function FilesUploadHandler() {
24 (0, _classCallCheck2.default)(this, FilesUploadHandler);
25 }
26 return (0, _createClass2.default)(FilesUploadHandler, null, [{
27 key: "isUploadEnabled",
28 value: function isUploadEnabled(mediaType) {
29 var unfilteredFilesTypes = ['svg', 'application/json'];
30 if (!unfilteredFilesTypes.includes(mediaType)) {
31 return true;
32 }
33 return elementorCommon.config.filesUpload.unfilteredFiles;
34 }
35 }, {
36 key: "setUploadTypeCaller",
37 value: function setUploadTypeCaller(frame) {
38 frame.uploader.uploader.param('uploadTypeCaller', 'elementor-wp-media-upload');
39 }
40 }, {
41 key: "getUnfilteredFilesNonAdminDialog",
42 value: function getUnfilteredFilesNonAdminDialog() {
43 return elementorCommon.dialogsManager.createWidget('alert', {
44 id: 'e-unfiltered-files-disabled-dialog',
45 headerMessage: __('Sorry, you can\'t upload that file yet', 'elementor'),
46 message: __('This is because JSON files may pose a security risk.', 'elementor') + '<br><br>' + __('To upload them anyway, ask the site administrator to enable unfiltered file uploads.', 'elementor'),
47 strings: {
48 confirm: __('Got it', 'elementor')
49 }
50 });
51 }
52 }, {
53 key: "getUnfilteredFilesNotEnabledDialog",
54 value: function getUnfilteredFilesNotEnabledDialog(callback) {
55 var elementorInstance = window.elementorAdmin || window.elementor;
56 if (!elementorInstance.config.user.is_administrator) {
57 return this.getUnfilteredFilesNonAdminDialog();
58 }
59 var onConfirm = function onConfirm() {
60 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {}, true);
61 elementorCommon.config.filesUpload.unfilteredFiles = true;
62 callback();
63 };
64 return elementorInstance.helpers.getSimpleDialog('e-enable-unfiltered-files-dialog', __('Enable Unfiltered File Uploads', 'elementor'), __('Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.', 'elementor'), __('Enable', 'elementor'), onConfirm);
65 }
66 }, {
67 key: "getUnfilteredFilesNotEnabledImportTemplateDialog",
68 value: function getUnfilteredFilesNotEnabledImportTemplateDialog(callback) {
69 if (!(window.elementorAdmin || window.elementor).config.user.is_administrator) {
70 return this.getUnfilteredFilesNonAdminDialog();
71 }
72 return elementorCommon.dialogsManager.createWidget('confirm', {
73 id: 'e-enable-unfiltered-files-dialog-import-template',
74 headerMessage: __('Enable Unfiltered File Uploads', 'elementor'),
75 message: __('Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.', 'elementor') + '<br /><br />' + __('If you do not enable uploading unfiltered files, any SVG or JSON (including lottie) files used in the uploaded template will not be imported.', 'elementor'),
76 position: {
77 my: 'center center',
78 at: 'center center'
79 },
80 strings: {
81 confirm: __('Enable and Import', 'elementor'),
82 cancel: __('Import Without Enabling', 'elementor')
83 },
84 onConfirm: function onConfirm() {
85 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {
86 success: function success() {
87 // This utility is used in both the admin and the Editor.
88 elementorCommon.config.filesUpload.unfilteredFiles = true;
89 callback();
90 }
91 }, true);
92 },
93 onCancel: function onCancel() {
94 return callback();
95 }
96 });
97 }
98 }]);
99 }();
100
101 /***/ }),
102
103 /***/ "../assets/dev/js/editor/utils/is-instanceof.js":
104 /*!******************************************************!*\
105 !*** ../assets/dev/js/editor/utils/is-instanceof.js ***!
106 \******************************************************/
107 /***/ ((__unused_webpack_module, exports) => {
108
109 "use strict";
110
111
112 Object.defineProperty(exports, "__esModule", ({
113 value: true
114 }));
115 exports["default"] = void 0;
116 function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
117 function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
118 function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
119 /**
120 * Some FileAPI objects such as FileList, DataTransferItem and DataTransferItemList has inconsistency with the retrieved
121 * object (from events, etc.) and the actual JavaScript object so a regular instanceof doesn't work. This function can
122 * check whether it's instanceof by using the objects constructor and prototype names.
123 *
124 * @param object
125 * @param constructors
126 * @return {boolean}
127 */
128 var _default = exports["default"] = function _default(object, constructors) {
129 constructors = Array.isArray(constructors) ? constructors : [constructors];
130 var _iterator = _createForOfIteratorHelper(constructors),
131 _step;
132 try {
133 for (_iterator.s(); !(_step = _iterator.n()).done;) {
134 var _constructor = _step.value;
135 if (object.constructor.name === _constructor.prototype[Symbol.toStringTag]) {
136 return true;
137 }
138 }
139 } catch (err) {
140 _iterator.e(err);
141 } finally {
142 _iterator.f();
143 }
144 return false;
145 };
146
147 /***/ }),
148
149 /***/ "../assets/dev/js/modules/imports/args-object.js":
150 /*!*******************************************************!*\
151 !*** ../assets/dev/js/modules/imports/args-object.js ***!
152 \*******************************************************/
153 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
154
155 "use strict";
156
157
158 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
159 Object.defineProperty(exports, "__esModule", ({
160 value: true
161 }));
162 exports["default"] = void 0;
163 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
164 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
165 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
166 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
167 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
168 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
169 var _instanceType = _interopRequireDefault(__webpack_require__(/*! ./instance-type */ "../assets/dev/js/modules/imports/instance-type.js"));
170 var _isInstanceof = _interopRequireDefault(__webpack_require__(/*! ../../editor/utils/is-instanceof */ "../assets/dev/js/editor/utils/is-instanceof.js"));
171 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
172 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
173 var ArgsObject = exports["default"] = /*#__PURE__*/function (_InstanceType) {
174 /**
175 * Function constructor().
176 *
177 * Create ArgsObject.
178 *
179 * @param {{}} args
180 */
181 function ArgsObject(args) {
182 var _this;
183 (0, _classCallCheck2.default)(this, ArgsObject);
184 _this = _callSuper(this, ArgsObject);
185 _this.args = args;
186 return _this;
187 }
188
189 /**
190 * Function requireArgument().
191 *
192 * Validate property in args.
193 *
194 * @param {string} property
195 * @param {{}} args
196 *
197 * @throws {Error}
198 */
199 (0, _inherits2.default)(ArgsObject, _InstanceType);
200 return (0, _createClass2.default)(ArgsObject, [{
201 key: "requireArgument",
202 value: function requireArgument(property) {
203 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.args;
204 if (!Object.prototype.hasOwnProperty.call(args, property)) {
205 throw Error("".concat(property, " is required."));
206 }
207 }
208
209 /**
210 * Function requireArgumentType().
211 *
212 * Validate property in args using `type === typeof(args.whatever)`.
213 *
214 * @param {string} property
215 * @param {string} type
216 * @param {{}} args
217 *
218 * @throws {Error}
219 */
220 }, {
221 key: "requireArgumentType",
222 value: function requireArgumentType(property, type) {
223 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
224 this.requireArgument(property, args);
225 if ((0, _typeof2.default)(args[property]) !== type) {
226 throw Error("".concat(property, " invalid type: ").concat(type, "."));
227 }
228 }
229
230 /**
231 * Function requireArgumentInstance().
232 *
233 * Validate property in args using `args.whatever instanceof instance`.
234 *
235 * @param {string} property
236 * @param {*} instance
237 * @param {{}} args
238 *
239 * @throws {Error}
240 */
241 }, {
242 key: "requireArgumentInstance",
243 value: function requireArgumentInstance(property, instance) {
244 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
245 this.requireArgument(property, args);
246 if (!(args[property] instanceof instance) && !(0, _isInstanceof.default)(args[property], instance)) {
247 throw Error("".concat(property, " invalid instance."));
248 }
249 }
250
251 /**
252 * Function requireArgumentConstructor().
253 *
254 * Validate property in args using `type === args.whatever.constructor`.
255 *
256 * @param {string} property
257 * @param {*} type
258 * @param {{}} args
259 *
260 * @throws {Error}
261 */
262 }, {
263 key: "requireArgumentConstructor",
264 value: function requireArgumentConstructor(property, type) {
265 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
266 this.requireArgument(property, args);
267
268 // Note: Converting the constructor to string in order to avoid equation issues
269 // due to different memory addresses between iframes (window.Object !== window.top.Object).
270 if (args[property].constructor.toString() !== type.prototype.constructor.toString()) {
271 throw Error("".concat(property, " invalid constructor type."));
272 }
273 }
274 }], [{
275 key: "getInstanceType",
276 value: function getInstanceType() {
277 return 'ArgsObject';
278 }
279 }]);
280 }(_instanceType.default);
281
282 /***/ }),
283
284 /***/ "../assets/dev/js/modules/imports/instance-type.js":
285 /*!*********************************************************!*\
286 !*** ../assets/dev/js/modules/imports/instance-type.js ***!
287 \*********************************************************/
288 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
289
290 "use strict";
291
292
293 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
294 Object.defineProperty(exports, "__esModule", ({
295 value: true
296 }));
297 exports["default"] = void 0;
298 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
299 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
300 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
301 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
302 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
303 var InstanceType = exports["default"] = /*#__PURE__*/function () {
304 function InstanceType() {
305 var _this = this;
306 (0, _classCallCheck2.default)(this, InstanceType);
307 // Since anonymous classes sometimes do not get validated by babel, do it manually.
308 var target = this instanceof InstanceType ? this.constructor : void 0;
309 var prototypes = [];
310 while (target.__proto__ && target.__proto__.name) {
311 prototypes.push(target.__proto__);
312 target = target.__proto__;
313 }
314 prototypes.reverse().forEach(function (proto) {
315 return _this instanceof proto;
316 });
317 }
318 return (0, _createClass2.default)(InstanceType, null, [{
319 key: Symbol.hasInstance,
320 value: function value(target) {
321 /**
322 * This is function extending being called each time JS uses instanceOf, since babel use it each time it create new class
323 * its give's opportunity to mange capabilities of instanceOf operator.
324 * saving current class each time will give option later to handle instanceOf manually.
325 */
326 var result = _superPropGet(InstanceType, Symbol.hasInstance, this, 2)([target]);
327
328 // Act normal when validate a class, which does not have instance type.
329 if (target && !target.constructor.getInstanceType) {
330 return result;
331 }
332 if (target) {
333 if (!target.instanceTypes) {
334 target.instanceTypes = [];
335 }
336 if (!result) {
337 if (this.getInstanceType() === target.constructor.getInstanceType()) {
338 result = true;
339 }
340 }
341 if (result) {
342 var name = this.getInstanceType === InstanceType.getInstanceType ? 'BaseInstanceType' : this.getInstanceType();
343 if (-1 === target.instanceTypes.indexOf(name)) {
344 target.instanceTypes.push(name);
345 }
346 }
347 }
348 if (!result && target) {
349 // Check if the given 'target', is instance of known types.
350 result = target.instanceTypes && Array.isArray(target.instanceTypes) && -1 !== target.instanceTypes.indexOf(this.getInstanceType());
351 }
352 return result;
353 }
354 }, {
355 key: "getInstanceType",
356 value: function getInstanceType() {
357 elementorModules.ForceMethodImplementation();
358 }
359 }]);
360 }();
361
362 /***/ }),
363
364 /***/ "../assets/dev/js/modules/imports/module.js":
365 /*!**************************************************!*\
366 !*** ../assets/dev/js/modules/imports/module.js ***!
367 \**************************************************/
368 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
369
370 "use strict";
371
372
373 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
374 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
375 var Module = function Module() {
376 var $ = jQuery,
377 instanceParams = arguments,
378 self = this,
379 events = {};
380 var settings;
381 var ensureClosureMethods = function ensureClosureMethods() {
382 $.each(self, function (methodName) {
383 var oldMethod = self[methodName];
384 if ('function' !== typeof oldMethod) {
385 return;
386 }
387 self[methodName] = function () {
388 return oldMethod.apply(self, arguments);
389 };
390 });
391 };
392 var initSettings = function initSettings() {
393 settings = self.getDefaultSettings();
394 var instanceSettings = instanceParams[0];
395 if (instanceSettings) {
396 $.extend(true, settings, instanceSettings);
397 }
398 };
399 var init = function init() {
400 self.__construct.apply(self, instanceParams);
401 ensureClosureMethods();
402 initSettings();
403 self.trigger('init');
404 };
405 this.getItems = function (items, itemKey) {
406 if (itemKey) {
407 var keyStack = itemKey.split('.'),
408 currentKey = keyStack.splice(0, 1);
409 if (!keyStack.length) {
410 return items[currentKey];
411 }
412 if (!items[currentKey]) {
413 return;
414 }
415 return this.getItems(items[currentKey], keyStack.join('.'));
416 }
417 return items;
418 };
419 this.getSettings = function (setting) {
420 return this.getItems(settings, setting);
421 };
422 this.setSettings = function (settingKey, value, settingsContainer) {
423 if (!settingsContainer) {
424 settingsContainer = settings;
425 }
426 if ('object' === (0, _typeof2.default)(settingKey)) {
427 $.extend(settingsContainer, settingKey);
428 return self;
429 }
430 var keyStack = settingKey.split('.'),
431 currentKey = keyStack.splice(0, 1);
432 if (!keyStack.length) {
433 settingsContainer[currentKey] = value;
434 return self;
435 }
436 if (!settingsContainer[currentKey]) {
437 settingsContainer[currentKey] = {};
438 }
439 return self.setSettings(keyStack.join('.'), value, settingsContainer[currentKey]);
440 };
441 this.getErrorMessage = function (type, functionName) {
442 var message;
443 switch (type) {
444 case 'forceMethodImplementation':
445 message = "The method '".concat(functionName, "' must to be implemented in the inheritor child.");
446 break;
447 default:
448 message = 'An error occurs';
449 }
450 return message;
451 };
452
453 // TODO: This function should be deleted ?.
454 this.forceMethodImplementation = function (functionName) {
455 throw new Error(this.getErrorMessage('forceMethodImplementation', functionName));
456 };
457 this.on = function (eventName, callback) {
458 if ('object' === (0, _typeof2.default)(eventName)) {
459 $.each(eventName, function (singleEventName) {
460 self.on(singleEventName, this);
461 });
462 return self;
463 }
464 var eventNames = eventName.split(' ');
465 eventNames.forEach(function (singleEventName) {
466 if (!events[singleEventName]) {
467 events[singleEventName] = [];
468 }
469 events[singleEventName].push(callback);
470 });
471 return self;
472 };
473 this.off = function (eventName, callback) {
474 if (!events[eventName]) {
475 return self;
476 }
477 if (!callback) {
478 delete events[eventName];
479 return self;
480 }
481 var callbackIndex = events[eventName].indexOf(callback);
482 if (-1 !== callbackIndex) {
483 delete events[eventName][callbackIndex];
484
485 // Reset array index (for next off on same event).
486 events[eventName] = events[eventName].filter(function (val) {
487 return val;
488 });
489 }
490 return self;
491 };
492 this.trigger = function (eventName) {
493 var methodName = 'on' + eventName[0].toUpperCase() + eventName.slice(1),
494 params = Array.prototype.slice.call(arguments, 1);
495 if (self[methodName]) {
496 self[methodName].apply(self, params);
497 }
498 var callbacks = events[eventName];
499 if (!callbacks) {
500 return self;
501 }
502 $.each(callbacks, function (index, callback) {
503 callback.apply(self, params);
504 });
505 return self;
506 };
507 init();
508 };
509 Module.prototype.__construct = function () {};
510 Module.prototype.getDefaultSettings = function () {
511 return {};
512 };
513 Module.prototype.getConstructorID = function () {
514 return this.constructor.name;
515 };
516 Module.extend = function (properties) {
517 var $ = jQuery,
518 parent = this;
519 var child = function child() {
520 return parent.apply(this, arguments);
521 };
522 $.extend(child, parent);
523 child.prototype = Object.create($.extend({}, parent.prototype, properties));
524 child.prototype.constructor = child;
525 child.__super__ = parent.prototype;
526 return child;
527 };
528 module.exports = Module;
529
530 /***/ }),
531
532 /***/ "../assets/dev/js/utils/notifications.js":
533 /*!***********************************************!*\
534 !*** ../assets/dev/js/utils/notifications.js ***!
535 \***********************************************/
536 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
537
538 "use strict";
539
540
541 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
542 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
543 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
544 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
545 module.exports = elementorModules.Module.extend({
546 initToast: function initToast() {
547 var toast = elementorCommon.dialogsManager.createWidget('buttons', {
548 id: 'elementor-toast',
549 position: {
550 my: 'center bottom',
551 at: 'center bottom-10',
552 of: '#elementor-panel-inner',
553 autoRefresh: true
554 },
555 hide: {
556 onClick: true,
557 auto: true,
558 autoDelay: 10000
559 },
560 effects: {
561 show: function show() {
562 var $widget = toast.getElements('widget');
563 $widget.show();
564 toast.refreshPosition();
565 var top = parseInt($widget.css('top'), 10);
566 $widget.hide().css('top', top + 100);
567 $widget.animate({
568 opacity: 'show',
569 height: 'show',
570 paddingBottom: 'show',
571 paddingTop: 'show',
572 top: top
573 }, {
574 easing: 'linear',
575 duration: 300
576 });
577 },
578 hide: function hide() {
579 var $widget = toast.getElements('widget'),
580 top = parseInt($widget.css('top'), 10);
581 $widget.animate({
582 opacity: 'hide',
583 height: 'hide',
584 paddingBottom: 'hide',
585 paddingTop: 'hide',
586 top: top + 100
587 }, {
588 easing: 'linear',
589 duration: 300
590 });
591 }
592 },
593 button: {
594 tag: 'div'
595 }
596 });
597 this.getToast = function () {
598 return toast;
599 };
600 },
601 showToast: function showToast(options) {
602 var toast = this.getToast();
603 toast.setMessage(options.message);
604 toast.getElements('buttonsWrapper').empty();
605 var isPositionValid = this.isPositionValid(options === null || options === void 0 ? void 0 : options.position);
606 if (!isPositionValid) {
607 this.positionToWindow();
608 }
609 if (options !== null && options !== void 0 && options.position && isPositionValid) {
610 toast.setSettings('position', options.position);
611 }
612 if (options.buttons) {
613 options.buttons.forEach(function (button) {
614 toast.addButton(button);
615 });
616 }
617 if (options.classes) {
618 toast.getElements('widget').addClass(options.classes);
619 }
620 if (options.sticky) {
621 toast.setSettings({
622 hide: {
623 auto: false,
624 onClick: false
625 }
626 });
627 }
628 return toast.show();
629 },
630 isPositionValid: function isPositionValid(position) {
631 var _position$of;
632 var positionToCheck = (_position$of = position === null || position === void 0 ? void 0 : position.of) !== null && _position$of !== void 0 ? _position$of : this.getToast().getSettings('position').of;
633 if (!positionToCheck) {
634 return false;
635 }
636 return !!document.querySelector(positionToCheck);
637 },
638 positionToWindow: function positionToWindow() {
639 var toast = this.getToast();
640 var position = _objectSpread(_objectSpread({}, toast.getSettings('position')), {}, {
641 my: 'right top',
642 at: 'right-10 top+42',
643 // 42px is the default admin bar height + 10px
644 of: ''
645 });
646 toast.setSettings('position', position);
647 toast.getElements('widget').addClass('dialog-position-window');
648 },
649 onInit: function onInit() {
650 this.initToast();
651 }
652 });
653
654 /***/ }),
655
656 /***/ "../assets/dev/js/utils/tiers.js":
657 /*!***************************************!*\
658 !*** ../assets/dev/js/utils/tiers.js ***!
659 \***************************************/
660 /***/ ((__unused_webpack_module, exports) => {
661
662 "use strict";
663
664
665 Object.defineProperty(exports, "__esModule", ({
666 value: true
667 }));
668 exports.isTierAtLeast = exports.TIERS_PRIORITY = exports.TIERS = void 0;
669 var TIERS_PRIORITY = exports.TIERS_PRIORITY = Object.freeze(['free', 'essential', 'essential-oct2023', 'advanced', 'expert', 'agency']);
670
671 /**
672 * @type {Readonly<{
673 * free: string;
674 * essential: string;
675 * 'essential-oct2023': string;
676 * advanced: string;
677 * expert: string;
678 * agency: string;
679 * }>}
680 */
681 var TIERS = exports.TIERS = Object.freeze(TIERS_PRIORITY.reduce(function (acc, tier) {
682 acc[tier] = tier;
683 return acc;
684 }, {}));
685 var isTierAtLeast = exports.isTierAtLeast = function isTierAtLeast(currentTier, expectedTier) {
686 var currentTierIndex = TIERS_PRIORITY.indexOf(currentTier);
687 var expectedTierIndex = TIERS_PRIORITY.indexOf(expectedTier);
688 if (-1 === currentTierIndex || -1 === expectedTierIndex) {
689 return false;
690 }
691 return currentTierIndex >= expectedTierIndex;
692 };
693
694 /***/ }),
695
696 /***/ "../assets/dev/js/utils/time.js":
697 /*!**************************************!*\
698 !*** ../assets/dev/js/utils/time.js ***!
699 \**************************************/
700 /***/ ((__unused_webpack_module, exports) => {
701
702 "use strict";
703
704
705 Object.defineProperty(exports, "__esModule", ({
706 value: true
707 }));
708 exports["default"] = getUserTimestamp;
709 /**
710 * Returns the timestamp in ISO8601 format with the UTC timezone offset.
711 *
712 * @since 3.6.0
713 *
714 * @param {Date} date
715 * @return {Date} timestamp
716 */
717 function getUserTimestamp() {
718 var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
719 var timezoneOffset = date.getTimezoneOffset();
720
721 // Local time for the user
722 var UTCTimestamp = new Date(date.getTime() - timezoneOffset * 60000).toISOString();
723
724 // Remove the Z suffix from the string.
725 UTCTimestamp = UTCTimestamp.slice(0, -1);
726
727 // Create the offset string in the format `+HH:00` (or minus (-) prefix for negative offset instead of plus)
728 var decimalTimezoneOffset = timezoneOffset / 60,
729 // Negative offsets include a '-' sign in the getTimezoneOffset value, positive values need a '+' prefix (ISO8601).
730 sign = 0 <= decimalTimezoneOffset ? '+' : '-',
731 hours = Math.abs(Math.floor(decimalTimezoneOffset)),
732 minutes = Math.abs(decimalTimezoneOffset % 1) * 60,
733 addZeroToHour = 10 > hours ? '0' : '',
734 addZeroToMinutes = 10 > minutes ? '0' : '';
735 var formattedTimezoneOffset = sign + addZeroToHour + hours + ':' + addZeroToMinutes + minutes;
736 return UTCTimestamp + formattedTimezoneOffset;
737 }
738
739 /***/ }),
740
741 /***/ "../core/common/assets/js/components/wordpress/commands-data/index.js":
742 /*!****************************************************************************!*\
743 !*** ../core/common/assets/js/components/wordpress/commands-data/index.js ***!
744 \****************************************************************************/
745 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
746
747 "use strict";
748
749
750 Object.defineProperty(exports, "__esModule", ({
751 value: true
752 }));
753 Object.defineProperty(exports, "Media", ({
754 enumerable: true,
755 get: function get() {
756 return _media.Media;
757 }
758 }));
759 var _media = __webpack_require__(/*! ./media */ "../core/common/assets/js/components/wordpress/commands-data/media.js");
760
761 /***/ }),
762
763 /***/ "../core/common/assets/js/components/wordpress/commands-data/media.js":
764 /*!****************************************************************************!*\
765 !*** ../core/common/assets/js/components/wordpress/commands-data/media.js ***!
766 \****************************************************************************/
767 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
768
769 "use strict";
770 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
771
772
773 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
774 Object.defineProperty(exports, "__esModule", ({
775 value: true
776 }));
777 exports.Media = void 0;
778 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
779 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
780 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
781 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
782 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
783 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
784 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
785 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
786 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
787 var _filesUploadHandler = _interopRequireDefault(__webpack_require__(/*! elementor-editor/utils/files-upload-handler */ "../assets/dev/js/editor/utils/files-upload-handler.js"));
788 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
789 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
790 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
791 var Media = exports.Media = /*#__PURE__*/function (_CommandData) {
792 function Media() {
793 (0, _classCallCheck2.default)(this, Media);
794 return _callSuper(this, Media, arguments);
795 }
796 (0, _inherits2.default)(Media, _CommandData);
797 return (0, _createClass2.default)(Media, [{
798 key: "validateArgs",
799 value: function validateArgs() {
800 this.requireArgumentInstance('file', File);
801 }
802 }, {
803 key: "getRequestData",
804 value: function getRequestData() {
805 var requestData = _superPropGet(Media, "getRequestData", this, 3)([]);
806 requestData.namespace = 'wp';
807 requestData.version = '2';
808 return requestData;
809 }
810 }, {
811 key: "applyBeforeCreate",
812 value: function applyBeforeCreate(args) {
813 var _args$options;
814 args.headers = {
815 'Content-Disposition': "attachment; filename=".concat(this.file.name),
816 'Content-Type': this.file.type
817 };
818 args.query = {
819 uploadTypeCaller: 'elementor-wp-media-upload'
820 };
821 args.data = this.file;
822 if ((_args$options = args.options) !== null && _args$options !== void 0 && _args$options.progress) {
823 this.toast = elementor.notifications.showToast({
824 // eslint-disable-next-line @wordpress/i18n-ellipsis
825 message: __('Uploading...'),
826 sticky: true
827 });
828 }
829 return args;
830 }
831 }, {
832 key: "applyAfterCreate",
833 value: function applyAfterCreate(data, args) {
834 var _args$options2;
835 if ((_args$options2 = args.options) !== null && _args$options2 !== void 0 && _args$options2.progress) {
836 this.toast.hide();
837 }
838 return data;
839 }
840 }, {
841 key: "run",
842 value: function () {
843 var _run = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
844 return _regenerator.default.wrap(function (_context) {
845 while (1) switch (_context.prev = _context.next) {
846 case 0:
847 this.file = this.args.file;
848 if (!(this.file.size > parseInt(window._wpPluploadSettings.defaults.filters.max_file_size, 10))) {
849 _context.next = 1;
850 break;
851 }
852 throw new Error(__('The file exceeds the maximum upload size for this site.', 'elementor'));
853 case 1:
854 if (!(!window._wpPluploadSettings.defaults.filters.mime_types[0].extensions.split(',').includes(this.file.name.split('.').pop()) && !elementor.config.filesUpload.unfilteredFiles)) {
855 _context.next = 2;
856 break;
857 }
858 _filesUploadHandler.default.getUnfilteredFilesNotEnabledDialog(function () {}).show();
859 return _context.abrupt("return");
860 case 2:
861 _context.next = 3;
862 return _superPropGet(Media, "run", this, 3)([]);
863 case 3:
864 return _context.abrupt("return", _context.sent);
865 case 4:
866 case "end":
867 return _context.stop();
868 }
869 }, _callee, this);
870 }));
871 function run() {
872 return _run.apply(this, arguments);
873 }
874 return run;
875 }()
876 }], [{
877 key: "getEndpointFormat",
878 value: function getEndpointFormat() {
879 // 'wp/media' to 'media' since `requestData.namespace` is 'wp'.
880 return 'media';
881 }
882 }]);
883 }(_commandData.default);
884
885 /***/ }),
886
887 /***/ "../core/common/assets/js/components/wordpress/component.js":
888 /*!******************************************************************!*\
889 !*** ../core/common/assets/js/components/wordpress/component.js ***!
890 \******************************************************************/
891 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
892
893 "use strict";
894
895
896 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
897 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
898 Object.defineProperty(exports, "__esModule", ({
899 value: true
900 }));
901 exports["default"] = void 0;
902 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
903 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
904 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
905 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
906 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
907 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
908 var dataCommands = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/assets/js/components/wordpress/commands-data/index.js"));
909 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
910 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
911 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
912 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
913 function Component() {
914 (0, _classCallCheck2.default)(this, Component);
915 return _callSuper(this, Component, arguments);
916 }
917 (0, _inherits2.default)(Component, _ComponentBase);
918 return (0, _createClass2.default)(Component, [{
919 key: "getNamespace",
920 value: function getNamespace() {
921 return 'wp';
922 }
923 }, {
924 key: "defaultData",
925 value: function defaultData() {
926 return this.importCommands(dataCommands);
927 }
928 }]);
929 }(_componentBase.default);
930
931 /***/ }),
932
933 /***/ "../core/common/assets/js/utils/debug.js":
934 /*!***********************************************!*\
935 !*** ../core/common/assets/js/utils/debug.js ***!
936 \***********************************************/
937 /***/ ((module) => {
938
939 "use strict";
940
941
942 // Moved from assets/dev/js/editor/utils
943 var Debug = function Debug() {
944 var self = this,
945 errorStack = [],
946 settings = {},
947 elements = {};
948 var initSettings = function initSettings() {
949 settings = {
950 debounceDelay: 500,
951 urlsToWatch: ['elementor/assets']
952 };
953 };
954 var initElements = function initElements() {
955 elements.$window = jQuery(window);
956 };
957 var onError = function onError(event) {
958 var _event$originalEvent;
959 var error = (_event$originalEvent = event.originalEvent) === null || _event$originalEvent === void 0 ? void 0 : _event$originalEvent.error;
960 if (!error) {
961 return;
962 }
963 var isInWatchList = false,
964 urlsToWatch = settings.urlsToWatch;
965 jQuery.each(urlsToWatch, function () {
966 if (-1 !== error.stack.indexOf(this)) {
967 isInWatchList = true;
968 return false;
969 }
970 });
971 if (!isInWatchList) {
972 return;
973 }
974 self.addError({
975 type: error.name,
976 message: error.message,
977 url: event.originalEvent.filename,
978 line: event.originalEvent.lineno,
979 column: event.originalEvent.colno
980 });
981 };
982 var bindEvents = function bindEvents() {
983 elements.$window.on('error', onError);
984 };
985 var init = function init() {
986 initSettings();
987 initElements();
988 bindEvents();
989 self.sendErrors = _.debounce(self.sendErrors, settings.debounceDelay);
990 };
991 this.addURLToWatch = function (url) {
992 settings.urlsToWatch.push(url);
993 };
994 this.addCustomError = function (error, category, tag) {
995 var errorInfo = {
996 type: error.name,
997 message: error.message,
998 url: error.fileName || error.sourceURL,
999 line: error.lineNumber || error.line,
1000 column: error.columnNumber || error.column,
1001 customFields: {
1002 category: category || 'general',
1003 tag: tag
1004 }
1005 };
1006 if (!errorInfo.url) {
1007 var stackInfo = error.stack.match(/\n {4}at (.*?(?=:(\d+):(\d+)))/);
1008 if (stackInfo) {
1009 errorInfo.url = stackInfo[1];
1010 errorInfo.line = stackInfo[2];
1011 errorInfo.column = stackInfo[3];
1012 }
1013 }
1014 this.addError(errorInfo);
1015 };
1016 this.addError = function (errorParams) {
1017 var defaultParams = {
1018 type: 'Error',
1019 timestamp: Math.floor(new Date().getTime() / 1000),
1020 message: null,
1021 url: null,
1022 line: null,
1023 column: null,
1024 customFields: {}
1025 };
1026 errorStack.push(jQuery.extend(true, defaultParams, errorParams));
1027 self.sendErrors();
1028 };
1029 this.sendErrors = function () {
1030 // Avoid recursions on errors in ajax
1031 elements.$window.off('error', onError);
1032 jQuery.ajax({
1033 url: elementorCommon.config.ajax.url,
1034 method: 'POST',
1035 data: {
1036 action: 'elementor_js_log',
1037 _nonce: elementorCommon.ajax.getSettings('nonce'),
1038 data: errorStack
1039 },
1040 success: function success() {
1041 errorStack = [];
1042
1043 // Restore error handler
1044 elements.$window.on('error', onError);
1045 }
1046 });
1047 };
1048 init();
1049 };
1050 module.exports = Debug;
1051
1052 /***/ }),
1053
1054 /***/ "../core/common/assets/js/utils/helpers.js":
1055 /*!*************************************************!*\
1056 !*** ../core/common/assets/js/utils/helpers.js ***!
1057 \*************************************************/
1058 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1059
1060 "use strict";
1061
1062
1063 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1064 Object.defineProperty(exports, "__esModule", ({
1065 value: true
1066 }));
1067 exports["default"] = void 0;
1068 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1069 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1070 var Helpers = exports["default"] = /*#__PURE__*/function () {
1071 function Helpers() {
1072 (0, _classCallCheck2.default)(this, Helpers);
1073 }
1074 return (0, _createClass2.default)(Helpers, [{
1075 key: "consoleWarn",
1076 value:
1077 /**
1078 * @param {*} args
1079 * @deprecated since 3.7.0, use `elementorDevTools.consoleWarn()` instead.
1080 */
1081 function consoleWarn() {
1082 var _elementorDevTools;
1083 (_elementorDevTools = elementorDevTools).consoleWarn.apply(_elementorDevTools, arguments);
1084
1085 // This is is self is deprecated.
1086 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleWarn()', '3.7.0', 'elementorDevTools.consoleWarn()');
1087 }
1088
1089 /**
1090 * @param {string} message
1091 * @deprecated since 3.7.0, use `console.error()` instead.
1092 */
1093 }, {
1094 key: "consoleError",
1095 value: function consoleError(message) {
1096 // eslint-disable-next-line no-console
1097 console.error(message);
1098
1099 // This is is self is deprecated.
1100 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleError()', '3.7.0', 'console.error()');
1101 }
1102 }, {
1103 key: "cloneObject",
1104 value: function cloneObject(object) {
1105 return JSON.parse(JSON.stringify(object));
1106 }
1107 }, {
1108 key: "upperCaseWords",
1109 value: function upperCaseWords(string) {
1110 return (string + '').replace(/^(.)|\s+(.)/g, function ($1) {
1111 return $1.toUpperCase();
1112 });
1113 }
1114 }, {
1115 key: "getUniqueId",
1116 value: function getUniqueId() {
1117 return Math.random().toString(16).substr(2, 7);
1118 }
1119 }]);
1120 }();
1121
1122 /***/ }),
1123
1124 /***/ "../core/common/assets/js/utils/storage.js":
1125 /*!*************************************************!*\
1126 !*** ../core/common/assets/js/utils/storage.js ***!
1127 \*************************************************/
1128 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1129
1130 "use strict";
1131
1132
1133 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1134 Object.defineProperty(exports, "__esModule", ({
1135 value: true
1136 }));
1137 exports["default"] = void 0;
1138 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1139 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1140 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1141 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1142 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1143 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1144 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1145 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1146 function _default() {
1147 (0, _classCallCheck2.default)(this, _default);
1148 return _callSuper(this, _default, arguments);
1149 }
1150 (0, _inherits2.default)(_default, _elementorModules$Mod);
1151 return (0, _createClass2.default)(_default, [{
1152 key: "get",
1153 value: function get(key, options) {
1154 options = options || {};
1155 var storage;
1156 try {
1157 storage = options.session ? sessionStorage : localStorage;
1158 } catch (e) {
1159 return key ? undefined : {};
1160 }
1161 var elementorStorage = storage.getItem('elementor');
1162 if (elementorStorage) {
1163 elementorStorage = JSON.parse(elementorStorage);
1164 } else {
1165 elementorStorage = {};
1166 }
1167 if (!elementorStorage.__expiration) {
1168 elementorStorage.__expiration = {};
1169 }
1170 var expiration = elementorStorage.__expiration;
1171 var expirationToCheck = [];
1172 if (key) {
1173 if (expiration[key]) {
1174 expirationToCheck = [key];
1175 }
1176 } else {
1177 expirationToCheck = Object.keys(expiration);
1178 }
1179 var entryExpired = false;
1180 expirationToCheck.forEach(function (expirationKey) {
1181 if (new Date(expiration[expirationKey]) < new Date()) {
1182 delete elementorStorage[expirationKey];
1183 delete expiration[expirationKey];
1184 entryExpired = true;
1185 }
1186 });
1187 if (entryExpired) {
1188 this.save(elementorStorage, options.session);
1189 }
1190 if (key) {
1191 return elementorStorage[key];
1192 }
1193 return elementorStorage;
1194 }
1195 }, {
1196 key: "set",
1197 value: function set(key, value, options) {
1198 options = options || {};
1199 var elementorStorage = this.get(null, options);
1200 elementorStorage[key] = value;
1201 if (options.lifetimeInSeconds) {
1202 var date = new Date();
1203 date.setTime(date.getTime() + options.lifetimeInSeconds * 1000);
1204 elementorStorage.__expiration[key] = date.getTime();
1205 }
1206 this.save(elementorStorage, options.session);
1207 }
1208 }, {
1209 key: "save",
1210 value: function save(object, session) {
1211 var storage;
1212 try {
1213 storage = session ? sessionStorage : localStorage;
1214 } catch (e) {
1215 return;
1216 }
1217 storage.setItem('elementor', JSON.stringify(object));
1218 }
1219 }]);
1220 }(elementorModules.Module);
1221
1222 /***/ }),
1223
1224 /***/ "../core/common/modules/ajax/assets/js/ajax.js":
1225 /*!*****************************************************!*\
1226 !*** ../core/common/modules/ajax/assets/js/ajax.js ***!
1227 \*****************************************************/
1228 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1229
1230 "use strict";
1231
1232
1233 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1234 Object.defineProperty(exports, "__esModule", ({
1235 value: true
1236 }));
1237 exports["default"] = void 0;
1238 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
1239 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1240 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1241 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1242 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1243 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1244 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1245 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1246 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1247 function _default() {
1248 var _this;
1249 (0, _classCallCheck2.default)(this, _default);
1250 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1251 args[_key] = arguments[_key];
1252 }
1253 _this = _callSuper(this, _default, [].concat(args));
1254 _this.requests = {};
1255 _this.cache = {};
1256 _this.initRequestConstants();
1257 _this.debounceSendBatch = _.debounce(_this.sendBatch.bind(_this), 500);
1258 return _this;
1259 }
1260 (0, _inherits2.default)(_default, _elementorModules$Mod);
1261 return (0, _createClass2.default)(_default, [{
1262 key: "getDefaultSettings",
1263 value: function getDefaultSettings() {
1264 return {
1265 ajaxParams: {
1266 type: 'POST',
1267 url: elementorCommon.config.ajax.url,
1268 data: {},
1269 dataType: 'json'
1270 },
1271 actionPrefix: 'elementor_'
1272 };
1273 }
1274 }, {
1275 key: "initRequestConstants",
1276 value: function initRequestConstants() {
1277 this.requestConstants = {
1278 _nonce: this.getSettings('nonce')
1279 };
1280 }
1281 }, {
1282 key: "addRequestConstant",
1283 value: function addRequestConstant(key, value) {
1284 this.requestConstants[key] = value;
1285 }
1286 }, {
1287 key: "getCacheKey",
1288 value: function getCacheKey(request) {
1289 return JSON.stringify({
1290 unique_id: request.unique_id,
1291 data: request.data
1292 });
1293 }
1294 }, {
1295 key: "loadObjects",
1296 value: function loadObjects(options) {
1297 var _this2 = this;
1298 var dataCollection = {};
1299 var deferredArray = [];
1300 if (options.before) {
1301 options.before();
1302 }
1303 options.ids.forEach(function (objectId) {
1304 deferredArray.push(_this2.load({
1305 action: options.action,
1306 unique_id: options.data.unique_id + objectId,
1307 data: jQuery.extend({
1308 id: objectId
1309 }, options.data)
1310 }).done(function (data) {
1311 return dataCollection = jQuery.extend(dataCollection, data);
1312 }));
1313 });
1314 jQuery.when.apply(jQuery, deferredArray).done(function () {
1315 return options.success(dataCollection);
1316 });
1317 }
1318 }, {
1319 key: "load",
1320 value: function load(request, immediately) {
1321 var _this3 = this;
1322 if (!request.unique_id) {
1323 request.unique_id = request.action;
1324 }
1325 if (request.before) {
1326 request.before();
1327 }
1328 var deferred;
1329 var cacheKey = this.getCacheKey(request);
1330 if (_.has(this.cache, cacheKey)) {
1331 deferred = jQuery.Deferred().done(request.success).resolve(this.cache[cacheKey]);
1332 } else {
1333 deferred = this.addRequest(request.action, {
1334 data: request.data,
1335 unique_id: request.unique_id,
1336 success: function success(data) {
1337 return _this3.cache[cacheKey] = data;
1338 }
1339 }, immediately).done(request.success);
1340 }
1341 return deferred;
1342 }
1343 }, {
1344 key: "cancelRequest",
1345 value: function cancelRequest(requestId) {
1346 var request = this.requests[requestId];
1347 if (!request) {
1348 return null;
1349 }
1350 if (request.options.deferred.jqXhr) {
1351 return request.options.deferred.jqXhr.abort('Request canceled');
1352 }
1353 if (request.options.deferred) {
1354 return request.options.deferred.reject('Request canceled');
1355 }
1356 }
1357 }, {
1358 key: "addRequest",
1359 value: function addRequest(action, options, immediately) {
1360 options = options || {};
1361 if (!options.unique_id) {
1362 options.unique_id = action;
1363 }
1364 options.deferred = jQuery.Deferred().done(options.success).fail(options.error).always(options.complete);
1365 var request = {
1366 action: action,
1367 options: options
1368 };
1369 if (immediately) {
1370 var requests = {};
1371 requests[options.unique_id] = request;
1372 options.deferred.jqXhr = this.sendBatch(requests);
1373 } else {
1374 this.requests[options.unique_id] = request;
1375 this.debounceSendBatch();
1376 }
1377 return options.deferred;
1378 }
1379 }, {
1380 key: "sendBatch",
1381 value: function sendBatch(requests) {
1382 var actions = {};
1383 if (!requests) {
1384 requests = this.requests;
1385
1386 // Empty for next batch.
1387 this.requests = {};
1388 }
1389 Object.entries(requests).forEach(function (_ref) {
1390 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
1391 id = _ref2[0],
1392 request = _ref2[1];
1393 return actions[id] = {
1394 action: request.action,
1395 data: request.options.data
1396 };
1397 });
1398 return this.send('ajax', {
1399 data: {
1400 actions: JSON.stringify(actions)
1401 },
1402 success: function success(data) {
1403 Object.entries(data.responses).forEach(function (_ref3) {
1404 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
1405 id = _ref4[0],
1406 response = _ref4[1];
1407 var options = requests[id].options;
1408 if (options) {
1409 if (response.success) {
1410 options.deferred.resolve(response.data);
1411 } else if (!response.success) {
1412 options.deferred.reject(response.data);
1413 }
1414 }
1415 });
1416 },
1417 error: function error(data) {
1418 return Object.values(requests).forEach(function (args) {
1419 if (args.options) {
1420 args.options.deferred.reject(data);
1421 }
1422 });
1423 }
1424 });
1425 }
1426 }, {
1427 key: "prepareSend",
1428 value: function prepareSend(action, options) {
1429 var _this4 = this;
1430 var settings = this.getSettings(),
1431 ajaxParams = elementorCommon.helpers.cloneObject(settings.ajaxParams);
1432 options = options || {};
1433 action = settings.actionPrefix + action;
1434 jQuery.extend(ajaxParams, options);
1435 var requestConstants = elementorCommon.helpers.cloneObject(this.requestConstants);
1436 requestConstants.action = action;
1437 var isFormData = ajaxParams.data instanceof FormData;
1438 Object.entries(requestConstants).forEach(function (_ref5) {
1439 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
1440 key = _ref6[0],
1441 value = _ref6[1];
1442 if (isFormData) {
1443 ajaxParams.data.append(key, value);
1444 } else {
1445 ajaxParams.data[key] = value;
1446 }
1447 });
1448 var successCallback = ajaxParams.success,
1449 errorCallback = ajaxParams.error;
1450 if (successCallback || errorCallback) {
1451 ajaxParams.success = function (response) {
1452 if (response.success && successCallback) {
1453 successCallback(response.data);
1454 }
1455 if (!response.success && errorCallback) {
1456 errorCallback(response.data);
1457 }
1458 };
1459 if (errorCallback) {
1460 ajaxParams.error = function (data) {
1461 return errorCallback(data);
1462 };
1463 } else {
1464 ajaxParams.error = function (xmlHttpRequest) {
1465 if (xmlHttpRequest.readyState || 'abort' !== xmlHttpRequest.statusText) {
1466 _this4.trigger('request:unhandledError', xmlHttpRequest);
1467 }
1468 };
1469 }
1470 }
1471 return ajaxParams;
1472 }
1473 }, {
1474 key: "send",
1475 value: function send(action, options) {
1476 return jQuery.ajax(this.prepareSend(action, options));
1477 }
1478 }, {
1479 key: "addRequestCache",
1480 value: function addRequestCache(request, data) {
1481 var cacheKey = this.getCacheKey(request);
1482 this.cache[cacheKey] = data;
1483 }
1484 }, {
1485 key: "invalidateCache",
1486 value: function invalidateCache(request) {
1487 var cacheKey = this.getCacheKey(request);
1488 delete this.cache[cacheKey];
1489 }
1490 }]);
1491 }(elementorModules.Module);
1492
1493 /***/ }),
1494
1495 /***/ "../core/common/modules/connect/assets/js/connect.js":
1496 /*!***********************************************************!*\
1497 !*** ../core/common/modules/connect/assets/js/connect.js ***!
1498 \***********************************************************/
1499 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1500
1501 "use strict";
1502 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1503
1504
1505 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1506 Object.defineProperty(exports, "__esModule", ({
1507 value: true
1508 }));
1509 exports["default"] = void 0;
1510 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1511 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1512 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1513 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1514 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1515 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1516 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1517 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1518 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
1519 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Vie) {
1520 function _default() {
1521 (0, _classCallCheck2.default)(this, _default);
1522 return _callSuper(this, _default, arguments);
1523 }
1524 (0, _inherits2.default)(_default, _elementorModules$Vie);
1525 return (0, _createClass2.default)(_default, [{
1526 key: "addPopupPlugin",
1527 value: function addPopupPlugin() {
1528 var counter = 0;
1529 jQuery.fn.elementorConnect = function (options) {
1530 var _this = this;
1531 // Open the Connect Dialog in a popup window.
1532 if (options !== null && options !== void 0 && options.popup) {
1533 jQuery(this).on('click', function (event) {
1534 var _options$popup, _options$popup2;
1535 event.preventDefault();
1536 var width = ((_options$popup = options.popup) === null || _options$popup === void 0 ? void 0 : _options$popup.width) || 600,
1537 height = ((_options$popup2 = options.popup) === null || _options$popup2 === void 0 ? void 0 : _options$popup2.height) || 700;
1538 window.open(jQuery(_this).attr('href') + '&mode=popup', 'elementorConnect', "toolbar=no, menubar=no, width=".concat(width, ", height=").concat(height, ", top=200, left=0"));
1539 });
1540 delete options.popup;
1541 }
1542 var settings = jQuery.extend({
1543 // These are the defaults.
1544 success: function success() {
1545 return location.reload();
1546 },
1547 error: function error() {
1548 elementor.notifications.showToast({
1549 message: __('Unable to connect', 'elementor')
1550 });
1551 },
1552 parseUrl: function parseUrl(url) {
1553 return url;
1554 } // Allow to change the url, e.g: replace placeholders like '%%template_type%%' with actual value.
1555 }, options);
1556 this.each(function () {
1557 counter++;
1558 var $this = jQuery(this),
1559 callbackId = 'cb' + counter;
1560 $this.attr({
1561 target: '_blank',
1562 rel: 'opener',
1563 href: settings.parseUrl($this.attr('href') + '&mode=popup&callback_id=' + callbackId)
1564 });
1565 elementorCommon.elements.$window.on('elementor/connect/success/' + callbackId, settings.success).on('elementor/connect/error/' + callbackId, settings.error);
1566 });
1567 return this;
1568 };
1569 }
1570 }, {
1571 key: "getDefaultSettings",
1572 value: function getDefaultSettings() {
1573 return {
1574 selectors: {
1575 connectButton: '#elementor-template-library-connect__button'
1576 }
1577 };
1578 }
1579 }, {
1580 key: "getDefaultElements",
1581 value: function getDefaultElements() {
1582 return {
1583 $connectButton: jQuery(this.getSettings('selectors.connectButton'))
1584 };
1585 }
1586 }, {
1587 key: "applyPopup",
1588 value: function applyPopup() {
1589 this.elements.$connectButton.elementorConnect();
1590 }
1591 }, {
1592 key: "onInit",
1593 value: function onInit() {
1594 _superPropGet(_default, "onInit", this, 3)([]);
1595 this.addPopupPlugin();
1596 this.applyPopup();
1597 }
1598 }]);
1599 }(elementorModules.ViewModule);
1600
1601 /***/ }),
1602
1603 /***/ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js":
1604 /*!**********************************************************************************!*\
1605 !*** ../core/common/modules/event-tracker/assets/js/data/commands-data/index.js ***!
1606 \**********************************************************************************/
1607 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1608
1609 "use strict";
1610
1611
1612 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1613 Object.defineProperty(exports, "__esModule", ({
1614 value: true
1615 }));
1616 exports.Index = void 0;
1617 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1618 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1619 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1620 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1621 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1622 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
1623 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1624 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1625 var Index = exports.Index = /*#__PURE__*/function (_CommandData) {
1626 function Index() {
1627 (0, _classCallCheck2.default)(this, Index);
1628 return _callSuper(this, Index, arguments);
1629 }
1630 (0, _inherits2.default)(Index, _CommandData);
1631 return (0, _createClass2.default)(Index, null, [{
1632 key: "getEndpointFormat",
1633 value: function getEndpointFormat() {
1634 return 'send-event';
1635 }
1636 }]);
1637 }(_commandData.default);
1638
1639 /***/ }),
1640
1641 /***/ "../core/common/modules/event-tracker/assets/js/data/component.js":
1642 /*!************************************************************************!*\
1643 !*** ../core/common/modules/event-tracker/assets/js/data/component.js ***!
1644 \************************************************************************/
1645 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1646
1647 "use strict";
1648
1649
1650 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1651 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
1652 Object.defineProperty(exports, "__esModule", ({
1653 value: true
1654 }));
1655 exports["default"] = void 0;
1656 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1657 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1658 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1659 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1660 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1661 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
1662 var commandsData = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js"));
1663 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
1664 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1665 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1666 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
1667 function Component() {
1668 (0, _classCallCheck2.default)(this, Component);
1669 return _callSuper(this, Component, arguments);
1670 }
1671 (0, _inherits2.default)(Component, _ComponentBase);
1672 return (0, _createClass2.default)(Component, [{
1673 key: "getNamespace",
1674 value: function getNamespace() {
1675 return 'event-tracker';
1676 }
1677 }, {
1678 key: "defaultData",
1679 value: function defaultData() {
1680 return this.importCommands(commandsData);
1681 }
1682 }]);
1683 }(_componentBase.default);
1684
1685 /***/ }),
1686
1687 /***/ "../core/common/modules/event-tracker/assets/js/events.js":
1688 /*!****************************************************************!*\
1689 !*** ../core/common/modules/event-tracker/assets/js/events.js ***!
1690 \****************************************************************/
1691 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1692
1693 "use strict";
1694
1695
1696 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1697 Object.defineProperty(exports, "__esModule", ({
1698 value: true
1699 }));
1700 exports["default"] = void 0;
1701 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1702 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1703 var _time = _interopRequireDefault(__webpack_require__(/*! elementor-utils/time */ "../assets/dev/js/utils/time.js"));
1704 var Events = exports["default"] = /*#__PURE__*/function () {
1705 function Events() {
1706 (0, _classCallCheck2.default)(this, Events);
1707 }
1708 return (0, _createClass2.default)(Events, [{
1709 key: "dispatchEvent",
1710 value: function dispatchEvent(eventData) {
1711 if (!eventData) {
1712 return;
1713 }
1714 eventData.ts = (0, _time.default)();
1715
1716 // No need to wait for response, no need to block browser in any way.
1717 $e.data.create('event-tracker/index', {
1718 event_data: eventData
1719 });
1720 }
1721 }]);
1722 }();
1723
1724 /***/ }),
1725
1726 /***/ "../core/common/modules/events-manager/assets/js/events-config.js":
1727 /*!************************************************************************!*\
1728 !*** ../core/common/modules/events-manager/assets/js/events-config.js ***!
1729 \************************************************************************/
1730 /***/ ((__unused_webpack_module, exports) => {
1731
1732 "use strict";
1733
1734
1735 Object.defineProperty(exports, "__esModule", ({
1736 value: true
1737 }));
1738 exports["default"] = void 0;
1739 var eventsConfig = {
1740 triggers: {
1741 click: 'Click',
1742 accordionClick: 'Accordion Click',
1743 toggleClick: 'Toggle Click',
1744 dropdownClick: 'Click Dropdown',
1745 editorLoaded: 'Editor Loaded',
1746 visible: 'Visible',
1747 pageLoaded: 'Page Loaded'
1748 },
1749 locations: {
1750 widgetPanel: 'Widget Panel',
1751 topBar: 'Top Bar',
1752 elementorEditor: 'Elementor Editor',
1753 templatesLibrary: {
1754 library: 'Templates Library'
1755 },
1756 app: {
1757 import: 'Import Kit',
1758 export: 'Export Kit',
1759 kitLibrary: 'Kit Library',
1760 cloudKitLibrary: 'Cloud Kit Library'
1761 },
1762 variables: 'Variables Panel',
1763 admin: 'WP admin'
1764 },
1765 secondaryLocations: {
1766 layout: 'Layout Section',
1767 basic: 'Basic Section',
1768 'pro-elements': 'Pro Section',
1769 general: 'General Section',
1770 'theme-elements': 'Site Section',
1771 'theme-elements-single': 'Single Section',
1772 'woocommerce-elements': 'WooCommerce Section',
1773 wordpress: 'WordPress Section',
1774 categories: 'Widgets Tab',
1775 global: 'Globals Tab',
1776 'whats-new': 'What\'s New',
1777 'document-settings': 'Document Settings icon',
1778 'preview-page': 'Preview Page',
1779 'publish-button': 'Publish Button',
1780 'widget-panel': 'Widget Panel Icon',
1781 finder: 'Finder',
1782 help: 'Help',
1783 elementorLogoDropdown: 'top_bar_elementor_logo_dropdown',
1784 elementorLogo: 'Elementor Logo',
1785 eLogoMenu: 'E-logo Menu',
1786 notes: 'Notes',
1787 siteSettings: 'Site Settings',
1788 structure: 'Structure',
1789 documentNameDropdown: 'Document Name dropdown',
1790 responsiveControls: 'Responsive controls',
1791 launchpad: 'launchpad',
1792 checklistHeader: 'Checklist Header',
1793 checklistSteps: 'Checklist Steps',
1794 userPreferences: 'User Preferences',
1795 contextMenu: 'Context Menu',
1796 templateLibrary: {
1797 saveModal: 'Save to Modal',
1798 moveModal: 'Move to Modal',
1799 bulkMoveModal: 'Bulk Move to Modal',
1800 copyModal: 'Copy to Modal',
1801 bulkCopyModal: 'Bulk Copy to Modal',
1802 saveModalSelectFolder: 'Save to Modal - select folder',
1803 saveModalSelectConnect: 'Save to Modal - connect',
1804 saveModalSelectUpgrade: 'Save to Modal - upgrade',
1805 importModal: 'Import Modal',
1806 newFolderModal: 'New Folder Modal',
1807 deleteDialog: 'Delete Dialog',
1808 deleteFolderDialog: 'Delete Folder Dialog',
1809 renameDialog: 'Rename Dialog',
1810 createFolderDialog: 'Create Folder Dialog',
1811 applySettingsDialog: 'Apply Settings Dialog',
1812 cloudTab: 'Cloud Tab',
1813 siteTab: 'Site Tab',
1814 cloudTabFolder: 'Cloud Tab - Folder',
1815 cloudTabConnect: 'Cloud Tab - Connect',
1816 cloudTabUpgrade: 'Cloud Tab - Upgrade',
1817 morePopup: 'Context Menu',
1818 quotaBar: 'Quota Bar'
1819 },
1820 kitLibrary: {
1821 cloudKitLibrary: 'kits_cloud_library',
1822 cloudKitLibraryConnect: 'kits_cloud_library_connect',
1823 cloudKitLibraryUpgrade: 'kits_cloud_library_upgrade',
1824 kitExportCustomization: 'kit_export_customization',
1825 kitExport: 'kit_export',
1826 kitExportCustomizationEdit: 'kit_export_customization_edit',
1827 kitExportSummary: 'kit_export_summary',
1828 kitImportUploadBox: 'kit_import_upload_box',
1829 kitImportCustomization: 'kit_import_customization',
1830 kitImportSummary: 'kit_import_summary'
1831 },
1832 variablesPopover: 'Variables Popover',
1833 admin: {
1834 pluginToolsTab: 'plugin_tools_tab',
1835 pluginWebsiteTemplatesTab: 'plugin_website_templates_tab'
1836 }
1837 },
1838 elements: {
1839 accordionSection: 'Accordion section',
1840 buttonIcon: 'Button Icon',
1841 mainCta: 'Main CTA',
1842 button: 'Button',
1843 link: 'Link',
1844 dropdown: 'Dropdown',
1845 toggle: 'Toggle',
1846 launchpadChecklist: 'Checklist popup'
1847 },
1848 names: {
1849 v1: {
1850 layout: 'v1_widgets_tab_layout_section',
1851 basic: 'v1_widgets_tab_basic_section',
1852 'pro-elements': 'v1_widgets_tab_pro_section',
1853 general: 'v1_widgets_tab_general_section',
1854 'theme-elements': 'v1_widgets_tab_site_section',
1855 'theme-elements-single': 'v1_widgets_tab_single_section',
1856 'woocommerce-elements': 'v1_widgets_tab_woocommerce_section',
1857 wordpress: 'v1_widgets_tab_wordpress_section',
1858 categories: 'v1_widgets_tab',
1859 global: 'v1_globals_tab'
1860 },
1861 topBar: {
1862 whatsNew: 'top_bar_whats_new',
1863 documentSettings: 'top_bar_document_settings_icon',
1864 previewPage: 'top_bar_preview_page',
1865 publishButton: 'top_bar_publish_button',
1866 widgetPanel: 'top_bar_widget_panel_icon',
1867 finder: 'top_bar_finder',
1868 help: 'top_bar_help',
1869 history: 'top_bar_elementor_logo_dropdown_history',
1870 userPreferences: 'top_bar_elementor_logo_dropdown_user_preferences',
1871 keyboardShortcuts: 'top_bar_elementor_logo_dropdown_keyboard_shortcuts',
1872 exitToWordpress: 'top_bar_elementor_logo_dropdown_exit_to_wordpress',
1873 themeBuilder: 'top_bar_elementor_logo_dropdown_theme_builder',
1874 notes: 'top_bar_notes',
1875 siteSettings: 'top_bar_site_setting',
1876 structure: 'top_bar_structure',
1877 documentNameDropdown: 'top_bar_document_name_dropdown',
1878 responsiveControls: 'top_bar_responsive_controls',
1879 launchpadOn: 'top_bar_checklist_icon_show',
1880 launchpadOff: 'top_bar_checklist_icon_hide',
1881 elementorLogoDropdown: 'open_e_menu',
1882 connectAccount: 'connect_account',
1883 accountConnected: 'account_connected'
1884 },
1885 // ChecklistSteps event names are generated dynamically, based on stepId and action type taken: title, action, done, undone, upgrade
1886 elementorEditor: {
1887 checklist: {
1888 checklistHeaderClose: 'checklist_header_close_icon',
1889 checklistFirstPopup: 'checklist popup triggered'
1890 },
1891 userPreferences: {
1892 checklistShow: 'checklist_userpreferences_toggle_show',
1893 checklistHide: 'checklist_userpreferences_toggle_hide'
1894 }
1895 },
1896 variables: {
1897 open: 'open_variables_popover',
1898 add: 'add_new_variable',
1899 connect: 'connect_variable',
1900 save: 'save_new_variable'
1901 }
1902 }
1903 };
1904 var _default = exports["default"] = eventsConfig;
1905
1906 /***/ }),
1907
1908 /***/ "../core/common/modules/events-manager/assets/js/module.js":
1909 /*!*****************************************************************!*\
1910 !*** ../core/common/modules/events-manager/assets/js/module.js ***!
1911 \*****************************************************************/
1912 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1913
1914 "use strict";
1915
1916
1917 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1918 Object.defineProperty(exports, "__esModule", ({
1919 value: true
1920 }));
1921 exports["default"] = void 0;
1922 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1923 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1924 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1925 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1926 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1927 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
1928 var _eventsConfig = _interopRequireDefault(__webpack_require__(/*! ./events-config */ "../core/common/modules/events-manager/assets/js/events-config.js"));
1929 var _mixpanelBrowser = _interopRequireDefault(__webpack_require__(/*! mixpanel-browser */ "../node_modules/mixpanel-browser/dist/mixpanel.module.js"));
1930 var _tiers = __webpack_require__(/*! elementor-utils/tiers */ "../assets/dev/js/utils/tiers.js");
1931 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1932 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1933 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
1934 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1935 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1936 function _default() {
1937 var _this;
1938 (0, _classCallCheck2.default)(this, _default);
1939 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1940 args[_key] = arguments[_key];
1941 }
1942 _this = _callSuper(this, _default, [].concat(args));
1943 (0, _defineProperty2.default)(_this, "trackingEnabled", false);
1944 return _this;
1945 }
1946 (0, _inherits2.default)(_default, _elementorModules$Mod);
1947 return (0, _createClass2.default)(_default, [{
1948 key: "onInit",
1949 value: function onInit() {
1950 var _elementorCommon$conf, _elementorCommon$conf2;
1951 this.config = _eventsConfig.default;
1952 _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
1953 persistence: 'localStorage',
1954 autocapture: false
1955 });
1956 if ((_elementorCommon$conf2 = elementorCommon.config.editor_events) !== null && _elementorCommon$conf2 !== void 0 && _elementorCommon$conf2.can_send_events) {
1957 this.enableTracking();
1958 }
1959 }
1960 }, {
1961 key: "enableTracking",
1962 value: function enableTracking() {
1963 var _elementorCommon$conf3;
1964 var userId = (_elementorCommon$conf3 = elementorCommon.config.library_connect) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.user_id;
1965 if (userId) {
1966 var _elementorCommon$conf4;
1967 _mixpanelBrowser.default.identify(userId);
1968 _mixpanelBrowser.default.register({
1969 appType: 'Editor'
1970 });
1971 _mixpanelBrowser.default.people.set_once({
1972 $user_id: userId,
1973 $last_login: new Date().toISOString(),
1974 $plan_type: ((_elementorCommon$conf4 = elementorCommon.config.library_connect) === null || _elementorCommon$conf4 === void 0 ? void 0 : _elementorCommon$conf4.plan_type) || _tiers.TIERS.free
1975 });
1976 }
1977 this.trackingEnabled = true;
1978 }
1979 }, {
1980 key: "dispatchEvent",
1981 value: function dispatchEvent(name, data) {
1982 var _elementorCommon$conf5, _elementorCommon$conf6, _elementorCommon$conf7, _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10, _elementorCommon$conf11;
1983 if (!((_elementorCommon$conf5 = elementorCommon.config.editor_events) !== null && _elementorCommon$conf5 !== void 0 && _elementorCommon$conf5.can_send_events)) {
1984 return;
1985 }
1986 if (!this.trackingEnabled) {
1987 this.enableTracking();
1988 }
1989 var eventData = _objectSpread({
1990 user_id: ((_elementorCommon$conf6 = elementorCommon.config.library_connect) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.user_id) || null,
1991 subscription_id: ((_elementorCommon$conf7 = elementorCommon.config.editor_events) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.subscription_id) || null,
1992 user_tier: ((_elementorCommon$conf8 = elementorCommon.config.library_connect) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.current_access_tier) || null,
1993 url: (_elementorCommon$conf9 = elementorCommon.config.editor_events) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.site_url,
1994 wp_version: (_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.wp_version,
1995 client_id: (_elementorCommon$conf1 = elementorCommon.config.editor_events) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.site_key,
1996 app_version: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.elementor_version,
1997 site_language: (_elementorCommon$conf11 = elementorCommon.config.editor_events) === null || _elementorCommon$conf11 === void 0 ? void 0 : _elementorCommon$conf11.site_language
1998 }, data);
1999 _mixpanelBrowser.default.track(name, _objectSpread({}, eventData));
2000 }
2001 }]);
2002 }(elementorModules.Module);
2003
2004 /***/ }),
2005
2006 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2007 /*!*****************************************************************!*\
2008 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2009 \*****************************************************************/
2010 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2011
2012 "use strict";
2013
2014
2015 Object.defineProperty(exports, "__esModule", ({
2016 value: true
2017 }));
2018 Object.defineProperty(exports, "NavigateDown", ({
2019 enumerable: true,
2020 get: function get() {
2021 return _navigateDown.NavigateDown;
2022 }
2023 }));
2024 Object.defineProperty(exports, "NavigateSelect", ({
2025 enumerable: true,
2026 get: function get() {
2027 return _navigateSelect.NavigateSelect;
2028 }
2029 }));
2030 Object.defineProperty(exports, "NavigateUp", ({
2031 enumerable: true,
2032 get: function get() {
2033 return _navigateUp.NavigateUp;
2034 }
2035 }));
2036 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2037 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2038 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2039
2040 /***/ }),
2041
2042 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2043 /*!*************************************************************************!*\
2044 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2045 \*************************************************************************/
2046 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2047
2048 "use strict";
2049
2050
2051 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2052 Object.defineProperty(exports, "__esModule", ({
2053 value: true
2054 }));
2055 exports["default"] = exports.NavigateDown = void 0;
2056 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2057 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2058 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2059 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2060 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2061 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2062 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2063 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2064 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2065 function NavigateDown() {
2066 (0, _classCallCheck2.default)(this, NavigateDown);
2067 return _callSuper(this, NavigateDown, arguments);
2068 }
2069 (0, _inherits2.default)(NavigateDown, _CommandBase);
2070 return (0, _createClass2.default)(NavigateDown, [{
2071 key: "apply",
2072 value: function apply() {
2073 this.component.getItemsView().activateNextItem();
2074 }
2075 }]);
2076 }(_commandBase.default);
2077 var _default = exports["default"] = NavigateDown;
2078
2079 /***/ }),
2080
2081 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2082 /*!***************************************************************************!*\
2083 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2084 \***************************************************************************/
2085 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2086
2087 "use strict";
2088
2089
2090 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2091 Object.defineProperty(exports, "__esModule", ({
2092 value: true
2093 }));
2094 exports["default"] = exports.NavigateSelect = void 0;
2095 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2096 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2097 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2098 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2099 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2100 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2101 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2102 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2103 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2104 function NavigateSelect() {
2105 (0, _classCallCheck2.default)(this, NavigateSelect);
2106 return _callSuper(this, NavigateSelect, arguments);
2107 }
2108 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2109 return (0, _createClass2.default)(NavigateSelect, [{
2110 key: "apply",
2111 value: function apply(args) {
2112 this.component.getItemsView().goToActiveItem(args);
2113 }
2114 }]);
2115 }(_commandBase.default);
2116 var _default = exports["default"] = NavigateSelect;
2117
2118 /***/ }),
2119
2120 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2121 /*!***********************************************************************!*\
2122 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2123 \***********************************************************************/
2124 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2125
2126 "use strict";
2127
2128
2129 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2130 Object.defineProperty(exports, "__esModule", ({
2131 value: true
2132 }));
2133 exports["default"] = exports.NavigateUp = void 0;
2134 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2135 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2136 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2137 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2138 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2139 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2140 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2141 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2142 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2143 function NavigateUp() {
2144 (0, _classCallCheck2.default)(this, NavigateUp);
2145 return _callSuper(this, NavigateUp, arguments);
2146 }
2147 (0, _inherits2.default)(NavigateUp, _CommandBase);
2148 return (0, _createClass2.default)(NavigateUp, [{
2149 key: "apply",
2150 value: function apply() {
2151 this.component.getItemsView().activateNextItem(true);
2152 }
2153 }]);
2154 }(_commandBase.default);
2155 var _default = exports["default"] = NavigateUp;
2156
2157 /***/ }),
2158
2159 /***/ "../core/common/modules/finder/assets/js/component.js":
2160 /*!************************************************************!*\
2161 !*** ../core/common/modules/finder/assets/js/component.js ***!
2162 \************************************************************/
2163 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2164
2165 "use strict";
2166
2167
2168 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2169 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2170 Object.defineProperty(exports, "__esModule", ({
2171 value: true
2172 }));
2173 exports["default"] = void 0;
2174 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2175 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2176 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2177 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2178 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2179 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2180 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2181 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2182 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2183 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2184 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
2185 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2186 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2187 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2188 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2189 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
2190 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2191 function Component() {
2192 (0, _classCallCheck2.default)(this, Component);
2193 return _callSuper(this, Component, arguments);
2194 }
2195 (0, _inherits2.default)(Component, _ComponentModalBase);
2196 return (0, _createClass2.default)(Component, [{
2197 key: "getNamespace",
2198 value: function getNamespace() {
2199 return 'finder';
2200 }
2201 }, {
2202 key: "defaultShortcuts",
2203 value: function defaultShortcuts() {
2204 var _this = this;
2205 return {
2206 '': {
2207 keys: 'ctrl+e'
2208 },
2209 'navigate-down': {
2210 keys: 'down',
2211 scopes: [this.getNamespace()],
2212 dependency: function dependency() {
2213 return _this.getItemsView();
2214 }
2215 },
2216 'navigate-up': {
2217 keys: 'up',
2218 scopes: [this.getNamespace()],
2219 dependency: function dependency() {
2220 return _this.getItemsView();
2221 }
2222 },
2223 'navigate-select': {
2224 keys: 'enter',
2225 scopes: [this.getNamespace()],
2226 dependency: function dependency() {
2227 return _this.getItemsView().$activeItem;
2228 }
2229 }
2230 };
2231 }
2232 }, {
2233 key: "defaultCommands",
2234 value: function defaultCommands() {
2235 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2236 return _objectSpread(_objectSpread({
2237 'navigate/down': function navigate_down() {
2238 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2239 $e.run('finder/navigate-down');
2240 },
2241 'navigate/up': function navigate_up() {
2242 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2243 $e.run('finder/navigate-up');
2244 },
2245 'navigate/select': function navigate_select(event) {
2246 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2247
2248 // TODO: Fix $e.shortcuts use args. ( args.event ).
2249 $e.run('finder/navigate-select', event);
2250 }
2251 }, modalCommands), this.importCommands(commands));
2252 }
2253 }, {
2254 key: "getModalLayout",
2255 value: function getModalLayout() {
2256 return _layout.default;
2257 }
2258 }, {
2259 key: "getItemsView",
2260 value: function getItemsView() {
2261 return this.layout.modalContent.currentView.content.currentView;
2262 }
2263 }]);
2264 }(_componentModalBase.default);
2265
2266 /***/ }),
2267
2268 /***/ "../core/common/modules/finder/assets/js/finder.js":
2269 /*!*********************************************************!*\
2270 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2271 \*********************************************************/
2272 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2273
2274 "use strict";
2275
2276
2277 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2278 Object.defineProperty(exports, "__esModule", ({
2279 value: true
2280 }));
2281 exports["default"] = void 0;
2282 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2283 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2284 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2285 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2286 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2287 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2288 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2289 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2290 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2291 function _default() {
2292 (0, _classCallCheck2.default)(this, _default);
2293 return _callSuper(this, _default, arguments);
2294 }
2295 (0, _inherits2.default)(_default, _elementorModules$Mod);
2296 return (0, _createClass2.default)(_default, [{
2297 key: "onInit",
2298 value: function onInit() {
2299 // TODO: Temp fix, do not load finder in theme-builder.
2300 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
2301 if (window.top !== window) {
2302 return;
2303 }
2304 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
2305 $e.components.register(new _component.default({
2306 manager: this
2307 }));
2308 }
2309 }]);
2310 }(elementorModules.Module);
2311
2312 /***/ }),
2313
2314 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
2315 /*!*******************************************************************!*\
2316 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
2317 \*******************************************************************/
2318 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2319
2320 "use strict";
2321
2322
2323 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2324 Object.defineProperty(exports, "__esModule", ({
2325 value: true
2326 }));
2327 exports["default"] = void 0;
2328 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2329 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2330 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2331 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2332 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2333 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2334 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2335 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
2336 function _default() {
2337 (0, _classCallCheck2.default)(this, _default);
2338 return _callSuper(this, _default, arguments);
2339 }
2340 (0, _inherits2.default)(_default, _Backbone$Model);
2341 return (0, _createClass2.default)(_default, [{
2342 key: "defaults",
2343 value: function defaults() {
2344 return {
2345 description: '',
2346 icon: 'settings',
2347 url: '',
2348 keywords: [],
2349 actions: [],
2350 lock: null
2351 };
2352 }
2353 }]);
2354 }(Backbone.Model);
2355
2356 /***/ }),
2357
2358 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
2359 /*!*************************************************************************!*\
2360 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
2361 \*************************************************************************/
2362 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2363
2364 "use strict";
2365
2366
2367 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2368 Object.defineProperty(exports, "__esModule", ({
2369 value: true
2370 }));
2371 exports["default"] = void 0;
2372 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2373 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2374 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2375 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2376 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2377 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2378 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
2379 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2380 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2381 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2382 function _default() {
2383 (0, _classCallCheck2.default)(this, _default);
2384 return _callSuper(this, _default, arguments);
2385 }
2386 (0, _inherits2.default)(_default, _Marionette$Composite);
2387 return (0, _createClass2.default)(_default, [{
2388 key: "id",
2389 value: function id() {
2390 return 'elementor-finder__results-container';
2391 }
2392 }, {
2393 key: "ui",
2394 value: function ui() {
2395 this.selectors = {
2396 noResults: '#elementor-finder__no-results',
2397 categoryItem: '.elementor-finder__results__item'
2398 };
2399 return this.selectors;
2400 }
2401 }, {
2402 key: "events",
2403 value: function events() {
2404 return {
2405 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
2406 };
2407 }
2408 }, {
2409 key: "getTemplate",
2410 value: function getTemplate() {
2411 return '#tmpl-elementor-finder-results-container';
2412 }
2413 }, {
2414 key: "getChildView",
2415 value: function getChildView(childModel) {
2416 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
2417 }
2418 }, {
2419 key: "initialize",
2420 value: function initialize() {
2421 this.$activeItem = null;
2422 this.childViewContainer = '#elementor-finder__results';
2423 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
2424 }
2425 }, {
2426 key: "activateItem",
2427 value: function activateItem($item) {
2428 if (this.$activeItem) {
2429 this.$activeItem.removeClass('elementor-active');
2430 }
2431 $item.addClass('elementor-active');
2432 this.$activeItem = $item;
2433 }
2434 }, {
2435 key: "activateNextItem",
2436 value: function activateNextItem(reverse) {
2437 var $allItems = jQuery(this.selectors.categoryItem);
2438 var nextItemIndex = 0;
2439 if (this.$activeItem) {
2440 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
2441 if (nextItemIndex >= $allItems.length) {
2442 nextItemIndex = 0;
2443 } else if (nextItemIndex < 0) {
2444 nextItemIndex = $allItems.length - 1;
2445 }
2446 }
2447 var $nextItem = $allItems.eq(nextItemIndex);
2448 this.activateItem($nextItem);
2449 $nextItem[0].scrollIntoView({
2450 block: 'nearest'
2451 });
2452 }
2453 }, {
2454 key: "goToActiveItem",
2455 value: function goToActiveItem(event) {
2456 var $a = this.$activeItem.children('a'),
2457 isControlClicked = $e.shortcuts.isControlEvent(event);
2458 if (isControlClicked) {
2459 $a.attr('target', '_blank');
2460 }
2461 $a[0].click();
2462 if (isControlClicked) {
2463 $a.removeAttr('target');
2464 }
2465 }
2466 }, {
2467 key: "onCategoryItemMouseEnter",
2468 value: function onCategoryItemMouseEnter(event) {
2469 this.activateItem(jQuery(event.currentTarget));
2470 }
2471 }, {
2472 key: "onChildviewToggleVisibility",
2473 value: function onChildviewToggleVisibility() {
2474 var allCategoriesAreEmpty = this.children.every(function (child) {
2475 return !child.isVisible;
2476 });
2477 this.ui.noResults.toggle(allCategoriesAreEmpty);
2478 }
2479 }]);
2480 }(Marionette.CompositeView);
2481
2482 /***/ }),
2483
2484 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
2485 /*!***********************************************************************!*\
2486 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
2487 \***********************************************************************/
2488 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2489
2490 "use strict";
2491
2492
2493 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2494 Object.defineProperty(exports, "__esModule", ({
2495 value: true
2496 }));
2497 exports["default"] = void 0;
2498 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2499 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2500 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2501 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2502 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2503 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
2504 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
2505 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2506 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2507 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2508 function _default() {
2509 (0, _classCallCheck2.default)(this, _default);
2510 return _callSuper(this, _default, arguments);
2511 }
2512 (0, _inherits2.default)(_default, _Marionette$Composite);
2513 return (0, _createClass2.default)(_default, [{
2514 key: "className",
2515 value: function className() {
2516 return 'elementor-finder__results__category';
2517 }
2518 }, {
2519 key: "getTemplate",
2520 value: function getTemplate() {
2521 return '#tmpl-elementor-finder__results__category';
2522 }
2523 }, {
2524 key: "getChildView",
2525 value: function getChildView() {
2526 return _item.default;
2527 }
2528 }, {
2529 key: "initialize",
2530 value: function initialize() {
2531 this.childViewContainer = '.elementor-finder__results__category__items';
2532 this.isVisible = true;
2533 var items = this.model.get('items');
2534 if (items) {
2535 items = Object.values(items);
2536 }
2537 this.collection = new Backbone.Collection(items, {
2538 model: _item2.default
2539 });
2540 }
2541 }, {
2542 key: "filter",
2543 value: function filter(childModel) {
2544 var textFilter = this.getTextFilter();
2545 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
2546 return true;
2547 }
2548 return childModel.get('keywords').some(function (keyword) {
2549 return keyword.indexOf(textFilter) >= 0;
2550 });
2551 }
2552 }, {
2553 key: "getTextFilter",
2554 value: function getTextFilter() {
2555 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
2556 }
2557 }, {
2558 key: "toggleElement",
2559 value: function toggleElement() {
2560 var isCurrentlyVisible = !!this.children.length;
2561 if (isCurrentlyVisible !== this.isVisible) {
2562 this.isVisible = isCurrentlyVisible;
2563 this.$el.toggle(isCurrentlyVisible);
2564 this.triggerMethod('toggle:visibility');
2565 }
2566 }
2567 }, {
2568 key: "onRender",
2569 value: function onRender() {
2570 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
2571 }
2572 }, {
2573 key: "onFilterChange",
2574 value: function onFilterChange() {
2575 this._renderChildren();
2576 }
2577 }, {
2578 key: "onRenderCollection",
2579 value: function onRenderCollection() {
2580 this.toggleElement();
2581 }
2582 }]);
2583 }(Marionette.CompositeView);
2584
2585 /***/ }),
2586
2587 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
2588 /*!**********************************************************************!*\
2589 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
2590 \**********************************************************************/
2591 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2592
2593 "use strict";
2594
2595
2596 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2597 Object.defineProperty(exports, "__esModule", ({
2598 value: true
2599 }));
2600 exports["default"] = void 0;
2601 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2602 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2603 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2604 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2605 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2606 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
2607 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2608 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2609 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
2610 function _default() {
2611 (0, _classCallCheck2.default)(this, _default);
2612 return _callSuper(this, _default, arguments);
2613 }
2614 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
2615 return (0, _createClass2.default)(_default, [{
2616 key: "id",
2617 value: function id() {
2618 return 'elementor-finder';
2619 }
2620 }, {
2621 key: "getTemplate",
2622 value: function getTemplate() {
2623 return '#tmpl-elementor-finder';
2624 }
2625 }, {
2626 key: "ui",
2627 value: function ui() {
2628 return {
2629 searchInput: '#elementor-finder__search__input'
2630 };
2631 }
2632 }, {
2633 key: "events",
2634 value: function events() {
2635 return {
2636 'input @ui.searchInput': 'onSearchInputInput'
2637 };
2638 }
2639 }, {
2640 key: "regions",
2641 value: function regions() {
2642 return {
2643 content: '#elementor-finder__content'
2644 };
2645 }
2646 }, {
2647 key: "showCategoriesView",
2648 value: function showCategoriesView() {
2649 this.content.show(new _categories.default());
2650 }
2651 }, {
2652 key: "onSearchInputInput",
2653 value: function onSearchInputInput() {
2654 var value = this.ui.searchInput.val();
2655 if (value) {
2656 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
2657 if (!(this.content.currentView instanceof _categories.default)) {
2658 this.showCategoriesView();
2659 }
2660 }
2661 this.content.currentView.$el.toggle(!!value);
2662 }
2663 }]);
2664 }(Marionette.LayoutView);
2665
2666 /***/ }),
2667
2668 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
2669 /*!*******************************************************************************!*\
2670 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
2671 \*******************************************************************************/
2672 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2673
2674 "use strict";
2675
2676
2677 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2678 Object.defineProperty(exports, "__esModule", ({
2679 value: true
2680 }));
2681 exports["default"] = void 0;
2682 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2683 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2684 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2685 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2686 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2687 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2688 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2689 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2690 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2691 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
2692 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
2693 function _default() {
2694 (0, _classCallCheck2.default)(this, _default);
2695 return _callSuper(this, _default, arguments);
2696 }
2697 (0, _inherits2.default)(_default, _Category);
2698 return (0, _createClass2.default)(_default, [{
2699 key: "className",
2700 value: function className() {
2701 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
2702 }
2703 }, {
2704 key: "ui",
2705 value: function ui() {
2706 return {
2707 title: '.elementor-finder__results__category__title'
2708 };
2709 }
2710 }, {
2711 key: "fetchData",
2712 value: function fetchData() {
2713 var _this = this;
2714 this.ui.loadingIcon.show();
2715 elementorCommon.ajax.addRequest('finder_get_category_items', {
2716 data: {
2717 category: this.model.get('name'),
2718 filter: this.getTextFilter()
2719 },
2720 success: function success(data) {
2721 if (_this.isDestroyed) {
2722 return;
2723 }
2724 _this.collection.set(data);
2725 _this.toggleElement();
2726 _this.ui.loadingIcon.hide();
2727 }
2728 });
2729 }
2730 }, {
2731 key: "filter",
2732 value: function filter() {
2733 return true;
2734 }
2735 }, {
2736 key: "onFilterChange",
2737 value: function onFilterChange() {
2738 this.fetchData();
2739 }
2740 }, {
2741 key: "onRender",
2742 value: function onRender() {
2743 _superPropGet(_default, "onRender", this, 3)([]);
2744 this.ui.loadingIcon = jQuery('<i>', {
2745 class: 'eicon-loading eicon-animation-spin'
2746 });
2747 this.ui.title.after(this.ui.loadingIcon);
2748 this.fetchData();
2749 }
2750 }]);
2751 }(_category.default);
2752
2753 /***/ }),
2754
2755 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
2756 /*!*******************************************************************!*\
2757 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
2758 \*******************************************************************/
2759 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2760
2761 "use strict";
2762 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
2763
2764
2765 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2766 Object.defineProperty(exports, "__esModule", ({
2767 value: true
2768 }));
2769 exports["default"] = void 0;
2770 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2771 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2772 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2773 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2774 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2775 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2776 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2777 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
2778 function _default() {
2779 (0, _classCallCheck2.default)(this, _default);
2780 return _callSuper(this, _default, arguments);
2781 }
2782 (0, _inherits2.default)(_default, _Marionette$ItemView);
2783 return (0, _createClass2.default)(_default, [{
2784 key: "className",
2785 value: function className() {
2786 return 'elementor-finder__results__item';
2787 }
2788 }, {
2789 key: "getTemplate",
2790 value: function getTemplate() {
2791 return '#tmpl-elementor-finder__results__item';
2792 }
2793 }, {
2794 key: "events",
2795 value: function events() {
2796 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
2797 }
2798 }, {
2799 key: "onClick",
2800 value: function onClick(e) {
2801 var _this = this;
2802 var lockOptions = this.model.get('lock');
2803 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
2804 return;
2805 }
2806 e.preventDefault();
2807 e.stopImmediatePropagation();
2808 elementorCommon.dialogsManager.createWidget('confirm', {
2809 id: 'elementor-finder__lock-dialog',
2810 headerMessage: lockOptions.content.heading,
2811 message: lockOptions.content.description,
2812 position: {
2813 my: 'center center',
2814 at: 'center center'
2815 },
2816 strings: {
2817 confirm: lockOptions.button.text,
2818 cancel: __('Cancel', 'elementor')
2819 },
2820 onConfirm: function onConfirm() {
2821 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
2822 window.open(link, '_blank');
2823 }
2824 }).show();
2825 }
2826 }, {
2827 key: "replaceLockLinkPlaceholders",
2828 value: function replaceLockLinkPlaceholders(link) {
2829 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
2830 }
2831 }]);
2832 }(Marionette.ItemView);
2833
2834 /***/ }),
2835
2836 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
2837 /*!*********************************************************************!*\
2838 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
2839 \*********************************************************************/
2840 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2841
2842 "use strict";
2843 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
2844
2845
2846 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2847 Object.defineProperty(exports, "__esModule", ({
2848 value: true
2849 }));
2850 exports["default"] = void 0;
2851 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2852 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2853 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2854 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2855 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2856 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2857 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
2858 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2859 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2860 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
2861 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
2862 function _default() {
2863 (0, _classCallCheck2.default)(this, _default);
2864 return _callSuper(this, _default, arguments);
2865 }
2866 (0, _inherits2.default)(_default, _elementorModules$com);
2867 return (0, _createClass2.default)(_default, [{
2868 key: "getModalOptions",
2869 value: function getModalOptions() {
2870 return {
2871 id: 'elementor-finder__modal',
2872 draggable: true,
2873 effects: {
2874 show: 'show',
2875 hide: 'hide'
2876 },
2877 position: {
2878 enable: false
2879 }
2880 };
2881 }
2882 }, {
2883 key: "getLogoOptions",
2884 value: function getLogoOptions() {
2885 return {
2886 title: __('Finder', 'elementor')
2887 };
2888 }
2889 }, {
2890 key: "initialize",
2891 value: function initialize() {
2892 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2893 args[_key] = arguments[_key];
2894 }
2895 _superPropGet(_default, "initialize", this, 3)(args);
2896 this.showLogo();
2897 this.showContentView();
2898 }
2899 }, {
2900 key: "showContentView",
2901 value: function showContentView() {
2902 this.modalContent.show(new _content.default());
2903 }
2904 }, {
2905 key: "showModal",
2906 value: function showModal() {
2907 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2908 args[_key2] = arguments[_key2];
2909 }
2910 _superPropGet(_default, "showModal", this, 3)(args);
2911 this.modalContent.currentView.ui.searchInput.focus();
2912 }
2913 }]);
2914 }(elementorModules.common.views.modal.Layout);
2915
2916 /***/ }),
2917
2918 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
2919 /*!*******************************************************************!*\
2920 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
2921 \*******************************************************************/
2922 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2923
2924 "use strict";
2925
2926
2927 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2928 Object.defineProperty(exports, "__esModule", ({
2929 value: true
2930 }));
2931 exports["default"] = void 0;
2932 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2933 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2934 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2935 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2936 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2937 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
2938 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2939 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
2940 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
2941 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2942 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2943 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
2944 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2945 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
2946 /**
2947 * Error constructor.
2948 *
2949 * @param {string} message
2950 * @param {string} code
2951 * @param {*} data
2952 */
2953 function BaseError() {
2954 var _this;
2955 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
2956 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2957 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
2958 (0, _classCallCheck2.default)(this, BaseError);
2959 _this = _callSuper(this, BaseError, [message]);
2960 /**
2961 * The server error code.
2962 *
2963 * @type {string}
2964 */
2965 (0, _defineProperty2.default)(_this, "code", '');
2966 /**
2967 * Additional data about the current error.
2968 *
2969 * @type {*[]}
2970 */
2971 (0, _defineProperty2.default)(_this, "data", []);
2972 _this.code = code;
2973 _this.data = data;
2974 return _this;
2975 }
2976
2977 /**
2978 * Notify a message when the error occurs.
2979 */
2980 (0, _inherits2.default)(BaseError, _Error);
2981 return (0, _createClass2.default)(BaseError, [{
2982 key: "notify",
2983 value: function notify() {
2984 _console.default.error(_objectSpread({
2985 message: this.message
2986 }, this));
2987 }
2988 }], [{
2989 key: "create",
2990 value:
2991 /**
2992 * Static helper function to create the error.
2993 *
2994 * @param {string} message
2995 * @param {string} code
2996 * @param {*} data
2997 * @return {BaseError} error
2998 */
2999 function create(message) {
3000 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3001 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3002 return new this(message, code, data);
3003 }
3004
3005 /**
3006 * Returns the status code of the error.
3007 */
3008 }, {
3009 key: "getHTTPErrorCode",
3010 value: function getHTTPErrorCode() {
3011 (0, _forceMethodImplementation.default)();
3012 }
3013 }]);
3014 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3015
3016 /***/ }),
3017
3018 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3019 /*!**********************************************************************!*\
3020 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3021 \**********************************************************************/
3022 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3023
3024 "use strict";
3025
3026
3027 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3028 Object.defineProperty(exports, "__esModule", ({
3029 value: true
3030 }));
3031 exports["default"] = exports.DefaultError = void 0;
3032 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3033 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3034 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3035 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3036 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3037 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3038 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3039 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3040 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3041 function DefaultError() {
3042 (0, _classCallCheck2.default)(this, DefaultError);
3043 return _callSuper(this, DefaultError, arguments);
3044 }
3045 (0, _inherits2.default)(DefaultError, _BaseError);
3046 return (0, _createClass2.default)(DefaultError, null, [{
3047 key: "getHTTPErrorCode",
3048 value: function getHTTPErrorCode() {
3049 return 501;
3050 }
3051 }]);
3052 }(_baseError.default);
3053 var _default = exports["default"] = DefaultError;
3054
3055 /***/ }),
3056
3057 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3058 /*!******************************************************************!*\
3059 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3060 \******************************************************************/
3061 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3062
3063 "use strict";
3064
3065
3066 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3067 Object.defineProperty(exports, "__esModule", ({
3068 value: true
3069 }));
3070 exports["default"] = exports.Error404 = void 0;
3071 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3072 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3073 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3074 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3075 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3076 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3077 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3078 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3079 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3080 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3081 function Error404() {
3082 (0, _classCallCheck2.default)(this, Error404);
3083 return _callSuper(this, Error404, arguments);
3084 }
3085 (0, _inherits2.default)(Error404, _BaseError);
3086 return (0, _createClass2.default)(Error404, [{
3087 key: "notify",
3088 value: function notify() {
3089 _console.default.warn(this.message);
3090 }
3091 }], [{
3092 key: "getHTTPErrorCode",
3093 value: function getHTTPErrorCode() {
3094 return 404;
3095 }
3096 }]);
3097 }(_baseError.default);
3098 var _default = exports["default"] = Error404;
3099
3100 /***/ }),
3101
3102 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3103 /*!**************************************************************!*\
3104 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3105 \**************************************************************/
3106 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3107
3108 "use strict";
3109
3110
3111 Object.defineProperty(exports, "__esModule", ({
3112 value: true
3113 }));
3114 Object.defineProperty(exports, "DefaultError", ({
3115 enumerable: true,
3116 get: function get() {
3117 return _defaultError.DefaultError;
3118 }
3119 }));
3120 Object.defineProperty(exports, "Error404", ({
3121 enumerable: true,
3122 get: function get() {
3123 return _error.Error404;
3124 }
3125 }));
3126 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3127 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3128
3129 /***/ }),
3130
3131 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3132 /*!************************************************************!*\
3133 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3134 \************************************************************/
3135 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3136
3137 "use strict";
3138
3139
3140 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3141 Object.defineProperty(exports, "__esModule", ({
3142 value: true
3143 }));
3144 exports["default"] = void 0;
3145 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3146 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3147 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3148 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3149 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3150 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3151 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3152 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3153 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3154 /**
3155 * @name $e.modules.CommandBase
3156 */
3157 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3158 function CommandBase() {
3159 (0, _classCallCheck2.default)(this, CommandBase);
3160 return _callSuper(this, CommandBase, arguments);
3161 }
3162 (0, _inherits2.default)(CommandBase, _CommandInfra);
3163 return (0, _createClass2.default)(CommandBase, [{
3164 key: "onBeforeRun",
3165 value: function onBeforeRun() {
3166 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3167 $e.hooks.runUIBefore(this.command, args);
3168 }
3169 }, {
3170 key: "onAfterRun",
3171 value: function onAfterRun() {
3172 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3173 var result = arguments.length > 1 ? arguments[1] : undefined;
3174 $e.hooks.runUIAfter(this.command, args, result);
3175 }
3176 }, {
3177 key: "onBeforeApply",
3178 value: function onBeforeApply() {
3179 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3180 $e.hooks.runDataDependency(this.command, args);
3181 }
3182 }, {
3183 key: "onAfterApply",
3184 value: function onAfterApply() {
3185 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3186 var result = arguments.length > 1 ? arguments[1] : undefined;
3187 return $e.hooks.runDataAfter(this.command, args, result);
3188 }
3189 }, {
3190 key: "onCatchApply",
3191 value: function onCatchApply(e) {
3192 this.runCatchHooks(e);
3193 }
3194
3195 /**
3196 * Run all the catch hooks.
3197 *
3198 * @param {Error} e
3199 */
3200 }, {
3201 key: "runCatchHooks",
3202 value: function runCatchHooks(e) {
3203 $e.hooks.runDataCatch(this.command, this.args, e);
3204 $e.hooks.runUICatch(this.command, this.args, e);
3205 }
3206
3207 /**
3208 * TODO - Remove - Backwards compatibility.
3209 *
3210 * Function requireContainer().
3211 *
3212 * Validate `arg.container` & `arg.containers`.
3213 *
3214 * @param {{}} args
3215 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3216 *
3217 * @throws {Error}
3218 */
3219 }, {
3220 key: "requireContainer",
3221 value: function requireContainer() {
3222 var _this = this;
3223 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3224 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3225 if (!args.container && !args.containers) {
3226 throw Error('container or containers are required.');
3227 }
3228 if (args.container && args.containers) {
3229 throw Error('container and containers cannot go together please select one of them.');
3230 }
3231 var containers = args.containers || [args.container];
3232 containers.forEach(function (container) {
3233 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3234 container: container
3235 });
3236 });
3237 }
3238 }], [{
3239 key: "getInstanceType",
3240 value: function getInstanceType() {
3241 return 'CommandBase';
3242 }
3243 }]);
3244 }(_commandInfra.default);
3245
3246 /***/ }),
3247
3248 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3249 /*!*********************************************************************!*\
3250 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3251 \*********************************************************************/
3252 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3253
3254 "use strict";
3255
3256
3257 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3258 Object.defineProperty(exports, "__esModule", ({
3259 value: true
3260 }));
3261 exports["default"] = void 0;
3262 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3263 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3264 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3265 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3266 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3267 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3268 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3269 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3270 /**
3271 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
3272 */
3273 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3274 function CommandCallbackBase() {
3275 (0, _classCallCheck2.default)(this, CommandCallbackBase);
3276 return _callSuper(this, CommandCallbackBase, arguments);
3277 }
3278 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
3279 return (0, _createClass2.default)(CommandCallbackBase, [{
3280 key: "apply",
3281 value: function apply() {
3282 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3283 return this.constructor.getCallback()(args);
3284 }
3285 }], [{
3286 key: "getInstanceType",
3287 value: function getInstanceType() {
3288 return 'CommandCallbackBase';
3289 }
3290
3291 /**
3292 * Get original callback of the command.
3293 *
3294 * Support pure callbacks ( Non command-base ).
3295 *
3296 * @return {()=>{}} Command Results.
3297 */
3298 }, {
3299 key: "getCallback",
3300 value: function getCallback() {
3301 return this.registerConfig.callback;
3302 }
3303 }]);
3304 }(_commandBase.default);
3305
3306 /***/ }),
3307
3308 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
3309 /*!************************************************************!*\
3310 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
3311 \************************************************************/
3312 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3313
3314 "use strict";
3315
3316
3317 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3318 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
3319 Object.defineProperty(exports, "__esModule", ({
3320 value: true
3321 }));
3322 exports["default"] = void 0;
3323 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3324 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3325 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3326 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3327 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3328 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3329 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3330 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
3331 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
3332 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3333 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3334 /**
3335 * @name $e.modules.CommandData
3336 */
3337 /**
3338 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
3339 */
3340 /**
3341 * @typedef {{}} RequestData
3342 */
3343 /**
3344 * @typedef {import('../core/data/errors/base-error')} BaseError
3345 */
3346 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3347 function CommandData(args) {
3348 var _this$args$options;
3349 var _this;
3350 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
3351 (0, _classCallCheck2.default)(this, CommandData);
3352 _this = _callSuper(this, CommandData, [args, commandsAPI]);
3353 /**
3354 * Data returned from remote.
3355 *
3356 * @type {*}
3357 */
3358 (0, _defineProperty2.default)(_this, "data", void 0);
3359 /**
3360 * Fetch type.
3361 *
3362 * @type {DataTypes}
3363 */
3364 (0, _defineProperty2.default)(_this, "type", void 0);
3365 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
3366 _this.type = _this.args.options.type;
3367 }
3368 return _this;
3369 }
3370
3371 /**
3372 * Function getEndpointFormat().
3373 *
3374 * @return {null|string} endpoint format
3375 */
3376 (0, _inherits2.default)(CommandData, _CommandBase);
3377 return (0, _createClass2.default)(CommandData, [{
3378 key: "getApplyMethods",
3379 value:
3380 /**
3381 * @param {DataTypes} type
3382 *
3383 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
3384 */
3385 function getApplyMethods() {
3386 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
3387 var before, after;
3388 switch (type) {
3389 case 'create':
3390 before = this.applyBeforeCreate;
3391 after = this.applyAfterCreate;
3392 break;
3393 case 'delete':
3394 before = this.applyBeforeDelete;
3395 after = this.applyAfterDelete;
3396 break;
3397 case 'get':
3398 before = this.applyBeforeGet;
3399 after = this.applyAfterGet;
3400 break;
3401 case 'update':
3402 before = this.applyBeforeUpdate;
3403 after = this.applyAfterUpdate;
3404 break;
3405 case 'options':
3406 before = this.applyBeforeOptions;
3407 after = this.applyAfterOptions;
3408 break;
3409 default:
3410 return false;
3411 }
3412 return {
3413 before: before.bind(this),
3414 after: after.bind(this)
3415 };
3416 }
3417
3418 /**
3419 * Function getRequestData().
3420 *
3421 * @return {RequestData} request data
3422 */
3423 }, {
3424 key: "getRequestData",
3425 value: function getRequestData() {
3426 return {
3427 type: this.type,
3428 args: this.args,
3429 timestamp: new Date().getTime(),
3430 component: this.component,
3431 command: this.command,
3432 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
3433 };
3434 }
3435 }, {
3436 key: "apply",
3437 value: function apply() {
3438 var _this2 = this;
3439 var applyMethods = this.getApplyMethods();
3440
3441 // Run 'before' method.
3442 this.args = applyMethods.before(this.args);
3443 var requestData = this.getRequestData();
3444 return $e.data.fetch(requestData).then(function (data) {
3445 _this2.data = data;
3446
3447 // Run 'after' method.
3448 _this2.data = applyMethods.after(data, _this2.args);
3449 _this2.data = {
3450 data: _this2.data
3451 };
3452
3453 // Append requestData.
3454 _this2.data = Object.assign({
3455 __requestData__: requestData
3456 }, _this2.data);
3457 return _this2.data;
3458 });
3459 }
3460
3461 /**
3462 * @param {*} [args={}]
3463 * @return {{}} filtered args
3464 */
3465 }, {
3466 key: "applyBeforeCreate",
3467 value: function applyBeforeCreate() {
3468 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3469 return args;
3470 }
3471
3472 /**
3473 * @param {{}} data
3474 * @param {*} [args={}]
3475 * @return {{}} filtered result
3476 */
3477 }, {
3478 key: "applyAfterCreate",
3479 value: function applyAfterCreate(data) {
3480 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3481 // eslint-disable-line no-unused-vars
3482 return data;
3483 }
3484
3485 /**
3486 * @param {*} [args={}]
3487 * @return {{}} filtered args
3488 */
3489 }, {
3490 key: "applyBeforeDelete",
3491 value: function applyBeforeDelete() {
3492 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3493 return args;
3494 }
3495
3496 /**
3497 * @param {{}} data
3498 * @param {*} [args={}]
3499 * @return {{}} filtered result
3500 */
3501 }, {
3502 key: "applyAfterDelete",
3503 value: function applyAfterDelete(data) {
3504 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3505 // eslint-disable-line no-unused-vars
3506 return data;
3507 }
3508
3509 /**
3510 * @param {*} [args={}]
3511 * @return {{}} filtered args
3512 */
3513 }, {
3514 key: "applyBeforeGet",
3515 value: function applyBeforeGet() {
3516 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3517 return args;
3518 }
3519
3520 /**
3521 * @param {{}} data
3522 * @param {*} [args={}]
3523 * @return {{}} filtered result
3524 */
3525 }, {
3526 key: "applyAfterGet",
3527 value: function applyAfterGet(data) {
3528 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3529 // eslint-disable-line no-unused-vars
3530 return data;
3531 }
3532
3533 /**
3534 * @param {*} [args={}]
3535 * @return {{}} filtered args
3536 */
3537 }, {
3538 key: "applyBeforeUpdate",
3539 value: function applyBeforeUpdate() {
3540 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3541 return args;
3542 }
3543
3544 /**
3545 * @param {{}} data
3546 * @param {*} [args={}]
3547 * @return {{}} filtered result
3548 */
3549 }, {
3550 key: "applyAfterUpdate",
3551 value: function applyAfterUpdate(data) {
3552 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3553 // eslint-disable-line no-unused-vars
3554 return data;
3555 }
3556
3557 /**
3558 * @param {*} [args={}]
3559 * @return {{}} filtered args
3560 */
3561 }, {
3562 key: "applyBeforeOptions",
3563 value: function applyBeforeOptions() {
3564 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3565 return args;
3566 }
3567
3568 /**
3569 * @param {{}} data
3570 * @param {*} [args={}]
3571 * @return {{}} filtered result
3572 */
3573 }, {
3574 key: "applyAfterOptions",
3575 value: function applyAfterOptions(data) {
3576 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3577 // eslint-disable-line no-unused-vars
3578 return data;
3579 }
3580
3581 /**
3582 * @param {BaseError} e
3583 */
3584 }, {
3585 key: "applyAfterCatch",
3586 value: function applyAfterCatch(e) {
3587 e.notify();
3588 }
3589 }, {
3590 key: "onCatchApply",
3591 value: function onCatchApply(e) {
3592 var _e;
3593 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
3594 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
3595 var dataError = Object.values(errors).find(function (error) {
3596 return error.getHTTPErrorCode() === httpErrorCode;
3597 });
3598 if (!dataError) {
3599 dataError = errors.DefaultError;
3600 }
3601 e = dataError.create(e.message, e.code, e.data || []);
3602 this.runCatchHooks(e);
3603 this.applyAfterCatch(e);
3604 }
3605 }], [{
3606 key: "getInstanceType",
3607 value: function getInstanceType() {
3608 return 'CommandData';
3609 }
3610 }, {
3611 key: "getEndpointFormat",
3612 value: function getEndpointFormat() {
3613 return null;
3614 }
3615 }]);
3616 }(_commandBase.default);
3617
3618 /***/ }),
3619
3620 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
3621 /*!*************************************************************!*\
3622 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
3623 \*************************************************************/
3624 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3625
3626 "use strict";
3627
3628
3629 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3630 Object.defineProperty(exports, "__esModule", ({
3631 value: true
3632 }));
3633 exports["default"] = void 0;
3634 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3635 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3636 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3637 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3638 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3639 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3640 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
3641 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3642 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3643 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3644 /**
3645 * @typedef {import('../modules/component-base')} ComponentBase
3646 */
3647 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
3648 /**
3649 * Function constructor().
3650 *
3651 * Create Commands Base.
3652 *
3653 * @param {{}} args
3654 */
3655 function CommandInfra() {
3656 var _this;
3657 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3658 (0, _classCallCheck2.default)(this, CommandInfra);
3659 _this = _callSuper(this, CommandInfra, [args]);
3660 if (!_this.constructor.registerConfig) {
3661 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
3662 }
3663
3664 // Acknowledge self about which command it run.
3665 _this.command = _this.constructor.getCommand();
3666
3667 // Assign instance of current component.
3668 _this.component = _this.constructor.getComponent();
3669
3670 // Who ever need do something before without `super` the constructor can use `initialize` method.
3671 _this.initialize(args);
3672
3673 // Refresh args, maybe the changed via `initialize`.
3674 args = _this.args;
3675
3676 // Validate args before run.
3677 _this.validateArgs(args);
3678 return _this;
3679 }
3680
3681 /**
3682 * Function initialize().
3683 *
3684 * Initialize command, called after construction.
3685 *
3686 * @param {{}} args
3687 */
3688 (0, _inherits2.default)(CommandInfra, _ArgsObject);
3689 return (0, _createClass2.default)(CommandInfra, [{
3690 key: "currentCommand",
3691 get:
3692 /**
3693 * @deprecated since 3.7.0, use `this.command` instead.
3694 */
3695 function get() {
3696 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
3697 return this.command;
3698 }
3699 }, {
3700 key: "initialize",
3701 value: function initialize() {
3702 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3703 } // eslint-disable-line no-unused-vars
3704
3705 /**
3706 * Function validateArgs().
3707 *
3708 * Validate command arguments.
3709 *
3710 * @param {{}} args
3711 */
3712 }, {
3713 key: "validateArgs",
3714 value: function validateArgs() {
3715 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3716 } // eslint-disable-line no-unused-vars
3717
3718 // eslint-disable-next-line jsdoc/require-returns-check
3719 /**
3720 * Function apply().
3721 *
3722 * Do the actual command.
3723 *
3724 * @param {{}} args
3725 *
3726 * @return {*} Command results.
3727 */
3728 }, {
3729 key: "apply",
3730 value: function apply() {
3731 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3732 // eslint-disable-line no-unused-vars
3733 elementorModules.ForceMethodImplementation();
3734 }
3735
3736 /**
3737 * Function run().
3738 *
3739 * Run command with history & hooks.
3740 *
3741 * @return {*} Command results.
3742 */
3743 }, {
3744 key: "run",
3745 value: function run() {
3746 return this.apply(this.args);
3747 }
3748
3749 /**
3750 * Function onBeforeRun.
3751 *
3752 * Called before run().
3753 *
3754 * @param {{}} args
3755 */
3756 }, {
3757 key: "onBeforeRun",
3758 value: function onBeforeRun() {
3759 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3760 } // eslint-disable-line no-unused-vars
3761
3762 /**
3763 * Function onAfterRun.
3764 *
3765 * Called after run().
3766 *
3767 * @param {{}} args
3768 * @param {*} result
3769 */
3770 }, {
3771 key: "onAfterRun",
3772 value: function onAfterRun() {
3773 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3774 var result = arguments.length > 1 ? arguments[1] : undefined;
3775 } // eslint-disable-line no-unused-vars
3776
3777 /**
3778 * Function onBeforeApply.
3779 *
3780 * Called before apply().
3781 *
3782 * @param {{}} args
3783 */
3784 }, {
3785 key: "onBeforeApply",
3786 value: function onBeforeApply() {
3787 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3788 } // eslint-disable-line no-unused-vars
3789
3790 /**
3791 * Function onAfterApply.
3792 *
3793 * Called after apply().
3794 *
3795 * @param {{}} args
3796 * @param {*} result
3797 */
3798 }, {
3799 key: "onAfterApply",
3800 value: function onAfterApply() {
3801 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3802 var result = arguments.length > 1 ? arguments[1] : undefined;
3803 } // eslint-disable-line no-unused-vars
3804
3805 /**
3806 * Function onCatchApply.
3807 *
3808 * Called after apply() failed.
3809 *
3810 * @param {Error} e
3811 */
3812 }, {
3813 key: "onCatchApply",
3814 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
3815 }], [{
3816 key: "getInstanceType",
3817 value: function getInstanceType() {
3818 return 'CommandInfra';
3819 }
3820
3821 /**
3822 * Get info of command.
3823 *
3824 * @return {Object} Extra information about the command.
3825 */
3826 }, {
3827 key: "getInfo",
3828 value: function getInfo() {
3829 return {};
3830 }
3831
3832 /**
3833 * @return {string} Self command name.
3834 */
3835 }, {
3836 key: "getCommand",
3837 value: function getCommand() {
3838 return this.registerConfig.command;
3839 }
3840
3841 /**
3842 * @return {ComponentBase} Self component
3843 */
3844 }, {
3845 key: "getComponent",
3846 value: function getComponent() {
3847 return this.registerConfig.component;
3848 }
3849 }, {
3850 key: "setRegisterConfig",
3851 value: function setRegisterConfig(config) {
3852 this.registerConfig = Object.freeze(config);
3853 }
3854 }]);
3855 }(_argsObject.default);
3856 /**
3857 * @type {Object}
3858 */
3859 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
3860
3861 /***/ }),
3862
3863 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
3864 /*!**************************************************************!*\
3865 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
3866 \**************************************************************/
3867 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3868
3869 "use strict";
3870
3871
3872 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3873 Object.defineProperty(exports, "__esModule", ({
3874 value: true
3875 }));
3876 exports["default"] = exports.Close = void 0;
3877 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3878 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3879 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3880 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3881 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3882 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3883 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3884 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3885 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
3886 function Close() {
3887 (0, _classCallCheck2.default)(this, Close);
3888 return _callSuper(this, Close, arguments);
3889 }
3890 (0, _inherits2.default)(Close, _CommandBase);
3891 return (0, _createClass2.default)(Close, [{
3892 key: "apply",
3893 value: function apply() {
3894 this.component.close();
3895 }
3896 }]);
3897 }(_commandBase.default);
3898 var _default = exports["default"] = Close;
3899
3900 /***/ }),
3901
3902 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
3903 /*!**************************************************************!*\
3904 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
3905 \**************************************************************/
3906 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3907
3908 "use strict";
3909
3910
3911 Object.defineProperty(exports, "__esModule", ({
3912 value: true
3913 }));
3914 Object.defineProperty(exports, "Close", ({
3915 enumerable: true,
3916 get: function get() {
3917 return _close.Close;
3918 }
3919 }));
3920 Object.defineProperty(exports, "Open", ({
3921 enumerable: true,
3922 get: function get() {
3923 return _open.Open;
3924 }
3925 }));
3926 Object.defineProperty(exports, "Toggle", ({
3927 enumerable: true,
3928 get: function get() {
3929 return _toggle.Toggle;
3930 }
3931 }));
3932 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
3933 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
3934 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
3935
3936 /***/ }),
3937
3938 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
3939 /*!*************************************************************!*\
3940 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
3941 \*************************************************************/
3942 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3943
3944 "use strict";
3945
3946
3947 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3948 Object.defineProperty(exports, "__esModule", ({
3949 value: true
3950 }));
3951 exports["default"] = exports.Open = void 0;
3952 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3953 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3954 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3955 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3956 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3957 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3958 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3959 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3960 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
3961 function Open() {
3962 (0, _classCallCheck2.default)(this, Open);
3963 return _callSuper(this, Open, arguments);
3964 }
3965 (0, _inherits2.default)(Open, _CommandBase);
3966 return (0, _createClass2.default)(Open, [{
3967 key: "apply",
3968 value: function apply() {
3969 $e.route(this.component.getNamespace());
3970 }
3971 }]);
3972 }(_commandBase.default);
3973 var _default = exports["default"] = Open;
3974
3975 /***/ }),
3976
3977 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
3978 /*!***************************************************************!*\
3979 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
3980 \***************************************************************/
3981 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3982
3983 "use strict";
3984
3985
3986 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3987 Object.defineProperty(exports, "__esModule", ({
3988 value: true
3989 }));
3990 exports["default"] = exports.Toggle = void 0;
3991 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3992 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3993 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3994 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3995 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3996 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3997 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
3998 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3999 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4000 function Toggle() {
4001 (0, _classCallCheck2.default)(this, Toggle);
4002 return _callSuper(this, Toggle, arguments);
4003 }
4004 (0, _inherits2.default)(Toggle, _CommandBase);
4005 return (0, _createClass2.default)(Toggle, [{
4006 key: "apply",
4007 value: function apply() {
4008 if (this.component.isOpen) {
4009 this.component.close();
4010 } else {
4011 $e.route(this.component.getNamespace());
4012 }
4013 }
4014 }]);
4015 }(_commandBase.default);
4016 var _default = exports["default"] = Toggle;
4017
4018 /***/ }),
4019
4020 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4021 /*!**************************************************************!*\
4022 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4023 \**************************************************************/
4024 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4025
4026 "use strict";
4027
4028
4029 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4030 Object.defineProperty(exports, "__esModule", ({
4031 value: true
4032 }));
4033 exports["default"] = void 0;
4034 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4035 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4036 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4037 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4038 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4039 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4040 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4041 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4042 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4043 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4044 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4045 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4046 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4047 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4048 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
4049 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4050 /**
4051 * @typedef {import('./command-infra')} CommandInfra
4052 * @typedef {import('./hook-base')} HookBase
4053 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4054 */
4055 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4056 function ComponentBase() {
4057 (0, _classCallCheck2.default)(this, ComponentBase);
4058 return _callSuper(this, ComponentBase, arguments);
4059 }
4060 (0, _inherits2.default)(ComponentBase, _Module);
4061 return (0, _createClass2.default)(ComponentBase, [{
4062 key: "__construct",
4063 value: function __construct() {
4064 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4065 if (args.manager) {
4066 this.manager = args.manager;
4067 }
4068 this.commands = this.defaultCommands();
4069 this.commandsInternal = this.defaultCommandsInternal();
4070 this.hooks = this.defaultHooks();
4071 this.routes = this.defaultRoutes();
4072 this.tabs = this.defaultTabs();
4073 this.shortcuts = this.defaultShortcuts();
4074 this.utils = this.defaultUtils();
4075 this.data = this.defaultData();
4076 this.uiStates = this.defaultUiStates();
4077 this.states = this.defaultStates();
4078 this.defaultRoute = '';
4079 this.currentTab = '';
4080 }
4081 }, {
4082 key: "registerAPI",
4083 value: function registerAPI() {
4084 var _this = this;
4085 Object.entries(this.getTabs()).forEach(function (tab) {
4086 return _this.registerTabRoute(tab[0]);
4087 });
4088 Object.entries(this.getRoutes()).forEach(function (_ref) {
4089 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4090 route = _ref2[0],
4091 callback = _ref2[1];
4092 return _this.registerRoute(route, callback);
4093 });
4094 Object.entries(this.getCommands()).forEach(function (_ref3) {
4095 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4096 command = _ref4[0],
4097 callback = _ref4[1];
4098 return _this.registerCommand(command, callback);
4099 });
4100 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4101 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4102 command = _ref6[0],
4103 callback = _ref6[1];
4104 return _this.registerCommandInternal(command, callback);
4105 });
4106 Object.values(this.getHooks()).forEach(function (instance) {
4107 return _this.registerHook(instance);
4108 });
4109 Object.entries(this.getData()).forEach(function (_ref7) {
4110 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4111 command = _ref8[0],
4112 callback = _ref8[1];
4113 return _this.registerData(command, callback);
4114 });
4115 Object.values(this.getUiStates()).forEach(function (instance) {
4116 return _this.registerUiState(instance);
4117 });
4118 Object.entries(this.getStates()).forEach(function (_ref9) {
4119 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4120 id = _ref0[0],
4121 state = _ref0[1];
4122 return _this.registerState(id, state);
4123 });
4124 }
4125
4126 // eslint-disable-next-line jsdoc/require-returns-check
4127 /**
4128 * @return {string} namespace
4129 */
4130 }, {
4131 key: "getNamespace",
4132 value: function getNamespace() {
4133 (0, _forceMethodImplementation.default)();
4134 }
4135
4136 /**
4137 * @deprecated since 3.7.0, use `getServiceName()` instead.
4138 */
4139 }, {
4140 key: "getRootContainer",
4141 value: function getRootContainer() {
4142 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4143 return this.getServiceName();
4144 }
4145 }, {
4146 key: "getServiceName",
4147 value: function getServiceName() {
4148 return this.getNamespace().split('/')[0];
4149 }
4150 }, {
4151 key: "store",
4152 get: function get() {
4153 return $e.store.get(this.getNamespace());
4154 }
4155 }, {
4156 key: "defaultTabs",
4157 value: function defaultTabs() {
4158 return {};
4159 }
4160 }, {
4161 key: "defaultRoutes",
4162 value: function defaultRoutes() {
4163 return {};
4164 }
4165 }, {
4166 key: "defaultCommands",
4167 value: function defaultCommands() {
4168 return {};
4169 }
4170 }, {
4171 key: "defaultCommandsInternal",
4172 value: function defaultCommandsInternal() {
4173 return {};
4174 }
4175 }, {
4176 key: "defaultHooks",
4177 value: function defaultHooks() {
4178 return {};
4179 }
4180
4181 /**
4182 * Get the component's default UI states.
4183 *
4184 * @return {Object} default UI states
4185 */
4186 }, {
4187 key: "defaultUiStates",
4188 value: function defaultUiStates() {
4189 return {};
4190 }
4191
4192 /**
4193 * Get the component's Redux slice settings.
4194 *
4195 * @return {Object} Redux slice settings
4196 */
4197 }, {
4198 key: "defaultStates",
4199 value: function defaultStates() {
4200 return {};
4201 }
4202 }, {
4203 key: "defaultShortcuts",
4204 value: function defaultShortcuts() {
4205 return {};
4206 }
4207 }, {
4208 key: "defaultUtils",
4209 value: function defaultUtils() {
4210 return {};
4211 }
4212 }, {
4213 key: "defaultData",
4214 value: function defaultData() {
4215 return {};
4216 }
4217 }, {
4218 key: "getCommands",
4219 value: function getCommands() {
4220 return this.commands;
4221 }
4222 }, {
4223 key: "getCommandsInternal",
4224 value: function getCommandsInternal() {
4225 return this.commandsInternal;
4226 }
4227 }, {
4228 key: "getHooks",
4229 value: function getHooks() {
4230 return this.hooks;
4231 }
4232
4233 /**
4234 * Retrieve the component's UI states.
4235 *
4236 * @return {Object} UI states
4237 */
4238 }, {
4239 key: "getUiStates",
4240 value: function getUiStates() {
4241 return this.uiStates;
4242 }
4243
4244 /**
4245 * Retrieve the component's Redux Slice.
4246 *
4247 * @return {Object} Redux Slice
4248 */
4249 }, {
4250 key: "getStates",
4251 value: function getStates() {
4252 return this.states;
4253 }
4254 }, {
4255 key: "getRoutes",
4256 value: function getRoutes() {
4257 return this.routes;
4258 }
4259 }, {
4260 key: "getTabs",
4261 value: function getTabs() {
4262 return this.tabs;
4263 }
4264 }, {
4265 key: "getShortcuts",
4266 value: function getShortcuts() {
4267 return this.shortcuts;
4268 }
4269 }, {
4270 key: "getData",
4271 value: function getData() {
4272 return this.data;
4273 }
4274
4275 /**
4276 * @param {string} command
4277 * @param {(()=>{}|CommandInfra)} context
4278 * @param {'default'|'internal'|'data'} commandsType
4279 */
4280 }, {
4281 key: "registerCommand",
4282 value: function registerCommand(command, context) {
4283 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
4284 var commandsManager;
4285 switch (commandsType) {
4286 case 'default':
4287 commandsManager = $e.commands;
4288 break;
4289 case 'internal':
4290 commandsManager = $e.commandsInternal;
4291 break;
4292 case 'data':
4293 commandsManager = $e.data;
4294 break;
4295 default:
4296 throw new Error("Invalid commands type: '".concat(command, "'"));
4297 }
4298 var fullCommand = this.getNamespace() + '/' + command,
4299 instanceType = context.getInstanceType ? context.getInstanceType() : false,
4300 registerConfig = {
4301 command: fullCommand,
4302 component: this
4303 };
4304
4305 // Support pure callback.
4306 if (!instanceType) {
4307 if ($e.devTools) {
4308 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
4309 }
4310 registerConfig.callback = context;
4311
4312 // Unique class.
4313 context = /*#__PURE__*/function (_CommandCallbackBase) {
4314 function context() {
4315 (0, _classCallCheck2.default)(this, context);
4316 return _callSuper(this, context, arguments);
4317 }
4318 (0, _inherits2.default)(context, _CommandCallbackBase);
4319 return (0, _createClass2.default)(context);
4320 }(_commandCallbackBase.default);
4321 }
4322 context.setRegisterConfig(registerConfig);
4323 commandsManager.register(this, command, context);
4324 }
4325
4326 /**
4327 * @param {HookBase} instance
4328 */
4329 }, {
4330 key: "registerHook",
4331 value: function registerHook(instance) {
4332 return instance.register();
4333 }
4334 }, {
4335 key: "registerCommandInternal",
4336 value: function registerCommandInternal(command, context) {
4337 this.registerCommand(command, context, 'internal');
4338 }
4339
4340 /**
4341 * Register a UI state.
4342 *
4343 * @param {UiStateBase} instance - UI state instance.
4344 *
4345 * @return {void}
4346 */
4347 }, {
4348 key: "registerUiState",
4349 value: function registerUiState(instance) {
4350 $e.uiStates.register(instance);
4351 }
4352
4353 /**
4354 * Register a Redux Slice.
4355 *
4356 * @param {string} id - State id.
4357 * @param {Object} stateConfig - The state config.
4358 *
4359 * @return {void}
4360 */
4361 }, {
4362 key: "registerState",
4363 value: function registerState(id, stateConfig) {
4364 id = this.getNamespace() + (id ? "/".concat(id) : '');
4365 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
4366 name: id
4367 }));
4368 $e.store.register(id, slice);
4369 }
4370 }, {
4371 key: "registerRoute",
4372 value: function registerRoute(route, callback) {
4373 $e.routes.register(this, route, callback);
4374 }
4375 }, {
4376 key: "registerData",
4377 value: function registerData(command, context) {
4378 this.registerCommand(command, context, 'data');
4379 }
4380 }, {
4381 key: "unregisterRoute",
4382 value: function unregisterRoute(route) {
4383 $e.routes.unregister(this, route);
4384 }
4385 }, {
4386 key: "registerTabRoute",
4387 value: function registerTabRoute(tab) {
4388 var _this2 = this;
4389 this.registerRoute(tab, function (args) {
4390 return _this2.activateTab(tab, args);
4391 });
4392 }
4393 }, {
4394 key: "dependency",
4395 value: function dependency() {
4396 return true;
4397 }
4398 }, {
4399 key: "open",
4400 value: function open() {
4401 return true;
4402 }
4403 }, {
4404 key: "close",
4405 value: function close() {
4406 if (!this.isOpen) {
4407 return false;
4408 }
4409 this.isOpen = false;
4410 this.inactivate();
4411 $e.routes.clearCurrent(this.getNamespace());
4412 $e.routes.clearHistory(this.getServiceName());
4413 return true;
4414 }
4415 }, {
4416 key: "activate",
4417 value: function activate() {
4418 $e.components.activate(this.getNamespace());
4419 }
4420 }, {
4421 key: "inactivate",
4422 value: function inactivate() {
4423 $e.components.inactivate(this.getNamespace());
4424 }
4425 }, {
4426 key: "isActive",
4427 value: function isActive() {
4428 return $e.components.isActive(this.getNamespace());
4429 }
4430 }, {
4431 key: "onRoute",
4432 value: function onRoute(route) {
4433 this.toggleRouteClass(route, true);
4434 this.toggleHistoryClass();
4435 this.activate();
4436 this.trigger('route/open', route);
4437 }
4438 }, {
4439 key: "onCloseRoute",
4440 value: function onCloseRoute(route) {
4441 this.toggleRouteClass(route, false);
4442 this.inactivate();
4443 this.trigger('route/close', route);
4444 }
4445 }, {
4446 key: "setDefaultRoute",
4447 value: function setDefaultRoute(route) {
4448 this.defaultRoute = this.getNamespace() + '/' + route;
4449 }
4450 }, {
4451 key: "getDefaultRoute",
4452 value: function getDefaultRoute() {
4453 return this.defaultRoute;
4454 }
4455 }, {
4456 key: "removeTab",
4457 value: function removeTab(tab) {
4458 delete this.tabs[tab];
4459 this.unregisterRoute(tab);
4460 }
4461 }, {
4462 key: "hasTab",
4463 value: function hasTab(tab) {
4464 return !!this.tabs[tab];
4465 }
4466 }, {
4467 key: "addTab",
4468 value: function addTab(tab, args, position) {
4469 var _this3 = this;
4470 this.tabs[tab] = args;
4471 // It can be 0.
4472 if ('undefined' !== typeof position) {
4473 var newTabs = {};
4474 var ids = Object.keys(this.tabs);
4475 // Remove new tab
4476 ids.pop();
4477
4478 // Add it to position.
4479 ids.splice(position, 0, tab);
4480 ids.forEach(function (id) {
4481 newTabs[id] = _this3.tabs[id];
4482 });
4483 this.tabs = newTabs;
4484 }
4485 this.registerTabRoute(tab);
4486 }
4487 }, {
4488 key: "getTabsWrapperSelector",
4489 value: function getTabsWrapperSelector() {
4490 return '';
4491 }
4492 }, {
4493 key: "getTabRoute",
4494 value: function getTabRoute(tab) {
4495 return this.getNamespace() + '/' + tab;
4496 }
4497 }, {
4498 key: "renderTab",
4499 value: function renderTab(tab) {} // eslint-disable-line
4500 }, {
4501 key: "activateTab",
4502 value: function activateTab(tab, args) {
4503 var _this4 = this;
4504 this.renderTab(tab, args);
4505 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
4506 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
4507 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
4508 }
4509 }, {
4510 key: "getActiveTabConfig",
4511 value: function getActiveTabConfig() {
4512 return this.tabs[this.currentTab] || {};
4513 }
4514 }, {
4515 key: "getBodyClass",
4516 value: function getBodyClass(route) {
4517 return 'e-route-' + route.replace(/\//g, '-');
4518 }
4519
4520 /**
4521 * If command includes uppercase character convert it to lowercase and add `-`.
4522 * e.g: `CopyAll` is converted to `copy-all`.
4523 *
4524 * @param {string} commandName
4525 */
4526 }, {
4527 key: "normalizeCommandName",
4528 value: function normalizeCommandName(commandName) {
4529 return commandName.replace(/[A-Z]/g, function (match, offset) {
4530 return (offset > 0 ? '-' : '') + match.toLowerCase();
4531 });
4532 }
4533
4534 /**
4535 * @param {{}} commandsFromImport
4536 * @return {{}} imported commands
4537 */
4538 }, {
4539 key: "importCommands",
4540 value: function importCommands(commandsFromImport) {
4541 var _this5 = this;
4542 var commands = {};
4543
4544 // Convert `Commands` to `ComponentBase` workable format.
4545 Object.entries(commandsFromImport).forEach(function (_ref1) {
4546 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
4547 className = _ref10[0],
4548 Class = _ref10[1];
4549 var command = _this5.normalizeCommandName(className);
4550 commands[command] = Class;
4551 });
4552 return commands;
4553 }
4554 }, {
4555 key: "importHooks",
4556 value: function importHooks(hooksFromImport) {
4557 var hooks = {};
4558 for (var key in hooksFromImport) {
4559 var hook = new hooksFromImport[key]();
4560 hooks[hook.getId()] = hook;
4561 }
4562 return hooks;
4563 }
4564
4565 /**
4566 * Import & initialize the component's UI states.
4567 * Should be used inside `defaultUiState()`.
4568 *
4569 * @param {Object} statesFromImport - UI states from import.
4570 *
4571 * @return {Object} UI States
4572 */
4573 }, {
4574 key: "importUiStates",
4575 value: function importUiStates(statesFromImport) {
4576 var _this6 = this;
4577 var uiStates = {};
4578 Object.values(statesFromImport).forEach(function (className) {
4579 var uiState = new className(_this6);
4580 uiStates[uiState.getId()] = uiState;
4581 });
4582 return uiStates;
4583 }
4584
4585 /**
4586 * Set a UI state value.
4587 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
4588 *
4589 * @param {string} state - Non-prefixed state ID.
4590 * @param {*} value - New state value.
4591 *
4592 * @return {void}
4593 */
4594 }, {
4595 key: "setUiState",
4596 value: function setUiState(state, value) {
4597 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
4598 }
4599 }, {
4600 key: "toggleRouteClass",
4601 value: function toggleRouteClass(route, state) {
4602 document.body.classList.toggle(this.getBodyClass(route), state);
4603 }
4604 }, {
4605 key: "toggleHistoryClass",
4606 value: function toggleHistoryClass() {
4607 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
4608 }
4609 }]);
4610 }(_module.default);
4611
4612 /***/ }),
4613
4614 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
4615 /*!********************************************************************!*\
4616 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
4617 \********************************************************************/
4618 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4619
4620 "use strict";
4621
4622
4623 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4624 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4625 Object.defineProperty(exports, "__esModule", ({
4626 value: true
4627 }));
4628 exports["default"] = void 0;
4629 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
4630 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4631 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4632 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4633 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4634 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
4635 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4636 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
4637 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
4638 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4639 function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
4640 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
4641 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4642 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
4643 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
4644 function ComponentModalBase() {
4645 (0, _classCallCheck2.default)(this, ComponentModalBase);
4646 return _callSuper(this, ComponentModalBase, arguments);
4647 }
4648 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
4649 return (0, _createClass2.default)(ComponentModalBase, [{
4650 key: "registerAPI",
4651 value: function registerAPI() {
4652 var _this = this;
4653 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
4654 $e.shortcuts.register('esc', {
4655 scopes: [this.getNamespace()],
4656 callback: function callback() {
4657 return _this.close();
4658 }
4659 });
4660 }
4661 }, {
4662 key: "defaultCommands",
4663 value: function defaultCommands() {
4664 return this.importCommands(commands);
4665 }
4666 }, {
4667 key: "defaultRoutes",
4668 value: function defaultRoutes() {
4669 return {
4670 '': function _() {/* Nothing to do, it's already rendered. */}
4671 };
4672 }
4673 }, {
4674 key: "open",
4675 value: function open() {
4676 var _this2 = this;
4677 if (!this.layout) {
4678 var layout = this.getModalLayout();
4679 this.layout = new layout({
4680 component: this
4681 });
4682 this.layout.getModal().on('hide', function () {
4683 return _this2.close();
4684 });
4685 }
4686 this.layout.showModal();
4687 return true;
4688 }
4689 }, {
4690 key: "close",
4691 value: function close() {
4692 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
4693 return false;
4694 }
4695 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
4696 close();
4697 return true;
4698 }
4699 }, {
4700 key: "getModalLayout",
4701 value: function getModalLayout() {
4702 (0, _forceMethodImplementation.default)();
4703 }
4704 }]);
4705 }(_componentBase.default);
4706
4707 /***/ }),
4708
4709 /***/ "../modules/web-cli/assets/js/utils/console.js":
4710 /*!*****************************************************!*\
4711 !*** ../modules/web-cli/assets/js/utils/console.js ***!
4712 \*****************************************************/
4713 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4714
4715 "use strict";
4716
4717
4718 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4719 Object.defineProperty(exports, "__esModule", ({
4720 value: true
4721 }));
4722 exports["default"] = void 0;
4723 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4724 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4725 var Console = exports["default"] = /*#__PURE__*/function () {
4726 function Console() {
4727 (0, _classCallCheck2.default)(this, Console);
4728 }
4729 return (0, _createClass2.default)(Console, null, [{
4730 key: "error",
4731 value: function error(message) {
4732 // Show an error if devTools is available.
4733 if ($e.devTools) {
4734 $e.devTools.log.error(message);
4735 }
4736
4737 // If not a 'Hook-Break' then show error.
4738 if (!(message instanceof $e.modules.HookBreak)) {
4739 // eslint-disable-next-line no-console
4740 console.error(message);
4741 }
4742 }
4743 }, {
4744 key: "warn",
4745 value: function warn() {
4746 var _console;
4747 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
4748 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4749 args[_key] = arguments[_key];
4750 }
4751 args.unshift('%c %c', style, '');
4752 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
4753 }
4754 }]);
4755 }();
4756
4757 /***/ }),
4758
4759 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
4760 /*!*********************************************************!*\
4761 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
4762 \*********************************************************/
4763 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4764
4765 "use strict";
4766
4767
4768 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4769 Object.defineProperty(exports, "__esModule", ({
4770 value: true
4771 }));
4772 exports["default"] = void 0;
4773 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4774 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4775 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4776 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
4777 // Copied from `modules/dev-tools/assets/js/deprecation.js`
4778 /**
4779 * @typedef {Object} Version
4780 * @property {number} major1 The first number
4781 * @property {number} major2 The second number
4782 * @property {number} minor The third number
4783 * @property {string} build The fourth number
4784 */
4785
4786 var softDeprecated = function softDeprecated(name, version, replacement) {
4787 if (elementorWebCliConfig.isDebug) {
4788 deprecatedMessage('soft', name, version, replacement);
4789 }
4790 };
4791 var hardDeprecated = function hardDeprecated(name, version, replacement) {
4792 deprecatedMessage('hard', name, version, replacement);
4793 };
4794 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
4795 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
4796 if (replacement) {
4797 message += " - Use `".concat(replacement, "` instead");
4798 }
4799 _console.default.warn(message);
4800 };
4801 var Deprecation = exports["default"] = /*#__PURE__*/function () {
4802 function Deprecation() {
4803 (0, _classCallCheck2.default)(this, Deprecation);
4804 }
4805 return (0, _createClass2.default)(Deprecation, null, [{
4806 key: "deprecated",
4807 value: function deprecated(name, version, replacement) {
4808 if (this.isHardDeprecated(version)) {
4809 hardDeprecated(name, version, replacement);
4810 } else {
4811 softDeprecated(name, version, replacement);
4812 }
4813 }
4814
4815 /**
4816 * @param {string} version
4817 *
4818 * @return {Version}
4819 */
4820 }, {
4821 key: "parseVersion",
4822 value: function parseVersion(version) {
4823 var versionParts = version.split('.');
4824 if (versionParts.length < 3 || versionParts.length > 4) {
4825 throw new RangeError('Invalid Semantic Version string provided');
4826 }
4827 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
4828 major1 = _versionParts[0],
4829 major2 = _versionParts[1],
4830 minor = _versionParts[2],
4831 _versionParts$ = _versionParts[3],
4832 build = _versionParts$ === void 0 ? '' : _versionParts$;
4833 return {
4834 major1: parseInt(major1),
4835 major2: parseInt(major2),
4836 minor: parseInt(minor),
4837 build: build
4838 };
4839 }
4840
4841 /**
4842 * Get total of major.
4843 *
4844 * Since `get_total_major` cannot determine how much really versions between 2.9.0 and 3.3.0 if there is 2.10.0 version for example,
4845 * versions with major2 more then 9 will be added to total.
4846 *
4847 * @param {Version} versionObj
4848 *
4849 * @return {number}
4850 */
4851 }, {
4852 key: "getTotalMajor",
4853 value: function getTotalMajor(versionObj) {
4854 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
4855 total = Number((total / 10).toFixed(0));
4856 if (versionObj.major2 > 9) {
4857 total = versionObj.major2 - 9;
4858 }
4859 return total;
4860 }
4861
4862 /**
4863 * @param {string} version1
4864 * @param {string} version2
4865 *
4866 * @return {number}
4867 */
4868 }, {
4869 key: "compareVersion",
4870 value: function compareVersion(version1, version2) {
4871 var _this = this;
4872 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
4873 return _this.getTotalMajor(versionObj);
4874 }).reduce(function (acc, major) {
4875 return acc - major;
4876 });
4877 }
4878
4879 /**
4880 * @param {string} version
4881 *
4882 * @return {boolean}
4883 */
4884 }, {
4885 key: "isSoftDeprecated",
4886 value: function isSoftDeprecated(version) {
4887 var total = this.compareVersion(version, elementorWebCliConfig.version);
4888 return total <= 4;
4889 }
4890
4891 /**
4892 * @param {string} version
4893 * @return {boolean}
4894 */
4895 }, {
4896 key: "isHardDeprecated",
4897 value: function isHardDeprecated(version) {
4898 var total = this.compareVersion(version, elementorWebCliConfig.version);
4899 return total < 0 || total >= 8;
4900 }
4901 }]);
4902 }();
4903
4904 /***/ }),
4905
4906 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
4907 /*!*************************************************************************!*\
4908 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
4909 \*************************************************************************/
4910 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4911
4912 "use strict";
4913
4914
4915 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4916 Object.defineProperty(exports, "__esModule", ({
4917 value: true
4918 }));
4919 exports["default"] = exports.ForceMethodImplementation = void 0;
4920 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4921 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4922 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4923 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4924 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4925 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
4926 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
4927 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4928 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
4929 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
4930 function ForceMethodImplementation() {
4931 var _this;
4932 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4933 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
4934 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
4935 Error.captureStackTrace(_this, ForceMethodImplementation);
4936 return _this;
4937 }
4938 (0, _inherits2.default)(ForceMethodImplementation, _Error);
4939 return (0, _createClass2.default)(ForceMethodImplementation);
4940 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
4941 var _default = exports["default"] = function _default() {
4942 var stack = Error().stack,
4943 caller = stack.split('\n')[2].trim(),
4944 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
4945 info = {};
4946 info.functionName = callerName;
4947 info.fullName = callerName;
4948 if (info.functionName.includes('.')) {
4949 var parts = info.functionName.split('.');
4950 info.className = parts[0];
4951 info.functionName = parts[1];
4952 } else {
4953 info.isStatic = true;
4954 }
4955 throw new ForceMethodImplementation(info);
4956 };
4957
4958 /***/ }),
4959
4960 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
4961 /*!***************************************************************!*\
4962 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
4963 \***************************************************************/
4964 /***/ ((module) => {
4965
4966 function _OverloadYield(e, d) {
4967 this.v = e, this.k = d;
4968 }
4969 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
4970
4971 /***/ }),
4972
4973 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
4974 /*!******************************************************************!*\
4975 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
4976 \******************************************************************/
4977 /***/ ((module) => {
4978
4979 function _arrayLikeToArray(r, a) {
4980 (null == a || a > r.length) && (a = r.length);
4981 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
4982 return n;
4983 }
4984 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
4985
4986 /***/ }),
4987
4988 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
4989 /*!****************************************************************!*\
4990 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
4991 \****************************************************************/
4992 /***/ ((module) => {
4993
4994 function _arrayWithHoles(r) {
4995 if (Array.isArray(r)) return r;
4996 }
4997 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
4998
4999 /***/ }),
5000
5001 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5002 /*!***********************************************************************!*\
5003 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5004 \***********************************************************************/
5005 /***/ ((module) => {
5006
5007 function _assertThisInitialized(e) {
5008 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5009 return e;
5010 }
5011 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5012
5013 /***/ }),
5014
5015 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5016 /*!******************************************************************!*\
5017 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5018 \******************************************************************/
5019 /***/ ((module) => {
5020
5021 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5022 try {
5023 var i = n[a](c),
5024 u = i.value;
5025 } catch (n) {
5026 return void e(n);
5027 }
5028 i.done ? t(u) : Promise.resolve(u).then(r, o);
5029 }
5030 function _asyncToGenerator(n) {
5031 return function () {
5032 var t = this,
5033 e = arguments;
5034 return new Promise(function (r, o) {
5035 var a = n.apply(t, e);
5036 function _next(n) {
5037 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5038 }
5039 function _throw(n) {
5040 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5041 }
5042 _next(void 0);
5043 });
5044 };
5045 }
5046 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5047
5048 /***/ }),
5049
5050 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5051 /*!****************************************************************!*\
5052 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5053 \****************************************************************/
5054 /***/ ((module) => {
5055
5056 function _classCallCheck(a, n) {
5057 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5058 }
5059 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5060
5061 /***/ }),
5062
5063 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5064 /*!***********************************************************!*\
5065 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5066 \***********************************************************/
5067 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5068
5069 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5070 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5071 function _construct(t, e, r) {
5072 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5073 var o = [null];
5074 o.push.apply(o, e);
5075 var p = new (t.bind.apply(t, o))();
5076 return r && setPrototypeOf(p, r.prototype), p;
5077 }
5078 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5079
5080 /***/ }),
5081
5082 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5083 /*!*************************************************************!*\
5084 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5085 \*************************************************************/
5086 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5087
5088 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5089 function _defineProperties(e, r) {
5090 for (var t = 0; t < r.length; t++) {
5091 var o = r[t];
5092 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5093 }
5094 }
5095 function _createClass(e, r, t) {
5096 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5097 writable: !1
5098 }), e;
5099 }
5100 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5101
5102 /***/ }),
5103
5104 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5105 /*!****************************************************************!*\
5106 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5107 \****************************************************************/
5108 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5109
5110 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5111 function _defineProperty(e, r, t) {
5112 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5113 value: t,
5114 enumerable: !0,
5115 configurable: !0,
5116 writable: !0
5117 }) : e[r] = t, e;
5118 }
5119 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5120
5121 /***/ }),
5122
5123 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5124 /*!********************************************************************!*\
5125 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5126 \********************************************************************/
5127 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5128
5129 "use strict";
5130 __webpack_require__.r(__webpack_exports__);
5131 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5132 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5133 /* harmony export */ });
5134 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5135
5136 function _defineProperty(e, r, t) {
5137 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5138 value: t,
5139 enumerable: !0,
5140 configurable: !0,
5141 writable: !0
5142 }) : e[r] = t, e;
5143 }
5144
5145
5146 /***/ }),
5147
5148 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5149 /*!*******************************************************************!*\
5150 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5151 \*******************************************************************/
5152 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5153
5154 "use strict";
5155 __webpack_require__.r(__webpack_exports__);
5156 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5157 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5158 /* harmony export */ });
5159 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5160
5161 function ownKeys(e, r) {
5162 var t = Object.keys(e);
5163 if (Object.getOwnPropertySymbols) {
5164 var o = Object.getOwnPropertySymbols(e);
5165 r && (o = o.filter(function (r) {
5166 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5167 })), t.push.apply(t, o);
5168 }
5169 return t;
5170 }
5171 function _objectSpread2(e) {
5172 for (var r = 1; r < arguments.length; r++) {
5173 var t = null != arguments[r] ? arguments[r] : {};
5174 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5175 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5176 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5177 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5178 });
5179 }
5180 return e;
5181 }
5182
5183
5184 /***/ }),
5185
5186 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5187 /*!*****************************************************************!*\
5188 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5189 \*****************************************************************/
5190 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5191
5192 "use strict";
5193 __webpack_require__.r(__webpack_exports__);
5194 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5195 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5196 /* harmony export */ });
5197 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5198
5199 function toPrimitive(t, r) {
5200 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5201 var e = t[Symbol.toPrimitive];
5202 if (void 0 !== e) {
5203 var i = e.call(t, r || "default");
5204 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5205 throw new TypeError("@@toPrimitive must return a primitive value.");
5206 }
5207 return ("string" === r ? String : Number)(t);
5208 }
5209
5210
5211 /***/ }),
5212
5213 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5214 /*!*******************************************************************!*\
5215 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5216 \*******************************************************************/
5217 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5218
5219 "use strict";
5220 __webpack_require__.r(__webpack_exports__);
5221 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5222 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5223 /* harmony export */ });
5224 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5225 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5226
5227
5228 function toPropertyKey(t) {
5229 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5230 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5231 }
5232
5233
5234 /***/ }),
5235
5236 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5237 /*!************************************************************!*\
5238 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5239 \************************************************************/
5240 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5241
5242 "use strict";
5243 __webpack_require__.r(__webpack_exports__);
5244 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5245 /* harmony export */ "default": () => (/* binding */ _typeof)
5246 /* harmony export */ });
5247 function _typeof(o) {
5248 "@babel/helpers - typeof";
5249
5250 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5251 return typeof o;
5252 } : function (o) {
5253 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5254 }, _typeof(o);
5255 }
5256
5257
5258 /***/ }),
5259
5260 /***/ "../node_modules/@babel/runtime/helpers/get.js":
5261 /*!*****************************************************!*\
5262 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
5263 \*****************************************************/
5264 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5265
5266 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
5267 function _get() {
5268 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
5269 var p = superPropBase(e, t);
5270 if (p) {
5271 var n = Object.getOwnPropertyDescriptor(p, t);
5272 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
5273 }
5274 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
5275 }
5276 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
5277
5278 /***/ }),
5279
5280 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
5281 /*!****************************************************************!*\
5282 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
5283 \****************************************************************/
5284 /***/ ((module) => {
5285
5286 function _getPrototypeOf(t) {
5287 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
5288 return t.__proto__ || Object.getPrototypeOf(t);
5289 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
5290 }
5291 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
5292
5293 /***/ }),
5294
5295 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
5296 /*!**********************************************************!*\
5297 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
5298 \**********************************************************/
5299 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5300
5301 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5302 function _inherits(t, e) {
5303 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
5304 t.prototype = Object.create(e && e.prototype, {
5305 constructor: {
5306 value: t,
5307 writable: !0,
5308 configurable: !0
5309 }
5310 }), Object.defineProperty(t, "prototype", {
5311 writable: !1
5312 }), e && setPrototypeOf(t, e);
5313 }
5314 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
5315
5316 /***/ }),
5317
5318 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
5319 /*!***********************************************************************!*\
5320 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
5321 \***********************************************************************/
5322 /***/ ((module) => {
5323
5324 function _interopRequireDefault(e) {
5325 return e && e.__esModule ? e : {
5326 "default": e
5327 };
5328 }
5329 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
5330
5331 /***/ }),
5332
5333 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
5334 /*!******************************************************************!*\
5335 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
5336 \******************************************************************/
5337 /***/ ((module) => {
5338
5339 function _isNativeFunction(t) {
5340 try {
5341 return -1 !== Function.toString.call(t).indexOf("[native code]");
5342 } catch (n) {
5343 return "function" == typeof t;
5344 }
5345 }
5346 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
5347
5348 /***/ }),
5349
5350 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
5351 /*!**************************************************************************!*\
5352 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
5353 \**************************************************************************/
5354 /***/ ((module) => {
5355
5356 function _isNativeReflectConstruct() {
5357 try {
5358 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
5359 } catch (t) {}
5360 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
5361 return !!t;
5362 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5363 }
5364 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5365
5366 /***/ }),
5367
5368 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
5369 /*!**********************************************************************!*\
5370 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
5371 \**********************************************************************/
5372 /***/ ((module) => {
5373
5374 function _iterableToArrayLimit(r, l) {
5375 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
5376 if (null != t) {
5377 var e,
5378 n,
5379 i,
5380 u,
5381 a = [],
5382 f = !0,
5383 o = !1;
5384 try {
5385 if (i = (t = t.call(r)).next, 0 === l) {
5386 if (Object(t) !== t) return;
5387 f = !1;
5388 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
5389 } catch (r) {
5390 o = !0, n = r;
5391 } finally {
5392 try {
5393 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
5394 } finally {
5395 if (o) throw n;
5396 }
5397 }
5398 return a;
5399 }
5400 }
5401 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
5402
5403 /***/ }),
5404
5405 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
5406 /*!*****************************************************************!*\
5407 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
5408 \*****************************************************************/
5409 /***/ ((module) => {
5410
5411 function _nonIterableRest() {
5412 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5413 }
5414 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
5415
5416 /***/ }),
5417
5418 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
5419 /*!***************************************************************************!*\
5420 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
5421 \***************************************************************************/
5422 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5423
5424 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5425 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
5426 function _possibleConstructorReturn(t, e) {
5427 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
5428 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
5429 return assertThisInitialized(t);
5430 }
5431 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
5432
5433 /***/ }),
5434
5435 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
5436 /*!***************************************************************!*\
5437 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
5438 \***************************************************************/
5439 /***/ ((module) => {
5440
5441 function _readOnlyError(r) {
5442 throw new TypeError('"' + r + '" is read-only');
5443 }
5444 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
5445
5446 /***/ }),
5447
5448 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
5449 /*!*************************************************************!*\
5450 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
5451 \*************************************************************/
5452 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5453
5454 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5455 function _regenerator() {
5456 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
5457 var e,
5458 t,
5459 r = "function" == typeof Symbol ? Symbol : {},
5460 n = r.iterator || "@@iterator",
5461 o = r.toStringTag || "@@toStringTag";
5462 function i(r, n, o, i) {
5463 var c = n && n.prototype instanceof Generator ? n : Generator,
5464 u = Object.create(c.prototype);
5465 return regeneratorDefine(u, "_invoke", function (r, n, o) {
5466 var i,
5467 c,
5468 u,
5469 f = 0,
5470 p = o || [],
5471 y = !1,
5472 G = {
5473 p: 0,
5474 n: 0,
5475 v: e,
5476 a: d,
5477 f: d.bind(e, 4),
5478 d: function d(t, r) {
5479 return i = t, c = 0, u = e, G.n = r, a;
5480 }
5481 };
5482 function d(r, n) {
5483 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
5484 var o,
5485 i = p[t],
5486 d = G.p,
5487 l = i[2];
5488 r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
5489 }
5490 if (o || r > 1) return a;
5491 throw y = !0, n;
5492 }
5493 return function (o, p, l) {
5494 if (f > 1) throw TypeError("Generator is already running");
5495 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
5496 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
5497 try {
5498 if (f = 2, i) {
5499 if (c || (o = "next"), t = i[o]) {
5500 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
5501 if (!t.done) return t;
5502 u = t.value, c < 2 && (c = 0);
5503 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
5504 i = e;
5505 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
5506 } catch (t) {
5507 i = e, c = 1, u = t;
5508 } finally {
5509 f = 1;
5510 }
5511 }
5512 return {
5513 value: t,
5514 done: y
5515 };
5516 };
5517 }(r, o, i), !0), u;
5518 }
5519 var a = {};
5520 function Generator() {}
5521 function GeneratorFunction() {}
5522 function GeneratorFunctionPrototype() {}
5523 t = Object.getPrototypeOf;
5524 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
5525 return this;
5526 }), t),
5527 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
5528 function f(e) {
5529 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
5530 }
5531 return GeneratorFunction.prototype = GeneratorFunctionPrototype, regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), regeneratorDefine(u), regeneratorDefine(u, o, "Generator"), regeneratorDefine(u, n, function () {
5532 return this;
5533 }), regeneratorDefine(u, "toString", function () {
5534 return "[object Generator]";
5535 }), (module.exports = _regenerator = function _regenerator() {
5536 return {
5537 w: i,
5538 m: f
5539 };
5540 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5541 }
5542 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5543
5544 /***/ }),
5545
5546 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
5547 /*!******************************************************************!*\
5548 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
5549 \******************************************************************/
5550 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5551
5552 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5553 function _regeneratorAsync(n, e, r, t, o) {
5554 var a = regeneratorAsyncGen(n, e, r, t, o);
5555 return a.next().then(function (n) {
5556 return n.done ? n.value : a.next();
5557 });
5558 }
5559 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
5560
5561 /***/ }),
5562
5563 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
5564 /*!*********************************************************************!*\
5565 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
5566 \*********************************************************************/
5567 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5568
5569 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5570 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5571 function _regeneratorAsyncGen(r, e, t, o, n) {
5572 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
5573 }
5574 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
5575
5576 /***/ }),
5577
5578 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
5579 /*!**************************************************************************!*\
5580 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
5581 \**************************************************************************/
5582 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5583
5584 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5585 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5586 function AsyncIterator(t, e) {
5587 function n(r, o, i, f) {
5588 try {
5589 var c = t[r](o),
5590 u = c.value;
5591 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
5592 n("next", t, i, f);
5593 }, function (t) {
5594 n("throw", t, i, f);
5595 }) : e.resolve(u).then(function (t) {
5596 c.value = t, i(c);
5597 }, function (t) {
5598 return n("throw", t, i, f);
5599 });
5600 } catch (t) {
5601 f(t);
5602 }
5603 }
5604 var r;
5605 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
5606 return this;
5607 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
5608 function f() {
5609 return new e(function (e, r) {
5610 n(t, i, e, r);
5611 });
5612 }
5613 return r = r ? r.then(f, f) : f();
5614 }, !0);
5615 }
5616 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5617
5618 /***/ }),
5619
5620 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
5621 /*!*******************************************************************!*\
5622 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
5623 \*******************************************************************/
5624 /***/ ((module) => {
5625
5626 function _regeneratorDefine(e, r, n, t) {
5627 var i = Object.defineProperty;
5628 try {
5629 i({}, "", {});
5630 } catch (e) {
5631 i = 0;
5632 }
5633 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
5634 if (r) i ? i(e, r, {
5635 value: n,
5636 enumerable: !t,
5637 configurable: !t,
5638 writable: !t
5639 }) : e[r] = n;else {
5640 var o = function o(r, n) {
5641 _regeneratorDefine(e, r, function (e) {
5642 return this._invoke(r, n, e);
5643 });
5644 };
5645 o("next", 0), o("throw", 1), o("return", 2);
5646 }
5647 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
5648 }
5649 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
5650
5651 /***/ }),
5652
5653 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
5654 /*!*****************************************************************!*\
5655 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
5656 \*****************************************************************/
5657 /***/ ((module) => {
5658
5659 function _regeneratorKeys(e) {
5660 var n = Object(e),
5661 r = [];
5662 for (var t in n) r.unshift(t);
5663 return function e() {
5664 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
5665 return e.done = !0, e;
5666 };
5667 }
5668 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
5669
5670 /***/ }),
5671
5672 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
5673 /*!********************************************************************!*\
5674 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
5675 \********************************************************************/
5676 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5677
5678 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5679 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5680 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
5681 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5682 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5683 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
5684 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
5685 function _regeneratorRuntime() {
5686 "use strict";
5687
5688 var r = regenerator(),
5689 e = r.m(_regeneratorRuntime),
5690 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
5691 function n(r) {
5692 var e = "function" == typeof r && r.constructor;
5693 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
5694 }
5695 var o = {
5696 "throw": 1,
5697 "return": 2,
5698 "break": 3,
5699 "continue": 3
5700 };
5701 function a(r) {
5702 var e, t;
5703 return function (n) {
5704 e || (e = {
5705 stop: function stop() {
5706 return t(n.a, 2);
5707 },
5708 "catch": function _catch() {
5709 return n.v;
5710 },
5711 abrupt: function abrupt(r, e) {
5712 return t(n.a, o[r], e);
5713 },
5714 delegateYield: function delegateYield(r, o, a) {
5715 return e.resultName = o, t(n.d, regeneratorValues(r), a);
5716 },
5717 finish: function finish(r) {
5718 return t(n.f, r);
5719 }
5720 }, t = function t(r, _t, o) {
5721 n.p = e.prev, n.n = e.next;
5722 try {
5723 return r(_t, o);
5724 } finally {
5725 e.next = n.n;
5726 }
5727 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
5728 try {
5729 return r.call(this, e);
5730 } finally {
5731 n.p = e.prev, n.n = e.next;
5732 }
5733 };
5734 }
5735 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
5736 return {
5737 wrap: function wrap(e, t, n, o) {
5738 return r.w(a(e), t, n, o && o.reverse());
5739 },
5740 isGeneratorFunction: n,
5741 mark: r.m,
5742 awrap: function awrap(r, e) {
5743 return new OverloadYield(r, e);
5744 },
5745 AsyncIterator: regeneratorAsyncIterator,
5746 async: function async(r, e, t, o, u) {
5747 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
5748 },
5749 keys: regeneratorKeys,
5750 values: regeneratorValues
5751 };
5752 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5753 }
5754 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
5755
5756 /***/ }),
5757
5758 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
5759 /*!*******************************************************************!*\
5760 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
5761 \*******************************************************************/
5762 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5763
5764 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5765 function _regeneratorValues(e) {
5766 if (null != e) {
5767 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
5768 r = 0;
5769 if (t) return t.call(e);
5770 if ("function" == typeof e.next) return e;
5771 if (!isNaN(e.length)) return {
5772 next: function next() {
5773 return e && r >= e.length && (e = void 0), {
5774 value: e && e[r++],
5775 done: !e
5776 };
5777 }
5778 };
5779 }
5780 throw new TypeError(_typeof(e) + " is not iterable");
5781 }
5782 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
5783
5784 /***/ }),
5785
5786 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
5787 /*!****************************************************************!*\
5788 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
5789 \****************************************************************/
5790 /***/ ((module) => {
5791
5792 function _setPrototypeOf(t, e) {
5793 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
5794 return t.__proto__ = e, t;
5795 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
5796 }
5797 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
5798
5799 /***/ }),
5800
5801 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
5802 /*!***************************************************************!*\
5803 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
5804 \***************************************************************/
5805 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5806
5807 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
5808 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
5809 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
5810 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
5811 function _slicedToArray(r, e) {
5812 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
5813 }
5814 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5815
5816 /***/ }),
5817
5818 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
5819 /*!***************************************************************!*\
5820 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
5821 \***************************************************************/
5822 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5823
5824 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
5825 function _superPropBase(t, o) {
5826 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
5827 return t;
5828 }
5829 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
5830
5831 /***/ }),
5832
5833 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
5834 /*!*************************************************************!*\
5835 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
5836 \*************************************************************/
5837 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5838
5839 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5840 function toPrimitive(t, r) {
5841 if ("object" != _typeof(t) || !t) return t;
5842 var e = t[Symbol.toPrimitive];
5843 if (void 0 !== e) {
5844 var i = e.call(t, r || "default");
5845 if ("object" != _typeof(i)) return i;
5846 throw new TypeError("@@toPrimitive must return a primitive value.");
5847 }
5848 return ("string" === r ? String : Number)(t);
5849 }
5850 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
5851
5852 /***/ }),
5853
5854 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
5855 /*!***************************************************************!*\
5856 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
5857 \***************************************************************/
5858 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5859
5860 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5861 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
5862 function toPropertyKey(t) {
5863 var i = toPrimitive(t, "string");
5864 return "symbol" == _typeof(i) ? i : i + "";
5865 }
5866 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
5867
5868 /***/ }),
5869
5870 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
5871 /*!********************************************************!*\
5872 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
5873 \********************************************************/
5874 /***/ ((module) => {
5875
5876 function _typeof(o) {
5877 "@babel/helpers - typeof";
5878
5879 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5880 return typeof o;
5881 } : function (o) {
5882 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5883 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
5884 }
5885 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
5886
5887 /***/ }),
5888
5889 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
5890 /*!****************************************************************************!*\
5891 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
5892 \****************************************************************************/
5893 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5894
5895 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
5896 function _unsupportedIterableToArray(r, a) {
5897 if (r) {
5898 if ("string" == typeof r) return arrayLikeToArray(r, a);
5899 var t = {}.toString.call(r).slice(8, -1);
5900 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? arrayLikeToArray(r, a) : void 0;
5901 }
5902 }
5903 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5904
5905 /***/ }),
5906
5907 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
5908 /*!*****************************************************************!*\
5909 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
5910 \*****************************************************************/
5911 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5912
5913 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
5914 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5915 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
5916 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
5917 function _wrapNativeSuper(t) {
5918 var r = "function" == typeof Map ? new Map() : void 0;
5919 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
5920 if (null === t || !isNativeFunction(t)) return t;
5921 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
5922 if (void 0 !== r) {
5923 if (r.has(t)) return r.get(t);
5924 r.set(t, Wrapper);
5925 }
5926 function Wrapper() {
5927 return construct(t, arguments, getPrototypeOf(this).constructor);
5928 }
5929 return Wrapper.prototype = Object.create(t.prototype, {
5930 constructor: {
5931 value: Wrapper,
5932 enumerable: !1,
5933 writable: !0,
5934 configurable: !0
5935 }
5936 }), setPrototypeOf(Wrapper, t);
5937 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
5938 }
5939 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
5940
5941 /***/ }),
5942
5943 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
5944 /*!***********************************************************!*\
5945 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
5946 \***********************************************************/
5947 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5948
5949 // TODO(Babel 8): Remove this file.
5950
5951 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
5952 module.exports = runtime;
5953
5954 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
5955 try {
5956 regeneratorRuntime = runtime;
5957 } catch (accidentalStrictMode) {
5958 if (typeof globalThis === "object") {
5959 globalThis.regeneratorRuntime = runtime;
5960 } else {
5961 Function("r", "regeneratorRuntime = r")(runtime);
5962 }
5963 }
5964
5965
5966 /***/ }),
5967
5968 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
5969 /*!******************************************************************!*\
5970 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
5971 \******************************************************************/
5972 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5973
5974 "use strict";
5975 __webpack_require__.r(__webpack_exports__);
5976 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5977 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
5978 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
5979 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
5980 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
5981 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.__DO_NOT_USE__ActionTypes),
5982 /* harmony export */ addListener: () => (/* binding */ addListener),
5983 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.applyMiddleware),
5984 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
5985 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.bindActionCreators),
5986 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
5987 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.combineReducers),
5988 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.compose),
5989 /* harmony export */ configureStore: () => (/* binding */ configureStore),
5990 /* harmony export */ createAction: () => (/* binding */ createAction),
5991 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
5992 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
5993 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
5994 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
5995 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
5996 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
5997 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_2__["default"]),
5998 /* harmony export */ createReducer: () => (/* binding */ createReducer),
5999 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector),
6000 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6001 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6002 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.createStore),
6003 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_2__.current),
6004 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6005 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_2__.freeze),
6006 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6007 /* harmony export */ getType: () => (/* binding */ getType),
6008 /* harmony export */ isAction: () => (/* binding */ isAction),
6009 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6010 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6011 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6012 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6013 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_2__.isDraft),
6014 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6015 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6016 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6017 /* harmony export */ isPending: () => (/* binding */ isPending),
6018 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6019 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6020 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6021 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6022 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.legacy_createStore),
6023 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6024 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6025 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_2__.original),
6026 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6027 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6028 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6029 /* harmony export */ });
6030 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6031 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6032 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6033 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6034 var __extends = (undefined && undefined.__extends) || (function () {
6035 var extendStatics = function (d, b) {
6036 extendStatics = Object.setPrototypeOf ||
6037 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6038 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6039 return extendStatics(d, b);
6040 };
6041 return function (d, b) {
6042 if (typeof b !== "function" && b !== null)
6043 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6044 extendStatics(d, b);
6045 function __() { this.constructor = d; }
6046 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6047 };
6048 })();
6049 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6050 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6051 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6052 function verb(n) { return function (v) { return step([n, v]); }; }
6053 function step(op) {
6054 if (f) throw new TypeError("Generator is already executing.");
6055 while (_) try {
6056 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
6057 if (y = 0, t) op = [op[0] & 2, t.value];
6058 switch (op[0]) {
6059 case 0: case 1: t = op; break;
6060 case 4: _.label++; return { value: op[1], done: false };
6061 case 5: _.label++; y = op[1]; op = [0]; continue;
6062 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6063 default:
6064 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6065 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6066 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6067 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6068 if (t[2]) _.ops.pop();
6069 _.trys.pop(); continue;
6070 }
6071 op = body.call(thisArg, _);
6072 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6073 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6074 }
6075 };
6076 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6077 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6078 to[j] = from[i];
6079 return to;
6080 };
6081 var __defProp = Object.defineProperty;
6082 var __defProps = Object.defineProperties;
6083 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6084 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6085 var __hasOwnProp = Object.prototype.hasOwnProperty;
6086 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6087 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6088 var __spreadValues = function (a, b) {
6089 for (var prop in b || (b = {}))
6090 if (__hasOwnProp.call(b, prop))
6091 __defNormalProp(a, prop, b[prop]);
6092 if (__getOwnPropSymbols)
6093 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6094 var prop = _c[_i];
6095 if (__propIsEnum.call(b, prop))
6096 __defNormalProp(a, prop, b[prop]);
6097 }
6098 return a;
6099 };
6100 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6101 var __async = function (__this, __arguments, generator) {
6102 return new Promise(function (resolve, reject) {
6103 var fulfilled = function (value) {
6104 try {
6105 step(generator.next(value));
6106 }
6107 catch (e) {
6108 reject(e);
6109 }
6110 };
6111 var rejected = function (value) {
6112 try {
6113 step(generator.throw(value));
6114 }
6115 catch (e) {
6116 reject(e);
6117 }
6118 };
6119 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6120 step((generator = generator.apply(__this, __arguments)).next());
6121 });
6122 };
6123 // src/index.ts
6124
6125
6126
6127
6128 // src/createDraftSafeSelector.ts
6129
6130
6131 var createDraftSafeSelector = function () {
6132 var args = [];
6133 for (var _i = 0; _i < arguments.length; _i++) {
6134 args[_i] = arguments[_i];
6135 }
6136 var selector = reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector.apply(void 0, args);
6137 var wrappedSelector = function (value) {
6138 var rest = [];
6139 for (var _i = 1; _i < arguments.length; _i++) {
6140 rest[_i - 1] = arguments[_i];
6141 }
6142 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_2__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_2__.current)(value) : value], rest));
6143 };
6144 return wrappedSelector;
6145 };
6146 // src/configureStore.ts
6147
6148 // src/devtoolsExtension.ts
6149
6150 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6151 if (arguments.length === 0)
6152 return void 0;
6153 if (typeof arguments[0] === "object")
6154 return redux__WEBPACK_IMPORTED_MODULE_0__.compose;
6155 return redux__WEBPACK_IMPORTED_MODULE_0__.compose.apply(null, arguments);
6156 };
6157 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6158 return function (noop2) {
6159 return noop2;
6160 };
6161 };
6162 // src/isPlainObject.ts
6163 function isPlainObject(value) {
6164 if (typeof value !== "object" || value === null)
6165 return false;
6166 var proto = Object.getPrototypeOf(value);
6167 if (proto === null)
6168 return true;
6169 var baseProto = proto;
6170 while (Object.getPrototypeOf(baseProto) !== null) {
6171 baseProto = Object.getPrototypeOf(baseProto);
6172 }
6173 return proto === baseProto;
6174 }
6175 // src/getDefaultMiddleware.ts
6176
6177 // src/tsHelpers.ts
6178 var hasMatchFunction = function (v) {
6179 return v && typeof v.match === "function";
6180 };
6181 // src/createAction.ts
6182 function createAction(type, prepareAction) {
6183 function actionCreator() {
6184 var args = [];
6185 for (var _i = 0; _i < arguments.length; _i++) {
6186 args[_i] = arguments[_i];
6187 }
6188 if (prepareAction) {
6189 var prepared = prepareAction.apply(void 0, args);
6190 if (!prepared) {
6191 throw new Error("prepareAction did not return an object");
6192 }
6193 return __spreadValues(__spreadValues({
6194 type: type,
6195 payload: prepared.payload
6196 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6197 }
6198 return { type: type, payload: args[0] };
6199 }
6200 actionCreator.toString = function () { return "" + type; };
6201 actionCreator.type = type;
6202 actionCreator.match = function (action) { return action.type === type; };
6203 return actionCreator;
6204 }
6205 function isAction(action) {
6206 return isPlainObject(action) && "type" in action;
6207 }
6208 function isActionCreator(action) {
6209 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6210 }
6211 function isFSA(action) {
6212 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6213 }
6214 function isValidKey(key) {
6215 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6216 }
6217 function getType(actionCreator) {
6218 return "" + actionCreator;
6219 }
6220 // src/actionCreatorInvariantMiddleware.ts
6221 function getMessage(type) {
6222 var splitType = type ? ("" + type).split("/") : [];
6223 var actionName = splitType[splitType.length - 1] || "actionCreator";
6224 return "Detected an action creator with type \"" + (type || "unknown") + "\" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. `dispatch(" + actionName + "())` instead of `dispatch(" + actionName + ")`. This is necessary even if the action has no payload.";
6225 }
6226 function createActionCreatorInvariantMiddleware(options) {
6227 if (options === void 0) { options = {}; }
6228 if (false) // removed by dead control flow
6229 {}
6230 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6231 return function () { return function (next) { return function (action) {
6232 if (isActionCreator2(action)) {
6233 console.warn(getMessage(action.type));
6234 }
6235 return next(action);
6236 }; }; };
6237 }
6238 // src/utils.ts
6239
6240 function getTimeMeasureUtils(maxDelay, fnName) {
6241 var elapsed = 0;
6242 return {
6243 measureTime: function (fn) {
6244 var started = Date.now();
6245 try {
6246 return fn();
6247 }
6248 finally {
6249 var finished = Date.now();
6250 elapsed += finished - started;
6251 }
6252 },
6253 warnIfExceeded: function () {
6254 if (elapsed > maxDelay) {
6255 console.warn(fnName + " took " + elapsed + "ms, which is more than the warning threshold of " + maxDelay + "ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.");
6256 }
6257 }
6258 };
6259 }
6260 var MiddlewareArray = /** @class */ (function (_super) {
6261 __extends(MiddlewareArray, _super);
6262 function MiddlewareArray() {
6263 var args = [];
6264 for (var _i = 0; _i < arguments.length; _i++) {
6265 args[_i] = arguments[_i];
6266 }
6267 var _this = _super.apply(this, args) || this;
6268 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
6269 return _this;
6270 }
6271 Object.defineProperty(MiddlewareArray, Symbol.species, {
6272 get: function () {
6273 return MiddlewareArray;
6274 },
6275 enumerable: false,
6276 configurable: true
6277 });
6278 MiddlewareArray.prototype.concat = function () {
6279 var arr = [];
6280 for (var _i = 0; _i < arguments.length; _i++) {
6281 arr[_i] = arguments[_i];
6282 }
6283 return _super.prototype.concat.apply(this, arr);
6284 };
6285 MiddlewareArray.prototype.prepend = function () {
6286 var arr = [];
6287 for (var _i = 0; _i < arguments.length; _i++) {
6288 arr[_i] = arguments[_i];
6289 }
6290 if (arr.length === 1 && Array.isArray(arr[0])) {
6291 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
6292 }
6293 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
6294 };
6295 return MiddlewareArray;
6296 }(Array));
6297 var EnhancerArray = /** @class */ (function (_super) {
6298 __extends(EnhancerArray, _super);
6299 function EnhancerArray() {
6300 var args = [];
6301 for (var _i = 0; _i < arguments.length; _i++) {
6302 args[_i] = arguments[_i];
6303 }
6304 var _this = _super.apply(this, args) || this;
6305 Object.setPrototypeOf(_this, EnhancerArray.prototype);
6306 return _this;
6307 }
6308 Object.defineProperty(EnhancerArray, Symbol.species, {
6309 get: function () {
6310 return EnhancerArray;
6311 },
6312 enumerable: false,
6313 configurable: true
6314 });
6315 EnhancerArray.prototype.concat = function () {
6316 var arr = [];
6317 for (var _i = 0; _i < arguments.length; _i++) {
6318 arr[_i] = arguments[_i];
6319 }
6320 return _super.prototype.concat.apply(this, arr);
6321 };
6322 EnhancerArray.prototype.prepend = function () {
6323 var arr = [];
6324 for (var _i = 0; _i < arguments.length; _i++) {
6325 arr[_i] = arguments[_i];
6326 }
6327 if (arr.length === 1 && Array.isArray(arr[0])) {
6328 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
6329 }
6330 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
6331 };
6332 return EnhancerArray;
6333 }(Array));
6334 function freezeDraftable(val) {
6335 return (0,immer__WEBPACK_IMPORTED_MODULE_2__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_2__["default"])(val, function () {
6336 }) : val;
6337 }
6338 // src/immutableStateInvariantMiddleware.ts
6339 var isProduction = "development" === "production";
6340 var prefix = "Invariant failed";
6341 function invariant(condition, message) {
6342 if (condition) {
6343 return;
6344 }
6345 if (isProduction) {
6346 throw new Error(prefix);
6347 }
6348 throw new Error(prefix + ": " + (message || ""));
6349 }
6350 function stringify(obj, serializer, indent, decycler) {
6351 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
6352 }
6353 function getSerialize(serializer, decycler) {
6354 var stack = [], keys = [];
6355 if (!decycler)
6356 decycler = function (_, value) {
6357 if (stack[0] === value)
6358 return "[Circular ~]";
6359 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
6360 };
6361 return function (key, value) {
6362 if (stack.length > 0) {
6363 var thisPos = stack.indexOf(this);
6364 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
6365 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
6366 if (~stack.indexOf(value))
6367 value = decycler.call(this, key, value);
6368 }
6369 else
6370 stack.push(value);
6371 return serializer == null ? value : serializer.call(this, key, value);
6372 };
6373 }
6374 function isImmutableDefault(value) {
6375 return typeof value !== "object" || value == null || Object.isFrozen(value);
6376 }
6377 function trackForMutations(isImmutable, ignorePaths, obj) {
6378 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
6379 return {
6380 detectMutations: function () {
6381 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
6382 }
6383 };
6384 }
6385 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
6386 if (ignorePaths === void 0) { ignorePaths = []; }
6387 if (path === void 0) { path = ""; }
6388 if (checkedObjects === void 0) { checkedObjects = new Set(); }
6389 var tracked = { value: obj };
6390 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
6391 checkedObjects.add(obj);
6392 tracked.children = {};
6393 for (var key in obj) {
6394 var childPath = path ? path + "." + key : key;
6395 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
6396 continue;
6397 }
6398 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
6399 }
6400 }
6401 return tracked;
6402 }
6403 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
6404 if (ignoredPaths === void 0) { ignoredPaths = []; }
6405 if (sameParentRef === void 0) { sameParentRef = false; }
6406 if (path === void 0) { path = ""; }
6407 var prevObj = trackedProperty ? trackedProperty.value : void 0;
6408 var sameRef = prevObj === obj;
6409 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
6410 return { wasMutated: true, path: path };
6411 }
6412 if (isImmutable(prevObj) || isImmutable(obj)) {
6413 return { wasMutated: false };
6414 }
6415 var keysToDetect = {};
6416 for (var key in trackedProperty.children) {
6417 keysToDetect[key] = true;
6418 }
6419 for (var key in obj) {
6420 keysToDetect[key] = true;
6421 }
6422 var hasIgnoredPaths = ignoredPaths.length > 0;
6423 var _loop_1 = function (key) {
6424 var nestedPath = path ? path + "." + key : key;
6425 if (hasIgnoredPaths) {
6426 var hasMatches = ignoredPaths.some(function (ignored) {
6427 if (ignored instanceof RegExp) {
6428 return ignored.test(nestedPath);
6429 }
6430 return nestedPath === ignored;
6431 });
6432 if (hasMatches) {
6433 return "continue";
6434 }
6435 }
6436 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
6437 if (result.wasMutated) {
6438 return { value: result };
6439 }
6440 };
6441 for (var key in keysToDetect) {
6442 var state_1 = _loop_1(key);
6443 if (typeof state_1 === "object")
6444 return state_1.value;
6445 }
6446 return { wasMutated: false };
6447 }
6448 function createImmutableStateInvariantMiddleware(options) {
6449 if (options === void 0) { options = {}; }
6450 if (false) // removed by dead control flow
6451 {}
6452 var _c = options.isImmutable, isImmutable = _c === void 0 ? isImmutableDefault : _c, ignoredPaths = options.ignoredPaths, _d = options.warnAfter, warnAfter = _d === void 0 ? 32 : _d, ignore = options.ignore;
6453 ignoredPaths = ignoredPaths || ignore;
6454 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
6455 return function (_c) {
6456 var getState = _c.getState;
6457 var state = getState();
6458 var tracker = track(state);
6459 var result;
6460 return function (next) { return function (action) {
6461 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
6462 measureUtils.measureTime(function () {
6463 state = getState();
6464 result = tracker.detectMutations();
6465 tracker = track(state);
6466 invariant(!result.wasMutated, "A state mutation was detected between dispatches, in the path '" + (result.path || "") + "'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
6467 });
6468 var dispatchedAction = next(action);
6469 measureUtils.measureTime(function () {
6470 state = getState();
6471 result = tracker.detectMutations();
6472 tracker = track(state);
6473 result.wasMutated && invariant(!result.wasMutated, "A state mutation was detected inside a dispatch, in the path: " + (result.path || "") + ". Take a look at the reducer(s) handling the action " + stringify(action) + ". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
6474 });
6475 measureUtils.warnIfExceeded();
6476 return dispatchedAction;
6477 }; };
6478 };
6479 }
6480 // src/serializableStateInvariantMiddleware.ts
6481 function isPlain(val) {
6482 var type = typeof val;
6483 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
6484 }
6485 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
6486 if (path === void 0) { path = ""; }
6487 if (isSerializable === void 0) { isSerializable = isPlain; }
6488 if (ignoredPaths === void 0) { ignoredPaths = []; }
6489 var foundNestedSerializable;
6490 if (!isSerializable(value)) {
6491 return {
6492 keyPath: path || "<root>",
6493 value: value
6494 };
6495 }
6496 if (typeof value !== "object" || value === null) {
6497 return false;
6498 }
6499 if (cache == null ? void 0 : cache.has(value))
6500 return false;
6501 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
6502 var hasIgnoredPaths = ignoredPaths.length > 0;
6503 var _loop_2 = function (key, nestedValue) {
6504 var nestedPath = path ? path + "." + key : key;
6505 if (hasIgnoredPaths) {
6506 var hasMatches = ignoredPaths.some(function (ignored) {
6507 if (ignored instanceof RegExp) {
6508 return ignored.test(nestedPath);
6509 }
6510 return nestedPath === ignored;
6511 });
6512 if (hasMatches) {
6513 return "continue";
6514 }
6515 }
6516 if (!isSerializable(nestedValue)) {
6517 return { value: {
6518 keyPath: nestedPath,
6519 value: nestedValue
6520 } };
6521 }
6522 if (typeof nestedValue === "object") {
6523 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
6524 if (foundNestedSerializable) {
6525 return { value: foundNestedSerializable };
6526 }
6527 }
6528 };
6529 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
6530 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
6531 var state_2 = _loop_2(key, nestedValue);
6532 if (typeof state_2 === "object")
6533 return state_2.value;
6534 }
6535 if (cache && isNestedFrozen(value))
6536 cache.add(value);
6537 return false;
6538 }
6539 function isNestedFrozen(value) {
6540 if (!Object.isFrozen(value))
6541 return false;
6542 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
6543 var nestedValue = _c[_i];
6544 if (typeof nestedValue !== "object" || nestedValue === null)
6545 continue;
6546 if (!isNestedFrozen(nestedValue))
6547 return false;
6548 }
6549 return true;
6550 }
6551 function createSerializableStateInvariantMiddleware(options) {
6552 if (options === void 0) { options = {}; }
6553 if (false) // removed by dead control flow
6554 {}
6555 var _c = options.isSerializable, isSerializable = _c === void 0 ? isPlain : _c, getEntries = options.getEntries, _d = options.ignoredActions, ignoredActions = _d === void 0 ? [] : _d, _e = options.ignoredActionPaths, ignoredActionPaths = _e === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _e, _f = options.ignoredPaths, ignoredPaths = _f === void 0 ? [] : _f, _g = options.warnAfter, warnAfter = _g === void 0 ? 32 : _g, _h = options.ignoreState, ignoreState = _h === void 0 ? false : _h, _j = options.ignoreActions, ignoreActions = _j === void 0 ? false : _j, _k = options.disableCache, disableCache = _k === void 0 ? false : _k;
6556 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
6557 return function (storeAPI) { return function (next) { return function (action) {
6558 var result = next(action);
6559 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
6560 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
6561 measureUtils.measureTime(function () {
6562 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
6563 if (foundActionNonSerializableValue) {
6564 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
6565 console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
6566 }
6567 });
6568 }
6569 if (!ignoreState) {
6570 measureUtils.measureTime(function () {
6571 var state = storeAPI.getState();
6572 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
6573 if (foundStateNonSerializableValue) {
6574 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
6575 console.error("A non-serializable value was detected in the state, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
6576 }
6577 });
6578 measureUtils.warnIfExceeded();
6579 }
6580 return result;
6581 }; }; };
6582 }
6583 // src/getDefaultMiddleware.ts
6584 function isBoolean(x) {
6585 return typeof x === "boolean";
6586 }
6587 function curryGetDefaultMiddleware() {
6588 return function curriedGetDefaultMiddleware(options) {
6589 return getDefaultMiddleware(options);
6590 };
6591 }
6592 function getDefaultMiddleware(options) {
6593 if (options === void 0) { options = {}; }
6594 var _c = options.thunk, thunk = _c === void 0 ? true : _c, _d = options.immutableCheck, immutableCheck = _d === void 0 ? true : _d, _e = options.serializableCheck, serializableCheck = _e === void 0 ? true : _e, _f = options.actionCreatorCheck, actionCreatorCheck = _f === void 0 ? true : _f;
6595 var middlewareArray = new MiddlewareArray();
6596 if (thunk) {
6597 if (isBoolean(thunk)) {
6598 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
6599 }
6600 else {
6601 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
6602 }
6603 }
6604 if (true) {
6605 if (immutableCheck) {
6606 var immutableOptions = {};
6607 if (!isBoolean(immutableCheck)) {
6608 immutableOptions = immutableCheck;
6609 }
6610 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
6611 }
6612 if (serializableCheck) {
6613 var serializableOptions = {};
6614 if (!isBoolean(serializableCheck)) {
6615 serializableOptions = serializableCheck;
6616 }
6617 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
6618 }
6619 if (actionCreatorCheck) {
6620 var actionCreatorOptions = {};
6621 if (!isBoolean(actionCreatorCheck)) {
6622 actionCreatorOptions = actionCreatorCheck;
6623 }
6624 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
6625 }
6626 }
6627 return middlewareArray;
6628 }
6629 // src/configureStore.ts
6630 var IS_PRODUCTION = "development" === "production";
6631 function configureStore(options) {
6632 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
6633 var _c = options || {}, _d = _c.reducer, reducer = _d === void 0 ? void 0 : _d, _e = _c.middleware, middleware = _e === void 0 ? curriedGetDefaultMiddleware() : _e, _f = _c.devTools, devTools = _f === void 0 ? true : _f, _g = _c.preloadedState, preloadedState = _g === void 0 ? void 0 : _g, _h = _c.enhancers, enhancers = _h === void 0 ? void 0 : _h;
6634 var rootReducer;
6635 if (typeof reducer === "function") {
6636 rootReducer = reducer;
6637 }
6638 else if (isPlainObject(reducer)) {
6639 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_0__.combineReducers)(reducer);
6640 }
6641 else {
6642 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
6643 }
6644 var finalMiddleware = middleware;
6645 if (typeof finalMiddleware === "function") {
6646 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
6647 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
6648 throw new Error("when using a middleware builder function, an array of middleware must be returned");
6649 }
6650 }
6651 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
6652 throw new Error("each middleware provided to configureStore must be a function");
6653 }
6654 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_0__.applyMiddleware.apply(void 0, finalMiddleware);
6655 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_0__.compose;
6656 if (devTools) {
6657 finalCompose = composeWithDevTools(__spreadValues({
6658 trace: !IS_PRODUCTION
6659 }, typeof devTools === "object" && devTools));
6660 }
6661 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
6662 var storeEnhancers = defaultEnhancers;
6663 if (Array.isArray(enhancers)) {
6664 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
6665 }
6666 else if (typeof enhancers === "function") {
6667 storeEnhancers = enhancers(defaultEnhancers);
6668 }
6669 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
6670 return (0,redux__WEBPACK_IMPORTED_MODULE_0__.createStore)(rootReducer, preloadedState, composedEnhancer);
6671 }
6672 // src/createReducer.ts
6673
6674 // src/mapBuilders.ts
6675 function executeReducerBuilderCallback(builderCallback) {
6676 var actionsMap = {};
6677 var actionMatchers = [];
6678 var defaultCaseReducer;
6679 var builder = {
6680 addCase: function (typeOrActionCreator, reducer) {
6681 if (true) {
6682 if (actionMatchers.length > 0) {
6683 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
6684 }
6685 if (defaultCaseReducer) {
6686 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
6687 }
6688 }
6689 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
6690 if (!type) {
6691 throw new Error("`builder.addCase` cannot be called with an empty action type");
6692 }
6693 if (type in actionsMap) {
6694 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
6695 }
6696 actionsMap[type] = reducer;
6697 return builder;
6698 },
6699 addMatcher: function (matcher, reducer) {
6700 if (true) {
6701 if (defaultCaseReducer) {
6702 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
6703 }
6704 }
6705 actionMatchers.push({ matcher: matcher, reducer: reducer });
6706 return builder;
6707 },
6708 addDefaultCase: function (reducer) {
6709 if (true) {
6710 if (defaultCaseReducer) {
6711 throw new Error("`builder.addDefaultCase` can only be called once");
6712 }
6713 }
6714 defaultCaseReducer = reducer;
6715 return builder;
6716 }
6717 };
6718 builderCallback(builder);
6719 return [actionsMap, actionMatchers, defaultCaseReducer];
6720 }
6721 // src/createReducer.ts
6722 function isStateFunction(x) {
6723 return typeof x === "function";
6724 }
6725 var hasWarnedAboutObjectNotation = false;
6726 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
6727 if (actionMatchers === void 0) { actionMatchers = []; }
6728 if (true) {
6729 if (typeof mapOrBuilderCallback === "object") {
6730 if (!hasWarnedAboutObjectNotation) {
6731 hasWarnedAboutObjectNotation = true;
6732 console.warn("The object notation for `createReducer` is deprecated, and will be removed in RTK 2.0. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
6733 }
6734 }
6735 }
6736 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
6737 var getInitialState;
6738 if (isStateFunction(initialState)) {
6739 getInitialState = function () { return freezeDraftable(initialState()); };
6740 }
6741 else {
6742 var frozenInitialState_1 = freezeDraftable(initialState);
6743 getInitialState = function () { return frozenInitialState_1; };
6744 }
6745 function reducer(state, action) {
6746 if (state === void 0) { state = getInitialState(); }
6747 var caseReducers = __spreadArray([
6748 actionsMap[action.type]
6749 ], finalActionMatchers.filter(function (_c) {
6750 var matcher = _c.matcher;
6751 return matcher(action);
6752 }).map(function (_c) {
6753 var reducer2 = _c.reducer;
6754 return reducer2;
6755 }));
6756 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
6757 caseReducers = [finalDefaultCaseReducer];
6758 }
6759 return caseReducers.reduce(function (previousState, caseReducer) {
6760 if (caseReducer) {
6761 if ((0,immer__WEBPACK_IMPORTED_MODULE_2__.isDraft)(previousState)) {
6762 var draft = previousState;
6763 var result = caseReducer(draft, action);
6764 if (result === void 0) {
6765 return previousState;
6766 }
6767 return result;
6768 }
6769 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_2__.isDraftable)(previousState)) {
6770 var result = caseReducer(previousState, action);
6771 if (result === void 0) {
6772 if (previousState === null) {
6773 return previousState;
6774 }
6775 throw Error("A case reducer on a non-draftable value must not return undefined");
6776 }
6777 return result;
6778 }
6779 else {
6780 return (0,immer__WEBPACK_IMPORTED_MODULE_2__["default"])(previousState, function (draft) {
6781 return caseReducer(draft, action);
6782 });
6783 }
6784 }
6785 return previousState;
6786 }, state);
6787 }
6788 reducer.getInitialState = getInitialState;
6789 return reducer;
6790 }
6791 // src/createSlice.ts
6792 var hasWarnedAboutObjectNotation2 = false;
6793 function getType2(slice, actionKey) {
6794 return slice + "/" + actionKey;
6795 }
6796 function createSlice(options) {
6797 var name = options.name;
6798 if (!name) {
6799 throw new Error("`name` is a required option for createSlice");
6800 }
6801 if (typeof process !== "undefined" && "development" === "development") {
6802 if (options.initialState === void 0) {
6803 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
6804 }
6805 }
6806 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
6807 var reducers = options.reducers || {};
6808 var reducerNames = Object.keys(reducers);
6809 var sliceCaseReducersByName = {};
6810 var sliceCaseReducersByType = {};
6811 var actionCreators = {};
6812 reducerNames.forEach(function (reducerName) {
6813 var maybeReducerWithPrepare = reducers[reducerName];
6814 var type = getType2(name, reducerName);
6815 var caseReducer;
6816 var prepareCallback;
6817 if ("reducer" in maybeReducerWithPrepare) {
6818 caseReducer = maybeReducerWithPrepare.reducer;
6819 prepareCallback = maybeReducerWithPrepare.prepare;
6820 }
6821 else {
6822 caseReducer = maybeReducerWithPrepare;
6823 }
6824 sliceCaseReducersByName[reducerName] = caseReducer;
6825 sliceCaseReducersByType[type] = caseReducer;
6826 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
6827 });
6828 function buildReducer() {
6829 if (true) {
6830 if (typeof options.extraReducers === "object") {
6831 if (!hasWarnedAboutObjectNotation2) {
6832 hasWarnedAboutObjectNotation2 = true;
6833 console.warn("The object notation for `createSlice.extraReducers` is deprecated, and will be removed in RTK 2.0. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
6834 }
6835 }
6836 }
6837 var _c = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers], _d = _c[0], extraReducers = _d === void 0 ? {} : _d, _e = _c[1], actionMatchers = _e === void 0 ? [] : _e, _f = _c[2], defaultCaseReducer = _f === void 0 ? void 0 : _f;
6838 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
6839 return createReducer(initialState, function (builder) {
6840 for (var key in finalCaseReducers) {
6841 builder.addCase(key, finalCaseReducers[key]);
6842 }
6843 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
6844 var m = actionMatchers_1[_i];
6845 builder.addMatcher(m.matcher, m.reducer);
6846 }
6847 if (defaultCaseReducer) {
6848 builder.addDefaultCase(defaultCaseReducer);
6849 }
6850 });
6851 }
6852 var _reducer;
6853 return {
6854 name: name,
6855 reducer: function (state, action) {
6856 if (!_reducer)
6857 _reducer = buildReducer();
6858 return _reducer(state, action);
6859 },
6860 actions: actionCreators,
6861 caseReducers: sliceCaseReducersByName,
6862 getInitialState: function () {
6863 if (!_reducer)
6864 _reducer = buildReducer();
6865 return _reducer.getInitialState();
6866 }
6867 };
6868 }
6869 // src/entities/entity_state.ts
6870 function getInitialEntityState() {
6871 return {
6872 ids: [],
6873 entities: {}
6874 };
6875 }
6876 function createInitialStateFactory() {
6877 function getInitialState(additionalState) {
6878 if (additionalState === void 0) { additionalState = {}; }
6879 return Object.assign(getInitialEntityState(), additionalState);
6880 }
6881 return { getInitialState: getInitialState };
6882 }
6883 // src/entities/state_selectors.ts
6884 function createSelectorsFactory() {
6885 function getSelectors(selectState) {
6886 var selectIds = function (state) { return state.ids; };
6887 var selectEntities = function (state) { return state.entities; };
6888 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
6889 var selectId = function (_, id) { return id; };
6890 var selectById = function (entities, id) { return entities[id]; };
6891 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
6892 if (!selectState) {
6893 return {
6894 selectIds: selectIds,
6895 selectEntities: selectEntities,
6896 selectAll: selectAll,
6897 selectTotal: selectTotal,
6898 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
6899 };
6900 }
6901 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
6902 return {
6903 selectIds: createDraftSafeSelector(selectState, selectIds),
6904 selectEntities: selectGlobalizedEntities,
6905 selectAll: createDraftSafeSelector(selectState, selectAll),
6906 selectTotal: createDraftSafeSelector(selectState, selectTotal),
6907 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
6908 };
6909 }
6910 return { getSelectors: getSelectors };
6911 }
6912 // src/entities/state_adapter.ts
6913
6914 function createSingleArgumentStateOperator(mutator) {
6915 var operator = createStateOperator(function (_, state) { return mutator(state); });
6916 return function operation(state) {
6917 return operator(state, void 0);
6918 };
6919 }
6920 function createStateOperator(mutator) {
6921 return function operation(state, arg) {
6922 function isPayloadActionArgument(arg2) {
6923 return isFSA(arg2);
6924 }
6925 var runMutator = function (draft) {
6926 if (isPayloadActionArgument(arg)) {
6927 mutator(arg.payload, draft);
6928 }
6929 else {
6930 mutator(arg, draft);
6931 }
6932 };
6933 if ((0,immer__WEBPACK_IMPORTED_MODULE_2__.isDraft)(state)) {
6934 runMutator(state);
6935 return state;
6936 }
6937 else {
6938 return (0,immer__WEBPACK_IMPORTED_MODULE_2__["default"])(state, runMutator);
6939 }
6940 };
6941 }
6942 // src/entities/utils.ts
6943 function selectIdValue(entity, selectId) {
6944 var key = selectId(entity);
6945 if ( true && key === void 0) {
6946 console.warn("The entity passed to the `selectId` implementation returned undefined.", "You should probably provide your own `selectId` implementation.", "The entity that was passed:", entity, "The `selectId` implementation:", selectId.toString());
6947 }
6948 return key;
6949 }
6950 function ensureEntitiesArray(entities) {
6951 if (!Array.isArray(entities)) {
6952 entities = Object.values(entities);
6953 }
6954 return entities;
6955 }
6956 function splitAddedUpdatedEntities(newEntities, selectId, state) {
6957 newEntities = ensureEntitiesArray(newEntities);
6958 var added = [];
6959 var updated = [];
6960 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
6961 var entity = newEntities_1[_i];
6962 var id = selectIdValue(entity, selectId);
6963 if (id in state.entities) {
6964 updated.push({ id: id, changes: entity });
6965 }
6966 else {
6967 added.push(entity);
6968 }
6969 }
6970 return [added, updated];
6971 }
6972 // src/entities/unsorted_state_adapter.ts
6973 function createUnsortedStateAdapter(selectId) {
6974 function addOneMutably(entity, state) {
6975 var key = selectIdValue(entity, selectId);
6976 if (key in state.entities) {
6977 return;
6978 }
6979 state.ids.push(key);
6980 state.entities[key] = entity;
6981 }
6982 function addManyMutably(newEntities, state) {
6983 newEntities = ensureEntitiesArray(newEntities);
6984 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
6985 var entity = newEntities_2[_i];
6986 addOneMutably(entity, state);
6987 }
6988 }
6989 function setOneMutably(entity, state) {
6990 var key = selectIdValue(entity, selectId);
6991 if (!(key in state.entities)) {
6992 state.ids.push(key);
6993 }
6994 state.entities[key] = entity;
6995 }
6996 function setManyMutably(newEntities, state) {
6997 newEntities = ensureEntitiesArray(newEntities);
6998 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
6999 var entity = newEntities_3[_i];
7000 setOneMutably(entity, state);
7001 }
7002 }
7003 function setAllMutably(newEntities, state) {
7004 newEntities = ensureEntitiesArray(newEntities);
7005 state.ids = [];
7006 state.entities = {};
7007 addManyMutably(newEntities, state);
7008 }
7009 function removeOneMutably(key, state) {
7010 return removeManyMutably([key], state);
7011 }
7012 function removeManyMutably(keys, state) {
7013 var didMutate = false;
7014 keys.forEach(function (key) {
7015 if (key in state.entities) {
7016 delete state.entities[key];
7017 didMutate = true;
7018 }
7019 });
7020 if (didMutate) {
7021 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7022 }
7023 }
7024 function removeAllMutably(state) {
7025 Object.assign(state, {
7026 ids: [],
7027 entities: {}
7028 });
7029 }
7030 function takeNewKey(keys, update, state) {
7031 var original2 = state.entities[update.id];
7032 var updated = Object.assign({}, original2, update.changes);
7033 var newKey = selectIdValue(updated, selectId);
7034 var hasNewKey = newKey !== update.id;
7035 if (hasNewKey) {
7036 keys[update.id] = newKey;
7037 delete state.entities[update.id];
7038 }
7039 state.entities[newKey] = updated;
7040 return hasNewKey;
7041 }
7042 function updateOneMutably(update, state) {
7043 return updateManyMutably([update], state);
7044 }
7045 function updateManyMutably(updates, state) {
7046 var newKeys = {};
7047 var updatesPerEntity = {};
7048 updates.forEach(function (update) {
7049 if (update.id in state.entities) {
7050 updatesPerEntity[update.id] = {
7051 id: update.id,
7052 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7053 };
7054 }
7055 });
7056 updates = Object.values(updatesPerEntity);
7057 var didMutateEntities = updates.length > 0;
7058 if (didMutateEntities) {
7059 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7060 if (didMutateIds) {
7061 state.ids = Object.keys(state.entities);
7062 }
7063 }
7064 }
7065 function upsertOneMutably(entity, state) {
7066 return upsertManyMutably([entity], state);
7067 }
7068 function upsertManyMutably(newEntities, state) {
7069 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7070 updateManyMutably(updated, state);
7071 addManyMutably(added, state);
7072 }
7073 return {
7074 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7075 addOne: createStateOperator(addOneMutably),
7076 addMany: createStateOperator(addManyMutably),
7077 setOne: createStateOperator(setOneMutably),
7078 setMany: createStateOperator(setManyMutably),
7079 setAll: createStateOperator(setAllMutably),
7080 updateOne: createStateOperator(updateOneMutably),
7081 updateMany: createStateOperator(updateManyMutably),
7082 upsertOne: createStateOperator(upsertOneMutably),
7083 upsertMany: createStateOperator(upsertManyMutably),
7084 removeOne: createStateOperator(removeOneMutably),
7085 removeMany: createStateOperator(removeManyMutably)
7086 };
7087 }
7088 // src/entities/sorted_state_adapter.ts
7089 function createSortedStateAdapter(selectId, sort) {
7090 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7091 function addOneMutably(entity, state) {
7092 return addManyMutably([entity], state);
7093 }
7094 function addManyMutably(newEntities, state) {
7095 newEntities = ensureEntitiesArray(newEntities);
7096 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7097 if (models.length !== 0) {
7098 merge(models, state);
7099 }
7100 }
7101 function setOneMutably(entity, state) {
7102 return setManyMutably([entity], state);
7103 }
7104 function setManyMutably(newEntities, state) {
7105 newEntities = ensureEntitiesArray(newEntities);
7106 if (newEntities.length !== 0) {
7107 merge(newEntities, state);
7108 }
7109 }
7110 function setAllMutably(newEntities, state) {
7111 newEntities = ensureEntitiesArray(newEntities);
7112 state.entities = {};
7113 state.ids = [];
7114 addManyMutably(newEntities, state);
7115 }
7116 function updateOneMutably(update, state) {
7117 return updateManyMutably([update], state);
7118 }
7119 function updateManyMutably(updates, state) {
7120 var appliedUpdates = false;
7121 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7122 var update = updates_1[_i];
7123 var entity = state.entities[update.id];
7124 if (!entity) {
7125 continue;
7126 }
7127 appliedUpdates = true;
7128 Object.assign(entity, update.changes);
7129 var newId = selectId(entity);
7130 if (update.id !== newId) {
7131 delete state.entities[update.id];
7132 state.entities[newId] = entity;
7133 }
7134 }
7135 if (appliedUpdates) {
7136 resortEntities(state);
7137 }
7138 }
7139 function upsertOneMutably(entity, state) {
7140 return upsertManyMutably([entity], state);
7141 }
7142 function upsertManyMutably(newEntities, state) {
7143 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7144 updateManyMutably(updated, state);
7145 addManyMutably(added, state);
7146 }
7147 function areArraysEqual(a, b) {
7148 if (a.length !== b.length) {
7149 return false;
7150 }
7151 for (var i = 0; i < a.length && i < b.length; i++) {
7152 if (a[i] === b[i]) {
7153 continue;
7154 }
7155 return false;
7156 }
7157 return true;
7158 }
7159 function merge(models, state) {
7160 models.forEach(function (model) {
7161 state.entities[selectId(model)] = model;
7162 });
7163 resortEntities(state);
7164 }
7165 function resortEntities(state) {
7166 var allEntities = Object.values(state.entities);
7167 allEntities.sort(sort);
7168 var newSortedIds = allEntities.map(selectId);
7169 var ids = state.ids;
7170 if (!areArraysEqual(ids, newSortedIds)) {
7171 state.ids = newSortedIds;
7172 }
7173 }
7174 return {
7175 removeOne: removeOne,
7176 removeMany: removeMany,
7177 removeAll: removeAll,
7178 addOne: createStateOperator(addOneMutably),
7179 updateOne: createStateOperator(updateOneMutably),
7180 upsertOne: createStateOperator(upsertOneMutably),
7181 setOne: createStateOperator(setOneMutably),
7182 setMany: createStateOperator(setManyMutably),
7183 setAll: createStateOperator(setAllMutably),
7184 addMany: createStateOperator(addManyMutably),
7185 updateMany: createStateOperator(updateManyMutably),
7186 upsertMany: createStateOperator(upsertManyMutably)
7187 };
7188 }
7189 // src/entities/create_adapter.ts
7190 function createEntityAdapter(options) {
7191 if (options === void 0) { options = {}; }
7192 var _c = __spreadValues({
7193 sortComparer: false,
7194 selectId: function (instance) { return instance.id; }
7195 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7196 var stateFactory = createInitialStateFactory();
7197 var selectorsFactory = createSelectorsFactory();
7198 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7199 return __spreadValues(__spreadValues(__spreadValues({
7200 selectId: selectId,
7201 sortComparer: sortComparer
7202 }, stateFactory), selectorsFactory), stateAdapter);
7203 }
7204 // src/nanoid.ts
7205 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7206 var nanoid = function (size) {
7207 if (size === void 0) { size = 21; }
7208 var id = "";
7209 var i = size;
7210 while (i--) {
7211 id += urlAlphabet[Math.random() * 64 | 0];
7212 }
7213 return id;
7214 };
7215 // src/createAsyncThunk.ts
7216 var commonProperties = [
7217 "name",
7218 "message",
7219 "stack",
7220 "code"
7221 ];
7222 var RejectWithValue = /** @class */ (function () {
7223 function RejectWithValue(payload, meta) {
7224 this.payload = payload;
7225 this.meta = meta;
7226 }
7227 return RejectWithValue;
7228 }());
7229 var FulfillWithMeta = /** @class */ (function () {
7230 function FulfillWithMeta(payload, meta) {
7231 this.payload = payload;
7232 this.meta = meta;
7233 }
7234 return FulfillWithMeta;
7235 }());
7236 var miniSerializeError = function (value) {
7237 if (typeof value === "object" && value !== null) {
7238 var simpleError = {};
7239 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7240 var property = commonProperties_1[_i];
7241 if (typeof value[property] === "string") {
7242 simpleError[property] = value[property];
7243 }
7244 }
7245 return simpleError;
7246 }
7247 return { message: String(value) };
7248 };
7249 var createAsyncThunk = (function () {
7250 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7251 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7252 payload: payload,
7253 meta: __spreadProps(__spreadValues({}, meta || {}), {
7254 arg: arg,
7255 requestId: requestId,
7256 requestStatus: "fulfilled"
7257 })
7258 }); });
7259 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
7260 payload: void 0,
7261 meta: __spreadProps(__spreadValues({}, meta || {}), {
7262 arg: arg,
7263 requestId: requestId,
7264 requestStatus: "pending"
7265 })
7266 }); });
7267 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
7268 payload: payload,
7269 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
7270 meta: __spreadProps(__spreadValues({}, meta || {}), {
7271 arg: arg,
7272 requestId: requestId,
7273 rejectedWithValue: !!payload,
7274 requestStatus: "rejected",
7275 aborted: (error == null ? void 0 : error.name) === "AbortError",
7276 condition: (error == null ? void 0 : error.name) === "ConditionError"
7277 })
7278 }); });
7279 var displayedWarning = false;
7280 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
7281 function class_1() {
7282 this.signal = {
7283 aborted: false,
7284 addEventListener: function () {
7285 },
7286 dispatchEvent: function () {
7287 return false;
7288 },
7289 onabort: function () {
7290 },
7291 removeEventListener: function () {
7292 },
7293 reason: void 0,
7294 throwIfAborted: function () {
7295 }
7296 };
7297 }
7298 class_1.prototype.abort = function () {
7299 if (true) {
7300 if (!displayedWarning) {
7301 displayedWarning = true;
7302 console.info("This platform does not implement AbortController. \nIf you want to use the AbortController to react to `abort` events, please consider importing a polyfill like 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'.");
7303 }
7304 }
7305 };
7306 return class_1;
7307 }());
7308 function actionCreator(arg) {
7309 return function (dispatch, getState, extra) {
7310 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
7311 var abortController = new AC();
7312 var abortReason;
7313 var started = false;
7314 function abort(reason) {
7315 abortReason = reason;
7316 abortController.abort();
7317 }
7318 var promise2 = function () {
7319 return __async(this, null, function () {
7320 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
7321 return __generator(this, function (_c) {
7322 switch (_c.label) {
7323 case 0:
7324 _c.trys.push([0, 4, , 5]);
7325 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
7326 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
7327 return [4 /*yield*/, conditionResult];
7328 case 1:
7329 conditionResult = _c.sent();
7330 _c.label = 2;
7331 case 2:
7332 if (conditionResult === false || abortController.signal.aborted) {
7333 throw {
7334 name: "ConditionError",
7335 message: "Aborted due to condition callback returning false."
7336 };
7337 }
7338 started = true;
7339 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
7340 name: "AbortError",
7341 message: abortReason || "Aborted"
7342 }); }); });
7343 dispatch(pending(requestId, arg, (_b = options == null ? void 0 : options.getPendingMeta) == null ? void 0 : _b.call(options, { requestId: requestId, arg: arg }, { getState: getState, extra: extra })));
7344 return [4 /*yield*/, Promise.race([
7345 abortedPromise,
7346 Promise.resolve(payloadCreator(arg, {
7347 dispatch: dispatch,
7348 getState: getState,
7349 extra: extra,
7350 requestId: requestId,
7351 signal: abortController.signal,
7352 abort: abort,
7353 rejectWithValue: function (value, meta) {
7354 return new RejectWithValue(value, meta);
7355 },
7356 fulfillWithValue: function (value, meta) {
7357 return new FulfillWithMeta(value, meta);
7358 }
7359 })).then(function (result) {
7360 if (result instanceof RejectWithValue) {
7361 throw result;
7362 }
7363 if (result instanceof FulfillWithMeta) {
7364 return fulfilled(result.payload, requestId, arg, result.meta);
7365 }
7366 return fulfilled(result, requestId, arg);
7367 })
7368 ])];
7369 case 3:
7370 finalAction = _c.sent();
7371 return [3 /*break*/, 5];
7372 case 4:
7373 err_1 = _c.sent();
7374 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
7375 return [3 /*break*/, 5];
7376 case 5:
7377 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
7378 if (!skipDispatch) {
7379 dispatch(finalAction);
7380 }
7381 return [2 /*return*/, finalAction];
7382 }
7383 });
7384 });
7385 }();
7386 return Object.assign(promise2, {
7387 abort: abort,
7388 requestId: requestId,
7389 arg: arg,
7390 unwrap: function () {
7391 return promise2.then(unwrapResult);
7392 }
7393 });
7394 };
7395 }
7396 return Object.assign(actionCreator, {
7397 pending: pending,
7398 rejected: rejected,
7399 fulfilled: fulfilled,
7400 typePrefix: typePrefix
7401 });
7402 }
7403 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
7404 return createAsyncThunk2;
7405 })();
7406 function unwrapResult(action) {
7407 if (action.meta && action.meta.rejectedWithValue) {
7408 throw action.payload;
7409 }
7410 if (action.error) {
7411 throw action.error;
7412 }
7413 return action.payload;
7414 }
7415 function isThenable(value) {
7416 return value !== null && typeof value === "object" && typeof value.then === "function";
7417 }
7418 // src/matchers.ts
7419 var matches = function (matcher, action) {
7420 if (hasMatchFunction(matcher)) {
7421 return matcher.match(action);
7422 }
7423 else {
7424 return matcher(action);
7425 }
7426 };
7427 function isAnyOf() {
7428 var matchers = [];
7429 for (var _i = 0; _i < arguments.length; _i++) {
7430 matchers[_i] = arguments[_i];
7431 }
7432 return function (action) {
7433 return matchers.some(function (matcher) { return matches(matcher, action); });
7434 };
7435 }
7436 function isAllOf() {
7437 var matchers = [];
7438 for (var _i = 0; _i < arguments.length; _i++) {
7439 matchers[_i] = arguments[_i];
7440 }
7441 return function (action) {
7442 return matchers.every(function (matcher) { return matches(matcher, action); });
7443 };
7444 }
7445 function hasExpectedRequestMetadata(action, validStatus) {
7446 if (!action || !action.meta)
7447 return false;
7448 var hasValidRequestId = typeof action.meta.requestId === "string";
7449 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
7450 return hasValidRequestId && hasValidRequestStatus;
7451 }
7452 function isAsyncThunkArray(a) {
7453 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
7454 }
7455 function isPending() {
7456 var asyncThunks = [];
7457 for (var _i = 0; _i < arguments.length; _i++) {
7458 asyncThunks[_i] = arguments[_i];
7459 }
7460 if (asyncThunks.length === 0) {
7461 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
7462 }
7463 if (!isAsyncThunkArray(asyncThunks)) {
7464 return isPending()(asyncThunks[0]);
7465 }
7466 return function (action) {
7467 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
7468 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7469 return combinedMatcher(action);
7470 };
7471 }
7472 function isRejected() {
7473 var asyncThunks = [];
7474 for (var _i = 0; _i < arguments.length; _i++) {
7475 asyncThunks[_i] = arguments[_i];
7476 }
7477 if (asyncThunks.length === 0) {
7478 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
7479 }
7480 if (!isAsyncThunkArray(asyncThunks)) {
7481 return isRejected()(asyncThunks[0]);
7482 }
7483 return function (action) {
7484 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
7485 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7486 return combinedMatcher(action);
7487 };
7488 }
7489 function isRejectedWithValue() {
7490 var asyncThunks = [];
7491 for (var _i = 0; _i < arguments.length; _i++) {
7492 asyncThunks[_i] = arguments[_i];
7493 }
7494 var hasFlag = function (action) {
7495 return action && action.meta && action.meta.rejectedWithValue;
7496 };
7497 if (asyncThunks.length === 0) {
7498 return function (action) {
7499 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7500 return combinedMatcher(action);
7501 };
7502 }
7503 if (!isAsyncThunkArray(asyncThunks)) {
7504 return isRejectedWithValue()(asyncThunks[0]);
7505 }
7506 return function (action) {
7507 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7508 return combinedMatcher(action);
7509 };
7510 }
7511 function isFulfilled() {
7512 var asyncThunks = [];
7513 for (var _i = 0; _i < arguments.length; _i++) {
7514 asyncThunks[_i] = arguments[_i];
7515 }
7516 if (asyncThunks.length === 0) {
7517 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
7518 }
7519 if (!isAsyncThunkArray(asyncThunks)) {
7520 return isFulfilled()(asyncThunks[0]);
7521 }
7522 return function (action) {
7523 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
7524 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7525 return combinedMatcher(action);
7526 };
7527 }
7528 function isAsyncThunkAction() {
7529 var asyncThunks = [];
7530 for (var _i = 0; _i < arguments.length; _i++) {
7531 asyncThunks[_i] = arguments[_i];
7532 }
7533 if (asyncThunks.length === 0) {
7534 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
7535 }
7536 if (!isAsyncThunkArray(asyncThunks)) {
7537 return isAsyncThunkAction()(asyncThunks[0]);
7538 }
7539 return function (action) {
7540 var matchers = [];
7541 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
7542 var asyncThunk = asyncThunks_1[_i];
7543 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
7544 }
7545 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7546 return combinedMatcher(action);
7547 };
7548 }
7549 // src/listenerMiddleware/utils.ts
7550 var assertFunction = function (func, expected) {
7551 if (typeof func !== "function") {
7552 throw new TypeError(expected + " is not a function");
7553 }
7554 };
7555 var noop = function () {
7556 };
7557 var catchRejection = function (promise2, onError) {
7558 if (onError === void 0) { onError = noop; }
7559 promise2.catch(onError);
7560 return promise2;
7561 };
7562 var addAbortSignalListener = function (abortSignal, callback) {
7563 abortSignal.addEventListener("abort", callback, { once: true });
7564 return function () { return abortSignal.removeEventListener("abort", callback); };
7565 };
7566 var abortControllerWithReason = function (abortController, reason) {
7567 var signal = abortController.signal;
7568 if (signal.aborted) {
7569 return;
7570 }
7571 if (!("reason" in signal)) {
7572 Object.defineProperty(signal, "reason", {
7573 enumerable: true,
7574 value: reason,
7575 configurable: true,
7576 writable: true
7577 });
7578 }
7579 ;
7580 abortController.abort(reason);
7581 };
7582 // src/listenerMiddleware/exceptions.ts
7583 var task = "task";
7584 var listener = "listener";
7585 var completed = "completed";
7586 var cancelled = "cancelled";
7587 var taskCancelled = "task-" + cancelled;
7588 var taskCompleted = "task-" + completed;
7589 var listenerCancelled = listener + "-" + cancelled;
7590 var listenerCompleted = listener + "-" + completed;
7591 var TaskAbortError = /** @class */ (function () {
7592 function TaskAbortError(code) {
7593 this.code = code;
7594 this.name = "TaskAbortError";
7595 this.message = task + " " + cancelled + " (reason: " + code + ")";
7596 }
7597 return TaskAbortError;
7598 }());
7599 // src/listenerMiddleware/task.ts
7600 var validateActive = function (signal) {
7601 if (signal.aborted) {
7602 throw new TaskAbortError(signal.reason);
7603 }
7604 };
7605 function raceWithSignal(signal, promise2) {
7606 var cleanup = noop;
7607 return new Promise(function (resolve, reject) {
7608 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
7609 if (signal.aborted) {
7610 notifyRejection();
7611 return;
7612 }
7613 cleanup = addAbortSignalListener(signal, notifyRejection);
7614 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
7615 }).finally(function () {
7616 cleanup = noop;
7617 });
7618 }
7619 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
7620 var value, error_1;
7621 return __generator(this, function (_c) {
7622 switch (_c.label) {
7623 case 0:
7624 _c.trys.push([0, 3, 4, 5]);
7625 return [4 /*yield*/, Promise.resolve()];
7626 case 1:
7627 _c.sent();
7628 return [4 /*yield*/, task2()];
7629 case 2:
7630 value = _c.sent();
7631 return [2 /*return*/, {
7632 status: "ok",
7633 value: value
7634 }];
7635 case 3:
7636 error_1 = _c.sent();
7637 return [2 /*return*/, {
7638 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
7639 error: error_1
7640 }];
7641 case 4:
7642 cleanUp == null ? void 0 : cleanUp();
7643 return [7 /*endfinally*/];
7644 case 5: return [2 /*return*/];
7645 }
7646 });
7647 }); };
7648 var createPause = function (signal) {
7649 return function (promise2) {
7650 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
7651 validateActive(signal);
7652 return output;
7653 }));
7654 };
7655 };
7656 var createDelay = function (signal) {
7657 var pause = createPause(signal);
7658 return function (timeoutMs) {
7659 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
7660 };
7661 };
7662 // src/listenerMiddleware/index.ts
7663 var assign = Object.assign;
7664 var INTERNAL_NIL_TOKEN = {};
7665 var alm = "listenerMiddleware";
7666 var createFork = function (parentAbortSignal, parentBlockingPromises) {
7667 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
7668 return function (taskExecutor, opts) {
7669 assertFunction(taskExecutor, "taskExecutor");
7670 var childAbortController = new AbortController();
7671 linkControllers(childAbortController);
7672 var result = runTask(function () { return __async(void 0, null, function () {
7673 var result2;
7674 return __generator(this, function (_c) {
7675 switch (_c.label) {
7676 case 0:
7677 validateActive(parentAbortSignal);
7678 validateActive(childAbortController.signal);
7679 return [4 /*yield*/, taskExecutor({
7680 pause: createPause(childAbortController.signal),
7681 delay: createDelay(childAbortController.signal),
7682 signal: childAbortController.signal
7683 })];
7684 case 1:
7685 result2 = _c.sent();
7686 validateActive(childAbortController.signal);
7687 return [2 /*return*/, result2];
7688 }
7689 });
7690 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
7691 if (opts == null ? void 0 : opts.autoJoin) {
7692 parentBlockingPromises.push(result);
7693 }
7694 return {
7695 result: createPause(parentAbortSignal)(result),
7696 cancel: function () {
7697 abortControllerWithReason(childAbortController, taskCancelled);
7698 }
7699 };
7700 };
7701 };
7702 var createTakePattern = function (startListening, signal) {
7703 var take = function (predicate, timeout) { return __async(void 0, null, function () {
7704 var unsubscribe, tuplePromise, promises, output;
7705 return __generator(this, function (_c) {
7706 switch (_c.label) {
7707 case 0:
7708 validateActive(signal);
7709 unsubscribe = function () {
7710 };
7711 tuplePromise = new Promise(function (resolve, reject) {
7712 var stopListening = startListening({
7713 predicate: predicate,
7714 effect: function (action, listenerApi) {
7715 listenerApi.unsubscribe();
7716 resolve([
7717 action,
7718 listenerApi.getState(),
7719 listenerApi.getOriginalState()
7720 ]);
7721 }
7722 });
7723 unsubscribe = function () {
7724 stopListening();
7725 reject();
7726 };
7727 });
7728 promises = [
7729 tuplePromise
7730 ];
7731 if (timeout != null) {
7732 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
7733 }
7734 _c.label = 1;
7735 case 1:
7736 _c.trys.push([1, , 3, 4]);
7737 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
7738 case 2:
7739 output = _c.sent();
7740 validateActive(signal);
7741 return [2 /*return*/, output];
7742 case 3:
7743 unsubscribe();
7744 return [7 /*endfinally*/];
7745 case 4: return [2 /*return*/];
7746 }
7747 });
7748 }); };
7749 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
7750 };
7751 var getListenerEntryPropsFrom = function (options) {
7752 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
7753 if (type) {
7754 predicate = createAction(type).match;
7755 }
7756 else if (actionCreator) {
7757 type = actionCreator.type;
7758 predicate = actionCreator.match;
7759 }
7760 else if (matcher) {
7761 predicate = matcher;
7762 }
7763 else if (predicate) {
7764 }
7765 else {
7766 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
7767 }
7768 assertFunction(effect, "options.listener");
7769 return { predicate: predicate, type: type, effect: effect };
7770 };
7771 var createListenerEntry = function (options) {
7772 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
7773 var id = nanoid();
7774 var entry = {
7775 id: id,
7776 effect: effect,
7777 type: type,
7778 predicate: predicate,
7779 pending: new Set(),
7780 unsubscribe: function () {
7781 throw new Error("Unsubscribe not initialized");
7782 }
7783 };
7784 return entry;
7785 };
7786 var cancelActiveListeners = function (entry) {
7787 entry.pending.forEach(function (controller) {
7788 abortControllerWithReason(controller, listenerCancelled);
7789 });
7790 };
7791 var createClearListenerMiddleware = function (listenerMap) {
7792 return function () {
7793 listenerMap.forEach(cancelActiveListeners);
7794 listenerMap.clear();
7795 };
7796 };
7797 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
7798 try {
7799 errorHandler(errorToNotify, errorInfo);
7800 }
7801 catch (errorHandlerError) {
7802 setTimeout(function () {
7803 throw errorHandlerError;
7804 }, 0);
7805 }
7806 };
7807 var addListener = createAction(alm + "/add");
7808 var clearAllListeners = createAction(alm + "/removeAll");
7809 var removeListener = createAction(alm + "/remove");
7810 var defaultErrorHandler = function () {
7811 var args = [];
7812 for (var _i = 0; _i < arguments.length; _i++) {
7813 args[_i] = arguments[_i];
7814 }
7815 console.error.apply(console, __spreadArray([alm + "/error"], args));
7816 };
7817 function createListenerMiddleware(middlewareOptions) {
7818 var _this = this;
7819 if (middlewareOptions === void 0) { middlewareOptions = {}; }
7820 var listenerMap = new Map();
7821 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
7822 assertFunction(onError, "onError");
7823 var insertEntry = function (entry) {
7824 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
7825 listenerMap.set(entry.id, entry);
7826 return function (cancelOptions) {
7827 entry.unsubscribe();
7828 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
7829 cancelActiveListeners(entry);
7830 }
7831 };
7832 };
7833 var findListenerEntry = function (comparator) {
7834 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
7835 var entry = _c[_i];
7836 if (comparator(entry)) {
7837 return entry;
7838 }
7839 }
7840 return void 0;
7841 };
7842 var startListening = function (options) {
7843 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
7844 if (!entry) {
7845 entry = createListenerEntry(options);
7846 }
7847 return insertEntry(entry);
7848 };
7849 var stopListening = function (options) {
7850 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
7851 var entry = findListenerEntry(function (entry2) {
7852 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
7853 return matchPredicateOrType && entry2.effect === effect;
7854 });
7855 if (entry) {
7856 entry.unsubscribe();
7857 if (options.cancelActive) {
7858 cancelActiveListeners(entry);
7859 }
7860 }
7861 return !!entry;
7862 };
7863 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
7864 var internalTaskController, take, autoJoinPromises, listenerError_1;
7865 return __generator(this, function (_c) {
7866 switch (_c.label) {
7867 case 0:
7868 internalTaskController = new AbortController();
7869 take = createTakePattern(startListening, internalTaskController.signal);
7870 autoJoinPromises = [];
7871 _c.label = 1;
7872 case 1:
7873 _c.trys.push([1, 3, 4, 6]);
7874 entry.pending.add(internalTaskController);
7875 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
7876 getOriginalState: getOriginalState,
7877 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
7878 take: take,
7879 delay: createDelay(internalTaskController.signal),
7880 pause: createPause(internalTaskController.signal),
7881 extra: extra,
7882 signal: internalTaskController.signal,
7883 fork: createFork(internalTaskController.signal, autoJoinPromises),
7884 unsubscribe: entry.unsubscribe,
7885 subscribe: function () {
7886 listenerMap.set(entry.id, entry);
7887 },
7888 cancelActiveListeners: function () {
7889 entry.pending.forEach(function (controller, _, set) {
7890 if (controller !== internalTaskController) {
7891 abortControllerWithReason(controller, listenerCancelled);
7892 set.delete(controller);
7893 }
7894 });
7895 }
7896 })))];
7897 case 2:
7898 _c.sent();
7899 return [3 /*break*/, 6];
7900 case 3:
7901 listenerError_1 = _c.sent();
7902 if (!(listenerError_1 instanceof TaskAbortError)) {
7903 safelyNotifyError(onError, listenerError_1, {
7904 raisedBy: "effect"
7905 });
7906 }
7907 return [3 /*break*/, 6];
7908 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
7909 case 5:
7910 _c.sent();
7911 abortControllerWithReason(internalTaskController, listenerCompleted);
7912 entry.pending.delete(internalTaskController);
7913 return [7 /*endfinally*/];
7914 case 6: return [2 /*return*/];
7915 }
7916 });
7917 }); };
7918 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
7919 var middleware = function (api) { return function (next) { return function (action) {
7920 if (!isAction(action)) {
7921 return next(action);
7922 }
7923 if (addListener.match(action)) {
7924 return startListening(action.payload);
7925 }
7926 if (clearAllListeners.match(action)) {
7927 clearListenerMiddleware();
7928 return;
7929 }
7930 if (removeListener.match(action)) {
7931 return stopListening(action.payload);
7932 }
7933 var originalState = api.getState();
7934 var getOriginalState = function () {
7935 if (originalState === INTERNAL_NIL_TOKEN) {
7936 throw new Error(alm + ": getOriginalState can only be called synchronously");
7937 }
7938 return originalState;
7939 };
7940 var result;
7941 try {
7942 result = next(action);
7943 if (listenerMap.size > 0) {
7944 var currentState = api.getState();
7945 var listenerEntries = Array.from(listenerMap.values());
7946 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
7947 var entry = listenerEntries_1[_i];
7948 var runListener = false;
7949 try {
7950 runListener = entry.predicate(action, currentState, originalState);
7951 }
7952 catch (predicateError) {
7953 runListener = false;
7954 safelyNotifyError(onError, predicateError, {
7955 raisedBy: "predicate"
7956 });
7957 }
7958 if (!runListener) {
7959 continue;
7960 }
7961 notifyListener(entry, action, api, getOriginalState);
7962 }
7963 }
7964 }
7965 finally {
7966 originalState = INTERNAL_NIL_TOKEN;
7967 }
7968 return result;
7969 }; }; };
7970 return {
7971 middleware: middleware,
7972 startListening: startListening,
7973 stopListening: stopListening,
7974 clearListeners: clearListenerMiddleware
7975 };
7976 }
7977 // src/autoBatchEnhancer.ts
7978 var SHOULD_AUTOBATCH = "RTK_autoBatch";
7979 var prepareAutoBatched = function () { return function (payload) {
7980 var _c;
7981 return ({
7982 payload: payload,
7983 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
7984 });
7985 }; };
7986 var promise;
7987 var queueMicrotaskShim = typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "undefined" ? window : typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : globalThis) : function (cb) { return (promise || (promise = Promise.resolve())).then(cb).catch(function (err) { return setTimeout(function () {
7988 throw err;
7989 }, 0); }); };
7990 var createQueueWithTimer = function (timeout) {
7991 return function (notify) {
7992 setTimeout(notify, timeout);
7993 };
7994 };
7995 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
7996 var autoBatchEnhancer = function (options) {
7997 if (options === void 0) { options = { type: "raf" }; }
7998 return function (next) { return function () {
7999 var args = [];
8000 for (var _i = 0; _i < arguments.length; _i++) {
8001 args[_i] = arguments[_i];
8002 }
8003 var store = next.apply(void 0, args);
8004 var notifying = true;
8005 var shouldNotifyAtEndOfTick = false;
8006 var notificationQueued = false;
8007 var listeners = new Set();
8008 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8009 var notifyListeners = function () {
8010 notificationQueued = false;
8011 if (shouldNotifyAtEndOfTick) {
8012 shouldNotifyAtEndOfTick = false;
8013 listeners.forEach(function (l) { return l(); });
8014 }
8015 };
8016 return Object.assign({}, store, {
8017 subscribe: function (listener2) {
8018 var wrappedListener = function () { return notifying && listener2(); };
8019 var unsubscribe = store.subscribe(wrappedListener);
8020 listeners.add(listener2);
8021 return function () {
8022 unsubscribe();
8023 listeners.delete(listener2);
8024 };
8025 },
8026 dispatch: function (action) {
8027 var _a;
8028 try {
8029 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8030 shouldNotifyAtEndOfTick = !notifying;
8031 if (shouldNotifyAtEndOfTick) {
8032 if (!notificationQueued) {
8033 notificationQueued = true;
8034 queueCallback(notifyListeners);
8035 }
8036 }
8037 return store.dispatch(action);
8038 }
8039 finally {
8040 notifying = true;
8041 }
8042 }
8043 });
8044 }; };
8045 };
8046 // src/index.ts
8047 (0,immer__WEBPACK_IMPORTED_MODULE_2__.enableES5)();
8048
8049 //# sourceMappingURL=redux-toolkit.esm.js.map
8050
8051 /***/ }),
8052
8053 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8054 /*!************************************************!*\
8055 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8056 \************************************************/
8057 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8058
8059 "use strict";
8060 __webpack_require__.r(__webpack_exports__);
8061 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8062 /* harmony export */ Immer: () => (/* binding */ un),
8063 /* harmony export */ applyPatches: () => (/* binding */ pn),
8064 /* harmony export */ castDraft: () => (/* binding */ K),
8065 /* harmony export */ castImmutable: () => (/* binding */ $),
8066 /* harmony export */ createDraft: () => (/* binding */ ln),
8067 /* harmony export */ current: () => (/* binding */ R),
8068 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8069 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8070 /* harmony export */ enableES5: () => (/* binding */ F),
8071 /* harmony export */ enableMapSet: () => (/* binding */ C),
8072 /* harmony export */ enablePatches: () => (/* binding */ T),
8073 /* harmony export */ finishDraft: () => (/* binding */ dn),
8074 /* harmony export */ freeze: () => (/* binding */ d),
8075 /* harmony export */ immerable: () => (/* binding */ L),
8076 /* harmony export */ isDraft: () => (/* binding */ r),
8077 /* harmony export */ isDraftable: () => (/* binding */ t),
8078 /* harmony export */ nothing: () => (/* binding */ H),
8079 /* harmony export */ original: () => (/* binding */ e),
8080 /* harmony export */ produce: () => (/* binding */ fn),
8081 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8082 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8083 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8084 /* harmony export */ });
8085 function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if(true){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}// removed by dead control flow
8086 {}}function r(n){return!!n&&!!n[Q]}function t(n){var r;return!!n&&(function(n){if(!n||"object"!=typeof n)return!1;var r=Object.getPrototypeOf(n);if(null===r)return!0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v(n))}function e(t){return r(t)||n(23,t),t[Q].t}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n)})):n.forEach((function(t,e){return r(e,t,n)}))}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]})}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=!1),y(n)||r(n)||!t(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,!0)}),!0)),n}function h(){n(2)}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function m(n,r){tn[n]||(tn[n]=r)}function _(){return false||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r)}function g(n){O(n),n.p.forEach(S),n.p=null}function O(n){n===U&&(U=n.l)}function w(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=!0}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b("ES5").S(e,r,o),o?(i[Q].P&&(g(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o,u=o,a=!1;3===e.i&&(u=new Set(o),o.clear(),a=!0),i(u,(function(r,i){return A(n,e,o,r,i,t,a)})),x(n,o,!1),t&&n.u&&b("Patches").N(e,t,n.u,n.s)}return e.o}function A(e,i,o,a,c,s,v){if( true&&c===o&&n(5),r(c)){var p=M(e,c,s&&i&&3!==i.i&&!u(i.R,a)?s.concat(a):void 0);if(f(o,a,p),!r(p))return;e.m=!1}else v&&o.add(c);if(t(c)&&!y(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x(e,c)}}function x(n,r,t){void 0===t&&(t=!1),!n.l&&n.h.D&&n.m&&d(r,t)}function z(n,r){var t=n[Q];return(t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t)}}function k(n){n.P||(n.P=!0,n.l&&k(n.l))}function E(n){n.o||(n.o=l(n.t))}function N(n,r,t){var e=s(r)?b("MapSet").F(r,t):v(r)?b("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return(t?t.A:_()).p.push(e),e}function R(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=!0,e=D(r,c),u.I=!1}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t))})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}function F(){function t(n,r){var t=s[n];return t?t.enumerable=r:s[n]=t={configurable:!0,enumerable:r,get:function(){var r=this[Q];return true&&f(r),en.get(r,n)},set:function(r){var t=this[Q]; true&&f(t),en.set(t,n,r)}},t}function e(n){for(var r=n.length-1;r>=0;r--){var t=n[r][Q];if(!t.P)switch(t.i){case 5:a(t)&&k(t);break;case 4:o(t)&&k(t)}}}function o(n){for(var r=n.t,t=n.k,e=nn(t),i=e.length-1;i>=0;i--){var o=e[i];if(o!==Q){var a=r[o];if(void 0===a&&!u(r,o))return!0;var f=t[o],s=f&&f[Q];if(s?s.t!==a:!c(f,a))return!0}}var v=!!r[Q];return e.length!==nn(r).length+(v?0:1)}function a(n){var r=n.k;if(r.length!==n.t.length)return!0;var t=Object.getOwnPropertyDescriptor(r,r.length-1);if(t&&!t.get)return!0;for(var e=0;e<r.length;e++)if(!r.hasOwnProperty(e))return!0;return!1}function f(r){r.g&&n(3,JSON.stringify(p(r)))}var s={};m("ES5",{J:function(n,r){var e=Array.isArray(n),i=function(n,r){if(n){for(var e=Array(r.length),i=0;i<r.length;i++)Object.defineProperty(e,""+i,t(i,!0));return e}var o=rn(r);delete o[Q];for(var u=nn(o),a=0;a<u.length;a++){var f=u[a];o[f]=t(f,n||!!o[f].enumerable)}return Object.create(Object.getPrototypeOf(r),o)}(e,n),o={i:e?5:4,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:i,o:null,g:!1,C:!1};return Object.defineProperty(i,Q,{value:o,writable:!0}),i},S:function(n,t,o){o?r(t)&&t[Q].A===n&&e(n.p):(n.u&&function n(r){if(r&&"object"==typeof r){var t=r[Q];if(t){var e=t.t,o=t.k,f=t.R,c=t.i;if(4===c)i(o,(function(r){r!==Q&&(void 0!==e[r]||u(e,r)?f[r]||n(o[r]):(f[r]=!0,k(t)))})),i(e,(function(n){void 0!==o[n]||u(o,n)||(f[n]=!1,k(t))}));else if(5===c){if(a(t)&&(k(t),f.length=!0),o.length<e.length)for(var s=o.length;s<e.length;s++)f[s]=!1;else for(var v=e.length;v<o.length;v++)f[v]=!0;for(var p=Math.min(o.length,e.length),l=0;l<p;l++)o.hasOwnProperty(l)||(f[l]=!0),void 0===f[l]&&n(o[l])}}}}(n.p[0]),e(n.p))},K:function(n){return 4===n.i?o(n):a(n)}})}function T(){function e(n){if(!t(n))return n;if(Array.isArray(n))return n.map(e);if(s(n))return new Map(Array.from(n.entries()).map((function(n){return[n[0],e(n[1])]})));if(v(n))return new Set(Array.from(n).map(e));var r=Object.create(Object.getPrototypeOf(n));for(var i in n)r[i]=e(n[i]);return u(n,L)&&(r[L]=n[L]),r}function f(n){return r(n)?e(n):n}var c="add";m("Patches",{$:function(r,t){return t.forEach((function(t){for(var i=t.path,u=t.op,f=r,s=0;s<i.length-1;s++){var v=o(f),p=i[s];"string"!=typeof p&&"number"!=typeof p&&(p=""+p),0!==v&&1!==v||"__proto__"!==p&&"constructor"!==p||n(24),"function"==typeof f&&"prototype"===p&&n(24),"object"!=typeof(f=a(f,p))&&n(15,i.join("/"))}var l=o(f),d=e(t.value),h=i[i.length-1];switch(u){case"replace":switch(l){case 2:return f.set(h,d);case 3:n(16);default:return f[h]=d}case c:switch(l){case 1:return"-"===h?f.push(d):f.splice(h,0,d);case 2:return f.set(h,d);case 3:return f.add(d);default:return f[h]=d}case"remove":switch(l){case 1:return f.splice(h,1);case 2:return f.delete(h);case 3:return f.delete(t.value);default:return delete f[h]}default:n(17,u)}})),r},N:function(n,r,t,e){switch(n.i){case 0:case 4:case 2:return function(n,r,t,e){var o=n.t,s=n.o;i(n.R,(function(n,i){var v=a(o,n),p=a(s,n),l=i?u(o,n)?"replace":c:"remove";if(v!==p||"replace"!==l){var d=r.concat(n);t.push("remove"===l?{op:l,path:d}:{op:l,path:d,value:p}),e.push(l===c?{op:"remove",path:d}:"remove"===l?{op:c,path:d,value:f(v)}:{op:"replace",path:d,value:f(v)})}}))}(n,r,t,e);case 5:case 1:return function(n,r,t,e){var i=n.t,o=n.R,u=n.o;if(u.length<i.length){var a=[u,i];i=a[0],u=a[1];var s=[e,t];t=s[0],e=s[1]}for(var v=0;v<i.length;v++)if(o[v]&&u[v]!==i[v]){var p=r.concat([v]);t.push({op:"replace",path:p,value:f(u[v])}),e.push({op:"replace",path:p,value:f(i[v])})}for(var l=i.length;l<u.length;l++){var d=r.concat([l]);t.push({op:c,path:d,value:f(u[l])})}i.length<u.length&&e.push({op:"replace",path:r.concat(["length"]),value:i.length})}(n,r,t,e);case 3:return function(n,r,t,e){var i=n.t,o=n.o,u=0;i.forEach((function(n){if(!o.has(n)){var i=r.concat([u]);t.push({op:"remove",path:i,value:n}),e.unshift({op:c,path:i,value:n})}u++})),u=0,o.forEach((function(n){if(!i.has(n)){var o=r.concat([u]);t.push({op:c,path:o,value:n}),e.unshift({op:"remove",path:o,value:n})}u++}))}(n,r,t,e)}},M:function(n,r,t,e){t.push({op:"replace",path:[],value:r===H?void 0:r}),e.push({op:"replace",path:[],value:n})}})}function C(){function r(n,r){function t(){this.constructor=n}a(n,r),n.prototype=(t.prototype=r.prototype,new t)}function e(n){n.o||(n.R=new Map,n.o=new Map(n.t))}function o(n){n.o||(n.o=new Set,n.t.forEach((function(r){if(t(r)){var e=N(n.A.h,r,n);n.p.set(r,e),n.o.add(e)}else n.o.add(r)})))}function u(r){r.g&&n(3,JSON.stringify(p(r)))}var a=function(n,r){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var t in r)r.hasOwnProperty(t)&&(n[t]=r[t])})(n,r)},f=function(){function n(n,r){return this[Q]={i:2,l:r,A:r?r.A:_(),P:!1,I:!1,o:void 0,R:void 0,t:n,k:this,C:!1,g:!1},this}r(n,Map);var o=n.prototype;return Object.defineProperty(o,"size",{get:function(){return p(this[Q]).size}}),o.has=function(n){return p(this[Q]).has(n)},o.set=function(n,r){var t=this[Q];return u(t),p(t).has(n)&&p(t).get(n)===r||(e(t),k(t),t.R.set(n,!0),t.o.set(n,r),t.R.set(n,!0)),this},o.delete=function(n){if(!this.has(n))return!1;var r=this[Q];return u(r),e(r),k(r),r.t.has(n)?r.R.set(n,!1):r.R.delete(n),r.o.delete(n),!0},o.clear=function(){var n=this[Q];u(n),p(n).size&&(e(n),k(n),n.R=new Map,i(n.t,(function(r){n.R.set(r,!1)})),n.o.clear())},o.forEach=function(n,r){var t=this;p(this[Q]).forEach((function(e,i){n.call(r,t.get(i),i,t)}))},o.get=function(n){var r=this[Q];u(r);var i=p(r).get(n);if(r.I||!t(i))return i;if(i!==r.t.get(n))return i;var o=N(r.A.h,i,r);return e(r),r.o.set(n,o),o},o.keys=function(){return p(this[Q]).keys()},o.values=function(){var n,r=this,t=this.keys();return(n={})[V]=function(){return r.values()},n.next=function(){var n=t.next();return n.done?n:{done:!1,value:r.get(n.value)}},n},o.entries=function(){var n,r=this,t=this.keys();return(n={})[V]=function(){return r.entries()},n.next=function(){var n=t.next();if(n.done)return n;var e=r.get(n.value);return{done:!1,value:[n.value,e]}},n},o[V]=function(){return this.entries()},n}(),c=function(){function n(n,r){return this[Q]={i:3,l:r,A:r?r.A:_(),P:!1,I:!1,o:void 0,t:n,k:this,p:new Map,g:!1,C:!1},this}r(n,Set);var t=n.prototype;return Object.defineProperty(t,"size",{get:function(){return p(this[Q]).size}}),t.has=function(n){var r=this[Q];return u(r),r.o?!!r.o.has(n)||!(!r.p.has(n)||!r.o.has(r.p.get(n))):r.t.has(n)},t.add=function(n){var r=this[Q];return u(r),this.has(n)||(o(r),k(r),r.o.add(n)),this},t.delete=function(n){if(!this.has(n))return!1;var r=this[Q];return u(r),o(r),k(r),r.o.delete(n)||!!r.p.has(n)&&r.o.delete(r.p.get(n))},t.clear=function(){var n=this[Q];u(n),p(n).size&&(o(n),k(n),n.o.clear())},t.values=function(){var n=this[Q];return u(n),o(n),n.o.values()},t.entries=function(){var n=this[Q];return u(n),o(n),n.o.entries()},t.keys=function(){return this.values()},t[V]=function(){return this.values()},t.forEach=function(n,r){for(var t=this.values(),e=t.next();!e.done;)n.call(r,e.value,e.value,this),e=t.next()},n}();m("MapSet",{F:function(n,r){return new f(n,r)},T:function(n,r){return new c(n,r)}})}function J(){F(),C(),T()}function K(n){return n}function $(n){return n}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",V="undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return"Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return"Unsupported patch operation: "+n},18:function(n){return"The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return"'current' expects a draft, got: "+n},23:function(n){return"'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t)})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=!1,!0;if(c(t,i)&&(void 0!==t||u(n.t,r)))return!0;E(n),k(n)}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=!0),!0},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.R[r]=!1,E(n),k(n)):delete n.R[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11)},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12)}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}})),on.deleteProperty=function(r,t){return true&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return true&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return(t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=N(e,r,void 0),v=!0;try{f=i(s),v=!1}finally{v?g(c):O(c)}return"undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d(f,!0),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l)}return f}n(21,r)},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r}));return"undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return[n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze)}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=R(e));var i=w(this),o=N(this,e,void 0);return o[Q].C=!0,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q]; true&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n},i.setUseProxies=function(r){r&&!B&&n(20),this.O=r},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce,cn=an.produceWithPatches.bind(an),sn=an.setAutoFreeze.bind(an),vn=an.setUseProxies.bind(an),pn=an.applyPatches.bind(an),ln=an.createDraft.bind(an),dn=an.finishDraft.bind(an);/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (fn);
8087 //# sourceMappingURL=immer.esm.js.map
8088
8089
8090 /***/ }),
8091
8092 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8093 /*!****************************************************************!*\
8094 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8095 \****************************************************************/
8096 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8097
8098 "use strict";
8099 __webpack_require__.r(__webpack_exports__);
8100 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8101 /* harmony export */ "default": () => (/* binding */ mixpanel)
8102 /* harmony export */ });
8103 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8104 var win;
8105 if (typeof(window) === 'undefined') {
8106 var loc = {
8107 hostname: ''
8108 };
8109 win = {
8110 crypto: {randomUUID: function() {throw Error('unsupported');}},
8111 navigator: { userAgent: '', onLine: true },
8112 document: {
8113 createElement: function() { return {}; },
8114 location: loc,
8115 referrer: ''
8116 },
8117 screen: { width: 0, height: 0 },
8118 location: loc,
8119 addEventListener: function() {},
8120 removeEventListener: function() {}
8121 };
8122 } else {
8123 win = window;
8124 }
8125
8126 function _array_like_to_array(arr, len) {
8127 if (len == null || len > arr.length) len = arr.length;
8128 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8129 return arr2;
8130 }
8131 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8132 try {
8133 var info = gen[key](arg);
8134 var value = info.value;
8135 } catch (error) {
8136 reject(error);
8137 return;
8138 }
8139 if (info.done) {
8140 resolve(value);
8141 } else {
8142 Promise.resolve(value).then(_next, _throw);
8143 }
8144 }
8145 function _async_to_generator(fn) {
8146 return function() {
8147 var self = this, args = arguments;
8148 return new Promise(function(resolve, reject) {
8149 var gen = fn.apply(self, args);
8150 function _next(value) {
8151 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8152 }
8153 function _throw(err) {
8154 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8155 }
8156 _next(undefined);
8157 });
8158 };
8159 }
8160 function _construct(Parent, args, Class) {
8161 if (_is_native_reflect_construct()) {
8162 _construct = Reflect.construct;
8163 } else {
8164 _construct = function construct(Parent, args, Class) {
8165 var a = [
8166 null
8167 ];
8168 a.push.apply(a, args);
8169 var Constructor = Function.bind.apply(Parent, a);
8170 var instance = new Constructor();
8171 if (Class) _set_prototype_of(instance, Class.prototype);
8172 return instance;
8173 };
8174 }
8175 return _construct.apply(null, arguments);
8176 }
8177 function _defineProperties(target, props) {
8178 for(var i = 0; i < props.length; i++){
8179 var descriptor = props[i];
8180 descriptor.enumerable = descriptor.enumerable || false;
8181 descriptor.configurable = true;
8182 if ("value" in descriptor) descriptor.writable = true;
8183 Object.defineProperty(target, descriptor.key, descriptor);
8184 }
8185 }
8186 function _create_class(Constructor, protoProps, staticProps) {
8187 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8188 return Constructor;
8189 }
8190 function _extends() {
8191 _extends = Object.assign || function(target) {
8192 for(var i = 1; i < arguments.length; i++){
8193 var source = arguments[i];
8194 for(var key in source){
8195 if (Object.prototype.hasOwnProperty.call(source, key)) {
8196 target[key] = source[key];
8197 }
8198 }
8199 }
8200 return target;
8201 };
8202 return _extends.apply(this, arguments);
8203 }
8204 function _get_prototype_of(o) {
8205 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8206 return o.__proto__ || Object.getPrototypeOf(o);
8207 };
8208 return _get_prototype_of(o);
8209 }
8210 function _inherits(subClass, superClass) {
8211 if (typeof superClass !== "function" && superClass !== null) {
8212 throw new TypeError("Super expression must either be null or a function");
8213 }
8214 subClass.prototype = Object.create(superClass && superClass.prototype, {
8215 constructor: {
8216 value: subClass,
8217 writable: true,
8218 configurable: true
8219 }
8220 });
8221 if (superClass) _set_prototype_of(subClass, superClass);
8222 }
8223 function _instanceof(left, right) {
8224 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8225 return !!right[Symbol.hasInstance](left);
8226 } else {
8227 return left instanceof right;
8228 }
8229 }
8230 function _is_native_function(fn) {
8231 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8232 }
8233 function _object_without_properties_loose(source, excluded) {
8234 if (source == null) return {};
8235 var target = {};
8236 var sourceKeys = Object.keys(source);
8237 var key, i;
8238 for(i = 0; i < sourceKeys.length; i++){
8239 key = sourceKeys[i];
8240 if (excluded.indexOf(key) >= 0) continue;
8241 target[key] = source[key];
8242 }
8243 return target;
8244 }
8245 function _set_prototype_of(o, p) {
8246 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8247 o.__proto__ = p;
8248 return o;
8249 };
8250 return _set_prototype_of(o, p);
8251 }
8252 function _type_of(obj) {
8253 "@swc/helpers - typeof";
8254 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8255 }
8256 function _unsupported_iterable_to_array(o, minLen) {
8257 if (!o) return;
8258 if (typeof o === "string") return _array_like_to_array(o, minLen);
8259 var n = Object.prototype.toString.call(o).slice(8, -1);
8260 if (n === "Object" && o.constructor) n = o.constructor.name;
8261 if (n === "Map" || n === "Set") return Array.from(n);
8262 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
8263 }
8264 function _wrap_native_super(Class) {
8265 var _cache = typeof Map === "function" ? new Map() : undefined;
8266 _wrap_native_super = function wrapNativeSuper(Class) {
8267 if (Class === null || !_is_native_function(Class)) return Class;
8268 if (typeof Class !== "function") {
8269 throw new TypeError("Super expression must either be null or a function");
8270 }
8271 if (typeof _cache !== "undefined") {
8272 if (_cache.has(Class)) return _cache.get(Class);
8273 _cache.set(Class, Wrapper);
8274 }
8275 function Wrapper() {
8276 return _construct(Class, arguments, _get_prototype_of(this).constructor);
8277 }
8278 Wrapper.prototype = Object.create(Class.prototype, {
8279 constructor: {
8280 value: Wrapper,
8281 enumerable: false,
8282 writable: true,
8283 configurable: true
8284 }
8285 });
8286 return _set_prototype_of(Wrapper, Class);
8287 };
8288 return _wrap_native_super(Class);
8289 }
8290 function _is_native_reflect_construct() {
8291 try {
8292 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
8293 } catch (_) {}
8294 return (_is_native_reflect_construct = function() {
8295 return !!result;
8296 })();
8297 }
8298 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
8299 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
8300 if (it) return (it = it.call(o)).next.bind(it);
8301 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
8302 if (it) o = it;
8303 var i = 0;
8304 return function() {
8305 if (i >= o.length) {
8306 return {
8307 done: true
8308 };
8309 }
8310 return {
8311 done: false,
8312 value: o[i++]
8313 };
8314 };
8315 }
8316 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8317 }
8318 function _ts_generator(thisArg, body) {
8319 var f, y, t, g, _ = {
8320 label: 0,
8321 sent: function() {
8322 if (t[0] & 1) throw t[1];
8323 return t[1];
8324 },
8325 trys: [],
8326 ops: []
8327 };
8328 return g = {
8329 next: verb(0),
8330 "throw": verb(1),
8331 "return": verb(2)
8332 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
8333 return this;
8334 }), g;
8335 function verb(n) {
8336 return function(v) {
8337 return step([
8338 n,
8339 v
8340 ]);
8341 };
8342 }
8343 function step(op) {
8344 if (f) throw new TypeError("Generator is already executing.");
8345 while(_)try {
8346 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
8347 if (y = 0, t) op = [
8348 op[0] & 2,
8349 t.value
8350 ];
8351 switch(op[0]){
8352 case 0:
8353 case 1:
8354 t = op;
8355 break;
8356 case 4:
8357 _.label++;
8358 return {
8359 value: op[1],
8360 done: false
8361 };
8362 case 5:
8363 _.label++;
8364 y = op[1];
8365 op = [
8366 0
8367 ];
8368 continue;
8369 case 7:
8370 op = _.ops.pop();
8371 _.trys.pop();
8372 continue;
8373 default:
8374 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
8375 _ = 0;
8376 continue;
8377 }
8378 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
8379 _.label = op[1];
8380 break;
8381 }
8382 if (op[0] === 6 && _.label < t[1]) {
8383 _.label = t[1];
8384 t = op;
8385 break;
8386 }
8387 if (t && _.label < t[2]) {
8388 _.label = t[2];
8389 _.ops.push(op);
8390 break;
8391 }
8392 if (t[2]) _.ops.pop();
8393 _.trys.pop();
8394 continue;
8395 }
8396 op = body.call(thisArg, _);
8397 } catch (e) {
8398 op = [
8399 6,
8400 e
8401 ];
8402 y = 0;
8403 } finally{
8404 f = t = 0;
8405 }
8406 if (op[0] & 5) throw op[1];
8407 return {
8408 value: op[0] ? op[1] : void 0,
8409 done: true
8410 };
8411 }
8412 }
8413 function _ts_values(o) {
8414 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
8415 if (m) return m.call(o);
8416 if (o && typeof o.length === "number") return {
8417 next: function() {
8418 if (o && i >= o.length) o = void 0;
8419 return {
8420 value: o && o[i++],
8421 done: !o
8422 };
8423 }
8424 };
8425 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
8426 }
8427 var __defProp = Object.defineProperty;
8428 var __defNormalProp = function(obj, key, value) {
8429 return key in obj ? __defProp(obj, key, {
8430 enumerable: true,
8431 configurable: true,
8432 writable: true,
8433 value: value
8434 }) : obj[key] = value;
8435 };
8436 var __publicField = function(obj, key, value) {
8437 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8438 };
8439 var _a;
8440 var __defProp$1 = Object.defineProperty;
8441 var __defNormalProp$1 = function(obj, key, value) {
8442 return key in obj ? __defProp$1(obj, key, {
8443 enumerable: true,
8444 configurable: true,
8445 writable: true,
8446 value: value
8447 }) : obj[key] = value;
8448 };
8449 var __publicField$1 = function(obj, key, value) {
8450 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8451 };
8452 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
8453 NodeType2[NodeType2["Document"] = 0] = "Document";
8454 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
8455 NodeType2[NodeType2["Element"] = 2] = "Element";
8456 NodeType2[NodeType2["Text"] = 3] = "Text";
8457 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
8458 NodeType2[NodeType2["Comment"] = 5] = "Comment";
8459 return NodeType2;
8460 }(NodeType$3 || {});
8461 var testableAccessors$1 = {
8462 Node: [
8463 "childNodes",
8464 "parentNode",
8465 "parentElement",
8466 "textContent"
8467 ],
8468 ShadowRoot: [
8469 "host",
8470 "styleSheets"
8471 ],
8472 Element: [
8473 "shadowRoot",
8474 "querySelector",
8475 "querySelectorAll"
8476 ],
8477 MutationObserver: []
8478 };
8479 var testableMethods$1 = {
8480 Node: [
8481 "contains",
8482 "getRootNode"
8483 ],
8484 ShadowRoot: [
8485 "getSelection"
8486 ],
8487 Element: [],
8488 MutationObserver: [
8489 "constructor"
8490 ]
8491 };
8492 var untaintedBasePrototype$1 = {};
8493 var isAngularZonePresent$1 = function() {
8494 return !!globalThis.Zone;
8495 };
8496 function getUntaintedPrototype$1(key) {
8497 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
8498 var defaultObj = globalThis[key];
8499 var defaultPrototype = defaultObj.prototype;
8500 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
8501 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
8502 accessorNames.every(function(accessor) {
8503 var _a2, _b;
8504 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
8505 }));
8506 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
8507 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
8508 function(method) {
8509 var _a2;
8510 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
8511 }));
8512 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
8513 untaintedBasePrototype$1[key] = defaultObj.prototype;
8514 return defaultObj.prototype;
8515 }
8516 try {
8517 var iframeEl = document.createElement("iframe");
8518 document.body.appendChild(iframeEl);
8519 var win = iframeEl.contentWindow;
8520 if (!win) return defaultObj.prototype;
8521 var untaintedObject = win[key].prototype;
8522 document.body.removeChild(iframeEl);
8523 if (!untaintedObject) return defaultPrototype;
8524 return untaintedBasePrototype$1[key] = untaintedObject;
8525 } catch (e) {
8526 return defaultPrototype;
8527 }
8528 }
8529 var untaintedAccessorCache$1 = {};
8530 function getUntaintedAccessor$1(key, instance, accessor) {
8531 var _a2;
8532 var cacheKey = key + "." + String(accessor);
8533 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
8534 var untaintedPrototype = getUntaintedPrototype$1(key);
8535 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
8536 if (!untaintedAccessor) return instance[accessor];
8537 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
8538 return untaintedAccessor.call(instance);
8539 }
8540 var untaintedMethodCache$1 = {};
8541 function getUntaintedMethod$1(key, instance, method) {
8542 var cacheKey = key + "." + String(method);
8543 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
8544 var untaintedPrototype = getUntaintedPrototype$1(key);
8545 var untaintedMethod = untaintedPrototype[method];
8546 if (typeof untaintedMethod !== "function") return instance[method];
8547 untaintedMethodCache$1[cacheKey] = untaintedMethod;
8548 return untaintedMethod.bind(instance);
8549 }
8550 function childNodes$1(n2) {
8551 return getUntaintedAccessor$1("Node", n2, "childNodes");
8552 }
8553 function parentNode$1(n2) {
8554 return getUntaintedAccessor$1("Node", n2, "parentNode");
8555 }
8556 function parentElement$1(n2) {
8557 return getUntaintedAccessor$1("Node", n2, "parentElement");
8558 }
8559 function textContent$1(n2) {
8560 return getUntaintedAccessor$1("Node", n2, "textContent");
8561 }
8562 function contains$1(n2, other) {
8563 return getUntaintedMethod$1("Node", n2, "contains")(other);
8564 }
8565 function getRootNode$1(n2) {
8566 return getUntaintedMethod$1("Node", n2, "getRootNode")();
8567 }
8568 function host$1(n2) {
8569 if (!n2 || !("host" in n2)) return null;
8570 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
8571 }
8572 function styleSheets$1(n2) {
8573 return n2.styleSheets;
8574 }
8575 function shadowRoot$1(n2) {
8576 if (!n2 || !("shadowRoot" in n2)) return null;
8577 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
8578 }
8579 function querySelector$1(n2, selectors) {
8580 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
8581 }
8582 function querySelectorAll$1(n2, selectors) {
8583 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
8584 }
8585 function mutationObserverCtor$1() {
8586 return getUntaintedPrototype$1("MutationObserver").constructor;
8587 }
8588 var index$1 = {
8589 childNodes: childNodes$1,
8590 parentNode: parentNode$1,
8591 parentElement: parentElement$1,
8592 textContent: textContent$1,
8593 contains: contains$1,
8594 getRootNode: getRootNode$1,
8595 host: host$1,
8596 styleSheets: styleSheets$1,
8597 shadowRoot: shadowRoot$1,
8598 querySelector: querySelector$1,
8599 querySelectorAll: querySelectorAll$1,
8600 mutationObserver: mutationObserverCtor$1
8601 };
8602 function isElement(n2) {
8603 return n2.nodeType === n2.ELEMENT_NODE;
8604 }
8605 function isShadowRoot(n2) {
8606 var hostEl = // anchor and textarea elements also have a `host` property
8607 // but only shadow roots have a `mode` property
8608 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
8609 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
8610 }
8611 function isNativeShadowDom(shadowRoot2) {
8612 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
8613 }
8614 function fixBrowserCompatibilityIssuesInCSS(cssText) {
8615 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
8616 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
8617 }
8618 return cssText;
8619 }
8620 function escapeImportStatement(rule2) {
8621 var cssText = rule2.cssText;
8622 if (cssText.split('"').length < 3) return cssText;
8623 var statement = [
8624 "@import",
8625 "url(" + JSON.stringify(rule2.href) + ")"
8626 ];
8627 if (rule2.layerName === "") {
8628 statement.push("layer");
8629 } else if (rule2.layerName) {
8630 statement.push("layer(" + rule2.layerName + ")");
8631 }
8632 if (rule2.supportsText) {
8633 statement.push("supports(" + rule2.supportsText + ")");
8634 }
8635 if (rule2.media.length) {
8636 statement.push(rule2.media.mediaText);
8637 }
8638 return statement.join(" ") + ";";
8639 }
8640 function stringifyStylesheet(s2) {
8641 try {
8642 var rules2 = s2.rules || s2.cssRules;
8643 if (!rules2) {
8644 return null;
8645 }
8646 var sheetHref = s2.href;
8647 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
8648 sheetHref = s2.ownerNode.ownerDocument.location.href;
8649 }
8650 var stringifiedRules = Array.from(rules2, function(rule2) {
8651 return stringifyRule(rule2, sheetHref);
8652 }).join("");
8653 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
8654 } catch (error) {
8655 return null;
8656 }
8657 }
8658 function stringifyRule(rule2, sheetHref) {
8659 if (isCSSImportRule(rule2)) {
8660 var importStringified;
8661 try {
8662 importStringified = // we can access the imported stylesheet rules directly
8663 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
8664 escapeImportStatement(rule2);
8665 } catch (error) {
8666 importStringified = rule2.cssText;
8667 }
8668 if (rule2.styleSheet.href) {
8669 return absolutifyURLs(importStringified, rule2.styleSheet.href);
8670 }
8671 return importStringified;
8672 } else {
8673 var ruleStringified = rule2.cssText;
8674 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
8675 ruleStringified = fixSafariColons(ruleStringified);
8676 }
8677 if (sheetHref) {
8678 return absolutifyURLs(ruleStringified, sheetHref);
8679 }
8680 return ruleStringified;
8681 }
8682 }
8683 function fixSafariColons(cssStringified) {
8684 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
8685 return cssStringified.replace(regex, "$1\\$2");
8686 }
8687 function isCSSImportRule(rule2) {
8688 return "styleSheet" in rule2;
8689 }
8690 function isCSSStyleRule(rule2) {
8691 return "selectorText" in rule2;
8692 }
8693 var Mirror = /*#__PURE__*/ function() {
8694 function Mirror() {
8695 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
8696 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
8697 }
8698 var _proto = Mirror.prototype;
8699 _proto.getId = function getId(n2) {
8700 var _a2;
8701 if (!n2) return -1;
8702 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
8703 return id != null ? id : -1;
8704 };
8705 _proto.getNode = function getNode(id) {
8706 return this.idNodeMap.get(id) || null;
8707 };
8708 _proto.getIds = function getIds() {
8709 return Array.from(this.idNodeMap.keys());
8710 };
8711 _proto.getMeta = function getMeta(n2) {
8712 return this.nodeMetaMap.get(n2) || null;
8713 };
8714 // removes the node from idNodeMap
8715 // doesn't remove the node from nodeMetaMap
8716 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
8717 var _this = this;
8718 var id = this.getId(n2);
8719 this.idNodeMap.delete(id);
8720 if (n2.childNodes) {
8721 n2.childNodes.forEach(function(childNode) {
8722 return _this.removeNodeFromMap(childNode);
8723 });
8724 }
8725 };
8726 _proto.has = function has(id) {
8727 return this.idNodeMap.has(id);
8728 };
8729 _proto.hasNode = function hasNode(node2) {
8730 return this.nodeMetaMap.has(node2);
8731 };
8732 _proto.add = function add(n2, meta) {
8733 var id = meta.id;
8734 this.idNodeMap.set(id, n2);
8735 this.nodeMetaMap.set(n2, meta);
8736 };
8737 _proto.replace = function replace(id, n2) {
8738 var oldNode = this.getNode(id);
8739 if (oldNode) {
8740 var meta = this.nodeMetaMap.get(oldNode);
8741 if (meta) this.nodeMetaMap.set(n2, meta);
8742 }
8743 this.idNodeMap.set(id, n2);
8744 };
8745 _proto.reset = function reset() {
8746 this.idNodeMap = /* @__PURE__ */ new Map();
8747 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
8748 };
8749 return Mirror;
8750 }();
8751 function createMirror$2() {
8752 return new Mirror();
8753 }
8754 function maskInputValue(param) {
8755 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
8756 var text = value || "";
8757 var actualType = type && toLowerCase(type);
8758 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
8759 if (maskInputFn) {
8760 text = maskInputFn(text, element);
8761 } else {
8762 text = "*".repeat(text.length);
8763 }
8764 }
8765 return text;
8766 }
8767 function toLowerCase(str) {
8768 return str.toLowerCase();
8769 }
8770 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
8771 function is2DCanvasBlank(canvas) {
8772 var ctx = canvas.getContext("2d");
8773 if (!ctx) return true;
8774 var chunkSize = 50;
8775 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
8776 for(var y = 0; y < canvas.height; y += chunkSize){
8777 var getImageData = ctx.getImageData;
8778 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
8779 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
8780 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
8781 if (pixelBuffer.some(function(pixel) {
8782 return pixel !== 0;
8783 })) return false;
8784 }
8785 }
8786 return true;
8787 }
8788 function getInputType(element) {
8789 var type = element.type;
8790 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
8791 toLowerCase(type) : null;
8792 }
8793 function extractFileExtension(path, baseURL) {
8794 var url;
8795 try {
8796 url = new URL(path, baseURL != null ? baseURL : window.location.href);
8797 } catch (err) {
8798 return null;
8799 }
8800 var regex = /\.([0-9a-z]+)(?:$)/i;
8801 var match = url.pathname.match(regex);
8802 var _ref;
8803 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
8804 }
8805 function extractOrigin(url) {
8806 var origin = "";
8807 if (url.indexOf("//") > -1) {
8808 origin = url.split("/").slice(0, 3).join("/");
8809 } else {
8810 origin = url.split("/")[0];
8811 }
8812 origin = origin.split("?")[0];
8813 return origin;
8814 }
8815 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
8816 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
8817 var URL_WWW_MATCH = /^www\..*/i;
8818 var DATA_URI = /^(data:)([^,]*),(.*)/i;
8819 function absolutifyURLs(cssText, href) {
8820 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
8821 var filePath = path1 || path2 || path3;
8822 var maybeQuote = quote1 || quote2 || "";
8823 if (!filePath) {
8824 return origin;
8825 }
8826 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
8827 return "url(" + maybeQuote + filePath + maybeQuote + ")";
8828 }
8829 if (DATA_URI.test(filePath)) {
8830 return "url(" + maybeQuote + filePath + maybeQuote + ")";
8831 }
8832 if (filePath[0] === "/") {
8833 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
8834 }
8835 var stack = href.split("/");
8836 var parts = filePath.split("/");
8837 stack.pop();
8838 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
8839 var part = _step.value;
8840 if (part === ".") {
8841 continue;
8842 } else if (part === "..") {
8843 stack.pop();
8844 } else {
8845 stack.push(part);
8846 }
8847 }
8848 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
8849 });
8850 }
8851 function normalizeCssString(cssText) {
8852 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
8853 }
8854 function splitCssText(cssText, style) {
8855 var childNodes2 = Array.from(style.childNodes);
8856 var splits = [];
8857 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
8858 var cssTextNorm = normalizeCssString(cssText);
8859 for(var i2 = 1; i2 < childNodes2.length; i2++){
8860 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
8861 var textContentNorm = normalizeCssString(childNodes2[i2].textContent);
8862 for(var j = 3; j < textContentNorm.length; j++){
8863 var bit = textContentNorm.substring(0, j);
8864 if (cssTextNorm.split(bit).length === 2) {
8865 var splitNorm = cssTextNorm.indexOf(bit);
8866 for(var k = splitNorm; k < cssText.length; k++){
8867 if (normalizeCssString(cssText.substring(0, k)).length === splitNorm) {
8868 splits.push(cssText.substring(0, k));
8869 cssText = cssText.substring(k);
8870 break;
8871 }
8872 }
8873 break;
8874 }
8875 }
8876 }
8877 }
8878 }
8879 splits.push(cssText);
8880 return splits;
8881 }
8882 function markCssSplits(cssText, style) {
8883 return splitCssText(cssText, style).join("/* rr_split */");
8884 }
8885 var _id = 1;
8886 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
8887 var IGNORED_NODE = -2;
8888 function genId() {
8889 return _id++;
8890 }
8891 function getValidTagName$1(element) {
8892 if (_instanceof(element, HTMLFormElement)) {
8893 return "form";
8894 }
8895 var processedTagName = toLowerCase(element.tagName);
8896 if (tagNameRegex.test(processedTagName)) {
8897 return "div";
8898 }
8899 return processedTagName;
8900 }
8901 var canvasService;
8902 var canvasCtx;
8903 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
8904 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
8905 function getAbsoluteSrcsetString(doc, attributeValue) {
8906 if (attributeValue.trim() === "") {
8907 return attributeValue;
8908 }
8909 var pos = 0;
8910 function collectCharacters(regEx) {
8911 var chars2;
8912 var match = regEx.exec(attributeValue.substring(pos));
8913 if (match) {
8914 chars2 = match[0];
8915 pos += chars2.length;
8916 return chars2;
8917 }
8918 return "";
8919 }
8920 var output = [];
8921 while(true){
8922 collectCharacters(SRCSET_COMMAS_OR_SPACES);
8923 if (pos >= attributeValue.length) {
8924 break;
8925 }
8926 var url = collectCharacters(SRCSET_NOT_SPACES);
8927 if (url.slice(-1) === ",") {
8928 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
8929 output.push(url);
8930 } else {
8931 var descriptorsStr = "";
8932 url = absoluteToDoc(doc, url);
8933 var inParens = false;
8934 while(true){
8935 var c2 = attributeValue.charAt(pos);
8936 if (c2 === "") {
8937 output.push((url + descriptorsStr).trim());
8938 break;
8939 } else if (!inParens) {
8940 if (c2 === ",") {
8941 pos += 1;
8942 output.push((url + descriptorsStr).trim());
8943 break;
8944 } else if (c2 === "(") {
8945 inParens = true;
8946 }
8947 } else {
8948 if (c2 === ")") {
8949 inParens = false;
8950 }
8951 }
8952 descriptorsStr += c2;
8953 pos += 1;
8954 }
8955 }
8956 }
8957 return output.join(", ");
8958 }
8959 var cachedDocument = /* @__PURE__ */ new WeakMap();
8960 function absoluteToDoc(doc, attributeValue) {
8961 if (!attributeValue || attributeValue.trim() === "") {
8962 return attributeValue;
8963 }
8964 return getHref(doc, attributeValue);
8965 }
8966 function isSVGElement(el) {
8967 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
8968 }
8969 function getHref(doc, customHref) {
8970 var a2 = cachedDocument.get(doc);
8971 if (!a2) {
8972 a2 = doc.createElement("a");
8973 cachedDocument.set(doc, a2);
8974 }
8975 if (!customHref) {
8976 customHref = "";
8977 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
8978 return customHref;
8979 }
8980 a2.setAttribute("href", customHref);
8981 return a2.href;
8982 }
8983 function transformAttribute(doc, tagName, name, value) {
8984 if (!value) {
8985 return value;
8986 }
8987 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
8988 return absoluteToDoc(doc, value);
8989 } else if (name === "xlink:href" && value[0] !== "#") {
8990 return absoluteToDoc(doc, value);
8991 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
8992 return absoluteToDoc(doc, value);
8993 } else if (name === "srcset") {
8994 return getAbsoluteSrcsetString(doc, value);
8995 } else if (name === "style") {
8996 return absolutifyURLs(value, getHref(doc));
8997 } else if (tagName === "object" && name === "data") {
8998 return absoluteToDoc(doc, value);
8999 }
9000 return value;
9001 }
9002 function ignoreAttribute(tagName, name, _value) {
9003 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9004 }
9005 function _isBlockedElement(element, blockClass, blockSelector) {
9006 try {
9007 if (typeof blockClass === "string") {
9008 if (element.classList.contains(blockClass)) {
9009 return true;
9010 }
9011 } else {
9012 for(var eIndex = element.classList.length; eIndex--;){
9013 var className = element.classList[eIndex];
9014 if (blockClass.test(className)) {
9015 return true;
9016 }
9017 }
9018 }
9019 if (blockSelector) {
9020 return element.matches(blockSelector);
9021 }
9022 } catch (e2) {}
9023 return false;
9024 }
9025 function classMatchesRegex(node2, regex, checkAncestors) {
9026 if (!node2) return false;
9027 if (node2.nodeType !== node2.ELEMENT_NODE) {
9028 if (!checkAncestors) return false;
9029 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9030 }
9031 for(var eIndex = node2.classList.length; eIndex--;){
9032 var className = node2.classList[eIndex];
9033 if (regex.test(className)) {
9034 return true;
9035 }
9036 }
9037 if (!checkAncestors) return false;
9038 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9039 }
9040 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9041 var el;
9042 if (isElement(node2)) {
9043 el = node2;
9044 if (!index$1.childNodes(el).length) {
9045 return false;
9046 }
9047 } else if (index$1.parentElement(node2) === null) {
9048 return false;
9049 } else {
9050 el = index$1.parentElement(node2);
9051 }
9052 try {
9053 if (typeof maskTextClass === "string") {
9054 if (checkAncestors) {
9055 if (el.closest("." + maskTextClass)) return true;
9056 } else {
9057 if (el.classList.contains(maskTextClass)) return true;
9058 }
9059 } else {
9060 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9061 }
9062 if (maskTextSelector) {
9063 if (checkAncestors) {
9064 if (el.closest(maskTextSelector)) return true;
9065 } else {
9066 if (el.matches(maskTextSelector)) return true;
9067 }
9068 }
9069 } catch (e2) {}
9070 return false;
9071 }
9072 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9073 var win = iframeEl.contentWindow;
9074 if (!win) {
9075 return;
9076 }
9077 var fired = false;
9078 var readyState;
9079 try {
9080 readyState = win.document.readyState;
9081 } catch (error) {
9082 return;
9083 }
9084 if (readyState !== "complete") {
9085 var timer = setTimeout(function() {
9086 if (!fired) {
9087 listener();
9088 fired = true;
9089 }
9090 }, iframeLoadTimeout);
9091 iframeEl.addEventListener("load", function() {
9092 clearTimeout(timer);
9093 fired = true;
9094 listener();
9095 });
9096 return;
9097 }
9098 var blankUrl = "about:blank";
9099 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9100 setTimeout(listener, 0);
9101 return iframeEl.addEventListener("load", listener);
9102 }
9103 iframeEl.addEventListener("load", listener);
9104 }
9105 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9106 var fired = false;
9107 var styleSheetLoaded;
9108 try {
9109 styleSheetLoaded = link.sheet;
9110 } catch (error) {
9111 return;
9112 }
9113 if (styleSheetLoaded) return;
9114 var timer = setTimeout(function() {
9115 if (!fired) {
9116 listener();
9117 fired = true;
9118 }
9119 }, styleSheetLoadTimeout);
9120 link.addEventListener("load", function() {
9121 clearTimeout(timer);
9122 fired = true;
9123 listener();
9124 });
9125 }
9126 function serializeNode(n2, options) {
9127 var doc = options.doc, mirror2 = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, needsMask = options.needsMask, inlineStylesheet = options.inlineStylesheet, _options_maskInputOptions = options.maskInputOptions, maskInputOptions = _options_maskInputOptions === void 0 ? {} : _options_maskInputOptions, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _options_dataURLOptions = options.dataURLOptions, dataURLOptions = _options_dataURLOptions === void 0 ? {} : _options_dataURLOptions, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, _options_newlyAddedElement = options.newlyAddedElement, newlyAddedElement = _options_newlyAddedElement === void 0 ? false : _options_newlyAddedElement, _options_cssCaptured = options.cssCaptured, cssCaptured = _options_cssCaptured === void 0 ? false : _options_cssCaptured;
9128 var rootId = getRootId(doc, mirror2);
9129 switch(n2.nodeType){
9130 case n2.DOCUMENT_NODE:
9131 if (n2.compatMode !== "CSS1Compat") {
9132 return {
9133 type: NodeType$3.Document,
9134 childNodes: [],
9135 compatMode: n2.compatMode
9136 };
9137 } else {
9138 return {
9139 type: NodeType$3.Document,
9140 childNodes: []
9141 };
9142 }
9143 case n2.DOCUMENT_TYPE_NODE:
9144 return {
9145 type: NodeType$3.DocumentType,
9146 name: n2.name,
9147 publicId: n2.publicId,
9148 systemId: n2.systemId,
9149 rootId: rootId
9150 };
9151 case n2.ELEMENT_NODE:
9152 return serializeElementNode(n2, {
9153 doc: doc,
9154 blockClass: blockClass,
9155 blockSelector: blockSelector,
9156 inlineStylesheet: inlineStylesheet,
9157 maskInputOptions: maskInputOptions,
9158 maskInputFn: maskInputFn,
9159 dataURLOptions: dataURLOptions,
9160 inlineImages: inlineImages,
9161 recordCanvas: recordCanvas,
9162 keepIframeSrcFn: keepIframeSrcFn,
9163 newlyAddedElement: newlyAddedElement,
9164 rootId: rootId
9165 });
9166 case n2.TEXT_NODE:
9167 return serializeTextNode(n2, {
9168 doc: doc,
9169 needsMask: needsMask,
9170 maskTextFn: maskTextFn,
9171 rootId: rootId,
9172 cssCaptured: cssCaptured
9173 });
9174 case n2.CDATA_SECTION_NODE:
9175 return {
9176 type: NodeType$3.CDATA,
9177 textContent: "",
9178 rootId: rootId
9179 };
9180 case n2.COMMENT_NODE:
9181 return {
9182 type: NodeType$3.Comment,
9183 textContent: index$1.textContent(n2) || "",
9184 rootId: rootId
9185 };
9186 default:
9187 return false;
9188 }
9189 }
9190 function getRootId(doc, mirror2) {
9191 if (!mirror2.hasNode(doc)) return void 0;
9192 var docId = mirror2.getId(doc);
9193 return docId === 1 ? void 0 : docId;
9194 }
9195 function serializeTextNode(n2, options) {
9196 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
9197 var parent = index$1.parentNode(n2);
9198 var parentTagName = parent && parent.tagName;
9199 var textContent2 = "";
9200 var isStyle = parentTagName === "STYLE" ? true : void 0;
9201 var isScript = parentTagName === "SCRIPT" ? true : void 0;
9202 if (isScript) {
9203 textContent2 = "SCRIPT_PLACEHOLDER";
9204 } else if (!cssCaptured) {
9205 textContent2 = index$1.textContent(n2);
9206 if (isStyle && textContent2) {
9207 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
9208 }
9209 }
9210 if (!isStyle && !isScript && textContent2 && needsMask) {
9211 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
9212 }
9213 return {
9214 type: NodeType$3.Text,
9215 textContent: textContent2 || "",
9216 rootId: rootId
9217 };
9218 }
9219 function serializeElementNode(n2, options) {
9220 var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, inlineStylesheet = options.inlineStylesheet, _options_maskInputOptions = options.maskInputOptions, maskInputOptions = _options_maskInputOptions === void 0 ? {} : _options_maskInputOptions, maskInputFn = options.maskInputFn, _options_dataURLOptions = options.dataURLOptions, dataURLOptions = _options_dataURLOptions === void 0 ? {} : _options_dataURLOptions, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, _options_newlyAddedElement = options.newlyAddedElement, newlyAddedElement = _options_newlyAddedElement === void 0 ? false : _options_newlyAddedElement, rootId = options.rootId;
9221 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
9222 var tagName = getValidTagName$1(n2);
9223 var attributes = {};
9224 var len = n2.attributes.length;
9225 for(var i2 = 0; i2 < len; i2++){
9226 var attr = n2.attributes[i2];
9227 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
9228 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
9229 }
9230 }
9231 if (tagName === "link" && inlineStylesheet) {
9232 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
9233 return s2.href === n2.href;
9234 });
9235 var cssText = null;
9236 if (stylesheet) {
9237 cssText = stringifyStylesheet(stylesheet);
9238 }
9239 if (cssText) {
9240 delete attributes.rel;
9241 delete attributes.href;
9242 attributes._cssText = cssText;
9243 }
9244 }
9245 if (tagName === "style" && n2.sheet) {
9246 var cssText1 = stringifyStylesheet(n2.sheet);
9247 if (cssText1) {
9248 if (n2.childNodes.length > 1) {
9249 cssText1 = markCssSplits(cssText1, n2);
9250 }
9251 attributes._cssText = cssText1;
9252 }
9253 }
9254 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
9255 var value = n2.value;
9256 var checked = n2.checked;
9257 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
9258 attributes.value = maskInputValue({
9259 element: n2,
9260 type: getInputType(n2),
9261 tagName: tagName,
9262 value: value,
9263 maskInputOptions: maskInputOptions,
9264 maskInputFn: maskInputFn
9265 });
9266 } else if (checked) {
9267 attributes.checked = checked;
9268 }
9269 }
9270 if (tagName === "option") {
9271 if (n2.selected && !maskInputOptions["select"]) {
9272 attributes.selected = true;
9273 } else {
9274 delete attributes.selected;
9275 }
9276 }
9277 if (tagName === "dialog" && n2.open) {
9278 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
9279 }
9280 if (tagName === "canvas" && recordCanvas) {
9281 if (n2.__context === "2d") {
9282 if (!is2DCanvasBlank(n2)) {
9283 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9284 }
9285 } else if (!("__context" in n2)) {
9286 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9287 var blankCanvas = doc.createElement("canvas");
9288 blankCanvas.width = n2.width;
9289 blankCanvas.height = n2.height;
9290 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9291 if (canvasDataURL !== blankCanvasDataURL) {
9292 attributes.rr_dataURL = canvasDataURL;
9293 }
9294 }
9295 }
9296 if (tagName === "img" && inlineImages) {
9297 if (!canvasService) {
9298 canvasService = doc.createElement("canvas");
9299 canvasCtx = canvasService.getContext("2d");
9300 }
9301 var image = n2;
9302 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
9303 var priorCrossOrigin = image.crossOrigin;
9304 var recordInlineImage = function() {
9305 image.removeEventListener("load", recordInlineImage);
9306 try {
9307 canvasService.width = image.naturalWidth;
9308 canvasService.height = image.naturalHeight;
9309 canvasCtx.drawImage(image, 0, 0);
9310 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9311 } catch (err) {
9312 if (image.crossOrigin !== "anonymous") {
9313 image.crossOrigin = "anonymous";
9314 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9315 else image.addEventListener("load", recordInlineImage);
9316 return;
9317 } else {
9318 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
9319 }
9320 }
9321 if (image.crossOrigin === "anonymous") {
9322 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
9323 }
9324 };
9325 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9326 else image.addEventListener("load", recordInlineImage);
9327 }
9328 if (tagName === "audio" || tagName === "video") {
9329 var mediaAttributes = attributes;
9330 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
9331 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
9332 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
9333 mediaAttributes.rr_mediaMuted = n2.muted;
9334 mediaAttributes.rr_mediaLoop = n2.loop;
9335 mediaAttributes.rr_mediaVolume = n2.volume;
9336 }
9337 if (!newlyAddedElement) {
9338 if (n2.scrollLeft) {
9339 attributes.rr_scrollLeft = n2.scrollLeft;
9340 }
9341 if (n2.scrollTop) {
9342 attributes.rr_scrollTop = n2.scrollTop;
9343 }
9344 }
9345 if (needBlock) {
9346 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
9347 attributes = {
9348 class: attributes.class,
9349 rr_width: "" + width + "px",
9350 rr_height: "" + height + "px"
9351 };
9352 }
9353 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
9354 if (!n2.contentDocument) {
9355 attributes.rr_src = attributes.src;
9356 }
9357 delete attributes.src;
9358 }
9359 var isCustomElement;
9360 try {
9361 if (customElements.get(tagName)) isCustomElement = true;
9362 } catch (e2) {}
9363 return {
9364 type: NodeType$3.Element,
9365 tagName: tagName,
9366 attributes: attributes,
9367 childNodes: [],
9368 isSVG: isSVGElement(n2) || void 0,
9369 needBlock: needBlock,
9370 rootId: rootId,
9371 isCustom: isCustomElement
9372 };
9373 }
9374 function lowerIfExists(maybeAttr) {
9375 if (maybeAttr === void 0 || maybeAttr === null) {
9376 return "";
9377 } else {
9378 return maybeAttr.toLowerCase();
9379 }
9380 }
9381 function slimDOMExcluded(sn, slimDOMOptions) {
9382 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
9383 return true;
9384 } else if (sn.type === NodeType$3.Element) {
9385 if (slimDOMOptions.script && // script tag
9386 (sn.tagName === "script" || // (module)preload link
9387 sn.tagName === "link" && (sn.attributes.rel === "preload" || sn.attributes.rel === "modulepreload") && sn.attributes.as === "script" || // prefetch link
9388 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
9389 return true;
9390 } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
9391 return true;
9392 } else if (sn.tagName === "meta") {
9393 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
9394 return true;
9395 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
9396 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
9397 return true;
9398 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
9399 return true;
9400 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
9401 return true;
9402 } else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
9403 return true;
9404 } else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) {
9405 return true;
9406 }
9407 }
9408 }
9409 return false;
9410 }
9411 function serializeNodeWithId(n2, options) {
9412 var doc = options.doc, mirror2 = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _options_skipChild = options.skipChild, skipChild = _options_skipChild === void 0 ? false : _options_skipChild, _options_inlineStylesheet = options.inlineStylesheet, inlineStylesheet = _options_inlineStylesheet === void 0 ? true : _options_inlineStylesheet, _options_maskInputOptions = options.maskInputOptions, maskInputOptions = _options_maskInputOptions === void 0 ? {} : _options_maskInputOptions, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _options_dataURLOptions = options.dataURLOptions, dataURLOptions = _options_dataURLOptions === void 0 ? {} : _options_dataURLOptions, _options_inlineImages = options.inlineImages, inlineImages = _options_inlineImages === void 0 ? false : _options_inlineImages, _options_recordCanvas = options.recordCanvas, recordCanvas = _options_recordCanvas === void 0 ? false : _options_recordCanvas, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _options_iframeLoadTimeout = options.iframeLoadTimeout, iframeLoadTimeout = _options_iframeLoadTimeout === void 0 ? 5e3 : _options_iframeLoadTimeout, onStylesheetLoad = options.onStylesheetLoad, _options_stylesheetLoadTimeout = options.stylesheetLoadTimeout, stylesheetLoadTimeout = _options_stylesheetLoadTimeout === void 0 ? 5e3 : _options_stylesheetLoadTimeout, _options_keepIframeSrcFn = options.keepIframeSrcFn, keepIframeSrcFn = _options_keepIframeSrcFn === void 0 ? function() {
9413 return false;
9414 } : _options_keepIframeSrcFn, _options_newlyAddedElement = options.newlyAddedElement, newlyAddedElement = _options_newlyAddedElement === void 0 ? false : _options_newlyAddedElement, _options_cssCaptured = options.cssCaptured, cssCaptured = _options_cssCaptured === void 0 ? false : _options_cssCaptured;
9415 var needsMask = options.needsMask;
9416 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
9417 if (!needsMask) {
9418 var checkAncestors = needsMask === void 0;
9419 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
9420 }
9421 var _serializedNode = serializeNode(n2, {
9422 doc: doc,
9423 mirror: mirror2,
9424 blockClass: blockClass,
9425 blockSelector: blockSelector,
9426 needsMask: needsMask,
9427 inlineStylesheet: inlineStylesheet,
9428 maskInputOptions: maskInputOptions,
9429 maskTextFn: maskTextFn,
9430 maskInputFn: maskInputFn,
9431 dataURLOptions: dataURLOptions,
9432 inlineImages: inlineImages,
9433 recordCanvas: recordCanvas,
9434 keepIframeSrcFn: keepIframeSrcFn,
9435 newlyAddedElement: newlyAddedElement,
9436 cssCaptured: cssCaptured
9437 });
9438 if (!_serializedNode) {
9439 console.warn(n2, "not serialized");
9440 return null;
9441 }
9442 var id;
9443 if (mirror2.hasNode(n2)) {
9444 id = mirror2.getId(n2);
9445 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
9446 id = IGNORED_NODE;
9447 } else {
9448 id = genId();
9449 }
9450 var serializedNode = Object.assign(_serializedNode, {
9451 id: id
9452 });
9453 mirror2.add(n2, serializedNode);
9454 if (id === IGNORED_NODE) {
9455 return null;
9456 }
9457 if (onSerialize) {
9458 onSerialize(n2);
9459 }
9460 var recordChild = !skipChild;
9461 if (serializedNode.type === NodeType$3.Element) {
9462 recordChild = recordChild && !serializedNode.needBlock;
9463 delete serializedNode.needBlock;
9464 var shadowRootEl = index$1.shadowRoot(n2);
9465 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
9466 }
9467 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
9468 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
9469 preserveWhiteSpace = false;
9470 }
9471 var bypassOptions = {
9472 doc: doc,
9473 mirror: mirror2,
9474 blockClass: blockClass,
9475 blockSelector: blockSelector,
9476 needsMask: needsMask,
9477 maskTextClass: maskTextClass,
9478 maskTextSelector: maskTextSelector,
9479 skipChild: skipChild,
9480 inlineStylesheet: inlineStylesheet,
9481 maskInputOptions: maskInputOptions,
9482 maskTextFn: maskTextFn,
9483 maskInputFn: maskInputFn,
9484 slimDOMOptions: slimDOMOptions,
9485 dataURLOptions: dataURLOptions,
9486 inlineImages: inlineImages,
9487 recordCanvas: recordCanvas,
9488 preserveWhiteSpace: preserveWhiteSpace,
9489 onSerialize: onSerialize,
9490 onIframeLoad: onIframeLoad,
9491 iframeLoadTimeout: iframeLoadTimeout,
9492 onStylesheetLoad: onStylesheetLoad,
9493 stylesheetLoadTimeout: stylesheetLoadTimeout,
9494 keepIframeSrcFn: keepIframeSrcFn,
9495 cssCaptured: false
9496 };
9497 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
9498 else {
9499 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
9500 bypassOptions.cssCaptured = true;
9501 }
9502 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
9503 var childN = _step.value;
9504 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
9505 if (serializedChildNode) {
9506 serializedNode.childNodes.push(serializedChildNode);
9507 }
9508 }
9509 }
9510 var shadowRootEl1 = null;
9511 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
9512 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
9513 var childN1 = _step1.value;
9514 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
9515 if (serializedChildNode1) {
9516 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
9517 serializedNode.childNodes.push(serializedChildNode1);
9518 }
9519 }
9520 }
9521 }
9522 var parent = index$1.parentNode(n2);
9523 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
9524 serializedNode.isShadow = true;
9525 }
9526 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
9527 onceIframeLoaded(n2, function() {
9528 var iframeDoc = n2.contentDocument;
9529 if (iframeDoc && onIframeLoad) {
9530 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
9531 doc: iframeDoc,
9532 mirror: mirror2,
9533 blockClass: blockClass,
9534 blockSelector: blockSelector,
9535 needsMask: needsMask,
9536 maskTextClass: maskTextClass,
9537 maskTextSelector: maskTextSelector,
9538 skipChild: false,
9539 inlineStylesheet: inlineStylesheet,
9540 maskInputOptions: maskInputOptions,
9541 maskTextFn: maskTextFn,
9542 maskInputFn: maskInputFn,
9543 slimDOMOptions: slimDOMOptions,
9544 dataURLOptions: dataURLOptions,
9545 inlineImages: inlineImages,
9546 recordCanvas: recordCanvas,
9547 preserveWhiteSpace: preserveWhiteSpace,
9548 onSerialize: onSerialize,
9549 onIframeLoad: onIframeLoad,
9550 iframeLoadTimeout: iframeLoadTimeout,
9551 onStylesheetLoad: onStylesheetLoad,
9552 stylesheetLoadTimeout: stylesheetLoadTimeout,
9553 keepIframeSrcFn: keepIframeSrcFn
9554 });
9555 if (serializedIframeNode) {
9556 onIframeLoad(n2, serializedIframeNode);
9557 }
9558 }
9559 }, iframeLoadTimeout);
9560 }
9561 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")) {
9562 onceStylesheetLoaded(n2, function() {
9563 if (onStylesheetLoad) {
9564 var serializedLinkNode = serializeNodeWithId(n2, {
9565 doc: doc,
9566 mirror: mirror2,
9567 blockClass: blockClass,
9568 blockSelector: blockSelector,
9569 needsMask: needsMask,
9570 maskTextClass: maskTextClass,
9571 maskTextSelector: maskTextSelector,
9572 skipChild: false,
9573 inlineStylesheet: inlineStylesheet,
9574 maskInputOptions: maskInputOptions,
9575 maskTextFn: maskTextFn,
9576 maskInputFn: maskInputFn,
9577 slimDOMOptions: slimDOMOptions,
9578 dataURLOptions: dataURLOptions,
9579 inlineImages: inlineImages,
9580 recordCanvas: recordCanvas,
9581 preserveWhiteSpace: preserveWhiteSpace,
9582 onSerialize: onSerialize,
9583 onIframeLoad: onIframeLoad,
9584 iframeLoadTimeout: iframeLoadTimeout,
9585 onStylesheetLoad: onStylesheetLoad,
9586 stylesheetLoadTimeout: stylesheetLoadTimeout,
9587 keepIframeSrcFn: keepIframeSrcFn
9588 });
9589 if (serializedLinkNode) {
9590 onStylesheetLoad(n2, serializedLinkNode);
9591 }
9592 }
9593 }, stylesheetLoadTimeout);
9594 }
9595 return serializedNode;
9596 }
9597 function snapshot(n2, options) {
9598 var _ref = options || {}, tmp = _ref.mirror, mirror2 = tmp === void 0 ? new Mirror() : tmp, _ref_blockClass = _ref.blockClass, blockClass = _ref_blockClass === void 0 ? "rr-block" : _ref_blockClass, _ref_blockSelector = _ref.blockSelector, blockSelector = _ref_blockSelector === void 0 ? null : _ref_blockSelector, _ref_maskTextClass = _ref.maskTextClass, maskTextClass = _ref_maskTextClass === void 0 ? "rr-mask" : _ref_maskTextClass, _ref_maskTextSelector = _ref.maskTextSelector, maskTextSelector = _ref_maskTextSelector === void 0 ? null : _ref_maskTextSelector, _ref_inlineStylesheet = _ref.inlineStylesheet, inlineStylesheet = _ref_inlineStylesheet === void 0 ? true : _ref_inlineStylesheet, _ref_inlineImages = _ref.inlineImages, inlineImages = _ref_inlineImages === void 0 ? false : _ref_inlineImages, _ref_recordCanvas = _ref.recordCanvas, recordCanvas = _ref_recordCanvas === void 0 ? false : _ref_recordCanvas, _ref_maskAllInputs = _ref.maskAllInputs, maskAllInputs = _ref_maskAllInputs === void 0 ? false : _ref_maskAllInputs, maskTextFn = _ref.maskTextFn, maskInputFn = _ref.maskInputFn, _ref_slimDOM = _ref.slimDOM, slimDOM = _ref_slimDOM === void 0 ? false : _ref_slimDOM, dataURLOptions = _ref.dataURLOptions, preserveWhiteSpace = _ref.preserveWhiteSpace, onSerialize = _ref.onSerialize, onIframeLoad = _ref.onIframeLoad, iframeLoadTimeout = _ref.iframeLoadTimeout, onStylesheetLoad = _ref.onStylesheetLoad, stylesheetLoadTimeout = _ref.stylesheetLoadTimeout, _ref_keepIframeSrcFn = _ref.keepIframeSrcFn, keepIframeSrcFn = _ref_keepIframeSrcFn === void 0 ? function() {
9599 return false;
9600 } : _ref_keepIframeSrcFn;
9601 var maskInputOptions = maskAllInputs === true ? {
9602 color: true,
9603 date: true,
9604 "datetime-local": true,
9605 email: true,
9606 month: true,
9607 number: true,
9608 range: true,
9609 search: true,
9610 tel: true,
9611 text: true,
9612 time: true,
9613 url: true,
9614 week: true,
9615 textarea: true,
9616 select: true,
9617 password: true
9618 } : maskAllInputs === false ? {
9619 password: true
9620 } : maskAllInputs;
9621 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
9622 {
9623 script: true,
9624 comment: true,
9625 headFavicon: true,
9626 headWhitespace: true,
9627 headMetaDescKeywords: slimDOM === "all",
9628 // destructive
9629 headMetaSocial: true,
9630 headMetaRobots: true,
9631 headMetaHttpEquiv: true,
9632 headMetaAuthorship: true,
9633 headMetaVerification: true
9634 } : slimDOM === false ? {} : slimDOM;
9635 return serializeNodeWithId(n2, {
9636 doc: n2,
9637 mirror: mirror2,
9638 blockClass: blockClass,
9639 blockSelector: blockSelector,
9640 maskTextClass: maskTextClass,
9641 maskTextSelector: maskTextSelector,
9642 skipChild: false,
9643 inlineStylesheet: inlineStylesheet,
9644 maskInputOptions: maskInputOptions,
9645 maskTextFn: maskTextFn,
9646 maskInputFn: maskInputFn,
9647 slimDOMOptions: slimDOMOptions,
9648 dataURLOptions: dataURLOptions,
9649 inlineImages: inlineImages,
9650 recordCanvas: recordCanvas,
9651 preserveWhiteSpace: preserveWhiteSpace,
9652 onSerialize: onSerialize,
9653 onIframeLoad: onIframeLoad,
9654 iframeLoadTimeout: iframeLoadTimeout,
9655 onStylesheetLoad: onStylesheetLoad,
9656 stylesheetLoadTimeout: stylesheetLoadTimeout,
9657 keepIframeSrcFn: keepIframeSrcFn,
9658 newlyAddedElement: false
9659 });
9660 }
9661 function getDefaultExportFromCjs$1(x2) {
9662 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
9663 }
9664 function getAugmentedNamespace$1(n2) {
9665 if (n2.__esModule) return n2;
9666 var f2 = n2.default;
9667 if (typeof f2 == "function") {
9668 var a2 = function a22() {
9669 if (_instanceof(this, a22)) {
9670 return Reflect.construct(f2, arguments, this.constructor);
9671 }
9672 return f2.apply(this, arguments);
9673 };
9674 a2.prototype = f2.prototype;
9675 } else a2 = {};
9676 Object.defineProperty(a2, "__esModule", {
9677 value: true
9678 });
9679 Object.keys(n2).forEach(function(k) {
9680 var d = Object.getOwnPropertyDescriptor(n2, k);
9681 Object.defineProperty(a2, k, d.get ? d : {
9682 enumerable: true,
9683 get: function get() {
9684 return n2[k];
9685 }
9686 });
9687 });
9688 return a2;
9689 }
9690 var picocolors_browser$1 = {
9691 exports: {}
9692 };
9693 var x$1 = String;
9694 var create$1 = function create$1() {
9695 return {
9696 isColorSupported: false,
9697 reset: x$1,
9698 bold: x$1,
9699 dim: x$1,
9700 italic: x$1,
9701 underline: x$1,
9702 inverse: x$1,
9703 hidden: x$1,
9704 strikethrough: x$1,
9705 black: x$1,
9706 red: x$1,
9707 green: x$1,
9708 yellow: x$1,
9709 blue: x$1,
9710 magenta: x$1,
9711 cyan: x$1,
9712 white: x$1,
9713 gray: x$1,
9714 bgBlack: x$1,
9715 bgRed: x$1,
9716 bgGreen: x$1,
9717 bgYellow: x$1,
9718 bgBlue: x$1,
9719 bgMagenta: x$1,
9720 bgCyan: x$1,
9721 bgWhite: x$1
9722 };
9723 };
9724 picocolors_browser$1.exports = create$1();
9725 picocolors_browser$1.exports.createColors = create$1;
9726 var picocolors_browserExports$1 = picocolors_browser$1.exports;
9727 var __viteBrowserExternal$2 = {};
9728 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9729 __proto__: null,
9730 default: __viteBrowserExternal$2
9731 }, Symbol.toStringTag, {
9732 value: "Module"
9733 }));
9734 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
9735 var pico$1 = picocolors_browserExports$1;
9736 var terminalHighlight$1$1 = require$$2$1;
9737 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
9738 _inherits(CssSyntaxError, Error1);
9739 function CssSyntaxError(message, line, column, source, file, plugin22) {
9740 var _this;
9741 _this = Error1.call(this, message) || this;
9742 _this.name = "CssSyntaxError";
9743 _this.reason = message;
9744 if (file) {
9745 _this.file = file;
9746 }
9747 if (source) {
9748 _this.source = source;
9749 }
9750 if (plugin22) {
9751 _this.plugin = plugin22;
9752 }
9753 if (typeof line !== "undefined" && typeof column !== "undefined") {
9754 if (typeof line === "number") {
9755 _this.line = line;
9756 _this.column = column;
9757 } else {
9758 _this.line = line.line;
9759 _this.column = line.column;
9760 _this.endLine = column.line;
9761 _this.endColumn = column.column;
9762 }
9763 }
9764 _this.setMessage();
9765 if (Error.captureStackTrace) {
9766 Error.captureStackTrace(_this, CssSyntaxError);
9767 }
9768 return _this;
9769 }
9770 var _proto = CssSyntaxError.prototype;
9771 _proto.setMessage = function setMessage() {
9772 this.message = this.plugin ? this.plugin + ": " : "";
9773 this.message += this.file ? this.file : "<css input>";
9774 if (typeof this.line !== "undefined") {
9775 this.message += ":" + this.line + ":" + this.column;
9776 }
9777 this.message += ": " + this.reason;
9778 };
9779 _proto.showSourceCode = function showSourceCode(color) {
9780 var _this = this;
9781 if (!this.source) return "";
9782 var css = this.source;
9783 if (color == null) color = pico$1.isColorSupported;
9784 if (terminalHighlight$1$1) {
9785 if (color) css = terminalHighlight$1$1(css);
9786 }
9787 var lines = css.split(/\r?\n/);
9788 var start = Math.max(this.line - 3, 0);
9789 var end = Math.min(this.line + 2, lines.length);
9790 var maxWidth = String(end).length;
9791 var mark, aside;
9792 if (color) {
9793 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
9794 mark = function(text) {
9795 return bold(red(text));
9796 };
9797 aside = function(text) {
9798 return gray(text);
9799 };
9800 } else {
9801 mark = aside = function(str) {
9802 return str;
9803 };
9804 }
9805 return lines.slice(start, end).map(function(line, index2) {
9806 var number = start + 1 + index2;
9807 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
9808 if (number === _this.line) {
9809 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
9810 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
9811 }
9812 return " " + aside(gutter) + line;
9813 }).join("\n");
9814 };
9815 _proto.toString = function toString() {
9816 var code = this.showSourceCode();
9817 if (code) {
9818 code = "\n\n" + code + "\n";
9819 }
9820 return this.name + ": " + this.message + code;
9821 };
9822 return CssSyntaxError;
9823 }(_wrap_native_super(Error));
9824 var cssSyntaxError$1 = CssSyntaxError$3$1;
9825 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
9826 var symbols$1 = {};
9827 symbols$1.isClean = Symbol("isClean");
9828 symbols$1.my = Symbol("my");
9829 var DEFAULT_RAW$1 = {
9830 after: "\n",
9831 beforeClose: "\n",
9832 beforeComment: "\n",
9833 beforeDecl: "\n",
9834 beforeOpen: " ",
9835 beforeRule: "\n",
9836 colon: ": ",
9837 commentLeft: " ",
9838 commentRight: " ",
9839 emptyBody: "",
9840 indent: " ",
9841 semicolon: false
9842 };
9843 function capitalize$1(str) {
9844 return str[0].toUpperCase() + str.slice(1);
9845 }
9846 var Stringifier$2$1 = /*#__PURE__*/ function() {
9847 function Stringifier(builder) {
9848 this.builder = builder;
9849 }
9850 var _proto = Stringifier.prototype;
9851 _proto.atrule = function atrule(node2, semicolon) {
9852 var name = "@" + node2.name;
9853 var params = node2.params ? this.rawValue(node2, "params") : "";
9854 if (typeof node2.raws.afterName !== "undefined") {
9855 name += node2.raws.afterName;
9856 } else if (params) {
9857 name += " ";
9858 }
9859 if (node2.nodes) {
9860 this.block(node2, name + params);
9861 } else {
9862 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
9863 this.builder(name + params + end, node2);
9864 }
9865 };
9866 _proto.beforeAfter = function beforeAfter(node2, detect) {
9867 var value;
9868 if (node2.type === "decl") {
9869 value = this.raw(node2, null, "beforeDecl");
9870 } else if (node2.type === "comment") {
9871 value = this.raw(node2, null, "beforeComment");
9872 } else if (detect === "before") {
9873 value = this.raw(node2, null, "beforeRule");
9874 } else {
9875 value = this.raw(node2, null, "beforeClose");
9876 }
9877 var buf = node2.parent;
9878 var depth = 0;
9879 while(buf && buf.type !== "root"){
9880 depth += 1;
9881 buf = buf.parent;
9882 }
9883 if (value.includes("\n")) {
9884 var indent = this.raw(node2, null, "indent");
9885 if (indent.length) {
9886 for(var step = 0; step < depth; step++)value += indent;
9887 }
9888 }
9889 return value;
9890 };
9891 _proto.block = function block(node2, start) {
9892 var between = this.raw(node2, "between", "beforeOpen");
9893 this.builder(start + between + "{", node2, "start");
9894 var after;
9895 if (node2.nodes && node2.nodes.length) {
9896 this.body(node2);
9897 after = this.raw(node2, "after");
9898 } else {
9899 after = this.raw(node2, "after", "emptyBody");
9900 }
9901 if (after) this.builder(after);
9902 this.builder("}", node2, "end");
9903 };
9904 _proto.body = function body(node2) {
9905 var last = node2.nodes.length - 1;
9906 while(last > 0){
9907 if (node2.nodes[last].type !== "comment") break;
9908 last -= 1;
9909 }
9910 var semicolon = this.raw(node2, "semicolon");
9911 for(var i2 = 0; i2 < node2.nodes.length; i2++){
9912 var child = node2.nodes[i2];
9913 var before = this.raw(child, "before");
9914 if (before) this.builder(before);
9915 this.stringify(child, last !== i2 || semicolon);
9916 }
9917 };
9918 _proto.comment = function comment(node2) {
9919 var left = this.raw(node2, "left", "commentLeft");
9920 var right = this.raw(node2, "right", "commentRight");
9921 this.builder("/*" + left + node2.text + right + "*/", node2);
9922 };
9923 _proto.decl = function decl(node2, semicolon) {
9924 var between = this.raw(node2, "between", "colon");
9925 var string = node2.prop + between + this.rawValue(node2, "value");
9926 if (node2.important) {
9927 string += node2.raws.important || " !important";
9928 }
9929 if (semicolon) string += ";";
9930 this.builder(string, node2);
9931 };
9932 _proto.document = function document1(node2) {
9933 this.body(node2);
9934 };
9935 _proto.raw = function raw(node2, own, detect) {
9936 var value;
9937 if (!detect) detect = own;
9938 if (own) {
9939 value = node2.raws[own];
9940 if (typeof value !== "undefined") return value;
9941 }
9942 var parent = node2.parent;
9943 if (detect === "before") {
9944 if (!parent || parent.type === "root" && parent.first === node2) {
9945 return "";
9946 }
9947 if (parent && parent.type === "document") {
9948 return "";
9949 }
9950 }
9951 if (!parent) return DEFAULT_RAW$1[detect];
9952 var root2 = node2.root();
9953 if (!root2.rawCache) root2.rawCache = {};
9954 if (typeof root2.rawCache[detect] !== "undefined") {
9955 return root2.rawCache[detect];
9956 }
9957 if (detect === "before" || detect === "after") {
9958 return this.beforeAfter(node2, detect);
9959 } else {
9960 var method = "raw" + capitalize$1(detect);
9961 if (this[method]) {
9962 value = this[method](root2, node2);
9963 } else {
9964 root2.walk(function(i2) {
9965 value = i2.raws[own];
9966 if (typeof value !== "undefined") return false;
9967 });
9968 }
9969 }
9970 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
9971 root2.rawCache[detect] = value;
9972 return value;
9973 };
9974 _proto.rawBeforeClose = function rawBeforeClose(root2) {
9975 var value;
9976 root2.walk(function(i2) {
9977 if (i2.nodes && i2.nodes.length > 0) {
9978 if (typeof i2.raws.after !== "undefined") {
9979 value = i2.raws.after;
9980 if (value.includes("\n")) {
9981 value = value.replace(/[^\n]+$/, "");
9982 }
9983 return false;
9984 }
9985 }
9986 });
9987 if (value) value = value.replace(/\S/g, "");
9988 return value;
9989 };
9990 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
9991 var value;
9992 root2.walkComments(function(i2) {
9993 if (typeof i2.raws.before !== "undefined") {
9994 value = i2.raws.before;
9995 if (value.includes("\n")) {
9996 value = value.replace(/[^\n]+$/, "");
9997 }
9998 return false;
9999 }
10000 });
10001 if (typeof value === "undefined") {
10002 value = this.raw(node2, null, "beforeDecl");
10003 } else if (value) {
10004 value = value.replace(/\S/g, "");
10005 }
10006 return value;
10007 };
10008 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10009 var value;
10010 root2.walkDecls(function(i2) {
10011 if (typeof i2.raws.before !== "undefined") {
10012 value = i2.raws.before;
10013 if (value.includes("\n")) {
10014 value = value.replace(/[^\n]+$/, "");
10015 }
10016 return false;
10017 }
10018 });
10019 if (typeof value === "undefined") {
10020 value = this.raw(node2, null, "beforeRule");
10021 } else if (value) {
10022 value = value.replace(/\S/g, "");
10023 }
10024 return value;
10025 };
10026 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10027 var value;
10028 root2.walk(function(i2) {
10029 if (i2.type !== "decl") {
10030 value = i2.raws.between;
10031 if (typeof value !== "undefined") return false;
10032 }
10033 });
10034 return value;
10035 };
10036 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10037 var value;
10038 root2.walk(function(i2) {
10039 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10040 if (typeof i2.raws.before !== "undefined") {
10041 value = i2.raws.before;
10042 if (value.includes("\n")) {
10043 value = value.replace(/[^\n]+$/, "");
10044 }
10045 return false;
10046 }
10047 }
10048 });
10049 if (value) value = value.replace(/\S/g, "");
10050 return value;
10051 };
10052 _proto.rawColon = function rawColon(root2) {
10053 var value;
10054 root2.walkDecls(function(i2) {
10055 if (typeof i2.raws.between !== "undefined") {
10056 value = i2.raws.between.replace(/[^\s:]/g, "");
10057 return false;
10058 }
10059 });
10060 return value;
10061 };
10062 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10063 var value;
10064 root2.walk(function(i2) {
10065 if (i2.nodes && i2.nodes.length === 0) {
10066 value = i2.raws.after;
10067 if (typeof value !== "undefined") return false;
10068 }
10069 });
10070 return value;
10071 };
10072 _proto.rawIndent = function rawIndent(root2) {
10073 if (root2.raws.indent) return root2.raws.indent;
10074 var value;
10075 root2.walk(function(i2) {
10076 var p = i2.parent;
10077 if (p && p !== root2 && p.parent && p.parent === root2) {
10078 if (typeof i2.raws.before !== "undefined") {
10079 var parts = i2.raws.before.split("\n");
10080 value = parts[parts.length - 1];
10081 value = value.replace(/\S/g, "");
10082 return false;
10083 }
10084 }
10085 });
10086 return value;
10087 };
10088 _proto.rawSemicolon = function rawSemicolon(root2) {
10089 var value;
10090 root2.walk(function(i2) {
10091 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10092 value = i2.raws.semicolon;
10093 if (typeof value !== "undefined") return false;
10094 }
10095 });
10096 return value;
10097 };
10098 _proto.rawValue = function rawValue(node2, prop) {
10099 var value = node2[prop];
10100 var raw = node2.raws[prop];
10101 if (raw && raw.value === value) {
10102 return raw.raw;
10103 }
10104 return value;
10105 };
10106 _proto.root = function root(node2) {
10107 this.body(node2);
10108 if (node2.raws.after) this.builder(node2.raws.after);
10109 };
10110 _proto.rule = function rule(node2) {
10111 this.block(node2, this.rawValue(node2, "selector"));
10112 if (node2.raws.ownSemicolon) {
10113 this.builder(node2.raws.ownSemicolon, node2, "end");
10114 }
10115 };
10116 _proto.stringify = function stringify(node2, semicolon) {
10117 if (!this[node2.type]) {
10118 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10119 }
10120 this[node2.type](node2, semicolon);
10121 };
10122 return Stringifier;
10123 }();
10124 var stringifier$1 = Stringifier$2$1;
10125 Stringifier$2$1.default = Stringifier$2$1;
10126 var Stringifier$1$1 = stringifier$1;
10127 function stringify$4$1(node2, builder) {
10128 var str = new Stringifier$1$1(builder);
10129 str.stringify(node2);
10130 }
10131 var stringify_1$1 = stringify$4$1;
10132 stringify$4$1.default = stringify$4$1;
10133 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10134 var CssSyntaxError$2$1 = cssSyntaxError$1;
10135 var Stringifier2$1 = stringifier$1;
10136 var stringify$3$1 = stringify_1$1;
10137 function cloneNode$1(obj, parent) {
10138 var cloned = new obj.constructor();
10139 for(var i2 in obj){
10140 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10141 continue;
10142 }
10143 if (i2 === "proxyCache") continue;
10144 var value = obj[i2];
10145 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10146 if (i2 === "parent" && type === "object") {
10147 if (parent) cloned[i2] = parent;
10148 } else if (i2 === "source") {
10149 cloned[i2] = value;
10150 } else if (Array.isArray(value)) {
10151 cloned[i2] = value.map(function(j) {
10152 return cloneNode$1(j, cloned);
10153 });
10154 } else {
10155 if (type === "object" && value !== null) value = cloneNode$1(value);
10156 cloned[i2] = value;
10157 }
10158 }
10159 return cloned;
10160 }
10161 var Node$4$1 = /*#__PURE__*/ function() {
10162 function Node2(defaults) {
10163 if (defaults === void 0) defaults = {};
10164 this.raws = {};
10165 this[isClean$2$1] = false;
10166 this[my$2$1] = true;
10167 for(var name in defaults){
10168 if (name === "nodes") {
10169 this.nodes = [];
10170 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10171 var node2 = _step.value;
10172 if (typeof node2.clone === "function") {
10173 this.append(node2.clone());
10174 } else {
10175 this.append(node2);
10176 }
10177 }
10178 } else {
10179 this[name] = defaults[name];
10180 }
10181 }
10182 }
10183 var _proto = Node2.prototype;
10184 _proto.addToError = function addToError(error) {
10185 error.postcssNode = this;
10186 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
10187 var s2 = this.source;
10188 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
10189 }
10190 return error;
10191 };
10192 _proto.after = function after(add) {
10193 this.parent.insertAfter(this, add);
10194 return this;
10195 };
10196 _proto.assign = function assign(overrides) {
10197 if (overrides === void 0) overrides = {};
10198 for(var name in overrides){
10199 this[name] = overrides[name];
10200 }
10201 return this;
10202 };
10203 _proto.before = function before(add) {
10204 this.parent.insertBefore(this, add);
10205 return this;
10206 };
10207 _proto.cleanRaws = function cleanRaws(keepBetween) {
10208 delete this.raws.before;
10209 delete this.raws.after;
10210 if (!keepBetween) delete this.raws.between;
10211 };
10212 _proto.clone = function clone(overrides) {
10213 if (overrides === void 0) overrides = {};
10214 var cloned = cloneNode$1(this);
10215 for(var name in overrides){
10216 cloned[name] = overrides[name];
10217 }
10218 return cloned;
10219 };
10220 _proto.cloneAfter = function cloneAfter(overrides) {
10221 if (overrides === void 0) overrides = {};
10222 var cloned = this.clone(overrides);
10223 this.parent.insertAfter(this, cloned);
10224 return cloned;
10225 };
10226 _proto.cloneBefore = function cloneBefore(overrides) {
10227 if (overrides === void 0) overrides = {};
10228 var cloned = this.clone(overrides);
10229 this.parent.insertBefore(this, cloned);
10230 return cloned;
10231 };
10232 _proto.error = function error(message, opts) {
10233 if (opts === void 0) opts = {};
10234 if (this.source) {
10235 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
10236 return this.source.input.error(message, {
10237 column: start.column,
10238 line: start.line
10239 }, {
10240 column: end.column,
10241 line: end.line
10242 }, opts);
10243 }
10244 return new CssSyntaxError$2$1(message);
10245 };
10246 _proto.getProxyProcessor = function getProxyProcessor() {
10247 return {
10248 get: function get(node2, prop) {
10249 if (prop === "proxyOf") {
10250 return node2;
10251 } else if (prop === "root") {
10252 return function() {
10253 return node2.root().toProxy();
10254 };
10255 } else {
10256 return node2[prop];
10257 }
10258 },
10259 set: function set(node2, prop, value) {
10260 if (node2[prop] === value) return true;
10261 node2[prop] = value;
10262 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
10263 node2.markDirty();
10264 }
10265 return true;
10266 }
10267 };
10268 };
10269 _proto.markDirty = function markDirty() {
10270 if (this[isClean$2$1]) {
10271 this[isClean$2$1] = false;
10272 var next = this;
10273 while(next = next.parent){
10274 next[isClean$2$1] = false;
10275 }
10276 }
10277 };
10278 _proto.next = function next() {
10279 if (!this.parent) return void 0;
10280 var index2 = this.parent.index(this);
10281 return this.parent.nodes[index2 + 1];
10282 };
10283 _proto.positionBy = function positionBy(opts, stringRepresentation) {
10284 var pos = this.source.start;
10285 if (opts.index) {
10286 pos = this.positionInside(opts.index, stringRepresentation);
10287 } else if (opts.word) {
10288 stringRepresentation = this.toString();
10289 var index2 = stringRepresentation.indexOf(opts.word);
10290 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
10291 }
10292 return pos;
10293 };
10294 _proto.positionInside = function positionInside(index2, stringRepresentation) {
10295 var string = stringRepresentation || this.toString();
10296 var column = this.source.start.column;
10297 var line = this.source.start.line;
10298 for(var i2 = 0; i2 < index2; i2++){
10299 if (string[i2] === "\n") {
10300 column = 1;
10301 line += 1;
10302 } else {
10303 column += 1;
10304 }
10305 }
10306 return {
10307 column: column,
10308 line: line
10309 };
10310 };
10311 _proto.prev = function prev() {
10312 if (!this.parent) return void 0;
10313 var index2 = this.parent.index(this);
10314 return this.parent.nodes[index2 - 1];
10315 };
10316 _proto.rangeBy = function rangeBy(opts) {
10317 var start = {
10318 column: this.source.start.column,
10319 line: this.source.start.line
10320 };
10321 var end = this.source.end ? {
10322 column: this.source.end.column + 1,
10323 line: this.source.end.line
10324 } : {
10325 column: start.column + 1,
10326 line: start.line
10327 };
10328 if (opts.word) {
10329 var stringRepresentation = this.toString();
10330 var index2 = stringRepresentation.indexOf(opts.word);
10331 if (index2 !== -1) {
10332 start = this.positionInside(index2, stringRepresentation);
10333 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
10334 }
10335 } else {
10336 if (opts.start) {
10337 start = {
10338 column: opts.start.column,
10339 line: opts.start.line
10340 };
10341 } else if (opts.index) {
10342 start = this.positionInside(opts.index);
10343 }
10344 if (opts.end) {
10345 end = {
10346 column: opts.end.column,
10347 line: opts.end.line
10348 };
10349 } else if (typeof opts.endIndex === "number") {
10350 end = this.positionInside(opts.endIndex);
10351 } else if (opts.index) {
10352 end = this.positionInside(opts.index + 1);
10353 }
10354 }
10355 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
10356 end = {
10357 column: start.column + 1,
10358 line: start.line
10359 };
10360 }
10361 return {
10362 end: end,
10363 start: start
10364 };
10365 };
10366 _proto.raw = function raw(prop, defaultType) {
10367 var str = new Stringifier2$1();
10368 return str.raw(this, prop, defaultType);
10369 };
10370 _proto.remove = function remove() {
10371 if (this.parent) {
10372 this.parent.removeChild(this);
10373 }
10374 this.parent = void 0;
10375 return this;
10376 };
10377 _proto.replaceWith = function replaceWith() {
10378 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
10379 nodes[_key] = arguments[_key];
10380 }
10381 if (this.parent) {
10382 var bookmark = this;
10383 var foundSelf = false;
10384 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
10385 var node2 = _step.value;
10386 if (node2 === this) {
10387 foundSelf = true;
10388 } else if (foundSelf) {
10389 this.parent.insertAfter(bookmark, node2);
10390 bookmark = node2;
10391 } else {
10392 this.parent.insertBefore(bookmark, node2);
10393 }
10394 }
10395 if (!foundSelf) {
10396 this.remove();
10397 }
10398 }
10399 return this;
10400 };
10401 _proto.root = function root() {
10402 var result2 = this;
10403 while(result2.parent && result2.parent.type !== "document"){
10404 result2 = result2.parent;
10405 }
10406 return result2;
10407 };
10408 _proto.toJSON = function toJSON(_, inputs) {
10409 var fixed = {};
10410 var emitInputs = inputs == null;
10411 inputs = inputs || /* @__PURE__ */ new Map();
10412 var inputsNextIndex = 0;
10413 for(var name in this){
10414 if (!Object.prototype.hasOwnProperty.call(this, name)) {
10415 continue;
10416 }
10417 if (name === "parent" || name === "proxyCache") continue;
10418 var value = this[name];
10419 if (Array.isArray(value)) {
10420 fixed[name] = value.map(function(i2) {
10421 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
10422 return i2.toJSON(null, inputs);
10423 } else {
10424 return i2;
10425 }
10426 });
10427 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
10428 fixed[name] = value.toJSON(null, inputs);
10429 } else if (name === "source") {
10430 var inputId = inputs.get(value.input);
10431 if (inputId == null) {
10432 inputId = inputsNextIndex;
10433 inputs.set(value.input, inputsNextIndex);
10434 inputsNextIndex++;
10435 }
10436 fixed[name] = {
10437 end: value.end,
10438 inputId: inputId,
10439 start: value.start
10440 };
10441 } else {
10442 fixed[name] = value;
10443 }
10444 }
10445 if (emitInputs) {
10446 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
10447 return input2.toJSON();
10448 });
10449 }
10450 return fixed;
10451 };
10452 _proto.toProxy = function toProxy() {
10453 if (!this.proxyCache) {
10454 this.proxyCache = new Proxy(this, this.getProxyProcessor());
10455 }
10456 return this.proxyCache;
10457 };
10458 _proto.toString = function toString(stringifier2) {
10459 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
10460 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
10461 var result2 = "";
10462 stringifier2(this, function(i2) {
10463 result2 += i2;
10464 });
10465 return result2;
10466 };
10467 _proto.warn = function warn(result2, text, opts) {
10468 var data = {
10469 node: this
10470 };
10471 for(var i2 in opts)data[i2] = opts[i2];
10472 return result2.warn(text, data);
10473 };
10474 _create_class(Node2, [
10475 {
10476 key: "proxyOf",
10477 get: function get() {
10478 return this;
10479 }
10480 }
10481 ]);
10482 return Node2;
10483 }();
10484 var node$1 = Node$4$1;
10485 Node$4$1.default = Node$4$1;
10486 var Node$3$1 = node$1;
10487 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
10488 _inherits(Declaration, Node$3$1);
10489 function Declaration(defaults) {
10490 var _this;
10491 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
10492 defaults = _extends({}, defaults, {
10493 value: String(defaults.value)
10494 });
10495 }
10496 _this = Node$3$1.call(this, defaults) || this;
10497 _this.type = "decl";
10498 return _this;
10499 }
10500 _create_class(Declaration, [
10501 {
10502 key: "variable",
10503 get: function get() {
10504 return this.prop.startsWith("--") || this.prop[0] === "$";
10505 }
10506 }
10507 ]);
10508 return Declaration;
10509 }(Node$3$1);
10510 var declaration$1 = Declaration$4$1;
10511 Declaration$4$1.default = Declaration$4$1;
10512 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
10513 var nanoid$1$1 = function(size) {
10514 if (size === void 0) size = 21;
10515 var id = "";
10516 var i2 = size;
10517 while(i2--){
10518 id += urlAlphabet$1[Math.random() * 64 | 0];
10519 }
10520 return id;
10521 };
10522 var nonSecure$1 = {
10523 nanoid: nanoid$1$1};
10524 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
10525 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
10526 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
10527 function fromBase64$1(str) {
10528 if (Buffer) {
10529 return Buffer.from(str, "base64").toString();
10530 } else {
10531 return window.atob(str);
10532 }
10533 }
10534 var PreviousMap$2$1 = /*#__PURE__*/ function() {
10535 function PreviousMap(css, opts) {
10536 if (opts.map === false) return;
10537 this.loadAnnotation(css);
10538 this.inline = this.startWith(this.annotation, "data:");
10539 var prev = opts.map ? opts.map.prev : void 0;
10540 var text = this.loadMap(opts.from, prev);
10541 if (!this.mapFile && opts.from) {
10542 this.mapFile = opts.from;
10543 }
10544 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
10545 if (text) this.text = text;
10546 }
10547 var _proto = PreviousMap.prototype;
10548 _proto.consumer = function consumer() {
10549 if (!this.consumerCache) {
10550 this.consumerCache = new SourceMapConsumer$2$1(this.text);
10551 }
10552 return this.consumerCache;
10553 };
10554 _proto.decodeInline = function decodeInline(text) {
10555 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
10556 var baseUri = /^data:application\/json;base64,/;
10557 var charsetUri = /^data:application\/json;charset=utf-?8,/;
10558 var uri = /^data:application\/json,/;
10559 if (charsetUri.test(text) || uri.test(text)) {
10560 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
10561 }
10562 if (baseCharsetUri.test(text) || baseUri.test(text)) {
10563 return fromBase64$1(text.substr(RegExp.lastMatch.length));
10564 }
10565 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
10566 throw new Error("Unsupported source map encoding " + encoding);
10567 };
10568 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
10569 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
10570 };
10571 _proto.isMap = function isMap(map) {
10572 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
10573 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
10574 };
10575 _proto.loadAnnotation = function loadAnnotation(css) {
10576 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
10577 if (!comments) return;
10578 var start = css.lastIndexOf(comments.pop());
10579 var end = css.indexOf("*/", start);
10580 if (start > -1 && end > -1) {
10581 this.annotation = this.getAnnotationURL(css.substring(start, end));
10582 }
10583 };
10584 _proto.loadFile = function loadFile(path) {
10585 this.root = dirname$1$1(path);
10586 if (existsSync$1(path)) {
10587 this.mapFile = path;
10588 return readFileSync$1(path, "utf-8").toString().trim();
10589 }
10590 };
10591 _proto.loadMap = function loadMap(file, prev) {
10592 if (prev === false) return false;
10593 if (prev) {
10594 if (typeof prev === "string") {
10595 return prev;
10596 } else if (typeof prev === "function") {
10597 var prevPath = prev(file);
10598 if (prevPath) {
10599 var map = this.loadFile(prevPath);
10600 if (!map) {
10601 throw new Error("Unable to load previous source map: " + prevPath.toString());
10602 }
10603 return map;
10604 }
10605 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
10606 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
10607 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
10608 return prev.toString();
10609 } else if (this.isMap(prev)) {
10610 return JSON.stringify(prev);
10611 } else {
10612 throw new Error("Unsupported previous source map format: " + prev.toString());
10613 }
10614 } else if (this.inline) {
10615 return this.decodeInline(this.annotation);
10616 } else if (this.annotation) {
10617 var map1 = this.annotation;
10618 if (file) map1 = join$1(dirname$1$1(file), map1);
10619 return this.loadFile(map1);
10620 }
10621 };
10622 _proto.startWith = function startWith(string, start) {
10623 if (!string) return false;
10624 return string.substr(0, start.length) === start;
10625 };
10626 _proto.withContent = function withContent() {
10627 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
10628 };
10629 return PreviousMap;
10630 }();
10631 var previousMap$1 = PreviousMap$2$1;
10632 PreviousMap$2$1.default = PreviousMap$2$1;
10633 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
10634 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
10635 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
10636 var nanoid$2 = nonSecure$1.nanoid;
10637 var terminalHighlight$2 = require$$2$1;
10638 var CssSyntaxError$1$1 = cssSyntaxError$1;
10639 var PreviousMap$1$1 = previousMap$1;
10640 var fromOffsetCache$1 = Symbol("fromOffsetCache");
10641 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
10642 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
10643 var Input$4$1 = /*#__PURE__*/ function() {
10644 function Input(css, opts) {
10645 if (opts === void 0) opts = {};
10646 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
10647 throw new Error("PostCSS received " + css + " instead of CSS string");
10648 }
10649 this.css = css.toString();
10650 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
10651 this.hasBOM = true;
10652 this.css = this.css.slice(1);
10653 } else {
10654 this.hasBOM = false;
10655 }
10656 if (opts.from) {
10657 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
10658 this.file = opts.from;
10659 } else {
10660 this.file = resolve$1$1(opts.from);
10661 }
10662 }
10663 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
10664 var map = new PreviousMap$1$1(this.css, opts);
10665 if (map.text) {
10666 this.map = map;
10667 var file = map.consumer().file;
10668 if (!this.file && file) this.file = this.mapResolve(file);
10669 }
10670 }
10671 if (!this.file) {
10672 this.id = "<input css " + nanoid$2(6) + ">";
10673 }
10674 if (this.map) this.map.file = this.from;
10675 }
10676 var _proto = Input.prototype;
10677 _proto.error = function error(message, line, column, opts) {
10678 if (opts === void 0) opts = {};
10679 var result2, endLine, endColumn;
10680 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
10681 var start = line;
10682 var end = column;
10683 if (typeof start.offset === "number") {
10684 var pos = this.fromOffset(start.offset);
10685 line = pos.line;
10686 column = pos.col;
10687 } else {
10688 line = start.line;
10689 column = start.column;
10690 }
10691 if (typeof end.offset === "number") {
10692 var pos1 = this.fromOffset(end.offset);
10693 endLine = pos1.line;
10694 endColumn = pos1.col;
10695 } else {
10696 endLine = end.line;
10697 endColumn = end.column;
10698 }
10699 } else if (!column) {
10700 var pos2 = this.fromOffset(line);
10701 line = pos2.line;
10702 column = pos2.col;
10703 }
10704 var origin = this.origin(line, column, endLine, endColumn);
10705 if (origin) {
10706 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
10707 column: origin.column,
10708 line: origin.line
10709 }, origin.endLine === void 0 ? origin.column : {
10710 column: origin.endColumn,
10711 line: origin.endLine
10712 }, origin.source, origin.file, opts.plugin);
10713 } else {
10714 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
10715 column: column,
10716 line: line
10717 }, endLine === void 0 ? column : {
10718 column: endColumn,
10719 line: endLine
10720 }, this.css, this.file, opts.plugin);
10721 }
10722 result2.input = {
10723 column: column,
10724 endColumn: endColumn,
10725 endLine: endLine,
10726 line: line,
10727 source: this.css
10728 };
10729 if (this.file) {
10730 if (pathToFileURL$1$1) {
10731 result2.input.url = pathToFileURL$1$1(this.file).toString();
10732 }
10733 result2.input.file = this.file;
10734 }
10735 return result2;
10736 };
10737 _proto.fromOffset = function fromOffset(offset) {
10738 var lastLine, lineToIndex;
10739 if (!this[fromOffsetCache$1]) {
10740 var lines = this.css.split("\n");
10741 lineToIndex = new Array(lines.length);
10742 var prevIndex = 0;
10743 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
10744 lineToIndex[i2] = prevIndex;
10745 prevIndex += lines[i2].length + 1;
10746 }
10747 this[fromOffsetCache$1] = lineToIndex;
10748 } else {
10749 lineToIndex = this[fromOffsetCache$1];
10750 }
10751 lastLine = lineToIndex[lineToIndex.length - 1];
10752 var min = 0;
10753 if (offset >= lastLine) {
10754 min = lineToIndex.length - 1;
10755 } else {
10756 var max = lineToIndex.length - 2;
10757 var mid;
10758 while(min < max){
10759 mid = min + (max - min >> 1);
10760 if (offset < lineToIndex[mid]) {
10761 max = mid - 1;
10762 } else if (offset >= lineToIndex[mid + 1]) {
10763 min = mid + 1;
10764 } else {
10765 min = mid;
10766 break;
10767 }
10768 }
10769 }
10770 return {
10771 col: offset - lineToIndex[min] + 1,
10772 line: min + 1
10773 };
10774 };
10775 _proto.mapResolve = function mapResolve(file) {
10776 if (/^\w+:\/\//.test(file)) {
10777 return file;
10778 }
10779 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
10780 };
10781 _proto.origin = function origin(line, column, endLine, endColumn) {
10782 if (!this.map) return false;
10783 var consumer = this.map.consumer();
10784 var from = consumer.originalPositionFor({
10785 column: column,
10786 line: line
10787 });
10788 if (!from.source) return false;
10789 var to;
10790 if (typeof endLine === "number") {
10791 to = consumer.originalPositionFor({
10792 column: endColumn,
10793 line: endLine
10794 });
10795 }
10796 var fromUrl;
10797 if (isAbsolute$1(from.source)) {
10798 fromUrl = pathToFileURL$1$1(from.source);
10799 } else {
10800 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
10801 }
10802 var result2 = {
10803 column: from.column,
10804 endColumn: to && to.column,
10805 endLine: to && to.line,
10806 line: from.line,
10807 url: fromUrl.toString()
10808 };
10809 if (fromUrl.protocol === "file:") {
10810 if (fileURLToPath$1) {
10811 result2.file = fileURLToPath$1(fromUrl);
10812 } else {
10813 throw new Error("file: protocol is not available in this PostCSS build");
10814 }
10815 }
10816 var source = consumer.sourceContentFor(from.source);
10817 if (source) result2.source = source;
10818 return result2;
10819 };
10820 _proto.toJSON = function toJSON() {
10821 var json = {};
10822 for(var _i = 0, _iter = [
10823 "hasBOM",
10824 "css",
10825 "file",
10826 "id"
10827 ]; _i < _iter.length; _i++){
10828 var name = _iter[_i];
10829 if (this[name] != null) {
10830 json[name] = this[name];
10831 }
10832 }
10833 if (this.map) {
10834 json.map = _extends({}, this.map);
10835 if (json.map.consumerCache) {
10836 json.map.consumerCache = void 0;
10837 }
10838 }
10839 return json;
10840 };
10841 _create_class(Input, [
10842 {
10843 key: "from",
10844 get: function get() {
10845 return this.file || this.id;
10846 }
10847 }
10848 ]);
10849 return Input;
10850 }();
10851 var input$1 = Input$4$1;
10852 Input$4$1.default = Input$4$1;
10853 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
10854 terminalHighlight$2.registerInput(Input$4$1);
10855 }
10856 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
10857 var dirname$2 = require$$2$1.dirname, relative$1 = require$$2$1.relative, resolve$2 = require$$2$1.resolve, sep$1 = require$$2$1.sep;
10858 var pathToFileURL$2 = require$$2$1.pathToFileURL;
10859 var Input$3$1 = input$1;
10860 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
10861 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
10862 var MapGenerator$2$1 = /*#__PURE__*/ function() {
10863 function MapGenerator(stringify2, root2, opts, cssString) {
10864 this.stringify = stringify2;
10865 this.mapOpts = opts.map || {};
10866 this.root = root2;
10867 this.opts = opts;
10868 this.css = cssString;
10869 this.originalCSS = cssString;
10870 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
10871 this.memoizedFileURLs = /* @__PURE__ */ new Map();
10872 this.memoizedPaths = /* @__PURE__ */ new Map();
10873 this.memoizedURLs = /* @__PURE__ */ new Map();
10874 }
10875 var _proto = MapGenerator.prototype;
10876 _proto.addAnnotation = function addAnnotation() {
10877 var content;
10878 if (this.isInline()) {
10879 content = "data:application/json;base64," + this.toBase64(this.map.toString());
10880 } else if (typeof this.mapOpts.annotation === "string") {
10881 content = this.mapOpts.annotation;
10882 } else if (typeof this.mapOpts.annotation === "function") {
10883 content = this.mapOpts.annotation(this.opts.to, this.root);
10884 } else {
10885 content = this.outputFile() + ".map";
10886 }
10887 var eol = "\n";
10888 if (this.css.includes("\r\n")) eol = "\r\n";
10889 this.css += eol + "/*# sourceMappingURL=" + content + " */";
10890 };
10891 _proto.applyPrevMaps = function applyPrevMaps() {
10892 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
10893 var prev = _step.value;
10894 var from = this.toUrl(this.path(prev.file));
10895 var root2 = prev.root || dirname$2(prev.file);
10896 var map = void 0;
10897 if (this.mapOpts.sourcesContent === false) {
10898 map = new SourceMapConsumer$3(prev.text);
10899 if (map.sourcesContent) {
10900 map.sourcesContent = null;
10901 }
10902 } else {
10903 map = prev.consumer();
10904 }
10905 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
10906 }
10907 };
10908 _proto.clearAnnotation = function clearAnnotation() {
10909 if (this.mapOpts.annotation === false) return;
10910 if (this.root) {
10911 var node2;
10912 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
10913 node2 = this.root.nodes[i2];
10914 if (node2.type !== "comment") continue;
10915 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
10916 this.root.removeChild(i2);
10917 }
10918 }
10919 } else if (this.css) {
10920 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
10921 }
10922 };
10923 _proto.generate = function generate() {
10924 this.clearAnnotation();
10925 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
10926 return this.generateMap();
10927 } else {
10928 var result2 = "";
10929 this.stringify(this.root, function(i2) {
10930 result2 += i2;
10931 });
10932 return [
10933 result2
10934 ];
10935 }
10936 };
10937 _proto.generateMap = function generateMap() {
10938 if (this.root) {
10939 this.generateString();
10940 } else if (this.previous().length === 1) {
10941 var prev = this.previous()[0].consumer();
10942 prev.file = this.outputFile();
10943 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
10944 ignoreInvalidMapping: true
10945 });
10946 } else {
10947 this.map = new SourceMapGenerator$3({
10948 file: this.outputFile(),
10949 ignoreInvalidMapping: true
10950 });
10951 this.map.addMapping({
10952 generated: {
10953 column: 0,
10954 line: 1
10955 },
10956 original: {
10957 column: 0,
10958 line: 1
10959 },
10960 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
10961 });
10962 }
10963 if (this.isSourcesContent()) this.setSourcesContent();
10964 if (this.root && this.previous().length > 0) this.applyPrevMaps();
10965 if (this.isAnnotation()) this.addAnnotation();
10966 if (this.isInline()) {
10967 return [
10968 this.css
10969 ];
10970 } else {
10971 return [
10972 this.css,
10973 this.map
10974 ];
10975 }
10976 };
10977 _proto.generateString = function generateString() {
10978 var _this = this;
10979 this.css = "";
10980 this.map = new SourceMapGenerator$3({
10981 file: this.outputFile(),
10982 ignoreInvalidMapping: true
10983 });
10984 var line = 1;
10985 var column = 1;
10986 var noSource = "<no source>";
10987 var mapping = {
10988 generated: {
10989 column: 0,
10990 line: 0
10991 },
10992 original: {
10993 column: 0,
10994 line: 0
10995 },
10996 source: ""
10997 };
10998 var lines, last;
10999 this.stringify(this.root, function(str, node2, type) {
11000 _this.css += str;
11001 if (node2 && type !== "end") {
11002 mapping.generated.line = line;
11003 mapping.generated.column = column - 1;
11004 if (node2.source && node2.source.start) {
11005 mapping.source = _this.sourcePath(node2);
11006 mapping.original.line = node2.source.start.line;
11007 mapping.original.column = node2.source.start.column - 1;
11008 _this.map.addMapping(mapping);
11009 } else {
11010 mapping.source = noSource;
11011 mapping.original.line = 1;
11012 mapping.original.column = 0;
11013 _this.map.addMapping(mapping);
11014 }
11015 }
11016 lines = str.match(/\n/g);
11017 if (lines) {
11018 line += lines.length;
11019 last = str.lastIndexOf("\n");
11020 column = str.length - last;
11021 } else {
11022 column += str.length;
11023 }
11024 if (node2 && type !== "start") {
11025 var p = node2.parent || {
11026 raws: {}
11027 };
11028 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11029 if (!childless || node2 !== p.last || p.raws.semicolon) {
11030 if (node2.source && node2.source.end) {
11031 mapping.source = _this.sourcePath(node2);
11032 mapping.original.line = node2.source.end.line;
11033 mapping.original.column = node2.source.end.column - 1;
11034 mapping.generated.line = line;
11035 mapping.generated.column = column - 2;
11036 _this.map.addMapping(mapping);
11037 } else {
11038 mapping.source = noSource;
11039 mapping.original.line = 1;
11040 mapping.original.column = 0;
11041 mapping.generated.line = line;
11042 mapping.generated.column = column - 1;
11043 _this.map.addMapping(mapping);
11044 }
11045 }
11046 }
11047 });
11048 };
11049 _proto.isAnnotation = function isAnnotation() {
11050 if (this.isInline()) {
11051 return true;
11052 }
11053 if (typeof this.mapOpts.annotation !== "undefined") {
11054 return this.mapOpts.annotation;
11055 }
11056 if (this.previous().length) {
11057 return this.previous().some(function(i2) {
11058 return i2.annotation;
11059 });
11060 }
11061 return true;
11062 };
11063 _proto.isInline = function isInline() {
11064 if (typeof this.mapOpts.inline !== "undefined") {
11065 return this.mapOpts.inline;
11066 }
11067 var annotation = this.mapOpts.annotation;
11068 if (typeof annotation !== "undefined" && annotation !== true) {
11069 return false;
11070 }
11071 if (this.previous().length) {
11072 return this.previous().some(function(i2) {
11073 return i2.inline;
11074 });
11075 }
11076 return true;
11077 };
11078 _proto.isMap = function isMap() {
11079 if (typeof this.opts.map !== "undefined") {
11080 return !!this.opts.map;
11081 }
11082 return this.previous().length > 0;
11083 };
11084 _proto.isSourcesContent = function isSourcesContent() {
11085 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11086 return this.mapOpts.sourcesContent;
11087 }
11088 if (this.previous().length) {
11089 return this.previous().some(function(i2) {
11090 return i2.withContent();
11091 });
11092 }
11093 return true;
11094 };
11095 _proto.outputFile = function outputFile() {
11096 if (this.opts.to) {
11097 return this.path(this.opts.to);
11098 } else if (this.opts.from) {
11099 return this.path(this.opts.from);
11100 } else {
11101 return "to.css";
11102 }
11103 };
11104 _proto.path = function path(file) {
11105 if (this.mapOpts.absolute) return file;
11106 if (file.charCodeAt(0) === 60) return file;
11107 if (/^\w+:\/\//.test(file)) return file;
11108 var cached = this.memoizedPaths.get(file);
11109 if (cached) return cached;
11110 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11111 if (typeof this.mapOpts.annotation === "string") {
11112 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11113 }
11114 var path = relative$1(from, file);
11115 this.memoizedPaths.set(file, path);
11116 return path;
11117 };
11118 _proto.previous = function previous() {
11119 var _this = this;
11120 if (!this.previousMaps) {
11121 this.previousMaps = [];
11122 if (this.root) {
11123 this.root.walk(function(node2) {
11124 if (node2.source && node2.source.input.map) {
11125 var map = node2.source.input.map;
11126 if (!_this.previousMaps.includes(map)) {
11127 _this.previousMaps.push(map);
11128 }
11129 }
11130 });
11131 } else {
11132 var input2 = new Input$3$1(this.originalCSS, this.opts);
11133 if (input2.map) this.previousMaps.push(input2.map);
11134 }
11135 }
11136 return this.previousMaps;
11137 };
11138 _proto.setSourcesContent = function setSourcesContent() {
11139 var _this = this;
11140 var already = {};
11141 if (this.root) {
11142 this.root.walk(function(node2) {
11143 if (node2.source) {
11144 var from = node2.source.input.from;
11145 if (from && !already[from]) {
11146 already[from] = true;
11147 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11148 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11149 }
11150 }
11151 });
11152 } else if (this.css) {
11153 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11154 this.map.setSourceContent(from, this.css);
11155 }
11156 };
11157 _proto.sourcePath = function sourcePath(node2) {
11158 if (this.mapOpts.from) {
11159 return this.toUrl(this.mapOpts.from);
11160 } else if (this.usesFileUrls) {
11161 return this.toFileUrl(node2.source.input.from);
11162 } else {
11163 return this.toUrl(this.path(node2.source.input.from));
11164 }
11165 };
11166 _proto.toBase64 = function toBase64(str) {
11167 if (Buffer) {
11168 return Buffer.from(str).toString("base64");
11169 } else {
11170 return window.btoa(unescape(encodeURIComponent(str)));
11171 }
11172 };
11173 _proto.toFileUrl = function toFileUrl(path) {
11174 var cached = this.memoizedFileURLs.get(path);
11175 if (cached) return cached;
11176 if (pathToFileURL$2) {
11177 var fileURL = pathToFileURL$2(path).toString();
11178 this.memoizedFileURLs.set(path, fileURL);
11179 return fileURL;
11180 } else {
11181 throw new Error("`map.absolute` option is not available in this PostCSS build");
11182 }
11183 };
11184 _proto.toUrl = function toUrl(path) {
11185 var cached = this.memoizedURLs.get(path);
11186 if (cached) return cached;
11187 if (sep$1 === "\\") {
11188 path = path.replace(/\\/g, "/");
11189 }
11190 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
11191 this.memoizedURLs.set(path, url);
11192 return url;
11193 };
11194 return MapGenerator;
11195 }();
11196 var mapGenerator$1 = MapGenerator$2$1;
11197 var Node$2$1 = node$1;
11198 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
11199 _inherits(Comment, Node$2$1);
11200 function Comment(defaults) {
11201 var _this;
11202 _this = Node$2$1.call(this, defaults) || this;
11203 _this.type = "comment";
11204 return _this;
11205 }
11206 return Comment;
11207 }(Node$2$1);
11208 var comment$1 = Comment$4$1;
11209 Comment$4$1.default = Comment$4$1;
11210 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
11211 var Declaration$3$1 = declaration$1;
11212 var Comment$3$1 = comment$1;
11213 var Node$1$1 = node$1;
11214 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
11215 function cleanSource$1(nodes) {
11216 return nodes.map(function(i2) {
11217 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
11218 delete i2.source;
11219 return i2;
11220 });
11221 }
11222 function markDirtyUp$1(node2) {
11223 node2[isClean$1$1] = false;
11224 if (node2.proxyOf.nodes) {
11225 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11226 var i2 = _step.value;
11227 markDirtyUp$1(i2);
11228 }
11229 }
11230 }
11231 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
11232 _inherits(Container, Node$1$1);
11233 function Container() {
11234 return Node$1$1.apply(this, arguments) || this;
11235 }
11236 var _proto = Container.prototype;
11237 _proto.append = function append() {
11238 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11239 children[_key] = arguments[_key];
11240 }
11241 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11242 var child = _step.value;
11243 var nodes = this.normalize(child, this.last);
11244 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11245 var node2 = _step1.value;
11246 this.proxyOf.nodes.push(node2);
11247 }
11248 }
11249 this.markDirty();
11250 return this;
11251 };
11252 _proto.cleanRaws = function cleanRaws(keepBetween) {
11253 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
11254 if (this.nodes) {
11255 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
11256 var node2 = _step.value;
11257 node2.cleanRaws(keepBetween);
11258 }
11259 }
11260 };
11261 _proto.each = function each(callback) {
11262 if (!this.proxyOf.nodes) return void 0;
11263 var iterator = this.getIterator();
11264 var index2, result2;
11265 while(this.indexes[iterator] < this.proxyOf.nodes.length){
11266 index2 = this.indexes[iterator];
11267 result2 = callback(this.proxyOf.nodes[index2], index2);
11268 if (result2 === false) break;
11269 this.indexes[iterator] += 1;
11270 }
11271 delete this.indexes[iterator];
11272 return result2;
11273 };
11274 _proto.every = function every(condition) {
11275 return this.nodes.every(condition);
11276 };
11277 _proto.getIterator = function getIterator() {
11278 if (!this.lastEach) this.lastEach = 0;
11279 if (!this.indexes) this.indexes = {};
11280 this.lastEach += 1;
11281 var iterator = this.lastEach;
11282 this.indexes[iterator] = 0;
11283 return iterator;
11284 };
11285 _proto.getProxyProcessor = function getProxyProcessor() {
11286 return {
11287 get: function get(node2, prop) {
11288 if (prop === "proxyOf") {
11289 return node2;
11290 } else if (!node2[prop]) {
11291 return node2[prop];
11292 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
11293 return function() {
11294 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
11295 args[_key] = arguments[_key];
11296 }
11297 var _node2;
11298 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
11299 if (typeof i2 === "function") {
11300 return function(child, index2) {
11301 return i2(child.toProxy(), index2);
11302 };
11303 } else {
11304 return i2;
11305 }
11306 })));
11307 };
11308 } else if (prop === "every" || prop === "some") {
11309 return function(cb) {
11310 return node2[prop](function(child) {
11311 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
11312 other[_key - 1] = arguments[_key];
11313 }
11314 return cb.apply(void 0, [].concat([
11315 child.toProxy()
11316 ], other));
11317 });
11318 };
11319 } else if (prop === "root") {
11320 return function() {
11321 return node2.root().toProxy();
11322 };
11323 } else if (prop === "nodes") {
11324 return node2.nodes.map(function(i2) {
11325 return i2.toProxy();
11326 });
11327 } else if (prop === "first" || prop === "last") {
11328 return node2[prop].toProxy();
11329 } else {
11330 return node2[prop];
11331 }
11332 },
11333 set: function set(node2, prop, value) {
11334 if (node2[prop] === value) return true;
11335 node2[prop] = value;
11336 if (prop === "name" || prop === "params" || prop === "selector") {
11337 node2.markDirty();
11338 }
11339 return true;
11340 }
11341 };
11342 };
11343 _proto.index = function index(child) {
11344 if (typeof child === "number") return child;
11345 if (child.proxyOf) child = child.proxyOf;
11346 return this.proxyOf.nodes.indexOf(child);
11347 };
11348 _proto.insertAfter = function insertAfter(exist, add) {
11349 var existIndex = this.index(exist);
11350 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
11351 existIndex = this.index(exist);
11352 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11353 var node2 = _step.value;
11354 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
11355 }
11356 var index2;
11357 for(var id in this.indexes){
11358 index2 = this.indexes[id];
11359 if (existIndex < index2) {
11360 this.indexes[id] = index2 + nodes.length;
11361 }
11362 }
11363 this.markDirty();
11364 return this;
11365 };
11366 _proto.insertBefore = function insertBefore(exist, add) {
11367 var existIndex = this.index(exist);
11368 var type = existIndex === 0 ? "prepend" : false;
11369 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
11370 existIndex = this.index(exist);
11371 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11372 var node2 = _step.value;
11373 this.proxyOf.nodes.splice(existIndex, 0, node2);
11374 }
11375 var index2;
11376 for(var id in this.indexes){
11377 index2 = this.indexes[id];
11378 if (existIndex <= index2) {
11379 this.indexes[id] = index2 + nodes.length;
11380 }
11381 }
11382 this.markDirty();
11383 return this;
11384 };
11385 _proto.normalize = function normalize(nodes, sample) {
11386 var _this = this;
11387 if (typeof nodes === "string") {
11388 nodes = cleanSource$1(parse$4$1(nodes).nodes);
11389 } else if (typeof nodes === "undefined") {
11390 nodes = [];
11391 } else if (Array.isArray(nodes)) {
11392 nodes = nodes.slice(0);
11393 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11394 var i2 = _step.value;
11395 if (i2.parent) i2.parent.removeChild(i2, "ignore");
11396 }
11397 } else if (nodes.type === "root" && this.type !== "document") {
11398 nodes = nodes.nodes.slice(0);
11399 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11400 var i21 = _step1.value;
11401 if (i21.parent) i21.parent.removeChild(i21, "ignore");
11402 }
11403 } else if (nodes.type) {
11404 nodes = [
11405 nodes
11406 ];
11407 } else if (nodes.prop) {
11408 if (typeof nodes.value === "undefined") {
11409 throw new Error("Value field is missed in node creation");
11410 } else if (typeof nodes.value !== "string") {
11411 nodes.value = String(nodes.value);
11412 }
11413 nodes = [
11414 new Declaration$3$1(nodes)
11415 ];
11416 } else if (nodes.selector) {
11417 nodes = [
11418 new Rule$4$1(nodes)
11419 ];
11420 } else if (nodes.name) {
11421 nodes = [
11422 new AtRule$4$1(nodes)
11423 ];
11424 } else if (nodes.text) {
11425 nodes = [
11426 new Comment$3$1(nodes)
11427 ];
11428 } else {
11429 throw new Error("Unknown node type in node creation");
11430 }
11431 var processed = nodes.map(function(i2) {
11432 if (!i2[my$1$1]) Container.rebuild(i2);
11433 i2 = i2.proxyOf;
11434 if (i2.parent) i2.parent.removeChild(i2);
11435 if (i2[isClean$1$1]) markDirtyUp$1(i2);
11436 if (typeof i2.raws.before === "undefined") {
11437 if (sample && typeof sample.raws.before !== "undefined") {
11438 i2.raws.before = sample.raws.before.replace(/\S/g, "");
11439 }
11440 }
11441 i2.parent = _this.proxyOf;
11442 return i2;
11443 });
11444 return processed;
11445 };
11446 _proto.prepend = function prepend() {
11447 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11448 children[_key] = arguments[_key];
11449 }
11450 children = children.reverse();
11451 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11452 var child = _step.value;
11453 var nodes = this.normalize(child, this.first, "prepend").reverse();
11454 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11455 var node2 = _step1.value;
11456 this.proxyOf.nodes.unshift(node2);
11457 }
11458 for(var id in this.indexes){
11459 this.indexes[id] = this.indexes[id] + nodes.length;
11460 }
11461 }
11462 this.markDirty();
11463 return this;
11464 };
11465 _proto.push = function push(child) {
11466 child.parent = this;
11467 this.proxyOf.nodes.push(child);
11468 return this;
11469 };
11470 _proto.removeAll = function removeAll() {
11471 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11472 var node2 = _step.value;
11473 node2.parent = void 0;
11474 }
11475 this.proxyOf.nodes = [];
11476 this.markDirty();
11477 return this;
11478 };
11479 _proto.removeChild = function removeChild(child) {
11480 child = this.index(child);
11481 this.proxyOf.nodes[child].parent = void 0;
11482 this.proxyOf.nodes.splice(child, 1);
11483 var index2;
11484 for(var id in this.indexes){
11485 index2 = this.indexes[id];
11486 if (index2 >= child) {
11487 this.indexes[id] = index2 - 1;
11488 }
11489 }
11490 this.markDirty();
11491 return this;
11492 };
11493 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
11494 if (!callback) {
11495 callback = opts;
11496 opts = {};
11497 }
11498 this.walkDecls(function(decl) {
11499 if (opts.props && !opts.props.includes(decl.prop)) return;
11500 if (opts.fast && !decl.value.includes(opts.fast)) return;
11501 decl.value = decl.value.replace(pattern, callback);
11502 });
11503 this.markDirty();
11504 return this;
11505 };
11506 _proto.some = function some(condition) {
11507 return this.nodes.some(condition);
11508 };
11509 _proto.walk = function walk(callback) {
11510 return this.each(function(child, i2) {
11511 var result2;
11512 try {
11513 result2 = callback(child, i2);
11514 } catch (e2) {
11515 throw child.addToError(e2);
11516 }
11517 if (result2 !== false && child.walk) {
11518 result2 = child.walk(callback);
11519 }
11520 return result2;
11521 });
11522 };
11523 _proto.walkAtRules = function walkAtRules(name, callback) {
11524 if (!callback) {
11525 callback = name;
11526 return this.walk(function(child, i2) {
11527 if (child.type === "atrule") {
11528 return callback(child, i2);
11529 }
11530 });
11531 }
11532 if (_instanceof(name, RegExp)) {
11533 return this.walk(function(child, i2) {
11534 if (child.type === "atrule" && name.test(child.name)) {
11535 return callback(child, i2);
11536 }
11537 });
11538 }
11539 return this.walk(function(child, i2) {
11540 if (child.type === "atrule" && child.name === name) {
11541 return callback(child, i2);
11542 }
11543 });
11544 };
11545 _proto.walkComments = function walkComments(callback) {
11546 return this.walk(function(child, i2) {
11547 if (child.type === "comment") {
11548 return callback(child, i2);
11549 }
11550 });
11551 };
11552 _proto.walkDecls = function walkDecls(prop, callback) {
11553 if (!callback) {
11554 callback = prop;
11555 return this.walk(function(child, i2) {
11556 if (child.type === "decl") {
11557 return callback(child, i2);
11558 }
11559 });
11560 }
11561 if (_instanceof(prop, RegExp)) {
11562 return this.walk(function(child, i2) {
11563 if (child.type === "decl" && prop.test(child.prop)) {
11564 return callback(child, i2);
11565 }
11566 });
11567 }
11568 return this.walk(function(child, i2) {
11569 if (child.type === "decl" && child.prop === prop) {
11570 return callback(child, i2);
11571 }
11572 });
11573 };
11574 _proto.walkRules = function walkRules(selector, callback) {
11575 if (!callback) {
11576 callback = selector;
11577 return this.walk(function(child, i2) {
11578 if (child.type === "rule") {
11579 return callback(child, i2);
11580 }
11581 });
11582 }
11583 if (_instanceof(selector, RegExp)) {
11584 return this.walk(function(child, i2) {
11585 if (child.type === "rule" && selector.test(child.selector)) {
11586 return callback(child, i2);
11587 }
11588 });
11589 }
11590 return this.walk(function(child, i2) {
11591 if (child.type === "rule" && child.selector === selector) {
11592 return callback(child, i2);
11593 }
11594 });
11595 };
11596 _create_class(Container, [
11597 {
11598 key: "first",
11599 get: function get() {
11600 if (!this.proxyOf.nodes) return void 0;
11601 return this.proxyOf.nodes[0];
11602 }
11603 },
11604 {
11605 key: "last",
11606 get: function get() {
11607 if (!this.proxyOf.nodes) return void 0;
11608 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
11609 }
11610 }
11611 ]);
11612 return Container;
11613 }(Node$1$1);
11614 Container$7$1.registerParse = function(dependant) {
11615 parse$4$1 = dependant;
11616 };
11617 Container$7$1.registerRule = function(dependant) {
11618 Rule$4$1 = dependant;
11619 };
11620 Container$7$1.registerAtRule = function(dependant) {
11621 AtRule$4$1 = dependant;
11622 };
11623 Container$7$1.registerRoot = function(dependant) {
11624 Root$6$1 = dependant;
11625 };
11626 var container$1 = Container$7$1;
11627 Container$7$1.default = Container$7$1;
11628 Container$7$1.rebuild = function(node2) {
11629 if (node2.type === "atrule") {
11630 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
11631 } else if (node2.type === "rule") {
11632 Object.setPrototypeOf(node2, Rule$4$1.prototype);
11633 } else if (node2.type === "decl") {
11634 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
11635 } else if (node2.type === "comment") {
11636 Object.setPrototypeOf(node2, Comment$3$1.prototype);
11637 } else if (node2.type === "root") {
11638 Object.setPrototypeOf(node2, Root$6$1.prototype);
11639 }
11640 node2[my$1$1] = true;
11641 if (node2.nodes) {
11642 node2.nodes.forEach(function(child) {
11643 Container$7$1.rebuild(child);
11644 });
11645 }
11646 };
11647 var Container$6$1 = container$1;
11648 var LazyResult$4$1, Processor$3$1;
11649 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
11650 _inherits(Document2, Container$6$1);
11651 function Document2(defaults) {
11652 var _this;
11653 _this = Container$6$1.call(this, _extends({
11654 type: "document"
11655 }, defaults)) || this;
11656 if (!_this.nodes) {
11657 _this.nodes = [];
11658 }
11659 return _this;
11660 }
11661 var _proto = Document2.prototype;
11662 _proto.toResult = function toResult(opts) {
11663 if (opts === void 0) opts = {};
11664 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
11665 return lazy.stringify();
11666 };
11667 return Document2;
11668 }(Container$6$1);
11669 Document$3$1.registerLazyResult = function(dependant) {
11670 LazyResult$4$1 = dependant;
11671 };
11672 Document$3$1.registerProcessor = function(dependant) {
11673 Processor$3$1 = dependant;
11674 };
11675 var document$1$1 = Document$3$1;
11676 Document$3$1.default = Document$3$1;
11677 var printed$1 = {};
11678 var warnOnce$2$1 = function warnOnce(message) {
11679 if (printed$1[message]) return;
11680 printed$1[message] = true;
11681 if (typeof console !== "undefined" && console.warn) {
11682 console.warn(message);
11683 }
11684 };
11685 var Warning$2$1 = /*#__PURE__*/ function() {
11686 function Warning(text, opts) {
11687 if (opts === void 0) opts = {};
11688 this.type = "warning";
11689 this.text = text;
11690 if (opts.node && opts.node.source) {
11691 var range = opts.node.rangeBy(opts);
11692 this.line = range.start.line;
11693 this.column = range.start.column;
11694 this.endLine = range.end.line;
11695 this.endColumn = range.end.column;
11696 }
11697 for(var opt in opts)this[opt] = opts[opt];
11698 }
11699 var _proto = Warning.prototype;
11700 _proto.toString = function toString() {
11701 if (this.node) {
11702 return this.node.error(this.text, {
11703 index: this.index,
11704 plugin: this.plugin,
11705 word: this.word
11706 }).message;
11707 }
11708 if (this.plugin) {
11709 return this.plugin + ": " + this.text;
11710 }
11711 return this.text;
11712 };
11713 return Warning;
11714 }();
11715 var warning$1 = Warning$2$1;
11716 Warning$2$1.default = Warning$2$1;
11717 var Warning$1$1 = warning$1;
11718 var Result$3$1 = /*#__PURE__*/ function() {
11719 function Result(processor2, root2, opts) {
11720 this.processor = processor2;
11721 this.messages = [];
11722 this.root = root2;
11723 this.opts = opts;
11724 this.css = void 0;
11725 this.map = void 0;
11726 }
11727 var _proto = Result.prototype;
11728 _proto.toString = function toString() {
11729 return this.css;
11730 };
11731 _proto.warn = function warn(text, opts) {
11732 if (opts === void 0) opts = {};
11733 if (!opts.plugin) {
11734 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
11735 opts.plugin = this.lastPlugin.postcssPlugin;
11736 }
11737 }
11738 var warning2 = new Warning$1$1(text, opts);
11739 this.messages.push(warning2);
11740 return warning2;
11741 };
11742 _proto.warnings = function warnings() {
11743 return this.messages.filter(function(i2) {
11744 return i2.type === "warning";
11745 });
11746 };
11747 _create_class(Result, [
11748 {
11749 key: "content",
11750 get: function get() {
11751 return this.css;
11752 }
11753 }
11754 ]);
11755 return Result;
11756 }();
11757 var result$1 = Result$3$1;
11758 Result$3$1.default = Result$3$1;
11759 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
11760 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
11761 var BACKSLASH$1 = "\\".charCodeAt(0);
11762 var SLASH$1 = "/".charCodeAt(0);
11763 var NEWLINE$1 = "\n".charCodeAt(0);
11764 var SPACE$1 = " ".charCodeAt(0);
11765 var FEED$1 = "\f".charCodeAt(0);
11766 var TAB$1 = " ".charCodeAt(0);
11767 var CR$1 = "\r".charCodeAt(0);
11768 var OPEN_SQUARE$1 = "[".charCodeAt(0);
11769 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
11770 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
11771 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
11772 var OPEN_CURLY$1 = "{".charCodeAt(0);
11773 var CLOSE_CURLY$1 = "}".charCodeAt(0);
11774 var SEMICOLON$1 = ";".charCodeAt(0);
11775 var ASTERISK$1 = "*".charCodeAt(0);
11776 var COLON$1 = ":".charCodeAt(0);
11777 var AT$1 = "@".charCodeAt(0);
11778 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
11779 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
11780 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
11781 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
11782 var tokenize$1 = function tokenizer(input2, options) {
11783 if (options === void 0) options = {};
11784 var css = input2.css.valueOf();
11785 var ignore = options.ignoreErrors;
11786 var code, next, quote, content, escape;
11787 var escaped, escapePos, prev, n2, currentToken;
11788 var length = css.length;
11789 var pos = 0;
11790 var buffer = [];
11791 var returned = [];
11792 function position() {
11793 return pos;
11794 }
11795 function unclosed(what) {
11796 throw input2.error("Unclosed " + what, pos);
11797 }
11798 function endOfFile() {
11799 return returned.length === 0 && pos >= length;
11800 }
11801 function nextToken(opts) {
11802 if (returned.length) return returned.pop();
11803 if (pos >= length) return;
11804 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
11805 code = css.charCodeAt(pos);
11806 switch(code){
11807 case NEWLINE$1:
11808 case SPACE$1:
11809 case TAB$1:
11810 case CR$1:
11811 case FEED$1:
11812 {
11813 next = pos;
11814 do {
11815 next += 1;
11816 code = css.charCodeAt(next);
11817 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
11818 currentToken = [
11819 "space",
11820 css.slice(pos, next)
11821 ];
11822 pos = next - 1;
11823 break;
11824 }
11825 case OPEN_SQUARE$1:
11826 case CLOSE_SQUARE$1:
11827 case OPEN_CURLY$1:
11828 case CLOSE_CURLY$1:
11829 case COLON$1:
11830 case SEMICOLON$1:
11831 case CLOSE_PARENTHESES$1:
11832 {
11833 var controlChar = String.fromCharCode(code);
11834 currentToken = [
11835 controlChar,
11836 controlChar,
11837 pos
11838 ];
11839 break;
11840 }
11841 case OPEN_PARENTHESES$1:
11842 {
11843 prev = buffer.length ? buffer.pop()[1] : "";
11844 n2 = css.charCodeAt(pos + 1);
11845 if (prev === "url" && n2 !== SINGLE_QUOTE$1 && n2 !== DOUBLE_QUOTE$1 && n2 !== SPACE$1 && n2 !== NEWLINE$1 && n2 !== TAB$1 && n2 !== FEED$1 && n2 !== CR$1) {
11846 next = pos;
11847 do {
11848 escaped = false;
11849 next = css.indexOf(")", next + 1);
11850 if (next === -1) {
11851 if (ignore || ignoreUnclosed) {
11852 next = pos;
11853 break;
11854 } else {
11855 unclosed("bracket");
11856 }
11857 }
11858 escapePos = next;
11859 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
11860 escapePos -= 1;
11861 escaped = !escaped;
11862 }
11863 }while (escaped);
11864 currentToken = [
11865 "brackets",
11866 css.slice(pos, next + 1),
11867 pos,
11868 next
11869 ];
11870 pos = next;
11871 } else {
11872 next = css.indexOf(")", pos + 1);
11873 content = css.slice(pos, next + 1);
11874 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
11875 currentToken = [
11876 "(",
11877 "(",
11878 pos
11879 ];
11880 } else {
11881 currentToken = [
11882 "brackets",
11883 content,
11884 pos,
11885 next
11886 ];
11887 pos = next;
11888 }
11889 }
11890 break;
11891 }
11892 case SINGLE_QUOTE$1:
11893 case DOUBLE_QUOTE$1:
11894 {
11895 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
11896 next = pos;
11897 do {
11898 escaped = false;
11899 next = css.indexOf(quote, next + 1);
11900 if (next === -1) {
11901 if (ignore || ignoreUnclosed) {
11902 next = pos + 1;
11903 break;
11904 } else {
11905 unclosed("string");
11906 }
11907 }
11908 escapePos = next;
11909 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
11910 escapePos -= 1;
11911 escaped = !escaped;
11912 }
11913 }while (escaped);
11914 currentToken = [
11915 "string",
11916 css.slice(pos, next + 1),
11917 pos,
11918 next
11919 ];
11920 pos = next;
11921 break;
11922 }
11923 case AT$1:
11924 {
11925 RE_AT_END$1.lastIndex = pos + 1;
11926 RE_AT_END$1.test(css);
11927 if (RE_AT_END$1.lastIndex === 0) {
11928 next = css.length - 1;
11929 } else {
11930 next = RE_AT_END$1.lastIndex - 2;
11931 }
11932 currentToken = [
11933 "at-word",
11934 css.slice(pos, next + 1),
11935 pos,
11936 next
11937 ];
11938 pos = next;
11939 break;
11940 }
11941 case BACKSLASH$1:
11942 {
11943 next = pos;
11944 escape = true;
11945 while(css.charCodeAt(next + 1) === BACKSLASH$1){
11946 next += 1;
11947 escape = !escape;
11948 }
11949 code = css.charCodeAt(next + 1);
11950 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
11951 next += 1;
11952 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
11953 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
11954 next += 1;
11955 }
11956 if (css.charCodeAt(next + 1) === SPACE$1) {
11957 next += 1;
11958 }
11959 }
11960 }
11961 currentToken = [
11962 "word",
11963 css.slice(pos, next + 1),
11964 pos,
11965 next
11966 ];
11967 pos = next;
11968 break;
11969 }
11970 default:
11971 {
11972 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
11973 next = css.indexOf("*/", pos + 2) + 1;
11974 if (next === 0) {
11975 if (ignore || ignoreUnclosed) {
11976 next = css.length;
11977 } else {
11978 unclosed("comment");
11979 }
11980 }
11981 currentToken = [
11982 "comment",
11983 css.slice(pos, next + 1),
11984 pos,
11985 next
11986 ];
11987 pos = next;
11988 } else {
11989 RE_WORD_END$1.lastIndex = pos + 1;
11990 RE_WORD_END$1.test(css);
11991 if (RE_WORD_END$1.lastIndex === 0) {
11992 next = css.length - 1;
11993 } else {
11994 next = RE_WORD_END$1.lastIndex - 2;
11995 }
11996 currentToken = [
11997 "word",
11998 css.slice(pos, next + 1),
11999 pos,
12000 next
12001 ];
12002 buffer.push(currentToken);
12003 pos = next;
12004 }
12005 break;
12006 }
12007 }
12008 pos++;
12009 return currentToken;
12010 }
12011 function back(token) {
12012 returned.push(token);
12013 }
12014 return {
12015 back: back,
12016 endOfFile: endOfFile,
12017 nextToken: nextToken,
12018 position: position
12019 };
12020 };
12021 var Container$5$1 = container$1;
12022 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12023 _inherits(AtRule, Container$5$1);
12024 function AtRule(defaults) {
12025 var _this;
12026 _this = Container$5$1.call(this, defaults) || this;
12027 _this.type = "atrule";
12028 return _this;
12029 }
12030 var _proto = AtRule.prototype;
12031 _proto.append = function append() {
12032 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12033 children[_key] = arguments[_key];
12034 }
12035 var _Container$5$1_prototype_append;
12036 if (!this.proxyOf.nodes) this.nodes = [];
12037 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12038 this
12039 ], children));
12040 };
12041 _proto.prepend = function prepend() {
12042 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12043 children[_key] = arguments[_key];
12044 }
12045 var _Container$5$1_prototype_prepend;
12046 if (!this.proxyOf.nodes) this.nodes = [];
12047 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12048 this
12049 ], children));
12050 };
12051 return AtRule;
12052 }(Container$5$1);
12053 var atRule$1 = AtRule$3$1;
12054 AtRule$3$1.default = AtRule$3$1;
12055 Container$5$1.registerAtRule(AtRule$3$1);
12056 var Container$4$1 = container$1;
12057 var LazyResult$3$1, Processor$2$1;
12058 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12059 _inherits(Root, Container$4$1);
12060 function Root(defaults) {
12061 var _this;
12062 _this = Container$4$1.call(this, defaults) || this;
12063 _this.type = "root";
12064 if (!_this.nodes) _this.nodes = [];
12065 return _this;
12066 }
12067 var _proto = Root.prototype;
12068 _proto.normalize = function normalize(child, sample, type) {
12069 var nodes = Container$4$1.prototype.normalize.call(this, child);
12070 if (sample) {
12071 if (type === "prepend") {
12072 if (this.nodes.length > 1) {
12073 sample.raws.before = this.nodes[1].raws.before;
12074 } else {
12075 delete sample.raws.before;
12076 }
12077 } else if (this.first !== sample) {
12078 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12079 var node2 = _step.value;
12080 node2.raws.before = sample.raws.before;
12081 }
12082 }
12083 }
12084 return nodes;
12085 };
12086 _proto.removeChild = function removeChild(child, ignore) {
12087 var index2 = this.index(child);
12088 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12089 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12090 }
12091 return Container$4$1.prototype.removeChild.call(this, child);
12092 };
12093 _proto.toResult = function toResult(opts) {
12094 if (opts === void 0) opts = {};
12095 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12096 return lazy.stringify();
12097 };
12098 return Root;
12099 }(Container$4$1);
12100 Root$5$1.registerLazyResult = function(dependant) {
12101 LazyResult$3$1 = dependant;
12102 };
12103 Root$5$1.registerProcessor = function(dependant) {
12104 Processor$2$1 = dependant;
12105 };
12106 var root$1 = Root$5$1;
12107 Root$5$1.default = Root$5$1;
12108 Container$4$1.registerRoot(Root$5$1);
12109 var list$2$1 = {
12110 comma: function comma(string) {
12111 return list$2$1.split(string, [
12112 ","
12113 ], true);
12114 },
12115 space: function space(string) {
12116 var spaces = [
12117 " ",
12118 "\n",
12119 " "
12120 ];
12121 return list$2$1.split(string, spaces);
12122 },
12123 split: function split(string, separators, last) {
12124 var array = [];
12125 var current = "";
12126 var split = false;
12127 var func = 0;
12128 var inQuote = false;
12129 var prevQuote = "";
12130 var escape = false;
12131 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12132 var letter = _step.value;
12133 if (escape) {
12134 escape = false;
12135 } else if (letter === "\\") {
12136 escape = true;
12137 } else if (inQuote) {
12138 if (letter === prevQuote) {
12139 inQuote = false;
12140 }
12141 } else if (letter === '"' || letter === "'") {
12142 inQuote = true;
12143 prevQuote = letter;
12144 } else if (letter === "(") {
12145 func += 1;
12146 } else if (letter === ")") {
12147 if (func > 0) func -= 1;
12148 } else if (func === 0) {
12149 if (separators.includes(letter)) split = true;
12150 }
12151 if (split) {
12152 if (current !== "") array.push(current.trim());
12153 current = "";
12154 split = false;
12155 } else {
12156 current += letter;
12157 }
12158 }
12159 if (last || current !== "") array.push(current.trim());
12160 return array;
12161 }
12162 };
12163 var list_1$1 = list$2$1;
12164 list$2$1.default = list$2$1;
12165 var Container$3$1 = container$1;
12166 var list$1$1 = list_1$1;
12167 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12168 _inherits(Rule, Container$3$1);
12169 function Rule(defaults) {
12170 var _this;
12171 _this = Container$3$1.call(this, defaults) || this;
12172 _this.type = "rule";
12173 if (!_this.nodes) _this.nodes = [];
12174 return _this;
12175 }
12176 _create_class(Rule, [
12177 {
12178 key: "selectors",
12179 get: function get() {
12180 return list$1$1.comma(this.selector);
12181 },
12182 set: function set(values) {
12183 var match = this.selector ? this.selector.match(/,\s*/) : null;
12184 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
12185 this.selector = values.join(sep2);
12186 }
12187 }
12188 ]);
12189 return Rule;
12190 }(Container$3$1);
12191 var rule$1 = Rule$3$1;
12192 Rule$3$1.default = Rule$3$1;
12193 Container$3$1.registerRule(Rule$3$1);
12194 var Declaration$2$1 = declaration$1;
12195 var tokenizer2$1 = tokenize$1;
12196 var Comment$2$1 = comment$1;
12197 var AtRule$2$1 = atRule$1;
12198 var Root$4$1 = root$1;
12199 var Rule$2$1 = rule$1;
12200 var SAFE_COMMENT_NEIGHBOR$1 = {
12201 empty: true,
12202 space: true
12203 };
12204 function findLastWithPosition$1(tokens) {
12205 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12206 var token = tokens[i2];
12207 var pos = token[3] || token[2];
12208 if (pos) return pos;
12209 }
12210 }
12211 var Parser$1$1 = /*#__PURE__*/ function() {
12212 function Parser(input2) {
12213 this.input = input2;
12214 this.root = new Root$4$1();
12215 this.current = this.root;
12216 this.spaces = "";
12217 this.semicolon = false;
12218 this.createTokenizer();
12219 this.root.source = {
12220 input: input2,
12221 start: {
12222 column: 1,
12223 line: 1,
12224 offset: 0
12225 }
12226 };
12227 }
12228 var _proto = Parser.prototype;
12229 _proto.atrule = function atrule(token) {
12230 var node2 = new AtRule$2$1();
12231 node2.name = token[1].slice(1);
12232 if (node2.name === "") {
12233 this.unnamedAtrule(node2, token);
12234 }
12235 this.init(node2, token[2]);
12236 var type;
12237 var prev;
12238 var shift;
12239 var last = false;
12240 var open = false;
12241 var params = [];
12242 var brackets = [];
12243 while(!this.tokenizer.endOfFile()){
12244 token = this.tokenizer.nextToken();
12245 type = token[0];
12246 if (type === "(" || type === "[") {
12247 brackets.push(type === "(" ? ")" : "]");
12248 } else if (type === "{" && brackets.length > 0) {
12249 brackets.push("}");
12250 } else if (type === brackets[brackets.length - 1]) {
12251 brackets.pop();
12252 }
12253 if (brackets.length === 0) {
12254 if (type === ";") {
12255 node2.source.end = this.getPosition(token[2]);
12256 node2.source.end.offset++;
12257 this.semicolon = true;
12258 break;
12259 } else if (type === "{") {
12260 open = true;
12261 break;
12262 } else if (type === "}") {
12263 if (params.length > 0) {
12264 shift = params.length - 1;
12265 prev = params[shift];
12266 while(prev && prev[0] === "space"){
12267 prev = params[--shift];
12268 }
12269 if (prev) {
12270 node2.source.end = this.getPosition(prev[3] || prev[2]);
12271 node2.source.end.offset++;
12272 }
12273 }
12274 this.end(token);
12275 break;
12276 } else {
12277 params.push(token);
12278 }
12279 } else {
12280 params.push(token);
12281 }
12282 if (this.tokenizer.endOfFile()) {
12283 last = true;
12284 break;
12285 }
12286 }
12287 node2.raws.between = this.spacesAndCommentsFromEnd(params);
12288 if (params.length) {
12289 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
12290 this.raw(node2, "params", params);
12291 if (last) {
12292 token = params[params.length - 1];
12293 node2.source.end = this.getPosition(token[3] || token[2]);
12294 node2.source.end.offset++;
12295 this.spaces = node2.raws.between;
12296 node2.raws.between = "";
12297 }
12298 } else {
12299 node2.raws.afterName = "";
12300 node2.params = "";
12301 }
12302 if (open) {
12303 node2.nodes = [];
12304 this.current = node2;
12305 }
12306 };
12307 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
12308 var colon = this.colon(tokens);
12309 if (colon === false) return;
12310 var founded = 0;
12311 var token;
12312 for(var j = colon - 1; j >= 0; j--){
12313 token = tokens[j];
12314 if (token[0] !== "space") {
12315 founded += 1;
12316 if (founded === 2) break;
12317 }
12318 }
12319 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
12320 };
12321 _proto.colon = function colon(tokens) {
12322 var brackets = 0;
12323 var token, type, prev;
12324 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
12325 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
12326 token = element;
12327 type = token[0];
12328 if (type === "(") {
12329 brackets += 1;
12330 }
12331 if (type === ")") {
12332 brackets -= 1;
12333 }
12334 if (brackets === 0 && type === ":") {
12335 if (!prev) {
12336 this.doubleColon(token);
12337 } else if (prev[0] === "word" && prev[1] === "progid") {
12338 continue;
12339 } else {
12340 return i2;
12341 }
12342 }
12343 prev = token;
12344 }
12345 return false;
12346 };
12347 _proto.comment = function comment(token) {
12348 var node2 = new Comment$2$1();
12349 this.init(node2, token[2]);
12350 node2.source.end = this.getPosition(token[3] || token[2]);
12351 node2.source.end.offset++;
12352 var text = token[1].slice(2, -2);
12353 if (/^\s*$/.test(text)) {
12354 node2.text = "";
12355 node2.raws.left = text;
12356 node2.raws.right = "";
12357 } else {
12358 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
12359 node2.text = match[2];
12360 node2.raws.left = match[1];
12361 node2.raws.right = match[3];
12362 }
12363 };
12364 _proto.createTokenizer = function createTokenizer() {
12365 this.tokenizer = tokenizer2$1(this.input);
12366 };
12367 _proto.decl = function decl(tokens, customProperty) {
12368 var node2 = new Declaration$2$1();
12369 this.init(node2, tokens[0][2]);
12370 var last = tokens[tokens.length - 1];
12371 if (last[0] === ";") {
12372 this.semicolon = true;
12373 tokens.pop();
12374 }
12375 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
12376 node2.source.end.offset++;
12377 while(tokens[0][0] !== "word"){
12378 if (tokens.length === 1) this.unknownWord(tokens);
12379 node2.raws.before += tokens.shift()[1];
12380 }
12381 node2.source.start = this.getPosition(tokens[0][2]);
12382 node2.prop = "";
12383 while(tokens.length){
12384 var type = tokens[0][0];
12385 if (type === ":" || type === "space" || type === "comment") {
12386 break;
12387 }
12388 node2.prop += tokens.shift()[1];
12389 }
12390 node2.raws.between = "";
12391 var token;
12392 while(tokens.length){
12393 token = tokens.shift();
12394 if (token[0] === ":") {
12395 node2.raws.between += token[1];
12396 break;
12397 } else {
12398 if (token[0] === "word" && /\w/.test(token[1])) {
12399 this.unknownWord([
12400 token
12401 ]);
12402 }
12403 node2.raws.between += token[1];
12404 }
12405 }
12406 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
12407 node2.raws.before += node2.prop[0];
12408 node2.prop = node2.prop.slice(1);
12409 }
12410 var firstSpaces = [];
12411 var next;
12412 while(tokens.length){
12413 next = tokens[0][0];
12414 if (next !== "space" && next !== "comment") break;
12415 firstSpaces.push(tokens.shift());
12416 }
12417 this.precheckMissedSemicolon(tokens);
12418 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12419 token = tokens[i2];
12420 if (token[1].toLowerCase() === "!important") {
12421 node2.important = true;
12422 var string = this.stringFrom(tokens, i2);
12423 string = this.spacesFromEnd(tokens) + string;
12424 if (string !== " !important") node2.raws.important = string;
12425 break;
12426 } else if (token[1].toLowerCase() === "important") {
12427 var cache = tokens.slice(0);
12428 var str = "";
12429 for(var j = i2; j > 0; j--){
12430 var type1 = cache[j][0];
12431 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
12432 break;
12433 }
12434 str = cache.pop()[1] + str;
12435 }
12436 if (str.trim().indexOf("!") === 0) {
12437 node2.important = true;
12438 node2.raws.important = str;
12439 tokens = cache;
12440 }
12441 }
12442 if (token[0] !== "space" && token[0] !== "comment") {
12443 break;
12444 }
12445 }
12446 var hasWord = tokens.some(function(i2) {
12447 return i2[0] !== "space" && i2[0] !== "comment";
12448 });
12449 if (hasWord) {
12450 node2.raws.between += firstSpaces.map(function(i2) {
12451 return i2[1];
12452 }).join("");
12453 firstSpaces = [];
12454 }
12455 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
12456 if (node2.value.includes(":") && !customProperty) {
12457 this.checkMissedSemicolon(tokens);
12458 }
12459 };
12460 _proto.doubleColon = function doubleColon(token) {
12461 throw this.input.error("Double colon", {
12462 offset: token[2]
12463 }, {
12464 offset: token[2] + token[1].length
12465 });
12466 };
12467 _proto.emptyRule = function emptyRule(token) {
12468 var node2 = new Rule$2$1();
12469 this.init(node2, token[2]);
12470 node2.selector = "";
12471 node2.raws.between = "";
12472 this.current = node2;
12473 };
12474 _proto.end = function end(token) {
12475 if (this.current.nodes && this.current.nodes.length) {
12476 this.current.raws.semicolon = this.semicolon;
12477 }
12478 this.semicolon = false;
12479 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12480 this.spaces = "";
12481 if (this.current.parent) {
12482 this.current.source.end = this.getPosition(token[2]);
12483 this.current.source.end.offset++;
12484 this.current = this.current.parent;
12485 } else {
12486 this.unexpectedClose(token);
12487 }
12488 };
12489 _proto.endFile = function endFile() {
12490 if (this.current.parent) this.unclosedBlock();
12491 if (this.current.nodes && this.current.nodes.length) {
12492 this.current.raws.semicolon = this.semicolon;
12493 }
12494 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12495 this.root.source.end = this.getPosition(this.tokenizer.position());
12496 };
12497 _proto.freeSemicolon = function freeSemicolon(token) {
12498 this.spaces += token[1];
12499 if (this.current.nodes) {
12500 var prev = this.current.nodes[this.current.nodes.length - 1];
12501 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
12502 prev.raws.ownSemicolon = this.spaces;
12503 this.spaces = "";
12504 }
12505 }
12506 };
12507 // Helpers
12508 _proto.getPosition = function getPosition(offset) {
12509 var pos = this.input.fromOffset(offset);
12510 return {
12511 column: pos.col,
12512 line: pos.line,
12513 offset: offset
12514 };
12515 };
12516 _proto.init = function init(node2, offset) {
12517 this.current.push(node2);
12518 node2.source = {
12519 input: this.input,
12520 start: this.getPosition(offset)
12521 };
12522 node2.raws.before = this.spaces;
12523 this.spaces = "";
12524 if (node2.type !== "comment") this.semicolon = false;
12525 };
12526 _proto.other = function other(start) {
12527 var end = false;
12528 var type = null;
12529 var colon = false;
12530 var bracket = null;
12531 var brackets = [];
12532 var customProperty = start[1].startsWith("--");
12533 var tokens = [];
12534 var token = start;
12535 while(token){
12536 type = token[0];
12537 tokens.push(token);
12538 if (type === "(" || type === "[") {
12539 if (!bracket) bracket = token;
12540 brackets.push(type === "(" ? ")" : "]");
12541 } else if (customProperty && colon && type === "{") {
12542 if (!bracket) bracket = token;
12543 brackets.push("}");
12544 } else if (brackets.length === 0) {
12545 if (type === ";") {
12546 if (colon) {
12547 this.decl(tokens, customProperty);
12548 return;
12549 } else {
12550 break;
12551 }
12552 } else if (type === "{") {
12553 this.rule(tokens);
12554 return;
12555 } else if (type === "}") {
12556 this.tokenizer.back(tokens.pop());
12557 end = true;
12558 break;
12559 } else if (type === ":") {
12560 colon = true;
12561 }
12562 } else if (type === brackets[brackets.length - 1]) {
12563 brackets.pop();
12564 if (brackets.length === 0) bracket = null;
12565 }
12566 token = this.tokenizer.nextToken();
12567 }
12568 if (this.tokenizer.endOfFile()) end = true;
12569 if (brackets.length > 0) this.unclosedBracket(bracket);
12570 if (end && colon) {
12571 if (!customProperty) {
12572 while(tokens.length){
12573 token = tokens[tokens.length - 1][0];
12574 if (token !== "space" && token !== "comment") break;
12575 this.tokenizer.back(tokens.pop());
12576 }
12577 }
12578 this.decl(tokens, customProperty);
12579 } else {
12580 this.unknownWord(tokens);
12581 }
12582 };
12583 _proto.parse = function parse() {
12584 var token;
12585 while(!this.tokenizer.endOfFile()){
12586 token = this.tokenizer.nextToken();
12587 switch(token[0]){
12588 case "space":
12589 this.spaces += token[1];
12590 break;
12591 case ";":
12592 this.freeSemicolon(token);
12593 break;
12594 case "}":
12595 this.end(token);
12596 break;
12597 case "comment":
12598 this.comment(token);
12599 break;
12600 case "at-word":
12601 this.atrule(token);
12602 break;
12603 case "{":
12604 this.emptyRule(token);
12605 break;
12606 default:
12607 this.other(token);
12608 break;
12609 }
12610 }
12611 this.endFile();
12612 };
12613 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
12614 _proto.raw = function raw(node2, prop, tokens, customProperty) {
12615 var token, type;
12616 var length = tokens.length;
12617 var value = "";
12618 var clean = true;
12619 var next, prev;
12620 for(var i2 = 0; i2 < length; i2 += 1){
12621 token = tokens[i2];
12622 type = token[0];
12623 if (type === "space" && i2 === length - 1 && !customProperty) {
12624 clean = false;
12625 } else if (type === "comment") {
12626 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
12627 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
12628 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
12629 if (value.slice(-1) === ",") {
12630 clean = false;
12631 } else {
12632 value += token[1];
12633 }
12634 } else {
12635 clean = false;
12636 }
12637 } else {
12638 value += token[1];
12639 }
12640 }
12641 if (!clean) {
12642 var raw = tokens.reduce(function(all, i2) {
12643 return all + i2[1];
12644 }, "");
12645 node2.raws[prop] = {
12646 raw: raw,
12647 value: value
12648 };
12649 }
12650 node2[prop] = value;
12651 };
12652 _proto.rule = function rule(tokens) {
12653 tokens.pop();
12654 var node2 = new Rule$2$1();
12655 this.init(node2, tokens[0][2]);
12656 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
12657 this.raw(node2, "selector", tokens);
12658 this.current = node2;
12659 };
12660 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
12661 var lastTokenType;
12662 var spaces = "";
12663 while(tokens.length){
12664 lastTokenType = tokens[tokens.length - 1][0];
12665 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
12666 spaces = tokens.pop()[1] + spaces;
12667 }
12668 return spaces;
12669 };
12670 // Errors
12671 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
12672 var next;
12673 var spaces = "";
12674 while(tokens.length){
12675 next = tokens[0][0];
12676 if (next !== "space" && next !== "comment") break;
12677 spaces += tokens.shift()[1];
12678 }
12679 return spaces;
12680 };
12681 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
12682 var lastTokenType;
12683 var spaces = "";
12684 while(tokens.length){
12685 lastTokenType = tokens[tokens.length - 1][0];
12686 if (lastTokenType !== "space") break;
12687 spaces = tokens.pop()[1] + spaces;
12688 }
12689 return spaces;
12690 };
12691 _proto.stringFrom = function stringFrom(tokens, from) {
12692 var result2 = "";
12693 for(var i2 = from; i2 < tokens.length; i2++){
12694 result2 += tokens[i2][1];
12695 }
12696 tokens.splice(from, tokens.length - from);
12697 return result2;
12698 };
12699 _proto.unclosedBlock = function unclosedBlock() {
12700 var pos = this.current.source.start;
12701 throw this.input.error("Unclosed block", pos.line, pos.column);
12702 };
12703 _proto.unclosedBracket = function unclosedBracket(bracket) {
12704 throw this.input.error("Unclosed bracket", {
12705 offset: bracket[2]
12706 }, {
12707 offset: bracket[2] + 1
12708 });
12709 };
12710 _proto.unexpectedClose = function unexpectedClose(token) {
12711 throw this.input.error("Unexpected }", {
12712 offset: token[2]
12713 }, {
12714 offset: token[2] + 1
12715 });
12716 };
12717 _proto.unknownWord = function unknownWord(tokens) {
12718 throw this.input.error("Unknown word", {
12719 offset: tokens[0][2]
12720 }, {
12721 offset: tokens[0][2] + tokens[0][1].length
12722 });
12723 };
12724 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
12725 throw this.input.error("At-rule without name", {
12726 offset: token[2]
12727 }, {
12728 offset: token[2] + token[1].length
12729 });
12730 };
12731 return Parser;
12732 }();
12733 var parser$1 = Parser$1$1;
12734 var Container$2$1 = container$1;
12735 var Parser2$1 = parser$1;
12736 var Input$2$1 = input$1;
12737 function parse$3$1(css, opts) {
12738 var input2 = new Input$2$1(css, opts);
12739 var parser2 = new Parser2$1(input2);
12740 try {
12741 parser2.parse();
12742 } catch (e2) {
12743 if (true) {
12744 if (e2.name === "CssSyntaxError" && opts && opts.from) {
12745 if (/\.scss$/i.test(opts.from)) {
12746 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
12747 } else if (/\.sass/i.test(opts.from)) {
12748 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
12749 } else if (/\.less$/i.test(opts.from)) {
12750 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
12751 }
12752 }
12753 }
12754 throw e2;
12755 }
12756 return parser2.root;
12757 }
12758 var parse_1$1 = parse$3$1;
12759 parse$3$1.default = parse$3$1;
12760 Container$2$1.registerParse(parse$3$1);
12761 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
12762 var MapGenerator$1$1 = mapGenerator$1;
12763 var stringify$2$1 = stringify_1$1;
12764 var Container$1$1 = container$1;
12765 var Document$2$1 = document$1$1;
12766 var warnOnce$1$1 = warnOnce$2$1;
12767 var Result$2$1 = result$1;
12768 var parse$2$1 = parse_1$1;
12769 var Root$3$1 = root$1;
12770 var TYPE_TO_CLASS_NAME$1 = {
12771 atrule: "AtRule",
12772 comment: "Comment",
12773 decl: "Declaration",
12774 document: "Document",
12775 root: "Root",
12776 rule: "Rule"
12777 };
12778 var PLUGIN_PROPS$1 = {
12779 AtRule: true,
12780 AtRuleExit: true,
12781 Comment: true,
12782 CommentExit: true,
12783 Declaration: true,
12784 DeclarationExit: true,
12785 Document: true,
12786 DocumentExit: true,
12787 Once: true,
12788 OnceExit: true,
12789 postcssPlugin: true,
12790 prepare: true,
12791 Root: true,
12792 RootExit: true,
12793 Rule: true,
12794 RuleExit: true
12795 };
12796 var NOT_VISITORS$1 = {
12797 Once: true,
12798 postcssPlugin: true,
12799 prepare: true
12800 };
12801 var CHILDREN$1 = 0;
12802 function isPromise$1(obj) {
12803 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
12804 }
12805 function getEvents$1(node2) {
12806 var key = false;
12807 var type = TYPE_TO_CLASS_NAME$1[node2.type];
12808 if (node2.type === "decl") {
12809 key = node2.prop.toLowerCase();
12810 } else if (node2.type === "atrule") {
12811 key = node2.name.toLowerCase();
12812 }
12813 if (key && node2.append) {
12814 return [
12815 type,
12816 type + "-" + key,
12817 CHILDREN$1,
12818 type + "Exit",
12819 type + "Exit-" + key
12820 ];
12821 } else if (key) {
12822 return [
12823 type,
12824 type + "-" + key,
12825 type + "Exit",
12826 type + "Exit-" + key
12827 ];
12828 } else if (node2.append) {
12829 return [
12830 type,
12831 CHILDREN$1,
12832 type + "Exit"
12833 ];
12834 } else {
12835 return [
12836 type,
12837 type + "Exit"
12838 ];
12839 }
12840 }
12841 function toStack$1(node2) {
12842 var events;
12843 if (node2.type === "document") {
12844 events = [
12845 "Document",
12846 CHILDREN$1,
12847 "DocumentExit"
12848 ];
12849 } else if (node2.type === "root") {
12850 events = [
12851 "Root",
12852 CHILDREN$1,
12853 "RootExit"
12854 ];
12855 } else {
12856 events = getEvents$1(node2);
12857 }
12858 return {
12859 eventIndex: 0,
12860 events: events,
12861 iterator: 0,
12862 node: node2,
12863 visitorIndex: 0,
12864 visitors: []
12865 };
12866 }
12867 function cleanMarks$1(node2) {
12868 node2[isClean$3] = false;
12869 if (node2.nodes) node2.nodes.forEach(function(i2) {
12870 return cleanMarks$1(i2);
12871 });
12872 return node2;
12873 }
12874 var postcss$2$1 = {};
12875 var LazyResult$2$1 = /*#__PURE__*/ function() {
12876 function LazyResult(processor2, css, opts) {
12877 var _this = this;
12878 this.stringified = false;
12879 this.processed = false;
12880 var root2;
12881 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
12882 root2 = cleanMarks$1(css);
12883 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
12884 root2 = cleanMarks$1(css.root);
12885 if (css.map) {
12886 if (typeof opts.map === "undefined") opts.map = {};
12887 if (!opts.map.inline) opts.map.inline = false;
12888 opts.map.prev = css.map;
12889 }
12890 } else {
12891 var parser2 = parse$2$1;
12892 if (opts.syntax) parser2 = opts.syntax.parse;
12893 if (opts.parser) parser2 = opts.parser;
12894 if (parser2.parse) parser2 = parser2.parse;
12895 try {
12896 root2 = parser2(css, opts);
12897 } catch (error) {
12898 this.processed = true;
12899 this.error = error;
12900 }
12901 if (root2 && !root2[my$3]) {
12902 Container$1$1.rebuild(root2);
12903 }
12904 }
12905 this.result = new Result$2$1(processor2, root2, opts);
12906 this.helpers = _extends({}, postcss$2$1, {
12907 postcss: postcss$2$1,
12908 result: this.result
12909 });
12910 this.plugins = this.processor.plugins.map(function(plugin22) {
12911 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
12912 return _extends({}, plugin22, plugin22.prepare(_this.result));
12913 } else {
12914 return plugin22;
12915 }
12916 });
12917 }
12918 var _proto = LazyResult.prototype;
12919 _proto.async = function async() {
12920 if (this.error) return Promise.reject(this.error);
12921 if (this.processed) return Promise.resolve(this.result);
12922 if (!this.processing) {
12923 this.processing = this.runAsync();
12924 }
12925 return this.processing;
12926 };
12927 _proto.catch = function _catch(onRejected) {
12928 return this.async().catch(onRejected);
12929 };
12930 _proto.finally = function _finally(onFinally) {
12931 return this.async().then(onFinally, onFinally);
12932 };
12933 _proto.getAsyncError = function getAsyncError() {
12934 throw new Error("Use process(css).then(cb) to work with async plugins");
12935 };
12936 _proto.handleError = function handleError(error, node2) {
12937 var plugin22 = this.result.lastPlugin;
12938 try {
12939 if (node2) node2.addToError(error);
12940 this.error = error;
12941 if (error.name === "CssSyntaxError" && !error.plugin) {
12942 error.plugin = plugin22.postcssPlugin;
12943 error.setMessage();
12944 } else if (plugin22.postcssVersion) {
12945 if (true) {
12946 var pluginName = plugin22.postcssPlugin;
12947 var pluginVer = plugin22.postcssVersion;
12948 var runtimeVer = this.result.processor.version;
12949 var a2 = pluginVer.split(".");
12950 var b = runtimeVer.split(".");
12951 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
12952 console.error("Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below.");
12953 }
12954 }
12955 }
12956 } catch (err) {
12957 if (console && console.error) console.error(err);
12958 }
12959 return error;
12960 };
12961 _proto.prepareVisitors = function prepareVisitors() {
12962 var _this = this;
12963 this.listeners = {};
12964 var add = function(plugin22, type, cb) {
12965 if (!_this.listeners[type]) _this.listeners[type] = [];
12966 _this.listeners[type].push([
12967 plugin22,
12968 cb
12969 ]);
12970 };
12971 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
12972 var plugin22 = _step.value;
12973 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
12974 for(var event in plugin22){
12975 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
12976 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
12977 }
12978 if (!NOT_VISITORS$1[event]) {
12979 if (_type_of(plugin22[event]) === "object") {
12980 for(var filter in plugin22[event]){
12981 if (filter === "*") {
12982 add(plugin22, event, plugin22[event][filter]);
12983 } else {
12984 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
12985 }
12986 }
12987 } else if (typeof plugin22[event] === "function") {
12988 add(plugin22, event, plugin22[event]);
12989 }
12990 }
12991 }
12992 }
12993 }
12994 this.hasListener = Object.keys(this.listeners).length > 0;
12995 };
12996 _proto.runAsync = function runAsync() {
12997 var _this = this;
12998 return _async_to_generator(function() {
12999 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13000 return _ts_generator(this, function(_state) {
13001 switch(_state.label){
13002 case 0:
13003 _this.plugin = 0;
13004 i2 = 0;
13005 _state.label = 1;
13006 case 1:
13007 if (!(i2 < _this.plugins.length)) return [
13008 3,
13009 6
13010 ];
13011 plugin22 = _this.plugins[i2];
13012 promise = _this.runOnRoot(plugin22);
13013 if (!isPromise$1(promise)) return [
13014 3,
13015 5
13016 ];
13017 _state.label = 2;
13018 case 2:
13019 _state.trys.push([
13020 2,
13021 4,
13022 ,
13023 5
13024 ]);
13025 return [
13026 4,
13027 promise
13028 ];
13029 case 3:
13030 _state.sent();
13031 return [
13032 3,
13033 5
13034 ];
13035 case 4:
13036 error = _state.sent();
13037 throw _this.handleError(error);
13038 case 5:
13039 i2++;
13040 return [
13041 3,
13042 1
13043 ];
13044 case 6:
13045 _this.prepareVisitors();
13046 if (!_this.hasListener) return [
13047 3,
13048 18
13049 ];
13050 root2 = _this.result.root;
13051 _state.label = 7;
13052 case 7:
13053 if (!!root2[isClean$3]) return [
13054 3,
13055 14
13056 ];
13057 root2[isClean$3] = true;
13058 stack = [
13059 toStack$1(root2)
13060 ];
13061 _state.label = 8;
13062 case 8:
13063 if (!(stack.length > 0)) return [
13064 3,
13065 13
13066 ];
13067 promise1 = _this.visitTick(stack);
13068 if (!isPromise$1(promise1)) return [
13069 3,
13070 12
13071 ];
13072 _state.label = 9;
13073 case 9:
13074 _state.trys.push([
13075 9,
13076 11,
13077 ,
13078 12
13079 ]);
13080 return [
13081 4,
13082 promise1
13083 ];
13084 case 10:
13085 _state.sent();
13086 return [
13087 3,
13088 12
13089 ];
13090 case 11:
13091 e2 = _state.sent();
13092 node2 = stack[stack.length - 1].node;
13093 throw _this.handleError(e2, node2);
13094 case 12:
13095 return [
13096 3,
13097 8
13098 ];
13099 case 13:
13100 return [
13101 3,
13102 7
13103 ];
13104 case 14:
13105 if (!_this.listeners.OnceExit) return [
13106 3,
13107 18
13108 ];
13109 _loop = function() {
13110 var _step_value, plugin22, visitor, roots, e2;
13111 return _ts_generator(this, function(_state) {
13112 switch(_state.label){
13113 case 0:
13114 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13115 _this.result.lastPlugin = plugin22;
13116 _state.label = 1;
13117 case 1:
13118 _state.trys.push([
13119 1,
13120 6,
13121 ,
13122 7
13123 ]);
13124 if (!(root2.type === "document")) return [
13125 3,
13126 3
13127 ];
13128 roots = root2.nodes.map(function(subRoot) {
13129 return visitor(subRoot, _this.helpers);
13130 });
13131 return [
13132 4,
13133 Promise.all(roots)
13134 ];
13135 case 2:
13136 _state.sent();
13137 return [
13138 3,
13139 5
13140 ];
13141 case 3:
13142 return [
13143 4,
13144 visitor(root2, _this.helpers)
13145 ];
13146 case 4:
13147 _state.sent();
13148 _state.label = 5;
13149 case 5:
13150 return [
13151 3,
13152 7
13153 ];
13154 case 6:
13155 e2 = _state.sent();
13156 throw _this.handleError(e2);
13157 case 7:
13158 return [
13159 2
13160 ];
13161 }
13162 });
13163 };
13164 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13165 _state.label = 15;
13166 case 15:
13167 if (!!(_step = _iterator()).done) return [
13168 3,
13169 18
13170 ];
13171 return [
13172 5,
13173 _ts_values(_loop())
13174 ];
13175 case 16:
13176 _state.sent();
13177 _state.label = 17;
13178 case 17:
13179 return [
13180 3,
13181 15
13182 ];
13183 case 18:
13184 _this.processed = true;
13185 return [
13186 2,
13187 _this.stringify()
13188 ];
13189 }
13190 });
13191 })();
13192 };
13193 _proto.runOnRoot = function runOnRoot(plugin22) {
13194 var _this = this;
13195 this.result.lastPlugin = plugin22;
13196 try {
13197 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
13198 if (this.result.root.type === "document") {
13199 var roots = this.result.root.nodes.map(function(root2) {
13200 return plugin22.Once(root2, _this.helpers);
13201 });
13202 if (isPromise$1(roots[0])) {
13203 return Promise.all(roots);
13204 }
13205 return roots;
13206 }
13207 return plugin22.Once(this.result.root, this.helpers);
13208 } else if (typeof plugin22 === "function") {
13209 return plugin22(this.result.root, this.result);
13210 }
13211 } catch (error) {
13212 throw this.handleError(error);
13213 }
13214 };
13215 _proto.stringify = function stringify() {
13216 if (this.error) throw this.error;
13217 if (this.stringified) return this.result;
13218 this.stringified = true;
13219 this.sync();
13220 var opts = this.result.opts;
13221 var str = stringify$2$1;
13222 if (opts.syntax) str = opts.syntax.stringify;
13223 if (opts.stringifier) str = opts.stringifier;
13224 if (str.stringify) str = str.stringify;
13225 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
13226 var data = map.generate();
13227 this.result.css = data[0];
13228 this.result.map = data[1];
13229 return this.result;
13230 };
13231 _proto.sync = function sync() {
13232 if (this.error) throw this.error;
13233 if (this.processed) return this.result;
13234 this.processed = true;
13235 if (this.processing) {
13236 throw this.getAsyncError();
13237 }
13238 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13239 var plugin22 = _step.value;
13240 var promise = this.runOnRoot(plugin22);
13241 if (isPromise$1(promise)) {
13242 throw this.getAsyncError();
13243 }
13244 }
13245 this.prepareVisitors();
13246 if (this.hasListener) {
13247 var root2 = this.result.root;
13248 while(!root2[isClean$3]){
13249 root2[isClean$3] = true;
13250 this.walkSync(root2);
13251 }
13252 if (this.listeners.OnceExit) {
13253 if (root2.type === "document") {
13254 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
13255 var subRoot = _step1.value;
13256 this.visitSync(this.listeners.OnceExit, subRoot);
13257 }
13258 } else {
13259 this.visitSync(this.listeners.OnceExit, root2);
13260 }
13261 }
13262 }
13263 return this.result;
13264 };
13265 _proto.then = function then(onFulfilled, onRejected) {
13266 if (true) {
13267 if (!("from" in this.opts)) {
13268 warnOnce$1$1("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.");
13269 }
13270 }
13271 return this.async().then(onFulfilled, onRejected);
13272 };
13273 _proto.toString = function toString() {
13274 return this.css;
13275 };
13276 _proto.visitSync = function visitSync(visitors, node2) {
13277 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
13278 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13279 this.result.lastPlugin = plugin22;
13280 var promise = void 0;
13281 try {
13282 promise = visitor(node2, this.helpers);
13283 } catch (e2) {
13284 throw this.handleError(e2, node2.proxyOf);
13285 }
13286 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13287 return true;
13288 }
13289 if (isPromise$1(promise)) {
13290 throw this.getAsyncError();
13291 }
13292 }
13293 };
13294 _proto.visitTick = function visitTick(stack) {
13295 var visit2 = stack[stack.length - 1];
13296 var node2 = visit2.node, visitors = visit2.visitors;
13297 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13298 stack.pop();
13299 return;
13300 }
13301 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
13302 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
13303 visit2.visitorIndex += 1;
13304 if (visit2.visitorIndex === visitors.length) {
13305 visit2.visitors = [];
13306 visit2.visitorIndex = 0;
13307 }
13308 this.result.lastPlugin = plugin22;
13309 try {
13310 return visitor(node2.toProxy(), this.helpers);
13311 } catch (e2) {
13312 throw this.handleError(e2, node2);
13313 }
13314 }
13315 if (visit2.iterator !== 0) {
13316 var iterator = visit2.iterator;
13317 var child;
13318 while(child = node2.nodes[node2.indexes[iterator]]){
13319 node2.indexes[iterator] += 1;
13320 if (!child[isClean$3]) {
13321 child[isClean$3] = true;
13322 stack.push(toStack$1(child));
13323 return;
13324 }
13325 }
13326 visit2.iterator = 0;
13327 delete node2.indexes[iterator];
13328 }
13329 var events = visit2.events;
13330 while(visit2.eventIndex < events.length){
13331 var event = events[visit2.eventIndex];
13332 visit2.eventIndex += 1;
13333 if (event === CHILDREN$1) {
13334 if (node2.nodes && node2.nodes.length) {
13335 node2[isClean$3] = true;
13336 visit2.iterator = node2.getIterator();
13337 }
13338 return;
13339 } else if (this.listeners[event]) {
13340 visit2.visitors = this.listeners[event];
13341 return;
13342 }
13343 }
13344 stack.pop();
13345 };
13346 _proto.walkSync = function walkSync(node2) {
13347 var _this = this;
13348 node2[isClean$3] = true;
13349 var events = getEvents$1(node2);
13350 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
13351 var event = _step.value;
13352 if (event === CHILDREN$1) {
13353 if (node2.nodes) {
13354 node2.each(function(child) {
13355 if (!child[isClean$3]) _this.walkSync(child);
13356 });
13357 }
13358 } else {
13359 var visitors = this.listeners[event];
13360 if (visitors) {
13361 if (this.visitSync(visitors, node2.toProxy())) return;
13362 }
13363 }
13364 }
13365 };
13366 _proto.warnings = function warnings() {
13367 return this.sync().warnings();
13368 };
13369 _create_class(LazyResult, [
13370 {
13371 key: "content",
13372 get: function get() {
13373 return this.stringify().content;
13374 }
13375 },
13376 {
13377 key: "css",
13378 get: function get() {
13379 return this.stringify().css;
13380 }
13381 },
13382 {
13383 key: "map",
13384 get: function get() {
13385 return this.stringify().map;
13386 }
13387 },
13388 {
13389 key: "messages",
13390 get: function get() {
13391 return this.sync().messages;
13392 }
13393 },
13394 {
13395 key: "opts",
13396 get: function get() {
13397 return this.result.opts;
13398 }
13399 },
13400 {
13401 key: "processor",
13402 get: function get() {
13403 return this.result.processor;
13404 }
13405 },
13406 {
13407 key: "root",
13408 get: function get() {
13409 return this.sync().root;
13410 }
13411 },
13412 {
13413 key: Symbol.toStringTag,
13414 get: function get() {
13415 return "LazyResult";
13416 }
13417 }
13418 ]);
13419 return LazyResult;
13420 }();
13421 LazyResult$2$1.registerPostcss = function(dependant) {
13422 postcss$2$1 = dependant;
13423 };
13424 var lazyResult$1 = LazyResult$2$1;
13425 LazyResult$2$1.default = LazyResult$2$1;
13426 Root$3$1.registerLazyResult(LazyResult$2$1);
13427 Document$2$1.registerLazyResult(LazyResult$2$1);
13428 var MapGenerator2$1 = mapGenerator$1;
13429 var stringify$1$1 = stringify_1$1;
13430 var warnOnce2$1 = warnOnce$2$1;
13431 var parse$1$1 = parse_1$1;
13432 var Result$1$1 = result$1;
13433 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
13434 function NoWorkResult(processor2, css, opts) {
13435 css = css.toString();
13436 this.stringified = false;
13437 this._processor = processor2;
13438 this._css = css;
13439 this._opts = opts;
13440 this._map = void 0;
13441 var root2;
13442 var str = stringify$1$1;
13443 this.result = new Result$1$1(this._processor, root2, this._opts);
13444 this.result.css = css;
13445 var self = this;
13446 Object.defineProperty(this.result, "root", {
13447 get: function get() {
13448 return self.root;
13449 }
13450 });
13451 var map = new MapGenerator2$1(str, root2, this._opts, css);
13452 if (map.isMap()) {
13453 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
13454 if (generatedCSS) {
13455 this.result.css = generatedCSS;
13456 }
13457 if (generatedMap) {
13458 this.result.map = generatedMap;
13459 }
13460 } else {
13461 map.clearAnnotation();
13462 this.result.css = map.css;
13463 }
13464 }
13465 var _proto = NoWorkResult.prototype;
13466 _proto.async = function async() {
13467 if (this.error) return Promise.reject(this.error);
13468 return Promise.resolve(this.result);
13469 };
13470 _proto.catch = function _catch(onRejected) {
13471 return this.async().catch(onRejected);
13472 };
13473 _proto.finally = function _finally(onFinally) {
13474 return this.async().then(onFinally, onFinally);
13475 };
13476 _proto.sync = function sync() {
13477 if (this.error) throw this.error;
13478 return this.result;
13479 };
13480 _proto.then = function then(onFulfilled, onRejected) {
13481 if (true) {
13482 if (!("from" in this._opts)) {
13483 warnOnce2$1("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.");
13484 }
13485 }
13486 return this.async().then(onFulfilled, onRejected);
13487 };
13488 _proto.toString = function toString() {
13489 return this._css;
13490 };
13491 _proto.warnings = function warnings() {
13492 return [];
13493 };
13494 _create_class(NoWorkResult, [
13495 {
13496 key: "content",
13497 get: function get() {
13498 return this.result.css;
13499 }
13500 },
13501 {
13502 key: "css",
13503 get: function get() {
13504 return this.result.css;
13505 }
13506 },
13507 {
13508 key: "map",
13509 get: function get() {
13510 return this.result.map;
13511 }
13512 },
13513 {
13514 key: "messages",
13515 get: function get() {
13516 return [];
13517 }
13518 },
13519 {
13520 key: "opts",
13521 get: function get() {
13522 return this.result.opts;
13523 }
13524 },
13525 {
13526 key: "processor",
13527 get: function get() {
13528 return this.result.processor;
13529 }
13530 },
13531 {
13532 key: "root",
13533 get: function get() {
13534 if (this._root) {
13535 return this._root;
13536 }
13537 var root2;
13538 var parser2 = parse$1$1;
13539 try {
13540 root2 = parser2(this._css, this._opts);
13541 } catch (error) {
13542 this.error = error;
13543 }
13544 if (this.error) {
13545 throw this.error;
13546 } else {
13547 this._root = root2;
13548 return root2;
13549 }
13550 }
13551 },
13552 {
13553 key: Symbol.toStringTag,
13554 get: function get() {
13555 return "NoWorkResult";
13556 }
13557 }
13558 ]);
13559 return NoWorkResult;
13560 }();
13561 var noWorkResult$1 = NoWorkResult$1$1;
13562 NoWorkResult$1$1.default = NoWorkResult$1$1;
13563 var NoWorkResult2$1 = noWorkResult$1;
13564 var LazyResult$1$1 = lazyResult$1;
13565 var Document$1$1 = document$1$1;
13566 var Root$2$1 = root$1;
13567 var Processor$1$1 = /*#__PURE__*/ function() {
13568 function Processor(plugins) {
13569 if (plugins === void 0) plugins = [];
13570 this.version = "8.4.38";
13571 this.plugins = this.normalize(plugins);
13572 }
13573 var _proto = Processor.prototype;
13574 _proto.normalize = function normalize(plugins) {
13575 var normalized = [];
13576 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
13577 var i2 = _step.value;
13578 if (i2.postcss === true) {
13579 i2 = i2();
13580 } else if (i2.postcss) {
13581 i2 = i2.postcss;
13582 }
13583 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
13584 normalized = normalized.concat(i2.plugins);
13585 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
13586 normalized.push(i2);
13587 } else if (typeof i2 === "function") {
13588 normalized.push(i2);
13589 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
13590 if (true) {
13591 throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.");
13592 }
13593 } else {
13594 throw new Error(i2 + " is not a PostCSS plugin");
13595 }
13596 }
13597 return normalized;
13598 };
13599 _proto.process = function process1(css, opts) {
13600 if (opts === void 0) opts = {};
13601 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
13602 return new NoWorkResult2$1(this, css, opts);
13603 } else {
13604 return new LazyResult$1$1(this, css, opts);
13605 }
13606 };
13607 _proto.use = function use(plugin22) {
13608 this.plugins = this.plugins.concat(this.normalize([
13609 plugin22
13610 ]));
13611 return this;
13612 };
13613 return Processor;
13614 }();
13615 var processor$1 = Processor$1$1;
13616 Processor$1$1.default = Processor$1$1;
13617 Root$2$1.registerProcessor(Processor$1$1);
13618 Document$1$1.registerProcessor(Processor$1$1);
13619 var Declaration$1$1 = declaration$1;
13620 var PreviousMap2$1 = previousMap$1;
13621 var Comment$1$1 = comment$1;
13622 var AtRule$1$1 = atRule$1;
13623 var Input$1$1 = input$1;
13624 var Root$1$1 = root$1;
13625 var Rule$1$1 = rule$1;
13626 function fromJSON$1$1(json, inputs) {
13627 if (Array.isArray(json)) return json.map(function(n2) {
13628 return fromJSON$1$1(n2);
13629 });
13630 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
13631 "inputs"
13632 ]);
13633 if (ownInputs) {
13634 inputs = [];
13635 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
13636 var input2 = _step.value;
13637 var inputHydrated = _extends({}, input2, {
13638 __proto__: Input$1$1.prototype
13639 });
13640 if (inputHydrated.map) {
13641 inputHydrated.map = _extends({}, inputHydrated.map, {
13642 __proto__: PreviousMap2$1.prototype
13643 });
13644 }
13645 inputs.push(inputHydrated);
13646 }
13647 }
13648 if (defaults.nodes) {
13649 defaults.nodes = json.nodes.map(function(n2) {
13650 return fromJSON$1$1(n2, inputs);
13651 });
13652 }
13653 if (defaults.source) {
13654 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
13655 "inputId"
13656 ]);
13657 defaults.source = source;
13658 if (inputId != null) {
13659 defaults.source.input = inputs[inputId];
13660 }
13661 }
13662 if (defaults.type === "root") {
13663 return new Root$1$1(defaults);
13664 } else if (defaults.type === "decl") {
13665 return new Declaration$1$1(defaults);
13666 } else if (defaults.type === "rule") {
13667 return new Rule$1$1(defaults);
13668 } else if (defaults.type === "comment") {
13669 return new Comment$1$1(defaults);
13670 } else if (defaults.type === "atrule") {
13671 return new AtRule$1$1(defaults);
13672 } else {
13673 throw new Error("Unknown node type: " + json.type);
13674 }
13675 }
13676 var fromJSON_1$1 = fromJSON$1$1;
13677 fromJSON$1$1.default = fromJSON$1$1;
13678 var CssSyntaxError2$1 = cssSyntaxError$1;
13679 var Declaration2$1 = declaration$1;
13680 var LazyResult2$1 = lazyResult$1;
13681 var Container2$1 = container$1;
13682 var Processor2$1 = processor$1;
13683 var stringify$5 = stringify_1$1;
13684 var fromJSON$2 = fromJSON_1$1;
13685 var Document22 = document$1$1;
13686 var Warning2$1 = warning$1;
13687 var Comment2$1 = comment$1;
13688 var AtRule2$1 = atRule$1;
13689 var Result2$1 = result$1;
13690 var Input2$1 = input$1;
13691 var parse$5 = parse_1$1;
13692 var list$3 = list_1$1;
13693 var Rule2$1 = rule$1;
13694 var Root2$1 = root$1;
13695 var Node2$1 = node$1;
13696 function postcss$3() {
13697 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
13698 plugins[_key] = arguments[_key];
13699 }
13700 if (plugins.length === 1 && Array.isArray(plugins[0])) {
13701 plugins = plugins[0];
13702 }
13703 return new Processor2$1(plugins);
13704 }
13705 postcss$3.plugin = function plugin(name, initializer) {
13706 var warningPrinted = false;
13707 function creator() {
13708 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
13709 args[_key] = arguments[_key];
13710 }
13711 if (console && console.warn && !warningPrinted) {
13712 warningPrinted = true;
13713 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
13714 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
13715 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
13716 }
13717 }
13718 var transformer = initializer.apply(void 0, [].concat(args));
13719 transformer.postcssPlugin = name;
13720 transformer.postcssVersion = new Processor2$1().version;
13721 return transformer;
13722 }
13723 var cache;
13724 Object.defineProperty(creator, "postcss", {
13725 get: function get() {
13726 if (!cache) cache = creator();
13727 return cache;
13728 }
13729 });
13730 creator.process = function(css, processOpts, pluginOpts) {
13731 return postcss$3([
13732 creator(pluginOpts)
13733 ]).process(css, processOpts);
13734 };
13735 return creator;
13736 };
13737 postcss$3.stringify = stringify$5;
13738 postcss$3.parse = parse$5;
13739 postcss$3.fromJSON = fromJSON$2;
13740 postcss$3.list = list$3;
13741 postcss$3.comment = function(defaults) {
13742 return new Comment2$1(defaults);
13743 };
13744 postcss$3.atRule = function(defaults) {
13745 return new AtRule2$1(defaults);
13746 };
13747 postcss$3.decl = function(defaults) {
13748 return new Declaration2$1(defaults);
13749 };
13750 postcss$3.rule = function(defaults) {
13751 return new Rule2$1(defaults);
13752 };
13753 postcss$3.root = function(defaults) {
13754 return new Root2$1(defaults);
13755 };
13756 postcss$3.document = function(defaults) {
13757 return new Document22(defaults);
13758 };
13759 postcss$3.CssSyntaxError = CssSyntaxError2$1;
13760 postcss$3.Declaration = Declaration2$1;
13761 postcss$3.Container = Container2$1;
13762 postcss$3.Processor = Processor2$1;
13763 postcss$3.Document = Document22;
13764 postcss$3.Comment = Comment2$1;
13765 postcss$3.Warning = Warning2$1;
13766 postcss$3.AtRule = AtRule2$1;
13767 postcss$3.Result = Result2$1;
13768 postcss$3.Input = Input2$1;
13769 postcss$3.Rule = Rule2$1;
13770 postcss$3.Root = Root2$1;
13771 postcss$3.Node = Node2$1;
13772 LazyResult2$1.registerPostcss(postcss$3);
13773 var postcss_1$1 = postcss$3;
13774 postcss$3.default = postcss$3;
13775 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
13776 postcss$1$1.stringify;
13777 postcss$1$1.fromJSON;
13778 postcss$1$1.plugin;
13779 postcss$1$1.parse;
13780 postcss$1$1.list;
13781 postcss$1$1.document;
13782 postcss$1$1.comment;
13783 postcss$1$1.atRule;
13784 postcss$1$1.rule;
13785 postcss$1$1.decl;
13786 postcss$1$1.root;
13787 postcss$1$1.CssSyntaxError;
13788 postcss$1$1.Declaration;
13789 postcss$1$1.Container;
13790 postcss$1$1.Processor;
13791 postcss$1$1.Document;
13792 postcss$1$1.Comment;
13793 postcss$1$1.Warning;
13794 postcss$1$1.AtRule;
13795 postcss$1$1.Result;
13796 postcss$1$1.Input;
13797 postcss$1$1.Rule;
13798 postcss$1$1.Root;
13799 postcss$1$1.Node;
13800 var __defProp2 = Object.defineProperty;
13801 var __defNormalProp2 = function(obj, key, value) {
13802 return key in obj ? __defProp2(obj, key, {
13803 enumerable: true,
13804 configurable: true,
13805 writable: true,
13806 value: value
13807 }) : obj[key] = value;
13808 };
13809 var __publicField2 = function(obj, key, value) {
13810 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
13811 };
13812 function getDefaultExportFromCjs(x2) {
13813 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
13814 }
13815 function getAugmentedNamespace(n2) {
13816 if (n2.__esModule) return n2;
13817 var f2 = n2.default;
13818 if (typeof f2 == "function") {
13819 var a2 = function a22() {
13820 if (_instanceof(this, a22)) {
13821 return Reflect.construct(f2, arguments, this.constructor);
13822 }
13823 return f2.apply(this, arguments);
13824 };
13825 a2.prototype = f2.prototype;
13826 } else a2 = {};
13827 Object.defineProperty(a2, "__esModule", {
13828 value: true
13829 });
13830 Object.keys(n2).forEach(function(k) {
13831 var d = Object.getOwnPropertyDescriptor(n2, k);
13832 Object.defineProperty(a2, k, d.get ? d : {
13833 enumerable: true,
13834 get: function get() {
13835 return n2[k];
13836 }
13837 });
13838 });
13839 return a2;
13840 }
13841 var picocolors_browser = {
13842 exports: {}
13843 };
13844 var x = String;
13845 var create = function create() {
13846 return {
13847 isColorSupported: false,
13848 reset: x,
13849 bold: x,
13850 dim: x,
13851 italic: x,
13852 underline: x,
13853 inverse: x,
13854 hidden: x,
13855 strikethrough: x,
13856 black: x,
13857 red: x,
13858 green: x,
13859 yellow: x,
13860 blue: x,
13861 magenta: x,
13862 cyan: x,
13863 white: x,
13864 gray: x,
13865 bgBlack: x,
13866 bgRed: x,
13867 bgGreen: x,
13868 bgYellow: x,
13869 bgBlue: x,
13870 bgMagenta: x,
13871 bgCyan: x,
13872 bgWhite: x
13873 };
13874 };
13875 picocolors_browser.exports = create();
13876 picocolors_browser.exports.createColors = create;
13877 var picocolors_browserExports = picocolors_browser.exports;
13878 var __viteBrowserExternal = {};
13879 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
13880 __proto__: null,
13881 default: __viteBrowserExternal
13882 }, Symbol.toStringTag, {
13883 value: "Module"
13884 }));
13885 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
13886 var pico = picocolors_browserExports;
13887 var terminalHighlight$1 = require$$2;
13888 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
13889 _inherits(CssSyntaxError2, Error1);
13890 function CssSyntaxError2(message, line, column, source, file, plugin22) {
13891 var _this;
13892 _this = Error1.call(this, message) || this;
13893 _this.name = "CssSyntaxError";
13894 _this.reason = message;
13895 if (file) {
13896 _this.file = file;
13897 }
13898 if (source) {
13899 _this.source = source;
13900 }
13901 if (plugin22) {
13902 _this.plugin = plugin22;
13903 }
13904 if (typeof line !== "undefined" && typeof column !== "undefined") {
13905 if (typeof line === "number") {
13906 _this.line = line;
13907 _this.column = column;
13908 } else {
13909 _this.line = line.line;
13910 _this.column = line.column;
13911 _this.endLine = column.line;
13912 _this.endColumn = column.column;
13913 }
13914 }
13915 _this.setMessage();
13916 if (Error.captureStackTrace) {
13917 Error.captureStackTrace(_this, CssSyntaxError2);
13918 }
13919 return _this;
13920 }
13921 var _proto = CssSyntaxError2.prototype;
13922 _proto.setMessage = function setMessage() {
13923 this.message = this.plugin ? this.plugin + ": " : "";
13924 this.message += this.file ? this.file : "<css input>";
13925 if (typeof this.line !== "undefined") {
13926 this.message += ":" + this.line + ":" + this.column;
13927 }
13928 this.message += ": " + this.reason;
13929 };
13930 _proto.showSourceCode = function showSourceCode(color) {
13931 var _this = this;
13932 if (!this.source) return "";
13933 var css = this.source;
13934 if (color == null) color = pico.isColorSupported;
13935 if (terminalHighlight$1) {
13936 if (color) css = terminalHighlight$1(css);
13937 }
13938 var lines = css.split(/\r?\n/);
13939 var start = Math.max(this.line - 3, 0);
13940 var end = Math.min(this.line + 2, lines.length);
13941 var maxWidth = String(end).length;
13942 var mark, aside;
13943 if (color) {
13944 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
13945 mark = function(text) {
13946 return bold(red(text));
13947 };
13948 aside = function(text) {
13949 return gray(text);
13950 };
13951 } else {
13952 mark = aside = function(str) {
13953 return str;
13954 };
13955 }
13956 return lines.slice(start, end).map(function(line, index2) {
13957 var number = start + 1 + index2;
13958 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
13959 if (number === _this.line) {
13960 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
13961 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
13962 }
13963 return " " + aside(gutter) + line;
13964 }).join("\n");
13965 };
13966 _proto.toString = function toString() {
13967 var code = this.showSourceCode();
13968 if (code) {
13969 code = "\n\n" + code + "\n";
13970 }
13971 return this.name + ": " + this.message + code;
13972 };
13973 return CssSyntaxError2;
13974 }(_wrap_native_super(Error));
13975 var cssSyntaxError = CssSyntaxError$3;
13976 CssSyntaxError$3.default = CssSyntaxError$3;
13977 var symbols = {};
13978 symbols.isClean = Symbol("isClean");
13979 symbols.my = Symbol("my");
13980 var DEFAULT_RAW = {
13981 after: "\n",
13982 beforeClose: "\n",
13983 beforeComment: "\n",
13984 beforeDecl: "\n",
13985 beforeOpen: " ",
13986 beforeRule: "\n",
13987 colon: ": ",
13988 commentLeft: " ",
13989 commentRight: " ",
13990 emptyBody: "",
13991 indent: " ",
13992 semicolon: false
13993 };
13994 function capitalize(str) {
13995 return str[0].toUpperCase() + str.slice(1);
13996 }
13997 var Stringifier$2 = /*#__PURE__*/ function() {
13998 function Stringifier2(builder) {
13999 this.builder = builder;
14000 }
14001 var _proto = Stringifier2.prototype;
14002 _proto.atrule = function atrule(node2, semicolon) {
14003 var name = "@" + node2.name;
14004 var params = node2.params ? this.rawValue(node2, "params") : "";
14005 if (typeof node2.raws.afterName !== "undefined") {
14006 name += node2.raws.afterName;
14007 } else if (params) {
14008 name += " ";
14009 }
14010 if (node2.nodes) {
14011 this.block(node2, name + params);
14012 } else {
14013 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14014 this.builder(name + params + end, node2);
14015 }
14016 };
14017 _proto.beforeAfter = function beforeAfter(node2, detect) {
14018 var value;
14019 if (node2.type === "decl") {
14020 value = this.raw(node2, null, "beforeDecl");
14021 } else if (node2.type === "comment") {
14022 value = this.raw(node2, null, "beforeComment");
14023 } else if (detect === "before") {
14024 value = this.raw(node2, null, "beforeRule");
14025 } else {
14026 value = this.raw(node2, null, "beforeClose");
14027 }
14028 var buf = node2.parent;
14029 var depth = 0;
14030 while(buf && buf.type !== "root"){
14031 depth += 1;
14032 buf = buf.parent;
14033 }
14034 if (value.includes("\n")) {
14035 var indent = this.raw(node2, null, "indent");
14036 if (indent.length) {
14037 for(var step = 0; step < depth; step++)value += indent;
14038 }
14039 }
14040 return value;
14041 };
14042 _proto.block = function block(node2, start) {
14043 var between = this.raw(node2, "between", "beforeOpen");
14044 this.builder(start + between + "{", node2, "start");
14045 var after;
14046 if (node2.nodes && node2.nodes.length) {
14047 this.body(node2);
14048 after = this.raw(node2, "after");
14049 } else {
14050 after = this.raw(node2, "after", "emptyBody");
14051 }
14052 if (after) this.builder(after);
14053 this.builder("}", node2, "end");
14054 };
14055 _proto.body = function body(node2) {
14056 var last = node2.nodes.length - 1;
14057 while(last > 0){
14058 if (node2.nodes[last].type !== "comment") break;
14059 last -= 1;
14060 }
14061 var semicolon = this.raw(node2, "semicolon");
14062 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14063 var child = node2.nodes[i2];
14064 var before = this.raw(child, "before");
14065 if (before) this.builder(before);
14066 this.stringify(child, last !== i2 || semicolon);
14067 }
14068 };
14069 _proto.comment = function comment(node2) {
14070 var left = this.raw(node2, "left", "commentLeft");
14071 var right = this.raw(node2, "right", "commentRight");
14072 this.builder("/*" + left + node2.text + right + "*/", node2);
14073 };
14074 _proto.decl = function decl(node2, semicolon) {
14075 var between = this.raw(node2, "between", "colon");
14076 var string = node2.prop + between + this.rawValue(node2, "value");
14077 if (node2.important) {
14078 string += node2.raws.important || " !important";
14079 }
14080 if (semicolon) string += ";";
14081 this.builder(string, node2);
14082 };
14083 _proto.document = function document1(node2) {
14084 this.body(node2);
14085 };
14086 _proto.raw = function raw(node2, own, detect) {
14087 var value;
14088 if (!detect) detect = own;
14089 if (own) {
14090 value = node2.raws[own];
14091 if (typeof value !== "undefined") return value;
14092 }
14093 var parent = node2.parent;
14094 if (detect === "before") {
14095 if (!parent || parent.type === "root" && parent.first === node2) {
14096 return "";
14097 }
14098 if (parent && parent.type === "document") {
14099 return "";
14100 }
14101 }
14102 if (!parent) return DEFAULT_RAW[detect];
14103 var root2 = node2.root();
14104 if (!root2.rawCache) root2.rawCache = {};
14105 if (typeof root2.rawCache[detect] !== "undefined") {
14106 return root2.rawCache[detect];
14107 }
14108 if (detect === "before" || detect === "after") {
14109 return this.beforeAfter(node2, detect);
14110 } else {
14111 var method = "raw" + capitalize(detect);
14112 if (this[method]) {
14113 value = this[method](root2, node2);
14114 } else {
14115 root2.walk(function(i2) {
14116 value = i2.raws[own];
14117 if (typeof value !== "undefined") return false;
14118 });
14119 }
14120 }
14121 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14122 root2.rawCache[detect] = value;
14123 return value;
14124 };
14125 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14126 var value;
14127 root2.walk(function(i2) {
14128 if (i2.nodes && i2.nodes.length > 0) {
14129 if (typeof i2.raws.after !== "undefined") {
14130 value = i2.raws.after;
14131 if (value.includes("\n")) {
14132 value = value.replace(/[^\n]+$/, "");
14133 }
14134 return false;
14135 }
14136 }
14137 });
14138 if (value) value = value.replace(/\S/g, "");
14139 return value;
14140 };
14141 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14142 var value;
14143 root2.walkComments(function(i2) {
14144 if (typeof i2.raws.before !== "undefined") {
14145 value = i2.raws.before;
14146 if (value.includes("\n")) {
14147 value = value.replace(/[^\n]+$/, "");
14148 }
14149 return false;
14150 }
14151 });
14152 if (typeof value === "undefined") {
14153 value = this.raw(node2, null, "beforeDecl");
14154 } else if (value) {
14155 value = value.replace(/\S/g, "");
14156 }
14157 return value;
14158 };
14159 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14160 var value;
14161 root2.walkDecls(function(i2) {
14162 if (typeof i2.raws.before !== "undefined") {
14163 value = i2.raws.before;
14164 if (value.includes("\n")) {
14165 value = value.replace(/[^\n]+$/, "");
14166 }
14167 return false;
14168 }
14169 });
14170 if (typeof value === "undefined") {
14171 value = this.raw(node2, null, "beforeRule");
14172 } else if (value) {
14173 value = value.replace(/\S/g, "");
14174 }
14175 return value;
14176 };
14177 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
14178 var value;
14179 root2.walk(function(i2) {
14180 if (i2.type !== "decl") {
14181 value = i2.raws.between;
14182 if (typeof value !== "undefined") return false;
14183 }
14184 });
14185 return value;
14186 };
14187 _proto.rawBeforeRule = function rawBeforeRule(root2) {
14188 var value;
14189 root2.walk(function(i2) {
14190 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
14191 if (typeof i2.raws.before !== "undefined") {
14192 value = i2.raws.before;
14193 if (value.includes("\n")) {
14194 value = value.replace(/[^\n]+$/, "");
14195 }
14196 return false;
14197 }
14198 }
14199 });
14200 if (value) value = value.replace(/\S/g, "");
14201 return value;
14202 };
14203 _proto.rawColon = function rawColon(root2) {
14204 var value;
14205 root2.walkDecls(function(i2) {
14206 if (typeof i2.raws.between !== "undefined") {
14207 value = i2.raws.between.replace(/[^\s:]/g, "");
14208 return false;
14209 }
14210 });
14211 return value;
14212 };
14213 _proto.rawEmptyBody = function rawEmptyBody(root2) {
14214 var value;
14215 root2.walk(function(i2) {
14216 if (i2.nodes && i2.nodes.length === 0) {
14217 value = i2.raws.after;
14218 if (typeof value !== "undefined") return false;
14219 }
14220 });
14221 return value;
14222 };
14223 _proto.rawIndent = function rawIndent(root2) {
14224 if (root2.raws.indent) return root2.raws.indent;
14225 var value;
14226 root2.walk(function(i2) {
14227 var p = i2.parent;
14228 if (p && p !== root2 && p.parent && p.parent === root2) {
14229 if (typeof i2.raws.before !== "undefined") {
14230 var parts = i2.raws.before.split("\n");
14231 value = parts[parts.length - 1];
14232 value = value.replace(/\S/g, "");
14233 return false;
14234 }
14235 }
14236 });
14237 return value;
14238 };
14239 _proto.rawSemicolon = function rawSemicolon(root2) {
14240 var value;
14241 root2.walk(function(i2) {
14242 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
14243 value = i2.raws.semicolon;
14244 if (typeof value !== "undefined") return false;
14245 }
14246 });
14247 return value;
14248 };
14249 _proto.rawValue = function rawValue(node2, prop) {
14250 var value = node2[prop];
14251 var raw = node2.raws[prop];
14252 if (raw && raw.value === value) {
14253 return raw.raw;
14254 }
14255 return value;
14256 };
14257 _proto.root = function root(node2) {
14258 this.body(node2);
14259 if (node2.raws.after) this.builder(node2.raws.after);
14260 };
14261 _proto.rule = function rule(node2) {
14262 this.block(node2, this.rawValue(node2, "selector"));
14263 if (node2.raws.ownSemicolon) {
14264 this.builder(node2.raws.ownSemicolon, node2, "end");
14265 }
14266 };
14267 _proto.stringify = function stringify(node2, semicolon) {
14268 if (!this[node2.type]) {
14269 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
14270 }
14271 this[node2.type](node2, semicolon);
14272 };
14273 return Stringifier2;
14274 }();
14275 var stringifier = Stringifier$2;
14276 Stringifier$2.default = Stringifier$2;
14277 var Stringifier$1 = stringifier;
14278 function stringify$4(node2, builder) {
14279 var str = new Stringifier$1(builder);
14280 str.stringify(node2);
14281 }
14282 var stringify_1 = stringify$4;
14283 stringify$4.default = stringify$4;
14284 var isClean$2 = symbols.isClean, my$2 = symbols.my;
14285 var CssSyntaxError$2 = cssSyntaxError;
14286 var Stringifier22 = stringifier;
14287 var stringify$3 = stringify_1;
14288 function cloneNode(obj, parent) {
14289 var cloned = new obj.constructor();
14290 for(var i2 in obj){
14291 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
14292 continue;
14293 }
14294 if (i2 === "proxyCache") continue;
14295 var value = obj[i2];
14296 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
14297 if (i2 === "parent" && type === "object") {
14298 if (parent) cloned[i2] = parent;
14299 } else if (i2 === "source") {
14300 cloned[i2] = value;
14301 } else if (Array.isArray(value)) {
14302 cloned[i2] = value.map(function(j) {
14303 return cloneNode(j, cloned);
14304 });
14305 } else {
14306 if (type === "object" && value !== null) value = cloneNode(value);
14307 cloned[i2] = value;
14308 }
14309 }
14310 return cloned;
14311 }
14312 var Node$4 = /*#__PURE__*/ function() {
14313 function Node3(defaults) {
14314 if (defaults === void 0) defaults = {};
14315 this.raws = {};
14316 this[isClean$2] = false;
14317 this[my$2] = true;
14318 for(var name in defaults){
14319 if (name === "nodes") {
14320 this.nodes = [];
14321 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
14322 var node2 = _step.value;
14323 if (typeof node2.clone === "function") {
14324 this.append(node2.clone());
14325 } else {
14326 this.append(node2);
14327 }
14328 }
14329 } else {
14330 this[name] = defaults[name];
14331 }
14332 }
14333 }
14334 var _proto = Node3.prototype;
14335 _proto.addToError = function addToError(error) {
14336 error.postcssNode = this;
14337 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
14338 var s2 = this.source;
14339 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
14340 }
14341 return error;
14342 };
14343 _proto.after = function after(add) {
14344 this.parent.insertAfter(this, add);
14345 return this;
14346 };
14347 _proto.assign = function assign(overrides) {
14348 if (overrides === void 0) overrides = {};
14349 for(var name in overrides){
14350 this[name] = overrides[name];
14351 }
14352 return this;
14353 };
14354 _proto.before = function before(add) {
14355 this.parent.insertBefore(this, add);
14356 return this;
14357 };
14358 _proto.cleanRaws = function cleanRaws(keepBetween) {
14359 delete this.raws.before;
14360 delete this.raws.after;
14361 if (!keepBetween) delete this.raws.between;
14362 };
14363 _proto.clone = function clone(overrides) {
14364 if (overrides === void 0) overrides = {};
14365 var cloned = cloneNode(this);
14366 for(var name in overrides){
14367 cloned[name] = overrides[name];
14368 }
14369 return cloned;
14370 };
14371 _proto.cloneAfter = function cloneAfter(overrides) {
14372 if (overrides === void 0) overrides = {};
14373 var cloned = this.clone(overrides);
14374 this.parent.insertAfter(this, cloned);
14375 return cloned;
14376 };
14377 _proto.cloneBefore = function cloneBefore(overrides) {
14378 if (overrides === void 0) overrides = {};
14379 var cloned = this.clone(overrides);
14380 this.parent.insertBefore(this, cloned);
14381 return cloned;
14382 };
14383 _proto.error = function error(message, opts) {
14384 if (opts === void 0) opts = {};
14385 if (this.source) {
14386 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
14387 return this.source.input.error(message, {
14388 column: start.column,
14389 line: start.line
14390 }, {
14391 column: end.column,
14392 line: end.line
14393 }, opts);
14394 }
14395 return new CssSyntaxError$2(message);
14396 };
14397 _proto.getProxyProcessor = function getProxyProcessor() {
14398 return {
14399 get: function get(node2, prop) {
14400 if (prop === "proxyOf") {
14401 return node2;
14402 } else if (prop === "root") {
14403 return function() {
14404 return node2.root().toProxy();
14405 };
14406 } else {
14407 return node2[prop];
14408 }
14409 },
14410 set: function set(node2, prop, value) {
14411 if (node2[prop] === value) return true;
14412 node2[prop] = value;
14413 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
14414 node2.markDirty();
14415 }
14416 return true;
14417 }
14418 };
14419 };
14420 _proto.markDirty = function markDirty() {
14421 if (this[isClean$2]) {
14422 this[isClean$2] = false;
14423 var next = this;
14424 while(next = next.parent){
14425 next[isClean$2] = false;
14426 }
14427 }
14428 };
14429 _proto.next = function next() {
14430 if (!this.parent) return void 0;
14431 var index2 = this.parent.index(this);
14432 return this.parent.nodes[index2 + 1];
14433 };
14434 _proto.positionBy = function positionBy(opts, stringRepresentation) {
14435 var pos = this.source.start;
14436 if (opts.index) {
14437 pos = this.positionInside(opts.index, stringRepresentation);
14438 } else if (opts.word) {
14439 stringRepresentation = this.toString();
14440 var index2 = stringRepresentation.indexOf(opts.word);
14441 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
14442 }
14443 return pos;
14444 };
14445 _proto.positionInside = function positionInside(index2, stringRepresentation) {
14446 var string = stringRepresentation || this.toString();
14447 var column = this.source.start.column;
14448 var line = this.source.start.line;
14449 for(var i2 = 0; i2 < index2; i2++){
14450 if (string[i2] === "\n") {
14451 column = 1;
14452 line += 1;
14453 } else {
14454 column += 1;
14455 }
14456 }
14457 return {
14458 column: column,
14459 line: line
14460 };
14461 };
14462 _proto.prev = function prev() {
14463 if (!this.parent) return void 0;
14464 var index2 = this.parent.index(this);
14465 return this.parent.nodes[index2 - 1];
14466 };
14467 _proto.rangeBy = function rangeBy(opts) {
14468 var start = {
14469 column: this.source.start.column,
14470 line: this.source.start.line
14471 };
14472 var end = this.source.end ? {
14473 column: this.source.end.column + 1,
14474 line: this.source.end.line
14475 } : {
14476 column: start.column + 1,
14477 line: start.line
14478 };
14479 if (opts.word) {
14480 var stringRepresentation = this.toString();
14481 var index2 = stringRepresentation.indexOf(opts.word);
14482 if (index2 !== -1) {
14483 start = this.positionInside(index2, stringRepresentation);
14484 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
14485 }
14486 } else {
14487 if (opts.start) {
14488 start = {
14489 column: opts.start.column,
14490 line: opts.start.line
14491 };
14492 } else if (opts.index) {
14493 start = this.positionInside(opts.index);
14494 }
14495 if (opts.end) {
14496 end = {
14497 column: opts.end.column,
14498 line: opts.end.line
14499 };
14500 } else if (typeof opts.endIndex === "number") {
14501 end = this.positionInside(opts.endIndex);
14502 } else if (opts.index) {
14503 end = this.positionInside(opts.index + 1);
14504 }
14505 }
14506 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
14507 end = {
14508 column: start.column + 1,
14509 line: start.line
14510 };
14511 }
14512 return {
14513 end: end,
14514 start: start
14515 };
14516 };
14517 _proto.raw = function raw(prop, defaultType) {
14518 var str = new Stringifier22();
14519 return str.raw(this, prop, defaultType);
14520 };
14521 _proto.remove = function remove() {
14522 if (this.parent) {
14523 this.parent.removeChild(this);
14524 }
14525 this.parent = void 0;
14526 return this;
14527 };
14528 _proto.replaceWith = function replaceWith() {
14529 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
14530 nodes[_key] = arguments[_key];
14531 }
14532 if (this.parent) {
14533 var bookmark = this;
14534 var foundSelf = false;
14535 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
14536 var node2 = _step.value;
14537 if (node2 === this) {
14538 foundSelf = true;
14539 } else if (foundSelf) {
14540 this.parent.insertAfter(bookmark, node2);
14541 bookmark = node2;
14542 } else {
14543 this.parent.insertBefore(bookmark, node2);
14544 }
14545 }
14546 if (!foundSelf) {
14547 this.remove();
14548 }
14549 }
14550 return this;
14551 };
14552 _proto.root = function root() {
14553 var result2 = this;
14554 while(result2.parent && result2.parent.type !== "document"){
14555 result2 = result2.parent;
14556 }
14557 return result2;
14558 };
14559 _proto.toJSON = function toJSON(_, inputs) {
14560 var fixed = {};
14561 var emitInputs = inputs == null;
14562 inputs = inputs || /* @__PURE__ */ new Map();
14563 var inputsNextIndex = 0;
14564 for(var name in this){
14565 if (!Object.prototype.hasOwnProperty.call(this, name)) {
14566 continue;
14567 }
14568 if (name === "parent" || name === "proxyCache") continue;
14569 var value = this[name];
14570 if (Array.isArray(value)) {
14571 fixed[name] = value.map(function(i2) {
14572 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
14573 return i2.toJSON(null, inputs);
14574 } else {
14575 return i2;
14576 }
14577 });
14578 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
14579 fixed[name] = value.toJSON(null, inputs);
14580 } else if (name === "source") {
14581 var inputId = inputs.get(value.input);
14582 if (inputId == null) {
14583 inputId = inputsNextIndex;
14584 inputs.set(value.input, inputsNextIndex);
14585 inputsNextIndex++;
14586 }
14587 fixed[name] = {
14588 end: value.end,
14589 inputId: inputId,
14590 start: value.start
14591 };
14592 } else {
14593 fixed[name] = value;
14594 }
14595 }
14596 if (emitInputs) {
14597 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
14598 return input2.toJSON();
14599 });
14600 }
14601 return fixed;
14602 };
14603 _proto.toProxy = function toProxy() {
14604 if (!this.proxyCache) {
14605 this.proxyCache = new Proxy(this, this.getProxyProcessor());
14606 }
14607 return this.proxyCache;
14608 };
14609 _proto.toString = function toString(stringifier2) {
14610 if (stringifier2 === void 0) stringifier2 = stringify$3;
14611 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
14612 var result2 = "";
14613 stringifier2(this, function(i2) {
14614 result2 += i2;
14615 });
14616 return result2;
14617 };
14618 _proto.warn = function warn(result2, text, opts) {
14619 var data = {
14620 node: this
14621 };
14622 for(var i2 in opts)data[i2] = opts[i2];
14623 return result2.warn(text, data);
14624 };
14625 _create_class(Node3, [
14626 {
14627 key: "proxyOf",
14628 get: function get() {
14629 return this;
14630 }
14631 }
14632 ]);
14633 return Node3;
14634 }();
14635 var node = Node$4;
14636 Node$4.default = Node$4;
14637 var Node$3 = node;
14638 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
14639 _inherits(Declaration2, Node$3);
14640 function Declaration2(defaults) {
14641 var _this;
14642 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
14643 defaults = _extends({}, defaults, {
14644 value: String(defaults.value)
14645 });
14646 }
14647 _this = Node$3.call(this, defaults) || this;
14648 _this.type = "decl";
14649 return _this;
14650 }
14651 _create_class(Declaration2, [
14652 {
14653 key: "variable",
14654 get: function get() {
14655 return this.prop.startsWith("--") || this.prop[0] === "$";
14656 }
14657 }
14658 ]);
14659 return Declaration2;
14660 }(Node$3);
14661 var declaration = Declaration$4;
14662 Declaration$4.default = Declaration$4;
14663 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
14664 var nanoid$1 = function(size) {
14665 if (size === void 0) size = 21;
14666 var id = "";
14667 var i2 = size;
14668 while(i2--){
14669 id += urlAlphabet[Math.random() * 64 | 0];
14670 }
14671 return id;
14672 };
14673 var nonSecure = {
14674 nanoid: nanoid$1};
14675 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
14676 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
14677 var dirname$1 = require$$2.dirname, join = require$$2.join;
14678 function fromBase64(str) {
14679 if (Buffer) {
14680 return Buffer.from(str, "base64").toString();
14681 } else {
14682 return window.atob(str);
14683 }
14684 }
14685 var PreviousMap$2 = /*#__PURE__*/ function() {
14686 function PreviousMap2(css, opts) {
14687 if (opts.map === false) return;
14688 this.loadAnnotation(css);
14689 this.inline = this.startWith(this.annotation, "data:");
14690 var prev = opts.map ? opts.map.prev : void 0;
14691 var text = this.loadMap(opts.from, prev);
14692 if (!this.mapFile && opts.from) {
14693 this.mapFile = opts.from;
14694 }
14695 if (this.mapFile) this.root = dirname$1(this.mapFile);
14696 if (text) this.text = text;
14697 }
14698 var _proto = PreviousMap2.prototype;
14699 _proto.consumer = function consumer() {
14700 if (!this.consumerCache) {
14701 this.consumerCache = new SourceMapConsumer$2(this.text);
14702 }
14703 return this.consumerCache;
14704 };
14705 _proto.decodeInline = function decodeInline(text) {
14706 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
14707 var baseUri = /^data:application\/json;base64,/;
14708 var charsetUri = /^data:application\/json;charset=utf-?8,/;
14709 var uri = /^data:application\/json,/;
14710 if (charsetUri.test(text) || uri.test(text)) {
14711 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
14712 }
14713 if (baseCharsetUri.test(text) || baseUri.test(text)) {
14714 return fromBase64(text.substr(RegExp.lastMatch.length));
14715 }
14716 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
14717 throw new Error("Unsupported source map encoding " + encoding);
14718 };
14719 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
14720 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
14721 };
14722 _proto.isMap = function isMap(map) {
14723 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
14724 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
14725 };
14726 _proto.loadAnnotation = function loadAnnotation(css) {
14727 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
14728 if (!comments) return;
14729 var start = css.lastIndexOf(comments.pop());
14730 var end = css.indexOf("*/", start);
14731 if (start > -1 && end > -1) {
14732 this.annotation = this.getAnnotationURL(css.substring(start, end));
14733 }
14734 };
14735 _proto.loadFile = function loadFile(path) {
14736 this.root = dirname$1(path);
14737 if (existsSync(path)) {
14738 this.mapFile = path;
14739 return readFileSync(path, "utf-8").toString().trim();
14740 }
14741 };
14742 _proto.loadMap = function loadMap(file, prev) {
14743 if (prev === false) return false;
14744 if (prev) {
14745 if (typeof prev === "string") {
14746 return prev;
14747 } else if (typeof prev === "function") {
14748 var prevPath = prev(file);
14749 if (prevPath) {
14750 var map = this.loadFile(prevPath);
14751 if (!map) {
14752 throw new Error("Unable to load previous source map: " + prevPath.toString());
14753 }
14754 return map;
14755 }
14756 } else if (_instanceof(prev, SourceMapConsumer$2)) {
14757 return SourceMapGenerator$2.fromSourceMap(prev).toString();
14758 } else if (_instanceof(prev, SourceMapGenerator$2)) {
14759 return prev.toString();
14760 } else if (this.isMap(prev)) {
14761 return JSON.stringify(prev);
14762 } else {
14763 throw new Error("Unsupported previous source map format: " + prev.toString());
14764 }
14765 } else if (this.inline) {
14766 return this.decodeInline(this.annotation);
14767 } else if (this.annotation) {
14768 var map1 = this.annotation;
14769 if (file) map1 = join(dirname$1(file), map1);
14770 return this.loadFile(map1);
14771 }
14772 };
14773 _proto.startWith = function startWith(string, start) {
14774 if (!string) return false;
14775 return string.substr(0, start.length) === start;
14776 };
14777 _proto.withContent = function withContent() {
14778 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
14779 };
14780 return PreviousMap2;
14781 }();
14782 var previousMap = PreviousMap$2;
14783 PreviousMap$2.default = PreviousMap$2;
14784 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
14785 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
14786 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
14787 var nanoid = nonSecure.nanoid;
14788 var terminalHighlight = require$$2;
14789 var CssSyntaxError$1 = cssSyntaxError;
14790 var PreviousMap$1 = previousMap;
14791 var fromOffsetCache = Symbol("fromOffsetCache");
14792 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
14793 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
14794 var Input$4 = /*#__PURE__*/ function() {
14795 function Input2(css, opts) {
14796 if (opts === void 0) opts = {};
14797 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
14798 throw new Error("PostCSS received " + css + " instead of CSS string");
14799 }
14800 this.css = css.toString();
14801 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
14802 this.hasBOM = true;
14803 this.css = this.css.slice(1);
14804 } else {
14805 this.hasBOM = false;
14806 }
14807 if (opts.from) {
14808 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
14809 this.file = opts.from;
14810 } else {
14811 this.file = resolve$1(opts.from);
14812 }
14813 }
14814 if (pathAvailable$1 && sourceMapAvailable$1) {
14815 var map = new PreviousMap$1(this.css, opts);
14816 if (map.text) {
14817 this.map = map;
14818 var file = map.consumer().file;
14819 if (!this.file && file) this.file = this.mapResolve(file);
14820 }
14821 }
14822 if (!this.file) {
14823 this.id = "<input css " + nanoid(6) + ">";
14824 }
14825 if (this.map) this.map.file = this.from;
14826 }
14827 var _proto = Input2.prototype;
14828 _proto.error = function error(message, line, column, opts) {
14829 if (opts === void 0) opts = {};
14830 var result2, endLine, endColumn;
14831 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
14832 var start = line;
14833 var end = column;
14834 if (typeof start.offset === "number") {
14835 var pos = this.fromOffset(start.offset);
14836 line = pos.line;
14837 column = pos.col;
14838 } else {
14839 line = start.line;
14840 column = start.column;
14841 }
14842 if (typeof end.offset === "number") {
14843 var pos1 = this.fromOffset(end.offset);
14844 endLine = pos1.line;
14845 endColumn = pos1.col;
14846 } else {
14847 endLine = end.line;
14848 endColumn = end.column;
14849 }
14850 } else if (!column) {
14851 var pos2 = this.fromOffset(line);
14852 line = pos2.line;
14853 column = pos2.col;
14854 }
14855 var origin = this.origin(line, column, endLine, endColumn);
14856 if (origin) {
14857 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
14858 column: origin.column,
14859 line: origin.line
14860 }, origin.endLine === void 0 ? origin.column : {
14861 column: origin.endColumn,
14862 line: origin.endLine
14863 }, origin.source, origin.file, opts.plugin);
14864 } else {
14865 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
14866 column: column,
14867 line: line
14868 }, endLine === void 0 ? column : {
14869 column: endColumn,
14870 line: endLine
14871 }, this.css, this.file, opts.plugin);
14872 }
14873 result2.input = {
14874 column: column,
14875 endColumn: endColumn,
14876 endLine: endLine,
14877 line: line,
14878 source: this.css
14879 };
14880 if (this.file) {
14881 if (pathToFileURL$1) {
14882 result2.input.url = pathToFileURL$1(this.file).toString();
14883 }
14884 result2.input.file = this.file;
14885 }
14886 return result2;
14887 };
14888 _proto.fromOffset = function fromOffset(offset) {
14889 var lastLine, lineToIndex;
14890 if (!this[fromOffsetCache]) {
14891 var lines = this.css.split("\n");
14892 lineToIndex = new Array(lines.length);
14893 var prevIndex = 0;
14894 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
14895 lineToIndex[i2] = prevIndex;
14896 prevIndex += lines[i2].length + 1;
14897 }
14898 this[fromOffsetCache] = lineToIndex;
14899 } else {
14900 lineToIndex = this[fromOffsetCache];
14901 }
14902 lastLine = lineToIndex[lineToIndex.length - 1];
14903 var min = 0;
14904 if (offset >= lastLine) {
14905 min = lineToIndex.length - 1;
14906 } else {
14907 var max = lineToIndex.length - 2;
14908 var mid;
14909 while(min < max){
14910 mid = min + (max - min >> 1);
14911 if (offset < lineToIndex[mid]) {
14912 max = mid - 1;
14913 } else if (offset >= lineToIndex[mid + 1]) {
14914 min = mid + 1;
14915 } else {
14916 min = mid;
14917 break;
14918 }
14919 }
14920 }
14921 return {
14922 col: offset - lineToIndex[min] + 1,
14923 line: min + 1
14924 };
14925 };
14926 _proto.mapResolve = function mapResolve(file) {
14927 if (/^\w+:\/\//.test(file)) {
14928 return file;
14929 }
14930 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
14931 };
14932 _proto.origin = function origin(line, column, endLine, endColumn) {
14933 if (!this.map) return false;
14934 var consumer = this.map.consumer();
14935 var from = consumer.originalPositionFor({
14936 column: column,
14937 line: line
14938 });
14939 if (!from.source) return false;
14940 var to;
14941 if (typeof endLine === "number") {
14942 to = consumer.originalPositionFor({
14943 column: endColumn,
14944 line: endLine
14945 });
14946 }
14947 var fromUrl;
14948 if (isAbsolute(from.source)) {
14949 fromUrl = pathToFileURL$1(from.source);
14950 } else {
14951 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
14952 }
14953 var result2 = {
14954 column: from.column,
14955 endColumn: to && to.column,
14956 endLine: to && to.line,
14957 line: from.line,
14958 url: fromUrl.toString()
14959 };
14960 if (fromUrl.protocol === "file:") {
14961 if (fileURLToPath) {
14962 result2.file = fileURLToPath(fromUrl);
14963 } else {
14964 throw new Error("file: protocol is not available in this PostCSS build");
14965 }
14966 }
14967 var source = consumer.sourceContentFor(from.source);
14968 if (source) result2.source = source;
14969 return result2;
14970 };
14971 _proto.toJSON = function toJSON() {
14972 var json = {};
14973 for(var _i = 0, _iter = [
14974 "hasBOM",
14975 "css",
14976 "file",
14977 "id"
14978 ]; _i < _iter.length; _i++){
14979 var name = _iter[_i];
14980 if (this[name] != null) {
14981 json[name] = this[name];
14982 }
14983 }
14984 if (this.map) {
14985 json.map = _extends({}, this.map);
14986 if (json.map.consumerCache) {
14987 json.map.consumerCache = void 0;
14988 }
14989 }
14990 return json;
14991 };
14992 _create_class(Input2, [
14993 {
14994 key: "from",
14995 get: function get() {
14996 return this.file || this.id;
14997 }
14998 }
14999 ]);
15000 return Input2;
15001 }();
15002 var input = Input$4;
15003 Input$4.default = Input$4;
15004 if (terminalHighlight && terminalHighlight.registerInput) {
15005 terminalHighlight.registerInput(Input$4);
15006 }
15007 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15008 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15009 var pathToFileURL = require$$2.pathToFileURL;
15010 var Input$3 = input;
15011 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15012 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15013 var MapGenerator$2 = /*#__PURE__*/ function() {
15014 function MapGenerator2(stringify2, root2, opts, cssString) {
15015 this.stringify = stringify2;
15016 this.mapOpts = opts.map || {};
15017 this.root = root2;
15018 this.opts = opts;
15019 this.css = cssString;
15020 this.originalCSS = cssString;
15021 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15022 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15023 this.memoizedPaths = /* @__PURE__ */ new Map();
15024 this.memoizedURLs = /* @__PURE__ */ new Map();
15025 }
15026 var _proto = MapGenerator2.prototype;
15027 _proto.addAnnotation = function addAnnotation() {
15028 var content;
15029 if (this.isInline()) {
15030 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15031 } else if (typeof this.mapOpts.annotation === "string") {
15032 content = this.mapOpts.annotation;
15033 } else if (typeof this.mapOpts.annotation === "function") {
15034 content = this.mapOpts.annotation(this.opts.to, this.root);
15035 } else {
15036 content = this.outputFile() + ".map";
15037 }
15038 var eol = "\n";
15039 if (this.css.includes("\r\n")) eol = "\r\n";
15040 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15041 };
15042 _proto.applyPrevMaps = function applyPrevMaps() {
15043 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15044 var prev = _step.value;
15045 var from = this.toUrl(this.path(prev.file));
15046 var root2 = prev.root || dirname(prev.file);
15047 var map = void 0;
15048 if (this.mapOpts.sourcesContent === false) {
15049 map = new SourceMapConsumer(prev.text);
15050 if (map.sourcesContent) {
15051 map.sourcesContent = null;
15052 }
15053 } else {
15054 map = prev.consumer();
15055 }
15056 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15057 }
15058 };
15059 _proto.clearAnnotation = function clearAnnotation() {
15060 if (this.mapOpts.annotation === false) return;
15061 if (this.root) {
15062 var node2;
15063 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15064 node2 = this.root.nodes[i2];
15065 if (node2.type !== "comment") continue;
15066 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15067 this.root.removeChild(i2);
15068 }
15069 }
15070 } else if (this.css) {
15071 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15072 }
15073 };
15074 _proto.generate = function generate() {
15075 this.clearAnnotation();
15076 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15077 return this.generateMap();
15078 } else {
15079 var result2 = "";
15080 this.stringify(this.root, function(i2) {
15081 result2 += i2;
15082 });
15083 return [
15084 result2
15085 ];
15086 }
15087 };
15088 _proto.generateMap = function generateMap() {
15089 if (this.root) {
15090 this.generateString();
15091 } else if (this.previous().length === 1) {
15092 var prev = this.previous()[0].consumer();
15093 prev.file = this.outputFile();
15094 this.map = SourceMapGenerator.fromSourceMap(prev, {
15095 ignoreInvalidMapping: true
15096 });
15097 } else {
15098 this.map = new SourceMapGenerator({
15099 file: this.outputFile(),
15100 ignoreInvalidMapping: true
15101 });
15102 this.map.addMapping({
15103 generated: {
15104 column: 0,
15105 line: 1
15106 },
15107 original: {
15108 column: 0,
15109 line: 1
15110 },
15111 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15112 });
15113 }
15114 if (this.isSourcesContent()) this.setSourcesContent();
15115 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15116 if (this.isAnnotation()) this.addAnnotation();
15117 if (this.isInline()) {
15118 return [
15119 this.css
15120 ];
15121 } else {
15122 return [
15123 this.css,
15124 this.map
15125 ];
15126 }
15127 };
15128 _proto.generateString = function generateString() {
15129 var _this = this;
15130 this.css = "";
15131 this.map = new SourceMapGenerator({
15132 file: this.outputFile(),
15133 ignoreInvalidMapping: true
15134 });
15135 var line = 1;
15136 var column = 1;
15137 var noSource = "<no source>";
15138 var mapping = {
15139 generated: {
15140 column: 0,
15141 line: 0
15142 },
15143 original: {
15144 column: 0,
15145 line: 0
15146 },
15147 source: ""
15148 };
15149 var lines, last;
15150 this.stringify(this.root, function(str, node2, type) {
15151 _this.css += str;
15152 if (node2 && type !== "end") {
15153 mapping.generated.line = line;
15154 mapping.generated.column = column - 1;
15155 if (node2.source && node2.source.start) {
15156 mapping.source = _this.sourcePath(node2);
15157 mapping.original.line = node2.source.start.line;
15158 mapping.original.column = node2.source.start.column - 1;
15159 _this.map.addMapping(mapping);
15160 } else {
15161 mapping.source = noSource;
15162 mapping.original.line = 1;
15163 mapping.original.column = 0;
15164 _this.map.addMapping(mapping);
15165 }
15166 }
15167 lines = str.match(/\n/g);
15168 if (lines) {
15169 line += lines.length;
15170 last = str.lastIndexOf("\n");
15171 column = str.length - last;
15172 } else {
15173 column += str.length;
15174 }
15175 if (node2 && type !== "start") {
15176 var p = node2.parent || {
15177 raws: {}
15178 };
15179 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
15180 if (!childless || node2 !== p.last || p.raws.semicolon) {
15181 if (node2.source && node2.source.end) {
15182 mapping.source = _this.sourcePath(node2);
15183 mapping.original.line = node2.source.end.line;
15184 mapping.original.column = node2.source.end.column - 1;
15185 mapping.generated.line = line;
15186 mapping.generated.column = column - 2;
15187 _this.map.addMapping(mapping);
15188 } else {
15189 mapping.source = noSource;
15190 mapping.original.line = 1;
15191 mapping.original.column = 0;
15192 mapping.generated.line = line;
15193 mapping.generated.column = column - 1;
15194 _this.map.addMapping(mapping);
15195 }
15196 }
15197 }
15198 });
15199 };
15200 _proto.isAnnotation = function isAnnotation() {
15201 if (this.isInline()) {
15202 return true;
15203 }
15204 if (typeof this.mapOpts.annotation !== "undefined") {
15205 return this.mapOpts.annotation;
15206 }
15207 if (this.previous().length) {
15208 return this.previous().some(function(i2) {
15209 return i2.annotation;
15210 });
15211 }
15212 return true;
15213 };
15214 _proto.isInline = function isInline() {
15215 if (typeof this.mapOpts.inline !== "undefined") {
15216 return this.mapOpts.inline;
15217 }
15218 var annotation = this.mapOpts.annotation;
15219 if (typeof annotation !== "undefined" && annotation !== true) {
15220 return false;
15221 }
15222 if (this.previous().length) {
15223 return this.previous().some(function(i2) {
15224 return i2.inline;
15225 });
15226 }
15227 return true;
15228 };
15229 _proto.isMap = function isMap() {
15230 if (typeof this.opts.map !== "undefined") {
15231 return !!this.opts.map;
15232 }
15233 return this.previous().length > 0;
15234 };
15235 _proto.isSourcesContent = function isSourcesContent() {
15236 if (typeof this.mapOpts.sourcesContent !== "undefined") {
15237 return this.mapOpts.sourcesContent;
15238 }
15239 if (this.previous().length) {
15240 return this.previous().some(function(i2) {
15241 return i2.withContent();
15242 });
15243 }
15244 return true;
15245 };
15246 _proto.outputFile = function outputFile() {
15247 if (this.opts.to) {
15248 return this.path(this.opts.to);
15249 } else if (this.opts.from) {
15250 return this.path(this.opts.from);
15251 } else {
15252 return "to.css";
15253 }
15254 };
15255 _proto.path = function path(file) {
15256 if (this.mapOpts.absolute) return file;
15257 if (file.charCodeAt(0) === 60) return file;
15258 if (/^\w+:\/\//.test(file)) return file;
15259 var cached = this.memoizedPaths.get(file);
15260 if (cached) return cached;
15261 var from = this.opts.to ? dirname(this.opts.to) : ".";
15262 if (typeof this.mapOpts.annotation === "string") {
15263 from = dirname(resolve$3(from, this.mapOpts.annotation));
15264 }
15265 var path = relative(from, file);
15266 this.memoizedPaths.set(file, path);
15267 return path;
15268 };
15269 _proto.previous = function previous() {
15270 var _this = this;
15271 if (!this.previousMaps) {
15272 this.previousMaps = [];
15273 if (this.root) {
15274 this.root.walk(function(node2) {
15275 if (node2.source && node2.source.input.map) {
15276 var map = node2.source.input.map;
15277 if (!_this.previousMaps.includes(map)) {
15278 _this.previousMaps.push(map);
15279 }
15280 }
15281 });
15282 } else {
15283 var input2 = new Input$3(this.originalCSS, this.opts);
15284 if (input2.map) this.previousMaps.push(input2.map);
15285 }
15286 }
15287 return this.previousMaps;
15288 };
15289 _proto.setSourcesContent = function setSourcesContent() {
15290 var _this = this;
15291 var already = {};
15292 if (this.root) {
15293 this.root.walk(function(node2) {
15294 if (node2.source) {
15295 var from = node2.source.input.from;
15296 if (from && !already[from]) {
15297 already[from] = true;
15298 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
15299 _this.map.setSourceContent(fromUrl, node2.source.input.css);
15300 }
15301 }
15302 });
15303 } else if (this.css) {
15304 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
15305 this.map.setSourceContent(from, this.css);
15306 }
15307 };
15308 _proto.sourcePath = function sourcePath(node2) {
15309 if (this.mapOpts.from) {
15310 return this.toUrl(this.mapOpts.from);
15311 } else if (this.usesFileUrls) {
15312 return this.toFileUrl(node2.source.input.from);
15313 } else {
15314 return this.toUrl(this.path(node2.source.input.from));
15315 }
15316 };
15317 _proto.toBase64 = function toBase64(str) {
15318 if (Buffer) {
15319 return Buffer.from(str).toString("base64");
15320 } else {
15321 return window.btoa(unescape(encodeURIComponent(str)));
15322 }
15323 };
15324 _proto.toFileUrl = function toFileUrl(path) {
15325 var cached = this.memoizedFileURLs.get(path);
15326 if (cached) return cached;
15327 if (pathToFileURL) {
15328 var fileURL = pathToFileURL(path).toString();
15329 this.memoizedFileURLs.set(path, fileURL);
15330 return fileURL;
15331 } else {
15332 throw new Error("`map.absolute` option is not available in this PostCSS build");
15333 }
15334 };
15335 _proto.toUrl = function toUrl(path) {
15336 var cached = this.memoizedURLs.get(path);
15337 if (cached) return cached;
15338 if (sep === "\\") {
15339 path = path.replace(/\\/g, "/");
15340 }
15341 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
15342 this.memoizedURLs.set(path, url);
15343 return url;
15344 };
15345 return MapGenerator2;
15346 }();
15347 var mapGenerator = MapGenerator$2;
15348 var Node$2 = node;
15349 var Comment$4 = /*#__PURE__*/ function(Node$2) {
15350 _inherits(Comment2, Node$2);
15351 function Comment2(defaults) {
15352 var _this;
15353 _this = Node$2.call(this, defaults) || this;
15354 _this.type = "comment";
15355 return _this;
15356 }
15357 return Comment2;
15358 }(Node$2);
15359 var comment = Comment$4;
15360 Comment$4.default = Comment$4;
15361 var isClean$1 = symbols.isClean, my$1 = symbols.my;
15362 var Declaration$3 = declaration;
15363 var Comment$3 = comment;
15364 var Node$1 = node;
15365 var parse$4, Rule$4, AtRule$4, Root$6;
15366 function cleanSource(nodes) {
15367 return nodes.map(function(i2) {
15368 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
15369 delete i2.source;
15370 return i2;
15371 });
15372 }
15373 function markDirtyUp(node2) {
15374 node2[isClean$1] = false;
15375 if (node2.proxyOf.nodes) {
15376 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15377 var i2 = _step.value;
15378 markDirtyUp(i2);
15379 }
15380 }
15381 }
15382 var Container$7 = /*#__PURE__*/ function(Node$1) {
15383 _inherits(Container2, Node$1);
15384 function Container2() {
15385 return Node$1.apply(this, arguments) || this;
15386 }
15387 var _proto = Container2.prototype;
15388 _proto.append = function append() {
15389 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15390 children[_key] = arguments[_key];
15391 }
15392 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15393 var child = _step.value;
15394 var nodes = this.normalize(child, this.last);
15395 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15396 var node2 = _step1.value;
15397 this.proxyOf.nodes.push(node2);
15398 }
15399 }
15400 this.markDirty();
15401 return this;
15402 };
15403 _proto.cleanRaws = function cleanRaws(keepBetween) {
15404 Node$1.prototype.cleanRaws.call(this, keepBetween);
15405 if (this.nodes) {
15406 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
15407 var node2 = _step.value;
15408 node2.cleanRaws(keepBetween);
15409 }
15410 }
15411 };
15412 _proto.each = function each(callback) {
15413 if (!this.proxyOf.nodes) return void 0;
15414 var iterator = this.getIterator();
15415 var index2, result2;
15416 while(this.indexes[iterator] < this.proxyOf.nodes.length){
15417 index2 = this.indexes[iterator];
15418 result2 = callback(this.proxyOf.nodes[index2], index2);
15419 if (result2 === false) break;
15420 this.indexes[iterator] += 1;
15421 }
15422 delete this.indexes[iterator];
15423 return result2;
15424 };
15425 _proto.every = function every(condition) {
15426 return this.nodes.every(condition);
15427 };
15428 _proto.getIterator = function getIterator() {
15429 if (!this.lastEach) this.lastEach = 0;
15430 if (!this.indexes) this.indexes = {};
15431 this.lastEach += 1;
15432 var iterator = this.lastEach;
15433 this.indexes[iterator] = 0;
15434 return iterator;
15435 };
15436 _proto.getProxyProcessor = function getProxyProcessor() {
15437 return {
15438 get: function get(node2, prop) {
15439 if (prop === "proxyOf") {
15440 return node2;
15441 } else if (!node2[prop]) {
15442 return node2[prop];
15443 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
15444 return function() {
15445 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
15446 args[_key] = arguments[_key];
15447 }
15448 var _node2;
15449 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
15450 if (typeof i2 === "function") {
15451 return function(child, index2) {
15452 return i2(child.toProxy(), index2);
15453 };
15454 } else {
15455 return i2;
15456 }
15457 })));
15458 };
15459 } else if (prop === "every" || prop === "some") {
15460 return function(cb) {
15461 return node2[prop](function(child) {
15462 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
15463 other[_key - 1] = arguments[_key];
15464 }
15465 return cb.apply(void 0, [].concat([
15466 child.toProxy()
15467 ], other));
15468 });
15469 };
15470 } else if (prop === "root") {
15471 return function() {
15472 return node2.root().toProxy();
15473 };
15474 } else if (prop === "nodes") {
15475 return node2.nodes.map(function(i2) {
15476 return i2.toProxy();
15477 });
15478 } else if (prop === "first" || prop === "last") {
15479 return node2[prop].toProxy();
15480 } else {
15481 return node2[prop];
15482 }
15483 },
15484 set: function set(node2, prop, value) {
15485 if (node2[prop] === value) return true;
15486 node2[prop] = value;
15487 if (prop === "name" || prop === "params" || prop === "selector") {
15488 node2.markDirty();
15489 }
15490 return true;
15491 }
15492 };
15493 };
15494 _proto.index = function index(child) {
15495 if (typeof child === "number") return child;
15496 if (child.proxyOf) child = child.proxyOf;
15497 return this.proxyOf.nodes.indexOf(child);
15498 };
15499 _proto.insertAfter = function insertAfter(exist, add) {
15500 var existIndex = this.index(exist);
15501 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
15502 existIndex = this.index(exist);
15503 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15504 var node2 = _step.value;
15505 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
15506 }
15507 var index2;
15508 for(var id in this.indexes){
15509 index2 = this.indexes[id];
15510 if (existIndex < index2) {
15511 this.indexes[id] = index2 + nodes.length;
15512 }
15513 }
15514 this.markDirty();
15515 return this;
15516 };
15517 _proto.insertBefore = function insertBefore(exist, add) {
15518 var existIndex = this.index(exist);
15519 var type = existIndex === 0 ? "prepend" : false;
15520 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
15521 existIndex = this.index(exist);
15522 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15523 var node2 = _step.value;
15524 this.proxyOf.nodes.splice(existIndex, 0, node2);
15525 }
15526 var index2;
15527 for(var id in this.indexes){
15528 index2 = this.indexes[id];
15529 if (existIndex <= index2) {
15530 this.indexes[id] = index2 + nodes.length;
15531 }
15532 }
15533 this.markDirty();
15534 return this;
15535 };
15536 _proto.normalize = function normalize(nodes, sample) {
15537 var _this = this;
15538 if (typeof nodes === "string") {
15539 nodes = cleanSource(parse$4(nodes).nodes);
15540 } else if (typeof nodes === "undefined") {
15541 nodes = [];
15542 } else if (Array.isArray(nodes)) {
15543 nodes = nodes.slice(0);
15544 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15545 var i2 = _step.value;
15546 if (i2.parent) i2.parent.removeChild(i2, "ignore");
15547 }
15548 } else if (nodes.type === "root" && this.type !== "document") {
15549 nodes = nodes.nodes.slice(0);
15550 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15551 var i21 = _step1.value;
15552 if (i21.parent) i21.parent.removeChild(i21, "ignore");
15553 }
15554 } else if (nodes.type) {
15555 nodes = [
15556 nodes
15557 ];
15558 } else if (nodes.prop) {
15559 if (typeof nodes.value === "undefined") {
15560 throw new Error("Value field is missed in node creation");
15561 } else if (typeof nodes.value !== "string") {
15562 nodes.value = String(nodes.value);
15563 }
15564 nodes = [
15565 new Declaration$3(nodes)
15566 ];
15567 } else if (nodes.selector) {
15568 nodes = [
15569 new Rule$4(nodes)
15570 ];
15571 } else if (nodes.name) {
15572 nodes = [
15573 new AtRule$4(nodes)
15574 ];
15575 } else if (nodes.text) {
15576 nodes = [
15577 new Comment$3(nodes)
15578 ];
15579 } else {
15580 throw new Error("Unknown node type in node creation");
15581 }
15582 var processed = nodes.map(function(i2) {
15583 if (!i2[my$1]) Container2.rebuild(i2);
15584 i2 = i2.proxyOf;
15585 if (i2.parent) i2.parent.removeChild(i2);
15586 if (i2[isClean$1]) markDirtyUp(i2);
15587 if (typeof i2.raws.before === "undefined") {
15588 if (sample && typeof sample.raws.before !== "undefined") {
15589 i2.raws.before = sample.raws.before.replace(/\S/g, "");
15590 }
15591 }
15592 i2.parent = _this.proxyOf;
15593 return i2;
15594 });
15595 return processed;
15596 };
15597 _proto.prepend = function prepend() {
15598 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15599 children[_key] = arguments[_key];
15600 }
15601 children = children.reverse();
15602 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15603 var child = _step.value;
15604 var nodes = this.normalize(child, this.first, "prepend").reverse();
15605 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15606 var node2 = _step1.value;
15607 this.proxyOf.nodes.unshift(node2);
15608 }
15609 for(var id in this.indexes){
15610 this.indexes[id] = this.indexes[id] + nodes.length;
15611 }
15612 }
15613 this.markDirty();
15614 return this;
15615 };
15616 _proto.push = function push(child) {
15617 child.parent = this;
15618 this.proxyOf.nodes.push(child);
15619 return this;
15620 };
15621 _proto.removeAll = function removeAll() {
15622 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15623 var node2 = _step.value;
15624 node2.parent = void 0;
15625 }
15626 this.proxyOf.nodes = [];
15627 this.markDirty();
15628 return this;
15629 };
15630 _proto.removeChild = function removeChild(child) {
15631 child = this.index(child);
15632 this.proxyOf.nodes[child].parent = void 0;
15633 this.proxyOf.nodes.splice(child, 1);
15634 var index2;
15635 for(var id in this.indexes){
15636 index2 = this.indexes[id];
15637 if (index2 >= child) {
15638 this.indexes[id] = index2 - 1;
15639 }
15640 }
15641 this.markDirty();
15642 return this;
15643 };
15644 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
15645 if (!callback) {
15646 callback = opts;
15647 opts = {};
15648 }
15649 this.walkDecls(function(decl) {
15650 if (opts.props && !opts.props.includes(decl.prop)) return;
15651 if (opts.fast && !decl.value.includes(opts.fast)) return;
15652 decl.value = decl.value.replace(pattern, callback);
15653 });
15654 this.markDirty();
15655 return this;
15656 };
15657 _proto.some = function some(condition) {
15658 return this.nodes.some(condition);
15659 };
15660 _proto.walk = function walk(callback) {
15661 return this.each(function(child, i2) {
15662 var result2;
15663 try {
15664 result2 = callback(child, i2);
15665 } catch (e2) {
15666 throw child.addToError(e2);
15667 }
15668 if (result2 !== false && child.walk) {
15669 result2 = child.walk(callback);
15670 }
15671 return result2;
15672 });
15673 };
15674 _proto.walkAtRules = function walkAtRules(name, callback) {
15675 if (!callback) {
15676 callback = name;
15677 return this.walk(function(child, i2) {
15678 if (child.type === "atrule") {
15679 return callback(child, i2);
15680 }
15681 });
15682 }
15683 if (_instanceof(name, RegExp)) {
15684 return this.walk(function(child, i2) {
15685 if (child.type === "atrule" && name.test(child.name)) {
15686 return callback(child, i2);
15687 }
15688 });
15689 }
15690 return this.walk(function(child, i2) {
15691 if (child.type === "atrule" && child.name === name) {
15692 return callback(child, i2);
15693 }
15694 });
15695 };
15696 _proto.walkComments = function walkComments(callback) {
15697 return this.walk(function(child, i2) {
15698 if (child.type === "comment") {
15699 return callback(child, i2);
15700 }
15701 });
15702 };
15703 _proto.walkDecls = function walkDecls(prop, callback) {
15704 if (!callback) {
15705 callback = prop;
15706 return this.walk(function(child, i2) {
15707 if (child.type === "decl") {
15708 return callback(child, i2);
15709 }
15710 });
15711 }
15712 if (_instanceof(prop, RegExp)) {
15713 return this.walk(function(child, i2) {
15714 if (child.type === "decl" && prop.test(child.prop)) {
15715 return callback(child, i2);
15716 }
15717 });
15718 }
15719 return this.walk(function(child, i2) {
15720 if (child.type === "decl" && child.prop === prop) {
15721 return callback(child, i2);
15722 }
15723 });
15724 };
15725 _proto.walkRules = function walkRules(selector, callback) {
15726 if (!callback) {
15727 callback = selector;
15728 return this.walk(function(child, i2) {
15729 if (child.type === "rule") {
15730 return callback(child, i2);
15731 }
15732 });
15733 }
15734 if (_instanceof(selector, RegExp)) {
15735 return this.walk(function(child, i2) {
15736 if (child.type === "rule" && selector.test(child.selector)) {
15737 return callback(child, i2);
15738 }
15739 });
15740 }
15741 return this.walk(function(child, i2) {
15742 if (child.type === "rule" && child.selector === selector) {
15743 return callback(child, i2);
15744 }
15745 });
15746 };
15747 _create_class(Container2, [
15748 {
15749 key: "first",
15750 get: function get() {
15751 if (!this.proxyOf.nodes) return void 0;
15752 return this.proxyOf.nodes[0];
15753 }
15754 },
15755 {
15756 key: "last",
15757 get: function get() {
15758 if (!this.proxyOf.nodes) return void 0;
15759 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
15760 }
15761 }
15762 ]);
15763 return Container2;
15764 }(Node$1);
15765 Container$7.registerParse = function(dependant) {
15766 parse$4 = dependant;
15767 };
15768 Container$7.registerRule = function(dependant) {
15769 Rule$4 = dependant;
15770 };
15771 Container$7.registerAtRule = function(dependant) {
15772 AtRule$4 = dependant;
15773 };
15774 Container$7.registerRoot = function(dependant) {
15775 Root$6 = dependant;
15776 };
15777 var container = Container$7;
15778 Container$7.default = Container$7;
15779 Container$7.rebuild = function(node2) {
15780 if (node2.type === "atrule") {
15781 Object.setPrototypeOf(node2, AtRule$4.prototype);
15782 } else if (node2.type === "rule") {
15783 Object.setPrototypeOf(node2, Rule$4.prototype);
15784 } else if (node2.type === "decl") {
15785 Object.setPrototypeOf(node2, Declaration$3.prototype);
15786 } else if (node2.type === "comment") {
15787 Object.setPrototypeOf(node2, Comment$3.prototype);
15788 } else if (node2.type === "root") {
15789 Object.setPrototypeOf(node2, Root$6.prototype);
15790 }
15791 node2[my$1] = true;
15792 if (node2.nodes) {
15793 node2.nodes.forEach(function(child) {
15794 Container$7.rebuild(child);
15795 });
15796 }
15797 };
15798 var Container$6 = container;
15799 var LazyResult$4, Processor$3;
15800 var Document$3 = /*#__PURE__*/ function(Container$6) {
15801 _inherits(Document23, Container$6);
15802 function Document23(defaults) {
15803 var _this;
15804 _this = Container$6.call(this, _extends({
15805 type: "document"
15806 }, defaults)) || this;
15807 if (!_this.nodes) {
15808 _this.nodes = [];
15809 }
15810 return _this;
15811 }
15812 var _proto = Document23.prototype;
15813 _proto.toResult = function toResult(opts) {
15814 if (opts === void 0) opts = {};
15815 var lazy = new LazyResult$4(new Processor$3(), this, opts);
15816 return lazy.stringify();
15817 };
15818 return Document23;
15819 }(Container$6);
15820 Document$3.registerLazyResult = function(dependant) {
15821 LazyResult$4 = dependant;
15822 };
15823 Document$3.registerProcessor = function(dependant) {
15824 Processor$3 = dependant;
15825 };
15826 var document$1$2 = Document$3;
15827 Document$3.default = Document$3;
15828 var printed = {};
15829 var warnOnce$2 = function warnOnce2(message) {
15830 if (printed[message]) return;
15831 printed[message] = true;
15832 if (typeof console !== "undefined" && console.warn) {
15833 console.warn(message);
15834 }
15835 };
15836 var Warning$2 = /*#__PURE__*/ function() {
15837 function Warning2(text, opts) {
15838 if (opts === void 0) opts = {};
15839 this.type = "warning";
15840 this.text = text;
15841 if (opts.node && opts.node.source) {
15842 var range = opts.node.rangeBy(opts);
15843 this.line = range.start.line;
15844 this.column = range.start.column;
15845 this.endLine = range.end.line;
15846 this.endColumn = range.end.column;
15847 }
15848 for(var opt in opts)this[opt] = opts[opt];
15849 }
15850 var _proto = Warning2.prototype;
15851 _proto.toString = function toString() {
15852 if (this.node) {
15853 return this.node.error(this.text, {
15854 index: this.index,
15855 plugin: this.plugin,
15856 word: this.word
15857 }).message;
15858 }
15859 if (this.plugin) {
15860 return this.plugin + ": " + this.text;
15861 }
15862 return this.text;
15863 };
15864 return Warning2;
15865 }();
15866 var warning = Warning$2;
15867 Warning$2.default = Warning$2;
15868 var Warning$1 = warning;
15869 var Result$3 = /*#__PURE__*/ function() {
15870 function Result2(processor2, root2, opts) {
15871 this.processor = processor2;
15872 this.messages = [];
15873 this.root = root2;
15874 this.opts = opts;
15875 this.css = void 0;
15876 this.map = void 0;
15877 }
15878 var _proto = Result2.prototype;
15879 _proto.toString = function toString() {
15880 return this.css;
15881 };
15882 _proto.warn = function warn(text, opts) {
15883 if (opts === void 0) opts = {};
15884 if (!opts.plugin) {
15885 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
15886 opts.plugin = this.lastPlugin.postcssPlugin;
15887 }
15888 }
15889 var warning2 = new Warning$1(text, opts);
15890 this.messages.push(warning2);
15891 return warning2;
15892 };
15893 _proto.warnings = function warnings() {
15894 return this.messages.filter(function(i2) {
15895 return i2.type === "warning";
15896 });
15897 };
15898 _create_class(Result2, [
15899 {
15900 key: "content",
15901 get: function get() {
15902 return this.css;
15903 }
15904 }
15905 ]);
15906 return Result2;
15907 }();
15908 var result = Result$3;
15909 Result$3.default = Result$3;
15910 var SINGLE_QUOTE = "'".charCodeAt(0);
15911 var DOUBLE_QUOTE = '"'.charCodeAt(0);
15912 var BACKSLASH = "\\".charCodeAt(0);
15913 var SLASH = "/".charCodeAt(0);
15914 var NEWLINE = "\n".charCodeAt(0);
15915 var SPACE = " ".charCodeAt(0);
15916 var FEED = "\f".charCodeAt(0);
15917 var TAB = " ".charCodeAt(0);
15918 var CR = "\r".charCodeAt(0);
15919 var OPEN_SQUARE = "[".charCodeAt(0);
15920 var CLOSE_SQUARE = "]".charCodeAt(0);
15921 var OPEN_PARENTHESES = "(".charCodeAt(0);
15922 var CLOSE_PARENTHESES = ")".charCodeAt(0);
15923 var OPEN_CURLY = "{".charCodeAt(0);
15924 var CLOSE_CURLY = "}".charCodeAt(0);
15925 var SEMICOLON = ";".charCodeAt(0);
15926 var ASTERISK = "*".charCodeAt(0);
15927 var COLON = ":".charCodeAt(0);
15928 var AT = "@".charCodeAt(0);
15929 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
15930 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
15931 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
15932 var RE_HEX_ESCAPE = /[\da-f]/i;
15933 var tokenize = function tokenizer2(input2, options) {
15934 if (options === void 0) options = {};
15935 var css = input2.css.valueOf();
15936 var ignore = options.ignoreErrors;
15937 var code, next, quote, content, escape;
15938 var escaped, escapePos, prev, n2, currentToken;
15939 var length = css.length;
15940 var pos = 0;
15941 var buffer = [];
15942 var returned = [];
15943 function position() {
15944 return pos;
15945 }
15946 function unclosed(what) {
15947 throw input2.error("Unclosed " + what, pos);
15948 }
15949 function endOfFile() {
15950 return returned.length === 0 && pos >= length;
15951 }
15952 function nextToken(opts) {
15953 if (returned.length) return returned.pop();
15954 if (pos >= length) return;
15955 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
15956 code = css.charCodeAt(pos);
15957 switch(code){
15958 case NEWLINE:
15959 case SPACE:
15960 case TAB:
15961 case CR:
15962 case FEED:
15963 {
15964 next = pos;
15965 do {
15966 next += 1;
15967 code = css.charCodeAt(next);
15968 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
15969 currentToken = [
15970 "space",
15971 css.slice(pos, next)
15972 ];
15973 pos = next - 1;
15974 break;
15975 }
15976 case OPEN_SQUARE:
15977 case CLOSE_SQUARE:
15978 case OPEN_CURLY:
15979 case CLOSE_CURLY:
15980 case COLON:
15981 case SEMICOLON:
15982 case CLOSE_PARENTHESES:
15983 {
15984 var controlChar = String.fromCharCode(code);
15985 currentToken = [
15986 controlChar,
15987 controlChar,
15988 pos
15989 ];
15990 break;
15991 }
15992 case OPEN_PARENTHESES:
15993 {
15994 prev = buffer.length ? buffer.pop()[1] : "";
15995 n2 = css.charCodeAt(pos + 1);
15996 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
15997 next = pos;
15998 do {
15999 escaped = false;
16000 next = css.indexOf(")", next + 1);
16001 if (next === -1) {
16002 if (ignore || ignoreUnclosed) {
16003 next = pos;
16004 break;
16005 } else {
16006 unclosed("bracket");
16007 }
16008 }
16009 escapePos = next;
16010 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16011 escapePos -= 1;
16012 escaped = !escaped;
16013 }
16014 }while (escaped);
16015 currentToken = [
16016 "brackets",
16017 css.slice(pos, next + 1),
16018 pos,
16019 next
16020 ];
16021 pos = next;
16022 } else {
16023 next = css.indexOf(")", pos + 1);
16024 content = css.slice(pos, next + 1);
16025 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16026 currentToken = [
16027 "(",
16028 "(",
16029 pos
16030 ];
16031 } else {
16032 currentToken = [
16033 "brackets",
16034 content,
16035 pos,
16036 next
16037 ];
16038 pos = next;
16039 }
16040 }
16041 break;
16042 }
16043 case SINGLE_QUOTE:
16044 case DOUBLE_QUOTE:
16045 {
16046 quote = code === SINGLE_QUOTE ? "'" : '"';
16047 next = pos;
16048 do {
16049 escaped = false;
16050 next = css.indexOf(quote, next + 1);
16051 if (next === -1) {
16052 if (ignore || ignoreUnclosed) {
16053 next = pos + 1;
16054 break;
16055 } else {
16056 unclosed("string");
16057 }
16058 }
16059 escapePos = next;
16060 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16061 escapePos -= 1;
16062 escaped = !escaped;
16063 }
16064 }while (escaped);
16065 currentToken = [
16066 "string",
16067 css.slice(pos, next + 1),
16068 pos,
16069 next
16070 ];
16071 pos = next;
16072 break;
16073 }
16074 case AT:
16075 {
16076 RE_AT_END.lastIndex = pos + 1;
16077 RE_AT_END.test(css);
16078 if (RE_AT_END.lastIndex === 0) {
16079 next = css.length - 1;
16080 } else {
16081 next = RE_AT_END.lastIndex - 2;
16082 }
16083 currentToken = [
16084 "at-word",
16085 css.slice(pos, next + 1),
16086 pos,
16087 next
16088 ];
16089 pos = next;
16090 break;
16091 }
16092 case BACKSLASH:
16093 {
16094 next = pos;
16095 escape = true;
16096 while(css.charCodeAt(next + 1) === BACKSLASH){
16097 next += 1;
16098 escape = !escape;
16099 }
16100 code = css.charCodeAt(next + 1);
16101 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16102 next += 1;
16103 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16104 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16105 next += 1;
16106 }
16107 if (css.charCodeAt(next + 1) === SPACE) {
16108 next += 1;
16109 }
16110 }
16111 }
16112 currentToken = [
16113 "word",
16114 css.slice(pos, next + 1),
16115 pos,
16116 next
16117 ];
16118 pos = next;
16119 break;
16120 }
16121 default:
16122 {
16123 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16124 next = css.indexOf("*/", pos + 2) + 1;
16125 if (next === 0) {
16126 if (ignore || ignoreUnclosed) {
16127 next = css.length;
16128 } else {
16129 unclosed("comment");
16130 }
16131 }
16132 currentToken = [
16133 "comment",
16134 css.slice(pos, next + 1),
16135 pos,
16136 next
16137 ];
16138 pos = next;
16139 } else {
16140 RE_WORD_END.lastIndex = pos + 1;
16141 RE_WORD_END.test(css);
16142 if (RE_WORD_END.lastIndex === 0) {
16143 next = css.length - 1;
16144 } else {
16145 next = RE_WORD_END.lastIndex - 2;
16146 }
16147 currentToken = [
16148 "word",
16149 css.slice(pos, next + 1),
16150 pos,
16151 next
16152 ];
16153 buffer.push(currentToken);
16154 pos = next;
16155 }
16156 break;
16157 }
16158 }
16159 pos++;
16160 return currentToken;
16161 }
16162 function back(token) {
16163 returned.push(token);
16164 }
16165 return {
16166 back: back,
16167 endOfFile: endOfFile,
16168 nextToken: nextToken,
16169 position: position
16170 };
16171 };
16172 var Container$5 = container;
16173 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16174 _inherits(AtRule2, Container$5);
16175 function AtRule2(defaults) {
16176 var _this;
16177 _this = Container$5.call(this, defaults) || this;
16178 _this.type = "atrule";
16179 return _this;
16180 }
16181 var _proto = AtRule2.prototype;
16182 _proto.append = function append() {
16183 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16184 children[_key] = arguments[_key];
16185 }
16186 var _Container$5_prototype_append;
16187 if (!this.proxyOf.nodes) this.nodes = [];
16188 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
16189 this
16190 ], children));
16191 };
16192 _proto.prepend = function prepend() {
16193 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16194 children[_key] = arguments[_key];
16195 }
16196 var _Container$5_prototype_prepend;
16197 if (!this.proxyOf.nodes) this.nodes = [];
16198 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
16199 this
16200 ], children));
16201 };
16202 return AtRule2;
16203 }(Container$5);
16204 var atRule = AtRule$3;
16205 AtRule$3.default = AtRule$3;
16206 Container$5.registerAtRule(AtRule$3);
16207 var Container$4 = container;
16208 var LazyResult$3, Processor$2;
16209 var Root$5 = /*#__PURE__*/ function(Container$4) {
16210 _inherits(Root2, Container$4);
16211 function Root2(defaults) {
16212 var _this;
16213 _this = Container$4.call(this, defaults) || this;
16214 _this.type = "root";
16215 if (!_this.nodes) _this.nodes = [];
16216 return _this;
16217 }
16218 var _proto = Root2.prototype;
16219 _proto.normalize = function normalize(child, sample, type) {
16220 var nodes = Container$4.prototype.normalize.call(this, child);
16221 if (sample) {
16222 if (type === "prepend") {
16223 if (this.nodes.length > 1) {
16224 sample.raws.before = this.nodes[1].raws.before;
16225 } else {
16226 delete sample.raws.before;
16227 }
16228 } else if (this.first !== sample) {
16229 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16230 var node2 = _step.value;
16231 node2.raws.before = sample.raws.before;
16232 }
16233 }
16234 }
16235 return nodes;
16236 };
16237 _proto.removeChild = function removeChild(child, ignore) {
16238 var index2 = this.index(child);
16239 if (!ignore && index2 === 0 && this.nodes.length > 1) {
16240 this.nodes[1].raws.before = this.nodes[index2].raws.before;
16241 }
16242 return Container$4.prototype.removeChild.call(this, child);
16243 };
16244 _proto.toResult = function toResult(opts) {
16245 if (opts === void 0) opts = {};
16246 var lazy = new LazyResult$3(new Processor$2(), this, opts);
16247 return lazy.stringify();
16248 };
16249 return Root2;
16250 }(Container$4);
16251 Root$5.registerLazyResult = function(dependant) {
16252 LazyResult$3 = dependant;
16253 };
16254 Root$5.registerProcessor = function(dependant) {
16255 Processor$2 = dependant;
16256 };
16257 var root = Root$5;
16258 Root$5.default = Root$5;
16259 Container$4.registerRoot(Root$5);
16260 var list$2 = {
16261 comma: function comma(string) {
16262 return list$2.split(string, [
16263 ","
16264 ], true);
16265 },
16266 space: function space(string) {
16267 var spaces = [
16268 " ",
16269 "\n",
16270 " "
16271 ];
16272 return list$2.split(string, spaces);
16273 },
16274 split: function split(string, separators, last) {
16275 var array = [];
16276 var current = "";
16277 var split = false;
16278 var func = 0;
16279 var inQuote = false;
16280 var prevQuote = "";
16281 var escape = false;
16282 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
16283 var letter = _step.value;
16284 if (escape) {
16285 escape = false;
16286 } else if (letter === "\\") {
16287 escape = true;
16288 } else if (inQuote) {
16289 if (letter === prevQuote) {
16290 inQuote = false;
16291 }
16292 } else if (letter === '"' || letter === "'") {
16293 inQuote = true;
16294 prevQuote = letter;
16295 } else if (letter === "(") {
16296 func += 1;
16297 } else if (letter === ")") {
16298 if (func > 0) func -= 1;
16299 } else if (func === 0) {
16300 if (separators.includes(letter)) split = true;
16301 }
16302 if (split) {
16303 if (current !== "") array.push(current.trim());
16304 current = "";
16305 split = false;
16306 } else {
16307 current += letter;
16308 }
16309 }
16310 if (last || current !== "") array.push(current.trim());
16311 return array;
16312 }
16313 };
16314 var list_1 = list$2;
16315 list$2.default = list$2;
16316 var Container$3 = container;
16317 var list$1 = list_1;
16318 var Rule$3 = /*#__PURE__*/ function(Container$3) {
16319 _inherits(Rule2, Container$3);
16320 function Rule2(defaults) {
16321 var _this;
16322 _this = Container$3.call(this, defaults) || this;
16323 _this.type = "rule";
16324 if (!_this.nodes) _this.nodes = [];
16325 return _this;
16326 }
16327 _create_class(Rule2, [
16328 {
16329 key: "selectors",
16330 get: function get() {
16331 return list$1.comma(this.selector);
16332 },
16333 set: function set(values) {
16334 var match = this.selector ? this.selector.match(/,\s*/) : null;
16335 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
16336 this.selector = values.join(sep2);
16337 }
16338 }
16339 ]);
16340 return Rule2;
16341 }(Container$3);
16342 var rule = Rule$3;
16343 Rule$3.default = Rule$3;
16344 Container$3.registerRule(Rule$3);
16345 var Declaration$2 = declaration;
16346 var tokenizer22 = tokenize;
16347 var Comment$2 = comment;
16348 var AtRule$2 = atRule;
16349 var Root$4 = root;
16350 var Rule$2 = rule;
16351 var SAFE_COMMENT_NEIGHBOR = {
16352 empty: true,
16353 space: true
16354 };
16355 function findLastWithPosition(tokens) {
16356 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16357 var token = tokens[i2];
16358 var pos = token[3] || token[2];
16359 if (pos) return pos;
16360 }
16361 }
16362 var Parser$1 = /*#__PURE__*/ function() {
16363 function Parser2(input2) {
16364 this.input = input2;
16365 this.root = new Root$4();
16366 this.current = this.root;
16367 this.spaces = "";
16368 this.semicolon = false;
16369 this.createTokenizer();
16370 this.root.source = {
16371 input: input2,
16372 start: {
16373 column: 1,
16374 line: 1,
16375 offset: 0
16376 }
16377 };
16378 }
16379 var _proto = Parser2.prototype;
16380 _proto.atrule = function atrule(token) {
16381 var node2 = new AtRule$2();
16382 node2.name = token[1].slice(1);
16383 if (node2.name === "") {
16384 this.unnamedAtrule(node2, token);
16385 }
16386 this.init(node2, token[2]);
16387 var type;
16388 var prev;
16389 var shift;
16390 var last = false;
16391 var open = false;
16392 var params = [];
16393 var brackets = [];
16394 while(!this.tokenizer.endOfFile()){
16395 token = this.tokenizer.nextToken();
16396 type = token[0];
16397 if (type === "(" || type === "[") {
16398 brackets.push(type === "(" ? ")" : "]");
16399 } else if (type === "{" && brackets.length > 0) {
16400 brackets.push("}");
16401 } else if (type === brackets[brackets.length - 1]) {
16402 brackets.pop();
16403 }
16404 if (brackets.length === 0) {
16405 if (type === ";") {
16406 node2.source.end = this.getPosition(token[2]);
16407 node2.source.end.offset++;
16408 this.semicolon = true;
16409 break;
16410 } else if (type === "{") {
16411 open = true;
16412 break;
16413 } else if (type === "}") {
16414 if (params.length > 0) {
16415 shift = params.length - 1;
16416 prev = params[shift];
16417 while(prev && prev[0] === "space"){
16418 prev = params[--shift];
16419 }
16420 if (prev) {
16421 node2.source.end = this.getPosition(prev[3] || prev[2]);
16422 node2.source.end.offset++;
16423 }
16424 }
16425 this.end(token);
16426 break;
16427 } else {
16428 params.push(token);
16429 }
16430 } else {
16431 params.push(token);
16432 }
16433 if (this.tokenizer.endOfFile()) {
16434 last = true;
16435 break;
16436 }
16437 }
16438 node2.raws.between = this.spacesAndCommentsFromEnd(params);
16439 if (params.length) {
16440 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
16441 this.raw(node2, "params", params);
16442 if (last) {
16443 token = params[params.length - 1];
16444 node2.source.end = this.getPosition(token[3] || token[2]);
16445 node2.source.end.offset++;
16446 this.spaces = node2.raws.between;
16447 node2.raws.between = "";
16448 }
16449 } else {
16450 node2.raws.afterName = "";
16451 node2.params = "";
16452 }
16453 if (open) {
16454 node2.nodes = [];
16455 this.current = node2;
16456 }
16457 };
16458 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
16459 var colon = this.colon(tokens);
16460 if (colon === false) return;
16461 var founded = 0;
16462 var token;
16463 for(var j = colon - 1; j >= 0; j--){
16464 token = tokens[j];
16465 if (token[0] !== "space") {
16466 founded += 1;
16467 if (founded === 2) break;
16468 }
16469 }
16470 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
16471 };
16472 _proto.colon = function colon(tokens) {
16473 var brackets = 0;
16474 var token, type, prev;
16475 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
16476 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
16477 token = element;
16478 type = token[0];
16479 if (type === "(") {
16480 brackets += 1;
16481 }
16482 if (type === ")") {
16483 brackets -= 1;
16484 }
16485 if (brackets === 0 && type === ":") {
16486 if (!prev) {
16487 this.doubleColon(token);
16488 } else if (prev[0] === "word" && prev[1] === "progid") {
16489 continue;
16490 } else {
16491 return i2;
16492 }
16493 }
16494 prev = token;
16495 }
16496 return false;
16497 };
16498 _proto.comment = function comment(token) {
16499 var node2 = new Comment$2();
16500 this.init(node2, token[2]);
16501 node2.source.end = this.getPosition(token[3] || token[2]);
16502 node2.source.end.offset++;
16503 var text = token[1].slice(2, -2);
16504 if (/^\s*$/.test(text)) {
16505 node2.text = "";
16506 node2.raws.left = text;
16507 node2.raws.right = "";
16508 } else {
16509 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
16510 node2.text = match[2];
16511 node2.raws.left = match[1];
16512 node2.raws.right = match[3];
16513 }
16514 };
16515 _proto.createTokenizer = function createTokenizer() {
16516 this.tokenizer = tokenizer22(this.input);
16517 };
16518 _proto.decl = function decl(tokens, customProperty) {
16519 var node2 = new Declaration$2();
16520 this.init(node2, tokens[0][2]);
16521 var last = tokens[tokens.length - 1];
16522 if (last[0] === ";") {
16523 this.semicolon = true;
16524 tokens.pop();
16525 }
16526 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
16527 node2.source.end.offset++;
16528 while(tokens[0][0] !== "word"){
16529 if (tokens.length === 1) this.unknownWord(tokens);
16530 node2.raws.before += tokens.shift()[1];
16531 }
16532 node2.source.start = this.getPosition(tokens[0][2]);
16533 node2.prop = "";
16534 while(tokens.length){
16535 var type = tokens[0][0];
16536 if (type === ":" || type === "space" || type === "comment") {
16537 break;
16538 }
16539 node2.prop += tokens.shift()[1];
16540 }
16541 node2.raws.between = "";
16542 var token;
16543 while(tokens.length){
16544 token = tokens.shift();
16545 if (token[0] === ":") {
16546 node2.raws.between += token[1];
16547 break;
16548 } else {
16549 if (token[0] === "word" && /\w/.test(token[1])) {
16550 this.unknownWord([
16551 token
16552 ]);
16553 }
16554 node2.raws.between += token[1];
16555 }
16556 }
16557 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
16558 node2.raws.before += node2.prop[0];
16559 node2.prop = node2.prop.slice(1);
16560 }
16561 var firstSpaces = [];
16562 var next;
16563 while(tokens.length){
16564 next = tokens[0][0];
16565 if (next !== "space" && next !== "comment") break;
16566 firstSpaces.push(tokens.shift());
16567 }
16568 this.precheckMissedSemicolon(tokens);
16569 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16570 token = tokens[i2];
16571 if (token[1].toLowerCase() === "!important") {
16572 node2.important = true;
16573 var string = this.stringFrom(tokens, i2);
16574 string = this.spacesFromEnd(tokens) + string;
16575 if (string !== " !important") node2.raws.important = string;
16576 break;
16577 } else if (token[1].toLowerCase() === "important") {
16578 var cache = tokens.slice(0);
16579 var str = "";
16580 for(var j = i2; j > 0; j--){
16581 var type1 = cache[j][0];
16582 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
16583 break;
16584 }
16585 str = cache.pop()[1] + str;
16586 }
16587 if (str.trim().indexOf("!") === 0) {
16588 node2.important = true;
16589 node2.raws.important = str;
16590 tokens = cache;
16591 }
16592 }
16593 if (token[0] !== "space" && token[0] !== "comment") {
16594 break;
16595 }
16596 }
16597 var hasWord = tokens.some(function(i2) {
16598 return i2[0] !== "space" && i2[0] !== "comment";
16599 });
16600 if (hasWord) {
16601 node2.raws.between += firstSpaces.map(function(i2) {
16602 return i2[1];
16603 }).join("");
16604 firstSpaces = [];
16605 }
16606 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
16607 if (node2.value.includes(":") && !customProperty) {
16608 this.checkMissedSemicolon(tokens);
16609 }
16610 };
16611 _proto.doubleColon = function doubleColon(token) {
16612 throw this.input.error("Double colon", {
16613 offset: token[2]
16614 }, {
16615 offset: token[2] + token[1].length
16616 });
16617 };
16618 _proto.emptyRule = function emptyRule(token) {
16619 var node2 = new Rule$2();
16620 this.init(node2, token[2]);
16621 node2.selector = "";
16622 node2.raws.between = "";
16623 this.current = node2;
16624 };
16625 _proto.end = function end(token) {
16626 if (this.current.nodes && this.current.nodes.length) {
16627 this.current.raws.semicolon = this.semicolon;
16628 }
16629 this.semicolon = false;
16630 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16631 this.spaces = "";
16632 if (this.current.parent) {
16633 this.current.source.end = this.getPosition(token[2]);
16634 this.current.source.end.offset++;
16635 this.current = this.current.parent;
16636 } else {
16637 this.unexpectedClose(token);
16638 }
16639 };
16640 _proto.endFile = function endFile() {
16641 if (this.current.parent) this.unclosedBlock();
16642 if (this.current.nodes && this.current.nodes.length) {
16643 this.current.raws.semicolon = this.semicolon;
16644 }
16645 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16646 this.root.source.end = this.getPosition(this.tokenizer.position());
16647 };
16648 _proto.freeSemicolon = function freeSemicolon(token) {
16649 this.spaces += token[1];
16650 if (this.current.nodes) {
16651 var prev = this.current.nodes[this.current.nodes.length - 1];
16652 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
16653 prev.raws.ownSemicolon = this.spaces;
16654 this.spaces = "";
16655 }
16656 }
16657 };
16658 // Helpers
16659 _proto.getPosition = function getPosition(offset) {
16660 var pos = this.input.fromOffset(offset);
16661 return {
16662 column: pos.col,
16663 line: pos.line,
16664 offset: offset
16665 };
16666 };
16667 _proto.init = function init(node2, offset) {
16668 this.current.push(node2);
16669 node2.source = {
16670 input: this.input,
16671 start: this.getPosition(offset)
16672 };
16673 node2.raws.before = this.spaces;
16674 this.spaces = "";
16675 if (node2.type !== "comment") this.semicolon = false;
16676 };
16677 _proto.other = function other(start) {
16678 var end = false;
16679 var type = null;
16680 var colon = false;
16681 var bracket = null;
16682 var brackets = [];
16683 var customProperty = start[1].startsWith("--");
16684 var tokens = [];
16685 var token = start;
16686 while(token){
16687 type = token[0];
16688 tokens.push(token);
16689 if (type === "(" || type === "[") {
16690 if (!bracket) bracket = token;
16691 brackets.push(type === "(" ? ")" : "]");
16692 } else if (customProperty && colon && type === "{") {
16693 if (!bracket) bracket = token;
16694 brackets.push("}");
16695 } else if (brackets.length === 0) {
16696 if (type === ";") {
16697 if (colon) {
16698 this.decl(tokens, customProperty);
16699 return;
16700 } else {
16701 break;
16702 }
16703 } else if (type === "{") {
16704 this.rule(tokens);
16705 return;
16706 } else if (type === "}") {
16707 this.tokenizer.back(tokens.pop());
16708 end = true;
16709 break;
16710 } else if (type === ":") {
16711 colon = true;
16712 }
16713 } else if (type === brackets[brackets.length - 1]) {
16714 brackets.pop();
16715 if (brackets.length === 0) bracket = null;
16716 }
16717 token = this.tokenizer.nextToken();
16718 }
16719 if (this.tokenizer.endOfFile()) end = true;
16720 if (brackets.length > 0) this.unclosedBracket(bracket);
16721 if (end && colon) {
16722 if (!customProperty) {
16723 while(tokens.length){
16724 token = tokens[tokens.length - 1][0];
16725 if (token !== "space" && token !== "comment") break;
16726 this.tokenizer.back(tokens.pop());
16727 }
16728 }
16729 this.decl(tokens, customProperty);
16730 } else {
16731 this.unknownWord(tokens);
16732 }
16733 };
16734 _proto.parse = function parse() {
16735 var token;
16736 while(!this.tokenizer.endOfFile()){
16737 token = this.tokenizer.nextToken();
16738 switch(token[0]){
16739 case "space":
16740 this.spaces += token[1];
16741 break;
16742 case ";":
16743 this.freeSemicolon(token);
16744 break;
16745 case "}":
16746 this.end(token);
16747 break;
16748 case "comment":
16749 this.comment(token);
16750 break;
16751 case "at-word":
16752 this.atrule(token);
16753 break;
16754 case "{":
16755 this.emptyRule(token);
16756 break;
16757 default:
16758 this.other(token);
16759 break;
16760 }
16761 }
16762 this.endFile();
16763 };
16764 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
16765 _proto.raw = function raw(node2, prop, tokens, customProperty) {
16766 var token, type;
16767 var length = tokens.length;
16768 var value = "";
16769 var clean = true;
16770 var next, prev;
16771 for(var i2 = 0; i2 < length; i2 += 1){
16772 token = tokens[i2];
16773 type = token[0];
16774 if (type === "space" && i2 === length - 1 && !customProperty) {
16775 clean = false;
16776 } else if (type === "comment") {
16777 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
16778 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
16779 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
16780 if (value.slice(-1) === ",") {
16781 clean = false;
16782 } else {
16783 value += token[1];
16784 }
16785 } else {
16786 clean = false;
16787 }
16788 } else {
16789 value += token[1];
16790 }
16791 }
16792 if (!clean) {
16793 var raw = tokens.reduce(function(all, i2) {
16794 return all + i2[1];
16795 }, "");
16796 node2.raws[prop] = {
16797 raw: raw,
16798 value: value
16799 };
16800 }
16801 node2[prop] = value;
16802 };
16803 _proto.rule = function rule(tokens) {
16804 tokens.pop();
16805 var node2 = new Rule$2();
16806 this.init(node2, tokens[0][2]);
16807 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
16808 this.raw(node2, "selector", tokens);
16809 this.current = node2;
16810 };
16811 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
16812 var lastTokenType;
16813 var spaces = "";
16814 while(tokens.length){
16815 lastTokenType = tokens[tokens.length - 1][0];
16816 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
16817 spaces = tokens.pop()[1] + spaces;
16818 }
16819 return spaces;
16820 };
16821 // Errors
16822 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
16823 var next;
16824 var spaces = "";
16825 while(tokens.length){
16826 next = tokens[0][0];
16827 if (next !== "space" && next !== "comment") break;
16828 spaces += tokens.shift()[1];
16829 }
16830 return spaces;
16831 };
16832 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
16833 var lastTokenType;
16834 var spaces = "";
16835 while(tokens.length){
16836 lastTokenType = tokens[tokens.length - 1][0];
16837 if (lastTokenType !== "space") break;
16838 spaces = tokens.pop()[1] + spaces;
16839 }
16840 return spaces;
16841 };
16842 _proto.stringFrom = function stringFrom(tokens, from) {
16843 var result2 = "";
16844 for(var i2 = from; i2 < tokens.length; i2++){
16845 result2 += tokens[i2][1];
16846 }
16847 tokens.splice(from, tokens.length - from);
16848 return result2;
16849 };
16850 _proto.unclosedBlock = function unclosedBlock() {
16851 var pos = this.current.source.start;
16852 throw this.input.error("Unclosed block", pos.line, pos.column);
16853 };
16854 _proto.unclosedBracket = function unclosedBracket(bracket) {
16855 throw this.input.error("Unclosed bracket", {
16856 offset: bracket[2]
16857 }, {
16858 offset: bracket[2] + 1
16859 });
16860 };
16861 _proto.unexpectedClose = function unexpectedClose(token) {
16862 throw this.input.error("Unexpected }", {
16863 offset: token[2]
16864 }, {
16865 offset: token[2] + 1
16866 });
16867 };
16868 _proto.unknownWord = function unknownWord(tokens) {
16869 throw this.input.error("Unknown word", {
16870 offset: tokens[0][2]
16871 }, {
16872 offset: tokens[0][2] + tokens[0][1].length
16873 });
16874 };
16875 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
16876 throw this.input.error("At-rule without name", {
16877 offset: token[2]
16878 }, {
16879 offset: token[2] + token[1].length
16880 });
16881 };
16882 return Parser2;
16883 }();
16884 var parser = Parser$1;
16885 var Container$2 = container;
16886 var Parser22 = parser;
16887 var Input$2 = input;
16888 function parse$3(css, opts) {
16889 var input2 = new Input$2(css, opts);
16890 var parser2 = new Parser22(input2);
16891 try {
16892 parser2.parse();
16893 } catch (e2) {
16894 if (true) {
16895 if (e2.name === "CssSyntaxError" && opts && opts.from) {
16896 if (/\.scss$/i.test(opts.from)) {
16897 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
16898 } else if (/\.sass/i.test(opts.from)) {
16899 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
16900 } else if (/\.less$/i.test(opts.from)) {
16901 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
16902 }
16903 }
16904 }
16905 throw e2;
16906 }
16907 return parser2.root;
16908 }
16909 var parse_1 = parse$3;
16910 parse$3.default = parse$3;
16911 Container$2.registerParse(parse$3);
16912 var isClean = symbols.isClean, my = symbols.my;
16913 var MapGenerator$1 = mapGenerator;
16914 var stringify$2 = stringify_1;
16915 var Container$1 = container;
16916 var Document$2 = document$1$2;
16917 var warnOnce$1 = warnOnce$2;
16918 var Result$2 = result;
16919 var parse$2 = parse_1;
16920 var Root$3 = root;
16921 var TYPE_TO_CLASS_NAME = {
16922 atrule: "AtRule",
16923 comment: "Comment",
16924 decl: "Declaration",
16925 document: "Document",
16926 root: "Root",
16927 rule: "Rule"
16928 };
16929 var PLUGIN_PROPS = {
16930 AtRule: true,
16931 AtRuleExit: true,
16932 Comment: true,
16933 CommentExit: true,
16934 Declaration: true,
16935 DeclarationExit: true,
16936 Document: true,
16937 DocumentExit: true,
16938 Once: true,
16939 OnceExit: true,
16940 postcssPlugin: true,
16941 prepare: true,
16942 Root: true,
16943 RootExit: true,
16944 Rule: true,
16945 RuleExit: true
16946 };
16947 var NOT_VISITORS = {
16948 Once: true,
16949 postcssPlugin: true,
16950 prepare: true
16951 };
16952 var CHILDREN = 0;
16953 function isPromise(obj) {
16954 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
16955 }
16956 function getEvents(node2) {
16957 var key = false;
16958 var type = TYPE_TO_CLASS_NAME[node2.type];
16959 if (node2.type === "decl") {
16960 key = node2.prop.toLowerCase();
16961 } else if (node2.type === "atrule") {
16962 key = node2.name.toLowerCase();
16963 }
16964 if (key && node2.append) {
16965 return [
16966 type,
16967 type + "-" + key,
16968 CHILDREN,
16969 type + "Exit",
16970 type + "Exit-" + key
16971 ];
16972 } else if (key) {
16973 return [
16974 type,
16975 type + "-" + key,
16976 type + "Exit",
16977 type + "Exit-" + key
16978 ];
16979 } else if (node2.append) {
16980 return [
16981 type,
16982 CHILDREN,
16983 type + "Exit"
16984 ];
16985 } else {
16986 return [
16987 type,
16988 type + "Exit"
16989 ];
16990 }
16991 }
16992 function toStack(node2) {
16993 var events;
16994 if (node2.type === "document") {
16995 events = [
16996 "Document",
16997 CHILDREN,
16998 "DocumentExit"
16999 ];
17000 } else if (node2.type === "root") {
17001 events = [
17002 "Root",
17003 CHILDREN,
17004 "RootExit"
17005 ];
17006 } else {
17007 events = getEvents(node2);
17008 }
17009 return {
17010 eventIndex: 0,
17011 events: events,
17012 iterator: 0,
17013 node: node2,
17014 visitorIndex: 0,
17015 visitors: []
17016 };
17017 }
17018 function cleanMarks(node2) {
17019 node2[isClean] = false;
17020 if (node2.nodes) node2.nodes.forEach(function(i2) {
17021 return cleanMarks(i2);
17022 });
17023 return node2;
17024 }
17025 var postcss$2 = {};
17026 var LazyResult$2 = /*#__PURE__*/ function() {
17027 function LazyResult2(processor2, css, opts) {
17028 var _this = this;
17029 this.stringified = false;
17030 this.processed = false;
17031 var root2;
17032 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17033 root2 = cleanMarks(css);
17034 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17035 root2 = cleanMarks(css.root);
17036 if (css.map) {
17037 if (typeof opts.map === "undefined") opts.map = {};
17038 if (!opts.map.inline) opts.map.inline = false;
17039 opts.map.prev = css.map;
17040 }
17041 } else {
17042 var parser2 = parse$2;
17043 if (opts.syntax) parser2 = opts.syntax.parse;
17044 if (opts.parser) parser2 = opts.parser;
17045 if (parser2.parse) parser2 = parser2.parse;
17046 try {
17047 root2 = parser2(css, opts);
17048 } catch (error) {
17049 this.processed = true;
17050 this.error = error;
17051 }
17052 if (root2 && !root2[my]) {
17053 Container$1.rebuild(root2);
17054 }
17055 }
17056 this.result = new Result$2(processor2, root2, opts);
17057 this.helpers = _extends({}, postcss$2, {
17058 postcss: postcss$2,
17059 result: this.result
17060 });
17061 this.plugins = this.processor.plugins.map(function(plugin22) {
17062 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17063 return _extends({}, plugin22, plugin22.prepare(_this.result));
17064 } else {
17065 return plugin22;
17066 }
17067 });
17068 }
17069 var _proto = LazyResult2.prototype;
17070 _proto.async = function async() {
17071 if (this.error) return Promise.reject(this.error);
17072 if (this.processed) return Promise.resolve(this.result);
17073 if (!this.processing) {
17074 this.processing = this.runAsync();
17075 }
17076 return this.processing;
17077 };
17078 _proto.catch = function _catch(onRejected) {
17079 return this.async().catch(onRejected);
17080 };
17081 _proto.finally = function _finally(onFinally) {
17082 return this.async().then(onFinally, onFinally);
17083 };
17084 _proto.getAsyncError = function getAsyncError() {
17085 throw new Error("Use process(css).then(cb) to work with async plugins");
17086 };
17087 _proto.handleError = function handleError(error, node2) {
17088 var plugin22 = this.result.lastPlugin;
17089 try {
17090 if (node2) node2.addToError(error);
17091 this.error = error;
17092 if (error.name === "CssSyntaxError" && !error.plugin) {
17093 error.plugin = plugin22.postcssPlugin;
17094 error.setMessage();
17095 } else if (plugin22.postcssVersion) {
17096 if (true) {
17097 var pluginName = plugin22.postcssPlugin;
17098 var pluginVer = plugin22.postcssVersion;
17099 var runtimeVer = this.result.processor.version;
17100 var a2 = pluginVer.split(".");
17101 var b = runtimeVer.split(".");
17102 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17103 console.error("Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below.");
17104 }
17105 }
17106 }
17107 } catch (err) {
17108 if (console && console.error) console.error(err);
17109 }
17110 return error;
17111 };
17112 _proto.prepareVisitors = function prepareVisitors() {
17113 var _this = this;
17114 this.listeners = {};
17115 var add = function(plugin22, type, cb) {
17116 if (!_this.listeners[type]) _this.listeners[type] = [];
17117 _this.listeners[type].push([
17118 plugin22,
17119 cb
17120 ]);
17121 };
17122 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17123 var plugin22 = _step.value;
17124 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17125 for(var event in plugin22){
17126 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17127 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17128 }
17129 if (!NOT_VISITORS[event]) {
17130 if (_type_of(plugin22[event]) === "object") {
17131 for(var filter in plugin22[event]){
17132 if (filter === "*") {
17133 add(plugin22, event, plugin22[event][filter]);
17134 } else {
17135 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17136 }
17137 }
17138 } else if (typeof plugin22[event] === "function") {
17139 add(plugin22, event, plugin22[event]);
17140 }
17141 }
17142 }
17143 }
17144 }
17145 this.hasListener = Object.keys(this.listeners).length > 0;
17146 };
17147 _proto.runAsync = function runAsync() {
17148 var _this = this;
17149 return _async_to_generator(function() {
17150 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17151 return _ts_generator(this, function(_state) {
17152 switch(_state.label){
17153 case 0:
17154 _this.plugin = 0;
17155 i2 = 0;
17156 _state.label = 1;
17157 case 1:
17158 if (!(i2 < _this.plugins.length)) return [
17159 3,
17160 6
17161 ];
17162 plugin22 = _this.plugins[i2];
17163 promise = _this.runOnRoot(plugin22);
17164 if (!isPromise(promise)) return [
17165 3,
17166 5
17167 ];
17168 _state.label = 2;
17169 case 2:
17170 _state.trys.push([
17171 2,
17172 4,
17173 ,
17174 5
17175 ]);
17176 return [
17177 4,
17178 promise
17179 ];
17180 case 3:
17181 _state.sent();
17182 return [
17183 3,
17184 5
17185 ];
17186 case 4:
17187 error = _state.sent();
17188 throw _this.handleError(error);
17189 case 5:
17190 i2++;
17191 return [
17192 3,
17193 1
17194 ];
17195 case 6:
17196 _this.prepareVisitors();
17197 if (!_this.hasListener) return [
17198 3,
17199 18
17200 ];
17201 root2 = _this.result.root;
17202 _state.label = 7;
17203 case 7:
17204 if (!!root2[isClean]) return [
17205 3,
17206 14
17207 ];
17208 root2[isClean] = true;
17209 stack = [
17210 toStack(root2)
17211 ];
17212 _state.label = 8;
17213 case 8:
17214 if (!(stack.length > 0)) return [
17215 3,
17216 13
17217 ];
17218 promise1 = _this.visitTick(stack);
17219 if (!isPromise(promise1)) return [
17220 3,
17221 12
17222 ];
17223 _state.label = 9;
17224 case 9:
17225 _state.trys.push([
17226 9,
17227 11,
17228 ,
17229 12
17230 ]);
17231 return [
17232 4,
17233 promise1
17234 ];
17235 case 10:
17236 _state.sent();
17237 return [
17238 3,
17239 12
17240 ];
17241 case 11:
17242 e2 = _state.sent();
17243 node2 = stack[stack.length - 1].node;
17244 throw _this.handleError(e2, node2);
17245 case 12:
17246 return [
17247 3,
17248 8
17249 ];
17250 case 13:
17251 return [
17252 3,
17253 7
17254 ];
17255 case 14:
17256 if (!_this.listeners.OnceExit) return [
17257 3,
17258 18
17259 ];
17260 _loop = function() {
17261 var _step_value, plugin22, visitor, roots, e2;
17262 return _ts_generator(this, function(_state) {
17263 switch(_state.label){
17264 case 0:
17265 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17266 _this.result.lastPlugin = plugin22;
17267 _state.label = 1;
17268 case 1:
17269 _state.trys.push([
17270 1,
17271 6,
17272 ,
17273 7
17274 ]);
17275 if (!(root2.type === "document")) return [
17276 3,
17277 3
17278 ];
17279 roots = root2.nodes.map(function(subRoot) {
17280 return visitor(subRoot, _this.helpers);
17281 });
17282 return [
17283 4,
17284 Promise.all(roots)
17285 ];
17286 case 2:
17287 _state.sent();
17288 return [
17289 3,
17290 5
17291 ];
17292 case 3:
17293 return [
17294 4,
17295 visitor(root2, _this.helpers)
17296 ];
17297 case 4:
17298 _state.sent();
17299 _state.label = 5;
17300 case 5:
17301 return [
17302 3,
17303 7
17304 ];
17305 case 6:
17306 e2 = _state.sent();
17307 throw _this.handleError(e2);
17308 case 7:
17309 return [
17310 2
17311 ];
17312 }
17313 });
17314 };
17315 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
17316 _state.label = 15;
17317 case 15:
17318 if (!!(_step = _iterator()).done) return [
17319 3,
17320 18
17321 ];
17322 return [
17323 5,
17324 _ts_values(_loop())
17325 ];
17326 case 16:
17327 _state.sent();
17328 _state.label = 17;
17329 case 17:
17330 return [
17331 3,
17332 15
17333 ];
17334 case 18:
17335 _this.processed = true;
17336 return [
17337 2,
17338 _this.stringify()
17339 ];
17340 }
17341 });
17342 })();
17343 };
17344 _proto.runOnRoot = function runOnRoot(plugin22) {
17345 var _this = this;
17346 this.result.lastPlugin = plugin22;
17347 try {
17348 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
17349 if (this.result.root.type === "document") {
17350 var roots = this.result.root.nodes.map(function(root2) {
17351 return plugin22.Once(root2, _this.helpers);
17352 });
17353 if (isPromise(roots[0])) {
17354 return Promise.all(roots);
17355 }
17356 return roots;
17357 }
17358 return plugin22.Once(this.result.root, this.helpers);
17359 } else if (typeof plugin22 === "function") {
17360 return plugin22(this.result.root, this.result);
17361 }
17362 } catch (error) {
17363 throw this.handleError(error);
17364 }
17365 };
17366 _proto.stringify = function stringify() {
17367 if (this.error) throw this.error;
17368 if (this.stringified) return this.result;
17369 this.stringified = true;
17370 this.sync();
17371 var opts = this.result.opts;
17372 var str = stringify$2;
17373 if (opts.syntax) str = opts.syntax.stringify;
17374 if (opts.stringifier) str = opts.stringifier;
17375 if (str.stringify) str = str.stringify;
17376 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
17377 var data = map.generate();
17378 this.result.css = data[0];
17379 this.result.map = data[1];
17380 return this.result;
17381 };
17382 _proto.sync = function sync() {
17383 if (this.error) throw this.error;
17384 if (this.processed) return this.result;
17385 this.processed = true;
17386 if (this.processing) {
17387 throw this.getAsyncError();
17388 }
17389 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17390 var plugin22 = _step.value;
17391 var promise = this.runOnRoot(plugin22);
17392 if (isPromise(promise)) {
17393 throw this.getAsyncError();
17394 }
17395 }
17396 this.prepareVisitors();
17397 if (this.hasListener) {
17398 var root2 = this.result.root;
17399 while(!root2[isClean]){
17400 root2[isClean] = true;
17401 this.walkSync(root2);
17402 }
17403 if (this.listeners.OnceExit) {
17404 if (root2.type === "document") {
17405 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
17406 var subRoot = _step1.value;
17407 this.visitSync(this.listeners.OnceExit, subRoot);
17408 }
17409 } else {
17410 this.visitSync(this.listeners.OnceExit, root2);
17411 }
17412 }
17413 }
17414 return this.result;
17415 };
17416 _proto.then = function then(onFulfilled, onRejected) {
17417 if (true) {
17418 if (!("from" in this.opts)) {
17419 warnOnce$1("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.");
17420 }
17421 }
17422 return this.async().then(onFulfilled, onRejected);
17423 };
17424 _proto.toString = function toString() {
17425 return this.css;
17426 };
17427 _proto.visitSync = function visitSync(visitors, node2) {
17428 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
17429 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17430 this.result.lastPlugin = plugin22;
17431 var promise = void 0;
17432 try {
17433 promise = visitor(node2, this.helpers);
17434 } catch (e2) {
17435 throw this.handleError(e2, node2.proxyOf);
17436 }
17437 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17438 return true;
17439 }
17440 if (isPromise(promise)) {
17441 throw this.getAsyncError();
17442 }
17443 }
17444 };
17445 _proto.visitTick = function visitTick(stack) {
17446 var visit2 = stack[stack.length - 1];
17447 var node2 = visit2.node, visitors = visit2.visitors;
17448 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17449 stack.pop();
17450 return;
17451 }
17452 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
17453 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
17454 visit2.visitorIndex += 1;
17455 if (visit2.visitorIndex === visitors.length) {
17456 visit2.visitors = [];
17457 visit2.visitorIndex = 0;
17458 }
17459 this.result.lastPlugin = plugin22;
17460 try {
17461 return visitor(node2.toProxy(), this.helpers);
17462 } catch (e2) {
17463 throw this.handleError(e2, node2);
17464 }
17465 }
17466 if (visit2.iterator !== 0) {
17467 var iterator = visit2.iterator;
17468 var child;
17469 while(child = node2.nodes[node2.indexes[iterator]]){
17470 node2.indexes[iterator] += 1;
17471 if (!child[isClean]) {
17472 child[isClean] = true;
17473 stack.push(toStack(child));
17474 return;
17475 }
17476 }
17477 visit2.iterator = 0;
17478 delete node2.indexes[iterator];
17479 }
17480 var events = visit2.events;
17481 while(visit2.eventIndex < events.length){
17482 var event = events[visit2.eventIndex];
17483 visit2.eventIndex += 1;
17484 if (event === CHILDREN) {
17485 if (node2.nodes && node2.nodes.length) {
17486 node2[isClean] = true;
17487 visit2.iterator = node2.getIterator();
17488 }
17489 return;
17490 } else if (this.listeners[event]) {
17491 visit2.visitors = this.listeners[event];
17492 return;
17493 }
17494 }
17495 stack.pop();
17496 };
17497 _proto.walkSync = function walkSync(node2) {
17498 var _this = this;
17499 node2[isClean] = true;
17500 var events = getEvents(node2);
17501 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
17502 var event = _step.value;
17503 if (event === CHILDREN) {
17504 if (node2.nodes) {
17505 node2.each(function(child) {
17506 if (!child[isClean]) _this.walkSync(child);
17507 });
17508 }
17509 } else {
17510 var visitors = this.listeners[event];
17511 if (visitors) {
17512 if (this.visitSync(visitors, node2.toProxy())) return;
17513 }
17514 }
17515 }
17516 };
17517 _proto.warnings = function warnings() {
17518 return this.sync().warnings();
17519 };
17520 _create_class(LazyResult2, [
17521 {
17522 key: "content",
17523 get: function get() {
17524 return this.stringify().content;
17525 }
17526 },
17527 {
17528 key: "css",
17529 get: function get() {
17530 return this.stringify().css;
17531 }
17532 },
17533 {
17534 key: "map",
17535 get: function get() {
17536 return this.stringify().map;
17537 }
17538 },
17539 {
17540 key: "messages",
17541 get: function get() {
17542 return this.sync().messages;
17543 }
17544 },
17545 {
17546 key: "opts",
17547 get: function get() {
17548 return this.result.opts;
17549 }
17550 },
17551 {
17552 key: "processor",
17553 get: function get() {
17554 return this.result.processor;
17555 }
17556 },
17557 {
17558 key: "root",
17559 get: function get() {
17560 return this.sync().root;
17561 }
17562 },
17563 {
17564 key: Symbol.toStringTag,
17565 get: function get() {
17566 return "LazyResult";
17567 }
17568 }
17569 ]);
17570 return LazyResult2;
17571 }();
17572 LazyResult$2.registerPostcss = function(dependant) {
17573 postcss$2 = dependant;
17574 };
17575 var lazyResult = LazyResult$2;
17576 LazyResult$2.default = LazyResult$2;
17577 Root$3.registerLazyResult(LazyResult$2);
17578 Document$2.registerLazyResult(LazyResult$2);
17579 var MapGenerator22 = mapGenerator;
17580 var stringify$1 = stringify_1;
17581 var warnOnce22 = warnOnce$2;
17582 var parse$1 = parse_1;
17583 var Result$1 = result;
17584 var NoWorkResult$1 = /*#__PURE__*/ function() {
17585 function NoWorkResult2(processor2, css, opts) {
17586 css = css.toString();
17587 this.stringified = false;
17588 this._processor = processor2;
17589 this._css = css;
17590 this._opts = opts;
17591 this._map = void 0;
17592 var root2;
17593 var str = stringify$1;
17594 this.result = new Result$1(this._processor, root2, this._opts);
17595 this.result.css = css;
17596 var self = this;
17597 Object.defineProperty(this.result, "root", {
17598 get: function get() {
17599 return self.root;
17600 }
17601 });
17602 var map = new MapGenerator22(str, root2, this._opts, css);
17603 if (map.isMap()) {
17604 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
17605 if (generatedCSS) {
17606 this.result.css = generatedCSS;
17607 }
17608 if (generatedMap) {
17609 this.result.map = generatedMap;
17610 }
17611 } else {
17612 map.clearAnnotation();
17613 this.result.css = map.css;
17614 }
17615 }
17616 var _proto = NoWorkResult2.prototype;
17617 _proto.async = function async() {
17618 if (this.error) return Promise.reject(this.error);
17619 return Promise.resolve(this.result);
17620 };
17621 _proto.catch = function _catch(onRejected) {
17622 return this.async().catch(onRejected);
17623 };
17624 _proto.finally = function _finally(onFinally) {
17625 return this.async().then(onFinally, onFinally);
17626 };
17627 _proto.sync = function sync() {
17628 if (this.error) throw this.error;
17629 return this.result;
17630 };
17631 _proto.then = function then(onFulfilled, onRejected) {
17632 if (true) {
17633 if (!("from" in this._opts)) {
17634 warnOnce22("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.");
17635 }
17636 }
17637 return this.async().then(onFulfilled, onRejected);
17638 };
17639 _proto.toString = function toString() {
17640 return this._css;
17641 };
17642 _proto.warnings = function warnings() {
17643 return [];
17644 };
17645 _create_class(NoWorkResult2, [
17646 {
17647 key: "content",
17648 get: function get() {
17649 return this.result.css;
17650 }
17651 },
17652 {
17653 key: "css",
17654 get: function get() {
17655 return this.result.css;
17656 }
17657 },
17658 {
17659 key: "map",
17660 get: function get() {
17661 return this.result.map;
17662 }
17663 },
17664 {
17665 key: "messages",
17666 get: function get() {
17667 return [];
17668 }
17669 },
17670 {
17671 key: "opts",
17672 get: function get() {
17673 return this.result.opts;
17674 }
17675 },
17676 {
17677 key: "processor",
17678 get: function get() {
17679 return this.result.processor;
17680 }
17681 },
17682 {
17683 key: "root",
17684 get: function get() {
17685 if (this._root) {
17686 return this._root;
17687 }
17688 var root2;
17689 var parser2 = parse$1;
17690 try {
17691 root2 = parser2(this._css, this._opts);
17692 } catch (error) {
17693 this.error = error;
17694 }
17695 if (this.error) {
17696 throw this.error;
17697 } else {
17698 this._root = root2;
17699 return root2;
17700 }
17701 }
17702 },
17703 {
17704 key: Symbol.toStringTag,
17705 get: function get() {
17706 return "NoWorkResult";
17707 }
17708 }
17709 ]);
17710 return NoWorkResult2;
17711 }();
17712 var noWorkResult = NoWorkResult$1;
17713 NoWorkResult$1.default = NoWorkResult$1;
17714 var NoWorkResult22 = noWorkResult;
17715 var LazyResult$1 = lazyResult;
17716 var Document$1 = document$1$2;
17717 var Root$2 = root;
17718 var Processor$1 = /*#__PURE__*/ function() {
17719 function Processor2(plugins) {
17720 if (plugins === void 0) plugins = [];
17721 this.version = "8.4.38";
17722 this.plugins = this.normalize(plugins);
17723 }
17724 var _proto = Processor2.prototype;
17725 _proto.normalize = function normalize(plugins) {
17726 var normalized = [];
17727 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
17728 var i2 = _step.value;
17729 if (i2.postcss === true) {
17730 i2 = i2();
17731 } else if (i2.postcss) {
17732 i2 = i2.postcss;
17733 }
17734 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
17735 normalized = normalized.concat(i2.plugins);
17736 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
17737 normalized.push(i2);
17738 } else if (typeof i2 === "function") {
17739 normalized.push(i2);
17740 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
17741 if (true) {
17742 throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.");
17743 }
17744 } else {
17745 throw new Error(i2 + " is not a PostCSS plugin");
17746 }
17747 }
17748 return normalized;
17749 };
17750 _proto.process = function process1(css, opts) {
17751 if (opts === void 0) opts = {};
17752 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
17753 return new NoWorkResult22(this, css, opts);
17754 } else {
17755 return new LazyResult$1(this, css, opts);
17756 }
17757 };
17758 _proto.use = function use(plugin22) {
17759 this.plugins = this.plugins.concat(this.normalize([
17760 plugin22
17761 ]));
17762 return this;
17763 };
17764 return Processor2;
17765 }();
17766 var processor = Processor$1;
17767 Processor$1.default = Processor$1;
17768 Root$2.registerProcessor(Processor$1);
17769 Document$1.registerProcessor(Processor$1);
17770 var Declaration$1 = declaration;
17771 var PreviousMap22 = previousMap;
17772 var Comment$1 = comment;
17773 var AtRule$1 = atRule;
17774 var Input$1 = input;
17775 var Root$1 = root;
17776 var Rule$1 = rule;
17777 function fromJSON$1(json, inputs) {
17778 if (Array.isArray(json)) return json.map(function(n2) {
17779 return fromJSON$1(n2);
17780 });
17781 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
17782 "inputs"
17783 ]);
17784 if (ownInputs) {
17785 inputs = [];
17786 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
17787 var input2 = _step.value;
17788 var inputHydrated = _extends({}, input2, {
17789 __proto__: Input$1.prototype
17790 });
17791 if (inputHydrated.map) {
17792 inputHydrated.map = _extends({}, inputHydrated.map, {
17793 __proto__: PreviousMap22.prototype
17794 });
17795 }
17796 inputs.push(inputHydrated);
17797 }
17798 }
17799 if (defaults.nodes) {
17800 defaults.nodes = json.nodes.map(function(n2) {
17801 return fromJSON$1(n2, inputs);
17802 });
17803 }
17804 if (defaults.source) {
17805 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
17806 "inputId"
17807 ]);
17808 defaults.source = source;
17809 if (inputId != null) {
17810 defaults.source.input = inputs[inputId];
17811 }
17812 }
17813 if (defaults.type === "root") {
17814 return new Root$1(defaults);
17815 } else if (defaults.type === "decl") {
17816 return new Declaration$1(defaults);
17817 } else if (defaults.type === "rule") {
17818 return new Rule$1(defaults);
17819 } else if (defaults.type === "comment") {
17820 return new Comment$1(defaults);
17821 } else if (defaults.type === "atrule") {
17822 return new AtRule$1(defaults);
17823 } else {
17824 throw new Error("Unknown node type: " + json.type);
17825 }
17826 }
17827 var fromJSON_1 = fromJSON$1;
17828 fromJSON$1.default = fromJSON$1;
17829 var CssSyntaxError22 = cssSyntaxError;
17830 var Declaration22 = declaration;
17831 var LazyResult22 = lazyResult;
17832 var Container22 = container;
17833 var Processor22 = processor;
17834 var stringify = stringify_1;
17835 var fromJSON = fromJSON_1;
17836 var Document222 = document$1$2;
17837 var Warning22 = warning;
17838 var Comment22 = comment;
17839 var AtRule22 = atRule;
17840 var Result22 = result;
17841 var Input22 = input;
17842 var parse = parse_1;
17843 var list = list_1;
17844 var Rule22 = rule;
17845 var Root22 = root;
17846 var Node22 = node;
17847 function postcss() {
17848 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
17849 plugins[_key] = arguments[_key];
17850 }
17851 if (plugins.length === 1 && Array.isArray(plugins[0])) {
17852 plugins = plugins[0];
17853 }
17854 return new Processor22(plugins);
17855 }
17856 postcss.plugin = function plugin2(name, initializer) {
17857 var warningPrinted = false;
17858 function creator() {
17859 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
17860 args[_key] = arguments[_key];
17861 }
17862 if (console && console.warn && !warningPrinted) {
17863 warningPrinted = true;
17864 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
17865 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
17866 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
17867 }
17868 }
17869 var transformer = initializer.apply(void 0, [].concat(args));
17870 transformer.postcssPlugin = name;
17871 transformer.postcssVersion = new Processor22().version;
17872 return transformer;
17873 }
17874 var cache;
17875 Object.defineProperty(creator, "postcss", {
17876 get: function get() {
17877 if (!cache) cache = creator();
17878 return cache;
17879 }
17880 });
17881 creator.process = function(css, processOpts, pluginOpts) {
17882 return postcss([
17883 creator(pluginOpts)
17884 ]).process(css, processOpts);
17885 };
17886 return creator;
17887 };
17888 postcss.stringify = stringify;
17889 postcss.parse = parse;
17890 postcss.fromJSON = fromJSON;
17891 postcss.list = list;
17892 postcss.comment = function(defaults) {
17893 return new Comment22(defaults);
17894 };
17895 postcss.atRule = function(defaults) {
17896 return new AtRule22(defaults);
17897 };
17898 postcss.decl = function(defaults) {
17899 return new Declaration22(defaults);
17900 };
17901 postcss.rule = function(defaults) {
17902 return new Rule22(defaults);
17903 };
17904 postcss.root = function(defaults) {
17905 return new Root22(defaults);
17906 };
17907 postcss.document = function(defaults) {
17908 return new Document222(defaults);
17909 };
17910 postcss.CssSyntaxError = CssSyntaxError22;
17911 postcss.Declaration = Declaration22;
17912 postcss.Container = Container22;
17913 postcss.Processor = Processor22;
17914 postcss.Document = Document222;
17915 postcss.Comment = Comment22;
17916 postcss.Warning = Warning22;
17917 postcss.AtRule = AtRule22;
17918 postcss.Result = Result22;
17919 postcss.Input = Input22;
17920 postcss.Rule = Rule22;
17921 postcss.Root = Root22;
17922 postcss.Node = Node22;
17923 LazyResult22.registerPostcss(postcss);
17924 var postcss_1 = postcss;
17925 postcss.default = postcss;
17926 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
17927 postcss$1.stringify;
17928 postcss$1.fromJSON;
17929 postcss$1.plugin;
17930 postcss$1.parse;
17931 postcss$1.list;
17932 postcss$1.document;
17933 postcss$1.comment;
17934 postcss$1.atRule;
17935 postcss$1.rule;
17936 postcss$1.decl;
17937 postcss$1.root;
17938 postcss$1.CssSyntaxError;
17939 postcss$1.Declaration;
17940 postcss$1.Container;
17941 postcss$1.Processor;
17942 postcss$1.Document;
17943 postcss$1.Comment;
17944 postcss$1.Warning;
17945 postcss$1.AtRule;
17946 postcss$1.Result;
17947 postcss$1.Input;
17948 postcss$1.Rule;
17949 postcss$1.Root;
17950 postcss$1.Node;
17951 var BaseRRNode = /*#__PURE__*/ function() {
17952 function BaseRRNode() {
17953 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
17954 _args[_key] = arguments[_key];
17955 }
17956 __publicField2(this, "parentElement", null);
17957 __publicField2(this, "parentNode", null);
17958 __publicField2(this, "ownerDocument");
17959 __publicField2(this, "firstChild", null);
17960 __publicField2(this, "lastChild", null);
17961 __publicField2(this, "previousSibling", null);
17962 __publicField2(this, "nextSibling", null);
17963 __publicField2(this, "ELEMENT_NODE", 1);
17964 __publicField2(this, "TEXT_NODE", 3);
17965 __publicField2(this, "nodeType");
17966 __publicField2(this, "nodeName");
17967 __publicField2(this, "RRNodeType");
17968 }
17969 var _proto = BaseRRNode.prototype;
17970 _proto.contains = function contains(node2) {
17971 if (!_instanceof(node2, BaseRRNode)) return false;
17972 else if (node2.ownerDocument !== this.ownerDocument) return false;
17973 else if (node2 === this) return true;
17974 while(node2.parentNode){
17975 if (node2.parentNode === this) return true;
17976 node2 = node2.parentNode;
17977 }
17978 return false;
17979 };
17980 // eslint-disable-next-line @typescript-eslint/no-unused-vars
17981 _proto.appendChild = function appendChild(_newChild) {
17982 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
17983 };
17984 // eslint-disable-next-line @typescript-eslint/no-unused-vars
17985 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
17986 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
17987 };
17988 // eslint-disable-next-line @typescript-eslint/no-unused-vars
17989 _proto.removeChild = function removeChild(_node) {
17990 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
17991 };
17992 _proto.toString = function toString() {
17993 return "RRNode";
17994 };
17995 _create_class(BaseRRNode, [
17996 {
17997 key: "childNodes",
17998 get: function get() {
17999 var childNodes2 = [];
18000 var childIterator = this.firstChild;
18001 while(childIterator){
18002 childNodes2.push(childIterator);
18003 childIterator = childIterator.nextSibling;
18004 }
18005 return childNodes2;
18006 }
18007 }
18008 ]);
18009 return BaseRRNode;
18010 }();
18011 var testableAccessors = {
18012 Node: [
18013 "childNodes",
18014 "parentNode",
18015 "parentElement",
18016 "textContent"
18017 ],
18018 ShadowRoot: [
18019 "host",
18020 "styleSheets"
18021 ],
18022 Element: [
18023 "shadowRoot",
18024 "querySelector",
18025 "querySelectorAll"
18026 ],
18027 MutationObserver: []
18028 };
18029 var testableMethods = {
18030 Node: [
18031 "contains",
18032 "getRootNode"
18033 ],
18034 ShadowRoot: [
18035 "getSelection"
18036 ],
18037 Element: [],
18038 MutationObserver: [
18039 "constructor"
18040 ]
18041 };
18042 var untaintedBasePrototype = {};
18043 var isAngularZonePresent = function() {
18044 return !!globalThis.Zone;
18045 };
18046 function getUntaintedPrototype(key) {
18047 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18048 var defaultObj = globalThis[key];
18049 var defaultPrototype = defaultObj.prototype;
18050 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18051 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18052 accessorNames.every(function(accessor) {
18053 var _a2, _b;
18054 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18055 }));
18056 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18057 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18058 function(method) {
18059 var _a2;
18060 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18061 }));
18062 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18063 untaintedBasePrototype[key] = defaultObj.prototype;
18064 return defaultObj.prototype;
18065 }
18066 try {
18067 var iframeEl = document.createElement("iframe");
18068 document.body.appendChild(iframeEl);
18069 var win = iframeEl.contentWindow;
18070 if (!win) return defaultObj.prototype;
18071 var untaintedObject = win[key].prototype;
18072 document.body.removeChild(iframeEl);
18073 if (!untaintedObject) return defaultPrototype;
18074 return untaintedBasePrototype[key] = untaintedObject;
18075 } catch (e) {
18076 return defaultPrototype;
18077 }
18078 }
18079 var untaintedAccessorCache = {};
18080 function getUntaintedAccessor(key, instance, accessor) {
18081 var _a2;
18082 var cacheKey = key + "." + String(accessor);
18083 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18084 var untaintedPrototype = getUntaintedPrototype(key);
18085 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18086 if (!untaintedAccessor) return instance[accessor];
18087 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18088 return untaintedAccessor.call(instance);
18089 }
18090 var untaintedMethodCache = {};
18091 function getUntaintedMethod(key, instance, method) {
18092 var cacheKey = key + "." + String(method);
18093 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18094 var untaintedPrototype = getUntaintedPrototype(key);
18095 var untaintedMethod = untaintedPrototype[method];
18096 if (typeof untaintedMethod !== "function") return instance[method];
18097 untaintedMethodCache[cacheKey] = untaintedMethod;
18098 return untaintedMethod.bind(instance);
18099 }
18100 function childNodes(n2) {
18101 return getUntaintedAccessor("Node", n2, "childNodes");
18102 }
18103 function parentNode(n2) {
18104 return getUntaintedAccessor("Node", n2, "parentNode");
18105 }
18106 function parentElement(n2) {
18107 return getUntaintedAccessor("Node", n2, "parentElement");
18108 }
18109 function textContent(n2) {
18110 return getUntaintedAccessor("Node", n2, "textContent");
18111 }
18112 function contains(n2, other) {
18113 return getUntaintedMethod("Node", n2, "contains")(other);
18114 }
18115 function getRootNode(n2) {
18116 return getUntaintedMethod("Node", n2, "getRootNode")();
18117 }
18118 function host(n2) {
18119 if (!n2 || !("host" in n2)) return null;
18120 return getUntaintedAccessor("ShadowRoot", n2, "host");
18121 }
18122 function styleSheets(n2) {
18123 return n2.styleSheets;
18124 }
18125 function shadowRoot(n2) {
18126 if (!n2 || !("shadowRoot" in n2)) return null;
18127 return getUntaintedAccessor("Element", n2, "shadowRoot");
18128 }
18129 function querySelector(n2, selectors) {
18130 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18131 }
18132 function querySelectorAll(n2, selectors) {
18133 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18134 }
18135 function mutationObserverCtor() {
18136 return getUntaintedPrototype("MutationObserver").constructor;
18137 }
18138 var index = {
18139 childNodes: childNodes,
18140 parentNode: parentNode,
18141 parentElement: parentElement,
18142 textContent: textContent,
18143 contains: contains,
18144 getRootNode: getRootNode,
18145 host: host,
18146 styleSheets: styleSheets,
18147 shadowRoot: shadowRoot,
18148 querySelector: querySelector,
18149 querySelectorAll: querySelectorAll,
18150 mutationObserver: mutationObserverCtor
18151 };
18152 function on(type, fn, target) {
18153 if (target === void 0) target = document;
18154 var options = {
18155 capture: true,
18156 passive: true
18157 };
18158 target.addEventListener(type, fn, options);
18159 return function() {
18160 return target.removeEventListener(type, fn, options);
18161 };
18162 }
18163 var DEPARTED_MIRROR_ACCESS_WARNING = "Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";
18164 var _mirror = {
18165 map: {},
18166 getId: function getId() {
18167 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18168 return -1;
18169 },
18170 getNode: function getNode() {
18171 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18172 return null;
18173 },
18174 removeNodeFromMap: function removeNodeFromMap() {
18175 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18176 },
18177 has: function has() {
18178 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18179 return false;
18180 },
18181 reset: function reset() {
18182 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18183 }
18184 };
18185 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
18186 _mirror = new Proxy(_mirror, {
18187 get: function get(target, prop, receiver) {
18188 if (prop === "map") {
18189 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18190 }
18191 return Reflect.get(target, prop, receiver);
18192 }
18193 });
18194 }
18195 function throttle(func, wait, options) {
18196 if (options === void 0) options = {};
18197 var timeout = null;
18198 var previous = 0;
18199 return function() {
18200 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18201 args[_key] = arguments[_key];
18202 }
18203 var now = Date.now();
18204 if (!previous && options.leading === false) {
18205 previous = now;
18206 }
18207 var remaining = wait - (now - previous);
18208 var context = this;
18209 if (remaining <= 0 || remaining > wait) {
18210 if (timeout) {
18211 clearTimeout(timeout);
18212 timeout = null;
18213 }
18214 previous = now;
18215 func.apply(context, args);
18216 } else if (!timeout && options.trailing !== false) {
18217 timeout = setTimeout(function() {
18218 previous = options.leading === false ? 0 : Date.now();
18219 timeout = null;
18220 func.apply(context, args);
18221 }, remaining);
18222 }
18223 };
18224 }
18225 function hookSetter(target, key, d, isRevoked, win) {
18226 if (win === void 0) win = window;
18227 var original = win.Object.getOwnPropertyDescriptor(target, key);
18228 win.Object.defineProperty(target, key, isRevoked ? d : {
18229 set: function set(value) {
18230 var _this = this;
18231 setTimeout(function() {
18232 d.set.call(_this, value);
18233 }, 0);
18234 if (original && original.set) {
18235 original.set.call(this, value);
18236 }
18237 }
18238 });
18239 return function() {
18240 return hookSetter(target, key, original || {}, true);
18241 };
18242 }
18243 function patch(source, name, replacement) {
18244 try {
18245 if (!(name in source)) {
18246 return function() {};
18247 }
18248 var original = source[name];
18249 var wrapped = replacement(original);
18250 if (typeof wrapped === "function") {
18251 wrapped.prototype = wrapped.prototype || {};
18252 Object.defineProperties(wrapped, {
18253 __rrweb_original__: {
18254 enumerable: false,
18255 value: original
18256 }
18257 });
18258 }
18259 source[name] = wrapped;
18260 return function() {
18261 source[name] = original;
18262 };
18263 } catch (e) {
18264 return function() {};
18265 }
18266 }
18267 var nowTimestamp = Date.now;
18268 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
18269 nowTimestamp = function() {
18270 return /* @__PURE__ */ new Date().getTime();
18271 };
18272 }
18273 function getWindowScroll(win) {
18274 var _a2, _b, _c, _d;
18275 var doc = win.document;
18276 return {
18277 left: doc.scrollingElement ? doc.scrollingElement.scrollLeft : win.pageXOffset !== void 0 ? win.pageXOffset : doc.documentElement.scrollLeft || (doc == null ? void 0 : doc.body) && ((_a2 = index.parentElement(doc.body)) == null ? void 0 : _a2.scrollLeft) || ((_b = doc == null ? void 0 : doc.body) == null ? void 0 : _b.scrollLeft) || 0,
18278 top: doc.scrollingElement ? doc.scrollingElement.scrollTop : win.pageYOffset !== void 0 ? win.pageYOffset : (doc == null ? void 0 : doc.documentElement.scrollTop) || (doc == null ? void 0 : doc.body) && ((_c = index.parentElement(doc.body)) == null ? void 0 : _c.scrollTop) || ((_d = doc == null ? void 0 : doc.body) == null ? void 0 : _d.scrollTop) || 0
18279 };
18280 }
18281 function getWindowHeight() {
18282 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
18283 }
18284 function getWindowWidth() {
18285 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
18286 }
18287 function closestElementOfNode(node2) {
18288 if (!node2) {
18289 return null;
18290 }
18291 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
18292 return el;
18293 }
18294 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
18295 if (!node2) {
18296 return false;
18297 }
18298 var el = closestElementOfNode(node2);
18299 if (!el) {
18300 return false;
18301 }
18302 try {
18303 if (typeof blockClass === "string") {
18304 if (el.classList.contains(blockClass)) return true;
18305 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
18306 } else {
18307 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
18308 }
18309 } catch (e2) {}
18310 if (blockSelector) {
18311 if (el.matches(blockSelector)) return true;
18312 if (checkAncestors && el.closest(blockSelector) !== null) return true;
18313 }
18314 return false;
18315 }
18316 function isSerialized(n2, mirror2) {
18317 return mirror2.getId(n2) !== -1;
18318 }
18319 function isIgnored(n2, mirror2, slimDOMOptions) {
18320 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
18321 return true;
18322 }
18323 return mirror2.getId(n2) === IGNORED_NODE;
18324 }
18325 function isAncestorRemoved(target, mirror2) {
18326 if (isShadowRoot(target)) {
18327 return false;
18328 }
18329 var id = mirror2.getId(target);
18330 if (!mirror2.has(id)) {
18331 return true;
18332 }
18333 var parent = index.parentNode(target);
18334 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
18335 return false;
18336 }
18337 if (!parent) {
18338 return true;
18339 }
18340 return isAncestorRemoved(parent, mirror2);
18341 }
18342 function legacy_isTouchEvent(event) {
18343 return Boolean(event.changedTouches);
18344 }
18345 function polyfill$1(win) {
18346 if (win === void 0) win = window;
18347 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
18348 win.NodeList.prototype.forEach = Array.prototype.forEach;
18349 }
18350 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
18351 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
18352 }
18353 }
18354 function isSerializedIframe(n2, mirror2) {
18355 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
18356 }
18357 function isSerializedStylesheet(n2, mirror2) {
18358 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
18359 }
18360 function hasShadowRoot(n2) {
18361 if (!n2) return false;
18362 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
18363 return Boolean(n2.shadowRoot);
18364 }
18365 return Boolean(index.shadowRoot(n2));
18366 }
18367 var StyleSheetMirror = /*#__PURE__*/ function() {
18368 function StyleSheetMirror() {
18369 __publicField(this, "id", 1);
18370 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
18371 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
18372 }
18373 var _proto = StyleSheetMirror.prototype;
18374 _proto.getId = function getId(stylesheet) {
18375 var _this_styleIDMap_get;
18376 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
18377 };
18378 _proto.has = function has(stylesheet) {
18379 return this.styleIDMap.has(stylesheet);
18380 };
18381 /**
18382 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
18383 */ _proto.add = function add(stylesheet, id) {
18384 if (this.has(stylesheet)) return this.getId(stylesheet);
18385 var newId;
18386 if (id === void 0) {
18387 newId = this.id++;
18388 } else newId = id;
18389 this.styleIDMap.set(stylesheet, newId);
18390 this.idStyleMap.set(newId, stylesheet);
18391 return newId;
18392 };
18393 _proto.getStyle = function getStyle(id) {
18394 return this.idStyleMap.get(id) || null;
18395 };
18396 _proto.reset = function reset() {
18397 this.styleIDMap = /* @__PURE__ */ new WeakMap();
18398 this.idStyleMap = /* @__PURE__ */ new Map();
18399 this.id = 1;
18400 };
18401 _proto.generateId = function generateId() {
18402 return this.id++;
18403 };
18404 return StyleSheetMirror;
18405 }();
18406 function getShadowHost(n2) {
18407 var _a2;
18408 var shadowHost = null;
18409 if ("getRootNode" in n2 && ((_a2 = index.getRootNode(n2)) == null ? void 0 : _a2.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && index.host(index.getRootNode(n2))) shadowHost = index.host(index.getRootNode(n2));
18410 return shadowHost;
18411 }
18412 function getRootShadowHost(n2) {
18413 var rootShadowHost = n2;
18414 var shadowHost;
18415 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
18416 return rootShadowHost;
18417 }
18418 function shadowHostInDom(n2) {
18419 var doc = n2.ownerDocument;
18420 if (!doc) return false;
18421 var shadowHost = getRootShadowHost(n2);
18422 return index.contains(doc, shadowHost);
18423 }
18424 function inDom(n2) {
18425 var doc = n2.ownerDocument;
18426 if (!doc) return false;
18427 return index.contains(doc, n2) || shadowHostInDom(n2);
18428 }
18429 var EventType = /* @__PURE__ */ function(EventType2) {
18430 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
18431 EventType2[EventType2["Load"] = 1] = "Load";
18432 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
18433 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
18434 EventType2[EventType2["Meta"] = 4] = "Meta";
18435 EventType2[EventType2["Custom"] = 5] = "Custom";
18436 EventType2[EventType2["Plugin"] = 6] = "Plugin";
18437 return EventType2;
18438 }(EventType || {});
18439 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
18440 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
18441 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
18442 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
18443 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
18444 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
18445 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
18446 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
18447 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
18448 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
18449 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
18450 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
18451 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
18452 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
18453 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
18454 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
18455 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
18456 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
18457 return IncrementalSource2;
18458 }(IncrementalSource || {});
18459 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
18460 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
18461 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
18462 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
18463 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
18464 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
18465 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
18466 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
18467 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
18468 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
18469 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
18470 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
18471 return MouseInteractions2;
18472 }(MouseInteractions || {});
18473 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
18474 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
18475 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
18476 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
18477 return PointerTypes2;
18478 }(PointerTypes || {});
18479 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
18480 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
18481 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
18482 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
18483 return CanvasContext2;
18484 }(CanvasContext || {});
18485 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
18486 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
18487 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
18488 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
18489 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
18490 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
18491 return MediaInteractions2;
18492 }(MediaInteractions || {});
18493 var NodeType = /* @__PURE__ */ function(NodeType2) {
18494 NodeType2[NodeType2["Document"] = 0] = "Document";
18495 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
18496 NodeType2[NodeType2["Element"] = 2] = "Element";
18497 NodeType2[NodeType2["Text"] = 3] = "Text";
18498 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
18499 NodeType2[NodeType2["Comment"] = 5] = "Comment";
18500 return NodeType2;
18501 }(NodeType || {});
18502 function isNodeInLinkedList(n2) {
18503 return "__ln" in n2;
18504 }
18505 var DoubleLinkedList = /*#__PURE__*/ function() {
18506 function DoubleLinkedList() {
18507 __publicField(this, "length", 0);
18508 __publicField(this, "head", null);
18509 __publicField(this, "tail", null);
18510 }
18511 var _proto = DoubleLinkedList.prototype;
18512 _proto.get = function get(position) {
18513 if (position >= this.length) {
18514 throw new Error("Position outside of list range");
18515 }
18516 var current = this.head;
18517 for(var index2 = 0; index2 < position; index2++){
18518 current = (current == null ? void 0 : current.next) || null;
18519 }
18520 return current;
18521 };
18522 _proto.addNode = function addNode(n2) {
18523 var node2 = {
18524 value: n2,
18525 previous: null,
18526 next: null
18527 };
18528 n2.__ln = node2;
18529 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
18530 var current = n2.previousSibling.__ln.next;
18531 node2.next = current;
18532 node2.previous = n2.previousSibling.__ln;
18533 n2.previousSibling.__ln.next = node2;
18534 if (current) {
18535 current.previous = node2;
18536 }
18537 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
18538 var current1 = n2.nextSibling.__ln.previous;
18539 node2.previous = current1;
18540 node2.next = n2.nextSibling.__ln;
18541 n2.nextSibling.__ln.previous = node2;
18542 if (current1) {
18543 current1.next = node2;
18544 }
18545 } else {
18546 if (this.head) {
18547 this.head.previous = node2;
18548 }
18549 node2.next = this.head;
18550 this.head = node2;
18551 }
18552 if (node2.next === null) {
18553 this.tail = node2;
18554 }
18555 this.length++;
18556 };
18557 _proto.removeNode = function removeNode(n2) {
18558 var current = n2.__ln;
18559 if (!this.head) {
18560 return;
18561 }
18562 if (!current.previous) {
18563 this.head = current.next;
18564 if (this.head) {
18565 this.head.previous = null;
18566 } else {
18567 this.tail = null;
18568 }
18569 } else {
18570 current.previous.next = current.next;
18571 if (current.next) {
18572 current.next.previous = current.previous;
18573 } else {
18574 this.tail = current.previous;
18575 }
18576 }
18577 if (n2.__ln) {
18578 delete n2.__ln;
18579 }
18580 this.length--;
18581 };
18582 return DoubleLinkedList;
18583 }();
18584 var moveKey = function(id, parentId) {
18585 return id + "@" + parentId;
18586 };
18587 var MutationBuffer = /*#__PURE__*/ function() {
18588 function MutationBuffer() {
18589 var _this = this;
18590 __publicField(this, "frozen", false);
18591 __publicField(this, "locked", false);
18592 __publicField(this, "texts", []);
18593 __publicField(this, "attributes", []);
18594 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
18595 __publicField(this, "removes", []);
18596 __publicField(this, "mapRemoves", []);
18597 __publicField(this, "movedMap", {});
18598 /**
18599 * the browser MutationObserver emits multiple mutations after
18600 * a delay for performance reasons, making tracing added nodes hard
18601 * in our `processMutations` callback function.
18602 * For example, if we append an element el_1 into body, and then append
18603 * another element el_2 into el_1, these two mutations may be passed to the
18604 * callback function together when the two operations were done.
18605 * Generally we need to trace child nodes of newly added nodes, but in this
18606 * case if we count el_2 as el_1's child node in the first mutation record,
18607 * then we will count el_2 again in the second mutation record which was
18608 * duplicated.
18609 * To avoid of duplicate counting added nodes, we use a Set to store
18610 * added nodes and its child nodes during iterate mutation records. Then
18611 * collect added nodes from the Set which have no duplicate copy. But
18612 * this also causes newly added nodes will not be serialized with id ASAP,
18613 * which means all the id related calculation should be lazy too.
18614 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
18615 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
18616 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
18617 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
18618 __publicField(this, "mutationCb");
18619 __publicField(this, "blockClass");
18620 __publicField(this, "blockSelector");
18621 __publicField(this, "maskTextClass");
18622 __publicField(this, "maskTextSelector");
18623 __publicField(this, "inlineStylesheet");
18624 __publicField(this, "maskInputOptions");
18625 __publicField(this, "maskTextFn");
18626 __publicField(this, "maskInputFn");
18627 __publicField(this, "keepIframeSrcFn");
18628 __publicField(this, "recordCanvas");
18629 __publicField(this, "inlineImages");
18630 __publicField(this, "slimDOMOptions");
18631 __publicField(this, "dataURLOptions");
18632 __publicField(this, "doc");
18633 __publicField(this, "mirror");
18634 __publicField(this, "iframeManager");
18635 __publicField(this, "stylesheetManager");
18636 __publicField(this, "shadowDomManager");
18637 __publicField(this, "canvasManager");
18638 __publicField(this, "processedNodeManager");
18639 __publicField(this, "unattachedDoc");
18640 __publicField(this, "processMutations", function(mutations) {
18641 mutations.forEach(_this.processMutation);
18642 _this.emit();
18643 });
18644 __publicField(this, "emit", function() {
18645 if (_this.frozen || _this.locked) {
18646 return;
18647 }
18648 var adds = [];
18649 var addedIds = /* @__PURE__ */ new Set();
18650 var addList = new DoubleLinkedList();
18651 var getNextId = function(n2) {
18652 var ns = n2;
18653 var nextId = IGNORED_NODE;
18654 while(nextId === IGNORED_NODE){
18655 ns = ns && ns.nextSibling;
18656 nextId = ns && _this.mirror.getId(ns);
18657 }
18658 return nextId;
18659 };
18660 var pushAdd = function(n2) {
18661 var parent = index.parentNode(n2);
18662 if (!parent || !inDom(n2)) {
18663 return;
18664 }
18665 var cssCaptured = false;
18666 if (n2.nodeType === Node.TEXT_NODE) {
18667 var parentTag = parent.tagName;
18668 if (parentTag === "TEXTAREA") {
18669 return;
18670 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
18671 cssCaptured = true;
18672 }
18673 }
18674 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
18675 var nextId = getNextId(n2);
18676 if (parentId === -1 || nextId === -1) {
18677 return addList.addNode(n2);
18678 }
18679 var sn = serializeNodeWithId(n2, {
18680 doc: _this.doc,
18681 mirror: _this.mirror,
18682 blockClass: _this.blockClass,
18683 blockSelector: _this.blockSelector,
18684 maskTextClass: _this.maskTextClass,
18685 maskTextSelector: _this.maskTextSelector,
18686 skipChild: true,
18687 newlyAddedElement: true,
18688 inlineStylesheet: _this.inlineStylesheet,
18689 maskInputOptions: _this.maskInputOptions,
18690 maskTextFn: _this.maskTextFn,
18691 maskInputFn: _this.maskInputFn,
18692 slimDOMOptions: _this.slimDOMOptions,
18693 dataURLOptions: _this.dataURLOptions,
18694 recordCanvas: _this.recordCanvas,
18695 inlineImages: _this.inlineImages,
18696 onSerialize: function(currentN) {
18697 if (isSerializedIframe(currentN, _this.mirror)) {
18698 _this.iframeManager.addIframe(currentN);
18699 }
18700 if (isSerializedStylesheet(currentN, _this.mirror)) {
18701 _this.stylesheetManager.trackLinkElement(currentN);
18702 }
18703 if (hasShadowRoot(n2)) {
18704 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
18705 }
18706 },
18707 onIframeLoad: function(iframe, childSn) {
18708 _this.iframeManager.attachIframe(iframe, childSn);
18709 _this.shadowDomManager.observeAttachShadow(iframe);
18710 },
18711 onStylesheetLoad: function(link, childSn) {
18712 _this.stylesheetManager.attachLinkElement(link, childSn);
18713 },
18714 cssCaptured: cssCaptured
18715 });
18716 if (sn) {
18717 adds.push({
18718 parentId: parentId,
18719 nextId: nextId,
18720 node: sn
18721 });
18722 addedIds.add(sn.id);
18723 }
18724 };
18725 while(_this.mapRemoves.length){
18726 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
18727 }
18728 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
18729 var n2 = _step.value;
18730 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
18731 continue;
18732 }
18733 pushAdd(n2);
18734 }
18735 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
18736 var n21 = _step1.value;
18737 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
18738 pushAdd(n21);
18739 } else if (isAncestorInSet(_this.movedSet, n21)) {
18740 pushAdd(n21);
18741 } else {
18742 _this.droppedSet.add(n21);
18743 }
18744 }
18745 var candidate = null;
18746 while(addList.length){
18747 var node2 = null;
18748 if (candidate) {
18749 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
18750 var nextId = getNextId(candidate.value);
18751 if (parentId !== -1 && nextId !== -1) {
18752 node2 = candidate;
18753 }
18754 }
18755 if (!node2) {
18756 var tailNode = addList.tail;
18757 while(tailNode){
18758 var _node = tailNode;
18759 tailNode = tailNode.previous;
18760 if (_node) {
18761 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
18762 var nextId1 = getNextId(_node.value);
18763 if (nextId1 === -1) continue;
18764 else if (parentId1 !== -1) {
18765 node2 = _node;
18766 break;
18767 } else {
18768 var unhandledNode = _node.value;
18769 var parent = index.parentNode(unhandledNode);
18770 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
18771 var shadowHost = index.host(parent);
18772 var parentId2 = _this.mirror.getId(shadowHost);
18773 if (parentId2 !== -1) {
18774 node2 = _node;
18775 break;
18776 }
18777 }
18778 }
18779 }
18780 }
18781 }
18782 if (!node2) {
18783 while(addList.head){
18784 addList.removeNode(addList.head.value);
18785 }
18786 break;
18787 }
18788 candidate = node2.previous;
18789 addList.removeNode(node2.value);
18790 pushAdd(node2.value);
18791 }
18792 var payload = {
18793 texts: _this.texts.map(function(text) {
18794 var n2 = text.node;
18795 var parent = index.parentNode(n2);
18796 if (parent && parent.tagName === "TEXTAREA") {
18797 _this.genTextAreaValueMutation(parent);
18798 }
18799 return {
18800 id: _this.mirror.getId(n2),
18801 value: text.value
18802 };
18803 }).filter(function(text) {
18804 return !addedIds.has(text.id);
18805 }).filter(function(text) {
18806 return _this.mirror.has(text.id);
18807 }),
18808 attributes: _this.attributes.map(function(attribute) {
18809 var attributes = attribute.attributes;
18810 if (typeof attributes.style === "string") {
18811 var diffAsStr = JSON.stringify(attribute.styleDiff);
18812 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
18813 if (diffAsStr.length < attributes.style.length) {
18814 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
18815 attributes.style = attribute.styleDiff;
18816 }
18817 }
18818 }
18819 return {
18820 id: _this.mirror.getId(attribute.node),
18821 attributes: attributes
18822 };
18823 }).filter(function(attribute) {
18824 return !addedIds.has(attribute.id);
18825 }).filter(function(attribute) {
18826 return _this.mirror.has(attribute.id);
18827 }),
18828 removes: _this.removes,
18829 adds: adds
18830 };
18831 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
18832 return;
18833 }
18834 _this.texts = [];
18835 _this.attributes = [];
18836 _this.attributeMap = /* @__PURE__ */ new WeakMap();
18837 _this.removes = [];
18838 _this.addedSet = /* @__PURE__ */ new Set();
18839 _this.movedSet = /* @__PURE__ */ new Set();
18840 _this.droppedSet = /* @__PURE__ */ new Set();
18841 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
18842 _this.movedMap = {};
18843 _this.mutationCb(payload);
18844 });
18845 __publicField(this, "genTextAreaValueMutation", function(textarea) {
18846 var item = _this.attributeMap.get(textarea);
18847 if (!item) {
18848 item = {
18849 node: textarea,
18850 attributes: {},
18851 styleDiff: {},
18852 _unchangedStyles: {}
18853 };
18854 _this.attributes.push(item);
18855 _this.attributeMap.set(textarea, item);
18856 }
18857 item.attributes.value = Array.from(index.childNodes(textarea), function(cn) {
18858 return index.textContent(cn) || "";
18859 }).join("");
18860 });
18861 __publicField(this, "processMutation", function(m) {
18862 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
18863 return;
18864 }
18865 switch(m.type){
18866 case "characterData":
18867 {
18868 var value = index.textContent(m.target);
18869 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
18870 _this.texts.push({
18871 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
18872 node: m.target
18873 });
18874 }
18875 break;
18876 }
18877 case "attributes":
18878 {
18879 var target = m.target;
18880 var attributeName = m.attributeName;
18881 var value1 = m.target.getAttribute(attributeName);
18882 if (attributeName === "value") {
18883 var type = getInputType(target);
18884 value1 = maskInputValue({
18885 element: target,
18886 maskInputOptions: _this.maskInputOptions,
18887 tagName: target.tagName,
18888 type: type,
18889 value: value1,
18890 maskInputFn: _this.maskInputFn
18891 });
18892 }
18893 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
18894 return;
18895 }
18896 var item = _this.attributeMap.get(m.target);
18897 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
18898 if (!target.contentDocument) {
18899 attributeName = "rr_src";
18900 } else {
18901 return;
18902 }
18903 }
18904 if (!item) {
18905 item = {
18906 node: m.target,
18907 attributes: {},
18908 styleDiff: {},
18909 _unchangedStyles: {}
18910 };
18911 _this.attributes.push(item);
18912 _this.attributeMap.set(m.target, item);
18913 }
18914 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
18915 target.setAttribute("data-rr-is-password", "true");
18916 }
18917 if (!ignoreAttribute(target.tagName, attributeName)) {
18918 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
18919 if (attributeName === "style") {
18920 if (!_this.unattachedDoc) {
18921 try {
18922 _this.unattachedDoc = document.implementation.createHTMLDocument();
18923 } catch (e2) {
18924 _this.unattachedDoc = _this.doc;
18925 }
18926 }
18927 var old = _this.unattachedDoc.createElement("span");
18928 if (m.oldValue) {
18929 old.setAttribute("style", m.oldValue);
18930 }
18931 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
18932 var pname = _step.value;
18933 var newValue = target.style.getPropertyValue(pname);
18934 var newPriority = target.style.getPropertyPriority(pname);
18935 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
18936 if (newPriority === "") {
18937 item.styleDiff[pname] = newValue;
18938 } else {
18939 item.styleDiff[pname] = [
18940 newValue,
18941 newPriority
18942 ];
18943 }
18944 } else {
18945 item._unchangedStyles[pname] = [
18946 newValue,
18947 newPriority
18948 ];
18949 }
18950 }
18951 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
18952 var pname1 = _step1.value;
18953 if (target.style.getPropertyValue(pname1) === "") {
18954 item.styleDiff[pname1] = false;
18955 }
18956 }
18957 } else if (attributeName === "open" && target.tagName === "DIALOG") {
18958 if (target.matches("dialog:modal")) {
18959 item.attributes["rr_open_mode"] = "modal";
18960 } else {
18961 item.attributes["rr_open_mode"] = "non-modal";
18962 }
18963 }
18964 }
18965 break;
18966 }
18967 case "childList":
18968 {
18969 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
18970 if (m.target.tagName === "TEXTAREA") {
18971 _this.genTextAreaValueMutation(m.target);
18972 return;
18973 }
18974 m.addedNodes.forEach(function(n2) {
18975 return _this.genAdds(n2, m.target);
18976 });
18977 m.removedNodes.forEach(function(n2) {
18978 var nodeId = _this.mirror.getId(n2);
18979 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
18980 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
18981 return;
18982 }
18983 if (_this.addedSet.has(n2)) {
18984 deepDelete(_this.addedSet, n2);
18985 _this.droppedSet.add(n2);
18986 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
18987 else if (isAncestorRemoved(m.target, _this.mirror)) ;
18988 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
18989 deepDelete(_this.movedSet, n2);
18990 } else {
18991 _this.removes.push({
18992 parentId: parentId,
18993 id: nodeId,
18994 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
18995 });
18996 processRemoves(n2, _this.removesSubTreeCache);
18997 }
18998 _this.mapRemoves.push(n2);
18999 });
19000 break;
19001 }
19002 }
19003 });
19004 /**
19005 * Make sure you check if `n`'s parent is blocked before calling this function
19006 * */ __publicField(this, "genAdds", function(n2, target) {
19007 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19008 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19009 if (_this.mirror.hasNode(n2)) {
19010 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19011 return;
19012 }
19013 _this.movedSet.add(n2);
19014 var targetId = null;
19015 if (target && _this.mirror.hasNode(target)) {
19016 targetId = _this.mirror.getId(target);
19017 }
19018 if (targetId && targetId !== -1) {
19019 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19020 }
19021 } else {
19022 _this.addedSet.add(n2);
19023 _this.droppedSet.delete(n2);
19024 }
19025 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19026 index.childNodes(n2).forEach(function(childN) {
19027 return _this.genAdds(childN);
19028 });
19029 if (hasShadowRoot(n2)) {
19030 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19031 _this.processedNodeManager.add(childN, _this);
19032 _this.genAdds(childN, n2);
19033 });
19034 }
19035 }
19036 });
19037 }
19038 var _proto = MutationBuffer.prototype;
19039 _proto.init = function init(options) {
19040 var _this = this;
19041 [
19042 "mutationCb",
19043 "blockClass",
19044 "blockSelector",
19045 "maskTextClass",
19046 "maskTextSelector",
19047 "inlineStylesheet",
19048 "maskInputOptions",
19049 "maskTextFn",
19050 "maskInputFn",
19051 "keepIframeSrcFn",
19052 "recordCanvas",
19053 "inlineImages",
19054 "slimDOMOptions",
19055 "dataURLOptions",
19056 "doc",
19057 "mirror",
19058 "iframeManager",
19059 "stylesheetManager",
19060 "shadowDomManager",
19061 "canvasManager",
19062 "processedNodeManager"
19063 ].forEach(function(key) {
19064 _this[key] = options[key];
19065 });
19066 };
19067 _proto.freeze = function freeze() {
19068 this.frozen = true;
19069 this.canvasManager.freeze();
19070 };
19071 _proto.unfreeze = function unfreeze() {
19072 this.frozen = false;
19073 this.canvasManager.unfreeze();
19074 this.emit();
19075 };
19076 _proto.isFrozen = function isFrozen() {
19077 return this.frozen;
19078 };
19079 _proto.lock = function lock() {
19080 this.locked = true;
19081 this.canvasManager.lock();
19082 };
19083 _proto.unlock = function unlock() {
19084 this.locked = false;
19085 this.canvasManager.unlock();
19086 this.emit();
19087 };
19088 _proto.reset = function reset() {
19089 this.shadowDomManager.reset();
19090 this.canvasManager.reset();
19091 };
19092 return MutationBuffer;
19093 }();
19094 function deepDelete(addsSet, n2) {
19095 addsSet.delete(n2);
19096 index.childNodes(n2).forEach(function(childN) {
19097 return deepDelete(addsSet, childN);
19098 });
19099 }
19100 function processRemoves(n2, cache) {
19101 var queue = [
19102 n2
19103 ];
19104 while(queue.length){
19105 var next = queue.pop();
19106 if (cache.has(next)) continue;
19107 cache.add(next);
19108 index.childNodes(next).forEach(function(n22) {
19109 return queue.push(n22);
19110 });
19111 }
19112 return;
19113 }
19114 function isParentRemoved(removes, n2, mirror2) {
19115 if (removes.size === 0) return false;
19116 return _isParentRemoved(removes, n2);
19117 }
19118 function _isParentRemoved(removes, n2, _mirror2) {
19119 var node2 = index.parentNode(n2);
19120 if (!node2) return false;
19121 return removes.has(node2);
19122 }
19123 function isAncestorInSet(set, n2) {
19124 if (set.size === 0) return false;
19125 return _isAncestorInSet(set, n2);
19126 }
19127 function _isAncestorInSet(set, n2) {
19128 var parent = index.parentNode(n2);
19129 if (!parent) {
19130 return false;
19131 }
19132 if (set.has(parent)) {
19133 return true;
19134 }
19135 return _isAncestorInSet(set, parent);
19136 }
19137 var errorHandler;
19138 function registerErrorHandler(handler) {
19139 errorHandler = handler;
19140 }
19141 function unregisterErrorHandler() {
19142 errorHandler = void 0;
19143 }
19144 var callbackWrapper = function(cb) {
19145 if (!errorHandler) {
19146 return cb;
19147 }
19148 var rrwebWrapped = function() {
19149 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19150 rest[_key] = arguments[_key];
19151 }
19152 try {
19153 return cb.apply(void 0, [].concat(rest));
19154 } catch (error) {
19155 if (errorHandler && errorHandler(error) === true) {
19156 return;
19157 }
19158 throw error;
19159 }
19160 };
19161 return rrwebWrapped;
19162 };
19163 var mutationBuffers = [];
19164 function getEventTarget(event) {
19165 try {
19166 if ("composedPath" in event) {
19167 var path = event.composedPath();
19168 if (path.length) {
19169 return path[0];
19170 }
19171 } else if ("path" in event && event.path.length) {
19172 return event.path[0];
19173 }
19174 } catch (e) {}
19175 return event && event.target;
19176 }
19177 function initMutationObserver(options, rootEl) {
19178 var mutationBuffer = new MutationBuffer();
19179 mutationBuffers.push(mutationBuffer);
19180 mutationBuffer.init(options);
19181 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
19182 observer.observe(rootEl, {
19183 attributes: true,
19184 attributeOldValue: true,
19185 characterData: true,
19186 characterDataOldValue: true,
19187 childList: true,
19188 subtree: true
19189 });
19190 return observer;
19191 }
19192 function initMoveObserver(param) {
19193 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
19194 if (sampling.mousemove === false) {
19195 return function() {};
19196 }
19197 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
19198 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
19199 var positions = [];
19200 var timeBaseline;
19201 var wrappedCb = throttle(callbackWrapper(function(source) {
19202 var totalOffset = Date.now() - timeBaseline;
19203 mousemoveCb(positions.map(function(p) {
19204 p.timeOffset -= totalOffset;
19205 return p;
19206 }), source);
19207 positions = [];
19208 timeBaseline = null;
19209 }), callbackThreshold);
19210 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19211 var target = getEventTarget(evt);
19212 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
19213 if (!timeBaseline) {
19214 timeBaseline = nowTimestamp();
19215 }
19216 positions.push({
19217 x: clientX,
19218 y: clientY,
19219 id: mirror2.getId(target),
19220 timeOffset: nowTimestamp() - timeBaseline
19221 });
19222 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
19223 }), threshold, {
19224 trailing: false
19225 }));
19226 var handlers = [
19227 on("mousemove", updatePosition, doc),
19228 on("touchmove", updatePosition, doc),
19229 on("drag", updatePosition, doc)
19230 ];
19231 return callbackWrapper(function() {
19232 handlers.forEach(function(h) {
19233 return h();
19234 });
19235 });
19236 }
19237 function initMouseInteractionObserver(param) {
19238 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19239 if (sampling.mouseInteraction === false) {
19240 return function() {};
19241 }
19242 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
19243 var handlers = [];
19244 var currentPointerType = null;
19245 var getHandler = function(eventKey) {
19246 return function(event) {
19247 var target = getEventTarget(event);
19248 if (isBlocked(target, blockClass, blockSelector, true)) {
19249 return;
19250 }
19251 var pointerType = null;
19252 var thisEventKey = eventKey;
19253 if ("pointerType" in event) {
19254 switch(event.pointerType){
19255 case "mouse":
19256 pointerType = PointerTypes.Mouse;
19257 break;
19258 case "touch":
19259 pointerType = PointerTypes.Touch;
19260 break;
19261 case "pen":
19262 pointerType = PointerTypes.Pen;
19263 break;
19264 }
19265 if (pointerType === PointerTypes.Touch) {
19266 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
19267 thisEventKey = "TouchStart";
19268 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
19269 thisEventKey = "TouchEnd";
19270 }
19271 } else if (pointerType === PointerTypes.Pen) ;
19272 } else if (legacy_isTouchEvent(event)) {
19273 pointerType = PointerTypes.Touch;
19274 }
19275 if (pointerType !== null) {
19276 currentPointerType = pointerType;
19277 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
19278 pointerType = null;
19279 }
19280 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
19281 pointerType = currentPointerType;
19282 currentPointerType = null;
19283 }
19284 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
19285 if (!e2) {
19286 return;
19287 }
19288 var id = mirror2.getId(target);
19289 var clientX = e2.clientX, clientY = e2.clientY;
19290 callbackWrapper(mouseInteractionCb)(_extends({
19291 type: MouseInteractions[thisEventKey],
19292 id: id,
19293 x: clientX,
19294 y: clientY
19295 }, pointerType !== null && {
19296 pointerType: pointerType
19297 }));
19298 };
19299 };
19300 Object.keys(MouseInteractions).filter(function(key) {
19301 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
19302 }).forEach(function(eventKey) {
19303 var eventName = toLowerCase(eventKey);
19304 var handler = getHandler(eventKey);
19305 if (window.PointerEvent) {
19306 switch(MouseInteractions[eventKey]){
19307 case MouseInteractions.MouseDown:
19308 case MouseInteractions.MouseUp:
19309 eventName = eventName.replace("mouse", "pointer");
19310 break;
19311 case MouseInteractions.TouchStart:
19312 case MouseInteractions.TouchEnd:
19313 return;
19314 }
19315 }
19316 handlers.push(on(eventName, handler, doc));
19317 });
19318 return callbackWrapper(function() {
19319 handlers.forEach(function(h) {
19320 return h();
19321 });
19322 });
19323 }
19324 function initScrollObserver(param) {
19325 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19326 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19327 var target = getEventTarget(evt);
19328 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
19329 return;
19330 }
19331 var id = mirror2.getId(target);
19332 if (target === doc && doc.defaultView) {
19333 var scrollLeftTop = getWindowScroll(doc.defaultView);
19334 scrollCb({
19335 id: id,
19336 x: scrollLeftTop.left,
19337 y: scrollLeftTop.top
19338 });
19339 } else {
19340 scrollCb({
19341 id: id,
19342 x: target.scrollLeft,
19343 y: target.scrollTop
19344 });
19345 }
19346 }), sampling.scroll || 100));
19347 return on("scroll", updatePosition, doc);
19348 }
19349 function initViewportResizeObserver(param, param1) {
19350 var viewportResizeCb = param.viewportResizeCb;
19351 var win = param1.win;
19352 var lastH = -1;
19353 var lastW = -1;
19354 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
19355 var height = getWindowHeight();
19356 var width = getWindowWidth();
19357 if (lastH !== height || lastW !== width) {
19358 viewportResizeCb({
19359 width: Number(width),
19360 height: Number(height)
19361 });
19362 lastH = height;
19363 lastW = width;
19364 }
19365 }), 200));
19366 return on("resize", updateDimension, win);
19367 }
19368 var INPUT_TAGS = [
19369 "INPUT",
19370 "TEXTAREA",
19371 "SELECT"
19372 ];
19373 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
19374 function initInputObserver(param) {
19375 var inputCb = param.inputCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, ignoreClass = param.ignoreClass, ignoreSelector = param.ignoreSelector, maskInputOptions = param.maskInputOptions, maskInputFn = param.maskInputFn, sampling = param.sampling, userTriggeredOnInput = param.userTriggeredOnInput;
19376 function eventHandler(event) {
19377 var target = getEventTarget(event);
19378 var userTriggered = event.isTrusted;
19379 var tagName = target && target.tagName;
19380 if (target && tagName === "OPTION") {
19381 target = index.parentElement(target);
19382 }
19383 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
19384 return;
19385 }
19386 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
19387 return;
19388 }
19389 var text = target.value;
19390 var isChecked = false;
19391 var type = getInputType(target) || "";
19392 if (type === "radio" || type === "checkbox") {
19393 isChecked = target.checked;
19394 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
19395 text = maskInputValue({
19396 element: target,
19397 maskInputOptions: maskInputOptions,
19398 tagName: tagName,
19399 type: type,
19400 value: text,
19401 maskInputFn: maskInputFn
19402 });
19403 }
19404 cbWithDedup(target, userTriggeredOnInput ? {
19405 text: text,
19406 isChecked: isChecked,
19407 userTriggered: userTriggered
19408 } : {
19409 text: text,
19410 isChecked: isChecked
19411 });
19412 var name = target.name;
19413 if (type === "radio" && name && isChecked) {
19414 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
19415 if (el !== target) {
19416 var text2 = el.value;
19417 cbWithDedup(el, userTriggeredOnInput ? {
19418 text: text2,
19419 isChecked: !isChecked,
19420 userTriggered: false
19421 } : {
19422 text: text2,
19423 isChecked: !isChecked
19424 });
19425 }
19426 });
19427 }
19428 }
19429 function cbWithDedup(target, v2) {
19430 var lastInputValue = lastInputValueMap.get(target);
19431 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
19432 lastInputValueMap.set(target, v2);
19433 var id = mirror2.getId(target);
19434 callbackWrapper(inputCb)(_extends({}, v2, {
19435 id: id
19436 }));
19437 }
19438 }
19439 var events = sampling.input === "last" ? [
19440 "change"
19441 ] : [
19442 "input",
19443 "change"
19444 ];
19445 var handlers = events.map(function(eventName) {
19446 return on(eventName, callbackWrapper(eventHandler), doc);
19447 });
19448 var currentWindow = doc.defaultView;
19449 if (!currentWindow) {
19450 return function() {
19451 handlers.forEach(function(h) {
19452 return h();
19453 });
19454 };
19455 }
19456 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
19457 var hookProperties = [
19458 [
19459 currentWindow.HTMLInputElement.prototype,
19460 "value"
19461 ],
19462 [
19463 currentWindow.HTMLInputElement.prototype,
19464 "checked"
19465 ],
19466 [
19467 currentWindow.HTMLSelectElement.prototype,
19468 "value"
19469 ],
19470 [
19471 currentWindow.HTMLTextAreaElement.prototype,
19472 "value"
19473 ],
19474 // Some UI library use selectedIndex to set select value
19475 [
19476 currentWindow.HTMLSelectElement.prototype,
19477 "selectedIndex"
19478 ],
19479 [
19480 currentWindow.HTMLOptionElement.prototype,
19481 "selected"
19482 ]
19483 ];
19484 if (propertyDescriptor && propertyDescriptor.set) {
19485 var _handlers;
19486 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
19487 return hookSetter(p[0], p[1], {
19488 set: function set() {
19489 callbackWrapper(eventHandler)({
19490 target: this,
19491 isTrusted: false
19492 });
19493 }
19494 }, false, currentWindow);
19495 })));
19496 }
19497 return callbackWrapper(function() {
19498 handlers.forEach(function(h) {
19499 return h();
19500 });
19501 });
19502 }
19503 function getNestedCSSRulePositions(rule2) {
19504 var positions = [];
19505 function recurse(childRule, pos) {
19506 if (hasNestedCSSRule("CSSGroupingRule") && _instanceof(childRule.parentRule, CSSGroupingRule) || hasNestedCSSRule("CSSMediaRule") && _instanceof(childRule.parentRule, CSSMediaRule) || hasNestedCSSRule("CSSSupportsRule") && _instanceof(childRule.parentRule, CSSSupportsRule) || hasNestedCSSRule("CSSConditionRule") && _instanceof(childRule.parentRule, CSSConditionRule)) {
19507 var rules2 = Array.from(childRule.parentRule.cssRules);
19508 var index2 = rules2.indexOf(childRule);
19509 pos.unshift(index2);
19510 } else if (childRule.parentStyleSheet) {
19511 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
19512 var index21 = rules21.indexOf(childRule);
19513 pos.unshift(index21);
19514 }
19515 return pos;
19516 }
19517 return recurse(rule2, positions);
19518 }
19519 function getIdAndStyleId(sheet, mirror2, styleMirror) {
19520 var id, styleId;
19521 if (!sheet) return {};
19522 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
19523 else styleId = styleMirror.getId(sheet);
19524 return {
19525 styleId: styleId,
19526 id: id
19527 };
19528 }
19529 function initStyleSheetObserver(param, param1) {
19530 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
19531 var win = param1.win;
19532 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
19533 return function() {};
19534 }
19535 var insertRule = win.CSSStyleSheet.prototype.insertRule;
19536 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
19537 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19538 var rule2 = argumentsList[0], index2 = argumentsList[1];
19539 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19540 if (id && id !== -1 || styleId && styleId !== -1) {
19541 styleSheetRuleCb({
19542 id: id,
19543 styleId: styleId,
19544 adds: [
19545 {
19546 rule: rule2,
19547 index: index2
19548 }
19549 ]
19550 });
19551 }
19552 return target.apply(thisArg, argumentsList);
19553 })
19554 });
19555 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
19556 if (index2 === void 0) index2 = this.cssRules.length;
19557 var rule2 = selector + " { " + styleBlock + " }";
19558 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
19559 rule2,
19560 index2
19561 ]);
19562 };
19563 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
19564 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
19565 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19566 var index2 = argumentsList[0];
19567 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19568 if (id && id !== -1 || styleId && styleId !== -1) {
19569 styleSheetRuleCb({
19570 id: id,
19571 styleId: styleId,
19572 removes: [
19573 {
19574 index: index2
19575 }
19576 ]
19577 });
19578 }
19579 return target.apply(thisArg, argumentsList);
19580 })
19581 });
19582 win.CSSStyleSheet.prototype.removeRule = function(index2) {
19583 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
19584 index2
19585 ]);
19586 };
19587 var replace;
19588 if (win.CSSStyleSheet.prototype.replace) {
19589 replace = win.CSSStyleSheet.prototype.replace;
19590 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
19591 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19592 var text = argumentsList[0];
19593 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19594 if (id && id !== -1 || styleId && styleId !== -1) {
19595 styleSheetRuleCb({
19596 id: id,
19597 styleId: styleId,
19598 replace: text
19599 });
19600 }
19601 return target.apply(thisArg, argumentsList);
19602 })
19603 });
19604 }
19605 var replaceSync;
19606 if (win.CSSStyleSheet.prototype.replaceSync) {
19607 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
19608 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
19609 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19610 var text = argumentsList[0];
19611 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19612 if (id && id !== -1 || styleId && styleId !== -1) {
19613 styleSheetRuleCb({
19614 id: id,
19615 styleId: styleId,
19616 replaceSync: text
19617 });
19618 }
19619 return target.apply(thisArg, argumentsList);
19620 })
19621 });
19622 }
19623 var supportedNestedCSSRuleTypes = {};
19624 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
19625 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
19626 } else {
19627 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
19628 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
19629 }
19630 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
19631 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
19632 }
19633 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
19634 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
19635 }
19636 }
19637 var unmodifiedFunctions = {};
19638 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
19639 var typeKey = param[0], type = param[1];
19640 unmodifiedFunctions[typeKey] = {
19641 // eslint-disable-next-line @typescript-eslint/unbound-method
19642 insertRule: type.prototype.insertRule,
19643 // eslint-disable-next-line @typescript-eslint/unbound-method
19644 deleteRule: type.prototype.deleteRule
19645 };
19646 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
19647 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19648 var rule2 = argumentsList[0], index2 = argumentsList[1];
19649 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19650 if (id && id !== -1 || styleId && styleId !== -1) {
19651 styleSheetRuleCb({
19652 id: id,
19653 styleId: styleId,
19654 adds: [
19655 {
19656 rule: rule2,
19657 index: [].concat(getNestedCSSRulePositions(thisArg), [
19658 index2 || 0
19659 ])
19660 }
19661 ]
19662 });
19663 }
19664 return target.apply(thisArg, argumentsList);
19665 })
19666 });
19667 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
19668 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19669 var index2 = argumentsList[0];
19670 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19671 if (id && id !== -1 || styleId && styleId !== -1) {
19672 styleSheetRuleCb({
19673 id: id,
19674 styleId: styleId,
19675 removes: [
19676 {
19677 index: [].concat(getNestedCSSRulePositions(thisArg), [
19678 index2
19679 ])
19680 }
19681 ]
19682 });
19683 }
19684 return target.apply(thisArg, argumentsList);
19685 })
19686 });
19687 });
19688 return callbackWrapper(function() {
19689 win.CSSStyleSheet.prototype.insertRule = insertRule;
19690 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
19691 replace && (win.CSSStyleSheet.prototype.replace = replace);
19692 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
19693 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
19694 var typeKey = param[0], type = param[1];
19695 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
19696 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
19697 });
19698 });
19699 }
19700 function initAdoptedStyleSheetObserver(param, host2) {
19701 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
19702 var _a2, _b, _c;
19703 var hostId = null;
19704 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
19705 else hostId = mirror2.getId(index.host(host2));
19706 var patchTarget = host2.nodeName === "#document" ? (_a2 = host2.defaultView) == null ? void 0 : _a2.Document : (_c = (_b = host2.ownerDocument) == null ? void 0 : _b.defaultView) == null ? void 0 : _c.ShadowRoot;
19707 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
19708 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
19709 Object.defineProperty(host2, "adoptedStyleSheets", {
19710 configurable: originalPropertyDescriptor.configurable,
19711 enumerable: originalPropertyDescriptor.enumerable,
19712 get: function get() {
19713 var _a3;
19714 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
19715 },
19716 set: function set(sheets) {
19717 var _a3;
19718 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
19719 if (hostId !== null && hostId !== -1) {
19720 try {
19721 stylesheetManager.adoptStyleSheets(sheets, hostId);
19722 } catch (e2) {}
19723 }
19724 return result2;
19725 }
19726 });
19727 return callbackWrapper(function() {
19728 Object.defineProperty(host2, "adoptedStyleSheets", {
19729 configurable: originalPropertyDescriptor.configurable,
19730 enumerable: originalPropertyDescriptor.enumerable,
19731 // eslint-disable-next-line @typescript-eslint/unbound-method
19732 get: originalPropertyDescriptor.get,
19733 // eslint-disable-next-line @typescript-eslint/unbound-method
19734 set: originalPropertyDescriptor.set
19735 });
19736 });
19737 }
19738 function initStyleDeclarationObserver(param, param1) {
19739 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
19740 var win = param1.win;
19741 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
19742 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
19743 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19744 var _a2;
19745 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
19746 if (ignoreCSSAttributes.has(property)) {
19747 return setProperty.apply(thisArg, [
19748 property,
19749 value,
19750 priority
19751 ]);
19752 }
19753 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19754 if (id && id !== -1 || styleId && styleId !== -1) {
19755 styleDeclarationCb({
19756 id: id,
19757 styleId: styleId,
19758 set: {
19759 property: property,
19760 value: value,
19761 priority: priority
19762 },
19763 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19764 index: getNestedCSSRulePositions(thisArg.parentRule)
19765 });
19766 }
19767 return target.apply(thisArg, argumentsList);
19768 })
19769 });
19770 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
19771 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
19772 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19773 var _a2;
19774 var property = argumentsList[0];
19775 if (ignoreCSSAttributes.has(property)) {
19776 return removeProperty.apply(thisArg, [
19777 property
19778 ]);
19779 }
19780 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19781 if (id && id !== -1 || styleId && styleId !== -1) {
19782 styleDeclarationCb({
19783 id: id,
19784 styleId: styleId,
19785 remove: {
19786 property: property
19787 },
19788 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19789 index: getNestedCSSRulePositions(thisArg.parentRule)
19790 });
19791 }
19792 return target.apply(thisArg, argumentsList);
19793 })
19794 });
19795 return callbackWrapper(function() {
19796 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
19797 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
19798 });
19799 }
19800 function initMediaInteractionObserver(param) {
19801 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
19802 var handler = callbackWrapper(function(type) {
19803 return throttle(callbackWrapper(function(event) {
19804 var target = getEventTarget(event);
19805 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
19806 return;
19807 }
19808 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
19809 mediaInteractionCb({
19810 type: type,
19811 id: mirror2.getId(target),
19812 currentTime: currentTime,
19813 volume: volume,
19814 muted: muted,
19815 playbackRate: playbackRate,
19816 loop: loop
19817 });
19818 }), sampling.media || 500);
19819 });
19820 var handlers = [
19821 on("play", handler(MediaInteractions.Play), doc),
19822 on("pause", handler(MediaInteractions.Pause), doc),
19823 on("seeked", handler(MediaInteractions.Seeked), doc),
19824 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
19825 on("ratechange", handler(MediaInteractions.RateChange), doc)
19826 ];
19827 return callbackWrapper(function() {
19828 handlers.forEach(function(h) {
19829 return h();
19830 });
19831 });
19832 }
19833 function initFontObserver(param) {
19834 var fontCb = param.fontCb, doc = param.doc;
19835 var win = doc.defaultView;
19836 if (!win) {
19837 return function() {};
19838 }
19839 var handlers = [];
19840 var fontMap = /* @__PURE__ */ new WeakMap();
19841 var originalFontFace = win.FontFace;
19842 win.FontFace = function FontFace2(family, source, descriptors) {
19843 var fontFace = new originalFontFace(family, source, descriptors);
19844 fontMap.set(fontFace, {
19845 family: family,
19846 buffer: typeof source !== "string",
19847 descriptors: descriptors,
19848 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
19849 });
19850 return fontFace;
19851 };
19852 var restoreHandler = patch(doc.fonts, "add", function(original) {
19853 return function(fontFace) {
19854 setTimeout(callbackWrapper(function() {
19855 var p = fontMap.get(fontFace);
19856 if (p) {
19857 fontCb(p);
19858 fontMap.delete(fontFace);
19859 }
19860 }), 0);
19861 return original.apply(this, [
19862 fontFace
19863 ]);
19864 };
19865 });
19866 handlers.push(function() {
19867 win.FontFace = originalFontFace;
19868 });
19869 handlers.push(restoreHandler);
19870 return callbackWrapper(function() {
19871 handlers.forEach(function(h) {
19872 return h();
19873 });
19874 });
19875 }
19876 function initSelectionObserver(param) {
19877 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
19878 var collapsed = true;
19879 var updateSelection = callbackWrapper(function() {
19880 var selection = doc.getSelection();
19881 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
19882 collapsed = selection.isCollapsed || false;
19883 var ranges = [];
19884 var count = selection.rangeCount || 0;
19885 for(var i2 = 0; i2 < count; i2++){
19886 var range = selection.getRangeAt(i2);
19887 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
19888 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
19889 if (blocked) continue;
19890 ranges.push({
19891 start: mirror2.getId(startContainer),
19892 startOffset: startOffset,
19893 end: mirror2.getId(endContainer),
19894 endOffset: endOffset
19895 });
19896 }
19897 selectionCb({
19898 ranges: ranges
19899 });
19900 });
19901 updateSelection();
19902 return on("selectionchange", updateSelection);
19903 }
19904 function initCustomElementObserver(param) {
19905 var doc = param.doc, customElementCb = param.customElementCb;
19906 var win = doc.defaultView;
19907 if (!win || !win.customElements) return function() {};
19908 var restoreHandler = patch(win.customElements, "define", function(original) {
19909 return function(name, constructor, options) {
19910 try {
19911 customElementCb({
19912 define: {
19913 name: name
19914 }
19915 });
19916 } catch (e2) {
19917 console.warn("Custom element callback failed for " + name);
19918 }
19919 return original.apply(this, [
19920 name,
19921 constructor,
19922 options
19923 ]);
19924 };
19925 });
19926 return restoreHandler;
19927 }
19928 function mergeHooks(o2, hooks) {
19929 var mutationCb = o2.mutationCb, mousemoveCb = o2.mousemoveCb, mouseInteractionCb = o2.mouseInteractionCb, scrollCb = o2.scrollCb, viewportResizeCb = o2.viewportResizeCb, inputCb = o2.inputCb, mediaInteractionCb = o2.mediaInteractionCb, styleSheetRuleCb = o2.styleSheetRuleCb, styleDeclarationCb = o2.styleDeclarationCb, canvasMutationCb = o2.canvasMutationCb, fontCb = o2.fontCb, selectionCb = o2.selectionCb, customElementCb = o2.customElementCb;
19930 o2.mutationCb = function() {
19931 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19932 p[_key] = arguments[_key];
19933 }
19934 if (hooks.mutation) {
19935 var _hooks;
19936 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
19937 }
19938 mutationCb.apply(void 0, [].concat(p));
19939 };
19940 o2.mousemoveCb = function() {
19941 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19942 p[_key] = arguments[_key];
19943 }
19944 if (hooks.mousemove) {
19945 var _hooks;
19946 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
19947 }
19948 mousemoveCb.apply(void 0, [].concat(p));
19949 };
19950 o2.mouseInteractionCb = function() {
19951 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19952 p[_key] = arguments[_key];
19953 }
19954 if (hooks.mouseInteraction) {
19955 var _hooks;
19956 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
19957 }
19958 mouseInteractionCb.apply(void 0, [].concat(p));
19959 };
19960 o2.scrollCb = function() {
19961 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19962 p[_key] = arguments[_key];
19963 }
19964 if (hooks.scroll) {
19965 var _hooks;
19966 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
19967 }
19968 scrollCb.apply(void 0, [].concat(p));
19969 };
19970 o2.viewportResizeCb = function() {
19971 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19972 p[_key] = arguments[_key];
19973 }
19974 if (hooks.viewportResize) {
19975 var _hooks;
19976 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
19977 }
19978 viewportResizeCb.apply(void 0, [].concat(p));
19979 };
19980 o2.inputCb = function() {
19981 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19982 p[_key] = arguments[_key];
19983 }
19984 if (hooks.input) {
19985 var _hooks;
19986 (_hooks = hooks).input.apply(_hooks, [].concat(p));
19987 }
19988 inputCb.apply(void 0, [].concat(p));
19989 };
19990 o2.mediaInteractionCb = function() {
19991 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19992 p[_key] = arguments[_key];
19993 }
19994 if (hooks.mediaInteaction) {
19995 var _hooks;
19996 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
19997 }
19998 mediaInteractionCb.apply(void 0, [].concat(p));
19999 };
20000 o2.styleSheetRuleCb = function() {
20001 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20002 p[_key] = arguments[_key];
20003 }
20004 if (hooks.styleSheetRule) {
20005 var _hooks;
20006 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20007 }
20008 styleSheetRuleCb.apply(void 0, [].concat(p));
20009 };
20010 o2.styleDeclarationCb = function() {
20011 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20012 p[_key] = arguments[_key];
20013 }
20014 if (hooks.styleDeclaration) {
20015 var _hooks;
20016 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20017 }
20018 styleDeclarationCb.apply(void 0, [].concat(p));
20019 };
20020 o2.canvasMutationCb = function() {
20021 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20022 p[_key] = arguments[_key];
20023 }
20024 if (hooks.canvasMutation) {
20025 var _hooks;
20026 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20027 }
20028 canvasMutationCb.apply(void 0, [].concat(p));
20029 };
20030 o2.fontCb = function() {
20031 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20032 p[_key] = arguments[_key];
20033 }
20034 if (hooks.font) {
20035 var _hooks;
20036 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20037 }
20038 fontCb.apply(void 0, [].concat(p));
20039 };
20040 o2.selectionCb = function() {
20041 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20042 p[_key] = arguments[_key];
20043 }
20044 if (hooks.selection) {
20045 var _hooks;
20046 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20047 }
20048 selectionCb.apply(void 0, [].concat(p));
20049 };
20050 o2.customElementCb = function() {
20051 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20052 c2[_key] = arguments[_key];
20053 }
20054 if (hooks.customElement) {
20055 var _hooks;
20056 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20057 }
20058 customElementCb.apply(void 0, [].concat(c2));
20059 };
20060 }
20061 function initObservers(o2, hooks) {
20062 if (hooks === void 0) hooks = {};
20063 var currentWindow = o2.doc.defaultView;
20064 if (!currentWindow) {
20065 return function() {};
20066 }
20067 mergeHooks(o2, hooks);
20068 var mutationObserver;
20069 if (o2.recordDOM) {
20070 mutationObserver = initMutationObserver(o2, o2.doc);
20071 }
20072 var mousemoveHandler = initMoveObserver(o2);
20073 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20074 var scrollHandler = initScrollObserver(o2);
20075 var viewportResizeHandler = initViewportResizeObserver(o2, {
20076 win: currentWindow
20077 });
20078 var inputHandler = initInputObserver(o2);
20079 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20080 var styleSheetObserver = function() {};
20081 var adoptedStyleSheetObserver = function() {};
20082 var styleDeclarationObserver = function() {};
20083 var fontObserver = function() {};
20084 if (o2.recordDOM) {
20085 styleSheetObserver = initStyleSheetObserver(o2, {
20086 win: currentWindow
20087 });
20088 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20089 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20090 win: currentWindow
20091 });
20092 if (o2.collectFonts) {
20093 fontObserver = initFontObserver(o2);
20094 }
20095 }
20096 var selectionObserver = initSelectionObserver(o2);
20097 var customElementObserver = initCustomElementObserver(o2);
20098 var pluginHandlers = [];
20099 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20100 var plugin3 = _step.value;
20101 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20102 }
20103 return callbackWrapper(function() {
20104 mutationBuffers.forEach(function(b) {
20105 return b.reset();
20106 });
20107 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20108 mousemoveHandler();
20109 mouseInteractionHandler();
20110 scrollHandler();
20111 viewportResizeHandler();
20112 inputHandler();
20113 mediaInteractionHandler();
20114 styleSheetObserver();
20115 adoptedStyleSheetObserver();
20116 styleDeclarationObserver();
20117 fontObserver();
20118 selectionObserver();
20119 customElementObserver();
20120 pluginHandlers.forEach(function(h) {
20121 return h();
20122 });
20123 });
20124 }
20125 function hasNestedCSSRule(prop) {
20126 return typeof window[prop] !== "undefined";
20127 }
20128 function canMonkeyPatchNestedCSSRule(prop) {
20129 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20130 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20131 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20132 }
20133 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20134 function CrossOriginIframeMirror(generateIdFn) {
20135 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20136 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20137 this.generateIdFn = generateIdFn;
20138 }
20139 var _proto = CrossOriginIframeMirror.prototype;
20140 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20141 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20142 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20143 var id = idToRemoteIdMap.get(remoteId);
20144 if (!id) {
20145 id = this.generateIdFn();
20146 idToRemoteIdMap.set(remoteId, id);
20147 remoteIdToIdMap.set(id, remoteId);
20148 }
20149 return id;
20150 };
20151 _proto.getIds = function getIds(iframe, remoteId) {
20152 var _this = this;
20153 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20154 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20155 return remoteId.map(function(id) {
20156 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20157 });
20158 };
20159 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20160 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20161 if (typeof id !== "number") return id;
20162 var remoteId = remoteIdToIdMap.get(id);
20163 if (!remoteId) return -1;
20164 return remoteId;
20165 };
20166 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
20167 var _this = this;
20168 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20169 return ids.map(function(id) {
20170 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
20171 });
20172 };
20173 _proto.reset = function reset(iframe) {
20174 if (!iframe) {
20175 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
20176 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
20177 return;
20178 }
20179 this.iframeIdToRemoteIdMap.delete(iframe);
20180 this.iframeRemoteIdToIdMap.delete(iframe);
20181 };
20182 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
20183 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
20184 if (!idToRemoteIdMap) {
20185 idToRemoteIdMap = /* @__PURE__ */ new Map();
20186 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
20187 }
20188 return idToRemoteIdMap;
20189 };
20190 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
20191 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
20192 if (!remoteIdToIdMap) {
20193 remoteIdToIdMap = /* @__PURE__ */ new Map();
20194 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
20195 }
20196 return remoteIdToIdMap;
20197 };
20198 return CrossOriginIframeMirror;
20199 }();
20200 var IframeManager = /*#__PURE__*/ function() {
20201 function IframeManager(options) {
20202 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
20203 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
20204 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
20205 __publicField(this, "crossOriginIframeStyleMirror");
20206 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
20207 __publicField(this, "mirror");
20208 __publicField(this, "mutationCb");
20209 __publicField(this, "wrappedEmit");
20210 __publicField(this, "loadListener");
20211 __publicField(this, "stylesheetManager");
20212 __publicField(this, "recordCrossOriginIframes");
20213 this.mutationCb = options.mutationCb;
20214 this.wrappedEmit = options.wrappedEmit;
20215 this.stylesheetManager = options.stylesheetManager;
20216 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
20217 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
20218 this.mirror = options.mirror;
20219 if (this.recordCrossOriginIframes) {
20220 window.addEventListener("message", this.handleMessage.bind(this));
20221 }
20222 }
20223 var _proto = IframeManager.prototype;
20224 _proto.addIframe = function addIframe(iframeEl) {
20225 this.iframes.set(iframeEl, true);
20226 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
20227 };
20228 _proto.addLoadListener = function addLoadListener(cb) {
20229 this.loadListener = cb;
20230 };
20231 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
20232 var _a2, _b;
20233 this.mutationCb({
20234 adds: [
20235 {
20236 parentId: this.mirror.getId(iframeEl),
20237 nextId: null,
20238 node: childSn
20239 }
20240 ],
20241 removes: [],
20242 texts: [],
20243 attributes: [],
20244 isAttachIframe: true
20245 });
20246 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
20247 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
20248 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
20249 };
20250 _proto.handleMessage = function handleMessage(message) {
20251 var crossOriginMessageEvent = message;
20252 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
20253 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
20254 var iframeSourceWindow = message.source;
20255 if (!iframeSourceWindow) return;
20256 var iframeEl = this.crossOriginIframeMap.get(message.source);
20257 if (!iframeEl) return;
20258 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
20259 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
20260 };
20261 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
20262 var _this = this;
20263 var _a2;
20264 switch(e2.type){
20265 case EventType.FullSnapshot:
20266 {
20267 this.crossOriginIframeMirror.reset(iframeEl);
20268 this.crossOriginIframeStyleMirror.reset(iframeEl);
20269 this.replaceIdOnNode(e2.data.node, iframeEl);
20270 var rootId = e2.data.node.id;
20271 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
20272 this.patchRootIdOnNode(e2.data.node, rootId);
20273 return {
20274 timestamp: e2.timestamp,
20275 type: EventType.IncrementalSnapshot,
20276 data: {
20277 source: IncrementalSource.Mutation,
20278 adds: [
20279 {
20280 parentId: this.mirror.getId(iframeEl),
20281 nextId: null,
20282 node: e2.data.node
20283 }
20284 ],
20285 removes: [],
20286 texts: [],
20287 attributes: [],
20288 isAttachIframe: true
20289 }
20290 };
20291 }
20292 case EventType.Meta:
20293 case EventType.Load:
20294 case EventType.DomContentLoaded:
20295 {
20296 return false;
20297 }
20298 case EventType.Plugin:
20299 {
20300 return e2;
20301 }
20302 case EventType.Custom:
20303 {
20304 this.replaceIds(e2.data.payload, iframeEl, [
20305 "id",
20306 "parentId",
20307 "previousId",
20308 "nextId"
20309 ]);
20310 return e2;
20311 }
20312 case EventType.IncrementalSnapshot:
20313 {
20314 switch(e2.data.source){
20315 case IncrementalSource.Mutation:
20316 {
20317 e2.data.adds.forEach(function(n2) {
20318 _this.replaceIds(n2, iframeEl, [
20319 "parentId",
20320 "nextId",
20321 "previousId"
20322 ]);
20323 _this.replaceIdOnNode(n2.node, iframeEl);
20324 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
20325 rootId && _this.patchRootIdOnNode(n2.node, rootId);
20326 });
20327 e2.data.removes.forEach(function(n2) {
20328 _this.replaceIds(n2, iframeEl, [
20329 "parentId",
20330 "id"
20331 ]);
20332 });
20333 e2.data.attributes.forEach(function(n2) {
20334 _this.replaceIds(n2, iframeEl, [
20335 "id"
20336 ]);
20337 });
20338 e2.data.texts.forEach(function(n2) {
20339 _this.replaceIds(n2, iframeEl, [
20340 "id"
20341 ]);
20342 });
20343 return e2;
20344 }
20345 case IncrementalSource.Drag:
20346 case IncrementalSource.TouchMove:
20347 case IncrementalSource.MouseMove:
20348 {
20349 e2.data.positions.forEach(function(p) {
20350 _this.replaceIds(p, iframeEl, [
20351 "id"
20352 ]);
20353 });
20354 return e2;
20355 }
20356 case IncrementalSource.ViewportResize:
20357 {
20358 return false;
20359 }
20360 case IncrementalSource.MediaInteraction:
20361 case IncrementalSource.MouseInteraction:
20362 case IncrementalSource.Scroll:
20363 case IncrementalSource.CanvasMutation:
20364 case IncrementalSource.Input:
20365 {
20366 this.replaceIds(e2.data, iframeEl, [
20367 "id"
20368 ]);
20369 return e2;
20370 }
20371 case IncrementalSource.StyleSheetRule:
20372 case IncrementalSource.StyleDeclaration:
20373 {
20374 this.replaceIds(e2.data, iframeEl, [
20375 "id"
20376 ]);
20377 this.replaceStyleIds(e2.data, iframeEl, [
20378 "styleId"
20379 ]);
20380 return e2;
20381 }
20382 case IncrementalSource.Font:
20383 {
20384 return e2;
20385 }
20386 case IncrementalSource.Selection:
20387 {
20388 e2.data.ranges.forEach(function(range) {
20389 _this.replaceIds(range, iframeEl, [
20390 "start",
20391 "end"
20392 ]);
20393 });
20394 return e2;
20395 }
20396 case IncrementalSource.AdoptedStyleSheet:
20397 {
20398 this.replaceIds(e2.data, iframeEl, [
20399 "id"
20400 ]);
20401 this.replaceStyleIds(e2.data, iframeEl, [
20402 "styleIds"
20403 ]);
20404 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
20405 _this.replaceStyleIds(style, iframeEl, [
20406 "styleId"
20407 ]);
20408 });
20409 return e2;
20410 }
20411 }
20412 }
20413 }
20414 return false;
20415 };
20416 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
20417 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
20418 var key = _step.value;
20419 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
20420 if (Array.isArray(obj[key])) {
20421 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
20422 } else {
20423 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
20424 }
20425 }
20426 return obj;
20427 };
20428 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
20429 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
20430 };
20431 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
20432 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
20433 };
20434 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
20435 var _this = this;
20436 this.replaceIds(node2, iframeEl, [
20437 "id",
20438 "rootId"
20439 ]);
20440 if ("childNodes" in node2) {
20441 node2.childNodes.forEach(function(child) {
20442 _this.replaceIdOnNode(child, iframeEl);
20443 });
20444 }
20445 };
20446 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
20447 var _this = this;
20448 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
20449 if ("childNodes" in node2) {
20450 node2.childNodes.forEach(function(child) {
20451 _this.patchRootIdOnNode(child, rootId);
20452 });
20453 }
20454 };
20455 return IframeManager;
20456 }();
20457 var ShadowDomManager = /*#__PURE__*/ function() {
20458 function ShadowDomManager(options) {
20459 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
20460 __publicField(this, "mutationCb");
20461 __publicField(this, "scrollCb");
20462 __publicField(this, "bypassOptions");
20463 __publicField(this, "mirror");
20464 __publicField(this, "restoreHandlers", []);
20465 this.mutationCb = options.mutationCb;
20466 this.scrollCb = options.scrollCb;
20467 this.bypassOptions = options.bypassOptions;
20468 this.mirror = options.mirror;
20469 this.init();
20470 }
20471 var _proto = ShadowDomManager.prototype;
20472 _proto.init = function init() {
20473 this.reset();
20474 this.patchAttachShadow(Element, document);
20475 };
20476 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
20477 var _this = this;
20478 if (!isNativeShadowDom(shadowRoot2)) return;
20479 if (this.shadowDoms.has(shadowRoot2)) return;
20480 this.shadowDoms.add(shadowRoot2);
20481 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
20482 doc: doc,
20483 mutationCb: this.mutationCb,
20484 mirror: this.mirror,
20485 shadowDomManager: this
20486 }), shadowRoot2);
20487 this.restoreHandlers.push(function() {
20488 return observer.disconnect();
20489 });
20490 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
20491 scrollCb: this.scrollCb,
20492 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
20493 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
20494 doc: shadowRoot2,
20495 mirror: this.mirror
20496 })));
20497 setTimeout(function() {
20498 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
20499 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
20500 mirror: _this.mirror,
20501 stylesheetManager: _this.bypassOptions.stylesheetManager
20502 }, shadowRoot2));
20503 }, 0);
20504 };
20505 /**
20506 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
20507 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
20508 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
20509 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
20510 };
20511 /**
20512 * Patch 'attachShadow' to observe newly added shadow doms.
20513 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
20514 var manager = this;
20515 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
20516 return function(option) {
20517 var sRoot = original.call(this, option);
20518 var shadowRootEl = index.shadowRoot(this);
20519 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
20520 return sRoot;
20521 };
20522 }));
20523 };
20524 _proto.reset = function reset() {
20525 this.restoreHandlers.forEach(function(handler) {
20526 try {
20527 handler();
20528 } catch (e2) {}
20529 });
20530 this.restoreHandlers = [];
20531 this.shadowDoms = /* @__PURE__ */ new WeakSet();
20532 };
20533 return ShadowDomManager;
20534 }();
20535 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
20536 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
20537 for(var i$1 = 0; i$1 < chars.length; i$1++){
20538 lookup[chars.charCodeAt(i$1)] = i$1;
20539 }
20540 var encode = function encode(arraybuffer) {
20541 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
20542 for(i2 = 0; i2 < len; i2 += 3){
20543 base64 += chars[bytes[i2] >> 2];
20544 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
20545 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
20546 base64 += chars[bytes[i2 + 2] & 63];
20547 }
20548 if (len % 3 === 2) {
20549 base64 = base64.substring(0, base64.length - 1) + "=";
20550 } else if (len % 3 === 1) {
20551 base64 = base64.substring(0, base64.length - 2) + "==";
20552 }
20553 return base64;
20554 };
20555 var canvasVarMap = /* @__PURE__ */ new Map();
20556 function variableListFor$1(ctx, ctor) {
20557 var contextMap = canvasVarMap.get(ctx);
20558 if (!contextMap) {
20559 contextMap = /* @__PURE__ */ new Map();
20560 canvasVarMap.set(ctx, contextMap);
20561 }
20562 if (!contextMap.has(ctor)) {
20563 contextMap.set(ctor, []);
20564 }
20565 return contextMap.get(ctor);
20566 }
20567 var saveWebGLVar = function(value, win, ctx) {
20568 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
20569 var name = value.constructor.name;
20570 var list2 = variableListFor$1(ctx, name);
20571 var index2 = list2.indexOf(value);
20572 if (index2 === -1) {
20573 index2 = list2.length;
20574 list2.push(value);
20575 }
20576 return index2;
20577 };
20578 function serializeArg(value, win, ctx) {
20579 if (_instanceof(value, Array)) {
20580 return value.map(function(arg) {
20581 return serializeArg(arg, win, ctx);
20582 });
20583 } else if (value === null) {
20584 return value;
20585 } else if (_instanceof(value, Float32Array) || _instanceof(value, Float64Array) || _instanceof(value, Int32Array) || _instanceof(value, Uint32Array) || _instanceof(value, Uint8Array) || _instanceof(value, Uint16Array) || _instanceof(value, Int16Array) || _instanceof(value, Int8Array) || _instanceof(value, Uint8ClampedArray)) {
20586 var name = value.constructor.name;
20587 return {
20588 rr_type: name,
20589 args: [
20590 Object.values(value)
20591 ]
20592 };
20593 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
20594 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
20595 // value instanceof SharedArrayBuffer ||
20596 _instanceof(value, ArrayBuffer)) {
20597 var name1 = value.constructor.name;
20598 var base64 = encode(value);
20599 return {
20600 rr_type: name1,
20601 base64: base64
20602 };
20603 } else if (_instanceof(value, DataView)) {
20604 var name2 = value.constructor.name;
20605 return {
20606 rr_type: name2,
20607 args: [
20608 serializeArg(value.buffer, win, ctx),
20609 value.byteOffset,
20610 value.byteLength
20611 ]
20612 };
20613 } else if (_instanceof(value, HTMLImageElement)) {
20614 var name3 = value.constructor.name;
20615 var src = value.src;
20616 return {
20617 rr_type: name3,
20618 src: src
20619 };
20620 } else if (_instanceof(value, HTMLCanvasElement)) {
20621 var name4 = "HTMLImageElement";
20622 var src1 = value.toDataURL();
20623 return {
20624 rr_type: name4,
20625 src: src1
20626 };
20627 } else if (_instanceof(value, ImageData)) {
20628 var name5 = value.constructor.name;
20629 return {
20630 rr_type: name5,
20631 args: [
20632 serializeArg(value.data, win, ctx),
20633 value.width,
20634 value.height
20635 ]
20636 };
20637 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
20638 var name6 = value.constructor.name;
20639 var index2 = saveWebGLVar(value, win, ctx);
20640 return {
20641 rr_type: name6,
20642 index: index2
20643 };
20644 }
20645 return value;
20646 }
20647 var serializeArgs = function(args, win, ctx) {
20648 return args.map(function(arg) {
20649 return serializeArg(arg, win, ctx);
20650 });
20651 };
20652 var isInstanceOfWebGLObject = function(value, win) {
20653 var webGLConstructorNames = [
20654 "WebGLActiveInfo",
20655 "WebGLBuffer",
20656 "WebGLFramebuffer",
20657 "WebGLProgram",
20658 "WebGLRenderbuffer",
20659 "WebGLShader",
20660 "WebGLShaderPrecisionFormat",
20661 "WebGLTexture",
20662 "WebGLUniformLocation",
20663 "WebGLVertexArrayObject",
20664 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
20665 "WebGLVertexArrayObjectOES"
20666 ];
20667 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
20668 return typeof win[name] === "function";
20669 });
20670 return Boolean(supportedWebGLConstructorNames.find(function(name) {
20671 return _instanceof(value, win[name]);
20672 }));
20673 };
20674 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
20675 var _loop = function() {
20676 var prop = _step.value;
20677 try {
20678 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
20679 return "continue";
20680 }
20681 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
20682 return function() {
20683 var _this = this;
20684 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
20685 args[_key] = arguments[_key];
20686 }
20687 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
20688 setTimeout(function() {
20689 var recordArgs = serializeArgs(args, win, _this);
20690 cb(_this.canvas, {
20691 type: CanvasContext["2D"],
20692 property: prop,
20693 args: recordArgs
20694 });
20695 }, 0);
20696 }
20697 return original.apply(this, args);
20698 };
20699 });
20700 handlers.push(restoreHandler);
20701 } catch (e) {
20702 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
20703 set: function set(v2) {
20704 cb(this.canvas, {
20705 type: CanvasContext["2D"],
20706 property: prop,
20707 args: [
20708 v2
20709 ],
20710 setter: true
20711 });
20712 }
20713 });
20714 handlers.push(hookHandler);
20715 }
20716 };
20717 var handlers = [];
20718 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
20719 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
20720 return function() {
20721 handlers.forEach(function(h) {
20722 return h();
20723 });
20724 };
20725 }
20726 function getNormalizedContextName(contextType) {
20727 return contextType === "experimental-webgl" ? "webgl" : contextType;
20728 }
20729 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
20730 var handlers = [];
20731 try {
20732 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
20733 return function(contextType) {
20734 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
20735 args[_key - 1] = arguments[_key];
20736 }
20737 if (!isBlocked(this, blockClass, blockSelector, true)) {
20738 var ctxName = getNormalizedContextName(contextType);
20739 if (!("__context" in this)) this.__context = ctxName;
20740 if (setPreserveDrawingBufferToTrue && [
20741 "webgl",
20742 "webgl2"
20743 ].includes(ctxName)) {
20744 if (args[0] && _type_of(args[0]) === "object") {
20745 var contextAttributes = args[0];
20746 if (!contextAttributes.preserveDrawingBuffer) {
20747 contextAttributes.preserveDrawingBuffer = true;
20748 }
20749 } else {
20750 args.splice(0, 1, {
20751 preserveDrawingBuffer: true
20752 });
20753 }
20754 }
20755 }
20756 return original.apply(this, [].concat([
20757 contextType
20758 ], args));
20759 };
20760 });
20761 handlers.push(restoreHandler);
20762 } catch (e) {
20763 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
20764 }
20765 return function() {
20766 handlers.forEach(function(h) {
20767 return h();
20768 });
20769 };
20770 }
20771 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
20772 var _loop = function() {
20773 var prop = _step.value;
20774 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
20775 [
20776 "isContextLost",
20777 "canvas",
20778 "drawingBufferWidth",
20779 "drawingBufferHeight"
20780 ].includes(prop)) {
20781 return "continue";
20782 }
20783 try {
20784 if (typeof prototype[prop] !== "function") {
20785 return "continue";
20786 }
20787 var restoreHandler = patch(prototype, prop, function(original) {
20788 return function() {
20789 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
20790 args[_key] = arguments[_key];
20791 }
20792 var result2 = original.apply(this, args);
20793 saveWebGLVar(result2, win, this);
20794 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
20795 var recordArgs = serializeArgs(args, win, this);
20796 var mutation = {
20797 type: type,
20798 property: prop,
20799 args: recordArgs
20800 };
20801 cb(this.canvas, mutation);
20802 }
20803 return result2;
20804 };
20805 });
20806 handlers.push(restoreHandler);
20807 } catch (e) {
20808 var hookHandler = hookSetter(prototype, prop, {
20809 set: function set(v2) {
20810 cb(this.canvas, {
20811 type: type,
20812 property: prop,
20813 args: [
20814 v2
20815 ],
20816 setter: true
20817 });
20818 }
20819 });
20820 handlers.push(hookHandler);
20821 }
20822 };
20823 var handlers = [];
20824 var props = Object.getOwnPropertyNames(prototype);
20825 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
20826 return handlers;
20827 }
20828 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
20829 var _handlers;
20830 var handlers = [];
20831 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
20832 if (typeof win.WebGL2RenderingContext !== "undefined") {
20833 var _handlers1;
20834 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
20835 }
20836 return function() {
20837 handlers.forEach(function(h) {
20838 return h();
20839 });
20840 };
20841 }
20842 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
20843 var decodeBase64 = function(base64) {
20844 return Uint8Array.from(atob(base64), function(c2) {
20845 return c2.charCodeAt(0);
20846 });
20847 };
20848 var blob = typeof window !== "undefined" && window.Blob && new Blob([
20849 decodeBase64(encodedJs)
20850 ], {
20851 type: "text/javascript;charset=utf-8"
20852 });
20853 function WorkerWrapper(options) {
20854 var objURL;
20855 try {
20856 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
20857 if (!objURL) throw "";
20858 var worker = new Worker(objURL, {
20859 name: options == null ? void 0 : options.name
20860 });
20861 worker.addEventListener("error", function() {
20862 (window.URL || window.webkitURL).revokeObjectURL(objURL);
20863 });
20864 return worker;
20865 } catch (e2) {
20866 return new Worker("data:text/javascript;base64," + encodedJs, {
20867 name: options == null ? void 0 : options.name
20868 });
20869 } finally{
20870 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
20871 }
20872 }
20873 var CanvasManager = /*#__PURE__*/ function() {
20874 function CanvasManager(options) {
20875 var _this = this;
20876 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
20877 __publicField(this, "rafStamps", {
20878 latestId: 0,
20879 invokeId: null
20880 });
20881 __publicField(this, "mirror");
20882 __publicField(this, "mutationCb");
20883 __publicField(this, "resetObservers");
20884 __publicField(this, "frozen", false);
20885 __publicField(this, "locked", false);
20886 __publicField(this, "processMutation", function(target, mutation) {
20887 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
20888 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
20889 if (!_this.pendingCanvasMutations.has(target)) {
20890 _this.pendingCanvasMutations.set(target, []);
20891 }
20892 _this.pendingCanvasMutations.get(target).push(mutation);
20893 });
20894 var _options_sampling = options.sampling, sampling = _options_sampling === void 0 ? "all" : _options_sampling, win = options.win, blockClass = options.blockClass, blockSelector = options.blockSelector, recordCanvas = options.recordCanvas, dataURLOptions = options.dataURLOptions;
20895 this.mutationCb = options.mutationCb;
20896 this.mirror = options.mirror;
20897 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
20898 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
20899 dataURLOptions: dataURLOptions
20900 });
20901 }
20902 var _proto = CanvasManager.prototype;
20903 _proto.reset = function reset() {
20904 this.pendingCanvasMutations.clear();
20905 this.resetObservers && this.resetObservers();
20906 };
20907 _proto.freeze = function freeze() {
20908 this.frozen = true;
20909 };
20910 _proto.unfreeze = function unfreeze() {
20911 this.frozen = false;
20912 };
20913 _proto.lock = function lock() {
20914 this.locked = true;
20915 };
20916 _proto.unlock = function unlock() {
20917 this.locked = false;
20918 };
20919 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
20920 var _this = this;
20921 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
20922 var snapshotInProgressMap = /* @__PURE__ */ new Map();
20923 var worker = new WorkerWrapper();
20924 worker.onmessage = function(e2) {
20925 var id = e2.data.id;
20926 snapshotInProgressMap.set(id, false);
20927 if (!("base64" in e2.data)) return;
20928 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
20929 _this.mutationCb({
20930 id: id,
20931 type: CanvasContext["2D"],
20932 commands: [
20933 {
20934 property: "clearRect",
20935 // wipe canvas
20936 args: [
20937 0,
20938 0,
20939 width,
20940 height
20941 ]
20942 },
20943 {
20944 property: "drawImage",
20945 // draws (semi-transparent) image
20946 args: [
20947 {
20948 rr_type: "ImageBitmap",
20949 args: [
20950 {
20951 rr_type: "Blob",
20952 data: [
20953 {
20954 rr_type: "ArrayBuffer",
20955 base64: base64
20956 }
20957 ],
20958 type: type
20959 }
20960 ]
20961 },
20962 0,
20963 0
20964 ]
20965 }
20966 ]
20967 });
20968 };
20969 var timeBetweenSnapshots = 1e3 / fps;
20970 var lastSnapshotTime = 0;
20971 var rafId;
20972 var getCanvas = function() {
20973 var matchedCanvas = [];
20974 win.document.querySelectorAll("canvas").forEach(function(canvas) {
20975 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
20976 matchedCanvas.push(canvas);
20977 }
20978 });
20979 return matchedCanvas;
20980 };
20981 var takeCanvasSnapshots = function(timestamp) {
20982 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
20983 rafId = requestAnimationFrame(takeCanvasSnapshots);
20984 return;
20985 }
20986 lastSnapshotTime = timestamp;
20987 var _this1 = _this;
20988 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
20989 var _a2, id, context, bitmap;
20990 return _ts_generator(this, function(_state) {
20991 switch(_state.label){
20992 case 0:
20993 id = _this1.mirror.getId(canvas);
20994 if (snapshotInProgressMap.get(id)) return [
20995 2
20996 ];
20997 if (canvas.width === 0 || canvas.height === 0) return [
20998 2
20999 ];
21000 snapshotInProgressMap.set(id, true);
21001 if ([
21002 "webgl",
21003 "webgl2"
21004 ].includes(canvas.__context)) {
21005 context = canvas.getContext(canvas.__context);
21006 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21007 context.clear(context.COLOR_BUFFER_BIT);
21008 }
21009 }
21010 return [
21011 4,
21012 createImageBitmap(canvas)
21013 ];
21014 case 1:
21015 bitmap = _state.sent();
21016 worker.postMessage({
21017 id: id,
21018 bitmap: bitmap,
21019 width: canvas.width,
21020 height: canvas.height,
21021 dataURLOptions: options.dataURLOptions
21022 }, [
21023 bitmap
21024 ]);
21025 return [
21026 2
21027 ];
21028 }
21029 });
21030 }));
21031 rafId = requestAnimationFrame(takeCanvasSnapshots);
21032 };
21033 rafId = requestAnimationFrame(takeCanvasSnapshots);
21034 this.resetObservers = function() {
21035 canvasContextReset();
21036 cancelAnimationFrame(rafId);
21037 };
21038 };
21039 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21040 this.startRAFTimestamping();
21041 this.startPendingCanvasMutationFlusher();
21042 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21043 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21044 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21045 this.resetObservers = function() {
21046 canvasContextReset();
21047 canvas2DReset();
21048 canvasWebGL1and2Reset();
21049 };
21050 };
21051 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21052 var _this = this;
21053 requestAnimationFrame(function() {
21054 return _this.flushPendingCanvasMutations();
21055 });
21056 };
21057 _proto.startRAFTimestamping = function startRAFTimestamping() {
21058 var _this = this;
21059 var setLatestRAFTimestamp = function(timestamp) {
21060 _this.rafStamps.latestId = timestamp;
21061 requestAnimationFrame(setLatestRAFTimestamp);
21062 };
21063 requestAnimationFrame(setLatestRAFTimestamp);
21064 };
21065 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21066 var _this = this;
21067 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21068 var id = _this.mirror.getId(canvas);
21069 _this.flushPendingCanvasMutationFor(canvas, id);
21070 });
21071 requestAnimationFrame(function() {
21072 return _this.flushPendingCanvasMutations();
21073 });
21074 };
21075 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21076 if (this.frozen || this.locked) {
21077 return;
21078 }
21079 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21080 if (!valuesWithType || id === -1) return;
21081 var values = valuesWithType.map(function(value) {
21082 value.type; var rest = _object_without_properties_loose(value, [
21083 "type"
21084 ]);
21085 return rest;
21086 });
21087 var type = valuesWithType[0].type;
21088 this.mutationCb({
21089 id: id,
21090 type: type,
21091 commands: values
21092 });
21093 this.pendingCanvasMutations.delete(canvas);
21094 };
21095 return CanvasManager;
21096 }();
21097 var StylesheetManager = /*#__PURE__*/ function() {
21098 function StylesheetManager(options) {
21099 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21100 __publicField(this, "mutationCb");
21101 __publicField(this, "adoptedStyleSheetCb");
21102 __publicField(this, "styleMirror", new StyleSheetMirror());
21103 this.mutationCb = options.mutationCb;
21104 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21105 }
21106 var _proto = StylesheetManager.prototype;
21107 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21108 if ("_cssText" in childSn.attributes) this.mutationCb({
21109 adds: [],
21110 removes: [],
21111 texts: [],
21112 attributes: [
21113 {
21114 id: childSn.id,
21115 attributes: childSn.attributes
21116 }
21117 ]
21118 });
21119 this.trackLinkElement(linkEl);
21120 };
21121 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21122 if (this.trackedLinkElements.has(linkEl)) return;
21123 this.trackedLinkElements.add(linkEl);
21124 this.trackStylesheetInLinkElement(linkEl);
21125 };
21126 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21127 var _this, _loop = function() {
21128 var sheet = _step.value;
21129 var styleId = void 0;
21130 if (!_this.styleMirror.has(sheet)) {
21131 styleId = _this.styleMirror.add(sheet);
21132 styles.push({
21133 styleId: styleId,
21134 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21135 return {
21136 rule: stringifyRule(r2, sheet.href),
21137 index: index2
21138 };
21139 })
21140 });
21141 } else styleId = _this.styleMirror.getId(sheet);
21142 adoptedStyleSheetData.styleIds.push(styleId);
21143 };
21144 if (sheets.length === 0) return;
21145 var adoptedStyleSheetData = {
21146 id: hostId,
21147 styleIds: []
21148 };
21149 var styles = [];
21150 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21151 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21152 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21153 };
21154 _proto.reset = function reset() {
21155 this.styleMirror.reset();
21156 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21157 };
21158 // TODO: take snapshot on stylesheet reload by applying event listener
21159 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21160 return StylesheetManager;
21161 }();
21162 var ProcessedNodeManager = /*#__PURE__*/ function() {
21163 function ProcessedNodeManager() {
21164 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21165 __publicField(this, "active", false);
21166 }
21167 var _proto = ProcessedNodeManager.prototype;
21168 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
21169 var buffers = this.nodeMap.get(node2);
21170 return buffers && Array.from(buffers).some(function(buffer) {
21171 return buffer !== thisBuffer;
21172 });
21173 };
21174 _proto.add = function add(node2, buffer) {
21175 var _this = this;
21176 if (!this.active) {
21177 this.active = true;
21178 requestAnimationFrame(function() {
21179 _this.nodeMap = /* @__PURE__ */ new WeakMap();
21180 _this.active = false;
21181 });
21182 }
21183 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
21184 };
21185 _proto.destroy = function destroy() {};
21186 return ProcessedNodeManager;
21187 }();
21188 var wrappedEmit;
21189 var takeFullSnapshot$1;
21190 var canvasManager;
21191 var recording = false;
21192 try {
21193 if (Array.from([
21194 1
21195 ], function(x2) {
21196 return x2 * 2;
21197 })[0] !== 2) {
21198 var cleanFrame = document.createElement("iframe");
21199 document.body.appendChild(cleanFrame);
21200 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
21201 document.body.removeChild(cleanFrame);
21202 }
21203 } catch (err) {
21204 console.debug("Unable to override Array.from", err);
21205 }
21206 var mirror = createMirror$2();
21207 function record(options) {
21208 if (options === void 0) options = {};
21209 var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _options_blockClass = options.blockClass, blockClass = _options_blockClass === void 0 ? "rr-block" : _options_blockClass, _options_blockSelector = options.blockSelector, blockSelector = _options_blockSelector === void 0 ? null : _options_blockSelector, _options_ignoreClass = options.ignoreClass, ignoreClass = _options_ignoreClass === void 0 ? "rr-ignore" : _options_ignoreClass, _options_ignoreSelector = options.ignoreSelector, ignoreSelector = _options_ignoreSelector === void 0 ? null : _options_ignoreSelector, _options_maskTextClass = options.maskTextClass, maskTextClass = _options_maskTextClass === void 0 ? "rr-mask" : _options_maskTextClass, _options_maskTextSelector = options.maskTextSelector, maskTextSelector = _options_maskTextSelector === void 0 ? null : _options_maskTextSelector, _options_inlineStylesheet = options.inlineStylesheet, inlineStylesheet = _options_inlineStylesheet === void 0 ? true : _options_inlineStylesheet, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _options_sampling = options.sampling, sampling = _options_sampling === void 0 ? {} : _options_sampling, _options_dataURLOptions = options.dataURLOptions, dataURLOptions = _options_dataURLOptions === void 0 ? {} : _options_dataURLOptions, mousemoveWait = options.mousemoveWait, _options_recordDOM = options.recordDOM, recordDOM = _options_recordDOM === void 0 ? true : _options_recordDOM, _options_recordCanvas = options.recordCanvas, recordCanvas = _options_recordCanvas === void 0 ? false : _options_recordCanvas, _options_recordCrossOriginIframes = options.recordCrossOriginIframes, recordCrossOriginIframes = _options_recordCrossOriginIframes === void 0 ? false : _options_recordCrossOriginIframes, _options_recordAfter = options.recordAfter, recordAfter = _options_recordAfter === void 0 ? options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load" : _options_recordAfter, _options_userTriggeredOnInput = options.userTriggeredOnInput, userTriggeredOnInput = _options_userTriggeredOnInput === void 0 ? false : _options_userTriggeredOnInput, _options_collectFonts = options.collectFonts, collectFonts = _options_collectFonts === void 0 ? false : _options_collectFonts, _options_inlineImages = options.inlineImages, inlineImages = _options_inlineImages === void 0 ? false : _options_inlineImages, plugins = options.plugins, _options_keepIframeSrcFn = options.keepIframeSrcFn, keepIframeSrcFn = _options_keepIframeSrcFn === void 0 ? function() {
21210 return false;
21211 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
21212 registerErrorHandler(errorHandler2);
21213 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
21214 var passEmitsToParent = false;
21215 if (!inEmittingFrame) {
21216 try {
21217 if (window.parent.document) {
21218 passEmitsToParent = false;
21219 }
21220 } catch (e2) {
21221 passEmitsToParent = true;
21222 }
21223 }
21224 if (inEmittingFrame && !emit) {
21225 throw new Error("emit function is required");
21226 }
21227 if (!inEmittingFrame && !passEmitsToParent) {
21228 return function() {};
21229 }
21230 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
21231 sampling.mousemove = mousemoveWait;
21232 }
21233 mirror.reset();
21234 var maskInputOptions = maskAllInputs === true ? {
21235 color: true,
21236 date: true,
21237 "datetime-local": true,
21238 email: true,
21239 month: true,
21240 number: true,
21241 range: true,
21242 search: true,
21243 tel: true,
21244 text: true,
21245 time: true,
21246 url: true,
21247 week: true,
21248 textarea: true,
21249 select: true,
21250 password: true
21251 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
21252 password: true
21253 };
21254 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
21255 script: true,
21256 comment: true,
21257 headFavicon: true,
21258 headWhitespace: true,
21259 headMetaSocial: true,
21260 headMetaRobots: true,
21261 headMetaHttpEquiv: true,
21262 headMetaVerification: true,
21263 // the following are off for slimDOMOptions === true,
21264 // as they destroy some (hidden) info:
21265 headMetaAuthorship: _slimDOMOptions === "all",
21266 headMetaDescKeywords: _slimDOMOptions === "all",
21267 headTitleMutations: _slimDOMOptions === "all"
21268 } : _slimDOMOptions ? _slimDOMOptions : {};
21269 polyfill$1();
21270 var lastFullSnapshotEvent;
21271 var incrementalSnapshotCount = 0;
21272 var eventProcessor = function(e2) {
21273 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21274 var plugin3 = _step.value;
21275 if (plugin3.eventProcessor) {
21276 e2 = plugin3.eventProcessor(e2);
21277 }
21278 }
21279 if (packFn && // Disable packing events which will be emitted to parent frames.
21280 !passEmitsToParent) {
21281 e2 = packFn(e2);
21282 }
21283 return e2;
21284 };
21285 wrappedEmit = function(r2, isCheckout) {
21286 var _a2;
21287 var e2 = r2;
21288 e2.timestamp = nowTimestamp();
21289 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
21290 mutationBuffers.forEach(function(buf) {
21291 return buf.unfreeze();
21292 });
21293 }
21294 if (inEmittingFrame) {
21295 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
21296 } else if (passEmitsToParent) {
21297 var message = {
21298 type: "rrweb",
21299 event: eventProcessor(e2),
21300 origin: window.location.origin,
21301 isCheckout: isCheckout
21302 };
21303 window.parent.postMessage(message, "*");
21304 }
21305 if (e2.type === EventType.FullSnapshot) {
21306 lastFullSnapshotEvent = e2;
21307 incrementalSnapshotCount = 0;
21308 } else if (e2.type === EventType.IncrementalSnapshot) {
21309 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
21310 return;
21311 }
21312 incrementalSnapshotCount++;
21313 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
21314 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
21315 if (exceedCount || exceedTime) {
21316 takeFullSnapshot$1(true);
21317 }
21318 }
21319 };
21320 var wrappedMutationEmit = function(m) {
21321 wrappedEmit({
21322 type: EventType.IncrementalSnapshot,
21323 data: _extends({
21324 source: IncrementalSource.Mutation
21325 }, m)
21326 });
21327 };
21328 var wrappedScrollEmit = function(p) {
21329 return wrappedEmit({
21330 type: EventType.IncrementalSnapshot,
21331 data: _extends({
21332 source: IncrementalSource.Scroll
21333 }, p)
21334 });
21335 };
21336 var wrappedCanvasMutationEmit = function(p) {
21337 return wrappedEmit({
21338 type: EventType.IncrementalSnapshot,
21339 data: _extends({
21340 source: IncrementalSource.CanvasMutation
21341 }, p)
21342 });
21343 };
21344 var wrappedAdoptedStyleSheetEmit = function(a2) {
21345 return wrappedEmit({
21346 type: EventType.IncrementalSnapshot,
21347 data: _extends({
21348 source: IncrementalSource.AdoptedStyleSheet
21349 }, a2)
21350 });
21351 };
21352 var stylesheetManager = new StylesheetManager({
21353 mutationCb: wrappedMutationEmit,
21354 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
21355 });
21356 var iframeManager = new IframeManager({
21357 mirror: mirror,
21358 mutationCb: wrappedMutationEmit,
21359 stylesheetManager: stylesheetManager,
21360 recordCrossOriginIframes: recordCrossOriginIframes,
21361 wrappedEmit: wrappedEmit
21362 });
21363 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21364 var plugin3 = _step.value;
21365 if (plugin3.getMirror) plugin3.getMirror({
21366 nodeMirror: mirror,
21367 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
21368 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
21369 });
21370 }
21371 var processedNodeManager = new ProcessedNodeManager();
21372 canvasManager = new CanvasManager({
21373 recordCanvas: recordCanvas,
21374 mutationCb: wrappedCanvasMutationEmit,
21375 win: window,
21376 blockClass: blockClass,
21377 blockSelector: blockSelector,
21378 mirror: mirror,
21379 sampling: sampling.canvas,
21380 dataURLOptions: dataURLOptions
21381 });
21382 var shadowDomManager = new ShadowDomManager({
21383 mutationCb: wrappedMutationEmit,
21384 scrollCb: wrappedScrollEmit,
21385 bypassOptions: {
21386 blockClass: blockClass,
21387 blockSelector: blockSelector,
21388 maskTextClass: maskTextClass,
21389 maskTextSelector: maskTextSelector,
21390 inlineStylesheet: inlineStylesheet,
21391 maskInputOptions: maskInputOptions,
21392 dataURLOptions: dataURLOptions,
21393 maskTextFn: maskTextFn,
21394 maskInputFn: maskInputFn,
21395 recordCanvas: recordCanvas,
21396 inlineImages: inlineImages,
21397 sampling: sampling,
21398 slimDOMOptions: slimDOMOptions,
21399 iframeManager: iframeManager,
21400 stylesheetManager: stylesheetManager,
21401 canvasManager: canvasManager,
21402 keepIframeSrcFn: keepIframeSrcFn,
21403 processedNodeManager: processedNodeManager
21404 },
21405 mirror: mirror
21406 });
21407 takeFullSnapshot$1 = function(isCheckout) {
21408 if (isCheckout === void 0) isCheckout = false;
21409 if (!recordDOM) {
21410 return;
21411 }
21412 wrappedEmit({
21413 type: EventType.Meta,
21414 data: {
21415 href: window.location.href,
21416 width: getWindowWidth(),
21417 height: getWindowHeight()
21418 }
21419 }, isCheckout);
21420 stylesheetManager.reset();
21421 shadowDomManager.init();
21422 mutationBuffers.forEach(function(buf) {
21423 return buf.lock();
21424 });
21425 var node2 = snapshot(document, {
21426 mirror: mirror,
21427 blockClass: blockClass,
21428 blockSelector: blockSelector,
21429 maskTextClass: maskTextClass,
21430 maskTextSelector: maskTextSelector,
21431 inlineStylesheet: inlineStylesheet,
21432 maskAllInputs: maskInputOptions,
21433 maskTextFn: maskTextFn,
21434 maskInputFn: maskInputFn,
21435 slimDOM: slimDOMOptions,
21436 dataURLOptions: dataURLOptions,
21437 recordCanvas: recordCanvas,
21438 inlineImages: inlineImages,
21439 onSerialize: function(n2) {
21440 if (isSerializedIframe(n2, mirror)) {
21441 iframeManager.addIframe(n2);
21442 }
21443 if (isSerializedStylesheet(n2, mirror)) {
21444 stylesheetManager.trackLinkElement(n2);
21445 }
21446 if (hasShadowRoot(n2)) {
21447 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
21448 }
21449 },
21450 onIframeLoad: function(iframe, childSn) {
21451 iframeManager.attachIframe(iframe, childSn);
21452 shadowDomManager.observeAttachShadow(iframe);
21453 },
21454 onStylesheetLoad: function(linkEl, childSn) {
21455 stylesheetManager.attachLinkElement(linkEl, childSn);
21456 },
21457 keepIframeSrcFn: keepIframeSrcFn
21458 });
21459 if (!node2) {
21460 return console.warn("Failed to snapshot the document");
21461 }
21462 wrappedEmit({
21463 type: EventType.FullSnapshot,
21464 data: {
21465 node: node2,
21466 initialOffset: getWindowScroll(window)
21467 }
21468 }, isCheckout);
21469 mutationBuffers.forEach(function(buf) {
21470 return buf.unlock();
21471 });
21472 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
21473 };
21474 try {
21475 var handlers = [];
21476 var observe = function(doc) {
21477 var _a2;
21478 return callbackWrapper(initObservers)({
21479 mutationCb: wrappedMutationEmit,
21480 mousemoveCb: function(positions, source) {
21481 return wrappedEmit({
21482 type: EventType.IncrementalSnapshot,
21483 data: {
21484 source: source,
21485 positions: positions
21486 }
21487 });
21488 },
21489 mouseInteractionCb: function(d) {
21490 return wrappedEmit({
21491 type: EventType.IncrementalSnapshot,
21492 data: _extends({
21493 source: IncrementalSource.MouseInteraction
21494 }, d)
21495 });
21496 },
21497 scrollCb: wrappedScrollEmit,
21498 viewportResizeCb: function(d) {
21499 return wrappedEmit({
21500 type: EventType.IncrementalSnapshot,
21501 data: _extends({
21502 source: IncrementalSource.ViewportResize
21503 }, d)
21504 });
21505 },
21506 inputCb: function(v2) {
21507 return wrappedEmit({
21508 type: EventType.IncrementalSnapshot,
21509 data: _extends({
21510 source: IncrementalSource.Input
21511 }, v2)
21512 });
21513 },
21514 mediaInteractionCb: function(p) {
21515 return wrappedEmit({
21516 type: EventType.IncrementalSnapshot,
21517 data: _extends({
21518 source: IncrementalSource.MediaInteraction
21519 }, p)
21520 });
21521 },
21522 styleSheetRuleCb: function(r2) {
21523 return wrappedEmit({
21524 type: EventType.IncrementalSnapshot,
21525 data: _extends({
21526 source: IncrementalSource.StyleSheetRule
21527 }, r2)
21528 });
21529 },
21530 styleDeclarationCb: function(r2) {
21531 return wrappedEmit({
21532 type: EventType.IncrementalSnapshot,
21533 data: _extends({
21534 source: IncrementalSource.StyleDeclaration
21535 }, r2)
21536 });
21537 },
21538 canvasMutationCb: wrappedCanvasMutationEmit,
21539 fontCb: function(p) {
21540 return wrappedEmit({
21541 type: EventType.IncrementalSnapshot,
21542 data: _extends({
21543 source: IncrementalSource.Font
21544 }, p)
21545 });
21546 },
21547 selectionCb: function(p) {
21548 wrappedEmit({
21549 type: EventType.IncrementalSnapshot,
21550 data: _extends({
21551 source: IncrementalSource.Selection
21552 }, p)
21553 });
21554 },
21555 customElementCb: function(c2) {
21556 wrappedEmit({
21557 type: EventType.IncrementalSnapshot,
21558 data: _extends({
21559 source: IncrementalSource.CustomElement
21560 }, c2)
21561 });
21562 },
21563 blockClass: blockClass,
21564 ignoreClass: ignoreClass,
21565 ignoreSelector: ignoreSelector,
21566 maskTextClass: maskTextClass,
21567 maskTextSelector: maskTextSelector,
21568 maskInputOptions: maskInputOptions,
21569 inlineStylesheet: inlineStylesheet,
21570 sampling: sampling,
21571 recordDOM: recordDOM,
21572 recordCanvas: recordCanvas,
21573 inlineImages: inlineImages,
21574 userTriggeredOnInput: userTriggeredOnInput,
21575 collectFonts: collectFonts,
21576 doc: doc,
21577 maskInputFn: maskInputFn,
21578 maskTextFn: maskTextFn,
21579 keepIframeSrcFn: keepIframeSrcFn,
21580 blockSelector: blockSelector,
21581 slimDOMOptions: slimDOMOptions,
21582 dataURLOptions: dataURLOptions,
21583 mirror: mirror,
21584 iframeManager: iframeManager,
21585 stylesheetManager: stylesheetManager,
21586 shadowDomManager: shadowDomManager,
21587 processedNodeManager: processedNodeManager,
21588 canvasManager: canvasManager,
21589 ignoreCSSAttributes: ignoreCSSAttributes,
21590 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
21591 return p.observer;
21592 })) == null ? void 0 : _a2.map(function(p) {
21593 return {
21594 observer: p.observer,
21595 options: p.options,
21596 callback: function(payload) {
21597 return wrappedEmit({
21598 type: EventType.Plugin,
21599 data: {
21600 plugin: p.name,
21601 payload: payload
21602 }
21603 });
21604 }
21605 };
21606 })) || []
21607 }, hooks);
21608 };
21609 iframeManager.addLoadListener(function(iframeEl) {
21610 try {
21611 handlers.push(observe(iframeEl.contentDocument));
21612 } catch (error) {
21613 console.warn(error);
21614 }
21615 });
21616 var init = function() {
21617 takeFullSnapshot$1();
21618 handlers.push(observe(document));
21619 recording = true;
21620 };
21621 if (document.readyState === "interactive" || document.readyState === "complete") {
21622 init();
21623 } else {
21624 handlers.push(on("DOMContentLoaded", function() {
21625 wrappedEmit({
21626 type: EventType.DomContentLoaded,
21627 data: {}
21628 });
21629 if (recordAfter === "DOMContentLoaded") init();
21630 }));
21631 handlers.push(on("load", function() {
21632 wrappedEmit({
21633 type: EventType.Load,
21634 data: {}
21635 });
21636 if (recordAfter === "load") init();
21637 }, window));
21638 }
21639 return function() {
21640 handlers.forEach(function(h) {
21641 return h();
21642 });
21643 processedNodeManager.destroy();
21644 recording = false;
21645 unregisterErrorHandler();
21646 };
21647 } catch (error) {
21648 console.warn(error);
21649 }
21650 }
21651 record.addCustomEvent = function(tag, payload) {
21652 if (!recording) {
21653 throw new Error("please add custom event after start recording");
21654 }
21655 wrappedEmit({
21656 type: EventType.Custom,
21657 data: {
21658 tag: tag,
21659 payload: payload
21660 }
21661 });
21662 };
21663 record.freezePage = function() {
21664 mutationBuffers.forEach(function(buf) {
21665 return buf.freeze();
21666 });
21667 };
21668 record.takeFullSnapshot = function(isCheckout) {
21669 if (!recording) {
21670 throw new Error("please take full snapshot after start recording");
21671 }
21672 takeFullSnapshot$1(isCheckout);
21673 };
21674 record.mirror = mirror;
21675 var n;
21676 !function(t2) {
21677 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
21678 }(n || (n = {}));
21679 record.addCustomEvent;
21680 record.freezePage;
21681 record.takeFullSnapshot;
21682
21683 var setImmediate = win['setImmediate'];
21684 var builtInProp, cycle, schedulingQueue,
21685 ToString = Object.prototype.toString,
21686 timer = (typeof setImmediate !== 'undefined') ?
21687 function timer(fn) { return setImmediate(fn); } :
21688 setTimeout;
21689
21690 // dammit, IE8.
21691 try {
21692 Object.defineProperty({},'x',{});
21693 builtInProp = function builtInProp(obj,name,val,config) {
21694 return Object.defineProperty(obj,name,{
21695 value: val,
21696 writable: true,
21697 configurable: config !== false
21698 });
21699 };
21700 }
21701 catch (err) {
21702 builtInProp = function builtInProp(obj,name,val) {
21703 obj[name] = val;
21704 return obj;
21705 };
21706 }
21707
21708 // Note: using a queue instead of array for efficiency
21709 schedulingQueue = (function Queue() {
21710 var first, last, item;
21711
21712 function Item(fn,self) {
21713 this.fn = fn;
21714 this.self = self;
21715 this.next = void 0;
21716 }
21717
21718 return {
21719 add: function add(fn,self) {
21720 item = new Item(fn,self);
21721 if (last) {
21722 last.next = item;
21723 }
21724 else {
21725 first = item;
21726 }
21727 last = item;
21728 item = void 0;
21729 },
21730 drain: function drain() {
21731 var f = first;
21732 first = last = cycle = void 0;
21733
21734 while (f) {
21735 f.fn.call(f.self);
21736 f = f.next;
21737 }
21738 }
21739 };
21740 })();
21741
21742 function schedule(fn,self) {
21743 schedulingQueue.add(fn,self);
21744 if (!cycle) {
21745 cycle = timer(schedulingQueue.drain);
21746 }
21747 }
21748
21749 // promise duck typing
21750 function isThenable(o) {
21751 var _then, oType = typeof o;
21752
21753 if (o !== null && (oType === 'object' || oType === 'function')) {
21754 _then = o.then;
21755 }
21756 return typeof _then === 'function' ? _then : false;
21757 }
21758
21759 function notify() {
21760 for (var i=0; i<this.chain.length; i++) {
21761 notifyIsolated(
21762 this,
21763 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
21764 this.chain[i]
21765 );
21766 }
21767 this.chain.length = 0;
21768 }
21769
21770 // NOTE: This is a separate function to isolate
21771 // the `try..catch` so that other code can be
21772 // optimized better
21773 function notifyIsolated(self,cb,chain) {
21774 var ret, _then;
21775 try {
21776 if (cb === false) {
21777 chain.reject(self.msg);
21778 }
21779 else {
21780 if (cb === true) {
21781 ret = self.msg;
21782 }
21783 else {
21784 ret = cb.call(void 0,self.msg);
21785 }
21786
21787 if (ret === chain.promise) {
21788 chain.reject(TypeError('Promise-chain cycle'));
21789 }
21790 // eslint-disable-next-line no-cond-assign
21791 else if (_then = isThenable(ret)) {
21792 _then.call(ret,chain.resolve,chain.reject);
21793 }
21794 else {
21795 chain.resolve(ret);
21796 }
21797 }
21798 }
21799 catch (err) {
21800 chain.reject(err);
21801 }
21802 }
21803
21804 function resolve(msg) {
21805 var _then, self = this;
21806
21807 // already triggered?
21808 if (self.triggered) { return; }
21809
21810 self.triggered = true;
21811
21812 // unwrap
21813 if (self.def) {
21814 self = self.def;
21815 }
21816
21817 try {
21818 // eslint-disable-next-line no-cond-assign
21819 if (_then = isThenable(msg)) {
21820 schedule(function(){
21821 var defWrapper = new MakeDefWrapper(self);
21822 try {
21823 _then.call(msg,
21824 function $resolve$(){ resolve.apply(defWrapper,arguments); },
21825 function $reject$(){ reject.apply(defWrapper,arguments); }
21826 );
21827 }
21828 catch (err) {
21829 reject.call(defWrapper,err);
21830 }
21831 });
21832 }
21833 else {
21834 self.msg = msg;
21835 self.state = 1;
21836 if (self.chain.length > 0) {
21837 schedule(notify,self);
21838 }
21839 }
21840 }
21841 catch (err) {
21842 reject.call(new MakeDefWrapper(self),err);
21843 }
21844 }
21845
21846 function reject(msg) {
21847 var self = this;
21848
21849 // already triggered?
21850 if (self.triggered) { return; }
21851
21852 self.triggered = true;
21853
21854 // unwrap
21855 if (self.def) {
21856 self = self.def;
21857 }
21858
21859 self.msg = msg;
21860 self.state = 2;
21861 if (self.chain.length > 0) {
21862 schedule(notify,self);
21863 }
21864 }
21865
21866 function iteratePromises(Constructor,arr,resolver,rejecter) {
21867 for (var idx=0; idx<arr.length; idx++) {
21868 (function IIFE(idx){
21869 Constructor.resolve(arr[idx])
21870 .then(
21871 function $resolver$(msg){
21872 resolver(idx,msg);
21873 },
21874 rejecter
21875 );
21876 })(idx);
21877 }
21878 }
21879
21880 function MakeDefWrapper(self) {
21881 this.def = self;
21882 this.triggered = false;
21883 }
21884
21885 function MakeDef(self) {
21886 this.promise = self;
21887 this.state = 0;
21888 this.triggered = false;
21889 this.chain = [];
21890 this.msg = void 0;
21891 }
21892
21893 function NpoPromise(executor) {
21894 if (typeof executor !== 'function') {
21895 throw TypeError('Not a function');
21896 }
21897
21898 if (this['__NPO__'] !== 0) {
21899 throw TypeError('Not a promise');
21900 }
21901
21902 // instance shadowing the inherited "brand"
21903 // to signal an already "initialized" promise
21904 this['__NPO__'] = 1;
21905
21906 var def = new MakeDef(this);
21907
21908 this['then'] = function then(success,failure) {
21909 var o = {
21910 success: typeof success === 'function' ? success : true,
21911 failure: typeof failure === 'function' ? failure : false
21912 };
21913 // Note: `then(..)` itself can be borrowed to be used against
21914 // a different promise constructor for making the chained promise,
21915 // by substituting a different `this` binding.
21916 o.promise = new this.constructor(function extractChain(resolve,reject) {
21917 if (typeof resolve !== 'function' || typeof reject !== 'function') {
21918 throw TypeError('Not a function');
21919 }
21920
21921 o.resolve = resolve;
21922 o.reject = reject;
21923 });
21924 def.chain.push(o);
21925
21926 if (def.state !== 0) {
21927 schedule(notify,def);
21928 }
21929
21930 return o.promise;
21931 };
21932 this['catch'] = function $catch$(failure) {
21933 return this.then(void 0,failure);
21934 };
21935
21936 try {
21937 executor.call(
21938 void 0,
21939 function publicResolve(msg){
21940 resolve.call(def,msg);
21941 },
21942 function publicReject(msg) {
21943 reject.call(def,msg);
21944 }
21945 );
21946 }
21947 catch (err) {
21948 reject.call(def,err);
21949 }
21950 }
21951
21952 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
21953 /*configurable=*/false
21954 );
21955
21956 // Note: Android 4 cannot use `Object.defineProperty(..)` here
21957 NpoPromise.prototype = PromisePrototype;
21958
21959 // built-in "brand" to signal an "uninitialized" promise
21960 builtInProp(PromisePrototype,'__NPO__',0,
21961 /*configurable=*/false
21962 );
21963
21964 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
21965 var Constructor = this;
21966
21967 // spec mandated checks
21968 // note: best "isPromise" check that's practical for now
21969 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
21970 return msg;
21971 }
21972
21973 return new Constructor(function executor(resolve,reject){
21974 if (typeof resolve !== 'function' || typeof reject !== 'function') {
21975 throw TypeError('Not a function');
21976 }
21977
21978 resolve(msg);
21979 });
21980 });
21981
21982 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
21983 return new this(function executor(resolve,reject){
21984 if (typeof resolve !== 'function' || typeof reject !== 'function') {
21985 throw TypeError('Not a function');
21986 }
21987
21988 reject(msg);
21989 });
21990 });
21991
21992 builtInProp(NpoPromise,'all',function Promise$all(arr) {
21993 var Constructor = this;
21994
21995 // spec mandated checks
21996 if (ToString.call(arr) !== '[object Array]') {
21997 return Constructor.reject(TypeError('Not an array'));
21998 }
21999 if (arr.length === 0) {
22000 return Constructor.resolve([]);
22001 }
22002
22003 return new Constructor(function executor(resolve,reject){
22004 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22005 throw TypeError('Not a function');
22006 }
22007
22008 var len = arr.length, msgs = Array(len), count = 0;
22009
22010 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22011 msgs[idx] = msg;
22012 if (++count === len) {
22013 resolve(msgs);
22014 }
22015 },reject);
22016 });
22017 });
22018
22019 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22020 var Constructor = this;
22021
22022 // spec mandated checks
22023 if (ToString.call(arr) !== '[object Array]') {
22024 return Constructor.reject(TypeError('Not an array'));
22025 }
22026
22027 return new Constructor(function executor(resolve,reject){
22028 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22029 throw TypeError('Not a function');
22030 }
22031
22032 iteratePromises(Constructor,arr,function resolver(idx,msg){
22033 resolve(msg);
22034 },reject);
22035 });
22036 });
22037
22038 var PromisePolyfill;
22039 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22040 PromisePolyfill = Promise;
22041 } else {
22042 PromisePolyfill = NpoPromise;
22043 }
22044
22045 var Config = {
22046 DEBUG: false,
22047 LIB_VERSION: '2.65.0'
22048 };
22049
22050 /* eslint camelcase: "off", eqeqeq: "off" */
22051
22052 // Maximum allowed session recording length
22053 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22054 // Maximum allowed value for minimum session recording length
22055 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22056
22057 /*
22058 * Saved references to long variable names, so that closure compiler can
22059 * minimize file size.
22060 */
22061
22062 var ArrayProto = Array.prototype,
22063 FuncProto = Function.prototype,
22064 ObjProto = Object.prototype,
22065 slice = ArrayProto.slice,
22066 toString = ObjProto.toString,
22067 hasOwnProperty = ObjProto.hasOwnProperty,
22068 windowConsole = win.console,
22069 navigator = win.navigator,
22070 document$1 = win.document,
22071 windowOpera = win.opera,
22072 screen = win.screen,
22073 userAgent = navigator.userAgent;
22074
22075 var nativeBind = FuncProto.bind,
22076 nativeForEach = ArrayProto.forEach,
22077 nativeIndexOf = ArrayProto.indexOf,
22078 nativeMap = ArrayProto.map,
22079 nativeIsArray = Array.isArray,
22080 breaker = {};
22081
22082 var _ = {
22083 trim: function(str) {
22084 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22085 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22086 }
22087 };
22088
22089 // Console override
22090 var console$1 = {
22091 /** @type {function(...*)} */
22092 log: function() {
22093 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22094 try {
22095 windowConsole.log.apply(windowConsole, arguments);
22096 } catch (err) {
22097 _.each(arguments, function(arg) {
22098 windowConsole.log(arg);
22099 });
22100 }
22101 }
22102 },
22103 /** @type {function(...*)} */
22104 warn: function() {
22105 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22106 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22107 try {
22108 windowConsole.warn.apply(windowConsole, args);
22109 } catch (err) {
22110 _.each(args, function(arg) {
22111 windowConsole.warn(arg);
22112 });
22113 }
22114 }
22115 },
22116 /** @type {function(...*)} */
22117 error: function() {
22118 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22119 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22120 try {
22121 windowConsole.error.apply(windowConsole, args);
22122 } catch (err) {
22123 _.each(args, function(arg) {
22124 windowConsole.error(arg);
22125 });
22126 }
22127 }
22128 },
22129 /** @type {function(...*)} */
22130 critical: function() {
22131 if (!_.isUndefined(windowConsole) && windowConsole) {
22132 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22133 try {
22134 windowConsole.error.apply(windowConsole, args);
22135 } catch (err) {
22136 _.each(args, function(arg) {
22137 windowConsole.error(arg);
22138 });
22139 }
22140 }
22141 }
22142 };
22143
22144 var log_func_with_prefix = function(func, prefix) {
22145 return function() {
22146 arguments[0] = '[' + prefix + '] ' + arguments[0];
22147 return func.apply(console$1, arguments);
22148 };
22149 };
22150 var console_with_prefix = function(prefix) {
22151 return {
22152 log: log_func_with_prefix(console$1.log, prefix),
22153 error: log_func_with_prefix(console$1.error, prefix),
22154 critical: log_func_with_prefix(console$1.critical, prefix)
22155 };
22156 };
22157
22158
22159 var safewrap = function(f) {
22160 return function() {
22161 try {
22162 return f.apply(this, arguments);
22163 } catch (e) {
22164 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
22165 if (Config.DEBUG){
22166 console$1.critical(e);
22167 }
22168 }
22169 };
22170 };
22171
22172 var safewrapClass = function(klass) {
22173 var proto = klass.prototype;
22174 for (var func in proto) {
22175 if (typeof(proto[func]) === 'function') {
22176 proto[func] = safewrap(proto[func]);
22177 }
22178 }
22179 };
22180
22181
22182 // UNDERSCORE
22183 // Embed part of the Underscore Library
22184 _.bind = function(func, context) {
22185 var args, bound;
22186 if (nativeBind && func.bind === nativeBind) {
22187 return nativeBind.apply(func, slice.call(arguments, 1));
22188 }
22189 if (!_.isFunction(func)) {
22190 throw new TypeError();
22191 }
22192 args = slice.call(arguments, 2);
22193 bound = function() {
22194 if (!(this instanceof bound)) {
22195 return func.apply(context, args.concat(slice.call(arguments)));
22196 }
22197 var ctor = {};
22198 ctor.prototype = func.prototype;
22199 var self = new ctor();
22200 ctor.prototype = null;
22201 var result = func.apply(self, args.concat(slice.call(arguments)));
22202 if (Object(result) === result) {
22203 return result;
22204 }
22205 return self;
22206 };
22207 return bound;
22208 };
22209
22210 /**
22211 * @param {*=} obj
22212 * @param {function(...*)=} iterator
22213 * @param {Object=} context
22214 */
22215 _.each = function(obj, iterator, context) {
22216 if (obj === null || obj === undefined) {
22217 return;
22218 }
22219 if (nativeForEach && obj.forEach === nativeForEach) {
22220 obj.forEach(iterator, context);
22221 } else if (obj.length === +obj.length) {
22222 for (var i = 0, l = obj.length; i < l; i++) {
22223 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
22224 return;
22225 }
22226 }
22227 } else {
22228 for (var key in obj) {
22229 if (hasOwnProperty.call(obj, key)) {
22230 if (iterator.call(context, obj[key], key, obj) === breaker) {
22231 return;
22232 }
22233 }
22234 }
22235 }
22236 };
22237
22238 _.extend = function(obj) {
22239 _.each(slice.call(arguments, 1), function(source) {
22240 for (var prop in source) {
22241 if (source[prop] !== void 0) {
22242 obj[prop] = source[prop];
22243 }
22244 }
22245 });
22246 return obj;
22247 };
22248
22249 _.isArray = nativeIsArray || function(obj) {
22250 return toString.call(obj) === '[object Array]';
22251 };
22252
22253 // from a comment on http://dbj.org/dbj/?p=286
22254 // fails on only one very rare and deliberate custom object:
22255 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
22256 _.isFunction = function(f) {
22257 try {
22258 return /^\s*\bfunction\b/.test(f);
22259 } catch (x) {
22260 return false;
22261 }
22262 };
22263
22264 _.isArguments = function(obj) {
22265 return !!(obj && hasOwnProperty.call(obj, 'callee'));
22266 };
22267
22268 _.toArray = function(iterable) {
22269 if (!iterable) {
22270 return [];
22271 }
22272 if (iterable.toArray) {
22273 return iterable.toArray();
22274 }
22275 if (_.isArray(iterable)) {
22276 return slice.call(iterable);
22277 }
22278 if (_.isArguments(iterable)) {
22279 return slice.call(iterable);
22280 }
22281 return _.values(iterable);
22282 };
22283
22284 _.map = function(arr, callback, context) {
22285 if (nativeMap && arr.map === nativeMap) {
22286 return arr.map(callback, context);
22287 } else {
22288 var results = [];
22289 _.each(arr, function(item) {
22290 results.push(callback.call(context, item));
22291 });
22292 return results;
22293 }
22294 };
22295
22296 _.keys = function(obj) {
22297 var results = [];
22298 if (obj === null) {
22299 return results;
22300 }
22301 _.each(obj, function(value, key) {
22302 results[results.length] = key;
22303 });
22304 return results;
22305 };
22306
22307 _.values = function(obj) {
22308 var results = [];
22309 if (obj === null) {
22310 return results;
22311 }
22312 _.each(obj, function(value) {
22313 results[results.length] = value;
22314 });
22315 return results;
22316 };
22317
22318 _.include = function(obj, target) {
22319 var found = false;
22320 if (obj === null) {
22321 return found;
22322 }
22323 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
22324 return obj.indexOf(target) != -1;
22325 }
22326 _.each(obj, function(value) {
22327 if (found || (found = (value === target))) {
22328 return breaker;
22329 }
22330 });
22331 return found;
22332 };
22333
22334 _.includes = function(str, needle) {
22335 return str.indexOf(needle) !== -1;
22336 };
22337
22338 // Underscore Addons
22339 _.inherit = function(subclass, superclass) {
22340 subclass.prototype = new superclass();
22341 subclass.prototype.constructor = subclass;
22342 subclass.superclass = superclass.prototype;
22343 return subclass;
22344 };
22345
22346 _.isObject = function(obj) {
22347 return (obj === Object(obj) && !_.isArray(obj));
22348 };
22349
22350 _.isEmptyObject = function(obj) {
22351 if (_.isObject(obj)) {
22352 for (var key in obj) {
22353 if (hasOwnProperty.call(obj, key)) {
22354 return false;
22355 }
22356 }
22357 return true;
22358 }
22359 return false;
22360 };
22361
22362 _.isUndefined = function(obj) {
22363 return obj === void 0;
22364 };
22365
22366 _.isString = function(obj) {
22367 return toString.call(obj) == '[object String]';
22368 };
22369
22370 _.isDate = function(obj) {
22371 return toString.call(obj) == '[object Date]';
22372 };
22373
22374 _.isNumber = function(obj) {
22375 return toString.call(obj) == '[object Number]';
22376 };
22377
22378 _.isElement = function(obj) {
22379 return !!(obj && obj.nodeType === 1);
22380 };
22381
22382 _.encodeDates = function(obj) {
22383 _.each(obj, function(v, k) {
22384 if (_.isDate(v)) {
22385 obj[k] = _.formatDate(v);
22386 } else if (_.isObject(v)) {
22387 obj[k] = _.encodeDates(v); // recurse
22388 }
22389 });
22390 return obj;
22391 };
22392
22393 _.timestamp = function() {
22394 Date.now = Date.now || function() {
22395 return +new Date;
22396 };
22397 return Date.now();
22398 };
22399
22400 _.formatDate = function(d) {
22401 // YYYY-MM-DDTHH:MM:SS in UTC
22402 function pad(n) {
22403 return n < 10 ? '0' + n : n;
22404 }
22405 return d.getUTCFullYear() + '-' +
22406 pad(d.getUTCMonth() + 1) + '-' +
22407 pad(d.getUTCDate()) + 'T' +
22408 pad(d.getUTCHours()) + ':' +
22409 pad(d.getUTCMinutes()) + ':' +
22410 pad(d.getUTCSeconds());
22411 };
22412
22413 _.strip_empty_properties = function(p) {
22414 var ret = {};
22415 _.each(p, function(v, k) {
22416 if (_.isString(v) && v.length > 0) {
22417 ret[k] = v;
22418 }
22419 });
22420 return ret;
22421 };
22422
22423 /*
22424 * this function returns a copy of object after truncating it. If
22425 * passed an Array or Object it will iterate through obj and
22426 * truncate all the values recursively.
22427 */
22428 _.truncate = function(obj, length) {
22429 var ret;
22430
22431 if (typeof(obj) === 'string') {
22432 ret = obj.slice(0, length);
22433 } else if (_.isArray(obj)) {
22434 ret = [];
22435 _.each(obj, function(val) {
22436 ret.push(_.truncate(val, length));
22437 });
22438 } else if (_.isObject(obj)) {
22439 ret = {};
22440 _.each(obj, function(val, key) {
22441 ret[key] = _.truncate(val, length);
22442 });
22443 } else {
22444 ret = obj;
22445 }
22446
22447 return ret;
22448 };
22449
22450 _.JSONEncode = (function() {
22451 return function(mixed_val) {
22452 var value = mixed_val;
22453 var quote = function(string) {
22454 var escapable = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; // eslint-disable-line no-control-regex
22455 var meta = { // table of character substitutions
22456 '\b': '\\b',
22457 '\t': '\\t',
22458 '\n': '\\n',
22459 '\f': '\\f',
22460 '\r': '\\r',
22461 '"': '\\"',
22462 '\\': '\\\\'
22463 };
22464
22465 escapable.lastIndex = 0;
22466 return escapable.test(string) ?
22467 '"' + string.replace(escapable, function(a) {
22468 var c = meta[a];
22469 return typeof c === 'string' ? c :
22470 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
22471 }) + '"' :
22472 '"' + string + '"';
22473 };
22474
22475 var str = function(key, holder) {
22476 var gap = '';
22477 var indent = ' ';
22478 var i = 0; // The loop counter.
22479 var k = ''; // The member key.
22480 var v = ''; // The member value.
22481 var length = 0;
22482 var mind = gap;
22483 var partial = [];
22484 var value = holder[key];
22485
22486 // If the value has a toJSON method, call it to obtain a replacement value.
22487 if (value && typeof value === 'object' &&
22488 typeof value.toJSON === 'function') {
22489 value = value.toJSON(key);
22490 }
22491
22492 // What happens next depends on the value's type.
22493 switch (typeof value) {
22494 case 'string':
22495 return quote(value);
22496
22497 case 'number':
22498 // JSON numbers must be finite. Encode non-finite numbers as null.
22499 return isFinite(value) ? String(value) : 'null';
22500
22501 case 'boolean':
22502 case 'null':
22503 // If the value is a boolean or null, convert it to a string. Note:
22504 // typeof null does not produce 'null'. The case is included here in
22505 // the remote chance that this gets fixed someday.
22506
22507 return String(value);
22508
22509 case 'object':
22510 // If the type is 'object', we might be dealing with an object or an array or
22511 // null.
22512 // Due to a specification blunder in ECMAScript, typeof null is 'object',
22513 // so watch out for that case.
22514 if (!value) {
22515 return 'null';
22516 }
22517
22518 // Make an array to hold the partial results of stringifying this object value.
22519 gap += indent;
22520 partial = [];
22521
22522 // Is the value an array?
22523 if (toString.apply(value) === '[object Array]') {
22524 // The value is an array. Stringify every element. Use null as a placeholder
22525 // for non-JSON values.
22526
22527 length = value.length;
22528 for (i = 0; i < length; i += 1) {
22529 partial[i] = str(i, value) || 'null';
22530 }
22531
22532 // Join all of the elements together, separated with commas, and wrap them in
22533 // brackets.
22534 v = partial.length === 0 ? '[]' :
22535 gap ? '[\n' + gap +
22536 partial.join(',\n' + gap) + '\n' +
22537 mind + ']' :
22538 '[' + partial.join(',') + ']';
22539 gap = mind;
22540 return v;
22541 }
22542
22543 // Iterate through all of the keys in the object.
22544 for (k in value) {
22545 if (hasOwnProperty.call(value, k)) {
22546 v = str(k, value);
22547 if (v) {
22548 partial.push(quote(k) + (gap ? ': ' : ':') + v);
22549 }
22550 }
22551 }
22552
22553 // Join all of the member texts together, separated with commas,
22554 // and wrap them in braces.
22555 v = partial.length === 0 ? '{}' :
22556 gap ? '{' + partial.join(',') + '' +
22557 mind + '}' : '{' + partial.join(',') + '}';
22558 gap = mind;
22559 return v;
22560 }
22561 };
22562
22563 // Make a fake root object containing our value under the key of ''.
22564 // Return the result of stringifying the value.
22565 return str('', {
22566 '': value
22567 });
22568 };
22569 })();
22570
22571 /**
22572 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
22573 * Slightly modified to throw a real Error rather than a POJO
22574 */
22575 _.JSONDecode = (function() {
22576 var at, // The index of the current character
22577 ch, // The current character
22578 escapee = {
22579 '"': '"',
22580 '\\': '\\',
22581 '/': '/',
22582 'b': '\b',
22583 'f': '\f',
22584 'n': '\n',
22585 'r': '\r',
22586 't': '\t'
22587 },
22588 text,
22589 error = function(m) {
22590 var e = new SyntaxError(m);
22591 e.at = at;
22592 e.text = text;
22593 throw e;
22594 },
22595 next = function(c) {
22596 // If a c parameter is provided, verify that it matches the current character.
22597 if (c && c !== ch) {
22598 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
22599 }
22600 // Get the next character. When there are no more characters,
22601 // return the empty string.
22602 ch = text.charAt(at);
22603 at += 1;
22604 return ch;
22605 },
22606 number = function() {
22607 // Parse a number value.
22608 var number,
22609 string = '';
22610
22611 if (ch === '-') {
22612 string = '-';
22613 next('-');
22614 }
22615 while (ch >= '0' && ch <= '9') {
22616 string += ch;
22617 next();
22618 }
22619 if (ch === '.') {
22620 string += '.';
22621 while (next() && ch >= '0' && ch <= '9') {
22622 string += ch;
22623 }
22624 }
22625 if (ch === 'e' || ch === 'E') {
22626 string += ch;
22627 next();
22628 if (ch === '-' || ch === '+') {
22629 string += ch;
22630 next();
22631 }
22632 while (ch >= '0' && ch <= '9') {
22633 string += ch;
22634 next();
22635 }
22636 }
22637 number = +string;
22638 if (!isFinite(number)) {
22639 error('Bad number');
22640 } else {
22641 return number;
22642 }
22643 },
22644
22645 string = function() {
22646 // Parse a string value.
22647 var hex,
22648 i,
22649 string = '',
22650 uffff;
22651 // When parsing for string values, we must look for " and \ characters.
22652 if (ch === '"') {
22653 while (next()) {
22654 if (ch === '"') {
22655 next();
22656 return string;
22657 }
22658 if (ch === '\\') {
22659 next();
22660 if (ch === 'u') {
22661 uffff = 0;
22662 for (i = 0; i < 4; i += 1) {
22663 hex = parseInt(next(), 16);
22664 if (!isFinite(hex)) {
22665 break;
22666 }
22667 uffff = uffff * 16 + hex;
22668 }
22669 string += String.fromCharCode(uffff);
22670 } else if (typeof escapee[ch] === 'string') {
22671 string += escapee[ch];
22672 } else {
22673 break;
22674 }
22675 } else {
22676 string += ch;
22677 }
22678 }
22679 }
22680 error('Bad string');
22681 },
22682 white = function() {
22683 // Skip whitespace.
22684 while (ch && ch <= ' ') {
22685 next();
22686 }
22687 },
22688 word = function() {
22689 // true, false, or null.
22690 switch (ch) {
22691 case 't':
22692 next('t');
22693 next('r');
22694 next('u');
22695 next('e');
22696 return true;
22697 case 'f':
22698 next('f');
22699 next('a');
22700 next('l');
22701 next('s');
22702 next('e');
22703 return false;
22704 case 'n':
22705 next('n');
22706 next('u');
22707 next('l');
22708 next('l');
22709 return null;
22710 }
22711 error('Unexpected "' + ch + '"');
22712 },
22713 value, // Placeholder for the value function.
22714 array = function() {
22715 // Parse an array value.
22716 var array = [];
22717
22718 if (ch === '[') {
22719 next('[');
22720 white();
22721 if (ch === ']') {
22722 next(']');
22723 return array; // empty array
22724 }
22725 while (ch) {
22726 array.push(value());
22727 white();
22728 if (ch === ']') {
22729 next(']');
22730 return array;
22731 }
22732 next(',');
22733 white();
22734 }
22735 }
22736 error('Bad array');
22737 },
22738 object = function() {
22739 // Parse an object value.
22740 var key,
22741 object = {};
22742
22743 if (ch === '{') {
22744 next('{');
22745 white();
22746 if (ch === '}') {
22747 next('}');
22748 return object; // empty object
22749 }
22750 while (ch) {
22751 key = string();
22752 white();
22753 next(':');
22754 if (Object.hasOwnProperty.call(object, key)) {
22755 error('Duplicate key "' + key + '"');
22756 }
22757 object[key] = value();
22758 white();
22759 if (ch === '}') {
22760 next('}');
22761 return object;
22762 }
22763 next(',');
22764 white();
22765 }
22766 }
22767 error('Bad object');
22768 };
22769
22770 value = function() {
22771 // Parse a JSON value. It could be an object, an array, a string,
22772 // a number, or a word.
22773 white();
22774 switch (ch) {
22775 case '{':
22776 return object();
22777 case '[':
22778 return array();
22779 case '"':
22780 return string();
22781 case '-':
22782 return number();
22783 default:
22784 return ch >= '0' && ch <= '9' ? number() : word();
22785 }
22786 };
22787
22788 // Return the json_parse function. It will have access to all of the
22789 // above functions and variables.
22790 return function(source) {
22791 var result;
22792
22793 text = source;
22794 at = 0;
22795 ch = ' ';
22796 result = value();
22797 white();
22798 if (ch) {
22799 error('Syntax error');
22800 }
22801
22802 return result;
22803 };
22804 })();
22805
22806 _.base64Encode = function(data) {
22807 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
22808 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
22809 ac = 0,
22810 enc = '',
22811 tmp_arr = [];
22812
22813 if (!data) {
22814 return data;
22815 }
22816
22817 data = _.utf8Encode(data);
22818
22819 do { // pack three octets into four hexets
22820 o1 = data.charCodeAt(i++);
22821 o2 = data.charCodeAt(i++);
22822 o3 = data.charCodeAt(i++);
22823
22824 bits = o1 << 16 | o2 << 8 | o3;
22825
22826 h1 = bits >> 18 & 0x3f;
22827 h2 = bits >> 12 & 0x3f;
22828 h3 = bits >> 6 & 0x3f;
22829 h4 = bits & 0x3f;
22830
22831 // use hexets to index into b64, and append result to encoded string
22832 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
22833 } while (i < data.length);
22834
22835 enc = tmp_arr.join('');
22836
22837 switch (data.length % 3) {
22838 case 1:
22839 enc = enc.slice(0, -2) + '==';
22840 break;
22841 case 2:
22842 enc = enc.slice(0, -1) + '=';
22843 break;
22844 }
22845
22846 return enc;
22847 };
22848
22849 _.utf8Encode = function(string) {
22850 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
22851
22852 var utftext = '',
22853 start,
22854 end;
22855 var stringl = 0,
22856 n;
22857
22858 start = end = 0;
22859 stringl = string.length;
22860
22861 for (n = 0; n < stringl; n++) {
22862 var c1 = string.charCodeAt(n);
22863 var enc = null;
22864
22865 if (c1 < 128) {
22866 end++;
22867 } else if ((c1 > 127) && (c1 < 2048)) {
22868 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
22869 } else {
22870 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
22871 }
22872 if (enc !== null) {
22873 if (end > start) {
22874 utftext += string.substring(start, end);
22875 }
22876 utftext += enc;
22877 start = end = n + 1;
22878 }
22879 }
22880
22881 if (end > start) {
22882 utftext += string.substring(start, string.length);
22883 }
22884
22885 return utftext;
22886 };
22887
22888 _.UUID = function() {
22889 try {
22890 // use native Crypto API when available
22891 return win['crypto']['randomUUID']();
22892 } catch (err) {
22893 // fall back to generating our own UUID
22894 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
22895 var uuid = new Array(36);
22896 for (var i = 0; i < 36; i++) {
22897 uuid[i] = Math.floor(Math.random() * 16);
22898 }
22899 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
22900 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
22901 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
22902 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
22903
22904 return _.map(uuid, function(x) {
22905 return x.toString(16);
22906 }).join('');
22907 }
22908 };
22909
22910 // _.isBlockedUA()
22911 // This is to block various web spiders from executing our JS and
22912 // sending false tracking data
22913 var BLOCKED_UA_STRS = [
22914 'ahrefsbot',
22915 'ahrefssiteaudit',
22916 'amazonbot',
22917 'baiduspider',
22918 'bingbot',
22919 'bingpreview',
22920 'chrome-lighthouse',
22921 'facebookexternal',
22922 'petalbot',
22923 'pinterest',
22924 'screaming frog',
22925 'yahoo! slurp',
22926 'yandex',
22927
22928 // a whole bunch of goog-specific crawlers
22929 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
22930 'adsbot-google',
22931 'apis-google',
22932 'duplexweb-google',
22933 'feedfetcher-google',
22934 'google favicon',
22935 'google web preview',
22936 'google-read-aloud',
22937 'googlebot',
22938 'googleweblight',
22939 'mediapartners-google',
22940 'storebot-google'
22941 ];
22942 _.isBlockedUA = function(ua) {
22943 var i;
22944 ua = ua.toLowerCase();
22945 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
22946 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
22947 return true;
22948 }
22949 }
22950 return false;
22951 };
22952
22953 /**
22954 * @param {Object=} formdata
22955 * @param {string=} arg_separator
22956 */
22957 _.HTTPBuildQuery = function(formdata, arg_separator) {
22958 var use_val, use_key, tmp_arr = [];
22959
22960 if (_.isUndefined(arg_separator)) {
22961 arg_separator = '&';
22962 }
22963
22964 _.each(formdata, function(val, key) {
22965 use_val = encodeURIComponent(val.toString());
22966 use_key = encodeURIComponent(key);
22967 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
22968 });
22969
22970 return tmp_arr.join(arg_separator);
22971 };
22972
22973 _.getQueryParam = function(url, param) {
22974 // Expects a raw URL
22975
22976 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
22977 var regexS = '[\\?&]' + param + '=([^&#]*)',
22978 regex = new RegExp(regexS),
22979 results = regex.exec(url);
22980 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
22981 return '';
22982 } else {
22983 var result = results[1];
22984 try {
22985 result = decodeURIComponent(result);
22986 } catch(err) {
22987 console$1.error('Skipping decoding for malformed query param: ' + result);
22988 }
22989 return result.replace(/\+/g, ' ');
22990 }
22991 };
22992
22993
22994 // _.cookie
22995 // Methods partially borrowed from quirksmode.org/js/cookies.html
22996 _.cookie = {
22997 get: function(name) {
22998 var nameEQ = name + '=';
22999 var ca = document$1.cookie.split(';');
23000 for (var i = 0; i < ca.length; i++) {
23001 var c = ca[i];
23002 while (c.charAt(0) == ' ') {
23003 c = c.substring(1, c.length);
23004 }
23005 if (c.indexOf(nameEQ) === 0) {
23006 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23007 }
23008 }
23009 return null;
23010 },
23011
23012 parse: function(name) {
23013 var cookie;
23014 try {
23015 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23016 } catch (err) {
23017 // noop
23018 }
23019 return cookie;
23020 },
23021
23022 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23023 var cdomain = '',
23024 expires = '',
23025 secure = '';
23026
23027 if (domain_override) {
23028 cdomain = '; domain=' + domain_override;
23029 } else if (is_cross_subdomain) {
23030 var domain = extract_domain(document$1.location.hostname);
23031 cdomain = domain ? '; domain=.' + domain : '';
23032 }
23033
23034 if (seconds) {
23035 var date = new Date();
23036 date.setTime(date.getTime() + (seconds * 1000));
23037 expires = '; expires=' + date.toGMTString();
23038 }
23039
23040 if (is_cross_site) {
23041 is_secure = true;
23042 secure = '; SameSite=None';
23043 }
23044 if (is_secure) {
23045 secure += '; secure';
23046 }
23047
23048 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23049 },
23050
23051 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23052 var cdomain = '', expires = '', secure = '';
23053
23054 if (domain_override) {
23055 cdomain = '; domain=' + domain_override;
23056 } else if (is_cross_subdomain) {
23057 var domain = extract_domain(document$1.location.hostname);
23058 cdomain = domain ? '; domain=.' + domain : '';
23059 }
23060
23061 if (days) {
23062 var date = new Date();
23063 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23064 expires = '; expires=' + date.toGMTString();
23065 }
23066
23067 if (is_cross_site) {
23068 is_secure = true;
23069 secure = '; SameSite=None';
23070 }
23071 if (is_secure) {
23072 secure += '; secure';
23073 }
23074
23075 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23076 document$1.cookie = new_cookie_val;
23077 return new_cookie_val;
23078 },
23079
23080 remove: function(name, is_cross_subdomain, domain_override) {
23081 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23082 }
23083 };
23084
23085 var _testStorageSupported = function (storage) {
23086 var supported = true;
23087 try {
23088 var key = '__mplss_' + cheap_guid(8),
23089 val = 'xyz';
23090 storage.setItem(key, val);
23091 if (storage.getItem(key) !== val) {
23092 supported = false;
23093 }
23094 storage.removeItem(key);
23095 } catch (err) {
23096 supported = false;
23097 }
23098 return supported;
23099 };
23100
23101 var _localStorageSupported = null;
23102 var localStorageSupported = function(storage, forceCheck) {
23103 if (_localStorageSupported !== null && !forceCheck) {
23104 return _localStorageSupported;
23105 }
23106 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23107 };
23108
23109 var _sessionStorageSupported = null;
23110 var sessionStorageSupported = function(storage, forceCheck) {
23111 if (_sessionStorageSupported !== null && !forceCheck) {
23112 return _sessionStorageSupported;
23113 }
23114 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23115 };
23116
23117 function _storageWrapper(storage, name, is_supported_fn) {
23118 var log_error = function(msg) {
23119 console$1.error(name + ' error: ' + msg);
23120 };
23121
23122 return {
23123 is_supported: function(forceCheck) {
23124 var supported = is_supported_fn(storage, forceCheck);
23125 if (!supported) {
23126 console$1.error(name + ' unsupported');
23127 }
23128 return supported;
23129 },
23130 error: log_error,
23131 get: function(key) {
23132 try {
23133 return storage.getItem(key);
23134 } catch (err) {
23135 log_error(err);
23136 }
23137 return null;
23138 },
23139 parse: function(key) {
23140 try {
23141 return _.JSONDecode(storage.getItem(key)) || {};
23142 } catch (err) {
23143 // noop
23144 }
23145 return null;
23146 },
23147 set: function(key, value) {
23148 try {
23149 storage.setItem(key, value);
23150 } catch (err) {
23151 log_error(err);
23152 }
23153 },
23154 remove: function(key) {
23155 try {
23156 storage.removeItem(key);
23157 } catch (err) {
23158 log_error(err);
23159 }
23160 }
23161 };
23162 }
23163
23164 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
23165 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
23166
23167 _.register_event = (function() {
23168 // written by Dean Edwards, 2005
23169 // with input from Tino Zijdel - crisp@xs4all.nl
23170 // with input from Carl Sverre - mail@carlsverre.com
23171 // with input from Mixpanel
23172 // http://dean.edwards.name/weblog/2005/10/add-event/
23173 // https://gist.github.com/1930440
23174
23175 /**
23176 * @param {Object} element
23177 * @param {string} type
23178 * @param {function(...*)} handler
23179 * @param {boolean=} oldSchool
23180 * @param {boolean=} useCapture
23181 */
23182 var register_event = function(element, type, handler, oldSchool, useCapture) {
23183 if (!element) {
23184 console$1.error('No valid element provided to register_event');
23185 return;
23186 }
23187
23188 if (element.addEventListener && !oldSchool) {
23189 element.addEventListener(type, handler, !!useCapture);
23190 } else {
23191 var ontype = 'on' + type;
23192 var old_handler = element[ontype]; // can be undefined
23193 element[ontype] = makeHandler(element, handler, old_handler);
23194 }
23195 };
23196
23197 function makeHandler(element, new_handler, old_handlers) {
23198 var handler = function(event) {
23199 event = event || fixEvent(win.event);
23200
23201 // this basically happens in firefox whenever another script
23202 // overwrites the onload callback and doesn't pass the event
23203 // object to previously defined callbacks. All the browsers
23204 // that don't define window.event implement addEventListener
23205 // so the dom_loaded handler will still be fired as usual.
23206 if (!event) {
23207 return undefined;
23208 }
23209
23210 var ret = true;
23211 var old_result, new_result;
23212
23213 if (_.isFunction(old_handlers)) {
23214 old_result = old_handlers(event);
23215 }
23216 new_result = new_handler.call(element, event);
23217
23218 if ((false === old_result) || (false === new_result)) {
23219 ret = false;
23220 }
23221
23222 return ret;
23223 };
23224
23225 return handler;
23226 }
23227
23228 function fixEvent(event) {
23229 if (event) {
23230 event.preventDefault = fixEvent.preventDefault;
23231 event.stopPropagation = fixEvent.stopPropagation;
23232 }
23233 return event;
23234 }
23235 fixEvent.preventDefault = function() {
23236 this.returnValue = false;
23237 };
23238 fixEvent.stopPropagation = function() {
23239 this.cancelBubble = true;
23240 };
23241
23242 return register_event;
23243 })();
23244
23245
23246 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
23247
23248 _.dom_query = (function() {
23249 /* document.getElementsBySelector(selector)
23250 - returns an array of element objects from the current document
23251 matching the CSS selector. Selectors can contain element names,
23252 class names and ids and can be nested. For example:
23253
23254 elements = document.getElementsBySelector('div#main p a.external')
23255
23256 Will return an array of all 'a' elements with 'external' in their
23257 class attribute that are contained inside 'p' elements that are
23258 contained inside the 'div' element which has id="main"
23259
23260 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
23261 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
23262
23263 Version 0.4 - Simon Willison, March 25th 2003
23264 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
23265 -- Opera 7 fails
23266
23267 Version 0.5 - Carl Sverre, Jan 7th 2013
23268 -- Now uses jQuery-esque `hasClass` for testing class name
23269 equality. This fixes a bug related to '-' characters being
23270 considered not part of a 'word' in regex.
23271 */
23272
23273 function getAllChildren(e) {
23274 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
23275 return e.all ? e.all : e.getElementsByTagName('*');
23276 }
23277
23278 var bad_whitespace = /[\t\r\n]/g;
23279
23280 function hasClass(elem, selector) {
23281 var className = ' ' + selector + ' ';
23282 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
23283 }
23284
23285 function getElementsBySelector(selector) {
23286 // Attempt to fail gracefully in lesser browsers
23287 if (!document$1.getElementsByTagName) {
23288 return [];
23289 }
23290 // Split selector in to tokens
23291 var tokens = selector.split(' ');
23292 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
23293 var currentContext = [document$1];
23294 for (i = 0; i < tokens.length; i++) {
23295 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
23296 if (token.indexOf('#') > -1) {
23297 // Token is an ID selector
23298 bits = token.split('#');
23299 tagName = bits[0];
23300 var id = bits[1];
23301 var element = document$1.getElementById(id);
23302 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
23303 // element not found or tag with that ID not found, return false
23304 return [];
23305 }
23306 // Set currentContext to contain just this element
23307 currentContext = [element];
23308 continue; // Skip to next token
23309 }
23310 if (token.indexOf('.') > -1) {
23311 // Token contains a class selector
23312 bits = token.split('.');
23313 tagName = bits[0];
23314 var className = bits[1];
23315 if (!tagName) {
23316 tagName = '*';
23317 }
23318 // Get elements matching tag, filter them for class selector
23319 found = [];
23320 foundCount = 0;
23321 for (j = 0; j < currentContext.length; j++) {
23322 if (tagName == '*') {
23323 elements = getAllChildren(currentContext[j]);
23324 } else {
23325 elements = currentContext[j].getElementsByTagName(tagName);
23326 }
23327 for (k = 0; k < elements.length; k++) {
23328 found[foundCount++] = elements[k];
23329 }
23330 }
23331 currentContext = [];
23332 currentContextIndex = 0;
23333 for (j = 0; j < found.length; j++) {
23334 if (found[j].className &&
23335 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
23336 hasClass(found[j], className)
23337 ) {
23338 currentContext[currentContextIndex++] = found[j];
23339 }
23340 }
23341 continue; // Skip to next token
23342 }
23343 // Code to deal with attribute selectors
23344 var token_match = token.match(TOKEN_MATCH_REGEX);
23345 if (token_match) {
23346 tagName = token_match[1];
23347 var attrName = token_match[2];
23348 var attrOperator = token_match[3];
23349 var attrValue = token_match[4];
23350 if (!tagName) {
23351 tagName = '*';
23352 }
23353 // Grab all of the tagName elements within current context
23354 found = [];
23355 foundCount = 0;
23356 for (j = 0; j < currentContext.length; j++) {
23357 if (tagName == '*') {
23358 elements = getAllChildren(currentContext[j]);
23359 } else {
23360 elements = currentContext[j].getElementsByTagName(tagName);
23361 }
23362 for (k = 0; k < elements.length; k++) {
23363 found[foundCount++] = elements[k];
23364 }
23365 }
23366 currentContext = [];
23367 currentContextIndex = 0;
23368 var checkFunction; // This function will be used to filter the elements
23369 switch (attrOperator) {
23370 case '=': // Equality
23371 checkFunction = function(e) {
23372 return (e.getAttribute(attrName) == attrValue);
23373 };
23374 break;
23375 case '~': // Match one of space seperated words
23376 checkFunction = function(e) {
23377 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
23378 };
23379 break;
23380 case '|': // Match start with value followed by optional hyphen
23381 checkFunction = function(e) {
23382 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
23383 };
23384 break;
23385 case '^': // Match starts with value
23386 checkFunction = function(e) {
23387 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
23388 };
23389 break;
23390 case '$': // Match ends with value - fails with "Warning" in Opera 7
23391 checkFunction = function(e) {
23392 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
23393 };
23394 break;
23395 case '*': // Match ends with value
23396 checkFunction = function(e) {
23397 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
23398 };
23399 break;
23400 default:
23401 // Just test for existence of attribute
23402 checkFunction = function(e) {
23403 return e.getAttribute(attrName);
23404 };
23405 }
23406 currentContext = [];
23407 currentContextIndex = 0;
23408 for (j = 0; j < found.length; j++) {
23409 if (checkFunction(found[j])) {
23410 currentContext[currentContextIndex++] = found[j];
23411 }
23412 }
23413 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
23414 continue; // Skip to next token
23415 }
23416 // If we get here, token is JUST an element (not a class or ID selector)
23417 tagName = token;
23418 found = [];
23419 foundCount = 0;
23420 for (j = 0; j < currentContext.length; j++) {
23421 elements = currentContext[j].getElementsByTagName(tagName);
23422 for (k = 0; k < elements.length; k++) {
23423 found[foundCount++] = elements[k];
23424 }
23425 }
23426 currentContext = found;
23427 }
23428 return currentContext;
23429 }
23430
23431 return function(query) {
23432 if (_.isElement(query)) {
23433 return [query];
23434 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
23435 return query;
23436 } else {
23437 return getElementsBySelector.call(this, query);
23438 }
23439 };
23440 })();
23441
23442 var CAMPAIGN_KEYWORDS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'utm_id', 'utm_source_platform','utm_campaign_id', 'utm_creative_format', 'utm_marketing_tactic'];
23443 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
23444
23445 _.info = {
23446 campaignParams: function(default_value) {
23447 var kw = '',
23448 params = {};
23449 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
23450 kw = _.getQueryParam(document$1.URL, kwkey);
23451 if (kw.length) {
23452 params[kwkey] = kw;
23453 } else if (default_value !== undefined) {
23454 params[kwkey] = default_value;
23455 }
23456 });
23457
23458 return params;
23459 },
23460
23461 clickParams: function() {
23462 var id = '',
23463 params = {};
23464 _.each(CLICK_IDS, function(idkey) {
23465 id = _.getQueryParam(document$1.URL, idkey);
23466 if (id.length) {
23467 params[idkey] = id;
23468 }
23469 });
23470
23471 return params;
23472 },
23473
23474 marketingParams: function() {
23475 return _.extend(_.info.campaignParams(), _.info.clickParams());
23476 },
23477
23478 searchEngine: function(referrer) {
23479 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
23480 return 'google';
23481 } else if (referrer.search('https?://(.*)bing.com') === 0) {
23482 return 'bing';
23483 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
23484 return 'yahoo';
23485 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
23486 return 'duckduckgo';
23487 } else {
23488 return null;
23489 }
23490 },
23491
23492 searchInfo: function(referrer) {
23493 var search = _.info.searchEngine(referrer),
23494 param = (search != 'yahoo') ? 'q' : 'p',
23495 ret = {};
23496
23497 if (search !== null) {
23498 ret['$search_engine'] = search;
23499
23500 var keyword = _.getQueryParam(referrer, param);
23501 if (keyword.length) {
23502 ret['mp_keyword'] = keyword;
23503 }
23504 }
23505
23506 return ret;
23507 },
23508
23509 /**
23510 * This function detects which browser is running this script.
23511 * The order of the checks are important since many user agents
23512 * include key words used in later checks.
23513 */
23514 browser: function(user_agent, vendor, opera) {
23515 vendor = vendor || ''; // vendor is undefined for at least IE9
23516 if (opera || _.includes(user_agent, ' OPR/')) {
23517 if (_.includes(user_agent, 'Mini')) {
23518 return 'Opera Mini';
23519 }
23520 return 'Opera';
23521 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23522 return 'BlackBerry';
23523 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
23524 return 'Internet Explorer Mobile';
23525 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
23526 // https://developer.samsung.com/internet/user-agent-string-format
23527 return 'Samsung Internet';
23528 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
23529 return 'Microsoft Edge';
23530 } else if (_.includes(user_agent, 'FBIOS')) {
23531 return 'Facebook Mobile';
23532 } else if (_.includes(user_agent, 'Whale/')) {
23533 // https://user-agents.net/browsers/whale-browser
23534 return 'Whale Browser';
23535 } else if (_.includes(user_agent, 'Chrome')) {
23536 return 'Chrome';
23537 } else if (_.includes(user_agent, 'CriOS')) {
23538 return 'Chrome iOS';
23539 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
23540 return 'UC Browser';
23541 } else if (_.includes(user_agent, 'FxiOS')) {
23542 return 'Firefox iOS';
23543 } else if (_.includes(vendor, 'Apple')) {
23544 if (_.includes(user_agent, 'Mobile')) {
23545 return 'Mobile Safari';
23546 }
23547 return 'Safari';
23548 } else if (_.includes(user_agent, 'Android')) {
23549 return 'Android Mobile';
23550 } else if (_.includes(user_agent, 'Konqueror')) {
23551 return 'Konqueror';
23552 } else if (_.includes(user_agent, 'Firefox')) {
23553 return 'Firefox';
23554 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
23555 return 'Internet Explorer';
23556 } else if (_.includes(user_agent, 'Gecko')) {
23557 return 'Mozilla';
23558 } else {
23559 return '';
23560 }
23561 },
23562
23563 /**
23564 * This function detects which browser version is running this script,
23565 * parsing major and minor version (e.g., 42.1). User agent strings from:
23566 * http://www.useragentstring.com/pages/useragentstring.php
23567 */
23568 browserVersion: function(userAgent, vendor, opera) {
23569 var browser = _.info.browser(userAgent, vendor, opera);
23570 var versionRegexs = {
23571 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
23572 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
23573 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
23574 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
23575 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
23576 'Safari': /Version\/(\d+(\.\d+)?)/,
23577 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
23578 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
23579 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
23580 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
23581 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
23582 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
23583 'Android Mobile': /android\s(\d+(\.\d+)?)/,
23584 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
23585 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
23586 'Mozilla': /rv:(\d+(\.\d+)?)/,
23587 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
23588 };
23589 var regex = versionRegexs[browser];
23590 if (regex === undefined) {
23591 return null;
23592 }
23593 var matches = userAgent.match(regex);
23594 if (!matches) {
23595 return null;
23596 }
23597 return parseFloat(matches[matches.length - 2]);
23598 },
23599
23600 os: function() {
23601 var a = userAgent;
23602 if (/Windows/i.test(a)) {
23603 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
23604 return 'Windows Phone';
23605 }
23606 return 'Windows';
23607 } else if (/(iPhone|iPad|iPod)/.test(a)) {
23608 return 'iOS';
23609 } else if (/Android/.test(a)) {
23610 return 'Android';
23611 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
23612 return 'BlackBerry';
23613 } else if (/Mac/i.test(a)) {
23614 return 'Mac OS X';
23615 } else if (/Linux/.test(a)) {
23616 return 'Linux';
23617 } else if (/CrOS/.test(a)) {
23618 return 'Chrome OS';
23619 } else {
23620 return '';
23621 }
23622 },
23623
23624 device: function(user_agent) {
23625 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
23626 return 'Windows Phone';
23627 } else if (/iPad/.test(user_agent)) {
23628 return 'iPad';
23629 } else if (/iPod/.test(user_agent)) {
23630 return 'iPod Touch';
23631 } else if (/iPhone/.test(user_agent)) {
23632 return 'iPhone';
23633 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23634 return 'BlackBerry';
23635 } else if (/Android/.test(user_agent)) {
23636 return 'Android';
23637 } else {
23638 return '';
23639 }
23640 },
23641
23642 referringDomain: function(referrer) {
23643 var split = referrer.split('/');
23644 if (split.length >= 3) {
23645 return split[2];
23646 }
23647 return '';
23648 },
23649
23650 currentUrl: function() {
23651 return win.location.href;
23652 },
23653
23654 properties: function(extra_props) {
23655 if (typeof extra_props !== 'object') {
23656 extra_props = {};
23657 }
23658 return _.extend(_.strip_empty_properties({
23659 '$os': _.info.os(),
23660 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
23661 '$referrer': document$1.referrer,
23662 '$referring_domain': _.info.referringDomain(document$1.referrer),
23663 '$device': _.info.device(userAgent)
23664 }), {
23665 '$current_url': _.info.currentUrl(),
23666 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
23667 '$screen_height': screen.height,
23668 '$screen_width': screen.width,
23669 'mp_lib': 'web',
23670 '$lib_version': Config.LIB_VERSION,
23671 '$insert_id': cheap_guid(),
23672 'time': _.timestamp() / 1000 // epoch time in seconds
23673 }, _.strip_empty_properties(extra_props));
23674 },
23675
23676 people_properties: function() {
23677 return _.extend(_.strip_empty_properties({
23678 '$os': _.info.os(),
23679 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
23680 }), {
23681 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
23682 });
23683 },
23684
23685 mpPageViewProperties: function() {
23686 return _.strip_empty_properties({
23687 'current_page_title': document$1.title,
23688 'current_domain': win.location.hostname,
23689 'current_url_path': win.location.pathname,
23690 'current_url_protocol': win.location.protocol,
23691 'current_url_search': win.location.search
23692 });
23693 }
23694 };
23695
23696 /**
23697 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
23698 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
23699 */
23700 var batchedThrottle = function (fn, waitMs) {
23701 var timeoutPromise = null;
23702 var throttledItems = [];
23703 return function (item) {
23704 var self = this;
23705 throttledItems.push(item);
23706
23707 if (!timeoutPromise) {
23708 timeoutPromise = new PromisePolyfill(function (resolve) {
23709 setTimeout(function () {
23710 var returnValue = fn.apply(self, [throttledItems]);
23711 timeoutPromise = null;
23712 throttledItems = [];
23713 resolve(returnValue);
23714 }, waitMs);
23715 });
23716 }
23717 return timeoutPromise;
23718 };
23719 };
23720
23721 var cheap_guid = function(maxlen) {
23722 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
23723 return maxlen ? guid.substring(0, maxlen) : guid;
23724 };
23725
23726 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
23727 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
23728 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
23729 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
23730 /**
23731 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
23732 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
23733 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
23734 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
23735 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
23736 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
23737 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
23738 * offers the 'cookie_domain' config option to set it explicitly.
23739 * @example
23740 * extract_domain('my.sub.example.com')
23741 * // 'example.com'
23742 */
23743 var extract_domain = function(hostname) {
23744 var domain_regex = DOMAIN_MATCH_REGEX;
23745 var parts = hostname.split('.');
23746 var tld = parts[parts.length - 1];
23747 if (tld.length > 4 || tld === 'com' || tld === 'org') {
23748 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
23749 }
23750 var matches = hostname.match(domain_regex);
23751 return matches ? matches[0] : '';
23752 };
23753
23754 /**
23755 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
23756 * @returns {boolean}
23757 */
23758 var isOnline = function() {
23759 var onLine = win.navigator['onLine'];
23760 return _.isUndefined(onLine) || onLine;
23761 };
23762
23763 var NOOP_FUNC = function () {};
23764
23765 var JSONStringify = null, JSONParse = null;
23766 if (typeof JSON !== 'undefined') {
23767 JSONStringify = JSON.stringify;
23768 JSONParse = JSON.parse;
23769 }
23770 JSONStringify = JSONStringify || _.JSONEncode;
23771 JSONParse = JSONParse || _.JSONDecode;
23772
23773 // UNMINIFIED EXPORTS (for closure compiler)
23774 _['info'] = _.info;
23775 _['info']['browser'] = _.info.browser;
23776 _['info']['browserVersion'] = _.info.browserVersion;
23777 _['info']['device'] = _.info.device;
23778 _['info']['properties'] = _.info.properties;
23779 _['isBlockedUA'] = _.isBlockedUA;
23780 _['isEmptyObject'] = _.isEmptyObject;
23781 _['isObject'] = _.isObject;
23782 _['JSONDecode'] = _.JSONDecode;
23783 _['JSONEncode'] = _.JSONEncode;
23784 _['toArray'] = _.toArray;
23785 _['NPO'] = NpoPromise;
23786
23787 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
23788
23789 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
23790 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
23791
23792 // note: increment the version number when adding new object stores
23793 var DB_VERSION = 1;
23794 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
23795
23796 /**
23797 * @type {import('./wrapper').StorageWrapper}
23798 */
23799 var IDBStorageWrapper = function (storeName) {
23800 /**
23801 * @type {Promise<IDBDatabase>|null}
23802 */
23803 this.dbPromise = null;
23804 this.storeName = storeName;
23805 };
23806
23807 IDBStorageWrapper.prototype._openDb = function () {
23808 return new PromisePolyfill(function (resolve, reject) {
23809 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
23810 openRequest['onerror'] = function () {
23811 reject(openRequest.error);
23812 };
23813
23814 openRequest['onsuccess'] = function () {
23815 resolve(openRequest.result);
23816 };
23817
23818 openRequest['onupgradeneeded'] = function (ev) {
23819 var db = ev.target.result;
23820
23821 OBJECT_STORES.forEach(function (storeName) {
23822 db.createObjectStore(storeName);
23823 });
23824 };
23825 });
23826 };
23827
23828 IDBStorageWrapper.prototype.init = function () {
23829 if (!win.indexedDB) {
23830 return PromisePolyfill.reject('indexedDB is not supported in this browser');
23831 }
23832
23833 if (!this.dbPromise) {
23834 this.dbPromise = this._openDb();
23835 }
23836
23837 return this.dbPromise
23838 .then(function (dbOrError) {
23839 if (dbOrError instanceof win['IDBDatabase']) {
23840 return PromisePolyfill.resolve();
23841 } else {
23842 return PromisePolyfill.reject(dbOrError);
23843 }
23844 });
23845 };
23846
23847 /**
23848 * @param {IDBTransactionMode} mode
23849 * @param {function(IDBObjectStore): void} storeCb
23850 */
23851 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
23852 var storeName = this.storeName;
23853 var doTransaction = function (db) {
23854 return new PromisePolyfill(function (resolve, reject) {
23855 var transaction = db.transaction(storeName, mode);
23856 transaction.oncomplete = function () {
23857 resolve(transaction);
23858 };
23859 transaction.onabort = transaction.onerror = function () {
23860 reject(transaction.error);
23861 };
23862
23863 storeCb(transaction.objectStore(storeName));
23864 });
23865 };
23866
23867 return this.dbPromise
23868 .then(doTransaction)
23869 .catch(function (err) {
23870 if (err && err['name'] === 'InvalidStateError') {
23871 // try reopening the DB if the connection is closed
23872 this.dbPromise = this._openDb();
23873 return this.dbPromise.then(doTransaction);
23874 } else {
23875 return PromisePolyfill.reject(err);
23876 }
23877 }.bind(this));
23878 };
23879
23880 IDBStorageWrapper.prototype.setItem = function (key, value) {
23881 return this.makeTransaction('readwrite', function (objectStore) {
23882 objectStore.put(value, key);
23883 });
23884 };
23885
23886 IDBStorageWrapper.prototype.getItem = function (key) {
23887 var req;
23888 return this.makeTransaction('readonly', function (objectStore) {
23889 req = objectStore.get(key);
23890 }).then(function () {
23891 return req.result;
23892 });
23893 };
23894
23895 IDBStorageWrapper.prototype.removeItem = function (key) {
23896 return this.makeTransaction('readwrite', function (objectStore) {
23897 objectStore.delete(key);
23898 });
23899 };
23900
23901 IDBStorageWrapper.prototype.getAll = function () {
23902 var req;
23903 return this.makeTransaction('readonly', function (objectStore) {
23904 req = objectStore.getAll();
23905 }).then(function () {
23906 return req.result;
23907 });
23908 };
23909
23910 /**
23911 * GDPR utils
23912 *
23913 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
23914 * and privacy for all individuals within the European Union. It addresses the export of personal
23915 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
23916 * over their personal data and to simplify the regulatory environment for international business
23917 * by unifying the regulation within the EU.
23918 *
23919 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
23920 * These functions are used internally by the SDK and are not intended to be publicly exposed.
23921 */
23922
23923
23924 /**
23925 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
23926 * @callback trackFunction
23927 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
23928 * @param {Object} [properties] A set of properties to include with the event you're sending. These describe the user who did the event or details about the event itself.
23929 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
23930 */
23931
23932 /** Public **/
23933
23934 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
23935
23936 /**
23937 * Opt the user in to data tracking and cookies/localstorage for the given token
23938 * @param {string} token - Mixpanel project tracking token
23939 * @param {Object} [options]
23940 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
23941 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
23942 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
23943 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
23944 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
23945 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
23946 * @param {string} [options.cookieDomain] - custom cookie domain
23947 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
23948 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
23949 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
23950 */
23951 function optIn(token, options) {
23952 _optInOut(true, token, options);
23953 }
23954
23955 /**
23956 * Opt the user out of data tracking and cookies/localstorage for the given token
23957 * @param {string} token - Mixpanel project tracking token
23958 * @param {Object} [options]
23959 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
23960 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
23961 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
23962 * @param {string} [options.cookieDomain] - custom cookie domain
23963 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
23964 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
23965 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
23966 */
23967 function optOut(token, options) {
23968 _optInOut(false, token, options);
23969 }
23970
23971 /**
23972 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
23973 * @param {string} token - Mixpanel project tracking token
23974 * @param {Object} [options]
23975 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
23976 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
23977 * @returns {boolean} whether the user has opted in to the given opt type
23978 */
23979 function hasOptedIn(token, options) {
23980 return _getStorageValue(token, options) === '1';
23981 }
23982
23983 /**
23984 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
23985 * @param {string} token - Mixpanel project tracking token
23986 * @param {Object} [options]
23987 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
23988 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
23989 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
23990 * @returns {boolean} whether the user has opted out of the given opt type
23991 */
23992 function hasOptedOut(token, options) {
23993 if (_hasDoNotTrackFlagOn(options)) {
23994 console$1.warn('This browser has "Do Not Track" enabled. This will prevent the Mixpanel SDK from sending any data. To ignore the "Do Not Track" browser setting, initialize the Mixpanel instance with the config "ignore_dnt: true"');
23995 return true;
23996 }
23997 var optedOut = _getStorageValue(token, options) === '0';
23998 if (optedOut) {
23999 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24000 }
24001 return optedOut;
24002 }
24003
24004 /**
24005 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24006 * If the user has opted out, return early instead of executing the method.
24007 * If a callback argument was provided, execute it passing the 0 error code.
24008 * @param {function} method - wrapped method to be executed if the user has not opted out
24009 * @returns {*} the result of executing method OR undefined if the user has opted out
24010 */
24011 function addOptOutCheckMixpanelLib(method) {
24012 return _addOptOutCheck(method, function(name) {
24013 return this.get_config(name);
24014 });
24015 }
24016
24017 /**
24018 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24019 * If the user has opted out, return early instead of executing the method.
24020 * If a callback argument was provided, execute it passing the 0 error code.
24021 * @param {function} method - wrapped method to be executed if the user has not opted out
24022 * @returns {*} the result of executing method OR undefined if the user has opted out
24023 */
24024 function addOptOutCheckMixpanelPeople(method) {
24025 return _addOptOutCheck(method, function(name) {
24026 return this._get_config(name);
24027 });
24028 }
24029
24030 /**
24031 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24032 * If the user has opted out, return early instead of executing the method.
24033 * If a callback argument was provided, execute it passing the 0 error code.
24034 * @param {function} method - wrapped method to be executed if the user has not opted out
24035 * @returns {*} the result of executing method OR undefined if the user has opted out
24036 */
24037 function addOptOutCheckMixpanelGroup(method) {
24038 return _addOptOutCheck(method, function(name) {
24039 return this._get_config(name);
24040 });
24041 }
24042
24043 /**
24044 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24045 * @param {string} token - Mixpanel project tracking token
24046 * @param {Object} [options]
24047 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24048 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24049 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24050 * @param {string} [options.cookieDomain] - custom cookie domain
24051 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24052 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24053 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24054 */
24055 function clearOptInOut(token, options) {
24056 options = options || {};
24057 _getStorage(options).remove(
24058 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24059 );
24060 }
24061
24062 /** Private **/
24063
24064 /**
24065 * Get storage util
24066 * @param {Object} [options]
24067 * @param {string} [options.persistenceType]
24068 * @returns {object} either _.cookie or _.localstorage
24069 */
24070 function _getStorage(options) {
24071 options = options || {};
24072 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24073 }
24074
24075 /**
24076 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24077 * @param {string} token - Mixpanel project tracking token
24078 * @param {Object} [options]
24079 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24080 * @returns {string} the name of the cookie for the given opt type
24081 */
24082 function _getStorageKey(token, options) {
24083 options = options || {};
24084 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24085 }
24086
24087 /**
24088 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24089 * @param {string} token - Mixpanel project tracking token
24090 * @param {Object} [options]
24091 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24092 * @returns {string} the value of the cookie for the given opt type
24093 */
24094 function _getStorageValue(token, options) {
24095 return _getStorage(options).get(_getStorageKey(token, options));
24096 }
24097
24098 /**
24099 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24100 * @param {Object} [options]
24101 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24102 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24103 * @returns {boolean} whether the DNT setting is true
24104 */
24105 function _hasDoNotTrackFlagOn(options) {
24106 if (options && options.ignoreDnt) {
24107 return false;
24108 }
24109 var win$1 = (options && options.window) || win;
24110 var nav = win$1['navigator'] || {};
24111 var hasDntOn = false;
24112
24113 _.each([
24114 nav['doNotTrack'], // standard
24115 nav['msDoNotTrack'],
24116 win$1['doNotTrack']
24117 ], function(dntValue) {
24118 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24119 hasDntOn = true;
24120 }
24121 });
24122
24123 return hasDntOn;
24124 }
24125
24126 /**
24127 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24128 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24129 * @param {string} token - Mixpanel project tracking token
24130 * @param {Object} [options]
24131 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24132 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24133 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24134 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24135 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24136 * @param {string} [options.cookieDomain] - custom cookie domain
24137 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24138 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24139 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24140 */
24141 function _optInOut(optValue, token, options) {
24142 if (!_.isString(token) || !token.length) {
24143 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
24144 return;
24145 }
24146
24147 options = options || {};
24148
24149 _getStorage(options).set(
24150 _getStorageKey(token, options),
24151 optValue ? 1 : 0,
24152 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
24153 !!options.crossSubdomainCookie,
24154 !!options.secureCookie,
24155 !!options.crossSiteCookie,
24156 options.cookieDomain
24157 );
24158
24159 if (options.track && optValue) { // only track event if opting in (optValue=true)
24160 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
24161 'send_immediately': true
24162 });
24163 }
24164 }
24165
24166 /**
24167 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24168 * If the user has opted out, return early instead of executing the method.
24169 * If a callback argument was provided, execute it passing the 0 error code.
24170 * @param {function} method - wrapped method to be executed if the user has not opted out
24171 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
24172 * @returns {*} the result of executing method OR undefined if the user has opted out
24173 */
24174 function _addOptOutCheck(method, getConfigValue) {
24175 return function() {
24176 var optedOut = false;
24177
24178 try {
24179 var token = getConfigValue.call(this, 'token');
24180 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
24181 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
24182 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
24183 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
24184
24185 if (token) { // if there was an issue getting the token, continue method execution as normal
24186 optedOut = hasOptedOut(token, {
24187 ignoreDnt: ignoreDnt,
24188 persistenceType: persistenceType,
24189 persistencePrefix: persistencePrefix,
24190 window: win
24191 });
24192 }
24193 } catch(err) {
24194 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
24195 }
24196
24197 if (!optedOut) {
24198 return method.apply(this, arguments);
24199 }
24200
24201 var callback = arguments[arguments.length - 1];
24202 if (typeof(callback) === 'function') {
24203 callback(0);
24204 }
24205
24206 return;
24207 };
24208 }
24209
24210 var logger$6 = console_with_prefix('lock');
24211
24212 /**
24213 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
24214 * window/tab at a time will be able to access shared resources.
24215 *
24216 * Based on the Alur and Taubenfeld fast lock
24217 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
24218 * with an added timeout to ensure there will be eventual progress in the event
24219 * that a window is closed in the middle of the callback.
24220 *
24221 * Implementation based on the original version by David Wolever (https://github.com/wolever)
24222 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
24223 *
24224 * @example
24225 * const myLock = new SharedLock('some-key');
24226 * myLock.withLock(function() {
24227 * console.log('I hold the mutex!');
24228 * });
24229 *
24230 * @constructor
24231 */
24232 var SharedLock = function(key, options) {
24233 options = options || {};
24234
24235 this.storageKey = key;
24236 this.storage = options.storage || win.localStorage;
24237 this.pollIntervalMS = options.pollIntervalMS || 100;
24238 this.timeoutMS = options.timeoutMS || 2000;
24239
24240 // dependency-inject promise implementation for testing purposes
24241 this.promiseImpl = options.promiseImpl || PromisePolyfill;
24242 };
24243
24244 // pass in a specific pid to test contention scenarios; otherwise
24245 // it is chosen randomly for each acquisition attempt
24246 SharedLock.prototype.withLock = function(lockedCB, pid) {
24247 var Promise = this.promiseImpl;
24248 return new Promise(_.bind(function (resolve, reject) {
24249 var i = pid || (new Date().getTime() + '|' + Math.random());
24250 var startTime = new Date().getTime();
24251 var key = this.storageKey;
24252 var pollIntervalMS = this.pollIntervalMS;
24253 var timeoutMS = this.timeoutMS;
24254 var storage = this.storage;
24255
24256 var keyX = key + ':X';
24257 var keyY = key + ':Y';
24258 var keyZ = key + ':Z';
24259
24260 var delay = function(cb) {
24261 if (new Date().getTime() - startTime > timeoutMS) {
24262 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
24263 storage.removeItem(keyZ);
24264 storage.removeItem(keyY);
24265 loop();
24266 return;
24267 }
24268 setTimeout(function() {
24269 try {
24270 cb();
24271 } catch(err) {
24272 reject(err);
24273 }
24274 }, pollIntervalMS * (Math.random() + 0.1));
24275 };
24276
24277 var waitFor = function(predicate, cb) {
24278 if (predicate()) {
24279 cb();
24280 } else {
24281 delay(function() {
24282 waitFor(predicate, cb);
24283 });
24284 }
24285 };
24286
24287 var getSetY = function() {
24288 var valY = storage.getItem(keyY);
24289 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
24290 return false;
24291 } else {
24292 storage.setItem(keyY, i);
24293 if (storage.getItem(keyY) === i) {
24294 return true;
24295 } else {
24296 if (!localStorageSupported(storage, true)) {
24297 reject(new Error('localStorage support dropped while acquiring lock'));
24298 }
24299 return false;
24300 }
24301 }
24302 };
24303
24304 var loop = function() {
24305 storage.setItem(keyX, i);
24306
24307 waitFor(getSetY, function() {
24308 if (storage.getItem(keyX) === i) {
24309 criticalSection();
24310 return;
24311 }
24312
24313 delay(function() {
24314 if (storage.getItem(keyY) !== i) {
24315 loop();
24316 return;
24317 }
24318 waitFor(function() {
24319 return !storage.getItem(keyZ);
24320 }, criticalSection);
24321 });
24322 });
24323 };
24324
24325 var criticalSection = function() {
24326 storage.setItem(keyZ, '1');
24327 var removeLock = function () {
24328 storage.removeItem(keyZ);
24329 if (storage.getItem(keyY) === i) {
24330 storage.removeItem(keyY);
24331 }
24332 if (storage.getItem(keyX) === i) {
24333 storage.removeItem(keyX);
24334 }
24335 };
24336
24337 lockedCB()
24338 .then(function (ret) {
24339 removeLock();
24340 resolve(ret);
24341 })
24342 .catch(function (err) {
24343 removeLock();
24344 reject(err);
24345 });
24346 };
24347
24348 try {
24349 if (localStorageSupported(storage, true)) {
24350 loop();
24351 } else {
24352 throw new Error('localStorage support check failed');
24353 }
24354 } catch(err) {
24355 reject(err);
24356 }
24357 }, this));
24358 };
24359
24360 /**
24361 * @type {import('./wrapper').StorageWrapper}
24362 */
24363 var LocalStorageWrapper = function (storageOverride) {
24364 this.storage = storageOverride || win.localStorage;
24365 };
24366
24367 LocalStorageWrapper.prototype.init = function () {
24368 return PromisePolyfill.resolve();
24369 };
24370
24371 LocalStorageWrapper.prototype.setItem = function (key, value) {
24372 return new PromisePolyfill(_.bind(function (resolve, reject) {
24373 try {
24374 this.storage.setItem(key, JSONStringify(value));
24375 } catch (e) {
24376 reject(e);
24377 }
24378 resolve();
24379 }, this));
24380 };
24381
24382 LocalStorageWrapper.prototype.getItem = function (key) {
24383 return new PromisePolyfill(_.bind(function (resolve, reject) {
24384 var item;
24385 try {
24386 item = JSONParse(this.storage.getItem(key));
24387 } catch (e) {
24388 reject(e);
24389 }
24390 resolve(item);
24391 }, this));
24392 };
24393
24394 LocalStorageWrapper.prototype.removeItem = function (key) {
24395 return new PromisePolyfill(_.bind(function (resolve, reject) {
24396 try {
24397 this.storage.removeItem(key);
24398 } catch (e) {
24399 reject(e);
24400 }
24401 resolve();
24402 }, this));
24403 };
24404
24405 var logger$5 = console_with_prefix('batch');
24406
24407 /**
24408 * RequestQueue: queue for batching API requests with localStorage backup for retries.
24409 * Maintains an in-memory queue which represents the source of truth for the current
24410 * page, but also writes all items out to a copy in the browser's localStorage, which
24411 * can be read on subsequent pageloads and retried. For batchability, all the request
24412 * items in the queue should be of the same type (events, people updates, group updates)
24413 * so they can be sent in a single request to the same API endpoint.
24414 *
24415 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
24416 * the same site to access the same persisted data, they must share the same localStorage
24417 * key (for instance based on project token and queue type). Therefore access to the
24418 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
24419 * simultaneously open windows/tabs from overwriting each other's data (which would lead
24420 * to data loss in some situations).
24421 * @constructor
24422 */
24423 var RequestQueue = function (storageKey, options) {
24424 options = options || {};
24425 this.storageKey = storageKey;
24426 this.usePersistence = options.usePersistence;
24427 if (this.usePersistence) {
24428 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
24429 this.lock = new SharedLock(storageKey, {
24430 storage: options.sharedLockStorage || win.localStorage,
24431 timeoutMS: options.sharedLockTimeoutMS,
24432 });
24433 }
24434 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
24435
24436 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
24437
24438 this.memQueue = [];
24439 this.initialized = false;
24440
24441 if (options.enqueueThrottleMs) {
24442 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
24443 } else {
24444 this.enqueuePersisted = _.bind(function (queueEntry) {
24445 return this._enqueuePersisted([queueEntry]);
24446 }, this);
24447 }
24448 };
24449
24450 RequestQueue.prototype.ensureInit = function () {
24451 if (this.initialized) {
24452 return PromisePolyfill.resolve();
24453 }
24454
24455 return this.queueStorage
24456 .init()
24457 .then(_.bind(function () {
24458 this.initialized = true;
24459 }, this))
24460 .catch(_.bind(function (err) {
24461 this.reportError('Error initializing queue persistence. Disabling persistence', err);
24462 this.initialized = true;
24463 this.usePersistence = false;
24464 }, this));
24465 };
24466
24467 /**
24468 * Add one item to queues (memory and localStorage). The queued entry includes
24469 * the given item along with an auto-generated ID and a "flush-after" timestamp.
24470 * It is expected that the item will be sent over the network and dequeued
24471 * before the flush-after time; if this doesn't happen it is considered orphaned
24472 * (e.g., the original tab where it was enqueued got closed before it could be
24473 * sent) and the item can be sent by any tab that finds it in localStorage.
24474 *
24475 * The final callback param is called with a param indicating success or
24476 * failure of the enqueue operation; it is asynchronous because the localStorage
24477 * lock is asynchronous.
24478 */
24479 RequestQueue.prototype.enqueue = function (item, flushInterval) {
24480 var queueEntry = {
24481 'id': cheap_guid(),
24482 'flushAfter': new Date().getTime() + flushInterval * 2,
24483 'payload': item
24484 };
24485
24486 if (!this.usePersistence) {
24487 this.memQueue.push(queueEntry);
24488 return PromisePolyfill.resolve(true);
24489 } else {
24490 return this.enqueuePersisted(queueEntry);
24491 }
24492 };
24493
24494 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
24495 var enqueueItem = _.bind(function () {
24496 return this.ensureInit()
24497 .then(_.bind(function () {
24498 return this.readFromStorage();
24499 }, this))
24500 .then(_.bind(function (storedQueue) {
24501 return this.saveToStorage(storedQueue.concat(queueEntries));
24502 }, this))
24503 .then(_.bind(function (succeeded) {
24504 // only add to in-memory queue when storage succeeds
24505 if (succeeded) {
24506 this.memQueue = this.memQueue.concat(queueEntries);
24507 }
24508
24509 return succeeded;
24510 }, this))
24511 .catch(_.bind(function (err) {
24512 this.reportError('Error enqueueing items', err, queueEntries);
24513 return false;
24514 }, this));
24515 }, this);
24516
24517 return this.lock
24518 .withLock(enqueueItem, this.pid)
24519 .catch(_.bind(function (err) {
24520 this.reportError('Error acquiring storage lock', err);
24521 return false;
24522 }, this));
24523 };
24524
24525 /**
24526 * Read out the given number of queue entries. If this.memQueue
24527 * has fewer than batchSize items, then look for "orphaned" items
24528 * in the persisted queue (items where the 'flushAfter' time has
24529 * already passed).
24530 */
24531 RequestQueue.prototype.fillBatch = function (batchSize) {
24532 var batch = this.memQueue.slice(0, batchSize);
24533 if (this.usePersistence && batch.length < batchSize) {
24534 // don't need lock just to read events; localStorage is thread-safe
24535 // and the worst that could happen is a duplicate send of some
24536 // orphaned events, which will be deduplicated on the server side
24537 return this.ensureInit()
24538 .then(_.bind(function () {
24539 return this.readFromStorage();
24540 }, this))
24541 .then(_.bind(function (storedQueue) {
24542 if (storedQueue.length) {
24543 // item IDs already in batch; don't duplicate out of storage
24544 var idsInBatch = {}; // poor man's Set
24545 _.each(batch, function (item) {
24546 idsInBatch[item['id']] = true;
24547 });
24548
24549 for (var i = 0; i < storedQueue.length; i++) {
24550 var item = storedQueue[i];
24551 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
24552 item.orphaned = true;
24553 batch.push(item);
24554 if (batch.length >= batchSize) {
24555 break;
24556 }
24557 }
24558 }
24559 }
24560
24561 return batch;
24562 }, this));
24563 } else {
24564 return PromisePolyfill.resolve(batch);
24565 }
24566 };
24567
24568 /**
24569 * Remove items with matching 'id' from array (immutably)
24570 * also remove any item without a valid id (e.g., malformed
24571 * storage entries).
24572 */
24573 var filterOutIDsAndInvalid = function (items, idSet) {
24574 var filteredItems = [];
24575 _.each(items, function (item) {
24576 if (item['id'] && !idSet[item['id']]) {
24577 filteredItems.push(item);
24578 }
24579 });
24580 return filteredItems;
24581 };
24582
24583 /**
24584 * Remove items with matching IDs from both in-memory queue
24585 * and persisted queue
24586 */
24587 RequestQueue.prototype.removeItemsByID = function (ids) {
24588 var idSet = {}; // poor man's Set
24589 _.each(ids, function (id) {
24590 idSet[id] = true;
24591 });
24592
24593 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
24594 if (!this.usePersistence) {
24595 return PromisePolyfill.resolve(true);
24596 } else {
24597 var removeFromStorage = _.bind(function () {
24598 return this.ensureInit()
24599 .then(_.bind(function () {
24600 return this.readFromStorage();
24601 }, this))
24602 .then(_.bind(function (storedQueue) {
24603 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
24604 return this.saveToStorage(storedQueue);
24605 }, this))
24606 .then(_.bind(function () {
24607 return this.readFromStorage();
24608 }, this))
24609 .then(_.bind(function (storedQueue) {
24610 // an extra check: did storage report success but somehow
24611 // the items are still there?
24612 for (var i = 0; i < storedQueue.length; i++) {
24613 var item = storedQueue[i];
24614 if (item['id'] && !!idSet[item['id']]) {
24615 throw new Error('Item not removed from storage');
24616 }
24617 }
24618 return true;
24619 }, this))
24620 .catch(_.bind(function (err) {
24621 this.reportError('Error removing items', err, ids);
24622 return false;
24623 }, this));
24624 }, this);
24625
24626 return this.lock
24627 .withLock(removeFromStorage, this.pid)
24628 .catch(_.bind(function (err) {
24629 this.reportError('Error acquiring storage lock', err);
24630 if (!localStorageSupported(this.lock.storage, true)) {
24631 // Looks like localStorage writes have stopped working sometime after
24632 // initialization (probably full), and so nobody can acquire locks
24633 // anymore. Consider it temporarily safe to remove items without the
24634 // lock, since nobody's writing successfully anyway.
24635 return removeFromStorage()
24636 .then(_.bind(function (success) {
24637 if (!success) {
24638 // OK, we couldn't even write out the smaller queue. Try clearing it
24639 // entirely.
24640 return this.queueStorage.removeItem(this.storageKey).then(function () {
24641 return success;
24642 });
24643 }
24644 return success;
24645 }, this))
24646 .catch(_.bind(function (err) {
24647 this.reportError('Error clearing queue', err);
24648 return false;
24649 }, this));
24650 } else {
24651 return false;
24652 }
24653 }, this));
24654 }
24655 };
24656
24657 // internal helper for RequestQueue.updatePayloads
24658 var updatePayloads = function (existingItems, itemsToUpdate) {
24659 var newItems = [];
24660 _.each(existingItems, function (item) {
24661 var id = item['id'];
24662 if (id in itemsToUpdate) {
24663 var newPayload = itemsToUpdate[id];
24664 if (newPayload !== null) {
24665 item['payload'] = newPayload;
24666 newItems.push(item);
24667 }
24668 } else {
24669 // no update
24670 newItems.push(item);
24671 }
24672 });
24673 return newItems;
24674 };
24675
24676 /**
24677 * Update payloads of given items in both in-memory queue and
24678 * persisted queue. Items set to null are removed from queues.
24679 */
24680 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
24681 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
24682 if (!this.usePersistence) {
24683 return PromisePolyfill.resolve(true);
24684 } else {
24685 return this.lock
24686 .withLock(_.bind(function lockAcquired() {
24687 return this.ensureInit()
24688 .then(_.bind(function () {
24689 return this.readFromStorage();
24690 }, this))
24691 .then(_.bind(function (storedQueue) {
24692 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
24693 return this.saveToStorage(storedQueue);
24694 }, this))
24695 .catch(_.bind(function (err) {
24696 this.reportError('Error updating items', itemsToUpdate, err);
24697 return false;
24698 }, this));
24699 }, this), this.pid)
24700 .catch(_.bind(function (err) {
24701 this.reportError('Error acquiring storage lock', err);
24702 return false;
24703 }, this));
24704 }
24705 };
24706
24707 /**
24708 * Read and parse items array from localStorage entry, handling
24709 * malformed/missing data if necessary.
24710 */
24711 RequestQueue.prototype.readFromStorage = function () {
24712 return this.ensureInit()
24713 .then(_.bind(function () {
24714 return this.queueStorage.getItem(this.storageKey);
24715 }, this))
24716 .then(_.bind(function (storageEntry) {
24717 if (storageEntry) {
24718 if (!_.isArray(storageEntry)) {
24719 this.reportError('Invalid storage entry:', storageEntry);
24720 storageEntry = null;
24721 }
24722 }
24723 return storageEntry || [];
24724 }, this))
24725 .catch(_.bind(function (err) {
24726 this.reportError('Error retrieving queue', err);
24727 return [];
24728 }, this));
24729 };
24730
24731 /**
24732 * Serialize the given items array to localStorage.
24733 */
24734 RequestQueue.prototype.saveToStorage = function (queue) {
24735 return this.ensureInit()
24736 .then(_.bind(function () {
24737 return this.queueStorage.setItem(this.storageKey, queue);
24738 }, this))
24739 .then(function () {
24740 return true;
24741 })
24742 .catch(_.bind(function (err) {
24743 this.reportError('Error saving queue', err);
24744 return false;
24745 }, this));
24746 };
24747
24748 /**
24749 * Clear out queues (memory and localStorage).
24750 */
24751 RequestQueue.prototype.clear = function () {
24752 this.memQueue = [];
24753
24754 if (this.usePersistence) {
24755 return this.ensureInit()
24756 .then(_.bind(function () {
24757 return this.queueStorage.removeItem(this.storageKey);
24758 }, this));
24759 } else {
24760 return PromisePolyfill.resolve();
24761 }
24762 };
24763
24764 // maximum interval between request retries after exponential backoff
24765 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
24766
24767 var logger$4 = console_with_prefix('batch');
24768
24769 /**
24770 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
24771 * type (events, people, groups).
24772 * Uses RequestQueue to manage the backing store.
24773 * @constructor
24774 */
24775 var RequestBatcher = function(storageKey, options) {
24776 this.errorReporter = options.errorReporter;
24777 this.queue = new RequestQueue(storageKey, {
24778 errorReporter: _.bind(this.reportError, this),
24779 queueStorage: options.queueStorage,
24780 sharedLockStorage: options.sharedLockStorage,
24781 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
24782 usePersistence: options.usePersistence,
24783 enqueueThrottleMs: options.enqueueThrottleMs
24784 });
24785
24786 this.libConfig = options.libConfig;
24787 this.sendRequest = options.sendRequestFunc;
24788 this.beforeSendHook = options.beforeSendHook;
24789 this.stopAllBatching = options.stopAllBatchingFunc;
24790
24791 // seed variable batch size + flush interval with configured values
24792 this.batchSize = this.libConfig['batch_size'];
24793 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
24794
24795 this.stopped = !this.libConfig['batch_autostart'];
24796 this.consecutiveRemovalFailures = 0;
24797
24798 // extra client-side dedupe
24799 this.itemIdsSentSuccessfully = {};
24800
24801 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
24802 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
24803 // in a request loop and get ratelimited by the server.
24804 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
24805
24806 this._flushPromise = null;
24807 };
24808
24809 /**
24810 * Add one item to queue.
24811 */
24812 RequestBatcher.prototype.enqueue = function(item) {
24813 return this.queue.enqueue(item, this.flushInterval);
24814 };
24815
24816 /**
24817 * Start flushing batches at the configured time interval. Must call
24818 * this method upon SDK init in order to send anything over the network.
24819 */
24820 RequestBatcher.prototype.start = function() {
24821 this.stopped = false;
24822 this.consecutiveRemovalFailures = 0;
24823 return this.flush();
24824 };
24825
24826 /**
24827 * Stop flushing batches. Can be restarted by calling start().
24828 */
24829 RequestBatcher.prototype.stop = function() {
24830 this.stopped = true;
24831 if (this.timeoutID) {
24832 clearTimeout(this.timeoutID);
24833 this.timeoutID = null;
24834 }
24835 };
24836
24837 /**
24838 * Clear out queue.
24839 */
24840 RequestBatcher.prototype.clear = function() {
24841 return this.queue.clear();
24842 };
24843
24844 /**
24845 * Restore batch size configuration to whatever is set in the main SDK.
24846 */
24847 RequestBatcher.prototype.resetBatchSize = function() {
24848 this.batchSize = this.libConfig['batch_size'];
24849 };
24850
24851 /**
24852 * Restore flush interval time configuration to whatever is set in the main SDK.
24853 */
24854 RequestBatcher.prototype.resetFlush = function() {
24855 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
24856 };
24857
24858 /**
24859 * Schedule the next flush in the given number of milliseconds.
24860 */
24861 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
24862 this.flushInterval = flushMS;
24863 if (!this.stopped) { // don't schedule anymore if batching has been stopped
24864 this.timeoutID = setTimeout(_.bind(function() {
24865 if (!this.stopped) {
24866 this._flushPromise = this.flush();
24867 }
24868 }, this), this.flushInterval);
24869 }
24870 };
24871
24872 /**
24873 * Send a request using the sendRequest callback, but promisified.
24874 * TODO: sendRequest should be promisified in the first place.
24875 */
24876 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
24877 return new PromisePolyfill(_.bind(function(resolve) {
24878 this.sendRequest(data, options, resolve);
24879 }, this));
24880 };
24881
24882
24883 /**
24884 * Flush one batch to network. Depending on success/failure modes, it will either
24885 * remove the batch from the queue or leave it in for retry, and schedule the next
24886 * flush. In cases of most network or API failures, it will back off exponentially
24887 * when retrying.
24888 * @param {Object} [options]
24889 * @param {boolean} [options.sendBeacon] - whether to send batch with
24890 * navigator.sendBeacon (only useful for sending batches before page unloads, as
24891 * sendBeacon offers no callbacks or status indications)
24892 */
24893 RequestBatcher.prototype.flush = function(options) {
24894 if (this.requestInProgress) {
24895 logger$4.log('Flush: Request already in progress');
24896 return PromisePolyfill.resolve();
24897 }
24898
24899 this.requestInProgress = true;
24900
24901 options = options || {};
24902 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
24903 var startTime = new Date().getTime();
24904 var currentBatchSize = this.batchSize;
24905
24906 return this.queue.fillBatch(currentBatchSize)
24907 .then(_.bind(function(batch) {
24908
24909 // if there's more items in the queue than the batch size, attempt
24910 // to flush again after the current batch is done.
24911 var attemptSecondaryFlush = batch.length === currentBatchSize;
24912 var dataForRequest = [];
24913 var transformedItems = {};
24914 _.each(batch, function(item) {
24915 var payload = item['payload'];
24916 if (this.beforeSendHook && !item.orphaned) {
24917 payload = this.beforeSendHook(payload);
24918 }
24919 if (payload) {
24920 // mp_sent_by_lib_version prop captures which lib version actually
24921 // sends each event (regardless of which version originally queued
24922 // it for sending)
24923 if (payload['event'] && payload['properties']) {
24924 payload['properties'] = _.extend(
24925 {},
24926 payload['properties'],
24927 {'mp_sent_by_lib_version': Config.LIB_VERSION}
24928 );
24929 }
24930 var addPayload = true;
24931 var itemId = item['id'];
24932 if (itemId) {
24933 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
24934 this.reportError('[dupe] item ID sent too many times, not sending', {
24935 item: item,
24936 batchSize: batch.length,
24937 timesSent: this.itemIdsSentSuccessfully[itemId]
24938 });
24939 addPayload = false;
24940 }
24941 } else {
24942 this.reportError('[dupe] found item with no ID', {item: item});
24943 }
24944
24945 if (addPayload) {
24946 dataForRequest.push(payload);
24947 }
24948 }
24949 transformedItems[item['id']] = payload;
24950 }, this);
24951
24952 if (dataForRequest.length < 1) {
24953 this.requestInProgress = false;
24954 this.resetFlush();
24955 return PromisePolyfill.resolve(); // nothing to do
24956 }
24957
24958 var removeItemsFromQueue = _.bind(function () {
24959 return this.queue
24960 .removeItemsByID(
24961 _.map(batch, function (item) {
24962 return item['id'];
24963 })
24964 )
24965 .then(_.bind(function (succeeded) {
24966 // client-side dedupe
24967 _.each(batch, _.bind(function(item) {
24968 var itemId = item['id'];
24969 if (itemId) {
24970 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
24971 this.itemIdsSentSuccessfully[itemId]++;
24972 if (this.itemIdsSentSuccessfully[itemId] > 5) {
24973 this.reportError('[dupe] item ID sent too many times', {
24974 item: item,
24975 batchSize: batch.length,
24976 timesSent: this.itemIdsSentSuccessfully[itemId]
24977 });
24978 }
24979 } else {
24980 this.reportError('[dupe] found item with no ID while removing', {item: item});
24981 }
24982 }, this));
24983
24984 if (succeeded) {
24985 this.consecutiveRemovalFailures = 0;
24986 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
24987 this.resetFlush(); // schedule next batch with a delay
24988 return PromisePolyfill.resolve();
24989 } else {
24990 return this.flush(); // handle next batch if the queue isn't empty
24991 }
24992 } else {
24993 if (++this.consecutiveRemovalFailures > 5) {
24994 this.reportError('Too many queue failures; disabling batching system.');
24995 this.stopAllBatching();
24996 } else {
24997 this.resetFlush();
24998 }
24999 return PromisePolyfill.resolve();
25000 }
25001 }, this));
25002 }, this);
25003
25004 var batchSendCallback = _.bind(function(res) {
25005 this.requestInProgress = false;
25006
25007 try {
25008
25009 // handle API response in a try-catch to make sure we can reset the
25010 // flush operation if something goes wrong
25011
25012 if (options.unloading) {
25013 // update persisted data to include hook transformations
25014 return this.queue.updatePayloads(transformedItems);
25015 } else if (
25016 _.isObject(res) &&
25017 res.error === 'timeout' &&
25018 new Date().getTime() - startTime >= timeoutMS
25019 ) {
25020 this.reportError('Network timeout; retrying');
25021 return this.flush();
25022 } else if (
25023 _.isObject(res) &&
25024 (
25025 res.httpStatusCode >= 500
25026 || res.httpStatusCode === 429
25027 || (res.httpStatusCode <= 0 && !isOnline())
25028 || res.error === 'timeout'
25029 )
25030 ) {
25031 // network or API error, or 429 Too Many Requests, retry
25032 var retryMS = this.flushInterval * 2;
25033 if (res.retryAfter) {
25034 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25035 }
25036 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25037 this.reportError('Error; retry in ' + retryMS + ' ms');
25038 this.scheduleFlush(retryMS);
25039 return PromisePolyfill.resolve();
25040 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25041 // 413 Payload Too Large
25042 if (batch.length > 1) {
25043 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25044 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25045 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25046 this.resetFlush();
25047 return PromisePolyfill.resolve();
25048 } else {
25049 this.reportError('Single-event request too large; dropping', batch);
25050 this.resetBatchSize();
25051 return removeItemsFromQueue();
25052 }
25053 } else {
25054 // successful network request+response; remove each item in batch from queue
25055 // (even if it was e.g. a 400, in which case retrying won't help)
25056 return removeItemsFromQueue();
25057 }
25058 } catch(err) {
25059 this.reportError('Error handling API response', err);
25060 this.resetFlush();
25061 }
25062 }, this);
25063 var requestOptions = {
25064 method: 'POST',
25065 verbose: true,
25066 ignore_json_errors: true, // eslint-disable-line camelcase
25067 timeout_ms: timeoutMS // eslint-disable-line camelcase
25068 };
25069 if (options.unloading) {
25070 requestOptions.transport = 'sendBeacon';
25071 }
25072 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25073 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25074 }, this))
25075 .catch(_.bind(function(err) {
25076 this.reportError('Error flushing request queue', err);
25077 this.resetFlush();
25078 }, this));
25079 };
25080
25081 /**
25082 * Log error to global logger and optional user-defined logger.
25083 */
25084 RequestBatcher.prototype.reportError = function(msg, err) {
25085 logger$4.error.apply(logger$4.error, arguments);
25086 if (this.errorReporter) {
25087 try {
25088 if (!(err instanceof Error)) {
25089 err = new Error(msg);
25090 }
25091 this.errorReporter(msg, err);
25092 } catch(err) {
25093 logger$4.error(err);
25094 }
25095 }
25096 };
25097
25098 /**
25099 * @param {import('./session-recording').SerializedRecording} serializedRecording
25100 * @returns {boolean}
25101 */
25102 var isRecordingExpired = function(serializedRecording) {
25103 var now = Date.now();
25104 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25105 };
25106
25107 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25108
25109 var logger$3 = console_with_prefix('recorder');
25110 var CompressionStream = win['CompressionStream'];
25111
25112 var RECORDER_BATCHER_LIB_CONFIG = {
25113 'batch_size': 1000,
25114 'batch_flush_interval_ms': 10 * 1000,
25115 'batch_request_timeout_ms': 90 * 1000,
25116 'batch_autostart': true
25117 };
25118
25119 var ACTIVE_SOURCES = new Set([
25120 IncrementalSource.MouseMove,
25121 IncrementalSource.MouseInteraction,
25122 IncrementalSource.Scroll,
25123 IncrementalSource.ViewportResize,
25124 IncrementalSource.Input,
25125 IncrementalSource.TouchMove,
25126 IncrementalSource.MediaInteraction,
25127 IncrementalSource.Drag,
25128 IncrementalSource.Selection,
25129 ]);
25130
25131 function isUserEvent(ev) {
25132 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25133 }
25134
25135 /**
25136 * @typedef {Object} SerializedRecording
25137 * @property {number} idleExpires
25138 * @property {number} maxExpires
25139 * @property {number} replayStartTime
25140 * @property {number} seqNo
25141 * @property {string} batchStartUrl
25142 * @property {string} replayId
25143 * @property {string} tabId
25144 * @property {string} replayStartUrl
25145 */
25146
25147 /**
25148 * @typedef {Object} SessionRecordingOptions
25149 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25150 * @property {String} [options.replayId] - unique uuid for a single replay
25151 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
25152 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
25153 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
25154 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
25155 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
25156 * optional properties for deserialization:
25157 * @property {number} idleExpires
25158 * @property {number} maxExpires
25159 * @property {number} replayStartTime
25160 * @property {number} seqNo
25161 * @property {string} batchStartUrl
25162 * @property {string} replayStartUrl
25163 */
25164
25165
25166 /**
25167 * This class encapsulates a single session recording and its lifecycle.
25168 * @param {SessionRecordingOptions} options
25169 */
25170 var SessionRecording = function(options) {
25171 this._mixpanel = options.mixpanelInstance;
25172 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
25173 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
25174 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
25175 this._rrwebRecord = options.rrwebRecord || null;
25176
25177 // internal rrweb stopRecording function
25178 this._stopRecording = null;
25179 this.replayId = options.replayId;
25180
25181 this.batchStartUrl = options.batchStartUrl || null;
25182 this.replayStartUrl = options.replayStartUrl || null;
25183 this.idleExpires = options.idleExpires || null;
25184 this.maxExpires = options.maxExpires || null;
25185 this.replayStartTime = options.replayStartTime || null;
25186 this.seqNo = options.seqNo || 0;
25187
25188 this.idleTimeoutId = null;
25189 this.maxTimeoutId = null;
25190
25191 this.recordMaxMs = MAX_RECORDING_MS;
25192 this.recordMinMs = 0;
25193
25194 // disable persistence if localStorage is not supported
25195 // request-queue will automatically disable persistence if indexedDB fails to initialize
25196 var usePersistence = localStorageSupported(options.sharedLockStorage, true);
25197
25198 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
25199 // this will be important when persistence is introduced
25200 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
25201 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
25202 this.batcher = new RequestBatcher(this.batcherKey, {
25203 errorReporter: this.reportError.bind(this),
25204 flushOnlyOnInterval: true,
25205 libConfig: RECORDER_BATCHER_LIB_CONFIG,
25206 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
25207 queueStorage: this.queueStorage,
25208 sharedLockStorage: options.sharedLockStorage,
25209 usePersistence: usePersistence,
25210 stopAllBatchingFunc: this.stopRecording.bind(this),
25211
25212 // increased throttle and shared lock timeout because recording events are very high frequency.
25213 // this will minimize the amount of lock contention between enqueued events.
25214 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
25215 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
25216 sharedLockTimeoutMS: 10 * 1000,
25217 });
25218 };
25219
25220 SessionRecording.prototype.unloadPersistedData = function () {
25221 this.batcher.stop();
25222 return this.batcher.flush()
25223 .then(function () {
25224 return this.queueStorage.removeItem(this.batcherKey);
25225 }.bind(this));
25226 };
25227
25228 SessionRecording.prototype.getConfig = function(configVar) {
25229 return this._mixpanel.get_config(configVar);
25230 };
25231
25232 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
25233 // reaches into this class instance and expects the snake case version of the function.
25234 // eslint-disable-next-line camelcase
25235 SessionRecording.prototype.get_config = function(configVar) {
25236 return this.getConfig(configVar);
25237 };
25238
25239 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
25240 if (this._rrwebRecord === null) {
25241 this.reportError('rrweb record function not provided. ');
25242 return;
25243 }
25244
25245 if (this._stopRecording !== null) {
25246 logger$3.log('Recording already in progress, skipping startRecording.');
25247 return;
25248 }
25249
25250 this.recordMaxMs = this.getConfig('record_max_ms');
25251 if (this.recordMaxMs > MAX_RECORDING_MS) {
25252 this.recordMaxMs = MAX_RECORDING_MS;
25253 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
25254 }
25255
25256 if (!this.maxExpires) {
25257 this.maxExpires = new Date().getTime() + this.recordMaxMs;
25258 }
25259
25260 this.recordMinMs = this.getConfig('record_min_ms');
25261 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
25262 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
25263 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
25264 }
25265
25266 if (!this.replayStartTime) {
25267 this.replayStartTime = new Date().getTime();
25268 this.batchStartUrl = _.info.currentUrl();
25269 this.replayStartUrl = _.info.currentUrl();
25270 }
25271
25272 if (shouldStopBatcher || this.recordMinMs > 0) {
25273 // the primary case for shouldStopBatcher is when we're starting recording after a reset
25274 // and don't want to send anything over the network until there's
25275 // actual user activity
25276 // this also applies if the minimum recording length has not been hit yet
25277 // so that we don't send data until we know the recording will be long enough
25278 this.batcher.stop();
25279 } else {
25280 this.batcher.start();
25281 }
25282
25283 var resetIdleTimeout = function () {
25284 clearTimeout(this.idleTimeoutId);
25285 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
25286 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
25287 this.idleExpires = new Date().getTime() + idleTimeoutMs;
25288 }.bind(this);
25289 resetIdleTimeout();
25290
25291 var blockSelector = this.getConfig('record_block_selector');
25292 if (blockSelector === '' || blockSelector === null) {
25293 blockSelector = undefined;
25294 }
25295
25296 try {
25297 this._stopRecording = this._rrwebRecord({
25298 'emit': function (ev) {
25299 if (this.idleExpires && this.idleExpires < ev.timestamp) {
25300 this._onIdleTimeout();
25301 return;
25302 }
25303 if (isUserEvent(ev)) {
25304 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
25305 // start flushing again after user activity
25306 this.batcher.start();
25307 }
25308 resetIdleTimeout();
25309 }
25310 // promise only used to await during tests
25311 this.__enqueuePromise = this.batcher.enqueue(ev);
25312 }.bind(this),
25313 'blockClass': this.getConfig('record_block_class'),
25314 'blockSelector': blockSelector,
25315 'collectFonts': this.getConfig('record_collect_fonts'),
25316 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
25317 'type': 'image/webp',
25318 'quality': 0.6
25319 },
25320 'maskAllInputs': true,
25321 'maskTextClass': this.getConfig('record_mask_text_class'),
25322 'maskTextSelector': this.getConfig('record_mask_text_selector'),
25323 'recordCanvas': this.getConfig('record_canvas'),
25324 'sampling': {
25325 'canvas': 15
25326 }
25327 });
25328 } catch (err) {
25329 this.reportError('Unexpected error when starting rrweb recording.', err);
25330 }
25331
25332 if (typeof this._stopRecording !== 'function') {
25333 this.reportError('rrweb failed to start, skipping this recording.');
25334 this._stopRecording = null;
25335 this.stopRecording(); // stop batcher looping and any timeouts
25336 return;
25337 }
25338
25339 var maxTimeoutMs = this.maxExpires - new Date().getTime();
25340 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
25341 };
25342
25343 SessionRecording.prototype.stopRecording = function (skipFlush) {
25344 if (!this.isRrwebStopped()) {
25345 try {
25346 this._stopRecording();
25347 } catch (err) {
25348 this.reportError('Error with rrweb stopRecording', err);
25349 }
25350 this._stopRecording = null;
25351 }
25352
25353 var flushPromise;
25354 if (this.batcher.stopped) {
25355 // never got user activity to flush after reset, so just clear the batcher
25356 flushPromise = this.batcher.clear();
25357 } else if (!skipFlush) {
25358 // flush any remaining events from running batcher
25359 flushPromise = this.batcher.flush();
25360 }
25361 this.batcher.stop();
25362
25363 clearTimeout(this.idleTimeoutId);
25364 clearTimeout(this.maxTimeoutId);
25365 return flushPromise;
25366 };
25367
25368 SessionRecording.prototype.isRrwebStopped = function () {
25369 return this._stopRecording === null;
25370 };
25371
25372
25373 /**
25374 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
25375 * we stop recording and dump any queued events if the user has opted out.
25376 */
25377 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
25378 var onOptOut = function (code) {
25379 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
25380 if (code === 0) {
25381 this.stopRecording();
25382 cb({error: 'Tracking has been opted out, stopping recording.'});
25383 }
25384 }.bind(this);
25385
25386 this._flushEvents(data, options, cb, onOptOut);
25387 };
25388
25389 /**
25390 * @returns {SerializedRecording}
25391 */
25392 SessionRecording.prototype.serialize = function () {
25393 // don't break if mixpanel instance was destroyed at some point
25394 var tabId;
25395 try {
25396 tabId = this._mixpanel.get_tab_id();
25397 } catch (e) {
25398 this.reportError('Error getting tab ID for serialization ', e);
25399 tabId = null;
25400 }
25401
25402 return {
25403 'replayId': this.replayId,
25404 'seqNo': this.seqNo,
25405 'replayStartTime': this.replayStartTime,
25406 'batchStartUrl': this.batchStartUrl,
25407 'replayStartUrl': this.replayStartUrl,
25408 'idleExpires': this.idleExpires,
25409 'maxExpires': this.maxExpires,
25410 'tabId': tabId,
25411 };
25412 };
25413
25414
25415 /**
25416 * @static
25417 * @param {SerializedRecording} serializedRecording
25418 * @param {SessionRecordingOptions} options
25419 * @returns {SessionRecording}
25420 */
25421 SessionRecording.deserialize = function (serializedRecording, options) {
25422 var recording = new SessionRecording(_.extend({}, options, {
25423 replayId: serializedRecording['replayId'],
25424 batchStartUrl: serializedRecording['batchStartUrl'],
25425 replayStartUrl: serializedRecording['replayStartUrl'],
25426 idleExpires: serializedRecording['idleExpires'],
25427 maxExpires: serializedRecording['maxExpires'],
25428 replayStartTime: serializedRecording['replayStartTime'],
25429 seqNo: serializedRecording['seqNo'],
25430 sharedLockStorage: options.sharedLockStorage,
25431 }));
25432
25433 return recording;
25434 };
25435
25436 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
25437 var onSuccess = function (response, responseBody) {
25438 // Update batch specific props only if the request was successful to guarantee ordering.
25439 // RequestBatcher will always flush the next batch after the previous one succeeds.
25440 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
25441 if (response.status === 200 && this.replayId === currentReplayId) {
25442 this.seqNo++;
25443 this.batchStartUrl = _.info.currentUrl();
25444 }
25445
25446 this._onBatchSent();
25447 callback({
25448 status: 0,
25449 httpStatusCode: response.status,
25450 responseBody: responseBody,
25451 retryAfter: response.headers.get('Retry-After')
25452 });
25453 }.bind(this);
25454
25455 win['fetch'](this.getConfig('api_host') + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
25456 'method': 'POST',
25457 'headers': {
25458 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
25459 'Content-Type': 'application/octet-stream'
25460 },
25461 'body': reqBody,
25462 }).then(function (response) {
25463 response.json().then(function (responseBody) {
25464 onSuccess(response, responseBody);
25465 }).catch(function (error) {
25466 callback({error: error});
25467 });
25468 }).catch(function (error) {
25469 callback({error: error, httpStatusCode: 0});
25470 });
25471 };
25472
25473 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
25474 var numEvents = data.length;
25475
25476 if (numEvents > 0) {
25477 var replayId = this.replayId;
25478
25479 // each rrweb event has a timestamp - leverage those to get time properties
25480 var batchStartTime = Infinity;
25481 var batchEndTime = -Infinity;
25482 var hasFullSnapshot = false;
25483 for (var i = 0; i < numEvents; i++) {
25484 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
25485 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
25486 if (data[i].type === EventType.FullSnapshot) {
25487 hasFullSnapshot = true;
25488 }
25489 }
25490
25491 if (this.seqNo === 0) {
25492 if (!hasFullSnapshot) {
25493 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
25494 this.stopRecording(true);
25495 return;
25496 }
25497 this.replayStartTime = batchStartTime;
25498 } else if (!this.replayStartTime) {
25499 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
25500 this.replayStartTime = batchStartTime;
25501 }
25502
25503 var replayLengthMs = batchEndTime - this.replayStartTime;
25504
25505 var reqParams = {
25506 '$current_url': this.batchStartUrl,
25507 '$lib_version': Config.LIB_VERSION,
25508 'batch_start_time': batchStartTime / 1000,
25509 'distinct_id': String(this._mixpanel.get_distinct_id()),
25510 'mp_lib': 'web',
25511 'replay_id': replayId,
25512 'replay_length_ms': replayLengthMs,
25513 'replay_start_time': this.replayStartTime / 1000,
25514 'replay_start_url': this.replayStartUrl,
25515 'seq': this.seqNo
25516 };
25517 var eventsJson = JSON.stringify(data);
25518
25519 // send ID management props if they exist
25520 var deviceId = this._mixpanel.get_property('$device_id');
25521 if (deviceId) {
25522 reqParams['$device_id'] = deviceId;
25523 }
25524 var userId = this._mixpanel.get_property('$user_id');
25525 if (userId) {
25526 reqParams['$user_id'] = userId;
25527 }
25528
25529 if (CompressionStream) {
25530 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
25531 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
25532 new Response(gzipStream)
25533 .blob()
25534 .then(function(compressedBlob) {
25535 reqParams['format'] = 'gzip';
25536 this._sendRequest(replayId, reqParams, compressedBlob, callback);
25537 }.bind(this));
25538 } else {
25539 reqParams['format'] = 'body';
25540 this._sendRequest(replayId, reqParams, eventsJson, callback);
25541 }
25542 }
25543 });
25544
25545
25546 SessionRecording.prototype.reportError = function(msg, err) {
25547 logger$3.error.apply(logger$3.error, arguments);
25548 try {
25549 if (!err && !(msg instanceof Error)) {
25550 msg = new Error(msg);
25551 }
25552 this.getConfig('error_reporter')(msg, err);
25553 } catch(err) {
25554 logger$3.error(err);
25555 }
25556 };
25557
25558 /**
25559 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
25560 * Makes sure that only one tab can be recording at a time.
25561 */
25562 var RecordingRegistry = function (options) {
25563 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
25564 this.errorReporter = options.errorReporter;
25565 this.mixpanelInstance = options.mixpanelInstance;
25566 this.sharedLockStorage = options.sharedLockStorage;
25567 };
25568
25569 RecordingRegistry.prototype.handleError = function (err) {
25570 this.errorReporter('IndexedDB error: ', err);
25571 };
25572
25573 /**
25574 * @param {import('./session-recording').SerializedRecording} serializedRecording
25575 */
25576 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
25577 var tabId = serializedRecording['tabId'];
25578 if (!tabId) {
25579 console.warn('No tab ID is set, cannot persist recording metadata.');
25580 return PromisePolyfill.resolve();
25581 }
25582
25583 return this.idb.init()
25584 .then(function () {
25585 return this.idb.setItem(tabId, serializedRecording);
25586 }.bind(this))
25587 .catch(this.handleError.bind(this));
25588 };
25589
25590 /**
25591 * @returns {Promise<import('./session-recording').SerializedRecording>}
25592 */
25593 RecordingRegistry.prototype.getActiveRecording = function () {
25594 return this.idb.init()
25595 .then(function () {
25596 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
25597 }.bind(this))
25598 .then(function (serializedRecording) {
25599 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
25600 }.bind(this))
25601 .catch(this.handleError.bind(this));
25602 };
25603
25604 RecordingRegistry.prototype.clearActiveRecording = function () {
25605 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
25606 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
25607 return this.getActiveRecording()
25608 .then(function (serializedRecording) {
25609 if (serializedRecording) {
25610 serializedRecording['maxExpires'] = 0;
25611 return this.setActiveRecording(serializedRecording);
25612 }
25613 }.bind(this))
25614 .catch(this.handleError.bind(this));
25615 };
25616
25617 /**
25618 * Flush any inactive recordings from the registry to minimize data loss.
25619 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
25620 */
25621 RecordingRegistry.prototype.flushInactiveRecordings = function () {
25622 return this.idb.init()
25623 .then(function() {
25624 return this.idb.getAll();
25625 }.bind(this))
25626 .then(function (serializedRecordings) {
25627 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
25628 var unloadPromises = serializedRecordings
25629 .filter(function (serializedRecording) {
25630 return isRecordingExpired(serializedRecording);
25631 })
25632 .map(function (serializedRecording) {
25633 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
25634 mixpanelInstance: this.mixpanelInstance,
25635 sharedLockStorage: this.sharedLockStorage
25636 });
25637 return sessionRecording.unloadPersistedData()
25638 .then(function () {
25639 // expired recording was successfully flushed, we can clean it up from the registry
25640 return this.idb.removeItem(serializedRecording['tabId']);
25641 }.bind(this))
25642 .catch(this.handleError.bind(this));
25643 }.bind(this));
25644
25645 return PromisePolyfill.all(unloadPromises);
25646 }.bind(this))
25647 .catch(this.handleError.bind(this));
25648 };
25649
25650 var logger$2 = console_with_prefix('recorder');
25651
25652 /**
25653 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
25654 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25655 */
25656 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
25657 this.mixpanelInstance = mixpanelInstance;
25658 this.rrwebRecord = rrwebRecord || record;
25659 this.sharedLockStorage = sharedLockStorage;
25660
25661 /**
25662 * @member {import('./registry').RecordingRegistry}
25663 */
25664 this.recordingRegistry = new RecordingRegistry({
25665 mixpanelInstance: this.mixpanelInstance,
25666 errorReporter: logger$2.error,
25667 sharedLockStorage: sharedLockStorage
25668 });
25669 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
25670
25671 this.activeRecording = null;
25672 };
25673
25674 MixpanelRecorder.prototype.startRecording = function(options) {
25675 options = options || {};
25676 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
25677 logger$2.log('Recording already in progress, skipping startRecording.');
25678 return;
25679 }
25680
25681 var onIdleTimeout = function () {
25682 logger$2.log('Idle timeout reached, restarting recording.');
25683 this.resetRecording();
25684 }.bind(this);
25685
25686 var onMaxLengthReached = function () {
25687 logger$2.log('Max recording length reached, stopping recording.');
25688 this.resetRecording();
25689 }.bind(this);
25690
25691 var onBatchSent = function () {
25692 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
25693 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
25694 }.bind(this);
25695
25696 /**
25697 * @type {import('./session-recording').SessionRecordingOptions}
25698 */
25699 var sessionRecordingOptions = {
25700 mixpanelInstance: this.mixpanelInstance,
25701 onBatchSent: onBatchSent,
25702 onIdleTimeout: onIdleTimeout,
25703 onMaxLengthReached: onMaxLengthReached,
25704 replayId: _.UUID(),
25705 rrwebRecord: this.rrwebRecord,
25706 sharedLockStorage: this.sharedLockStorage
25707 };
25708
25709 if (options.activeSerializedRecording) {
25710 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
25711 } else {
25712 this.activeRecording = new SessionRecording(sessionRecordingOptions);
25713 }
25714
25715 this.activeRecording.startRecording(options.shouldStopBatcher);
25716 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
25717 };
25718
25719 MixpanelRecorder.prototype.stopRecording = function() {
25720 var stopPromise = this._stopCurrentRecording(false);
25721 this.recordingRegistry.clearActiveRecording();
25722 this.activeRecording = null;
25723 return stopPromise;
25724 };
25725
25726 MixpanelRecorder.prototype.pauseRecording = function() {
25727 return this._stopCurrentRecording(false);
25728 };
25729
25730 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush) {
25731 if (this.activeRecording) {
25732 return this.activeRecording.stopRecording(skipFlush);
25733 }
25734 return PromisePolyfill.resolve();
25735 };
25736
25737 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
25738 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
25739 this.activeRecording.startRecording(false);
25740 return PromisePolyfill.resolve(null);
25741 }
25742
25743 return this.recordingRegistry.getActiveRecording()
25744 .then(function (activeSerializedRecording) {
25745 if (activeSerializedRecording) {
25746 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
25747 } else if (startNewIfInactive) {
25748 return this.startRecording({shouldStopBatcher: false});
25749 } else {
25750 logger$2.log('No resumable recording found.');
25751 return null;
25752 }
25753 }.bind(this));
25754 };
25755
25756
25757 MixpanelRecorder.prototype.resetRecording = function () {
25758 this.stopRecording();
25759 this.startRecording({shouldStopBatcher: true});
25760 };
25761
25762 MixpanelRecorder.prototype.getActiveReplayId = function () {
25763 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
25764 return this.activeRecording.replayId;
25765 } else {
25766 return null;
25767 }
25768 };
25769
25770 // getter so that older mixpanel-core versions can still retrieve the replay ID
25771 // when pulling the latest recorder bundle from the CDN
25772 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
25773 get: function () {
25774 return this.getActiveReplayId();
25775 }
25776 });
25777
25778 win['__mp_recorder'] = MixpanelRecorder;
25779
25780 // stateless utils
25781 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
25782
25783
25784 var EV_CHANGE = 'change';
25785 var EV_CLICK = 'click';
25786 var EV_HASHCHANGE = 'hashchange';
25787 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
25788 var EV_POPSTATE = 'popstate';
25789 // TODO scrollend isn't available in Safari: document or polyfill?
25790 var EV_SCROLLEND = 'scrollend';
25791 var EV_SUBMIT = 'submit';
25792
25793 var CLICK_EVENT_PROPS = [
25794 'clientX', 'clientY',
25795 'offsetX', 'offsetY',
25796 'pageX', 'pageY',
25797 'screenX', 'screenY',
25798 'x', 'y'
25799 ];
25800 var OPT_IN_CLASSES = ['mp-include'];
25801 var OPT_OUT_CLASSES = ['mp-no-track'];
25802 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
25803 var TRACKED_ATTRS = [
25804 'aria-label', 'aria-labelledby', 'aria-describedby',
25805 'href', 'name', 'role', 'title', 'type'
25806 ];
25807
25808 var logger$1 = console_with_prefix('autocapture');
25809
25810
25811 function getClasses(el) {
25812 var classes = {};
25813 var classList = getClassName(el).split(' ');
25814 for (var i = 0; i < classList.length; i++) {
25815 var cls = classList[i];
25816 if (cls) {
25817 classes[cls] = true;
25818 }
25819 }
25820 return classes;
25821 }
25822
25823 /*
25824 * Get the className of an element, accounting for edge cases where element.className is an object
25825 * @param {Element} el - element to get the className of
25826 * @returns {string} the element's class
25827 */
25828 function getClassName(el) {
25829 switch(typeof el.className) {
25830 case 'string':
25831 return el.className;
25832 case 'object': // handle cases where className might be SVGAnimatedString or some other type
25833 return el.className.baseVal || el.getAttribute('class') || '';
25834 default: // future proof
25835 return '';
25836 }
25837 }
25838
25839 function getPreviousElementSibling(el) {
25840 if (el.previousElementSibling) {
25841 return el.previousElementSibling;
25842 } else {
25843 do {
25844 el = el.previousSibling;
25845 } while (el && !isElementNode(el));
25846 return el;
25847 }
25848 }
25849
25850 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
25851 var props = {
25852 '$classes': getClassName(el).split(' '),
25853 '$tag_name': el.tagName.toLowerCase()
25854 };
25855 var elId = el.id;
25856 if (elId) {
25857 props['$id'] = elId;
25858 }
25859
25860 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
25861 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
25862 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
25863 var attrVal = el.getAttribute(attr);
25864 if (shouldTrackValue(attrVal)) {
25865 props['$attr-' + attr] = attrVal;
25866 }
25867 }
25868 });
25869 }
25870
25871 var nthChild = 1;
25872 var nthOfType = 1;
25873 var currentElem = el;
25874 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
25875 nthChild++;
25876 if (currentElem.tagName === el.tagName) {
25877 nthOfType++;
25878 }
25879 }
25880 props['$nth_child'] = nthChild;
25881 props['$nth_of_type'] = nthOfType;
25882
25883 return props;
25884 }
25885
25886 function getPropsForDOMEvent(ev, config) {
25887 var allowElementCallback = config.allowElementCallback;
25888 var allowSelectors = config.allowSelectors || [];
25889 var blockAttrs = config.blockAttrs || [];
25890 var blockElementCallback = config.blockElementCallback;
25891 var blockSelectors = config.blockSelectors || [];
25892 var captureTextContent = config.captureTextContent || false;
25893 var captureExtraAttrs = config.captureExtraAttrs || [];
25894 var capturedForHeatMap = config.capturedForHeatMap || false;
25895
25896 // convert array to set every time, as the config may have changed
25897 var blockAttrsSet = {};
25898 _.each(blockAttrs, function(attr) {
25899 blockAttrsSet[attr] = true;
25900 });
25901
25902 var props = null;
25903
25904 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
25905 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
25906 target = target.parentNode;
25907 }
25908
25909 if (
25910 shouldTrackDomEvent(target, ev) &&
25911 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
25912 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
25913 ) {
25914 var targetElementList = [target];
25915 var curEl = target;
25916 while (curEl.parentNode && !isTag(curEl, 'body')) {
25917 targetElementList.push(curEl.parentNode);
25918 curEl = curEl.parentNode;
25919 }
25920
25921 var elementsJson = [];
25922 var href, explicitNoTrack = false;
25923 _.each(targetElementList, function(el) {
25924 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
25925
25926 // if the element or a parent element is an anchor tag
25927 // include the href as a property
25928 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
25929 href = el.getAttribute('href');
25930 href = shouldTrackDetails && shouldTrackValue(href) && href;
25931 }
25932
25933 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
25934 explicitNoTrack = true;
25935 }
25936
25937 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
25938 }, this);
25939
25940 if (!explicitNoTrack) {
25941 var docElement = document$1['documentElement'];
25942 props = {
25943 '$event_type': ev.type,
25944 '$host': win.location.host,
25945 '$pathname': win.location.pathname,
25946 '$elements': elementsJson,
25947 '$el_attr__href': href,
25948 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
25949 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
25950 '$pageHeight': document$1['body']['offsetHeight'] || 0,
25951 '$pageWidth': document$1['body']['offsetWidth'] || 0,
25952 };
25953 _.each(captureExtraAttrs, function(attr) {
25954 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
25955 var attrVal = target.getAttribute(attr);
25956 if (shouldTrackValue(attrVal)) {
25957 props['$el_attr__' + attr] = attrVal;
25958 }
25959 }
25960 });
25961
25962 if (captureTextContent) {
25963 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
25964 if (elementText && elementText.length) {
25965 props['$el_text'] = elementText;
25966 }
25967 }
25968
25969 if (ev.type === EV_CLICK) {
25970 _.each(CLICK_EVENT_PROPS, function(prop) {
25971 if (prop in ev) {
25972 props['$' + prop] = ev[prop];
25973 }
25974 });
25975 if (capturedForHeatMap) {
25976 props['$captured_for_heatmap'] = true;
25977 }
25978 target = guessRealClickTarget(ev);
25979 }
25980 // prioritize text content from "real" click target if different from original target
25981 if (captureTextContent) {
25982 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
25983 if (elementText && elementText.length) {
25984 props['$el_text'] = elementText;
25985 }
25986 }
25987
25988 if (target) {
25989 // target may have been recalculated; check allowlists and blocklists again
25990 if (
25991 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
25992 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
25993 ) {
25994 return null;
25995 }
25996
25997 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
25998 props['$target'] = targetProps;
25999 // pull up more props onto main event props
26000 props['$el_classes'] = targetProps['$classes'];
26001 _.extend(props, _.strip_empty_properties({
26002 '$el_id': targetProps['$id'],
26003 '$el_tag_name': targetProps['$tag_name']
26004 }));
26005 }
26006 }
26007 }
26008
26009 return props;
26010 }
26011
26012
26013 /**
26014 * Get the direct text content of an element, protecting against sensitive data collection.
26015 * Concats textContent of each of the element's text node children; this avoids potential
26016 * collection of sensitive data that could happen if we used element.textContent and the
26017 * element had sensitive child elements, since element.textContent includes child content.
26018 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
26019 * @param {Element} el - element to get the text of
26020 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26021 * @returns {string} the element's direct text content
26022 */
26023 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
26024 var elText = '';
26025
26026 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
26027 _.each(el.childNodes, function(child) {
26028 if (isTextNode(child) && child.textContent) {
26029 elText += _.trim(child.textContent)
26030 // scrub potentially sensitive values
26031 .split(/(\s+)/).filter(shouldTrackValue).join('')
26032 // normalize whitespace
26033 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
26034 // truncate
26035 .substring(0, 255);
26036 }
26037 });
26038 }
26039
26040 return _.trim(elText);
26041 }
26042
26043 function guessRealClickTarget(ev) {
26044 var target = ev.target;
26045 var composedPath = ev['composedPath']();
26046 for (var i = 0; i < composedPath.length; i++) {
26047 var node = composedPath[i];
26048 if (
26049 isTag(node, 'a') ||
26050 isTag(node, 'button') ||
26051 isTag(node, 'input') ||
26052 isTag(node, 'select') ||
26053 (node.getAttribute && node.getAttribute('role') === 'button')
26054 ) {
26055 target = node;
26056 break;
26057 }
26058 if (node === target) {
26059 break;
26060 }
26061 }
26062 return target;
26063 }
26064
26065 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
26066 if (allowElementCallback) {
26067 try {
26068 if (!allowElementCallback(el, ev)) {
26069 return false;
26070 }
26071 } catch (err) {
26072 logger$1.critical('Error while checking element in allowElementCallback', err);
26073 return false;
26074 }
26075 }
26076
26077 if (!allowSelectors.length) {
26078 // no allowlist; all elements are fair game
26079 return true;
26080 }
26081
26082 for (var i = 0; i < allowSelectors.length; i++) {
26083 var sel = allowSelectors[i];
26084 try {
26085 if (el['matches'](sel)) {
26086 return true;
26087 }
26088 } catch (err) {
26089 logger$1.critical('Error while checking selector: ' + sel, err);
26090 }
26091 }
26092 return false;
26093 }
26094
26095 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
26096 var i;
26097
26098 if (blockElementCallback) {
26099 try {
26100 if (blockElementCallback(el, ev)) {
26101 return true;
26102 }
26103 } catch (err) {
26104 logger$1.critical('Error while checking element in blockElementCallback', err);
26105 return true;
26106 }
26107 }
26108
26109 if (blockSelectors && blockSelectors.length) {
26110 // programmatically prevent tracking of elements that match CSS selectors
26111 for (i = 0; i < blockSelectors.length; i++) {
26112 var sel = blockSelectors[i];
26113 try {
26114 if (el['matches'](sel)) {
26115 return true;
26116 }
26117 } catch (err) {
26118 logger$1.critical('Error while checking selector: ' + sel, err);
26119 }
26120 }
26121 }
26122
26123 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
26124 var classes = getClasses(el);
26125 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
26126 if (classes[OPT_OUT_CLASSES[i]]) {
26127 return true;
26128 }
26129 }
26130
26131 return false;
26132 }
26133
26134 /*
26135 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
26136 * @param {Node} node - node to check
26137 * @returns {boolean} whether node is of the correct nodeType
26138 */
26139 function isElementNode(node) {
26140 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
26141 }
26142
26143 /*
26144 * Check whether an element is of a given tag type.
26145 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
26146 * we want to match tagNames instead of specific references because something like
26147 * element === document.body won't always work because element might not be a native
26148 * element.
26149 * @param {Element} el - element to check
26150 * @param {string} tag - tag name (e.g., "div")
26151 * @returns {boolean} whether el is of the given tag type
26152 */
26153 function isTag(el, tag) {
26154 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
26155 }
26156
26157 /*
26158 * Check whether a DOM node is a TEXT_NODE
26159 * @param {Node} node - node to check
26160 * @returns {boolean} whether node is of type Node.TEXT_NODE
26161 */
26162 function isTextNode(node) {
26163 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
26164 }
26165
26166 function minDOMApisSupported() {
26167 try {
26168 var testEl = document$1.createElement('div');
26169 return !!testEl['matches'];
26170 } catch (err) {
26171 return false;
26172 }
26173 }
26174
26175 /*
26176 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
26177 * using a variety of heuristics.
26178 * @param {Element} el - element to check
26179 * @param {Event} ev - event to check
26180 * @returns {boolean} whether the event should be tracked
26181 */
26182 function shouldTrackDomEvent(el, ev) {
26183 if (!el || isTag(el, 'html') || !isElementNode(el)) {
26184 return false;
26185 }
26186 var tag = el.tagName.toLowerCase();
26187 switch (tag) {
26188 case 'form':
26189 return ev.type === EV_SUBMIT;
26190 case 'input':
26191 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
26192 return ev.type === EV_CHANGE;
26193 } else {
26194 return ev.type === EV_CLICK;
26195 }
26196 case 'select':
26197 case 'textarea':
26198 return ev.type === EV_CHANGE;
26199 default:
26200 return ev.type === EV_CLICK;
26201 }
26202 }
26203
26204 /*
26205 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
26206 * using a variety of heuristics.
26207 * @param {Element} el - element to check
26208 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26209 * @returns {boolean} whether the element should be tracked
26210 */
26211 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
26212 var i;
26213
26214 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
26215 return false;
26216 }
26217
26218 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
26219 var classes = getClasses(curEl);
26220 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
26221 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
26222 return false;
26223 }
26224 }
26225 }
26226
26227 var elClasses = getClasses(el);
26228 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
26229 if (elClasses[OPT_IN_CLASSES[i]]) {
26230 return true;
26231 }
26232 }
26233
26234 // don't send data from inputs or similar elements since there will always be
26235 // a risk of clientside javascript placing sensitive data in attributes
26236 if (
26237 isTag(el, 'input') ||
26238 isTag(el, 'select') ||
26239 isTag(el, 'textarea') ||
26240 el.getAttribute('contenteditable') === 'true'
26241 ) {
26242 return false;
26243 }
26244
26245 // don't include hidden or password fields
26246 var type = el.type || '';
26247 if (typeof type === 'string') { // it's possible for el.type to be a DOM element if el is a form with a child input[name="type"]
26248 switch(type.toLowerCase()) {
26249 case 'hidden':
26250 return false;
26251 case 'password':
26252 return false;
26253 }
26254 }
26255
26256 // filter out data from fields that look like sensitive fields
26257 var name = el.name || el.id || '';
26258 if (typeof name === 'string') { // it's possible for el.name or el.id to be a DOM element if el is a form with a child input[name="name"]
26259 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
26260 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
26261 return false;
26262 }
26263 }
26264
26265 return true;
26266 }
26267
26268
26269 /*
26270 * Check whether a string value should be "tracked" or if it may contain sensitive data
26271 * using a variety of heuristics.
26272 * @param {string} value - string value to check
26273 * @returns {boolean} whether the element should be tracked
26274 */
26275 function shouldTrackValue(value) {
26276 if (value === null || _.isUndefined(value)) {
26277 return false;
26278 }
26279
26280 if (typeof value === 'string') {
26281 value = _.trim(value);
26282
26283 // check to see if input value looks like a credit card number
26284 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
26285 var ccRegex = /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/;
26286 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
26287 return false;
26288 }
26289
26290 // check to see if input value looks like a social security number
26291 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
26292 if (ssnRegex.test(value)) {
26293 return false;
26294 }
26295 }
26296
26297 return true;
26298 }
26299
26300 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
26301 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
26302
26303 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
26304 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
26305 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
26306
26307 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
26308 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
26309 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
26310 var CONFIG_BLOCK_ATTRS = 'block_attrs';
26311 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
26312 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
26313 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
26314 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
26315 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
26316 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
26317 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
26318 var CONFIG_TRACK_CLICK = 'click';
26319 var CONFIG_TRACK_INPUT = 'input';
26320 var CONFIG_TRACK_PAGEVIEW = 'pageview';
26321 var CONFIG_TRACK_SCROLL = 'scroll';
26322 var CONFIG_TRACK_SUBMIT = 'submit';
26323
26324 var CONFIG_DEFAULTS$1 = {};
26325 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
26326 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
26327 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
26328 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
26329 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
26330 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
26331 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
26332 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
26333 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
26334 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
26335 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
26336 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
26337 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
26338 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
26339 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
26340
26341 var DEFAULT_PROPS = {
26342 '$mp_autocapture': true
26343 };
26344
26345 var MP_EV_CLICK = '$mp_click';
26346 var MP_EV_INPUT = '$mp_input_change';
26347 var MP_EV_SCROLL = '$mp_scroll';
26348 var MP_EV_SUBMIT = '$mp_submit';
26349
26350 /**
26351 * Autocapture: manages automatic event tracking
26352 * @constructor
26353 */
26354 var Autocapture = function(mp) {
26355 this.mp = mp;
26356 };
26357
26358 Autocapture.prototype.init = function() {
26359 if (!minDOMApisSupported()) {
26360 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
26361 return;
26362 }
26363
26364 this.initPageviewTracking();
26365 this.initClickTracking();
26366 this.initInputTracking();
26367 this.initScrollTracking();
26368 this.initSubmitTracking();
26369 };
26370
26371 Autocapture.prototype.getFullConfig = function() {
26372 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
26373 if (!autocaptureConfig) {
26374 // Autocapture is completely off
26375 return {};
26376 } else if (_.isObject(autocaptureConfig)) {
26377 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
26378 } else {
26379 // Autocapture config is non-object truthy value, return default
26380 return CONFIG_DEFAULTS$1;
26381 }
26382 };
26383
26384 Autocapture.prototype.getConfig = function(key) {
26385 return this.getFullConfig()[key];
26386 };
26387
26388 Autocapture.prototype.currentUrlBlocked = function() {
26389 var i;
26390 var currentUrl = _.info.currentUrl();
26391
26392 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
26393 if (allowUrlRegexes.length) {
26394 // we're using an allowlist, only track if current URL matches
26395 var allowed = false;
26396 for (i = 0; i < allowUrlRegexes.length; i++) {
26397 var allowRegex = allowUrlRegexes[i];
26398 try {
26399 if (currentUrl.match(allowRegex)) {
26400 allowed = true;
26401 break;
26402 }
26403 } catch (err) {
26404 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
26405 return true;
26406 }
26407 }
26408 if (!allowed) {
26409 // wasn't allowed by any regex
26410 return true;
26411 }
26412 }
26413
26414 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
26415 if (!blockUrlRegexes || !blockUrlRegexes.length) {
26416 return false;
26417 }
26418
26419 for (i = 0; i < blockUrlRegexes.length; i++) {
26420 try {
26421 if (currentUrl.match(blockUrlRegexes[i])) {
26422 return true;
26423 }
26424 } catch (err) {
26425 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
26426 return true;
26427 }
26428 }
26429 return false;
26430 };
26431
26432 Autocapture.prototype.pageviewTrackingConfig = function() {
26433 // supports both autocapture config and old track_pageview config
26434 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
26435 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
26436 } else {
26437 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
26438 }
26439 };
26440
26441 // helper for event handlers
26442 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
26443 if (this.currentUrlBlocked()) {
26444 return;
26445 }
26446
26447 var props = getPropsForDOMEvent(ev, {
26448 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
26449 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
26450 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
26451 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
26452 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
26453 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
26454 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
26455 capturedForHeatMap: mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK) && this.mp.is_recording_heatmap_data(),
26456 });
26457 if (props) {
26458 _.extend(props, DEFAULT_PROPS);
26459 this.mp.track(mpEventName, props);
26460 }
26461 };
26462
26463 Autocapture.prototype.initClickTracking = function() {
26464 win.removeEventListener(EV_CLICK, this.listenerClick);
26465
26466 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
26467 return;
26468 }
26469 logger$1.log('Initializing click tracking');
26470
26471 this.listenerClick = win.addEventListener(EV_CLICK, function(ev) {
26472 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
26473 return;
26474 }
26475 this.trackDomEvent(ev, MP_EV_CLICK);
26476 }.bind(this));
26477 };
26478
26479 Autocapture.prototype.initInputTracking = function() {
26480 win.removeEventListener(EV_CHANGE, this.listenerChange);
26481
26482 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
26483 return;
26484 }
26485 logger$1.log('Initializing input tracking');
26486
26487 this.listenerChange = win.addEventListener(EV_CHANGE, function(ev) {
26488 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
26489 return;
26490 }
26491 this.trackDomEvent(ev, MP_EV_INPUT);
26492 }.bind(this));
26493 };
26494
26495 Autocapture.prototype.initPageviewTracking = function() {
26496 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
26497 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
26498 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
26499
26500 if (!this.pageviewTrackingConfig()) {
26501 return;
26502 }
26503 logger$1.log('Initializing pageview tracking');
26504
26505 var previousTrackedUrl = '';
26506 var tracked = false;
26507 if (!this.currentUrlBlocked()) {
26508 tracked = this.mp.track_pageview(DEFAULT_PROPS);
26509 }
26510 if (tracked) {
26511 previousTrackedUrl = _.info.currentUrl();
26512 }
26513
26514 this.listenerPopstate = win.addEventListener(EV_POPSTATE, function() {
26515 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
26516 });
26517 this.listenerHashchange = win.addEventListener(EV_HASHCHANGE, function() {
26518 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
26519 });
26520 var nativePushState = win.history.pushState;
26521 if (typeof nativePushState === 'function') {
26522 win.history.pushState = function(state, unused, url) {
26523 nativePushState.call(win.history, state, unused, url);
26524 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
26525 };
26526 }
26527 var nativeReplaceState = win.history.replaceState;
26528 if (typeof nativeReplaceState === 'function') {
26529 win.history.replaceState = function(state, unused, url) {
26530 nativeReplaceState.call(win.history, state, unused, url);
26531 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
26532 };
26533 }
26534 this.listenerLocationchange = win.addEventListener(EV_MP_LOCATION_CHANGE, safewrap(function() {
26535 if (this.currentUrlBlocked()) {
26536 return;
26537 }
26538
26539 var currentUrl = _.info.currentUrl();
26540 var shouldTrack = false;
26541 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
26542 var trackPageviewOption = this.pageviewTrackingConfig();
26543 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
26544 shouldTrack = currentUrl !== previousTrackedUrl;
26545 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
26546 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
26547 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
26548 shouldTrack = didPathChange;
26549 }
26550
26551 if (shouldTrack) {
26552 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
26553 if (tracked) {
26554 previousTrackedUrl = currentUrl;
26555 }
26556 if (didPathChange) {
26557 this.lastScrollCheckpoint = 0;
26558 logger$1.log('Path change: re-initializing scroll depth checkpoints');
26559 }
26560 }
26561 }.bind(this)));
26562 };
26563
26564 Autocapture.prototype.initScrollTracking = function() {
26565 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
26566
26567 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
26568 return;
26569 }
26570 logger$1.log('Initializing scroll tracking');
26571 this.lastScrollCheckpoint = 0;
26572
26573 this.listenerScroll = win.addEventListener(EV_SCROLLEND, safewrap(function() {
26574 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
26575 return;
26576 }
26577 if (this.currentUrlBlocked()) {
26578 return;
26579 }
26580
26581 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
26582 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
26583 .slice()
26584 .sort(function(a, b) { return a - b; });
26585
26586 var scrollTop = win.scrollY;
26587 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
26588 try {
26589 var scrollHeight = document$1.body.scrollHeight;
26590 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
26591 props['$scroll_height'] = scrollHeight;
26592 props['$scroll_percentage'] = scrollPercentage;
26593 if (scrollPercentage > this.lastScrollCheckpoint) {
26594 for (var i = 0; i < scrollCheckpoints.length; i++) {
26595 var checkpoint = scrollCheckpoints[i];
26596 if (
26597 scrollPercentage >= checkpoint &&
26598 this.lastScrollCheckpoint < checkpoint
26599 ) {
26600 props['$scroll_checkpoint'] = checkpoint;
26601 this.lastScrollCheckpoint = checkpoint;
26602 shouldTrack = true;
26603 }
26604 }
26605 }
26606 } catch (err) {
26607 logger$1.critical('Error while calculating scroll percentage', err);
26608 }
26609 if (shouldTrack) {
26610 this.mp.track(MP_EV_SCROLL, props);
26611 }
26612 }.bind(this)));
26613 };
26614
26615 Autocapture.prototype.initSubmitTracking = function() {
26616 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
26617
26618 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
26619 return;
26620 }
26621 logger$1.log('Initializing submit tracking');
26622
26623 this.listenerSubmit = win.addEventListener(EV_SUBMIT, function(ev) {
26624 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
26625 return;
26626 }
26627 this.trackDomEvent(ev, MP_EV_SUBMIT);
26628 }.bind(this));
26629 };
26630
26631 // TODO integrate error_reporter from mixpanel instance
26632 safewrapClass(Autocapture);
26633
26634 var fetch = win['fetch'];
26635 var logger = console_with_prefix('flags');
26636
26637 var FLAGS_CONFIG_KEY = 'flags';
26638
26639 var CONFIG_CONTEXT = 'context';
26640 var CONFIG_DEFAULTS = {};
26641 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
26642
26643 /**
26644 * FeatureFlagManager: support for Mixpanel's feature flagging product
26645 * @constructor
26646 */
26647 var FeatureFlagManager = function(initOptions) {
26648 this.getMpConfig = initOptions.getConfigFunc;
26649 this.getDistinctId = initOptions.getDistinctIdFunc;
26650 this.track = initOptions.trackingFunc;
26651 };
26652
26653 FeatureFlagManager.prototype.init = function() {
26654 if (!minApisSupported()) {
26655 logger.critical('Feature Flags unavailable: missing minimum required APIs');
26656 return;
26657 }
26658
26659 this.flags = null;
26660 this.fetchFlags();
26661
26662 this.trackedFeatures = new Set();
26663 };
26664
26665 FeatureFlagManager.prototype.getFullConfig = function() {
26666 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
26667 if (!ffConfig) {
26668 // flags are completely off
26669 return {};
26670 } else if (_.isObject(ffConfig)) {
26671 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
26672 } else {
26673 // config is non-object truthy value, return default
26674 return CONFIG_DEFAULTS;
26675 }
26676 };
26677
26678 FeatureFlagManager.prototype.getConfig = function(key) {
26679 return this.getFullConfig()[key];
26680 };
26681
26682 FeatureFlagManager.prototype.isSystemEnabled = function() {
26683 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
26684 };
26685
26686 FeatureFlagManager.prototype.areFlagsReady = function() {
26687 if (!this.isSystemEnabled()) {
26688 logger.error('Feature Flags not enabled');
26689 }
26690 return !!this.flags;
26691 };
26692
26693 FeatureFlagManager.prototype.fetchFlags = function() {
26694 if (!this.isSystemEnabled()) {
26695 return;
26696 }
26697
26698 var distinctId = this.getDistinctId();
26699 logger.log('Fetching flags for distinct ID: ' + distinctId);
26700 var reqParams = {
26701 'context': _.extend({'distinct_id': distinctId}, this.getConfig(CONFIG_CONTEXT))
26702 };
26703 this.fetchPromise = win['fetch'](this.getMpConfig('api_host') + '/' + this.getMpConfig('api_routes')['flags'], {
26704 'method': 'POST',
26705 'headers': {
26706 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
26707 'Content-Type': 'application/octet-stream'
26708 },
26709 'body': JSON.stringify(reqParams)
26710 }).then(function(response) {
26711 return response.json().then(function(responseBody) {
26712 var responseFlags = responseBody['flags'];
26713 if (!responseFlags) {
26714 throw new Error('No flags in API response');
26715 }
26716 var flags = new Map();
26717 _.each(responseFlags, function(data, key) {
26718 flags.set(key, {
26719 'key': data['variant_key'],
26720 'value': data['variant_value']
26721 });
26722 });
26723 this.flags = flags;
26724 }.bind(this)).catch(function(error) {
26725 logger.error(error);
26726 });
26727 }.bind(this)).catch(function() {});
26728 };
26729
26730 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
26731 if (!this.fetchPromise) {
26732 return new Promise(function(resolve) {
26733 logger.critical('Feature Flags not initialized');
26734 resolve(fallback);
26735 });
26736 }
26737
26738 return this.fetchPromise.then(function() {
26739 return this.getVariantSync(featureName, fallback);
26740 }.bind(this)).catch(function(error) {
26741 logger.error(error);
26742 return fallback;
26743 });
26744 };
26745
26746 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
26747 if (!this.areFlagsReady()) {
26748 logger.log('Flags not loaded yet');
26749 return fallback;
26750 }
26751 var feature = this.flags.get(featureName);
26752 if (!feature) {
26753 logger.log('No flag found: "' + featureName + '"');
26754 return fallback;
26755 }
26756 this.trackFeatureCheck(featureName, feature);
26757 return feature;
26758 };
26759
26760 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
26761 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
26762 return feature['value'];
26763 }).catch(function(error) {
26764 logger.error(error);
26765 return fallbackValue;
26766 });
26767 };
26768
26769 // TODO remove deprecated method
26770 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
26771 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
26772 return this.getVariantValue(featureName, fallbackValue);
26773 };
26774
26775 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
26776 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
26777 };
26778
26779 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
26780 return this.getVariantValue(featureName).then(function() {
26781 return this.isEnabledSync(featureName, fallbackValue);
26782 }.bind(this)).catch(function(error) {
26783 logger.error(error);
26784 return fallbackValue;
26785 });
26786 };
26787
26788 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
26789 fallbackValue = fallbackValue || false;
26790 var val = this.getVariantValueSync(featureName, fallbackValue);
26791 if (val !== true && val !== false) {
26792 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
26793 val = fallbackValue;
26794 }
26795 return val;
26796 };
26797
26798 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
26799 if (this.trackedFeatures.has(featureName)) {
26800 return;
26801 }
26802 this.trackedFeatures.add(featureName);
26803 this.track('$experiment_started', {
26804 'Experiment name': featureName,
26805 'Variant name': feature['key'],
26806 '$experiment_type': 'feature_flag'
26807 });
26808 };
26809
26810 function minApisSupported() {
26811 return !!fetch &&
26812 typeof Promise !== 'undefined' &&
26813 typeof Map !== 'undefined' &&
26814 typeof Set !== 'undefined';
26815 }
26816
26817 safewrapClass(FeatureFlagManager);
26818
26819 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
26820 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
26821 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
26822 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
26823 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
26824 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
26825 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
26826
26827 // Deprecated method
26828 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
26829
26830 /* eslint camelcase: "off" */
26831
26832
26833 /**
26834 * DomTracker Object
26835 * @constructor
26836 */
26837 var DomTracker = function() {};
26838
26839
26840 // interface
26841 DomTracker.prototype.create_properties = function() {};
26842 DomTracker.prototype.event_handler = function() {};
26843 DomTracker.prototype.after_track_handler = function() {};
26844
26845 DomTracker.prototype.init = function(mixpanel_instance) {
26846 this.mp = mixpanel_instance;
26847 return this;
26848 };
26849
26850 /**
26851 * @param {Object|string} query
26852 * @param {string} event_name
26853 * @param {Object=} properties
26854 * @param {function=} user_callback
26855 */
26856 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
26857 var that = this;
26858 var elements = _.dom_query(query);
26859
26860 if (elements.length === 0) {
26861 console$1.error('The DOM query (' + query + ') returned 0 elements');
26862 return;
26863 }
26864
26865 _.each(elements, function(element) {
26866 _.register_event(element, this.override_event, function(e) {
26867 var options = {};
26868 var props = that.create_properties(properties, this);
26869 var timeout = that.mp.get_config('track_links_timeout');
26870
26871 that.event_handler(e, this, options);
26872
26873 // in case the mixpanel servers don't get back to us in time
26874 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
26875
26876 // fire the tracking event
26877 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
26878 });
26879 }, this);
26880
26881 return true;
26882 };
26883
26884 /**
26885 * @param {function} user_callback
26886 * @param {Object} props
26887 * @param {boolean=} timeout_occured
26888 */
26889 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
26890 timeout_occured = timeout_occured || false;
26891 var that = this;
26892
26893 return function() {
26894 // options is referenced from both callbacks, so we can have
26895 // a 'lock' of sorts to ensure only one fires
26896 if (options.callback_fired) { return; }
26897 options.callback_fired = true;
26898
26899 if (user_callback && user_callback(timeout_occured, props) === false) {
26900 // user can prevent the default functionality by
26901 // returning false from their callback
26902 return;
26903 }
26904
26905 that.after_track_handler(props, options, timeout_occured);
26906 };
26907 };
26908
26909 DomTracker.prototype.create_properties = function(properties, element) {
26910 var props;
26911
26912 if (typeof(properties) === 'function') {
26913 props = properties(element);
26914 } else {
26915 props = _.extend({}, properties);
26916 }
26917
26918 return props;
26919 };
26920
26921 /**
26922 * LinkTracker Object
26923 * @constructor
26924 * @extends DomTracker
26925 */
26926 var LinkTracker = function() {
26927 this.override_event = 'click';
26928 };
26929 _.inherit(LinkTracker, DomTracker);
26930
26931 LinkTracker.prototype.create_properties = function(properties, element) {
26932 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
26933
26934 if (element.href) { props['url'] = element.href; }
26935
26936 return props;
26937 };
26938
26939 LinkTracker.prototype.event_handler = function(evt, element, options) {
26940 options.new_tab = (
26941 evt.which === 2 ||
26942 evt.metaKey ||
26943 evt.ctrlKey ||
26944 element.target === '_blank'
26945 );
26946 options.href = element.href;
26947
26948 if (!options.new_tab) {
26949 evt.preventDefault();
26950 }
26951 };
26952
26953 LinkTracker.prototype.after_track_handler = function(props, options) {
26954 if (options.new_tab) { return; }
26955
26956 setTimeout(function() {
26957 window.location = options.href;
26958 }, 0);
26959 };
26960
26961 /**
26962 * FormTracker Object
26963 * @constructor
26964 * @extends DomTracker
26965 */
26966 var FormTracker = function() {
26967 this.override_event = 'submit';
26968 };
26969 _.inherit(FormTracker, DomTracker);
26970
26971 FormTracker.prototype.event_handler = function(evt, element, options) {
26972 options.element = element;
26973 evt.preventDefault();
26974 };
26975
26976 FormTracker.prototype.after_track_handler = function(props, options) {
26977 setTimeout(function() {
26978 options.element.submit();
26979 }, 0);
26980 };
26981
26982 /* eslint camelcase: "off" */
26983
26984
26985 /** @const */ var SET_ACTION = '$set';
26986 /** @const */ var SET_ONCE_ACTION = '$set_once';
26987 /** @const */ var UNSET_ACTION = '$unset';
26988 /** @const */ var ADD_ACTION = '$add';
26989 /** @const */ var APPEND_ACTION = '$append';
26990 /** @const */ var UNION_ACTION = '$union';
26991 /** @const */ var REMOVE_ACTION = '$remove';
26992 /** @const */ var DELETE_ACTION = '$delete';
26993
26994 // Common internal methods for mixpanel.people and mixpanel.group APIs.
26995 // These methods shouldn't involve network I/O.
26996 var apiActions = {
26997 set_action: function(prop, to) {
26998 var data = {};
26999 var $set = {};
27000 if (_.isObject(prop)) {
27001 _.each(prop, function(v, k) {
27002 if (!this._is_reserved_property(k)) {
27003 $set[k] = v;
27004 }
27005 }, this);
27006 } else {
27007 $set[prop] = to;
27008 }
27009
27010 data[SET_ACTION] = $set;
27011 return data;
27012 },
27013
27014 unset_action: function(prop) {
27015 var data = {};
27016 var $unset = [];
27017 if (!_.isArray(prop)) {
27018 prop = [prop];
27019 }
27020
27021 _.each(prop, function(k) {
27022 if (!this._is_reserved_property(k)) {
27023 $unset.push(k);
27024 }
27025 }, this);
27026
27027 data[UNSET_ACTION] = $unset;
27028 return data;
27029 },
27030
27031 set_once_action: function(prop, to) {
27032 var data = {};
27033 var $set_once = {};
27034 if (_.isObject(prop)) {
27035 _.each(prop, function(v, k) {
27036 if (!this._is_reserved_property(k)) {
27037 $set_once[k] = v;
27038 }
27039 }, this);
27040 } else {
27041 $set_once[prop] = to;
27042 }
27043 data[SET_ONCE_ACTION] = $set_once;
27044 return data;
27045 },
27046
27047 union_action: function(list_name, values) {
27048 var data = {};
27049 var $union = {};
27050 if (_.isObject(list_name)) {
27051 _.each(list_name, function(v, k) {
27052 if (!this._is_reserved_property(k)) {
27053 $union[k] = _.isArray(v) ? v : [v];
27054 }
27055 }, this);
27056 } else {
27057 $union[list_name] = _.isArray(values) ? values : [values];
27058 }
27059 data[UNION_ACTION] = $union;
27060 return data;
27061 },
27062
27063 append_action: function(list_name, value) {
27064 var data = {};
27065 var $append = {};
27066 if (_.isObject(list_name)) {
27067 _.each(list_name, function(v, k) {
27068 if (!this._is_reserved_property(k)) {
27069 $append[k] = v;
27070 }
27071 }, this);
27072 } else {
27073 $append[list_name] = value;
27074 }
27075 data[APPEND_ACTION] = $append;
27076 return data;
27077 },
27078
27079 remove_action: function(list_name, value) {
27080 var data = {};
27081 var $remove = {};
27082 if (_.isObject(list_name)) {
27083 _.each(list_name, function(v, k) {
27084 if (!this._is_reserved_property(k)) {
27085 $remove[k] = v;
27086 }
27087 }, this);
27088 } else {
27089 $remove[list_name] = value;
27090 }
27091 data[REMOVE_ACTION] = $remove;
27092 return data;
27093 },
27094
27095 delete_action: function() {
27096 var data = {};
27097 data[DELETE_ACTION] = '';
27098 return data;
27099 }
27100 };
27101
27102 /* eslint camelcase: "off" */
27103
27104 /**
27105 * Mixpanel Group Object
27106 * @constructor
27107 */
27108 var MixpanelGroup = function() {};
27109
27110 _.extend(MixpanelGroup.prototype, apiActions);
27111
27112 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
27113 this._mixpanel = mixpanel_instance;
27114 this._group_key = group_key;
27115 this._group_id = group_id;
27116 };
27117
27118 /**
27119 * Set properties on a group.
27120 *
27121 * ### Usage:
27122 *
27123 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
27124 *
27125 * // or set multiple properties at once
27126 * mixpanel.get_group('company', 'mixpanel').set({
27127 * 'Location': '405 Howard',
27128 * 'Founded' : 2009,
27129 * });
27130 * // properties can be strings, integers, dates, or lists
27131 *
27132 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
27133 * @param {*} [to] A value to set on the given property name
27134 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27135 */
27136 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
27137 var data = this.set_action(prop, to);
27138 if (_.isObject(prop)) {
27139 callback = to;
27140 }
27141 return this._send_request(data, callback);
27142 });
27143
27144 /**
27145 * Set properties on a group, only if they do not yet exist.
27146 * This will not overwrite previous group property values, unlike
27147 * group.set().
27148 *
27149 * ### Usage:
27150 *
27151 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
27152 *
27153 * // or set multiple properties at once
27154 * mixpanel.get_group('company', 'mixpanel').set_once({
27155 * 'Location': '405 Howard',
27156 * 'Founded' : 2009,
27157 * });
27158 * // properties can be strings, integers, lists or dates
27159 *
27160 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
27161 * @param {*} [to] A value to set on the given property name
27162 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27163 */
27164 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
27165 var data = this.set_once_action(prop, to);
27166 if (_.isObject(prop)) {
27167 callback = to;
27168 }
27169 return this._send_request(data, callback);
27170 });
27171
27172 /**
27173 * Unset properties on a group permanently.
27174 *
27175 * ### Usage:
27176 *
27177 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
27178 *
27179 * @param {String} prop The name of the property.
27180 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27181 */
27182 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
27183 var data = this.unset_action(prop);
27184 return this._send_request(data, callback);
27185 });
27186
27187 /**
27188 * Merge a given list with a list-valued group property, excluding duplicate values.
27189 *
27190 * ### Usage:
27191 *
27192 * // merge a value to a list, creating it if needed
27193 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
27194 *
27195 * @param {String} list_name Name of the property.
27196 * @param {Array} values Values to merge with the given property
27197 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27198 */
27199 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
27200 if (_.isObject(list_name)) {
27201 callback = values;
27202 }
27203 var data = this.union_action(list_name, values);
27204 return this._send_request(data, callback);
27205 });
27206
27207 /**
27208 * Permanently delete a group.
27209 *
27210 * ### Usage:
27211 *
27212 * mixpanel.get_group('company', 'mixpanel').delete();
27213 *
27214 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27215 */
27216 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
27217 // bracket notation above prevents a minification error related to reserved words
27218 var data = this.delete_action();
27219 return this._send_request(data, callback);
27220 });
27221
27222 /**
27223 * Remove a property from a group. The value will be ignored if doesn't exist.
27224 *
27225 * ### Usage:
27226 *
27227 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
27228 *
27229 * @param {String} list_name Name of the property.
27230 * @param {Object} value Value to remove from the given group property
27231 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27232 */
27233 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
27234 var data = this.remove_action(list_name, value);
27235 return this._send_request(data, callback);
27236 });
27237
27238 MixpanelGroup.prototype._send_request = function(data, callback) {
27239 data['$group_key'] = this._group_key;
27240 data['$group_id'] = this._group_id;
27241 data['$token'] = this._get_config('token');
27242
27243 var date_encoded_data = _.encodeDates(data);
27244 return this._mixpanel._track_or_batch({
27245 type: 'groups',
27246 data: date_encoded_data,
27247 endpoint: this._get_config('api_host') + '/' + this._get_config('api_routes')['groups'],
27248 batcher: this._mixpanel.request_batchers.groups
27249 }, callback);
27250 };
27251
27252 MixpanelGroup.prototype._is_reserved_property = function(prop) {
27253 return prop === '$group_key' || prop === '$group_id';
27254 };
27255
27256 MixpanelGroup.prototype._get_config = function(conf) {
27257 return this._mixpanel.get_config(conf);
27258 };
27259
27260 MixpanelGroup.prototype.toString = function() {
27261 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
27262 };
27263
27264 // MixpanelGroup Exports
27265 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
27266 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
27267 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
27268 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
27269 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
27270 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
27271
27272 /* eslint camelcase: "off" */
27273
27274 /**
27275 * Mixpanel People Object
27276 * @constructor
27277 */
27278 var MixpanelPeople = function() {};
27279
27280 _.extend(MixpanelPeople.prototype, apiActions);
27281
27282 MixpanelPeople.prototype._init = function(mixpanel_instance) {
27283 this._mixpanel = mixpanel_instance;
27284 };
27285
27286 /*
27287 * Set properties on a user record.
27288 *
27289 * ### Usage:
27290 *
27291 * mixpanel.people.set('gender', 'm');
27292 *
27293 * // or set multiple properties at once
27294 * mixpanel.people.set({
27295 * 'Company': 'Acme',
27296 * 'Plan': 'Premium',
27297 * 'Upgrade date': new Date()
27298 * });
27299 * // properties can be strings, integers, dates, or lists
27300 *
27301 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
27302 * @param {*} [to] A value to set on the given property name
27303 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27304 */
27305 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
27306 var data = this.set_action(prop, to);
27307 if (_.isObject(prop)) {
27308 callback = to;
27309 }
27310 // make sure that the referrer info has been updated and saved
27311 if (this._get_config('save_referrer')) {
27312 this._mixpanel['persistence'].update_referrer_info(document.referrer);
27313 }
27314
27315 // update $set object with default people properties
27316 data[SET_ACTION] = _.extend(
27317 {},
27318 _.info.people_properties(),
27319 data[SET_ACTION]
27320 );
27321 return this._send_request(data, callback);
27322 });
27323
27324 /*
27325 * Set properties on a user record, only if they do not yet exist.
27326 * This will not overwrite previous people property values, unlike
27327 * people.set().
27328 *
27329 * ### Usage:
27330 *
27331 * mixpanel.people.set_once('First Login Date', new Date());
27332 *
27333 * // or set multiple properties at once
27334 * mixpanel.people.set_once({
27335 * 'First Login Date': new Date(),
27336 * 'Starting Plan': 'Premium'
27337 * });
27338 *
27339 * // properties can be strings, integers or dates
27340 *
27341 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
27342 * @param {*} [to] A value to set on the given property name
27343 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27344 */
27345 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
27346 var data = this.set_once_action(prop, to);
27347 if (_.isObject(prop)) {
27348 callback = to;
27349 }
27350 return this._send_request(data, callback);
27351 });
27352
27353 /*
27354 * Unset properties on a user record (permanently removes the properties and their values from a profile).
27355 *
27356 * ### Usage:
27357 *
27358 * mixpanel.people.unset('gender');
27359 *
27360 * // or unset multiple properties at once
27361 * mixpanel.people.unset(['gender', 'Company']);
27362 *
27363 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
27364 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27365 */
27366 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
27367 var data = this.unset_action(prop);
27368 return this._send_request(data, callback);
27369 });
27370
27371 /*
27372 * Increment/decrement numeric people analytics properties.
27373 *
27374 * ### Usage:
27375 *
27376 * mixpanel.people.increment('page_views', 1);
27377 *
27378 * // or, for convenience, if you're just incrementing a counter by
27379 * // 1, you can simply do
27380 * mixpanel.people.increment('page_views');
27381 *
27382 * // to decrement a counter, pass a negative number
27383 * mixpanel.people.increment('credits_left', -1);
27384 *
27385 * // like mixpanel.people.set(), you can increment multiple
27386 * // properties at once:
27387 * mixpanel.people.increment({
27388 * counter1: 1,
27389 * counter2: 6
27390 * });
27391 *
27392 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and numeric values.
27393 * @param {Number} [by] An amount to increment the given property
27394 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27395 */
27396 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
27397 var data = {};
27398 var $add = {};
27399 if (_.isObject(prop)) {
27400 _.each(prop, function(v, k) {
27401 if (!this._is_reserved_property(k)) {
27402 if (isNaN(parseFloat(v))) {
27403 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
27404 return;
27405 } else {
27406 $add[k] = v;
27407 }
27408 }
27409 }, this);
27410 callback = by;
27411 } else {
27412 // convenience: mixpanel.people.increment('property'); will
27413 // increment 'property' by 1
27414 if (_.isUndefined(by)) {
27415 by = 1;
27416 }
27417 $add[prop] = by;
27418 }
27419 data[ADD_ACTION] = $add;
27420
27421 return this._send_request(data, callback);
27422 });
27423
27424 /*
27425 * Append a value to a list-valued people analytics property.
27426 *
27427 * ### Usage:
27428 *
27429 * // append a value to a list, creating it if needed
27430 * mixpanel.people.append('pages_visited', 'homepage');
27431 *
27432 * // like mixpanel.people.set(), you can append multiple
27433 * // properties at once:
27434 * mixpanel.people.append({
27435 * list1: 'bob',
27436 * list2: 123
27437 * });
27438 *
27439 * @param {Object|String} list_name If a string, this is the name of the property. If an object, this is an associative array of names and values.
27440 * @param {*} [value] value An item to append to the list
27441 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27442 */
27443 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
27444 if (_.isObject(list_name)) {
27445 callback = value;
27446 }
27447 var data = this.append_action(list_name, value);
27448 return this._send_request(data, callback);
27449 });
27450
27451 /*
27452 * Remove a value from a list-valued people analytics property.
27453 *
27454 * ### Usage:
27455 *
27456 * mixpanel.people.remove('School', 'UCB');
27457 *
27458 * @param {Object|String} list_name If a string, this is the name of the property. If an object, this is an associative array of names and values.
27459 * @param {*} [value] value Item to remove from the list
27460 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27461 */
27462 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
27463 if (_.isObject(list_name)) {
27464 callback = value;
27465 }
27466 var data = this.remove_action(list_name, value);
27467 return this._send_request(data, callback);
27468 });
27469
27470 /*
27471 * Merge a given list with a list-valued people analytics property,
27472 * excluding duplicate values.
27473 *
27474 * ### Usage:
27475 *
27476 * // merge a value to a list, creating it if needed
27477 * mixpanel.people.union('pages_visited', 'homepage');
27478 *
27479 * // like mixpanel.people.set(), you can append multiple
27480 * // properties at once:
27481 * mixpanel.people.union({
27482 * list1: 'bob',
27483 * list2: 123
27484 * });
27485 *
27486 * // like mixpanel.people.append(), you can append multiple
27487 * // values to the same list:
27488 * mixpanel.people.union({
27489 * list1: ['bob', 'billy']
27490 * });
27491 *
27492 * @param {Object|String} list_name If a string, this is the name of the property. If an object, this is an associative array of names and values.
27493 * @param {*} [value] Value / values to merge with the given property
27494 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27495 */
27496 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
27497 if (_.isObject(list_name)) {
27498 callback = values;
27499 }
27500 var data = this.union_action(list_name, values);
27501 return this._send_request(data, callback);
27502 });
27503
27504 /*
27505 * Record that you have charged the current user a certain amount
27506 * of money. Charges recorded with track_charge() will appear in the
27507 * Mixpanel revenue report.
27508 *
27509 * ### Usage:
27510 *
27511 * // charge a user $50
27512 * mixpanel.people.track_charge(50);
27513 *
27514 * // charge a user $30.50 on the 2nd of january
27515 * mixpanel.people.track_charge(30.50, {
27516 * '$time': new Date('jan 1 2012')
27517 * });
27518 *
27519 * @param {Number} amount The amount of money charged to the current user
27520 * @param {Object} [properties] An associative array of properties associated with the charge
27521 * @param {Function} [callback] If provided, the callback will be called when the server responds
27522 * @deprecated
27523 */
27524 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
27525 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
27526 });
27527
27528 /*
27529 * Permanently clear all revenue report transactions from the
27530 * current user's people analytics profile.
27531 *
27532 * ### Usage:
27533 *
27534 * mixpanel.people.clear_charges();
27535 *
27536 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27537 * @deprecated
27538 */
27539 MixpanelPeople.prototype.clear_charges = function(callback) {
27540 return this.set('$transactions', [], callback);
27541 };
27542
27543 /*
27544 * Permanently deletes the current people analytics profile from
27545 * Mixpanel (using the current distinct_id).
27546 *
27547 * ### Usage:
27548 *
27549 * // remove the all data you have stored about the current user
27550 * mixpanel.people.delete_user();
27551 *
27552 */
27553 MixpanelPeople.prototype.delete_user = function() {
27554 if (!this._identify_called()) {
27555 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
27556 return;
27557 }
27558 var data = {'$delete': this._mixpanel.get_distinct_id()};
27559 return this._send_request(data);
27560 };
27561
27562 MixpanelPeople.prototype.toString = function() {
27563 return this._mixpanel.toString() + '.people';
27564 };
27565
27566 MixpanelPeople.prototype._send_request = function(data, callback) {
27567 data['$token'] = this._get_config('token');
27568 data['$distinct_id'] = this._mixpanel.get_distinct_id();
27569 var device_id = this._mixpanel.get_property('$device_id');
27570 var user_id = this._mixpanel.get_property('$user_id');
27571 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
27572 if (device_id) {
27573 data['$device_id'] = device_id;
27574 }
27575 if (user_id) {
27576 data['$user_id'] = user_id;
27577 }
27578 if (had_persisted_distinct_id) {
27579 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
27580 }
27581
27582 var date_encoded_data = _.encodeDates(data);
27583
27584 if (!this._identify_called()) {
27585 this._enqueue(data);
27586 if (!_.isUndefined(callback)) {
27587 if (this._get_config('verbose')) {
27588 callback({status: -1, error: null});
27589 } else {
27590 callback(-1);
27591 }
27592 }
27593 return _.truncate(date_encoded_data, 255);
27594 }
27595
27596 return this._mixpanel._track_or_batch({
27597 type: 'people',
27598 data: date_encoded_data,
27599 endpoint: this._get_config('api_host') + '/' + this._get_config('api_routes')['engage'],
27600 batcher: this._mixpanel.request_batchers.people
27601 }, callback);
27602 };
27603
27604 MixpanelPeople.prototype._get_config = function(conf_var) {
27605 return this._mixpanel.get_config(conf_var);
27606 };
27607
27608 MixpanelPeople.prototype._identify_called = function() {
27609 return this._mixpanel._flags.identify_called === true;
27610 };
27611
27612 // Queue up engage operations if identify hasn't been called yet.
27613 MixpanelPeople.prototype._enqueue = function(data) {
27614 if (SET_ACTION in data) {
27615 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
27616 } else if (SET_ONCE_ACTION in data) {
27617 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
27618 } else if (UNSET_ACTION in data) {
27619 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
27620 } else if (ADD_ACTION in data) {
27621 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
27622 } else if (APPEND_ACTION in data) {
27623 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
27624 } else if (REMOVE_ACTION in data) {
27625 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
27626 } else if (UNION_ACTION in data) {
27627 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
27628 } else {
27629 console$1.error('Invalid call to _enqueue():', data);
27630 }
27631 };
27632
27633 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
27634 var _this = this;
27635 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
27636 var action_params = queued_data;
27637
27638 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
27639 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
27640 _this._mixpanel['persistence'].save();
27641 if (queue_to_params_fn) {
27642 action_params = queue_to_params_fn(queued_data);
27643 }
27644 action_method.call(_this, action_params, function(response, data) {
27645 // on bad response, we want to add it back to the queue
27646 if (response === 0) {
27647 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
27648 }
27649 if (!_.isUndefined(callback)) {
27650 callback(response, data);
27651 }
27652 });
27653 }
27654 };
27655
27656 // Flush queued engage operations - order does not matter,
27657 // and there are network level race conditions anyway
27658 MixpanelPeople.prototype._flush = function(
27659 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
27660 ) {
27661 var _this = this;
27662
27663 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
27664 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
27665 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
27666 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
27667 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
27668
27669 // we have to fire off each $append individually since there is
27670 // no concat method server side
27671 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
27672 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
27673 var $append_item;
27674 var append_callback = function(response, data) {
27675 if (response === 0) {
27676 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
27677 }
27678 if (!_.isUndefined(_append_callback)) {
27679 _append_callback(response, data);
27680 }
27681 };
27682 for (var i = $append_queue.length - 1; i >= 0; i--) {
27683 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
27684 $append_item = $append_queue.pop();
27685 _this._mixpanel['persistence'].save();
27686 if (!_.isEmptyObject($append_item)) {
27687 _this.append($append_item, append_callback);
27688 }
27689 }
27690 }
27691
27692 // same for $remove
27693 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
27694 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
27695 var $remove_item;
27696 var remove_callback = function(response, data) {
27697 if (response === 0) {
27698 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
27699 }
27700 if (!_.isUndefined(_remove_callback)) {
27701 _remove_callback(response, data);
27702 }
27703 };
27704 for (var j = $remove_queue.length - 1; j >= 0; j--) {
27705 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
27706 $remove_item = $remove_queue.pop();
27707 _this._mixpanel['persistence'].save();
27708 if (!_.isEmptyObject($remove_item)) {
27709 _this.remove($remove_item, remove_callback);
27710 }
27711 }
27712 }
27713 };
27714
27715 MixpanelPeople.prototype._is_reserved_property = function(prop) {
27716 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
27717 };
27718
27719 // MixpanelPeople Exports
27720 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
27721 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
27722 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
27723 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
27724 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
27725 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
27726 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
27727 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
27728 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
27729 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
27730 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
27731
27732 /* eslint camelcase: "off" */
27733
27734
27735 /*
27736 * Constants
27737 */
27738 /** @const */ var SET_QUEUE_KEY = '__mps';
27739 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
27740 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
27741 /** @const */ var ADD_QUEUE_KEY = '__mpa';
27742 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
27743 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
27744 /** @const */ var UNION_QUEUE_KEY = '__mpu';
27745 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
27746 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
27747 /** @const */ var ALIAS_ID_KEY = '__alias';
27748 /** @const */ var EVENT_TIMERS_KEY = '__timers';
27749 /** @const */ var RESERVED_PROPERTIES = [
27750 SET_QUEUE_KEY,
27751 SET_ONCE_QUEUE_KEY,
27752 UNSET_QUEUE_KEY,
27753 ADD_QUEUE_KEY,
27754 APPEND_QUEUE_KEY,
27755 REMOVE_QUEUE_KEY,
27756 UNION_QUEUE_KEY,
27757 PEOPLE_DISTINCT_ID_KEY,
27758 ALIAS_ID_KEY,
27759 EVENT_TIMERS_KEY
27760 ];
27761
27762 /**
27763 * Mixpanel Persistence Object
27764 * @constructor
27765 */
27766 var MixpanelPersistence = function(config) {
27767 this['props'] = {};
27768 this.campaign_params_saved = false;
27769
27770 if (config['persistence_name']) {
27771 this.name = 'mp_' + config['persistence_name'];
27772 } else {
27773 this.name = 'mp_' + config['token'] + '_mixpanel';
27774 }
27775
27776 var storage_type = config['persistence'];
27777 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
27778 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
27779 storage_type = config['persistence'] = 'cookie';
27780 }
27781
27782 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
27783 this.storage = _.localStorage;
27784 } else {
27785 this.storage = _.cookie;
27786 }
27787
27788 this.load();
27789 this.update_config(config);
27790 this.upgrade();
27791 this.save();
27792 };
27793
27794 MixpanelPersistence.prototype.properties = function() {
27795 var p = {};
27796
27797 this.load();
27798
27799 // Filter out reserved properties
27800 _.each(this['props'], function(v, k) {
27801 if (!_.include(RESERVED_PROPERTIES, k)) {
27802 p[k] = v;
27803 }
27804 });
27805 return p;
27806 };
27807
27808 MixpanelPersistence.prototype.load = function() {
27809 if (this.disabled) { return; }
27810
27811 var entry = this.storage.parse(this.name);
27812
27813 if (entry) {
27814 this['props'] = _.extend({}, entry);
27815 }
27816 };
27817
27818 MixpanelPersistence.prototype.upgrade = function() {
27819 var old_cookie,
27820 old_localstorage;
27821
27822 // if transferring from cookie to localStorage or vice-versa, copy existing
27823 // super properties over to new storage mode
27824 if (this.storage === _.localStorage) {
27825 old_cookie = _.cookie.parse(this.name);
27826
27827 _.cookie.remove(this.name);
27828 _.cookie.remove(this.name, true);
27829
27830 if (old_cookie) {
27831 this.register_once(old_cookie);
27832 }
27833 } else if (this.storage === _.cookie) {
27834 old_localstorage = _.localStorage.parse(this.name);
27835
27836 _.localStorage.remove(this.name);
27837
27838 if (old_localstorage) {
27839 this.register_once(old_localstorage);
27840 }
27841 }
27842 };
27843
27844 MixpanelPersistence.prototype.save = function() {
27845 if (this.disabled) { return; }
27846
27847 this.storage.set(
27848 this.name,
27849 JSONStringify(this['props']),
27850 this.expire_days,
27851 this.cross_subdomain,
27852 this.secure,
27853 this.cross_site,
27854 this.cookie_domain
27855 );
27856 };
27857
27858 MixpanelPersistence.prototype.load_prop = function(key) {
27859 this.load();
27860 return this['props'][key];
27861 };
27862
27863 MixpanelPersistence.prototype.remove = function() {
27864 // remove both domain and subdomain cookies
27865 this.storage.remove(this.name, false, this.cookie_domain);
27866 this.storage.remove(this.name, true, this.cookie_domain);
27867 };
27868
27869 // removes the storage entry and deletes all loaded data
27870 // forced name for tests
27871 MixpanelPersistence.prototype.clear = function() {
27872 this.remove();
27873 this['props'] = {};
27874 };
27875
27876 /**
27877 * @param {Object} props
27878 * @param {*=} default_value
27879 * @param {number=} days
27880 */
27881 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
27882 if (_.isObject(props)) {
27883 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
27884 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
27885
27886 this.load();
27887
27888 _.each(props, function(val, prop) {
27889 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
27890 this['props'][prop] = val;
27891 }
27892 }, this);
27893
27894 this.save();
27895
27896 return true;
27897 }
27898 return false;
27899 };
27900
27901 /**
27902 * @param {Object} props
27903 * @param {number=} days
27904 */
27905 MixpanelPersistence.prototype.register = function(props, days) {
27906 if (_.isObject(props)) {
27907 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
27908
27909 this.load();
27910 _.extend(this['props'], props);
27911 this.save();
27912
27913 return true;
27914 }
27915 return false;
27916 };
27917
27918 MixpanelPersistence.prototype.unregister = function(prop) {
27919 this.load();
27920 if (prop in this['props']) {
27921 delete this['props'][prop];
27922 this.save();
27923 }
27924 };
27925
27926 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
27927 this.register(_.info.searchInfo(referrer));
27928 };
27929
27930 // EXPORTED METHOD, we test this directly.
27931 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
27932 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
27933 this.register_once({
27934 '$initial_referrer': referrer || '$direct',
27935 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
27936 }, '');
27937 };
27938
27939 MixpanelPersistence.prototype.get_referrer_info = function() {
27940 return _.strip_empty_properties({
27941 '$initial_referrer': this['props']['$initial_referrer'],
27942 '$initial_referring_domain': this['props']['$initial_referring_domain']
27943 });
27944 };
27945
27946 MixpanelPersistence.prototype.update_config = function(config) {
27947 this.default_expiry = this.expire_days = config['cookie_expiration'];
27948 this.set_disabled(config['disable_persistence']);
27949 this.set_cookie_domain(config['cookie_domain']);
27950 this.set_cross_site(config['cross_site_cookie']);
27951 this.set_cross_subdomain(config['cross_subdomain_cookie']);
27952 this.set_secure(config['secure_cookie']);
27953 };
27954
27955 MixpanelPersistence.prototype.set_disabled = function(disabled) {
27956 this.disabled = disabled;
27957 if (this.disabled) {
27958 this.remove();
27959 } else {
27960 this.save();
27961 }
27962 };
27963
27964 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
27965 if (cookie_domain !== this.cookie_domain) {
27966 this.remove();
27967 this.cookie_domain = cookie_domain;
27968 this.save();
27969 }
27970 };
27971
27972 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
27973 if (cross_site !== this.cross_site) {
27974 this.cross_site = cross_site;
27975 this.remove();
27976 this.save();
27977 }
27978 };
27979
27980 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
27981 if (cross_subdomain !== this.cross_subdomain) {
27982 this.cross_subdomain = cross_subdomain;
27983 this.remove();
27984 this.save();
27985 }
27986 };
27987
27988 MixpanelPersistence.prototype.get_cross_subdomain = function() {
27989 return this.cross_subdomain;
27990 };
27991
27992 MixpanelPersistence.prototype.set_secure = function(secure) {
27993 if (secure !== this.secure) {
27994 this.secure = secure ? true : false;
27995 this.remove();
27996 this.save();
27997 }
27998 };
27999
28000 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
28001 var q_key = this._get_queue_key(queue),
28002 q_data = data[queue],
28003 set_q = this._get_or_create_queue(SET_ACTION),
28004 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
28005 unset_q = this._get_or_create_queue(UNSET_ACTION),
28006 add_q = this._get_or_create_queue(ADD_ACTION),
28007 union_q = this._get_or_create_queue(UNION_ACTION),
28008 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
28009 append_q = this._get_or_create_queue(APPEND_ACTION, []);
28010
28011 if (q_key === SET_QUEUE_KEY) {
28012 // Update the set queue - we can override any existing values
28013 _.extend(set_q, q_data);
28014 // if there was a pending increment, override it
28015 // with the set.
28016 this._pop_from_people_queue(ADD_ACTION, q_data);
28017 // if there was a pending union, override it
28018 // with the set.
28019 this._pop_from_people_queue(UNION_ACTION, q_data);
28020 this._pop_from_people_queue(UNSET_ACTION, q_data);
28021 } else if (q_key === SET_ONCE_QUEUE_KEY) {
28022 // only queue the data if there is not already a set_once call for it.
28023 _.each(q_data, function(v, k) {
28024 if (!(k in set_once_q)) {
28025 set_once_q[k] = v;
28026 }
28027 });
28028 this._pop_from_people_queue(UNSET_ACTION, q_data);
28029 } else if (q_key === UNSET_QUEUE_KEY) {
28030 _.each(q_data, function(prop) {
28031
28032 // undo previously-queued actions on this key
28033 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
28034 if (prop in enqueued_obj) {
28035 delete enqueued_obj[prop];
28036 }
28037 });
28038 _.each(append_q, function(append_obj) {
28039 if (prop in append_obj) {
28040 delete append_obj[prop];
28041 }
28042 });
28043
28044 unset_q[prop] = true;
28045
28046 });
28047 } else if (q_key === ADD_QUEUE_KEY) {
28048 _.each(q_data, function(v, k) {
28049 // If it exists in the set queue, increment
28050 // the value
28051 if (k in set_q) {
28052 set_q[k] += v;
28053 } else {
28054 // If it doesn't exist, update the add
28055 // queue
28056 if (!(k in add_q)) {
28057 add_q[k] = 0;
28058 }
28059 add_q[k] += v;
28060 }
28061 }, this);
28062 this._pop_from_people_queue(UNSET_ACTION, q_data);
28063 } else if (q_key === UNION_QUEUE_KEY) {
28064 _.each(q_data, function(v, k) {
28065 if (_.isArray(v)) {
28066 if (!(k in union_q)) {
28067 union_q[k] = [];
28068 }
28069 // Prevent duplicate values
28070 _.each(v, function(item) {
28071 if (!_.include(union_q[k], item)) {
28072 union_q[k].push(item);
28073 }
28074 });
28075 }
28076 });
28077 this._pop_from_people_queue(UNSET_ACTION, q_data);
28078 } else if (q_key === REMOVE_QUEUE_KEY) {
28079 remove_q.push(q_data);
28080 this._pop_from_people_queue(APPEND_ACTION, q_data);
28081 } else if (q_key === APPEND_QUEUE_KEY) {
28082 append_q.push(q_data);
28083 this._pop_from_people_queue(UNSET_ACTION, q_data);
28084 }
28085
28086 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
28087 console$1.log(data);
28088
28089 this.save();
28090 };
28091
28092 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
28093 var q = this['props'][this._get_queue_key(queue)];
28094 if (!_.isUndefined(q)) {
28095 _.each(data, function(v, k) {
28096 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
28097 // list actions: only remove if both k+v match
28098 // e.g. remove should not override append in a case like
28099 // append({foo: 'bar'}); remove({foo: 'qux'})
28100 _.each(q, function(queued_action) {
28101 if (queued_action[k] === v) {
28102 delete queued_action[k];
28103 }
28104 });
28105 } else {
28106 delete q[k];
28107 }
28108 }, this);
28109 }
28110 };
28111
28112 MixpanelPersistence.prototype.load_queue = function(queue) {
28113 return this.load_prop(this._get_queue_key(queue));
28114 };
28115
28116 MixpanelPersistence.prototype._get_queue_key = function(queue) {
28117 if (queue === SET_ACTION) {
28118 return SET_QUEUE_KEY;
28119 } else if (queue === SET_ONCE_ACTION) {
28120 return SET_ONCE_QUEUE_KEY;
28121 } else if (queue === UNSET_ACTION) {
28122 return UNSET_QUEUE_KEY;
28123 } else if (queue === ADD_ACTION) {
28124 return ADD_QUEUE_KEY;
28125 } else if (queue === APPEND_ACTION) {
28126 return APPEND_QUEUE_KEY;
28127 } else if (queue === REMOVE_ACTION) {
28128 return REMOVE_QUEUE_KEY;
28129 } else if (queue === UNION_ACTION) {
28130 return UNION_QUEUE_KEY;
28131 } else {
28132 console$1.error('Invalid queue:', queue);
28133 }
28134 };
28135
28136 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
28137 var key = this._get_queue_key(queue);
28138 default_val = _.isUndefined(default_val) ? {} : default_val;
28139 return this['props'][key] || (this['props'][key] = default_val);
28140 };
28141
28142 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
28143 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
28144 timers[event_name] = timestamp;
28145 this['props'][EVENT_TIMERS_KEY] = timers;
28146 this.save();
28147 };
28148
28149 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
28150 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
28151 var timestamp = timers[event_name];
28152 if (!_.isUndefined(timestamp)) {
28153 delete this['props'][EVENT_TIMERS_KEY][event_name];
28154 this.save();
28155 }
28156 return timestamp;
28157 };
28158
28159 /* eslint camelcase: "off" */
28160
28161 /*
28162 * Mixpanel JS Library
28163 *
28164 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
28165 * http://mixpanel.com/
28166 *
28167 * Includes portions of Underscore.js
28168 * http://documentcloud.github.com/underscore/
28169 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
28170 * Released under the MIT License.
28171 */
28172
28173 /*
28174 SIMPLE STYLE GUIDE:
28175
28176 this.x === public function
28177 this._x === internal - only use within this file
28178 this.__x === private - only use within the class
28179
28180 Globals should be all caps
28181 */
28182
28183 var init_type; // MODULE or SNIPPET loader
28184 // allow bundlers to specify how extra code (recorder bundle) should be loaded
28185 // eslint-disable-next-line no-unused-vars
28186 var load_extra_bundle = function(src, _onload) {
28187 throw new Error(src + ' not available in this build.');
28188 };
28189
28190 var mixpanel_master; // main mixpanel instance / object
28191 var INIT_MODULE = 0;
28192 var INIT_SNIPPET = 1;
28193
28194 var IDENTITY_FUNC = function(x) {return x;};
28195
28196 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
28197 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
28198 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
28199 /** @const */ var DEVICE_ID_PREFIX = '$device:';
28200
28201
28202 /*
28203 * Dynamic... constants? Is that an oxymoron?
28204 */
28205 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
28206 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
28207 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
28208
28209 // IE<10 does not support cross-origin XHR's but script tags
28210 // with defer won't block window.onload; ENQUEUE_REQUESTS
28211 // should only be true for Opera<12
28212 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
28213
28214 // save reference to navigator.sendBeacon so it can be minified
28215 var sendBeacon = null;
28216 if (navigator['sendBeacon']) {
28217 sendBeacon = function() {
28218 // late reference to navigator.sendBeacon to allow patching/spying
28219 return navigator['sendBeacon'].apply(navigator, arguments);
28220 };
28221 }
28222
28223 var DEFAULT_API_ROUTES = {
28224 'track': 'track/',
28225 'engage': 'engage/',
28226 'groups': 'groups/',
28227 'record': 'record/',
28228 'flags': 'flags/'
28229 };
28230
28231 /*
28232 * Module-level globals
28233 */
28234 var DEFAULT_CONFIG = {
28235 'api_host': 'https://api-js.mixpanel.com',
28236 'api_routes': DEFAULT_API_ROUTES,
28237 'api_extra_query_params': {},
28238 'api_method': 'POST',
28239 'api_transport': 'XHR',
28240 'api_payload_format': PAYLOAD_TYPE_BASE64,
28241 'app_host': 'https://mixpanel.com',
28242 'autocapture': false,
28243 'cdn': 'https://cdn.mxpnl.com',
28244 'cross_site_cookie': false,
28245 'cross_subdomain_cookie': true,
28246 'error_reporter': NOOP_FUNC,
28247 'flags': false,
28248 'persistence': 'cookie',
28249 'persistence_name': '',
28250 'cookie_domain': '',
28251 'cookie_name': '',
28252 'loaded': NOOP_FUNC,
28253 'mp_loader': null,
28254 'track_marketing': true,
28255 'track_pageview': false,
28256 'skip_first_touch_marketing': false,
28257 'store_google': true,
28258 'stop_utm_persistence': false,
28259 'save_referrer': true,
28260 'test': false,
28261 'verbose': false,
28262 'img': false,
28263 'debug': false,
28264 'track_links_timeout': 300,
28265 'cookie_expiration': 365,
28266 'upgrade': false,
28267 'disable_persistence': false,
28268 'disable_cookie': false,
28269 'secure_cookie': false,
28270 'ip': true,
28271 'opt_out_tracking_by_default': false,
28272 'opt_out_persistence_by_default': false,
28273 'opt_out_tracking_persistence_type': 'localStorage',
28274 'opt_out_tracking_cookie_prefix': null,
28275 'property_blacklist': [],
28276 'xhr_headers': {}, // { header: value, header2: value }
28277 'ignore_dnt': false,
28278 'batch_requests': true,
28279 'batch_size': 50,
28280 'batch_flush_interval_ms': 5000,
28281 'batch_request_timeout_ms': 90000,
28282 'batch_autostart': true,
28283 'hooks': {},
28284 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
28285 'record_block_selector': 'img, video',
28286 'record_canvas': false,
28287 'record_collect_fonts': false,
28288 'record_heatmap_data': false,
28289 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
28290 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
28291 'record_mask_text_selector': '*',
28292 'record_max_ms': MAX_RECORDING_MS,
28293 'record_min_ms': 0,
28294 'record_sessions_percent': 0,
28295 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
28296 };
28297
28298 var DOM_LOADED = false;
28299
28300 /**
28301 * Mixpanel Library Object
28302 * @constructor
28303 */
28304 var MixpanelLib = function() {};
28305
28306
28307 /**
28308 * create_mplib(token:string, config:object, name:string)
28309 *
28310 * This function is used by the init method of MixpanelLib objects
28311 * as well as the main initializer at the end of the JSLib (that
28312 * initializes document.mixpanel as well as any additional instances
28313 * declared before this file has loaded).
28314 */
28315 var create_mplib = function(token, config, name) {
28316 var instance,
28317 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
28318
28319 if (target && init_type === INIT_MODULE) {
28320 instance = target;
28321 } else {
28322 if (target && !_.isArray(target)) {
28323 console$1.error('You have already initialized ' + name);
28324 return;
28325 }
28326 instance = new MixpanelLib();
28327 }
28328
28329 instance._cached_groups = {}; // cache groups in a pool
28330
28331 instance._init(token, config, name);
28332
28333 instance['people'] = new MixpanelPeople();
28334 instance['people']._init(instance);
28335
28336 if (!instance.get_config('skip_first_touch_marketing')) {
28337 // We need null UTM params in the object because
28338 // UTM parameters act as a tuple. If any UTM param
28339 // is present, then we set all UTM params including
28340 // empty ones together
28341 var utm_params = _.info.campaignParams(null);
28342 var initial_utm_params = {};
28343 var has_utm = false;
28344 _.each(utm_params, function(utm_value, utm_key) {
28345 initial_utm_params['initial_' + utm_key] = utm_value;
28346 if (utm_value) {
28347 has_utm = true;
28348 }
28349 });
28350 if (has_utm) {
28351 instance['people'].set_once(initial_utm_params);
28352 }
28353 }
28354
28355 // if any instance on the page has debug = true, we set the
28356 // global debug to be true
28357 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
28358
28359 // if target is not defined, we called init after the lib already
28360 // loaded, so there won't be an array of things to execute
28361 if (!_.isUndefined(target) && _.isArray(target)) {
28362 // Crunch through the people queue first - we queue this data up &
28363 // flush on identify, so it's better to do all these operations first
28364 instance._execute_array.call(instance['people'], target['people']);
28365 instance._execute_array(target);
28366 }
28367
28368 return instance;
28369 };
28370
28371 // Initialization methods
28372
28373 /**
28374 * This function initializes a new instance of the Mixpanel tracking object.
28375 * All new instances are added to the main mixpanel object as sub properties (such as
28376 * mixpanel.library_name) and also returned by this function. To define a
28377 * second instance on the page, you would call:
28378 *
28379 * mixpanel.init('new token', { your: 'config' }, 'library_name');
28380 *
28381 * and use it like so:
28382 *
28383 * mixpanel.library_name.track(...);
28384 *
28385 * @param {String} token Your Mixpanel API token
28386 * @param {Object} [config] A dictionary of config options to override. <a href="https://github.com/mixpanel/mixpanel-js/blob/v2.46.0/src/mixpanel-core.js#L88-L127">See a list of default config options</a>.
28387 * @param {String} [name] The name for the new mixpanel instance that you want created
28388 */
28389 MixpanelLib.prototype.init = function (token, config, name) {
28390 if (_.isUndefined(name)) {
28391 this.report_error('You must name your new library: init(token, config, name)');
28392 return;
28393 }
28394 if (name === PRIMARY_INSTANCE_NAME) {
28395 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
28396 return;
28397 }
28398
28399 var instance = create_mplib(token, config, name);
28400 mixpanel_master[name] = instance;
28401 instance._loaded();
28402
28403 return instance;
28404 };
28405
28406 // mixpanel._init(token:string, config:object, name:string)
28407 //
28408 // This function sets up the current instance of the mixpanel
28409 // library. The difference between this method and the init(...)
28410 // method is this one initializes the actual instance, whereas the
28411 // init(...) method sets up a new library and calls _init on it.
28412 //
28413 MixpanelLib.prototype._init = function(token, config, name) {
28414 config = config || {};
28415
28416 this['__loaded'] = true;
28417 this['config'] = {};
28418
28419 var variable_features = {};
28420
28421 // default to JSON payload for standard mixpanel.com API hosts
28422 if (!('api_payload_format' in config)) {
28423 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
28424 if (api_host.match(/\.mixpanel\.com/)) {
28425 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
28426 }
28427 }
28428
28429 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
28430 'name': name,
28431 'token': token,
28432 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
28433 }));
28434
28435 this['_jsc'] = NOOP_FUNC;
28436
28437 this.__dom_loaded_queue = [];
28438 this.__request_queue = [];
28439 this.__disabled_events = [];
28440 this._flags = {
28441 'disable_all_events': false,
28442 'identify_called': false
28443 };
28444
28445 // set up request queueing/batching
28446 this.request_batchers = {};
28447 this._batch_requests = this.get_config('batch_requests');
28448 if (this._batch_requests) {
28449 if (!_.localStorage.is_supported(true) || !USE_XHR) {
28450 this._batch_requests = false;
28451 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
28452 _.each(this.get_batcher_configs(), function(batcher_config) {
28453 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
28454 _.localStorage.remove(batcher_config.queue_key);
28455 });
28456 } else {
28457 this.init_batchers();
28458 if (sendBeacon && win.addEventListener) {
28459 // Before page closes or hides (user tabs away etc), attempt to flush any events
28460 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
28461 // events will not be removed from the persistent store; if the site is loaded again,
28462 // the events will be flushed again on startup and deduplicated on the Mixpanel server
28463 // side.
28464 // There is no reliable way to capture only page close events, so we lean on the
28465 // visibilitychange and pagehide events as recommended at
28466 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
28467 // These events fire when the user clicks away from the current page/tab, so will occur
28468 // more frequently than page unload, but are the only mechanism currently for capturing
28469 // this scenario somewhat reliably.
28470 var flush_on_unload = _.bind(function() {
28471 if (!this.request_batchers.events.stopped) {
28472 this.request_batchers.events.flush({unloading: true});
28473 }
28474 }, this);
28475 win.addEventListener('pagehide', function(ev) {
28476 if (ev['persisted']) {
28477 flush_on_unload();
28478 }
28479 });
28480 win.addEventListener('visibilitychange', function() {
28481 if (document$1['visibilityState'] === 'hidden') {
28482 flush_on_unload();
28483 }
28484 });
28485 }
28486 }
28487 }
28488
28489 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
28490 this.unpersisted_superprops = {};
28491 this._gdpr_init();
28492
28493 var uuid = _.UUID();
28494 if (!this.get_distinct_id()) {
28495 // There is no need to set the distinct id
28496 // or the device id if something was already stored
28497 // in the persitence
28498 this.register_once({
28499 'distinct_id': DEVICE_ID_PREFIX + uuid,
28500 '$device_id': uuid
28501 }, '');
28502 }
28503
28504 this.flags = new FeatureFlagManager({
28505 getConfigFunc: _.bind(this.get_config, this),
28506 getDistinctIdFunc: _.bind(this.get_distinct_id, this),
28507 trackingFunc: _.bind(this.track, this)
28508 });
28509 this.flags.init();
28510 this['flags'] = this.flags;
28511
28512 this.autocapture = new Autocapture(this);
28513 this.autocapture.init();
28514
28515 this._init_tab_id();
28516 this._check_and_start_session_recording();
28517 };
28518
28519 /**
28520 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
28521 * This is primarily used for session recording, where data must be isolated to the current tab.
28522 */
28523 MixpanelLib.prototype._init_tab_id = function() {
28524 if (_.sessionStorage.is_supported()) {
28525 try {
28526 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
28527 var tab_id_key = 'mp_tab_id_' + key_suffix;
28528
28529 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
28530 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
28531 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
28532 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
28533 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
28534 }
28535
28536 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
28537 this.tab_id = _.sessionStorage.get(tab_id_key);
28538
28539 // Remove the flag when the tab is unloaded to indicate the stored tab ID can be reused. This event is not reliable to detect all page unloads,
28540 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
28541 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
28542 win.addEventListener('beforeunload', function () {
28543 _.sessionStorage.remove(should_generate_new_tab_id_key);
28544 });
28545 } catch(err) {
28546 this.report_error('Error initializing tab id', err);
28547 }
28548 } else {
28549 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
28550 }
28551 };
28552
28553 MixpanelLib.prototype.get_tab_id = function () {
28554 return this.tab_id || null;
28555 };
28556
28557 MixpanelLib.prototype._should_load_recorder = function () {
28558 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
28559 var tab_id = this.get_tab_id();
28560 return recording_registry_idb.init()
28561 .then(function () {
28562 return recording_registry_idb.getAll();
28563 })
28564 .then(function (recordings) {
28565 for (var i = 0; i < recordings.length; i++) {
28566 // if there are expired recordings in the registry, we should load the recorder to flush them
28567 // if there's a recording for this tab id, we should load the recorder to continue the recording
28568 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
28569 return true;
28570 }
28571 }
28572 return false;
28573 })
28574 .catch(_.bind(function (err) {
28575 this.report_error('Error checking recording registry', err);
28576 }, this));
28577 };
28578
28579 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
28580 if (!win['MutationObserver']) {
28581 console$1.critical('Browser does not support MutationObserver; skipping session recording');
28582 return;
28583 }
28584
28585 var loadRecorder = _.bind(function(startNewIfInactive) {
28586 var handleLoadedRecorder = _.bind(function() {
28587 this._recorder = this._recorder || new win['__mp_recorder'](this);
28588 this._recorder['resumeRecording'](startNewIfInactive);
28589 }, this);
28590
28591 if (_.isUndefined(win['__mp_recorder'])) {
28592 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
28593 } else {
28594 handleLoadedRecorder();
28595 }
28596 }, this);
28597
28598 /**
28599 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
28600 * Otherwise, if the recording registry has any records then it's likely there's a recording in progress or orphaned data that needs to be flushed.
28601 */
28602 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
28603 if (force_start || is_sampled) {
28604 loadRecorder(true);
28605 } else {
28606 this._should_load_recorder()
28607 .then(function (shouldLoad) {
28608 if (shouldLoad) {
28609 loadRecorder(false);
28610 }
28611 });
28612 }
28613 });
28614
28615 MixpanelLib.prototype.start_session_recording = function () {
28616 this._check_and_start_session_recording(true);
28617 };
28618
28619 MixpanelLib.prototype.stop_session_recording = function () {
28620 if (this._recorder) {
28621 this._recorder['stopRecording']();
28622 }
28623 };
28624
28625 MixpanelLib.prototype.pause_session_recording = function () {
28626 if (this._recorder) {
28627 this._recorder['pauseRecording']();
28628 }
28629 };
28630
28631 MixpanelLib.prototype.resume_session_recording = function () {
28632 if (this._recorder) {
28633 this._recorder['resumeRecording']();
28634 }
28635 };
28636
28637 MixpanelLib.prototype.is_recording_heatmap_data = function () {
28638 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
28639 };
28640
28641 MixpanelLib.prototype.get_session_recording_properties = function () {
28642 var props = {};
28643 var replay_id = this._get_session_replay_id();
28644 if (replay_id) {
28645 props['$mp_replay_id'] = replay_id;
28646 }
28647 return props;
28648 };
28649
28650 MixpanelLib.prototype.get_session_replay_url = function () {
28651 var replay_url = null;
28652 var replay_id = this._get_session_replay_id();
28653 if (replay_id) {
28654 var query_params = _.HTTPBuildQuery({
28655 'replay_id': replay_id,
28656 'distinct_id': this.get_distinct_id(),
28657 'token': this.get_config('token')
28658 });
28659 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
28660 }
28661 return replay_url;
28662 };
28663
28664 MixpanelLib.prototype._get_session_replay_id = function () {
28665 var replay_id = null;
28666 if (this._recorder) {
28667 replay_id = this._recorder['replayId'];
28668 }
28669 return replay_id || null;
28670 };
28671
28672 // "private" public method to reach into the recorder in test cases
28673 MixpanelLib.prototype.__get_recorder = function () {
28674 return this._recorder;
28675 };
28676
28677 // Private methods
28678
28679 MixpanelLib.prototype._loaded = function() {
28680 this.get_config('loaded')(this);
28681 this._set_default_superprops();
28682 this['people'].set_once(this['persistence'].get_referrer_info());
28683
28684 // `store_google` is now deprecated and previously stored UTM parameters are cleared
28685 // from persistence by default.
28686 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
28687 var utm_params = _.info.campaignParams(null);
28688 _.each(utm_params, function(_utm_value, utm_key) {
28689 // We need to unregister persisted UTM parameters so old values
28690 // are not mixed with the new UTM parameters
28691 this.unregister(utm_key);
28692 }.bind(this));
28693 }
28694 };
28695
28696 // update persistence with info on referrer, UTM params, etc
28697 MixpanelLib.prototype._set_default_superprops = function() {
28698 this['persistence'].update_search_keyword(document$1.referrer);
28699 // Registering super properties for UTM persistence by 'store_google' is deprecated.
28700 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
28701 this.register(_.info.campaignParams());
28702 }
28703 if (this.get_config('save_referrer')) {
28704 this['persistence'].update_referrer_info(document$1.referrer);
28705 }
28706 };
28707
28708 MixpanelLib.prototype._dom_loaded = function() {
28709 _.each(this.__dom_loaded_queue, function(item) {
28710 this._track_dom.apply(this, item);
28711 }, this);
28712
28713 if (!this.has_opted_out_tracking()) {
28714 _.each(this.__request_queue, function(item) {
28715 this._send_request.apply(this, item);
28716 }, this);
28717 }
28718
28719 delete this.__dom_loaded_queue;
28720 delete this.__request_queue;
28721 };
28722
28723 MixpanelLib.prototype._track_dom = function(DomClass, args) {
28724 if (this.get_config('img')) {
28725 this.report_error('You can\'t use DOM tracking functions with img = true.');
28726 return false;
28727 }
28728
28729 if (!DOM_LOADED) {
28730 this.__dom_loaded_queue.push([DomClass, args]);
28731 return false;
28732 }
28733
28734 var dt = new DomClass().init(this);
28735 return dt.track.apply(dt, args);
28736 };
28737
28738 /**
28739 * _prepare_callback() should be called by callers of _send_request for use
28740 * as the callback argument.
28741 *
28742 * If there is no callback, this returns null.
28743 * If we are going to make XHR/XDR requests, this returns a function.
28744 * If we are going to use script tags, this returns a string to use as the
28745 * callback GET param.
28746 */
28747 MixpanelLib.prototype._prepare_callback = function(callback, data) {
28748 if (_.isUndefined(callback)) {
28749 return null;
28750 }
28751
28752 if (USE_XHR) {
28753 var callback_function = function(response) {
28754 callback(response, data);
28755 };
28756 return callback_function;
28757 } else {
28758 // if the user gives us a callback, we store as a random
28759 // property on this instances jsc function and update our
28760 // callback string to reflect that.
28761 var jsc = this['_jsc'];
28762 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
28763 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
28764 jsc[randomized_cb] = function(response) {
28765 delete jsc[randomized_cb];
28766 callback(response, data);
28767 };
28768 return callback_string;
28769 }
28770 };
28771
28772 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
28773 var succeeded = true;
28774
28775 if (ENQUEUE_REQUESTS) {
28776 this.__request_queue.push(arguments);
28777 return succeeded;
28778 }
28779
28780 var DEFAULT_OPTIONS = {
28781 method: this.get_config('api_method'),
28782 transport: this.get_config('api_transport'),
28783 verbose: this.get_config('verbose')
28784 };
28785 var body_data = null;
28786
28787 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
28788 callback = options;
28789 options = null;
28790 }
28791 options = _.extend(DEFAULT_OPTIONS, options || {});
28792 if (!USE_XHR) {
28793 options.method = 'GET';
28794 }
28795 var use_post = options.method === 'POST';
28796 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
28797
28798 // needed to correctly format responses
28799 var verbose_mode = options.verbose;
28800 if (data['verbose']) { verbose_mode = true; }
28801
28802 if (this.get_config('test')) { data['test'] = 1; }
28803 if (verbose_mode) { data['verbose'] = 1; }
28804 if (this.get_config('img')) { data['img'] = 1; }
28805 if (!USE_XHR) {
28806 if (callback) {
28807 data['callback'] = callback;
28808 } else if (verbose_mode || this.get_config('test')) {
28809 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
28810 // which by itself is not valid javascript. Without a callback, this verbose output will
28811 // cause an error when returned via jsonp, so we force a no-op callback param.
28812 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
28813 data['callback'] = '(function(){})';
28814 }
28815 }
28816
28817 data['ip'] = this.get_config('ip')?1:0;
28818 data['_'] = new Date().getTime().toString();
28819
28820 if (use_post) {
28821 body_data = 'data=' + encodeURIComponent(data['data']);
28822 delete data['data'];
28823 }
28824
28825 _.extend(data, this.get_config('api_extra_query_params'));
28826
28827 url += '?' + _.HTTPBuildQuery(data);
28828
28829 var lib = this;
28830 if ('img' in data) {
28831 var img = document$1.createElement('img');
28832 img.src = url;
28833 document$1.body.appendChild(img);
28834 } else if (use_sendBeacon) {
28835 try {
28836 succeeded = sendBeacon(url, body_data);
28837 } catch (e) {
28838 lib.report_error(e);
28839 succeeded = false;
28840 }
28841 try {
28842 if (callback) {
28843 callback(succeeded ? 1 : 0);
28844 }
28845 } catch (e) {
28846 lib.report_error(e);
28847 }
28848 } else if (USE_XHR) {
28849 try {
28850 var req = new XMLHttpRequest();
28851 req.open(options.method, url, true);
28852
28853 var headers = this.get_config('xhr_headers');
28854 if (use_post) {
28855 headers['Content-Type'] = 'application/x-www-form-urlencoded';
28856 }
28857 _.each(headers, function(headerValue, headerName) {
28858 req.setRequestHeader(headerName, headerValue);
28859 });
28860
28861 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
28862 req.timeout = options.timeout_ms;
28863 var start_time = new Date().getTime();
28864 }
28865
28866 // send the mp_optout cookie
28867 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
28868 req.withCredentials = true;
28869 req.onreadystatechange = function () {
28870 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
28871 if (req.status === 200) {
28872 if (callback) {
28873 if (verbose_mode) {
28874 var response;
28875 try {
28876 response = _.JSONDecode(req.responseText);
28877 } catch (e) {
28878 lib.report_error(e);
28879 if (options.ignore_json_errors) {
28880 response = req.responseText;
28881 } else {
28882 return;
28883 }
28884 }
28885 callback(response);
28886 } else {
28887 callback(Number(req.responseText));
28888 }
28889 }
28890 } else {
28891 var error;
28892 if (
28893 req.timeout &&
28894 !req.status &&
28895 new Date().getTime() - start_time >= req.timeout
28896 ) {
28897 error = 'timeout';
28898 } else {
28899 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
28900 }
28901 lib.report_error(error);
28902 if (callback) {
28903 if (verbose_mode) {
28904 var response_headers = req['responseHeaders'] || {};
28905 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
28906 } else {
28907 callback(0);
28908 }
28909 }
28910 }
28911 }
28912 };
28913 req.send(body_data);
28914 } catch (e) {
28915 lib.report_error(e);
28916 succeeded = false;
28917 }
28918 } else {
28919 var script = document$1.createElement('script');
28920 script.type = 'text/javascript';
28921 script.async = true;
28922 script.defer = true;
28923 script.src = url;
28924 var s = document$1.getElementsByTagName('script')[0];
28925 s.parentNode.insertBefore(script, s);
28926 }
28927
28928 return succeeded;
28929 };
28930
28931 /**
28932 * _execute_array() deals with processing any mixpanel function
28933 * calls that were called before the Mixpanel library were loaded
28934 * (and are thus stored in an array so they can be called later)
28935 *
28936 * Note: we fire off all the mixpanel function calls && user defined
28937 * functions BEFORE we fire off mixpanel tracking calls. This is so
28938 * identify/register/set_config calls can properly modify early
28939 * tracking calls.
28940 *
28941 * @param {Array} array
28942 */
28943 MixpanelLib.prototype._execute_array = function(array) {
28944 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
28945 _.each(array, function(item) {
28946 if (item) {
28947 fn_name = item[0];
28948 if (_.isArray(fn_name)) {
28949 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
28950 } else if (typeof(item) === 'function') {
28951 item.call(this);
28952 } else if (_.isArray(item) && fn_name === 'alias') {
28953 alias_calls.push(item);
28954 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
28955 tracking_calls.push(item);
28956 } else {
28957 other_calls.push(item);
28958 }
28959 }
28960 }, this);
28961
28962 var execute = function(calls, context) {
28963 _.each(calls, function(item) {
28964 if (_.isArray(item[0])) {
28965 // chained call
28966 var caller = context;
28967 _.each(item, function(call) {
28968 caller = caller[call[0]].apply(caller, call.slice(1));
28969 });
28970 } else {
28971 this[item[0]].apply(this, item.slice(1));
28972 }
28973 }, context);
28974 };
28975
28976 execute(alias_calls, this);
28977 execute(other_calls, this);
28978 execute(tracking_calls, this);
28979 };
28980
28981 // request queueing utils
28982
28983 MixpanelLib.prototype.are_batchers_initialized = function() {
28984 return !!this.request_batchers.events;
28985 };
28986
28987 MixpanelLib.prototype.get_batcher_configs = function() {
28988 var queue_prefix = '__mpq_' + this.get_config('token');
28989 var api_routes = this.get_config('api_routes');
28990 this._batcher_configs = this._batcher_configs || {
28991 events: {type: 'events', endpoint: '/' + api_routes['track'], queue_key: queue_prefix + '_ev'},
28992 people: {type: 'people', endpoint: '/' + api_routes['engage'], queue_key: queue_prefix + '_pp'},
28993 groups: {type: 'groups', endpoint: '/' + api_routes['groups'], queue_key: queue_prefix + '_gr'}
28994 };
28995 return this._batcher_configs;
28996 };
28997
28998 MixpanelLib.prototype.init_batchers = function() {
28999 if (!this.are_batchers_initialized()) {
29000 var batcher_for = _.bind(function(attrs) {
29001 return new RequestBatcher(
29002 attrs.queue_key,
29003 {
29004 libConfig: this['config'],
29005 errorReporter: this.get_config('error_reporter'),
29006 sendRequestFunc: _.bind(function(data, options, cb) {
29007 this._send_request(
29008 this.get_config('api_host') + attrs.endpoint,
29009 this._encode_data_for_request(data),
29010 options,
29011 this._prepare_callback(cb, data)
29012 );
29013 }, this),
29014 beforeSendHook: _.bind(function(item) {
29015 return this._run_hook('before_send_' + attrs.type, item);
29016 }, this),
29017 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
29018 usePersistence: true,
29019 }
29020 );
29021 }, this);
29022 var batcher_configs = this.get_batcher_configs();
29023 this.request_batchers = {
29024 events: batcher_for(batcher_configs.events),
29025 people: batcher_for(batcher_configs.people),
29026 groups: batcher_for(batcher_configs.groups)
29027 };
29028 }
29029 if (this.get_config('batch_autostart')) {
29030 this.start_batch_senders();
29031 }
29032 };
29033
29034 MixpanelLib.prototype.start_batch_senders = function() {
29035 this._batchers_were_started = true;
29036 if (this.are_batchers_initialized()) {
29037 this._batch_requests = true;
29038 _.each(this.request_batchers, function(batcher) {
29039 batcher.start();
29040 });
29041 }
29042 };
29043
29044 MixpanelLib.prototype.stop_batch_senders = function() {
29045 this._batch_requests = false;
29046 _.each(this.request_batchers, function(batcher) {
29047 batcher.stop();
29048 batcher.clear();
29049 });
29050 };
29051
29052 /**
29053 * push() keeps the standard async-array-push
29054 * behavior around after the lib is loaded.
29055 * This is only useful for external integrations that
29056 * do not wish to rely on our convenience methods
29057 * (created in the snippet).
29058 *
29059 * ### Usage:
29060 * mixpanel.push(['register', { a: 'b' }]);
29061 *
29062 * @param {Array} item A [function_name, args...] array to be executed
29063 */
29064 MixpanelLib.prototype.push = function(item) {
29065 this._execute_array([item]);
29066 };
29067
29068 /**
29069 * Disable events on the Mixpanel object. If passed no arguments,
29070 * this function disables tracking of any event. If passed an
29071 * array of event names, those events will be disabled, but other
29072 * events will continue to be tracked.
29073 *
29074 * Note: this function does not stop other mixpanel functions from
29075 * firing, such as register() or people.set().
29076 *
29077 * @param {Array} [events] An array of event names to disable
29078 */
29079 MixpanelLib.prototype.disable = function(events) {
29080 if (typeof(events) === 'undefined') {
29081 this._flags.disable_all_events = true;
29082 } else {
29083 this.__disabled_events = this.__disabled_events.concat(events);
29084 }
29085 };
29086
29087 MixpanelLib.prototype._encode_data_for_request = function(data) {
29088 var encoded_data = JSONStringify(data);
29089 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
29090 encoded_data = _.base64Encode(encoded_data);
29091 }
29092 return {'data': encoded_data};
29093 };
29094
29095 // internal method for handling track vs batch-enqueue logic
29096 MixpanelLib.prototype._track_or_batch = function(options, callback) {
29097 var truncated_data = _.truncate(options.data, 255);
29098 var endpoint = options.endpoint;
29099 var batcher = options.batcher;
29100 var should_send_immediately = options.should_send_immediately;
29101 var send_request_options = options.send_request_options || {};
29102 callback = callback || NOOP_FUNC;
29103
29104 var request_enqueued_or_initiated = true;
29105 var send_request_immediately = _.bind(function() {
29106 if (!send_request_options.skip_hooks) {
29107 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
29108 }
29109 if (truncated_data) {
29110 console$1.log('MIXPANEL REQUEST:');
29111 console$1.log(truncated_data);
29112 return this._send_request(
29113 endpoint,
29114 this._encode_data_for_request(truncated_data),
29115 send_request_options,
29116 this._prepare_callback(callback, truncated_data)
29117 );
29118 } else {
29119 return null;
29120 }
29121 }, this);
29122
29123 if (this._batch_requests && !should_send_immediately) {
29124 batcher.enqueue(truncated_data).then(function(succeeded) {
29125 if (succeeded) {
29126 callback(1, truncated_data);
29127 } else {
29128 send_request_immediately();
29129 }
29130 });
29131 } else {
29132 request_enqueued_or_initiated = send_request_immediately();
29133 }
29134
29135 return request_enqueued_or_initiated && truncated_data;
29136 };
29137
29138 /**
29139 * Track an event. This is the most important and
29140 * frequently used Mixpanel function.
29141 *
29142 * ### Usage:
29143 *
29144 * // track an event named 'Registered'
29145 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
29146 *
29147 * // track an event using navigator.sendBeacon
29148 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
29149 *
29150 * To track link clicks or form submissions, see track_links() or track_forms().
29151 *
29152 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
29153 * @param {Object} [properties] A set of properties to include with the event you're sending. These describe the user who did the event or details about the event itself.
29154 * @param {Object} [options] Optional configuration for this track request.
29155 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
29156 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
29157 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
29158 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
29159 * with the tracking payload sent to the API server is returned; otherwise false.
29160 */
29161 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
29162 if (!callback && typeof options === 'function') {
29163 callback = options;
29164 options = null;
29165 }
29166 options = options || {};
29167 var transport = options['transport']; // external API, don't minify 'transport' prop
29168 if (transport) {
29169 options.transport = transport; // 'transport' prop name can be minified internally
29170 }
29171 var should_send_immediately = options['send_immediately'];
29172 if (typeof callback !== 'function') {
29173 callback = NOOP_FUNC;
29174 }
29175
29176 if (_.isUndefined(event_name)) {
29177 this.report_error('No event name provided to mixpanel.track');
29178 return;
29179 }
29180
29181 if (this._event_is_disabled(event_name)) {
29182 callback(0);
29183 return;
29184 }
29185
29186 // set defaults
29187 properties = _.extend({}, properties);
29188 properties['token'] = this.get_config('token');
29189
29190 // set $duration if time_event was previously called for this event
29191 var start_timestamp = this['persistence'].remove_event_timer(event_name);
29192 if (!_.isUndefined(start_timestamp)) {
29193 var duration_in_ms = new Date().getTime() - start_timestamp;
29194 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
29195 }
29196
29197 this._set_default_superprops();
29198
29199 var marketing_properties = this.get_config('track_marketing')
29200 ? _.info.marketingParams()
29201 : {};
29202
29203 // note: extend writes to the first object, so lets make sure we
29204 // don't write to the persistence properties object and info
29205 // properties object by passing in a new object
29206
29207 // update properties with pageview info and super-properties
29208 properties = _.extend(
29209 {},
29210 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
29211 marketing_properties,
29212 this['persistence'].properties(),
29213 this.unpersisted_superprops,
29214 this.get_session_recording_properties(),
29215 properties
29216 );
29217
29218 var property_blacklist = this.get_config('property_blacklist');
29219 if (_.isArray(property_blacklist)) {
29220 _.each(property_blacklist, function(blacklisted_prop) {
29221 delete properties[blacklisted_prop];
29222 });
29223 } else {
29224 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
29225 }
29226
29227 var data = {
29228 'event': event_name,
29229 'properties': properties
29230 };
29231 var ret = this._track_or_batch({
29232 type: 'events',
29233 data: data,
29234 endpoint: this.get_config('api_host') + '/' + this.get_config('api_routes')['track'],
29235 batcher: this.request_batchers.events,
29236 should_send_immediately: should_send_immediately,
29237 send_request_options: options
29238 }, callback);
29239
29240 return ret;
29241 });
29242
29243 /**
29244 * Register the current user into one/many groups.
29245 *
29246 * ### Usage:
29247 *
29248 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
29249 * mixpanel.set_group('company', 'mixpanel')
29250 * mixpanel.set_group('company', 128746312)
29251 *
29252 * @param {String} group_key Group key
29253 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
29254 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29255 *
29256 */
29257 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
29258 if (!_.isArray(group_ids)) {
29259 group_ids = [group_ids];
29260 }
29261 var prop = {};
29262 prop[group_key] = group_ids;
29263 this.register(prop);
29264 return this['people'].set(group_key, group_ids, callback);
29265 });
29266
29267 /**
29268 * Add a new group for this user.
29269 *
29270 * ### Usage:
29271 *
29272 * mixpanel.add_group('company', 'mixpanel')
29273 *
29274 * @param {String} group_key Group key
29275 * @param {*} group_id A valid Mixpanel property type
29276 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29277 */
29278 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
29279 var old_values = this.get_property(group_key);
29280 var prop = {};
29281 if (old_values === undefined) {
29282 prop[group_key] = [group_id];
29283 this.register(prop);
29284 } else {
29285 if (old_values.indexOf(group_id) === -1) {
29286 old_values.push(group_id);
29287 prop[group_key] = old_values;
29288 this.register(prop);
29289 }
29290 }
29291 return this['people'].union(group_key, group_id, callback);
29292 });
29293
29294 /**
29295 * Remove a group from this user.
29296 *
29297 * ### Usage:
29298 *
29299 * mixpanel.remove_group('company', 'mixpanel')
29300 *
29301 * @param {String} group_key Group key
29302 * @param {*} group_id A valid Mixpanel property type
29303 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29304 */
29305 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
29306 var old_value = this.get_property(group_key);
29307 // if the value doesn't exist, the persistent store is unchanged
29308 if (old_value !== undefined) {
29309 var idx = old_value.indexOf(group_id);
29310 if (idx > -1) {
29311 old_value.splice(idx, 1);
29312 this.register({group_key: old_value});
29313 }
29314 if (old_value.length === 0) {
29315 this.unregister(group_key);
29316 }
29317 }
29318 return this['people'].remove(group_key, group_id, callback);
29319 });
29320
29321 /**
29322 * Track an event with specific groups.
29323 *
29324 * ### Usage:
29325 *
29326 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
29327 *
29328 * @param {String} event_name The name of the event (see `mixpanel.track()`)
29329 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
29330 * @param {Object=} groups An object mapping group name keys to one or more values
29331 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29332 */
29333 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
29334 var tracking_props = _.extend({}, properties || {});
29335 _.each(groups, function(v, k) {
29336 if (v !== null && v !== undefined) {
29337 tracking_props[k] = v;
29338 }
29339 });
29340 return this.track(event_name, tracking_props, callback);
29341 });
29342
29343 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
29344 return group_key + '_' + JSON.stringify(group_id);
29345 };
29346
29347 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
29348 delete this._cached_groups[this._create_map_key(group_key, group_id)];
29349 };
29350
29351 /**
29352 * Look up reference to a Mixpanel group
29353 *
29354 * ### Usage:
29355 *
29356 * mixpanel.get_group(group_key, group_id)
29357 *
29358 * @param {String} group_key Group key
29359 * @param {Object} group_id A valid Mixpanel property type
29360 * @returns {Object} A MixpanelGroup identifier
29361 */
29362 MixpanelLib.prototype.get_group = function (group_key, group_id) {
29363 var map_key = this._create_map_key(group_key, group_id);
29364 var group = this._cached_groups[map_key];
29365 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
29366 group = new MixpanelGroup();
29367 group._init(this, group_key, group_id);
29368 this._cached_groups[map_key] = group;
29369 }
29370 return group;
29371 };
29372
29373 /**
29374 * Track a default Mixpanel page view event, which includes extra default event properties to
29375 * improve page view data.
29376 *
29377 * ### Usage:
29378 *
29379 * // track a default $mp_web_page_view event
29380 * mixpanel.track_pageview();
29381 *
29382 * // track a page view event with additional event properties
29383 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
29384 *
29385 * // example approach to track page views on different page types as event properties
29386 * mixpanel.track_pageview({'page': 'pricing'});
29387 * mixpanel.track_pageview({'page': 'homepage'});
29388 *
29389 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
29390 * // individual pages on the same site or product. Use cases for custom event_name may be page
29391 * // views on different products or internal applications that are considered completely separate
29392 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
29393 *
29394 * ### Notes:
29395 *
29396 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
29397 * may be turned on for tracking page loads automatically.
29398 *
29399 * // track only page loads
29400 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
29401 *
29402 * // track when the URL changes in any manner
29403 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
29404 *
29405 * // track when the URL changes, ignoring any changes in the hash part
29406 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
29407 *
29408 * // track when the path changes, ignoring any query parameter or hash changes
29409 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
29410 *
29411 * @param {Object} [properties] An optional set of additional properties to send with the page view event
29412 * @param {Object} [options] Page view tracking options
29413 * @param {String} [options.event_name] - Alternate name for the tracking event
29414 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
29415 * with the tracking payload sent to the API server is returned; otherwise false.
29416 */
29417 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
29418 if (typeof properties !== 'object') {
29419 properties = {};
29420 }
29421 options = options || {};
29422 var event_name = options['event_name'] || '$mp_web_page_view';
29423
29424 var default_page_properties = _.extend(
29425 _.info.mpPageViewProperties(),
29426 _.info.campaignParams(),
29427 _.info.clickParams()
29428 );
29429
29430 var event_properties = _.extend(
29431 {},
29432 default_page_properties,
29433 properties
29434 );
29435
29436 return this.track(event_name, event_properties);
29437 });
29438
29439 /**
29440 * Track clicks on a set of document elements. Selector must be a
29441 * valid query. Elements must exist on the page at the time track_links is called.
29442 *
29443 * ### Usage:
29444 *
29445 * // track click for link id #nav
29446 * mixpanel.track_links('#nav', 'Clicked Nav Link');
29447 *
29448 * ### Notes:
29449 *
29450 * This function will wait up to 300 ms for the Mixpanel
29451 * servers to respond. If they have not responded by that time
29452 * it will head to the link without ensuring that your event
29453 * has been tracked. To configure this timeout please see the
29454 * set_config() documentation below.
29455 *
29456 * If you pass a function in as the properties argument, the
29457 * function will receive the DOMElement that triggered the
29458 * event as an argument. You are expected to return an object
29459 * from the function; any properties defined on this object
29460 * will be sent to mixpanel as event properties.
29461 *
29462 * @type {Function}
29463 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
29464 * @param {String} event_name The name of the event to track
29465 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
29466 */
29467 MixpanelLib.prototype.track_links = function() {
29468 return this._track_dom.call(this, LinkTracker, arguments);
29469 };
29470
29471 /**
29472 * Track form submissions. Selector must be a valid query.
29473 *
29474 * ### Usage:
29475 *
29476 * // track submission for form id 'register'
29477 * mixpanel.track_forms('#register', 'Created Account');
29478 *
29479 * ### Notes:
29480 *
29481 * This function will wait up to 300 ms for the mixpanel
29482 * servers to respond, if they have not responded by that time
29483 * it will head to the link without ensuring that your event
29484 * has been tracked. To configure this timeout please see the
29485 * set_config() documentation below.
29486 *
29487 * If you pass a function in as the properties argument, the
29488 * function will receive the DOMElement that triggered the
29489 * event as an argument. You are expected to return an object
29490 * from the function; any properties defined on this object
29491 * will be sent to mixpanel as event properties.
29492 *
29493 * @type {Function}
29494 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
29495 * @param {String} event_name The name of the event to track
29496 * @param {Object|Function} [properties] This can be a set of properties, or a function that returns a set of properties after being passed a DOMElement
29497 */
29498 MixpanelLib.prototype.track_forms = function() {
29499 return this._track_dom.call(this, FormTracker, arguments);
29500 };
29501
29502 /**
29503 * Time an event by including the time between this call and a
29504 * later 'track' call for the same event in the properties sent
29505 * with the event.
29506 *
29507 * ### Usage:
29508 *
29509 * // time an event named 'Registered'
29510 * mixpanel.time_event('Registered');
29511 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
29512 *
29513 * When called for a particular event name, the next track call for that event
29514 * name will include the elapsed time between the 'time_event' and 'track'
29515 * calls. This value is stored as seconds in the '$duration' property.
29516 *
29517 * @param {String} event_name The name of the event.
29518 */
29519 MixpanelLib.prototype.time_event = function(event_name) {
29520 if (_.isUndefined(event_name)) {
29521 this.report_error('No event name provided to mixpanel.time_event');
29522 return;
29523 }
29524
29525 if (this._event_is_disabled(event_name)) {
29526 return;
29527 }
29528
29529 this['persistence'].set_event_timer(event_name, new Date().getTime());
29530 };
29531
29532 var REGISTER_DEFAULTS = {
29533 'persistent': true
29534 };
29535 /**
29536 * Helper to parse options param for register methods, maintaining
29537 * legacy support for plain "days" param instead of options object
29538 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
29539 * @returns {Object} options object
29540 */
29541 var options_for_register = function(days_or_options) {
29542 var options;
29543 if (_.isObject(days_or_options)) {
29544 options = days_or_options;
29545 } else if (!_.isUndefined(days_or_options)) {
29546 options = {'days': days_or_options};
29547 } else {
29548 options = {};
29549 }
29550 return _.extend({}, REGISTER_DEFAULTS, options);
29551 };
29552
29553 /**
29554 * Register a set of super properties, which are included with all
29555 * events. This will overwrite previous super property values.
29556 *
29557 * ### Usage:
29558 *
29559 * // register 'Gender' as a super property
29560 * mixpanel.register({'Gender': 'Female'});
29561 *
29562 * // register several super properties when a user signs up
29563 * mixpanel.register({
29564 * 'Email': 'jdoe@example.com',
29565 * 'Account Type': 'Free'
29566 * });
29567 *
29568 * // register only for the current pageload
29569 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
29570 *
29571 * @param {Object} properties An associative array of properties to store about the user
29572 * @param {Number|Object} [days_or_options] Options object or number of days since the user's last visit to store the super properties (only valid for persisted props)
29573 * @param {boolean} [days_or_options.days] - number of days since the user's last visit to store the super properties (only valid for persisted props)
29574 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
29575 */
29576 MixpanelLib.prototype.register = function(props, days_or_options) {
29577 var options = options_for_register(days_or_options);
29578 if (options['persistent']) {
29579 this['persistence'].register(props, options['days']);
29580 } else {
29581 _.extend(this.unpersisted_superprops, props);
29582 }
29583 };
29584
29585 /**
29586 * Register a set of super properties only once. This will not
29587 * overwrite previous super property values, unlike register().
29588 *
29589 * ### Usage:
29590 *
29591 * // register a super property for the first time only
29592 * mixpanel.register_once({
29593 * 'First Login Date': new Date().toISOString()
29594 * });
29595 *
29596 * // register once, only for the current pageload
29597 * mixpanel.register_once({
29598 * 'First interaction time': new Date().toISOString()
29599 * }, 'None', {persistent: false});
29600 *
29601 * ### Notes:
29602 *
29603 * If default_value is specified, current super properties
29604 * with that value will be overwritten.
29605 *
29606 * @param {Object} properties An associative array of properties to store about the user
29607 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
29608 * @param {Number|Object} [days_or_options] Options object or number of days since the user's last visit to store the super properties (only valid for persisted props)
29609 * @param {boolean} [days_or_options.days] - number of days since the user's last visit to store the super properties (only valid for persisted props)
29610 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
29611 */
29612 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
29613 var options = options_for_register(days_or_options);
29614 if (options['persistent']) {
29615 this['persistence'].register_once(props, default_value, options['days']);
29616 } else {
29617 if (typeof(default_value) === 'undefined') {
29618 default_value = 'None';
29619 }
29620 _.each(props, function(val, prop) {
29621 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
29622 this.unpersisted_superprops[prop] = val;
29623 }
29624 }, this);
29625 }
29626 };
29627
29628 /**
29629 * Delete a super property stored with the current user.
29630 *
29631 * @param {String} property The name of the super property to remove
29632 * @param {Object} [options]
29633 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
29634 */
29635 MixpanelLib.prototype.unregister = function(property, options) {
29636 options = options_for_register(options);
29637 if (options['persistent']) {
29638 this['persistence'].unregister(property);
29639 } else {
29640 delete this.unpersisted_superprops[property];
29641 }
29642 };
29643
29644 MixpanelLib.prototype._register_single = function(prop, value) {
29645 var props = {};
29646 props[prop] = value;
29647 this.register(props);
29648 };
29649
29650 /**
29651 * Identify a user with a unique ID to track user activity across
29652 * devices, tie a user to their events, and create a user profile.
29653 * If you never call this method, unique visitors are tracked using
29654 * a UUID generated the first time they visit the site.
29655 *
29656 * Call identify when you know the identity of the current user,
29657 * typically after login or signup. We recommend against using
29658 * identify for anonymous visitors to your site.
29659 *
29660 * ### Notes:
29661 * If your project has
29662 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
29663 * enabled, the identify method will connect pre- and
29664 * post-authentication events when appropriate.
29665 *
29666 * If your project does not have ID Merge enabled, identify will
29667 * change the user's local distinct_id to the unique ID you pass.
29668 * Events tracked prior to authentication will not be connected
29669 * to the same user identity. If ID Merge is disabled, alias can
29670 * be used to connect pre- and post-registration events.
29671 *
29672 * @param {String} [unique_id] A string that uniquely identifies a user. If not provided, the distinct_id currently in the persistent store (cookie or localStorage) will be used.
29673 */
29674 MixpanelLib.prototype.identify = function(
29675 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
29676 ) {
29677 // Optional Parameters
29678 // _set_callback:function A callback to be run if and when the People set queue is flushed
29679 // _add_callback:function A callback to be run if and when the People add queue is flushed
29680 // _append_callback:function A callback to be run if and when the People append queue is flushed
29681 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
29682 // _union_callback:function A callback to be run if and when the People union queue is flushed
29683 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
29684
29685 var previous_distinct_id = this.get_distinct_id();
29686 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
29687 // we allow the following condition if previous distinct_id is same as new_distinct_id
29688 // so that you can force flush people updates for anonymous profiles.
29689 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
29690 this.report_error('distinct_id cannot have $device: prefix');
29691 return -1;
29692 }
29693 this.register({'$user_id': new_distinct_id});
29694 }
29695
29696 if (!this.get_property('$device_id')) {
29697 // The persisted distinct id might not actually be a device id at all
29698 // it might be a distinct id of the user from before
29699 var device_id = previous_distinct_id;
29700 this.register_once({
29701 '$had_persisted_distinct_id': true,
29702 '$device_id': device_id
29703 }, '');
29704 }
29705
29706 // identify only changes the distinct id if it doesn't match either the existing or the alias;
29707 // if it's new, blow away the alias as well.
29708 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
29709 this.unregister(ALIAS_ID_KEY);
29710 this.register({'distinct_id': new_distinct_id});
29711 }
29712 this._flags.identify_called = true;
29713 // Flush any queued up people requests
29714 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
29715
29716 // send an $identify event any time the distinct_id is changing - logic on the server
29717 // will determine whether or not to do anything with it.
29718 if (new_distinct_id !== previous_distinct_id) {
29719 this.track('$identify', {
29720 'distinct_id': new_distinct_id,
29721 '$anon_distinct_id': previous_distinct_id
29722 }, {skip_hooks: true});
29723 }
29724
29725 // check feature flags again if distinct id has changed
29726 if (new_distinct_id !== previous_distinct_id) {
29727 this.flags.fetchFlags();
29728 }
29729 };
29730
29731 /**
29732 * Clears super properties and generates a new random distinct_id for this instance.
29733 * Useful for clearing data when a user logs out.
29734 */
29735 MixpanelLib.prototype.reset = function() {
29736 this['persistence'].clear();
29737 this._flags.identify_called = false;
29738 var uuid = _.UUID();
29739 this.register_once({
29740 'distinct_id': DEVICE_ID_PREFIX + uuid,
29741 '$device_id': uuid
29742 }, '');
29743 this.stop_session_recording();
29744 this._check_and_start_session_recording();
29745 };
29746
29747 /**
29748 * Returns the current distinct id of the user. This is either the id automatically
29749 * generated by the library or the id that has been passed by a call to identify().
29750 *
29751 * ### Notes:
29752 *
29753 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
29754 * init() has a loaded function available to handle this automatically. For example:
29755 *
29756 * // set distinct_id after the mixpanel library has loaded
29757 * mixpanel.init('YOUR PROJECT TOKEN', {
29758 * loaded: function(mixpanel) {
29759 * distinct_id = mixpanel.get_distinct_id();
29760 * }
29761 * });
29762 */
29763 MixpanelLib.prototype.get_distinct_id = function() {
29764 return this.get_property('distinct_id');
29765 };
29766
29767 /**
29768 * The alias method creates an alias which Mixpanel will use to
29769 * remap one id to another. Multiple aliases can point to the
29770 * same identifier.
29771 *
29772 * The following is a valid use of alias:
29773 *
29774 * mixpanel.alias('new_id', 'existing_id');
29775 * // You can add multiple id aliases to the existing ID
29776 * mixpanel.alias('newer_id', 'existing_id');
29777 *
29778 * Aliases can also be chained - the following is a valid example:
29779 *
29780 * mixpanel.alias('new_id', 'existing_id');
29781 * // chain newer_id - new_id - existing_id
29782 * mixpanel.alias('newer_id', 'new_id');
29783 *
29784 * Aliases cannot point to multiple identifiers - the following
29785 * example will not work:
29786 *
29787 * mixpanel.alias('new_id', 'existing_id');
29788 * // this is invalid as 'new_id' already points to 'existing_id'
29789 * mixpanel.alias('new_id', 'newer_id');
29790 *
29791 * ### Notes:
29792 *
29793 * If your project does not have
29794 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
29795 * enabled, the best practice is to call alias once when a unique
29796 * ID is first created for a user (e.g., when a user first registers
29797 * for an account). Do not use alias multiple times for a single
29798 * user without ID Merge enabled.
29799 *
29800 * @param {String} alias A unique identifier that you want to use for this user in the future.
29801 * @param {String} [original] The current identifier being used for this user.
29802 */
29803 MixpanelLib.prototype.alias = function(alias, original) {
29804 // If the $people_distinct_id key exists in persistence, there has been a previous
29805 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
29806 // this ID, as it will duplicate users.
29807 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
29808 this.report_error('Attempting to create alias for existing People user - aborting.');
29809 return -2;
29810 }
29811
29812 var _this = this;
29813 if (_.isUndefined(original)) {
29814 original = this.get_distinct_id();
29815 }
29816 if (alias !== original) {
29817 this._register_single(ALIAS_ID_KEY, alias);
29818 return this.track('$create_alias', {
29819 'alias': alias,
29820 'distinct_id': original
29821 }, {
29822 skip_hooks: true
29823 }, function() {
29824 // Flush the people queue
29825 _this.identify(alias);
29826 });
29827 } else {
29828 this.report_error('alias matches current distinct_id - skipping api call.');
29829 this.identify(alias);
29830 return -1;
29831 }
29832 };
29833
29834 /**
29835 * Provide a string to recognize the user by. The string passed to
29836 * this method will appear in the Mixpanel Streams product rather
29837 * than an automatically generated name. Name tags do not have to
29838 * be unique.
29839 *
29840 * This value will only be included in Streams data.
29841 *
29842 * @param {String} name_tag A human readable name for the user
29843 * @deprecated
29844 */
29845 MixpanelLib.prototype.name_tag = function(name_tag) {
29846 this._register_single('mp_name_tag', name_tag);
29847 };
29848
29849 /**
29850 * Update the configuration of a mixpanel library instance.
29851 *
29852 * The default config is:
29853 *
29854 * {
29855 * // host for requests (customizable for e.g. a local proxy)
29856 * api_host: 'https://api-js.mixpanel.com',
29857 *
29858 * // endpoints for different types of requests
29859 * api_routes: {
29860 * track: 'track/',
29861 * engage: 'engage/',
29862 * groups: 'groups/',
29863 * }
29864 *
29865 * // HTTP method for tracking requests
29866 * api_method: 'POST'
29867 *
29868 * // transport for sending requests ('XHR' or 'sendBeacon')
29869 * // NB: sendBeacon should only be used for scenarios such as
29870 * // page unload where a "best-effort" attempt to send is
29871 * // acceptable; the sendBeacon API does not support callbacks
29872 * // or any way to know the result of the request. Mixpanel
29873 * // tracking via sendBeacon will not support any event-
29874 * // batching or retry mechanisms.
29875 * api_transport: 'XHR'
29876 *
29877 * // request-batching/queueing/retry
29878 * batch_requests: true,
29879 *
29880 * // maximum number of events/updates to send in a single
29881 * // network request
29882 * batch_size: 50,
29883 *
29884 * // milliseconds to wait between sending batch requests
29885 * batch_flush_interval_ms: 5000,
29886 *
29887 * // milliseconds to wait for network responses to batch requests
29888 * // before they are considered timed-out and retried
29889 * batch_request_timeout_ms: 90000,
29890 *
29891 * // override value for cookie domain, only useful for ensuring
29892 * // correct cross-subdomain cookies on unusual domains like
29893 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
29894 * // set cookies on a different domain than the current origin
29895 * cookie_domain: ''
29896 *
29897 * // super properties cookie expiration (in days)
29898 * cookie_expiration: 365
29899 *
29900 * // if true, cookie will be set with SameSite=None; Secure
29901 * // this is only useful in special situations, like embedded
29902 * // 3rd-party iframes that set up a Mixpanel instance
29903 * cross_site_cookie: false
29904 *
29905 * // super properties span subdomains
29906 * cross_subdomain_cookie: true
29907 *
29908 * // debug mode
29909 * debug: false
29910 *
29911 * // if this is true, the mixpanel cookie or localStorage entry
29912 * // will be deleted, and no user persistence will take place
29913 * disable_persistence: false
29914 *
29915 * // if this is true, Mixpanel will automatically determine
29916 * // City, Region and Country data using the IP address of
29917 * //the client
29918 * ip: true
29919 *
29920 * // opt users out of tracking by this Mixpanel instance by default
29921 * opt_out_tracking_by_default: false
29922 *
29923 * // opt users out of browser data storage by this Mixpanel instance by default
29924 * opt_out_persistence_by_default: false
29925 *
29926 * // persistence mechanism used by opt-in/opt-out methods - cookie
29927 * // or localStorage - falls back to cookie if localStorage is unavailable
29928 * opt_out_tracking_persistence_type: 'localStorage'
29929 *
29930 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
29931 * opt_out_tracking_cookie_prefix: null
29932 *
29933 * // type of persistent store for super properties (cookie/
29934 * // localStorage) if set to 'localStorage', any existing
29935 * // mixpanel cookie value with the same persistence_name
29936 * // will be transferred to localStorage and deleted
29937 * persistence: 'cookie'
29938 *
29939 * // name for super properties persistent store
29940 * persistence_name: ''
29941 *
29942 * // names of properties/superproperties which should never
29943 * // be sent with track() calls
29944 * property_blacklist: []
29945 *
29946 * // if this is true, mixpanel cookies will be marked as
29947 * // secure, meaning they will only be transmitted over https
29948 * secure_cookie: false
29949 *
29950 * // disables enriching user profiles with first touch marketing data
29951 * skip_first_touch_marketing: false
29952 *
29953 * // the amount of time track_links will
29954 * // wait for Mixpanel's servers to respond
29955 * track_links_timeout: 300
29956 *
29957 * // adds any UTM parameters and click IDs present on the page to any events fired
29958 * track_marketing: true
29959 *
29960 * // enables automatic page view tracking using default page view events through
29961 * // the track_pageview() method
29962 * track_pageview: false
29963 *
29964 * // if you set upgrade to be true, the library will check for
29965 * // a cookie from our old js library and import super
29966 * // properties from it, then the old cookie is deleted
29967 * // The upgrade config option only works in the initialization,
29968 * // so make sure you set it when you create the library.
29969 * upgrade: false
29970 *
29971 * // extra HTTP request headers to set for each API request, in
29972 * // the format {'Header-Name': value}
29973 * xhr_headers: {}
29974 *
29975 * // whether to ignore or respect the web browser's Do Not Track setting
29976 * ignore_dnt: false
29977 * }
29978 *
29979 *
29980 * @param {Object} config A dictionary of new configuration values to update
29981 */
29982 MixpanelLib.prototype.set_config = function(config) {
29983 if (_.isObject(config)) {
29984 _.extend(this['config'], config);
29985
29986 var new_batch_size = config['batch_size'];
29987 if (new_batch_size) {
29988 _.each(this.request_batchers, function(batcher) {
29989 batcher.resetBatchSize();
29990 });
29991 }
29992
29993 if (!this.get_config('persistence_name')) {
29994 this['config']['persistence_name'] = this['config']['cookie_name'];
29995 }
29996 if (!this.get_config('disable_persistence')) {
29997 this['config']['disable_persistence'] = this['config']['disable_cookie'];
29998 }
29999
30000 if (this['persistence']) {
30001 this['persistence'].update_config(this['config']);
30002 }
30003 Config.DEBUG = Config.DEBUG || this.get_config('debug');
30004
30005 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
30006 this.autocapture.init();
30007 }
30008 }
30009 };
30010
30011 /**
30012 * returns the current config object for the library.
30013 */
30014 MixpanelLib.prototype.get_config = function(prop_name) {
30015 return this['config'][prop_name];
30016 };
30017
30018 /**
30019 * Fetch a hook function from config, with safe default, and run it
30020 * against the given arguments
30021 * @param {string} hook_name which hook to retrieve
30022 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
30023 */
30024 MixpanelLib.prototype._run_hook = function(hook_name) {
30025 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
30026 if (typeof ret === 'undefined') {
30027 this.report_error(hook_name + ' hook did not return a value');
30028 ret = null;
30029 }
30030 return ret;
30031 };
30032
30033 /**
30034 * Returns the value of the super property named property_name. If no such
30035 * property is set, get_property() will return the undefined value.
30036 *
30037 * ### Notes:
30038 *
30039 * get_property() can only be called after the Mixpanel library has finished loading.
30040 * init() has a loaded function available to handle this automatically. For example:
30041 *
30042 * // grab value for 'user_id' after the mixpanel library has loaded
30043 * mixpanel.init('YOUR PROJECT TOKEN', {
30044 * loaded: function(mixpanel) {
30045 * user_id = mixpanel.get_property('user_id');
30046 * }
30047 * });
30048 *
30049 * @param {String} property_name The name of the super property you want to retrieve
30050 */
30051 MixpanelLib.prototype.get_property = function(property_name) {
30052 return this['persistence'].load_prop([property_name]);
30053 };
30054
30055 MixpanelLib.prototype.toString = function() {
30056 var name = this.get_config('name');
30057 if (name !== PRIMARY_INSTANCE_NAME) {
30058 name = PRIMARY_INSTANCE_NAME + '.' + name;
30059 }
30060 return name;
30061 };
30062
30063 MixpanelLib.prototype._event_is_disabled = function(event_name) {
30064 return _.isBlockedUA(userAgent) ||
30065 this._flags.disable_all_events ||
30066 _.include(this.__disabled_events, event_name);
30067 };
30068
30069 // perform some housekeeping around GDPR opt-in/out state
30070 MixpanelLib.prototype._gdpr_init = function() {
30071 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
30072
30073 // try to convert opt-in/out cookies to localStorage if possible
30074 if (is_localStorage_requested && _.localStorage.is_supported()) {
30075 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
30076 this.opt_in_tracking({'enable_persistence': false});
30077 }
30078 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
30079 this.opt_out_tracking({'clear_persistence': false});
30080 }
30081 this.clear_opt_in_out_tracking({
30082 'persistence_type': 'cookie',
30083 'enable_persistence': false
30084 });
30085 }
30086
30087 // check whether the user has already opted out - if so, clear & disable persistence
30088 if (this.has_opted_out_tracking()) {
30089 this._gdpr_update_persistence({'clear_persistence': true});
30090
30091 // check whether we should opt out by default
30092 // note: we don't clear persistence here by default since opt-out default state is often
30093 // used as an initial state while GDPR information is being collected
30094 } else if (!this.has_opted_in_tracking() && (
30095 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
30096 )) {
30097 _.cookie.remove('mp_optout');
30098 this.opt_out_tracking({
30099 'clear_persistence': this.get_config('opt_out_persistence_by_default')
30100 });
30101 }
30102 };
30103
30104 /**
30105 * Enable or disable persistence based on options
30106 * only enable/disable if persistence is not already in this state
30107 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
30108 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
30109 */
30110 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
30111 var disabled;
30112 if (options && options['clear_persistence']) {
30113 disabled = true;
30114 } else if (options && options['enable_persistence']) {
30115 disabled = false;
30116 } else {
30117 return;
30118 }
30119
30120 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
30121 this['persistence'].set_disabled(disabled);
30122 }
30123
30124 if (disabled) {
30125 this.stop_batch_senders();
30126 this.stop_session_recording();
30127 } else {
30128 // only start batchers after opt-in if they have previously been started
30129 // in order to avoid unintentionally starting up batching for the first time
30130 if (this._batchers_were_started) {
30131 this.start_batch_senders();
30132 }
30133 }
30134 };
30135
30136 // call a base gdpr function after constructing the appropriate token and options args
30137 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
30138 options = _.extend({
30139 'track': _.bind(this.track, this),
30140 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
30141 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
30142 'cookie_expiration': this.get_config('cookie_expiration'),
30143 'cross_site_cookie': this.get_config('cross_site_cookie'),
30144 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
30145 'cookie_domain': this.get_config('cookie_domain'),
30146 'secure_cookie': this.get_config('secure_cookie'),
30147 'ignore_dnt': this.get_config('ignore_dnt')
30148 }, options);
30149
30150 // check if localStorage can be used for recording opt out status, fall back to cookie if not
30151 if (!_.localStorage.is_supported()) {
30152 options['persistence_type'] = 'cookie';
30153 }
30154
30155 return func(this.get_config('token'), {
30156 track: options['track'],
30157 trackEventName: options['track_event_name'],
30158 trackProperties: options['track_properties'],
30159 persistenceType: options['persistence_type'],
30160 persistencePrefix: options['cookie_prefix'],
30161 cookieDomain: options['cookie_domain'],
30162 cookieExpiration: options['cookie_expiration'],
30163 crossSiteCookie: options['cross_site_cookie'],
30164 crossSubdomainCookie: options['cross_subdomain_cookie'],
30165 secureCookie: options['secure_cookie'],
30166 ignoreDnt: options['ignore_dnt']
30167 });
30168 };
30169
30170 /**
30171 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
30172 *
30173 * ### Usage:
30174 *
30175 * // opt user in
30176 * mixpanel.opt_in_tracking();
30177 *
30178 * // opt user in with specific event name, properties, cookie configuration
30179 * mixpanel.opt_in_tracking({
30180 * track_event_name: 'User opted in',
30181 * track_event_properties: {
30182 * 'Email': 'jdoe@example.com'
30183 * },
30184 * cookie_expiration: 30,
30185 * secure_cookie: true
30186 * });
30187 *
30188 * @param {Object} [options] A dictionary of config options to override
30189 * @param {function} [options.track] Function used for tracking a Mixpanel event to record the opt-in action (default is this Mixpanel instance's track method)
30190 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
30191 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
30192 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
30193 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
30194 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
30195 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
30196 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
30197 * @param {boolean} [options.cross_site_cookie] Whether the opt-in cookie is set as cross-site-enabled (overrides value specified in this Mixpanel instance's config)
30198 * @param {boolean} [options.cross_subdomain_cookie] Whether the opt-in cookie is set as cross-subdomain or not (overrides value specified in this Mixpanel instance's config)
30199 * @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this Mixpanel instance's config)
30200 */
30201 MixpanelLib.prototype.opt_in_tracking = function(options) {
30202 options = _.extend({
30203 'enable_persistence': true
30204 }, options);
30205
30206 this._gdpr_call_func(optIn, options);
30207 this._gdpr_update_persistence(options);
30208 };
30209
30210 /**
30211 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
30212 *
30213 * ### Usage:
30214 *
30215 * // opt user out
30216 * mixpanel.opt_out_tracking();
30217 *
30218 * // opt user out with different cookie configuration from Mixpanel instance
30219 * mixpanel.opt_out_tracking({
30220 * cookie_expiration: 30,
30221 * secure_cookie: true
30222 * });
30223 *
30224 * @param {Object} [options] A dictionary of config options to override
30225 * @param {boolean} [options.delete_user=true] If true, will delete the currently identified user's profile and clear all charges after opting the user out
30226 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
30227 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
30228 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
30229 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
30230 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
30231 * @param {boolean} [options.cross_site_cookie] Whether the opt-in cookie is set as cross-site-enabled (overrides value specified in this Mixpanel instance's config)
30232 * @param {boolean} [options.cross_subdomain_cookie] Whether the opt-in cookie is set as cross-subdomain or not (overrides value specified in this Mixpanel instance's config)
30233 * @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this Mixpanel instance's config)
30234 */
30235 MixpanelLib.prototype.opt_out_tracking = function(options) {
30236 options = _.extend({
30237 'clear_persistence': true,
30238 'delete_user': true
30239 }, options);
30240
30241 // delete user and clear charges since these methods may be disabled by opt-out
30242 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
30243 this['people'].delete_user();
30244 this['people'].clear_charges();
30245 }
30246
30247 this._gdpr_call_func(optOut, options);
30248 this._gdpr_update_persistence(options);
30249 };
30250
30251 /**
30252 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
30253 *
30254 * ### Usage:
30255 *
30256 * var has_opted_in = mixpanel.has_opted_in_tracking();
30257 * // use has_opted_in value
30258 *
30259 * @param {Object} [options] A dictionary of config options to override
30260 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
30261 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
30262 * @returns {boolean} current opt-in status
30263 */
30264 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
30265 return this._gdpr_call_func(hasOptedIn, options);
30266 };
30267
30268 /**
30269 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
30270 *
30271 * ### Usage:
30272 *
30273 * var has_opted_out = mixpanel.has_opted_out_tracking();
30274 * // use has_opted_out value
30275 *
30276 * @param {Object} [options] A dictionary of config options to override
30277 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
30278 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
30279 * @returns {boolean} current opt-out status
30280 */
30281 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
30282 return this._gdpr_call_func(hasOptedOut, options);
30283 };
30284
30285 /**
30286 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
30287 *
30288 * ### Usage:
30289 *
30290 * // clear user's opt-in/out status
30291 * mixpanel.clear_opt_in_out_tracking();
30292 *
30293 * // clear user's opt-in/out status with specific cookie configuration - should match
30294 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
30295 * mixpanel.clear_opt_in_out_tracking({
30296 * cookie_expiration: 30,
30297 * secure_cookie: true
30298 * });
30299 *
30300 * @param {Object} [options] A dictionary of config options to override
30301 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
30302 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
30303 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
30304 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
30305 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
30306 * @param {boolean} [options.cross_site_cookie] Whether the opt-in cookie is set as cross-site-enabled (overrides value specified in this Mixpanel instance's config)
30307 * @param {boolean} [options.cross_subdomain_cookie] Whether the opt-in cookie is set as cross-subdomain or not (overrides value specified in this Mixpanel instance's config)
30308 * @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this Mixpanel instance's config)
30309 */
30310 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
30311 options = _.extend({
30312 'enable_persistence': true
30313 }, options);
30314
30315 this._gdpr_call_func(clearOptInOut, options);
30316 this._gdpr_update_persistence(options);
30317 };
30318
30319 MixpanelLib.prototype.report_error = function(msg, err) {
30320 console$1.error.apply(console$1.error, arguments);
30321 try {
30322 if (!err && !(msg instanceof Error)) {
30323 msg = new Error(msg);
30324 }
30325 this.get_config('error_reporter')(msg, err);
30326 } catch(err) {
30327 console$1.error(err);
30328 }
30329 };
30330
30331 // EXPORTS (for closure compiler)
30332
30333 // MixpanelLib Exports
30334 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
30335 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
30336 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
30337 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
30338 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
30339 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
30340 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
30341 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
30342 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
30343 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
30344 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
30345 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
30346 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
30347 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
30348 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
30349 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
30350 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
30351 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
30352 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
30353 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
30354 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
30355 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
30356 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
30357 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
30358 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
30359 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
30360 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
30361 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
30362 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
30363 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
30364 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
30365 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
30366 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
30367 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
30368 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
30369 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
30370 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
30371 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
30372 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
30373
30374 // Exports intended only for testing
30375 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
30376
30377 // MixpanelPersistence Exports
30378 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
30379 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
30380 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
30381 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
30382 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
30383
30384
30385 var instances = {};
30386 var extend_mp = function() {
30387 // add all the sub mixpanel instances
30388 _.each(instances, function(instance, name) {
30389 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
30390 });
30391
30392 // add private functions as _
30393 mixpanel_master['_'] = _;
30394 };
30395
30396 var override_mp_init_func = function() {
30397 // we override the snippets init function to handle the case where a
30398 // user initializes the mixpanel library after the script loads & runs
30399 mixpanel_master['init'] = function(token, config, name) {
30400 if (name) {
30401 // initialize a sub library
30402 if (!mixpanel_master[name]) {
30403 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
30404 mixpanel_master[name]._loaded();
30405 }
30406 return mixpanel_master[name];
30407 } else {
30408 var instance = mixpanel_master;
30409
30410 if (instances[PRIMARY_INSTANCE_NAME]) {
30411 // main mixpanel lib already initialized
30412 instance = instances[PRIMARY_INSTANCE_NAME];
30413 } else if (token) {
30414 // intialize the main mixpanel lib
30415 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
30416 instance._loaded();
30417 instances[PRIMARY_INSTANCE_NAME] = instance;
30418 }
30419
30420 mixpanel_master = instance;
30421 if (init_type === INIT_SNIPPET) {
30422 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
30423 }
30424 extend_mp();
30425 }
30426 };
30427 };
30428
30429 var add_dom_loaded_handler = function() {
30430 // Cross browser DOM Loaded support
30431 function dom_loaded_handler() {
30432 // function flag since we only want to execute this once
30433 if (dom_loaded_handler.done) { return; }
30434 dom_loaded_handler.done = true;
30435
30436 DOM_LOADED = true;
30437 ENQUEUE_REQUESTS = false;
30438
30439 _.each(instances, function(inst) {
30440 inst._dom_loaded();
30441 });
30442 }
30443
30444 function do_scroll_check() {
30445 try {
30446 document$1.documentElement.doScroll('left');
30447 } catch(e) {
30448 setTimeout(do_scroll_check, 1);
30449 return;
30450 }
30451
30452 dom_loaded_handler();
30453 }
30454
30455 if (document$1.addEventListener) {
30456 if (document$1.readyState === 'complete') {
30457 // safari 4 can fire the DOMContentLoaded event before loading all
30458 // external JS (including this file). you will see some copypasta
30459 // on the internet that checks for 'complete' and 'loaded', but
30460 // 'loaded' is an IE thing
30461 dom_loaded_handler();
30462 } else {
30463 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
30464 }
30465 } else if (document$1.attachEvent) {
30466 // IE
30467 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
30468
30469 // check to make sure we arn't in a frame
30470 var toplevel = false;
30471 try {
30472 toplevel = win.frameElement === null;
30473 } catch(e) {
30474 // noop
30475 }
30476
30477 if (document$1.documentElement.doScroll && toplevel) {
30478 do_scroll_check();
30479 }
30480 }
30481
30482 // fallback handler, always will work
30483 _.register_event(win, 'load', dom_loaded_handler, true);
30484 };
30485
30486 function init_as_module(bundle_loader) {
30487 load_extra_bundle = bundle_loader;
30488 init_type = INIT_MODULE;
30489 mixpanel_master = new MixpanelLib();
30490
30491 override_mp_init_func();
30492 mixpanel_master['init']();
30493 add_dom_loaded_handler();
30494
30495 return mixpanel_master;
30496 }
30497
30498 // For loading separate bundles asynchronously via script tag
30499 // so that we don't load them until they are needed at runtime.
30500
30501 // For builds that have everything in one bundle, no extra work.
30502 function loadNoop (_src, onload) {
30503 onload();
30504 }
30505
30506 /* eslint camelcase: "off" */
30507
30508 var mixpanel = init_as_module(loadNoop);
30509
30510
30511
30512
30513 /***/ }),
30514
30515 /***/ "../node_modules/redux-thunk/es/index.js":
30516 /*!***********************************************!*\
30517 !*** ../node_modules/redux-thunk/es/index.js ***!
30518 \***********************************************/
30519 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
30520
30521 "use strict";
30522 __webpack_require__.r(__webpack_exports__);
30523 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
30524 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
30525 /* harmony export */ });
30526 /** A function that accepts a potential "extra argument" value to be injected later,
30527 * and returns an instance of the thunk middleware that uses that value
30528 */
30529 function createThunkMiddleware(extraArgument) {
30530 // Standard Redux middleware definition pattern:
30531 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
30532 var middleware = function middleware(_ref) {
30533 var dispatch = _ref.dispatch,
30534 getState = _ref.getState;
30535 return function (next) {
30536 return function (action) {
30537 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
30538 // If this "action" is really a function, call it and return the result.
30539 if (typeof action === 'function') {
30540 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
30541 return action(dispatch, getState, extraArgument);
30542 } // Otherwise, pass the action down the middleware chain as usual
30543
30544
30545 return next(action);
30546 };
30547 };
30548 };
30549
30550 return middleware;
30551 }
30552
30553 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
30554 // with whatever "extra arg" they want to inject into their thunks
30555
30556 thunk.withExtraArgument = createThunkMiddleware;
30557 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
30558
30559 /***/ }),
30560
30561 /***/ "../node_modules/redux/es/redux.js":
30562 /*!*****************************************!*\
30563 !*** ../node_modules/redux/es/redux.js ***!
30564 \*****************************************/
30565 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
30566
30567 "use strict";
30568 __webpack_require__.r(__webpack_exports__);
30569 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
30570 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
30571 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
30572 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
30573 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
30574 /* harmony export */ compose: () => (/* binding */ compose),
30575 /* harmony export */ createStore: () => (/* binding */ createStore),
30576 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
30577 /* harmony export */ });
30578 /* harmony import */ var _babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/objectSpread2 */ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js");
30579
30580
30581 /**
30582 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
30583 *
30584 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
30585 * during build.
30586 * @param {number} code
30587 */
30588 function formatProdErrorMessage(code) {
30589 return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
30590 }
30591
30592 // Inlined version of the `symbol-observable` polyfill
30593 var $$observable = (function () {
30594 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
30595 })();
30596
30597 /**
30598 * These are private action types reserved by Redux.
30599 * For any unknown actions, you must return the current state.
30600 * If the current state is undefined, you must return the initial state.
30601 * Do not reference these action types directly in your code.
30602 */
30603 var randomString = function randomString() {
30604 return Math.random().toString(36).substring(7).split('').join('.');
30605 };
30606
30607 var ActionTypes = {
30608 INIT: "@@redux/INIT" + randomString(),
30609 REPLACE: "@@redux/REPLACE" + randomString(),
30610 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
30611 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
30612 }
30613 };
30614
30615 /**
30616 * @param {any} obj The object to inspect.
30617 * @returns {boolean} True if the argument appears to be a plain object.
30618 */
30619 function isPlainObject(obj) {
30620 if (typeof obj !== 'object' || obj === null) return false;
30621 var proto = obj;
30622
30623 while (Object.getPrototypeOf(proto) !== null) {
30624 proto = Object.getPrototypeOf(proto);
30625 }
30626
30627 return Object.getPrototypeOf(obj) === proto;
30628 }
30629
30630 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
30631 function miniKindOf(val) {
30632 if (val === void 0) return 'undefined';
30633 if (val === null) return 'null';
30634 var type = typeof val;
30635
30636 switch (type) {
30637 case 'boolean':
30638 case 'string':
30639 case 'number':
30640 case 'symbol':
30641 case 'function':
30642 {
30643 return type;
30644 }
30645 }
30646
30647 if (Array.isArray(val)) return 'array';
30648 if (isDate(val)) return 'date';
30649 if (isError(val)) return 'error';
30650 var constructorName = ctorName(val);
30651
30652 switch (constructorName) {
30653 case 'Symbol':
30654 case 'Promise':
30655 case 'WeakMap':
30656 case 'WeakSet':
30657 case 'Map':
30658 case 'Set':
30659 return constructorName;
30660 } // other
30661
30662
30663 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
30664 }
30665
30666 function ctorName(val) {
30667 return typeof val.constructor === 'function' ? val.constructor.name : null;
30668 }
30669
30670 function isError(val) {
30671 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
30672 }
30673
30674 function isDate(val) {
30675 if (val instanceof Date) return true;
30676 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
30677 }
30678
30679 function kindOf(val) {
30680 var typeOfVal = typeof val;
30681
30682 if (true) {
30683 typeOfVal = miniKindOf(val);
30684 }
30685
30686 return typeOfVal;
30687 }
30688
30689 /**
30690 * @deprecated
30691 *
30692 * **We recommend using the `configureStore` method
30693 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
30694 *
30695 * Redux Toolkit is our recommended approach for writing Redux logic today,
30696 * including store setup, reducers, data fetching, and more.
30697 *
30698 * **For more details, please read this Redux docs page:**
30699 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
30700 *
30701 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
30702 * simplifies setup and helps avoid common bugs.
30703 *
30704 * You should not be using the `redux` core package by itself today, except for learning purposes.
30705 * The `createStore` method from the core `redux` package will not be removed, but we encourage
30706 * all users to migrate to using Redux Toolkit for all Redux code.
30707 *
30708 * If you want to use `createStore` without this visual deprecation warning, use
30709 * the `legacy_createStore` import instead:
30710 *
30711 * `import { legacy_createStore as createStore} from 'redux'`
30712 *
30713 */
30714
30715 function createStore(reducer, preloadedState, enhancer) {
30716 var _ref2;
30717
30718 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
30719 throw new Error( false ? 0 : 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
30720 }
30721
30722 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
30723 enhancer = preloadedState;
30724 preloadedState = undefined;
30725 }
30726
30727 if (typeof enhancer !== 'undefined') {
30728 if (typeof enhancer !== 'function') {
30729 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
30730 }
30731
30732 return enhancer(createStore)(reducer, preloadedState);
30733 }
30734
30735 if (typeof reducer !== 'function') {
30736 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
30737 }
30738
30739 var currentReducer = reducer;
30740 var currentState = preloadedState;
30741 var currentListeners = [];
30742 var nextListeners = currentListeners;
30743 var isDispatching = false;
30744 /**
30745 * This makes a shallow copy of currentListeners so we can use
30746 * nextListeners as a temporary list while dispatching.
30747 *
30748 * This prevents any bugs around consumers calling
30749 * subscribe/unsubscribe in the middle of a dispatch.
30750 */
30751
30752 function ensureCanMutateNextListeners() {
30753 if (nextListeners === currentListeners) {
30754 nextListeners = currentListeners.slice();
30755 }
30756 }
30757 /**
30758 * Reads the state tree managed by the store.
30759 *
30760 * @returns {any} The current state tree of your application.
30761 */
30762
30763
30764 function getState() {
30765 if (isDispatching) {
30766 throw new Error( false ? 0 : 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
30767 }
30768
30769 return currentState;
30770 }
30771 /**
30772 * Adds a change listener. It will be called any time an action is dispatched,
30773 * and some part of the state tree may potentially have changed. You may then
30774 * call `getState()` to read the current state tree inside the callback.
30775 *
30776 * You may call `dispatch()` from a change listener, with the following
30777 * caveats:
30778 *
30779 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
30780 * If you subscribe or unsubscribe while the listeners are being invoked, this
30781 * will not have any effect on the `dispatch()` that is currently in progress.
30782 * However, the next `dispatch()` call, whether nested or not, will use a more
30783 * recent snapshot of the subscription list.
30784 *
30785 * 2. The listener should not expect to see all state changes, as the state
30786 * might have been updated multiple times during a nested `dispatch()` before
30787 * the listener is called. It is, however, guaranteed that all subscribers
30788 * registered before the `dispatch()` started will be called with the latest
30789 * state by the time it exits.
30790 *
30791 * @param {Function} listener A callback to be invoked on every dispatch.
30792 * @returns {Function} A function to remove this change listener.
30793 */
30794
30795
30796 function subscribe(listener) {
30797 if (typeof listener !== 'function') {
30798 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
30799 }
30800
30801 if (isDispatching) {
30802 throw new Error( false ? 0 : 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
30803 }
30804
30805 var isSubscribed = true;
30806 ensureCanMutateNextListeners();
30807 nextListeners.push(listener);
30808 return function unsubscribe() {
30809 if (!isSubscribed) {
30810 return;
30811 }
30812
30813 if (isDispatching) {
30814 throw new Error( false ? 0 : 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
30815 }
30816
30817 isSubscribed = false;
30818 ensureCanMutateNextListeners();
30819 var index = nextListeners.indexOf(listener);
30820 nextListeners.splice(index, 1);
30821 currentListeners = null;
30822 };
30823 }
30824 /**
30825 * Dispatches an action. It is the only way to trigger a state change.
30826 *
30827 * The `reducer` function, used to create the store, will be called with the
30828 * current state tree and the given `action`. Its return value will
30829 * be considered the **next** state of the tree, and the change listeners
30830 * will be notified.
30831 *
30832 * The base implementation only supports plain object actions. If you want to
30833 * dispatch a Promise, an Observable, a thunk, or something else, you need to
30834 * wrap your store creating function into the corresponding middleware. For
30835 * example, see the documentation for the `redux-thunk` package. Even the
30836 * middleware will eventually dispatch plain object actions using this method.
30837 *
30838 * @param {Object} action A plain object representing “what changed”. It is
30839 * a good idea to keep actions serializable so you can record and replay user
30840 * sessions, or use the time travelling `redux-devtools`. An action must have
30841 * a `type` property which may not be `undefined`. It is a good idea to use
30842 * string constants for action types.
30843 *
30844 * @returns {Object} For convenience, the same action object you dispatched.
30845 *
30846 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
30847 * return something else (for example, a Promise you can await).
30848 */
30849
30850
30851 function dispatch(action) {
30852 if (!isPlainObject(action)) {
30853 throw new Error( false ? 0 : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
30854 }
30855
30856 if (typeof action.type === 'undefined') {
30857 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
30858 }
30859
30860 if (isDispatching) {
30861 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
30862 }
30863
30864 try {
30865 isDispatching = true;
30866 currentState = currentReducer(currentState, action);
30867 } finally {
30868 isDispatching = false;
30869 }
30870
30871 var listeners = currentListeners = nextListeners;
30872
30873 for (var i = 0; i < listeners.length; i++) {
30874 var listener = listeners[i];
30875 listener();
30876 }
30877
30878 return action;
30879 }
30880 /**
30881 * Replaces the reducer currently used by the store to calculate the state.
30882 *
30883 * You might need this if your app implements code splitting and you want to
30884 * load some of the reducers dynamically. You might also need this if you
30885 * implement a hot reloading mechanism for Redux.
30886 *
30887 * @param {Function} nextReducer The reducer for the store to use instead.
30888 * @returns {void}
30889 */
30890
30891
30892 function replaceReducer(nextReducer) {
30893 if (typeof nextReducer !== 'function') {
30894 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
30895 }
30896
30897 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
30898 // Any reducers that existed in both the new and old rootReducer
30899 // will receive the previous state. This effectively populates
30900 // the new state tree with any relevant data from the old one.
30901
30902 dispatch({
30903 type: ActionTypes.REPLACE
30904 });
30905 }
30906 /**
30907 * Interoperability point for observable/reactive libraries.
30908 * @returns {observable} A minimal observable of state changes.
30909 * For more information, see the observable proposal:
30910 * https://github.com/tc39/proposal-observable
30911 */
30912
30913
30914 function observable() {
30915 var _ref;
30916
30917 var outerSubscribe = subscribe;
30918 return _ref = {
30919 /**
30920 * The minimal observable subscription method.
30921 * @param {Object} observer Any object that can be used as an observer.
30922 * The observer object should have a `next` method.
30923 * @returns {subscription} An object with an `unsubscribe` method that can
30924 * be used to unsubscribe the observable from the store, and prevent further
30925 * emission of values from the observable.
30926 */
30927 subscribe: function subscribe(observer) {
30928 if (typeof observer !== 'object' || observer === null) {
30929 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
30930 }
30931
30932 function observeState() {
30933 if (observer.next) {
30934 observer.next(getState());
30935 }
30936 }
30937
30938 observeState();
30939 var unsubscribe = outerSubscribe(observeState);
30940 return {
30941 unsubscribe: unsubscribe
30942 };
30943 }
30944 }, _ref[$$observable] = function () {
30945 return this;
30946 }, _ref;
30947 } // When a store is created, an "INIT" action is dispatched so that every
30948 // reducer returns their initial state. This effectively populates
30949 // the initial state tree.
30950
30951
30952 dispatch({
30953 type: ActionTypes.INIT
30954 });
30955 return _ref2 = {
30956 dispatch: dispatch,
30957 subscribe: subscribe,
30958 getState: getState,
30959 replaceReducer: replaceReducer
30960 }, _ref2[$$observable] = observable, _ref2;
30961 }
30962 /**
30963 * Creates a Redux store that holds the state tree.
30964 *
30965 * **We recommend using `configureStore` from the
30966 * `@reduxjs/toolkit` package**, which replaces `createStore`:
30967 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
30968 *
30969 * The only way to change the data in the store is to call `dispatch()` on it.
30970 *
30971 * There should only be a single store in your app. To specify how different
30972 * parts of the state tree respond to actions, you may combine several reducers
30973 * into a single reducer function by using `combineReducers`.
30974 *
30975 * @param {Function} reducer A function that returns the next state tree, given
30976 * the current state tree and the action to handle.
30977 *
30978 * @param {any} [preloadedState] The initial state. You may optionally specify it
30979 * to hydrate the state from the server in universal apps, or to restore a
30980 * previously serialized user session.
30981 * If you use `combineReducers` to produce the root reducer function, this must be
30982 * an object with the same shape as `combineReducers` keys.
30983 *
30984 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
30985 * to enhance the store with third-party capabilities such as middleware,
30986 * time travel, persistence, etc. The only store enhancer that ships with Redux
30987 * is `applyMiddleware()`.
30988 *
30989 * @returns {Store} A Redux store that lets you read the state, dispatch actions
30990 * and subscribe to changes.
30991 */
30992
30993 var legacy_createStore = createStore;
30994
30995 /**
30996 * Prints a warning in the console if it exists.
30997 *
30998 * @param {String} message The warning message.
30999 * @returns {void}
31000 */
31001 function warning(message) {
31002 /* eslint-disable no-console */
31003 if (typeof console !== 'undefined' && typeof console.error === 'function') {
31004 console.error(message);
31005 }
31006 /* eslint-enable no-console */
31007
31008
31009 try {
31010 // This error was thrown as a convenience so that if you enable
31011 // "break on all exceptions" in your console,
31012 // it would pause the execution at this line.
31013 throw new Error(message);
31014 } catch (e) {} // eslint-disable-line no-empty
31015
31016 }
31017
31018 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
31019 var reducerKeys = Object.keys(reducers);
31020 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
31021
31022 if (reducerKeys.length === 0) {
31023 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
31024 }
31025
31026 if (!isPlainObject(inputState)) {
31027 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
31028 }
31029
31030 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
31031 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
31032 });
31033 unexpectedKeys.forEach(function (key) {
31034 unexpectedKeyCache[key] = true;
31035 });
31036 if (action && action.type === ActionTypes.REPLACE) return;
31037
31038 if (unexpectedKeys.length > 0) {
31039 return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
31040 }
31041 }
31042
31043 function assertReducerShape(reducers) {
31044 Object.keys(reducers).forEach(function (key) {
31045 var reducer = reducers[key];
31046 var initialState = reducer(undefined, {
31047 type: ActionTypes.INIT
31048 });
31049
31050 if (typeof initialState === 'undefined') {
31051 throw new Error( false ? 0 : "The slice reducer for key \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
31052 }
31053
31054 if (typeof reducer(undefined, {
31055 type: ActionTypes.PROBE_UNKNOWN_ACTION()
31056 }) === 'undefined') {
31057 throw new Error( false ? 0 : "The slice reducer for key \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle '" + ActionTypes.INIT + "' or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
31058 }
31059 });
31060 }
31061 /**
31062 * Turns an object whose values are different reducer functions, into a single
31063 * reducer function. It will call every child reducer, and gather their results
31064 * into a single state object, whose keys correspond to the keys of the passed
31065 * reducer functions.
31066 *
31067 * @param {Object} reducers An object whose values correspond to different
31068 * reducer functions that need to be combined into one. One handy way to obtain
31069 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
31070 * undefined for any action. Instead, they should return their initial state
31071 * if the state passed to them was undefined, and the current state for any
31072 * unrecognized action.
31073 *
31074 * @returns {Function} A reducer function that invokes every reducer inside the
31075 * passed object, and builds a state object with the same shape.
31076 */
31077
31078
31079 function combineReducers(reducers) {
31080 var reducerKeys = Object.keys(reducers);
31081 var finalReducers = {};
31082
31083 for (var i = 0; i < reducerKeys.length; i++) {
31084 var key = reducerKeys[i];
31085
31086 if (true) {
31087 if (typeof reducers[key] === 'undefined') {
31088 warning("No reducer provided for key \"" + key + "\"");
31089 }
31090 }
31091
31092 if (typeof reducers[key] === 'function') {
31093 finalReducers[key] = reducers[key];
31094 }
31095 }
31096
31097 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
31098 // keys multiple times.
31099
31100 var unexpectedKeyCache;
31101
31102 if (true) {
31103 unexpectedKeyCache = {};
31104 }
31105
31106 var shapeAssertionError;
31107
31108 try {
31109 assertReducerShape(finalReducers);
31110 } catch (e) {
31111 shapeAssertionError = e;
31112 }
31113
31114 return function combination(state, action) {
31115 if (state === void 0) {
31116 state = {};
31117 }
31118
31119 if (shapeAssertionError) {
31120 throw shapeAssertionError;
31121 }
31122
31123 if (true) {
31124 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
31125
31126 if (warningMessage) {
31127 warning(warningMessage);
31128 }
31129 }
31130
31131 var hasChanged = false;
31132 var nextState = {};
31133
31134 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
31135 var _key = finalReducerKeys[_i];
31136 var reducer = finalReducers[_key];
31137 var previousStateForKey = state[_key];
31138 var nextStateForKey = reducer(previousStateForKey, action);
31139
31140 if (typeof nextStateForKey === 'undefined') {
31141 var actionType = action && action.type;
31142 throw new Error( false ? 0 : "When called with an action of type " + (actionType ? "\"" + String(actionType) + "\"" : '(unknown type)') + ", the slice reducer for key \"" + _key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.");
31143 }
31144
31145 nextState[_key] = nextStateForKey;
31146 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
31147 }
31148
31149 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
31150 return hasChanged ? nextState : state;
31151 };
31152 }
31153
31154 function bindActionCreator(actionCreator, dispatch) {
31155 return function () {
31156 return dispatch(actionCreator.apply(this, arguments));
31157 };
31158 }
31159 /**
31160 * Turns an object whose values are action creators, into an object with the
31161 * same keys, but with every function wrapped into a `dispatch` call so they
31162 * may be invoked directly. This is just a convenience method, as you can call
31163 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
31164 *
31165 * For convenience, you can also pass an action creator as the first argument,
31166 * and get a dispatch wrapped function in return.
31167 *
31168 * @param {Function|Object} actionCreators An object whose values are action
31169 * creator functions. One handy way to obtain it is to use ES6 `import * as`
31170 * syntax. You may also pass a single function.
31171 *
31172 * @param {Function} dispatch The `dispatch` function available on your Redux
31173 * store.
31174 *
31175 * @returns {Function|Object} The object mimicking the original object, but with
31176 * every action creator wrapped into the `dispatch` call. If you passed a
31177 * function as `actionCreators`, the return value will also be a single
31178 * function.
31179 */
31180
31181
31182 function bindActionCreators(actionCreators, dispatch) {
31183 if (typeof actionCreators === 'function') {
31184 return bindActionCreator(actionCreators, dispatch);
31185 }
31186
31187 if (typeof actionCreators !== 'object' || actionCreators === null) {
31188 throw new Error( false ? 0 : "bindActionCreators expected an object or a function, but instead received: '" + kindOf(actionCreators) + "'. " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
31189 }
31190
31191 var boundActionCreators = {};
31192
31193 for (var key in actionCreators) {
31194 var actionCreator = actionCreators[key];
31195
31196 if (typeof actionCreator === 'function') {
31197 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
31198 }
31199 }
31200
31201 return boundActionCreators;
31202 }
31203
31204 /**
31205 * Composes single-argument functions from right to left. The rightmost
31206 * function can take multiple arguments as it provides the signature for
31207 * the resulting composite function.
31208 *
31209 * @param {...Function} funcs The functions to compose.
31210 * @returns {Function} A function obtained by composing the argument functions
31211 * from right to left. For example, compose(f, g, h) is identical to doing
31212 * (...args) => f(g(h(...args))).
31213 */
31214 function compose() {
31215 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
31216 funcs[_key] = arguments[_key];
31217 }
31218
31219 if (funcs.length === 0) {
31220 return function (arg) {
31221 return arg;
31222 };
31223 }
31224
31225 if (funcs.length === 1) {
31226 return funcs[0];
31227 }
31228
31229 return funcs.reduce(function (a, b) {
31230 return function () {
31231 return a(b.apply(void 0, arguments));
31232 };
31233 });
31234 }
31235
31236 /**
31237 * Creates a store enhancer that applies middleware to the dispatch method
31238 * of the Redux store. This is handy for a variety of tasks, such as expressing
31239 * asynchronous actions in a concise manner, or logging every action payload.
31240 *
31241 * See `redux-thunk` package as an example of the Redux middleware.
31242 *
31243 * Because middleware is potentially asynchronous, this should be the first
31244 * store enhancer in the composition chain.
31245 *
31246 * Note that each middleware will be given the `dispatch` and `getState` functions
31247 * as named arguments.
31248 *
31249 * @param {...Function} middlewares The middleware chain to be applied.
31250 * @returns {Function} A store enhancer applying the middleware.
31251 */
31252
31253 function applyMiddleware() {
31254 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
31255 middlewares[_key] = arguments[_key];
31256 }
31257
31258 return function (createStore) {
31259 return function () {
31260 var store = createStore.apply(void 0, arguments);
31261
31262 var _dispatch = function dispatch() {
31263 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
31264 };
31265
31266 var middlewareAPI = {
31267 getState: store.getState,
31268 dispatch: function dispatch() {
31269 return _dispatch.apply(void 0, arguments);
31270 }
31271 };
31272 var chain = middlewares.map(function (middleware) {
31273 return middleware(middlewareAPI);
31274 });
31275 _dispatch = compose.apply(void 0, chain)(store.dispatch);
31276 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
31277 dispatch: _dispatch
31278 });
31279 };
31280 };
31281 }
31282
31283
31284
31285
31286 /***/ }),
31287
31288 /***/ "../node_modules/reselect/es/defaultMemoize.js":
31289 /*!*****************************************************!*\
31290 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
31291 \*****************************************************/
31292 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31293
31294 "use strict";
31295 __webpack_require__.r(__webpack_exports__);
31296 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31297 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
31298 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
31299 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
31300 /* harmony export */ });
31301 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
31302 // https://github.com/erikras/lru-memoize
31303 var NOT_FOUND = 'NOT_FOUND';
31304
31305 function createSingletonCache(equals) {
31306 var entry;
31307 return {
31308 get: function get(key) {
31309 if (entry && equals(entry.key, key)) {
31310 return entry.value;
31311 }
31312
31313 return NOT_FOUND;
31314 },
31315 put: function put(key, value) {
31316 entry = {
31317 key: key,
31318 value: value
31319 };
31320 },
31321 getEntries: function getEntries() {
31322 return entry ? [entry] : [];
31323 },
31324 clear: function clear() {
31325 entry = undefined;
31326 }
31327 };
31328 }
31329
31330 function createLruCache(maxSize, equals) {
31331 var entries = [];
31332
31333 function get(key) {
31334 var cacheIndex = entries.findIndex(function (entry) {
31335 return equals(key, entry.key);
31336 }); // We found a cached entry
31337
31338 if (cacheIndex > -1) {
31339 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
31340
31341 if (cacheIndex > 0) {
31342 entries.splice(cacheIndex, 1);
31343 entries.unshift(entry);
31344 }
31345
31346 return entry.value;
31347 } // No entry found in cache, return sentinel
31348
31349
31350 return NOT_FOUND;
31351 }
31352
31353 function put(key, value) {
31354 if (get(key) === NOT_FOUND) {
31355 // TODO Is unshift slow?
31356 entries.unshift({
31357 key: key,
31358 value: value
31359 });
31360
31361 if (entries.length > maxSize) {
31362 entries.pop();
31363 }
31364 }
31365 }
31366
31367 function getEntries() {
31368 return entries;
31369 }
31370
31371 function clear() {
31372 entries = [];
31373 }
31374
31375 return {
31376 get: get,
31377 put: put,
31378 getEntries: getEntries,
31379 clear: clear
31380 };
31381 }
31382
31383 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
31384 return a === b;
31385 };
31386 function createCacheKeyComparator(equalityCheck) {
31387 return function areArgumentsShallowlyEqual(prev, next) {
31388 if (prev === null || next === null || prev.length !== next.length) {
31389 return false;
31390 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
31391
31392
31393 var length = prev.length;
31394
31395 for (var i = 0; i < length; i++) {
31396 if (!equalityCheck(prev[i], next[i])) {
31397 return false;
31398 }
31399 }
31400
31401 return true;
31402 };
31403 }
31404 // defaultMemoize now supports a configurable cache size with LRU behavior,
31405 // and optional comparison of the result value with existing values
31406 function defaultMemoize(func, equalityCheckOrOptions) {
31407 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
31408 equalityCheck: equalityCheckOrOptions
31409 };
31410 var _providedOptions$equa = providedOptions.equalityCheck,
31411 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
31412 _providedOptions$maxS = providedOptions.maxSize,
31413 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
31414 resultEqualityCheck = providedOptions.resultEqualityCheck;
31415 var comparator = createCacheKeyComparator(equalityCheck);
31416 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
31417
31418 function memoized() {
31419 var value = cache.get(arguments);
31420
31421 if (value === NOT_FOUND) {
31422 // @ts-ignore
31423 value = func.apply(null, arguments);
31424
31425 if (resultEqualityCheck) {
31426 var entries = cache.getEntries();
31427 var matchingEntry = entries.find(function (entry) {
31428 return resultEqualityCheck(entry.value, value);
31429 });
31430
31431 if (matchingEntry) {
31432 value = matchingEntry.value;
31433 }
31434 }
31435
31436 cache.put(arguments, value);
31437 }
31438
31439 return value;
31440 }
31441
31442 memoized.clearCache = function () {
31443 return cache.clear();
31444 };
31445
31446 return memoized;
31447 }
31448
31449 /***/ }),
31450
31451 /***/ "../node_modules/reselect/es/index.js":
31452 /*!********************************************!*\
31453 !*** ../node_modules/reselect/es/index.js ***!
31454 \********************************************/
31455 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31456
31457 "use strict";
31458 __webpack_require__.r(__webpack_exports__);
31459 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31460 /* harmony export */ createSelector: () => (/* binding */ createSelector),
31461 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
31462 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
31463 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
31464 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
31465 /* harmony export */ });
31466 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
31467
31468
31469
31470 function getDependencies(funcs) {
31471 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
31472
31473 if (!dependencies.every(function (dep) {
31474 return typeof dep === 'function';
31475 })) {
31476 var dependencyTypes = dependencies.map(function (dep) {
31477 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
31478 }).join(', ');
31479 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
31480 }
31481
31482 return dependencies;
31483 }
31484
31485 function createSelectorCreator(memoize) {
31486 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
31487 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
31488 }
31489
31490 var createSelector = function createSelector() {
31491 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
31492 funcs[_key2] = arguments[_key2];
31493 }
31494
31495 var _recomputations = 0;
31496
31497 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
31498 // So, start by declaring the default value here.
31499 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
31500
31501
31502 var directlyPassedOptions = {
31503 memoizeOptions: undefined
31504 }; // Normally, the result func or "output selector" is the last arg
31505
31506 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
31507
31508 if (typeof resultFunc === 'object') {
31509 directlyPassedOptions = resultFunc; // and pop the real result func off
31510
31511 resultFunc = funcs.pop();
31512 }
31513
31514 if (typeof resultFunc !== 'function') {
31515 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
31516 } // Determine which set of options we're using. Prefer options passed directly,
31517 // but fall back to options given to createSelectorCreator.
31518
31519
31520 var _directlyPassedOption = directlyPassedOptions,
31521 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
31522 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
31523 // is an array. In most libs I've looked at, it's an equality function or options object.
31524 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
31525 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
31526 // we wrap it in an array so we can apply it.
31527
31528 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
31529 var dependencies = getDependencies(funcs);
31530 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
31531 _recomputations++; // apply arguments instead of spreading for performance.
31532
31533 return resultFunc.apply(null, arguments);
31534 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
31535
31536 var selector = memoize(function dependenciesChecker() {
31537 var params = [];
31538 var length = dependencies.length;
31539
31540 for (var i = 0; i < length; i++) {
31541 // apply arguments instead of spreading and mutate a local list of params for performance.
31542 // @ts-ignore
31543 params.push(dependencies[i].apply(null, arguments));
31544 } // apply arguments instead of spreading for performance.
31545
31546
31547 _lastResult = memoizedResultFunc.apply(null, params);
31548 return _lastResult;
31549 });
31550 Object.assign(selector, {
31551 resultFunc: resultFunc,
31552 memoizedResultFunc: memoizedResultFunc,
31553 dependencies: dependencies,
31554 lastResult: function lastResult() {
31555 return _lastResult;
31556 },
31557 recomputations: function recomputations() {
31558 return _recomputations;
31559 },
31560 resetRecomputations: function resetRecomputations() {
31561 return _recomputations = 0;
31562 }
31563 });
31564 return selector;
31565 }; // @ts-ignore
31566
31567
31568 return createSelector;
31569 }
31570 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
31571 // Manual definition of state and output arguments
31572 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
31573 if (selectorCreator === void 0) {
31574 selectorCreator = createSelector;
31575 }
31576
31577 if (typeof selectors !== 'object') {
31578 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
31579 }
31580
31581 var objectKeys = Object.keys(selectors);
31582 var resultSelector = selectorCreator( // @ts-ignore
31583 objectKeys.map(function (key) {
31584 return selectors[key];
31585 }), function () {
31586 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
31587 values[_key3] = arguments[_key3];
31588 }
31589
31590 return values.reduce(function (composition, value, index) {
31591 composition[objectKeys[index]] = value;
31592 return composition;
31593 }, {});
31594 });
31595 return resultSelector;
31596 };
31597
31598 /***/ }),
31599
31600 /***/ "@wordpress/i18n":
31601 /*!**************************!*\
31602 !*** external "wp.i18n" ***!
31603 \**************************/
31604 /***/ ((module) => {
31605
31606 "use strict";
31607 module.exports = wp.i18n;
31608
31609 /***/ })
31610
31611 /******/ });
31612 /************************************************************************/
31613 /******/ // The module cache
31614 /******/ var __webpack_module_cache__ = {};
31615 /******/
31616 /******/ // The require function
31617 /******/ function __webpack_require__(moduleId) {
31618 /******/ // Check if module is in cache
31619 /******/ var cachedModule = __webpack_module_cache__[moduleId];
31620 /******/ if (cachedModule !== undefined) {
31621 /******/ return cachedModule.exports;
31622 /******/ }
31623 /******/ // Create a new module (and put it into the cache)
31624 /******/ var module = __webpack_module_cache__[moduleId] = {
31625 /******/ // no module.id needed
31626 /******/ // no module.loaded needed
31627 /******/ exports: {}
31628 /******/ };
31629 /******/
31630 /******/ // Execute the module function
31631 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
31632 /******/
31633 /******/ // Return the exports of the module
31634 /******/ return module.exports;
31635 /******/ }
31636 /******/
31637 /************************************************************************/
31638 /******/ /* webpack/runtime/define property getters */
31639 /******/ (() => {
31640 /******/ // define getter functions for harmony exports
31641 /******/ __webpack_require__.d = (exports, definition) => {
31642 /******/ for(var key in definition) {
31643 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
31644 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
31645 /******/ }
31646 /******/ }
31647 /******/ };
31648 /******/ })();
31649 /******/
31650 /******/ /* webpack/runtime/global */
31651 /******/ (() => {
31652 /******/ __webpack_require__.g = (function() {
31653 /******/ if (typeof globalThis === 'object') return globalThis;
31654 /******/ try {
31655 /******/ return this || new Function('return this')();
31656 /******/ } catch (e) {
31657 /******/ if (typeof window === 'object') return window;
31658 /******/ }
31659 /******/ })();
31660 /******/ })();
31661 /******/
31662 /******/ /* webpack/runtime/hasOwnProperty shorthand */
31663 /******/ (() => {
31664 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
31665 /******/ })();
31666 /******/
31667 /******/ /* webpack/runtime/make namespace object */
31668 /******/ (() => {
31669 /******/ // define __esModule on exports
31670 /******/ __webpack_require__.r = (exports) => {
31671 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
31672 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
31673 /******/ }
31674 /******/ Object.defineProperty(exports, '__esModule', { value: true });
31675 /******/ };
31676 /******/ })();
31677 /******/
31678 /************************************************************************/
31679 var __webpack_exports__ = {};
31680 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
31681 (() => {
31682 "use strict";
31683 /*!******************************************!*\
31684 !*** ../core/common/assets/js/common.js ***!
31685 \******************************************/
31686
31687
31688 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
31689 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
31690 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
31691 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
31692 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
31693 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
31694 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
31695 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
31696 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
31697 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
31698 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
31699 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
31700 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
31701 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
31702 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
31703 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
31704 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
31705 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
31706 function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
31707 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
31708 function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
31709 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
31710 function ElementorCommonApp() {
31711 (0, _classCallCheck2.default)(this, ElementorCommonApp);
31712 return _callSuper(this, ElementorCommonApp, arguments);
31713 }
31714 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
31715 return (0, _createClass2.default)(ElementorCommonApp, [{
31716 key: "setMarionetteTemplateCompiler",
31717 value: function setMarionetteTemplateCompiler() {
31718 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
31719 options = {
31720 evaluate: /<#([\s\S]+?)#>/g,
31721 interpolate: /{{{([\s\S]+?)}}}/g,
31722 escape: /{{([^}]+?)}}(?!})/g
31723 };
31724 return _.template(rawTemplate, options);
31725 };
31726 }
31727 }, {
31728 key: "getDefaultElements",
31729 value: function getDefaultElements() {
31730 return {
31731 $window: jQuery(window),
31732 $document: jQuery(document),
31733 $body: jQuery(document.body)
31734 };
31735 }
31736 }, {
31737 key: "initComponents",
31738 value: function initComponents() {
31739 this.events = new _events.default();
31740 this.eventsManager = new _module.default();
31741 this.debug = new _debug.default();
31742 this.helpers = new _helpers.default();
31743 this.storage = new _storage.default();
31744 this.dialogsManager = new DialogsManager.Instance();
31745 this.notifications = new _notifications.default();
31746 this.api = window.$e;
31747 $e.components.register(new _component2.default());
31748 elementorCommon.elements.$window.on('elementor:init-components', function () {
31749 $e.components.register(new _component.default());
31750 });
31751 this.initModules();
31752 }
31753 }, {
31754 key: "initModules",
31755 value: function initModules() {
31756 var _this = this;
31757 var activeModules = this.config.activeModules;
31758 var modules = {
31759 ajax: _ajax.default,
31760 finder: _finder.default,
31761 connect: _connect.default
31762 };
31763 activeModules.forEach(function (name) {
31764 if (modules[name]) {
31765 _this[name] = new modules[name](_this.config[name]);
31766 }
31767 });
31768 }
31769 }, {
31770 key: "compileArrayTemplateArgs",
31771 value: function compileArrayTemplateArgs(template, templateArgs) {
31772 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
31773 if (!number) {
31774 number = 1;
31775 }
31776 number--;
31777 return undefined !== templateArgs[number] ? templateArgs[number] : match;
31778 });
31779 }
31780 }, {
31781 key: "compileObjectTemplateArgs",
31782 value: function compileObjectTemplateArgs(template, templateArgs) {
31783 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
31784 return templateArgs[name] ? templateArgs[name] : match;
31785 });
31786 }
31787 }, {
31788 key: "compileTemplate",
31789 value: function compileTemplate(template, templateArgs) {
31790 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
31791 }
31792 }, {
31793 key: "translate",
31794 value: function translate(stringKey, context, templateArgs, i18nStack) {
31795 if (context) {
31796 i18nStack = this.config[context].i18n;
31797 }
31798 if (!i18nStack) {
31799 i18nStack = this.config.i18n;
31800 }
31801 var string = i18nStack[stringKey];
31802 if (undefined === string) {
31803 string = stringKey;
31804 }
31805 if (templateArgs) {
31806 string = this.compileTemplate(string, templateArgs);
31807 }
31808 return string;
31809 }
31810 }, {
31811 key: "onInit",
31812 value: function onInit() {
31813 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
31814 this.config = elementorCommonConfig;
31815 this.setMarionetteTemplateCompiler();
31816 }
31817 }]);
31818 }(elementorModules.ViewModule);
31819 window.elementorCommon = new ElementorCommonApp();
31820 elementorCommon.initComponents();
31821 })();
31822
31823 /******/ })()
31824 ;
31825 //# sourceMappingURL=common.js.map