PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.0-dev3
Elementor Website Builder – more than just a page builder v3.32.0-dev3
4.3.0-beta3 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 All 452 releases
elementor / assets / js / common.js

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

31,809 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 - 08-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 _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
1923 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1924 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1925 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1926 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1927 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.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 (0, _classCallCheck2.default)(this, _default);
1938 return _callSuper(this, _default, arguments);
1939 }
1940 (0, _inherits2.default)(_default, _elementorModules$Mod);
1941 return (0, _createClass2.default)(_default, [{
1942 key: "onInit",
1943 value: function onInit() {
1944 var _elementorCommon$conf;
1945 this.config = _eventsConfig.default;
1946 if ((_elementorCommon$conf = elementorCommon.config.editor_events) !== null && _elementorCommon$conf !== void 0 && _elementorCommon$conf.can_send_events) {
1947 var _elementorCommon$conf2, _elementorCommon$conf3;
1948 _mixpanelBrowser.default.init((_elementorCommon$conf2 = elementorCommon.config.editor_events) === null || _elementorCommon$conf2 === void 0 ? void 0 : _elementorCommon$conf2.token, {
1949 persistence: 'localStorage'
1950 });
1951 var userId = (_elementorCommon$conf3 = elementorCommon.config.library_connect) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.user_id;
1952 if (userId) {
1953 var _elementorCommon$conf4;
1954 _mixpanelBrowser.default.identify(userId);
1955 _mixpanelBrowser.default.register({
1956 appType: 'Editor'
1957 });
1958 _mixpanelBrowser.default.people.set_once({
1959 $user_id: userId,
1960 $last_login: new Date().toISOString(),
1961 $plan_type: ((_elementorCommon$conf4 = elementorCommon.config.library_connect) === null || _elementorCommon$conf4 === void 0 ? void 0 : _elementorCommon$conf4.plan_type) || _tiers.TIERS.free
1962 });
1963 }
1964 }
1965 }
1966 }, {
1967 key: "dispatchEvent",
1968 value: function dispatchEvent(name, data) {
1969 var _elementorCommon$conf5, _elementorCommon$conf6, _elementorCommon$conf7, _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10, _elementorCommon$conf11;
1970 if (!((_elementorCommon$conf5 = elementorCommon.config.editor_events) !== null && _elementorCommon$conf5 !== void 0 && _elementorCommon$conf5.can_send_events)) {
1971 return;
1972 }
1973 var eventData = _objectSpread({
1974 user_id: ((_elementorCommon$conf6 = elementorCommon.config.library_connect) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.user_id) || null,
1975 subscription_id: ((_elementorCommon$conf7 = elementorCommon.config.editor_events) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.subscription_id) || null,
1976 user_tier: ((_elementorCommon$conf8 = elementorCommon.config.library_connect) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.current_access_tier) || null,
1977 url: (_elementorCommon$conf9 = elementorCommon.config.editor_events) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.site_url,
1978 wp_version: (_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.wp_version,
1979 client_id: (_elementorCommon$conf1 = elementorCommon.config.editor_events) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.site_key,
1980 app_version: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.elementor_version,
1981 site_language: (_elementorCommon$conf11 = elementorCommon.config.editor_events) === null || _elementorCommon$conf11 === void 0 ? void 0 : _elementorCommon$conf11.site_language
1982 }, data);
1983 _mixpanelBrowser.default.track(name, _objectSpread({}, eventData));
1984 }
1985 }]);
1986 }(elementorModules.Module);
1987
1988 /***/ }),
1989
1990 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
1991 /*!*****************************************************************!*\
1992 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
1993 \*****************************************************************/
1994 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1995
1996 "use strict";
1997
1998
1999 Object.defineProperty(exports, "__esModule", ({
2000 value: true
2001 }));
2002 Object.defineProperty(exports, "NavigateDown", ({
2003 enumerable: true,
2004 get: function get() {
2005 return _navigateDown.NavigateDown;
2006 }
2007 }));
2008 Object.defineProperty(exports, "NavigateSelect", ({
2009 enumerable: true,
2010 get: function get() {
2011 return _navigateSelect.NavigateSelect;
2012 }
2013 }));
2014 Object.defineProperty(exports, "NavigateUp", ({
2015 enumerable: true,
2016 get: function get() {
2017 return _navigateUp.NavigateUp;
2018 }
2019 }));
2020 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2021 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2022 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2023
2024 /***/ }),
2025
2026 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2027 /*!*************************************************************************!*\
2028 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2029 \*************************************************************************/
2030 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2031
2032 "use strict";
2033
2034
2035 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2036 Object.defineProperty(exports, "__esModule", ({
2037 value: true
2038 }));
2039 exports["default"] = exports.NavigateDown = void 0;
2040 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2041 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2042 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2043 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2044 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2045 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2046 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)); }
2047 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2048 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2049 function NavigateDown() {
2050 (0, _classCallCheck2.default)(this, NavigateDown);
2051 return _callSuper(this, NavigateDown, arguments);
2052 }
2053 (0, _inherits2.default)(NavigateDown, _CommandBase);
2054 return (0, _createClass2.default)(NavigateDown, [{
2055 key: "apply",
2056 value: function apply() {
2057 this.component.getItemsView().activateNextItem();
2058 }
2059 }]);
2060 }(_commandBase.default);
2061 var _default = exports["default"] = NavigateDown;
2062
2063 /***/ }),
2064
2065 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2066 /*!***************************************************************************!*\
2067 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2068 \***************************************************************************/
2069 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2070
2071 "use strict";
2072
2073
2074 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2075 Object.defineProperty(exports, "__esModule", ({
2076 value: true
2077 }));
2078 exports["default"] = exports.NavigateSelect = void 0;
2079 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2080 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2081 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2082 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2083 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2084 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2085 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)); }
2086 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2087 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2088 function NavigateSelect() {
2089 (0, _classCallCheck2.default)(this, NavigateSelect);
2090 return _callSuper(this, NavigateSelect, arguments);
2091 }
2092 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2093 return (0, _createClass2.default)(NavigateSelect, [{
2094 key: "apply",
2095 value: function apply(args) {
2096 this.component.getItemsView().goToActiveItem(args);
2097 }
2098 }]);
2099 }(_commandBase.default);
2100 var _default = exports["default"] = NavigateSelect;
2101
2102 /***/ }),
2103
2104 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2105 /*!***********************************************************************!*\
2106 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2107 \***********************************************************************/
2108 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2109
2110 "use strict";
2111
2112
2113 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2114 Object.defineProperty(exports, "__esModule", ({
2115 value: true
2116 }));
2117 exports["default"] = exports.NavigateUp = void 0;
2118 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2119 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2120 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2121 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2122 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2123 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2124 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)); }
2125 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2126 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2127 function NavigateUp() {
2128 (0, _classCallCheck2.default)(this, NavigateUp);
2129 return _callSuper(this, NavigateUp, arguments);
2130 }
2131 (0, _inherits2.default)(NavigateUp, _CommandBase);
2132 return (0, _createClass2.default)(NavigateUp, [{
2133 key: "apply",
2134 value: function apply() {
2135 this.component.getItemsView().activateNextItem(true);
2136 }
2137 }]);
2138 }(_commandBase.default);
2139 var _default = exports["default"] = NavigateUp;
2140
2141 /***/ }),
2142
2143 /***/ "../core/common/modules/finder/assets/js/component.js":
2144 /*!************************************************************!*\
2145 !*** ../core/common/modules/finder/assets/js/component.js ***!
2146 \************************************************************/
2147 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2148
2149 "use strict";
2150
2151
2152 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2153 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2154 Object.defineProperty(exports, "__esModule", ({
2155 value: true
2156 }));
2157 exports["default"] = void 0;
2158 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2159 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2160 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2161 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2162 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2163 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2164 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2165 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2166 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2167 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2168 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); }
2169 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; }
2170 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; }
2171 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)); }
2172 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2173 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; }
2174 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2175 function Component() {
2176 (0, _classCallCheck2.default)(this, Component);
2177 return _callSuper(this, Component, arguments);
2178 }
2179 (0, _inherits2.default)(Component, _ComponentModalBase);
2180 return (0, _createClass2.default)(Component, [{
2181 key: "getNamespace",
2182 value: function getNamespace() {
2183 return 'finder';
2184 }
2185 }, {
2186 key: "defaultShortcuts",
2187 value: function defaultShortcuts() {
2188 var _this = this;
2189 return {
2190 '': {
2191 keys: 'ctrl+e'
2192 },
2193 'navigate-down': {
2194 keys: 'down',
2195 scopes: [this.getNamespace()],
2196 dependency: function dependency() {
2197 return _this.getItemsView();
2198 }
2199 },
2200 'navigate-up': {
2201 keys: 'up',
2202 scopes: [this.getNamespace()],
2203 dependency: function dependency() {
2204 return _this.getItemsView();
2205 }
2206 },
2207 'navigate-select': {
2208 keys: 'enter',
2209 scopes: [this.getNamespace()],
2210 dependency: function dependency() {
2211 return _this.getItemsView().$activeItem;
2212 }
2213 }
2214 };
2215 }
2216 }, {
2217 key: "defaultCommands",
2218 value: function defaultCommands() {
2219 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2220 return _objectSpread(_objectSpread({
2221 'navigate/down': function navigate_down() {
2222 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2223 $e.run('finder/navigate-down');
2224 },
2225 'navigate/up': function navigate_up() {
2226 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2227 $e.run('finder/navigate-up');
2228 },
2229 'navigate/select': function navigate_select(event) {
2230 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2231
2232 // TODO: Fix $e.shortcuts use args. ( args.event ).
2233 $e.run('finder/navigate-select', event);
2234 }
2235 }, modalCommands), this.importCommands(commands));
2236 }
2237 }, {
2238 key: "getModalLayout",
2239 value: function getModalLayout() {
2240 return _layout.default;
2241 }
2242 }, {
2243 key: "getItemsView",
2244 value: function getItemsView() {
2245 return this.layout.modalContent.currentView.content.currentView;
2246 }
2247 }]);
2248 }(_componentModalBase.default);
2249
2250 /***/ }),
2251
2252 /***/ "../core/common/modules/finder/assets/js/finder.js":
2253 /*!*********************************************************!*\
2254 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2255 \*********************************************************/
2256 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2257
2258 "use strict";
2259
2260
2261 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2262 Object.defineProperty(exports, "__esModule", ({
2263 value: true
2264 }));
2265 exports["default"] = void 0;
2266 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2267 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2268 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2269 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2270 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2271 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2272 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)); }
2273 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2274 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2275 function _default() {
2276 (0, _classCallCheck2.default)(this, _default);
2277 return _callSuper(this, _default, arguments);
2278 }
2279 (0, _inherits2.default)(_default, _elementorModules$Mod);
2280 return (0, _createClass2.default)(_default, [{
2281 key: "onInit",
2282 value: function onInit() {
2283 // TODO: Temp fix, do not load finder in theme-builder.
2284 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
2285 if (window.top !== window) {
2286 return;
2287 }
2288 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
2289 $e.components.register(new _component.default({
2290 manager: this
2291 }));
2292 }
2293 }]);
2294 }(elementorModules.Module);
2295
2296 /***/ }),
2297
2298 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
2299 /*!*******************************************************************!*\
2300 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
2301 \*******************************************************************/
2302 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2303
2304 "use strict";
2305
2306
2307 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2308 Object.defineProperty(exports, "__esModule", ({
2309 value: true
2310 }));
2311 exports["default"] = void 0;
2312 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2313 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2314 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2315 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2316 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2317 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)); }
2318 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2319 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
2320 function _default() {
2321 (0, _classCallCheck2.default)(this, _default);
2322 return _callSuper(this, _default, arguments);
2323 }
2324 (0, _inherits2.default)(_default, _Backbone$Model);
2325 return (0, _createClass2.default)(_default, [{
2326 key: "defaults",
2327 value: function defaults() {
2328 return {
2329 description: '',
2330 icon: 'settings',
2331 url: '',
2332 keywords: [],
2333 actions: [],
2334 lock: null
2335 };
2336 }
2337 }]);
2338 }(Backbone.Model);
2339
2340 /***/ }),
2341
2342 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
2343 /*!*************************************************************************!*\
2344 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
2345 \*************************************************************************/
2346 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2347
2348 "use strict";
2349
2350
2351 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2352 Object.defineProperty(exports, "__esModule", ({
2353 value: true
2354 }));
2355 exports["default"] = void 0;
2356 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2357 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2358 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2359 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2360 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2361 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2362 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
2363 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)); }
2364 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2365 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2366 function _default() {
2367 (0, _classCallCheck2.default)(this, _default);
2368 return _callSuper(this, _default, arguments);
2369 }
2370 (0, _inherits2.default)(_default, _Marionette$Composite);
2371 return (0, _createClass2.default)(_default, [{
2372 key: "id",
2373 value: function id() {
2374 return 'elementor-finder__results-container';
2375 }
2376 }, {
2377 key: "ui",
2378 value: function ui() {
2379 this.selectors = {
2380 noResults: '#elementor-finder__no-results',
2381 categoryItem: '.elementor-finder__results__item'
2382 };
2383 return this.selectors;
2384 }
2385 }, {
2386 key: "events",
2387 value: function events() {
2388 return {
2389 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
2390 };
2391 }
2392 }, {
2393 key: "getTemplate",
2394 value: function getTemplate() {
2395 return '#tmpl-elementor-finder-results-container';
2396 }
2397 }, {
2398 key: "getChildView",
2399 value: function getChildView(childModel) {
2400 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
2401 }
2402 }, {
2403 key: "initialize",
2404 value: function initialize() {
2405 this.$activeItem = null;
2406 this.childViewContainer = '#elementor-finder__results';
2407 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
2408 }
2409 }, {
2410 key: "activateItem",
2411 value: function activateItem($item) {
2412 if (this.$activeItem) {
2413 this.$activeItem.removeClass('elementor-active');
2414 }
2415 $item.addClass('elementor-active');
2416 this.$activeItem = $item;
2417 }
2418 }, {
2419 key: "activateNextItem",
2420 value: function activateNextItem(reverse) {
2421 var $allItems = jQuery(this.selectors.categoryItem);
2422 var nextItemIndex = 0;
2423 if (this.$activeItem) {
2424 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
2425 if (nextItemIndex >= $allItems.length) {
2426 nextItemIndex = 0;
2427 } else if (nextItemIndex < 0) {
2428 nextItemIndex = $allItems.length - 1;
2429 }
2430 }
2431 var $nextItem = $allItems.eq(nextItemIndex);
2432 this.activateItem($nextItem);
2433 $nextItem[0].scrollIntoView({
2434 block: 'nearest'
2435 });
2436 }
2437 }, {
2438 key: "goToActiveItem",
2439 value: function goToActiveItem(event) {
2440 var $a = this.$activeItem.children('a'),
2441 isControlClicked = $e.shortcuts.isControlEvent(event);
2442 if (isControlClicked) {
2443 $a.attr('target', '_blank');
2444 }
2445 $a[0].click();
2446 if (isControlClicked) {
2447 $a.removeAttr('target');
2448 }
2449 }
2450 }, {
2451 key: "onCategoryItemMouseEnter",
2452 value: function onCategoryItemMouseEnter(event) {
2453 this.activateItem(jQuery(event.currentTarget));
2454 }
2455 }, {
2456 key: "onChildviewToggleVisibility",
2457 value: function onChildviewToggleVisibility() {
2458 var allCategoriesAreEmpty = this.children.every(function (child) {
2459 return !child.isVisible;
2460 });
2461 this.ui.noResults.toggle(allCategoriesAreEmpty);
2462 }
2463 }]);
2464 }(Marionette.CompositeView);
2465
2466 /***/ }),
2467
2468 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
2469 /*!***********************************************************************!*\
2470 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
2471 \***********************************************************************/
2472 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2473
2474 "use strict";
2475
2476
2477 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2478 Object.defineProperty(exports, "__esModule", ({
2479 value: true
2480 }));
2481 exports["default"] = void 0;
2482 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2483 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2484 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2485 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2486 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2487 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
2488 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
2489 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)); }
2490 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2491 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
2492 function _default() {
2493 (0, _classCallCheck2.default)(this, _default);
2494 return _callSuper(this, _default, arguments);
2495 }
2496 (0, _inherits2.default)(_default, _Marionette$Composite);
2497 return (0, _createClass2.default)(_default, [{
2498 key: "className",
2499 value: function className() {
2500 return 'elementor-finder__results__category';
2501 }
2502 }, {
2503 key: "getTemplate",
2504 value: function getTemplate() {
2505 return '#tmpl-elementor-finder__results__category';
2506 }
2507 }, {
2508 key: "getChildView",
2509 value: function getChildView() {
2510 return _item.default;
2511 }
2512 }, {
2513 key: "initialize",
2514 value: function initialize() {
2515 this.childViewContainer = '.elementor-finder__results__category__items';
2516 this.isVisible = true;
2517 var items = this.model.get('items');
2518 if (items) {
2519 items = Object.values(items);
2520 }
2521 this.collection = new Backbone.Collection(items, {
2522 model: _item2.default
2523 });
2524 }
2525 }, {
2526 key: "filter",
2527 value: function filter(childModel) {
2528 var textFilter = this.getTextFilter();
2529 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
2530 return true;
2531 }
2532 return childModel.get('keywords').some(function (keyword) {
2533 return keyword.indexOf(textFilter) >= 0;
2534 });
2535 }
2536 }, {
2537 key: "getTextFilter",
2538 value: function getTextFilter() {
2539 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
2540 }
2541 }, {
2542 key: "toggleElement",
2543 value: function toggleElement() {
2544 var isCurrentlyVisible = !!this.children.length;
2545 if (isCurrentlyVisible !== this.isVisible) {
2546 this.isVisible = isCurrentlyVisible;
2547 this.$el.toggle(isCurrentlyVisible);
2548 this.triggerMethod('toggle:visibility');
2549 }
2550 }
2551 }, {
2552 key: "onRender",
2553 value: function onRender() {
2554 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
2555 }
2556 }, {
2557 key: "onFilterChange",
2558 value: function onFilterChange() {
2559 this._renderChildren();
2560 }
2561 }, {
2562 key: "onRenderCollection",
2563 value: function onRenderCollection() {
2564 this.toggleElement();
2565 }
2566 }]);
2567 }(Marionette.CompositeView);
2568
2569 /***/ }),
2570
2571 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
2572 /*!**********************************************************************!*\
2573 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
2574 \**********************************************************************/
2575 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2576
2577 "use strict";
2578
2579
2580 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2581 Object.defineProperty(exports, "__esModule", ({
2582 value: true
2583 }));
2584 exports["default"] = void 0;
2585 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2586 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2587 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2588 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2589 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2590 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
2591 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)); }
2592 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2593 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
2594 function _default() {
2595 (0, _classCallCheck2.default)(this, _default);
2596 return _callSuper(this, _default, arguments);
2597 }
2598 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
2599 return (0, _createClass2.default)(_default, [{
2600 key: "id",
2601 value: function id() {
2602 return 'elementor-finder';
2603 }
2604 }, {
2605 key: "getTemplate",
2606 value: function getTemplate() {
2607 return '#tmpl-elementor-finder';
2608 }
2609 }, {
2610 key: "ui",
2611 value: function ui() {
2612 return {
2613 searchInput: '#elementor-finder__search__input'
2614 };
2615 }
2616 }, {
2617 key: "events",
2618 value: function events() {
2619 return {
2620 'input @ui.searchInput': 'onSearchInputInput'
2621 };
2622 }
2623 }, {
2624 key: "regions",
2625 value: function regions() {
2626 return {
2627 content: '#elementor-finder__content'
2628 };
2629 }
2630 }, {
2631 key: "showCategoriesView",
2632 value: function showCategoriesView() {
2633 this.content.show(new _categories.default());
2634 }
2635 }, {
2636 key: "onSearchInputInput",
2637 value: function onSearchInputInput() {
2638 var value = this.ui.searchInput.val();
2639 if (value) {
2640 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
2641 if (!(this.content.currentView instanceof _categories.default)) {
2642 this.showCategoriesView();
2643 }
2644 }
2645 this.content.currentView.$el.toggle(!!value);
2646 }
2647 }]);
2648 }(Marionette.LayoutView);
2649
2650 /***/ }),
2651
2652 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
2653 /*!*******************************************************************************!*\
2654 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
2655 \*******************************************************************************/
2656 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2657
2658 "use strict";
2659
2660
2661 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2662 Object.defineProperty(exports, "__esModule", ({
2663 value: true
2664 }));
2665 exports["default"] = void 0;
2666 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2667 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2668 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2669 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2670 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2671 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2672 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
2673 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)); }
2674 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2675 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; }
2676 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
2677 function _default() {
2678 (0, _classCallCheck2.default)(this, _default);
2679 return _callSuper(this, _default, arguments);
2680 }
2681 (0, _inherits2.default)(_default, _Category);
2682 return (0, _createClass2.default)(_default, [{
2683 key: "className",
2684 value: function className() {
2685 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
2686 }
2687 }, {
2688 key: "ui",
2689 value: function ui() {
2690 return {
2691 title: '.elementor-finder__results__category__title'
2692 };
2693 }
2694 }, {
2695 key: "fetchData",
2696 value: function fetchData() {
2697 var _this = this;
2698 this.ui.loadingIcon.show();
2699 elementorCommon.ajax.addRequest('finder_get_category_items', {
2700 data: {
2701 category: this.model.get('name'),
2702 filter: this.getTextFilter()
2703 },
2704 success: function success(data) {
2705 if (_this.isDestroyed) {
2706 return;
2707 }
2708 _this.collection.set(data);
2709 _this.toggleElement();
2710 _this.ui.loadingIcon.hide();
2711 }
2712 });
2713 }
2714 }, {
2715 key: "filter",
2716 value: function filter() {
2717 return true;
2718 }
2719 }, {
2720 key: "onFilterChange",
2721 value: function onFilterChange() {
2722 this.fetchData();
2723 }
2724 }, {
2725 key: "onRender",
2726 value: function onRender() {
2727 _superPropGet(_default, "onRender", this, 3)([]);
2728 this.ui.loadingIcon = jQuery('<i>', {
2729 class: 'eicon-loading eicon-animation-spin'
2730 });
2731 this.ui.title.after(this.ui.loadingIcon);
2732 this.fetchData();
2733 }
2734 }]);
2735 }(_category.default);
2736
2737 /***/ }),
2738
2739 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
2740 /*!*******************************************************************!*\
2741 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
2742 \*******************************************************************/
2743 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2744
2745 "use strict";
2746 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
2747
2748
2749 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2750 Object.defineProperty(exports, "__esModule", ({
2751 value: true
2752 }));
2753 exports["default"] = void 0;
2754 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2755 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2756 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2757 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2758 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2759 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)); }
2760 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2761 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
2762 function _default() {
2763 (0, _classCallCheck2.default)(this, _default);
2764 return _callSuper(this, _default, arguments);
2765 }
2766 (0, _inherits2.default)(_default, _Marionette$ItemView);
2767 return (0, _createClass2.default)(_default, [{
2768 key: "className",
2769 value: function className() {
2770 return 'elementor-finder__results__item';
2771 }
2772 }, {
2773 key: "getTemplate",
2774 value: function getTemplate() {
2775 return '#tmpl-elementor-finder__results__item';
2776 }
2777 }, {
2778 key: "events",
2779 value: function events() {
2780 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
2781 }
2782 }, {
2783 key: "onClick",
2784 value: function onClick(e) {
2785 var _this = this;
2786 var lockOptions = this.model.get('lock');
2787 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
2788 return;
2789 }
2790 e.preventDefault();
2791 e.stopImmediatePropagation();
2792 elementorCommon.dialogsManager.createWidget('confirm', {
2793 id: 'elementor-finder__lock-dialog',
2794 headerMessage: lockOptions.content.heading,
2795 message: lockOptions.content.description,
2796 position: {
2797 my: 'center center',
2798 at: 'center center'
2799 },
2800 strings: {
2801 confirm: lockOptions.button.text,
2802 cancel: __('Cancel', 'elementor')
2803 },
2804 onConfirm: function onConfirm() {
2805 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
2806 window.open(link, '_blank');
2807 }
2808 }).show();
2809 }
2810 }, {
2811 key: "replaceLockLinkPlaceholders",
2812 value: function replaceLockLinkPlaceholders(link) {
2813 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
2814 }
2815 }]);
2816 }(Marionette.ItemView);
2817
2818 /***/ }),
2819
2820 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
2821 /*!*********************************************************************!*\
2822 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
2823 \*********************************************************************/
2824 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2825
2826 "use strict";
2827 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
2828
2829
2830 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2831 Object.defineProperty(exports, "__esModule", ({
2832 value: true
2833 }));
2834 exports["default"] = void 0;
2835 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2836 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2837 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2838 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2839 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2840 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2841 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
2842 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)); }
2843 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2844 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; }
2845 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
2846 function _default() {
2847 (0, _classCallCheck2.default)(this, _default);
2848 return _callSuper(this, _default, arguments);
2849 }
2850 (0, _inherits2.default)(_default, _elementorModules$com);
2851 return (0, _createClass2.default)(_default, [{
2852 key: "getModalOptions",
2853 value: function getModalOptions() {
2854 return {
2855 id: 'elementor-finder__modal',
2856 draggable: true,
2857 effects: {
2858 show: 'show',
2859 hide: 'hide'
2860 },
2861 position: {
2862 enable: false
2863 }
2864 };
2865 }
2866 }, {
2867 key: "getLogoOptions",
2868 value: function getLogoOptions() {
2869 return {
2870 title: __('Finder', 'elementor')
2871 };
2872 }
2873 }, {
2874 key: "initialize",
2875 value: function initialize() {
2876 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2877 args[_key] = arguments[_key];
2878 }
2879 _superPropGet(_default, "initialize", this, 3)(args);
2880 this.showLogo();
2881 this.showContentView();
2882 }
2883 }, {
2884 key: "showContentView",
2885 value: function showContentView() {
2886 this.modalContent.show(new _content.default());
2887 }
2888 }, {
2889 key: "showModal",
2890 value: function showModal() {
2891 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2892 args[_key2] = arguments[_key2];
2893 }
2894 _superPropGet(_default, "showModal", this, 3)(args);
2895 this.modalContent.currentView.ui.searchInput.focus();
2896 }
2897 }]);
2898 }(elementorModules.common.views.modal.Layout);
2899
2900 /***/ }),
2901
2902 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
2903 /*!*******************************************************************!*\
2904 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
2905 \*******************************************************************/
2906 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2907
2908 "use strict";
2909
2910
2911 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2912 Object.defineProperty(exports, "__esModule", ({
2913 value: true
2914 }));
2915 exports["default"] = void 0;
2916 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2917 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2918 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2919 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2920 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2921 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
2922 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2923 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
2924 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
2925 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; }
2926 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; }
2927 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)); }
2928 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2929 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
2930 /**
2931 * Error constructor.
2932 *
2933 * @param {string} message
2934 * @param {string} code
2935 * @param {*} data
2936 */
2937 function BaseError() {
2938 var _this;
2939 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
2940 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2941 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
2942 (0, _classCallCheck2.default)(this, BaseError);
2943 _this = _callSuper(this, BaseError, [message]);
2944 /**
2945 * The server error code.
2946 *
2947 * @type {string}
2948 */
2949 (0, _defineProperty2.default)(_this, "code", '');
2950 /**
2951 * Additional data about the current error.
2952 *
2953 * @type {*[]}
2954 */
2955 (0, _defineProperty2.default)(_this, "data", []);
2956 _this.code = code;
2957 _this.data = data;
2958 return _this;
2959 }
2960
2961 /**
2962 * Notify a message when the error occurs.
2963 */
2964 (0, _inherits2.default)(BaseError, _Error);
2965 return (0, _createClass2.default)(BaseError, [{
2966 key: "notify",
2967 value: function notify() {
2968 _console.default.error(_objectSpread({
2969 message: this.message
2970 }, this));
2971 }
2972 }], [{
2973 key: "create",
2974 value:
2975 /**
2976 * Static helper function to create the error.
2977 *
2978 * @param {string} message
2979 * @param {string} code
2980 * @param {*} data
2981 * @return {BaseError} error
2982 */
2983 function create(message) {
2984 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2985 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
2986 return new this(message, code, data);
2987 }
2988
2989 /**
2990 * Returns the status code of the error.
2991 */
2992 }, {
2993 key: "getHTTPErrorCode",
2994 value: function getHTTPErrorCode() {
2995 (0, _forceMethodImplementation.default)();
2996 }
2997 }]);
2998 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
2999
3000 /***/ }),
3001
3002 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3003 /*!**********************************************************************!*\
3004 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3005 \**********************************************************************/
3006 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3007
3008 "use strict";
3009
3010
3011 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3012 Object.defineProperty(exports, "__esModule", ({
3013 value: true
3014 }));
3015 exports["default"] = exports.DefaultError = void 0;
3016 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3017 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3018 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3019 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3020 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3021 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3022 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)); }
3023 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3024 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3025 function DefaultError() {
3026 (0, _classCallCheck2.default)(this, DefaultError);
3027 return _callSuper(this, DefaultError, arguments);
3028 }
3029 (0, _inherits2.default)(DefaultError, _BaseError);
3030 return (0, _createClass2.default)(DefaultError, null, [{
3031 key: "getHTTPErrorCode",
3032 value: function getHTTPErrorCode() {
3033 return 501;
3034 }
3035 }]);
3036 }(_baseError.default);
3037 var _default = exports["default"] = DefaultError;
3038
3039 /***/ }),
3040
3041 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3042 /*!******************************************************************!*\
3043 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3044 \******************************************************************/
3045 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3046
3047 "use strict";
3048
3049
3050 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3051 Object.defineProperty(exports, "__esModule", ({
3052 value: true
3053 }));
3054 exports["default"] = exports.Error404 = void 0;
3055 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3056 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3057 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3058 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3059 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3060 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3061 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3062 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)); }
3063 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3064 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3065 function Error404() {
3066 (0, _classCallCheck2.default)(this, Error404);
3067 return _callSuper(this, Error404, arguments);
3068 }
3069 (0, _inherits2.default)(Error404, _BaseError);
3070 return (0, _createClass2.default)(Error404, [{
3071 key: "notify",
3072 value: function notify() {
3073 _console.default.warn(this.message);
3074 }
3075 }], [{
3076 key: "getHTTPErrorCode",
3077 value: function getHTTPErrorCode() {
3078 return 404;
3079 }
3080 }]);
3081 }(_baseError.default);
3082 var _default = exports["default"] = Error404;
3083
3084 /***/ }),
3085
3086 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3087 /*!**************************************************************!*\
3088 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3089 \**************************************************************/
3090 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3091
3092 "use strict";
3093
3094
3095 Object.defineProperty(exports, "__esModule", ({
3096 value: true
3097 }));
3098 Object.defineProperty(exports, "DefaultError", ({
3099 enumerable: true,
3100 get: function get() {
3101 return _defaultError.DefaultError;
3102 }
3103 }));
3104 Object.defineProperty(exports, "Error404", ({
3105 enumerable: true,
3106 get: function get() {
3107 return _error.Error404;
3108 }
3109 }));
3110 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3111 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3112
3113 /***/ }),
3114
3115 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3116 /*!************************************************************!*\
3117 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3118 \************************************************************/
3119 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3120
3121 "use strict";
3122
3123
3124 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3125 Object.defineProperty(exports, "__esModule", ({
3126 value: true
3127 }));
3128 exports["default"] = void 0;
3129 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3130 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3131 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3132 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3133 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3134 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3135 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3136 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)); }
3137 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3138 /**
3139 * @name $e.modules.CommandBase
3140 */
3141 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3142 function CommandBase() {
3143 (0, _classCallCheck2.default)(this, CommandBase);
3144 return _callSuper(this, CommandBase, arguments);
3145 }
3146 (0, _inherits2.default)(CommandBase, _CommandInfra);
3147 return (0, _createClass2.default)(CommandBase, [{
3148 key: "onBeforeRun",
3149 value: function onBeforeRun() {
3150 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3151 $e.hooks.runUIBefore(this.command, args);
3152 }
3153 }, {
3154 key: "onAfterRun",
3155 value: function onAfterRun() {
3156 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3157 var result = arguments.length > 1 ? arguments[1] : undefined;
3158 $e.hooks.runUIAfter(this.command, args, result);
3159 }
3160 }, {
3161 key: "onBeforeApply",
3162 value: function onBeforeApply() {
3163 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3164 $e.hooks.runDataDependency(this.command, args);
3165 }
3166 }, {
3167 key: "onAfterApply",
3168 value: function onAfterApply() {
3169 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3170 var result = arguments.length > 1 ? arguments[1] : undefined;
3171 return $e.hooks.runDataAfter(this.command, args, result);
3172 }
3173 }, {
3174 key: "onCatchApply",
3175 value: function onCatchApply(e) {
3176 this.runCatchHooks(e);
3177 }
3178
3179 /**
3180 * Run all the catch hooks.
3181 *
3182 * @param {Error} e
3183 */
3184 }, {
3185 key: "runCatchHooks",
3186 value: function runCatchHooks(e) {
3187 $e.hooks.runDataCatch(this.command, this.args, e);
3188 $e.hooks.runUICatch(this.command, this.args, e);
3189 }
3190
3191 /**
3192 * TODO - Remove - Backwards compatibility.
3193 *
3194 * Function requireContainer().
3195 *
3196 * Validate `arg.container` & `arg.containers`.
3197 *
3198 * @param {{}} args
3199 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3200 *
3201 * @throws {Error}
3202 */
3203 }, {
3204 key: "requireContainer",
3205 value: function requireContainer() {
3206 var _this = this;
3207 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3208 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3209 if (!args.container && !args.containers) {
3210 throw Error('container or containers are required.');
3211 }
3212 if (args.container && args.containers) {
3213 throw Error('container and containers cannot go together please select one of them.');
3214 }
3215 var containers = args.containers || [args.container];
3216 containers.forEach(function (container) {
3217 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3218 container: container
3219 });
3220 });
3221 }
3222 }], [{
3223 key: "getInstanceType",
3224 value: function getInstanceType() {
3225 return 'CommandBase';
3226 }
3227 }]);
3228 }(_commandInfra.default);
3229
3230 /***/ }),
3231
3232 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3233 /*!*********************************************************************!*\
3234 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3235 \*********************************************************************/
3236 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3237
3238 "use strict";
3239
3240
3241 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3242 Object.defineProperty(exports, "__esModule", ({
3243 value: true
3244 }));
3245 exports["default"] = void 0;
3246 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3247 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3248 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3249 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3250 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3251 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3252 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)); }
3253 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3254 /**
3255 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
3256 */
3257 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3258 function CommandCallbackBase() {
3259 (0, _classCallCheck2.default)(this, CommandCallbackBase);
3260 return _callSuper(this, CommandCallbackBase, arguments);
3261 }
3262 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
3263 return (0, _createClass2.default)(CommandCallbackBase, [{
3264 key: "apply",
3265 value: function apply() {
3266 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3267 return this.constructor.getCallback()(args);
3268 }
3269 }], [{
3270 key: "getInstanceType",
3271 value: function getInstanceType() {
3272 return 'CommandCallbackBase';
3273 }
3274
3275 /**
3276 * Get original callback of the command.
3277 *
3278 * Support pure callbacks ( Non command-base ).
3279 *
3280 * @return {()=>{}} Command Results.
3281 */
3282 }, {
3283 key: "getCallback",
3284 value: function getCallback() {
3285 return this.registerConfig.callback;
3286 }
3287 }]);
3288 }(_commandBase.default);
3289
3290 /***/ }),
3291
3292 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
3293 /*!************************************************************!*\
3294 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
3295 \************************************************************/
3296 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3297
3298 "use strict";
3299
3300
3301 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3302 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
3303 Object.defineProperty(exports, "__esModule", ({
3304 value: true
3305 }));
3306 exports["default"] = void 0;
3307 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3308 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3309 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3310 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3311 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3312 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3313 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3314 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
3315 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); }
3316 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)); }
3317 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3318 /**
3319 * @name $e.modules.CommandData
3320 */
3321 /**
3322 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
3323 */
3324 /**
3325 * @typedef {{}} RequestData
3326 */
3327 /**
3328 * @typedef {import('../core/data/errors/base-error')} BaseError
3329 */
3330 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3331 function CommandData(args) {
3332 var _this$args$options;
3333 var _this;
3334 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
3335 (0, _classCallCheck2.default)(this, CommandData);
3336 _this = _callSuper(this, CommandData, [args, commandsAPI]);
3337 /**
3338 * Data returned from remote.
3339 *
3340 * @type {*}
3341 */
3342 (0, _defineProperty2.default)(_this, "data", void 0);
3343 /**
3344 * Fetch type.
3345 *
3346 * @type {DataTypes}
3347 */
3348 (0, _defineProperty2.default)(_this, "type", void 0);
3349 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
3350 _this.type = _this.args.options.type;
3351 }
3352 return _this;
3353 }
3354
3355 /**
3356 * Function getEndpointFormat().
3357 *
3358 * @return {null|string} endpoint format
3359 */
3360 (0, _inherits2.default)(CommandData, _CommandBase);
3361 return (0, _createClass2.default)(CommandData, [{
3362 key: "getApplyMethods",
3363 value:
3364 /**
3365 * @param {DataTypes} type
3366 *
3367 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
3368 */
3369 function getApplyMethods() {
3370 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
3371 var before, after;
3372 switch (type) {
3373 case 'create':
3374 before = this.applyBeforeCreate;
3375 after = this.applyAfterCreate;
3376 break;
3377 case 'delete':
3378 before = this.applyBeforeDelete;
3379 after = this.applyAfterDelete;
3380 break;
3381 case 'get':
3382 before = this.applyBeforeGet;
3383 after = this.applyAfterGet;
3384 break;
3385 case 'update':
3386 before = this.applyBeforeUpdate;
3387 after = this.applyAfterUpdate;
3388 break;
3389 case 'options':
3390 before = this.applyBeforeOptions;
3391 after = this.applyAfterOptions;
3392 break;
3393 default:
3394 return false;
3395 }
3396 return {
3397 before: before.bind(this),
3398 after: after.bind(this)
3399 };
3400 }
3401
3402 /**
3403 * Function getRequestData().
3404 *
3405 * @return {RequestData} request data
3406 */
3407 }, {
3408 key: "getRequestData",
3409 value: function getRequestData() {
3410 return {
3411 type: this.type,
3412 args: this.args,
3413 timestamp: new Date().getTime(),
3414 component: this.component,
3415 command: this.command,
3416 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
3417 };
3418 }
3419 }, {
3420 key: "apply",
3421 value: function apply() {
3422 var _this2 = this;
3423 var applyMethods = this.getApplyMethods();
3424
3425 // Run 'before' method.
3426 this.args = applyMethods.before(this.args);
3427 var requestData = this.getRequestData();
3428 return $e.data.fetch(requestData).then(function (data) {
3429 _this2.data = data;
3430
3431 // Run 'after' method.
3432 _this2.data = applyMethods.after(data, _this2.args);
3433 _this2.data = {
3434 data: _this2.data
3435 };
3436
3437 // Append requestData.
3438 _this2.data = Object.assign({
3439 __requestData__: requestData
3440 }, _this2.data);
3441 return _this2.data;
3442 });
3443 }
3444
3445 /**
3446 * @param {*} [args={}]
3447 * @return {{}} filtered args
3448 */
3449 }, {
3450 key: "applyBeforeCreate",
3451 value: function applyBeforeCreate() {
3452 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3453 return args;
3454 }
3455
3456 /**
3457 * @param {{}} data
3458 * @param {*} [args={}]
3459 * @return {{}} filtered result
3460 */
3461 }, {
3462 key: "applyAfterCreate",
3463 value: function applyAfterCreate(data) {
3464 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3465 // eslint-disable-line no-unused-vars
3466 return data;
3467 }
3468
3469 /**
3470 * @param {*} [args={}]
3471 * @return {{}} filtered args
3472 */
3473 }, {
3474 key: "applyBeforeDelete",
3475 value: function applyBeforeDelete() {
3476 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3477 return args;
3478 }
3479
3480 /**
3481 * @param {{}} data
3482 * @param {*} [args={}]
3483 * @return {{}} filtered result
3484 */
3485 }, {
3486 key: "applyAfterDelete",
3487 value: function applyAfterDelete(data) {
3488 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3489 // eslint-disable-line no-unused-vars
3490 return data;
3491 }
3492
3493 /**
3494 * @param {*} [args={}]
3495 * @return {{}} filtered args
3496 */
3497 }, {
3498 key: "applyBeforeGet",
3499 value: function applyBeforeGet() {
3500 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3501 return args;
3502 }
3503
3504 /**
3505 * @param {{}} data
3506 * @param {*} [args={}]
3507 * @return {{}} filtered result
3508 */
3509 }, {
3510 key: "applyAfterGet",
3511 value: function applyAfterGet(data) {
3512 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3513 // eslint-disable-line no-unused-vars
3514 return data;
3515 }
3516
3517 /**
3518 * @param {*} [args={}]
3519 * @return {{}} filtered args
3520 */
3521 }, {
3522 key: "applyBeforeUpdate",
3523 value: function applyBeforeUpdate() {
3524 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3525 return args;
3526 }
3527
3528 /**
3529 * @param {{}} data
3530 * @param {*} [args={}]
3531 * @return {{}} filtered result
3532 */
3533 }, {
3534 key: "applyAfterUpdate",
3535 value: function applyAfterUpdate(data) {
3536 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3537 // eslint-disable-line no-unused-vars
3538 return data;
3539 }
3540
3541 /**
3542 * @param {*} [args={}]
3543 * @return {{}} filtered args
3544 */
3545 }, {
3546 key: "applyBeforeOptions",
3547 value: function applyBeforeOptions() {
3548 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3549 return args;
3550 }
3551
3552 /**
3553 * @param {{}} data
3554 * @param {*} [args={}]
3555 * @return {{}} filtered result
3556 */
3557 }, {
3558 key: "applyAfterOptions",
3559 value: function applyAfterOptions(data) {
3560 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3561 // eslint-disable-line no-unused-vars
3562 return data;
3563 }
3564
3565 /**
3566 * @param {BaseError} e
3567 */
3568 }, {
3569 key: "applyAfterCatch",
3570 value: function applyAfterCatch(e) {
3571 e.notify();
3572 }
3573 }, {
3574 key: "onCatchApply",
3575 value: function onCatchApply(e) {
3576 var _e;
3577 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
3578 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
3579 var dataError = Object.values(errors).find(function (error) {
3580 return error.getHTTPErrorCode() === httpErrorCode;
3581 });
3582 if (!dataError) {
3583 dataError = errors.DefaultError;
3584 }
3585 e = dataError.create(e.message, e.code, e.data || []);
3586 this.runCatchHooks(e);
3587 this.applyAfterCatch(e);
3588 }
3589 }], [{
3590 key: "getInstanceType",
3591 value: function getInstanceType() {
3592 return 'CommandData';
3593 }
3594 }, {
3595 key: "getEndpointFormat",
3596 value: function getEndpointFormat() {
3597 return null;
3598 }
3599 }]);
3600 }(_commandBase.default);
3601
3602 /***/ }),
3603
3604 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
3605 /*!*************************************************************!*\
3606 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
3607 \*************************************************************/
3608 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3609
3610 "use strict";
3611
3612
3613 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3614 Object.defineProperty(exports, "__esModule", ({
3615 value: true
3616 }));
3617 exports["default"] = void 0;
3618 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3619 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3620 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3621 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3622 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3623 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3624 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
3625 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3626 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)); }
3627 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3628 /**
3629 * @typedef {import('../modules/component-base')} ComponentBase
3630 */
3631 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
3632 /**
3633 * Function constructor().
3634 *
3635 * Create Commands Base.
3636 *
3637 * @param {{}} args
3638 */
3639 function CommandInfra() {
3640 var _this;
3641 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3642 (0, _classCallCheck2.default)(this, CommandInfra);
3643 _this = _callSuper(this, CommandInfra, [args]);
3644 if (!_this.constructor.registerConfig) {
3645 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
3646 }
3647
3648 // Acknowledge self about which command it run.
3649 _this.command = _this.constructor.getCommand();
3650
3651 // Assign instance of current component.
3652 _this.component = _this.constructor.getComponent();
3653
3654 // Who ever need do something before without `super` the constructor can use `initialize` method.
3655 _this.initialize(args);
3656
3657 // Refresh args, maybe the changed via `initialize`.
3658 args = _this.args;
3659
3660 // Validate args before run.
3661 _this.validateArgs(args);
3662 return _this;
3663 }
3664
3665 /**
3666 * Function initialize().
3667 *
3668 * Initialize command, called after construction.
3669 *
3670 * @param {{}} args
3671 */
3672 (0, _inherits2.default)(CommandInfra, _ArgsObject);
3673 return (0, _createClass2.default)(CommandInfra, [{
3674 key: "currentCommand",
3675 get:
3676 /**
3677 * @deprecated since 3.7.0, use `this.command` instead.
3678 */
3679 function get() {
3680 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
3681 return this.command;
3682 }
3683 }, {
3684 key: "initialize",
3685 value: function initialize() {
3686 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3687 } // eslint-disable-line no-unused-vars
3688
3689 /**
3690 * Function validateArgs().
3691 *
3692 * Validate command arguments.
3693 *
3694 * @param {{}} args
3695 */
3696 }, {
3697 key: "validateArgs",
3698 value: function validateArgs() {
3699 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3700 } // eslint-disable-line no-unused-vars
3701
3702 // eslint-disable-next-line jsdoc/require-returns-check
3703 /**
3704 * Function apply().
3705 *
3706 * Do the actual command.
3707 *
3708 * @param {{}} args
3709 *
3710 * @return {*} Command results.
3711 */
3712 }, {
3713 key: "apply",
3714 value: function apply() {
3715 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3716 // eslint-disable-line no-unused-vars
3717 elementorModules.ForceMethodImplementation();
3718 }
3719
3720 /**
3721 * Function run().
3722 *
3723 * Run command with history & hooks.
3724 *
3725 * @return {*} Command results.
3726 */
3727 }, {
3728 key: "run",
3729 value: function run() {
3730 return this.apply(this.args);
3731 }
3732
3733 /**
3734 * Function onBeforeRun.
3735 *
3736 * Called before run().
3737 *
3738 * @param {{}} args
3739 */
3740 }, {
3741 key: "onBeforeRun",
3742 value: function onBeforeRun() {
3743 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3744 } // eslint-disable-line no-unused-vars
3745
3746 /**
3747 * Function onAfterRun.
3748 *
3749 * Called after run().
3750 *
3751 * @param {{}} args
3752 * @param {*} result
3753 */
3754 }, {
3755 key: "onAfterRun",
3756 value: function onAfterRun() {
3757 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3758 var result = arguments.length > 1 ? arguments[1] : undefined;
3759 } // eslint-disable-line no-unused-vars
3760
3761 /**
3762 * Function onBeforeApply.
3763 *
3764 * Called before apply().
3765 *
3766 * @param {{}} args
3767 */
3768 }, {
3769 key: "onBeforeApply",
3770 value: function onBeforeApply() {
3771 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3772 } // eslint-disable-line no-unused-vars
3773
3774 /**
3775 * Function onAfterApply.
3776 *
3777 * Called after apply().
3778 *
3779 * @param {{}} args
3780 * @param {*} result
3781 */
3782 }, {
3783 key: "onAfterApply",
3784 value: function onAfterApply() {
3785 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3786 var result = arguments.length > 1 ? arguments[1] : undefined;
3787 } // eslint-disable-line no-unused-vars
3788
3789 /**
3790 * Function onCatchApply.
3791 *
3792 * Called after apply() failed.
3793 *
3794 * @param {Error} e
3795 */
3796 }, {
3797 key: "onCatchApply",
3798 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
3799 }], [{
3800 key: "getInstanceType",
3801 value: function getInstanceType() {
3802 return 'CommandInfra';
3803 }
3804
3805 /**
3806 * Get info of command.
3807 *
3808 * @return {Object} Extra information about the command.
3809 */
3810 }, {
3811 key: "getInfo",
3812 value: function getInfo() {
3813 return {};
3814 }
3815
3816 /**
3817 * @return {string} Self command name.
3818 */
3819 }, {
3820 key: "getCommand",
3821 value: function getCommand() {
3822 return this.registerConfig.command;
3823 }
3824
3825 /**
3826 * @return {ComponentBase} Self component
3827 */
3828 }, {
3829 key: "getComponent",
3830 value: function getComponent() {
3831 return this.registerConfig.component;
3832 }
3833 }, {
3834 key: "setRegisterConfig",
3835 value: function setRegisterConfig(config) {
3836 this.registerConfig = Object.freeze(config);
3837 }
3838 }]);
3839 }(_argsObject.default);
3840 /**
3841 * @type {Object}
3842 */
3843 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
3844
3845 /***/ }),
3846
3847 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
3848 /*!**************************************************************!*\
3849 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
3850 \**************************************************************/
3851 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3852
3853 "use strict";
3854
3855
3856 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3857 Object.defineProperty(exports, "__esModule", ({
3858 value: true
3859 }));
3860 exports["default"] = exports.Close = void 0;
3861 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3862 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3863 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3864 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3865 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3866 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3867 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)); }
3868 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3869 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
3870 function Close() {
3871 (0, _classCallCheck2.default)(this, Close);
3872 return _callSuper(this, Close, arguments);
3873 }
3874 (0, _inherits2.default)(Close, _CommandBase);
3875 return (0, _createClass2.default)(Close, [{
3876 key: "apply",
3877 value: function apply() {
3878 this.component.close();
3879 }
3880 }]);
3881 }(_commandBase.default);
3882 var _default = exports["default"] = Close;
3883
3884 /***/ }),
3885
3886 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
3887 /*!**************************************************************!*\
3888 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
3889 \**************************************************************/
3890 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3891
3892 "use strict";
3893
3894
3895 Object.defineProperty(exports, "__esModule", ({
3896 value: true
3897 }));
3898 Object.defineProperty(exports, "Close", ({
3899 enumerable: true,
3900 get: function get() {
3901 return _close.Close;
3902 }
3903 }));
3904 Object.defineProperty(exports, "Open", ({
3905 enumerable: true,
3906 get: function get() {
3907 return _open.Open;
3908 }
3909 }));
3910 Object.defineProperty(exports, "Toggle", ({
3911 enumerable: true,
3912 get: function get() {
3913 return _toggle.Toggle;
3914 }
3915 }));
3916 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
3917 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
3918 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
3919
3920 /***/ }),
3921
3922 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
3923 /*!*************************************************************!*\
3924 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
3925 \*************************************************************/
3926 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3927
3928 "use strict";
3929
3930
3931 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3932 Object.defineProperty(exports, "__esModule", ({
3933 value: true
3934 }));
3935 exports["default"] = exports.Open = void 0;
3936 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3937 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3938 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3939 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3940 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3941 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3942 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)); }
3943 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3944 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
3945 function Open() {
3946 (0, _classCallCheck2.default)(this, Open);
3947 return _callSuper(this, Open, arguments);
3948 }
3949 (0, _inherits2.default)(Open, _CommandBase);
3950 return (0, _createClass2.default)(Open, [{
3951 key: "apply",
3952 value: function apply() {
3953 $e.route(this.component.getNamespace());
3954 }
3955 }]);
3956 }(_commandBase.default);
3957 var _default = exports["default"] = Open;
3958
3959 /***/ }),
3960
3961 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
3962 /*!***************************************************************!*\
3963 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
3964 \***************************************************************/
3965 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3966
3967 "use strict";
3968
3969
3970 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3971 Object.defineProperty(exports, "__esModule", ({
3972 value: true
3973 }));
3974 exports["default"] = exports.Toggle = void 0;
3975 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3976 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3977 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3978 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3979 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3980 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3981 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)); }
3982 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3983 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
3984 function Toggle() {
3985 (0, _classCallCheck2.default)(this, Toggle);
3986 return _callSuper(this, Toggle, arguments);
3987 }
3988 (0, _inherits2.default)(Toggle, _CommandBase);
3989 return (0, _createClass2.default)(Toggle, [{
3990 key: "apply",
3991 value: function apply() {
3992 if (this.component.isOpen) {
3993 this.component.close();
3994 } else {
3995 $e.route(this.component.getNamespace());
3996 }
3997 }
3998 }]);
3999 }(_commandBase.default);
4000 var _default = exports["default"] = Toggle;
4001
4002 /***/ }),
4003
4004 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4005 /*!**************************************************************!*\
4006 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4007 \**************************************************************/
4008 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4009
4010 "use strict";
4011
4012
4013 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4014 Object.defineProperty(exports, "__esModule", ({
4015 value: true
4016 }));
4017 exports["default"] = void 0;
4018 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4019 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4020 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4021 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4022 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4023 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4024 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4025 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4026 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4027 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4028 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4029 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4030 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; }
4031 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; }
4032 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)); }
4033 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4034 /**
4035 * @typedef {import('./command-infra')} CommandInfra
4036 * @typedef {import('./hook-base')} HookBase
4037 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4038 */
4039 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4040 function ComponentBase() {
4041 (0, _classCallCheck2.default)(this, ComponentBase);
4042 return _callSuper(this, ComponentBase, arguments);
4043 }
4044 (0, _inherits2.default)(ComponentBase, _Module);
4045 return (0, _createClass2.default)(ComponentBase, [{
4046 key: "__construct",
4047 value: function __construct() {
4048 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4049 if (args.manager) {
4050 this.manager = args.manager;
4051 }
4052 this.commands = this.defaultCommands();
4053 this.commandsInternal = this.defaultCommandsInternal();
4054 this.hooks = this.defaultHooks();
4055 this.routes = this.defaultRoutes();
4056 this.tabs = this.defaultTabs();
4057 this.shortcuts = this.defaultShortcuts();
4058 this.utils = this.defaultUtils();
4059 this.data = this.defaultData();
4060 this.uiStates = this.defaultUiStates();
4061 this.states = this.defaultStates();
4062 this.defaultRoute = '';
4063 this.currentTab = '';
4064 }
4065 }, {
4066 key: "registerAPI",
4067 value: function registerAPI() {
4068 var _this = this;
4069 Object.entries(this.getTabs()).forEach(function (tab) {
4070 return _this.registerTabRoute(tab[0]);
4071 });
4072 Object.entries(this.getRoutes()).forEach(function (_ref) {
4073 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4074 route = _ref2[0],
4075 callback = _ref2[1];
4076 return _this.registerRoute(route, callback);
4077 });
4078 Object.entries(this.getCommands()).forEach(function (_ref3) {
4079 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4080 command = _ref4[0],
4081 callback = _ref4[1];
4082 return _this.registerCommand(command, callback);
4083 });
4084 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4085 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4086 command = _ref6[0],
4087 callback = _ref6[1];
4088 return _this.registerCommandInternal(command, callback);
4089 });
4090 Object.values(this.getHooks()).forEach(function (instance) {
4091 return _this.registerHook(instance);
4092 });
4093 Object.entries(this.getData()).forEach(function (_ref7) {
4094 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4095 command = _ref8[0],
4096 callback = _ref8[1];
4097 return _this.registerData(command, callback);
4098 });
4099 Object.values(this.getUiStates()).forEach(function (instance) {
4100 return _this.registerUiState(instance);
4101 });
4102 Object.entries(this.getStates()).forEach(function (_ref9) {
4103 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4104 id = _ref0[0],
4105 state = _ref0[1];
4106 return _this.registerState(id, state);
4107 });
4108 }
4109
4110 // eslint-disable-next-line jsdoc/require-returns-check
4111 /**
4112 * @return {string} namespace
4113 */
4114 }, {
4115 key: "getNamespace",
4116 value: function getNamespace() {
4117 (0, _forceMethodImplementation.default)();
4118 }
4119
4120 /**
4121 * @deprecated since 3.7.0, use `getServiceName()` instead.
4122 */
4123 }, {
4124 key: "getRootContainer",
4125 value: function getRootContainer() {
4126 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4127 return this.getServiceName();
4128 }
4129 }, {
4130 key: "getServiceName",
4131 value: function getServiceName() {
4132 return this.getNamespace().split('/')[0];
4133 }
4134 }, {
4135 key: "store",
4136 get: function get() {
4137 return $e.store.get(this.getNamespace());
4138 }
4139 }, {
4140 key: "defaultTabs",
4141 value: function defaultTabs() {
4142 return {};
4143 }
4144 }, {
4145 key: "defaultRoutes",
4146 value: function defaultRoutes() {
4147 return {};
4148 }
4149 }, {
4150 key: "defaultCommands",
4151 value: function defaultCommands() {
4152 return {};
4153 }
4154 }, {
4155 key: "defaultCommandsInternal",
4156 value: function defaultCommandsInternal() {
4157 return {};
4158 }
4159 }, {
4160 key: "defaultHooks",
4161 value: function defaultHooks() {
4162 return {};
4163 }
4164
4165 /**
4166 * Get the component's default UI states.
4167 *
4168 * @return {Object} default UI states
4169 */
4170 }, {
4171 key: "defaultUiStates",
4172 value: function defaultUiStates() {
4173 return {};
4174 }
4175
4176 /**
4177 * Get the component's Redux slice settings.
4178 *
4179 * @return {Object} Redux slice settings
4180 */
4181 }, {
4182 key: "defaultStates",
4183 value: function defaultStates() {
4184 return {};
4185 }
4186 }, {
4187 key: "defaultShortcuts",
4188 value: function defaultShortcuts() {
4189 return {};
4190 }
4191 }, {
4192 key: "defaultUtils",
4193 value: function defaultUtils() {
4194 return {};
4195 }
4196 }, {
4197 key: "defaultData",
4198 value: function defaultData() {
4199 return {};
4200 }
4201 }, {
4202 key: "getCommands",
4203 value: function getCommands() {
4204 return this.commands;
4205 }
4206 }, {
4207 key: "getCommandsInternal",
4208 value: function getCommandsInternal() {
4209 return this.commandsInternal;
4210 }
4211 }, {
4212 key: "getHooks",
4213 value: function getHooks() {
4214 return this.hooks;
4215 }
4216
4217 /**
4218 * Retrieve the component's UI states.
4219 *
4220 * @return {Object} UI states
4221 */
4222 }, {
4223 key: "getUiStates",
4224 value: function getUiStates() {
4225 return this.uiStates;
4226 }
4227
4228 /**
4229 * Retrieve the component's Redux Slice.
4230 *
4231 * @return {Object} Redux Slice
4232 */
4233 }, {
4234 key: "getStates",
4235 value: function getStates() {
4236 return this.states;
4237 }
4238 }, {
4239 key: "getRoutes",
4240 value: function getRoutes() {
4241 return this.routes;
4242 }
4243 }, {
4244 key: "getTabs",
4245 value: function getTabs() {
4246 return this.tabs;
4247 }
4248 }, {
4249 key: "getShortcuts",
4250 value: function getShortcuts() {
4251 return this.shortcuts;
4252 }
4253 }, {
4254 key: "getData",
4255 value: function getData() {
4256 return this.data;
4257 }
4258
4259 /**
4260 * @param {string} command
4261 * @param {(()=>{}|CommandInfra)} context
4262 * @param {'default'|'internal'|'data'} commandsType
4263 */
4264 }, {
4265 key: "registerCommand",
4266 value: function registerCommand(command, context) {
4267 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
4268 var commandsManager;
4269 switch (commandsType) {
4270 case 'default':
4271 commandsManager = $e.commands;
4272 break;
4273 case 'internal':
4274 commandsManager = $e.commandsInternal;
4275 break;
4276 case 'data':
4277 commandsManager = $e.data;
4278 break;
4279 default:
4280 throw new Error("Invalid commands type: '".concat(command, "'"));
4281 }
4282 var fullCommand = this.getNamespace() + '/' + command,
4283 instanceType = context.getInstanceType ? context.getInstanceType() : false,
4284 registerConfig = {
4285 command: fullCommand,
4286 component: this
4287 };
4288
4289 // Support pure callback.
4290 if (!instanceType) {
4291 if ($e.devTools) {
4292 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
4293 }
4294 registerConfig.callback = context;
4295
4296 // Unique class.
4297 context = /*#__PURE__*/function (_CommandCallbackBase) {
4298 function context() {
4299 (0, _classCallCheck2.default)(this, context);
4300 return _callSuper(this, context, arguments);
4301 }
4302 (0, _inherits2.default)(context, _CommandCallbackBase);
4303 return (0, _createClass2.default)(context);
4304 }(_commandCallbackBase.default);
4305 }
4306 context.setRegisterConfig(registerConfig);
4307 commandsManager.register(this, command, context);
4308 }
4309
4310 /**
4311 * @param {HookBase} instance
4312 */
4313 }, {
4314 key: "registerHook",
4315 value: function registerHook(instance) {
4316 return instance.register();
4317 }
4318 }, {
4319 key: "registerCommandInternal",
4320 value: function registerCommandInternal(command, context) {
4321 this.registerCommand(command, context, 'internal');
4322 }
4323
4324 /**
4325 * Register a UI state.
4326 *
4327 * @param {UiStateBase} instance - UI state instance.
4328 *
4329 * @return {void}
4330 */
4331 }, {
4332 key: "registerUiState",
4333 value: function registerUiState(instance) {
4334 $e.uiStates.register(instance);
4335 }
4336
4337 /**
4338 * Register a Redux Slice.
4339 *
4340 * @param {string} id - State id.
4341 * @param {Object} stateConfig - The state config.
4342 *
4343 * @return {void}
4344 */
4345 }, {
4346 key: "registerState",
4347 value: function registerState(id, stateConfig) {
4348 id = this.getNamespace() + (id ? "/".concat(id) : '');
4349 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
4350 name: id
4351 }));
4352 $e.store.register(id, slice);
4353 }
4354 }, {
4355 key: "registerRoute",
4356 value: function registerRoute(route, callback) {
4357 $e.routes.register(this, route, callback);
4358 }
4359 }, {
4360 key: "registerData",
4361 value: function registerData(command, context) {
4362 this.registerCommand(command, context, 'data');
4363 }
4364 }, {
4365 key: "unregisterRoute",
4366 value: function unregisterRoute(route) {
4367 $e.routes.unregister(this, route);
4368 }
4369 }, {
4370 key: "registerTabRoute",
4371 value: function registerTabRoute(tab) {
4372 var _this2 = this;
4373 this.registerRoute(tab, function (args) {
4374 return _this2.activateTab(tab, args);
4375 });
4376 }
4377 }, {
4378 key: "dependency",
4379 value: function dependency() {
4380 return true;
4381 }
4382 }, {
4383 key: "open",
4384 value: function open() {
4385 return true;
4386 }
4387 }, {
4388 key: "close",
4389 value: function close() {
4390 if (!this.isOpen) {
4391 return false;
4392 }
4393 this.isOpen = false;
4394 this.inactivate();
4395 $e.routes.clearCurrent(this.getNamespace());
4396 $e.routes.clearHistory(this.getServiceName());
4397 return true;
4398 }
4399 }, {
4400 key: "activate",
4401 value: function activate() {
4402 $e.components.activate(this.getNamespace());
4403 }
4404 }, {
4405 key: "inactivate",
4406 value: function inactivate() {
4407 $e.components.inactivate(this.getNamespace());
4408 }
4409 }, {
4410 key: "isActive",
4411 value: function isActive() {
4412 return $e.components.isActive(this.getNamespace());
4413 }
4414 }, {
4415 key: "onRoute",
4416 value: function onRoute(route) {
4417 this.toggleRouteClass(route, true);
4418 this.toggleHistoryClass();
4419 this.activate();
4420 this.trigger('route/open', route);
4421 }
4422 }, {
4423 key: "onCloseRoute",
4424 value: function onCloseRoute(route) {
4425 this.toggleRouteClass(route, false);
4426 this.inactivate();
4427 this.trigger('route/close', route);
4428 }
4429 }, {
4430 key: "setDefaultRoute",
4431 value: function setDefaultRoute(route) {
4432 this.defaultRoute = this.getNamespace() + '/' + route;
4433 }
4434 }, {
4435 key: "getDefaultRoute",
4436 value: function getDefaultRoute() {
4437 return this.defaultRoute;
4438 }
4439 }, {
4440 key: "removeTab",
4441 value: function removeTab(tab) {
4442 delete this.tabs[tab];
4443 this.unregisterRoute(tab);
4444 }
4445 }, {
4446 key: "hasTab",
4447 value: function hasTab(tab) {
4448 return !!this.tabs[tab];
4449 }
4450 }, {
4451 key: "addTab",
4452 value: function addTab(tab, args, position) {
4453 var _this3 = this;
4454 this.tabs[tab] = args;
4455 // It can be 0.
4456 if ('undefined' !== typeof position) {
4457 var newTabs = {};
4458 var ids = Object.keys(this.tabs);
4459 // Remove new tab
4460 ids.pop();
4461
4462 // Add it to position.
4463 ids.splice(position, 0, tab);
4464 ids.forEach(function (id) {
4465 newTabs[id] = _this3.tabs[id];
4466 });
4467 this.tabs = newTabs;
4468 }
4469 this.registerTabRoute(tab);
4470 }
4471 }, {
4472 key: "getTabsWrapperSelector",
4473 value: function getTabsWrapperSelector() {
4474 return '';
4475 }
4476 }, {
4477 key: "getTabRoute",
4478 value: function getTabRoute(tab) {
4479 return this.getNamespace() + '/' + tab;
4480 }
4481 }, {
4482 key: "renderTab",
4483 value: function renderTab(tab) {} // eslint-disable-line
4484 }, {
4485 key: "activateTab",
4486 value: function activateTab(tab, args) {
4487 var _this4 = this;
4488 this.renderTab(tab, args);
4489 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
4490 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
4491 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
4492 }
4493 }, {
4494 key: "getActiveTabConfig",
4495 value: function getActiveTabConfig() {
4496 return this.tabs[this.currentTab] || {};
4497 }
4498 }, {
4499 key: "getBodyClass",
4500 value: function getBodyClass(route) {
4501 return 'e-route-' + route.replace(/\//g, '-');
4502 }
4503
4504 /**
4505 * If command includes uppercase character convert it to lowercase and add `-`.
4506 * e.g: `CopyAll` is converted to `copy-all`.
4507 *
4508 * @param {string} commandName
4509 */
4510 }, {
4511 key: "normalizeCommandName",
4512 value: function normalizeCommandName(commandName) {
4513 return commandName.replace(/[A-Z]/g, function (match, offset) {
4514 return (offset > 0 ? '-' : '') + match.toLowerCase();
4515 });
4516 }
4517
4518 /**
4519 * @param {{}} commandsFromImport
4520 * @return {{}} imported commands
4521 */
4522 }, {
4523 key: "importCommands",
4524 value: function importCommands(commandsFromImport) {
4525 var _this5 = this;
4526 var commands = {};
4527
4528 // Convert `Commands` to `ComponentBase` workable format.
4529 Object.entries(commandsFromImport).forEach(function (_ref1) {
4530 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
4531 className = _ref10[0],
4532 Class = _ref10[1];
4533 var command = _this5.normalizeCommandName(className);
4534 commands[command] = Class;
4535 });
4536 return commands;
4537 }
4538 }, {
4539 key: "importHooks",
4540 value: function importHooks(hooksFromImport) {
4541 var hooks = {};
4542 for (var key in hooksFromImport) {
4543 var hook = new hooksFromImport[key]();
4544 hooks[hook.getId()] = hook;
4545 }
4546 return hooks;
4547 }
4548
4549 /**
4550 * Import & initialize the component's UI states.
4551 * Should be used inside `defaultUiState()`.
4552 *
4553 * @param {Object} statesFromImport - UI states from import.
4554 *
4555 * @return {Object} UI States
4556 */
4557 }, {
4558 key: "importUiStates",
4559 value: function importUiStates(statesFromImport) {
4560 var _this6 = this;
4561 var uiStates = {};
4562 Object.values(statesFromImport).forEach(function (className) {
4563 var uiState = new className(_this6);
4564 uiStates[uiState.getId()] = uiState;
4565 });
4566 return uiStates;
4567 }
4568
4569 /**
4570 * Set a UI state value.
4571 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
4572 *
4573 * @param {string} state - Non-prefixed state ID.
4574 * @param {*} value - New state value.
4575 *
4576 * @return {void}
4577 */
4578 }, {
4579 key: "setUiState",
4580 value: function setUiState(state, value) {
4581 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
4582 }
4583 }, {
4584 key: "toggleRouteClass",
4585 value: function toggleRouteClass(route, state) {
4586 document.body.classList.toggle(this.getBodyClass(route), state);
4587 }
4588 }, {
4589 key: "toggleHistoryClass",
4590 value: function toggleHistoryClass() {
4591 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
4592 }
4593 }]);
4594 }(_module.default);
4595
4596 /***/ }),
4597
4598 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
4599 /*!********************************************************************!*\
4600 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
4601 \********************************************************************/
4602 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4603
4604 "use strict";
4605
4606
4607 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4608 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4609 Object.defineProperty(exports, "__esModule", ({
4610 value: true
4611 }));
4612 exports["default"] = void 0;
4613 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
4614 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4615 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4616 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4617 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4618 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
4619 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4620 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
4621 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
4622 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4623 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); }
4624 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)); }
4625 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4626 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; }
4627 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
4628 function ComponentModalBase() {
4629 (0, _classCallCheck2.default)(this, ComponentModalBase);
4630 return _callSuper(this, ComponentModalBase, arguments);
4631 }
4632 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
4633 return (0, _createClass2.default)(ComponentModalBase, [{
4634 key: "registerAPI",
4635 value: function registerAPI() {
4636 var _this = this;
4637 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
4638 $e.shortcuts.register('esc', {
4639 scopes: [this.getNamespace()],
4640 callback: function callback() {
4641 return _this.close();
4642 }
4643 });
4644 }
4645 }, {
4646 key: "defaultCommands",
4647 value: function defaultCommands() {
4648 return this.importCommands(commands);
4649 }
4650 }, {
4651 key: "defaultRoutes",
4652 value: function defaultRoutes() {
4653 return {
4654 '': function _() {/* Nothing to do, it's already rendered. */}
4655 };
4656 }
4657 }, {
4658 key: "open",
4659 value: function open() {
4660 var _this2 = this;
4661 if (!this.layout) {
4662 var layout = this.getModalLayout();
4663 this.layout = new layout({
4664 component: this
4665 });
4666 this.layout.getModal().on('hide', function () {
4667 return _this2.close();
4668 });
4669 }
4670 this.layout.showModal();
4671 return true;
4672 }
4673 }, {
4674 key: "close",
4675 value: function close() {
4676 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
4677 return false;
4678 }
4679 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
4680 close();
4681 return true;
4682 }
4683 }, {
4684 key: "getModalLayout",
4685 value: function getModalLayout() {
4686 (0, _forceMethodImplementation.default)();
4687 }
4688 }]);
4689 }(_componentBase.default);
4690
4691 /***/ }),
4692
4693 /***/ "../modules/web-cli/assets/js/utils/console.js":
4694 /*!*****************************************************!*\
4695 !*** ../modules/web-cli/assets/js/utils/console.js ***!
4696 \*****************************************************/
4697 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4698
4699 "use strict";
4700
4701
4702 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4703 Object.defineProperty(exports, "__esModule", ({
4704 value: true
4705 }));
4706 exports["default"] = void 0;
4707 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4708 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4709 var Console = exports["default"] = /*#__PURE__*/function () {
4710 function Console() {
4711 (0, _classCallCheck2.default)(this, Console);
4712 }
4713 return (0, _createClass2.default)(Console, null, [{
4714 key: "error",
4715 value: function error(message) {
4716 // Show an error if devTools is available.
4717 if ($e.devTools) {
4718 $e.devTools.log.error(message);
4719 }
4720
4721 // If not a 'Hook-Break' then show error.
4722 if (!(message instanceof $e.modules.HookBreak)) {
4723 // eslint-disable-next-line no-console
4724 console.error(message);
4725 }
4726 }
4727 }, {
4728 key: "warn",
4729 value: function warn() {
4730 var _console;
4731 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
4732 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4733 args[_key] = arguments[_key];
4734 }
4735 args.unshift('%c %c', style, '');
4736 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
4737 }
4738 }]);
4739 }();
4740
4741 /***/ }),
4742
4743 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
4744 /*!*********************************************************!*\
4745 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
4746 \*********************************************************/
4747 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4748
4749 "use strict";
4750
4751
4752 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4753 Object.defineProperty(exports, "__esModule", ({
4754 value: true
4755 }));
4756 exports["default"] = void 0;
4757 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4758 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4759 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4760 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
4761 // Copied from `modules/dev-tools/assets/js/deprecation.js`
4762 /**
4763 * @typedef {Object} Version
4764 * @property {number} major1 The first number
4765 * @property {number} major2 The second number
4766 * @property {number} minor The third number
4767 * @property {string} build The fourth number
4768 */
4769
4770 var softDeprecated = function softDeprecated(name, version, replacement) {
4771 if (elementorWebCliConfig.isDebug) {
4772 deprecatedMessage('soft', name, version, replacement);
4773 }
4774 };
4775 var hardDeprecated = function hardDeprecated(name, version, replacement) {
4776 deprecatedMessage('hard', name, version, replacement);
4777 };
4778 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
4779 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
4780 if (replacement) {
4781 message += " - Use `".concat(replacement, "` instead");
4782 }
4783 _console.default.warn(message);
4784 };
4785 var Deprecation = exports["default"] = /*#__PURE__*/function () {
4786 function Deprecation() {
4787 (0, _classCallCheck2.default)(this, Deprecation);
4788 }
4789 return (0, _createClass2.default)(Deprecation, null, [{
4790 key: "deprecated",
4791 value: function deprecated(name, version, replacement) {
4792 if (this.isHardDeprecated(version)) {
4793 hardDeprecated(name, version, replacement);
4794 } else {
4795 softDeprecated(name, version, replacement);
4796 }
4797 }
4798
4799 /**
4800 * @param {string} version
4801 *
4802 * @return {Version}
4803 */
4804 }, {
4805 key: "parseVersion",
4806 value: function parseVersion(version) {
4807 var versionParts = version.split('.');
4808 if (versionParts.length < 3 || versionParts.length > 4) {
4809 throw new RangeError('Invalid Semantic Version string provided');
4810 }
4811 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
4812 major1 = _versionParts[0],
4813 major2 = _versionParts[1],
4814 minor = _versionParts[2],
4815 _versionParts$ = _versionParts[3],
4816 build = _versionParts$ === void 0 ? '' : _versionParts$;
4817 return {
4818 major1: parseInt(major1),
4819 major2: parseInt(major2),
4820 minor: parseInt(minor),
4821 build: build
4822 };
4823 }
4824
4825 /**
4826 * Get total of major.
4827 *
4828 * 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,
4829 * versions with major2 more then 9 will be added to total.
4830 *
4831 * @param {Version} versionObj
4832 *
4833 * @return {number}
4834 */
4835 }, {
4836 key: "getTotalMajor",
4837 value: function getTotalMajor(versionObj) {
4838 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
4839 total = Number((total / 10).toFixed(0));
4840 if (versionObj.major2 > 9) {
4841 total = versionObj.major2 - 9;
4842 }
4843 return total;
4844 }
4845
4846 /**
4847 * @param {string} version1
4848 * @param {string} version2
4849 *
4850 * @return {number}
4851 */
4852 }, {
4853 key: "compareVersion",
4854 value: function compareVersion(version1, version2) {
4855 var _this = this;
4856 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
4857 return _this.getTotalMajor(versionObj);
4858 }).reduce(function (acc, major) {
4859 return acc - major;
4860 });
4861 }
4862
4863 /**
4864 * @param {string} version
4865 *
4866 * @return {boolean}
4867 */
4868 }, {
4869 key: "isSoftDeprecated",
4870 value: function isSoftDeprecated(version) {
4871 var total = this.compareVersion(version, elementorWebCliConfig.version);
4872 return total <= 4;
4873 }
4874
4875 /**
4876 * @param {string} version
4877 * @return {boolean}
4878 */
4879 }, {
4880 key: "isHardDeprecated",
4881 value: function isHardDeprecated(version) {
4882 var total = this.compareVersion(version, elementorWebCliConfig.version);
4883 return total < 0 || total >= 8;
4884 }
4885 }]);
4886 }();
4887
4888 /***/ }),
4889
4890 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
4891 /*!*************************************************************************!*\
4892 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
4893 \*************************************************************************/
4894 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4895
4896 "use strict";
4897
4898
4899 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4900 Object.defineProperty(exports, "__esModule", ({
4901 value: true
4902 }));
4903 exports["default"] = exports.ForceMethodImplementation = void 0;
4904 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4905 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4906 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4907 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4908 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4909 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
4910 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)); }
4911 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4912 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
4913 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
4914 function ForceMethodImplementation() {
4915 var _this;
4916 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4917 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
4918 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
4919 Error.captureStackTrace(_this, ForceMethodImplementation);
4920 return _this;
4921 }
4922 (0, _inherits2.default)(ForceMethodImplementation, _Error);
4923 return (0, _createClass2.default)(ForceMethodImplementation);
4924 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
4925 var _default = exports["default"] = function _default() {
4926 var stack = Error().stack,
4927 caller = stack.split('\n')[2].trim(),
4928 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
4929 info = {};
4930 info.functionName = callerName;
4931 info.fullName = callerName;
4932 if (info.functionName.includes('.')) {
4933 var parts = info.functionName.split('.');
4934 info.className = parts[0];
4935 info.functionName = parts[1];
4936 } else {
4937 info.isStatic = true;
4938 }
4939 throw new ForceMethodImplementation(info);
4940 };
4941
4942 /***/ }),
4943
4944 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
4945 /*!***************************************************************!*\
4946 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
4947 \***************************************************************/
4948 /***/ ((module) => {
4949
4950 function _OverloadYield(e, d) {
4951 this.v = e, this.k = d;
4952 }
4953 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
4954
4955 /***/ }),
4956
4957 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
4958 /*!******************************************************************!*\
4959 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
4960 \******************************************************************/
4961 /***/ ((module) => {
4962
4963 function _arrayLikeToArray(r, a) {
4964 (null == a || a > r.length) && (a = r.length);
4965 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
4966 return n;
4967 }
4968 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
4969
4970 /***/ }),
4971
4972 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
4973 /*!****************************************************************!*\
4974 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
4975 \****************************************************************/
4976 /***/ ((module) => {
4977
4978 function _arrayWithHoles(r) {
4979 if (Array.isArray(r)) return r;
4980 }
4981 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
4982
4983 /***/ }),
4984
4985 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
4986 /*!***********************************************************************!*\
4987 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
4988 \***********************************************************************/
4989 /***/ ((module) => {
4990
4991 function _assertThisInitialized(e) {
4992 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4993 return e;
4994 }
4995 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
4996
4997 /***/ }),
4998
4999 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5000 /*!******************************************************************!*\
5001 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5002 \******************************************************************/
5003 /***/ ((module) => {
5004
5005 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5006 try {
5007 var i = n[a](c),
5008 u = i.value;
5009 } catch (n) {
5010 return void e(n);
5011 }
5012 i.done ? t(u) : Promise.resolve(u).then(r, o);
5013 }
5014 function _asyncToGenerator(n) {
5015 return function () {
5016 var t = this,
5017 e = arguments;
5018 return new Promise(function (r, o) {
5019 var a = n.apply(t, e);
5020 function _next(n) {
5021 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5022 }
5023 function _throw(n) {
5024 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5025 }
5026 _next(void 0);
5027 });
5028 };
5029 }
5030 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5031
5032 /***/ }),
5033
5034 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5035 /*!****************************************************************!*\
5036 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5037 \****************************************************************/
5038 /***/ ((module) => {
5039
5040 function _classCallCheck(a, n) {
5041 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5042 }
5043 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5044
5045 /***/ }),
5046
5047 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5048 /*!***********************************************************!*\
5049 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5050 \***********************************************************/
5051 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5052
5053 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5054 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5055 function _construct(t, e, r) {
5056 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5057 var o = [null];
5058 o.push.apply(o, e);
5059 var p = new (t.bind.apply(t, o))();
5060 return r && setPrototypeOf(p, r.prototype), p;
5061 }
5062 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5063
5064 /***/ }),
5065
5066 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5067 /*!*************************************************************!*\
5068 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5069 \*************************************************************/
5070 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5071
5072 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5073 function _defineProperties(e, r) {
5074 for (var t = 0; t < r.length; t++) {
5075 var o = r[t];
5076 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5077 }
5078 }
5079 function _createClass(e, r, t) {
5080 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5081 writable: !1
5082 }), e;
5083 }
5084 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5085
5086 /***/ }),
5087
5088 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5089 /*!****************************************************************!*\
5090 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5091 \****************************************************************/
5092 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5093
5094 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5095 function _defineProperty(e, r, t) {
5096 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5097 value: t,
5098 enumerable: !0,
5099 configurable: !0,
5100 writable: !0
5101 }) : e[r] = t, e;
5102 }
5103 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5104
5105 /***/ }),
5106
5107 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5108 /*!********************************************************************!*\
5109 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5110 \********************************************************************/
5111 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5112
5113 "use strict";
5114 __webpack_require__.r(__webpack_exports__);
5115 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5116 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5117 /* harmony export */ });
5118 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5119
5120 function _defineProperty(e, r, t) {
5121 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5122 value: t,
5123 enumerable: !0,
5124 configurable: !0,
5125 writable: !0
5126 }) : e[r] = t, e;
5127 }
5128
5129
5130 /***/ }),
5131
5132 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5133 /*!*******************************************************************!*\
5134 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5135 \*******************************************************************/
5136 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5137
5138 "use strict";
5139 __webpack_require__.r(__webpack_exports__);
5140 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5141 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5142 /* harmony export */ });
5143 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5144
5145 function ownKeys(e, r) {
5146 var t = Object.keys(e);
5147 if (Object.getOwnPropertySymbols) {
5148 var o = Object.getOwnPropertySymbols(e);
5149 r && (o = o.filter(function (r) {
5150 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5151 })), t.push.apply(t, o);
5152 }
5153 return t;
5154 }
5155 function _objectSpread2(e) {
5156 for (var r = 1; r < arguments.length; r++) {
5157 var t = null != arguments[r] ? arguments[r] : {};
5158 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5159 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5160 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5161 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5162 });
5163 }
5164 return e;
5165 }
5166
5167
5168 /***/ }),
5169
5170 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5171 /*!*****************************************************************!*\
5172 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5173 \*****************************************************************/
5174 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5175
5176 "use strict";
5177 __webpack_require__.r(__webpack_exports__);
5178 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5179 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5180 /* harmony export */ });
5181 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5182
5183 function toPrimitive(t, r) {
5184 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5185 var e = t[Symbol.toPrimitive];
5186 if (void 0 !== e) {
5187 var i = e.call(t, r || "default");
5188 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5189 throw new TypeError("@@toPrimitive must return a primitive value.");
5190 }
5191 return ("string" === r ? String : Number)(t);
5192 }
5193
5194
5195 /***/ }),
5196
5197 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5198 /*!*******************************************************************!*\
5199 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5200 \*******************************************************************/
5201 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5202
5203 "use strict";
5204 __webpack_require__.r(__webpack_exports__);
5205 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5206 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5207 /* harmony export */ });
5208 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5209 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5210
5211
5212 function toPropertyKey(t) {
5213 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5214 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5215 }
5216
5217
5218 /***/ }),
5219
5220 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5221 /*!************************************************************!*\
5222 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5223 \************************************************************/
5224 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5225
5226 "use strict";
5227 __webpack_require__.r(__webpack_exports__);
5228 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5229 /* harmony export */ "default": () => (/* binding */ _typeof)
5230 /* harmony export */ });
5231 function _typeof(o) {
5232 "@babel/helpers - typeof";
5233
5234 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5235 return typeof o;
5236 } : function (o) {
5237 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5238 }, _typeof(o);
5239 }
5240
5241
5242 /***/ }),
5243
5244 /***/ "../node_modules/@babel/runtime/helpers/get.js":
5245 /*!*****************************************************!*\
5246 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
5247 \*****************************************************/
5248 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5249
5250 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
5251 function _get() {
5252 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
5253 var p = superPropBase(e, t);
5254 if (p) {
5255 var n = Object.getOwnPropertyDescriptor(p, t);
5256 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
5257 }
5258 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
5259 }
5260 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
5261
5262 /***/ }),
5263
5264 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
5265 /*!****************************************************************!*\
5266 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
5267 \****************************************************************/
5268 /***/ ((module) => {
5269
5270 function _getPrototypeOf(t) {
5271 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
5272 return t.__proto__ || Object.getPrototypeOf(t);
5273 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
5274 }
5275 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
5276
5277 /***/ }),
5278
5279 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
5280 /*!**********************************************************!*\
5281 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
5282 \**********************************************************/
5283 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5284
5285 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5286 function _inherits(t, e) {
5287 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
5288 t.prototype = Object.create(e && e.prototype, {
5289 constructor: {
5290 value: t,
5291 writable: !0,
5292 configurable: !0
5293 }
5294 }), Object.defineProperty(t, "prototype", {
5295 writable: !1
5296 }), e && setPrototypeOf(t, e);
5297 }
5298 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
5299
5300 /***/ }),
5301
5302 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
5303 /*!***********************************************************************!*\
5304 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
5305 \***********************************************************************/
5306 /***/ ((module) => {
5307
5308 function _interopRequireDefault(e) {
5309 return e && e.__esModule ? e : {
5310 "default": e
5311 };
5312 }
5313 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
5314
5315 /***/ }),
5316
5317 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
5318 /*!******************************************************************!*\
5319 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
5320 \******************************************************************/
5321 /***/ ((module) => {
5322
5323 function _isNativeFunction(t) {
5324 try {
5325 return -1 !== Function.toString.call(t).indexOf("[native code]");
5326 } catch (n) {
5327 return "function" == typeof t;
5328 }
5329 }
5330 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
5331
5332 /***/ }),
5333
5334 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
5335 /*!**************************************************************************!*\
5336 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
5337 \**************************************************************************/
5338 /***/ ((module) => {
5339
5340 function _isNativeReflectConstruct() {
5341 try {
5342 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
5343 } catch (t) {}
5344 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
5345 return !!t;
5346 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5347 }
5348 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5349
5350 /***/ }),
5351
5352 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
5353 /*!**********************************************************************!*\
5354 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
5355 \**********************************************************************/
5356 /***/ ((module) => {
5357
5358 function _iterableToArrayLimit(r, l) {
5359 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
5360 if (null != t) {
5361 var e,
5362 n,
5363 i,
5364 u,
5365 a = [],
5366 f = !0,
5367 o = !1;
5368 try {
5369 if (i = (t = t.call(r)).next, 0 === l) {
5370 if (Object(t) !== t) return;
5371 f = !1;
5372 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
5373 } catch (r) {
5374 o = !0, n = r;
5375 } finally {
5376 try {
5377 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
5378 } finally {
5379 if (o) throw n;
5380 }
5381 }
5382 return a;
5383 }
5384 }
5385 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
5386
5387 /***/ }),
5388
5389 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
5390 /*!*****************************************************************!*\
5391 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
5392 \*****************************************************************/
5393 /***/ ((module) => {
5394
5395 function _nonIterableRest() {
5396 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5397 }
5398 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
5399
5400 /***/ }),
5401
5402 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
5403 /*!***************************************************************************!*\
5404 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
5405 \***************************************************************************/
5406 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5407
5408 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5409 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
5410 function _possibleConstructorReturn(t, e) {
5411 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
5412 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
5413 return assertThisInitialized(t);
5414 }
5415 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
5416
5417 /***/ }),
5418
5419 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
5420 /*!***************************************************************!*\
5421 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
5422 \***************************************************************/
5423 /***/ ((module) => {
5424
5425 function _readOnlyError(r) {
5426 throw new TypeError('"' + r + '" is read-only');
5427 }
5428 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
5429
5430 /***/ }),
5431
5432 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
5433 /*!*************************************************************!*\
5434 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
5435 \*************************************************************/
5436 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5437
5438 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5439 function _regenerator() {
5440 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
5441 var e,
5442 t,
5443 r = "function" == typeof Symbol ? Symbol : {},
5444 n = r.iterator || "@@iterator",
5445 o = r.toStringTag || "@@toStringTag";
5446 function i(r, n, o, i) {
5447 var c = n && n.prototype instanceof Generator ? n : Generator,
5448 u = Object.create(c.prototype);
5449 return regeneratorDefine(u, "_invoke", function (r, n, o) {
5450 var i,
5451 c,
5452 u,
5453 f = 0,
5454 p = o || [],
5455 y = !1,
5456 G = {
5457 p: 0,
5458 n: 0,
5459 v: e,
5460 a: d,
5461 f: d.bind(e, 4),
5462 d: function d(t, r) {
5463 return i = t, c = 0, u = e, G.n = r, a;
5464 }
5465 };
5466 function d(r, n) {
5467 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
5468 var o,
5469 i = p[t],
5470 d = G.p,
5471 l = i[2];
5472 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));
5473 }
5474 if (o || r > 1) return a;
5475 throw y = !0, n;
5476 }
5477 return function (o, p, l) {
5478 if (f > 1) throw TypeError("Generator is already running");
5479 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
5480 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
5481 try {
5482 if (f = 2, i) {
5483 if (c || (o = "next"), t = i[o]) {
5484 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
5485 if (!t.done) return t;
5486 u = t.value, c < 2 && (c = 0);
5487 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
5488 i = e;
5489 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
5490 } catch (t) {
5491 i = e, c = 1, u = t;
5492 } finally {
5493 f = 1;
5494 }
5495 }
5496 return {
5497 value: t,
5498 done: y
5499 };
5500 };
5501 }(r, o, i), !0), u;
5502 }
5503 var a = {};
5504 function Generator() {}
5505 function GeneratorFunction() {}
5506 function GeneratorFunctionPrototype() {}
5507 t = Object.getPrototypeOf;
5508 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
5509 return this;
5510 }), t),
5511 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
5512 function f(e) {
5513 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
5514 }
5515 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 () {
5516 return this;
5517 }), regeneratorDefine(u, "toString", function () {
5518 return "[object Generator]";
5519 }), (module.exports = _regenerator = function _regenerator() {
5520 return {
5521 w: i,
5522 m: f
5523 };
5524 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5525 }
5526 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5527
5528 /***/ }),
5529
5530 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
5531 /*!******************************************************************!*\
5532 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
5533 \******************************************************************/
5534 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5535
5536 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5537 function _regeneratorAsync(n, e, r, t, o) {
5538 var a = regeneratorAsyncGen(n, e, r, t, o);
5539 return a.next().then(function (n) {
5540 return n.done ? n.value : a.next();
5541 });
5542 }
5543 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
5544
5545 /***/ }),
5546
5547 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
5548 /*!*********************************************************************!*\
5549 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
5550 \*********************************************************************/
5551 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5552
5553 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5554 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5555 function _regeneratorAsyncGen(r, e, t, o, n) {
5556 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
5557 }
5558 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
5559
5560 /***/ }),
5561
5562 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
5563 /*!**************************************************************************!*\
5564 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
5565 \**************************************************************************/
5566 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5567
5568 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5569 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
5570 function AsyncIterator(t, e) {
5571 function n(r, o, i, f) {
5572 try {
5573 var c = t[r](o),
5574 u = c.value;
5575 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
5576 n("next", t, i, f);
5577 }, function (t) {
5578 n("throw", t, i, f);
5579 }) : e.resolve(u).then(function (t) {
5580 c.value = t, i(c);
5581 }, function (t) {
5582 return n("throw", t, i, f);
5583 });
5584 } catch (t) {
5585 f(t);
5586 }
5587 }
5588 var r;
5589 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
5590 return this;
5591 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
5592 function f() {
5593 return new e(function (e, r) {
5594 n(t, i, e, r);
5595 });
5596 }
5597 return r = r ? r.then(f, f) : f();
5598 }, !0);
5599 }
5600 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5601
5602 /***/ }),
5603
5604 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
5605 /*!*******************************************************************!*\
5606 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
5607 \*******************************************************************/
5608 /***/ ((module) => {
5609
5610 function _regeneratorDefine(e, r, n, t) {
5611 var i = Object.defineProperty;
5612 try {
5613 i({}, "", {});
5614 } catch (e) {
5615 i = 0;
5616 }
5617 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
5618 if (r) i ? i(e, r, {
5619 value: n,
5620 enumerable: !t,
5621 configurable: !t,
5622 writable: !t
5623 }) : e[r] = n;else {
5624 var o = function o(r, n) {
5625 _regeneratorDefine(e, r, function (e) {
5626 return this._invoke(r, n, e);
5627 });
5628 };
5629 o("next", 0), o("throw", 1), o("return", 2);
5630 }
5631 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
5632 }
5633 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
5634
5635 /***/ }),
5636
5637 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
5638 /*!*****************************************************************!*\
5639 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
5640 \*****************************************************************/
5641 /***/ ((module) => {
5642
5643 function _regeneratorKeys(e) {
5644 var n = Object(e),
5645 r = [];
5646 for (var t in n) r.unshift(t);
5647 return function e() {
5648 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
5649 return e.done = !0, e;
5650 };
5651 }
5652 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
5653
5654 /***/ }),
5655
5656 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
5657 /*!********************************************************************!*\
5658 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
5659 \********************************************************************/
5660 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5661
5662 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
5663 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
5664 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
5665 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
5666 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
5667 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
5668 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
5669 function _regeneratorRuntime() {
5670 "use strict";
5671
5672 var r = regenerator(),
5673 e = r.m(_regeneratorRuntime),
5674 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
5675 function n(r) {
5676 var e = "function" == typeof r && r.constructor;
5677 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
5678 }
5679 var o = {
5680 "throw": 1,
5681 "return": 2,
5682 "break": 3,
5683 "continue": 3
5684 };
5685 function a(r) {
5686 var e, t;
5687 return function (n) {
5688 e || (e = {
5689 stop: function stop() {
5690 return t(n.a, 2);
5691 },
5692 "catch": function _catch() {
5693 return n.v;
5694 },
5695 abrupt: function abrupt(r, e) {
5696 return t(n.a, o[r], e);
5697 },
5698 delegateYield: function delegateYield(r, o, a) {
5699 return e.resultName = o, t(n.d, regeneratorValues(r), a);
5700 },
5701 finish: function finish(r) {
5702 return t(n.f, r);
5703 }
5704 }, t = function t(r, _t, o) {
5705 n.p = e.prev, n.n = e.next;
5706 try {
5707 return r(_t, o);
5708 } finally {
5709 e.next = n.n;
5710 }
5711 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
5712 try {
5713 return r.call(this, e);
5714 } finally {
5715 n.p = e.prev, n.n = e.next;
5716 }
5717 };
5718 }
5719 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
5720 return {
5721 wrap: function wrap(e, t, n, o) {
5722 return r.w(a(e), t, n, o && o.reverse());
5723 },
5724 isGeneratorFunction: n,
5725 mark: r.m,
5726 awrap: function awrap(r, e) {
5727 return new OverloadYield(r, e);
5728 },
5729 AsyncIterator: regeneratorAsyncIterator,
5730 async: function async(r, e, t, o, u) {
5731 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
5732 },
5733 keys: regeneratorKeys,
5734 values: regeneratorValues
5735 };
5736 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
5737 }
5738 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
5739
5740 /***/ }),
5741
5742 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
5743 /*!*******************************************************************!*\
5744 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
5745 \*******************************************************************/
5746 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5747
5748 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5749 function _regeneratorValues(e) {
5750 if (null != e) {
5751 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
5752 r = 0;
5753 if (t) return t.call(e);
5754 if ("function" == typeof e.next) return e;
5755 if (!isNaN(e.length)) return {
5756 next: function next() {
5757 return e && r >= e.length && (e = void 0), {
5758 value: e && e[r++],
5759 done: !e
5760 };
5761 }
5762 };
5763 }
5764 throw new TypeError(_typeof(e) + " is not iterable");
5765 }
5766 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
5767
5768 /***/ }),
5769
5770 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
5771 /*!****************************************************************!*\
5772 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
5773 \****************************************************************/
5774 /***/ ((module) => {
5775
5776 function _setPrototypeOf(t, e) {
5777 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
5778 return t.__proto__ = e, t;
5779 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
5780 }
5781 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
5782
5783 /***/ }),
5784
5785 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
5786 /*!***************************************************************!*\
5787 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
5788 \***************************************************************/
5789 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5790
5791 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
5792 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
5793 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
5794 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
5795 function _slicedToArray(r, e) {
5796 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
5797 }
5798 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5799
5800 /***/ }),
5801
5802 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
5803 /*!***************************************************************!*\
5804 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
5805 \***************************************************************/
5806 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5807
5808 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
5809 function _superPropBase(t, o) {
5810 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
5811 return t;
5812 }
5813 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
5814
5815 /***/ }),
5816
5817 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
5818 /*!*************************************************************!*\
5819 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
5820 \*************************************************************/
5821 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5822
5823 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5824 function toPrimitive(t, r) {
5825 if ("object" != _typeof(t) || !t) return t;
5826 var e = t[Symbol.toPrimitive];
5827 if (void 0 !== e) {
5828 var i = e.call(t, r || "default");
5829 if ("object" != _typeof(i)) return i;
5830 throw new TypeError("@@toPrimitive must return a primitive value.");
5831 }
5832 return ("string" === r ? String : Number)(t);
5833 }
5834 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
5835
5836 /***/ }),
5837
5838 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
5839 /*!***************************************************************!*\
5840 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
5841 \***************************************************************/
5842 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5843
5844 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
5845 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
5846 function toPropertyKey(t) {
5847 var i = toPrimitive(t, "string");
5848 return "symbol" == _typeof(i) ? i : i + "";
5849 }
5850 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
5851
5852 /***/ }),
5853
5854 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
5855 /*!********************************************************!*\
5856 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
5857 \********************************************************/
5858 /***/ ((module) => {
5859
5860 function _typeof(o) {
5861 "@babel/helpers - typeof";
5862
5863 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5864 return typeof o;
5865 } : function (o) {
5866 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5867 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
5868 }
5869 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
5870
5871 /***/ }),
5872
5873 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
5874 /*!****************************************************************************!*\
5875 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
5876 \****************************************************************************/
5877 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5878
5879 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
5880 function _unsupportedIterableToArray(r, a) {
5881 if (r) {
5882 if ("string" == typeof r) return arrayLikeToArray(r, a);
5883 var t = {}.toString.call(r).slice(8, -1);
5884 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;
5885 }
5886 }
5887 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5888
5889 /***/ }),
5890
5891 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
5892 /*!*****************************************************************!*\
5893 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
5894 \*****************************************************************/
5895 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5896
5897 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
5898 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5899 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
5900 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
5901 function _wrapNativeSuper(t) {
5902 var r = "function" == typeof Map ? new Map() : void 0;
5903 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
5904 if (null === t || !isNativeFunction(t)) return t;
5905 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
5906 if (void 0 !== r) {
5907 if (r.has(t)) return r.get(t);
5908 r.set(t, Wrapper);
5909 }
5910 function Wrapper() {
5911 return construct(t, arguments, getPrototypeOf(this).constructor);
5912 }
5913 return Wrapper.prototype = Object.create(t.prototype, {
5914 constructor: {
5915 value: Wrapper,
5916 enumerable: !1,
5917 writable: !0,
5918 configurable: !0
5919 }
5920 }), setPrototypeOf(Wrapper, t);
5921 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
5922 }
5923 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
5924
5925 /***/ }),
5926
5927 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
5928 /*!***********************************************************!*\
5929 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
5930 \***********************************************************/
5931 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5932
5933 // TODO(Babel 8): Remove this file.
5934
5935 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
5936 module.exports = runtime;
5937
5938 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
5939 try {
5940 regeneratorRuntime = runtime;
5941 } catch (accidentalStrictMode) {
5942 if (typeof globalThis === "object") {
5943 globalThis.regeneratorRuntime = runtime;
5944 } else {
5945 Function("r", "regeneratorRuntime = r")(runtime);
5946 }
5947 }
5948
5949
5950 /***/ }),
5951
5952 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
5953 /*!******************************************************************!*\
5954 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
5955 \******************************************************************/
5956 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5957
5958 "use strict";
5959 __webpack_require__.r(__webpack_exports__);
5960 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5961 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
5962 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
5963 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
5964 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
5965 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.__DO_NOT_USE__ActionTypes),
5966 /* harmony export */ addListener: () => (/* binding */ addListener),
5967 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.applyMiddleware),
5968 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
5969 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.bindActionCreators),
5970 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
5971 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.combineReducers),
5972 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.compose),
5973 /* harmony export */ configureStore: () => (/* binding */ configureStore),
5974 /* harmony export */ createAction: () => (/* binding */ createAction),
5975 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
5976 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
5977 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
5978 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
5979 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
5980 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
5981 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_2__["default"]),
5982 /* harmony export */ createReducer: () => (/* binding */ createReducer),
5983 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector),
5984 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
5985 /* harmony export */ createSlice: () => (/* binding */ createSlice),
5986 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.createStore),
5987 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_2__.current),
5988 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
5989 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_2__.freeze),
5990 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
5991 /* harmony export */ getType: () => (/* binding */ getType),
5992 /* harmony export */ isAction: () => (/* binding */ isAction),
5993 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
5994 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
5995 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
5996 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
5997 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_2__.isDraft),
5998 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
5999 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6000 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6001 /* harmony export */ isPending: () => (/* binding */ isPending),
6002 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6003 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6004 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6005 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6006 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.legacy_createStore),
6007 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6008 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6009 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_2__.original),
6010 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6011 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6012 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6013 /* harmony export */ });
6014 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6015 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6016 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6017 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6018 var __extends = (undefined && undefined.__extends) || (function () {
6019 var extendStatics = function (d, b) {
6020 extendStatics = Object.setPrototypeOf ||
6021 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6022 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6023 return extendStatics(d, b);
6024 };
6025 return function (d, b) {
6026 if (typeof b !== "function" && b !== null)
6027 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6028 extendStatics(d, b);
6029 function __() { this.constructor = d; }
6030 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6031 };
6032 })();
6033 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6034 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6035 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6036 function verb(n) { return function (v) { return step([n, v]); }; }
6037 function step(op) {
6038 if (f) throw new TypeError("Generator is already executing.");
6039 while (_) try {
6040 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;
6041 if (y = 0, t) op = [op[0] & 2, t.value];
6042 switch (op[0]) {
6043 case 0: case 1: t = op; break;
6044 case 4: _.label++; return { value: op[1], done: false };
6045 case 5: _.label++; y = op[1]; op = [0]; continue;
6046 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6047 default:
6048 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6049 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6050 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6051 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6052 if (t[2]) _.ops.pop();
6053 _.trys.pop(); continue;
6054 }
6055 op = body.call(thisArg, _);
6056 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6057 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6058 }
6059 };
6060 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6061 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6062 to[j] = from[i];
6063 return to;
6064 };
6065 var __defProp = Object.defineProperty;
6066 var __defProps = Object.defineProperties;
6067 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6068 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6069 var __hasOwnProp = Object.prototype.hasOwnProperty;
6070 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6071 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6072 var __spreadValues = function (a, b) {
6073 for (var prop in b || (b = {}))
6074 if (__hasOwnProp.call(b, prop))
6075 __defNormalProp(a, prop, b[prop]);
6076 if (__getOwnPropSymbols)
6077 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6078 var prop = _c[_i];
6079 if (__propIsEnum.call(b, prop))
6080 __defNormalProp(a, prop, b[prop]);
6081 }
6082 return a;
6083 };
6084 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6085 var __async = function (__this, __arguments, generator) {
6086 return new Promise(function (resolve, reject) {
6087 var fulfilled = function (value) {
6088 try {
6089 step(generator.next(value));
6090 }
6091 catch (e) {
6092 reject(e);
6093 }
6094 };
6095 var rejected = function (value) {
6096 try {
6097 step(generator.throw(value));
6098 }
6099 catch (e) {
6100 reject(e);
6101 }
6102 };
6103 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6104 step((generator = generator.apply(__this, __arguments)).next());
6105 });
6106 };
6107 // src/index.ts
6108
6109
6110
6111
6112 // src/createDraftSafeSelector.ts
6113
6114
6115 var createDraftSafeSelector = function () {
6116 var args = [];
6117 for (var _i = 0; _i < arguments.length; _i++) {
6118 args[_i] = arguments[_i];
6119 }
6120 var selector = reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector.apply(void 0, args);
6121 var wrappedSelector = function (value) {
6122 var rest = [];
6123 for (var _i = 1; _i < arguments.length; _i++) {
6124 rest[_i - 1] = arguments[_i];
6125 }
6126 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_2__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_2__.current)(value) : value], rest));
6127 };
6128 return wrappedSelector;
6129 };
6130 // src/configureStore.ts
6131
6132 // src/devtoolsExtension.ts
6133
6134 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6135 if (arguments.length === 0)
6136 return void 0;
6137 if (typeof arguments[0] === "object")
6138 return redux__WEBPACK_IMPORTED_MODULE_0__.compose;
6139 return redux__WEBPACK_IMPORTED_MODULE_0__.compose.apply(null, arguments);
6140 };
6141 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6142 return function (noop2) {
6143 return noop2;
6144 };
6145 };
6146 // src/isPlainObject.ts
6147 function isPlainObject(value) {
6148 if (typeof value !== "object" || value === null)
6149 return false;
6150 var proto = Object.getPrototypeOf(value);
6151 if (proto === null)
6152 return true;
6153 var baseProto = proto;
6154 while (Object.getPrototypeOf(baseProto) !== null) {
6155 baseProto = Object.getPrototypeOf(baseProto);
6156 }
6157 return proto === baseProto;
6158 }
6159 // src/getDefaultMiddleware.ts
6160
6161 // src/tsHelpers.ts
6162 var hasMatchFunction = function (v) {
6163 return v && typeof v.match === "function";
6164 };
6165 // src/createAction.ts
6166 function createAction(type, prepareAction) {
6167 function actionCreator() {
6168 var args = [];
6169 for (var _i = 0; _i < arguments.length; _i++) {
6170 args[_i] = arguments[_i];
6171 }
6172 if (prepareAction) {
6173 var prepared = prepareAction.apply(void 0, args);
6174 if (!prepared) {
6175 throw new Error("prepareAction did not return an object");
6176 }
6177 return __spreadValues(__spreadValues({
6178 type: type,
6179 payload: prepared.payload
6180 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6181 }
6182 return { type: type, payload: args[0] };
6183 }
6184 actionCreator.toString = function () { return "" + type; };
6185 actionCreator.type = type;
6186 actionCreator.match = function (action) { return action.type === type; };
6187 return actionCreator;
6188 }
6189 function isAction(action) {
6190 return isPlainObject(action) && "type" in action;
6191 }
6192 function isActionCreator(action) {
6193 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6194 }
6195 function isFSA(action) {
6196 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6197 }
6198 function isValidKey(key) {
6199 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6200 }
6201 function getType(actionCreator) {
6202 return "" + actionCreator;
6203 }
6204 // src/actionCreatorInvariantMiddleware.ts
6205 function getMessage(type) {
6206 var splitType = type ? ("" + type).split("/") : [];
6207 var actionName = splitType[splitType.length - 1] || "actionCreator";
6208 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.";
6209 }
6210 function createActionCreatorInvariantMiddleware(options) {
6211 if (options === void 0) { options = {}; }
6212 if (false) // removed by dead control flow
6213 {}
6214 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6215 return function () { return function (next) { return function (action) {
6216 if (isActionCreator2(action)) {
6217 console.warn(getMessage(action.type));
6218 }
6219 return next(action);
6220 }; }; };
6221 }
6222 // src/utils.ts
6223
6224 function getTimeMeasureUtils(maxDelay, fnName) {
6225 var elapsed = 0;
6226 return {
6227 measureTime: function (fn) {
6228 var started = Date.now();
6229 try {
6230 return fn();
6231 }
6232 finally {
6233 var finished = Date.now();
6234 elapsed += finished - started;
6235 }
6236 },
6237 warnIfExceeded: function () {
6238 if (elapsed > maxDelay) {
6239 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.");
6240 }
6241 }
6242 };
6243 }
6244 var MiddlewareArray = /** @class */ (function (_super) {
6245 __extends(MiddlewareArray, _super);
6246 function MiddlewareArray() {
6247 var args = [];
6248 for (var _i = 0; _i < arguments.length; _i++) {
6249 args[_i] = arguments[_i];
6250 }
6251 var _this = _super.apply(this, args) || this;
6252 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
6253 return _this;
6254 }
6255 Object.defineProperty(MiddlewareArray, Symbol.species, {
6256 get: function () {
6257 return MiddlewareArray;
6258 },
6259 enumerable: false,
6260 configurable: true
6261 });
6262 MiddlewareArray.prototype.concat = function () {
6263 var arr = [];
6264 for (var _i = 0; _i < arguments.length; _i++) {
6265 arr[_i] = arguments[_i];
6266 }
6267 return _super.prototype.concat.apply(this, arr);
6268 };
6269 MiddlewareArray.prototype.prepend = function () {
6270 var arr = [];
6271 for (var _i = 0; _i < arguments.length; _i++) {
6272 arr[_i] = arguments[_i];
6273 }
6274 if (arr.length === 1 && Array.isArray(arr[0])) {
6275 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
6276 }
6277 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
6278 };
6279 return MiddlewareArray;
6280 }(Array));
6281 var EnhancerArray = /** @class */ (function (_super) {
6282 __extends(EnhancerArray, _super);
6283 function EnhancerArray() {
6284 var args = [];
6285 for (var _i = 0; _i < arguments.length; _i++) {
6286 args[_i] = arguments[_i];
6287 }
6288 var _this = _super.apply(this, args) || this;
6289 Object.setPrototypeOf(_this, EnhancerArray.prototype);
6290 return _this;
6291 }
6292 Object.defineProperty(EnhancerArray, Symbol.species, {
6293 get: function () {
6294 return EnhancerArray;
6295 },
6296 enumerable: false,
6297 configurable: true
6298 });
6299 EnhancerArray.prototype.concat = function () {
6300 var arr = [];
6301 for (var _i = 0; _i < arguments.length; _i++) {
6302 arr[_i] = arguments[_i];
6303 }
6304 return _super.prototype.concat.apply(this, arr);
6305 };
6306 EnhancerArray.prototype.prepend = function () {
6307 var arr = [];
6308 for (var _i = 0; _i < arguments.length; _i++) {
6309 arr[_i] = arguments[_i];
6310 }
6311 if (arr.length === 1 && Array.isArray(arr[0])) {
6312 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
6313 }
6314 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
6315 };
6316 return EnhancerArray;
6317 }(Array));
6318 function freezeDraftable(val) {
6319 return (0,immer__WEBPACK_IMPORTED_MODULE_2__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_2__["default"])(val, function () {
6320 }) : val;
6321 }
6322 // src/immutableStateInvariantMiddleware.ts
6323 var isProduction = "development" === "production";
6324 var prefix = "Invariant failed";
6325 function invariant(condition, message) {
6326 if (condition) {
6327 return;
6328 }
6329 if (isProduction) {
6330 throw new Error(prefix);
6331 }
6332 throw new Error(prefix + ": " + (message || ""));
6333 }
6334 function stringify(obj, serializer, indent, decycler) {
6335 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
6336 }
6337 function getSerialize(serializer, decycler) {
6338 var stack = [], keys = [];
6339 if (!decycler)
6340 decycler = function (_, value) {
6341 if (stack[0] === value)
6342 return "[Circular ~]";
6343 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
6344 };
6345 return function (key, value) {
6346 if (stack.length > 0) {
6347 var thisPos = stack.indexOf(this);
6348 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
6349 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
6350 if (~stack.indexOf(value))
6351 value = decycler.call(this, key, value);
6352 }
6353 else
6354 stack.push(value);
6355 return serializer == null ? value : serializer.call(this, key, value);
6356 };
6357 }
6358 function isImmutableDefault(value) {
6359 return typeof value !== "object" || value == null || Object.isFrozen(value);
6360 }
6361 function trackForMutations(isImmutable, ignorePaths, obj) {
6362 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
6363 return {
6364 detectMutations: function () {
6365 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
6366 }
6367 };
6368 }
6369 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
6370 if (ignorePaths === void 0) { ignorePaths = []; }
6371 if (path === void 0) { path = ""; }
6372 if (checkedObjects === void 0) { checkedObjects = new Set(); }
6373 var tracked = { value: obj };
6374 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
6375 checkedObjects.add(obj);
6376 tracked.children = {};
6377 for (var key in obj) {
6378 var childPath = path ? path + "." + key : key;
6379 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
6380 continue;
6381 }
6382 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
6383 }
6384 }
6385 return tracked;
6386 }
6387 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
6388 if (ignoredPaths === void 0) { ignoredPaths = []; }
6389 if (sameParentRef === void 0) { sameParentRef = false; }
6390 if (path === void 0) { path = ""; }
6391 var prevObj = trackedProperty ? trackedProperty.value : void 0;
6392 var sameRef = prevObj === obj;
6393 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
6394 return { wasMutated: true, path: path };
6395 }
6396 if (isImmutable(prevObj) || isImmutable(obj)) {
6397 return { wasMutated: false };
6398 }
6399 var keysToDetect = {};
6400 for (var key in trackedProperty.children) {
6401 keysToDetect[key] = true;
6402 }
6403 for (var key in obj) {
6404 keysToDetect[key] = true;
6405 }
6406 var hasIgnoredPaths = ignoredPaths.length > 0;
6407 var _loop_1 = function (key) {
6408 var nestedPath = path ? path + "." + key : key;
6409 if (hasIgnoredPaths) {
6410 var hasMatches = ignoredPaths.some(function (ignored) {
6411 if (ignored instanceof RegExp) {
6412 return ignored.test(nestedPath);
6413 }
6414 return nestedPath === ignored;
6415 });
6416 if (hasMatches) {
6417 return "continue";
6418 }
6419 }
6420 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
6421 if (result.wasMutated) {
6422 return { value: result };
6423 }
6424 };
6425 for (var key in keysToDetect) {
6426 var state_1 = _loop_1(key);
6427 if (typeof state_1 === "object")
6428 return state_1.value;
6429 }
6430 return { wasMutated: false };
6431 }
6432 function createImmutableStateInvariantMiddleware(options) {
6433 if (options === void 0) { options = {}; }
6434 if (false) // removed by dead control flow
6435 {}
6436 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;
6437 ignoredPaths = ignoredPaths || ignore;
6438 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
6439 return function (_c) {
6440 var getState = _c.getState;
6441 var state = getState();
6442 var tracker = track(state);
6443 var result;
6444 return function (next) { return function (action) {
6445 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
6446 measureUtils.measureTime(function () {
6447 state = getState();
6448 result = tracker.detectMutations();
6449 tracker = track(state);
6450 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)");
6451 });
6452 var dispatchedAction = next(action);
6453 measureUtils.measureTime(function () {
6454 state = getState();
6455 result = tracker.detectMutations();
6456 tracker = track(state);
6457 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)");
6458 });
6459 measureUtils.warnIfExceeded();
6460 return dispatchedAction;
6461 }; };
6462 };
6463 }
6464 // src/serializableStateInvariantMiddleware.ts
6465 function isPlain(val) {
6466 var type = typeof val;
6467 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
6468 }
6469 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
6470 if (path === void 0) { path = ""; }
6471 if (isSerializable === void 0) { isSerializable = isPlain; }
6472 if (ignoredPaths === void 0) { ignoredPaths = []; }
6473 var foundNestedSerializable;
6474 if (!isSerializable(value)) {
6475 return {
6476 keyPath: path || "<root>",
6477 value: value
6478 };
6479 }
6480 if (typeof value !== "object" || value === null) {
6481 return false;
6482 }
6483 if (cache == null ? void 0 : cache.has(value))
6484 return false;
6485 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
6486 var hasIgnoredPaths = ignoredPaths.length > 0;
6487 var _loop_2 = function (key, nestedValue) {
6488 var nestedPath = path ? path + "." + key : key;
6489 if (hasIgnoredPaths) {
6490 var hasMatches = ignoredPaths.some(function (ignored) {
6491 if (ignored instanceof RegExp) {
6492 return ignored.test(nestedPath);
6493 }
6494 return nestedPath === ignored;
6495 });
6496 if (hasMatches) {
6497 return "continue";
6498 }
6499 }
6500 if (!isSerializable(nestedValue)) {
6501 return { value: {
6502 keyPath: nestedPath,
6503 value: nestedValue
6504 } };
6505 }
6506 if (typeof nestedValue === "object") {
6507 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
6508 if (foundNestedSerializable) {
6509 return { value: foundNestedSerializable };
6510 }
6511 }
6512 };
6513 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
6514 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
6515 var state_2 = _loop_2(key, nestedValue);
6516 if (typeof state_2 === "object")
6517 return state_2.value;
6518 }
6519 if (cache && isNestedFrozen(value))
6520 cache.add(value);
6521 return false;
6522 }
6523 function isNestedFrozen(value) {
6524 if (!Object.isFrozen(value))
6525 return false;
6526 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
6527 var nestedValue = _c[_i];
6528 if (typeof nestedValue !== "object" || nestedValue === null)
6529 continue;
6530 if (!isNestedFrozen(nestedValue))
6531 return false;
6532 }
6533 return true;
6534 }
6535 function createSerializableStateInvariantMiddleware(options) {
6536 if (options === void 0) { options = {}; }
6537 if (false) // removed by dead control flow
6538 {}
6539 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;
6540 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
6541 return function (storeAPI) { return function (next) { return function (action) {
6542 var result = next(action);
6543 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
6544 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
6545 measureUtils.measureTime(function () {
6546 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
6547 if (foundActionNonSerializableValue) {
6548 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
6549 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)");
6550 }
6551 });
6552 }
6553 if (!ignoreState) {
6554 measureUtils.measureTime(function () {
6555 var state = storeAPI.getState();
6556 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
6557 if (foundStateNonSerializableValue) {
6558 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
6559 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)");
6560 }
6561 });
6562 measureUtils.warnIfExceeded();
6563 }
6564 return result;
6565 }; }; };
6566 }
6567 // src/getDefaultMiddleware.ts
6568 function isBoolean(x) {
6569 return typeof x === "boolean";
6570 }
6571 function curryGetDefaultMiddleware() {
6572 return function curriedGetDefaultMiddleware(options) {
6573 return getDefaultMiddleware(options);
6574 };
6575 }
6576 function getDefaultMiddleware(options) {
6577 if (options === void 0) { options = {}; }
6578 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;
6579 var middlewareArray = new MiddlewareArray();
6580 if (thunk) {
6581 if (isBoolean(thunk)) {
6582 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
6583 }
6584 else {
6585 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
6586 }
6587 }
6588 if (true) {
6589 if (immutableCheck) {
6590 var immutableOptions = {};
6591 if (!isBoolean(immutableCheck)) {
6592 immutableOptions = immutableCheck;
6593 }
6594 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
6595 }
6596 if (serializableCheck) {
6597 var serializableOptions = {};
6598 if (!isBoolean(serializableCheck)) {
6599 serializableOptions = serializableCheck;
6600 }
6601 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
6602 }
6603 if (actionCreatorCheck) {
6604 var actionCreatorOptions = {};
6605 if (!isBoolean(actionCreatorCheck)) {
6606 actionCreatorOptions = actionCreatorCheck;
6607 }
6608 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
6609 }
6610 }
6611 return middlewareArray;
6612 }
6613 // src/configureStore.ts
6614 var IS_PRODUCTION = "development" === "production";
6615 function configureStore(options) {
6616 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
6617 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;
6618 var rootReducer;
6619 if (typeof reducer === "function") {
6620 rootReducer = reducer;
6621 }
6622 else if (isPlainObject(reducer)) {
6623 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_0__.combineReducers)(reducer);
6624 }
6625 else {
6626 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
6627 }
6628 var finalMiddleware = middleware;
6629 if (typeof finalMiddleware === "function") {
6630 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
6631 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
6632 throw new Error("when using a middleware builder function, an array of middleware must be returned");
6633 }
6634 }
6635 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
6636 throw new Error("each middleware provided to configureStore must be a function");
6637 }
6638 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_0__.applyMiddleware.apply(void 0, finalMiddleware);
6639 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_0__.compose;
6640 if (devTools) {
6641 finalCompose = composeWithDevTools(__spreadValues({
6642 trace: !IS_PRODUCTION
6643 }, typeof devTools === "object" && devTools));
6644 }
6645 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
6646 var storeEnhancers = defaultEnhancers;
6647 if (Array.isArray(enhancers)) {
6648 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
6649 }
6650 else if (typeof enhancers === "function") {
6651 storeEnhancers = enhancers(defaultEnhancers);
6652 }
6653 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
6654 return (0,redux__WEBPACK_IMPORTED_MODULE_0__.createStore)(rootReducer, preloadedState, composedEnhancer);
6655 }
6656 // src/createReducer.ts
6657
6658 // src/mapBuilders.ts
6659 function executeReducerBuilderCallback(builderCallback) {
6660 var actionsMap = {};
6661 var actionMatchers = [];
6662 var defaultCaseReducer;
6663 var builder = {
6664 addCase: function (typeOrActionCreator, reducer) {
6665 if (true) {
6666 if (actionMatchers.length > 0) {
6667 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
6668 }
6669 if (defaultCaseReducer) {
6670 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
6671 }
6672 }
6673 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
6674 if (!type) {
6675 throw new Error("`builder.addCase` cannot be called with an empty action type");
6676 }
6677 if (type in actionsMap) {
6678 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
6679 }
6680 actionsMap[type] = reducer;
6681 return builder;
6682 },
6683 addMatcher: function (matcher, reducer) {
6684 if (true) {
6685 if (defaultCaseReducer) {
6686 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
6687 }
6688 }
6689 actionMatchers.push({ matcher: matcher, reducer: reducer });
6690 return builder;
6691 },
6692 addDefaultCase: function (reducer) {
6693 if (true) {
6694 if (defaultCaseReducer) {
6695 throw new Error("`builder.addDefaultCase` can only be called once");
6696 }
6697 }
6698 defaultCaseReducer = reducer;
6699 return builder;
6700 }
6701 };
6702 builderCallback(builder);
6703 return [actionsMap, actionMatchers, defaultCaseReducer];
6704 }
6705 // src/createReducer.ts
6706 function isStateFunction(x) {
6707 return typeof x === "function";
6708 }
6709 var hasWarnedAboutObjectNotation = false;
6710 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
6711 if (actionMatchers === void 0) { actionMatchers = []; }
6712 if (true) {
6713 if (typeof mapOrBuilderCallback === "object") {
6714 if (!hasWarnedAboutObjectNotation) {
6715 hasWarnedAboutObjectNotation = true;
6716 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");
6717 }
6718 }
6719 }
6720 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
6721 var getInitialState;
6722 if (isStateFunction(initialState)) {
6723 getInitialState = function () { return freezeDraftable(initialState()); };
6724 }
6725 else {
6726 var frozenInitialState_1 = freezeDraftable(initialState);
6727 getInitialState = function () { return frozenInitialState_1; };
6728 }
6729 function reducer(state, action) {
6730 if (state === void 0) { state = getInitialState(); }
6731 var caseReducers = __spreadArray([
6732 actionsMap[action.type]
6733 ], finalActionMatchers.filter(function (_c) {
6734 var matcher = _c.matcher;
6735 return matcher(action);
6736 }).map(function (_c) {
6737 var reducer2 = _c.reducer;
6738 return reducer2;
6739 }));
6740 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
6741 caseReducers = [finalDefaultCaseReducer];
6742 }
6743 return caseReducers.reduce(function (previousState, caseReducer) {
6744 if (caseReducer) {
6745 if ((0,immer__WEBPACK_IMPORTED_MODULE_2__.isDraft)(previousState)) {
6746 var draft = previousState;
6747 var result = caseReducer(draft, action);
6748 if (result === void 0) {
6749 return previousState;
6750 }
6751 return result;
6752 }
6753 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_2__.isDraftable)(previousState)) {
6754 var result = caseReducer(previousState, action);
6755 if (result === void 0) {
6756 if (previousState === null) {
6757 return previousState;
6758 }
6759 throw Error("A case reducer on a non-draftable value must not return undefined");
6760 }
6761 return result;
6762 }
6763 else {
6764 return (0,immer__WEBPACK_IMPORTED_MODULE_2__["default"])(previousState, function (draft) {
6765 return caseReducer(draft, action);
6766 });
6767 }
6768 }
6769 return previousState;
6770 }, state);
6771 }
6772 reducer.getInitialState = getInitialState;
6773 return reducer;
6774 }
6775 // src/createSlice.ts
6776 var hasWarnedAboutObjectNotation2 = false;
6777 function getType2(slice, actionKey) {
6778 return slice + "/" + actionKey;
6779 }
6780 function createSlice(options) {
6781 var name = options.name;
6782 if (!name) {
6783 throw new Error("`name` is a required option for createSlice");
6784 }
6785 if (typeof process !== "undefined" && "development" === "development") {
6786 if (options.initialState === void 0) {
6787 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
6788 }
6789 }
6790 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
6791 var reducers = options.reducers || {};
6792 var reducerNames = Object.keys(reducers);
6793 var sliceCaseReducersByName = {};
6794 var sliceCaseReducersByType = {};
6795 var actionCreators = {};
6796 reducerNames.forEach(function (reducerName) {
6797 var maybeReducerWithPrepare = reducers[reducerName];
6798 var type = getType2(name, reducerName);
6799 var caseReducer;
6800 var prepareCallback;
6801 if ("reducer" in maybeReducerWithPrepare) {
6802 caseReducer = maybeReducerWithPrepare.reducer;
6803 prepareCallback = maybeReducerWithPrepare.prepare;
6804 }
6805 else {
6806 caseReducer = maybeReducerWithPrepare;
6807 }
6808 sliceCaseReducersByName[reducerName] = caseReducer;
6809 sliceCaseReducersByType[type] = caseReducer;
6810 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
6811 });
6812 function buildReducer() {
6813 if (true) {
6814 if (typeof options.extraReducers === "object") {
6815 if (!hasWarnedAboutObjectNotation2) {
6816 hasWarnedAboutObjectNotation2 = true;
6817 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");
6818 }
6819 }
6820 }
6821 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;
6822 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
6823 return createReducer(initialState, function (builder) {
6824 for (var key in finalCaseReducers) {
6825 builder.addCase(key, finalCaseReducers[key]);
6826 }
6827 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
6828 var m = actionMatchers_1[_i];
6829 builder.addMatcher(m.matcher, m.reducer);
6830 }
6831 if (defaultCaseReducer) {
6832 builder.addDefaultCase(defaultCaseReducer);
6833 }
6834 });
6835 }
6836 var _reducer;
6837 return {
6838 name: name,
6839 reducer: function (state, action) {
6840 if (!_reducer)
6841 _reducer = buildReducer();
6842 return _reducer(state, action);
6843 },
6844 actions: actionCreators,
6845 caseReducers: sliceCaseReducersByName,
6846 getInitialState: function () {
6847 if (!_reducer)
6848 _reducer = buildReducer();
6849 return _reducer.getInitialState();
6850 }
6851 };
6852 }
6853 // src/entities/entity_state.ts
6854 function getInitialEntityState() {
6855 return {
6856 ids: [],
6857 entities: {}
6858 };
6859 }
6860 function createInitialStateFactory() {
6861 function getInitialState(additionalState) {
6862 if (additionalState === void 0) { additionalState = {}; }
6863 return Object.assign(getInitialEntityState(), additionalState);
6864 }
6865 return { getInitialState: getInitialState };
6866 }
6867 // src/entities/state_selectors.ts
6868 function createSelectorsFactory() {
6869 function getSelectors(selectState) {
6870 var selectIds = function (state) { return state.ids; };
6871 var selectEntities = function (state) { return state.entities; };
6872 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
6873 var selectId = function (_, id) { return id; };
6874 var selectById = function (entities, id) { return entities[id]; };
6875 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
6876 if (!selectState) {
6877 return {
6878 selectIds: selectIds,
6879 selectEntities: selectEntities,
6880 selectAll: selectAll,
6881 selectTotal: selectTotal,
6882 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
6883 };
6884 }
6885 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
6886 return {
6887 selectIds: createDraftSafeSelector(selectState, selectIds),
6888 selectEntities: selectGlobalizedEntities,
6889 selectAll: createDraftSafeSelector(selectState, selectAll),
6890 selectTotal: createDraftSafeSelector(selectState, selectTotal),
6891 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
6892 };
6893 }
6894 return { getSelectors: getSelectors };
6895 }
6896 // src/entities/state_adapter.ts
6897
6898 function createSingleArgumentStateOperator(mutator) {
6899 var operator = createStateOperator(function (_, state) { return mutator(state); });
6900 return function operation(state) {
6901 return operator(state, void 0);
6902 };
6903 }
6904 function createStateOperator(mutator) {
6905 return function operation(state, arg) {
6906 function isPayloadActionArgument(arg2) {
6907 return isFSA(arg2);
6908 }
6909 var runMutator = function (draft) {
6910 if (isPayloadActionArgument(arg)) {
6911 mutator(arg.payload, draft);
6912 }
6913 else {
6914 mutator(arg, draft);
6915 }
6916 };
6917 if ((0,immer__WEBPACK_IMPORTED_MODULE_2__.isDraft)(state)) {
6918 runMutator(state);
6919 return state;
6920 }
6921 else {
6922 return (0,immer__WEBPACK_IMPORTED_MODULE_2__["default"])(state, runMutator);
6923 }
6924 };
6925 }
6926 // src/entities/utils.ts
6927 function selectIdValue(entity, selectId) {
6928 var key = selectId(entity);
6929 if ( true && key === void 0) {
6930 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());
6931 }
6932 return key;
6933 }
6934 function ensureEntitiesArray(entities) {
6935 if (!Array.isArray(entities)) {
6936 entities = Object.values(entities);
6937 }
6938 return entities;
6939 }
6940 function splitAddedUpdatedEntities(newEntities, selectId, state) {
6941 newEntities = ensureEntitiesArray(newEntities);
6942 var added = [];
6943 var updated = [];
6944 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
6945 var entity = newEntities_1[_i];
6946 var id = selectIdValue(entity, selectId);
6947 if (id in state.entities) {
6948 updated.push({ id: id, changes: entity });
6949 }
6950 else {
6951 added.push(entity);
6952 }
6953 }
6954 return [added, updated];
6955 }
6956 // src/entities/unsorted_state_adapter.ts
6957 function createUnsortedStateAdapter(selectId) {
6958 function addOneMutably(entity, state) {
6959 var key = selectIdValue(entity, selectId);
6960 if (key in state.entities) {
6961 return;
6962 }
6963 state.ids.push(key);
6964 state.entities[key] = entity;
6965 }
6966 function addManyMutably(newEntities, state) {
6967 newEntities = ensureEntitiesArray(newEntities);
6968 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
6969 var entity = newEntities_2[_i];
6970 addOneMutably(entity, state);
6971 }
6972 }
6973 function setOneMutably(entity, state) {
6974 var key = selectIdValue(entity, selectId);
6975 if (!(key in state.entities)) {
6976 state.ids.push(key);
6977 }
6978 state.entities[key] = entity;
6979 }
6980 function setManyMutably(newEntities, state) {
6981 newEntities = ensureEntitiesArray(newEntities);
6982 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
6983 var entity = newEntities_3[_i];
6984 setOneMutably(entity, state);
6985 }
6986 }
6987 function setAllMutably(newEntities, state) {
6988 newEntities = ensureEntitiesArray(newEntities);
6989 state.ids = [];
6990 state.entities = {};
6991 addManyMutably(newEntities, state);
6992 }
6993 function removeOneMutably(key, state) {
6994 return removeManyMutably([key], state);
6995 }
6996 function removeManyMutably(keys, state) {
6997 var didMutate = false;
6998 keys.forEach(function (key) {
6999 if (key in state.entities) {
7000 delete state.entities[key];
7001 didMutate = true;
7002 }
7003 });
7004 if (didMutate) {
7005 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7006 }
7007 }
7008 function removeAllMutably(state) {
7009 Object.assign(state, {
7010 ids: [],
7011 entities: {}
7012 });
7013 }
7014 function takeNewKey(keys, update, state) {
7015 var original2 = state.entities[update.id];
7016 var updated = Object.assign({}, original2, update.changes);
7017 var newKey = selectIdValue(updated, selectId);
7018 var hasNewKey = newKey !== update.id;
7019 if (hasNewKey) {
7020 keys[update.id] = newKey;
7021 delete state.entities[update.id];
7022 }
7023 state.entities[newKey] = updated;
7024 return hasNewKey;
7025 }
7026 function updateOneMutably(update, state) {
7027 return updateManyMutably([update], state);
7028 }
7029 function updateManyMutably(updates, state) {
7030 var newKeys = {};
7031 var updatesPerEntity = {};
7032 updates.forEach(function (update) {
7033 if (update.id in state.entities) {
7034 updatesPerEntity[update.id] = {
7035 id: update.id,
7036 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7037 };
7038 }
7039 });
7040 updates = Object.values(updatesPerEntity);
7041 var didMutateEntities = updates.length > 0;
7042 if (didMutateEntities) {
7043 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7044 if (didMutateIds) {
7045 state.ids = Object.keys(state.entities);
7046 }
7047 }
7048 }
7049 function upsertOneMutably(entity, state) {
7050 return upsertManyMutably([entity], state);
7051 }
7052 function upsertManyMutably(newEntities, state) {
7053 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7054 updateManyMutably(updated, state);
7055 addManyMutably(added, state);
7056 }
7057 return {
7058 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7059 addOne: createStateOperator(addOneMutably),
7060 addMany: createStateOperator(addManyMutably),
7061 setOne: createStateOperator(setOneMutably),
7062 setMany: createStateOperator(setManyMutably),
7063 setAll: createStateOperator(setAllMutably),
7064 updateOne: createStateOperator(updateOneMutably),
7065 updateMany: createStateOperator(updateManyMutably),
7066 upsertOne: createStateOperator(upsertOneMutably),
7067 upsertMany: createStateOperator(upsertManyMutably),
7068 removeOne: createStateOperator(removeOneMutably),
7069 removeMany: createStateOperator(removeManyMutably)
7070 };
7071 }
7072 // src/entities/sorted_state_adapter.ts
7073 function createSortedStateAdapter(selectId, sort) {
7074 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7075 function addOneMutably(entity, state) {
7076 return addManyMutably([entity], state);
7077 }
7078 function addManyMutably(newEntities, state) {
7079 newEntities = ensureEntitiesArray(newEntities);
7080 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7081 if (models.length !== 0) {
7082 merge(models, state);
7083 }
7084 }
7085 function setOneMutably(entity, state) {
7086 return setManyMutably([entity], state);
7087 }
7088 function setManyMutably(newEntities, state) {
7089 newEntities = ensureEntitiesArray(newEntities);
7090 if (newEntities.length !== 0) {
7091 merge(newEntities, state);
7092 }
7093 }
7094 function setAllMutably(newEntities, state) {
7095 newEntities = ensureEntitiesArray(newEntities);
7096 state.entities = {};
7097 state.ids = [];
7098 addManyMutably(newEntities, state);
7099 }
7100 function updateOneMutably(update, state) {
7101 return updateManyMutably([update], state);
7102 }
7103 function updateManyMutably(updates, state) {
7104 var appliedUpdates = false;
7105 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7106 var update = updates_1[_i];
7107 var entity = state.entities[update.id];
7108 if (!entity) {
7109 continue;
7110 }
7111 appliedUpdates = true;
7112 Object.assign(entity, update.changes);
7113 var newId = selectId(entity);
7114 if (update.id !== newId) {
7115 delete state.entities[update.id];
7116 state.entities[newId] = entity;
7117 }
7118 }
7119 if (appliedUpdates) {
7120 resortEntities(state);
7121 }
7122 }
7123 function upsertOneMutably(entity, state) {
7124 return upsertManyMutably([entity], state);
7125 }
7126 function upsertManyMutably(newEntities, state) {
7127 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7128 updateManyMutably(updated, state);
7129 addManyMutably(added, state);
7130 }
7131 function areArraysEqual(a, b) {
7132 if (a.length !== b.length) {
7133 return false;
7134 }
7135 for (var i = 0; i < a.length && i < b.length; i++) {
7136 if (a[i] === b[i]) {
7137 continue;
7138 }
7139 return false;
7140 }
7141 return true;
7142 }
7143 function merge(models, state) {
7144 models.forEach(function (model) {
7145 state.entities[selectId(model)] = model;
7146 });
7147 resortEntities(state);
7148 }
7149 function resortEntities(state) {
7150 var allEntities = Object.values(state.entities);
7151 allEntities.sort(sort);
7152 var newSortedIds = allEntities.map(selectId);
7153 var ids = state.ids;
7154 if (!areArraysEqual(ids, newSortedIds)) {
7155 state.ids = newSortedIds;
7156 }
7157 }
7158 return {
7159 removeOne: removeOne,
7160 removeMany: removeMany,
7161 removeAll: removeAll,
7162 addOne: createStateOperator(addOneMutably),
7163 updateOne: createStateOperator(updateOneMutably),
7164 upsertOne: createStateOperator(upsertOneMutably),
7165 setOne: createStateOperator(setOneMutably),
7166 setMany: createStateOperator(setManyMutably),
7167 setAll: createStateOperator(setAllMutably),
7168 addMany: createStateOperator(addManyMutably),
7169 updateMany: createStateOperator(updateManyMutably),
7170 upsertMany: createStateOperator(upsertManyMutably)
7171 };
7172 }
7173 // src/entities/create_adapter.ts
7174 function createEntityAdapter(options) {
7175 if (options === void 0) { options = {}; }
7176 var _c = __spreadValues({
7177 sortComparer: false,
7178 selectId: function (instance) { return instance.id; }
7179 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7180 var stateFactory = createInitialStateFactory();
7181 var selectorsFactory = createSelectorsFactory();
7182 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7183 return __spreadValues(__spreadValues(__spreadValues({
7184 selectId: selectId,
7185 sortComparer: sortComparer
7186 }, stateFactory), selectorsFactory), stateAdapter);
7187 }
7188 // src/nanoid.ts
7189 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7190 var nanoid = function (size) {
7191 if (size === void 0) { size = 21; }
7192 var id = "";
7193 var i = size;
7194 while (i--) {
7195 id += urlAlphabet[Math.random() * 64 | 0];
7196 }
7197 return id;
7198 };
7199 // src/createAsyncThunk.ts
7200 var commonProperties = [
7201 "name",
7202 "message",
7203 "stack",
7204 "code"
7205 ];
7206 var RejectWithValue = /** @class */ (function () {
7207 function RejectWithValue(payload, meta) {
7208 this.payload = payload;
7209 this.meta = meta;
7210 }
7211 return RejectWithValue;
7212 }());
7213 var FulfillWithMeta = /** @class */ (function () {
7214 function FulfillWithMeta(payload, meta) {
7215 this.payload = payload;
7216 this.meta = meta;
7217 }
7218 return FulfillWithMeta;
7219 }());
7220 var miniSerializeError = function (value) {
7221 if (typeof value === "object" && value !== null) {
7222 var simpleError = {};
7223 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7224 var property = commonProperties_1[_i];
7225 if (typeof value[property] === "string") {
7226 simpleError[property] = value[property];
7227 }
7228 }
7229 return simpleError;
7230 }
7231 return { message: String(value) };
7232 };
7233 var createAsyncThunk = (function () {
7234 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7235 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7236 payload: payload,
7237 meta: __spreadProps(__spreadValues({}, meta || {}), {
7238 arg: arg,
7239 requestId: requestId,
7240 requestStatus: "fulfilled"
7241 })
7242 }); });
7243 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
7244 payload: void 0,
7245 meta: __spreadProps(__spreadValues({}, meta || {}), {
7246 arg: arg,
7247 requestId: requestId,
7248 requestStatus: "pending"
7249 })
7250 }); });
7251 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
7252 payload: payload,
7253 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
7254 meta: __spreadProps(__spreadValues({}, meta || {}), {
7255 arg: arg,
7256 requestId: requestId,
7257 rejectedWithValue: !!payload,
7258 requestStatus: "rejected",
7259 aborted: (error == null ? void 0 : error.name) === "AbortError",
7260 condition: (error == null ? void 0 : error.name) === "ConditionError"
7261 })
7262 }); });
7263 var displayedWarning = false;
7264 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
7265 function class_1() {
7266 this.signal = {
7267 aborted: false,
7268 addEventListener: function () {
7269 },
7270 dispatchEvent: function () {
7271 return false;
7272 },
7273 onabort: function () {
7274 },
7275 removeEventListener: function () {
7276 },
7277 reason: void 0,
7278 throwIfAborted: function () {
7279 }
7280 };
7281 }
7282 class_1.prototype.abort = function () {
7283 if (true) {
7284 if (!displayedWarning) {
7285 displayedWarning = true;
7286 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'.");
7287 }
7288 }
7289 };
7290 return class_1;
7291 }());
7292 function actionCreator(arg) {
7293 return function (dispatch, getState, extra) {
7294 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
7295 var abortController = new AC();
7296 var abortReason;
7297 var started = false;
7298 function abort(reason) {
7299 abortReason = reason;
7300 abortController.abort();
7301 }
7302 var promise2 = function () {
7303 return __async(this, null, function () {
7304 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
7305 return __generator(this, function (_c) {
7306 switch (_c.label) {
7307 case 0:
7308 _c.trys.push([0, 4, , 5]);
7309 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
7310 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
7311 return [4 /*yield*/, conditionResult];
7312 case 1:
7313 conditionResult = _c.sent();
7314 _c.label = 2;
7315 case 2:
7316 if (conditionResult === false || abortController.signal.aborted) {
7317 throw {
7318 name: "ConditionError",
7319 message: "Aborted due to condition callback returning false."
7320 };
7321 }
7322 started = true;
7323 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
7324 name: "AbortError",
7325 message: abortReason || "Aborted"
7326 }); }); });
7327 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 })));
7328 return [4 /*yield*/, Promise.race([
7329 abortedPromise,
7330 Promise.resolve(payloadCreator(arg, {
7331 dispatch: dispatch,
7332 getState: getState,
7333 extra: extra,
7334 requestId: requestId,
7335 signal: abortController.signal,
7336 abort: abort,
7337 rejectWithValue: function (value, meta) {
7338 return new RejectWithValue(value, meta);
7339 },
7340 fulfillWithValue: function (value, meta) {
7341 return new FulfillWithMeta(value, meta);
7342 }
7343 })).then(function (result) {
7344 if (result instanceof RejectWithValue) {
7345 throw result;
7346 }
7347 if (result instanceof FulfillWithMeta) {
7348 return fulfilled(result.payload, requestId, arg, result.meta);
7349 }
7350 return fulfilled(result, requestId, arg);
7351 })
7352 ])];
7353 case 3:
7354 finalAction = _c.sent();
7355 return [3 /*break*/, 5];
7356 case 4:
7357 err_1 = _c.sent();
7358 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
7359 return [3 /*break*/, 5];
7360 case 5:
7361 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
7362 if (!skipDispatch) {
7363 dispatch(finalAction);
7364 }
7365 return [2 /*return*/, finalAction];
7366 }
7367 });
7368 });
7369 }();
7370 return Object.assign(promise2, {
7371 abort: abort,
7372 requestId: requestId,
7373 arg: arg,
7374 unwrap: function () {
7375 return promise2.then(unwrapResult);
7376 }
7377 });
7378 };
7379 }
7380 return Object.assign(actionCreator, {
7381 pending: pending,
7382 rejected: rejected,
7383 fulfilled: fulfilled,
7384 typePrefix: typePrefix
7385 });
7386 }
7387 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
7388 return createAsyncThunk2;
7389 })();
7390 function unwrapResult(action) {
7391 if (action.meta && action.meta.rejectedWithValue) {
7392 throw action.payload;
7393 }
7394 if (action.error) {
7395 throw action.error;
7396 }
7397 return action.payload;
7398 }
7399 function isThenable(value) {
7400 return value !== null && typeof value === "object" && typeof value.then === "function";
7401 }
7402 // src/matchers.ts
7403 var matches = function (matcher, action) {
7404 if (hasMatchFunction(matcher)) {
7405 return matcher.match(action);
7406 }
7407 else {
7408 return matcher(action);
7409 }
7410 };
7411 function isAnyOf() {
7412 var matchers = [];
7413 for (var _i = 0; _i < arguments.length; _i++) {
7414 matchers[_i] = arguments[_i];
7415 }
7416 return function (action) {
7417 return matchers.some(function (matcher) { return matches(matcher, action); });
7418 };
7419 }
7420 function isAllOf() {
7421 var matchers = [];
7422 for (var _i = 0; _i < arguments.length; _i++) {
7423 matchers[_i] = arguments[_i];
7424 }
7425 return function (action) {
7426 return matchers.every(function (matcher) { return matches(matcher, action); });
7427 };
7428 }
7429 function hasExpectedRequestMetadata(action, validStatus) {
7430 if (!action || !action.meta)
7431 return false;
7432 var hasValidRequestId = typeof action.meta.requestId === "string";
7433 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
7434 return hasValidRequestId && hasValidRequestStatus;
7435 }
7436 function isAsyncThunkArray(a) {
7437 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
7438 }
7439 function isPending() {
7440 var asyncThunks = [];
7441 for (var _i = 0; _i < arguments.length; _i++) {
7442 asyncThunks[_i] = arguments[_i];
7443 }
7444 if (asyncThunks.length === 0) {
7445 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
7446 }
7447 if (!isAsyncThunkArray(asyncThunks)) {
7448 return isPending()(asyncThunks[0]);
7449 }
7450 return function (action) {
7451 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
7452 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7453 return combinedMatcher(action);
7454 };
7455 }
7456 function isRejected() {
7457 var asyncThunks = [];
7458 for (var _i = 0; _i < arguments.length; _i++) {
7459 asyncThunks[_i] = arguments[_i];
7460 }
7461 if (asyncThunks.length === 0) {
7462 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
7463 }
7464 if (!isAsyncThunkArray(asyncThunks)) {
7465 return isRejected()(asyncThunks[0]);
7466 }
7467 return function (action) {
7468 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
7469 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7470 return combinedMatcher(action);
7471 };
7472 }
7473 function isRejectedWithValue() {
7474 var asyncThunks = [];
7475 for (var _i = 0; _i < arguments.length; _i++) {
7476 asyncThunks[_i] = arguments[_i];
7477 }
7478 var hasFlag = function (action) {
7479 return action && action.meta && action.meta.rejectedWithValue;
7480 };
7481 if (asyncThunks.length === 0) {
7482 return function (action) {
7483 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7484 return combinedMatcher(action);
7485 };
7486 }
7487 if (!isAsyncThunkArray(asyncThunks)) {
7488 return isRejectedWithValue()(asyncThunks[0]);
7489 }
7490 return function (action) {
7491 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
7492 return combinedMatcher(action);
7493 };
7494 }
7495 function isFulfilled() {
7496 var asyncThunks = [];
7497 for (var _i = 0; _i < arguments.length; _i++) {
7498 asyncThunks[_i] = arguments[_i];
7499 }
7500 if (asyncThunks.length === 0) {
7501 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
7502 }
7503 if (!isAsyncThunkArray(asyncThunks)) {
7504 return isFulfilled()(asyncThunks[0]);
7505 }
7506 return function (action) {
7507 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
7508 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7509 return combinedMatcher(action);
7510 };
7511 }
7512 function isAsyncThunkAction() {
7513 var asyncThunks = [];
7514 for (var _i = 0; _i < arguments.length; _i++) {
7515 asyncThunks[_i] = arguments[_i];
7516 }
7517 if (asyncThunks.length === 0) {
7518 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
7519 }
7520 if (!isAsyncThunkArray(asyncThunks)) {
7521 return isAsyncThunkAction()(asyncThunks[0]);
7522 }
7523 return function (action) {
7524 var matchers = [];
7525 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
7526 var asyncThunk = asyncThunks_1[_i];
7527 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
7528 }
7529 var combinedMatcher = isAnyOf.apply(void 0, matchers);
7530 return combinedMatcher(action);
7531 };
7532 }
7533 // src/listenerMiddleware/utils.ts
7534 var assertFunction = function (func, expected) {
7535 if (typeof func !== "function") {
7536 throw new TypeError(expected + " is not a function");
7537 }
7538 };
7539 var noop = function () {
7540 };
7541 var catchRejection = function (promise2, onError) {
7542 if (onError === void 0) { onError = noop; }
7543 promise2.catch(onError);
7544 return promise2;
7545 };
7546 var addAbortSignalListener = function (abortSignal, callback) {
7547 abortSignal.addEventListener("abort", callback, { once: true });
7548 return function () { return abortSignal.removeEventListener("abort", callback); };
7549 };
7550 var abortControllerWithReason = function (abortController, reason) {
7551 var signal = abortController.signal;
7552 if (signal.aborted) {
7553 return;
7554 }
7555 if (!("reason" in signal)) {
7556 Object.defineProperty(signal, "reason", {
7557 enumerable: true,
7558 value: reason,
7559 configurable: true,
7560 writable: true
7561 });
7562 }
7563 ;
7564 abortController.abort(reason);
7565 };
7566 // src/listenerMiddleware/exceptions.ts
7567 var task = "task";
7568 var listener = "listener";
7569 var completed = "completed";
7570 var cancelled = "cancelled";
7571 var taskCancelled = "task-" + cancelled;
7572 var taskCompleted = "task-" + completed;
7573 var listenerCancelled = listener + "-" + cancelled;
7574 var listenerCompleted = listener + "-" + completed;
7575 var TaskAbortError = /** @class */ (function () {
7576 function TaskAbortError(code) {
7577 this.code = code;
7578 this.name = "TaskAbortError";
7579 this.message = task + " " + cancelled + " (reason: " + code + ")";
7580 }
7581 return TaskAbortError;
7582 }());
7583 // src/listenerMiddleware/task.ts
7584 var validateActive = function (signal) {
7585 if (signal.aborted) {
7586 throw new TaskAbortError(signal.reason);
7587 }
7588 };
7589 function raceWithSignal(signal, promise2) {
7590 var cleanup = noop;
7591 return new Promise(function (resolve, reject) {
7592 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
7593 if (signal.aborted) {
7594 notifyRejection();
7595 return;
7596 }
7597 cleanup = addAbortSignalListener(signal, notifyRejection);
7598 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
7599 }).finally(function () {
7600 cleanup = noop;
7601 });
7602 }
7603 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
7604 var value, error_1;
7605 return __generator(this, function (_c) {
7606 switch (_c.label) {
7607 case 0:
7608 _c.trys.push([0, 3, 4, 5]);
7609 return [4 /*yield*/, Promise.resolve()];
7610 case 1:
7611 _c.sent();
7612 return [4 /*yield*/, task2()];
7613 case 2:
7614 value = _c.sent();
7615 return [2 /*return*/, {
7616 status: "ok",
7617 value: value
7618 }];
7619 case 3:
7620 error_1 = _c.sent();
7621 return [2 /*return*/, {
7622 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
7623 error: error_1
7624 }];
7625 case 4:
7626 cleanUp == null ? void 0 : cleanUp();
7627 return [7 /*endfinally*/];
7628 case 5: return [2 /*return*/];
7629 }
7630 });
7631 }); };
7632 var createPause = function (signal) {
7633 return function (promise2) {
7634 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
7635 validateActive(signal);
7636 return output;
7637 }));
7638 };
7639 };
7640 var createDelay = function (signal) {
7641 var pause = createPause(signal);
7642 return function (timeoutMs) {
7643 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
7644 };
7645 };
7646 // src/listenerMiddleware/index.ts
7647 var assign = Object.assign;
7648 var INTERNAL_NIL_TOKEN = {};
7649 var alm = "listenerMiddleware";
7650 var createFork = function (parentAbortSignal, parentBlockingPromises) {
7651 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
7652 return function (taskExecutor, opts) {
7653 assertFunction(taskExecutor, "taskExecutor");
7654 var childAbortController = new AbortController();
7655 linkControllers(childAbortController);
7656 var result = runTask(function () { return __async(void 0, null, function () {
7657 var result2;
7658 return __generator(this, function (_c) {
7659 switch (_c.label) {
7660 case 0:
7661 validateActive(parentAbortSignal);
7662 validateActive(childAbortController.signal);
7663 return [4 /*yield*/, taskExecutor({
7664 pause: createPause(childAbortController.signal),
7665 delay: createDelay(childAbortController.signal),
7666 signal: childAbortController.signal
7667 })];
7668 case 1:
7669 result2 = _c.sent();
7670 validateActive(childAbortController.signal);
7671 return [2 /*return*/, result2];
7672 }
7673 });
7674 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
7675 if (opts == null ? void 0 : opts.autoJoin) {
7676 parentBlockingPromises.push(result);
7677 }
7678 return {
7679 result: createPause(parentAbortSignal)(result),
7680 cancel: function () {
7681 abortControllerWithReason(childAbortController, taskCancelled);
7682 }
7683 };
7684 };
7685 };
7686 var createTakePattern = function (startListening, signal) {
7687 var take = function (predicate, timeout) { return __async(void 0, null, function () {
7688 var unsubscribe, tuplePromise, promises, output;
7689 return __generator(this, function (_c) {
7690 switch (_c.label) {
7691 case 0:
7692 validateActive(signal);
7693 unsubscribe = function () {
7694 };
7695 tuplePromise = new Promise(function (resolve, reject) {
7696 var stopListening = startListening({
7697 predicate: predicate,
7698 effect: function (action, listenerApi) {
7699 listenerApi.unsubscribe();
7700 resolve([
7701 action,
7702 listenerApi.getState(),
7703 listenerApi.getOriginalState()
7704 ]);
7705 }
7706 });
7707 unsubscribe = function () {
7708 stopListening();
7709 reject();
7710 };
7711 });
7712 promises = [
7713 tuplePromise
7714 ];
7715 if (timeout != null) {
7716 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
7717 }
7718 _c.label = 1;
7719 case 1:
7720 _c.trys.push([1, , 3, 4]);
7721 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
7722 case 2:
7723 output = _c.sent();
7724 validateActive(signal);
7725 return [2 /*return*/, output];
7726 case 3:
7727 unsubscribe();
7728 return [7 /*endfinally*/];
7729 case 4: return [2 /*return*/];
7730 }
7731 });
7732 }); };
7733 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
7734 };
7735 var getListenerEntryPropsFrom = function (options) {
7736 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
7737 if (type) {
7738 predicate = createAction(type).match;
7739 }
7740 else if (actionCreator) {
7741 type = actionCreator.type;
7742 predicate = actionCreator.match;
7743 }
7744 else if (matcher) {
7745 predicate = matcher;
7746 }
7747 else if (predicate) {
7748 }
7749 else {
7750 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
7751 }
7752 assertFunction(effect, "options.listener");
7753 return { predicate: predicate, type: type, effect: effect };
7754 };
7755 var createListenerEntry = function (options) {
7756 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
7757 var id = nanoid();
7758 var entry = {
7759 id: id,
7760 effect: effect,
7761 type: type,
7762 predicate: predicate,
7763 pending: new Set(),
7764 unsubscribe: function () {
7765 throw new Error("Unsubscribe not initialized");
7766 }
7767 };
7768 return entry;
7769 };
7770 var cancelActiveListeners = function (entry) {
7771 entry.pending.forEach(function (controller) {
7772 abortControllerWithReason(controller, listenerCancelled);
7773 });
7774 };
7775 var createClearListenerMiddleware = function (listenerMap) {
7776 return function () {
7777 listenerMap.forEach(cancelActiveListeners);
7778 listenerMap.clear();
7779 };
7780 };
7781 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
7782 try {
7783 errorHandler(errorToNotify, errorInfo);
7784 }
7785 catch (errorHandlerError) {
7786 setTimeout(function () {
7787 throw errorHandlerError;
7788 }, 0);
7789 }
7790 };
7791 var addListener = createAction(alm + "/add");
7792 var clearAllListeners = createAction(alm + "/removeAll");
7793 var removeListener = createAction(alm + "/remove");
7794 var defaultErrorHandler = function () {
7795 var args = [];
7796 for (var _i = 0; _i < arguments.length; _i++) {
7797 args[_i] = arguments[_i];
7798 }
7799 console.error.apply(console, __spreadArray([alm + "/error"], args));
7800 };
7801 function createListenerMiddleware(middlewareOptions) {
7802 var _this = this;
7803 if (middlewareOptions === void 0) { middlewareOptions = {}; }
7804 var listenerMap = new Map();
7805 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
7806 assertFunction(onError, "onError");
7807 var insertEntry = function (entry) {
7808 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
7809 listenerMap.set(entry.id, entry);
7810 return function (cancelOptions) {
7811 entry.unsubscribe();
7812 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
7813 cancelActiveListeners(entry);
7814 }
7815 };
7816 };
7817 var findListenerEntry = function (comparator) {
7818 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
7819 var entry = _c[_i];
7820 if (comparator(entry)) {
7821 return entry;
7822 }
7823 }
7824 return void 0;
7825 };
7826 var startListening = function (options) {
7827 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
7828 if (!entry) {
7829 entry = createListenerEntry(options);
7830 }
7831 return insertEntry(entry);
7832 };
7833 var stopListening = function (options) {
7834 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
7835 var entry = findListenerEntry(function (entry2) {
7836 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
7837 return matchPredicateOrType && entry2.effect === effect;
7838 });
7839 if (entry) {
7840 entry.unsubscribe();
7841 if (options.cancelActive) {
7842 cancelActiveListeners(entry);
7843 }
7844 }
7845 return !!entry;
7846 };
7847 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
7848 var internalTaskController, take, autoJoinPromises, listenerError_1;
7849 return __generator(this, function (_c) {
7850 switch (_c.label) {
7851 case 0:
7852 internalTaskController = new AbortController();
7853 take = createTakePattern(startListening, internalTaskController.signal);
7854 autoJoinPromises = [];
7855 _c.label = 1;
7856 case 1:
7857 _c.trys.push([1, 3, 4, 6]);
7858 entry.pending.add(internalTaskController);
7859 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
7860 getOriginalState: getOriginalState,
7861 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
7862 take: take,
7863 delay: createDelay(internalTaskController.signal),
7864 pause: createPause(internalTaskController.signal),
7865 extra: extra,
7866 signal: internalTaskController.signal,
7867 fork: createFork(internalTaskController.signal, autoJoinPromises),
7868 unsubscribe: entry.unsubscribe,
7869 subscribe: function () {
7870 listenerMap.set(entry.id, entry);
7871 },
7872 cancelActiveListeners: function () {
7873 entry.pending.forEach(function (controller, _, set) {
7874 if (controller !== internalTaskController) {
7875 abortControllerWithReason(controller, listenerCancelled);
7876 set.delete(controller);
7877 }
7878 });
7879 }
7880 })))];
7881 case 2:
7882 _c.sent();
7883 return [3 /*break*/, 6];
7884 case 3:
7885 listenerError_1 = _c.sent();
7886 if (!(listenerError_1 instanceof TaskAbortError)) {
7887 safelyNotifyError(onError, listenerError_1, {
7888 raisedBy: "effect"
7889 });
7890 }
7891 return [3 /*break*/, 6];
7892 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
7893 case 5:
7894 _c.sent();
7895 abortControllerWithReason(internalTaskController, listenerCompleted);
7896 entry.pending.delete(internalTaskController);
7897 return [7 /*endfinally*/];
7898 case 6: return [2 /*return*/];
7899 }
7900 });
7901 }); };
7902 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
7903 var middleware = function (api) { return function (next) { return function (action) {
7904 if (!isAction(action)) {
7905 return next(action);
7906 }
7907 if (addListener.match(action)) {
7908 return startListening(action.payload);
7909 }
7910 if (clearAllListeners.match(action)) {
7911 clearListenerMiddleware();
7912 return;
7913 }
7914 if (removeListener.match(action)) {
7915 return stopListening(action.payload);
7916 }
7917 var originalState = api.getState();
7918 var getOriginalState = function () {
7919 if (originalState === INTERNAL_NIL_TOKEN) {
7920 throw new Error(alm + ": getOriginalState can only be called synchronously");
7921 }
7922 return originalState;
7923 };
7924 var result;
7925 try {
7926 result = next(action);
7927 if (listenerMap.size > 0) {
7928 var currentState = api.getState();
7929 var listenerEntries = Array.from(listenerMap.values());
7930 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
7931 var entry = listenerEntries_1[_i];
7932 var runListener = false;
7933 try {
7934 runListener = entry.predicate(action, currentState, originalState);
7935 }
7936 catch (predicateError) {
7937 runListener = false;
7938 safelyNotifyError(onError, predicateError, {
7939 raisedBy: "predicate"
7940 });
7941 }
7942 if (!runListener) {
7943 continue;
7944 }
7945 notifyListener(entry, action, api, getOriginalState);
7946 }
7947 }
7948 }
7949 finally {
7950 originalState = INTERNAL_NIL_TOKEN;
7951 }
7952 return result;
7953 }; }; };
7954 return {
7955 middleware: middleware,
7956 startListening: startListening,
7957 stopListening: stopListening,
7958 clearListeners: clearListenerMiddleware
7959 };
7960 }
7961 // src/autoBatchEnhancer.ts
7962 var SHOULD_AUTOBATCH = "RTK_autoBatch";
7963 var prepareAutoBatched = function () { return function (payload) {
7964 var _c;
7965 return ({
7966 payload: payload,
7967 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
7968 });
7969 }; };
7970 var promise;
7971 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 () {
7972 throw err;
7973 }, 0); }); };
7974 var createQueueWithTimer = function (timeout) {
7975 return function (notify) {
7976 setTimeout(notify, timeout);
7977 };
7978 };
7979 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
7980 var autoBatchEnhancer = function (options) {
7981 if (options === void 0) { options = { type: "raf" }; }
7982 return function (next) { return function () {
7983 var args = [];
7984 for (var _i = 0; _i < arguments.length; _i++) {
7985 args[_i] = arguments[_i];
7986 }
7987 var store = next.apply(void 0, args);
7988 var notifying = true;
7989 var shouldNotifyAtEndOfTick = false;
7990 var notificationQueued = false;
7991 var listeners = new Set();
7992 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
7993 var notifyListeners = function () {
7994 notificationQueued = false;
7995 if (shouldNotifyAtEndOfTick) {
7996 shouldNotifyAtEndOfTick = false;
7997 listeners.forEach(function (l) { return l(); });
7998 }
7999 };
8000 return Object.assign({}, store, {
8001 subscribe: function (listener2) {
8002 var wrappedListener = function () { return notifying && listener2(); };
8003 var unsubscribe = store.subscribe(wrappedListener);
8004 listeners.add(listener2);
8005 return function () {
8006 unsubscribe();
8007 listeners.delete(listener2);
8008 };
8009 },
8010 dispatch: function (action) {
8011 var _a;
8012 try {
8013 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8014 shouldNotifyAtEndOfTick = !notifying;
8015 if (shouldNotifyAtEndOfTick) {
8016 if (!notificationQueued) {
8017 notificationQueued = true;
8018 queueCallback(notifyListeners);
8019 }
8020 }
8021 return store.dispatch(action);
8022 }
8023 finally {
8024 notifying = true;
8025 }
8026 }
8027 });
8028 }; };
8029 };
8030 // src/index.ts
8031 (0,immer__WEBPACK_IMPORTED_MODULE_2__.enableES5)();
8032
8033 //# sourceMappingURL=redux-toolkit.esm.js.map
8034
8035 /***/ }),
8036
8037 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8038 /*!************************************************!*\
8039 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8040 \************************************************/
8041 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8042
8043 "use strict";
8044 __webpack_require__.r(__webpack_exports__);
8045 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8046 /* harmony export */ Immer: () => (/* binding */ un),
8047 /* harmony export */ applyPatches: () => (/* binding */ pn),
8048 /* harmony export */ castDraft: () => (/* binding */ K),
8049 /* harmony export */ castImmutable: () => (/* binding */ $),
8050 /* harmony export */ createDraft: () => (/* binding */ ln),
8051 /* harmony export */ current: () => (/* binding */ R),
8052 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8053 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8054 /* harmony export */ enableES5: () => (/* binding */ F),
8055 /* harmony export */ enableMapSet: () => (/* binding */ C),
8056 /* harmony export */ enablePatches: () => (/* binding */ T),
8057 /* harmony export */ finishDraft: () => (/* binding */ dn),
8058 /* harmony export */ freeze: () => (/* binding */ d),
8059 /* harmony export */ immerable: () => (/* binding */ L),
8060 /* harmony export */ isDraft: () => (/* binding */ r),
8061 /* harmony export */ isDraftable: () => (/* binding */ t),
8062 /* harmony export */ nothing: () => (/* binding */ H),
8063 /* harmony export */ original: () => (/* binding */ e),
8064 /* harmony export */ produce: () => (/* binding */ fn),
8065 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8066 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8067 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8068 /* harmony export */ });
8069 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
8070 {}}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);
8071 //# sourceMappingURL=immer.esm.js.map
8072
8073
8074 /***/ }),
8075
8076 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8077 /*!****************************************************************!*\
8078 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8079 \****************************************************************/
8080 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8081
8082 "use strict";
8083 __webpack_require__.r(__webpack_exports__);
8084 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8085 /* harmony export */ "default": () => (/* binding */ mixpanel)
8086 /* harmony export */ });
8087 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8088 var win;
8089 if (typeof(window) === 'undefined') {
8090 var loc = {
8091 hostname: ''
8092 };
8093 win = {
8094 crypto: {randomUUID: function() {throw Error('unsupported');}},
8095 navigator: { userAgent: '', onLine: true },
8096 document: {
8097 createElement: function() { return {}; },
8098 location: loc,
8099 referrer: ''
8100 },
8101 screen: { width: 0, height: 0 },
8102 location: loc,
8103 addEventListener: function() {},
8104 removeEventListener: function() {}
8105 };
8106 } else {
8107 win = window;
8108 }
8109
8110 function _array_like_to_array(arr, len) {
8111 if (len == null || len > arr.length) len = arr.length;
8112 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8113 return arr2;
8114 }
8115 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8116 try {
8117 var info = gen[key](arg);
8118 var value = info.value;
8119 } catch (error) {
8120 reject(error);
8121 return;
8122 }
8123 if (info.done) {
8124 resolve(value);
8125 } else {
8126 Promise.resolve(value).then(_next, _throw);
8127 }
8128 }
8129 function _async_to_generator(fn) {
8130 return function() {
8131 var self = this, args = arguments;
8132 return new Promise(function(resolve, reject) {
8133 var gen = fn.apply(self, args);
8134 function _next(value) {
8135 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8136 }
8137 function _throw(err) {
8138 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8139 }
8140 _next(undefined);
8141 });
8142 };
8143 }
8144 function _construct(Parent, args, Class) {
8145 if (_is_native_reflect_construct()) {
8146 _construct = Reflect.construct;
8147 } else {
8148 _construct = function construct(Parent, args, Class) {
8149 var a = [
8150 null
8151 ];
8152 a.push.apply(a, args);
8153 var Constructor = Function.bind.apply(Parent, a);
8154 var instance = new Constructor();
8155 if (Class) _set_prototype_of(instance, Class.prototype);
8156 return instance;
8157 };
8158 }
8159 return _construct.apply(null, arguments);
8160 }
8161 function _defineProperties(target, props) {
8162 for(var i = 0; i < props.length; i++){
8163 var descriptor = props[i];
8164 descriptor.enumerable = descriptor.enumerable || false;
8165 descriptor.configurable = true;
8166 if ("value" in descriptor) descriptor.writable = true;
8167 Object.defineProperty(target, descriptor.key, descriptor);
8168 }
8169 }
8170 function _create_class(Constructor, protoProps, staticProps) {
8171 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8172 return Constructor;
8173 }
8174 function _extends() {
8175 _extends = Object.assign || function(target) {
8176 for(var i = 1; i < arguments.length; i++){
8177 var source = arguments[i];
8178 for(var key in source){
8179 if (Object.prototype.hasOwnProperty.call(source, key)) {
8180 target[key] = source[key];
8181 }
8182 }
8183 }
8184 return target;
8185 };
8186 return _extends.apply(this, arguments);
8187 }
8188 function _get_prototype_of(o) {
8189 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8190 return o.__proto__ || Object.getPrototypeOf(o);
8191 };
8192 return _get_prototype_of(o);
8193 }
8194 function _inherits(subClass, superClass) {
8195 if (typeof superClass !== "function" && superClass !== null) {
8196 throw new TypeError("Super expression must either be null or a function");
8197 }
8198 subClass.prototype = Object.create(superClass && superClass.prototype, {
8199 constructor: {
8200 value: subClass,
8201 writable: true,
8202 configurable: true
8203 }
8204 });
8205 if (superClass) _set_prototype_of(subClass, superClass);
8206 }
8207 function _instanceof(left, right) {
8208 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8209 return !!right[Symbol.hasInstance](left);
8210 } else {
8211 return left instanceof right;
8212 }
8213 }
8214 function _is_native_function(fn) {
8215 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8216 }
8217 function _object_without_properties_loose(source, excluded) {
8218 if (source == null) return {};
8219 var target = {};
8220 var sourceKeys = Object.keys(source);
8221 var key, i;
8222 for(i = 0; i < sourceKeys.length; i++){
8223 key = sourceKeys[i];
8224 if (excluded.indexOf(key) >= 0) continue;
8225 target[key] = source[key];
8226 }
8227 return target;
8228 }
8229 function _set_prototype_of(o, p) {
8230 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8231 o.__proto__ = p;
8232 return o;
8233 };
8234 return _set_prototype_of(o, p);
8235 }
8236 function _type_of(obj) {
8237 "@swc/helpers - typeof";
8238 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8239 }
8240 function _unsupported_iterable_to_array(o, minLen) {
8241 if (!o) return;
8242 if (typeof o === "string") return _array_like_to_array(o, minLen);
8243 var n = Object.prototype.toString.call(o).slice(8, -1);
8244 if (n === "Object" && o.constructor) n = o.constructor.name;
8245 if (n === "Map" || n === "Set") return Array.from(n);
8246 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
8247 }
8248 function _wrap_native_super(Class) {
8249 var _cache = typeof Map === "function" ? new Map() : undefined;
8250 _wrap_native_super = function wrapNativeSuper(Class) {
8251 if (Class === null || !_is_native_function(Class)) return Class;
8252 if (typeof Class !== "function") {
8253 throw new TypeError("Super expression must either be null or a function");
8254 }
8255 if (typeof _cache !== "undefined") {
8256 if (_cache.has(Class)) return _cache.get(Class);
8257 _cache.set(Class, Wrapper);
8258 }
8259 function Wrapper() {
8260 return _construct(Class, arguments, _get_prototype_of(this).constructor);
8261 }
8262 Wrapper.prototype = Object.create(Class.prototype, {
8263 constructor: {
8264 value: Wrapper,
8265 enumerable: false,
8266 writable: true,
8267 configurable: true
8268 }
8269 });
8270 return _set_prototype_of(Wrapper, Class);
8271 };
8272 return _wrap_native_super(Class);
8273 }
8274 function _is_native_reflect_construct() {
8275 try {
8276 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
8277 } catch (_) {}
8278 return (_is_native_reflect_construct = function() {
8279 return !!result;
8280 })();
8281 }
8282 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
8283 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
8284 if (it) return (it = it.call(o)).next.bind(it);
8285 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
8286 if (it) o = it;
8287 var i = 0;
8288 return function() {
8289 if (i >= o.length) {
8290 return {
8291 done: true
8292 };
8293 }
8294 return {
8295 done: false,
8296 value: o[i++]
8297 };
8298 };
8299 }
8300 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8301 }
8302 function _ts_generator(thisArg, body) {
8303 var f, y, t, g, _ = {
8304 label: 0,
8305 sent: function() {
8306 if (t[0] & 1) throw t[1];
8307 return t[1];
8308 },
8309 trys: [],
8310 ops: []
8311 };
8312 return g = {
8313 next: verb(0),
8314 "throw": verb(1),
8315 "return": verb(2)
8316 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
8317 return this;
8318 }), g;
8319 function verb(n) {
8320 return function(v) {
8321 return step([
8322 n,
8323 v
8324 ]);
8325 };
8326 }
8327 function step(op) {
8328 if (f) throw new TypeError("Generator is already executing.");
8329 while(_)try {
8330 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;
8331 if (y = 0, t) op = [
8332 op[0] & 2,
8333 t.value
8334 ];
8335 switch(op[0]){
8336 case 0:
8337 case 1:
8338 t = op;
8339 break;
8340 case 4:
8341 _.label++;
8342 return {
8343 value: op[1],
8344 done: false
8345 };
8346 case 5:
8347 _.label++;
8348 y = op[1];
8349 op = [
8350 0
8351 ];
8352 continue;
8353 case 7:
8354 op = _.ops.pop();
8355 _.trys.pop();
8356 continue;
8357 default:
8358 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
8359 _ = 0;
8360 continue;
8361 }
8362 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
8363 _.label = op[1];
8364 break;
8365 }
8366 if (op[0] === 6 && _.label < t[1]) {
8367 _.label = t[1];
8368 t = op;
8369 break;
8370 }
8371 if (t && _.label < t[2]) {
8372 _.label = t[2];
8373 _.ops.push(op);
8374 break;
8375 }
8376 if (t[2]) _.ops.pop();
8377 _.trys.pop();
8378 continue;
8379 }
8380 op = body.call(thisArg, _);
8381 } catch (e) {
8382 op = [
8383 6,
8384 e
8385 ];
8386 y = 0;
8387 } finally{
8388 f = t = 0;
8389 }
8390 if (op[0] & 5) throw op[1];
8391 return {
8392 value: op[0] ? op[1] : void 0,
8393 done: true
8394 };
8395 }
8396 }
8397 function _ts_values(o) {
8398 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
8399 if (m) return m.call(o);
8400 if (o && typeof o.length === "number") return {
8401 next: function() {
8402 if (o && i >= o.length) o = void 0;
8403 return {
8404 value: o && o[i++],
8405 done: !o
8406 };
8407 }
8408 };
8409 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
8410 }
8411 var __defProp = Object.defineProperty;
8412 var __defNormalProp = function(obj, key, value) {
8413 return key in obj ? __defProp(obj, key, {
8414 enumerable: true,
8415 configurable: true,
8416 writable: true,
8417 value: value
8418 }) : obj[key] = value;
8419 };
8420 var __publicField = function(obj, key, value) {
8421 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8422 };
8423 var _a;
8424 var __defProp$1 = Object.defineProperty;
8425 var __defNormalProp$1 = function(obj, key, value) {
8426 return key in obj ? __defProp$1(obj, key, {
8427 enumerable: true,
8428 configurable: true,
8429 writable: true,
8430 value: value
8431 }) : obj[key] = value;
8432 };
8433 var __publicField$1 = function(obj, key, value) {
8434 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
8435 };
8436 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
8437 NodeType2[NodeType2["Document"] = 0] = "Document";
8438 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
8439 NodeType2[NodeType2["Element"] = 2] = "Element";
8440 NodeType2[NodeType2["Text"] = 3] = "Text";
8441 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
8442 NodeType2[NodeType2["Comment"] = 5] = "Comment";
8443 return NodeType2;
8444 }(NodeType$3 || {});
8445 var testableAccessors$1 = {
8446 Node: [
8447 "childNodes",
8448 "parentNode",
8449 "parentElement",
8450 "textContent"
8451 ],
8452 ShadowRoot: [
8453 "host",
8454 "styleSheets"
8455 ],
8456 Element: [
8457 "shadowRoot",
8458 "querySelector",
8459 "querySelectorAll"
8460 ],
8461 MutationObserver: []
8462 };
8463 var testableMethods$1 = {
8464 Node: [
8465 "contains",
8466 "getRootNode"
8467 ],
8468 ShadowRoot: [
8469 "getSelection"
8470 ],
8471 Element: [],
8472 MutationObserver: [
8473 "constructor"
8474 ]
8475 };
8476 var untaintedBasePrototype$1 = {};
8477 var isAngularZonePresent$1 = function() {
8478 return !!globalThis.Zone;
8479 };
8480 function getUntaintedPrototype$1(key) {
8481 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
8482 var defaultObj = globalThis[key];
8483 var defaultPrototype = defaultObj.prototype;
8484 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
8485 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
8486 accessorNames.every(function(accessor) {
8487 var _a2, _b;
8488 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
8489 }));
8490 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
8491 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
8492 function(method) {
8493 var _a2;
8494 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
8495 }));
8496 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
8497 untaintedBasePrototype$1[key] = defaultObj.prototype;
8498 return defaultObj.prototype;
8499 }
8500 try {
8501 var iframeEl = document.createElement("iframe");
8502 document.body.appendChild(iframeEl);
8503 var win = iframeEl.contentWindow;
8504 if (!win) return defaultObj.prototype;
8505 var untaintedObject = win[key].prototype;
8506 document.body.removeChild(iframeEl);
8507 if (!untaintedObject) return defaultPrototype;
8508 return untaintedBasePrototype$1[key] = untaintedObject;
8509 } catch (e) {
8510 return defaultPrototype;
8511 }
8512 }
8513 var untaintedAccessorCache$1 = {};
8514 function getUntaintedAccessor$1(key, instance, accessor) {
8515 var _a2;
8516 var cacheKey = key + "." + String(accessor);
8517 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
8518 var untaintedPrototype = getUntaintedPrototype$1(key);
8519 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
8520 if (!untaintedAccessor) return instance[accessor];
8521 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
8522 return untaintedAccessor.call(instance);
8523 }
8524 var untaintedMethodCache$1 = {};
8525 function getUntaintedMethod$1(key, instance, method) {
8526 var cacheKey = key + "." + String(method);
8527 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
8528 var untaintedPrototype = getUntaintedPrototype$1(key);
8529 var untaintedMethod = untaintedPrototype[method];
8530 if (typeof untaintedMethod !== "function") return instance[method];
8531 untaintedMethodCache$1[cacheKey] = untaintedMethod;
8532 return untaintedMethod.bind(instance);
8533 }
8534 function childNodes$1(n2) {
8535 return getUntaintedAccessor$1("Node", n2, "childNodes");
8536 }
8537 function parentNode$1(n2) {
8538 return getUntaintedAccessor$1("Node", n2, "parentNode");
8539 }
8540 function parentElement$1(n2) {
8541 return getUntaintedAccessor$1("Node", n2, "parentElement");
8542 }
8543 function textContent$1(n2) {
8544 return getUntaintedAccessor$1("Node", n2, "textContent");
8545 }
8546 function contains$1(n2, other) {
8547 return getUntaintedMethod$1("Node", n2, "contains")(other);
8548 }
8549 function getRootNode$1(n2) {
8550 return getUntaintedMethod$1("Node", n2, "getRootNode")();
8551 }
8552 function host$1(n2) {
8553 if (!n2 || !("host" in n2)) return null;
8554 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
8555 }
8556 function styleSheets$1(n2) {
8557 return n2.styleSheets;
8558 }
8559 function shadowRoot$1(n2) {
8560 if (!n2 || !("shadowRoot" in n2)) return null;
8561 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
8562 }
8563 function querySelector$1(n2, selectors) {
8564 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
8565 }
8566 function querySelectorAll$1(n2, selectors) {
8567 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
8568 }
8569 function mutationObserverCtor$1() {
8570 return getUntaintedPrototype$1("MutationObserver").constructor;
8571 }
8572 var index$1 = {
8573 childNodes: childNodes$1,
8574 parentNode: parentNode$1,
8575 parentElement: parentElement$1,
8576 textContent: textContent$1,
8577 contains: contains$1,
8578 getRootNode: getRootNode$1,
8579 host: host$1,
8580 styleSheets: styleSheets$1,
8581 shadowRoot: shadowRoot$1,
8582 querySelector: querySelector$1,
8583 querySelectorAll: querySelectorAll$1,
8584 mutationObserver: mutationObserverCtor$1
8585 };
8586 function isElement(n2) {
8587 return n2.nodeType === n2.ELEMENT_NODE;
8588 }
8589 function isShadowRoot(n2) {
8590 var hostEl = // anchor and textarea elements also have a `host` property
8591 // but only shadow roots have a `mode` property
8592 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
8593 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
8594 }
8595 function isNativeShadowDom(shadowRoot2) {
8596 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
8597 }
8598 function fixBrowserCompatibilityIssuesInCSS(cssText) {
8599 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
8600 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
8601 }
8602 return cssText;
8603 }
8604 function escapeImportStatement(rule2) {
8605 var cssText = rule2.cssText;
8606 if (cssText.split('"').length < 3) return cssText;
8607 var statement = [
8608 "@import",
8609 "url(" + JSON.stringify(rule2.href) + ")"
8610 ];
8611 if (rule2.layerName === "") {
8612 statement.push("layer");
8613 } else if (rule2.layerName) {
8614 statement.push("layer(" + rule2.layerName + ")");
8615 }
8616 if (rule2.supportsText) {
8617 statement.push("supports(" + rule2.supportsText + ")");
8618 }
8619 if (rule2.media.length) {
8620 statement.push(rule2.media.mediaText);
8621 }
8622 return statement.join(" ") + ";";
8623 }
8624 function stringifyStylesheet(s2) {
8625 try {
8626 var rules2 = s2.rules || s2.cssRules;
8627 if (!rules2) {
8628 return null;
8629 }
8630 var sheetHref = s2.href;
8631 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
8632 sheetHref = s2.ownerNode.ownerDocument.location.href;
8633 }
8634 var stringifiedRules = Array.from(rules2, function(rule2) {
8635 return stringifyRule(rule2, sheetHref);
8636 }).join("");
8637 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
8638 } catch (error) {
8639 return null;
8640 }
8641 }
8642 function stringifyRule(rule2, sheetHref) {
8643 if (isCSSImportRule(rule2)) {
8644 var importStringified;
8645 try {
8646 importStringified = // we can access the imported stylesheet rules directly
8647 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
8648 escapeImportStatement(rule2);
8649 } catch (error) {
8650 importStringified = rule2.cssText;
8651 }
8652 if (rule2.styleSheet.href) {
8653 return absolutifyURLs(importStringified, rule2.styleSheet.href);
8654 }
8655 return importStringified;
8656 } else {
8657 var ruleStringified = rule2.cssText;
8658 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
8659 ruleStringified = fixSafariColons(ruleStringified);
8660 }
8661 if (sheetHref) {
8662 return absolutifyURLs(ruleStringified, sheetHref);
8663 }
8664 return ruleStringified;
8665 }
8666 }
8667 function fixSafariColons(cssStringified) {
8668 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
8669 return cssStringified.replace(regex, "$1\\$2");
8670 }
8671 function isCSSImportRule(rule2) {
8672 return "styleSheet" in rule2;
8673 }
8674 function isCSSStyleRule(rule2) {
8675 return "selectorText" in rule2;
8676 }
8677 var Mirror = /*#__PURE__*/ function() {
8678 function Mirror() {
8679 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
8680 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
8681 }
8682 var _proto = Mirror.prototype;
8683 _proto.getId = function getId(n2) {
8684 var _a2;
8685 if (!n2) return -1;
8686 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
8687 return id != null ? id : -1;
8688 };
8689 _proto.getNode = function getNode(id) {
8690 return this.idNodeMap.get(id) || null;
8691 };
8692 _proto.getIds = function getIds() {
8693 return Array.from(this.idNodeMap.keys());
8694 };
8695 _proto.getMeta = function getMeta(n2) {
8696 return this.nodeMetaMap.get(n2) || null;
8697 };
8698 // removes the node from idNodeMap
8699 // doesn't remove the node from nodeMetaMap
8700 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
8701 var _this = this;
8702 var id = this.getId(n2);
8703 this.idNodeMap.delete(id);
8704 if (n2.childNodes) {
8705 n2.childNodes.forEach(function(childNode) {
8706 return _this.removeNodeFromMap(childNode);
8707 });
8708 }
8709 };
8710 _proto.has = function has(id) {
8711 return this.idNodeMap.has(id);
8712 };
8713 _proto.hasNode = function hasNode(node2) {
8714 return this.nodeMetaMap.has(node2);
8715 };
8716 _proto.add = function add(n2, meta) {
8717 var id = meta.id;
8718 this.idNodeMap.set(id, n2);
8719 this.nodeMetaMap.set(n2, meta);
8720 };
8721 _proto.replace = function replace(id, n2) {
8722 var oldNode = this.getNode(id);
8723 if (oldNode) {
8724 var meta = this.nodeMetaMap.get(oldNode);
8725 if (meta) this.nodeMetaMap.set(n2, meta);
8726 }
8727 this.idNodeMap.set(id, n2);
8728 };
8729 _proto.reset = function reset() {
8730 this.idNodeMap = /* @__PURE__ */ new Map();
8731 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
8732 };
8733 return Mirror;
8734 }();
8735 function createMirror$2() {
8736 return new Mirror();
8737 }
8738 function maskInputValue(param) {
8739 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
8740 var text = value || "";
8741 var actualType = type && toLowerCase(type);
8742 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
8743 if (maskInputFn) {
8744 text = maskInputFn(text, element);
8745 } else {
8746 text = "*".repeat(text.length);
8747 }
8748 }
8749 return text;
8750 }
8751 function toLowerCase(str) {
8752 return str.toLowerCase();
8753 }
8754 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
8755 function is2DCanvasBlank(canvas) {
8756 var ctx = canvas.getContext("2d");
8757 if (!ctx) return true;
8758 var chunkSize = 50;
8759 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
8760 for(var y = 0; y < canvas.height; y += chunkSize){
8761 var getImageData = ctx.getImageData;
8762 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
8763 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
8764 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
8765 if (pixelBuffer.some(function(pixel) {
8766 return pixel !== 0;
8767 })) return false;
8768 }
8769 }
8770 return true;
8771 }
8772 function getInputType(element) {
8773 var type = element.type;
8774 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
8775 toLowerCase(type) : null;
8776 }
8777 function extractFileExtension(path, baseURL) {
8778 var url;
8779 try {
8780 url = new URL(path, baseURL != null ? baseURL : window.location.href);
8781 } catch (err) {
8782 return null;
8783 }
8784 var regex = /\.([0-9a-z]+)(?:$)/i;
8785 var match = url.pathname.match(regex);
8786 var _ref;
8787 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
8788 }
8789 function extractOrigin(url) {
8790 var origin = "";
8791 if (url.indexOf("//") > -1) {
8792 origin = url.split("/").slice(0, 3).join("/");
8793 } else {
8794 origin = url.split("/")[0];
8795 }
8796 origin = origin.split("?")[0];
8797 return origin;
8798 }
8799 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
8800 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
8801 var URL_WWW_MATCH = /^www\..*/i;
8802 var DATA_URI = /^(data:)([^,]*),(.*)/i;
8803 function absolutifyURLs(cssText, href) {
8804 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
8805 var filePath = path1 || path2 || path3;
8806 var maybeQuote = quote1 || quote2 || "";
8807 if (!filePath) {
8808 return origin;
8809 }
8810 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
8811 return "url(" + maybeQuote + filePath + maybeQuote + ")";
8812 }
8813 if (DATA_URI.test(filePath)) {
8814 return "url(" + maybeQuote + filePath + maybeQuote + ")";
8815 }
8816 if (filePath[0] === "/") {
8817 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
8818 }
8819 var stack = href.split("/");
8820 var parts = filePath.split("/");
8821 stack.pop();
8822 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
8823 var part = _step.value;
8824 if (part === ".") {
8825 continue;
8826 } else if (part === "..") {
8827 stack.pop();
8828 } else {
8829 stack.push(part);
8830 }
8831 }
8832 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
8833 });
8834 }
8835 function normalizeCssString(cssText) {
8836 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
8837 }
8838 function splitCssText(cssText, style) {
8839 var childNodes2 = Array.from(style.childNodes);
8840 var splits = [];
8841 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
8842 var cssTextNorm = normalizeCssString(cssText);
8843 for(var i2 = 1; i2 < childNodes2.length; i2++){
8844 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
8845 var textContentNorm = normalizeCssString(childNodes2[i2].textContent);
8846 for(var j = 3; j < textContentNorm.length; j++){
8847 var bit = textContentNorm.substring(0, j);
8848 if (cssTextNorm.split(bit).length === 2) {
8849 var splitNorm = cssTextNorm.indexOf(bit);
8850 for(var k = splitNorm; k < cssText.length; k++){
8851 if (normalizeCssString(cssText.substring(0, k)).length === splitNorm) {
8852 splits.push(cssText.substring(0, k));
8853 cssText = cssText.substring(k);
8854 break;
8855 }
8856 }
8857 break;
8858 }
8859 }
8860 }
8861 }
8862 }
8863 splits.push(cssText);
8864 return splits;
8865 }
8866 function markCssSplits(cssText, style) {
8867 return splitCssText(cssText, style).join("/* rr_split */");
8868 }
8869 var _id = 1;
8870 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
8871 var IGNORED_NODE = -2;
8872 function genId() {
8873 return _id++;
8874 }
8875 function getValidTagName$1(element) {
8876 if (_instanceof(element, HTMLFormElement)) {
8877 return "form";
8878 }
8879 var processedTagName = toLowerCase(element.tagName);
8880 if (tagNameRegex.test(processedTagName)) {
8881 return "div";
8882 }
8883 return processedTagName;
8884 }
8885 var canvasService;
8886 var canvasCtx;
8887 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
8888 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
8889 function getAbsoluteSrcsetString(doc, attributeValue) {
8890 if (attributeValue.trim() === "") {
8891 return attributeValue;
8892 }
8893 var pos = 0;
8894 function collectCharacters(regEx) {
8895 var chars2;
8896 var match = regEx.exec(attributeValue.substring(pos));
8897 if (match) {
8898 chars2 = match[0];
8899 pos += chars2.length;
8900 return chars2;
8901 }
8902 return "";
8903 }
8904 var output = [];
8905 while(true){
8906 collectCharacters(SRCSET_COMMAS_OR_SPACES);
8907 if (pos >= attributeValue.length) {
8908 break;
8909 }
8910 var url = collectCharacters(SRCSET_NOT_SPACES);
8911 if (url.slice(-1) === ",") {
8912 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
8913 output.push(url);
8914 } else {
8915 var descriptorsStr = "";
8916 url = absoluteToDoc(doc, url);
8917 var inParens = false;
8918 while(true){
8919 var c2 = attributeValue.charAt(pos);
8920 if (c2 === "") {
8921 output.push((url + descriptorsStr).trim());
8922 break;
8923 } else if (!inParens) {
8924 if (c2 === ",") {
8925 pos += 1;
8926 output.push((url + descriptorsStr).trim());
8927 break;
8928 } else if (c2 === "(") {
8929 inParens = true;
8930 }
8931 } else {
8932 if (c2 === ")") {
8933 inParens = false;
8934 }
8935 }
8936 descriptorsStr += c2;
8937 pos += 1;
8938 }
8939 }
8940 }
8941 return output.join(", ");
8942 }
8943 var cachedDocument = /* @__PURE__ */ new WeakMap();
8944 function absoluteToDoc(doc, attributeValue) {
8945 if (!attributeValue || attributeValue.trim() === "") {
8946 return attributeValue;
8947 }
8948 return getHref(doc, attributeValue);
8949 }
8950 function isSVGElement(el) {
8951 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
8952 }
8953 function getHref(doc, customHref) {
8954 var a2 = cachedDocument.get(doc);
8955 if (!a2) {
8956 a2 = doc.createElement("a");
8957 cachedDocument.set(doc, a2);
8958 }
8959 if (!customHref) {
8960 customHref = "";
8961 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
8962 return customHref;
8963 }
8964 a2.setAttribute("href", customHref);
8965 return a2.href;
8966 }
8967 function transformAttribute(doc, tagName, name, value) {
8968 if (!value) {
8969 return value;
8970 }
8971 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
8972 return absoluteToDoc(doc, value);
8973 } else if (name === "xlink:href" && value[0] !== "#") {
8974 return absoluteToDoc(doc, value);
8975 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
8976 return absoluteToDoc(doc, value);
8977 } else if (name === "srcset") {
8978 return getAbsoluteSrcsetString(doc, value);
8979 } else if (name === "style") {
8980 return absolutifyURLs(value, getHref(doc));
8981 } else if (tagName === "object" && name === "data") {
8982 return absoluteToDoc(doc, value);
8983 }
8984 return value;
8985 }
8986 function ignoreAttribute(tagName, name, _value) {
8987 return (tagName === "video" || tagName === "audio") && name === "autoplay";
8988 }
8989 function _isBlockedElement(element, blockClass, blockSelector) {
8990 try {
8991 if (typeof blockClass === "string") {
8992 if (element.classList.contains(blockClass)) {
8993 return true;
8994 }
8995 } else {
8996 for(var eIndex = element.classList.length; eIndex--;){
8997 var className = element.classList[eIndex];
8998 if (blockClass.test(className)) {
8999 return true;
9000 }
9001 }
9002 }
9003 if (blockSelector) {
9004 return element.matches(blockSelector);
9005 }
9006 } catch (e2) {}
9007 return false;
9008 }
9009 function classMatchesRegex(node2, regex, checkAncestors) {
9010 if (!node2) return false;
9011 if (node2.nodeType !== node2.ELEMENT_NODE) {
9012 if (!checkAncestors) return false;
9013 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9014 }
9015 for(var eIndex = node2.classList.length; eIndex--;){
9016 var className = node2.classList[eIndex];
9017 if (regex.test(className)) {
9018 return true;
9019 }
9020 }
9021 if (!checkAncestors) return false;
9022 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9023 }
9024 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9025 var el;
9026 if (isElement(node2)) {
9027 el = node2;
9028 if (!index$1.childNodes(el).length) {
9029 return false;
9030 }
9031 } else if (index$1.parentElement(node2) === null) {
9032 return false;
9033 } else {
9034 el = index$1.parentElement(node2);
9035 }
9036 try {
9037 if (typeof maskTextClass === "string") {
9038 if (checkAncestors) {
9039 if (el.closest("." + maskTextClass)) return true;
9040 } else {
9041 if (el.classList.contains(maskTextClass)) return true;
9042 }
9043 } else {
9044 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9045 }
9046 if (maskTextSelector) {
9047 if (checkAncestors) {
9048 if (el.closest(maskTextSelector)) return true;
9049 } else {
9050 if (el.matches(maskTextSelector)) return true;
9051 }
9052 }
9053 } catch (e2) {}
9054 return false;
9055 }
9056 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9057 var win = iframeEl.contentWindow;
9058 if (!win) {
9059 return;
9060 }
9061 var fired = false;
9062 var readyState;
9063 try {
9064 readyState = win.document.readyState;
9065 } catch (error) {
9066 return;
9067 }
9068 if (readyState !== "complete") {
9069 var timer = setTimeout(function() {
9070 if (!fired) {
9071 listener();
9072 fired = true;
9073 }
9074 }, iframeLoadTimeout);
9075 iframeEl.addEventListener("load", function() {
9076 clearTimeout(timer);
9077 fired = true;
9078 listener();
9079 });
9080 return;
9081 }
9082 var blankUrl = "about:blank";
9083 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9084 setTimeout(listener, 0);
9085 return iframeEl.addEventListener("load", listener);
9086 }
9087 iframeEl.addEventListener("load", listener);
9088 }
9089 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9090 var fired = false;
9091 var styleSheetLoaded;
9092 try {
9093 styleSheetLoaded = link.sheet;
9094 } catch (error) {
9095 return;
9096 }
9097 if (styleSheetLoaded) return;
9098 var timer = setTimeout(function() {
9099 if (!fired) {
9100 listener();
9101 fired = true;
9102 }
9103 }, styleSheetLoadTimeout);
9104 link.addEventListener("load", function() {
9105 clearTimeout(timer);
9106 fired = true;
9107 listener();
9108 });
9109 }
9110 function serializeNode(n2, options) {
9111 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;
9112 var rootId = getRootId(doc, mirror2);
9113 switch(n2.nodeType){
9114 case n2.DOCUMENT_NODE:
9115 if (n2.compatMode !== "CSS1Compat") {
9116 return {
9117 type: NodeType$3.Document,
9118 childNodes: [],
9119 compatMode: n2.compatMode
9120 };
9121 } else {
9122 return {
9123 type: NodeType$3.Document,
9124 childNodes: []
9125 };
9126 }
9127 case n2.DOCUMENT_TYPE_NODE:
9128 return {
9129 type: NodeType$3.DocumentType,
9130 name: n2.name,
9131 publicId: n2.publicId,
9132 systemId: n2.systemId,
9133 rootId: rootId
9134 };
9135 case n2.ELEMENT_NODE:
9136 return serializeElementNode(n2, {
9137 doc: doc,
9138 blockClass: blockClass,
9139 blockSelector: blockSelector,
9140 inlineStylesheet: inlineStylesheet,
9141 maskInputOptions: maskInputOptions,
9142 maskInputFn: maskInputFn,
9143 dataURLOptions: dataURLOptions,
9144 inlineImages: inlineImages,
9145 recordCanvas: recordCanvas,
9146 keepIframeSrcFn: keepIframeSrcFn,
9147 newlyAddedElement: newlyAddedElement,
9148 rootId: rootId
9149 });
9150 case n2.TEXT_NODE:
9151 return serializeTextNode(n2, {
9152 doc: doc,
9153 needsMask: needsMask,
9154 maskTextFn: maskTextFn,
9155 rootId: rootId,
9156 cssCaptured: cssCaptured
9157 });
9158 case n2.CDATA_SECTION_NODE:
9159 return {
9160 type: NodeType$3.CDATA,
9161 textContent: "",
9162 rootId: rootId
9163 };
9164 case n2.COMMENT_NODE:
9165 return {
9166 type: NodeType$3.Comment,
9167 textContent: index$1.textContent(n2) || "",
9168 rootId: rootId
9169 };
9170 default:
9171 return false;
9172 }
9173 }
9174 function getRootId(doc, mirror2) {
9175 if (!mirror2.hasNode(doc)) return void 0;
9176 var docId = mirror2.getId(doc);
9177 return docId === 1 ? void 0 : docId;
9178 }
9179 function serializeTextNode(n2, options) {
9180 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
9181 var parent = index$1.parentNode(n2);
9182 var parentTagName = parent && parent.tagName;
9183 var textContent2 = "";
9184 var isStyle = parentTagName === "STYLE" ? true : void 0;
9185 var isScript = parentTagName === "SCRIPT" ? true : void 0;
9186 if (isScript) {
9187 textContent2 = "SCRIPT_PLACEHOLDER";
9188 } else if (!cssCaptured) {
9189 textContent2 = index$1.textContent(n2);
9190 if (isStyle && textContent2) {
9191 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
9192 }
9193 }
9194 if (!isStyle && !isScript && textContent2 && needsMask) {
9195 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
9196 }
9197 return {
9198 type: NodeType$3.Text,
9199 textContent: textContent2 || "",
9200 rootId: rootId
9201 };
9202 }
9203 function serializeElementNode(n2, options) {
9204 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;
9205 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
9206 var tagName = getValidTagName$1(n2);
9207 var attributes = {};
9208 var len = n2.attributes.length;
9209 for(var i2 = 0; i2 < len; i2++){
9210 var attr = n2.attributes[i2];
9211 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
9212 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
9213 }
9214 }
9215 if (tagName === "link" && inlineStylesheet) {
9216 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
9217 return s2.href === n2.href;
9218 });
9219 var cssText = null;
9220 if (stylesheet) {
9221 cssText = stringifyStylesheet(stylesheet);
9222 }
9223 if (cssText) {
9224 delete attributes.rel;
9225 delete attributes.href;
9226 attributes._cssText = cssText;
9227 }
9228 }
9229 if (tagName === "style" && n2.sheet) {
9230 var cssText1 = stringifyStylesheet(n2.sheet);
9231 if (cssText1) {
9232 if (n2.childNodes.length > 1) {
9233 cssText1 = markCssSplits(cssText1, n2);
9234 }
9235 attributes._cssText = cssText1;
9236 }
9237 }
9238 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
9239 var value = n2.value;
9240 var checked = n2.checked;
9241 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
9242 attributes.value = maskInputValue({
9243 element: n2,
9244 type: getInputType(n2),
9245 tagName: tagName,
9246 value: value,
9247 maskInputOptions: maskInputOptions,
9248 maskInputFn: maskInputFn
9249 });
9250 } else if (checked) {
9251 attributes.checked = checked;
9252 }
9253 }
9254 if (tagName === "option") {
9255 if (n2.selected && !maskInputOptions["select"]) {
9256 attributes.selected = true;
9257 } else {
9258 delete attributes.selected;
9259 }
9260 }
9261 if (tagName === "dialog" && n2.open) {
9262 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
9263 }
9264 if (tagName === "canvas" && recordCanvas) {
9265 if (n2.__context === "2d") {
9266 if (!is2DCanvasBlank(n2)) {
9267 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9268 }
9269 } else if (!("__context" in n2)) {
9270 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9271 var blankCanvas = doc.createElement("canvas");
9272 blankCanvas.width = n2.width;
9273 blankCanvas.height = n2.height;
9274 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9275 if (canvasDataURL !== blankCanvasDataURL) {
9276 attributes.rr_dataURL = canvasDataURL;
9277 }
9278 }
9279 }
9280 if (tagName === "img" && inlineImages) {
9281 if (!canvasService) {
9282 canvasService = doc.createElement("canvas");
9283 canvasCtx = canvasService.getContext("2d");
9284 }
9285 var image = n2;
9286 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
9287 var priorCrossOrigin = image.crossOrigin;
9288 var recordInlineImage = function() {
9289 image.removeEventListener("load", recordInlineImage);
9290 try {
9291 canvasService.width = image.naturalWidth;
9292 canvasService.height = image.naturalHeight;
9293 canvasCtx.drawImage(image, 0, 0);
9294 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
9295 } catch (err) {
9296 if (image.crossOrigin !== "anonymous") {
9297 image.crossOrigin = "anonymous";
9298 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9299 else image.addEventListener("load", recordInlineImage);
9300 return;
9301 } else {
9302 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
9303 }
9304 }
9305 if (image.crossOrigin === "anonymous") {
9306 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
9307 }
9308 };
9309 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
9310 else image.addEventListener("load", recordInlineImage);
9311 }
9312 if (tagName === "audio" || tagName === "video") {
9313 var mediaAttributes = attributes;
9314 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
9315 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
9316 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
9317 mediaAttributes.rr_mediaMuted = n2.muted;
9318 mediaAttributes.rr_mediaLoop = n2.loop;
9319 mediaAttributes.rr_mediaVolume = n2.volume;
9320 }
9321 if (!newlyAddedElement) {
9322 if (n2.scrollLeft) {
9323 attributes.rr_scrollLeft = n2.scrollLeft;
9324 }
9325 if (n2.scrollTop) {
9326 attributes.rr_scrollTop = n2.scrollTop;
9327 }
9328 }
9329 if (needBlock) {
9330 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
9331 attributes = {
9332 class: attributes.class,
9333 rr_width: "" + width + "px",
9334 rr_height: "" + height + "px"
9335 };
9336 }
9337 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
9338 if (!n2.contentDocument) {
9339 attributes.rr_src = attributes.src;
9340 }
9341 delete attributes.src;
9342 }
9343 var isCustomElement;
9344 try {
9345 if (customElements.get(tagName)) isCustomElement = true;
9346 } catch (e2) {}
9347 return {
9348 type: NodeType$3.Element,
9349 tagName: tagName,
9350 attributes: attributes,
9351 childNodes: [],
9352 isSVG: isSVGElement(n2) || void 0,
9353 needBlock: needBlock,
9354 rootId: rootId,
9355 isCustom: isCustomElement
9356 };
9357 }
9358 function lowerIfExists(maybeAttr) {
9359 if (maybeAttr === void 0 || maybeAttr === null) {
9360 return "";
9361 } else {
9362 return maybeAttr.toLowerCase();
9363 }
9364 }
9365 function slimDOMExcluded(sn, slimDOMOptions) {
9366 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
9367 return true;
9368 } else if (sn.type === NodeType$3.Element) {
9369 if (slimDOMOptions.script && // script tag
9370 (sn.tagName === "script" || // (module)preload link
9371 sn.tagName === "link" && (sn.attributes.rel === "preload" || sn.attributes.rel === "modulepreload") && sn.attributes.as === "script" || // prefetch link
9372 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
9373 return true;
9374 } 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"))) {
9375 return true;
9376 } else if (sn.tagName === "meta") {
9377 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
9378 return true;
9379 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
9380 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
9381 return true;
9382 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
9383 return true;
9384 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
9385 return true;
9386 } 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:/))) {
9387 return true;
9388 } 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")) {
9389 return true;
9390 }
9391 }
9392 }
9393 return false;
9394 }
9395 function serializeNodeWithId(n2, options) {
9396 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() {
9397 return false;
9398 } : _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;
9399 var needsMask = options.needsMask;
9400 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
9401 if (!needsMask) {
9402 var checkAncestors = needsMask === void 0;
9403 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
9404 }
9405 var _serializedNode = serializeNode(n2, {
9406 doc: doc,
9407 mirror: mirror2,
9408 blockClass: blockClass,
9409 blockSelector: blockSelector,
9410 needsMask: needsMask,
9411 inlineStylesheet: inlineStylesheet,
9412 maskInputOptions: maskInputOptions,
9413 maskTextFn: maskTextFn,
9414 maskInputFn: maskInputFn,
9415 dataURLOptions: dataURLOptions,
9416 inlineImages: inlineImages,
9417 recordCanvas: recordCanvas,
9418 keepIframeSrcFn: keepIframeSrcFn,
9419 newlyAddedElement: newlyAddedElement,
9420 cssCaptured: cssCaptured
9421 });
9422 if (!_serializedNode) {
9423 console.warn(n2, "not serialized");
9424 return null;
9425 }
9426 var id;
9427 if (mirror2.hasNode(n2)) {
9428 id = mirror2.getId(n2);
9429 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
9430 id = IGNORED_NODE;
9431 } else {
9432 id = genId();
9433 }
9434 var serializedNode = Object.assign(_serializedNode, {
9435 id: id
9436 });
9437 mirror2.add(n2, serializedNode);
9438 if (id === IGNORED_NODE) {
9439 return null;
9440 }
9441 if (onSerialize) {
9442 onSerialize(n2);
9443 }
9444 var recordChild = !skipChild;
9445 if (serializedNode.type === NodeType$3.Element) {
9446 recordChild = recordChild && !serializedNode.needBlock;
9447 delete serializedNode.needBlock;
9448 var shadowRootEl = index$1.shadowRoot(n2);
9449 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
9450 }
9451 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
9452 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
9453 preserveWhiteSpace = false;
9454 }
9455 var bypassOptions = {
9456 doc: doc,
9457 mirror: mirror2,
9458 blockClass: blockClass,
9459 blockSelector: blockSelector,
9460 needsMask: needsMask,
9461 maskTextClass: maskTextClass,
9462 maskTextSelector: maskTextSelector,
9463 skipChild: skipChild,
9464 inlineStylesheet: inlineStylesheet,
9465 maskInputOptions: maskInputOptions,
9466 maskTextFn: maskTextFn,
9467 maskInputFn: maskInputFn,
9468 slimDOMOptions: slimDOMOptions,
9469 dataURLOptions: dataURLOptions,
9470 inlineImages: inlineImages,
9471 recordCanvas: recordCanvas,
9472 preserveWhiteSpace: preserveWhiteSpace,
9473 onSerialize: onSerialize,
9474 onIframeLoad: onIframeLoad,
9475 iframeLoadTimeout: iframeLoadTimeout,
9476 onStylesheetLoad: onStylesheetLoad,
9477 stylesheetLoadTimeout: stylesheetLoadTimeout,
9478 keepIframeSrcFn: keepIframeSrcFn,
9479 cssCaptured: false
9480 };
9481 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
9482 else {
9483 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
9484 bypassOptions.cssCaptured = true;
9485 }
9486 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
9487 var childN = _step.value;
9488 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
9489 if (serializedChildNode) {
9490 serializedNode.childNodes.push(serializedChildNode);
9491 }
9492 }
9493 }
9494 var shadowRootEl1 = null;
9495 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
9496 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
9497 var childN1 = _step1.value;
9498 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
9499 if (serializedChildNode1) {
9500 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
9501 serializedNode.childNodes.push(serializedChildNode1);
9502 }
9503 }
9504 }
9505 }
9506 var parent = index$1.parentNode(n2);
9507 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
9508 serializedNode.isShadow = true;
9509 }
9510 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
9511 onceIframeLoaded(n2, function() {
9512 var iframeDoc = n2.contentDocument;
9513 if (iframeDoc && onIframeLoad) {
9514 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
9515 doc: iframeDoc,
9516 mirror: mirror2,
9517 blockClass: blockClass,
9518 blockSelector: blockSelector,
9519 needsMask: needsMask,
9520 maskTextClass: maskTextClass,
9521 maskTextSelector: maskTextSelector,
9522 skipChild: false,
9523 inlineStylesheet: inlineStylesheet,
9524 maskInputOptions: maskInputOptions,
9525 maskTextFn: maskTextFn,
9526 maskInputFn: maskInputFn,
9527 slimDOMOptions: slimDOMOptions,
9528 dataURLOptions: dataURLOptions,
9529 inlineImages: inlineImages,
9530 recordCanvas: recordCanvas,
9531 preserveWhiteSpace: preserveWhiteSpace,
9532 onSerialize: onSerialize,
9533 onIframeLoad: onIframeLoad,
9534 iframeLoadTimeout: iframeLoadTimeout,
9535 onStylesheetLoad: onStylesheetLoad,
9536 stylesheetLoadTimeout: stylesheetLoadTimeout,
9537 keepIframeSrcFn: keepIframeSrcFn
9538 });
9539 if (serializedIframeNode) {
9540 onIframeLoad(n2, serializedIframeNode);
9541 }
9542 }
9543 }, iframeLoadTimeout);
9544 }
9545 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")) {
9546 onceStylesheetLoaded(n2, function() {
9547 if (onStylesheetLoad) {
9548 var serializedLinkNode = serializeNodeWithId(n2, {
9549 doc: doc,
9550 mirror: mirror2,
9551 blockClass: blockClass,
9552 blockSelector: blockSelector,
9553 needsMask: needsMask,
9554 maskTextClass: maskTextClass,
9555 maskTextSelector: maskTextSelector,
9556 skipChild: false,
9557 inlineStylesheet: inlineStylesheet,
9558 maskInputOptions: maskInputOptions,
9559 maskTextFn: maskTextFn,
9560 maskInputFn: maskInputFn,
9561 slimDOMOptions: slimDOMOptions,
9562 dataURLOptions: dataURLOptions,
9563 inlineImages: inlineImages,
9564 recordCanvas: recordCanvas,
9565 preserveWhiteSpace: preserveWhiteSpace,
9566 onSerialize: onSerialize,
9567 onIframeLoad: onIframeLoad,
9568 iframeLoadTimeout: iframeLoadTimeout,
9569 onStylesheetLoad: onStylesheetLoad,
9570 stylesheetLoadTimeout: stylesheetLoadTimeout,
9571 keepIframeSrcFn: keepIframeSrcFn
9572 });
9573 if (serializedLinkNode) {
9574 onStylesheetLoad(n2, serializedLinkNode);
9575 }
9576 }
9577 }, stylesheetLoadTimeout);
9578 }
9579 return serializedNode;
9580 }
9581 function snapshot(n2, options) {
9582 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() {
9583 return false;
9584 } : _ref_keepIframeSrcFn;
9585 var maskInputOptions = maskAllInputs === true ? {
9586 color: true,
9587 date: true,
9588 "datetime-local": true,
9589 email: true,
9590 month: true,
9591 number: true,
9592 range: true,
9593 search: true,
9594 tel: true,
9595 text: true,
9596 time: true,
9597 url: true,
9598 week: true,
9599 textarea: true,
9600 select: true,
9601 password: true
9602 } : maskAllInputs === false ? {
9603 password: true
9604 } : maskAllInputs;
9605 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
9606 {
9607 script: true,
9608 comment: true,
9609 headFavicon: true,
9610 headWhitespace: true,
9611 headMetaDescKeywords: slimDOM === "all",
9612 // destructive
9613 headMetaSocial: true,
9614 headMetaRobots: true,
9615 headMetaHttpEquiv: true,
9616 headMetaAuthorship: true,
9617 headMetaVerification: true
9618 } : slimDOM === false ? {} : slimDOM;
9619 return serializeNodeWithId(n2, {
9620 doc: n2,
9621 mirror: mirror2,
9622 blockClass: blockClass,
9623 blockSelector: blockSelector,
9624 maskTextClass: maskTextClass,
9625 maskTextSelector: maskTextSelector,
9626 skipChild: false,
9627 inlineStylesheet: inlineStylesheet,
9628 maskInputOptions: maskInputOptions,
9629 maskTextFn: maskTextFn,
9630 maskInputFn: maskInputFn,
9631 slimDOMOptions: slimDOMOptions,
9632 dataURLOptions: dataURLOptions,
9633 inlineImages: inlineImages,
9634 recordCanvas: recordCanvas,
9635 preserveWhiteSpace: preserveWhiteSpace,
9636 onSerialize: onSerialize,
9637 onIframeLoad: onIframeLoad,
9638 iframeLoadTimeout: iframeLoadTimeout,
9639 onStylesheetLoad: onStylesheetLoad,
9640 stylesheetLoadTimeout: stylesheetLoadTimeout,
9641 keepIframeSrcFn: keepIframeSrcFn,
9642 newlyAddedElement: false
9643 });
9644 }
9645 function getDefaultExportFromCjs$1(x2) {
9646 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
9647 }
9648 function getAugmentedNamespace$1(n2) {
9649 if (n2.__esModule) return n2;
9650 var f2 = n2.default;
9651 if (typeof f2 == "function") {
9652 var a2 = function a22() {
9653 if (_instanceof(this, a22)) {
9654 return Reflect.construct(f2, arguments, this.constructor);
9655 }
9656 return f2.apply(this, arguments);
9657 };
9658 a2.prototype = f2.prototype;
9659 } else a2 = {};
9660 Object.defineProperty(a2, "__esModule", {
9661 value: true
9662 });
9663 Object.keys(n2).forEach(function(k) {
9664 var d = Object.getOwnPropertyDescriptor(n2, k);
9665 Object.defineProperty(a2, k, d.get ? d : {
9666 enumerable: true,
9667 get: function get() {
9668 return n2[k];
9669 }
9670 });
9671 });
9672 return a2;
9673 }
9674 var picocolors_browser$1 = {
9675 exports: {}
9676 };
9677 var x$1 = String;
9678 var create$1 = function create$1() {
9679 return {
9680 isColorSupported: false,
9681 reset: x$1,
9682 bold: x$1,
9683 dim: x$1,
9684 italic: x$1,
9685 underline: x$1,
9686 inverse: x$1,
9687 hidden: x$1,
9688 strikethrough: x$1,
9689 black: x$1,
9690 red: x$1,
9691 green: x$1,
9692 yellow: x$1,
9693 blue: x$1,
9694 magenta: x$1,
9695 cyan: x$1,
9696 white: x$1,
9697 gray: x$1,
9698 bgBlack: x$1,
9699 bgRed: x$1,
9700 bgGreen: x$1,
9701 bgYellow: x$1,
9702 bgBlue: x$1,
9703 bgMagenta: x$1,
9704 bgCyan: x$1,
9705 bgWhite: x$1
9706 };
9707 };
9708 picocolors_browser$1.exports = create$1();
9709 picocolors_browser$1.exports.createColors = create$1;
9710 var picocolors_browserExports$1 = picocolors_browser$1.exports;
9711 var __viteBrowserExternal$2 = {};
9712 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9713 __proto__: null,
9714 default: __viteBrowserExternal$2
9715 }, Symbol.toStringTag, {
9716 value: "Module"
9717 }));
9718 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
9719 var pico$1 = picocolors_browserExports$1;
9720 var terminalHighlight$1$1 = require$$2$1;
9721 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
9722 _inherits(CssSyntaxError, Error1);
9723 function CssSyntaxError(message, line, column, source, file, plugin22) {
9724 var _this;
9725 _this = Error1.call(this, message) || this;
9726 _this.name = "CssSyntaxError";
9727 _this.reason = message;
9728 if (file) {
9729 _this.file = file;
9730 }
9731 if (source) {
9732 _this.source = source;
9733 }
9734 if (plugin22) {
9735 _this.plugin = plugin22;
9736 }
9737 if (typeof line !== "undefined" && typeof column !== "undefined") {
9738 if (typeof line === "number") {
9739 _this.line = line;
9740 _this.column = column;
9741 } else {
9742 _this.line = line.line;
9743 _this.column = line.column;
9744 _this.endLine = column.line;
9745 _this.endColumn = column.column;
9746 }
9747 }
9748 _this.setMessage();
9749 if (Error.captureStackTrace) {
9750 Error.captureStackTrace(_this, CssSyntaxError);
9751 }
9752 return _this;
9753 }
9754 var _proto = CssSyntaxError.prototype;
9755 _proto.setMessage = function setMessage() {
9756 this.message = this.plugin ? this.plugin + ": " : "";
9757 this.message += this.file ? this.file : "<css input>";
9758 if (typeof this.line !== "undefined") {
9759 this.message += ":" + this.line + ":" + this.column;
9760 }
9761 this.message += ": " + this.reason;
9762 };
9763 _proto.showSourceCode = function showSourceCode(color) {
9764 var _this = this;
9765 if (!this.source) return "";
9766 var css = this.source;
9767 if (color == null) color = pico$1.isColorSupported;
9768 if (terminalHighlight$1$1) {
9769 if (color) css = terminalHighlight$1$1(css);
9770 }
9771 var lines = css.split(/\r?\n/);
9772 var start = Math.max(this.line - 3, 0);
9773 var end = Math.min(this.line + 2, lines.length);
9774 var maxWidth = String(end).length;
9775 var mark, aside;
9776 if (color) {
9777 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
9778 mark = function(text) {
9779 return bold(red(text));
9780 };
9781 aside = function(text) {
9782 return gray(text);
9783 };
9784 } else {
9785 mark = aside = function(str) {
9786 return str;
9787 };
9788 }
9789 return lines.slice(start, end).map(function(line, index2) {
9790 var number = start + 1 + index2;
9791 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
9792 if (number === _this.line) {
9793 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
9794 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
9795 }
9796 return " " + aside(gutter) + line;
9797 }).join("\n");
9798 };
9799 _proto.toString = function toString() {
9800 var code = this.showSourceCode();
9801 if (code) {
9802 code = "\n\n" + code + "\n";
9803 }
9804 return this.name + ": " + this.message + code;
9805 };
9806 return CssSyntaxError;
9807 }(_wrap_native_super(Error));
9808 var cssSyntaxError$1 = CssSyntaxError$3$1;
9809 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
9810 var symbols$1 = {};
9811 symbols$1.isClean = Symbol("isClean");
9812 symbols$1.my = Symbol("my");
9813 var DEFAULT_RAW$1 = {
9814 after: "\n",
9815 beforeClose: "\n",
9816 beforeComment: "\n",
9817 beforeDecl: "\n",
9818 beforeOpen: " ",
9819 beforeRule: "\n",
9820 colon: ": ",
9821 commentLeft: " ",
9822 commentRight: " ",
9823 emptyBody: "",
9824 indent: " ",
9825 semicolon: false
9826 };
9827 function capitalize$1(str) {
9828 return str[0].toUpperCase() + str.slice(1);
9829 }
9830 var Stringifier$2$1 = /*#__PURE__*/ function() {
9831 function Stringifier(builder) {
9832 this.builder = builder;
9833 }
9834 var _proto = Stringifier.prototype;
9835 _proto.atrule = function atrule(node2, semicolon) {
9836 var name = "@" + node2.name;
9837 var params = node2.params ? this.rawValue(node2, "params") : "";
9838 if (typeof node2.raws.afterName !== "undefined") {
9839 name += node2.raws.afterName;
9840 } else if (params) {
9841 name += " ";
9842 }
9843 if (node2.nodes) {
9844 this.block(node2, name + params);
9845 } else {
9846 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
9847 this.builder(name + params + end, node2);
9848 }
9849 };
9850 _proto.beforeAfter = function beforeAfter(node2, detect) {
9851 var value;
9852 if (node2.type === "decl") {
9853 value = this.raw(node2, null, "beforeDecl");
9854 } else if (node2.type === "comment") {
9855 value = this.raw(node2, null, "beforeComment");
9856 } else if (detect === "before") {
9857 value = this.raw(node2, null, "beforeRule");
9858 } else {
9859 value = this.raw(node2, null, "beforeClose");
9860 }
9861 var buf = node2.parent;
9862 var depth = 0;
9863 while(buf && buf.type !== "root"){
9864 depth += 1;
9865 buf = buf.parent;
9866 }
9867 if (value.includes("\n")) {
9868 var indent = this.raw(node2, null, "indent");
9869 if (indent.length) {
9870 for(var step = 0; step < depth; step++)value += indent;
9871 }
9872 }
9873 return value;
9874 };
9875 _proto.block = function block(node2, start) {
9876 var between = this.raw(node2, "between", "beforeOpen");
9877 this.builder(start + between + "{", node2, "start");
9878 var after;
9879 if (node2.nodes && node2.nodes.length) {
9880 this.body(node2);
9881 after = this.raw(node2, "after");
9882 } else {
9883 after = this.raw(node2, "after", "emptyBody");
9884 }
9885 if (after) this.builder(after);
9886 this.builder("}", node2, "end");
9887 };
9888 _proto.body = function body(node2) {
9889 var last = node2.nodes.length - 1;
9890 while(last > 0){
9891 if (node2.nodes[last].type !== "comment") break;
9892 last -= 1;
9893 }
9894 var semicolon = this.raw(node2, "semicolon");
9895 for(var i2 = 0; i2 < node2.nodes.length; i2++){
9896 var child = node2.nodes[i2];
9897 var before = this.raw(child, "before");
9898 if (before) this.builder(before);
9899 this.stringify(child, last !== i2 || semicolon);
9900 }
9901 };
9902 _proto.comment = function comment(node2) {
9903 var left = this.raw(node2, "left", "commentLeft");
9904 var right = this.raw(node2, "right", "commentRight");
9905 this.builder("/*" + left + node2.text + right + "*/", node2);
9906 };
9907 _proto.decl = function decl(node2, semicolon) {
9908 var between = this.raw(node2, "between", "colon");
9909 var string = node2.prop + between + this.rawValue(node2, "value");
9910 if (node2.important) {
9911 string += node2.raws.important || " !important";
9912 }
9913 if (semicolon) string += ";";
9914 this.builder(string, node2);
9915 };
9916 _proto.document = function document1(node2) {
9917 this.body(node2);
9918 };
9919 _proto.raw = function raw(node2, own, detect) {
9920 var value;
9921 if (!detect) detect = own;
9922 if (own) {
9923 value = node2.raws[own];
9924 if (typeof value !== "undefined") return value;
9925 }
9926 var parent = node2.parent;
9927 if (detect === "before") {
9928 if (!parent || parent.type === "root" && parent.first === node2) {
9929 return "";
9930 }
9931 if (parent && parent.type === "document") {
9932 return "";
9933 }
9934 }
9935 if (!parent) return DEFAULT_RAW$1[detect];
9936 var root2 = node2.root();
9937 if (!root2.rawCache) root2.rawCache = {};
9938 if (typeof root2.rawCache[detect] !== "undefined") {
9939 return root2.rawCache[detect];
9940 }
9941 if (detect === "before" || detect === "after") {
9942 return this.beforeAfter(node2, detect);
9943 } else {
9944 var method = "raw" + capitalize$1(detect);
9945 if (this[method]) {
9946 value = this[method](root2, node2);
9947 } else {
9948 root2.walk(function(i2) {
9949 value = i2.raws[own];
9950 if (typeof value !== "undefined") return false;
9951 });
9952 }
9953 }
9954 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
9955 root2.rawCache[detect] = value;
9956 return value;
9957 };
9958 _proto.rawBeforeClose = function rawBeforeClose(root2) {
9959 var value;
9960 root2.walk(function(i2) {
9961 if (i2.nodes && i2.nodes.length > 0) {
9962 if (typeof i2.raws.after !== "undefined") {
9963 value = i2.raws.after;
9964 if (value.includes("\n")) {
9965 value = value.replace(/[^\n]+$/, "");
9966 }
9967 return false;
9968 }
9969 }
9970 });
9971 if (value) value = value.replace(/\S/g, "");
9972 return value;
9973 };
9974 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
9975 var value;
9976 root2.walkComments(function(i2) {
9977 if (typeof i2.raws.before !== "undefined") {
9978 value = i2.raws.before;
9979 if (value.includes("\n")) {
9980 value = value.replace(/[^\n]+$/, "");
9981 }
9982 return false;
9983 }
9984 });
9985 if (typeof value === "undefined") {
9986 value = this.raw(node2, null, "beforeDecl");
9987 } else if (value) {
9988 value = value.replace(/\S/g, "");
9989 }
9990 return value;
9991 };
9992 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
9993 var value;
9994 root2.walkDecls(function(i2) {
9995 if (typeof i2.raws.before !== "undefined") {
9996 value = i2.raws.before;
9997 if (value.includes("\n")) {
9998 value = value.replace(/[^\n]+$/, "");
9999 }
10000 return false;
10001 }
10002 });
10003 if (typeof value === "undefined") {
10004 value = this.raw(node2, null, "beforeRule");
10005 } else if (value) {
10006 value = value.replace(/\S/g, "");
10007 }
10008 return value;
10009 };
10010 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10011 var value;
10012 root2.walk(function(i2) {
10013 if (i2.type !== "decl") {
10014 value = i2.raws.between;
10015 if (typeof value !== "undefined") return false;
10016 }
10017 });
10018 return value;
10019 };
10020 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10021 var value;
10022 root2.walk(function(i2) {
10023 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10024 if (typeof i2.raws.before !== "undefined") {
10025 value = i2.raws.before;
10026 if (value.includes("\n")) {
10027 value = value.replace(/[^\n]+$/, "");
10028 }
10029 return false;
10030 }
10031 }
10032 });
10033 if (value) value = value.replace(/\S/g, "");
10034 return value;
10035 };
10036 _proto.rawColon = function rawColon(root2) {
10037 var value;
10038 root2.walkDecls(function(i2) {
10039 if (typeof i2.raws.between !== "undefined") {
10040 value = i2.raws.between.replace(/[^\s:]/g, "");
10041 return false;
10042 }
10043 });
10044 return value;
10045 };
10046 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10047 var value;
10048 root2.walk(function(i2) {
10049 if (i2.nodes && i2.nodes.length === 0) {
10050 value = i2.raws.after;
10051 if (typeof value !== "undefined") return false;
10052 }
10053 });
10054 return value;
10055 };
10056 _proto.rawIndent = function rawIndent(root2) {
10057 if (root2.raws.indent) return root2.raws.indent;
10058 var value;
10059 root2.walk(function(i2) {
10060 var p = i2.parent;
10061 if (p && p !== root2 && p.parent && p.parent === root2) {
10062 if (typeof i2.raws.before !== "undefined") {
10063 var parts = i2.raws.before.split("\n");
10064 value = parts[parts.length - 1];
10065 value = value.replace(/\S/g, "");
10066 return false;
10067 }
10068 }
10069 });
10070 return value;
10071 };
10072 _proto.rawSemicolon = function rawSemicolon(root2) {
10073 var value;
10074 root2.walk(function(i2) {
10075 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10076 value = i2.raws.semicolon;
10077 if (typeof value !== "undefined") return false;
10078 }
10079 });
10080 return value;
10081 };
10082 _proto.rawValue = function rawValue(node2, prop) {
10083 var value = node2[prop];
10084 var raw = node2.raws[prop];
10085 if (raw && raw.value === value) {
10086 return raw.raw;
10087 }
10088 return value;
10089 };
10090 _proto.root = function root(node2) {
10091 this.body(node2);
10092 if (node2.raws.after) this.builder(node2.raws.after);
10093 };
10094 _proto.rule = function rule(node2) {
10095 this.block(node2, this.rawValue(node2, "selector"));
10096 if (node2.raws.ownSemicolon) {
10097 this.builder(node2.raws.ownSemicolon, node2, "end");
10098 }
10099 };
10100 _proto.stringify = function stringify(node2, semicolon) {
10101 if (!this[node2.type]) {
10102 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10103 }
10104 this[node2.type](node2, semicolon);
10105 };
10106 return Stringifier;
10107 }();
10108 var stringifier$1 = Stringifier$2$1;
10109 Stringifier$2$1.default = Stringifier$2$1;
10110 var Stringifier$1$1 = stringifier$1;
10111 function stringify$4$1(node2, builder) {
10112 var str = new Stringifier$1$1(builder);
10113 str.stringify(node2);
10114 }
10115 var stringify_1$1 = stringify$4$1;
10116 stringify$4$1.default = stringify$4$1;
10117 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10118 var CssSyntaxError$2$1 = cssSyntaxError$1;
10119 var Stringifier2$1 = stringifier$1;
10120 var stringify$3$1 = stringify_1$1;
10121 function cloneNode$1(obj, parent) {
10122 var cloned = new obj.constructor();
10123 for(var i2 in obj){
10124 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10125 continue;
10126 }
10127 if (i2 === "proxyCache") continue;
10128 var value = obj[i2];
10129 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10130 if (i2 === "parent" && type === "object") {
10131 if (parent) cloned[i2] = parent;
10132 } else if (i2 === "source") {
10133 cloned[i2] = value;
10134 } else if (Array.isArray(value)) {
10135 cloned[i2] = value.map(function(j) {
10136 return cloneNode$1(j, cloned);
10137 });
10138 } else {
10139 if (type === "object" && value !== null) value = cloneNode$1(value);
10140 cloned[i2] = value;
10141 }
10142 }
10143 return cloned;
10144 }
10145 var Node$4$1 = /*#__PURE__*/ function() {
10146 function Node2(defaults) {
10147 if (defaults === void 0) defaults = {};
10148 this.raws = {};
10149 this[isClean$2$1] = false;
10150 this[my$2$1] = true;
10151 for(var name in defaults){
10152 if (name === "nodes") {
10153 this.nodes = [];
10154 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10155 var node2 = _step.value;
10156 if (typeof node2.clone === "function") {
10157 this.append(node2.clone());
10158 } else {
10159 this.append(node2);
10160 }
10161 }
10162 } else {
10163 this[name] = defaults[name];
10164 }
10165 }
10166 }
10167 var _proto = Node2.prototype;
10168 _proto.addToError = function addToError(error) {
10169 error.postcssNode = this;
10170 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
10171 var s2 = this.source;
10172 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
10173 }
10174 return error;
10175 };
10176 _proto.after = function after(add) {
10177 this.parent.insertAfter(this, add);
10178 return this;
10179 };
10180 _proto.assign = function assign(overrides) {
10181 if (overrides === void 0) overrides = {};
10182 for(var name in overrides){
10183 this[name] = overrides[name];
10184 }
10185 return this;
10186 };
10187 _proto.before = function before(add) {
10188 this.parent.insertBefore(this, add);
10189 return this;
10190 };
10191 _proto.cleanRaws = function cleanRaws(keepBetween) {
10192 delete this.raws.before;
10193 delete this.raws.after;
10194 if (!keepBetween) delete this.raws.between;
10195 };
10196 _proto.clone = function clone(overrides) {
10197 if (overrides === void 0) overrides = {};
10198 var cloned = cloneNode$1(this);
10199 for(var name in overrides){
10200 cloned[name] = overrides[name];
10201 }
10202 return cloned;
10203 };
10204 _proto.cloneAfter = function cloneAfter(overrides) {
10205 if (overrides === void 0) overrides = {};
10206 var cloned = this.clone(overrides);
10207 this.parent.insertAfter(this, cloned);
10208 return cloned;
10209 };
10210 _proto.cloneBefore = function cloneBefore(overrides) {
10211 if (overrides === void 0) overrides = {};
10212 var cloned = this.clone(overrides);
10213 this.parent.insertBefore(this, cloned);
10214 return cloned;
10215 };
10216 _proto.error = function error(message, opts) {
10217 if (opts === void 0) opts = {};
10218 if (this.source) {
10219 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
10220 return this.source.input.error(message, {
10221 column: start.column,
10222 line: start.line
10223 }, {
10224 column: end.column,
10225 line: end.line
10226 }, opts);
10227 }
10228 return new CssSyntaxError$2$1(message);
10229 };
10230 _proto.getProxyProcessor = function getProxyProcessor() {
10231 return {
10232 get: function get(node2, prop) {
10233 if (prop === "proxyOf") {
10234 return node2;
10235 } else if (prop === "root") {
10236 return function() {
10237 return node2.root().toProxy();
10238 };
10239 } else {
10240 return node2[prop];
10241 }
10242 },
10243 set: function set(node2, prop, value) {
10244 if (node2[prop] === value) return true;
10245 node2[prop] = value;
10246 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
10247 node2.markDirty();
10248 }
10249 return true;
10250 }
10251 };
10252 };
10253 _proto.markDirty = function markDirty() {
10254 if (this[isClean$2$1]) {
10255 this[isClean$2$1] = false;
10256 var next = this;
10257 while(next = next.parent){
10258 next[isClean$2$1] = false;
10259 }
10260 }
10261 };
10262 _proto.next = function next() {
10263 if (!this.parent) return void 0;
10264 var index2 = this.parent.index(this);
10265 return this.parent.nodes[index2 + 1];
10266 };
10267 _proto.positionBy = function positionBy(opts, stringRepresentation) {
10268 var pos = this.source.start;
10269 if (opts.index) {
10270 pos = this.positionInside(opts.index, stringRepresentation);
10271 } else if (opts.word) {
10272 stringRepresentation = this.toString();
10273 var index2 = stringRepresentation.indexOf(opts.word);
10274 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
10275 }
10276 return pos;
10277 };
10278 _proto.positionInside = function positionInside(index2, stringRepresentation) {
10279 var string = stringRepresentation || this.toString();
10280 var column = this.source.start.column;
10281 var line = this.source.start.line;
10282 for(var i2 = 0; i2 < index2; i2++){
10283 if (string[i2] === "\n") {
10284 column = 1;
10285 line += 1;
10286 } else {
10287 column += 1;
10288 }
10289 }
10290 return {
10291 column: column,
10292 line: line
10293 };
10294 };
10295 _proto.prev = function prev() {
10296 if (!this.parent) return void 0;
10297 var index2 = this.parent.index(this);
10298 return this.parent.nodes[index2 - 1];
10299 };
10300 _proto.rangeBy = function rangeBy(opts) {
10301 var start = {
10302 column: this.source.start.column,
10303 line: this.source.start.line
10304 };
10305 var end = this.source.end ? {
10306 column: this.source.end.column + 1,
10307 line: this.source.end.line
10308 } : {
10309 column: start.column + 1,
10310 line: start.line
10311 };
10312 if (opts.word) {
10313 var stringRepresentation = this.toString();
10314 var index2 = stringRepresentation.indexOf(opts.word);
10315 if (index2 !== -1) {
10316 start = this.positionInside(index2, stringRepresentation);
10317 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
10318 }
10319 } else {
10320 if (opts.start) {
10321 start = {
10322 column: opts.start.column,
10323 line: opts.start.line
10324 };
10325 } else if (opts.index) {
10326 start = this.positionInside(opts.index);
10327 }
10328 if (opts.end) {
10329 end = {
10330 column: opts.end.column,
10331 line: opts.end.line
10332 };
10333 } else if (typeof opts.endIndex === "number") {
10334 end = this.positionInside(opts.endIndex);
10335 } else if (opts.index) {
10336 end = this.positionInside(opts.index + 1);
10337 }
10338 }
10339 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
10340 end = {
10341 column: start.column + 1,
10342 line: start.line
10343 };
10344 }
10345 return {
10346 end: end,
10347 start: start
10348 };
10349 };
10350 _proto.raw = function raw(prop, defaultType) {
10351 var str = new Stringifier2$1();
10352 return str.raw(this, prop, defaultType);
10353 };
10354 _proto.remove = function remove() {
10355 if (this.parent) {
10356 this.parent.removeChild(this);
10357 }
10358 this.parent = void 0;
10359 return this;
10360 };
10361 _proto.replaceWith = function replaceWith() {
10362 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
10363 nodes[_key] = arguments[_key];
10364 }
10365 if (this.parent) {
10366 var bookmark = this;
10367 var foundSelf = false;
10368 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
10369 var node2 = _step.value;
10370 if (node2 === this) {
10371 foundSelf = true;
10372 } else if (foundSelf) {
10373 this.parent.insertAfter(bookmark, node2);
10374 bookmark = node2;
10375 } else {
10376 this.parent.insertBefore(bookmark, node2);
10377 }
10378 }
10379 if (!foundSelf) {
10380 this.remove();
10381 }
10382 }
10383 return this;
10384 };
10385 _proto.root = function root() {
10386 var result2 = this;
10387 while(result2.parent && result2.parent.type !== "document"){
10388 result2 = result2.parent;
10389 }
10390 return result2;
10391 };
10392 _proto.toJSON = function toJSON(_, inputs) {
10393 var fixed = {};
10394 var emitInputs = inputs == null;
10395 inputs = inputs || /* @__PURE__ */ new Map();
10396 var inputsNextIndex = 0;
10397 for(var name in this){
10398 if (!Object.prototype.hasOwnProperty.call(this, name)) {
10399 continue;
10400 }
10401 if (name === "parent" || name === "proxyCache") continue;
10402 var value = this[name];
10403 if (Array.isArray(value)) {
10404 fixed[name] = value.map(function(i2) {
10405 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
10406 return i2.toJSON(null, inputs);
10407 } else {
10408 return i2;
10409 }
10410 });
10411 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
10412 fixed[name] = value.toJSON(null, inputs);
10413 } else if (name === "source") {
10414 var inputId = inputs.get(value.input);
10415 if (inputId == null) {
10416 inputId = inputsNextIndex;
10417 inputs.set(value.input, inputsNextIndex);
10418 inputsNextIndex++;
10419 }
10420 fixed[name] = {
10421 end: value.end,
10422 inputId: inputId,
10423 start: value.start
10424 };
10425 } else {
10426 fixed[name] = value;
10427 }
10428 }
10429 if (emitInputs) {
10430 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
10431 return input2.toJSON();
10432 });
10433 }
10434 return fixed;
10435 };
10436 _proto.toProxy = function toProxy() {
10437 if (!this.proxyCache) {
10438 this.proxyCache = new Proxy(this, this.getProxyProcessor());
10439 }
10440 return this.proxyCache;
10441 };
10442 _proto.toString = function toString(stringifier2) {
10443 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
10444 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
10445 var result2 = "";
10446 stringifier2(this, function(i2) {
10447 result2 += i2;
10448 });
10449 return result2;
10450 };
10451 _proto.warn = function warn(result2, text, opts) {
10452 var data = {
10453 node: this
10454 };
10455 for(var i2 in opts)data[i2] = opts[i2];
10456 return result2.warn(text, data);
10457 };
10458 _create_class(Node2, [
10459 {
10460 key: "proxyOf",
10461 get: function get() {
10462 return this;
10463 }
10464 }
10465 ]);
10466 return Node2;
10467 }();
10468 var node$1 = Node$4$1;
10469 Node$4$1.default = Node$4$1;
10470 var Node$3$1 = node$1;
10471 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
10472 _inherits(Declaration, Node$3$1);
10473 function Declaration(defaults) {
10474 var _this;
10475 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
10476 defaults = _extends({}, defaults, {
10477 value: String(defaults.value)
10478 });
10479 }
10480 _this = Node$3$1.call(this, defaults) || this;
10481 _this.type = "decl";
10482 return _this;
10483 }
10484 _create_class(Declaration, [
10485 {
10486 key: "variable",
10487 get: function get() {
10488 return this.prop.startsWith("--") || this.prop[0] === "$";
10489 }
10490 }
10491 ]);
10492 return Declaration;
10493 }(Node$3$1);
10494 var declaration$1 = Declaration$4$1;
10495 Declaration$4$1.default = Declaration$4$1;
10496 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
10497 var nanoid$1$1 = function(size) {
10498 if (size === void 0) size = 21;
10499 var id = "";
10500 var i2 = size;
10501 while(i2--){
10502 id += urlAlphabet$1[Math.random() * 64 | 0];
10503 }
10504 return id;
10505 };
10506 var nonSecure$1 = {
10507 nanoid: nanoid$1$1};
10508 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
10509 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
10510 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
10511 function fromBase64$1(str) {
10512 if (Buffer) {
10513 return Buffer.from(str, "base64").toString();
10514 } else {
10515 return window.atob(str);
10516 }
10517 }
10518 var PreviousMap$2$1 = /*#__PURE__*/ function() {
10519 function PreviousMap(css, opts) {
10520 if (opts.map === false) return;
10521 this.loadAnnotation(css);
10522 this.inline = this.startWith(this.annotation, "data:");
10523 var prev = opts.map ? opts.map.prev : void 0;
10524 var text = this.loadMap(opts.from, prev);
10525 if (!this.mapFile && opts.from) {
10526 this.mapFile = opts.from;
10527 }
10528 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
10529 if (text) this.text = text;
10530 }
10531 var _proto = PreviousMap.prototype;
10532 _proto.consumer = function consumer() {
10533 if (!this.consumerCache) {
10534 this.consumerCache = new SourceMapConsumer$2$1(this.text);
10535 }
10536 return this.consumerCache;
10537 };
10538 _proto.decodeInline = function decodeInline(text) {
10539 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
10540 var baseUri = /^data:application\/json;base64,/;
10541 var charsetUri = /^data:application\/json;charset=utf-?8,/;
10542 var uri = /^data:application\/json,/;
10543 if (charsetUri.test(text) || uri.test(text)) {
10544 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
10545 }
10546 if (baseCharsetUri.test(text) || baseUri.test(text)) {
10547 return fromBase64$1(text.substr(RegExp.lastMatch.length));
10548 }
10549 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
10550 throw new Error("Unsupported source map encoding " + encoding);
10551 };
10552 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
10553 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
10554 };
10555 _proto.isMap = function isMap(map) {
10556 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
10557 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
10558 };
10559 _proto.loadAnnotation = function loadAnnotation(css) {
10560 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
10561 if (!comments) return;
10562 var start = css.lastIndexOf(comments.pop());
10563 var end = css.indexOf("*/", start);
10564 if (start > -1 && end > -1) {
10565 this.annotation = this.getAnnotationURL(css.substring(start, end));
10566 }
10567 };
10568 _proto.loadFile = function loadFile(path) {
10569 this.root = dirname$1$1(path);
10570 if (existsSync$1(path)) {
10571 this.mapFile = path;
10572 return readFileSync$1(path, "utf-8").toString().trim();
10573 }
10574 };
10575 _proto.loadMap = function loadMap(file, prev) {
10576 if (prev === false) return false;
10577 if (prev) {
10578 if (typeof prev === "string") {
10579 return prev;
10580 } else if (typeof prev === "function") {
10581 var prevPath = prev(file);
10582 if (prevPath) {
10583 var map = this.loadFile(prevPath);
10584 if (!map) {
10585 throw new Error("Unable to load previous source map: " + prevPath.toString());
10586 }
10587 return map;
10588 }
10589 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
10590 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
10591 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
10592 return prev.toString();
10593 } else if (this.isMap(prev)) {
10594 return JSON.stringify(prev);
10595 } else {
10596 throw new Error("Unsupported previous source map format: " + prev.toString());
10597 }
10598 } else if (this.inline) {
10599 return this.decodeInline(this.annotation);
10600 } else if (this.annotation) {
10601 var map1 = this.annotation;
10602 if (file) map1 = join$1(dirname$1$1(file), map1);
10603 return this.loadFile(map1);
10604 }
10605 };
10606 _proto.startWith = function startWith(string, start) {
10607 if (!string) return false;
10608 return string.substr(0, start.length) === start;
10609 };
10610 _proto.withContent = function withContent() {
10611 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
10612 };
10613 return PreviousMap;
10614 }();
10615 var previousMap$1 = PreviousMap$2$1;
10616 PreviousMap$2$1.default = PreviousMap$2$1;
10617 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
10618 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
10619 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
10620 var nanoid$2 = nonSecure$1.nanoid;
10621 var terminalHighlight$2 = require$$2$1;
10622 var CssSyntaxError$1$1 = cssSyntaxError$1;
10623 var PreviousMap$1$1 = previousMap$1;
10624 var fromOffsetCache$1 = Symbol("fromOffsetCache");
10625 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
10626 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
10627 var Input$4$1 = /*#__PURE__*/ function() {
10628 function Input(css, opts) {
10629 if (opts === void 0) opts = {};
10630 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
10631 throw new Error("PostCSS received " + css + " instead of CSS string");
10632 }
10633 this.css = css.toString();
10634 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
10635 this.hasBOM = true;
10636 this.css = this.css.slice(1);
10637 } else {
10638 this.hasBOM = false;
10639 }
10640 if (opts.from) {
10641 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
10642 this.file = opts.from;
10643 } else {
10644 this.file = resolve$1$1(opts.from);
10645 }
10646 }
10647 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
10648 var map = new PreviousMap$1$1(this.css, opts);
10649 if (map.text) {
10650 this.map = map;
10651 var file = map.consumer().file;
10652 if (!this.file && file) this.file = this.mapResolve(file);
10653 }
10654 }
10655 if (!this.file) {
10656 this.id = "<input css " + nanoid$2(6) + ">";
10657 }
10658 if (this.map) this.map.file = this.from;
10659 }
10660 var _proto = Input.prototype;
10661 _proto.error = function error(message, line, column, opts) {
10662 if (opts === void 0) opts = {};
10663 var result2, endLine, endColumn;
10664 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
10665 var start = line;
10666 var end = column;
10667 if (typeof start.offset === "number") {
10668 var pos = this.fromOffset(start.offset);
10669 line = pos.line;
10670 column = pos.col;
10671 } else {
10672 line = start.line;
10673 column = start.column;
10674 }
10675 if (typeof end.offset === "number") {
10676 var pos1 = this.fromOffset(end.offset);
10677 endLine = pos1.line;
10678 endColumn = pos1.col;
10679 } else {
10680 endLine = end.line;
10681 endColumn = end.column;
10682 }
10683 } else if (!column) {
10684 var pos2 = this.fromOffset(line);
10685 line = pos2.line;
10686 column = pos2.col;
10687 }
10688 var origin = this.origin(line, column, endLine, endColumn);
10689 if (origin) {
10690 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
10691 column: origin.column,
10692 line: origin.line
10693 }, origin.endLine === void 0 ? origin.column : {
10694 column: origin.endColumn,
10695 line: origin.endLine
10696 }, origin.source, origin.file, opts.plugin);
10697 } else {
10698 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
10699 column: column,
10700 line: line
10701 }, endLine === void 0 ? column : {
10702 column: endColumn,
10703 line: endLine
10704 }, this.css, this.file, opts.plugin);
10705 }
10706 result2.input = {
10707 column: column,
10708 endColumn: endColumn,
10709 endLine: endLine,
10710 line: line,
10711 source: this.css
10712 };
10713 if (this.file) {
10714 if (pathToFileURL$1$1) {
10715 result2.input.url = pathToFileURL$1$1(this.file).toString();
10716 }
10717 result2.input.file = this.file;
10718 }
10719 return result2;
10720 };
10721 _proto.fromOffset = function fromOffset(offset) {
10722 var lastLine, lineToIndex;
10723 if (!this[fromOffsetCache$1]) {
10724 var lines = this.css.split("\n");
10725 lineToIndex = new Array(lines.length);
10726 var prevIndex = 0;
10727 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
10728 lineToIndex[i2] = prevIndex;
10729 prevIndex += lines[i2].length + 1;
10730 }
10731 this[fromOffsetCache$1] = lineToIndex;
10732 } else {
10733 lineToIndex = this[fromOffsetCache$1];
10734 }
10735 lastLine = lineToIndex[lineToIndex.length - 1];
10736 var min = 0;
10737 if (offset >= lastLine) {
10738 min = lineToIndex.length - 1;
10739 } else {
10740 var max = lineToIndex.length - 2;
10741 var mid;
10742 while(min < max){
10743 mid = min + (max - min >> 1);
10744 if (offset < lineToIndex[mid]) {
10745 max = mid - 1;
10746 } else if (offset >= lineToIndex[mid + 1]) {
10747 min = mid + 1;
10748 } else {
10749 min = mid;
10750 break;
10751 }
10752 }
10753 }
10754 return {
10755 col: offset - lineToIndex[min] + 1,
10756 line: min + 1
10757 };
10758 };
10759 _proto.mapResolve = function mapResolve(file) {
10760 if (/^\w+:\/\//.test(file)) {
10761 return file;
10762 }
10763 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
10764 };
10765 _proto.origin = function origin(line, column, endLine, endColumn) {
10766 if (!this.map) return false;
10767 var consumer = this.map.consumer();
10768 var from = consumer.originalPositionFor({
10769 column: column,
10770 line: line
10771 });
10772 if (!from.source) return false;
10773 var to;
10774 if (typeof endLine === "number") {
10775 to = consumer.originalPositionFor({
10776 column: endColumn,
10777 line: endLine
10778 });
10779 }
10780 var fromUrl;
10781 if (isAbsolute$1(from.source)) {
10782 fromUrl = pathToFileURL$1$1(from.source);
10783 } else {
10784 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
10785 }
10786 var result2 = {
10787 column: from.column,
10788 endColumn: to && to.column,
10789 endLine: to && to.line,
10790 line: from.line,
10791 url: fromUrl.toString()
10792 };
10793 if (fromUrl.protocol === "file:") {
10794 if (fileURLToPath$1) {
10795 result2.file = fileURLToPath$1(fromUrl);
10796 } else {
10797 throw new Error("file: protocol is not available in this PostCSS build");
10798 }
10799 }
10800 var source = consumer.sourceContentFor(from.source);
10801 if (source) result2.source = source;
10802 return result2;
10803 };
10804 _proto.toJSON = function toJSON() {
10805 var json = {};
10806 for(var _i = 0, _iter = [
10807 "hasBOM",
10808 "css",
10809 "file",
10810 "id"
10811 ]; _i < _iter.length; _i++){
10812 var name = _iter[_i];
10813 if (this[name] != null) {
10814 json[name] = this[name];
10815 }
10816 }
10817 if (this.map) {
10818 json.map = _extends({}, this.map);
10819 if (json.map.consumerCache) {
10820 json.map.consumerCache = void 0;
10821 }
10822 }
10823 return json;
10824 };
10825 _create_class(Input, [
10826 {
10827 key: "from",
10828 get: function get() {
10829 return this.file || this.id;
10830 }
10831 }
10832 ]);
10833 return Input;
10834 }();
10835 var input$1 = Input$4$1;
10836 Input$4$1.default = Input$4$1;
10837 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
10838 terminalHighlight$2.registerInput(Input$4$1);
10839 }
10840 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
10841 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;
10842 var pathToFileURL$2 = require$$2$1.pathToFileURL;
10843 var Input$3$1 = input$1;
10844 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
10845 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
10846 var MapGenerator$2$1 = /*#__PURE__*/ function() {
10847 function MapGenerator(stringify2, root2, opts, cssString) {
10848 this.stringify = stringify2;
10849 this.mapOpts = opts.map || {};
10850 this.root = root2;
10851 this.opts = opts;
10852 this.css = cssString;
10853 this.originalCSS = cssString;
10854 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
10855 this.memoizedFileURLs = /* @__PURE__ */ new Map();
10856 this.memoizedPaths = /* @__PURE__ */ new Map();
10857 this.memoizedURLs = /* @__PURE__ */ new Map();
10858 }
10859 var _proto = MapGenerator.prototype;
10860 _proto.addAnnotation = function addAnnotation() {
10861 var content;
10862 if (this.isInline()) {
10863 content = "data:application/json;base64," + this.toBase64(this.map.toString());
10864 } else if (typeof this.mapOpts.annotation === "string") {
10865 content = this.mapOpts.annotation;
10866 } else if (typeof this.mapOpts.annotation === "function") {
10867 content = this.mapOpts.annotation(this.opts.to, this.root);
10868 } else {
10869 content = this.outputFile() + ".map";
10870 }
10871 var eol = "\n";
10872 if (this.css.includes("\r\n")) eol = "\r\n";
10873 this.css += eol + "/*# sourceMappingURL=" + content + " */";
10874 };
10875 _proto.applyPrevMaps = function applyPrevMaps() {
10876 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
10877 var prev = _step.value;
10878 var from = this.toUrl(this.path(prev.file));
10879 var root2 = prev.root || dirname$2(prev.file);
10880 var map = void 0;
10881 if (this.mapOpts.sourcesContent === false) {
10882 map = new SourceMapConsumer$3(prev.text);
10883 if (map.sourcesContent) {
10884 map.sourcesContent = null;
10885 }
10886 } else {
10887 map = prev.consumer();
10888 }
10889 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
10890 }
10891 };
10892 _proto.clearAnnotation = function clearAnnotation() {
10893 if (this.mapOpts.annotation === false) return;
10894 if (this.root) {
10895 var node2;
10896 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
10897 node2 = this.root.nodes[i2];
10898 if (node2.type !== "comment") continue;
10899 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
10900 this.root.removeChild(i2);
10901 }
10902 }
10903 } else if (this.css) {
10904 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
10905 }
10906 };
10907 _proto.generate = function generate() {
10908 this.clearAnnotation();
10909 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
10910 return this.generateMap();
10911 } else {
10912 var result2 = "";
10913 this.stringify(this.root, function(i2) {
10914 result2 += i2;
10915 });
10916 return [
10917 result2
10918 ];
10919 }
10920 };
10921 _proto.generateMap = function generateMap() {
10922 if (this.root) {
10923 this.generateString();
10924 } else if (this.previous().length === 1) {
10925 var prev = this.previous()[0].consumer();
10926 prev.file = this.outputFile();
10927 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
10928 ignoreInvalidMapping: true
10929 });
10930 } else {
10931 this.map = new SourceMapGenerator$3({
10932 file: this.outputFile(),
10933 ignoreInvalidMapping: true
10934 });
10935 this.map.addMapping({
10936 generated: {
10937 column: 0,
10938 line: 1
10939 },
10940 original: {
10941 column: 0,
10942 line: 1
10943 },
10944 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
10945 });
10946 }
10947 if (this.isSourcesContent()) this.setSourcesContent();
10948 if (this.root && this.previous().length > 0) this.applyPrevMaps();
10949 if (this.isAnnotation()) this.addAnnotation();
10950 if (this.isInline()) {
10951 return [
10952 this.css
10953 ];
10954 } else {
10955 return [
10956 this.css,
10957 this.map
10958 ];
10959 }
10960 };
10961 _proto.generateString = function generateString() {
10962 var _this = this;
10963 this.css = "";
10964 this.map = new SourceMapGenerator$3({
10965 file: this.outputFile(),
10966 ignoreInvalidMapping: true
10967 });
10968 var line = 1;
10969 var column = 1;
10970 var noSource = "<no source>";
10971 var mapping = {
10972 generated: {
10973 column: 0,
10974 line: 0
10975 },
10976 original: {
10977 column: 0,
10978 line: 0
10979 },
10980 source: ""
10981 };
10982 var lines, last;
10983 this.stringify(this.root, function(str, node2, type) {
10984 _this.css += str;
10985 if (node2 && type !== "end") {
10986 mapping.generated.line = line;
10987 mapping.generated.column = column - 1;
10988 if (node2.source && node2.source.start) {
10989 mapping.source = _this.sourcePath(node2);
10990 mapping.original.line = node2.source.start.line;
10991 mapping.original.column = node2.source.start.column - 1;
10992 _this.map.addMapping(mapping);
10993 } else {
10994 mapping.source = noSource;
10995 mapping.original.line = 1;
10996 mapping.original.column = 0;
10997 _this.map.addMapping(mapping);
10998 }
10999 }
11000 lines = str.match(/\n/g);
11001 if (lines) {
11002 line += lines.length;
11003 last = str.lastIndexOf("\n");
11004 column = str.length - last;
11005 } else {
11006 column += str.length;
11007 }
11008 if (node2 && type !== "start") {
11009 var p = node2.parent || {
11010 raws: {}
11011 };
11012 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11013 if (!childless || node2 !== p.last || p.raws.semicolon) {
11014 if (node2.source && node2.source.end) {
11015 mapping.source = _this.sourcePath(node2);
11016 mapping.original.line = node2.source.end.line;
11017 mapping.original.column = node2.source.end.column - 1;
11018 mapping.generated.line = line;
11019 mapping.generated.column = column - 2;
11020 _this.map.addMapping(mapping);
11021 } else {
11022 mapping.source = noSource;
11023 mapping.original.line = 1;
11024 mapping.original.column = 0;
11025 mapping.generated.line = line;
11026 mapping.generated.column = column - 1;
11027 _this.map.addMapping(mapping);
11028 }
11029 }
11030 }
11031 });
11032 };
11033 _proto.isAnnotation = function isAnnotation() {
11034 if (this.isInline()) {
11035 return true;
11036 }
11037 if (typeof this.mapOpts.annotation !== "undefined") {
11038 return this.mapOpts.annotation;
11039 }
11040 if (this.previous().length) {
11041 return this.previous().some(function(i2) {
11042 return i2.annotation;
11043 });
11044 }
11045 return true;
11046 };
11047 _proto.isInline = function isInline() {
11048 if (typeof this.mapOpts.inline !== "undefined") {
11049 return this.mapOpts.inline;
11050 }
11051 var annotation = this.mapOpts.annotation;
11052 if (typeof annotation !== "undefined" && annotation !== true) {
11053 return false;
11054 }
11055 if (this.previous().length) {
11056 return this.previous().some(function(i2) {
11057 return i2.inline;
11058 });
11059 }
11060 return true;
11061 };
11062 _proto.isMap = function isMap() {
11063 if (typeof this.opts.map !== "undefined") {
11064 return !!this.opts.map;
11065 }
11066 return this.previous().length > 0;
11067 };
11068 _proto.isSourcesContent = function isSourcesContent() {
11069 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11070 return this.mapOpts.sourcesContent;
11071 }
11072 if (this.previous().length) {
11073 return this.previous().some(function(i2) {
11074 return i2.withContent();
11075 });
11076 }
11077 return true;
11078 };
11079 _proto.outputFile = function outputFile() {
11080 if (this.opts.to) {
11081 return this.path(this.opts.to);
11082 } else if (this.opts.from) {
11083 return this.path(this.opts.from);
11084 } else {
11085 return "to.css";
11086 }
11087 };
11088 _proto.path = function path(file) {
11089 if (this.mapOpts.absolute) return file;
11090 if (file.charCodeAt(0) === 60) return file;
11091 if (/^\w+:\/\//.test(file)) return file;
11092 var cached = this.memoizedPaths.get(file);
11093 if (cached) return cached;
11094 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11095 if (typeof this.mapOpts.annotation === "string") {
11096 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11097 }
11098 var path = relative$1(from, file);
11099 this.memoizedPaths.set(file, path);
11100 return path;
11101 };
11102 _proto.previous = function previous() {
11103 var _this = this;
11104 if (!this.previousMaps) {
11105 this.previousMaps = [];
11106 if (this.root) {
11107 this.root.walk(function(node2) {
11108 if (node2.source && node2.source.input.map) {
11109 var map = node2.source.input.map;
11110 if (!_this.previousMaps.includes(map)) {
11111 _this.previousMaps.push(map);
11112 }
11113 }
11114 });
11115 } else {
11116 var input2 = new Input$3$1(this.originalCSS, this.opts);
11117 if (input2.map) this.previousMaps.push(input2.map);
11118 }
11119 }
11120 return this.previousMaps;
11121 };
11122 _proto.setSourcesContent = function setSourcesContent() {
11123 var _this = this;
11124 var already = {};
11125 if (this.root) {
11126 this.root.walk(function(node2) {
11127 if (node2.source) {
11128 var from = node2.source.input.from;
11129 if (from && !already[from]) {
11130 already[from] = true;
11131 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11132 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11133 }
11134 }
11135 });
11136 } else if (this.css) {
11137 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11138 this.map.setSourceContent(from, this.css);
11139 }
11140 };
11141 _proto.sourcePath = function sourcePath(node2) {
11142 if (this.mapOpts.from) {
11143 return this.toUrl(this.mapOpts.from);
11144 } else if (this.usesFileUrls) {
11145 return this.toFileUrl(node2.source.input.from);
11146 } else {
11147 return this.toUrl(this.path(node2.source.input.from));
11148 }
11149 };
11150 _proto.toBase64 = function toBase64(str) {
11151 if (Buffer) {
11152 return Buffer.from(str).toString("base64");
11153 } else {
11154 return window.btoa(unescape(encodeURIComponent(str)));
11155 }
11156 };
11157 _proto.toFileUrl = function toFileUrl(path) {
11158 var cached = this.memoizedFileURLs.get(path);
11159 if (cached) return cached;
11160 if (pathToFileURL$2) {
11161 var fileURL = pathToFileURL$2(path).toString();
11162 this.memoizedFileURLs.set(path, fileURL);
11163 return fileURL;
11164 } else {
11165 throw new Error("`map.absolute` option is not available in this PostCSS build");
11166 }
11167 };
11168 _proto.toUrl = function toUrl(path) {
11169 var cached = this.memoizedURLs.get(path);
11170 if (cached) return cached;
11171 if (sep$1 === "\\") {
11172 path = path.replace(/\\/g, "/");
11173 }
11174 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
11175 this.memoizedURLs.set(path, url);
11176 return url;
11177 };
11178 return MapGenerator;
11179 }();
11180 var mapGenerator$1 = MapGenerator$2$1;
11181 var Node$2$1 = node$1;
11182 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
11183 _inherits(Comment, Node$2$1);
11184 function Comment(defaults) {
11185 var _this;
11186 _this = Node$2$1.call(this, defaults) || this;
11187 _this.type = "comment";
11188 return _this;
11189 }
11190 return Comment;
11191 }(Node$2$1);
11192 var comment$1 = Comment$4$1;
11193 Comment$4$1.default = Comment$4$1;
11194 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
11195 var Declaration$3$1 = declaration$1;
11196 var Comment$3$1 = comment$1;
11197 var Node$1$1 = node$1;
11198 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
11199 function cleanSource$1(nodes) {
11200 return nodes.map(function(i2) {
11201 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
11202 delete i2.source;
11203 return i2;
11204 });
11205 }
11206 function markDirtyUp$1(node2) {
11207 node2[isClean$1$1] = false;
11208 if (node2.proxyOf.nodes) {
11209 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11210 var i2 = _step.value;
11211 markDirtyUp$1(i2);
11212 }
11213 }
11214 }
11215 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
11216 _inherits(Container, Node$1$1);
11217 function Container() {
11218 return Node$1$1.apply(this, arguments) || this;
11219 }
11220 var _proto = Container.prototype;
11221 _proto.append = function append() {
11222 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11223 children[_key] = arguments[_key];
11224 }
11225 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11226 var child = _step.value;
11227 var nodes = this.normalize(child, this.last);
11228 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11229 var node2 = _step1.value;
11230 this.proxyOf.nodes.push(node2);
11231 }
11232 }
11233 this.markDirty();
11234 return this;
11235 };
11236 _proto.cleanRaws = function cleanRaws(keepBetween) {
11237 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
11238 if (this.nodes) {
11239 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
11240 var node2 = _step.value;
11241 node2.cleanRaws(keepBetween);
11242 }
11243 }
11244 };
11245 _proto.each = function each(callback) {
11246 if (!this.proxyOf.nodes) return void 0;
11247 var iterator = this.getIterator();
11248 var index2, result2;
11249 while(this.indexes[iterator] < this.proxyOf.nodes.length){
11250 index2 = this.indexes[iterator];
11251 result2 = callback(this.proxyOf.nodes[index2], index2);
11252 if (result2 === false) break;
11253 this.indexes[iterator] += 1;
11254 }
11255 delete this.indexes[iterator];
11256 return result2;
11257 };
11258 _proto.every = function every(condition) {
11259 return this.nodes.every(condition);
11260 };
11261 _proto.getIterator = function getIterator() {
11262 if (!this.lastEach) this.lastEach = 0;
11263 if (!this.indexes) this.indexes = {};
11264 this.lastEach += 1;
11265 var iterator = this.lastEach;
11266 this.indexes[iterator] = 0;
11267 return iterator;
11268 };
11269 _proto.getProxyProcessor = function getProxyProcessor() {
11270 return {
11271 get: function get(node2, prop) {
11272 if (prop === "proxyOf") {
11273 return node2;
11274 } else if (!node2[prop]) {
11275 return node2[prop];
11276 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
11277 return function() {
11278 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
11279 args[_key] = arguments[_key];
11280 }
11281 var _node2;
11282 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
11283 if (typeof i2 === "function") {
11284 return function(child, index2) {
11285 return i2(child.toProxy(), index2);
11286 };
11287 } else {
11288 return i2;
11289 }
11290 })));
11291 };
11292 } else if (prop === "every" || prop === "some") {
11293 return function(cb) {
11294 return node2[prop](function(child) {
11295 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
11296 other[_key - 1] = arguments[_key];
11297 }
11298 return cb.apply(void 0, [].concat([
11299 child.toProxy()
11300 ], other));
11301 });
11302 };
11303 } else if (prop === "root") {
11304 return function() {
11305 return node2.root().toProxy();
11306 };
11307 } else if (prop === "nodes") {
11308 return node2.nodes.map(function(i2) {
11309 return i2.toProxy();
11310 });
11311 } else if (prop === "first" || prop === "last") {
11312 return node2[prop].toProxy();
11313 } else {
11314 return node2[prop];
11315 }
11316 },
11317 set: function set(node2, prop, value) {
11318 if (node2[prop] === value) return true;
11319 node2[prop] = value;
11320 if (prop === "name" || prop === "params" || prop === "selector") {
11321 node2.markDirty();
11322 }
11323 return true;
11324 }
11325 };
11326 };
11327 _proto.index = function index(child) {
11328 if (typeof child === "number") return child;
11329 if (child.proxyOf) child = child.proxyOf;
11330 return this.proxyOf.nodes.indexOf(child);
11331 };
11332 _proto.insertAfter = function insertAfter(exist, add) {
11333 var existIndex = this.index(exist);
11334 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
11335 existIndex = this.index(exist);
11336 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11337 var node2 = _step.value;
11338 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
11339 }
11340 var index2;
11341 for(var id in this.indexes){
11342 index2 = this.indexes[id];
11343 if (existIndex < index2) {
11344 this.indexes[id] = index2 + nodes.length;
11345 }
11346 }
11347 this.markDirty();
11348 return this;
11349 };
11350 _proto.insertBefore = function insertBefore(exist, add) {
11351 var existIndex = this.index(exist);
11352 var type = existIndex === 0 ? "prepend" : false;
11353 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
11354 existIndex = this.index(exist);
11355 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11356 var node2 = _step.value;
11357 this.proxyOf.nodes.splice(existIndex, 0, node2);
11358 }
11359 var index2;
11360 for(var id in this.indexes){
11361 index2 = this.indexes[id];
11362 if (existIndex <= index2) {
11363 this.indexes[id] = index2 + nodes.length;
11364 }
11365 }
11366 this.markDirty();
11367 return this;
11368 };
11369 _proto.normalize = function normalize(nodes, sample) {
11370 var _this = this;
11371 if (typeof nodes === "string") {
11372 nodes = cleanSource$1(parse$4$1(nodes).nodes);
11373 } else if (typeof nodes === "undefined") {
11374 nodes = [];
11375 } else if (Array.isArray(nodes)) {
11376 nodes = nodes.slice(0);
11377 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11378 var i2 = _step.value;
11379 if (i2.parent) i2.parent.removeChild(i2, "ignore");
11380 }
11381 } else if (nodes.type === "root" && this.type !== "document") {
11382 nodes = nodes.nodes.slice(0);
11383 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11384 var i21 = _step1.value;
11385 if (i21.parent) i21.parent.removeChild(i21, "ignore");
11386 }
11387 } else if (nodes.type) {
11388 nodes = [
11389 nodes
11390 ];
11391 } else if (nodes.prop) {
11392 if (typeof nodes.value === "undefined") {
11393 throw new Error("Value field is missed in node creation");
11394 } else if (typeof nodes.value !== "string") {
11395 nodes.value = String(nodes.value);
11396 }
11397 nodes = [
11398 new Declaration$3$1(nodes)
11399 ];
11400 } else if (nodes.selector) {
11401 nodes = [
11402 new Rule$4$1(nodes)
11403 ];
11404 } else if (nodes.name) {
11405 nodes = [
11406 new AtRule$4$1(nodes)
11407 ];
11408 } else if (nodes.text) {
11409 nodes = [
11410 new Comment$3$1(nodes)
11411 ];
11412 } else {
11413 throw new Error("Unknown node type in node creation");
11414 }
11415 var processed = nodes.map(function(i2) {
11416 if (!i2[my$1$1]) Container.rebuild(i2);
11417 i2 = i2.proxyOf;
11418 if (i2.parent) i2.parent.removeChild(i2);
11419 if (i2[isClean$1$1]) markDirtyUp$1(i2);
11420 if (typeof i2.raws.before === "undefined") {
11421 if (sample && typeof sample.raws.before !== "undefined") {
11422 i2.raws.before = sample.raws.before.replace(/\S/g, "");
11423 }
11424 }
11425 i2.parent = _this.proxyOf;
11426 return i2;
11427 });
11428 return processed;
11429 };
11430 _proto.prepend = function prepend() {
11431 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
11432 children[_key] = arguments[_key];
11433 }
11434 children = children.reverse();
11435 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
11436 var child = _step.value;
11437 var nodes = this.normalize(child, this.first, "prepend").reverse();
11438 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
11439 var node2 = _step1.value;
11440 this.proxyOf.nodes.unshift(node2);
11441 }
11442 for(var id in this.indexes){
11443 this.indexes[id] = this.indexes[id] + nodes.length;
11444 }
11445 }
11446 this.markDirty();
11447 return this;
11448 };
11449 _proto.push = function push(child) {
11450 child.parent = this;
11451 this.proxyOf.nodes.push(child);
11452 return this;
11453 };
11454 _proto.removeAll = function removeAll() {
11455 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
11456 var node2 = _step.value;
11457 node2.parent = void 0;
11458 }
11459 this.proxyOf.nodes = [];
11460 this.markDirty();
11461 return this;
11462 };
11463 _proto.removeChild = function removeChild(child) {
11464 child = this.index(child);
11465 this.proxyOf.nodes[child].parent = void 0;
11466 this.proxyOf.nodes.splice(child, 1);
11467 var index2;
11468 for(var id in this.indexes){
11469 index2 = this.indexes[id];
11470 if (index2 >= child) {
11471 this.indexes[id] = index2 - 1;
11472 }
11473 }
11474 this.markDirty();
11475 return this;
11476 };
11477 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
11478 if (!callback) {
11479 callback = opts;
11480 opts = {};
11481 }
11482 this.walkDecls(function(decl) {
11483 if (opts.props && !opts.props.includes(decl.prop)) return;
11484 if (opts.fast && !decl.value.includes(opts.fast)) return;
11485 decl.value = decl.value.replace(pattern, callback);
11486 });
11487 this.markDirty();
11488 return this;
11489 };
11490 _proto.some = function some(condition) {
11491 return this.nodes.some(condition);
11492 };
11493 _proto.walk = function walk(callback) {
11494 return this.each(function(child, i2) {
11495 var result2;
11496 try {
11497 result2 = callback(child, i2);
11498 } catch (e2) {
11499 throw child.addToError(e2);
11500 }
11501 if (result2 !== false && child.walk) {
11502 result2 = child.walk(callback);
11503 }
11504 return result2;
11505 });
11506 };
11507 _proto.walkAtRules = function walkAtRules(name, callback) {
11508 if (!callback) {
11509 callback = name;
11510 return this.walk(function(child, i2) {
11511 if (child.type === "atrule") {
11512 return callback(child, i2);
11513 }
11514 });
11515 }
11516 if (_instanceof(name, RegExp)) {
11517 return this.walk(function(child, i2) {
11518 if (child.type === "atrule" && name.test(child.name)) {
11519 return callback(child, i2);
11520 }
11521 });
11522 }
11523 return this.walk(function(child, i2) {
11524 if (child.type === "atrule" && child.name === name) {
11525 return callback(child, i2);
11526 }
11527 });
11528 };
11529 _proto.walkComments = function walkComments(callback) {
11530 return this.walk(function(child, i2) {
11531 if (child.type === "comment") {
11532 return callback(child, i2);
11533 }
11534 });
11535 };
11536 _proto.walkDecls = function walkDecls(prop, callback) {
11537 if (!callback) {
11538 callback = prop;
11539 return this.walk(function(child, i2) {
11540 if (child.type === "decl") {
11541 return callback(child, i2);
11542 }
11543 });
11544 }
11545 if (_instanceof(prop, RegExp)) {
11546 return this.walk(function(child, i2) {
11547 if (child.type === "decl" && prop.test(child.prop)) {
11548 return callback(child, i2);
11549 }
11550 });
11551 }
11552 return this.walk(function(child, i2) {
11553 if (child.type === "decl" && child.prop === prop) {
11554 return callback(child, i2);
11555 }
11556 });
11557 };
11558 _proto.walkRules = function walkRules(selector, callback) {
11559 if (!callback) {
11560 callback = selector;
11561 return this.walk(function(child, i2) {
11562 if (child.type === "rule") {
11563 return callback(child, i2);
11564 }
11565 });
11566 }
11567 if (_instanceof(selector, RegExp)) {
11568 return this.walk(function(child, i2) {
11569 if (child.type === "rule" && selector.test(child.selector)) {
11570 return callback(child, i2);
11571 }
11572 });
11573 }
11574 return this.walk(function(child, i2) {
11575 if (child.type === "rule" && child.selector === selector) {
11576 return callback(child, i2);
11577 }
11578 });
11579 };
11580 _create_class(Container, [
11581 {
11582 key: "first",
11583 get: function get() {
11584 if (!this.proxyOf.nodes) return void 0;
11585 return this.proxyOf.nodes[0];
11586 }
11587 },
11588 {
11589 key: "last",
11590 get: function get() {
11591 if (!this.proxyOf.nodes) return void 0;
11592 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
11593 }
11594 }
11595 ]);
11596 return Container;
11597 }(Node$1$1);
11598 Container$7$1.registerParse = function(dependant) {
11599 parse$4$1 = dependant;
11600 };
11601 Container$7$1.registerRule = function(dependant) {
11602 Rule$4$1 = dependant;
11603 };
11604 Container$7$1.registerAtRule = function(dependant) {
11605 AtRule$4$1 = dependant;
11606 };
11607 Container$7$1.registerRoot = function(dependant) {
11608 Root$6$1 = dependant;
11609 };
11610 var container$1 = Container$7$1;
11611 Container$7$1.default = Container$7$1;
11612 Container$7$1.rebuild = function(node2) {
11613 if (node2.type === "atrule") {
11614 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
11615 } else if (node2.type === "rule") {
11616 Object.setPrototypeOf(node2, Rule$4$1.prototype);
11617 } else if (node2.type === "decl") {
11618 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
11619 } else if (node2.type === "comment") {
11620 Object.setPrototypeOf(node2, Comment$3$1.prototype);
11621 } else if (node2.type === "root") {
11622 Object.setPrototypeOf(node2, Root$6$1.prototype);
11623 }
11624 node2[my$1$1] = true;
11625 if (node2.nodes) {
11626 node2.nodes.forEach(function(child) {
11627 Container$7$1.rebuild(child);
11628 });
11629 }
11630 };
11631 var Container$6$1 = container$1;
11632 var LazyResult$4$1, Processor$3$1;
11633 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
11634 _inherits(Document2, Container$6$1);
11635 function Document2(defaults) {
11636 var _this;
11637 _this = Container$6$1.call(this, _extends({
11638 type: "document"
11639 }, defaults)) || this;
11640 if (!_this.nodes) {
11641 _this.nodes = [];
11642 }
11643 return _this;
11644 }
11645 var _proto = Document2.prototype;
11646 _proto.toResult = function toResult(opts) {
11647 if (opts === void 0) opts = {};
11648 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
11649 return lazy.stringify();
11650 };
11651 return Document2;
11652 }(Container$6$1);
11653 Document$3$1.registerLazyResult = function(dependant) {
11654 LazyResult$4$1 = dependant;
11655 };
11656 Document$3$1.registerProcessor = function(dependant) {
11657 Processor$3$1 = dependant;
11658 };
11659 var document$1$1 = Document$3$1;
11660 Document$3$1.default = Document$3$1;
11661 var printed$1 = {};
11662 var warnOnce$2$1 = function warnOnce(message) {
11663 if (printed$1[message]) return;
11664 printed$1[message] = true;
11665 if (typeof console !== "undefined" && console.warn) {
11666 console.warn(message);
11667 }
11668 };
11669 var Warning$2$1 = /*#__PURE__*/ function() {
11670 function Warning(text, opts) {
11671 if (opts === void 0) opts = {};
11672 this.type = "warning";
11673 this.text = text;
11674 if (opts.node && opts.node.source) {
11675 var range = opts.node.rangeBy(opts);
11676 this.line = range.start.line;
11677 this.column = range.start.column;
11678 this.endLine = range.end.line;
11679 this.endColumn = range.end.column;
11680 }
11681 for(var opt in opts)this[opt] = opts[opt];
11682 }
11683 var _proto = Warning.prototype;
11684 _proto.toString = function toString() {
11685 if (this.node) {
11686 return this.node.error(this.text, {
11687 index: this.index,
11688 plugin: this.plugin,
11689 word: this.word
11690 }).message;
11691 }
11692 if (this.plugin) {
11693 return this.plugin + ": " + this.text;
11694 }
11695 return this.text;
11696 };
11697 return Warning;
11698 }();
11699 var warning$1 = Warning$2$1;
11700 Warning$2$1.default = Warning$2$1;
11701 var Warning$1$1 = warning$1;
11702 var Result$3$1 = /*#__PURE__*/ function() {
11703 function Result(processor2, root2, opts) {
11704 this.processor = processor2;
11705 this.messages = [];
11706 this.root = root2;
11707 this.opts = opts;
11708 this.css = void 0;
11709 this.map = void 0;
11710 }
11711 var _proto = Result.prototype;
11712 _proto.toString = function toString() {
11713 return this.css;
11714 };
11715 _proto.warn = function warn(text, opts) {
11716 if (opts === void 0) opts = {};
11717 if (!opts.plugin) {
11718 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
11719 opts.plugin = this.lastPlugin.postcssPlugin;
11720 }
11721 }
11722 var warning2 = new Warning$1$1(text, opts);
11723 this.messages.push(warning2);
11724 return warning2;
11725 };
11726 _proto.warnings = function warnings() {
11727 return this.messages.filter(function(i2) {
11728 return i2.type === "warning";
11729 });
11730 };
11731 _create_class(Result, [
11732 {
11733 key: "content",
11734 get: function get() {
11735 return this.css;
11736 }
11737 }
11738 ]);
11739 return Result;
11740 }();
11741 var result$1 = Result$3$1;
11742 Result$3$1.default = Result$3$1;
11743 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
11744 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
11745 var BACKSLASH$1 = "\\".charCodeAt(0);
11746 var SLASH$1 = "/".charCodeAt(0);
11747 var NEWLINE$1 = "\n".charCodeAt(0);
11748 var SPACE$1 = " ".charCodeAt(0);
11749 var FEED$1 = "\f".charCodeAt(0);
11750 var TAB$1 = " ".charCodeAt(0);
11751 var CR$1 = "\r".charCodeAt(0);
11752 var OPEN_SQUARE$1 = "[".charCodeAt(0);
11753 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
11754 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
11755 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
11756 var OPEN_CURLY$1 = "{".charCodeAt(0);
11757 var CLOSE_CURLY$1 = "}".charCodeAt(0);
11758 var SEMICOLON$1 = ";".charCodeAt(0);
11759 var ASTERISK$1 = "*".charCodeAt(0);
11760 var COLON$1 = ":".charCodeAt(0);
11761 var AT$1 = "@".charCodeAt(0);
11762 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
11763 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
11764 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
11765 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
11766 var tokenize$1 = function tokenizer(input2, options) {
11767 if (options === void 0) options = {};
11768 var css = input2.css.valueOf();
11769 var ignore = options.ignoreErrors;
11770 var code, next, quote, content, escape;
11771 var escaped, escapePos, prev, n2, currentToken;
11772 var length = css.length;
11773 var pos = 0;
11774 var buffer = [];
11775 var returned = [];
11776 function position() {
11777 return pos;
11778 }
11779 function unclosed(what) {
11780 throw input2.error("Unclosed " + what, pos);
11781 }
11782 function endOfFile() {
11783 return returned.length === 0 && pos >= length;
11784 }
11785 function nextToken(opts) {
11786 if (returned.length) return returned.pop();
11787 if (pos >= length) return;
11788 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
11789 code = css.charCodeAt(pos);
11790 switch(code){
11791 case NEWLINE$1:
11792 case SPACE$1:
11793 case TAB$1:
11794 case CR$1:
11795 case FEED$1:
11796 {
11797 next = pos;
11798 do {
11799 next += 1;
11800 code = css.charCodeAt(next);
11801 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
11802 currentToken = [
11803 "space",
11804 css.slice(pos, next)
11805 ];
11806 pos = next - 1;
11807 break;
11808 }
11809 case OPEN_SQUARE$1:
11810 case CLOSE_SQUARE$1:
11811 case OPEN_CURLY$1:
11812 case CLOSE_CURLY$1:
11813 case COLON$1:
11814 case SEMICOLON$1:
11815 case CLOSE_PARENTHESES$1:
11816 {
11817 var controlChar = String.fromCharCode(code);
11818 currentToken = [
11819 controlChar,
11820 controlChar,
11821 pos
11822 ];
11823 break;
11824 }
11825 case OPEN_PARENTHESES$1:
11826 {
11827 prev = buffer.length ? buffer.pop()[1] : "";
11828 n2 = css.charCodeAt(pos + 1);
11829 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) {
11830 next = pos;
11831 do {
11832 escaped = false;
11833 next = css.indexOf(")", next + 1);
11834 if (next === -1) {
11835 if (ignore || ignoreUnclosed) {
11836 next = pos;
11837 break;
11838 } else {
11839 unclosed("bracket");
11840 }
11841 }
11842 escapePos = next;
11843 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
11844 escapePos -= 1;
11845 escaped = !escaped;
11846 }
11847 }while (escaped);
11848 currentToken = [
11849 "brackets",
11850 css.slice(pos, next + 1),
11851 pos,
11852 next
11853 ];
11854 pos = next;
11855 } else {
11856 next = css.indexOf(")", pos + 1);
11857 content = css.slice(pos, next + 1);
11858 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
11859 currentToken = [
11860 "(",
11861 "(",
11862 pos
11863 ];
11864 } else {
11865 currentToken = [
11866 "brackets",
11867 content,
11868 pos,
11869 next
11870 ];
11871 pos = next;
11872 }
11873 }
11874 break;
11875 }
11876 case SINGLE_QUOTE$1:
11877 case DOUBLE_QUOTE$1:
11878 {
11879 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
11880 next = pos;
11881 do {
11882 escaped = false;
11883 next = css.indexOf(quote, next + 1);
11884 if (next === -1) {
11885 if (ignore || ignoreUnclosed) {
11886 next = pos + 1;
11887 break;
11888 } else {
11889 unclosed("string");
11890 }
11891 }
11892 escapePos = next;
11893 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
11894 escapePos -= 1;
11895 escaped = !escaped;
11896 }
11897 }while (escaped);
11898 currentToken = [
11899 "string",
11900 css.slice(pos, next + 1),
11901 pos,
11902 next
11903 ];
11904 pos = next;
11905 break;
11906 }
11907 case AT$1:
11908 {
11909 RE_AT_END$1.lastIndex = pos + 1;
11910 RE_AT_END$1.test(css);
11911 if (RE_AT_END$1.lastIndex === 0) {
11912 next = css.length - 1;
11913 } else {
11914 next = RE_AT_END$1.lastIndex - 2;
11915 }
11916 currentToken = [
11917 "at-word",
11918 css.slice(pos, next + 1),
11919 pos,
11920 next
11921 ];
11922 pos = next;
11923 break;
11924 }
11925 case BACKSLASH$1:
11926 {
11927 next = pos;
11928 escape = true;
11929 while(css.charCodeAt(next + 1) === BACKSLASH$1){
11930 next += 1;
11931 escape = !escape;
11932 }
11933 code = css.charCodeAt(next + 1);
11934 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
11935 next += 1;
11936 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
11937 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
11938 next += 1;
11939 }
11940 if (css.charCodeAt(next + 1) === SPACE$1) {
11941 next += 1;
11942 }
11943 }
11944 }
11945 currentToken = [
11946 "word",
11947 css.slice(pos, next + 1),
11948 pos,
11949 next
11950 ];
11951 pos = next;
11952 break;
11953 }
11954 default:
11955 {
11956 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
11957 next = css.indexOf("*/", pos + 2) + 1;
11958 if (next === 0) {
11959 if (ignore || ignoreUnclosed) {
11960 next = css.length;
11961 } else {
11962 unclosed("comment");
11963 }
11964 }
11965 currentToken = [
11966 "comment",
11967 css.slice(pos, next + 1),
11968 pos,
11969 next
11970 ];
11971 pos = next;
11972 } else {
11973 RE_WORD_END$1.lastIndex = pos + 1;
11974 RE_WORD_END$1.test(css);
11975 if (RE_WORD_END$1.lastIndex === 0) {
11976 next = css.length - 1;
11977 } else {
11978 next = RE_WORD_END$1.lastIndex - 2;
11979 }
11980 currentToken = [
11981 "word",
11982 css.slice(pos, next + 1),
11983 pos,
11984 next
11985 ];
11986 buffer.push(currentToken);
11987 pos = next;
11988 }
11989 break;
11990 }
11991 }
11992 pos++;
11993 return currentToken;
11994 }
11995 function back(token) {
11996 returned.push(token);
11997 }
11998 return {
11999 back: back,
12000 endOfFile: endOfFile,
12001 nextToken: nextToken,
12002 position: position
12003 };
12004 };
12005 var Container$5$1 = container$1;
12006 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12007 _inherits(AtRule, Container$5$1);
12008 function AtRule(defaults) {
12009 var _this;
12010 _this = Container$5$1.call(this, defaults) || this;
12011 _this.type = "atrule";
12012 return _this;
12013 }
12014 var _proto = AtRule.prototype;
12015 _proto.append = function append() {
12016 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12017 children[_key] = arguments[_key];
12018 }
12019 var _Container$5$1_prototype_append;
12020 if (!this.proxyOf.nodes) this.nodes = [];
12021 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12022 this
12023 ], children));
12024 };
12025 _proto.prepend = function prepend() {
12026 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12027 children[_key] = arguments[_key];
12028 }
12029 var _Container$5$1_prototype_prepend;
12030 if (!this.proxyOf.nodes) this.nodes = [];
12031 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12032 this
12033 ], children));
12034 };
12035 return AtRule;
12036 }(Container$5$1);
12037 var atRule$1 = AtRule$3$1;
12038 AtRule$3$1.default = AtRule$3$1;
12039 Container$5$1.registerAtRule(AtRule$3$1);
12040 var Container$4$1 = container$1;
12041 var LazyResult$3$1, Processor$2$1;
12042 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12043 _inherits(Root, Container$4$1);
12044 function Root(defaults) {
12045 var _this;
12046 _this = Container$4$1.call(this, defaults) || this;
12047 _this.type = "root";
12048 if (!_this.nodes) _this.nodes = [];
12049 return _this;
12050 }
12051 var _proto = Root.prototype;
12052 _proto.normalize = function normalize(child, sample, type) {
12053 var nodes = Container$4$1.prototype.normalize.call(this, child);
12054 if (sample) {
12055 if (type === "prepend") {
12056 if (this.nodes.length > 1) {
12057 sample.raws.before = this.nodes[1].raws.before;
12058 } else {
12059 delete sample.raws.before;
12060 }
12061 } else if (this.first !== sample) {
12062 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12063 var node2 = _step.value;
12064 node2.raws.before = sample.raws.before;
12065 }
12066 }
12067 }
12068 return nodes;
12069 };
12070 _proto.removeChild = function removeChild(child, ignore) {
12071 var index2 = this.index(child);
12072 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12073 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12074 }
12075 return Container$4$1.prototype.removeChild.call(this, child);
12076 };
12077 _proto.toResult = function toResult(opts) {
12078 if (opts === void 0) opts = {};
12079 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12080 return lazy.stringify();
12081 };
12082 return Root;
12083 }(Container$4$1);
12084 Root$5$1.registerLazyResult = function(dependant) {
12085 LazyResult$3$1 = dependant;
12086 };
12087 Root$5$1.registerProcessor = function(dependant) {
12088 Processor$2$1 = dependant;
12089 };
12090 var root$1 = Root$5$1;
12091 Root$5$1.default = Root$5$1;
12092 Container$4$1.registerRoot(Root$5$1);
12093 var list$2$1 = {
12094 comma: function comma(string) {
12095 return list$2$1.split(string, [
12096 ","
12097 ], true);
12098 },
12099 space: function space(string) {
12100 var spaces = [
12101 " ",
12102 "\n",
12103 " "
12104 ];
12105 return list$2$1.split(string, spaces);
12106 },
12107 split: function split(string, separators, last) {
12108 var array = [];
12109 var current = "";
12110 var split = false;
12111 var func = 0;
12112 var inQuote = false;
12113 var prevQuote = "";
12114 var escape = false;
12115 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12116 var letter = _step.value;
12117 if (escape) {
12118 escape = false;
12119 } else if (letter === "\\") {
12120 escape = true;
12121 } else if (inQuote) {
12122 if (letter === prevQuote) {
12123 inQuote = false;
12124 }
12125 } else if (letter === '"' || letter === "'") {
12126 inQuote = true;
12127 prevQuote = letter;
12128 } else if (letter === "(") {
12129 func += 1;
12130 } else if (letter === ")") {
12131 if (func > 0) func -= 1;
12132 } else if (func === 0) {
12133 if (separators.includes(letter)) split = true;
12134 }
12135 if (split) {
12136 if (current !== "") array.push(current.trim());
12137 current = "";
12138 split = false;
12139 } else {
12140 current += letter;
12141 }
12142 }
12143 if (last || current !== "") array.push(current.trim());
12144 return array;
12145 }
12146 };
12147 var list_1$1 = list$2$1;
12148 list$2$1.default = list$2$1;
12149 var Container$3$1 = container$1;
12150 var list$1$1 = list_1$1;
12151 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12152 _inherits(Rule, Container$3$1);
12153 function Rule(defaults) {
12154 var _this;
12155 _this = Container$3$1.call(this, defaults) || this;
12156 _this.type = "rule";
12157 if (!_this.nodes) _this.nodes = [];
12158 return _this;
12159 }
12160 _create_class(Rule, [
12161 {
12162 key: "selectors",
12163 get: function get() {
12164 return list$1$1.comma(this.selector);
12165 },
12166 set: function set(values) {
12167 var match = this.selector ? this.selector.match(/,\s*/) : null;
12168 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
12169 this.selector = values.join(sep2);
12170 }
12171 }
12172 ]);
12173 return Rule;
12174 }(Container$3$1);
12175 var rule$1 = Rule$3$1;
12176 Rule$3$1.default = Rule$3$1;
12177 Container$3$1.registerRule(Rule$3$1);
12178 var Declaration$2$1 = declaration$1;
12179 var tokenizer2$1 = tokenize$1;
12180 var Comment$2$1 = comment$1;
12181 var AtRule$2$1 = atRule$1;
12182 var Root$4$1 = root$1;
12183 var Rule$2$1 = rule$1;
12184 var SAFE_COMMENT_NEIGHBOR$1 = {
12185 empty: true,
12186 space: true
12187 };
12188 function findLastWithPosition$1(tokens) {
12189 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12190 var token = tokens[i2];
12191 var pos = token[3] || token[2];
12192 if (pos) return pos;
12193 }
12194 }
12195 var Parser$1$1 = /*#__PURE__*/ function() {
12196 function Parser(input2) {
12197 this.input = input2;
12198 this.root = new Root$4$1();
12199 this.current = this.root;
12200 this.spaces = "";
12201 this.semicolon = false;
12202 this.createTokenizer();
12203 this.root.source = {
12204 input: input2,
12205 start: {
12206 column: 1,
12207 line: 1,
12208 offset: 0
12209 }
12210 };
12211 }
12212 var _proto = Parser.prototype;
12213 _proto.atrule = function atrule(token) {
12214 var node2 = new AtRule$2$1();
12215 node2.name = token[1].slice(1);
12216 if (node2.name === "") {
12217 this.unnamedAtrule(node2, token);
12218 }
12219 this.init(node2, token[2]);
12220 var type;
12221 var prev;
12222 var shift;
12223 var last = false;
12224 var open = false;
12225 var params = [];
12226 var brackets = [];
12227 while(!this.tokenizer.endOfFile()){
12228 token = this.tokenizer.nextToken();
12229 type = token[0];
12230 if (type === "(" || type === "[") {
12231 brackets.push(type === "(" ? ")" : "]");
12232 } else if (type === "{" && brackets.length > 0) {
12233 brackets.push("}");
12234 } else if (type === brackets[brackets.length - 1]) {
12235 brackets.pop();
12236 }
12237 if (brackets.length === 0) {
12238 if (type === ";") {
12239 node2.source.end = this.getPosition(token[2]);
12240 node2.source.end.offset++;
12241 this.semicolon = true;
12242 break;
12243 } else if (type === "{") {
12244 open = true;
12245 break;
12246 } else if (type === "}") {
12247 if (params.length > 0) {
12248 shift = params.length - 1;
12249 prev = params[shift];
12250 while(prev && prev[0] === "space"){
12251 prev = params[--shift];
12252 }
12253 if (prev) {
12254 node2.source.end = this.getPosition(prev[3] || prev[2]);
12255 node2.source.end.offset++;
12256 }
12257 }
12258 this.end(token);
12259 break;
12260 } else {
12261 params.push(token);
12262 }
12263 } else {
12264 params.push(token);
12265 }
12266 if (this.tokenizer.endOfFile()) {
12267 last = true;
12268 break;
12269 }
12270 }
12271 node2.raws.between = this.spacesAndCommentsFromEnd(params);
12272 if (params.length) {
12273 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
12274 this.raw(node2, "params", params);
12275 if (last) {
12276 token = params[params.length - 1];
12277 node2.source.end = this.getPosition(token[3] || token[2]);
12278 node2.source.end.offset++;
12279 this.spaces = node2.raws.between;
12280 node2.raws.between = "";
12281 }
12282 } else {
12283 node2.raws.afterName = "";
12284 node2.params = "";
12285 }
12286 if (open) {
12287 node2.nodes = [];
12288 this.current = node2;
12289 }
12290 };
12291 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
12292 var colon = this.colon(tokens);
12293 if (colon === false) return;
12294 var founded = 0;
12295 var token;
12296 for(var j = colon - 1; j >= 0; j--){
12297 token = tokens[j];
12298 if (token[0] !== "space") {
12299 founded += 1;
12300 if (founded === 2) break;
12301 }
12302 }
12303 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
12304 };
12305 _proto.colon = function colon(tokens) {
12306 var brackets = 0;
12307 var token, type, prev;
12308 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
12309 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
12310 token = element;
12311 type = token[0];
12312 if (type === "(") {
12313 brackets += 1;
12314 }
12315 if (type === ")") {
12316 brackets -= 1;
12317 }
12318 if (brackets === 0 && type === ":") {
12319 if (!prev) {
12320 this.doubleColon(token);
12321 } else if (prev[0] === "word" && prev[1] === "progid") {
12322 continue;
12323 } else {
12324 return i2;
12325 }
12326 }
12327 prev = token;
12328 }
12329 return false;
12330 };
12331 _proto.comment = function comment(token) {
12332 var node2 = new Comment$2$1();
12333 this.init(node2, token[2]);
12334 node2.source.end = this.getPosition(token[3] || token[2]);
12335 node2.source.end.offset++;
12336 var text = token[1].slice(2, -2);
12337 if (/^\s*$/.test(text)) {
12338 node2.text = "";
12339 node2.raws.left = text;
12340 node2.raws.right = "";
12341 } else {
12342 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
12343 node2.text = match[2];
12344 node2.raws.left = match[1];
12345 node2.raws.right = match[3];
12346 }
12347 };
12348 _proto.createTokenizer = function createTokenizer() {
12349 this.tokenizer = tokenizer2$1(this.input);
12350 };
12351 _proto.decl = function decl(tokens, customProperty) {
12352 var node2 = new Declaration$2$1();
12353 this.init(node2, tokens[0][2]);
12354 var last = tokens[tokens.length - 1];
12355 if (last[0] === ";") {
12356 this.semicolon = true;
12357 tokens.pop();
12358 }
12359 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
12360 node2.source.end.offset++;
12361 while(tokens[0][0] !== "word"){
12362 if (tokens.length === 1) this.unknownWord(tokens);
12363 node2.raws.before += tokens.shift()[1];
12364 }
12365 node2.source.start = this.getPosition(tokens[0][2]);
12366 node2.prop = "";
12367 while(tokens.length){
12368 var type = tokens[0][0];
12369 if (type === ":" || type === "space" || type === "comment") {
12370 break;
12371 }
12372 node2.prop += tokens.shift()[1];
12373 }
12374 node2.raws.between = "";
12375 var token;
12376 while(tokens.length){
12377 token = tokens.shift();
12378 if (token[0] === ":") {
12379 node2.raws.between += token[1];
12380 break;
12381 } else {
12382 if (token[0] === "word" && /\w/.test(token[1])) {
12383 this.unknownWord([
12384 token
12385 ]);
12386 }
12387 node2.raws.between += token[1];
12388 }
12389 }
12390 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
12391 node2.raws.before += node2.prop[0];
12392 node2.prop = node2.prop.slice(1);
12393 }
12394 var firstSpaces = [];
12395 var next;
12396 while(tokens.length){
12397 next = tokens[0][0];
12398 if (next !== "space" && next !== "comment") break;
12399 firstSpaces.push(tokens.shift());
12400 }
12401 this.precheckMissedSemicolon(tokens);
12402 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
12403 token = tokens[i2];
12404 if (token[1].toLowerCase() === "!important") {
12405 node2.important = true;
12406 var string = this.stringFrom(tokens, i2);
12407 string = this.spacesFromEnd(tokens) + string;
12408 if (string !== " !important") node2.raws.important = string;
12409 break;
12410 } else if (token[1].toLowerCase() === "important") {
12411 var cache = tokens.slice(0);
12412 var str = "";
12413 for(var j = i2; j > 0; j--){
12414 var type1 = cache[j][0];
12415 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
12416 break;
12417 }
12418 str = cache.pop()[1] + str;
12419 }
12420 if (str.trim().indexOf("!") === 0) {
12421 node2.important = true;
12422 node2.raws.important = str;
12423 tokens = cache;
12424 }
12425 }
12426 if (token[0] !== "space" && token[0] !== "comment") {
12427 break;
12428 }
12429 }
12430 var hasWord = tokens.some(function(i2) {
12431 return i2[0] !== "space" && i2[0] !== "comment";
12432 });
12433 if (hasWord) {
12434 node2.raws.between += firstSpaces.map(function(i2) {
12435 return i2[1];
12436 }).join("");
12437 firstSpaces = [];
12438 }
12439 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
12440 if (node2.value.includes(":") && !customProperty) {
12441 this.checkMissedSemicolon(tokens);
12442 }
12443 };
12444 _proto.doubleColon = function doubleColon(token) {
12445 throw this.input.error("Double colon", {
12446 offset: token[2]
12447 }, {
12448 offset: token[2] + token[1].length
12449 });
12450 };
12451 _proto.emptyRule = function emptyRule(token) {
12452 var node2 = new Rule$2$1();
12453 this.init(node2, token[2]);
12454 node2.selector = "";
12455 node2.raws.between = "";
12456 this.current = node2;
12457 };
12458 _proto.end = function end(token) {
12459 if (this.current.nodes && this.current.nodes.length) {
12460 this.current.raws.semicolon = this.semicolon;
12461 }
12462 this.semicolon = false;
12463 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12464 this.spaces = "";
12465 if (this.current.parent) {
12466 this.current.source.end = this.getPosition(token[2]);
12467 this.current.source.end.offset++;
12468 this.current = this.current.parent;
12469 } else {
12470 this.unexpectedClose(token);
12471 }
12472 };
12473 _proto.endFile = function endFile() {
12474 if (this.current.parent) this.unclosedBlock();
12475 if (this.current.nodes && this.current.nodes.length) {
12476 this.current.raws.semicolon = this.semicolon;
12477 }
12478 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
12479 this.root.source.end = this.getPosition(this.tokenizer.position());
12480 };
12481 _proto.freeSemicolon = function freeSemicolon(token) {
12482 this.spaces += token[1];
12483 if (this.current.nodes) {
12484 var prev = this.current.nodes[this.current.nodes.length - 1];
12485 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
12486 prev.raws.ownSemicolon = this.spaces;
12487 this.spaces = "";
12488 }
12489 }
12490 };
12491 // Helpers
12492 _proto.getPosition = function getPosition(offset) {
12493 var pos = this.input.fromOffset(offset);
12494 return {
12495 column: pos.col,
12496 line: pos.line,
12497 offset: offset
12498 };
12499 };
12500 _proto.init = function init(node2, offset) {
12501 this.current.push(node2);
12502 node2.source = {
12503 input: this.input,
12504 start: this.getPosition(offset)
12505 };
12506 node2.raws.before = this.spaces;
12507 this.spaces = "";
12508 if (node2.type !== "comment") this.semicolon = false;
12509 };
12510 _proto.other = function other(start) {
12511 var end = false;
12512 var type = null;
12513 var colon = false;
12514 var bracket = null;
12515 var brackets = [];
12516 var customProperty = start[1].startsWith("--");
12517 var tokens = [];
12518 var token = start;
12519 while(token){
12520 type = token[0];
12521 tokens.push(token);
12522 if (type === "(" || type === "[") {
12523 if (!bracket) bracket = token;
12524 brackets.push(type === "(" ? ")" : "]");
12525 } else if (customProperty && colon && type === "{") {
12526 if (!bracket) bracket = token;
12527 brackets.push("}");
12528 } else if (brackets.length === 0) {
12529 if (type === ";") {
12530 if (colon) {
12531 this.decl(tokens, customProperty);
12532 return;
12533 } else {
12534 break;
12535 }
12536 } else if (type === "{") {
12537 this.rule(tokens);
12538 return;
12539 } else if (type === "}") {
12540 this.tokenizer.back(tokens.pop());
12541 end = true;
12542 break;
12543 } else if (type === ":") {
12544 colon = true;
12545 }
12546 } else if (type === brackets[brackets.length - 1]) {
12547 brackets.pop();
12548 if (brackets.length === 0) bracket = null;
12549 }
12550 token = this.tokenizer.nextToken();
12551 }
12552 if (this.tokenizer.endOfFile()) end = true;
12553 if (brackets.length > 0) this.unclosedBracket(bracket);
12554 if (end && colon) {
12555 if (!customProperty) {
12556 while(tokens.length){
12557 token = tokens[tokens.length - 1][0];
12558 if (token !== "space" && token !== "comment") break;
12559 this.tokenizer.back(tokens.pop());
12560 }
12561 }
12562 this.decl(tokens, customProperty);
12563 } else {
12564 this.unknownWord(tokens);
12565 }
12566 };
12567 _proto.parse = function parse() {
12568 var token;
12569 while(!this.tokenizer.endOfFile()){
12570 token = this.tokenizer.nextToken();
12571 switch(token[0]){
12572 case "space":
12573 this.spaces += token[1];
12574 break;
12575 case ";":
12576 this.freeSemicolon(token);
12577 break;
12578 case "}":
12579 this.end(token);
12580 break;
12581 case "comment":
12582 this.comment(token);
12583 break;
12584 case "at-word":
12585 this.atrule(token);
12586 break;
12587 case "{":
12588 this.emptyRule(token);
12589 break;
12590 default:
12591 this.other(token);
12592 break;
12593 }
12594 }
12595 this.endFile();
12596 };
12597 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
12598 _proto.raw = function raw(node2, prop, tokens, customProperty) {
12599 var token, type;
12600 var length = tokens.length;
12601 var value = "";
12602 var clean = true;
12603 var next, prev;
12604 for(var i2 = 0; i2 < length; i2 += 1){
12605 token = tokens[i2];
12606 type = token[0];
12607 if (type === "space" && i2 === length - 1 && !customProperty) {
12608 clean = false;
12609 } else if (type === "comment") {
12610 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
12611 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
12612 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
12613 if (value.slice(-1) === ",") {
12614 clean = false;
12615 } else {
12616 value += token[1];
12617 }
12618 } else {
12619 clean = false;
12620 }
12621 } else {
12622 value += token[1];
12623 }
12624 }
12625 if (!clean) {
12626 var raw = tokens.reduce(function(all, i2) {
12627 return all + i2[1];
12628 }, "");
12629 node2.raws[prop] = {
12630 raw: raw,
12631 value: value
12632 };
12633 }
12634 node2[prop] = value;
12635 };
12636 _proto.rule = function rule(tokens) {
12637 tokens.pop();
12638 var node2 = new Rule$2$1();
12639 this.init(node2, tokens[0][2]);
12640 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
12641 this.raw(node2, "selector", tokens);
12642 this.current = node2;
12643 };
12644 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
12645 var lastTokenType;
12646 var spaces = "";
12647 while(tokens.length){
12648 lastTokenType = tokens[tokens.length - 1][0];
12649 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
12650 spaces = tokens.pop()[1] + spaces;
12651 }
12652 return spaces;
12653 };
12654 // Errors
12655 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
12656 var next;
12657 var spaces = "";
12658 while(tokens.length){
12659 next = tokens[0][0];
12660 if (next !== "space" && next !== "comment") break;
12661 spaces += tokens.shift()[1];
12662 }
12663 return spaces;
12664 };
12665 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
12666 var lastTokenType;
12667 var spaces = "";
12668 while(tokens.length){
12669 lastTokenType = tokens[tokens.length - 1][0];
12670 if (lastTokenType !== "space") break;
12671 spaces = tokens.pop()[1] + spaces;
12672 }
12673 return spaces;
12674 };
12675 _proto.stringFrom = function stringFrom(tokens, from) {
12676 var result2 = "";
12677 for(var i2 = from; i2 < tokens.length; i2++){
12678 result2 += tokens[i2][1];
12679 }
12680 tokens.splice(from, tokens.length - from);
12681 return result2;
12682 };
12683 _proto.unclosedBlock = function unclosedBlock() {
12684 var pos = this.current.source.start;
12685 throw this.input.error("Unclosed block", pos.line, pos.column);
12686 };
12687 _proto.unclosedBracket = function unclosedBracket(bracket) {
12688 throw this.input.error("Unclosed bracket", {
12689 offset: bracket[2]
12690 }, {
12691 offset: bracket[2] + 1
12692 });
12693 };
12694 _proto.unexpectedClose = function unexpectedClose(token) {
12695 throw this.input.error("Unexpected }", {
12696 offset: token[2]
12697 }, {
12698 offset: token[2] + 1
12699 });
12700 };
12701 _proto.unknownWord = function unknownWord(tokens) {
12702 throw this.input.error("Unknown word", {
12703 offset: tokens[0][2]
12704 }, {
12705 offset: tokens[0][2] + tokens[0][1].length
12706 });
12707 };
12708 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
12709 throw this.input.error("At-rule without name", {
12710 offset: token[2]
12711 }, {
12712 offset: token[2] + token[1].length
12713 });
12714 };
12715 return Parser;
12716 }();
12717 var parser$1 = Parser$1$1;
12718 var Container$2$1 = container$1;
12719 var Parser2$1 = parser$1;
12720 var Input$2$1 = input$1;
12721 function parse$3$1(css, opts) {
12722 var input2 = new Input$2$1(css, opts);
12723 var parser2 = new Parser2$1(input2);
12724 try {
12725 parser2.parse();
12726 } catch (e2) {
12727 if (true) {
12728 if (e2.name === "CssSyntaxError" && opts && opts.from) {
12729 if (/\.scss$/i.test(opts.from)) {
12730 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
12731 } else if (/\.sass/i.test(opts.from)) {
12732 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
12733 } else if (/\.less$/i.test(opts.from)) {
12734 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
12735 }
12736 }
12737 }
12738 throw e2;
12739 }
12740 return parser2.root;
12741 }
12742 var parse_1$1 = parse$3$1;
12743 parse$3$1.default = parse$3$1;
12744 Container$2$1.registerParse(parse$3$1);
12745 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
12746 var MapGenerator$1$1 = mapGenerator$1;
12747 var stringify$2$1 = stringify_1$1;
12748 var Container$1$1 = container$1;
12749 var Document$2$1 = document$1$1;
12750 var warnOnce$1$1 = warnOnce$2$1;
12751 var Result$2$1 = result$1;
12752 var parse$2$1 = parse_1$1;
12753 var Root$3$1 = root$1;
12754 var TYPE_TO_CLASS_NAME$1 = {
12755 atrule: "AtRule",
12756 comment: "Comment",
12757 decl: "Declaration",
12758 document: "Document",
12759 root: "Root",
12760 rule: "Rule"
12761 };
12762 var PLUGIN_PROPS$1 = {
12763 AtRule: true,
12764 AtRuleExit: true,
12765 Comment: true,
12766 CommentExit: true,
12767 Declaration: true,
12768 DeclarationExit: true,
12769 Document: true,
12770 DocumentExit: true,
12771 Once: true,
12772 OnceExit: true,
12773 postcssPlugin: true,
12774 prepare: true,
12775 Root: true,
12776 RootExit: true,
12777 Rule: true,
12778 RuleExit: true
12779 };
12780 var NOT_VISITORS$1 = {
12781 Once: true,
12782 postcssPlugin: true,
12783 prepare: true
12784 };
12785 var CHILDREN$1 = 0;
12786 function isPromise$1(obj) {
12787 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
12788 }
12789 function getEvents$1(node2) {
12790 var key = false;
12791 var type = TYPE_TO_CLASS_NAME$1[node2.type];
12792 if (node2.type === "decl") {
12793 key = node2.prop.toLowerCase();
12794 } else if (node2.type === "atrule") {
12795 key = node2.name.toLowerCase();
12796 }
12797 if (key && node2.append) {
12798 return [
12799 type,
12800 type + "-" + key,
12801 CHILDREN$1,
12802 type + "Exit",
12803 type + "Exit-" + key
12804 ];
12805 } else if (key) {
12806 return [
12807 type,
12808 type + "-" + key,
12809 type + "Exit",
12810 type + "Exit-" + key
12811 ];
12812 } else if (node2.append) {
12813 return [
12814 type,
12815 CHILDREN$1,
12816 type + "Exit"
12817 ];
12818 } else {
12819 return [
12820 type,
12821 type + "Exit"
12822 ];
12823 }
12824 }
12825 function toStack$1(node2) {
12826 var events;
12827 if (node2.type === "document") {
12828 events = [
12829 "Document",
12830 CHILDREN$1,
12831 "DocumentExit"
12832 ];
12833 } else if (node2.type === "root") {
12834 events = [
12835 "Root",
12836 CHILDREN$1,
12837 "RootExit"
12838 ];
12839 } else {
12840 events = getEvents$1(node2);
12841 }
12842 return {
12843 eventIndex: 0,
12844 events: events,
12845 iterator: 0,
12846 node: node2,
12847 visitorIndex: 0,
12848 visitors: []
12849 };
12850 }
12851 function cleanMarks$1(node2) {
12852 node2[isClean$3] = false;
12853 if (node2.nodes) node2.nodes.forEach(function(i2) {
12854 return cleanMarks$1(i2);
12855 });
12856 return node2;
12857 }
12858 var postcss$2$1 = {};
12859 var LazyResult$2$1 = /*#__PURE__*/ function() {
12860 function LazyResult(processor2, css, opts) {
12861 var _this = this;
12862 this.stringified = false;
12863 this.processed = false;
12864 var root2;
12865 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
12866 root2 = cleanMarks$1(css);
12867 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
12868 root2 = cleanMarks$1(css.root);
12869 if (css.map) {
12870 if (typeof opts.map === "undefined") opts.map = {};
12871 if (!opts.map.inline) opts.map.inline = false;
12872 opts.map.prev = css.map;
12873 }
12874 } else {
12875 var parser2 = parse$2$1;
12876 if (opts.syntax) parser2 = opts.syntax.parse;
12877 if (opts.parser) parser2 = opts.parser;
12878 if (parser2.parse) parser2 = parser2.parse;
12879 try {
12880 root2 = parser2(css, opts);
12881 } catch (error) {
12882 this.processed = true;
12883 this.error = error;
12884 }
12885 if (root2 && !root2[my$3]) {
12886 Container$1$1.rebuild(root2);
12887 }
12888 }
12889 this.result = new Result$2$1(processor2, root2, opts);
12890 this.helpers = _extends({}, postcss$2$1, {
12891 postcss: postcss$2$1,
12892 result: this.result
12893 });
12894 this.plugins = this.processor.plugins.map(function(plugin22) {
12895 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
12896 return _extends({}, plugin22, plugin22.prepare(_this.result));
12897 } else {
12898 return plugin22;
12899 }
12900 });
12901 }
12902 var _proto = LazyResult.prototype;
12903 _proto.async = function async() {
12904 if (this.error) return Promise.reject(this.error);
12905 if (this.processed) return Promise.resolve(this.result);
12906 if (!this.processing) {
12907 this.processing = this.runAsync();
12908 }
12909 return this.processing;
12910 };
12911 _proto.catch = function _catch(onRejected) {
12912 return this.async().catch(onRejected);
12913 };
12914 _proto.finally = function _finally(onFinally) {
12915 return this.async().then(onFinally, onFinally);
12916 };
12917 _proto.getAsyncError = function getAsyncError() {
12918 throw new Error("Use process(css).then(cb) to work with async plugins");
12919 };
12920 _proto.handleError = function handleError(error, node2) {
12921 var plugin22 = this.result.lastPlugin;
12922 try {
12923 if (node2) node2.addToError(error);
12924 this.error = error;
12925 if (error.name === "CssSyntaxError" && !error.plugin) {
12926 error.plugin = plugin22.postcssPlugin;
12927 error.setMessage();
12928 } else if (plugin22.postcssVersion) {
12929 if (true) {
12930 var pluginName = plugin22.postcssPlugin;
12931 var pluginVer = plugin22.postcssVersion;
12932 var runtimeVer = this.result.processor.version;
12933 var a2 = pluginVer.split(".");
12934 var b = runtimeVer.split(".");
12935 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
12936 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.");
12937 }
12938 }
12939 }
12940 } catch (err) {
12941 if (console && console.error) console.error(err);
12942 }
12943 return error;
12944 };
12945 _proto.prepareVisitors = function prepareVisitors() {
12946 var _this = this;
12947 this.listeners = {};
12948 var add = function(plugin22, type, cb) {
12949 if (!_this.listeners[type]) _this.listeners[type] = [];
12950 _this.listeners[type].push([
12951 plugin22,
12952 cb
12953 ]);
12954 };
12955 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
12956 var plugin22 = _step.value;
12957 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
12958 for(var event in plugin22){
12959 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
12960 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
12961 }
12962 if (!NOT_VISITORS$1[event]) {
12963 if (_type_of(plugin22[event]) === "object") {
12964 for(var filter in plugin22[event]){
12965 if (filter === "*") {
12966 add(plugin22, event, plugin22[event][filter]);
12967 } else {
12968 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
12969 }
12970 }
12971 } else if (typeof plugin22[event] === "function") {
12972 add(plugin22, event, plugin22[event]);
12973 }
12974 }
12975 }
12976 }
12977 }
12978 this.hasListener = Object.keys(this.listeners).length > 0;
12979 };
12980 _proto.runAsync = function runAsync() {
12981 var _this = this;
12982 return _async_to_generator(function() {
12983 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
12984 return _ts_generator(this, function(_state) {
12985 switch(_state.label){
12986 case 0:
12987 _this.plugin = 0;
12988 i2 = 0;
12989 _state.label = 1;
12990 case 1:
12991 if (!(i2 < _this.plugins.length)) return [
12992 3,
12993 6
12994 ];
12995 plugin22 = _this.plugins[i2];
12996 promise = _this.runOnRoot(plugin22);
12997 if (!isPromise$1(promise)) return [
12998 3,
12999 5
13000 ];
13001 _state.label = 2;
13002 case 2:
13003 _state.trys.push([
13004 2,
13005 4,
13006 ,
13007 5
13008 ]);
13009 return [
13010 4,
13011 promise
13012 ];
13013 case 3:
13014 _state.sent();
13015 return [
13016 3,
13017 5
13018 ];
13019 case 4:
13020 error = _state.sent();
13021 throw _this.handleError(error);
13022 case 5:
13023 i2++;
13024 return [
13025 3,
13026 1
13027 ];
13028 case 6:
13029 _this.prepareVisitors();
13030 if (!_this.hasListener) return [
13031 3,
13032 18
13033 ];
13034 root2 = _this.result.root;
13035 _state.label = 7;
13036 case 7:
13037 if (!!root2[isClean$3]) return [
13038 3,
13039 14
13040 ];
13041 root2[isClean$3] = true;
13042 stack = [
13043 toStack$1(root2)
13044 ];
13045 _state.label = 8;
13046 case 8:
13047 if (!(stack.length > 0)) return [
13048 3,
13049 13
13050 ];
13051 promise1 = _this.visitTick(stack);
13052 if (!isPromise$1(promise1)) return [
13053 3,
13054 12
13055 ];
13056 _state.label = 9;
13057 case 9:
13058 _state.trys.push([
13059 9,
13060 11,
13061 ,
13062 12
13063 ]);
13064 return [
13065 4,
13066 promise1
13067 ];
13068 case 10:
13069 _state.sent();
13070 return [
13071 3,
13072 12
13073 ];
13074 case 11:
13075 e2 = _state.sent();
13076 node2 = stack[stack.length - 1].node;
13077 throw _this.handleError(e2, node2);
13078 case 12:
13079 return [
13080 3,
13081 8
13082 ];
13083 case 13:
13084 return [
13085 3,
13086 7
13087 ];
13088 case 14:
13089 if (!_this.listeners.OnceExit) return [
13090 3,
13091 18
13092 ];
13093 _loop = function() {
13094 var _step_value, plugin22, visitor, roots, e2;
13095 return _ts_generator(this, function(_state) {
13096 switch(_state.label){
13097 case 0:
13098 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13099 _this.result.lastPlugin = plugin22;
13100 _state.label = 1;
13101 case 1:
13102 _state.trys.push([
13103 1,
13104 6,
13105 ,
13106 7
13107 ]);
13108 if (!(root2.type === "document")) return [
13109 3,
13110 3
13111 ];
13112 roots = root2.nodes.map(function(subRoot) {
13113 return visitor(subRoot, _this.helpers);
13114 });
13115 return [
13116 4,
13117 Promise.all(roots)
13118 ];
13119 case 2:
13120 _state.sent();
13121 return [
13122 3,
13123 5
13124 ];
13125 case 3:
13126 return [
13127 4,
13128 visitor(root2, _this.helpers)
13129 ];
13130 case 4:
13131 _state.sent();
13132 _state.label = 5;
13133 case 5:
13134 return [
13135 3,
13136 7
13137 ];
13138 case 6:
13139 e2 = _state.sent();
13140 throw _this.handleError(e2);
13141 case 7:
13142 return [
13143 2
13144 ];
13145 }
13146 });
13147 };
13148 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13149 _state.label = 15;
13150 case 15:
13151 if (!!(_step = _iterator()).done) return [
13152 3,
13153 18
13154 ];
13155 return [
13156 5,
13157 _ts_values(_loop())
13158 ];
13159 case 16:
13160 _state.sent();
13161 _state.label = 17;
13162 case 17:
13163 return [
13164 3,
13165 15
13166 ];
13167 case 18:
13168 _this.processed = true;
13169 return [
13170 2,
13171 _this.stringify()
13172 ];
13173 }
13174 });
13175 })();
13176 };
13177 _proto.runOnRoot = function runOnRoot(plugin22) {
13178 var _this = this;
13179 this.result.lastPlugin = plugin22;
13180 try {
13181 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
13182 if (this.result.root.type === "document") {
13183 var roots = this.result.root.nodes.map(function(root2) {
13184 return plugin22.Once(root2, _this.helpers);
13185 });
13186 if (isPromise$1(roots[0])) {
13187 return Promise.all(roots);
13188 }
13189 return roots;
13190 }
13191 return plugin22.Once(this.result.root, this.helpers);
13192 } else if (typeof plugin22 === "function") {
13193 return plugin22(this.result.root, this.result);
13194 }
13195 } catch (error) {
13196 throw this.handleError(error);
13197 }
13198 };
13199 _proto.stringify = function stringify() {
13200 if (this.error) throw this.error;
13201 if (this.stringified) return this.result;
13202 this.stringified = true;
13203 this.sync();
13204 var opts = this.result.opts;
13205 var str = stringify$2$1;
13206 if (opts.syntax) str = opts.syntax.stringify;
13207 if (opts.stringifier) str = opts.stringifier;
13208 if (str.stringify) str = str.stringify;
13209 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
13210 var data = map.generate();
13211 this.result.css = data[0];
13212 this.result.map = data[1];
13213 return this.result;
13214 };
13215 _proto.sync = function sync() {
13216 if (this.error) throw this.error;
13217 if (this.processed) return this.result;
13218 this.processed = true;
13219 if (this.processing) {
13220 throw this.getAsyncError();
13221 }
13222 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13223 var plugin22 = _step.value;
13224 var promise = this.runOnRoot(plugin22);
13225 if (isPromise$1(promise)) {
13226 throw this.getAsyncError();
13227 }
13228 }
13229 this.prepareVisitors();
13230 if (this.hasListener) {
13231 var root2 = this.result.root;
13232 while(!root2[isClean$3]){
13233 root2[isClean$3] = true;
13234 this.walkSync(root2);
13235 }
13236 if (this.listeners.OnceExit) {
13237 if (root2.type === "document") {
13238 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
13239 var subRoot = _step1.value;
13240 this.visitSync(this.listeners.OnceExit, subRoot);
13241 }
13242 } else {
13243 this.visitSync(this.listeners.OnceExit, root2);
13244 }
13245 }
13246 }
13247 return this.result;
13248 };
13249 _proto.then = function then(onFulfilled, onRejected) {
13250 if (true) {
13251 if (!("from" in this.opts)) {
13252 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.");
13253 }
13254 }
13255 return this.async().then(onFulfilled, onRejected);
13256 };
13257 _proto.toString = function toString() {
13258 return this.css;
13259 };
13260 _proto.visitSync = function visitSync(visitors, node2) {
13261 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
13262 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13263 this.result.lastPlugin = plugin22;
13264 var promise = void 0;
13265 try {
13266 promise = visitor(node2, this.helpers);
13267 } catch (e2) {
13268 throw this.handleError(e2, node2.proxyOf);
13269 }
13270 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13271 return true;
13272 }
13273 if (isPromise$1(promise)) {
13274 throw this.getAsyncError();
13275 }
13276 }
13277 };
13278 _proto.visitTick = function visitTick(stack) {
13279 var visit2 = stack[stack.length - 1];
13280 var node2 = visit2.node, visitors = visit2.visitors;
13281 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
13282 stack.pop();
13283 return;
13284 }
13285 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
13286 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
13287 visit2.visitorIndex += 1;
13288 if (visit2.visitorIndex === visitors.length) {
13289 visit2.visitors = [];
13290 visit2.visitorIndex = 0;
13291 }
13292 this.result.lastPlugin = plugin22;
13293 try {
13294 return visitor(node2.toProxy(), this.helpers);
13295 } catch (e2) {
13296 throw this.handleError(e2, node2);
13297 }
13298 }
13299 if (visit2.iterator !== 0) {
13300 var iterator = visit2.iterator;
13301 var child;
13302 while(child = node2.nodes[node2.indexes[iterator]]){
13303 node2.indexes[iterator] += 1;
13304 if (!child[isClean$3]) {
13305 child[isClean$3] = true;
13306 stack.push(toStack$1(child));
13307 return;
13308 }
13309 }
13310 visit2.iterator = 0;
13311 delete node2.indexes[iterator];
13312 }
13313 var events = visit2.events;
13314 while(visit2.eventIndex < events.length){
13315 var event = events[visit2.eventIndex];
13316 visit2.eventIndex += 1;
13317 if (event === CHILDREN$1) {
13318 if (node2.nodes && node2.nodes.length) {
13319 node2[isClean$3] = true;
13320 visit2.iterator = node2.getIterator();
13321 }
13322 return;
13323 } else if (this.listeners[event]) {
13324 visit2.visitors = this.listeners[event];
13325 return;
13326 }
13327 }
13328 stack.pop();
13329 };
13330 _proto.walkSync = function walkSync(node2) {
13331 var _this = this;
13332 node2[isClean$3] = true;
13333 var events = getEvents$1(node2);
13334 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
13335 var event = _step.value;
13336 if (event === CHILDREN$1) {
13337 if (node2.nodes) {
13338 node2.each(function(child) {
13339 if (!child[isClean$3]) _this.walkSync(child);
13340 });
13341 }
13342 } else {
13343 var visitors = this.listeners[event];
13344 if (visitors) {
13345 if (this.visitSync(visitors, node2.toProxy())) return;
13346 }
13347 }
13348 }
13349 };
13350 _proto.warnings = function warnings() {
13351 return this.sync().warnings();
13352 };
13353 _create_class(LazyResult, [
13354 {
13355 key: "content",
13356 get: function get() {
13357 return this.stringify().content;
13358 }
13359 },
13360 {
13361 key: "css",
13362 get: function get() {
13363 return this.stringify().css;
13364 }
13365 },
13366 {
13367 key: "map",
13368 get: function get() {
13369 return this.stringify().map;
13370 }
13371 },
13372 {
13373 key: "messages",
13374 get: function get() {
13375 return this.sync().messages;
13376 }
13377 },
13378 {
13379 key: "opts",
13380 get: function get() {
13381 return this.result.opts;
13382 }
13383 },
13384 {
13385 key: "processor",
13386 get: function get() {
13387 return this.result.processor;
13388 }
13389 },
13390 {
13391 key: "root",
13392 get: function get() {
13393 return this.sync().root;
13394 }
13395 },
13396 {
13397 key: Symbol.toStringTag,
13398 get: function get() {
13399 return "LazyResult";
13400 }
13401 }
13402 ]);
13403 return LazyResult;
13404 }();
13405 LazyResult$2$1.registerPostcss = function(dependant) {
13406 postcss$2$1 = dependant;
13407 };
13408 var lazyResult$1 = LazyResult$2$1;
13409 LazyResult$2$1.default = LazyResult$2$1;
13410 Root$3$1.registerLazyResult(LazyResult$2$1);
13411 Document$2$1.registerLazyResult(LazyResult$2$1);
13412 var MapGenerator2$1 = mapGenerator$1;
13413 var stringify$1$1 = stringify_1$1;
13414 var warnOnce2$1 = warnOnce$2$1;
13415 var parse$1$1 = parse_1$1;
13416 var Result$1$1 = result$1;
13417 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
13418 function NoWorkResult(processor2, css, opts) {
13419 css = css.toString();
13420 this.stringified = false;
13421 this._processor = processor2;
13422 this._css = css;
13423 this._opts = opts;
13424 this._map = void 0;
13425 var root2;
13426 var str = stringify$1$1;
13427 this.result = new Result$1$1(this._processor, root2, this._opts);
13428 this.result.css = css;
13429 var self = this;
13430 Object.defineProperty(this.result, "root", {
13431 get: function get() {
13432 return self.root;
13433 }
13434 });
13435 var map = new MapGenerator2$1(str, root2, this._opts, css);
13436 if (map.isMap()) {
13437 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
13438 if (generatedCSS) {
13439 this.result.css = generatedCSS;
13440 }
13441 if (generatedMap) {
13442 this.result.map = generatedMap;
13443 }
13444 } else {
13445 map.clearAnnotation();
13446 this.result.css = map.css;
13447 }
13448 }
13449 var _proto = NoWorkResult.prototype;
13450 _proto.async = function async() {
13451 if (this.error) return Promise.reject(this.error);
13452 return Promise.resolve(this.result);
13453 };
13454 _proto.catch = function _catch(onRejected) {
13455 return this.async().catch(onRejected);
13456 };
13457 _proto.finally = function _finally(onFinally) {
13458 return this.async().then(onFinally, onFinally);
13459 };
13460 _proto.sync = function sync() {
13461 if (this.error) throw this.error;
13462 return this.result;
13463 };
13464 _proto.then = function then(onFulfilled, onRejected) {
13465 if (true) {
13466 if (!("from" in this._opts)) {
13467 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.");
13468 }
13469 }
13470 return this.async().then(onFulfilled, onRejected);
13471 };
13472 _proto.toString = function toString() {
13473 return this._css;
13474 };
13475 _proto.warnings = function warnings() {
13476 return [];
13477 };
13478 _create_class(NoWorkResult, [
13479 {
13480 key: "content",
13481 get: function get() {
13482 return this.result.css;
13483 }
13484 },
13485 {
13486 key: "css",
13487 get: function get() {
13488 return this.result.css;
13489 }
13490 },
13491 {
13492 key: "map",
13493 get: function get() {
13494 return this.result.map;
13495 }
13496 },
13497 {
13498 key: "messages",
13499 get: function get() {
13500 return [];
13501 }
13502 },
13503 {
13504 key: "opts",
13505 get: function get() {
13506 return this.result.opts;
13507 }
13508 },
13509 {
13510 key: "processor",
13511 get: function get() {
13512 return this.result.processor;
13513 }
13514 },
13515 {
13516 key: "root",
13517 get: function get() {
13518 if (this._root) {
13519 return this._root;
13520 }
13521 var root2;
13522 var parser2 = parse$1$1;
13523 try {
13524 root2 = parser2(this._css, this._opts);
13525 } catch (error) {
13526 this.error = error;
13527 }
13528 if (this.error) {
13529 throw this.error;
13530 } else {
13531 this._root = root2;
13532 return root2;
13533 }
13534 }
13535 },
13536 {
13537 key: Symbol.toStringTag,
13538 get: function get() {
13539 return "NoWorkResult";
13540 }
13541 }
13542 ]);
13543 return NoWorkResult;
13544 }();
13545 var noWorkResult$1 = NoWorkResult$1$1;
13546 NoWorkResult$1$1.default = NoWorkResult$1$1;
13547 var NoWorkResult2$1 = noWorkResult$1;
13548 var LazyResult$1$1 = lazyResult$1;
13549 var Document$1$1 = document$1$1;
13550 var Root$2$1 = root$1;
13551 var Processor$1$1 = /*#__PURE__*/ function() {
13552 function Processor(plugins) {
13553 if (plugins === void 0) plugins = [];
13554 this.version = "8.4.38";
13555 this.plugins = this.normalize(plugins);
13556 }
13557 var _proto = Processor.prototype;
13558 _proto.normalize = function normalize(plugins) {
13559 var normalized = [];
13560 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
13561 var i2 = _step.value;
13562 if (i2.postcss === true) {
13563 i2 = i2();
13564 } else if (i2.postcss) {
13565 i2 = i2.postcss;
13566 }
13567 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
13568 normalized = normalized.concat(i2.plugins);
13569 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
13570 normalized.push(i2);
13571 } else if (typeof i2 === "function") {
13572 normalized.push(i2);
13573 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
13574 if (true) {
13575 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.");
13576 }
13577 } else {
13578 throw new Error(i2 + " is not a PostCSS plugin");
13579 }
13580 }
13581 return normalized;
13582 };
13583 _proto.process = function process1(css, opts) {
13584 if (opts === void 0) opts = {};
13585 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
13586 return new NoWorkResult2$1(this, css, opts);
13587 } else {
13588 return new LazyResult$1$1(this, css, opts);
13589 }
13590 };
13591 _proto.use = function use(plugin22) {
13592 this.plugins = this.plugins.concat(this.normalize([
13593 plugin22
13594 ]));
13595 return this;
13596 };
13597 return Processor;
13598 }();
13599 var processor$1 = Processor$1$1;
13600 Processor$1$1.default = Processor$1$1;
13601 Root$2$1.registerProcessor(Processor$1$1);
13602 Document$1$1.registerProcessor(Processor$1$1);
13603 var Declaration$1$1 = declaration$1;
13604 var PreviousMap2$1 = previousMap$1;
13605 var Comment$1$1 = comment$1;
13606 var AtRule$1$1 = atRule$1;
13607 var Input$1$1 = input$1;
13608 var Root$1$1 = root$1;
13609 var Rule$1$1 = rule$1;
13610 function fromJSON$1$1(json, inputs) {
13611 if (Array.isArray(json)) return json.map(function(n2) {
13612 return fromJSON$1$1(n2);
13613 });
13614 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
13615 "inputs"
13616 ]);
13617 if (ownInputs) {
13618 inputs = [];
13619 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
13620 var input2 = _step.value;
13621 var inputHydrated = _extends({}, input2, {
13622 __proto__: Input$1$1.prototype
13623 });
13624 if (inputHydrated.map) {
13625 inputHydrated.map = _extends({}, inputHydrated.map, {
13626 __proto__: PreviousMap2$1.prototype
13627 });
13628 }
13629 inputs.push(inputHydrated);
13630 }
13631 }
13632 if (defaults.nodes) {
13633 defaults.nodes = json.nodes.map(function(n2) {
13634 return fromJSON$1$1(n2, inputs);
13635 });
13636 }
13637 if (defaults.source) {
13638 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
13639 "inputId"
13640 ]);
13641 defaults.source = source;
13642 if (inputId != null) {
13643 defaults.source.input = inputs[inputId];
13644 }
13645 }
13646 if (defaults.type === "root") {
13647 return new Root$1$1(defaults);
13648 } else if (defaults.type === "decl") {
13649 return new Declaration$1$1(defaults);
13650 } else if (defaults.type === "rule") {
13651 return new Rule$1$1(defaults);
13652 } else if (defaults.type === "comment") {
13653 return new Comment$1$1(defaults);
13654 } else if (defaults.type === "atrule") {
13655 return new AtRule$1$1(defaults);
13656 } else {
13657 throw new Error("Unknown node type: " + json.type);
13658 }
13659 }
13660 var fromJSON_1$1 = fromJSON$1$1;
13661 fromJSON$1$1.default = fromJSON$1$1;
13662 var CssSyntaxError2$1 = cssSyntaxError$1;
13663 var Declaration2$1 = declaration$1;
13664 var LazyResult2$1 = lazyResult$1;
13665 var Container2$1 = container$1;
13666 var Processor2$1 = processor$1;
13667 var stringify$5 = stringify_1$1;
13668 var fromJSON$2 = fromJSON_1$1;
13669 var Document22 = document$1$1;
13670 var Warning2$1 = warning$1;
13671 var Comment2$1 = comment$1;
13672 var AtRule2$1 = atRule$1;
13673 var Result2$1 = result$1;
13674 var Input2$1 = input$1;
13675 var parse$5 = parse_1$1;
13676 var list$3 = list_1$1;
13677 var Rule2$1 = rule$1;
13678 var Root2$1 = root$1;
13679 var Node2$1 = node$1;
13680 function postcss$3() {
13681 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
13682 plugins[_key] = arguments[_key];
13683 }
13684 if (plugins.length === 1 && Array.isArray(plugins[0])) {
13685 plugins = plugins[0];
13686 }
13687 return new Processor2$1(plugins);
13688 }
13689 postcss$3.plugin = function plugin(name, initializer) {
13690 var warningPrinted = false;
13691 function creator() {
13692 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
13693 args[_key] = arguments[_key];
13694 }
13695 if (console && console.warn && !warningPrinted) {
13696 warningPrinted = true;
13697 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
13698 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
13699 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
13700 }
13701 }
13702 var transformer = initializer.apply(void 0, [].concat(args));
13703 transformer.postcssPlugin = name;
13704 transformer.postcssVersion = new Processor2$1().version;
13705 return transformer;
13706 }
13707 var cache;
13708 Object.defineProperty(creator, "postcss", {
13709 get: function get() {
13710 if (!cache) cache = creator();
13711 return cache;
13712 }
13713 });
13714 creator.process = function(css, processOpts, pluginOpts) {
13715 return postcss$3([
13716 creator(pluginOpts)
13717 ]).process(css, processOpts);
13718 };
13719 return creator;
13720 };
13721 postcss$3.stringify = stringify$5;
13722 postcss$3.parse = parse$5;
13723 postcss$3.fromJSON = fromJSON$2;
13724 postcss$3.list = list$3;
13725 postcss$3.comment = function(defaults) {
13726 return new Comment2$1(defaults);
13727 };
13728 postcss$3.atRule = function(defaults) {
13729 return new AtRule2$1(defaults);
13730 };
13731 postcss$3.decl = function(defaults) {
13732 return new Declaration2$1(defaults);
13733 };
13734 postcss$3.rule = function(defaults) {
13735 return new Rule2$1(defaults);
13736 };
13737 postcss$3.root = function(defaults) {
13738 return new Root2$1(defaults);
13739 };
13740 postcss$3.document = function(defaults) {
13741 return new Document22(defaults);
13742 };
13743 postcss$3.CssSyntaxError = CssSyntaxError2$1;
13744 postcss$3.Declaration = Declaration2$1;
13745 postcss$3.Container = Container2$1;
13746 postcss$3.Processor = Processor2$1;
13747 postcss$3.Document = Document22;
13748 postcss$3.Comment = Comment2$1;
13749 postcss$3.Warning = Warning2$1;
13750 postcss$3.AtRule = AtRule2$1;
13751 postcss$3.Result = Result2$1;
13752 postcss$3.Input = Input2$1;
13753 postcss$3.Rule = Rule2$1;
13754 postcss$3.Root = Root2$1;
13755 postcss$3.Node = Node2$1;
13756 LazyResult2$1.registerPostcss(postcss$3);
13757 var postcss_1$1 = postcss$3;
13758 postcss$3.default = postcss$3;
13759 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
13760 postcss$1$1.stringify;
13761 postcss$1$1.fromJSON;
13762 postcss$1$1.plugin;
13763 postcss$1$1.parse;
13764 postcss$1$1.list;
13765 postcss$1$1.document;
13766 postcss$1$1.comment;
13767 postcss$1$1.atRule;
13768 postcss$1$1.rule;
13769 postcss$1$1.decl;
13770 postcss$1$1.root;
13771 postcss$1$1.CssSyntaxError;
13772 postcss$1$1.Declaration;
13773 postcss$1$1.Container;
13774 postcss$1$1.Processor;
13775 postcss$1$1.Document;
13776 postcss$1$1.Comment;
13777 postcss$1$1.Warning;
13778 postcss$1$1.AtRule;
13779 postcss$1$1.Result;
13780 postcss$1$1.Input;
13781 postcss$1$1.Rule;
13782 postcss$1$1.Root;
13783 postcss$1$1.Node;
13784 var __defProp2 = Object.defineProperty;
13785 var __defNormalProp2 = function(obj, key, value) {
13786 return key in obj ? __defProp2(obj, key, {
13787 enumerable: true,
13788 configurable: true,
13789 writable: true,
13790 value: value
13791 }) : obj[key] = value;
13792 };
13793 var __publicField2 = function(obj, key, value) {
13794 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
13795 };
13796 function getDefaultExportFromCjs(x2) {
13797 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
13798 }
13799 function getAugmentedNamespace(n2) {
13800 if (n2.__esModule) return n2;
13801 var f2 = n2.default;
13802 if (typeof f2 == "function") {
13803 var a2 = function a22() {
13804 if (_instanceof(this, a22)) {
13805 return Reflect.construct(f2, arguments, this.constructor);
13806 }
13807 return f2.apply(this, arguments);
13808 };
13809 a2.prototype = f2.prototype;
13810 } else a2 = {};
13811 Object.defineProperty(a2, "__esModule", {
13812 value: true
13813 });
13814 Object.keys(n2).forEach(function(k) {
13815 var d = Object.getOwnPropertyDescriptor(n2, k);
13816 Object.defineProperty(a2, k, d.get ? d : {
13817 enumerable: true,
13818 get: function get() {
13819 return n2[k];
13820 }
13821 });
13822 });
13823 return a2;
13824 }
13825 var picocolors_browser = {
13826 exports: {}
13827 };
13828 var x = String;
13829 var create = function create() {
13830 return {
13831 isColorSupported: false,
13832 reset: x,
13833 bold: x,
13834 dim: x,
13835 italic: x,
13836 underline: x,
13837 inverse: x,
13838 hidden: x,
13839 strikethrough: x,
13840 black: x,
13841 red: x,
13842 green: x,
13843 yellow: x,
13844 blue: x,
13845 magenta: x,
13846 cyan: x,
13847 white: x,
13848 gray: x,
13849 bgBlack: x,
13850 bgRed: x,
13851 bgGreen: x,
13852 bgYellow: x,
13853 bgBlue: x,
13854 bgMagenta: x,
13855 bgCyan: x,
13856 bgWhite: x
13857 };
13858 };
13859 picocolors_browser.exports = create();
13860 picocolors_browser.exports.createColors = create;
13861 var picocolors_browserExports = picocolors_browser.exports;
13862 var __viteBrowserExternal = {};
13863 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
13864 __proto__: null,
13865 default: __viteBrowserExternal
13866 }, Symbol.toStringTag, {
13867 value: "Module"
13868 }));
13869 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
13870 var pico = picocolors_browserExports;
13871 var terminalHighlight$1 = require$$2;
13872 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
13873 _inherits(CssSyntaxError2, Error1);
13874 function CssSyntaxError2(message, line, column, source, file, plugin22) {
13875 var _this;
13876 _this = Error1.call(this, message) || this;
13877 _this.name = "CssSyntaxError";
13878 _this.reason = message;
13879 if (file) {
13880 _this.file = file;
13881 }
13882 if (source) {
13883 _this.source = source;
13884 }
13885 if (plugin22) {
13886 _this.plugin = plugin22;
13887 }
13888 if (typeof line !== "undefined" && typeof column !== "undefined") {
13889 if (typeof line === "number") {
13890 _this.line = line;
13891 _this.column = column;
13892 } else {
13893 _this.line = line.line;
13894 _this.column = line.column;
13895 _this.endLine = column.line;
13896 _this.endColumn = column.column;
13897 }
13898 }
13899 _this.setMessage();
13900 if (Error.captureStackTrace) {
13901 Error.captureStackTrace(_this, CssSyntaxError2);
13902 }
13903 return _this;
13904 }
13905 var _proto = CssSyntaxError2.prototype;
13906 _proto.setMessage = function setMessage() {
13907 this.message = this.plugin ? this.plugin + ": " : "";
13908 this.message += this.file ? this.file : "<css input>";
13909 if (typeof this.line !== "undefined") {
13910 this.message += ":" + this.line + ":" + this.column;
13911 }
13912 this.message += ": " + this.reason;
13913 };
13914 _proto.showSourceCode = function showSourceCode(color) {
13915 var _this = this;
13916 if (!this.source) return "";
13917 var css = this.source;
13918 if (color == null) color = pico.isColorSupported;
13919 if (terminalHighlight$1) {
13920 if (color) css = terminalHighlight$1(css);
13921 }
13922 var lines = css.split(/\r?\n/);
13923 var start = Math.max(this.line - 3, 0);
13924 var end = Math.min(this.line + 2, lines.length);
13925 var maxWidth = String(end).length;
13926 var mark, aside;
13927 if (color) {
13928 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
13929 mark = function(text) {
13930 return bold(red(text));
13931 };
13932 aside = function(text) {
13933 return gray(text);
13934 };
13935 } else {
13936 mark = aside = function(str) {
13937 return str;
13938 };
13939 }
13940 return lines.slice(start, end).map(function(line, index2) {
13941 var number = start + 1 + index2;
13942 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
13943 if (number === _this.line) {
13944 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
13945 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
13946 }
13947 return " " + aside(gutter) + line;
13948 }).join("\n");
13949 };
13950 _proto.toString = function toString() {
13951 var code = this.showSourceCode();
13952 if (code) {
13953 code = "\n\n" + code + "\n";
13954 }
13955 return this.name + ": " + this.message + code;
13956 };
13957 return CssSyntaxError2;
13958 }(_wrap_native_super(Error));
13959 var cssSyntaxError = CssSyntaxError$3;
13960 CssSyntaxError$3.default = CssSyntaxError$3;
13961 var symbols = {};
13962 symbols.isClean = Symbol("isClean");
13963 symbols.my = Symbol("my");
13964 var DEFAULT_RAW = {
13965 after: "\n",
13966 beforeClose: "\n",
13967 beforeComment: "\n",
13968 beforeDecl: "\n",
13969 beforeOpen: " ",
13970 beforeRule: "\n",
13971 colon: ": ",
13972 commentLeft: " ",
13973 commentRight: " ",
13974 emptyBody: "",
13975 indent: " ",
13976 semicolon: false
13977 };
13978 function capitalize(str) {
13979 return str[0].toUpperCase() + str.slice(1);
13980 }
13981 var Stringifier$2 = /*#__PURE__*/ function() {
13982 function Stringifier2(builder) {
13983 this.builder = builder;
13984 }
13985 var _proto = Stringifier2.prototype;
13986 _proto.atrule = function atrule(node2, semicolon) {
13987 var name = "@" + node2.name;
13988 var params = node2.params ? this.rawValue(node2, "params") : "";
13989 if (typeof node2.raws.afterName !== "undefined") {
13990 name += node2.raws.afterName;
13991 } else if (params) {
13992 name += " ";
13993 }
13994 if (node2.nodes) {
13995 this.block(node2, name + params);
13996 } else {
13997 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
13998 this.builder(name + params + end, node2);
13999 }
14000 };
14001 _proto.beforeAfter = function beforeAfter(node2, detect) {
14002 var value;
14003 if (node2.type === "decl") {
14004 value = this.raw(node2, null, "beforeDecl");
14005 } else if (node2.type === "comment") {
14006 value = this.raw(node2, null, "beforeComment");
14007 } else if (detect === "before") {
14008 value = this.raw(node2, null, "beforeRule");
14009 } else {
14010 value = this.raw(node2, null, "beforeClose");
14011 }
14012 var buf = node2.parent;
14013 var depth = 0;
14014 while(buf && buf.type !== "root"){
14015 depth += 1;
14016 buf = buf.parent;
14017 }
14018 if (value.includes("\n")) {
14019 var indent = this.raw(node2, null, "indent");
14020 if (indent.length) {
14021 for(var step = 0; step < depth; step++)value += indent;
14022 }
14023 }
14024 return value;
14025 };
14026 _proto.block = function block(node2, start) {
14027 var between = this.raw(node2, "between", "beforeOpen");
14028 this.builder(start + between + "{", node2, "start");
14029 var after;
14030 if (node2.nodes && node2.nodes.length) {
14031 this.body(node2);
14032 after = this.raw(node2, "after");
14033 } else {
14034 after = this.raw(node2, "after", "emptyBody");
14035 }
14036 if (after) this.builder(after);
14037 this.builder("}", node2, "end");
14038 };
14039 _proto.body = function body(node2) {
14040 var last = node2.nodes.length - 1;
14041 while(last > 0){
14042 if (node2.nodes[last].type !== "comment") break;
14043 last -= 1;
14044 }
14045 var semicolon = this.raw(node2, "semicolon");
14046 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14047 var child = node2.nodes[i2];
14048 var before = this.raw(child, "before");
14049 if (before) this.builder(before);
14050 this.stringify(child, last !== i2 || semicolon);
14051 }
14052 };
14053 _proto.comment = function comment(node2) {
14054 var left = this.raw(node2, "left", "commentLeft");
14055 var right = this.raw(node2, "right", "commentRight");
14056 this.builder("/*" + left + node2.text + right + "*/", node2);
14057 };
14058 _proto.decl = function decl(node2, semicolon) {
14059 var between = this.raw(node2, "between", "colon");
14060 var string = node2.prop + between + this.rawValue(node2, "value");
14061 if (node2.important) {
14062 string += node2.raws.important || " !important";
14063 }
14064 if (semicolon) string += ";";
14065 this.builder(string, node2);
14066 };
14067 _proto.document = function document1(node2) {
14068 this.body(node2);
14069 };
14070 _proto.raw = function raw(node2, own, detect) {
14071 var value;
14072 if (!detect) detect = own;
14073 if (own) {
14074 value = node2.raws[own];
14075 if (typeof value !== "undefined") return value;
14076 }
14077 var parent = node2.parent;
14078 if (detect === "before") {
14079 if (!parent || parent.type === "root" && parent.first === node2) {
14080 return "";
14081 }
14082 if (parent && parent.type === "document") {
14083 return "";
14084 }
14085 }
14086 if (!parent) return DEFAULT_RAW[detect];
14087 var root2 = node2.root();
14088 if (!root2.rawCache) root2.rawCache = {};
14089 if (typeof root2.rawCache[detect] !== "undefined") {
14090 return root2.rawCache[detect];
14091 }
14092 if (detect === "before" || detect === "after") {
14093 return this.beforeAfter(node2, detect);
14094 } else {
14095 var method = "raw" + capitalize(detect);
14096 if (this[method]) {
14097 value = this[method](root2, node2);
14098 } else {
14099 root2.walk(function(i2) {
14100 value = i2.raws[own];
14101 if (typeof value !== "undefined") return false;
14102 });
14103 }
14104 }
14105 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14106 root2.rawCache[detect] = value;
14107 return value;
14108 };
14109 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14110 var value;
14111 root2.walk(function(i2) {
14112 if (i2.nodes && i2.nodes.length > 0) {
14113 if (typeof i2.raws.after !== "undefined") {
14114 value = i2.raws.after;
14115 if (value.includes("\n")) {
14116 value = value.replace(/[^\n]+$/, "");
14117 }
14118 return false;
14119 }
14120 }
14121 });
14122 if (value) value = value.replace(/\S/g, "");
14123 return value;
14124 };
14125 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14126 var value;
14127 root2.walkComments(function(i2) {
14128 if (typeof i2.raws.before !== "undefined") {
14129 value = i2.raws.before;
14130 if (value.includes("\n")) {
14131 value = value.replace(/[^\n]+$/, "");
14132 }
14133 return false;
14134 }
14135 });
14136 if (typeof value === "undefined") {
14137 value = this.raw(node2, null, "beforeDecl");
14138 } else if (value) {
14139 value = value.replace(/\S/g, "");
14140 }
14141 return value;
14142 };
14143 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14144 var value;
14145 root2.walkDecls(function(i2) {
14146 if (typeof i2.raws.before !== "undefined") {
14147 value = i2.raws.before;
14148 if (value.includes("\n")) {
14149 value = value.replace(/[^\n]+$/, "");
14150 }
14151 return false;
14152 }
14153 });
14154 if (typeof value === "undefined") {
14155 value = this.raw(node2, null, "beforeRule");
14156 } else if (value) {
14157 value = value.replace(/\S/g, "");
14158 }
14159 return value;
14160 };
14161 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
14162 var value;
14163 root2.walk(function(i2) {
14164 if (i2.type !== "decl") {
14165 value = i2.raws.between;
14166 if (typeof value !== "undefined") return false;
14167 }
14168 });
14169 return value;
14170 };
14171 _proto.rawBeforeRule = function rawBeforeRule(root2) {
14172 var value;
14173 root2.walk(function(i2) {
14174 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
14175 if (typeof i2.raws.before !== "undefined") {
14176 value = i2.raws.before;
14177 if (value.includes("\n")) {
14178 value = value.replace(/[^\n]+$/, "");
14179 }
14180 return false;
14181 }
14182 }
14183 });
14184 if (value) value = value.replace(/\S/g, "");
14185 return value;
14186 };
14187 _proto.rawColon = function rawColon(root2) {
14188 var value;
14189 root2.walkDecls(function(i2) {
14190 if (typeof i2.raws.between !== "undefined") {
14191 value = i2.raws.between.replace(/[^\s:]/g, "");
14192 return false;
14193 }
14194 });
14195 return value;
14196 };
14197 _proto.rawEmptyBody = function rawEmptyBody(root2) {
14198 var value;
14199 root2.walk(function(i2) {
14200 if (i2.nodes && i2.nodes.length === 0) {
14201 value = i2.raws.after;
14202 if (typeof value !== "undefined") return false;
14203 }
14204 });
14205 return value;
14206 };
14207 _proto.rawIndent = function rawIndent(root2) {
14208 if (root2.raws.indent) return root2.raws.indent;
14209 var value;
14210 root2.walk(function(i2) {
14211 var p = i2.parent;
14212 if (p && p !== root2 && p.parent && p.parent === root2) {
14213 if (typeof i2.raws.before !== "undefined") {
14214 var parts = i2.raws.before.split("\n");
14215 value = parts[parts.length - 1];
14216 value = value.replace(/\S/g, "");
14217 return false;
14218 }
14219 }
14220 });
14221 return value;
14222 };
14223 _proto.rawSemicolon = function rawSemicolon(root2) {
14224 var value;
14225 root2.walk(function(i2) {
14226 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
14227 value = i2.raws.semicolon;
14228 if (typeof value !== "undefined") return false;
14229 }
14230 });
14231 return value;
14232 };
14233 _proto.rawValue = function rawValue(node2, prop) {
14234 var value = node2[prop];
14235 var raw = node2.raws[prop];
14236 if (raw && raw.value === value) {
14237 return raw.raw;
14238 }
14239 return value;
14240 };
14241 _proto.root = function root(node2) {
14242 this.body(node2);
14243 if (node2.raws.after) this.builder(node2.raws.after);
14244 };
14245 _proto.rule = function rule(node2) {
14246 this.block(node2, this.rawValue(node2, "selector"));
14247 if (node2.raws.ownSemicolon) {
14248 this.builder(node2.raws.ownSemicolon, node2, "end");
14249 }
14250 };
14251 _proto.stringify = function stringify(node2, semicolon) {
14252 if (!this[node2.type]) {
14253 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
14254 }
14255 this[node2.type](node2, semicolon);
14256 };
14257 return Stringifier2;
14258 }();
14259 var stringifier = Stringifier$2;
14260 Stringifier$2.default = Stringifier$2;
14261 var Stringifier$1 = stringifier;
14262 function stringify$4(node2, builder) {
14263 var str = new Stringifier$1(builder);
14264 str.stringify(node2);
14265 }
14266 var stringify_1 = stringify$4;
14267 stringify$4.default = stringify$4;
14268 var isClean$2 = symbols.isClean, my$2 = symbols.my;
14269 var CssSyntaxError$2 = cssSyntaxError;
14270 var Stringifier22 = stringifier;
14271 var stringify$3 = stringify_1;
14272 function cloneNode(obj, parent) {
14273 var cloned = new obj.constructor();
14274 for(var i2 in obj){
14275 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
14276 continue;
14277 }
14278 if (i2 === "proxyCache") continue;
14279 var value = obj[i2];
14280 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
14281 if (i2 === "parent" && type === "object") {
14282 if (parent) cloned[i2] = parent;
14283 } else if (i2 === "source") {
14284 cloned[i2] = value;
14285 } else if (Array.isArray(value)) {
14286 cloned[i2] = value.map(function(j) {
14287 return cloneNode(j, cloned);
14288 });
14289 } else {
14290 if (type === "object" && value !== null) value = cloneNode(value);
14291 cloned[i2] = value;
14292 }
14293 }
14294 return cloned;
14295 }
14296 var Node$4 = /*#__PURE__*/ function() {
14297 function Node3(defaults) {
14298 if (defaults === void 0) defaults = {};
14299 this.raws = {};
14300 this[isClean$2] = false;
14301 this[my$2] = true;
14302 for(var name in defaults){
14303 if (name === "nodes") {
14304 this.nodes = [];
14305 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
14306 var node2 = _step.value;
14307 if (typeof node2.clone === "function") {
14308 this.append(node2.clone());
14309 } else {
14310 this.append(node2);
14311 }
14312 }
14313 } else {
14314 this[name] = defaults[name];
14315 }
14316 }
14317 }
14318 var _proto = Node3.prototype;
14319 _proto.addToError = function addToError(error) {
14320 error.postcssNode = this;
14321 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
14322 var s2 = this.source;
14323 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
14324 }
14325 return error;
14326 };
14327 _proto.after = function after(add) {
14328 this.parent.insertAfter(this, add);
14329 return this;
14330 };
14331 _proto.assign = function assign(overrides) {
14332 if (overrides === void 0) overrides = {};
14333 for(var name in overrides){
14334 this[name] = overrides[name];
14335 }
14336 return this;
14337 };
14338 _proto.before = function before(add) {
14339 this.parent.insertBefore(this, add);
14340 return this;
14341 };
14342 _proto.cleanRaws = function cleanRaws(keepBetween) {
14343 delete this.raws.before;
14344 delete this.raws.after;
14345 if (!keepBetween) delete this.raws.between;
14346 };
14347 _proto.clone = function clone(overrides) {
14348 if (overrides === void 0) overrides = {};
14349 var cloned = cloneNode(this);
14350 for(var name in overrides){
14351 cloned[name] = overrides[name];
14352 }
14353 return cloned;
14354 };
14355 _proto.cloneAfter = function cloneAfter(overrides) {
14356 if (overrides === void 0) overrides = {};
14357 var cloned = this.clone(overrides);
14358 this.parent.insertAfter(this, cloned);
14359 return cloned;
14360 };
14361 _proto.cloneBefore = function cloneBefore(overrides) {
14362 if (overrides === void 0) overrides = {};
14363 var cloned = this.clone(overrides);
14364 this.parent.insertBefore(this, cloned);
14365 return cloned;
14366 };
14367 _proto.error = function error(message, opts) {
14368 if (opts === void 0) opts = {};
14369 if (this.source) {
14370 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
14371 return this.source.input.error(message, {
14372 column: start.column,
14373 line: start.line
14374 }, {
14375 column: end.column,
14376 line: end.line
14377 }, opts);
14378 }
14379 return new CssSyntaxError$2(message);
14380 };
14381 _proto.getProxyProcessor = function getProxyProcessor() {
14382 return {
14383 get: function get(node2, prop) {
14384 if (prop === "proxyOf") {
14385 return node2;
14386 } else if (prop === "root") {
14387 return function() {
14388 return node2.root().toProxy();
14389 };
14390 } else {
14391 return node2[prop];
14392 }
14393 },
14394 set: function set(node2, prop, value) {
14395 if (node2[prop] === value) return true;
14396 node2[prop] = value;
14397 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
14398 node2.markDirty();
14399 }
14400 return true;
14401 }
14402 };
14403 };
14404 _proto.markDirty = function markDirty() {
14405 if (this[isClean$2]) {
14406 this[isClean$2] = false;
14407 var next = this;
14408 while(next = next.parent){
14409 next[isClean$2] = false;
14410 }
14411 }
14412 };
14413 _proto.next = function next() {
14414 if (!this.parent) return void 0;
14415 var index2 = this.parent.index(this);
14416 return this.parent.nodes[index2 + 1];
14417 };
14418 _proto.positionBy = function positionBy(opts, stringRepresentation) {
14419 var pos = this.source.start;
14420 if (opts.index) {
14421 pos = this.positionInside(opts.index, stringRepresentation);
14422 } else if (opts.word) {
14423 stringRepresentation = this.toString();
14424 var index2 = stringRepresentation.indexOf(opts.word);
14425 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
14426 }
14427 return pos;
14428 };
14429 _proto.positionInside = function positionInside(index2, stringRepresentation) {
14430 var string = stringRepresentation || this.toString();
14431 var column = this.source.start.column;
14432 var line = this.source.start.line;
14433 for(var i2 = 0; i2 < index2; i2++){
14434 if (string[i2] === "\n") {
14435 column = 1;
14436 line += 1;
14437 } else {
14438 column += 1;
14439 }
14440 }
14441 return {
14442 column: column,
14443 line: line
14444 };
14445 };
14446 _proto.prev = function prev() {
14447 if (!this.parent) return void 0;
14448 var index2 = this.parent.index(this);
14449 return this.parent.nodes[index2 - 1];
14450 };
14451 _proto.rangeBy = function rangeBy(opts) {
14452 var start = {
14453 column: this.source.start.column,
14454 line: this.source.start.line
14455 };
14456 var end = this.source.end ? {
14457 column: this.source.end.column + 1,
14458 line: this.source.end.line
14459 } : {
14460 column: start.column + 1,
14461 line: start.line
14462 };
14463 if (opts.word) {
14464 var stringRepresentation = this.toString();
14465 var index2 = stringRepresentation.indexOf(opts.word);
14466 if (index2 !== -1) {
14467 start = this.positionInside(index2, stringRepresentation);
14468 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
14469 }
14470 } else {
14471 if (opts.start) {
14472 start = {
14473 column: opts.start.column,
14474 line: opts.start.line
14475 };
14476 } else if (opts.index) {
14477 start = this.positionInside(opts.index);
14478 }
14479 if (opts.end) {
14480 end = {
14481 column: opts.end.column,
14482 line: opts.end.line
14483 };
14484 } else if (typeof opts.endIndex === "number") {
14485 end = this.positionInside(opts.endIndex);
14486 } else if (opts.index) {
14487 end = this.positionInside(opts.index + 1);
14488 }
14489 }
14490 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
14491 end = {
14492 column: start.column + 1,
14493 line: start.line
14494 };
14495 }
14496 return {
14497 end: end,
14498 start: start
14499 };
14500 };
14501 _proto.raw = function raw(prop, defaultType) {
14502 var str = new Stringifier22();
14503 return str.raw(this, prop, defaultType);
14504 };
14505 _proto.remove = function remove() {
14506 if (this.parent) {
14507 this.parent.removeChild(this);
14508 }
14509 this.parent = void 0;
14510 return this;
14511 };
14512 _proto.replaceWith = function replaceWith() {
14513 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
14514 nodes[_key] = arguments[_key];
14515 }
14516 if (this.parent) {
14517 var bookmark = this;
14518 var foundSelf = false;
14519 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
14520 var node2 = _step.value;
14521 if (node2 === this) {
14522 foundSelf = true;
14523 } else if (foundSelf) {
14524 this.parent.insertAfter(bookmark, node2);
14525 bookmark = node2;
14526 } else {
14527 this.parent.insertBefore(bookmark, node2);
14528 }
14529 }
14530 if (!foundSelf) {
14531 this.remove();
14532 }
14533 }
14534 return this;
14535 };
14536 _proto.root = function root() {
14537 var result2 = this;
14538 while(result2.parent && result2.parent.type !== "document"){
14539 result2 = result2.parent;
14540 }
14541 return result2;
14542 };
14543 _proto.toJSON = function toJSON(_, inputs) {
14544 var fixed = {};
14545 var emitInputs = inputs == null;
14546 inputs = inputs || /* @__PURE__ */ new Map();
14547 var inputsNextIndex = 0;
14548 for(var name in this){
14549 if (!Object.prototype.hasOwnProperty.call(this, name)) {
14550 continue;
14551 }
14552 if (name === "parent" || name === "proxyCache") continue;
14553 var value = this[name];
14554 if (Array.isArray(value)) {
14555 fixed[name] = value.map(function(i2) {
14556 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
14557 return i2.toJSON(null, inputs);
14558 } else {
14559 return i2;
14560 }
14561 });
14562 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
14563 fixed[name] = value.toJSON(null, inputs);
14564 } else if (name === "source") {
14565 var inputId = inputs.get(value.input);
14566 if (inputId == null) {
14567 inputId = inputsNextIndex;
14568 inputs.set(value.input, inputsNextIndex);
14569 inputsNextIndex++;
14570 }
14571 fixed[name] = {
14572 end: value.end,
14573 inputId: inputId,
14574 start: value.start
14575 };
14576 } else {
14577 fixed[name] = value;
14578 }
14579 }
14580 if (emitInputs) {
14581 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
14582 return input2.toJSON();
14583 });
14584 }
14585 return fixed;
14586 };
14587 _proto.toProxy = function toProxy() {
14588 if (!this.proxyCache) {
14589 this.proxyCache = new Proxy(this, this.getProxyProcessor());
14590 }
14591 return this.proxyCache;
14592 };
14593 _proto.toString = function toString(stringifier2) {
14594 if (stringifier2 === void 0) stringifier2 = stringify$3;
14595 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
14596 var result2 = "";
14597 stringifier2(this, function(i2) {
14598 result2 += i2;
14599 });
14600 return result2;
14601 };
14602 _proto.warn = function warn(result2, text, opts) {
14603 var data = {
14604 node: this
14605 };
14606 for(var i2 in opts)data[i2] = opts[i2];
14607 return result2.warn(text, data);
14608 };
14609 _create_class(Node3, [
14610 {
14611 key: "proxyOf",
14612 get: function get() {
14613 return this;
14614 }
14615 }
14616 ]);
14617 return Node3;
14618 }();
14619 var node = Node$4;
14620 Node$4.default = Node$4;
14621 var Node$3 = node;
14622 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
14623 _inherits(Declaration2, Node$3);
14624 function Declaration2(defaults) {
14625 var _this;
14626 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
14627 defaults = _extends({}, defaults, {
14628 value: String(defaults.value)
14629 });
14630 }
14631 _this = Node$3.call(this, defaults) || this;
14632 _this.type = "decl";
14633 return _this;
14634 }
14635 _create_class(Declaration2, [
14636 {
14637 key: "variable",
14638 get: function get() {
14639 return this.prop.startsWith("--") || this.prop[0] === "$";
14640 }
14641 }
14642 ]);
14643 return Declaration2;
14644 }(Node$3);
14645 var declaration = Declaration$4;
14646 Declaration$4.default = Declaration$4;
14647 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
14648 var nanoid$1 = function(size) {
14649 if (size === void 0) size = 21;
14650 var id = "";
14651 var i2 = size;
14652 while(i2--){
14653 id += urlAlphabet[Math.random() * 64 | 0];
14654 }
14655 return id;
14656 };
14657 var nonSecure = {
14658 nanoid: nanoid$1};
14659 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
14660 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
14661 var dirname$1 = require$$2.dirname, join = require$$2.join;
14662 function fromBase64(str) {
14663 if (Buffer) {
14664 return Buffer.from(str, "base64").toString();
14665 } else {
14666 return window.atob(str);
14667 }
14668 }
14669 var PreviousMap$2 = /*#__PURE__*/ function() {
14670 function PreviousMap2(css, opts) {
14671 if (opts.map === false) return;
14672 this.loadAnnotation(css);
14673 this.inline = this.startWith(this.annotation, "data:");
14674 var prev = opts.map ? opts.map.prev : void 0;
14675 var text = this.loadMap(opts.from, prev);
14676 if (!this.mapFile && opts.from) {
14677 this.mapFile = opts.from;
14678 }
14679 if (this.mapFile) this.root = dirname$1(this.mapFile);
14680 if (text) this.text = text;
14681 }
14682 var _proto = PreviousMap2.prototype;
14683 _proto.consumer = function consumer() {
14684 if (!this.consumerCache) {
14685 this.consumerCache = new SourceMapConsumer$2(this.text);
14686 }
14687 return this.consumerCache;
14688 };
14689 _proto.decodeInline = function decodeInline(text) {
14690 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
14691 var baseUri = /^data:application\/json;base64,/;
14692 var charsetUri = /^data:application\/json;charset=utf-?8,/;
14693 var uri = /^data:application\/json,/;
14694 if (charsetUri.test(text) || uri.test(text)) {
14695 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
14696 }
14697 if (baseCharsetUri.test(text) || baseUri.test(text)) {
14698 return fromBase64(text.substr(RegExp.lastMatch.length));
14699 }
14700 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
14701 throw new Error("Unsupported source map encoding " + encoding);
14702 };
14703 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
14704 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
14705 };
14706 _proto.isMap = function isMap(map) {
14707 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
14708 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
14709 };
14710 _proto.loadAnnotation = function loadAnnotation(css) {
14711 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
14712 if (!comments) return;
14713 var start = css.lastIndexOf(comments.pop());
14714 var end = css.indexOf("*/", start);
14715 if (start > -1 && end > -1) {
14716 this.annotation = this.getAnnotationURL(css.substring(start, end));
14717 }
14718 };
14719 _proto.loadFile = function loadFile(path) {
14720 this.root = dirname$1(path);
14721 if (existsSync(path)) {
14722 this.mapFile = path;
14723 return readFileSync(path, "utf-8").toString().trim();
14724 }
14725 };
14726 _proto.loadMap = function loadMap(file, prev) {
14727 if (prev === false) return false;
14728 if (prev) {
14729 if (typeof prev === "string") {
14730 return prev;
14731 } else if (typeof prev === "function") {
14732 var prevPath = prev(file);
14733 if (prevPath) {
14734 var map = this.loadFile(prevPath);
14735 if (!map) {
14736 throw new Error("Unable to load previous source map: " + prevPath.toString());
14737 }
14738 return map;
14739 }
14740 } else if (_instanceof(prev, SourceMapConsumer$2)) {
14741 return SourceMapGenerator$2.fromSourceMap(prev).toString();
14742 } else if (_instanceof(prev, SourceMapGenerator$2)) {
14743 return prev.toString();
14744 } else if (this.isMap(prev)) {
14745 return JSON.stringify(prev);
14746 } else {
14747 throw new Error("Unsupported previous source map format: " + prev.toString());
14748 }
14749 } else if (this.inline) {
14750 return this.decodeInline(this.annotation);
14751 } else if (this.annotation) {
14752 var map1 = this.annotation;
14753 if (file) map1 = join(dirname$1(file), map1);
14754 return this.loadFile(map1);
14755 }
14756 };
14757 _proto.startWith = function startWith(string, start) {
14758 if (!string) return false;
14759 return string.substr(0, start.length) === start;
14760 };
14761 _proto.withContent = function withContent() {
14762 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
14763 };
14764 return PreviousMap2;
14765 }();
14766 var previousMap = PreviousMap$2;
14767 PreviousMap$2.default = PreviousMap$2;
14768 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
14769 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
14770 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
14771 var nanoid = nonSecure.nanoid;
14772 var terminalHighlight = require$$2;
14773 var CssSyntaxError$1 = cssSyntaxError;
14774 var PreviousMap$1 = previousMap;
14775 var fromOffsetCache = Symbol("fromOffsetCache");
14776 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
14777 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
14778 var Input$4 = /*#__PURE__*/ function() {
14779 function Input2(css, opts) {
14780 if (opts === void 0) opts = {};
14781 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
14782 throw new Error("PostCSS received " + css + " instead of CSS string");
14783 }
14784 this.css = css.toString();
14785 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
14786 this.hasBOM = true;
14787 this.css = this.css.slice(1);
14788 } else {
14789 this.hasBOM = false;
14790 }
14791 if (opts.from) {
14792 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
14793 this.file = opts.from;
14794 } else {
14795 this.file = resolve$1(opts.from);
14796 }
14797 }
14798 if (pathAvailable$1 && sourceMapAvailable$1) {
14799 var map = new PreviousMap$1(this.css, opts);
14800 if (map.text) {
14801 this.map = map;
14802 var file = map.consumer().file;
14803 if (!this.file && file) this.file = this.mapResolve(file);
14804 }
14805 }
14806 if (!this.file) {
14807 this.id = "<input css " + nanoid(6) + ">";
14808 }
14809 if (this.map) this.map.file = this.from;
14810 }
14811 var _proto = Input2.prototype;
14812 _proto.error = function error(message, line, column, opts) {
14813 if (opts === void 0) opts = {};
14814 var result2, endLine, endColumn;
14815 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
14816 var start = line;
14817 var end = column;
14818 if (typeof start.offset === "number") {
14819 var pos = this.fromOffset(start.offset);
14820 line = pos.line;
14821 column = pos.col;
14822 } else {
14823 line = start.line;
14824 column = start.column;
14825 }
14826 if (typeof end.offset === "number") {
14827 var pos1 = this.fromOffset(end.offset);
14828 endLine = pos1.line;
14829 endColumn = pos1.col;
14830 } else {
14831 endLine = end.line;
14832 endColumn = end.column;
14833 }
14834 } else if (!column) {
14835 var pos2 = this.fromOffset(line);
14836 line = pos2.line;
14837 column = pos2.col;
14838 }
14839 var origin = this.origin(line, column, endLine, endColumn);
14840 if (origin) {
14841 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
14842 column: origin.column,
14843 line: origin.line
14844 }, origin.endLine === void 0 ? origin.column : {
14845 column: origin.endColumn,
14846 line: origin.endLine
14847 }, origin.source, origin.file, opts.plugin);
14848 } else {
14849 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
14850 column: column,
14851 line: line
14852 }, endLine === void 0 ? column : {
14853 column: endColumn,
14854 line: endLine
14855 }, this.css, this.file, opts.plugin);
14856 }
14857 result2.input = {
14858 column: column,
14859 endColumn: endColumn,
14860 endLine: endLine,
14861 line: line,
14862 source: this.css
14863 };
14864 if (this.file) {
14865 if (pathToFileURL$1) {
14866 result2.input.url = pathToFileURL$1(this.file).toString();
14867 }
14868 result2.input.file = this.file;
14869 }
14870 return result2;
14871 };
14872 _proto.fromOffset = function fromOffset(offset) {
14873 var lastLine, lineToIndex;
14874 if (!this[fromOffsetCache]) {
14875 var lines = this.css.split("\n");
14876 lineToIndex = new Array(lines.length);
14877 var prevIndex = 0;
14878 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
14879 lineToIndex[i2] = prevIndex;
14880 prevIndex += lines[i2].length + 1;
14881 }
14882 this[fromOffsetCache] = lineToIndex;
14883 } else {
14884 lineToIndex = this[fromOffsetCache];
14885 }
14886 lastLine = lineToIndex[lineToIndex.length - 1];
14887 var min = 0;
14888 if (offset >= lastLine) {
14889 min = lineToIndex.length - 1;
14890 } else {
14891 var max = lineToIndex.length - 2;
14892 var mid;
14893 while(min < max){
14894 mid = min + (max - min >> 1);
14895 if (offset < lineToIndex[mid]) {
14896 max = mid - 1;
14897 } else if (offset >= lineToIndex[mid + 1]) {
14898 min = mid + 1;
14899 } else {
14900 min = mid;
14901 break;
14902 }
14903 }
14904 }
14905 return {
14906 col: offset - lineToIndex[min] + 1,
14907 line: min + 1
14908 };
14909 };
14910 _proto.mapResolve = function mapResolve(file) {
14911 if (/^\w+:\/\//.test(file)) {
14912 return file;
14913 }
14914 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
14915 };
14916 _proto.origin = function origin(line, column, endLine, endColumn) {
14917 if (!this.map) return false;
14918 var consumer = this.map.consumer();
14919 var from = consumer.originalPositionFor({
14920 column: column,
14921 line: line
14922 });
14923 if (!from.source) return false;
14924 var to;
14925 if (typeof endLine === "number") {
14926 to = consumer.originalPositionFor({
14927 column: endColumn,
14928 line: endLine
14929 });
14930 }
14931 var fromUrl;
14932 if (isAbsolute(from.source)) {
14933 fromUrl = pathToFileURL$1(from.source);
14934 } else {
14935 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
14936 }
14937 var result2 = {
14938 column: from.column,
14939 endColumn: to && to.column,
14940 endLine: to && to.line,
14941 line: from.line,
14942 url: fromUrl.toString()
14943 };
14944 if (fromUrl.protocol === "file:") {
14945 if (fileURLToPath) {
14946 result2.file = fileURLToPath(fromUrl);
14947 } else {
14948 throw new Error("file: protocol is not available in this PostCSS build");
14949 }
14950 }
14951 var source = consumer.sourceContentFor(from.source);
14952 if (source) result2.source = source;
14953 return result2;
14954 };
14955 _proto.toJSON = function toJSON() {
14956 var json = {};
14957 for(var _i = 0, _iter = [
14958 "hasBOM",
14959 "css",
14960 "file",
14961 "id"
14962 ]; _i < _iter.length; _i++){
14963 var name = _iter[_i];
14964 if (this[name] != null) {
14965 json[name] = this[name];
14966 }
14967 }
14968 if (this.map) {
14969 json.map = _extends({}, this.map);
14970 if (json.map.consumerCache) {
14971 json.map.consumerCache = void 0;
14972 }
14973 }
14974 return json;
14975 };
14976 _create_class(Input2, [
14977 {
14978 key: "from",
14979 get: function get() {
14980 return this.file || this.id;
14981 }
14982 }
14983 ]);
14984 return Input2;
14985 }();
14986 var input = Input$4;
14987 Input$4.default = Input$4;
14988 if (terminalHighlight && terminalHighlight.registerInput) {
14989 terminalHighlight.registerInput(Input$4);
14990 }
14991 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
14992 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
14993 var pathToFileURL = require$$2.pathToFileURL;
14994 var Input$3 = input;
14995 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
14996 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
14997 var MapGenerator$2 = /*#__PURE__*/ function() {
14998 function MapGenerator2(stringify2, root2, opts, cssString) {
14999 this.stringify = stringify2;
15000 this.mapOpts = opts.map || {};
15001 this.root = root2;
15002 this.opts = opts;
15003 this.css = cssString;
15004 this.originalCSS = cssString;
15005 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15006 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15007 this.memoizedPaths = /* @__PURE__ */ new Map();
15008 this.memoizedURLs = /* @__PURE__ */ new Map();
15009 }
15010 var _proto = MapGenerator2.prototype;
15011 _proto.addAnnotation = function addAnnotation() {
15012 var content;
15013 if (this.isInline()) {
15014 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15015 } else if (typeof this.mapOpts.annotation === "string") {
15016 content = this.mapOpts.annotation;
15017 } else if (typeof this.mapOpts.annotation === "function") {
15018 content = this.mapOpts.annotation(this.opts.to, this.root);
15019 } else {
15020 content = this.outputFile() + ".map";
15021 }
15022 var eol = "\n";
15023 if (this.css.includes("\r\n")) eol = "\r\n";
15024 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15025 };
15026 _proto.applyPrevMaps = function applyPrevMaps() {
15027 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15028 var prev = _step.value;
15029 var from = this.toUrl(this.path(prev.file));
15030 var root2 = prev.root || dirname(prev.file);
15031 var map = void 0;
15032 if (this.mapOpts.sourcesContent === false) {
15033 map = new SourceMapConsumer(prev.text);
15034 if (map.sourcesContent) {
15035 map.sourcesContent = null;
15036 }
15037 } else {
15038 map = prev.consumer();
15039 }
15040 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15041 }
15042 };
15043 _proto.clearAnnotation = function clearAnnotation() {
15044 if (this.mapOpts.annotation === false) return;
15045 if (this.root) {
15046 var node2;
15047 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15048 node2 = this.root.nodes[i2];
15049 if (node2.type !== "comment") continue;
15050 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15051 this.root.removeChild(i2);
15052 }
15053 }
15054 } else if (this.css) {
15055 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15056 }
15057 };
15058 _proto.generate = function generate() {
15059 this.clearAnnotation();
15060 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15061 return this.generateMap();
15062 } else {
15063 var result2 = "";
15064 this.stringify(this.root, function(i2) {
15065 result2 += i2;
15066 });
15067 return [
15068 result2
15069 ];
15070 }
15071 };
15072 _proto.generateMap = function generateMap() {
15073 if (this.root) {
15074 this.generateString();
15075 } else if (this.previous().length === 1) {
15076 var prev = this.previous()[0].consumer();
15077 prev.file = this.outputFile();
15078 this.map = SourceMapGenerator.fromSourceMap(prev, {
15079 ignoreInvalidMapping: true
15080 });
15081 } else {
15082 this.map = new SourceMapGenerator({
15083 file: this.outputFile(),
15084 ignoreInvalidMapping: true
15085 });
15086 this.map.addMapping({
15087 generated: {
15088 column: 0,
15089 line: 1
15090 },
15091 original: {
15092 column: 0,
15093 line: 1
15094 },
15095 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15096 });
15097 }
15098 if (this.isSourcesContent()) this.setSourcesContent();
15099 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15100 if (this.isAnnotation()) this.addAnnotation();
15101 if (this.isInline()) {
15102 return [
15103 this.css
15104 ];
15105 } else {
15106 return [
15107 this.css,
15108 this.map
15109 ];
15110 }
15111 };
15112 _proto.generateString = function generateString() {
15113 var _this = this;
15114 this.css = "";
15115 this.map = new SourceMapGenerator({
15116 file: this.outputFile(),
15117 ignoreInvalidMapping: true
15118 });
15119 var line = 1;
15120 var column = 1;
15121 var noSource = "<no source>";
15122 var mapping = {
15123 generated: {
15124 column: 0,
15125 line: 0
15126 },
15127 original: {
15128 column: 0,
15129 line: 0
15130 },
15131 source: ""
15132 };
15133 var lines, last;
15134 this.stringify(this.root, function(str, node2, type) {
15135 _this.css += str;
15136 if (node2 && type !== "end") {
15137 mapping.generated.line = line;
15138 mapping.generated.column = column - 1;
15139 if (node2.source && node2.source.start) {
15140 mapping.source = _this.sourcePath(node2);
15141 mapping.original.line = node2.source.start.line;
15142 mapping.original.column = node2.source.start.column - 1;
15143 _this.map.addMapping(mapping);
15144 } else {
15145 mapping.source = noSource;
15146 mapping.original.line = 1;
15147 mapping.original.column = 0;
15148 _this.map.addMapping(mapping);
15149 }
15150 }
15151 lines = str.match(/\n/g);
15152 if (lines) {
15153 line += lines.length;
15154 last = str.lastIndexOf("\n");
15155 column = str.length - last;
15156 } else {
15157 column += str.length;
15158 }
15159 if (node2 && type !== "start") {
15160 var p = node2.parent || {
15161 raws: {}
15162 };
15163 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
15164 if (!childless || node2 !== p.last || p.raws.semicolon) {
15165 if (node2.source && node2.source.end) {
15166 mapping.source = _this.sourcePath(node2);
15167 mapping.original.line = node2.source.end.line;
15168 mapping.original.column = node2.source.end.column - 1;
15169 mapping.generated.line = line;
15170 mapping.generated.column = column - 2;
15171 _this.map.addMapping(mapping);
15172 } else {
15173 mapping.source = noSource;
15174 mapping.original.line = 1;
15175 mapping.original.column = 0;
15176 mapping.generated.line = line;
15177 mapping.generated.column = column - 1;
15178 _this.map.addMapping(mapping);
15179 }
15180 }
15181 }
15182 });
15183 };
15184 _proto.isAnnotation = function isAnnotation() {
15185 if (this.isInline()) {
15186 return true;
15187 }
15188 if (typeof this.mapOpts.annotation !== "undefined") {
15189 return this.mapOpts.annotation;
15190 }
15191 if (this.previous().length) {
15192 return this.previous().some(function(i2) {
15193 return i2.annotation;
15194 });
15195 }
15196 return true;
15197 };
15198 _proto.isInline = function isInline() {
15199 if (typeof this.mapOpts.inline !== "undefined") {
15200 return this.mapOpts.inline;
15201 }
15202 var annotation = this.mapOpts.annotation;
15203 if (typeof annotation !== "undefined" && annotation !== true) {
15204 return false;
15205 }
15206 if (this.previous().length) {
15207 return this.previous().some(function(i2) {
15208 return i2.inline;
15209 });
15210 }
15211 return true;
15212 };
15213 _proto.isMap = function isMap() {
15214 if (typeof this.opts.map !== "undefined") {
15215 return !!this.opts.map;
15216 }
15217 return this.previous().length > 0;
15218 };
15219 _proto.isSourcesContent = function isSourcesContent() {
15220 if (typeof this.mapOpts.sourcesContent !== "undefined") {
15221 return this.mapOpts.sourcesContent;
15222 }
15223 if (this.previous().length) {
15224 return this.previous().some(function(i2) {
15225 return i2.withContent();
15226 });
15227 }
15228 return true;
15229 };
15230 _proto.outputFile = function outputFile() {
15231 if (this.opts.to) {
15232 return this.path(this.opts.to);
15233 } else if (this.opts.from) {
15234 return this.path(this.opts.from);
15235 } else {
15236 return "to.css";
15237 }
15238 };
15239 _proto.path = function path(file) {
15240 if (this.mapOpts.absolute) return file;
15241 if (file.charCodeAt(0) === 60) return file;
15242 if (/^\w+:\/\//.test(file)) return file;
15243 var cached = this.memoizedPaths.get(file);
15244 if (cached) return cached;
15245 var from = this.opts.to ? dirname(this.opts.to) : ".";
15246 if (typeof this.mapOpts.annotation === "string") {
15247 from = dirname(resolve$3(from, this.mapOpts.annotation));
15248 }
15249 var path = relative(from, file);
15250 this.memoizedPaths.set(file, path);
15251 return path;
15252 };
15253 _proto.previous = function previous() {
15254 var _this = this;
15255 if (!this.previousMaps) {
15256 this.previousMaps = [];
15257 if (this.root) {
15258 this.root.walk(function(node2) {
15259 if (node2.source && node2.source.input.map) {
15260 var map = node2.source.input.map;
15261 if (!_this.previousMaps.includes(map)) {
15262 _this.previousMaps.push(map);
15263 }
15264 }
15265 });
15266 } else {
15267 var input2 = new Input$3(this.originalCSS, this.opts);
15268 if (input2.map) this.previousMaps.push(input2.map);
15269 }
15270 }
15271 return this.previousMaps;
15272 };
15273 _proto.setSourcesContent = function setSourcesContent() {
15274 var _this = this;
15275 var already = {};
15276 if (this.root) {
15277 this.root.walk(function(node2) {
15278 if (node2.source) {
15279 var from = node2.source.input.from;
15280 if (from && !already[from]) {
15281 already[from] = true;
15282 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
15283 _this.map.setSourceContent(fromUrl, node2.source.input.css);
15284 }
15285 }
15286 });
15287 } else if (this.css) {
15288 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
15289 this.map.setSourceContent(from, this.css);
15290 }
15291 };
15292 _proto.sourcePath = function sourcePath(node2) {
15293 if (this.mapOpts.from) {
15294 return this.toUrl(this.mapOpts.from);
15295 } else if (this.usesFileUrls) {
15296 return this.toFileUrl(node2.source.input.from);
15297 } else {
15298 return this.toUrl(this.path(node2.source.input.from));
15299 }
15300 };
15301 _proto.toBase64 = function toBase64(str) {
15302 if (Buffer) {
15303 return Buffer.from(str).toString("base64");
15304 } else {
15305 return window.btoa(unescape(encodeURIComponent(str)));
15306 }
15307 };
15308 _proto.toFileUrl = function toFileUrl(path) {
15309 var cached = this.memoizedFileURLs.get(path);
15310 if (cached) return cached;
15311 if (pathToFileURL) {
15312 var fileURL = pathToFileURL(path).toString();
15313 this.memoizedFileURLs.set(path, fileURL);
15314 return fileURL;
15315 } else {
15316 throw new Error("`map.absolute` option is not available in this PostCSS build");
15317 }
15318 };
15319 _proto.toUrl = function toUrl(path) {
15320 var cached = this.memoizedURLs.get(path);
15321 if (cached) return cached;
15322 if (sep === "\\") {
15323 path = path.replace(/\\/g, "/");
15324 }
15325 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
15326 this.memoizedURLs.set(path, url);
15327 return url;
15328 };
15329 return MapGenerator2;
15330 }();
15331 var mapGenerator = MapGenerator$2;
15332 var Node$2 = node;
15333 var Comment$4 = /*#__PURE__*/ function(Node$2) {
15334 _inherits(Comment2, Node$2);
15335 function Comment2(defaults) {
15336 var _this;
15337 _this = Node$2.call(this, defaults) || this;
15338 _this.type = "comment";
15339 return _this;
15340 }
15341 return Comment2;
15342 }(Node$2);
15343 var comment = Comment$4;
15344 Comment$4.default = Comment$4;
15345 var isClean$1 = symbols.isClean, my$1 = symbols.my;
15346 var Declaration$3 = declaration;
15347 var Comment$3 = comment;
15348 var Node$1 = node;
15349 var parse$4, Rule$4, AtRule$4, Root$6;
15350 function cleanSource(nodes) {
15351 return nodes.map(function(i2) {
15352 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
15353 delete i2.source;
15354 return i2;
15355 });
15356 }
15357 function markDirtyUp(node2) {
15358 node2[isClean$1] = false;
15359 if (node2.proxyOf.nodes) {
15360 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15361 var i2 = _step.value;
15362 markDirtyUp(i2);
15363 }
15364 }
15365 }
15366 var Container$7 = /*#__PURE__*/ function(Node$1) {
15367 _inherits(Container2, Node$1);
15368 function Container2() {
15369 return Node$1.apply(this, arguments) || this;
15370 }
15371 var _proto = Container2.prototype;
15372 _proto.append = function append() {
15373 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15374 children[_key] = arguments[_key];
15375 }
15376 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15377 var child = _step.value;
15378 var nodes = this.normalize(child, this.last);
15379 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15380 var node2 = _step1.value;
15381 this.proxyOf.nodes.push(node2);
15382 }
15383 }
15384 this.markDirty();
15385 return this;
15386 };
15387 _proto.cleanRaws = function cleanRaws(keepBetween) {
15388 Node$1.prototype.cleanRaws.call(this, keepBetween);
15389 if (this.nodes) {
15390 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
15391 var node2 = _step.value;
15392 node2.cleanRaws(keepBetween);
15393 }
15394 }
15395 };
15396 _proto.each = function each(callback) {
15397 if (!this.proxyOf.nodes) return void 0;
15398 var iterator = this.getIterator();
15399 var index2, result2;
15400 while(this.indexes[iterator] < this.proxyOf.nodes.length){
15401 index2 = this.indexes[iterator];
15402 result2 = callback(this.proxyOf.nodes[index2], index2);
15403 if (result2 === false) break;
15404 this.indexes[iterator] += 1;
15405 }
15406 delete this.indexes[iterator];
15407 return result2;
15408 };
15409 _proto.every = function every(condition) {
15410 return this.nodes.every(condition);
15411 };
15412 _proto.getIterator = function getIterator() {
15413 if (!this.lastEach) this.lastEach = 0;
15414 if (!this.indexes) this.indexes = {};
15415 this.lastEach += 1;
15416 var iterator = this.lastEach;
15417 this.indexes[iterator] = 0;
15418 return iterator;
15419 };
15420 _proto.getProxyProcessor = function getProxyProcessor() {
15421 return {
15422 get: function get(node2, prop) {
15423 if (prop === "proxyOf") {
15424 return node2;
15425 } else if (!node2[prop]) {
15426 return node2[prop];
15427 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
15428 return function() {
15429 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
15430 args[_key] = arguments[_key];
15431 }
15432 var _node2;
15433 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
15434 if (typeof i2 === "function") {
15435 return function(child, index2) {
15436 return i2(child.toProxy(), index2);
15437 };
15438 } else {
15439 return i2;
15440 }
15441 })));
15442 };
15443 } else if (prop === "every" || prop === "some") {
15444 return function(cb) {
15445 return node2[prop](function(child) {
15446 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
15447 other[_key - 1] = arguments[_key];
15448 }
15449 return cb.apply(void 0, [].concat([
15450 child.toProxy()
15451 ], other));
15452 });
15453 };
15454 } else if (prop === "root") {
15455 return function() {
15456 return node2.root().toProxy();
15457 };
15458 } else if (prop === "nodes") {
15459 return node2.nodes.map(function(i2) {
15460 return i2.toProxy();
15461 });
15462 } else if (prop === "first" || prop === "last") {
15463 return node2[prop].toProxy();
15464 } else {
15465 return node2[prop];
15466 }
15467 },
15468 set: function set(node2, prop, value) {
15469 if (node2[prop] === value) return true;
15470 node2[prop] = value;
15471 if (prop === "name" || prop === "params" || prop === "selector") {
15472 node2.markDirty();
15473 }
15474 return true;
15475 }
15476 };
15477 };
15478 _proto.index = function index(child) {
15479 if (typeof child === "number") return child;
15480 if (child.proxyOf) child = child.proxyOf;
15481 return this.proxyOf.nodes.indexOf(child);
15482 };
15483 _proto.insertAfter = function insertAfter(exist, add) {
15484 var existIndex = this.index(exist);
15485 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
15486 existIndex = this.index(exist);
15487 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15488 var node2 = _step.value;
15489 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
15490 }
15491 var index2;
15492 for(var id in this.indexes){
15493 index2 = this.indexes[id];
15494 if (existIndex < index2) {
15495 this.indexes[id] = index2 + nodes.length;
15496 }
15497 }
15498 this.markDirty();
15499 return this;
15500 };
15501 _proto.insertBefore = function insertBefore(exist, add) {
15502 var existIndex = this.index(exist);
15503 var type = existIndex === 0 ? "prepend" : false;
15504 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
15505 existIndex = this.index(exist);
15506 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15507 var node2 = _step.value;
15508 this.proxyOf.nodes.splice(existIndex, 0, node2);
15509 }
15510 var index2;
15511 for(var id in this.indexes){
15512 index2 = this.indexes[id];
15513 if (existIndex <= index2) {
15514 this.indexes[id] = index2 + nodes.length;
15515 }
15516 }
15517 this.markDirty();
15518 return this;
15519 };
15520 _proto.normalize = function normalize(nodes, sample) {
15521 var _this = this;
15522 if (typeof nodes === "string") {
15523 nodes = cleanSource(parse$4(nodes).nodes);
15524 } else if (typeof nodes === "undefined") {
15525 nodes = [];
15526 } else if (Array.isArray(nodes)) {
15527 nodes = nodes.slice(0);
15528 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15529 var i2 = _step.value;
15530 if (i2.parent) i2.parent.removeChild(i2, "ignore");
15531 }
15532 } else if (nodes.type === "root" && this.type !== "document") {
15533 nodes = nodes.nodes.slice(0);
15534 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15535 var i21 = _step1.value;
15536 if (i21.parent) i21.parent.removeChild(i21, "ignore");
15537 }
15538 } else if (nodes.type) {
15539 nodes = [
15540 nodes
15541 ];
15542 } else if (nodes.prop) {
15543 if (typeof nodes.value === "undefined") {
15544 throw new Error("Value field is missed in node creation");
15545 } else if (typeof nodes.value !== "string") {
15546 nodes.value = String(nodes.value);
15547 }
15548 nodes = [
15549 new Declaration$3(nodes)
15550 ];
15551 } else if (nodes.selector) {
15552 nodes = [
15553 new Rule$4(nodes)
15554 ];
15555 } else if (nodes.name) {
15556 nodes = [
15557 new AtRule$4(nodes)
15558 ];
15559 } else if (nodes.text) {
15560 nodes = [
15561 new Comment$3(nodes)
15562 ];
15563 } else {
15564 throw new Error("Unknown node type in node creation");
15565 }
15566 var processed = nodes.map(function(i2) {
15567 if (!i2[my$1]) Container2.rebuild(i2);
15568 i2 = i2.proxyOf;
15569 if (i2.parent) i2.parent.removeChild(i2);
15570 if (i2[isClean$1]) markDirtyUp(i2);
15571 if (typeof i2.raws.before === "undefined") {
15572 if (sample && typeof sample.raws.before !== "undefined") {
15573 i2.raws.before = sample.raws.before.replace(/\S/g, "");
15574 }
15575 }
15576 i2.parent = _this.proxyOf;
15577 return i2;
15578 });
15579 return processed;
15580 };
15581 _proto.prepend = function prepend() {
15582 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
15583 children[_key] = arguments[_key];
15584 }
15585 children = children.reverse();
15586 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
15587 var child = _step.value;
15588 var nodes = this.normalize(child, this.first, "prepend").reverse();
15589 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
15590 var node2 = _step1.value;
15591 this.proxyOf.nodes.unshift(node2);
15592 }
15593 for(var id in this.indexes){
15594 this.indexes[id] = this.indexes[id] + nodes.length;
15595 }
15596 }
15597 this.markDirty();
15598 return this;
15599 };
15600 _proto.push = function push(child) {
15601 child.parent = this;
15602 this.proxyOf.nodes.push(child);
15603 return this;
15604 };
15605 _proto.removeAll = function removeAll() {
15606 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
15607 var node2 = _step.value;
15608 node2.parent = void 0;
15609 }
15610 this.proxyOf.nodes = [];
15611 this.markDirty();
15612 return this;
15613 };
15614 _proto.removeChild = function removeChild(child) {
15615 child = this.index(child);
15616 this.proxyOf.nodes[child].parent = void 0;
15617 this.proxyOf.nodes.splice(child, 1);
15618 var index2;
15619 for(var id in this.indexes){
15620 index2 = this.indexes[id];
15621 if (index2 >= child) {
15622 this.indexes[id] = index2 - 1;
15623 }
15624 }
15625 this.markDirty();
15626 return this;
15627 };
15628 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
15629 if (!callback) {
15630 callback = opts;
15631 opts = {};
15632 }
15633 this.walkDecls(function(decl) {
15634 if (opts.props && !opts.props.includes(decl.prop)) return;
15635 if (opts.fast && !decl.value.includes(opts.fast)) return;
15636 decl.value = decl.value.replace(pattern, callback);
15637 });
15638 this.markDirty();
15639 return this;
15640 };
15641 _proto.some = function some(condition) {
15642 return this.nodes.some(condition);
15643 };
15644 _proto.walk = function walk(callback) {
15645 return this.each(function(child, i2) {
15646 var result2;
15647 try {
15648 result2 = callback(child, i2);
15649 } catch (e2) {
15650 throw child.addToError(e2);
15651 }
15652 if (result2 !== false && child.walk) {
15653 result2 = child.walk(callback);
15654 }
15655 return result2;
15656 });
15657 };
15658 _proto.walkAtRules = function walkAtRules(name, callback) {
15659 if (!callback) {
15660 callback = name;
15661 return this.walk(function(child, i2) {
15662 if (child.type === "atrule") {
15663 return callback(child, i2);
15664 }
15665 });
15666 }
15667 if (_instanceof(name, RegExp)) {
15668 return this.walk(function(child, i2) {
15669 if (child.type === "atrule" && name.test(child.name)) {
15670 return callback(child, i2);
15671 }
15672 });
15673 }
15674 return this.walk(function(child, i2) {
15675 if (child.type === "atrule" && child.name === name) {
15676 return callback(child, i2);
15677 }
15678 });
15679 };
15680 _proto.walkComments = function walkComments(callback) {
15681 return this.walk(function(child, i2) {
15682 if (child.type === "comment") {
15683 return callback(child, i2);
15684 }
15685 });
15686 };
15687 _proto.walkDecls = function walkDecls(prop, callback) {
15688 if (!callback) {
15689 callback = prop;
15690 return this.walk(function(child, i2) {
15691 if (child.type === "decl") {
15692 return callback(child, i2);
15693 }
15694 });
15695 }
15696 if (_instanceof(prop, RegExp)) {
15697 return this.walk(function(child, i2) {
15698 if (child.type === "decl" && prop.test(child.prop)) {
15699 return callback(child, i2);
15700 }
15701 });
15702 }
15703 return this.walk(function(child, i2) {
15704 if (child.type === "decl" && child.prop === prop) {
15705 return callback(child, i2);
15706 }
15707 });
15708 };
15709 _proto.walkRules = function walkRules(selector, callback) {
15710 if (!callback) {
15711 callback = selector;
15712 return this.walk(function(child, i2) {
15713 if (child.type === "rule") {
15714 return callback(child, i2);
15715 }
15716 });
15717 }
15718 if (_instanceof(selector, RegExp)) {
15719 return this.walk(function(child, i2) {
15720 if (child.type === "rule" && selector.test(child.selector)) {
15721 return callback(child, i2);
15722 }
15723 });
15724 }
15725 return this.walk(function(child, i2) {
15726 if (child.type === "rule" && child.selector === selector) {
15727 return callback(child, i2);
15728 }
15729 });
15730 };
15731 _create_class(Container2, [
15732 {
15733 key: "first",
15734 get: function get() {
15735 if (!this.proxyOf.nodes) return void 0;
15736 return this.proxyOf.nodes[0];
15737 }
15738 },
15739 {
15740 key: "last",
15741 get: function get() {
15742 if (!this.proxyOf.nodes) return void 0;
15743 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
15744 }
15745 }
15746 ]);
15747 return Container2;
15748 }(Node$1);
15749 Container$7.registerParse = function(dependant) {
15750 parse$4 = dependant;
15751 };
15752 Container$7.registerRule = function(dependant) {
15753 Rule$4 = dependant;
15754 };
15755 Container$7.registerAtRule = function(dependant) {
15756 AtRule$4 = dependant;
15757 };
15758 Container$7.registerRoot = function(dependant) {
15759 Root$6 = dependant;
15760 };
15761 var container = Container$7;
15762 Container$7.default = Container$7;
15763 Container$7.rebuild = function(node2) {
15764 if (node2.type === "atrule") {
15765 Object.setPrototypeOf(node2, AtRule$4.prototype);
15766 } else if (node2.type === "rule") {
15767 Object.setPrototypeOf(node2, Rule$4.prototype);
15768 } else if (node2.type === "decl") {
15769 Object.setPrototypeOf(node2, Declaration$3.prototype);
15770 } else if (node2.type === "comment") {
15771 Object.setPrototypeOf(node2, Comment$3.prototype);
15772 } else if (node2.type === "root") {
15773 Object.setPrototypeOf(node2, Root$6.prototype);
15774 }
15775 node2[my$1] = true;
15776 if (node2.nodes) {
15777 node2.nodes.forEach(function(child) {
15778 Container$7.rebuild(child);
15779 });
15780 }
15781 };
15782 var Container$6 = container;
15783 var LazyResult$4, Processor$3;
15784 var Document$3 = /*#__PURE__*/ function(Container$6) {
15785 _inherits(Document23, Container$6);
15786 function Document23(defaults) {
15787 var _this;
15788 _this = Container$6.call(this, _extends({
15789 type: "document"
15790 }, defaults)) || this;
15791 if (!_this.nodes) {
15792 _this.nodes = [];
15793 }
15794 return _this;
15795 }
15796 var _proto = Document23.prototype;
15797 _proto.toResult = function toResult(opts) {
15798 if (opts === void 0) opts = {};
15799 var lazy = new LazyResult$4(new Processor$3(), this, opts);
15800 return lazy.stringify();
15801 };
15802 return Document23;
15803 }(Container$6);
15804 Document$3.registerLazyResult = function(dependant) {
15805 LazyResult$4 = dependant;
15806 };
15807 Document$3.registerProcessor = function(dependant) {
15808 Processor$3 = dependant;
15809 };
15810 var document$1$2 = Document$3;
15811 Document$3.default = Document$3;
15812 var printed = {};
15813 var warnOnce$2 = function warnOnce2(message) {
15814 if (printed[message]) return;
15815 printed[message] = true;
15816 if (typeof console !== "undefined" && console.warn) {
15817 console.warn(message);
15818 }
15819 };
15820 var Warning$2 = /*#__PURE__*/ function() {
15821 function Warning2(text, opts) {
15822 if (opts === void 0) opts = {};
15823 this.type = "warning";
15824 this.text = text;
15825 if (opts.node && opts.node.source) {
15826 var range = opts.node.rangeBy(opts);
15827 this.line = range.start.line;
15828 this.column = range.start.column;
15829 this.endLine = range.end.line;
15830 this.endColumn = range.end.column;
15831 }
15832 for(var opt in opts)this[opt] = opts[opt];
15833 }
15834 var _proto = Warning2.prototype;
15835 _proto.toString = function toString() {
15836 if (this.node) {
15837 return this.node.error(this.text, {
15838 index: this.index,
15839 plugin: this.plugin,
15840 word: this.word
15841 }).message;
15842 }
15843 if (this.plugin) {
15844 return this.plugin + ": " + this.text;
15845 }
15846 return this.text;
15847 };
15848 return Warning2;
15849 }();
15850 var warning = Warning$2;
15851 Warning$2.default = Warning$2;
15852 var Warning$1 = warning;
15853 var Result$3 = /*#__PURE__*/ function() {
15854 function Result2(processor2, root2, opts) {
15855 this.processor = processor2;
15856 this.messages = [];
15857 this.root = root2;
15858 this.opts = opts;
15859 this.css = void 0;
15860 this.map = void 0;
15861 }
15862 var _proto = Result2.prototype;
15863 _proto.toString = function toString() {
15864 return this.css;
15865 };
15866 _proto.warn = function warn(text, opts) {
15867 if (opts === void 0) opts = {};
15868 if (!opts.plugin) {
15869 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
15870 opts.plugin = this.lastPlugin.postcssPlugin;
15871 }
15872 }
15873 var warning2 = new Warning$1(text, opts);
15874 this.messages.push(warning2);
15875 return warning2;
15876 };
15877 _proto.warnings = function warnings() {
15878 return this.messages.filter(function(i2) {
15879 return i2.type === "warning";
15880 });
15881 };
15882 _create_class(Result2, [
15883 {
15884 key: "content",
15885 get: function get() {
15886 return this.css;
15887 }
15888 }
15889 ]);
15890 return Result2;
15891 }();
15892 var result = Result$3;
15893 Result$3.default = Result$3;
15894 var SINGLE_QUOTE = "'".charCodeAt(0);
15895 var DOUBLE_QUOTE = '"'.charCodeAt(0);
15896 var BACKSLASH = "\\".charCodeAt(0);
15897 var SLASH = "/".charCodeAt(0);
15898 var NEWLINE = "\n".charCodeAt(0);
15899 var SPACE = " ".charCodeAt(0);
15900 var FEED = "\f".charCodeAt(0);
15901 var TAB = " ".charCodeAt(0);
15902 var CR = "\r".charCodeAt(0);
15903 var OPEN_SQUARE = "[".charCodeAt(0);
15904 var CLOSE_SQUARE = "]".charCodeAt(0);
15905 var OPEN_PARENTHESES = "(".charCodeAt(0);
15906 var CLOSE_PARENTHESES = ")".charCodeAt(0);
15907 var OPEN_CURLY = "{".charCodeAt(0);
15908 var CLOSE_CURLY = "}".charCodeAt(0);
15909 var SEMICOLON = ";".charCodeAt(0);
15910 var ASTERISK = "*".charCodeAt(0);
15911 var COLON = ":".charCodeAt(0);
15912 var AT = "@".charCodeAt(0);
15913 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
15914 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
15915 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
15916 var RE_HEX_ESCAPE = /[\da-f]/i;
15917 var tokenize = function tokenizer2(input2, options) {
15918 if (options === void 0) options = {};
15919 var css = input2.css.valueOf();
15920 var ignore = options.ignoreErrors;
15921 var code, next, quote, content, escape;
15922 var escaped, escapePos, prev, n2, currentToken;
15923 var length = css.length;
15924 var pos = 0;
15925 var buffer = [];
15926 var returned = [];
15927 function position() {
15928 return pos;
15929 }
15930 function unclosed(what) {
15931 throw input2.error("Unclosed " + what, pos);
15932 }
15933 function endOfFile() {
15934 return returned.length === 0 && pos >= length;
15935 }
15936 function nextToken(opts) {
15937 if (returned.length) return returned.pop();
15938 if (pos >= length) return;
15939 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
15940 code = css.charCodeAt(pos);
15941 switch(code){
15942 case NEWLINE:
15943 case SPACE:
15944 case TAB:
15945 case CR:
15946 case FEED:
15947 {
15948 next = pos;
15949 do {
15950 next += 1;
15951 code = css.charCodeAt(next);
15952 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
15953 currentToken = [
15954 "space",
15955 css.slice(pos, next)
15956 ];
15957 pos = next - 1;
15958 break;
15959 }
15960 case OPEN_SQUARE:
15961 case CLOSE_SQUARE:
15962 case OPEN_CURLY:
15963 case CLOSE_CURLY:
15964 case COLON:
15965 case SEMICOLON:
15966 case CLOSE_PARENTHESES:
15967 {
15968 var controlChar = String.fromCharCode(code);
15969 currentToken = [
15970 controlChar,
15971 controlChar,
15972 pos
15973 ];
15974 break;
15975 }
15976 case OPEN_PARENTHESES:
15977 {
15978 prev = buffer.length ? buffer.pop()[1] : "";
15979 n2 = css.charCodeAt(pos + 1);
15980 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
15981 next = pos;
15982 do {
15983 escaped = false;
15984 next = css.indexOf(")", next + 1);
15985 if (next === -1) {
15986 if (ignore || ignoreUnclosed) {
15987 next = pos;
15988 break;
15989 } else {
15990 unclosed("bracket");
15991 }
15992 }
15993 escapePos = next;
15994 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
15995 escapePos -= 1;
15996 escaped = !escaped;
15997 }
15998 }while (escaped);
15999 currentToken = [
16000 "brackets",
16001 css.slice(pos, next + 1),
16002 pos,
16003 next
16004 ];
16005 pos = next;
16006 } else {
16007 next = css.indexOf(")", pos + 1);
16008 content = css.slice(pos, next + 1);
16009 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16010 currentToken = [
16011 "(",
16012 "(",
16013 pos
16014 ];
16015 } else {
16016 currentToken = [
16017 "brackets",
16018 content,
16019 pos,
16020 next
16021 ];
16022 pos = next;
16023 }
16024 }
16025 break;
16026 }
16027 case SINGLE_QUOTE:
16028 case DOUBLE_QUOTE:
16029 {
16030 quote = code === SINGLE_QUOTE ? "'" : '"';
16031 next = pos;
16032 do {
16033 escaped = false;
16034 next = css.indexOf(quote, next + 1);
16035 if (next === -1) {
16036 if (ignore || ignoreUnclosed) {
16037 next = pos + 1;
16038 break;
16039 } else {
16040 unclosed("string");
16041 }
16042 }
16043 escapePos = next;
16044 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16045 escapePos -= 1;
16046 escaped = !escaped;
16047 }
16048 }while (escaped);
16049 currentToken = [
16050 "string",
16051 css.slice(pos, next + 1),
16052 pos,
16053 next
16054 ];
16055 pos = next;
16056 break;
16057 }
16058 case AT:
16059 {
16060 RE_AT_END.lastIndex = pos + 1;
16061 RE_AT_END.test(css);
16062 if (RE_AT_END.lastIndex === 0) {
16063 next = css.length - 1;
16064 } else {
16065 next = RE_AT_END.lastIndex - 2;
16066 }
16067 currentToken = [
16068 "at-word",
16069 css.slice(pos, next + 1),
16070 pos,
16071 next
16072 ];
16073 pos = next;
16074 break;
16075 }
16076 case BACKSLASH:
16077 {
16078 next = pos;
16079 escape = true;
16080 while(css.charCodeAt(next + 1) === BACKSLASH){
16081 next += 1;
16082 escape = !escape;
16083 }
16084 code = css.charCodeAt(next + 1);
16085 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16086 next += 1;
16087 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16088 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16089 next += 1;
16090 }
16091 if (css.charCodeAt(next + 1) === SPACE) {
16092 next += 1;
16093 }
16094 }
16095 }
16096 currentToken = [
16097 "word",
16098 css.slice(pos, next + 1),
16099 pos,
16100 next
16101 ];
16102 pos = next;
16103 break;
16104 }
16105 default:
16106 {
16107 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16108 next = css.indexOf("*/", pos + 2) + 1;
16109 if (next === 0) {
16110 if (ignore || ignoreUnclosed) {
16111 next = css.length;
16112 } else {
16113 unclosed("comment");
16114 }
16115 }
16116 currentToken = [
16117 "comment",
16118 css.slice(pos, next + 1),
16119 pos,
16120 next
16121 ];
16122 pos = next;
16123 } else {
16124 RE_WORD_END.lastIndex = pos + 1;
16125 RE_WORD_END.test(css);
16126 if (RE_WORD_END.lastIndex === 0) {
16127 next = css.length - 1;
16128 } else {
16129 next = RE_WORD_END.lastIndex - 2;
16130 }
16131 currentToken = [
16132 "word",
16133 css.slice(pos, next + 1),
16134 pos,
16135 next
16136 ];
16137 buffer.push(currentToken);
16138 pos = next;
16139 }
16140 break;
16141 }
16142 }
16143 pos++;
16144 return currentToken;
16145 }
16146 function back(token) {
16147 returned.push(token);
16148 }
16149 return {
16150 back: back,
16151 endOfFile: endOfFile,
16152 nextToken: nextToken,
16153 position: position
16154 };
16155 };
16156 var Container$5 = container;
16157 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16158 _inherits(AtRule2, Container$5);
16159 function AtRule2(defaults) {
16160 var _this;
16161 _this = Container$5.call(this, defaults) || this;
16162 _this.type = "atrule";
16163 return _this;
16164 }
16165 var _proto = AtRule2.prototype;
16166 _proto.append = function append() {
16167 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16168 children[_key] = arguments[_key];
16169 }
16170 var _Container$5_prototype_append;
16171 if (!this.proxyOf.nodes) this.nodes = [];
16172 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
16173 this
16174 ], children));
16175 };
16176 _proto.prepend = function prepend() {
16177 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16178 children[_key] = arguments[_key];
16179 }
16180 var _Container$5_prototype_prepend;
16181 if (!this.proxyOf.nodes) this.nodes = [];
16182 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
16183 this
16184 ], children));
16185 };
16186 return AtRule2;
16187 }(Container$5);
16188 var atRule = AtRule$3;
16189 AtRule$3.default = AtRule$3;
16190 Container$5.registerAtRule(AtRule$3);
16191 var Container$4 = container;
16192 var LazyResult$3, Processor$2;
16193 var Root$5 = /*#__PURE__*/ function(Container$4) {
16194 _inherits(Root2, Container$4);
16195 function Root2(defaults) {
16196 var _this;
16197 _this = Container$4.call(this, defaults) || this;
16198 _this.type = "root";
16199 if (!_this.nodes) _this.nodes = [];
16200 return _this;
16201 }
16202 var _proto = Root2.prototype;
16203 _proto.normalize = function normalize(child, sample, type) {
16204 var nodes = Container$4.prototype.normalize.call(this, child);
16205 if (sample) {
16206 if (type === "prepend") {
16207 if (this.nodes.length > 1) {
16208 sample.raws.before = this.nodes[1].raws.before;
16209 } else {
16210 delete sample.raws.before;
16211 }
16212 } else if (this.first !== sample) {
16213 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16214 var node2 = _step.value;
16215 node2.raws.before = sample.raws.before;
16216 }
16217 }
16218 }
16219 return nodes;
16220 };
16221 _proto.removeChild = function removeChild(child, ignore) {
16222 var index2 = this.index(child);
16223 if (!ignore && index2 === 0 && this.nodes.length > 1) {
16224 this.nodes[1].raws.before = this.nodes[index2].raws.before;
16225 }
16226 return Container$4.prototype.removeChild.call(this, child);
16227 };
16228 _proto.toResult = function toResult(opts) {
16229 if (opts === void 0) opts = {};
16230 var lazy = new LazyResult$3(new Processor$2(), this, opts);
16231 return lazy.stringify();
16232 };
16233 return Root2;
16234 }(Container$4);
16235 Root$5.registerLazyResult = function(dependant) {
16236 LazyResult$3 = dependant;
16237 };
16238 Root$5.registerProcessor = function(dependant) {
16239 Processor$2 = dependant;
16240 };
16241 var root = Root$5;
16242 Root$5.default = Root$5;
16243 Container$4.registerRoot(Root$5);
16244 var list$2 = {
16245 comma: function comma(string) {
16246 return list$2.split(string, [
16247 ","
16248 ], true);
16249 },
16250 space: function space(string) {
16251 var spaces = [
16252 " ",
16253 "\n",
16254 " "
16255 ];
16256 return list$2.split(string, spaces);
16257 },
16258 split: function split(string, separators, last) {
16259 var array = [];
16260 var current = "";
16261 var split = false;
16262 var func = 0;
16263 var inQuote = false;
16264 var prevQuote = "";
16265 var escape = false;
16266 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
16267 var letter = _step.value;
16268 if (escape) {
16269 escape = false;
16270 } else if (letter === "\\") {
16271 escape = true;
16272 } else if (inQuote) {
16273 if (letter === prevQuote) {
16274 inQuote = false;
16275 }
16276 } else if (letter === '"' || letter === "'") {
16277 inQuote = true;
16278 prevQuote = letter;
16279 } else if (letter === "(") {
16280 func += 1;
16281 } else if (letter === ")") {
16282 if (func > 0) func -= 1;
16283 } else if (func === 0) {
16284 if (separators.includes(letter)) split = true;
16285 }
16286 if (split) {
16287 if (current !== "") array.push(current.trim());
16288 current = "";
16289 split = false;
16290 } else {
16291 current += letter;
16292 }
16293 }
16294 if (last || current !== "") array.push(current.trim());
16295 return array;
16296 }
16297 };
16298 var list_1 = list$2;
16299 list$2.default = list$2;
16300 var Container$3 = container;
16301 var list$1 = list_1;
16302 var Rule$3 = /*#__PURE__*/ function(Container$3) {
16303 _inherits(Rule2, Container$3);
16304 function Rule2(defaults) {
16305 var _this;
16306 _this = Container$3.call(this, defaults) || this;
16307 _this.type = "rule";
16308 if (!_this.nodes) _this.nodes = [];
16309 return _this;
16310 }
16311 _create_class(Rule2, [
16312 {
16313 key: "selectors",
16314 get: function get() {
16315 return list$1.comma(this.selector);
16316 },
16317 set: function set(values) {
16318 var match = this.selector ? this.selector.match(/,\s*/) : null;
16319 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
16320 this.selector = values.join(sep2);
16321 }
16322 }
16323 ]);
16324 return Rule2;
16325 }(Container$3);
16326 var rule = Rule$3;
16327 Rule$3.default = Rule$3;
16328 Container$3.registerRule(Rule$3);
16329 var Declaration$2 = declaration;
16330 var tokenizer22 = tokenize;
16331 var Comment$2 = comment;
16332 var AtRule$2 = atRule;
16333 var Root$4 = root;
16334 var Rule$2 = rule;
16335 var SAFE_COMMENT_NEIGHBOR = {
16336 empty: true,
16337 space: true
16338 };
16339 function findLastWithPosition(tokens) {
16340 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16341 var token = tokens[i2];
16342 var pos = token[3] || token[2];
16343 if (pos) return pos;
16344 }
16345 }
16346 var Parser$1 = /*#__PURE__*/ function() {
16347 function Parser2(input2) {
16348 this.input = input2;
16349 this.root = new Root$4();
16350 this.current = this.root;
16351 this.spaces = "";
16352 this.semicolon = false;
16353 this.createTokenizer();
16354 this.root.source = {
16355 input: input2,
16356 start: {
16357 column: 1,
16358 line: 1,
16359 offset: 0
16360 }
16361 };
16362 }
16363 var _proto = Parser2.prototype;
16364 _proto.atrule = function atrule(token) {
16365 var node2 = new AtRule$2();
16366 node2.name = token[1].slice(1);
16367 if (node2.name === "") {
16368 this.unnamedAtrule(node2, token);
16369 }
16370 this.init(node2, token[2]);
16371 var type;
16372 var prev;
16373 var shift;
16374 var last = false;
16375 var open = false;
16376 var params = [];
16377 var brackets = [];
16378 while(!this.tokenizer.endOfFile()){
16379 token = this.tokenizer.nextToken();
16380 type = token[0];
16381 if (type === "(" || type === "[") {
16382 brackets.push(type === "(" ? ")" : "]");
16383 } else if (type === "{" && brackets.length > 0) {
16384 brackets.push("}");
16385 } else if (type === brackets[brackets.length - 1]) {
16386 brackets.pop();
16387 }
16388 if (brackets.length === 0) {
16389 if (type === ";") {
16390 node2.source.end = this.getPosition(token[2]);
16391 node2.source.end.offset++;
16392 this.semicolon = true;
16393 break;
16394 } else if (type === "{") {
16395 open = true;
16396 break;
16397 } else if (type === "}") {
16398 if (params.length > 0) {
16399 shift = params.length - 1;
16400 prev = params[shift];
16401 while(prev && prev[0] === "space"){
16402 prev = params[--shift];
16403 }
16404 if (prev) {
16405 node2.source.end = this.getPosition(prev[3] || prev[2]);
16406 node2.source.end.offset++;
16407 }
16408 }
16409 this.end(token);
16410 break;
16411 } else {
16412 params.push(token);
16413 }
16414 } else {
16415 params.push(token);
16416 }
16417 if (this.tokenizer.endOfFile()) {
16418 last = true;
16419 break;
16420 }
16421 }
16422 node2.raws.between = this.spacesAndCommentsFromEnd(params);
16423 if (params.length) {
16424 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
16425 this.raw(node2, "params", params);
16426 if (last) {
16427 token = params[params.length - 1];
16428 node2.source.end = this.getPosition(token[3] || token[2]);
16429 node2.source.end.offset++;
16430 this.spaces = node2.raws.between;
16431 node2.raws.between = "";
16432 }
16433 } else {
16434 node2.raws.afterName = "";
16435 node2.params = "";
16436 }
16437 if (open) {
16438 node2.nodes = [];
16439 this.current = node2;
16440 }
16441 };
16442 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
16443 var colon = this.colon(tokens);
16444 if (colon === false) return;
16445 var founded = 0;
16446 var token;
16447 for(var j = colon - 1; j >= 0; j--){
16448 token = tokens[j];
16449 if (token[0] !== "space") {
16450 founded += 1;
16451 if (founded === 2) break;
16452 }
16453 }
16454 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
16455 };
16456 _proto.colon = function colon(tokens) {
16457 var brackets = 0;
16458 var token, type, prev;
16459 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
16460 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
16461 token = element;
16462 type = token[0];
16463 if (type === "(") {
16464 brackets += 1;
16465 }
16466 if (type === ")") {
16467 brackets -= 1;
16468 }
16469 if (brackets === 0 && type === ":") {
16470 if (!prev) {
16471 this.doubleColon(token);
16472 } else if (prev[0] === "word" && prev[1] === "progid") {
16473 continue;
16474 } else {
16475 return i2;
16476 }
16477 }
16478 prev = token;
16479 }
16480 return false;
16481 };
16482 _proto.comment = function comment(token) {
16483 var node2 = new Comment$2();
16484 this.init(node2, token[2]);
16485 node2.source.end = this.getPosition(token[3] || token[2]);
16486 node2.source.end.offset++;
16487 var text = token[1].slice(2, -2);
16488 if (/^\s*$/.test(text)) {
16489 node2.text = "";
16490 node2.raws.left = text;
16491 node2.raws.right = "";
16492 } else {
16493 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
16494 node2.text = match[2];
16495 node2.raws.left = match[1];
16496 node2.raws.right = match[3];
16497 }
16498 };
16499 _proto.createTokenizer = function createTokenizer() {
16500 this.tokenizer = tokenizer22(this.input);
16501 };
16502 _proto.decl = function decl(tokens, customProperty) {
16503 var node2 = new Declaration$2();
16504 this.init(node2, tokens[0][2]);
16505 var last = tokens[tokens.length - 1];
16506 if (last[0] === ";") {
16507 this.semicolon = true;
16508 tokens.pop();
16509 }
16510 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
16511 node2.source.end.offset++;
16512 while(tokens[0][0] !== "word"){
16513 if (tokens.length === 1) this.unknownWord(tokens);
16514 node2.raws.before += tokens.shift()[1];
16515 }
16516 node2.source.start = this.getPosition(tokens[0][2]);
16517 node2.prop = "";
16518 while(tokens.length){
16519 var type = tokens[0][0];
16520 if (type === ":" || type === "space" || type === "comment") {
16521 break;
16522 }
16523 node2.prop += tokens.shift()[1];
16524 }
16525 node2.raws.between = "";
16526 var token;
16527 while(tokens.length){
16528 token = tokens.shift();
16529 if (token[0] === ":") {
16530 node2.raws.between += token[1];
16531 break;
16532 } else {
16533 if (token[0] === "word" && /\w/.test(token[1])) {
16534 this.unknownWord([
16535 token
16536 ]);
16537 }
16538 node2.raws.between += token[1];
16539 }
16540 }
16541 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
16542 node2.raws.before += node2.prop[0];
16543 node2.prop = node2.prop.slice(1);
16544 }
16545 var firstSpaces = [];
16546 var next;
16547 while(tokens.length){
16548 next = tokens[0][0];
16549 if (next !== "space" && next !== "comment") break;
16550 firstSpaces.push(tokens.shift());
16551 }
16552 this.precheckMissedSemicolon(tokens);
16553 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
16554 token = tokens[i2];
16555 if (token[1].toLowerCase() === "!important") {
16556 node2.important = true;
16557 var string = this.stringFrom(tokens, i2);
16558 string = this.spacesFromEnd(tokens) + string;
16559 if (string !== " !important") node2.raws.important = string;
16560 break;
16561 } else if (token[1].toLowerCase() === "important") {
16562 var cache = tokens.slice(0);
16563 var str = "";
16564 for(var j = i2; j > 0; j--){
16565 var type1 = cache[j][0];
16566 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
16567 break;
16568 }
16569 str = cache.pop()[1] + str;
16570 }
16571 if (str.trim().indexOf("!") === 0) {
16572 node2.important = true;
16573 node2.raws.important = str;
16574 tokens = cache;
16575 }
16576 }
16577 if (token[0] !== "space" && token[0] !== "comment") {
16578 break;
16579 }
16580 }
16581 var hasWord = tokens.some(function(i2) {
16582 return i2[0] !== "space" && i2[0] !== "comment";
16583 });
16584 if (hasWord) {
16585 node2.raws.between += firstSpaces.map(function(i2) {
16586 return i2[1];
16587 }).join("");
16588 firstSpaces = [];
16589 }
16590 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
16591 if (node2.value.includes(":") && !customProperty) {
16592 this.checkMissedSemicolon(tokens);
16593 }
16594 };
16595 _proto.doubleColon = function doubleColon(token) {
16596 throw this.input.error("Double colon", {
16597 offset: token[2]
16598 }, {
16599 offset: token[2] + token[1].length
16600 });
16601 };
16602 _proto.emptyRule = function emptyRule(token) {
16603 var node2 = new Rule$2();
16604 this.init(node2, token[2]);
16605 node2.selector = "";
16606 node2.raws.between = "";
16607 this.current = node2;
16608 };
16609 _proto.end = function end(token) {
16610 if (this.current.nodes && this.current.nodes.length) {
16611 this.current.raws.semicolon = this.semicolon;
16612 }
16613 this.semicolon = false;
16614 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16615 this.spaces = "";
16616 if (this.current.parent) {
16617 this.current.source.end = this.getPosition(token[2]);
16618 this.current.source.end.offset++;
16619 this.current = this.current.parent;
16620 } else {
16621 this.unexpectedClose(token);
16622 }
16623 };
16624 _proto.endFile = function endFile() {
16625 if (this.current.parent) this.unclosedBlock();
16626 if (this.current.nodes && this.current.nodes.length) {
16627 this.current.raws.semicolon = this.semicolon;
16628 }
16629 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
16630 this.root.source.end = this.getPosition(this.tokenizer.position());
16631 };
16632 _proto.freeSemicolon = function freeSemicolon(token) {
16633 this.spaces += token[1];
16634 if (this.current.nodes) {
16635 var prev = this.current.nodes[this.current.nodes.length - 1];
16636 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
16637 prev.raws.ownSemicolon = this.spaces;
16638 this.spaces = "";
16639 }
16640 }
16641 };
16642 // Helpers
16643 _proto.getPosition = function getPosition(offset) {
16644 var pos = this.input.fromOffset(offset);
16645 return {
16646 column: pos.col,
16647 line: pos.line,
16648 offset: offset
16649 };
16650 };
16651 _proto.init = function init(node2, offset) {
16652 this.current.push(node2);
16653 node2.source = {
16654 input: this.input,
16655 start: this.getPosition(offset)
16656 };
16657 node2.raws.before = this.spaces;
16658 this.spaces = "";
16659 if (node2.type !== "comment") this.semicolon = false;
16660 };
16661 _proto.other = function other(start) {
16662 var end = false;
16663 var type = null;
16664 var colon = false;
16665 var bracket = null;
16666 var brackets = [];
16667 var customProperty = start[1].startsWith("--");
16668 var tokens = [];
16669 var token = start;
16670 while(token){
16671 type = token[0];
16672 tokens.push(token);
16673 if (type === "(" || type === "[") {
16674 if (!bracket) bracket = token;
16675 brackets.push(type === "(" ? ")" : "]");
16676 } else if (customProperty && colon && type === "{") {
16677 if (!bracket) bracket = token;
16678 brackets.push("}");
16679 } else if (brackets.length === 0) {
16680 if (type === ";") {
16681 if (colon) {
16682 this.decl(tokens, customProperty);
16683 return;
16684 } else {
16685 break;
16686 }
16687 } else if (type === "{") {
16688 this.rule(tokens);
16689 return;
16690 } else if (type === "}") {
16691 this.tokenizer.back(tokens.pop());
16692 end = true;
16693 break;
16694 } else if (type === ":") {
16695 colon = true;
16696 }
16697 } else if (type === brackets[brackets.length - 1]) {
16698 brackets.pop();
16699 if (brackets.length === 0) bracket = null;
16700 }
16701 token = this.tokenizer.nextToken();
16702 }
16703 if (this.tokenizer.endOfFile()) end = true;
16704 if (brackets.length > 0) this.unclosedBracket(bracket);
16705 if (end && colon) {
16706 if (!customProperty) {
16707 while(tokens.length){
16708 token = tokens[tokens.length - 1][0];
16709 if (token !== "space" && token !== "comment") break;
16710 this.tokenizer.back(tokens.pop());
16711 }
16712 }
16713 this.decl(tokens, customProperty);
16714 } else {
16715 this.unknownWord(tokens);
16716 }
16717 };
16718 _proto.parse = function parse() {
16719 var token;
16720 while(!this.tokenizer.endOfFile()){
16721 token = this.tokenizer.nextToken();
16722 switch(token[0]){
16723 case "space":
16724 this.spaces += token[1];
16725 break;
16726 case ";":
16727 this.freeSemicolon(token);
16728 break;
16729 case "}":
16730 this.end(token);
16731 break;
16732 case "comment":
16733 this.comment(token);
16734 break;
16735 case "at-word":
16736 this.atrule(token);
16737 break;
16738 case "{":
16739 this.emptyRule(token);
16740 break;
16741 default:
16742 this.other(token);
16743 break;
16744 }
16745 }
16746 this.endFile();
16747 };
16748 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
16749 _proto.raw = function raw(node2, prop, tokens, customProperty) {
16750 var token, type;
16751 var length = tokens.length;
16752 var value = "";
16753 var clean = true;
16754 var next, prev;
16755 for(var i2 = 0; i2 < length; i2 += 1){
16756 token = tokens[i2];
16757 type = token[0];
16758 if (type === "space" && i2 === length - 1 && !customProperty) {
16759 clean = false;
16760 } else if (type === "comment") {
16761 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
16762 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
16763 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
16764 if (value.slice(-1) === ",") {
16765 clean = false;
16766 } else {
16767 value += token[1];
16768 }
16769 } else {
16770 clean = false;
16771 }
16772 } else {
16773 value += token[1];
16774 }
16775 }
16776 if (!clean) {
16777 var raw = tokens.reduce(function(all, i2) {
16778 return all + i2[1];
16779 }, "");
16780 node2.raws[prop] = {
16781 raw: raw,
16782 value: value
16783 };
16784 }
16785 node2[prop] = value;
16786 };
16787 _proto.rule = function rule(tokens) {
16788 tokens.pop();
16789 var node2 = new Rule$2();
16790 this.init(node2, tokens[0][2]);
16791 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
16792 this.raw(node2, "selector", tokens);
16793 this.current = node2;
16794 };
16795 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
16796 var lastTokenType;
16797 var spaces = "";
16798 while(tokens.length){
16799 lastTokenType = tokens[tokens.length - 1][0];
16800 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
16801 spaces = tokens.pop()[1] + spaces;
16802 }
16803 return spaces;
16804 };
16805 // Errors
16806 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
16807 var next;
16808 var spaces = "";
16809 while(tokens.length){
16810 next = tokens[0][0];
16811 if (next !== "space" && next !== "comment") break;
16812 spaces += tokens.shift()[1];
16813 }
16814 return spaces;
16815 };
16816 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
16817 var lastTokenType;
16818 var spaces = "";
16819 while(tokens.length){
16820 lastTokenType = tokens[tokens.length - 1][0];
16821 if (lastTokenType !== "space") break;
16822 spaces = tokens.pop()[1] + spaces;
16823 }
16824 return spaces;
16825 };
16826 _proto.stringFrom = function stringFrom(tokens, from) {
16827 var result2 = "";
16828 for(var i2 = from; i2 < tokens.length; i2++){
16829 result2 += tokens[i2][1];
16830 }
16831 tokens.splice(from, tokens.length - from);
16832 return result2;
16833 };
16834 _proto.unclosedBlock = function unclosedBlock() {
16835 var pos = this.current.source.start;
16836 throw this.input.error("Unclosed block", pos.line, pos.column);
16837 };
16838 _proto.unclosedBracket = function unclosedBracket(bracket) {
16839 throw this.input.error("Unclosed bracket", {
16840 offset: bracket[2]
16841 }, {
16842 offset: bracket[2] + 1
16843 });
16844 };
16845 _proto.unexpectedClose = function unexpectedClose(token) {
16846 throw this.input.error("Unexpected }", {
16847 offset: token[2]
16848 }, {
16849 offset: token[2] + 1
16850 });
16851 };
16852 _proto.unknownWord = function unknownWord(tokens) {
16853 throw this.input.error("Unknown word", {
16854 offset: tokens[0][2]
16855 }, {
16856 offset: tokens[0][2] + tokens[0][1].length
16857 });
16858 };
16859 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
16860 throw this.input.error("At-rule without name", {
16861 offset: token[2]
16862 }, {
16863 offset: token[2] + token[1].length
16864 });
16865 };
16866 return Parser2;
16867 }();
16868 var parser = Parser$1;
16869 var Container$2 = container;
16870 var Parser22 = parser;
16871 var Input$2 = input;
16872 function parse$3(css, opts) {
16873 var input2 = new Input$2(css, opts);
16874 var parser2 = new Parser22(input2);
16875 try {
16876 parser2.parse();
16877 } catch (e2) {
16878 if (true) {
16879 if (e2.name === "CssSyntaxError" && opts && opts.from) {
16880 if (/\.scss$/i.test(opts.from)) {
16881 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
16882 } else if (/\.sass/i.test(opts.from)) {
16883 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
16884 } else if (/\.less$/i.test(opts.from)) {
16885 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
16886 }
16887 }
16888 }
16889 throw e2;
16890 }
16891 return parser2.root;
16892 }
16893 var parse_1 = parse$3;
16894 parse$3.default = parse$3;
16895 Container$2.registerParse(parse$3);
16896 var isClean = symbols.isClean, my = symbols.my;
16897 var MapGenerator$1 = mapGenerator;
16898 var stringify$2 = stringify_1;
16899 var Container$1 = container;
16900 var Document$2 = document$1$2;
16901 var warnOnce$1 = warnOnce$2;
16902 var Result$2 = result;
16903 var parse$2 = parse_1;
16904 var Root$3 = root;
16905 var TYPE_TO_CLASS_NAME = {
16906 atrule: "AtRule",
16907 comment: "Comment",
16908 decl: "Declaration",
16909 document: "Document",
16910 root: "Root",
16911 rule: "Rule"
16912 };
16913 var PLUGIN_PROPS = {
16914 AtRule: true,
16915 AtRuleExit: true,
16916 Comment: true,
16917 CommentExit: true,
16918 Declaration: true,
16919 DeclarationExit: true,
16920 Document: true,
16921 DocumentExit: true,
16922 Once: true,
16923 OnceExit: true,
16924 postcssPlugin: true,
16925 prepare: true,
16926 Root: true,
16927 RootExit: true,
16928 Rule: true,
16929 RuleExit: true
16930 };
16931 var NOT_VISITORS = {
16932 Once: true,
16933 postcssPlugin: true,
16934 prepare: true
16935 };
16936 var CHILDREN = 0;
16937 function isPromise(obj) {
16938 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
16939 }
16940 function getEvents(node2) {
16941 var key = false;
16942 var type = TYPE_TO_CLASS_NAME[node2.type];
16943 if (node2.type === "decl") {
16944 key = node2.prop.toLowerCase();
16945 } else if (node2.type === "atrule") {
16946 key = node2.name.toLowerCase();
16947 }
16948 if (key && node2.append) {
16949 return [
16950 type,
16951 type + "-" + key,
16952 CHILDREN,
16953 type + "Exit",
16954 type + "Exit-" + key
16955 ];
16956 } else if (key) {
16957 return [
16958 type,
16959 type + "-" + key,
16960 type + "Exit",
16961 type + "Exit-" + key
16962 ];
16963 } else if (node2.append) {
16964 return [
16965 type,
16966 CHILDREN,
16967 type + "Exit"
16968 ];
16969 } else {
16970 return [
16971 type,
16972 type + "Exit"
16973 ];
16974 }
16975 }
16976 function toStack(node2) {
16977 var events;
16978 if (node2.type === "document") {
16979 events = [
16980 "Document",
16981 CHILDREN,
16982 "DocumentExit"
16983 ];
16984 } else if (node2.type === "root") {
16985 events = [
16986 "Root",
16987 CHILDREN,
16988 "RootExit"
16989 ];
16990 } else {
16991 events = getEvents(node2);
16992 }
16993 return {
16994 eventIndex: 0,
16995 events: events,
16996 iterator: 0,
16997 node: node2,
16998 visitorIndex: 0,
16999 visitors: []
17000 };
17001 }
17002 function cleanMarks(node2) {
17003 node2[isClean] = false;
17004 if (node2.nodes) node2.nodes.forEach(function(i2) {
17005 return cleanMarks(i2);
17006 });
17007 return node2;
17008 }
17009 var postcss$2 = {};
17010 var LazyResult$2 = /*#__PURE__*/ function() {
17011 function LazyResult2(processor2, css, opts) {
17012 var _this = this;
17013 this.stringified = false;
17014 this.processed = false;
17015 var root2;
17016 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17017 root2 = cleanMarks(css);
17018 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17019 root2 = cleanMarks(css.root);
17020 if (css.map) {
17021 if (typeof opts.map === "undefined") opts.map = {};
17022 if (!opts.map.inline) opts.map.inline = false;
17023 opts.map.prev = css.map;
17024 }
17025 } else {
17026 var parser2 = parse$2;
17027 if (opts.syntax) parser2 = opts.syntax.parse;
17028 if (opts.parser) parser2 = opts.parser;
17029 if (parser2.parse) parser2 = parser2.parse;
17030 try {
17031 root2 = parser2(css, opts);
17032 } catch (error) {
17033 this.processed = true;
17034 this.error = error;
17035 }
17036 if (root2 && !root2[my]) {
17037 Container$1.rebuild(root2);
17038 }
17039 }
17040 this.result = new Result$2(processor2, root2, opts);
17041 this.helpers = _extends({}, postcss$2, {
17042 postcss: postcss$2,
17043 result: this.result
17044 });
17045 this.plugins = this.processor.plugins.map(function(plugin22) {
17046 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17047 return _extends({}, plugin22, plugin22.prepare(_this.result));
17048 } else {
17049 return plugin22;
17050 }
17051 });
17052 }
17053 var _proto = LazyResult2.prototype;
17054 _proto.async = function async() {
17055 if (this.error) return Promise.reject(this.error);
17056 if (this.processed) return Promise.resolve(this.result);
17057 if (!this.processing) {
17058 this.processing = this.runAsync();
17059 }
17060 return this.processing;
17061 };
17062 _proto.catch = function _catch(onRejected) {
17063 return this.async().catch(onRejected);
17064 };
17065 _proto.finally = function _finally(onFinally) {
17066 return this.async().then(onFinally, onFinally);
17067 };
17068 _proto.getAsyncError = function getAsyncError() {
17069 throw new Error("Use process(css).then(cb) to work with async plugins");
17070 };
17071 _proto.handleError = function handleError(error, node2) {
17072 var plugin22 = this.result.lastPlugin;
17073 try {
17074 if (node2) node2.addToError(error);
17075 this.error = error;
17076 if (error.name === "CssSyntaxError" && !error.plugin) {
17077 error.plugin = plugin22.postcssPlugin;
17078 error.setMessage();
17079 } else if (plugin22.postcssVersion) {
17080 if (true) {
17081 var pluginName = plugin22.postcssPlugin;
17082 var pluginVer = plugin22.postcssVersion;
17083 var runtimeVer = this.result.processor.version;
17084 var a2 = pluginVer.split(".");
17085 var b = runtimeVer.split(".");
17086 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17087 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.");
17088 }
17089 }
17090 }
17091 } catch (err) {
17092 if (console && console.error) console.error(err);
17093 }
17094 return error;
17095 };
17096 _proto.prepareVisitors = function prepareVisitors() {
17097 var _this = this;
17098 this.listeners = {};
17099 var add = function(plugin22, type, cb) {
17100 if (!_this.listeners[type]) _this.listeners[type] = [];
17101 _this.listeners[type].push([
17102 plugin22,
17103 cb
17104 ]);
17105 };
17106 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17107 var plugin22 = _step.value;
17108 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17109 for(var event in plugin22){
17110 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17111 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17112 }
17113 if (!NOT_VISITORS[event]) {
17114 if (_type_of(plugin22[event]) === "object") {
17115 for(var filter in plugin22[event]){
17116 if (filter === "*") {
17117 add(plugin22, event, plugin22[event][filter]);
17118 } else {
17119 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17120 }
17121 }
17122 } else if (typeof plugin22[event] === "function") {
17123 add(plugin22, event, plugin22[event]);
17124 }
17125 }
17126 }
17127 }
17128 }
17129 this.hasListener = Object.keys(this.listeners).length > 0;
17130 };
17131 _proto.runAsync = function runAsync() {
17132 var _this = this;
17133 return _async_to_generator(function() {
17134 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17135 return _ts_generator(this, function(_state) {
17136 switch(_state.label){
17137 case 0:
17138 _this.plugin = 0;
17139 i2 = 0;
17140 _state.label = 1;
17141 case 1:
17142 if (!(i2 < _this.plugins.length)) return [
17143 3,
17144 6
17145 ];
17146 plugin22 = _this.plugins[i2];
17147 promise = _this.runOnRoot(plugin22);
17148 if (!isPromise(promise)) return [
17149 3,
17150 5
17151 ];
17152 _state.label = 2;
17153 case 2:
17154 _state.trys.push([
17155 2,
17156 4,
17157 ,
17158 5
17159 ]);
17160 return [
17161 4,
17162 promise
17163 ];
17164 case 3:
17165 _state.sent();
17166 return [
17167 3,
17168 5
17169 ];
17170 case 4:
17171 error = _state.sent();
17172 throw _this.handleError(error);
17173 case 5:
17174 i2++;
17175 return [
17176 3,
17177 1
17178 ];
17179 case 6:
17180 _this.prepareVisitors();
17181 if (!_this.hasListener) return [
17182 3,
17183 18
17184 ];
17185 root2 = _this.result.root;
17186 _state.label = 7;
17187 case 7:
17188 if (!!root2[isClean]) return [
17189 3,
17190 14
17191 ];
17192 root2[isClean] = true;
17193 stack = [
17194 toStack(root2)
17195 ];
17196 _state.label = 8;
17197 case 8:
17198 if (!(stack.length > 0)) return [
17199 3,
17200 13
17201 ];
17202 promise1 = _this.visitTick(stack);
17203 if (!isPromise(promise1)) return [
17204 3,
17205 12
17206 ];
17207 _state.label = 9;
17208 case 9:
17209 _state.trys.push([
17210 9,
17211 11,
17212 ,
17213 12
17214 ]);
17215 return [
17216 4,
17217 promise1
17218 ];
17219 case 10:
17220 _state.sent();
17221 return [
17222 3,
17223 12
17224 ];
17225 case 11:
17226 e2 = _state.sent();
17227 node2 = stack[stack.length - 1].node;
17228 throw _this.handleError(e2, node2);
17229 case 12:
17230 return [
17231 3,
17232 8
17233 ];
17234 case 13:
17235 return [
17236 3,
17237 7
17238 ];
17239 case 14:
17240 if (!_this.listeners.OnceExit) return [
17241 3,
17242 18
17243 ];
17244 _loop = function() {
17245 var _step_value, plugin22, visitor, roots, e2;
17246 return _ts_generator(this, function(_state) {
17247 switch(_state.label){
17248 case 0:
17249 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17250 _this.result.lastPlugin = plugin22;
17251 _state.label = 1;
17252 case 1:
17253 _state.trys.push([
17254 1,
17255 6,
17256 ,
17257 7
17258 ]);
17259 if (!(root2.type === "document")) return [
17260 3,
17261 3
17262 ];
17263 roots = root2.nodes.map(function(subRoot) {
17264 return visitor(subRoot, _this.helpers);
17265 });
17266 return [
17267 4,
17268 Promise.all(roots)
17269 ];
17270 case 2:
17271 _state.sent();
17272 return [
17273 3,
17274 5
17275 ];
17276 case 3:
17277 return [
17278 4,
17279 visitor(root2, _this.helpers)
17280 ];
17281 case 4:
17282 _state.sent();
17283 _state.label = 5;
17284 case 5:
17285 return [
17286 3,
17287 7
17288 ];
17289 case 6:
17290 e2 = _state.sent();
17291 throw _this.handleError(e2);
17292 case 7:
17293 return [
17294 2
17295 ];
17296 }
17297 });
17298 };
17299 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
17300 _state.label = 15;
17301 case 15:
17302 if (!!(_step = _iterator()).done) return [
17303 3,
17304 18
17305 ];
17306 return [
17307 5,
17308 _ts_values(_loop())
17309 ];
17310 case 16:
17311 _state.sent();
17312 _state.label = 17;
17313 case 17:
17314 return [
17315 3,
17316 15
17317 ];
17318 case 18:
17319 _this.processed = true;
17320 return [
17321 2,
17322 _this.stringify()
17323 ];
17324 }
17325 });
17326 })();
17327 };
17328 _proto.runOnRoot = function runOnRoot(plugin22) {
17329 var _this = this;
17330 this.result.lastPlugin = plugin22;
17331 try {
17332 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
17333 if (this.result.root.type === "document") {
17334 var roots = this.result.root.nodes.map(function(root2) {
17335 return plugin22.Once(root2, _this.helpers);
17336 });
17337 if (isPromise(roots[0])) {
17338 return Promise.all(roots);
17339 }
17340 return roots;
17341 }
17342 return plugin22.Once(this.result.root, this.helpers);
17343 } else if (typeof plugin22 === "function") {
17344 return plugin22(this.result.root, this.result);
17345 }
17346 } catch (error) {
17347 throw this.handleError(error);
17348 }
17349 };
17350 _proto.stringify = function stringify() {
17351 if (this.error) throw this.error;
17352 if (this.stringified) return this.result;
17353 this.stringified = true;
17354 this.sync();
17355 var opts = this.result.opts;
17356 var str = stringify$2;
17357 if (opts.syntax) str = opts.syntax.stringify;
17358 if (opts.stringifier) str = opts.stringifier;
17359 if (str.stringify) str = str.stringify;
17360 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
17361 var data = map.generate();
17362 this.result.css = data[0];
17363 this.result.map = data[1];
17364 return this.result;
17365 };
17366 _proto.sync = function sync() {
17367 if (this.error) throw this.error;
17368 if (this.processed) return this.result;
17369 this.processed = true;
17370 if (this.processing) {
17371 throw this.getAsyncError();
17372 }
17373 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17374 var plugin22 = _step.value;
17375 var promise = this.runOnRoot(plugin22);
17376 if (isPromise(promise)) {
17377 throw this.getAsyncError();
17378 }
17379 }
17380 this.prepareVisitors();
17381 if (this.hasListener) {
17382 var root2 = this.result.root;
17383 while(!root2[isClean]){
17384 root2[isClean] = true;
17385 this.walkSync(root2);
17386 }
17387 if (this.listeners.OnceExit) {
17388 if (root2.type === "document") {
17389 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
17390 var subRoot = _step1.value;
17391 this.visitSync(this.listeners.OnceExit, subRoot);
17392 }
17393 } else {
17394 this.visitSync(this.listeners.OnceExit, root2);
17395 }
17396 }
17397 }
17398 return this.result;
17399 };
17400 _proto.then = function then(onFulfilled, onRejected) {
17401 if (true) {
17402 if (!("from" in this.opts)) {
17403 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.");
17404 }
17405 }
17406 return this.async().then(onFulfilled, onRejected);
17407 };
17408 _proto.toString = function toString() {
17409 return this.css;
17410 };
17411 _proto.visitSync = function visitSync(visitors, node2) {
17412 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
17413 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
17414 this.result.lastPlugin = plugin22;
17415 var promise = void 0;
17416 try {
17417 promise = visitor(node2, this.helpers);
17418 } catch (e2) {
17419 throw this.handleError(e2, node2.proxyOf);
17420 }
17421 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17422 return true;
17423 }
17424 if (isPromise(promise)) {
17425 throw this.getAsyncError();
17426 }
17427 }
17428 };
17429 _proto.visitTick = function visitTick(stack) {
17430 var visit2 = stack[stack.length - 1];
17431 var node2 = visit2.node, visitors = visit2.visitors;
17432 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
17433 stack.pop();
17434 return;
17435 }
17436 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
17437 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
17438 visit2.visitorIndex += 1;
17439 if (visit2.visitorIndex === visitors.length) {
17440 visit2.visitors = [];
17441 visit2.visitorIndex = 0;
17442 }
17443 this.result.lastPlugin = plugin22;
17444 try {
17445 return visitor(node2.toProxy(), this.helpers);
17446 } catch (e2) {
17447 throw this.handleError(e2, node2);
17448 }
17449 }
17450 if (visit2.iterator !== 0) {
17451 var iterator = visit2.iterator;
17452 var child;
17453 while(child = node2.nodes[node2.indexes[iterator]]){
17454 node2.indexes[iterator] += 1;
17455 if (!child[isClean]) {
17456 child[isClean] = true;
17457 stack.push(toStack(child));
17458 return;
17459 }
17460 }
17461 visit2.iterator = 0;
17462 delete node2.indexes[iterator];
17463 }
17464 var events = visit2.events;
17465 while(visit2.eventIndex < events.length){
17466 var event = events[visit2.eventIndex];
17467 visit2.eventIndex += 1;
17468 if (event === CHILDREN) {
17469 if (node2.nodes && node2.nodes.length) {
17470 node2[isClean] = true;
17471 visit2.iterator = node2.getIterator();
17472 }
17473 return;
17474 } else if (this.listeners[event]) {
17475 visit2.visitors = this.listeners[event];
17476 return;
17477 }
17478 }
17479 stack.pop();
17480 };
17481 _proto.walkSync = function walkSync(node2) {
17482 var _this = this;
17483 node2[isClean] = true;
17484 var events = getEvents(node2);
17485 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
17486 var event = _step.value;
17487 if (event === CHILDREN) {
17488 if (node2.nodes) {
17489 node2.each(function(child) {
17490 if (!child[isClean]) _this.walkSync(child);
17491 });
17492 }
17493 } else {
17494 var visitors = this.listeners[event];
17495 if (visitors) {
17496 if (this.visitSync(visitors, node2.toProxy())) return;
17497 }
17498 }
17499 }
17500 };
17501 _proto.warnings = function warnings() {
17502 return this.sync().warnings();
17503 };
17504 _create_class(LazyResult2, [
17505 {
17506 key: "content",
17507 get: function get() {
17508 return this.stringify().content;
17509 }
17510 },
17511 {
17512 key: "css",
17513 get: function get() {
17514 return this.stringify().css;
17515 }
17516 },
17517 {
17518 key: "map",
17519 get: function get() {
17520 return this.stringify().map;
17521 }
17522 },
17523 {
17524 key: "messages",
17525 get: function get() {
17526 return this.sync().messages;
17527 }
17528 },
17529 {
17530 key: "opts",
17531 get: function get() {
17532 return this.result.opts;
17533 }
17534 },
17535 {
17536 key: "processor",
17537 get: function get() {
17538 return this.result.processor;
17539 }
17540 },
17541 {
17542 key: "root",
17543 get: function get() {
17544 return this.sync().root;
17545 }
17546 },
17547 {
17548 key: Symbol.toStringTag,
17549 get: function get() {
17550 return "LazyResult";
17551 }
17552 }
17553 ]);
17554 return LazyResult2;
17555 }();
17556 LazyResult$2.registerPostcss = function(dependant) {
17557 postcss$2 = dependant;
17558 };
17559 var lazyResult = LazyResult$2;
17560 LazyResult$2.default = LazyResult$2;
17561 Root$3.registerLazyResult(LazyResult$2);
17562 Document$2.registerLazyResult(LazyResult$2);
17563 var MapGenerator22 = mapGenerator;
17564 var stringify$1 = stringify_1;
17565 var warnOnce22 = warnOnce$2;
17566 var parse$1 = parse_1;
17567 var Result$1 = result;
17568 var NoWorkResult$1 = /*#__PURE__*/ function() {
17569 function NoWorkResult2(processor2, css, opts) {
17570 css = css.toString();
17571 this.stringified = false;
17572 this._processor = processor2;
17573 this._css = css;
17574 this._opts = opts;
17575 this._map = void 0;
17576 var root2;
17577 var str = stringify$1;
17578 this.result = new Result$1(this._processor, root2, this._opts);
17579 this.result.css = css;
17580 var self = this;
17581 Object.defineProperty(this.result, "root", {
17582 get: function get() {
17583 return self.root;
17584 }
17585 });
17586 var map = new MapGenerator22(str, root2, this._opts, css);
17587 if (map.isMap()) {
17588 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
17589 if (generatedCSS) {
17590 this.result.css = generatedCSS;
17591 }
17592 if (generatedMap) {
17593 this.result.map = generatedMap;
17594 }
17595 } else {
17596 map.clearAnnotation();
17597 this.result.css = map.css;
17598 }
17599 }
17600 var _proto = NoWorkResult2.prototype;
17601 _proto.async = function async() {
17602 if (this.error) return Promise.reject(this.error);
17603 return Promise.resolve(this.result);
17604 };
17605 _proto.catch = function _catch(onRejected) {
17606 return this.async().catch(onRejected);
17607 };
17608 _proto.finally = function _finally(onFinally) {
17609 return this.async().then(onFinally, onFinally);
17610 };
17611 _proto.sync = function sync() {
17612 if (this.error) throw this.error;
17613 return this.result;
17614 };
17615 _proto.then = function then(onFulfilled, onRejected) {
17616 if (true) {
17617 if (!("from" in this._opts)) {
17618 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.");
17619 }
17620 }
17621 return this.async().then(onFulfilled, onRejected);
17622 };
17623 _proto.toString = function toString() {
17624 return this._css;
17625 };
17626 _proto.warnings = function warnings() {
17627 return [];
17628 };
17629 _create_class(NoWorkResult2, [
17630 {
17631 key: "content",
17632 get: function get() {
17633 return this.result.css;
17634 }
17635 },
17636 {
17637 key: "css",
17638 get: function get() {
17639 return this.result.css;
17640 }
17641 },
17642 {
17643 key: "map",
17644 get: function get() {
17645 return this.result.map;
17646 }
17647 },
17648 {
17649 key: "messages",
17650 get: function get() {
17651 return [];
17652 }
17653 },
17654 {
17655 key: "opts",
17656 get: function get() {
17657 return this.result.opts;
17658 }
17659 },
17660 {
17661 key: "processor",
17662 get: function get() {
17663 return this.result.processor;
17664 }
17665 },
17666 {
17667 key: "root",
17668 get: function get() {
17669 if (this._root) {
17670 return this._root;
17671 }
17672 var root2;
17673 var parser2 = parse$1;
17674 try {
17675 root2 = parser2(this._css, this._opts);
17676 } catch (error) {
17677 this.error = error;
17678 }
17679 if (this.error) {
17680 throw this.error;
17681 } else {
17682 this._root = root2;
17683 return root2;
17684 }
17685 }
17686 },
17687 {
17688 key: Symbol.toStringTag,
17689 get: function get() {
17690 return "NoWorkResult";
17691 }
17692 }
17693 ]);
17694 return NoWorkResult2;
17695 }();
17696 var noWorkResult = NoWorkResult$1;
17697 NoWorkResult$1.default = NoWorkResult$1;
17698 var NoWorkResult22 = noWorkResult;
17699 var LazyResult$1 = lazyResult;
17700 var Document$1 = document$1$2;
17701 var Root$2 = root;
17702 var Processor$1 = /*#__PURE__*/ function() {
17703 function Processor2(plugins) {
17704 if (plugins === void 0) plugins = [];
17705 this.version = "8.4.38";
17706 this.plugins = this.normalize(plugins);
17707 }
17708 var _proto = Processor2.prototype;
17709 _proto.normalize = function normalize(plugins) {
17710 var normalized = [];
17711 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
17712 var i2 = _step.value;
17713 if (i2.postcss === true) {
17714 i2 = i2();
17715 } else if (i2.postcss) {
17716 i2 = i2.postcss;
17717 }
17718 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
17719 normalized = normalized.concat(i2.plugins);
17720 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
17721 normalized.push(i2);
17722 } else if (typeof i2 === "function") {
17723 normalized.push(i2);
17724 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
17725 if (true) {
17726 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.");
17727 }
17728 } else {
17729 throw new Error(i2 + " is not a PostCSS plugin");
17730 }
17731 }
17732 return normalized;
17733 };
17734 _proto.process = function process1(css, opts) {
17735 if (opts === void 0) opts = {};
17736 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
17737 return new NoWorkResult22(this, css, opts);
17738 } else {
17739 return new LazyResult$1(this, css, opts);
17740 }
17741 };
17742 _proto.use = function use(plugin22) {
17743 this.plugins = this.plugins.concat(this.normalize([
17744 plugin22
17745 ]));
17746 return this;
17747 };
17748 return Processor2;
17749 }();
17750 var processor = Processor$1;
17751 Processor$1.default = Processor$1;
17752 Root$2.registerProcessor(Processor$1);
17753 Document$1.registerProcessor(Processor$1);
17754 var Declaration$1 = declaration;
17755 var PreviousMap22 = previousMap;
17756 var Comment$1 = comment;
17757 var AtRule$1 = atRule;
17758 var Input$1 = input;
17759 var Root$1 = root;
17760 var Rule$1 = rule;
17761 function fromJSON$1(json, inputs) {
17762 if (Array.isArray(json)) return json.map(function(n2) {
17763 return fromJSON$1(n2);
17764 });
17765 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
17766 "inputs"
17767 ]);
17768 if (ownInputs) {
17769 inputs = [];
17770 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
17771 var input2 = _step.value;
17772 var inputHydrated = _extends({}, input2, {
17773 __proto__: Input$1.prototype
17774 });
17775 if (inputHydrated.map) {
17776 inputHydrated.map = _extends({}, inputHydrated.map, {
17777 __proto__: PreviousMap22.prototype
17778 });
17779 }
17780 inputs.push(inputHydrated);
17781 }
17782 }
17783 if (defaults.nodes) {
17784 defaults.nodes = json.nodes.map(function(n2) {
17785 return fromJSON$1(n2, inputs);
17786 });
17787 }
17788 if (defaults.source) {
17789 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
17790 "inputId"
17791 ]);
17792 defaults.source = source;
17793 if (inputId != null) {
17794 defaults.source.input = inputs[inputId];
17795 }
17796 }
17797 if (defaults.type === "root") {
17798 return new Root$1(defaults);
17799 } else if (defaults.type === "decl") {
17800 return new Declaration$1(defaults);
17801 } else if (defaults.type === "rule") {
17802 return new Rule$1(defaults);
17803 } else if (defaults.type === "comment") {
17804 return new Comment$1(defaults);
17805 } else if (defaults.type === "atrule") {
17806 return new AtRule$1(defaults);
17807 } else {
17808 throw new Error("Unknown node type: " + json.type);
17809 }
17810 }
17811 var fromJSON_1 = fromJSON$1;
17812 fromJSON$1.default = fromJSON$1;
17813 var CssSyntaxError22 = cssSyntaxError;
17814 var Declaration22 = declaration;
17815 var LazyResult22 = lazyResult;
17816 var Container22 = container;
17817 var Processor22 = processor;
17818 var stringify = stringify_1;
17819 var fromJSON = fromJSON_1;
17820 var Document222 = document$1$2;
17821 var Warning22 = warning;
17822 var Comment22 = comment;
17823 var AtRule22 = atRule;
17824 var Result22 = result;
17825 var Input22 = input;
17826 var parse = parse_1;
17827 var list = list_1;
17828 var Rule22 = rule;
17829 var Root22 = root;
17830 var Node22 = node;
17831 function postcss() {
17832 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
17833 plugins[_key] = arguments[_key];
17834 }
17835 if (plugins.length === 1 && Array.isArray(plugins[0])) {
17836 plugins = plugins[0];
17837 }
17838 return new Processor22(plugins);
17839 }
17840 postcss.plugin = function plugin2(name, initializer) {
17841 var warningPrinted = false;
17842 function creator() {
17843 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
17844 args[_key] = arguments[_key];
17845 }
17846 if (console && console.warn && !warningPrinted) {
17847 warningPrinted = true;
17848 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
17849 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
17850 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
17851 }
17852 }
17853 var transformer = initializer.apply(void 0, [].concat(args));
17854 transformer.postcssPlugin = name;
17855 transformer.postcssVersion = new Processor22().version;
17856 return transformer;
17857 }
17858 var cache;
17859 Object.defineProperty(creator, "postcss", {
17860 get: function get() {
17861 if (!cache) cache = creator();
17862 return cache;
17863 }
17864 });
17865 creator.process = function(css, processOpts, pluginOpts) {
17866 return postcss([
17867 creator(pluginOpts)
17868 ]).process(css, processOpts);
17869 };
17870 return creator;
17871 };
17872 postcss.stringify = stringify;
17873 postcss.parse = parse;
17874 postcss.fromJSON = fromJSON;
17875 postcss.list = list;
17876 postcss.comment = function(defaults) {
17877 return new Comment22(defaults);
17878 };
17879 postcss.atRule = function(defaults) {
17880 return new AtRule22(defaults);
17881 };
17882 postcss.decl = function(defaults) {
17883 return new Declaration22(defaults);
17884 };
17885 postcss.rule = function(defaults) {
17886 return new Rule22(defaults);
17887 };
17888 postcss.root = function(defaults) {
17889 return new Root22(defaults);
17890 };
17891 postcss.document = function(defaults) {
17892 return new Document222(defaults);
17893 };
17894 postcss.CssSyntaxError = CssSyntaxError22;
17895 postcss.Declaration = Declaration22;
17896 postcss.Container = Container22;
17897 postcss.Processor = Processor22;
17898 postcss.Document = Document222;
17899 postcss.Comment = Comment22;
17900 postcss.Warning = Warning22;
17901 postcss.AtRule = AtRule22;
17902 postcss.Result = Result22;
17903 postcss.Input = Input22;
17904 postcss.Rule = Rule22;
17905 postcss.Root = Root22;
17906 postcss.Node = Node22;
17907 LazyResult22.registerPostcss(postcss);
17908 var postcss_1 = postcss;
17909 postcss.default = postcss;
17910 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
17911 postcss$1.stringify;
17912 postcss$1.fromJSON;
17913 postcss$1.plugin;
17914 postcss$1.parse;
17915 postcss$1.list;
17916 postcss$1.document;
17917 postcss$1.comment;
17918 postcss$1.atRule;
17919 postcss$1.rule;
17920 postcss$1.decl;
17921 postcss$1.root;
17922 postcss$1.CssSyntaxError;
17923 postcss$1.Declaration;
17924 postcss$1.Container;
17925 postcss$1.Processor;
17926 postcss$1.Document;
17927 postcss$1.Comment;
17928 postcss$1.Warning;
17929 postcss$1.AtRule;
17930 postcss$1.Result;
17931 postcss$1.Input;
17932 postcss$1.Rule;
17933 postcss$1.Root;
17934 postcss$1.Node;
17935 var BaseRRNode = /*#__PURE__*/ function() {
17936 function BaseRRNode() {
17937 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
17938 _args[_key] = arguments[_key];
17939 }
17940 __publicField2(this, "parentElement", null);
17941 __publicField2(this, "parentNode", null);
17942 __publicField2(this, "ownerDocument");
17943 __publicField2(this, "firstChild", null);
17944 __publicField2(this, "lastChild", null);
17945 __publicField2(this, "previousSibling", null);
17946 __publicField2(this, "nextSibling", null);
17947 __publicField2(this, "ELEMENT_NODE", 1);
17948 __publicField2(this, "TEXT_NODE", 3);
17949 __publicField2(this, "nodeType");
17950 __publicField2(this, "nodeName");
17951 __publicField2(this, "RRNodeType");
17952 }
17953 var _proto = BaseRRNode.prototype;
17954 _proto.contains = function contains(node2) {
17955 if (!_instanceof(node2, BaseRRNode)) return false;
17956 else if (node2.ownerDocument !== this.ownerDocument) return false;
17957 else if (node2 === this) return true;
17958 while(node2.parentNode){
17959 if (node2.parentNode === this) return true;
17960 node2 = node2.parentNode;
17961 }
17962 return false;
17963 };
17964 // eslint-disable-next-line @typescript-eslint/no-unused-vars
17965 _proto.appendChild = function appendChild(_newChild) {
17966 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
17967 };
17968 // eslint-disable-next-line @typescript-eslint/no-unused-vars
17969 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
17970 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
17971 };
17972 // eslint-disable-next-line @typescript-eslint/no-unused-vars
17973 _proto.removeChild = function removeChild(_node) {
17974 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
17975 };
17976 _proto.toString = function toString() {
17977 return "RRNode";
17978 };
17979 _create_class(BaseRRNode, [
17980 {
17981 key: "childNodes",
17982 get: function get() {
17983 var childNodes2 = [];
17984 var childIterator = this.firstChild;
17985 while(childIterator){
17986 childNodes2.push(childIterator);
17987 childIterator = childIterator.nextSibling;
17988 }
17989 return childNodes2;
17990 }
17991 }
17992 ]);
17993 return BaseRRNode;
17994 }();
17995 var testableAccessors = {
17996 Node: [
17997 "childNodes",
17998 "parentNode",
17999 "parentElement",
18000 "textContent"
18001 ],
18002 ShadowRoot: [
18003 "host",
18004 "styleSheets"
18005 ],
18006 Element: [
18007 "shadowRoot",
18008 "querySelector",
18009 "querySelectorAll"
18010 ],
18011 MutationObserver: []
18012 };
18013 var testableMethods = {
18014 Node: [
18015 "contains",
18016 "getRootNode"
18017 ],
18018 ShadowRoot: [
18019 "getSelection"
18020 ],
18021 Element: [],
18022 MutationObserver: [
18023 "constructor"
18024 ]
18025 };
18026 var untaintedBasePrototype = {};
18027 var isAngularZonePresent = function() {
18028 return !!globalThis.Zone;
18029 };
18030 function getUntaintedPrototype(key) {
18031 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18032 var defaultObj = globalThis[key];
18033 var defaultPrototype = defaultObj.prototype;
18034 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18035 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18036 accessorNames.every(function(accessor) {
18037 var _a2, _b;
18038 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18039 }));
18040 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18041 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18042 function(method) {
18043 var _a2;
18044 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18045 }));
18046 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18047 untaintedBasePrototype[key] = defaultObj.prototype;
18048 return defaultObj.prototype;
18049 }
18050 try {
18051 var iframeEl = document.createElement("iframe");
18052 document.body.appendChild(iframeEl);
18053 var win = iframeEl.contentWindow;
18054 if (!win) return defaultObj.prototype;
18055 var untaintedObject = win[key].prototype;
18056 document.body.removeChild(iframeEl);
18057 if (!untaintedObject) return defaultPrototype;
18058 return untaintedBasePrototype[key] = untaintedObject;
18059 } catch (e) {
18060 return defaultPrototype;
18061 }
18062 }
18063 var untaintedAccessorCache = {};
18064 function getUntaintedAccessor(key, instance, accessor) {
18065 var _a2;
18066 var cacheKey = key + "." + String(accessor);
18067 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18068 var untaintedPrototype = getUntaintedPrototype(key);
18069 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18070 if (!untaintedAccessor) return instance[accessor];
18071 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18072 return untaintedAccessor.call(instance);
18073 }
18074 var untaintedMethodCache = {};
18075 function getUntaintedMethod(key, instance, method) {
18076 var cacheKey = key + "." + String(method);
18077 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18078 var untaintedPrototype = getUntaintedPrototype(key);
18079 var untaintedMethod = untaintedPrototype[method];
18080 if (typeof untaintedMethod !== "function") return instance[method];
18081 untaintedMethodCache[cacheKey] = untaintedMethod;
18082 return untaintedMethod.bind(instance);
18083 }
18084 function childNodes(n2) {
18085 return getUntaintedAccessor("Node", n2, "childNodes");
18086 }
18087 function parentNode(n2) {
18088 return getUntaintedAccessor("Node", n2, "parentNode");
18089 }
18090 function parentElement(n2) {
18091 return getUntaintedAccessor("Node", n2, "parentElement");
18092 }
18093 function textContent(n2) {
18094 return getUntaintedAccessor("Node", n2, "textContent");
18095 }
18096 function contains(n2, other) {
18097 return getUntaintedMethod("Node", n2, "contains")(other);
18098 }
18099 function getRootNode(n2) {
18100 return getUntaintedMethod("Node", n2, "getRootNode")();
18101 }
18102 function host(n2) {
18103 if (!n2 || !("host" in n2)) return null;
18104 return getUntaintedAccessor("ShadowRoot", n2, "host");
18105 }
18106 function styleSheets(n2) {
18107 return n2.styleSheets;
18108 }
18109 function shadowRoot(n2) {
18110 if (!n2 || !("shadowRoot" in n2)) return null;
18111 return getUntaintedAccessor("Element", n2, "shadowRoot");
18112 }
18113 function querySelector(n2, selectors) {
18114 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18115 }
18116 function querySelectorAll(n2, selectors) {
18117 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18118 }
18119 function mutationObserverCtor() {
18120 return getUntaintedPrototype("MutationObserver").constructor;
18121 }
18122 var index = {
18123 childNodes: childNodes,
18124 parentNode: parentNode,
18125 parentElement: parentElement,
18126 textContent: textContent,
18127 contains: contains,
18128 getRootNode: getRootNode,
18129 host: host,
18130 styleSheets: styleSheets,
18131 shadowRoot: shadowRoot,
18132 querySelector: querySelector,
18133 querySelectorAll: querySelectorAll,
18134 mutationObserver: mutationObserverCtor
18135 };
18136 function on(type, fn, target) {
18137 if (target === void 0) target = document;
18138 var options = {
18139 capture: true,
18140 passive: true
18141 };
18142 target.addEventListener(type, fn, options);
18143 return function() {
18144 return target.removeEventListener(type, fn, options);
18145 };
18146 }
18147 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.";
18148 var _mirror = {
18149 map: {},
18150 getId: function getId() {
18151 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18152 return -1;
18153 },
18154 getNode: function getNode() {
18155 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18156 return null;
18157 },
18158 removeNodeFromMap: function removeNodeFromMap() {
18159 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18160 },
18161 has: function has() {
18162 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18163 return false;
18164 },
18165 reset: function reset() {
18166 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18167 }
18168 };
18169 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
18170 _mirror = new Proxy(_mirror, {
18171 get: function get(target, prop, receiver) {
18172 if (prop === "map") {
18173 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18174 }
18175 return Reflect.get(target, prop, receiver);
18176 }
18177 });
18178 }
18179 function throttle(func, wait, options) {
18180 if (options === void 0) options = {};
18181 var timeout = null;
18182 var previous = 0;
18183 return function() {
18184 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18185 args[_key] = arguments[_key];
18186 }
18187 var now = Date.now();
18188 if (!previous && options.leading === false) {
18189 previous = now;
18190 }
18191 var remaining = wait - (now - previous);
18192 var context = this;
18193 if (remaining <= 0 || remaining > wait) {
18194 if (timeout) {
18195 clearTimeout(timeout);
18196 timeout = null;
18197 }
18198 previous = now;
18199 func.apply(context, args);
18200 } else if (!timeout && options.trailing !== false) {
18201 timeout = setTimeout(function() {
18202 previous = options.leading === false ? 0 : Date.now();
18203 timeout = null;
18204 func.apply(context, args);
18205 }, remaining);
18206 }
18207 };
18208 }
18209 function hookSetter(target, key, d, isRevoked, win) {
18210 if (win === void 0) win = window;
18211 var original = win.Object.getOwnPropertyDescriptor(target, key);
18212 win.Object.defineProperty(target, key, isRevoked ? d : {
18213 set: function set(value) {
18214 var _this = this;
18215 setTimeout(function() {
18216 d.set.call(_this, value);
18217 }, 0);
18218 if (original && original.set) {
18219 original.set.call(this, value);
18220 }
18221 }
18222 });
18223 return function() {
18224 return hookSetter(target, key, original || {}, true);
18225 };
18226 }
18227 function patch(source, name, replacement) {
18228 try {
18229 if (!(name in source)) {
18230 return function() {};
18231 }
18232 var original = source[name];
18233 var wrapped = replacement(original);
18234 if (typeof wrapped === "function") {
18235 wrapped.prototype = wrapped.prototype || {};
18236 Object.defineProperties(wrapped, {
18237 __rrweb_original__: {
18238 enumerable: false,
18239 value: original
18240 }
18241 });
18242 }
18243 source[name] = wrapped;
18244 return function() {
18245 source[name] = original;
18246 };
18247 } catch (e) {
18248 return function() {};
18249 }
18250 }
18251 var nowTimestamp = Date.now;
18252 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
18253 nowTimestamp = function() {
18254 return /* @__PURE__ */ new Date().getTime();
18255 };
18256 }
18257 function getWindowScroll(win) {
18258 var _a2, _b, _c, _d;
18259 var doc = win.document;
18260 return {
18261 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,
18262 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
18263 };
18264 }
18265 function getWindowHeight() {
18266 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
18267 }
18268 function getWindowWidth() {
18269 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
18270 }
18271 function closestElementOfNode(node2) {
18272 if (!node2) {
18273 return null;
18274 }
18275 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
18276 return el;
18277 }
18278 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
18279 if (!node2) {
18280 return false;
18281 }
18282 var el = closestElementOfNode(node2);
18283 if (!el) {
18284 return false;
18285 }
18286 try {
18287 if (typeof blockClass === "string") {
18288 if (el.classList.contains(blockClass)) return true;
18289 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
18290 } else {
18291 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
18292 }
18293 } catch (e2) {}
18294 if (blockSelector) {
18295 if (el.matches(blockSelector)) return true;
18296 if (checkAncestors && el.closest(blockSelector) !== null) return true;
18297 }
18298 return false;
18299 }
18300 function isSerialized(n2, mirror2) {
18301 return mirror2.getId(n2) !== -1;
18302 }
18303 function isIgnored(n2, mirror2, slimDOMOptions) {
18304 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
18305 return true;
18306 }
18307 return mirror2.getId(n2) === IGNORED_NODE;
18308 }
18309 function isAncestorRemoved(target, mirror2) {
18310 if (isShadowRoot(target)) {
18311 return false;
18312 }
18313 var id = mirror2.getId(target);
18314 if (!mirror2.has(id)) {
18315 return true;
18316 }
18317 var parent = index.parentNode(target);
18318 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
18319 return false;
18320 }
18321 if (!parent) {
18322 return true;
18323 }
18324 return isAncestorRemoved(parent, mirror2);
18325 }
18326 function legacy_isTouchEvent(event) {
18327 return Boolean(event.changedTouches);
18328 }
18329 function polyfill$1(win) {
18330 if (win === void 0) win = window;
18331 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
18332 win.NodeList.prototype.forEach = Array.prototype.forEach;
18333 }
18334 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
18335 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
18336 }
18337 }
18338 function isSerializedIframe(n2, mirror2) {
18339 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
18340 }
18341 function isSerializedStylesheet(n2, mirror2) {
18342 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
18343 }
18344 function hasShadowRoot(n2) {
18345 if (!n2) return false;
18346 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
18347 return Boolean(n2.shadowRoot);
18348 }
18349 return Boolean(index.shadowRoot(n2));
18350 }
18351 var StyleSheetMirror = /*#__PURE__*/ function() {
18352 function StyleSheetMirror() {
18353 __publicField(this, "id", 1);
18354 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
18355 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
18356 }
18357 var _proto = StyleSheetMirror.prototype;
18358 _proto.getId = function getId(stylesheet) {
18359 var _this_styleIDMap_get;
18360 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
18361 };
18362 _proto.has = function has(stylesheet) {
18363 return this.styleIDMap.has(stylesheet);
18364 };
18365 /**
18366 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
18367 */ _proto.add = function add(stylesheet, id) {
18368 if (this.has(stylesheet)) return this.getId(stylesheet);
18369 var newId;
18370 if (id === void 0) {
18371 newId = this.id++;
18372 } else newId = id;
18373 this.styleIDMap.set(stylesheet, newId);
18374 this.idStyleMap.set(newId, stylesheet);
18375 return newId;
18376 };
18377 _proto.getStyle = function getStyle(id) {
18378 return this.idStyleMap.get(id) || null;
18379 };
18380 _proto.reset = function reset() {
18381 this.styleIDMap = /* @__PURE__ */ new WeakMap();
18382 this.idStyleMap = /* @__PURE__ */ new Map();
18383 this.id = 1;
18384 };
18385 _proto.generateId = function generateId() {
18386 return this.id++;
18387 };
18388 return StyleSheetMirror;
18389 }();
18390 function getShadowHost(n2) {
18391 var _a2;
18392 var shadowHost = null;
18393 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));
18394 return shadowHost;
18395 }
18396 function getRootShadowHost(n2) {
18397 var rootShadowHost = n2;
18398 var shadowHost;
18399 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
18400 return rootShadowHost;
18401 }
18402 function shadowHostInDom(n2) {
18403 var doc = n2.ownerDocument;
18404 if (!doc) return false;
18405 var shadowHost = getRootShadowHost(n2);
18406 return index.contains(doc, shadowHost);
18407 }
18408 function inDom(n2) {
18409 var doc = n2.ownerDocument;
18410 if (!doc) return false;
18411 return index.contains(doc, n2) || shadowHostInDom(n2);
18412 }
18413 var EventType = /* @__PURE__ */ function(EventType2) {
18414 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
18415 EventType2[EventType2["Load"] = 1] = "Load";
18416 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
18417 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
18418 EventType2[EventType2["Meta"] = 4] = "Meta";
18419 EventType2[EventType2["Custom"] = 5] = "Custom";
18420 EventType2[EventType2["Plugin"] = 6] = "Plugin";
18421 return EventType2;
18422 }(EventType || {});
18423 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
18424 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
18425 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
18426 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
18427 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
18428 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
18429 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
18430 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
18431 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
18432 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
18433 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
18434 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
18435 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
18436 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
18437 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
18438 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
18439 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
18440 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
18441 return IncrementalSource2;
18442 }(IncrementalSource || {});
18443 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
18444 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
18445 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
18446 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
18447 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
18448 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
18449 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
18450 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
18451 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
18452 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
18453 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
18454 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
18455 return MouseInteractions2;
18456 }(MouseInteractions || {});
18457 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
18458 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
18459 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
18460 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
18461 return PointerTypes2;
18462 }(PointerTypes || {});
18463 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
18464 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
18465 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
18466 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
18467 return CanvasContext2;
18468 }(CanvasContext || {});
18469 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
18470 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
18471 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
18472 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
18473 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
18474 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
18475 return MediaInteractions2;
18476 }(MediaInteractions || {});
18477 var NodeType = /* @__PURE__ */ function(NodeType2) {
18478 NodeType2[NodeType2["Document"] = 0] = "Document";
18479 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
18480 NodeType2[NodeType2["Element"] = 2] = "Element";
18481 NodeType2[NodeType2["Text"] = 3] = "Text";
18482 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
18483 NodeType2[NodeType2["Comment"] = 5] = "Comment";
18484 return NodeType2;
18485 }(NodeType || {});
18486 function isNodeInLinkedList(n2) {
18487 return "__ln" in n2;
18488 }
18489 var DoubleLinkedList = /*#__PURE__*/ function() {
18490 function DoubleLinkedList() {
18491 __publicField(this, "length", 0);
18492 __publicField(this, "head", null);
18493 __publicField(this, "tail", null);
18494 }
18495 var _proto = DoubleLinkedList.prototype;
18496 _proto.get = function get(position) {
18497 if (position >= this.length) {
18498 throw new Error("Position outside of list range");
18499 }
18500 var current = this.head;
18501 for(var index2 = 0; index2 < position; index2++){
18502 current = (current == null ? void 0 : current.next) || null;
18503 }
18504 return current;
18505 };
18506 _proto.addNode = function addNode(n2) {
18507 var node2 = {
18508 value: n2,
18509 previous: null,
18510 next: null
18511 };
18512 n2.__ln = node2;
18513 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
18514 var current = n2.previousSibling.__ln.next;
18515 node2.next = current;
18516 node2.previous = n2.previousSibling.__ln;
18517 n2.previousSibling.__ln.next = node2;
18518 if (current) {
18519 current.previous = node2;
18520 }
18521 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
18522 var current1 = n2.nextSibling.__ln.previous;
18523 node2.previous = current1;
18524 node2.next = n2.nextSibling.__ln;
18525 n2.nextSibling.__ln.previous = node2;
18526 if (current1) {
18527 current1.next = node2;
18528 }
18529 } else {
18530 if (this.head) {
18531 this.head.previous = node2;
18532 }
18533 node2.next = this.head;
18534 this.head = node2;
18535 }
18536 if (node2.next === null) {
18537 this.tail = node2;
18538 }
18539 this.length++;
18540 };
18541 _proto.removeNode = function removeNode(n2) {
18542 var current = n2.__ln;
18543 if (!this.head) {
18544 return;
18545 }
18546 if (!current.previous) {
18547 this.head = current.next;
18548 if (this.head) {
18549 this.head.previous = null;
18550 } else {
18551 this.tail = null;
18552 }
18553 } else {
18554 current.previous.next = current.next;
18555 if (current.next) {
18556 current.next.previous = current.previous;
18557 } else {
18558 this.tail = current.previous;
18559 }
18560 }
18561 if (n2.__ln) {
18562 delete n2.__ln;
18563 }
18564 this.length--;
18565 };
18566 return DoubleLinkedList;
18567 }();
18568 var moveKey = function(id, parentId) {
18569 return id + "@" + parentId;
18570 };
18571 var MutationBuffer = /*#__PURE__*/ function() {
18572 function MutationBuffer() {
18573 var _this = this;
18574 __publicField(this, "frozen", false);
18575 __publicField(this, "locked", false);
18576 __publicField(this, "texts", []);
18577 __publicField(this, "attributes", []);
18578 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
18579 __publicField(this, "removes", []);
18580 __publicField(this, "mapRemoves", []);
18581 __publicField(this, "movedMap", {});
18582 /**
18583 * the browser MutationObserver emits multiple mutations after
18584 * a delay for performance reasons, making tracing added nodes hard
18585 * in our `processMutations` callback function.
18586 * For example, if we append an element el_1 into body, and then append
18587 * another element el_2 into el_1, these two mutations may be passed to the
18588 * callback function together when the two operations were done.
18589 * Generally we need to trace child nodes of newly added nodes, but in this
18590 * case if we count el_2 as el_1's child node in the first mutation record,
18591 * then we will count el_2 again in the second mutation record which was
18592 * duplicated.
18593 * To avoid of duplicate counting added nodes, we use a Set to store
18594 * added nodes and its child nodes during iterate mutation records. Then
18595 * collect added nodes from the Set which have no duplicate copy. But
18596 * this also causes newly added nodes will not be serialized with id ASAP,
18597 * which means all the id related calculation should be lazy too.
18598 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
18599 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
18600 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
18601 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
18602 __publicField(this, "mutationCb");
18603 __publicField(this, "blockClass");
18604 __publicField(this, "blockSelector");
18605 __publicField(this, "maskTextClass");
18606 __publicField(this, "maskTextSelector");
18607 __publicField(this, "inlineStylesheet");
18608 __publicField(this, "maskInputOptions");
18609 __publicField(this, "maskTextFn");
18610 __publicField(this, "maskInputFn");
18611 __publicField(this, "keepIframeSrcFn");
18612 __publicField(this, "recordCanvas");
18613 __publicField(this, "inlineImages");
18614 __publicField(this, "slimDOMOptions");
18615 __publicField(this, "dataURLOptions");
18616 __publicField(this, "doc");
18617 __publicField(this, "mirror");
18618 __publicField(this, "iframeManager");
18619 __publicField(this, "stylesheetManager");
18620 __publicField(this, "shadowDomManager");
18621 __publicField(this, "canvasManager");
18622 __publicField(this, "processedNodeManager");
18623 __publicField(this, "unattachedDoc");
18624 __publicField(this, "processMutations", function(mutations) {
18625 mutations.forEach(_this.processMutation);
18626 _this.emit();
18627 });
18628 __publicField(this, "emit", function() {
18629 if (_this.frozen || _this.locked) {
18630 return;
18631 }
18632 var adds = [];
18633 var addedIds = /* @__PURE__ */ new Set();
18634 var addList = new DoubleLinkedList();
18635 var getNextId = function(n2) {
18636 var ns = n2;
18637 var nextId = IGNORED_NODE;
18638 while(nextId === IGNORED_NODE){
18639 ns = ns && ns.nextSibling;
18640 nextId = ns && _this.mirror.getId(ns);
18641 }
18642 return nextId;
18643 };
18644 var pushAdd = function(n2) {
18645 var parent = index.parentNode(n2);
18646 if (!parent || !inDom(n2)) {
18647 return;
18648 }
18649 var cssCaptured = false;
18650 if (n2.nodeType === Node.TEXT_NODE) {
18651 var parentTag = parent.tagName;
18652 if (parentTag === "TEXTAREA") {
18653 return;
18654 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
18655 cssCaptured = true;
18656 }
18657 }
18658 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
18659 var nextId = getNextId(n2);
18660 if (parentId === -1 || nextId === -1) {
18661 return addList.addNode(n2);
18662 }
18663 var sn = serializeNodeWithId(n2, {
18664 doc: _this.doc,
18665 mirror: _this.mirror,
18666 blockClass: _this.blockClass,
18667 blockSelector: _this.blockSelector,
18668 maskTextClass: _this.maskTextClass,
18669 maskTextSelector: _this.maskTextSelector,
18670 skipChild: true,
18671 newlyAddedElement: true,
18672 inlineStylesheet: _this.inlineStylesheet,
18673 maskInputOptions: _this.maskInputOptions,
18674 maskTextFn: _this.maskTextFn,
18675 maskInputFn: _this.maskInputFn,
18676 slimDOMOptions: _this.slimDOMOptions,
18677 dataURLOptions: _this.dataURLOptions,
18678 recordCanvas: _this.recordCanvas,
18679 inlineImages: _this.inlineImages,
18680 onSerialize: function(currentN) {
18681 if (isSerializedIframe(currentN, _this.mirror)) {
18682 _this.iframeManager.addIframe(currentN);
18683 }
18684 if (isSerializedStylesheet(currentN, _this.mirror)) {
18685 _this.stylesheetManager.trackLinkElement(currentN);
18686 }
18687 if (hasShadowRoot(n2)) {
18688 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
18689 }
18690 },
18691 onIframeLoad: function(iframe, childSn) {
18692 _this.iframeManager.attachIframe(iframe, childSn);
18693 _this.shadowDomManager.observeAttachShadow(iframe);
18694 },
18695 onStylesheetLoad: function(link, childSn) {
18696 _this.stylesheetManager.attachLinkElement(link, childSn);
18697 },
18698 cssCaptured: cssCaptured
18699 });
18700 if (sn) {
18701 adds.push({
18702 parentId: parentId,
18703 nextId: nextId,
18704 node: sn
18705 });
18706 addedIds.add(sn.id);
18707 }
18708 };
18709 while(_this.mapRemoves.length){
18710 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
18711 }
18712 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
18713 var n2 = _step.value;
18714 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
18715 continue;
18716 }
18717 pushAdd(n2);
18718 }
18719 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
18720 var n21 = _step1.value;
18721 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
18722 pushAdd(n21);
18723 } else if (isAncestorInSet(_this.movedSet, n21)) {
18724 pushAdd(n21);
18725 } else {
18726 _this.droppedSet.add(n21);
18727 }
18728 }
18729 var candidate = null;
18730 while(addList.length){
18731 var node2 = null;
18732 if (candidate) {
18733 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
18734 var nextId = getNextId(candidate.value);
18735 if (parentId !== -1 && nextId !== -1) {
18736 node2 = candidate;
18737 }
18738 }
18739 if (!node2) {
18740 var tailNode = addList.tail;
18741 while(tailNode){
18742 var _node = tailNode;
18743 tailNode = tailNode.previous;
18744 if (_node) {
18745 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
18746 var nextId1 = getNextId(_node.value);
18747 if (nextId1 === -1) continue;
18748 else if (parentId1 !== -1) {
18749 node2 = _node;
18750 break;
18751 } else {
18752 var unhandledNode = _node.value;
18753 var parent = index.parentNode(unhandledNode);
18754 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
18755 var shadowHost = index.host(parent);
18756 var parentId2 = _this.mirror.getId(shadowHost);
18757 if (parentId2 !== -1) {
18758 node2 = _node;
18759 break;
18760 }
18761 }
18762 }
18763 }
18764 }
18765 }
18766 if (!node2) {
18767 while(addList.head){
18768 addList.removeNode(addList.head.value);
18769 }
18770 break;
18771 }
18772 candidate = node2.previous;
18773 addList.removeNode(node2.value);
18774 pushAdd(node2.value);
18775 }
18776 var payload = {
18777 texts: _this.texts.map(function(text) {
18778 var n2 = text.node;
18779 var parent = index.parentNode(n2);
18780 if (parent && parent.tagName === "TEXTAREA") {
18781 _this.genTextAreaValueMutation(parent);
18782 }
18783 return {
18784 id: _this.mirror.getId(n2),
18785 value: text.value
18786 };
18787 }).filter(function(text) {
18788 return !addedIds.has(text.id);
18789 }).filter(function(text) {
18790 return _this.mirror.has(text.id);
18791 }),
18792 attributes: _this.attributes.map(function(attribute) {
18793 var attributes = attribute.attributes;
18794 if (typeof attributes.style === "string") {
18795 var diffAsStr = JSON.stringify(attribute.styleDiff);
18796 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
18797 if (diffAsStr.length < attributes.style.length) {
18798 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
18799 attributes.style = attribute.styleDiff;
18800 }
18801 }
18802 }
18803 return {
18804 id: _this.mirror.getId(attribute.node),
18805 attributes: attributes
18806 };
18807 }).filter(function(attribute) {
18808 return !addedIds.has(attribute.id);
18809 }).filter(function(attribute) {
18810 return _this.mirror.has(attribute.id);
18811 }),
18812 removes: _this.removes,
18813 adds: adds
18814 };
18815 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
18816 return;
18817 }
18818 _this.texts = [];
18819 _this.attributes = [];
18820 _this.attributeMap = /* @__PURE__ */ new WeakMap();
18821 _this.removes = [];
18822 _this.addedSet = /* @__PURE__ */ new Set();
18823 _this.movedSet = /* @__PURE__ */ new Set();
18824 _this.droppedSet = /* @__PURE__ */ new Set();
18825 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
18826 _this.movedMap = {};
18827 _this.mutationCb(payload);
18828 });
18829 __publicField(this, "genTextAreaValueMutation", function(textarea) {
18830 var item = _this.attributeMap.get(textarea);
18831 if (!item) {
18832 item = {
18833 node: textarea,
18834 attributes: {},
18835 styleDiff: {},
18836 _unchangedStyles: {}
18837 };
18838 _this.attributes.push(item);
18839 _this.attributeMap.set(textarea, item);
18840 }
18841 item.attributes.value = Array.from(index.childNodes(textarea), function(cn) {
18842 return index.textContent(cn) || "";
18843 }).join("");
18844 });
18845 __publicField(this, "processMutation", function(m) {
18846 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
18847 return;
18848 }
18849 switch(m.type){
18850 case "characterData":
18851 {
18852 var value = index.textContent(m.target);
18853 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
18854 _this.texts.push({
18855 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
18856 node: m.target
18857 });
18858 }
18859 break;
18860 }
18861 case "attributes":
18862 {
18863 var target = m.target;
18864 var attributeName = m.attributeName;
18865 var value1 = m.target.getAttribute(attributeName);
18866 if (attributeName === "value") {
18867 var type = getInputType(target);
18868 value1 = maskInputValue({
18869 element: target,
18870 maskInputOptions: _this.maskInputOptions,
18871 tagName: target.tagName,
18872 type: type,
18873 value: value1,
18874 maskInputFn: _this.maskInputFn
18875 });
18876 }
18877 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
18878 return;
18879 }
18880 var item = _this.attributeMap.get(m.target);
18881 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
18882 if (!target.contentDocument) {
18883 attributeName = "rr_src";
18884 } else {
18885 return;
18886 }
18887 }
18888 if (!item) {
18889 item = {
18890 node: m.target,
18891 attributes: {},
18892 styleDiff: {},
18893 _unchangedStyles: {}
18894 };
18895 _this.attributes.push(item);
18896 _this.attributeMap.set(m.target, item);
18897 }
18898 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
18899 target.setAttribute("data-rr-is-password", "true");
18900 }
18901 if (!ignoreAttribute(target.tagName, attributeName)) {
18902 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
18903 if (attributeName === "style") {
18904 if (!_this.unattachedDoc) {
18905 try {
18906 _this.unattachedDoc = document.implementation.createHTMLDocument();
18907 } catch (e2) {
18908 _this.unattachedDoc = _this.doc;
18909 }
18910 }
18911 var old = _this.unattachedDoc.createElement("span");
18912 if (m.oldValue) {
18913 old.setAttribute("style", m.oldValue);
18914 }
18915 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
18916 var pname = _step.value;
18917 var newValue = target.style.getPropertyValue(pname);
18918 var newPriority = target.style.getPropertyPriority(pname);
18919 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
18920 if (newPriority === "") {
18921 item.styleDiff[pname] = newValue;
18922 } else {
18923 item.styleDiff[pname] = [
18924 newValue,
18925 newPriority
18926 ];
18927 }
18928 } else {
18929 item._unchangedStyles[pname] = [
18930 newValue,
18931 newPriority
18932 ];
18933 }
18934 }
18935 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
18936 var pname1 = _step1.value;
18937 if (target.style.getPropertyValue(pname1) === "") {
18938 item.styleDiff[pname1] = false;
18939 }
18940 }
18941 } else if (attributeName === "open" && target.tagName === "DIALOG") {
18942 if (target.matches("dialog:modal")) {
18943 item.attributes["rr_open_mode"] = "modal";
18944 } else {
18945 item.attributes["rr_open_mode"] = "non-modal";
18946 }
18947 }
18948 }
18949 break;
18950 }
18951 case "childList":
18952 {
18953 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
18954 if (m.target.tagName === "TEXTAREA") {
18955 _this.genTextAreaValueMutation(m.target);
18956 return;
18957 }
18958 m.addedNodes.forEach(function(n2) {
18959 return _this.genAdds(n2, m.target);
18960 });
18961 m.removedNodes.forEach(function(n2) {
18962 var nodeId = _this.mirror.getId(n2);
18963 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
18964 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
18965 return;
18966 }
18967 if (_this.addedSet.has(n2)) {
18968 deepDelete(_this.addedSet, n2);
18969 _this.droppedSet.add(n2);
18970 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
18971 else if (isAncestorRemoved(m.target, _this.mirror)) ;
18972 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
18973 deepDelete(_this.movedSet, n2);
18974 } else {
18975 _this.removes.push({
18976 parentId: parentId,
18977 id: nodeId,
18978 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
18979 });
18980 processRemoves(n2, _this.removesSubTreeCache);
18981 }
18982 _this.mapRemoves.push(n2);
18983 });
18984 break;
18985 }
18986 }
18987 });
18988 /**
18989 * Make sure you check if `n`'s parent is blocked before calling this function
18990 * */ __publicField(this, "genAdds", function(n2, target) {
18991 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
18992 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
18993 if (_this.mirror.hasNode(n2)) {
18994 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
18995 return;
18996 }
18997 _this.movedSet.add(n2);
18998 var targetId = null;
18999 if (target && _this.mirror.hasNode(target)) {
19000 targetId = _this.mirror.getId(target);
19001 }
19002 if (targetId && targetId !== -1) {
19003 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19004 }
19005 } else {
19006 _this.addedSet.add(n2);
19007 _this.droppedSet.delete(n2);
19008 }
19009 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19010 index.childNodes(n2).forEach(function(childN) {
19011 return _this.genAdds(childN);
19012 });
19013 if (hasShadowRoot(n2)) {
19014 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19015 _this.processedNodeManager.add(childN, _this);
19016 _this.genAdds(childN, n2);
19017 });
19018 }
19019 }
19020 });
19021 }
19022 var _proto = MutationBuffer.prototype;
19023 _proto.init = function init(options) {
19024 var _this = this;
19025 [
19026 "mutationCb",
19027 "blockClass",
19028 "blockSelector",
19029 "maskTextClass",
19030 "maskTextSelector",
19031 "inlineStylesheet",
19032 "maskInputOptions",
19033 "maskTextFn",
19034 "maskInputFn",
19035 "keepIframeSrcFn",
19036 "recordCanvas",
19037 "inlineImages",
19038 "slimDOMOptions",
19039 "dataURLOptions",
19040 "doc",
19041 "mirror",
19042 "iframeManager",
19043 "stylesheetManager",
19044 "shadowDomManager",
19045 "canvasManager",
19046 "processedNodeManager"
19047 ].forEach(function(key) {
19048 _this[key] = options[key];
19049 });
19050 };
19051 _proto.freeze = function freeze() {
19052 this.frozen = true;
19053 this.canvasManager.freeze();
19054 };
19055 _proto.unfreeze = function unfreeze() {
19056 this.frozen = false;
19057 this.canvasManager.unfreeze();
19058 this.emit();
19059 };
19060 _proto.isFrozen = function isFrozen() {
19061 return this.frozen;
19062 };
19063 _proto.lock = function lock() {
19064 this.locked = true;
19065 this.canvasManager.lock();
19066 };
19067 _proto.unlock = function unlock() {
19068 this.locked = false;
19069 this.canvasManager.unlock();
19070 this.emit();
19071 };
19072 _proto.reset = function reset() {
19073 this.shadowDomManager.reset();
19074 this.canvasManager.reset();
19075 };
19076 return MutationBuffer;
19077 }();
19078 function deepDelete(addsSet, n2) {
19079 addsSet.delete(n2);
19080 index.childNodes(n2).forEach(function(childN) {
19081 return deepDelete(addsSet, childN);
19082 });
19083 }
19084 function processRemoves(n2, cache) {
19085 var queue = [
19086 n2
19087 ];
19088 while(queue.length){
19089 var next = queue.pop();
19090 if (cache.has(next)) continue;
19091 cache.add(next);
19092 index.childNodes(next).forEach(function(n22) {
19093 return queue.push(n22);
19094 });
19095 }
19096 return;
19097 }
19098 function isParentRemoved(removes, n2, mirror2) {
19099 if (removes.size === 0) return false;
19100 return _isParentRemoved(removes, n2);
19101 }
19102 function _isParentRemoved(removes, n2, _mirror2) {
19103 var node2 = index.parentNode(n2);
19104 if (!node2) return false;
19105 return removes.has(node2);
19106 }
19107 function isAncestorInSet(set, n2) {
19108 if (set.size === 0) return false;
19109 return _isAncestorInSet(set, n2);
19110 }
19111 function _isAncestorInSet(set, n2) {
19112 var parent = index.parentNode(n2);
19113 if (!parent) {
19114 return false;
19115 }
19116 if (set.has(parent)) {
19117 return true;
19118 }
19119 return _isAncestorInSet(set, parent);
19120 }
19121 var errorHandler;
19122 function registerErrorHandler(handler) {
19123 errorHandler = handler;
19124 }
19125 function unregisterErrorHandler() {
19126 errorHandler = void 0;
19127 }
19128 var callbackWrapper = function(cb) {
19129 if (!errorHandler) {
19130 return cb;
19131 }
19132 var rrwebWrapped = function() {
19133 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19134 rest[_key] = arguments[_key];
19135 }
19136 try {
19137 return cb.apply(void 0, [].concat(rest));
19138 } catch (error) {
19139 if (errorHandler && errorHandler(error) === true) {
19140 return;
19141 }
19142 throw error;
19143 }
19144 };
19145 return rrwebWrapped;
19146 };
19147 var mutationBuffers = [];
19148 function getEventTarget(event) {
19149 try {
19150 if ("composedPath" in event) {
19151 var path = event.composedPath();
19152 if (path.length) {
19153 return path[0];
19154 }
19155 } else if ("path" in event && event.path.length) {
19156 return event.path[0];
19157 }
19158 } catch (e) {}
19159 return event && event.target;
19160 }
19161 function initMutationObserver(options, rootEl) {
19162 var mutationBuffer = new MutationBuffer();
19163 mutationBuffers.push(mutationBuffer);
19164 mutationBuffer.init(options);
19165 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
19166 observer.observe(rootEl, {
19167 attributes: true,
19168 attributeOldValue: true,
19169 characterData: true,
19170 characterDataOldValue: true,
19171 childList: true,
19172 subtree: true
19173 });
19174 return observer;
19175 }
19176 function initMoveObserver(param) {
19177 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
19178 if (sampling.mousemove === false) {
19179 return function() {};
19180 }
19181 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
19182 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
19183 var positions = [];
19184 var timeBaseline;
19185 var wrappedCb = throttle(callbackWrapper(function(source) {
19186 var totalOffset = Date.now() - timeBaseline;
19187 mousemoveCb(positions.map(function(p) {
19188 p.timeOffset -= totalOffset;
19189 return p;
19190 }), source);
19191 positions = [];
19192 timeBaseline = null;
19193 }), callbackThreshold);
19194 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19195 var target = getEventTarget(evt);
19196 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
19197 if (!timeBaseline) {
19198 timeBaseline = nowTimestamp();
19199 }
19200 positions.push({
19201 x: clientX,
19202 y: clientY,
19203 id: mirror2.getId(target),
19204 timeOffset: nowTimestamp() - timeBaseline
19205 });
19206 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
19207 }), threshold, {
19208 trailing: false
19209 }));
19210 var handlers = [
19211 on("mousemove", updatePosition, doc),
19212 on("touchmove", updatePosition, doc),
19213 on("drag", updatePosition, doc)
19214 ];
19215 return callbackWrapper(function() {
19216 handlers.forEach(function(h) {
19217 return h();
19218 });
19219 });
19220 }
19221 function initMouseInteractionObserver(param) {
19222 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19223 if (sampling.mouseInteraction === false) {
19224 return function() {};
19225 }
19226 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
19227 var handlers = [];
19228 var currentPointerType = null;
19229 var getHandler = function(eventKey) {
19230 return function(event) {
19231 var target = getEventTarget(event);
19232 if (isBlocked(target, blockClass, blockSelector, true)) {
19233 return;
19234 }
19235 var pointerType = null;
19236 var thisEventKey = eventKey;
19237 if ("pointerType" in event) {
19238 switch(event.pointerType){
19239 case "mouse":
19240 pointerType = PointerTypes.Mouse;
19241 break;
19242 case "touch":
19243 pointerType = PointerTypes.Touch;
19244 break;
19245 case "pen":
19246 pointerType = PointerTypes.Pen;
19247 break;
19248 }
19249 if (pointerType === PointerTypes.Touch) {
19250 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
19251 thisEventKey = "TouchStart";
19252 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
19253 thisEventKey = "TouchEnd";
19254 }
19255 } else if (pointerType === PointerTypes.Pen) ;
19256 } else if (legacy_isTouchEvent(event)) {
19257 pointerType = PointerTypes.Touch;
19258 }
19259 if (pointerType !== null) {
19260 currentPointerType = pointerType;
19261 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
19262 pointerType = null;
19263 }
19264 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
19265 pointerType = currentPointerType;
19266 currentPointerType = null;
19267 }
19268 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
19269 if (!e2) {
19270 return;
19271 }
19272 var id = mirror2.getId(target);
19273 var clientX = e2.clientX, clientY = e2.clientY;
19274 callbackWrapper(mouseInteractionCb)(_extends({
19275 type: MouseInteractions[thisEventKey],
19276 id: id,
19277 x: clientX,
19278 y: clientY
19279 }, pointerType !== null && {
19280 pointerType: pointerType
19281 }));
19282 };
19283 };
19284 Object.keys(MouseInteractions).filter(function(key) {
19285 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
19286 }).forEach(function(eventKey) {
19287 var eventName = toLowerCase(eventKey);
19288 var handler = getHandler(eventKey);
19289 if (window.PointerEvent) {
19290 switch(MouseInteractions[eventKey]){
19291 case MouseInteractions.MouseDown:
19292 case MouseInteractions.MouseUp:
19293 eventName = eventName.replace("mouse", "pointer");
19294 break;
19295 case MouseInteractions.TouchStart:
19296 case MouseInteractions.TouchEnd:
19297 return;
19298 }
19299 }
19300 handlers.push(on(eventName, handler, doc));
19301 });
19302 return callbackWrapper(function() {
19303 handlers.forEach(function(h) {
19304 return h();
19305 });
19306 });
19307 }
19308 function initScrollObserver(param) {
19309 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
19310 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
19311 var target = getEventTarget(evt);
19312 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
19313 return;
19314 }
19315 var id = mirror2.getId(target);
19316 if (target === doc && doc.defaultView) {
19317 var scrollLeftTop = getWindowScroll(doc.defaultView);
19318 scrollCb({
19319 id: id,
19320 x: scrollLeftTop.left,
19321 y: scrollLeftTop.top
19322 });
19323 } else {
19324 scrollCb({
19325 id: id,
19326 x: target.scrollLeft,
19327 y: target.scrollTop
19328 });
19329 }
19330 }), sampling.scroll || 100));
19331 return on("scroll", updatePosition, doc);
19332 }
19333 function initViewportResizeObserver(param, param1) {
19334 var viewportResizeCb = param.viewportResizeCb;
19335 var win = param1.win;
19336 var lastH = -1;
19337 var lastW = -1;
19338 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
19339 var height = getWindowHeight();
19340 var width = getWindowWidth();
19341 if (lastH !== height || lastW !== width) {
19342 viewportResizeCb({
19343 width: Number(width),
19344 height: Number(height)
19345 });
19346 lastH = height;
19347 lastW = width;
19348 }
19349 }), 200));
19350 return on("resize", updateDimension, win);
19351 }
19352 var INPUT_TAGS = [
19353 "INPUT",
19354 "TEXTAREA",
19355 "SELECT"
19356 ];
19357 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
19358 function initInputObserver(param) {
19359 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;
19360 function eventHandler(event) {
19361 var target = getEventTarget(event);
19362 var userTriggered = event.isTrusted;
19363 var tagName = target && target.tagName;
19364 if (target && tagName === "OPTION") {
19365 target = index.parentElement(target);
19366 }
19367 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
19368 return;
19369 }
19370 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
19371 return;
19372 }
19373 var text = target.value;
19374 var isChecked = false;
19375 var type = getInputType(target) || "";
19376 if (type === "radio" || type === "checkbox") {
19377 isChecked = target.checked;
19378 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
19379 text = maskInputValue({
19380 element: target,
19381 maskInputOptions: maskInputOptions,
19382 tagName: tagName,
19383 type: type,
19384 value: text,
19385 maskInputFn: maskInputFn
19386 });
19387 }
19388 cbWithDedup(target, userTriggeredOnInput ? {
19389 text: text,
19390 isChecked: isChecked,
19391 userTriggered: userTriggered
19392 } : {
19393 text: text,
19394 isChecked: isChecked
19395 });
19396 var name = target.name;
19397 if (type === "radio" && name && isChecked) {
19398 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
19399 if (el !== target) {
19400 var text2 = el.value;
19401 cbWithDedup(el, userTriggeredOnInput ? {
19402 text: text2,
19403 isChecked: !isChecked,
19404 userTriggered: false
19405 } : {
19406 text: text2,
19407 isChecked: !isChecked
19408 });
19409 }
19410 });
19411 }
19412 }
19413 function cbWithDedup(target, v2) {
19414 var lastInputValue = lastInputValueMap.get(target);
19415 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
19416 lastInputValueMap.set(target, v2);
19417 var id = mirror2.getId(target);
19418 callbackWrapper(inputCb)(_extends({}, v2, {
19419 id: id
19420 }));
19421 }
19422 }
19423 var events = sampling.input === "last" ? [
19424 "change"
19425 ] : [
19426 "input",
19427 "change"
19428 ];
19429 var handlers = events.map(function(eventName) {
19430 return on(eventName, callbackWrapper(eventHandler), doc);
19431 });
19432 var currentWindow = doc.defaultView;
19433 if (!currentWindow) {
19434 return function() {
19435 handlers.forEach(function(h) {
19436 return h();
19437 });
19438 };
19439 }
19440 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
19441 var hookProperties = [
19442 [
19443 currentWindow.HTMLInputElement.prototype,
19444 "value"
19445 ],
19446 [
19447 currentWindow.HTMLInputElement.prototype,
19448 "checked"
19449 ],
19450 [
19451 currentWindow.HTMLSelectElement.prototype,
19452 "value"
19453 ],
19454 [
19455 currentWindow.HTMLTextAreaElement.prototype,
19456 "value"
19457 ],
19458 // Some UI library use selectedIndex to set select value
19459 [
19460 currentWindow.HTMLSelectElement.prototype,
19461 "selectedIndex"
19462 ],
19463 [
19464 currentWindow.HTMLOptionElement.prototype,
19465 "selected"
19466 ]
19467 ];
19468 if (propertyDescriptor && propertyDescriptor.set) {
19469 var _handlers;
19470 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
19471 return hookSetter(p[0], p[1], {
19472 set: function set() {
19473 callbackWrapper(eventHandler)({
19474 target: this,
19475 isTrusted: false
19476 });
19477 }
19478 }, false, currentWindow);
19479 })));
19480 }
19481 return callbackWrapper(function() {
19482 handlers.forEach(function(h) {
19483 return h();
19484 });
19485 });
19486 }
19487 function getNestedCSSRulePositions(rule2) {
19488 var positions = [];
19489 function recurse(childRule, pos) {
19490 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)) {
19491 var rules2 = Array.from(childRule.parentRule.cssRules);
19492 var index2 = rules2.indexOf(childRule);
19493 pos.unshift(index2);
19494 } else if (childRule.parentStyleSheet) {
19495 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
19496 var index21 = rules21.indexOf(childRule);
19497 pos.unshift(index21);
19498 }
19499 return pos;
19500 }
19501 return recurse(rule2, positions);
19502 }
19503 function getIdAndStyleId(sheet, mirror2, styleMirror) {
19504 var id, styleId;
19505 if (!sheet) return {};
19506 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
19507 else styleId = styleMirror.getId(sheet);
19508 return {
19509 styleId: styleId,
19510 id: id
19511 };
19512 }
19513 function initStyleSheetObserver(param, param1) {
19514 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
19515 var win = param1.win;
19516 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
19517 return function() {};
19518 }
19519 var insertRule = win.CSSStyleSheet.prototype.insertRule;
19520 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
19521 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19522 var rule2 = argumentsList[0], index2 = argumentsList[1];
19523 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19524 if (id && id !== -1 || styleId && styleId !== -1) {
19525 styleSheetRuleCb({
19526 id: id,
19527 styleId: styleId,
19528 adds: [
19529 {
19530 rule: rule2,
19531 index: index2
19532 }
19533 ]
19534 });
19535 }
19536 return target.apply(thisArg, argumentsList);
19537 })
19538 });
19539 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
19540 if (index2 === void 0) index2 = this.cssRules.length;
19541 var rule2 = selector + " { " + styleBlock + " }";
19542 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
19543 rule2,
19544 index2
19545 ]);
19546 };
19547 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
19548 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
19549 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19550 var index2 = argumentsList[0];
19551 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19552 if (id && id !== -1 || styleId && styleId !== -1) {
19553 styleSheetRuleCb({
19554 id: id,
19555 styleId: styleId,
19556 removes: [
19557 {
19558 index: index2
19559 }
19560 ]
19561 });
19562 }
19563 return target.apply(thisArg, argumentsList);
19564 })
19565 });
19566 win.CSSStyleSheet.prototype.removeRule = function(index2) {
19567 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
19568 index2
19569 ]);
19570 };
19571 var replace;
19572 if (win.CSSStyleSheet.prototype.replace) {
19573 replace = win.CSSStyleSheet.prototype.replace;
19574 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
19575 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19576 var text = argumentsList[0];
19577 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19578 if (id && id !== -1 || styleId && styleId !== -1) {
19579 styleSheetRuleCb({
19580 id: id,
19581 styleId: styleId,
19582 replace: text
19583 });
19584 }
19585 return target.apply(thisArg, argumentsList);
19586 })
19587 });
19588 }
19589 var replaceSync;
19590 if (win.CSSStyleSheet.prototype.replaceSync) {
19591 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
19592 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
19593 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19594 var text = argumentsList[0];
19595 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19596 if (id && id !== -1 || styleId && styleId !== -1) {
19597 styleSheetRuleCb({
19598 id: id,
19599 styleId: styleId,
19600 replaceSync: text
19601 });
19602 }
19603 return target.apply(thisArg, argumentsList);
19604 })
19605 });
19606 }
19607 var supportedNestedCSSRuleTypes = {};
19608 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
19609 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
19610 } else {
19611 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
19612 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
19613 }
19614 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
19615 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
19616 }
19617 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
19618 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
19619 }
19620 }
19621 var unmodifiedFunctions = {};
19622 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
19623 var typeKey = param[0], type = param[1];
19624 unmodifiedFunctions[typeKey] = {
19625 // eslint-disable-next-line @typescript-eslint/unbound-method
19626 insertRule: type.prototype.insertRule,
19627 // eslint-disable-next-line @typescript-eslint/unbound-method
19628 deleteRule: type.prototype.deleteRule
19629 };
19630 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
19631 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19632 var rule2 = argumentsList[0], index2 = argumentsList[1];
19633 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19634 if (id && id !== -1 || styleId && styleId !== -1) {
19635 styleSheetRuleCb({
19636 id: id,
19637 styleId: styleId,
19638 adds: [
19639 {
19640 rule: rule2,
19641 index: [].concat(getNestedCSSRulePositions(thisArg), [
19642 index2 || 0
19643 ])
19644 }
19645 ]
19646 });
19647 }
19648 return target.apply(thisArg, argumentsList);
19649 })
19650 });
19651 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
19652 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19653 var index2 = argumentsList[0];
19654 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19655 if (id && id !== -1 || styleId && styleId !== -1) {
19656 styleSheetRuleCb({
19657 id: id,
19658 styleId: styleId,
19659 removes: [
19660 {
19661 index: [].concat(getNestedCSSRulePositions(thisArg), [
19662 index2
19663 ])
19664 }
19665 ]
19666 });
19667 }
19668 return target.apply(thisArg, argumentsList);
19669 })
19670 });
19671 });
19672 return callbackWrapper(function() {
19673 win.CSSStyleSheet.prototype.insertRule = insertRule;
19674 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
19675 replace && (win.CSSStyleSheet.prototype.replace = replace);
19676 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
19677 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
19678 var typeKey = param[0], type = param[1];
19679 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
19680 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
19681 });
19682 });
19683 }
19684 function initAdoptedStyleSheetObserver(param, host2) {
19685 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
19686 var _a2, _b, _c;
19687 var hostId = null;
19688 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
19689 else hostId = mirror2.getId(index.host(host2));
19690 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;
19691 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
19692 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
19693 Object.defineProperty(host2, "adoptedStyleSheets", {
19694 configurable: originalPropertyDescriptor.configurable,
19695 enumerable: originalPropertyDescriptor.enumerable,
19696 get: function get() {
19697 var _a3;
19698 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
19699 },
19700 set: function set(sheets) {
19701 var _a3;
19702 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
19703 if (hostId !== null && hostId !== -1) {
19704 try {
19705 stylesheetManager.adoptStyleSheets(sheets, hostId);
19706 } catch (e2) {}
19707 }
19708 return result2;
19709 }
19710 });
19711 return callbackWrapper(function() {
19712 Object.defineProperty(host2, "adoptedStyleSheets", {
19713 configurable: originalPropertyDescriptor.configurable,
19714 enumerable: originalPropertyDescriptor.enumerable,
19715 // eslint-disable-next-line @typescript-eslint/unbound-method
19716 get: originalPropertyDescriptor.get,
19717 // eslint-disable-next-line @typescript-eslint/unbound-method
19718 set: originalPropertyDescriptor.set
19719 });
19720 });
19721 }
19722 function initStyleDeclarationObserver(param, param1) {
19723 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
19724 var win = param1.win;
19725 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
19726 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
19727 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19728 var _a2;
19729 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
19730 if (ignoreCSSAttributes.has(property)) {
19731 return setProperty.apply(thisArg, [
19732 property,
19733 value,
19734 priority
19735 ]);
19736 }
19737 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19738 if (id && id !== -1 || styleId && styleId !== -1) {
19739 styleDeclarationCb({
19740 id: id,
19741 styleId: styleId,
19742 set: {
19743 property: property,
19744 value: value,
19745 priority: priority
19746 },
19747 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19748 index: getNestedCSSRulePositions(thisArg.parentRule)
19749 });
19750 }
19751 return target.apply(thisArg, argumentsList);
19752 })
19753 });
19754 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
19755 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
19756 apply: callbackWrapper(function(target, thisArg, argumentsList) {
19757 var _a2;
19758 var property = argumentsList[0];
19759 if (ignoreCSSAttributes.has(property)) {
19760 return removeProperty.apply(thisArg, [
19761 property
19762 ]);
19763 }
19764 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
19765 if (id && id !== -1 || styleId && styleId !== -1) {
19766 styleDeclarationCb({
19767 id: id,
19768 styleId: styleId,
19769 remove: {
19770 property: property
19771 },
19772 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19773 index: getNestedCSSRulePositions(thisArg.parentRule)
19774 });
19775 }
19776 return target.apply(thisArg, argumentsList);
19777 })
19778 });
19779 return callbackWrapper(function() {
19780 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
19781 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
19782 });
19783 }
19784 function initMediaInteractionObserver(param) {
19785 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
19786 var handler = callbackWrapper(function(type) {
19787 return throttle(callbackWrapper(function(event) {
19788 var target = getEventTarget(event);
19789 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
19790 return;
19791 }
19792 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
19793 mediaInteractionCb({
19794 type: type,
19795 id: mirror2.getId(target),
19796 currentTime: currentTime,
19797 volume: volume,
19798 muted: muted,
19799 playbackRate: playbackRate,
19800 loop: loop
19801 });
19802 }), sampling.media || 500);
19803 });
19804 var handlers = [
19805 on("play", handler(MediaInteractions.Play), doc),
19806 on("pause", handler(MediaInteractions.Pause), doc),
19807 on("seeked", handler(MediaInteractions.Seeked), doc),
19808 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
19809 on("ratechange", handler(MediaInteractions.RateChange), doc)
19810 ];
19811 return callbackWrapper(function() {
19812 handlers.forEach(function(h) {
19813 return h();
19814 });
19815 });
19816 }
19817 function initFontObserver(param) {
19818 var fontCb = param.fontCb, doc = param.doc;
19819 var win = doc.defaultView;
19820 if (!win) {
19821 return function() {};
19822 }
19823 var handlers = [];
19824 var fontMap = /* @__PURE__ */ new WeakMap();
19825 var originalFontFace = win.FontFace;
19826 win.FontFace = function FontFace2(family, source, descriptors) {
19827 var fontFace = new originalFontFace(family, source, descriptors);
19828 fontMap.set(fontFace, {
19829 family: family,
19830 buffer: typeof source !== "string",
19831 descriptors: descriptors,
19832 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
19833 });
19834 return fontFace;
19835 };
19836 var restoreHandler = patch(doc.fonts, "add", function(original) {
19837 return function(fontFace) {
19838 setTimeout(callbackWrapper(function() {
19839 var p = fontMap.get(fontFace);
19840 if (p) {
19841 fontCb(p);
19842 fontMap.delete(fontFace);
19843 }
19844 }), 0);
19845 return original.apply(this, [
19846 fontFace
19847 ]);
19848 };
19849 });
19850 handlers.push(function() {
19851 win.FontFace = originalFontFace;
19852 });
19853 handlers.push(restoreHandler);
19854 return callbackWrapper(function() {
19855 handlers.forEach(function(h) {
19856 return h();
19857 });
19858 });
19859 }
19860 function initSelectionObserver(param) {
19861 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
19862 var collapsed = true;
19863 var updateSelection = callbackWrapper(function() {
19864 var selection = doc.getSelection();
19865 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
19866 collapsed = selection.isCollapsed || false;
19867 var ranges = [];
19868 var count = selection.rangeCount || 0;
19869 for(var i2 = 0; i2 < count; i2++){
19870 var range = selection.getRangeAt(i2);
19871 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
19872 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
19873 if (blocked) continue;
19874 ranges.push({
19875 start: mirror2.getId(startContainer),
19876 startOffset: startOffset,
19877 end: mirror2.getId(endContainer),
19878 endOffset: endOffset
19879 });
19880 }
19881 selectionCb({
19882 ranges: ranges
19883 });
19884 });
19885 updateSelection();
19886 return on("selectionchange", updateSelection);
19887 }
19888 function initCustomElementObserver(param) {
19889 var doc = param.doc, customElementCb = param.customElementCb;
19890 var win = doc.defaultView;
19891 if (!win || !win.customElements) return function() {};
19892 var restoreHandler = patch(win.customElements, "define", function(original) {
19893 return function(name, constructor, options) {
19894 try {
19895 customElementCb({
19896 define: {
19897 name: name
19898 }
19899 });
19900 } catch (e2) {
19901 console.warn("Custom element callback failed for " + name);
19902 }
19903 return original.apply(this, [
19904 name,
19905 constructor,
19906 options
19907 ]);
19908 };
19909 });
19910 return restoreHandler;
19911 }
19912 function mergeHooks(o2, hooks) {
19913 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;
19914 o2.mutationCb = function() {
19915 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19916 p[_key] = arguments[_key];
19917 }
19918 if (hooks.mutation) {
19919 var _hooks;
19920 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
19921 }
19922 mutationCb.apply(void 0, [].concat(p));
19923 };
19924 o2.mousemoveCb = function() {
19925 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19926 p[_key] = arguments[_key];
19927 }
19928 if (hooks.mousemove) {
19929 var _hooks;
19930 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
19931 }
19932 mousemoveCb.apply(void 0, [].concat(p));
19933 };
19934 o2.mouseInteractionCb = function() {
19935 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19936 p[_key] = arguments[_key];
19937 }
19938 if (hooks.mouseInteraction) {
19939 var _hooks;
19940 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
19941 }
19942 mouseInteractionCb.apply(void 0, [].concat(p));
19943 };
19944 o2.scrollCb = function() {
19945 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19946 p[_key] = arguments[_key];
19947 }
19948 if (hooks.scroll) {
19949 var _hooks;
19950 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
19951 }
19952 scrollCb.apply(void 0, [].concat(p));
19953 };
19954 o2.viewportResizeCb = function() {
19955 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19956 p[_key] = arguments[_key];
19957 }
19958 if (hooks.viewportResize) {
19959 var _hooks;
19960 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
19961 }
19962 viewportResizeCb.apply(void 0, [].concat(p));
19963 };
19964 o2.inputCb = function() {
19965 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19966 p[_key] = arguments[_key];
19967 }
19968 if (hooks.input) {
19969 var _hooks;
19970 (_hooks = hooks).input.apply(_hooks, [].concat(p));
19971 }
19972 inputCb.apply(void 0, [].concat(p));
19973 };
19974 o2.mediaInteractionCb = function() {
19975 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19976 p[_key] = arguments[_key];
19977 }
19978 if (hooks.mediaInteaction) {
19979 var _hooks;
19980 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
19981 }
19982 mediaInteractionCb.apply(void 0, [].concat(p));
19983 };
19984 o2.styleSheetRuleCb = function() {
19985 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19986 p[_key] = arguments[_key];
19987 }
19988 if (hooks.styleSheetRule) {
19989 var _hooks;
19990 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
19991 }
19992 styleSheetRuleCb.apply(void 0, [].concat(p));
19993 };
19994 o2.styleDeclarationCb = function() {
19995 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
19996 p[_key] = arguments[_key];
19997 }
19998 if (hooks.styleDeclaration) {
19999 var _hooks;
20000 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20001 }
20002 styleDeclarationCb.apply(void 0, [].concat(p));
20003 };
20004 o2.canvasMutationCb = function() {
20005 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20006 p[_key] = arguments[_key];
20007 }
20008 if (hooks.canvasMutation) {
20009 var _hooks;
20010 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20011 }
20012 canvasMutationCb.apply(void 0, [].concat(p));
20013 };
20014 o2.fontCb = function() {
20015 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20016 p[_key] = arguments[_key];
20017 }
20018 if (hooks.font) {
20019 var _hooks;
20020 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20021 }
20022 fontCb.apply(void 0, [].concat(p));
20023 };
20024 o2.selectionCb = function() {
20025 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20026 p[_key] = arguments[_key];
20027 }
20028 if (hooks.selection) {
20029 var _hooks;
20030 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20031 }
20032 selectionCb.apply(void 0, [].concat(p));
20033 };
20034 o2.customElementCb = function() {
20035 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20036 c2[_key] = arguments[_key];
20037 }
20038 if (hooks.customElement) {
20039 var _hooks;
20040 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20041 }
20042 customElementCb.apply(void 0, [].concat(c2));
20043 };
20044 }
20045 function initObservers(o2, hooks) {
20046 if (hooks === void 0) hooks = {};
20047 var currentWindow = o2.doc.defaultView;
20048 if (!currentWindow) {
20049 return function() {};
20050 }
20051 mergeHooks(o2, hooks);
20052 var mutationObserver;
20053 if (o2.recordDOM) {
20054 mutationObserver = initMutationObserver(o2, o2.doc);
20055 }
20056 var mousemoveHandler = initMoveObserver(o2);
20057 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20058 var scrollHandler = initScrollObserver(o2);
20059 var viewportResizeHandler = initViewportResizeObserver(o2, {
20060 win: currentWindow
20061 });
20062 var inputHandler = initInputObserver(o2);
20063 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20064 var styleSheetObserver = function() {};
20065 var adoptedStyleSheetObserver = function() {};
20066 var styleDeclarationObserver = function() {};
20067 var fontObserver = function() {};
20068 if (o2.recordDOM) {
20069 styleSheetObserver = initStyleSheetObserver(o2, {
20070 win: currentWindow
20071 });
20072 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20073 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20074 win: currentWindow
20075 });
20076 if (o2.collectFonts) {
20077 fontObserver = initFontObserver(o2);
20078 }
20079 }
20080 var selectionObserver = initSelectionObserver(o2);
20081 var customElementObserver = initCustomElementObserver(o2);
20082 var pluginHandlers = [];
20083 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20084 var plugin3 = _step.value;
20085 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20086 }
20087 return callbackWrapper(function() {
20088 mutationBuffers.forEach(function(b) {
20089 return b.reset();
20090 });
20091 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20092 mousemoveHandler();
20093 mouseInteractionHandler();
20094 scrollHandler();
20095 viewportResizeHandler();
20096 inputHandler();
20097 mediaInteractionHandler();
20098 styleSheetObserver();
20099 adoptedStyleSheetObserver();
20100 styleDeclarationObserver();
20101 fontObserver();
20102 selectionObserver();
20103 customElementObserver();
20104 pluginHandlers.forEach(function(h) {
20105 return h();
20106 });
20107 });
20108 }
20109 function hasNestedCSSRule(prop) {
20110 return typeof window[prop] !== "undefined";
20111 }
20112 function canMonkeyPatchNestedCSSRule(prop) {
20113 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20114 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20115 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20116 }
20117 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20118 function CrossOriginIframeMirror(generateIdFn) {
20119 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20120 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20121 this.generateIdFn = generateIdFn;
20122 }
20123 var _proto = CrossOriginIframeMirror.prototype;
20124 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20125 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20126 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20127 var id = idToRemoteIdMap.get(remoteId);
20128 if (!id) {
20129 id = this.generateIdFn();
20130 idToRemoteIdMap.set(remoteId, id);
20131 remoteIdToIdMap.set(id, remoteId);
20132 }
20133 return id;
20134 };
20135 _proto.getIds = function getIds(iframe, remoteId) {
20136 var _this = this;
20137 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20138 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20139 return remoteId.map(function(id) {
20140 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20141 });
20142 };
20143 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20144 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20145 if (typeof id !== "number") return id;
20146 var remoteId = remoteIdToIdMap.get(id);
20147 if (!remoteId) return -1;
20148 return remoteId;
20149 };
20150 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
20151 var _this = this;
20152 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20153 return ids.map(function(id) {
20154 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
20155 });
20156 };
20157 _proto.reset = function reset(iframe) {
20158 if (!iframe) {
20159 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
20160 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
20161 return;
20162 }
20163 this.iframeIdToRemoteIdMap.delete(iframe);
20164 this.iframeRemoteIdToIdMap.delete(iframe);
20165 };
20166 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
20167 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
20168 if (!idToRemoteIdMap) {
20169 idToRemoteIdMap = /* @__PURE__ */ new Map();
20170 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
20171 }
20172 return idToRemoteIdMap;
20173 };
20174 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
20175 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
20176 if (!remoteIdToIdMap) {
20177 remoteIdToIdMap = /* @__PURE__ */ new Map();
20178 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
20179 }
20180 return remoteIdToIdMap;
20181 };
20182 return CrossOriginIframeMirror;
20183 }();
20184 var IframeManager = /*#__PURE__*/ function() {
20185 function IframeManager(options) {
20186 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
20187 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
20188 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
20189 __publicField(this, "crossOriginIframeStyleMirror");
20190 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
20191 __publicField(this, "mirror");
20192 __publicField(this, "mutationCb");
20193 __publicField(this, "wrappedEmit");
20194 __publicField(this, "loadListener");
20195 __publicField(this, "stylesheetManager");
20196 __publicField(this, "recordCrossOriginIframes");
20197 this.mutationCb = options.mutationCb;
20198 this.wrappedEmit = options.wrappedEmit;
20199 this.stylesheetManager = options.stylesheetManager;
20200 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
20201 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
20202 this.mirror = options.mirror;
20203 if (this.recordCrossOriginIframes) {
20204 window.addEventListener("message", this.handleMessage.bind(this));
20205 }
20206 }
20207 var _proto = IframeManager.prototype;
20208 _proto.addIframe = function addIframe(iframeEl) {
20209 this.iframes.set(iframeEl, true);
20210 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
20211 };
20212 _proto.addLoadListener = function addLoadListener(cb) {
20213 this.loadListener = cb;
20214 };
20215 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
20216 var _a2, _b;
20217 this.mutationCb({
20218 adds: [
20219 {
20220 parentId: this.mirror.getId(iframeEl),
20221 nextId: null,
20222 node: childSn
20223 }
20224 ],
20225 removes: [],
20226 texts: [],
20227 attributes: [],
20228 isAttachIframe: true
20229 });
20230 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
20231 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
20232 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
20233 };
20234 _proto.handleMessage = function handleMessage(message) {
20235 var crossOriginMessageEvent = message;
20236 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
20237 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
20238 var iframeSourceWindow = message.source;
20239 if (!iframeSourceWindow) return;
20240 var iframeEl = this.crossOriginIframeMap.get(message.source);
20241 if (!iframeEl) return;
20242 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
20243 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
20244 };
20245 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
20246 var _this = this;
20247 var _a2;
20248 switch(e2.type){
20249 case EventType.FullSnapshot:
20250 {
20251 this.crossOriginIframeMirror.reset(iframeEl);
20252 this.crossOriginIframeStyleMirror.reset(iframeEl);
20253 this.replaceIdOnNode(e2.data.node, iframeEl);
20254 var rootId = e2.data.node.id;
20255 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
20256 this.patchRootIdOnNode(e2.data.node, rootId);
20257 return {
20258 timestamp: e2.timestamp,
20259 type: EventType.IncrementalSnapshot,
20260 data: {
20261 source: IncrementalSource.Mutation,
20262 adds: [
20263 {
20264 parentId: this.mirror.getId(iframeEl),
20265 nextId: null,
20266 node: e2.data.node
20267 }
20268 ],
20269 removes: [],
20270 texts: [],
20271 attributes: [],
20272 isAttachIframe: true
20273 }
20274 };
20275 }
20276 case EventType.Meta:
20277 case EventType.Load:
20278 case EventType.DomContentLoaded:
20279 {
20280 return false;
20281 }
20282 case EventType.Plugin:
20283 {
20284 return e2;
20285 }
20286 case EventType.Custom:
20287 {
20288 this.replaceIds(e2.data.payload, iframeEl, [
20289 "id",
20290 "parentId",
20291 "previousId",
20292 "nextId"
20293 ]);
20294 return e2;
20295 }
20296 case EventType.IncrementalSnapshot:
20297 {
20298 switch(e2.data.source){
20299 case IncrementalSource.Mutation:
20300 {
20301 e2.data.adds.forEach(function(n2) {
20302 _this.replaceIds(n2, iframeEl, [
20303 "parentId",
20304 "nextId",
20305 "previousId"
20306 ]);
20307 _this.replaceIdOnNode(n2.node, iframeEl);
20308 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
20309 rootId && _this.patchRootIdOnNode(n2.node, rootId);
20310 });
20311 e2.data.removes.forEach(function(n2) {
20312 _this.replaceIds(n2, iframeEl, [
20313 "parentId",
20314 "id"
20315 ]);
20316 });
20317 e2.data.attributes.forEach(function(n2) {
20318 _this.replaceIds(n2, iframeEl, [
20319 "id"
20320 ]);
20321 });
20322 e2.data.texts.forEach(function(n2) {
20323 _this.replaceIds(n2, iframeEl, [
20324 "id"
20325 ]);
20326 });
20327 return e2;
20328 }
20329 case IncrementalSource.Drag:
20330 case IncrementalSource.TouchMove:
20331 case IncrementalSource.MouseMove:
20332 {
20333 e2.data.positions.forEach(function(p) {
20334 _this.replaceIds(p, iframeEl, [
20335 "id"
20336 ]);
20337 });
20338 return e2;
20339 }
20340 case IncrementalSource.ViewportResize:
20341 {
20342 return false;
20343 }
20344 case IncrementalSource.MediaInteraction:
20345 case IncrementalSource.MouseInteraction:
20346 case IncrementalSource.Scroll:
20347 case IncrementalSource.CanvasMutation:
20348 case IncrementalSource.Input:
20349 {
20350 this.replaceIds(e2.data, iframeEl, [
20351 "id"
20352 ]);
20353 return e2;
20354 }
20355 case IncrementalSource.StyleSheetRule:
20356 case IncrementalSource.StyleDeclaration:
20357 {
20358 this.replaceIds(e2.data, iframeEl, [
20359 "id"
20360 ]);
20361 this.replaceStyleIds(e2.data, iframeEl, [
20362 "styleId"
20363 ]);
20364 return e2;
20365 }
20366 case IncrementalSource.Font:
20367 {
20368 return e2;
20369 }
20370 case IncrementalSource.Selection:
20371 {
20372 e2.data.ranges.forEach(function(range) {
20373 _this.replaceIds(range, iframeEl, [
20374 "start",
20375 "end"
20376 ]);
20377 });
20378 return e2;
20379 }
20380 case IncrementalSource.AdoptedStyleSheet:
20381 {
20382 this.replaceIds(e2.data, iframeEl, [
20383 "id"
20384 ]);
20385 this.replaceStyleIds(e2.data, iframeEl, [
20386 "styleIds"
20387 ]);
20388 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
20389 _this.replaceStyleIds(style, iframeEl, [
20390 "styleId"
20391 ]);
20392 });
20393 return e2;
20394 }
20395 }
20396 }
20397 }
20398 return false;
20399 };
20400 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
20401 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
20402 var key = _step.value;
20403 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
20404 if (Array.isArray(obj[key])) {
20405 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
20406 } else {
20407 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
20408 }
20409 }
20410 return obj;
20411 };
20412 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
20413 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
20414 };
20415 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
20416 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
20417 };
20418 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
20419 var _this = this;
20420 this.replaceIds(node2, iframeEl, [
20421 "id",
20422 "rootId"
20423 ]);
20424 if ("childNodes" in node2) {
20425 node2.childNodes.forEach(function(child) {
20426 _this.replaceIdOnNode(child, iframeEl);
20427 });
20428 }
20429 };
20430 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
20431 var _this = this;
20432 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
20433 if ("childNodes" in node2) {
20434 node2.childNodes.forEach(function(child) {
20435 _this.patchRootIdOnNode(child, rootId);
20436 });
20437 }
20438 };
20439 return IframeManager;
20440 }();
20441 var ShadowDomManager = /*#__PURE__*/ function() {
20442 function ShadowDomManager(options) {
20443 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
20444 __publicField(this, "mutationCb");
20445 __publicField(this, "scrollCb");
20446 __publicField(this, "bypassOptions");
20447 __publicField(this, "mirror");
20448 __publicField(this, "restoreHandlers", []);
20449 this.mutationCb = options.mutationCb;
20450 this.scrollCb = options.scrollCb;
20451 this.bypassOptions = options.bypassOptions;
20452 this.mirror = options.mirror;
20453 this.init();
20454 }
20455 var _proto = ShadowDomManager.prototype;
20456 _proto.init = function init() {
20457 this.reset();
20458 this.patchAttachShadow(Element, document);
20459 };
20460 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
20461 var _this = this;
20462 if (!isNativeShadowDom(shadowRoot2)) return;
20463 if (this.shadowDoms.has(shadowRoot2)) return;
20464 this.shadowDoms.add(shadowRoot2);
20465 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
20466 doc: doc,
20467 mutationCb: this.mutationCb,
20468 mirror: this.mirror,
20469 shadowDomManager: this
20470 }), shadowRoot2);
20471 this.restoreHandlers.push(function() {
20472 return observer.disconnect();
20473 });
20474 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
20475 scrollCb: this.scrollCb,
20476 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
20477 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
20478 doc: shadowRoot2,
20479 mirror: this.mirror
20480 })));
20481 setTimeout(function() {
20482 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
20483 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
20484 mirror: _this.mirror,
20485 stylesheetManager: _this.bypassOptions.stylesheetManager
20486 }, shadowRoot2));
20487 }, 0);
20488 };
20489 /**
20490 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
20491 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
20492 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
20493 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
20494 };
20495 /**
20496 * Patch 'attachShadow' to observe newly added shadow doms.
20497 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
20498 var manager = this;
20499 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
20500 return function(option) {
20501 var sRoot = original.call(this, option);
20502 var shadowRootEl = index.shadowRoot(this);
20503 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
20504 return sRoot;
20505 };
20506 }));
20507 };
20508 _proto.reset = function reset() {
20509 this.restoreHandlers.forEach(function(handler) {
20510 try {
20511 handler();
20512 } catch (e2) {}
20513 });
20514 this.restoreHandlers = [];
20515 this.shadowDoms = /* @__PURE__ */ new WeakSet();
20516 };
20517 return ShadowDomManager;
20518 }();
20519 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
20520 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
20521 for(var i$1 = 0; i$1 < chars.length; i$1++){
20522 lookup[chars.charCodeAt(i$1)] = i$1;
20523 }
20524 var encode = function encode(arraybuffer) {
20525 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
20526 for(i2 = 0; i2 < len; i2 += 3){
20527 base64 += chars[bytes[i2] >> 2];
20528 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
20529 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
20530 base64 += chars[bytes[i2 + 2] & 63];
20531 }
20532 if (len % 3 === 2) {
20533 base64 = base64.substring(0, base64.length - 1) + "=";
20534 } else if (len % 3 === 1) {
20535 base64 = base64.substring(0, base64.length - 2) + "==";
20536 }
20537 return base64;
20538 };
20539 var canvasVarMap = /* @__PURE__ */ new Map();
20540 function variableListFor$1(ctx, ctor) {
20541 var contextMap = canvasVarMap.get(ctx);
20542 if (!contextMap) {
20543 contextMap = /* @__PURE__ */ new Map();
20544 canvasVarMap.set(ctx, contextMap);
20545 }
20546 if (!contextMap.has(ctor)) {
20547 contextMap.set(ctor, []);
20548 }
20549 return contextMap.get(ctor);
20550 }
20551 var saveWebGLVar = function(value, win, ctx) {
20552 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
20553 var name = value.constructor.name;
20554 var list2 = variableListFor$1(ctx, name);
20555 var index2 = list2.indexOf(value);
20556 if (index2 === -1) {
20557 index2 = list2.length;
20558 list2.push(value);
20559 }
20560 return index2;
20561 };
20562 function serializeArg(value, win, ctx) {
20563 if (_instanceof(value, Array)) {
20564 return value.map(function(arg) {
20565 return serializeArg(arg, win, ctx);
20566 });
20567 } else if (value === null) {
20568 return value;
20569 } 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)) {
20570 var name = value.constructor.name;
20571 return {
20572 rr_type: name,
20573 args: [
20574 Object.values(value)
20575 ]
20576 };
20577 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
20578 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
20579 // value instanceof SharedArrayBuffer ||
20580 _instanceof(value, ArrayBuffer)) {
20581 var name1 = value.constructor.name;
20582 var base64 = encode(value);
20583 return {
20584 rr_type: name1,
20585 base64: base64
20586 };
20587 } else if (_instanceof(value, DataView)) {
20588 var name2 = value.constructor.name;
20589 return {
20590 rr_type: name2,
20591 args: [
20592 serializeArg(value.buffer, win, ctx),
20593 value.byteOffset,
20594 value.byteLength
20595 ]
20596 };
20597 } else if (_instanceof(value, HTMLImageElement)) {
20598 var name3 = value.constructor.name;
20599 var src = value.src;
20600 return {
20601 rr_type: name3,
20602 src: src
20603 };
20604 } else if (_instanceof(value, HTMLCanvasElement)) {
20605 var name4 = "HTMLImageElement";
20606 var src1 = value.toDataURL();
20607 return {
20608 rr_type: name4,
20609 src: src1
20610 };
20611 } else if (_instanceof(value, ImageData)) {
20612 var name5 = value.constructor.name;
20613 return {
20614 rr_type: name5,
20615 args: [
20616 serializeArg(value.data, win, ctx),
20617 value.width,
20618 value.height
20619 ]
20620 };
20621 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
20622 var name6 = value.constructor.name;
20623 var index2 = saveWebGLVar(value, win, ctx);
20624 return {
20625 rr_type: name6,
20626 index: index2
20627 };
20628 }
20629 return value;
20630 }
20631 var serializeArgs = function(args, win, ctx) {
20632 return args.map(function(arg) {
20633 return serializeArg(arg, win, ctx);
20634 });
20635 };
20636 var isInstanceOfWebGLObject = function(value, win) {
20637 var webGLConstructorNames = [
20638 "WebGLActiveInfo",
20639 "WebGLBuffer",
20640 "WebGLFramebuffer",
20641 "WebGLProgram",
20642 "WebGLRenderbuffer",
20643 "WebGLShader",
20644 "WebGLShaderPrecisionFormat",
20645 "WebGLTexture",
20646 "WebGLUniformLocation",
20647 "WebGLVertexArrayObject",
20648 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
20649 "WebGLVertexArrayObjectOES"
20650 ];
20651 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
20652 return typeof win[name] === "function";
20653 });
20654 return Boolean(supportedWebGLConstructorNames.find(function(name) {
20655 return _instanceof(value, win[name]);
20656 }));
20657 };
20658 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
20659 var _loop = function() {
20660 var prop = _step.value;
20661 try {
20662 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
20663 return "continue";
20664 }
20665 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
20666 return function() {
20667 var _this = this;
20668 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
20669 args[_key] = arguments[_key];
20670 }
20671 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
20672 setTimeout(function() {
20673 var recordArgs = serializeArgs(args, win, _this);
20674 cb(_this.canvas, {
20675 type: CanvasContext["2D"],
20676 property: prop,
20677 args: recordArgs
20678 });
20679 }, 0);
20680 }
20681 return original.apply(this, args);
20682 };
20683 });
20684 handlers.push(restoreHandler);
20685 } catch (e) {
20686 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
20687 set: function set(v2) {
20688 cb(this.canvas, {
20689 type: CanvasContext["2D"],
20690 property: prop,
20691 args: [
20692 v2
20693 ],
20694 setter: true
20695 });
20696 }
20697 });
20698 handlers.push(hookHandler);
20699 }
20700 };
20701 var handlers = [];
20702 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
20703 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
20704 return function() {
20705 handlers.forEach(function(h) {
20706 return h();
20707 });
20708 };
20709 }
20710 function getNormalizedContextName(contextType) {
20711 return contextType === "experimental-webgl" ? "webgl" : contextType;
20712 }
20713 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
20714 var handlers = [];
20715 try {
20716 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
20717 return function(contextType) {
20718 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
20719 args[_key - 1] = arguments[_key];
20720 }
20721 if (!isBlocked(this, blockClass, blockSelector, true)) {
20722 var ctxName = getNormalizedContextName(contextType);
20723 if (!("__context" in this)) this.__context = ctxName;
20724 if (setPreserveDrawingBufferToTrue && [
20725 "webgl",
20726 "webgl2"
20727 ].includes(ctxName)) {
20728 if (args[0] && _type_of(args[0]) === "object") {
20729 var contextAttributes = args[0];
20730 if (!contextAttributes.preserveDrawingBuffer) {
20731 contextAttributes.preserveDrawingBuffer = true;
20732 }
20733 } else {
20734 args.splice(0, 1, {
20735 preserveDrawingBuffer: true
20736 });
20737 }
20738 }
20739 }
20740 return original.apply(this, [].concat([
20741 contextType
20742 ], args));
20743 };
20744 });
20745 handlers.push(restoreHandler);
20746 } catch (e) {
20747 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
20748 }
20749 return function() {
20750 handlers.forEach(function(h) {
20751 return h();
20752 });
20753 };
20754 }
20755 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
20756 var _loop = function() {
20757 var prop = _step.value;
20758 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
20759 [
20760 "isContextLost",
20761 "canvas",
20762 "drawingBufferWidth",
20763 "drawingBufferHeight"
20764 ].includes(prop)) {
20765 return "continue";
20766 }
20767 try {
20768 if (typeof prototype[prop] !== "function") {
20769 return "continue";
20770 }
20771 var restoreHandler = patch(prototype, prop, function(original) {
20772 return function() {
20773 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
20774 args[_key] = arguments[_key];
20775 }
20776 var result2 = original.apply(this, args);
20777 saveWebGLVar(result2, win, this);
20778 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
20779 var recordArgs = serializeArgs(args, win, this);
20780 var mutation = {
20781 type: type,
20782 property: prop,
20783 args: recordArgs
20784 };
20785 cb(this.canvas, mutation);
20786 }
20787 return result2;
20788 };
20789 });
20790 handlers.push(restoreHandler);
20791 } catch (e) {
20792 var hookHandler = hookSetter(prototype, prop, {
20793 set: function set(v2) {
20794 cb(this.canvas, {
20795 type: type,
20796 property: prop,
20797 args: [
20798 v2
20799 ],
20800 setter: true
20801 });
20802 }
20803 });
20804 handlers.push(hookHandler);
20805 }
20806 };
20807 var handlers = [];
20808 var props = Object.getOwnPropertyNames(prototype);
20809 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
20810 return handlers;
20811 }
20812 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
20813 var _handlers;
20814 var handlers = [];
20815 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
20816 if (typeof win.WebGL2RenderingContext !== "undefined") {
20817 var _handlers1;
20818 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
20819 }
20820 return function() {
20821 handlers.forEach(function(h) {
20822 return h();
20823 });
20824 };
20825 }
20826 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
20827 var decodeBase64 = function(base64) {
20828 return Uint8Array.from(atob(base64), function(c2) {
20829 return c2.charCodeAt(0);
20830 });
20831 };
20832 var blob = typeof window !== "undefined" && window.Blob && new Blob([
20833 decodeBase64(encodedJs)
20834 ], {
20835 type: "text/javascript;charset=utf-8"
20836 });
20837 function WorkerWrapper(options) {
20838 var objURL;
20839 try {
20840 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
20841 if (!objURL) throw "";
20842 var worker = new Worker(objURL, {
20843 name: options == null ? void 0 : options.name
20844 });
20845 worker.addEventListener("error", function() {
20846 (window.URL || window.webkitURL).revokeObjectURL(objURL);
20847 });
20848 return worker;
20849 } catch (e2) {
20850 return new Worker("data:text/javascript;base64," + encodedJs, {
20851 name: options == null ? void 0 : options.name
20852 });
20853 } finally{
20854 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
20855 }
20856 }
20857 var CanvasManager = /*#__PURE__*/ function() {
20858 function CanvasManager(options) {
20859 var _this = this;
20860 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
20861 __publicField(this, "rafStamps", {
20862 latestId: 0,
20863 invokeId: null
20864 });
20865 __publicField(this, "mirror");
20866 __publicField(this, "mutationCb");
20867 __publicField(this, "resetObservers");
20868 __publicField(this, "frozen", false);
20869 __publicField(this, "locked", false);
20870 __publicField(this, "processMutation", function(target, mutation) {
20871 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
20872 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
20873 if (!_this.pendingCanvasMutations.has(target)) {
20874 _this.pendingCanvasMutations.set(target, []);
20875 }
20876 _this.pendingCanvasMutations.get(target).push(mutation);
20877 });
20878 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;
20879 this.mutationCb = options.mutationCb;
20880 this.mirror = options.mirror;
20881 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
20882 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
20883 dataURLOptions: dataURLOptions
20884 });
20885 }
20886 var _proto = CanvasManager.prototype;
20887 _proto.reset = function reset() {
20888 this.pendingCanvasMutations.clear();
20889 this.resetObservers && this.resetObservers();
20890 };
20891 _proto.freeze = function freeze() {
20892 this.frozen = true;
20893 };
20894 _proto.unfreeze = function unfreeze() {
20895 this.frozen = false;
20896 };
20897 _proto.lock = function lock() {
20898 this.locked = true;
20899 };
20900 _proto.unlock = function unlock() {
20901 this.locked = false;
20902 };
20903 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
20904 var _this = this;
20905 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
20906 var snapshotInProgressMap = /* @__PURE__ */ new Map();
20907 var worker = new WorkerWrapper();
20908 worker.onmessage = function(e2) {
20909 var id = e2.data.id;
20910 snapshotInProgressMap.set(id, false);
20911 if (!("base64" in e2.data)) return;
20912 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
20913 _this.mutationCb({
20914 id: id,
20915 type: CanvasContext["2D"],
20916 commands: [
20917 {
20918 property: "clearRect",
20919 // wipe canvas
20920 args: [
20921 0,
20922 0,
20923 width,
20924 height
20925 ]
20926 },
20927 {
20928 property: "drawImage",
20929 // draws (semi-transparent) image
20930 args: [
20931 {
20932 rr_type: "ImageBitmap",
20933 args: [
20934 {
20935 rr_type: "Blob",
20936 data: [
20937 {
20938 rr_type: "ArrayBuffer",
20939 base64: base64
20940 }
20941 ],
20942 type: type
20943 }
20944 ]
20945 },
20946 0,
20947 0
20948 ]
20949 }
20950 ]
20951 });
20952 };
20953 var timeBetweenSnapshots = 1e3 / fps;
20954 var lastSnapshotTime = 0;
20955 var rafId;
20956 var getCanvas = function() {
20957 var matchedCanvas = [];
20958 win.document.querySelectorAll("canvas").forEach(function(canvas) {
20959 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
20960 matchedCanvas.push(canvas);
20961 }
20962 });
20963 return matchedCanvas;
20964 };
20965 var takeCanvasSnapshots = function(timestamp) {
20966 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
20967 rafId = requestAnimationFrame(takeCanvasSnapshots);
20968 return;
20969 }
20970 lastSnapshotTime = timestamp;
20971 var _this1 = _this;
20972 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
20973 var _a2, id, context, bitmap;
20974 return _ts_generator(this, function(_state) {
20975 switch(_state.label){
20976 case 0:
20977 id = _this1.mirror.getId(canvas);
20978 if (snapshotInProgressMap.get(id)) return [
20979 2
20980 ];
20981 if (canvas.width === 0 || canvas.height === 0) return [
20982 2
20983 ];
20984 snapshotInProgressMap.set(id, true);
20985 if ([
20986 "webgl",
20987 "webgl2"
20988 ].includes(canvas.__context)) {
20989 context = canvas.getContext(canvas.__context);
20990 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
20991 context.clear(context.COLOR_BUFFER_BIT);
20992 }
20993 }
20994 return [
20995 4,
20996 createImageBitmap(canvas)
20997 ];
20998 case 1:
20999 bitmap = _state.sent();
21000 worker.postMessage({
21001 id: id,
21002 bitmap: bitmap,
21003 width: canvas.width,
21004 height: canvas.height,
21005 dataURLOptions: options.dataURLOptions
21006 }, [
21007 bitmap
21008 ]);
21009 return [
21010 2
21011 ];
21012 }
21013 });
21014 }));
21015 rafId = requestAnimationFrame(takeCanvasSnapshots);
21016 };
21017 rafId = requestAnimationFrame(takeCanvasSnapshots);
21018 this.resetObservers = function() {
21019 canvasContextReset();
21020 cancelAnimationFrame(rafId);
21021 };
21022 };
21023 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21024 this.startRAFTimestamping();
21025 this.startPendingCanvasMutationFlusher();
21026 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21027 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21028 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21029 this.resetObservers = function() {
21030 canvasContextReset();
21031 canvas2DReset();
21032 canvasWebGL1and2Reset();
21033 };
21034 };
21035 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21036 var _this = this;
21037 requestAnimationFrame(function() {
21038 return _this.flushPendingCanvasMutations();
21039 });
21040 };
21041 _proto.startRAFTimestamping = function startRAFTimestamping() {
21042 var _this = this;
21043 var setLatestRAFTimestamp = function(timestamp) {
21044 _this.rafStamps.latestId = timestamp;
21045 requestAnimationFrame(setLatestRAFTimestamp);
21046 };
21047 requestAnimationFrame(setLatestRAFTimestamp);
21048 };
21049 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21050 var _this = this;
21051 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21052 var id = _this.mirror.getId(canvas);
21053 _this.flushPendingCanvasMutationFor(canvas, id);
21054 });
21055 requestAnimationFrame(function() {
21056 return _this.flushPendingCanvasMutations();
21057 });
21058 };
21059 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21060 if (this.frozen || this.locked) {
21061 return;
21062 }
21063 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21064 if (!valuesWithType || id === -1) return;
21065 var values = valuesWithType.map(function(value) {
21066 value.type; var rest = _object_without_properties_loose(value, [
21067 "type"
21068 ]);
21069 return rest;
21070 });
21071 var type = valuesWithType[0].type;
21072 this.mutationCb({
21073 id: id,
21074 type: type,
21075 commands: values
21076 });
21077 this.pendingCanvasMutations.delete(canvas);
21078 };
21079 return CanvasManager;
21080 }();
21081 var StylesheetManager = /*#__PURE__*/ function() {
21082 function StylesheetManager(options) {
21083 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21084 __publicField(this, "mutationCb");
21085 __publicField(this, "adoptedStyleSheetCb");
21086 __publicField(this, "styleMirror", new StyleSheetMirror());
21087 this.mutationCb = options.mutationCb;
21088 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21089 }
21090 var _proto = StylesheetManager.prototype;
21091 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21092 if ("_cssText" in childSn.attributes) this.mutationCb({
21093 adds: [],
21094 removes: [],
21095 texts: [],
21096 attributes: [
21097 {
21098 id: childSn.id,
21099 attributes: childSn.attributes
21100 }
21101 ]
21102 });
21103 this.trackLinkElement(linkEl);
21104 };
21105 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21106 if (this.trackedLinkElements.has(linkEl)) return;
21107 this.trackedLinkElements.add(linkEl);
21108 this.trackStylesheetInLinkElement(linkEl);
21109 };
21110 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21111 var _this, _loop = function() {
21112 var sheet = _step.value;
21113 var styleId = void 0;
21114 if (!_this.styleMirror.has(sheet)) {
21115 styleId = _this.styleMirror.add(sheet);
21116 styles.push({
21117 styleId: styleId,
21118 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21119 return {
21120 rule: stringifyRule(r2, sheet.href),
21121 index: index2
21122 };
21123 })
21124 });
21125 } else styleId = _this.styleMirror.getId(sheet);
21126 adoptedStyleSheetData.styleIds.push(styleId);
21127 };
21128 if (sheets.length === 0) return;
21129 var adoptedStyleSheetData = {
21130 id: hostId,
21131 styleIds: []
21132 };
21133 var styles = [];
21134 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21135 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21136 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21137 };
21138 _proto.reset = function reset() {
21139 this.styleMirror.reset();
21140 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21141 };
21142 // TODO: take snapshot on stylesheet reload by applying event listener
21143 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21144 return StylesheetManager;
21145 }();
21146 var ProcessedNodeManager = /*#__PURE__*/ function() {
21147 function ProcessedNodeManager() {
21148 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21149 __publicField(this, "active", false);
21150 }
21151 var _proto = ProcessedNodeManager.prototype;
21152 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
21153 var buffers = this.nodeMap.get(node2);
21154 return buffers && Array.from(buffers).some(function(buffer) {
21155 return buffer !== thisBuffer;
21156 });
21157 };
21158 _proto.add = function add(node2, buffer) {
21159 var _this = this;
21160 if (!this.active) {
21161 this.active = true;
21162 requestAnimationFrame(function() {
21163 _this.nodeMap = /* @__PURE__ */ new WeakMap();
21164 _this.active = false;
21165 });
21166 }
21167 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
21168 };
21169 _proto.destroy = function destroy() {};
21170 return ProcessedNodeManager;
21171 }();
21172 var wrappedEmit;
21173 var takeFullSnapshot$1;
21174 var canvasManager;
21175 var recording = false;
21176 try {
21177 if (Array.from([
21178 1
21179 ], function(x2) {
21180 return x2 * 2;
21181 })[0] !== 2) {
21182 var cleanFrame = document.createElement("iframe");
21183 document.body.appendChild(cleanFrame);
21184 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
21185 document.body.removeChild(cleanFrame);
21186 }
21187 } catch (err) {
21188 console.debug("Unable to override Array.from", err);
21189 }
21190 var mirror = createMirror$2();
21191 function record(options) {
21192 if (options === void 0) options = {};
21193 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() {
21194 return false;
21195 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
21196 registerErrorHandler(errorHandler2);
21197 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
21198 var passEmitsToParent = false;
21199 if (!inEmittingFrame) {
21200 try {
21201 if (window.parent.document) {
21202 passEmitsToParent = false;
21203 }
21204 } catch (e2) {
21205 passEmitsToParent = true;
21206 }
21207 }
21208 if (inEmittingFrame && !emit) {
21209 throw new Error("emit function is required");
21210 }
21211 if (!inEmittingFrame && !passEmitsToParent) {
21212 return function() {};
21213 }
21214 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
21215 sampling.mousemove = mousemoveWait;
21216 }
21217 mirror.reset();
21218 var maskInputOptions = maskAllInputs === true ? {
21219 color: true,
21220 date: true,
21221 "datetime-local": true,
21222 email: true,
21223 month: true,
21224 number: true,
21225 range: true,
21226 search: true,
21227 tel: true,
21228 text: true,
21229 time: true,
21230 url: true,
21231 week: true,
21232 textarea: true,
21233 select: true,
21234 password: true
21235 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
21236 password: true
21237 };
21238 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
21239 script: true,
21240 comment: true,
21241 headFavicon: true,
21242 headWhitespace: true,
21243 headMetaSocial: true,
21244 headMetaRobots: true,
21245 headMetaHttpEquiv: true,
21246 headMetaVerification: true,
21247 // the following are off for slimDOMOptions === true,
21248 // as they destroy some (hidden) info:
21249 headMetaAuthorship: _slimDOMOptions === "all",
21250 headMetaDescKeywords: _slimDOMOptions === "all",
21251 headTitleMutations: _slimDOMOptions === "all"
21252 } : _slimDOMOptions ? _slimDOMOptions : {};
21253 polyfill$1();
21254 var lastFullSnapshotEvent;
21255 var incrementalSnapshotCount = 0;
21256 var eventProcessor = function(e2) {
21257 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21258 var plugin3 = _step.value;
21259 if (plugin3.eventProcessor) {
21260 e2 = plugin3.eventProcessor(e2);
21261 }
21262 }
21263 if (packFn && // Disable packing events which will be emitted to parent frames.
21264 !passEmitsToParent) {
21265 e2 = packFn(e2);
21266 }
21267 return e2;
21268 };
21269 wrappedEmit = function(r2, isCheckout) {
21270 var _a2;
21271 var e2 = r2;
21272 e2.timestamp = nowTimestamp();
21273 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
21274 mutationBuffers.forEach(function(buf) {
21275 return buf.unfreeze();
21276 });
21277 }
21278 if (inEmittingFrame) {
21279 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
21280 } else if (passEmitsToParent) {
21281 var message = {
21282 type: "rrweb",
21283 event: eventProcessor(e2),
21284 origin: window.location.origin,
21285 isCheckout: isCheckout
21286 };
21287 window.parent.postMessage(message, "*");
21288 }
21289 if (e2.type === EventType.FullSnapshot) {
21290 lastFullSnapshotEvent = e2;
21291 incrementalSnapshotCount = 0;
21292 } else if (e2.type === EventType.IncrementalSnapshot) {
21293 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
21294 return;
21295 }
21296 incrementalSnapshotCount++;
21297 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
21298 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
21299 if (exceedCount || exceedTime) {
21300 takeFullSnapshot$1(true);
21301 }
21302 }
21303 };
21304 var wrappedMutationEmit = function(m) {
21305 wrappedEmit({
21306 type: EventType.IncrementalSnapshot,
21307 data: _extends({
21308 source: IncrementalSource.Mutation
21309 }, m)
21310 });
21311 };
21312 var wrappedScrollEmit = function(p) {
21313 return wrappedEmit({
21314 type: EventType.IncrementalSnapshot,
21315 data: _extends({
21316 source: IncrementalSource.Scroll
21317 }, p)
21318 });
21319 };
21320 var wrappedCanvasMutationEmit = function(p) {
21321 return wrappedEmit({
21322 type: EventType.IncrementalSnapshot,
21323 data: _extends({
21324 source: IncrementalSource.CanvasMutation
21325 }, p)
21326 });
21327 };
21328 var wrappedAdoptedStyleSheetEmit = function(a2) {
21329 return wrappedEmit({
21330 type: EventType.IncrementalSnapshot,
21331 data: _extends({
21332 source: IncrementalSource.AdoptedStyleSheet
21333 }, a2)
21334 });
21335 };
21336 var stylesheetManager = new StylesheetManager({
21337 mutationCb: wrappedMutationEmit,
21338 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
21339 });
21340 var iframeManager = new IframeManager({
21341 mirror: mirror,
21342 mutationCb: wrappedMutationEmit,
21343 stylesheetManager: stylesheetManager,
21344 recordCrossOriginIframes: recordCrossOriginIframes,
21345 wrappedEmit: wrappedEmit
21346 });
21347 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
21348 var plugin3 = _step.value;
21349 if (plugin3.getMirror) plugin3.getMirror({
21350 nodeMirror: mirror,
21351 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
21352 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
21353 });
21354 }
21355 var processedNodeManager = new ProcessedNodeManager();
21356 canvasManager = new CanvasManager({
21357 recordCanvas: recordCanvas,
21358 mutationCb: wrappedCanvasMutationEmit,
21359 win: window,
21360 blockClass: blockClass,
21361 blockSelector: blockSelector,
21362 mirror: mirror,
21363 sampling: sampling.canvas,
21364 dataURLOptions: dataURLOptions
21365 });
21366 var shadowDomManager = new ShadowDomManager({
21367 mutationCb: wrappedMutationEmit,
21368 scrollCb: wrappedScrollEmit,
21369 bypassOptions: {
21370 blockClass: blockClass,
21371 blockSelector: blockSelector,
21372 maskTextClass: maskTextClass,
21373 maskTextSelector: maskTextSelector,
21374 inlineStylesheet: inlineStylesheet,
21375 maskInputOptions: maskInputOptions,
21376 dataURLOptions: dataURLOptions,
21377 maskTextFn: maskTextFn,
21378 maskInputFn: maskInputFn,
21379 recordCanvas: recordCanvas,
21380 inlineImages: inlineImages,
21381 sampling: sampling,
21382 slimDOMOptions: slimDOMOptions,
21383 iframeManager: iframeManager,
21384 stylesheetManager: stylesheetManager,
21385 canvasManager: canvasManager,
21386 keepIframeSrcFn: keepIframeSrcFn,
21387 processedNodeManager: processedNodeManager
21388 },
21389 mirror: mirror
21390 });
21391 takeFullSnapshot$1 = function(isCheckout) {
21392 if (isCheckout === void 0) isCheckout = false;
21393 if (!recordDOM) {
21394 return;
21395 }
21396 wrappedEmit({
21397 type: EventType.Meta,
21398 data: {
21399 href: window.location.href,
21400 width: getWindowWidth(),
21401 height: getWindowHeight()
21402 }
21403 }, isCheckout);
21404 stylesheetManager.reset();
21405 shadowDomManager.init();
21406 mutationBuffers.forEach(function(buf) {
21407 return buf.lock();
21408 });
21409 var node2 = snapshot(document, {
21410 mirror: mirror,
21411 blockClass: blockClass,
21412 blockSelector: blockSelector,
21413 maskTextClass: maskTextClass,
21414 maskTextSelector: maskTextSelector,
21415 inlineStylesheet: inlineStylesheet,
21416 maskAllInputs: maskInputOptions,
21417 maskTextFn: maskTextFn,
21418 maskInputFn: maskInputFn,
21419 slimDOM: slimDOMOptions,
21420 dataURLOptions: dataURLOptions,
21421 recordCanvas: recordCanvas,
21422 inlineImages: inlineImages,
21423 onSerialize: function(n2) {
21424 if (isSerializedIframe(n2, mirror)) {
21425 iframeManager.addIframe(n2);
21426 }
21427 if (isSerializedStylesheet(n2, mirror)) {
21428 stylesheetManager.trackLinkElement(n2);
21429 }
21430 if (hasShadowRoot(n2)) {
21431 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
21432 }
21433 },
21434 onIframeLoad: function(iframe, childSn) {
21435 iframeManager.attachIframe(iframe, childSn);
21436 shadowDomManager.observeAttachShadow(iframe);
21437 },
21438 onStylesheetLoad: function(linkEl, childSn) {
21439 stylesheetManager.attachLinkElement(linkEl, childSn);
21440 },
21441 keepIframeSrcFn: keepIframeSrcFn
21442 });
21443 if (!node2) {
21444 return console.warn("Failed to snapshot the document");
21445 }
21446 wrappedEmit({
21447 type: EventType.FullSnapshot,
21448 data: {
21449 node: node2,
21450 initialOffset: getWindowScroll(window)
21451 }
21452 }, isCheckout);
21453 mutationBuffers.forEach(function(buf) {
21454 return buf.unlock();
21455 });
21456 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
21457 };
21458 try {
21459 var handlers = [];
21460 var observe = function(doc) {
21461 var _a2;
21462 return callbackWrapper(initObservers)({
21463 mutationCb: wrappedMutationEmit,
21464 mousemoveCb: function(positions, source) {
21465 return wrappedEmit({
21466 type: EventType.IncrementalSnapshot,
21467 data: {
21468 source: source,
21469 positions: positions
21470 }
21471 });
21472 },
21473 mouseInteractionCb: function(d) {
21474 return wrappedEmit({
21475 type: EventType.IncrementalSnapshot,
21476 data: _extends({
21477 source: IncrementalSource.MouseInteraction
21478 }, d)
21479 });
21480 },
21481 scrollCb: wrappedScrollEmit,
21482 viewportResizeCb: function(d) {
21483 return wrappedEmit({
21484 type: EventType.IncrementalSnapshot,
21485 data: _extends({
21486 source: IncrementalSource.ViewportResize
21487 }, d)
21488 });
21489 },
21490 inputCb: function(v2) {
21491 return wrappedEmit({
21492 type: EventType.IncrementalSnapshot,
21493 data: _extends({
21494 source: IncrementalSource.Input
21495 }, v2)
21496 });
21497 },
21498 mediaInteractionCb: function(p) {
21499 return wrappedEmit({
21500 type: EventType.IncrementalSnapshot,
21501 data: _extends({
21502 source: IncrementalSource.MediaInteraction
21503 }, p)
21504 });
21505 },
21506 styleSheetRuleCb: function(r2) {
21507 return wrappedEmit({
21508 type: EventType.IncrementalSnapshot,
21509 data: _extends({
21510 source: IncrementalSource.StyleSheetRule
21511 }, r2)
21512 });
21513 },
21514 styleDeclarationCb: function(r2) {
21515 return wrappedEmit({
21516 type: EventType.IncrementalSnapshot,
21517 data: _extends({
21518 source: IncrementalSource.StyleDeclaration
21519 }, r2)
21520 });
21521 },
21522 canvasMutationCb: wrappedCanvasMutationEmit,
21523 fontCb: function(p) {
21524 return wrappedEmit({
21525 type: EventType.IncrementalSnapshot,
21526 data: _extends({
21527 source: IncrementalSource.Font
21528 }, p)
21529 });
21530 },
21531 selectionCb: function(p) {
21532 wrappedEmit({
21533 type: EventType.IncrementalSnapshot,
21534 data: _extends({
21535 source: IncrementalSource.Selection
21536 }, p)
21537 });
21538 },
21539 customElementCb: function(c2) {
21540 wrappedEmit({
21541 type: EventType.IncrementalSnapshot,
21542 data: _extends({
21543 source: IncrementalSource.CustomElement
21544 }, c2)
21545 });
21546 },
21547 blockClass: blockClass,
21548 ignoreClass: ignoreClass,
21549 ignoreSelector: ignoreSelector,
21550 maskTextClass: maskTextClass,
21551 maskTextSelector: maskTextSelector,
21552 maskInputOptions: maskInputOptions,
21553 inlineStylesheet: inlineStylesheet,
21554 sampling: sampling,
21555 recordDOM: recordDOM,
21556 recordCanvas: recordCanvas,
21557 inlineImages: inlineImages,
21558 userTriggeredOnInput: userTriggeredOnInput,
21559 collectFonts: collectFonts,
21560 doc: doc,
21561 maskInputFn: maskInputFn,
21562 maskTextFn: maskTextFn,
21563 keepIframeSrcFn: keepIframeSrcFn,
21564 blockSelector: blockSelector,
21565 slimDOMOptions: slimDOMOptions,
21566 dataURLOptions: dataURLOptions,
21567 mirror: mirror,
21568 iframeManager: iframeManager,
21569 stylesheetManager: stylesheetManager,
21570 shadowDomManager: shadowDomManager,
21571 processedNodeManager: processedNodeManager,
21572 canvasManager: canvasManager,
21573 ignoreCSSAttributes: ignoreCSSAttributes,
21574 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
21575 return p.observer;
21576 })) == null ? void 0 : _a2.map(function(p) {
21577 return {
21578 observer: p.observer,
21579 options: p.options,
21580 callback: function(payload) {
21581 return wrappedEmit({
21582 type: EventType.Plugin,
21583 data: {
21584 plugin: p.name,
21585 payload: payload
21586 }
21587 });
21588 }
21589 };
21590 })) || []
21591 }, hooks);
21592 };
21593 iframeManager.addLoadListener(function(iframeEl) {
21594 try {
21595 handlers.push(observe(iframeEl.contentDocument));
21596 } catch (error) {
21597 console.warn(error);
21598 }
21599 });
21600 var init = function() {
21601 takeFullSnapshot$1();
21602 handlers.push(observe(document));
21603 recording = true;
21604 };
21605 if (document.readyState === "interactive" || document.readyState === "complete") {
21606 init();
21607 } else {
21608 handlers.push(on("DOMContentLoaded", function() {
21609 wrappedEmit({
21610 type: EventType.DomContentLoaded,
21611 data: {}
21612 });
21613 if (recordAfter === "DOMContentLoaded") init();
21614 }));
21615 handlers.push(on("load", function() {
21616 wrappedEmit({
21617 type: EventType.Load,
21618 data: {}
21619 });
21620 if (recordAfter === "load") init();
21621 }, window));
21622 }
21623 return function() {
21624 handlers.forEach(function(h) {
21625 return h();
21626 });
21627 processedNodeManager.destroy();
21628 recording = false;
21629 unregisterErrorHandler();
21630 };
21631 } catch (error) {
21632 console.warn(error);
21633 }
21634 }
21635 record.addCustomEvent = function(tag, payload) {
21636 if (!recording) {
21637 throw new Error("please add custom event after start recording");
21638 }
21639 wrappedEmit({
21640 type: EventType.Custom,
21641 data: {
21642 tag: tag,
21643 payload: payload
21644 }
21645 });
21646 };
21647 record.freezePage = function() {
21648 mutationBuffers.forEach(function(buf) {
21649 return buf.freeze();
21650 });
21651 };
21652 record.takeFullSnapshot = function(isCheckout) {
21653 if (!recording) {
21654 throw new Error("please take full snapshot after start recording");
21655 }
21656 takeFullSnapshot$1(isCheckout);
21657 };
21658 record.mirror = mirror;
21659 var n;
21660 !function(t2) {
21661 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
21662 }(n || (n = {}));
21663 record.addCustomEvent;
21664 record.freezePage;
21665 record.takeFullSnapshot;
21666
21667 var setImmediate = win['setImmediate'];
21668 var builtInProp, cycle, schedulingQueue,
21669 ToString = Object.prototype.toString,
21670 timer = (typeof setImmediate !== 'undefined') ?
21671 function timer(fn) { return setImmediate(fn); } :
21672 setTimeout;
21673
21674 // dammit, IE8.
21675 try {
21676 Object.defineProperty({},'x',{});
21677 builtInProp = function builtInProp(obj,name,val,config) {
21678 return Object.defineProperty(obj,name,{
21679 value: val,
21680 writable: true,
21681 configurable: config !== false
21682 });
21683 };
21684 }
21685 catch (err) {
21686 builtInProp = function builtInProp(obj,name,val) {
21687 obj[name] = val;
21688 return obj;
21689 };
21690 }
21691
21692 // Note: using a queue instead of array for efficiency
21693 schedulingQueue = (function Queue() {
21694 var first, last, item;
21695
21696 function Item(fn,self) {
21697 this.fn = fn;
21698 this.self = self;
21699 this.next = void 0;
21700 }
21701
21702 return {
21703 add: function add(fn,self) {
21704 item = new Item(fn,self);
21705 if (last) {
21706 last.next = item;
21707 }
21708 else {
21709 first = item;
21710 }
21711 last = item;
21712 item = void 0;
21713 },
21714 drain: function drain() {
21715 var f = first;
21716 first = last = cycle = void 0;
21717
21718 while (f) {
21719 f.fn.call(f.self);
21720 f = f.next;
21721 }
21722 }
21723 };
21724 })();
21725
21726 function schedule(fn,self) {
21727 schedulingQueue.add(fn,self);
21728 if (!cycle) {
21729 cycle = timer(schedulingQueue.drain);
21730 }
21731 }
21732
21733 // promise duck typing
21734 function isThenable(o) {
21735 var _then, oType = typeof o;
21736
21737 if (o !== null && (oType === 'object' || oType === 'function')) {
21738 _then = o.then;
21739 }
21740 return typeof _then === 'function' ? _then : false;
21741 }
21742
21743 function notify() {
21744 for (var i=0; i<this.chain.length; i++) {
21745 notifyIsolated(
21746 this,
21747 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
21748 this.chain[i]
21749 );
21750 }
21751 this.chain.length = 0;
21752 }
21753
21754 // NOTE: This is a separate function to isolate
21755 // the `try..catch` so that other code can be
21756 // optimized better
21757 function notifyIsolated(self,cb,chain) {
21758 var ret, _then;
21759 try {
21760 if (cb === false) {
21761 chain.reject(self.msg);
21762 }
21763 else {
21764 if (cb === true) {
21765 ret = self.msg;
21766 }
21767 else {
21768 ret = cb.call(void 0,self.msg);
21769 }
21770
21771 if (ret === chain.promise) {
21772 chain.reject(TypeError('Promise-chain cycle'));
21773 }
21774 // eslint-disable-next-line no-cond-assign
21775 else if (_then = isThenable(ret)) {
21776 _then.call(ret,chain.resolve,chain.reject);
21777 }
21778 else {
21779 chain.resolve(ret);
21780 }
21781 }
21782 }
21783 catch (err) {
21784 chain.reject(err);
21785 }
21786 }
21787
21788 function resolve(msg) {
21789 var _then, self = this;
21790
21791 // already triggered?
21792 if (self.triggered) { return; }
21793
21794 self.triggered = true;
21795
21796 // unwrap
21797 if (self.def) {
21798 self = self.def;
21799 }
21800
21801 try {
21802 // eslint-disable-next-line no-cond-assign
21803 if (_then = isThenable(msg)) {
21804 schedule(function(){
21805 var defWrapper = new MakeDefWrapper(self);
21806 try {
21807 _then.call(msg,
21808 function $resolve$(){ resolve.apply(defWrapper,arguments); },
21809 function $reject$(){ reject.apply(defWrapper,arguments); }
21810 );
21811 }
21812 catch (err) {
21813 reject.call(defWrapper,err);
21814 }
21815 });
21816 }
21817 else {
21818 self.msg = msg;
21819 self.state = 1;
21820 if (self.chain.length > 0) {
21821 schedule(notify,self);
21822 }
21823 }
21824 }
21825 catch (err) {
21826 reject.call(new MakeDefWrapper(self),err);
21827 }
21828 }
21829
21830 function reject(msg) {
21831 var self = this;
21832
21833 // already triggered?
21834 if (self.triggered) { return; }
21835
21836 self.triggered = true;
21837
21838 // unwrap
21839 if (self.def) {
21840 self = self.def;
21841 }
21842
21843 self.msg = msg;
21844 self.state = 2;
21845 if (self.chain.length > 0) {
21846 schedule(notify,self);
21847 }
21848 }
21849
21850 function iteratePromises(Constructor,arr,resolver,rejecter) {
21851 for (var idx=0; idx<arr.length; idx++) {
21852 (function IIFE(idx){
21853 Constructor.resolve(arr[idx])
21854 .then(
21855 function $resolver$(msg){
21856 resolver(idx,msg);
21857 },
21858 rejecter
21859 );
21860 })(idx);
21861 }
21862 }
21863
21864 function MakeDefWrapper(self) {
21865 this.def = self;
21866 this.triggered = false;
21867 }
21868
21869 function MakeDef(self) {
21870 this.promise = self;
21871 this.state = 0;
21872 this.triggered = false;
21873 this.chain = [];
21874 this.msg = void 0;
21875 }
21876
21877 function NpoPromise(executor) {
21878 if (typeof executor !== 'function') {
21879 throw TypeError('Not a function');
21880 }
21881
21882 if (this['__NPO__'] !== 0) {
21883 throw TypeError('Not a promise');
21884 }
21885
21886 // instance shadowing the inherited "brand"
21887 // to signal an already "initialized" promise
21888 this['__NPO__'] = 1;
21889
21890 var def = new MakeDef(this);
21891
21892 this['then'] = function then(success,failure) {
21893 var o = {
21894 success: typeof success === 'function' ? success : true,
21895 failure: typeof failure === 'function' ? failure : false
21896 };
21897 // Note: `then(..)` itself can be borrowed to be used against
21898 // a different promise constructor for making the chained promise,
21899 // by substituting a different `this` binding.
21900 o.promise = new this.constructor(function extractChain(resolve,reject) {
21901 if (typeof resolve !== 'function' || typeof reject !== 'function') {
21902 throw TypeError('Not a function');
21903 }
21904
21905 o.resolve = resolve;
21906 o.reject = reject;
21907 });
21908 def.chain.push(o);
21909
21910 if (def.state !== 0) {
21911 schedule(notify,def);
21912 }
21913
21914 return o.promise;
21915 };
21916 this['catch'] = function $catch$(failure) {
21917 return this.then(void 0,failure);
21918 };
21919
21920 try {
21921 executor.call(
21922 void 0,
21923 function publicResolve(msg){
21924 resolve.call(def,msg);
21925 },
21926 function publicReject(msg) {
21927 reject.call(def,msg);
21928 }
21929 );
21930 }
21931 catch (err) {
21932 reject.call(def,err);
21933 }
21934 }
21935
21936 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
21937 /*configurable=*/false
21938 );
21939
21940 // Note: Android 4 cannot use `Object.defineProperty(..)` here
21941 NpoPromise.prototype = PromisePrototype;
21942
21943 // built-in "brand" to signal an "uninitialized" promise
21944 builtInProp(PromisePrototype,'__NPO__',0,
21945 /*configurable=*/false
21946 );
21947
21948 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
21949 var Constructor = this;
21950
21951 // spec mandated checks
21952 // note: best "isPromise" check that's practical for now
21953 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
21954 return msg;
21955 }
21956
21957 return new Constructor(function executor(resolve,reject){
21958 if (typeof resolve !== 'function' || typeof reject !== 'function') {
21959 throw TypeError('Not a function');
21960 }
21961
21962 resolve(msg);
21963 });
21964 });
21965
21966 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
21967 return new this(function executor(resolve,reject){
21968 if (typeof resolve !== 'function' || typeof reject !== 'function') {
21969 throw TypeError('Not a function');
21970 }
21971
21972 reject(msg);
21973 });
21974 });
21975
21976 builtInProp(NpoPromise,'all',function Promise$all(arr) {
21977 var Constructor = this;
21978
21979 // spec mandated checks
21980 if (ToString.call(arr) !== '[object Array]') {
21981 return Constructor.reject(TypeError('Not an array'));
21982 }
21983 if (arr.length === 0) {
21984 return Constructor.resolve([]);
21985 }
21986
21987 return new Constructor(function executor(resolve,reject){
21988 if (typeof resolve !== 'function' || typeof reject !== 'function') {
21989 throw TypeError('Not a function');
21990 }
21991
21992 var len = arr.length, msgs = Array(len), count = 0;
21993
21994 iteratePromises(Constructor,arr,function resolver(idx,msg) {
21995 msgs[idx] = msg;
21996 if (++count === len) {
21997 resolve(msgs);
21998 }
21999 },reject);
22000 });
22001 });
22002
22003 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22004 var Constructor = this;
22005
22006 // spec mandated checks
22007 if (ToString.call(arr) !== '[object Array]') {
22008 return Constructor.reject(TypeError('Not an array'));
22009 }
22010
22011 return new Constructor(function executor(resolve,reject){
22012 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22013 throw TypeError('Not a function');
22014 }
22015
22016 iteratePromises(Constructor,arr,function resolver(idx,msg){
22017 resolve(msg);
22018 },reject);
22019 });
22020 });
22021
22022 var PromisePolyfill;
22023 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22024 PromisePolyfill = Promise;
22025 } else {
22026 PromisePolyfill = NpoPromise;
22027 }
22028
22029 var Config = {
22030 DEBUG: false,
22031 LIB_VERSION: '2.65.0'
22032 };
22033
22034 /* eslint camelcase: "off", eqeqeq: "off" */
22035
22036 // Maximum allowed session recording length
22037 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22038 // Maximum allowed value for minimum session recording length
22039 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22040
22041 /*
22042 * Saved references to long variable names, so that closure compiler can
22043 * minimize file size.
22044 */
22045
22046 var ArrayProto = Array.prototype,
22047 FuncProto = Function.prototype,
22048 ObjProto = Object.prototype,
22049 slice = ArrayProto.slice,
22050 toString = ObjProto.toString,
22051 hasOwnProperty = ObjProto.hasOwnProperty,
22052 windowConsole = win.console,
22053 navigator = win.navigator,
22054 document$1 = win.document,
22055 windowOpera = win.opera,
22056 screen = win.screen,
22057 userAgent = navigator.userAgent;
22058
22059 var nativeBind = FuncProto.bind,
22060 nativeForEach = ArrayProto.forEach,
22061 nativeIndexOf = ArrayProto.indexOf,
22062 nativeMap = ArrayProto.map,
22063 nativeIsArray = Array.isArray,
22064 breaker = {};
22065
22066 var _ = {
22067 trim: function(str) {
22068 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22069 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22070 }
22071 };
22072
22073 // Console override
22074 var console$1 = {
22075 /** @type {function(...*)} */
22076 log: function() {
22077 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22078 try {
22079 windowConsole.log.apply(windowConsole, arguments);
22080 } catch (err) {
22081 _.each(arguments, function(arg) {
22082 windowConsole.log(arg);
22083 });
22084 }
22085 }
22086 },
22087 /** @type {function(...*)} */
22088 warn: function() {
22089 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22090 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22091 try {
22092 windowConsole.warn.apply(windowConsole, args);
22093 } catch (err) {
22094 _.each(args, function(arg) {
22095 windowConsole.warn(arg);
22096 });
22097 }
22098 }
22099 },
22100 /** @type {function(...*)} */
22101 error: function() {
22102 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22103 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22104 try {
22105 windowConsole.error.apply(windowConsole, args);
22106 } catch (err) {
22107 _.each(args, function(arg) {
22108 windowConsole.error(arg);
22109 });
22110 }
22111 }
22112 },
22113 /** @type {function(...*)} */
22114 critical: function() {
22115 if (!_.isUndefined(windowConsole) && windowConsole) {
22116 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22117 try {
22118 windowConsole.error.apply(windowConsole, args);
22119 } catch (err) {
22120 _.each(args, function(arg) {
22121 windowConsole.error(arg);
22122 });
22123 }
22124 }
22125 }
22126 };
22127
22128 var log_func_with_prefix = function(func, prefix) {
22129 return function() {
22130 arguments[0] = '[' + prefix + '] ' + arguments[0];
22131 return func.apply(console$1, arguments);
22132 };
22133 };
22134 var console_with_prefix = function(prefix) {
22135 return {
22136 log: log_func_with_prefix(console$1.log, prefix),
22137 error: log_func_with_prefix(console$1.error, prefix),
22138 critical: log_func_with_prefix(console$1.critical, prefix)
22139 };
22140 };
22141
22142
22143 var safewrap = function(f) {
22144 return function() {
22145 try {
22146 return f.apply(this, arguments);
22147 } catch (e) {
22148 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
22149 if (Config.DEBUG){
22150 console$1.critical(e);
22151 }
22152 }
22153 };
22154 };
22155
22156 var safewrapClass = function(klass) {
22157 var proto = klass.prototype;
22158 for (var func in proto) {
22159 if (typeof(proto[func]) === 'function') {
22160 proto[func] = safewrap(proto[func]);
22161 }
22162 }
22163 };
22164
22165
22166 // UNDERSCORE
22167 // Embed part of the Underscore Library
22168 _.bind = function(func, context) {
22169 var args, bound;
22170 if (nativeBind && func.bind === nativeBind) {
22171 return nativeBind.apply(func, slice.call(arguments, 1));
22172 }
22173 if (!_.isFunction(func)) {
22174 throw new TypeError();
22175 }
22176 args = slice.call(arguments, 2);
22177 bound = function() {
22178 if (!(this instanceof bound)) {
22179 return func.apply(context, args.concat(slice.call(arguments)));
22180 }
22181 var ctor = {};
22182 ctor.prototype = func.prototype;
22183 var self = new ctor();
22184 ctor.prototype = null;
22185 var result = func.apply(self, args.concat(slice.call(arguments)));
22186 if (Object(result) === result) {
22187 return result;
22188 }
22189 return self;
22190 };
22191 return bound;
22192 };
22193
22194 /**
22195 * @param {*=} obj
22196 * @param {function(...*)=} iterator
22197 * @param {Object=} context
22198 */
22199 _.each = function(obj, iterator, context) {
22200 if (obj === null || obj === undefined) {
22201 return;
22202 }
22203 if (nativeForEach && obj.forEach === nativeForEach) {
22204 obj.forEach(iterator, context);
22205 } else if (obj.length === +obj.length) {
22206 for (var i = 0, l = obj.length; i < l; i++) {
22207 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
22208 return;
22209 }
22210 }
22211 } else {
22212 for (var key in obj) {
22213 if (hasOwnProperty.call(obj, key)) {
22214 if (iterator.call(context, obj[key], key, obj) === breaker) {
22215 return;
22216 }
22217 }
22218 }
22219 }
22220 };
22221
22222 _.extend = function(obj) {
22223 _.each(slice.call(arguments, 1), function(source) {
22224 for (var prop in source) {
22225 if (source[prop] !== void 0) {
22226 obj[prop] = source[prop];
22227 }
22228 }
22229 });
22230 return obj;
22231 };
22232
22233 _.isArray = nativeIsArray || function(obj) {
22234 return toString.call(obj) === '[object Array]';
22235 };
22236
22237 // from a comment on http://dbj.org/dbj/?p=286
22238 // fails on only one very rare and deliberate custom object:
22239 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
22240 _.isFunction = function(f) {
22241 try {
22242 return /^\s*\bfunction\b/.test(f);
22243 } catch (x) {
22244 return false;
22245 }
22246 };
22247
22248 _.isArguments = function(obj) {
22249 return !!(obj && hasOwnProperty.call(obj, 'callee'));
22250 };
22251
22252 _.toArray = function(iterable) {
22253 if (!iterable) {
22254 return [];
22255 }
22256 if (iterable.toArray) {
22257 return iterable.toArray();
22258 }
22259 if (_.isArray(iterable)) {
22260 return slice.call(iterable);
22261 }
22262 if (_.isArguments(iterable)) {
22263 return slice.call(iterable);
22264 }
22265 return _.values(iterable);
22266 };
22267
22268 _.map = function(arr, callback, context) {
22269 if (nativeMap && arr.map === nativeMap) {
22270 return arr.map(callback, context);
22271 } else {
22272 var results = [];
22273 _.each(arr, function(item) {
22274 results.push(callback.call(context, item));
22275 });
22276 return results;
22277 }
22278 };
22279
22280 _.keys = function(obj) {
22281 var results = [];
22282 if (obj === null) {
22283 return results;
22284 }
22285 _.each(obj, function(value, key) {
22286 results[results.length] = key;
22287 });
22288 return results;
22289 };
22290
22291 _.values = function(obj) {
22292 var results = [];
22293 if (obj === null) {
22294 return results;
22295 }
22296 _.each(obj, function(value) {
22297 results[results.length] = value;
22298 });
22299 return results;
22300 };
22301
22302 _.include = function(obj, target) {
22303 var found = false;
22304 if (obj === null) {
22305 return found;
22306 }
22307 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
22308 return obj.indexOf(target) != -1;
22309 }
22310 _.each(obj, function(value) {
22311 if (found || (found = (value === target))) {
22312 return breaker;
22313 }
22314 });
22315 return found;
22316 };
22317
22318 _.includes = function(str, needle) {
22319 return str.indexOf(needle) !== -1;
22320 };
22321
22322 // Underscore Addons
22323 _.inherit = function(subclass, superclass) {
22324 subclass.prototype = new superclass();
22325 subclass.prototype.constructor = subclass;
22326 subclass.superclass = superclass.prototype;
22327 return subclass;
22328 };
22329
22330 _.isObject = function(obj) {
22331 return (obj === Object(obj) && !_.isArray(obj));
22332 };
22333
22334 _.isEmptyObject = function(obj) {
22335 if (_.isObject(obj)) {
22336 for (var key in obj) {
22337 if (hasOwnProperty.call(obj, key)) {
22338 return false;
22339 }
22340 }
22341 return true;
22342 }
22343 return false;
22344 };
22345
22346 _.isUndefined = function(obj) {
22347 return obj === void 0;
22348 };
22349
22350 _.isString = function(obj) {
22351 return toString.call(obj) == '[object String]';
22352 };
22353
22354 _.isDate = function(obj) {
22355 return toString.call(obj) == '[object Date]';
22356 };
22357
22358 _.isNumber = function(obj) {
22359 return toString.call(obj) == '[object Number]';
22360 };
22361
22362 _.isElement = function(obj) {
22363 return !!(obj && obj.nodeType === 1);
22364 };
22365
22366 _.encodeDates = function(obj) {
22367 _.each(obj, function(v, k) {
22368 if (_.isDate(v)) {
22369 obj[k] = _.formatDate(v);
22370 } else if (_.isObject(v)) {
22371 obj[k] = _.encodeDates(v); // recurse
22372 }
22373 });
22374 return obj;
22375 };
22376
22377 _.timestamp = function() {
22378 Date.now = Date.now || function() {
22379 return +new Date;
22380 };
22381 return Date.now();
22382 };
22383
22384 _.formatDate = function(d) {
22385 // YYYY-MM-DDTHH:MM:SS in UTC
22386 function pad(n) {
22387 return n < 10 ? '0' + n : n;
22388 }
22389 return d.getUTCFullYear() + '-' +
22390 pad(d.getUTCMonth() + 1) + '-' +
22391 pad(d.getUTCDate()) + 'T' +
22392 pad(d.getUTCHours()) + ':' +
22393 pad(d.getUTCMinutes()) + ':' +
22394 pad(d.getUTCSeconds());
22395 };
22396
22397 _.strip_empty_properties = function(p) {
22398 var ret = {};
22399 _.each(p, function(v, k) {
22400 if (_.isString(v) && v.length > 0) {
22401 ret[k] = v;
22402 }
22403 });
22404 return ret;
22405 };
22406
22407 /*
22408 * this function returns a copy of object after truncating it. If
22409 * passed an Array or Object it will iterate through obj and
22410 * truncate all the values recursively.
22411 */
22412 _.truncate = function(obj, length) {
22413 var ret;
22414
22415 if (typeof(obj) === 'string') {
22416 ret = obj.slice(0, length);
22417 } else if (_.isArray(obj)) {
22418 ret = [];
22419 _.each(obj, function(val) {
22420 ret.push(_.truncate(val, length));
22421 });
22422 } else if (_.isObject(obj)) {
22423 ret = {};
22424 _.each(obj, function(val, key) {
22425 ret[key] = _.truncate(val, length);
22426 });
22427 } else {
22428 ret = obj;
22429 }
22430
22431 return ret;
22432 };
22433
22434 _.JSONEncode = (function() {
22435 return function(mixed_val) {
22436 var value = mixed_val;
22437 var quote = function(string) {
22438 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
22439 var meta = { // table of character substitutions
22440 '\b': '\\b',
22441 '\t': '\\t',
22442 '\n': '\\n',
22443 '\f': '\\f',
22444 '\r': '\\r',
22445 '"': '\\"',
22446 '\\': '\\\\'
22447 };
22448
22449 escapable.lastIndex = 0;
22450 return escapable.test(string) ?
22451 '"' + string.replace(escapable, function(a) {
22452 var c = meta[a];
22453 return typeof c === 'string' ? c :
22454 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
22455 }) + '"' :
22456 '"' + string + '"';
22457 };
22458
22459 var str = function(key, holder) {
22460 var gap = '';
22461 var indent = ' ';
22462 var i = 0; // The loop counter.
22463 var k = ''; // The member key.
22464 var v = ''; // The member value.
22465 var length = 0;
22466 var mind = gap;
22467 var partial = [];
22468 var value = holder[key];
22469
22470 // If the value has a toJSON method, call it to obtain a replacement value.
22471 if (value && typeof value === 'object' &&
22472 typeof value.toJSON === 'function') {
22473 value = value.toJSON(key);
22474 }
22475
22476 // What happens next depends on the value's type.
22477 switch (typeof value) {
22478 case 'string':
22479 return quote(value);
22480
22481 case 'number':
22482 // JSON numbers must be finite. Encode non-finite numbers as null.
22483 return isFinite(value) ? String(value) : 'null';
22484
22485 case 'boolean':
22486 case 'null':
22487 // If the value is a boolean or null, convert it to a string. Note:
22488 // typeof null does not produce 'null'. The case is included here in
22489 // the remote chance that this gets fixed someday.
22490
22491 return String(value);
22492
22493 case 'object':
22494 // If the type is 'object', we might be dealing with an object or an array or
22495 // null.
22496 // Due to a specification blunder in ECMAScript, typeof null is 'object',
22497 // so watch out for that case.
22498 if (!value) {
22499 return 'null';
22500 }
22501
22502 // Make an array to hold the partial results of stringifying this object value.
22503 gap += indent;
22504 partial = [];
22505
22506 // Is the value an array?
22507 if (toString.apply(value) === '[object Array]') {
22508 // The value is an array. Stringify every element. Use null as a placeholder
22509 // for non-JSON values.
22510
22511 length = value.length;
22512 for (i = 0; i < length; i += 1) {
22513 partial[i] = str(i, value) || 'null';
22514 }
22515
22516 // Join all of the elements together, separated with commas, and wrap them in
22517 // brackets.
22518 v = partial.length === 0 ? '[]' :
22519 gap ? '[\n' + gap +
22520 partial.join(',\n' + gap) + '\n' +
22521 mind + ']' :
22522 '[' + partial.join(',') + ']';
22523 gap = mind;
22524 return v;
22525 }
22526
22527 // Iterate through all of the keys in the object.
22528 for (k in value) {
22529 if (hasOwnProperty.call(value, k)) {
22530 v = str(k, value);
22531 if (v) {
22532 partial.push(quote(k) + (gap ? ': ' : ':') + v);
22533 }
22534 }
22535 }
22536
22537 // Join all of the member texts together, separated with commas,
22538 // and wrap them in braces.
22539 v = partial.length === 0 ? '{}' :
22540 gap ? '{' + partial.join(',') + '' +
22541 mind + '}' : '{' + partial.join(',') + '}';
22542 gap = mind;
22543 return v;
22544 }
22545 };
22546
22547 // Make a fake root object containing our value under the key of ''.
22548 // Return the result of stringifying the value.
22549 return str('', {
22550 '': value
22551 });
22552 };
22553 })();
22554
22555 /**
22556 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
22557 * Slightly modified to throw a real Error rather than a POJO
22558 */
22559 _.JSONDecode = (function() {
22560 var at, // The index of the current character
22561 ch, // The current character
22562 escapee = {
22563 '"': '"',
22564 '\\': '\\',
22565 '/': '/',
22566 'b': '\b',
22567 'f': '\f',
22568 'n': '\n',
22569 'r': '\r',
22570 't': '\t'
22571 },
22572 text,
22573 error = function(m) {
22574 var e = new SyntaxError(m);
22575 e.at = at;
22576 e.text = text;
22577 throw e;
22578 },
22579 next = function(c) {
22580 // If a c parameter is provided, verify that it matches the current character.
22581 if (c && c !== ch) {
22582 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
22583 }
22584 // Get the next character. When there are no more characters,
22585 // return the empty string.
22586 ch = text.charAt(at);
22587 at += 1;
22588 return ch;
22589 },
22590 number = function() {
22591 // Parse a number value.
22592 var number,
22593 string = '';
22594
22595 if (ch === '-') {
22596 string = '-';
22597 next('-');
22598 }
22599 while (ch >= '0' && ch <= '9') {
22600 string += ch;
22601 next();
22602 }
22603 if (ch === '.') {
22604 string += '.';
22605 while (next() && ch >= '0' && ch <= '9') {
22606 string += ch;
22607 }
22608 }
22609 if (ch === 'e' || ch === 'E') {
22610 string += ch;
22611 next();
22612 if (ch === '-' || ch === '+') {
22613 string += ch;
22614 next();
22615 }
22616 while (ch >= '0' && ch <= '9') {
22617 string += ch;
22618 next();
22619 }
22620 }
22621 number = +string;
22622 if (!isFinite(number)) {
22623 error('Bad number');
22624 } else {
22625 return number;
22626 }
22627 },
22628
22629 string = function() {
22630 // Parse a string value.
22631 var hex,
22632 i,
22633 string = '',
22634 uffff;
22635 // When parsing for string values, we must look for " and \ characters.
22636 if (ch === '"') {
22637 while (next()) {
22638 if (ch === '"') {
22639 next();
22640 return string;
22641 }
22642 if (ch === '\\') {
22643 next();
22644 if (ch === 'u') {
22645 uffff = 0;
22646 for (i = 0; i < 4; i += 1) {
22647 hex = parseInt(next(), 16);
22648 if (!isFinite(hex)) {
22649 break;
22650 }
22651 uffff = uffff * 16 + hex;
22652 }
22653 string += String.fromCharCode(uffff);
22654 } else if (typeof escapee[ch] === 'string') {
22655 string += escapee[ch];
22656 } else {
22657 break;
22658 }
22659 } else {
22660 string += ch;
22661 }
22662 }
22663 }
22664 error('Bad string');
22665 },
22666 white = function() {
22667 // Skip whitespace.
22668 while (ch && ch <= ' ') {
22669 next();
22670 }
22671 },
22672 word = function() {
22673 // true, false, or null.
22674 switch (ch) {
22675 case 't':
22676 next('t');
22677 next('r');
22678 next('u');
22679 next('e');
22680 return true;
22681 case 'f':
22682 next('f');
22683 next('a');
22684 next('l');
22685 next('s');
22686 next('e');
22687 return false;
22688 case 'n':
22689 next('n');
22690 next('u');
22691 next('l');
22692 next('l');
22693 return null;
22694 }
22695 error('Unexpected "' + ch + '"');
22696 },
22697 value, // Placeholder for the value function.
22698 array = function() {
22699 // Parse an array value.
22700 var array = [];
22701
22702 if (ch === '[') {
22703 next('[');
22704 white();
22705 if (ch === ']') {
22706 next(']');
22707 return array; // empty array
22708 }
22709 while (ch) {
22710 array.push(value());
22711 white();
22712 if (ch === ']') {
22713 next(']');
22714 return array;
22715 }
22716 next(',');
22717 white();
22718 }
22719 }
22720 error('Bad array');
22721 },
22722 object = function() {
22723 // Parse an object value.
22724 var key,
22725 object = {};
22726
22727 if (ch === '{') {
22728 next('{');
22729 white();
22730 if (ch === '}') {
22731 next('}');
22732 return object; // empty object
22733 }
22734 while (ch) {
22735 key = string();
22736 white();
22737 next(':');
22738 if (Object.hasOwnProperty.call(object, key)) {
22739 error('Duplicate key "' + key + '"');
22740 }
22741 object[key] = value();
22742 white();
22743 if (ch === '}') {
22744 next('}');
22745 return object;
22746 }
22747 next(',');
22748 white();
22749 }
22750 }
22751 error('Bad object');
22752 };
22753
22754 value = function() {
22755 // Parse a JSON value. It could be an object, an array, a string,
22756 // a number, or a word.
22757 white();
22758 switch (ch) {
22759 case '{':
22760 return object();
22761 case '[':
22762 return array();
22763 case '"':
22764 return string();
22765 case '-':
22766 return number();
22767 default:
22768 return ch >= '0' && ch <= '9' ? number() : word();
22769 }
22770 };
22771
22772 // Return the json_parse function. It will have access to all of the
22773 // above functions and variables.
22774 return function(source) {
22775 var result;
22776
22777 text = source;
22778 at = 0;
22779 ch = ' ';
22780 result = value();
22781 white();
22782 if (ch) {
22783 error('Syntax error');
22784 }
22785
22786 return result;
22787 };
22788 })();
22789
22790 _.base64Encode = function(data) {
22791 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
22792 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
22793 ac = 0,
22794 enc = '',
22795 tmp_arr = [];
22796
22797 if (!data) {
22798 return data;
22799 }
22800
22801 data = _.utf8Encode(data);
22802
22803 do { // pack three octets into four hexets
22804 o1 = data.charCodeAt(i++);
22805 o2 = data.charCodeAt(i++);
22806 o3 = data.charCodeAt(i++);
22807
22808 bits = o1 << 16 | o2 << 8 | o3;
22809
22810 h1 = bits >> 18 & 0x3f;
22811 h2 = bits >> 12 & 0x3f;
22812 h3 = bits >> 6 & 0x3f;
22813 h4 = bits & 0x3f;
22814
22815 // use hexets to index into b64, and append result to encoded string
22816 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
22817 } while (i < data.length);
22818
22819 enc = tmp_arr.join('');
22820
22821 switch (data.length % 3) {
22822 case 1:
22823 enc = enc.slice(0, -2) + '==';
22824 break;
22825 case 2:
22826 enc = enc.slice(0, -1) + '=';
22827 break;
22828 }
22829
22830 return enc;
22831 };
22832
22833 _.utf8Encode = function(string) {
22834 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
22835
22836 var utftext = '',
22837 start,
22838 end;
22839 var stringl = 0,
22840 n;
22841
22842 start = end = 0;
22843 stringl = string.length;
22844
22845 for (n = 0; n < stringl; n++) {
22846 var c1 = string.charCodeAt(n);
22847 var enc = null;
22848
22849 if (c1 < 128) {
22850 end++;
22851 } else if ((c1 > 127) && (c1 < 2048)) {
22852 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
22853 } else {
22854 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
22855 }
22856 if (enc !== null) {
22857 if (end > start) {
22858 utftext += string.substring(start, end);
22859 }
22860 utftext += enc;
22861 start = end = n + 1;
22862 }
22863 }
22864
22865 if (end > start) {
22866 utftext += string.substring(start, string.length);
22867 }
22868
22869 return utftext;
22870 };
22871
22872 _.UUID = function() {
22873 try {
22874 // use native Crypto API when available
22875 return win['crypto']['randomUUID']();
22876 } catch (err) {
22877 // fall back to generating our own UUID
22878 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
22879 var uuid = new Array(36);
22880 for (var i = 0; i < 36; i++) {
22881 uuid[i] = Math.floor(Math.random() * 16);
22882 }
22883 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
22884 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
22885 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
22886 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
22887
22888 return _.map(uuid, function(x) {
22889 return x.toString(16);
22890 }).join('');
22891 }
22892 };
22893
22894 // _.isBlockedUA()
22895 // This is to block various web spiders from executing our JS and
22896 // sending false tracking data
22897 var BLOCKED_UA_STRS = [
22898 'ahrefsbot',
22899 'ahrefssiteaudit',
22900 'amazonbot',
22901 'baiduspider',
22902 'bingbot',
22903 'bingpreview',
22904 'chrome-lighthouse',
22905 'facebookexternal',
22906 'petalbot',
22907 'pinterest',
22908 'screaming frog',
22909 'yahoo! slurp',
22910 'yandex',
22911
22912 // a whole bunch of goog-specific crawlers
22913 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
22914 'adsbot-google',
22915 'apis-google',
22916 'duplexweb-google',
22917 'feedfetcher-google',
22918 'google favicon',
22919 'google web preview',
22920 'google-read-aloud',
22921 'googlebot',
22922 'googleweblight',
22923 'mediapartners-google',
22924 'storebot-google'
22925 ];
22926 _.isBlockedUA = function(ua) {
22927 var i;
22928 ua = ua.toLowerCase();
22929 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
22930 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
22931 return true;
22932 }
22933 }
22934 return false;
22935 };
22936
22937 /**
22938 * @param {Object=} formdata
22939 * @param {string=} arg_separator
22940 */
22941 _.HTTPBuildQuery = function(formdata, arg_separator) {
22942 var use_val, use_key, tmp_arr = [];
22943
22944 if (_.isUndefined(arg_separator)) {
22945 arg_separator = '&';
22946 }
22947
22948 _.each(formdata, function(val, key) {
22949 use_val = encodeURIComponent(val.toString());
22950 use_key = encodeURIComponent(key);
22951 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
22952 });
22953
22954 return tmp_arr.join(arg_separator);
22955 };
22956
22957 _.getQueryParam = function(url, param) {
22958 // Expects a raw URL
22959
22960 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
22961 var regexS = '[\\?&]' + param + '=([^&#]*)',
22962 regex = new RegExp(regexS),
22963 results = regex.exec(url);
22964 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
22965 return '';
22966 } else {
22967 var result = results[1];
22968 try {
22969 result = decodeURIComponent(result);
22970 } catch(err) {
22971 console$1.error('Skipping decoding for malformed query param: ' + result);
22972 }
22973 return result.replace(/\+/g, ' ');
22974 }
22975 };
22976
22977
22978 // _.cookie
22979 // Methods partially borrowed from quirksmode.org/js/cookies.html
22980 _.cookie = {
22981 get: function(name) {
22982 var nameEQ = name + '=';
22983 var ca = document$1.cookie.split(';');
22984 for (var i = 0; i < ca.length; i++) {
22985 var c = ca[i];
22986 while (c.charAt(0) == ' ') {
22987 c = c.substring(1, c.length);
22988 }
22989 if (c.indexOf(nameEQ) === 0) {
22990 return decodeURIComponent(c.substring(nameEQ.length, c.length));
22991 }
22992 }
22993 return null;
22994 },
22995
22996 parse: function(name) {
22997 var cookie;
22998 try {
22999 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23000 } catch (err) {
23001 // noop
23002 }
23003 return cookie;
23004 },
23005
23006 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23007 var cdomain = '',
23008 expires = '',
23009 secure = '';
23010
23011 if (domain_override) {
23012 cdomain = '; domain=' + domain_override;
23013 } else if (is_cross_subdomain) {
23014 var domain = extract_domain(document$1.location.hostname);
23015 cdomain = domain ? '; domain=.' + domain : '';
23016 }
23017
23018 if (seconds) {
23019 var date = new Date();
23020 date.setTime(date.getTime() + (seconds * 1000));
23021 expires = '; expires=' + date.toGMTString();
23022 }
23023
23024 if (is_cross_site) {
23025 is_secure = true;
23026 secure = '; SameSite=None';
23027 }
23028 if (is_secure) {
23029 secure += '; secure';
23030 }
23031
23032 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23033 },
23034
23035 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23036 var cdomain = '', expires = '', secure = '';
23037
23038 if (domain_override) {
23039 cdomain = '; domain=' + domain_override;
23040 } else if (is_cross_subdomain) {
23041 var domain = extract_domain(document$1.location.hostname);
23042 cdomain = domain ? '; domain=.' + domain : '';
23043 }
23044
23045 if (days) {
23046 var date = new Date();
23047 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23048 expires = '; expires=' + date.toGMTString();
23049 }
23050
23051 if (is_cross_site) {
23052 is_secure = true;
23053 secure = '; SameSite=None';
23054 }
23055 if (is_secure) {
23056 secure += '; secure';
23057 }
23058
23059 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23060 document$1.cookie = new_cookie_val;
23061 return new_cookie_val;
23062 },
23063
23064 remove: function(name, is_cross_subdomain, domain_override) {
23065 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23066 }
23067 };
23068
23069 var _testStorageSupported = function (storage) {
23070 var supported = true;
23071 try {
23072 var key = '__mplss_' + cheap_guid(8),
23073 val = 'xyz';
23074 storage.setItem(key, val);
23075 if (storage.getItem(key) !== val) {
23076 supported = false;
23077 }
23078 storage.removeItem(key);
23079 } catch (err) {
23080 supported = false;
23081 }
23082 return supported;
23083 };
23084
23085 var _localStorageSupported = null;
23086 var localStorageSupported = function(storage, forceCheck) {
23087 if (_localStorageSupported !== null && !forceCheck) {
23088 return _localStorageSupported;
23089 }
23090 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23091 };
23092
23093 var _sessionStorageSupported = null;
23094 var sessionStorageSupported = function(storage, forceCheck) {
23095 if (_sessionStorageSupported !== null && !forceCheck) {
23096 return _sessionStorageSupported;
23097 }
23098 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23099 };
23100
23101 function _storageWrapper(storage, name, is_supported_fn) {
23102 var log_error = function(msg) {
23103 console$1.error(name + ' error: ' + msg);
23104 };
23105
23106 return {
23107 is_supported: function(forceCheck) {
23108 var supported = is_supported_fn(storage, forceCheck);
23109 if (!supported) {
23110 console$1.error(name + ' unsupported');
23111 }
23112 return supported;
23113 },
23114 error: log_error,
23115 get: function(key) {
23116 try {
23117 return storage.getItem(key);
23118 } catch (err) {
23119 log_error(err);
23120 }
23121 return null;
23122 },
23123 parse: function(key) {
23124 try {
23125 return _.JSONDecode(storage.getItem(key)) || {};
23126 } catch (err) {
23127 // noop
23128 }
23129 return null;
23130 },
23131 set: function(key, value) {
23132 try {
23133 storage.setItem(key, value);
23134 } catch (err) {
23135 log_error(err);
23136 }
23137 },
23138 remove: function(key) {
23139 try {
23140 storage.removeItem(key);
23141 } catch (err) {
23142 log_error(err);
23143 }
23144 }
23145 };
23146 }
23147
23148 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
23149 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
23150
23151 _.register_event = (function() {
23152 // written by Dean Edwards, 2005
23153 // with input from Tino Zijdel - crisp@xs4all.nl
23154 // with input from Carl Sverre - mail@carlsverre.com
23155 // with input from Mixpanel
23156 // http://dean.edwards.name/weblog/2005/10/add-event/
23157 // https://gist.github.com/1930440
23158
23159 /**
23160 * @param {Object} element
23161 * @param {string} type
23162 * @param {function(...*)} handler
23163 * @param {boolean=} oldSchool
23164 * @param {boolean=} useCapture
23165 */
23166 var register_event = function(element, type, handler, oldSchool, useCapture) {
23167 if (!element) {
23168 console$1.error('No valid element provided to register_event');
23169 return;
23170 }
23171
23172 if (element.addEventListener && !oldSchool) {
23173 element.addEventListener(type, handler, !!useCapture);
23174 } else {
23175 var ontype = 'on' + type;
23176 var old_handler = element[ontype]; // can be undefined
23177 element[ontype] = makeHandler(element, handler, old_handler);
23178 }
23179 };
23180
23181 function makeHandler(element, new_handler, old_handlers) {
23182 var handler = function(event) {
23183 event = event || fixEvent(win.event);
23184
23185 // this basically happens in firefox whenever another script
23186 // overwrites the onload callback and doesn't pass the event
23187 // object to previously defined callbacks. All the browsers
23188 // that don't define window.event implement addEventListener
23189 // so the dom_loaded handler will still be fired as usual.
23190 if (!event) {
23191 return undefined;
23192 }
23193
23194 var ret = true;
23195 var old_result, new_result;
23196
23197 if (_.isFunction(old_handlers)) {
23198 old_result = old_handlers(event);
23199 }
23200 new_result = new_handler.call(element, event);
23201
23202 if ((false === old_result) || (false === new_result)) {
23203 ret = false;
23204 }
23205
23206 return ret;
23207 };
23208
23209 return handler;
23210 }
23211
23212 function fixEvent(event) {
23213 if (event) {
23214 event.preventDefault = fixEvent.preventDefault;
23215 event.stopPropagation = fixEvent.stopPropagation;
23216 }
23217 return event;
23218 }
23219 fixEvent.preventDefault = function() {
23220 this.returnValue = false;
23221 };
23222 fixEvent.stopPropagation = function() {
23223 this.cancelBubble = true;
23224 };
23225
23226 return register_event;
23227 })();
23228
23229
23230 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
23231
23232 _.dom_query = (function() {
23233 /* document.getElementsBySelector(selector)
23234 - returns an array of element objects from the current document
23235 matching the CSS selector. Selectors can contain element names,
23236 class names and ids and can be nested. For example:
23237
23238 elements = document.getElementsBySelector('div#main p a.external')
23239
23240 Will return an array of all 'a' elements with 'external' in their
23241 class attribute that are contained inside 'p' elements that are
23242 contained inside the 'div' element which has id="main"
23243
23244 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
23245 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
23246
23247 Version 0.4 - Simon Willison, March 25th 2003
23248 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
23249 -- Opera 7 fails
23250
23251 Version 0.5 - Carl Sverre, Jan 7th 2013
23252 -- Now uses jQuery-esque `hasClass` for testing class name
23253 equality. This fixes a bug related to '-' characters being
23254 considered not part of a 'word' in regex.
23255 */
23256
23257 function getAllChildren(e) {
23258 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
23259 return e.all ? e.all : e.getElementsByTagName('*');
23260 }
23261
23262 var bad_whitespace = /[\t\r\n]/g;
23263
23264 function hasClass(elem, selector) {
23265 var className = ' ' + selector + ' ';
23266 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
23267 }
23268
23269 function getElementsBySelector(selector) {
23270 // Attempt to fail gracefully in lesser browsers
23271 if (!document$1.getElementsByTagName) {
23272 return [];
23273 }
23274 // Split selector in to tokens
23275 var tokens = selector.split(' ');
23276 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
23277 var currentContext = [document$1];
23278 for (i = 0; i < tokens.length; i++) {
23279 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
23280 if (token.indexOf('#') > -1) {
23281 // Token is an ID selector
23282 bits = token.split('#');
23283 tagName = bits[0];
23284 var id = bits[1];
23285 var element = document$1.getElementById(id);
23286 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
23287 // element not found or tag with that ID not found, return false
23288 return [];
23289 }
23290 // Set currentContext to contain just this element
23291 currentContext = [element];
23292 continue; // Skip to next token
23293 }
23294 if (token.indexOf('.') > -1) {
23295 // Token contains a class selector
23296 bits = token.split('.');
23297 tagName = bits[0];
23298 var className = bits[1];
23299 if (!tagName) {
23300 tagName = '*';
23301 }
23302 // Get elements matching tag, filter them for class selector
23303 found = [];
23304 foundCount = 0;
23305 for (j = 0; j < currentContext.length; j++) {
23306 if (tagName == '*') {
23307 elements = getAllChildren(currentContext[j]);
23308 } else {
23309 elements = currentContext[j].getElementsByTagName(tagName);
23310 }
23311 for (k = 0; k < elements.length; k++) {
23312 found[foundCount++] = elements[k];
23313 }
23314 }
23315 currentContext = [];
23316 currentContextIndex = 0;
23317 for (j = 0; j < found.length; j++) {
23318 if (found[j].className &&
23319 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
23320 hasClass(found[j], className)
23321 ) {
23322 currentContext[currentContextIndex++] = found[j];
23323 }
23324 }
23325 continue; // Skip to next token
23326 }
23327 // Code to deal with attribute selectors
23328 var token_match = token.match(TOKEN_MATCH_REGEX);
23329 if (token_match) {
23330 tagName = token_match[1];
23331 var attrName = token_match[2];
23332 var attrOperator = token_match[3];
23333 var attrValue = token_match[4];
23334 if (!tagName) {
23335 tagName = '*';
23336 }
23337 // Grab all of the tagName elements within current context
23338 found = [];
23339 foundCount = 0;
23340 for (j = 0; j < currentContext.length; j++) {
23341 if (tagName == '*') {
23342 elements = getAllChildren(currentContext[j]);
23343 } else {
23344 elements = currentContext[j].getElementsByTagName(tagName);
23345 }
23346 for (k = 0; k < elements.length; k++) {
23347 found[foundCount++] = elements[k];
23348 }
23349 }
23350 currentContext = [];
23351 currentContextIndex = 0;
23352 var checkFunction; // This function will be used to filter the elements
23353 switch (attrOperator) {
23354 case '=': // Equality
23355 checkFunction = function(e) {
23356 return (e.getAttribute(attrName) == attrValue);
23357 };
23358 break;
23359 case '~': // Match one of space seperated words
23360 checkFunction = function(e) {
23361 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
23362 };
23363 break;
23364 case '|': // Match start with value followed by optional hyphen
23365 checkFunction = function(e) {
23366 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
23367 };
23368 break;
23369 case '^': // Match starts with value
23370 checkFunction = function(e) {
23371 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
23372 };
23373 break;
23374 case '$': // Match ends with value - fails with "Warning" in Opera 7
23375 checkFunction = function(e) {
23376 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
23377 };
23378 break;
23379 case '*': // Match ends with value
23380 checkFunction = function(e) {
23381 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
23382 };
23383 break;
23384 default:
23385 // Just test for existence of attribute
23386 checkFunction = function(e) {
23387 return e.getAttribute(attrName);
23388 };
23389 }
23390 currentContext = [];
23391 currentContextIndex = 0;
23392 for (j = 0; j < found.length; j++) {
23393 if (checkFunction(found[j])) {
23394 currentContext[currentContextIndex++] = found[j];
23395 }
23396 }
23397 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
23398 continue; // Skip to next token
23399 }
23400 // If we get here, token is JUST an element (not a class or ID selector)
23401 tagName = token;
23402 found = [];
23403 foundCount = 0;
23404 for (j = 0; j < currentContext.length; j++) {
23405 elements = currentContext[j].getElementsByTagName(tagName);
23406 for (k = 0; k < elements.length; k++) {
23407 found[foundCount++] = elements[k];
23408 }
23409 }
23410 currentContext = found;
23411 }
23412 return currentContext;
23413 }
23414
23415 return function(query) {
23416 if (_.isElement(query)) {
23417 return [query];
23418 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
23419 return query;
23420 } else {
23421 return getElementsBySelector.call(this, query);
23422 }
23423 };
23424 })();
23425
23426 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'];
23427 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
23428
23429 _.info = {
23430 campaignParams: function(default_value) {
23431 var kw = '',
23432 params = {};
23433 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
23434 kw = _.getQueryParam(document$1.URL, kwkey);
23435 if (kw.length) {
23436 params[kwkey] = kw;
23437 } else if (default_value !== undefined) {
23438 params[kwkey] = default_value;
23439 }
23440 });
23441
23442 return params;
23443 },
23444
23445 clickParams: function() {
23446 var id = '',
23447 params = {};
23448 _.each(CLICK_IDS, function(idkey) {
23449 id = _.getQueryParam(document$1.URL, idkey);
23450 if (id.length) {
23451 params[idkey] = id;
23452 }
23453 });
23454
23455 return params;
23456 },
23457
23458 marketingParams: function() {
23459 return _.extend(_.info.campaignParams(), _.info.clickParams());
23460 },
23461
23462 searchEngine: function(referrer) {
23463 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
23464 return 'google';
23465 } else if (referrer.search('https?://(.*)bing.com') === 0) {
23466 return 'bing';
23467 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
23468 return 'yahoo';
23469 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
23470 return 'duckduckgo';
23471 } else {
23472 return null;
23473 }
23474 },
23475
23476 searchInfo: function(referrer) {
23477 var search = _.info.searchEngine(referrer),
23478 param = (search != 'yahoo') ? 'q' : 'p',
23479 ret = {};
23480
23481 if (search !== null) {
23482 ret['$search_engine'] = search;
23483
23484 var keyword = _.getQueryParam(referrer, param);
23485 if (keyword.length) {
23486 ret['mp_keyword'] = keyword;
23487 }
23488 }
23489
23490 return ret;
23491 },
23492
23493 /**
23494 * This function detects which browser is running this script.
23495 * The order of the checks are important since many user agents
23496 * include key words used in later checks.
23497 */
23498 browser: function(user_agent, vendor, opera) {
23499 vendor = vendor || ''; // vendor is undefined for at least IE9
23500 if (opera || _.includes(user_agent, ' OPR/')) {
23501 if (_.includes(user_agent, 'Mini')) {
23502 return 'Opera Mini';
23503 }
23504 return 'Opera';
23505 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23506 return 'BlackBerry';
23507 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
23508 return 'Internet Explorer Mobile';
23509 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
23510 // https://developer.samsung.com/internet/user-agent-string-format
23511 return 'Samsung Internet';
23512 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
23513 return 'Microsoft Edge';
23514 } else if (_.includes(user_agent, 'FBIOS')) {
23515 return 'Facebook Mobile';
23516 } else if (_.includes(user_agent, 'Whale/')) {
23517 // https://user-agents.net/browsers/whale-browser
23518 return 'Whale Browser';
23519 } else if (_.includes(user_agent, 'Chrome')) {
23520 return 'Chrome';
23521 } else if (_.includes(user_agent, 'CriOS')) {
23522 return 'Chrome iOS';
23523 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
23524 return 'UC Browser';
23525 } else if (_.includes(user_agent, 'FxiOS')) {
23526 return 'Firefox iOS';
23527 } else if (_.includes(vendor, 'Apple')) {
23528 if (_.includes(user_agent, 'Mobile')) {
23529 return 'Mobile Safari';
23530 }
23531 return 'Safari';
23532 } else if (_.includes(user_agent, 'Android')) {
23533 return 'Android Mobile';
23534 } else if (_.includes(user_agent, 'Konqueror')) {
23535 return 'Konqueror';
23536 } else if (_.includes(user_agent, 'Firefox')) {
23537 return 'Firefox';
23538 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
23539 return 'Internet Explorer';
23540 } else if (_.includes(user_agent, 'Gecko')) {
23541 return 'Mozilla';
23542 } else {
23543 return '';
23544 }
23545 },
23546
23547 /**
23548 * This function detects which browser version is running this script,
23549 * parsing major and minor version (e.g., 42.1). User agent strings from:
23550 * http://www.useragentstring.com/pages/useragentstring.php
23551 */
23552 browserVersion: function(userAgent, vendor, opera) {
23553 var browser = _.info.browser(userAgent, vendor, opera);
23554 var versionRegexs = {
23555 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
23556 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
23557 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
23558 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
23559 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
23560 'Safari': /Version\/(\d+(\.\d+)?)/,
23561 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
23562 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
23563 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
23564 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
23565 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
23566 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
23567 'Android Mobile': /android\s(\d+(\.\d+)?)/,
23568 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
23569 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
23570 'Mozilla': /rv:(\d+(\.\d+)?)/,
23571 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
23572 };
23573 var regex = versionRegexs[browser];
23574 if (regex === undefined) {
23575 return null;
23576 }
23577 var matches = userAgent.match(regex);
23578 if (!matches) {
23579 return null;
23580 }
23581 return parseFloat(matches[matches.length - 2]);
23582 },
23583
23584 os: function() {
23585 var a = userAgent;
23586 if (/Windows/i.test(a)) {
23587 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
23588 return 'Windows Phone';
23589 }
23590 return 'Windows';
23591 } else if (/(iPhone|iPad|iPod)/.test(a)) {
23592 return 'iOS';
23593 } else if (/Android/.test(a)) {
23594 return 'Android';
23595 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
23596 return 'BlackBerry';
23597 } else if (/Mac/i.test(a)) {
23598 return 'Mac OS X';
23599 } else if (/Linux/.test(a)) {
23600 return 'Linux';
23601 } else if (/CrOS/.test(a)) {
23602 return 'Chrome OS';
23603 } else {
23604 return '';
23605 }
23606 },
23607
23608 device: function(user_agent) {
23609 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
23610 return 'Windows Phone';
23611 } else if (/iPad/.test(user_agent)) {
23612 return 'iPad';
23613 } else if (/iPod/.test(user_agent)) {
23614 return 'iPod Touch';
23615 } else if (/iPhone/.test(user_agent)) {
23616 return 'iPhone';
23617 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
23618 return 'BlackBerry';
23619 } else if (/Android/.test(user_agent)) {
23620 return 'Android';
23621 } else {
23622 return '';
23623 }
23624 },
23625
23626 referringDomain: function(referrer) {
23627 var split = referrer.split('/');
23628 if (split.length >= 3) {
23629 return split[2];
23630 }
23631 return '';
23632 },
23633
23634 currentUrl: function() {
23635 return win.location.href;
23636 },
23637
23638 properties: function(extra_props) {
23639 if (typeof extra_props !== 'object') {
23640 extra_props = {};
23641 }
23642 return _.extend(_.strip_empty_properties({
23643 '$os': _.info.os(),
23644 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
23645 '$referrer': document$1.referrer,
23646 '$referring_domain': _.info.referringDomain(document$1.referrer),
23647 '$device': _.info.device(userAgent)
23648 }), {
23649 '$current_url': _.info.currentUrl(),
23650 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
23651 '$screen_height': screen.height,
23652 '$screen_width': screen.width,
23653 'mp_lib': 'web',
23654 '$lib_version': Config.LIB_VERSION,
23655 '$insert_id': cheap_guid(),
23656 'time': _.timestamp() / 1000 // epoch time in seconds
23657 }, _.strip_empty_properties(extra_props));
23658 },
23659
23660 people_properties: function() {
23661 return _.extend(_.strip_empty_properties({
23662 '$os': _.info.os(),
23663 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
23664 }), {
23665 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
23666 });
23667 },
23668
23669 mpPageViewProperties: function() {
23670 return _.strip_empty_properties({
23671 'current_page_title': document$1.title,
23672 'current_domain': win.location.hostname,
23673 'current_url_path': win.location.pathname,
23674 'current_url_protocol': win.location.protocol,
23675 'current_url_search': win.location.search
23676 });
23677 }
23678 };
23679
23680 /**
23681 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
23682 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
23683 */
23684 var batchedThrottle = function (fn, waitMs) {
23685 var timeoutPromise = null;
23686 var throttledItems = [];
23687 return function (item) {
23688 var self = this;
23689 throttledItems.push(item);
23690
23691 if (!timeoutPromise) {
23692 timeoutPromise = new PromisePolyfill(function (resolve) {
23693 setTimeout(function () {
23694 var returnValue = fn.apply(self, [throttledItems]);
23695 timeoutPromise = null;
23696 throttledItems = [];
23697 resolve(returnValue);
23698 }, waitMs);
23699 });
23700 }
23701 return timeoutPromise;
23702 };
23703 };
23704
23705 var cheap_guid = function(maxlen) {
23706 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
23707 return maxlen ? guid.substring(0, maxlen) : guid;
23708 };
23709
23710 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
23711 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
23712 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
23713 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
23714 /**
23715 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
23716 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
23717 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
23718 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
23719 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
23720 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
23721 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
23722 * offers the 'cookie_domain' config option to set it explicitly.
23723 * @example
23724 * extract_domain('my.sub.example.com')
23725 * // 'example.com'
23726 */
23727 var extract_domain = function(hostname) {
23728 var domain_regex = DOMAIN_MATCH_REGEX;
23729 var parts = hostname.split('.');
23730 var tld = parts[parts.length - 1];
23731 if (tld.length > 4 || tld === 'com' || tld === 'org') {
23732 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
23733 }
23734 var matches = hostname.match(domain_regex);
23735 return matches ? matches[0] : '';
23736 };
23737
23738 /**
23739 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
23740 * @returns {boolean}
23741 */
23742 var isOnline = function() {
23743 var onLine = win.navigator['onLine'];
23744 return _.isUndefined(onLine) || onLine;
23745 };
23746
23747 var NOOP_FUNC = function () {};
23748
23749 var JSONStringify = null, JSONParse = null;
23750 if (typeof JSON !== 'undefined') {
23751 JSONStringify = JSON.stringify;
23752 JSONParse = JSON.parse;
23753 }
23754 JSONStringify = JSONStringify || _.JSONEncode;
23755 JSONParse = JSONParse || _.JSONDecode;
23756
23757 // UNMINIFIED EXPORTS (for closure compiler)
23758 _['info'] = _.info;
23759 _['info']['browser'] = _.info.browser;
23760 _['info']['browserVersion'] = _.info.browserVersion;
23761 _['info']['device'] = _.info.device;
23762 _['info']['properties'] = _.info.properties;
23763 _['isBlockedUA'] = _.isBlockedUA;
23764 _['isEmptyObject'] = _.isEmptyObject;
23765 _['isObject'] = _.isObject;
23766 _['JSONDecode'] = _.JSONDecode;
23767 _['JSONEncode'] = _.JSONEncode;
23768 _['toArray'] = _.toArray;
23769 _['NPO'] = NpoPromise;
23770
23771 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
23772
23773 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
23774 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
23775
23776 // note: increment the version number when adding new object stores
23777 var DB_VERSION = 1;
23778 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
23779
23780 /**
23781 * @type {import('./wrapper').StorageWrapper}
23782 */
23783 var IDBStorageWrapper = function (storeName) {
23784 /**
23785 * @type {Promise<IDBDatabase>|null}
23786 */
23787 this.dbPromise = null;
23788 this.storeName = storeName;
23789 };
23790
23791 IDBStorageWrapper.prototype._openDb = function () {
23792 return new PromisePolyfill(function (resolve, reject) {
23793 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
23794 openRequest['onerror'] = function () {
23795 reject(openRequest.error);
23796 };
23797
23798 openRequest['onsuccess'] = function () {
23799 resolve(openRequest.result);
23800 };
23801
23802 openRequest['onupgradeneeded'] = function (ev) {
23803 var db = ev.target.result;
23804
23805 OBJECT_STORES.forEach(function (storeName) {
23806 db.createObjectStore(storeName);
23807 });
23808 };
23809 });
23810 };
23811
23812 IDBStorageWrapper.prototype.init = function () {
23813 if (!win.indexedDB) {
23814 return PromisePolyfill.reject('indexedDB is not supported in this browser');
23815 }
23816
23817 if (!this.dbPromise) {
23818 this.dbPromise = this._openDb();
23819 }
23820
23821 return this.dbPromise
23822 .then(function (dbOrError) {
23823 if (dbOrError instanceof win['IDBDatabase']) {
23824 return PromisePolyfill.resolve();
23825 } else {
23826 return PromisePolyfill.reject(dbOrError);
23827 }
23828 });
23829 };
23830
23831 /**
23832 * @param {IDBTransactionMode} mode
23833 * @param {function(IDBObjectStore): void} storeCb
23834 */
23835 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
23836 var storeName = this.storeName;
23837 var doTransaction = function (db) {
23838 return new PromisePolyfill(function (resolve, reject) {
23839 var transaction = db.transaction(storeName, mode);
23840 transaction.oncomplete = function () {
23841 resolve(transaction);
23842 };
23843 transaction.onabort = transaction.onerror = function () {
23844 reject(transaction.error);
23845 };
23846
23847 storeCb(transaction.objectStore(storeName));
23848 });
23849 };
23850
23851 return this.dbPromise
23852 .then(doTransaction)
23853 .catch(function (err) {
23854 if (err && err['name'] === 'InvalidStateError') {
23855 // try reopening the DB if the connection is closed
23856 this.dbPromise = this._openDb();
23857 return this.dbPromise.then(doTransaction);
23858 } else {
23859 return PromisePolyfill.reject(err);
23860 }
23861 }.bind(this));
23862 };
23863
23864 IDBStorageWrapper.prototype.setItem = function (key, value) {
23865 return this.makeTransaction('readwrite', function (objectStore) {
23866 objectStore.put(value, key);
23867 });
23868 };
23869
23870 IDBStorageWrapper.prototype.getItem = function (key) {
23871 var req;
23872 return this.makeTransaction('readonly', function (objectStore) {
23873 req = objectStore.get(key);
23874 }).then(function () {
23875 return req.result;
23876 });
23877 };
23878
23879 IDBStorageWrapper.prototype.removeItem = function (key) {
23880 return this.makeTransaction('readwrite', function (objectStore) {
23881 objectStore.delete(key);
23882 });
23883 };
23884
23885 IDBStorageWrapper.prototype.getAll = function () {
23886 var req;
23887 return this.makeTransaction('readonly', function (objectStore) {
23888 req = objectStore.getAll();
23889 }).then(function () {
23890 return req.result;
23891 });
23892 };
23893
23894 /**
23895 * GDPR utils
23896 *
23897 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
23898 * and privacy for all individuals within the European Union. It addresses the export of personal
23899 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
23900 * over their personal data and to simplify the regulatory environment for international business
23901 * by unifying the regulation within the EU.
23902 *
23903 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
23904 * These functions are used internally by the SDK and are not intended to be publicly exposed.
23905 */
23906
23907
23908 /**
23909 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
23910 * @callback trackFunction
23911 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
23912 * @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.
23913 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
23914 */
23915
23916 /** Public **/
23917
23918 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
23919
23920 /**
23921 * Opt the user in to data tracking and cookies/localstorage for the given token
23922 * @param {string} token - Mixpanel project tracking token
23923 * @param {Object} [options]
23924 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
23925 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
23926 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
23927 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
23928 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
23929 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
23930 * @param {string} [options.cookieDomain] - custom cookie domain
23931 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
23932 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
23933 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
23934 */
23935 function optIn(token, options) {
23936 _optInOut(true, token, options);
23937 }
23938
23939 /**
23940 * Opt the user out of data tracking and cookies/localstorage for the given token
23941 * @param {string} token - Mixpanel project tracking token
23942 * @param {Object} [options]
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-out 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-out cookie is set as cross-subdomain or not
23949 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
23950 */
23951 function optOut(token, options) {
23952 _optInOut(false, token, options);
23953 }
23954
23955 /**
23956 * Check whether the user has opted in to 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 * @returns {boolean} whether the user has opted in to the given opt type
23962 */
23963 function hasOptedIn(token, options) {
23964 return _getStorageValue(token, options) === '1';
23965 }
23966
23967 /**
23968 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
23969 * @param {string} token - Mixpanel project tracking token
23970 * @param {Object} [options]
23971 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
23972 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
23973 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
23974 * @returns {boolean} whether the user has opted out of the given opt type
23975 */
23976 function hasOptedOut(token, options) {
23977 if (_hasDoNotTrackFlagOn(options)) {
23978 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"');
23979 return true;
23980 }
23981 var optedOut = _getStorageValue(token, options) === '0';
23982 if (optedOut) {
23983 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
23984 }
23985 return optedOut;
23986 }
23987
23988 /**
23989 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
23990 * If the user has opted out, return early instead of executing the method.
23991 * If a callback argument was provided, execute it passing the 0 error code.
23992 * @param {function} method - wrapped method to be executed if the user has not opted out
23993 * @returns {*} the result of executing method OR undefined if the user has opted out
23994 */
23995 function addOptOutCheckMixpanelLib(method) {
23996 return _addOptOutCheck(method, function(name) {
23997 return this.get_config(name);
23998 });
23999 }
24000
24001 /**
24002 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24003 * If the user has opted out, return early instead of executing the method.
24004 * If a callback argument was provided, execute it passing the 0 error code.
24005 * @param {function} method - wrapped method to be executed if the user has not opted out
24006 * @returns {*} the result of executing method OR undefined if the user has opted out
24007 */
24008 function addOptOutCheckMixpanelPeople(method) {
24009 return _addOptOutCheck(method, function(name) {
24010 return this._get_config(name);
24011 });
24012 }
24013
24014 /**
24015 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24016 * If the user has opted out, return early instead of executing the method.
24017 * If a callback argument was provided, execute it passing the 0 error code.
24018 * @param {function} method - wrapped method to be executed if the user has not opted out
24019 * @returns {*} the result of executing method OR undefined if the user has opted out
24020 */
24021 function addOptOutCheckMixpanelGroup(method) {
24022 return _addOptOutCheck(method, function(name) {
24023 return this._get_config(name);
24024 });
24025 }
24026
24027 /**
24028 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24029 * @param {string} token - Mixpanel project tracking token
24030 * @param {Object} [options]
24031 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24032 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24033 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24034 * @param {string} [options.cookieDomain] - custom cookie domain
24035 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24036 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24037 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24038 */
24039 function clearOptInOut(token, options) {
24040 options = options || {};
24041 _getStorage(options).remove(
24042 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24043 );
24044 }
24045
24046 /** Private **/
24047
24048 /**
24049 * Get storage util
24050 * @param {Object} [options]
24051 * @param {string} [options.persistenceType]
24052 * @returns {object} either _.cookie or _.localstorage
24053 */
24054 function _getStorage(options) {
24055 options = options || {};
24056 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24057 }
24058
24059 /**
24060 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24061 * @param {string} token - Mixpanel project tracking token
24062 * @param {Object} [options]
24063 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24064 * @returns {string} the name of the cookie for the given opt type
24065 */
24066 function _getStorageKey(token, options) {
24067 options = options || {};
24068 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24069 }
24070
24071 /**
24072 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24073 * @param {string} token - Mixpanel project tracking token
24074 * @param {Object} [options]
24075 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24076 * @returns {string} the value of the cookie for the given opt type
24077 */
24078 function _getStorageValue(token, options) {
24079 return _getStorage(options).get(_getStorageKey(token, options));
24080 }
24081
24082 /**
24083 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24084 * @param {Object} [options]
24085 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24086 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24087 * @returns {boolean} whether the DNT setting is true
24088 */
24089 function _hasDoNotTrackFlagOn(options) {
24090 if (options && options.ignoreDnt) {
24091 return false;
24092 }
24093 var win$1 = (options && options.window) || win;
24094 var nav = win$1['navigator'] || {};
24095 var hasDntOn = false;
24096
24097 _.each([
24098 nav['doNotTrack'], // standard
24099 nav['msDoNotTrack'],
24100 win$1['doNotTrack']
24101 ], function(dntValue) {
24102 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24103 hasDntOn = true;
24104 }
24105 });
24106
24107 return hasDntOn;
24108 }
24109
24110 /**
24111 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24112 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24113 * @param {string} token - Mixpanel project tracking token
24114 * @param {Object} [options]
24115 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24116 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24117 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24118 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24119 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24120 * @param {string} [options.cookieDomain] - custom cookie domain
24121 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24122 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24123 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24124 */
24125 function _optInOut(optValue, token, options) {
24126 if (!_.isString(token) || !token.length) {
24127 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
24128 return;
24129 }
24130
24131 options = options || {};
24132
24133 _getStorage(options).set(
24134 _getStorageKey(token, options),
24135 optValue ? 1 : 0,
24136 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
24137 !!options.crossSubdomainCookie,
24138 !!options.secureCookie,
24139 !!options.crossSiteCookie,
24140 options.cookieDomain
24141 );
24142
24143 if (options.track && optValue) { // only track event if opting in (optValue=true)
24144 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
24145 'send_immediately': true
24146 });
24147 }
24148 }
24149
24150 /**
24151 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24152 * If the user has opted out, return early instead of executing the method.
24153 * If a callback argument was provided, execute it passing the 0 error code.
24154 * @param {function} method - wrapped method to be executed if the user has not opted out
24155 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
24156 * @returns {*} the result of executing method OR undefined if the user has opted out
24157 */
24158 function _addOptOutCheck(method, getConfigValue) {
24159 return function() {
24160 var optedOut = false;
24161
24162 try {
24163 var token = getConfigValue.call(this, 'token');
24164 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
24165 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
24166 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
24167 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
24168
24169 if (token) { // if there was an issue getting the token, continue method execution as normal
24170 optedOut = hasOptedOut(token, {
24171 ignoreDnt: ignoreDnt,
24172 persistenceType: persistenceType,
24173 persistencePrefix: persistencePrefix,
24174 window: win
24175 });
24176 }
24177 } catch(err) {
24178 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
24179 }
24180
24181 if (!optedOut) {
24182 return method.apply(this, arguments);
24183 }
24184
24185 var callback = arguments[arguments.length - 1];
24186 if (typeof(callback) === 'function') {
24187 callback(0);
24188 }
24189
24190 return;
24191 };
24192 }
24193
24194 var logger$6 = console_with_prefix('lock');
24195
24196 /**
24197 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
24198 * window/tab at a time will be able to access shared resources.
24199 *
24200 * Based on the Alur and Taubenfeld fast lock
24201 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
24202 * with an added timeout to ensure there will be eventual progress in the event
24203 * that a window is closed in the middle of the callback.
24204 *
24205 * Implementation based on the original version by David Wolever (https://github.com/wolever)
24206 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
24207 *
24208 * @example
24209 * const myLock = new SharedLock('some-key');
24210 * myLock.withLock(function() {
24211 * console.log('I hold the mutex!');
24212 * });
24213 *
24214 * @constructor
24215 */
24216 var SharedLock = function(key, options) {
24217 options = options || {};
24218
24219 this.storageKey = key;
24220 this.storage = options.storage || win.localStorage;
24221 this.pollIntervalMS = options.pollIntervalMS || 100;
24222 this.timeoutMS = options.timeoutMS || 2000;
24223
24224 // dependency-inject promise implementation for testing purposes
24225 this.promiseImpl = options.promiseImpl || PromisePolyfill;
24226 };
24227
24228 // pass in a specific pid to test contention scenarios; otherwise
24229 // it is chosen randomly for each acquisition attempt
24230 SharedLock.prototype.withLock = function(lockedCB, pid) {
24231 var Promise = this.promiseImpl;
24232 return new Promise(_.bind(function (resolve, reject) {
24233 var i = pid || (new Date().getTime() + '|' + Math.random());
24234 var startTime = new Date().getTime();
24235 var key = this.storageKey;
24236 var pollIntervalMS = this.pollIntervalMS;
24237 var timeoutMS = this.timeoutMS;
24238 var storage = this.storage;
24239
24240 var keyX = key + ':X';
24241 var keyY = key + ':Y';
24242 var keyZ = key + ':Z';
24243
24244 var delay = function(cb) {
24245 if (new Date().getTime() - startTime > timeoutMS) {
24246 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
24247 storage.removeItem(keyZ);
24248 storage.removeItem(keyY);
24249 loop();
24250 return;
24251 }
24252 setTimeout(function() {
24253 try {
24254 cb();
24255 } catch(err) {
24256 reject(err);
24257 }
24258 }, pollIntervalMS * (Math.random() + 0.1));
24259 };
24260
24261 var waitFor = function(predicate, cb) {
24262 if (predicate()) {
24263 cb();
24264 } else {
24265 delay(function() {
24266 waitFor(predicate, cb);
24267 });
24268 }
24269 };
24270
24271 var getSetY = function() {
24272 var valY = storage.getItem(keyY);
24273 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
24274 return false;
24275 } else {
24276 storage.setItem(keyY, i);
24277 if (storage.getItem(keyY) === i) {
24278 return true;
24279 } else {
24280 if (!localStorageSupported(storage, true)) {
24281 reject(new Error('localStorage support dropped while acquiring lock'));
24282 }
24283 return false;
24284 }
24285 }
24286 };
24287
24288 var loop = function() {
24289 storage.setItem(keyX, i);
24290
24291 waitFor(getSetY, function() {
24292 if (storage.getItem(keyX) === i) {
24293 criticalSection();
24294 return;
24295 }
24296
24297 delay(function() {
24298 if (storage.getItem(keyY) !== i) {
24299 loop();
24300 return;
24301 }
24302 waitFor(function() {
24303 return !storage.getItem(keyZ);
24304 }, criticalSection);
24305 });
24306 });
24307 };
24308
24309 var criticalSection = function() {
24310 storage.setItem(keyZ, '1');
24311 var removeLock = function () {
24312 storage.removeItem(keyZ);
24313 if (storage.getItem(keyY) === i) {
24314 storage.removeItem(keyY);
24315 }
24316 if (storage.getItem(keyX) === i) {
24317 storage.removeItem(keyX);
24318 }
24319 };
24320
24321 lockedCB()
24322 .then(function (ret) {
24323 removeLock();
24324 resolve(ret);
24325 })
24326 .catch(function (err) {
24327 removeLock();
24328 reject(err);
24329 });
24330 };
24331
24332 try {
24333 if (localStorageSupported(storage, true)) {
24334 loop();
24335 } else {
24336 throw new Error('localStorage support check failed');
24337 }
24338 } catch(err) {
24339 reject(err);
24340 }
24341 }, this));
24342 };
24343
24344 /**
24345 * @type {import('./wrapper').StorageWrapper}
24346 */
24347 var LocalStorageWrapper = function (storageOverride) {
24348 this.storage = storageOverride || win.localStorage;
24349 };
24350
24351 LocalStorageWrapper.prototype.init = function () {
24352 return PromisePolyfill.resolve();
24353 };
24354
24355 LocalStorageWrapper.prototype.setItem = function (key, value) {
24356 return new PromisePolyfill(_.bind(function (resolve, reject) {
24357 try {
24358 this.storage.setItem(key, JSONStringify(value));
24359 } catch (e) {
24360 reject(e);
24361 }
24362 resolve();
24363 }, this));
24364 };
24365
24366 LocalStorageWrapper.prototype.getItem = function (key) {
24367 return new PromisePolyfill(_.bind(function (resolve, reject) {
24368 var item;
24369 try {
24370 item = JSONParse(this.storage.getItem(key));
24371 } catch (e) {
24372 reject(e);
24373 }
24374 resolve(item);
24375 }, this));
24376 };
24377
24378 LocalStorageWrapper.prototype.removeItem = function (key) {
24379 return new PromisePolyfill(_.bind(function (resolve, reject) {
24380 try {
24381 this.storage.removeItem(key);
24382 } catch (e) {
24383 reject(e);
24384 }
24385 resolve();
24386 }, this));
24387 };
24388
24389 var logger$5 = console_with_prefix('batch');
24390
24391 /**
24392 * RequestQueue: queue for batching API requests with localStorage backup for retries.
24393 * Maintains an in-memory queue which represents the source of truth for the current
24394 * page, but also writes all items out to a copy in the browser's localStorage, which
24395 * can be read on subsequent pageloads and retried. For batchability, all the request
24396 * items in the queue should be of the same type (events, people updates, group updates)
24397 * so they can be sent in a single request to the same API endpoint.
24398 *
24399 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
24400 * the same site to access the same persisted data, they must share the same localStorage
24401 * key (for instance based on project token and queue type). Therefore access to the
24402 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
24403 * simultaneously open windows/tabs from overwriting each other's data (which would lead
24404 * to data loss in some situations).
24405 * @constructor
24406 */
24407 var RequestQueue = function (storageKey, options) {
24408 options = options || {};
24409 this.storageKey = storageKey;
24410 this.usePersistence = options.usePersistence;
24411 if (this.usePersistence) {
24412 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
24413 this.lock = new SharedLock(storageKey, {
24414 storage: options.sharedLockStorage || win.localStorage,
24415 timeoutMS: options.sharedLockTimeoutMS,
24416 });
24417 }
24418 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
24419
24420 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
24421
24422 this.memQueue = [];
24423 this.initialized = false;
24424
24425 if (options.enqueueThrottleMs) {
24426 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
24427 } else {
24428 this.enqueuePersisted = _.bind(function (queueEntry) {
24429 return this._enqueuePersisted([queueEntry]);
24430 }, this);
24431 }
24432 };
24433
24434 RequestQueue.prototype.ensureInit = function () {
24435 if (this.initialized) {
24436 return PromisePolyfill.resolve();
24437 }
24438
24439 return this.queueStorage
24440 .init()
24441 .then(_.bind(function () {
24442 this.initialized = true;
24443 }, this))
24444 .catch(_.bind(function (err) {
24445 this.reportError('Error initializing queue persistence. Disabling persistence', err);
24446 this.initialized = true;
24447 this.usePersistence = false;
24448 }, this));
24449 };
24450
24451 /**
24452 * Add one item to queues (memory and localStorage). The queued entry includes
24453 * the given item along with an auto-generated ID and a "flush-after" timestamp.
24454 * It is expected that the item will be sent over the network and dequeued
24455 * before the flush-after time; if this doesn't happen it is considered orphaned
24456 * (e.g., the original tab where it was enqueued got closed before it could be
24457 * sent) and the item can be sent by any tab that finds it in localStorage.
24458 *
24459 * The final callback param is called with a param indicating success or
24460 * failure of the enqueue operation; it is asynchronous because the localStorage
24461 * lock is asynchronous.
24462 */
24463 RequestQueue.prototype.enqueue = function (item, flushInterval) {
24464 var queueEntry = {
24465 'id': cheap_guid(),
24466 'flushAfter': new Date().getTime() + flushInterval * 2,
24467 'payload': item
24468 };
24469
24470 if (!this.usePersistence) {
24471 this.memQueue.push(queueEntry);
24472 return PromisePolyfill.resolve(true);
24473 } else {
24474 return this.enqueuePersisted(queueEntry);
24475 }
24476 };
24477
24478 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
24479 var enqueueItem = _.bind(function () {
24480 return this.ensureInit()
24481 .then(_.bind(function () {
24482 return this.readFromStorage();
24483 }, this))
24484 .then(_.bind(function (storedQueue) {
24485 return this.saveToStorage(storedQueue.concat(queueEntries));
24486 }, this))
24487 .then(_.bind(function (succeeded) {
24488 // only add to in-memory queue when storage succeeds
24489 if (succeeded) {
24490 this.memQueue = this.memQueue.concat(queueEntries);
24491 }
24492
24493 return succeeded;
24494 }, this))
24495 .catch(_.bind(function (err) {
24496 this.reportError('Error enqueueing items', err, queueEntries);
24497 return false;
24498 }, this));
24499 }, this);
24500
24501 return this.lock
24502 .withLock(enqueueItem, this.pid)
24503 .catch(_.bind(function (err) {
24504 this.reportError('Error acquiring storage lock', err);
24505 return false;
24506 }, this));
24507 };
24508
24509 /**
24510 * Read out the given number of queue entries. If this.memQueue
24511 * has fewer than batchSize items, then look for "orphaned" items
24512 * in the persisted queue (items where the 'flushAfter' time has
24513 * already passed).
24514 */
24515 RequestQueue.prototype.fillBatch = function (batchSize) {
24516 var batch = this.memQueue.slice(0, batchSize);
24517 if (this.usePersistence && batch.length < batchSize) {
24518 // don't need lock just to read events; localStorage is thread-safe
24519 // and the worst that could happen is a duplicate send of some
24520 // orphaned events, which will be deduplicated on the server side
24521 return this.ensureInit()
24522 .then(_.bind(function () {
24523 return this.readFromStorage();
24524 }, this))
24525 .then(_.bind(function (storedQueue) {
24526 if (storedQueue.length) {
24527 // item IDs already in batch; don't duplicate out of storage
24528 var idsInBatch = {}; // poor man's Set
24529 _.each(batch, function (item) {
24530 idsInBatch[item['id']] = true;
24531 });
24532
24533 for (var i = 0; i < storedQueue.length; i++) {
24534 var item = storedQueue[i];
24535 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
24536 item.orphaned = true;
24537 batch.push(item);
24538 if (batch.length >= batchSize) {
24539 break;
24540 }
24541 }
24542 }
24543 }
24544
24545 return batch;
24546 }, this));
24547 } else {
24548 return PromisePolyfill.resolve(batch);
24549 }
24550 };
24551
24552 /**
24553 * Remove items with matching 'id' from array (immutably)
24554 * also remove any item without a valid id (e.g., malformed
24555 * storage entries).
24556 */
24557 var filterOutIDsAndInvalid = function (items, idSet) {
24558 var filteredItems = [];
24559 _.each(items, function (item) {
24560 if (item['id'] && !idSet[item['id']]) {
24561 filteredItems.push(item);
24562 }
24563 });
24564 return filteredItems;
24565 };
24566
24567 /**
24568 * Remove items with matching IDs from both in-memory queue
24569 * and persisted queue
24570 */
24571 RequestQueue.prototype.removeItemsByID = function (ids) {
24572 var idSet = {}; // poor man's Set
24573 _.each(ids, function (id) {
24574 idSet[id] = true;
24575 });
24576
24577 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
24578 if (!this.usePersistence) {
24579 return PromisePolyfill.resolve(true);
24580 } else {
24581 var removeFromStorage = _.bind(function () {
24582 return this.ensureInit()
24583 .then(_.bind(function () {
24584 return this.readFromStorage();
24585 }, this))
24586 .then(_.bind(function (storedQueue) {
24587 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
24588 return this.saveToStorage(storedQueue);
24589 }, this))
24590 .then(_.bind(function () {
24591 return this.readFromStorage();
24592 }, this))
24593 .then(_.bind(function (storedQueue) {
24594 // an extra check: did storage report success but somehow
24595 // the items are still there?
24596 for (var i = 0; i < storedQueue.length; i++) {
24597 var item = storedQueue[i];
24598 if (item['id'] && !!idSet[item['id']]) {
24599 throw new Error('Item not removed from storage');
24600 }
24601 }
24602 return true;
24603 }, this))
24604 .catch(_.bind(function (err) {
24605 this.reportError('Error removing items', err, ids);
24606 return false;
24607 }, this));
24608 }, this);
24609
24610 return this.lock
24611 .withLock(removeFromStorage, this.pid)
24612 .catch(_.bind(function (err) {
24613 this.reportError('Error acquiring storage lock', err);
24614 if (!localStorageSupported(this.lock.storage, true)) {
24615 // Looks like localStorage writes have stopped working sometime after
24616 // initialization (probably full), and so nobody can acquire locks
24617 // anymore. Consider it temporarily safe to remove items without the
24618 // lock, since nobody's writing successfully anyway.
24619 return removeFromStorage()
24620 .then(_.bind(function (success) {
24621 if (!success) {
24622 // OK, we couldn't even write out the smaller queue. Try clearing it
24623 // entirely.
24624 return this.queueStorage.removeItem(this.storageKey).then(function () {
24625 return success;
24626 });
24627 }
24628 return success;
24629 }, this))
24630 .catch(_.bind(function (err) {
24631 this.reportError('Error clearing queue', err);
24632 return false;
24633 }, this));
24634 } else {
24635 return false;
24636 }
24637 }, this));
24638 }
24639 };
24640
24641 // internal helper for RequestQueue.updatePayloads
24642 var updatePayloads = function (existingItems, itemsToUpdate) {
24643 var newItems = [];
24644 _.each(existingItems, function (item) {
24645 var id = item['id'];
24646 if (id in itemsToUpdate) {
24647 var newPayload = itemsToUpdate[id];
24648 if (newPayload !== null) {
24649 item['payload'] = newPayload;
24650 newItems.push(item);
24651 }
24652 } else {
24653 // no update
24654 newItems.push(item);
24655 }
24656 });
24657 return newItems;
24658 };
24659
24660 /**
24661 * Update payloads of given items in both in-memory queue and
24662 * persisted queue. Items set to null are removed from queues.
24663 */
24664 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
24665 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
24666 if (!this.usePersistence) {
24667 return PromisePolyfill.resolve(true);
24668 } else {
24669 return this.lock
24670 .withLock(_.bind(function lockAcquired() {
24671 return this.ensureInit()
24672 .then(_.bind(function () {
24673 return this.readFromStorage();
24674 }, this))
24675 .then(_.bind(function (storedQueue) {
24676 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
24677 return this.saveToStorage(storedQueue);
24678 }, this))
24679 .catch(_.bind(function (err) {
24680 this.reportError('Error updating items', itemsToUpdate, err);
24681 return false;
24682 }, this));
24683 }, this), this.pid)
24684 .catch(_.bind(function (err) {
24685 this.reportError('Error acquiring storage lock', err);
24686 return false;
24687 }, this));
24688 }
24689 };
24690
24691 /**
24692 * Read and parse items array from localStorage entry, handling
24693 * malformed/missing data if necessary.
24694 */
24695 RequestQueue.prototype.readFromStorage = function () {
24696 return this.ensureInit()
24697 .then(_.bind(function () {
24698 return this.queueStorage.getItem(this.storageKey);
24699 }, this))
24700 .then(_.bind(function (storageEntry) {
24701 if (storageEntry) {
24702 if (!_.isArray(storageEntry)) {
24703 this.reportError('Invalid storage entry:', storageEntry);
24704 storageEntry = null;
24705 }
24706 }
24707 return storageEntry || [];
24708 }, this))
24709 .catch(_.bind(function (err) {
24710 this.reportError('Error retrieving queue', err);
24711 return [];
24712 }, this));
24713 };
24714
24715 /**
24716 * Serialize the given items array to localStorage.
24717 */
24718 RequestQueue.prototype.saveToStorage = function (queue) {
24719 return this.ensureInit()
24720 .then(_.bind(function () {
24721 return this.queueStorage.setItem(this.storageKey, queue);
24722 }, this))
24723 .then(function () {
24724 return true;
24725 })
24726 .catch(_.bind(function (err) {
24727 this.reportError('Error saving queue', err);
24728 return false;
24729 }, this));
24730 };
24731
24732 /**
24733 * Clear out queues (memory and localStorage).
24734 */
24735 RequestQueue.prototype.clear = function () {
24736 this.memQueue = [];
24737
24738 if (this.usePersistence) {
24739 return this.ensureInit()
24740 .then(_.bind(function () {
24741 return this.queueStorage.removeItem(this.storageKey);
24742 }, this));
24743 } else {
24744 return PromisePolyfill.resolve();
24745 }
24746 };
24747
24748 // maximum interval between request retries after exponential backoff
24749 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
24750
24751 var logger$4 = console_with_prefix('batch');
24752
24753 /**
24754 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
24755 * type (events, people, groups).
24756 * Uses RequestQueue to manage the backing store.
24757 * @constructor
24758 */
24759 var RequestBatcher = function(storageKey, options) {
24760 this.errorReporter = options.errorReporter;
24761 this.queue = new RequestQueue(storageKey, {
24762 errorReporter: _.bind(this.reportError, this),
24763 queueStorage: options.queueStorage,
24764 sharedLockStorage: options.sharedLockStorage,
24765 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
24766 usePersistence: options.usePersistence,
24767 enqueueThrottleMs: options.enqueueThrottleMs
24768 });
24769
24770 this.libConfig = options.libConfig;
24771 this.sendRequest = options.sendRequestFunc;
24772 this.beforeSendHook = options.beforeSendHook;
24773 this.stopAllBatching = options.stopAllBatchingFunc;
24774
24775 // seed variable batch size + flush interval with configured values
24776 this.batchSize = this.libConfig['batch_size'];
24777 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
24778
24779 this.stopped = !this.libConfig['batch_autostart'];
24780 this.consecutiveRemovalFailures = 0;
24781
24782 // extra client-side dedupe
24783 this.itemIdsSentSuccessfully = {};
24784
24785 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
24786 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
24787 // in a request loop and get ratelimited by the server.
24788 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
24789
24790 this._flushPromise = null;
24791 };
24792
24793 /**
24794 * Add one item to queue.
24795 */
24796 RequestBatcher.prototype.enqueue = function(item) {
24797 return this.queue.enqueue(item, this.flushInterval);
24798 };
24799
24800 /**
24801 * Start flushing batches at the configured time interval. Must call
24802 * this method upon SDK init in order to send anything over the network.
24803 */
24804 RequestBatcher.prototype.start = function() {
24805 this.stopped = false;
24806 this.consecutiveRemovalFailures = 0;
24807 return this.flush();
24808 };
24809
24810 /**
24811 * Stop flushing batches. Can be restarted by calling start().
24812 */
24813 RequestBatcher.prototype.stop = function() {
24814 this.stopped = true;
24815 if (this.timeoutID) {
24816 clearTimeout(this.timeoutID);
24817 this.timeoutID = null;
24818 }
24819 };
24820
24821 /**
24822 * Clear out queue.
24823 */
24824 RequestBatcher.prototype.clear = function() {
24825 return this.queue.clear();
24826 };
24827
24828 /**
24829 * Restore batch size configuration to whatever is set in the main SDK.
24830 */
24831 RequestBatcher.prototype.resetBatchSize = function() {
24832 this.batchSize = this.libConfig['batch_size'];
24833 };
24834
24835 /**
24836 * Restore flush interval time configuration to whatever is set in the main SDK.
24837 */
24838 RequestBatcher.prototype.resetFlush = function() {
24839 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
24840 };
24841
24842 /**
24843 * Schedule the next flush in the given number of milliseconds.
24844 */
24845 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
24846 this.flushInterval = flushMS;
24847 if (!this.stopped) { // don't schedule anymore if batching has been stopped
24848 this.timeoutID = setTimeout(_.bind(function() {
24849 if (!this.stopped) {
24850 this._flushPromise = this.flush();
24851 }
24852 }, this), this.flushInterval);
24853 }
24854 };
24855
24856 /**
24857 * Send a request using the sendRequest callback, but promisified.
24858 * TODO: sendRequest should be promisified in the first place.
24859 */
24860 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
24861 return new PromisePolyfill(_.bind(function(resolve) {
24862 this.sendRequest(data, options, resolve);
24863 }, this));
24864 };
24865
24866
24867 /**
24868 * Flush one batch to network. Depending on success/failure modes, it will either
24869 * remove the batch from the queue or leave it in for retry, and schedule the next
24870 * flush. In cases of most network or API failures, it will back off exponentially
24871 * when retrying.
24872 * @param {Object} [options]
24873 * @param {boolean} [options.sendBeacon] - whether to send batch with
24874 * navigator.sendBeacon (only useful for sending batches before page unloads, as
24875 * sendBeacon offers no callbacks or status indications)
24876 */
24877 RequestBatcher.prototype.flush = function(options) {
24878 if (this.requestInProgress) {
24879 logger$4.log('Flush: Request already in progress');
24880 return PromisePolyfill.resolve();
24881 }
24882
24883 this.requestInProgress = true;
24884
24885 options = options || {};
24886 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
24887 var startTime = new Date().getTime();
24888 var currentBatchSize = this.batchSize;
24889
24890 return this.queue.fillBatch(currentBatchSize)
24891 .then(_.bind(function(batch) {
24892
24893 // if there's more items in the queue than the batch size, attempt
24894 // to flush again after the current batch is done.
24895 var attemptSecondaryFlush = batch.length === currentBatchSize;
24896 var dataForRequest = [];
24897 var transformedItems = {};
24898 _.each(batch, function(item) {
24899 var payload = item['payload'];
24900 if (this.beforeSendHook && !item.orphaned) {
24901 payload = this.beforeSendHook(payload);
24902 }
24903 if (payload) {
24904 // mp_sent_by_lib_version prop captures which lib version actually
24905 // sends each event (regardless of which version originally queued
24906 // it for sending)
24907 if (payload['event'] && payload['properties']) {
24908 payload['properties'] = _.extend(
24909 {},
24910 payload['properties'],
24911 {'mp_sent_by_lib_version': Config.LIB_VERSION}
24912 );
24913 }
24914 var addPayload = true;
24915 var itemId = item['id'];
24916 if (itemId) {
24917 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
24918 this.reportError('[dupe] item ID sent too many times, not sending', {
24919 item: item,
24920 batchSize: batch.length,
24921 timesSent: this.itemIdsSentSuccessfully[itemId]
24922 });
24923 addPayload = false;
24924 }
24925 } else {
24926 this.reportError('[dupe] found item with no ID', {item: item});
24927 }
24928
24929 if (addPayload) {
24930 dataForRequest.push(payload);
24931 }
24932 }
24933 transformedItems[item['id']] = payload;
24934 }, this);
24935
24936 if (dataForRequest.length < 1) {
24937 this.requestInProgress = false;
24938 this.resetFlush();
24939 return PromisePolyfill.resolve(); // nothing to do
24940 }
24941
24942 var removeItemsFromQueue = _.bind(function () {
24943 return this.queue
24944 .removeItemsByID(
24945 _.map(batch, function (item) {
24946 return item['id'];
24947 })
24948 )
24949 .then(_.bind(function (succeeded) {
24950 // client-side dedupe
24951 _.each(batch, _.bind(function(item) {
24952 var itemId = item['id'];
24953 if (itemId) {
24954 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
24955 this.itemIdsSentSuccessfully[itemId]++;
24956 if (this.itemIdsSentSuccessfully[itemId] > 5) {
24957 this.reportError('[dupe] item ID sent too many times', {
24958 item: item,
24959 batchSize: batch.length,
24960 timesSent: this.itemIdsSentSuccessfully[itemId]
24961 });
24962 }
24963 } else {
24964 this.reportError('[dupe] found item with no ID while removing', {item: item});
24965 }
24966 }, this));
24967
24968 if (succeeded) {
24969 this.consecutiveRemovalFailures = 0;
24970 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
24971 this.resetFlush(); // schedule next batch with a delay
24972 return PromisePolyfill.resolve();
24973 } else {
24974 return this.flush(); // handle next batch if the queue isn't empty
24975 }
24976 } else {
24977 if (++this.consecutiveRemovalFailures > 5) {
24978 this.reportError('Too many queue failures; disabling batching system.');
24979 this.stopAllBatching();
24980 } else {
24981 this.resetFlush();
24982 }
24983 return PromisePolyfill.resolve();
24984 }
24985 }, this));
24986 }, this);
24987
24988 var batchSendCallback = _.bind(function(res) {
24989 this.requestInProgress = false;
24990
24991 try {
24992
24993 // handle API response in a try-catch to make sure we can reset the
24994 // flush operation if something goes wrong
24995
24996 if (options.unloading) {
24997 // update persisted data to include hook transformations
24998 return this.queue.updatePayloads(transformedItems);
24999 } else if (
25000 _.isObject(res) &&
25001 res.error === 'timeout' &&
25002 new Date().getTime() - startTime >= timeoutMS
25003 ) {
25004 this.reportError('Network timeout; retrying');
25005 return this.flush();
25006 } else if (
25007 _.isObject(res) &&
25008 (
25009 res.httpStatusCode >= 500
25010 || res.httpStatusCode === 429
25011 || (res.httpStatusCode <= 0 && !isOnline())
25012 || res.error === 'timeout'
25013 )
25014 ) {
25015 // network or API error, or 429 Too Many Requests, retry
25016 var retryMS = this.flushInterval * 2;
25017 if (res.retryAfter) {
25018 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25019 }
25020 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25021 this.reportError('Error; retry in ' + retryMS + ' ms');
25022 this.scheduleFlush(retryMS);
25023 return PromisePolyfill.resolve();
25024 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25025 // 413 Payload Too Large
25026 if (batch.length > 1) {
25027 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25028 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25029 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25030 this.resetFlush();
25031 return PromisePolyfill.resolve();
25032 } else {
25033 this.reportError('Single-event request too large; dropping', batch);
25034 this.resetBatchSize();
25035 return removeItemsFromQueue();
25036 }
25037 } else {
25038 // successful network request+response; remove each item in batch from queue
25039 // (even if it was e.g. a 400, in which case retrying won't help)
25040 return removeItemsFromQueue();
25041 }
25042 } catch(err) {
25043 this.reportError('Error handling API response', err);
25044 this.resetFlush();
25045 }
25046 }, this);
25047 var requestOptions = {
25048 method: 'POST',
25049 verbose: true,
25050 ignore_json_errors: true, // eslint-disable-line camelcase
25051 timeout_ms: timeoutMS // eslint-disable-line camelcase
25052 };
25053 if (options.unloading) {
25054 requestOptions.transport = 'sendBeacon';
25055 }
25056 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25057 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25058 }, this))
25059 .catch(_.bind(function(err) {
25060 this.reportError('Error flushing request queue', err);
25061 this.resetFlush();
25062 }, this));
25063 };
25064
25065 /**
25066 * Log error to global logger and optional user-defined logger.
25067 */
25068 RequestBatcher.prototype.reportError = function(msg, err) {
25069 logger$4.error.apply(logger$4.error, arguments);
25070 if (this.errorReporter) {
25071 try {
25072 if (!(err instanceof Error)) {
25073 err = new Error(msg);
25074 }
25075 this.errorReporter(msg, err);
25076 } catch(err) {
25077 logger$4.error(err);
25078 }
25079 }
25080 };
25081
25082 /**
25083 * @param {import('./session-recording').SerializedRecording} serializedRecording
25084 * @returns {boolean}
25085 */
25086 var isRecordingExpired = function(serializedRecording) {
25087 var now = Date.now();
25088 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25089 };
25090
25091 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25092
25093 var logger$3 = console_with_prefix('recorder');
25094 var CompressionStream = win['CompressionStream'];
25095
25096 var RECORDER_BATCHER_LIB_CONFIG = {
25097 'batch_size': 1000,
25098 'batch_flush_interval_ms': 10 * 1000,
25099 'batch_request_timeout_ms': 90 * 1000,
25100 'batch_autostart': true
25101 };
25102
25103 var ACTIVE_SOURCES = new Set([
25104 IncrementalSource.MouseMove,
25105 IncrementalSource.MouseInteraction,
25106 IncrementalSource.Scroll,
25107 IncrementalSource.ViewportResize,
25108 IncrementalSource.Input,
25109 IncrementalSource.TouchMove,
25110 IncrementalSource.MediaInteraction,
25111 IncrementalSource.Drag,
25112 IncrementalSource.Selection,
25113 ]);
25114
25115 function isUserEvent(ev) {
25116 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25117 }
25118
25119 /**
25120 * @typedef {Object} SerializedRecording
25121 * @property {number} idleExpires
25122 * @property {number} maxExpires
25123 * @property {number} replayStartTime
25124 * @property {number} seqNo
25125 * @property {string} batchStartUrl
25126 * @property {string} replayId
25127 * @property {string} tabId
25128 * @property {string} replayStartUrl
25129 */
25130
25131 /**
25132 * @typedef {Object} SessionRecordingOptions
25133 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25134 * @property {String} [options.replayId] - unique uuid for a single replay
25135 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
25136 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
25137 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
25138 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
25139 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
25140 * optional properties for deserialization:
25141 * @property {number} idleExpires
25142 * @property {number} maxExpires
25143 * @property {number} replayStartTime
25144 * @property {number} seqNo
25145 * @property {string} batchStartUrl
25146 * @property {string} replayStartUrl
25147 */
25148
25149
25150 /**
25151 * This class encapsulates a single session recording and its lifecycle.
25152 * @param {SessionRecordingOptions} options
25153 */
25154 var SessionRecording = function(options) {
25155 this._mixpanel = options.mixpanelInstance;
25156 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
25157 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
25158 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
25159 this._rrwebRecord = options.rrwebRecord || null;
25160
25161 // internal rrweb stopRecording function
25162 this._stopRecording = null;
25163 this.replayId = options.replayId;
25164
25165 this.batchStartUrl = options.batchStartUrl || null;
25166 this.replayStartUrl = options.replayStartUrl || null;
25167 this.idleExpires = options.idleExpires || null;
25168 this.maxExpires = options.maxExpires || null;
25169 this.replayStartTime = options.replayStartTime || null;
25170 this.seqNo = options.seqNo || 0;
25171
25172 this.idleTimeoutId = null;
25173 this.maxTimeoutId = null;
25174
25175 this.recordMaxMs = MAX_RECORDING_MS;
25176 this.recordMinMs = 0;
25177
25178 // disable persistence if localStorage is not supported
25179 // request-queue will automatically disable persistence if indexedDB fails to initialize
25180 var usePersistence = localStorageSupported(options.sharedLockStorage, true);
25181
25182 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
25183 // this will be important when persistence is introduced
25184 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
25185 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
25186 this.batcher = new RequestBatcher(this.batcherKey, {
25187 errorReporter: this.reportError.bind(this),
25188 flushOnlyOnInterval: true,
25189 libConfig: RECORDER_BATCHER_LIB_CONFIG,
25190 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
25191 queueStorage: this.queueStorage,
25192 sharedLockStorage: options.sharedLockStorage,
25193 usePersistence: usePersistence,
25194 stopAllBatchingFunc: this.stopRecording.bind(this),
25195
25196 // increased throttle and shared lock timeout because recording events are very high frequency.
25197 // this will minimize the amount of lock contention between enqueued events.
25198 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
25199 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
25200 sharedLockTimeoutMS: 10 * 1000,
25201 });
25202 };
25203
25204 SessionRecording.prototype.unloadPersistedData = function () {
25205 this.batcher.stop();
25206 return this.batcher.flush()
25207 .then(function () {
25208 return this.queueStorage.removeItem(this.batcherKey);
25209 }.bind(this));
25210 };
25211
25212 SessionRecording.prototype.getConfig = function(configVar) {
25213 return this._mixpanel.get_config(configVar);
25214 };
25215
25216 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
25217 // reaches into this class instance and expects the snake case version of the function.
25218 // eslint-disable-next-line camelcase
25219 SessionRecording.prototype.get_config = function(configVar) {
25220 return this.getConfig(configVar);
25221 };
25222
25223 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
25224 if (this._rrwebRecord === null) {
25225 this.reportError('rrweb record function not provided. ');
25226 return;
25227 }
25228
25229 if (this._stopRecording !== null) {
25230 logger$3.log('Recording already in progress, skipping startRecording.');
25231 return;
25232 }
25233
25234 this.recordMaxMs = this.getConfig('record_max_ms');
25235 if (this.recordMaxMs > MAX_RECORDING_MS) {
25236 this.recordMaxMs = MAX_RECORDING_MS;
25237 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
25238 }
25239
25240 if (!this.maxExpires) {
25241 this.maxExpires = new Date().getTime() + this.recordMaxMs;
25242 }
25243
25244 this.recordMinMs = this.getConfig('record_min_ms');
25245 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
25246 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
25247 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
25248 }
25249
25250 if (!this.replayStartTime) {
25251 this.replayStartTime = new Date().getTime();
25252 this.batchStartUrl = _.info.currentUrl();
25253 this.replayStartUrl = _.info.currentUrl();
25254 }
25255
25256 if (shouldStopBatcher || this.recordMinMs > 0) {
25257 // the primary case for shouldStopBatcher is when we're starting recording after a reset
25258 // and don't want to send anything over the network until there's
25259 // actual user activity
25260 // this also applies if the minimum recording length has not been hit yet
25261 // so that we don't send data until we know the recording will be long enough
25262 this.batcher.stop();
25263 } else {
25264 this.batcher.start();
25265 }
25266
25267 var resetIdleTimeout = function () {
25268 clearTimeout(this.idleTimeoutId);
25269 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
25270 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
25271 this.idleExpires = new Date().getTime() + idleTimeoutMs;
25272 }.bind(this);
25273 resetIdleTimeout();
25274
25275 var blockSelector = this.getConfig('record_block_selector');
25276 if (blockSelector === '' || blockSelector === null) {
25277 blockSelector = undefined;
25278 }
25279
25280 try {
25281 this._stopRecording = this._rrwebRecord({
25282 'emit': function (ev) {
25283 if (this.idleExpires && this.idleExpires < ev.timestamp) {
25284 this._onIdleTimeout();
25285 return;
25286 }
25287 if (isUserEvent(ev)) {
25288 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
25289 // start flushing again after user activity
25290 this.batcher.start();
25291 }
25292 resetIdleTimeout();
25293 }
25294 // promise only used to await during tests
25295 this.__enqueuePromise = this.batcher.enqueue(ev);
25296 }.bind(this),
25297 'blockClass': this.getConfig('record_block_class'),
25298 'blockSelector': blockSelector,
25299 'collectFonts': this.getConfig('record_collect_fonts'),
25300 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
25301 'type': 'image/webp',
25302 'quality': 0.6
25303 },
25304 'maskAllInputs': true,
25305 'maskTextClass': this.getConfig('record_mask_text_class'),
25306 'maskTextSelector': this.getConfig('record_mask_text_selector'),
25307 'recordCanvas': this.getConfig('record_canvas'),
25308 'sampling': {
25309 'canvas': 15
25310 }
25311 });
25312 } catch (err) {
25313 this.reportError('Unexpected error when starting rrweb recording.', err);
25314 }
25315
25316 if (typeof this._stopRecording !== 'function') {
25317 this.reportError('rrweb failed to start, skipping this recording.');
25318 this._stopRecording = null;
25319 this.stopRecording(); // stop batcher looping and any timeouts
25320 return;
25321 }
25322
25323 var maxTimeoutMs = this.maxExpires - new Date().getTime();
25324 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
25325 };
25326
25327 SessionRecording.prototype.stopRecording = function (skipFlush) {
25328 if (!this.isRrwebStopped()) {
25329 try {
25330 this._stopRecording();
25331 } catch (err) {
25332 this.reportError('Error with rrweb stopRecording', err);
25333 }
25334 this._stopRecording = null;
25335 }
25336
25337 var flushPromise;
25338 if (this.batcher.stopped) {
25339 // never got user activity to flush after reset, so just clear the batcher
25340 flushPromise = this.batcher.clear();
25341 } else if (!skipFlush) {
25342 // flush any remaining events from running batcher
25343 flushPromise = this.batcher.flush();
25344 }
25345 this.batcher.stop();
25346
25347 clearTimeout(this.idleTimeoutId);
25348 clearTimeout(this.maxTimeoutId);
25349 return flushPromise;
25350 };
25351
25352 SessionRecording.prototype.isRrwebStopped = function () {
25353 return this._stopRecording === null;
25354 };
25355
25356
25357 /**
25358 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
25359 * we stop recording and dump any queued events if the user has opted out.
25360 */
25361 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
25362 var onOptOut = function (code) {
25363 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
25364 if (code === 0) {
25365 this.stopRecording();
25366 cb({error: 'Tracking has been opted out, stopping recording.'});
25367 }
25368 }.bind(this);
25369
25370 this._flushEvents(data, options, cb, onOptOut);
25371 };
25372
25373 /**
25374 * @returns {SerializedRecording}
25375 */
25376 SessionRecording.prototype.serialize = function () {
25377 // don't break if mixpanel instance was destroyed at some point
25378 var tabId;
25379 try {
25380 tabId = this._mixpanel.get_tab_id();
25381 } catch (e) {
25382 this.reportError('Error getting tab ID for serialization ', e);
25383 tabId = null;
25384 }
25385
25386 return {
25387 'replayId': this.replayId,
25388 'seqNo': this.seqNo,
25389 'replayStartTime': this.replayStartTime,
25390 'batchStartUrl': this.batchStartUrl,
25391 'replayStartUrl': this.replayStartUrl,
25392 'idleExpires': this.idleExpires,
25393 'maxExpires': this.maxExpires,
25394 'tabId': tabId,
25395 };
25396 };
25397
25398
25399 /**
25400 * @static
25401 * @param {SerializedRecording} serializedRecording
25402 * @param {SessionRecordingOptions} options
25403 * @returns {SessionRecording}
25404 */
25405 SessionRecording.deserialize = function (serializedRecording, options) {
25406 var recording = new SessionRecording(_.extend({}, options, {
25407 replayId: serializedRecording['replayId'],
25408 batchStartUrl: serializedRecording['batchStartUrl'],
25409 replayStartUrl: serializedRecording['replayStartUrl'],
25410 idleExpires: serializedRecording['idleExpires'],
25411 maxExpires: serializedRecording['maxExpires'],
25412 replayStartTime: serializedRecording['replayStartTime'],
25413 seqNo: serializedRecording['seqNo'],
25414 sharedLockStorage: options.sharedLockStorage,
25415 }));
25416
25417 return recording;
25418 };
25419
25420 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
25421 var onSuccess = function (response, responseBody) {
25422 // Update batch specific props only if the request was successful to guarantee ordering.
25423 // RequestBatcher will always flush the next batch after the previous one succeeds.
25424 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
25425 if (response.status === 200 && this.replayId === currentReplayId) {
25426 this.seqNo++;
25427 this.batchStartUrl = _.info.currentUrl();
25428 }
25429
25430 this._onBatchSent();
25431 callback({
25432 status: 0,
25433 httpStatusCode: response.status,
25434 responseBody: responseBody,
25435 retryAfter: response.headers.get('Retry-After')
25436 });
25437 }.bind(this);
25438
25439 win['fetch'](this.getConfig('api_host') + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
25440 'method': 'POST',
25441 'headers': {
25442 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
25443 'Content-Type': 'application/octet-stream'
25444 },
25445 'body': reqBody,
25446 }).then(function (response) {
25447 response.json().then(function (responseBody) {
25448 onSuccess(response, responseBody);
25449 }).catch(function (error) {
25450 callback({error: error});
25451 });
25452 }).catch(function (error) {
25453 callback({error: error, httpStatusCode: 0});
25454 });
25455 };
25456
25457 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
25458 var numEvents = data.length;
25459
25460 if (numEvents > 0) {
25461 var replayId = this.replayId;
25462
25463 // each rrweb event has a timestamp - leverage those to get time properties
25464 var batchStartTime = Infinity;
25465 var batchEndTime = -Infinity;
25466 var hasFullSnapshot = false;
25467 for (var i = 0; i < numEvents; i++) {
25468 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
25469 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
25470 if (data[i].type === EventType.FullSnapshot) {
25471 hasFullSnapshot = true;
25472 }
25473 }
25474
25475 if (this.seqNo === 0) {
25476 if (!hasFullSnapshot) {
25477 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
25478 this.stopRecording(true);
25479 return;
25480 }
25481 this.replayStartTime = batchStartTime;
25482 } else if (!this.replayStartTime) {
25483 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
25484 this.replayStartTime = batchStartTime;
25485 }
25486
25487 var replayLengthMs = batchEndTime - this.replayStartTime;
25488
25489 var reqParams = {
25490 '$current_url': this.batchStartUrl,
25491 '$lib_version': Config.LIB_VERSION,
25492 'batch_start_time': batchStartTime / 1000,
25493 'distinct_id': String(this._mixpanel.get_distinct_id()),
25494 'mp_lib': 'web',
25495 'replay_id': replayId,
25496 'replay_length_ms': replayLengthMs,
25497 'replay_start_time': this.replayStartTime / 1000,
25498 'replay_start_url': this.replayStartUrl,
25499 'seq': this.seqNo
25500 };
25501 var eventsJson = JSON.stringify(data);
25502
25503 // send ID management props if they exist
25504 var deviceId = this._mixpanel.get_property('$device_id');
25505 if (deviceId) {
25506 reqParams['$device_id'] = deviceId;
25507 }
25508 var userId = this._mixpanel.get_property('$user_id');
25509 if (userId) {
25510 reqParams['$user_id'] = userId;
25511 }
25512
25513 if (CompressionStream) {
25514 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
25515 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
25516 new Response(gzipStream)
25517 .blob()
25518 .then(function(compressedBlob) {
25519 reqParams['format'] = 'gzip';
25520 this._sendRequest(replayId, reqParams, compressedBlob, callback);
25521 }.bind(this));
25522 } else {
25523 reqParams['format'] = 'body';
25524 this._sendRequest(replayId, reqParams, eventsJson, callback);
25525 }
25526 }
25527 });
25528
25529
25530 SessionRecording.prototype.reportError = function(msg, err) {
25531 logger$3.error.apply(logger$3.error, arguments);
25532 try {
25533 if (!err && !(msg instanceof Error)) {
25534 msg = new Error(msg);
25535 }
25536 this.getConfig('error_reporter')(msg, err);
25537 } catch(err) {
25538 logger$3.error(err);
25539 }
25540 };
25541
25542 /**
25543 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
25544 * Makes sure that only one tab can be recording at a time.
25545 */
25546 var RecordingRegistry = function (options) {
25547 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
25548 this.errorReporter = options.errorReporter;
25549 this.mixpanelInstance = options.mixpanelInstance;
25550 this.sharedLockStorage = options.sharedLockStorage;
25551 };
25552
25553 RecordingRegistry.prototype.handleError = function (err) {
25554 this.errorReporter('IndexedDB error: ', err);
25555 };
25556
25557 /**
25558 * @param {import('./session-recording').SerializedRecording} serializedRecording
25559 */
25560 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
25561 var tabId = serializedRecording['tabId'];
25562 if (!tabId) {
25563 console.warn('No tab ID is set, cannot persist recording metadata.');
25564 return PromisePolyfill.resolve();
25565 }
25566
25567 return this.idb.init()
25568 .then(function () {
25569 return this.idb.setItem(tabId, serializedRecording);
25570 }.bind(this))
25571 .catch(this.handleError.bind(this));
25572 };
25573
25574 /**
25575 * @returns {Promise<import('./session-recording').SerializedRecording>}
25576 */
25577 RecordingRegistry.prototype.getActiveRecording = function () {
25578 return this.idb.init()
25579 .then(function () {
25580 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
25581 }.bind(this))
25582 .then(function (serializedRecording) {
25583 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
25584 }.bind(this))
25585 .catch(this.handleError.bind(this));
25586 };
25587
25588 RecordingRegistry.prototype.clearActiveRecording = function () {
25589 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
25590 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
25591 return this.getActiveRecording()
25592 .then(function (serializedRecording) {
25593 if (serializedRecording) {
25594 serializedRecording['maxExpires'] = 0;
25595 return this.setActiveRecording(serializedRecording);
25596 }
25597 }.bind(this))
25598 .catch(this.handleError.bind(this));
25599 };
25600
25601 /**
25602 * Flush any inactive recordings from the registry to minimize data loss.
25603 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
25604 */
25605 RecordingRegistry.prototype.flushInactiveRecordings = function () {
25606 return this.idb.init()
25607 .then(function() {
25608 return this.idb.getAll();
25609 }.bind(this))
25610 .then(function (serializedRecordings) {
25611 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
25612 var unloadPromises = serializedRecordings
25613 .filter(function (serializedRecording) {
25614 return isRecordingExpired(serializedRecording);
25615 })
25616 .map(function (serializedRecording) {
25617 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
25618 mixpanelInstance: this.mixpanelInstance,
25619 sharedLockStorage: this.sharedLockStorage
25620 });
25621 return sessionRecording.unloadPersistedData()
25622 .then(function () {
25623 // expired recording was successfully flushed, we can clean it up from the registry
25624 return this.idb.removeItem(serializedRecording['tabId']);
25625 }.bind(this))
25626 .catch(this.handleError.bind(this));
25627 }.bind(this));
25628
25629 return PromisePolyfill.all(unloadPromises);
25630 }.bind(this))
25631 .catch(this.handleError.bind(this));
25632 };
25633
25634 var logger$2 = console_with_prefix('recorder');
25635
25636 /**
25637 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
25638 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25639 */
25640 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
25641 this.mixpanelInstance = mixpanelInstance;
25642 this.rrwebRecord = rrwebRecord || record;
25643 this.sharedLockStorage = sharedLockStorage;
25644
25645 /**
25646 * @member {import('./registry').RecordingRegistry}
25647 */
25648 this.recordingRegistry = new RecordingRegistry({
25649 mixpanelInstance: this.mixpanelInstance,
25650 errorReporter: logger$2.error,
25651 sharedLockStorage: sharedLockStorage
25652 });
25653 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
25654
25655 this.activeRecording = null;
25656 };
25657
25658 MixpanelRecorder.prototype.startRecording = function(options) {
25659 options = options || {};
25660 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
25661 logger$2.log('Recording already in progress, skipping startRecording.');
25662 return;
25663 }
25664
25665 var onIdleTimeout = function () {
25666 logger$2.log('Idle timeout reached, restarting recording.');
25667 this.resetRecording();
25668 }.bind(this);
25669
25670 var onMaxLengthReached = function () {
25671 logger$2.log('Max recording length reached, stopping recording.');
25672 this.resetRecording();
25673 }.bind(this);
25674
25675 var onBatchSent = function () {
25676 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
25677 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
25678 }.bind(this);
25679
25680 /**
25681 * @type {import('./session-recording').SessionRecordingOptions}
25682 */
25683 var sessionRecordingOptions = {
25684 mixpanelInstance: this.mixpanelInstance,
25685 onBatchSent: onBatchSent,
25686 onIdleTimeout: onIdleTimeout,
25687 onMaxLengthReached: onMaxLengthReached,
25688 replayId: _.UUID(),
25689 rrwebRecord: this.rrwebRecord,
25690 sharedLockStorage: this.sharedLockStorage
25691 };
25692
25693 if (options.activeSerializedRecording) {
25694 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
25695 } else {
25696 this.activeRecording = new SessionRecording(sessionRecordingOptions);
25697 }
25698
25699 this.activeRecording.startRecording(options.shouldStopBatcher);
25700 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
25701 };
25702
25703 MixpanelRecorder.prototype.stopRecording = function() {
25704 var stopPromise = this._stopCurrentRecording(false);
25705 this.recordingRegistry.clearActiveRecording();
25706 this.activeRecording = null;
25707 return stopPromise;
25708 };
25709
25710 MixpanelRecorder.prototype.pauseRecording = function() {
25711 return this._stopCurrentRecording(false);
25712 };
25713
25714 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush) {
25715 if (this.activeRecording) {
25716 return this.activeRecording.stopRecording(skipFlush);
25717 }
25718 return PromisePolyfill.resolve();
25719 };
25720
25721 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
25722 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
25723 this.activeRecording.startRecording(false);
25724 return PromisePolyfill.resolve(null);
25725 }
25726
25727 return this.recordingRegistry.getActiveRecording()
25728 .then(function (activeSerializedRecording) {
25729 if (activeSerializedRecording) {
25730 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
25731 } else if (startNewIfInactive) {
25732 return this.startRecording({shouldStopBatcher: false});
25733 } else {
25734 logger$2.log('No resumable recording found.');
25735 return null;
25736 }
25737 }.bind(this));
25738 };
25739
25740
25741 MixpanelRecorder.prototype.resetRecording = function () {
25742 this.stopRecording();
25743 this.startRecording({shouldStopBatcher: true});
25744 };
25745
25746 MixpanelRecorder.prototype.getActiveReplayId = function () {
25747 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
25748 return this.activeRecording.replayId;
25749 } else {
25750 return null;
25751 }
25752 };
25753
25754 // getter so that older mixpanel-core versions can still retrieve the replay ID
25755 // when pulling the latest recorder bundle from the CDN
25756 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
25757 get: function () {
25758 return this.getActiveReplayId();
25759 }
25760 });
25761
25762 win['__mp_recorder'] = MixpanelRecorder;
25763
25764 // stateless utils
25765 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
25766
25767
25768 var EV_CHANGE = 'change';
25769 var EV_CLICK = 'click';
25770 var EV_HASHCHANGE = 'hashchange';
25771 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
25772 var EV_POPSTATE = 'popstate';
25773 // TODO scrollend isn't available in Safari: document or polyfill?
25774 var EV_SCROLLEND = 'scrollend';
25775 var EV_SUBMIT = 'submit';
25776
25777 var CLICK_EVENT_PROPS = [
25778 'clientX', 'clientY',
25779 'offsetX', 'offsetY',
25780 'pageX', 'pageY',
25781 'screenX', 'screenY',
25782 'x', 'y'
25783 ];
25784 var OPT_IN_CLASSES = ['mp-include'];
25785 var OPT_OUT_CLASSES = ['mp-no-track'];
25786 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
25787 var TRACKED_ATTRS = [
25788 'aria-label', 'aria-labelledby', 'aria-describedby',
25789 'href', 'name', 'role', 'title', 'type'
25790 ];
25791
25792 var logger$1 = console_with_prefix('autocapture');
25793
25794
25795 function getClasses(el) {
25796 var classes = {};
25797 var classList = getClassName(el).split(' ');
25798 for (var i = 0; i < classList.length; i++) {
25799 var cls = classList[i];
25800 if (cls) {
25801 classes[cls] = true;
25802 }
25803 }
25804 return classes;
25805 }
25806
25807 /*
25808 * Get the className of an element, accounting for edge cases where element.className is an object
25809 * @param {Element} el - element to get the className of
25810 * @returns {string} the element's class
25811 */
25812 function getClassName(el) {
25813 switch(typeof el.className) {
25814 case 'string':
25815 return el.className;
25816 case 'object': // handle cases where className might be SVGAnimatedString or some other type
25817 return el.className.baseVal || el.getAttribute('class') || '';
25818 default: // future proof
25819 return '';
25820 }
25821 }
25822
25823 function getPreviousElementSibling(el) {
25824 if (el.previousElementSibling) {
25825 return el.previousElementSibling;
25826 } else {
25827 do {
25828 el = el.previousSibling;
25829 } while (el && !isElementNode(el));
25830 return el;
25831 }
25832 }
25833
25834 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
25835 var props = {
25836 '$classes': getClassName(el).split(' '),
25837 '$tag_name': el.tagName.toLowerCase()
25838 };
25839 var elId = el.id;
25840 if (elId) {
25841 props['$id'] = elId;
25842 }
25843
25844 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
25845 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
25846 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
25847 var attrVal = el.getAttribute(attr);
25848 if (shouldTrackValue(attrVal)) {
25849 props['$attr-' + attr] = attrVal;
25850 }
25851 }
25852 });
25853 }
25854
25855 var nthChild = 1;
25856 var nthOfType = 1;
25857 var currentElem = el;
25858 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
25859 nthChild++;
25860 if (currentElem.tagName === el.tagName) {
25861 nthOfType++;
25862 }
25863 }
25864 props['$nth_child'] = nthChild;
25865 props['$nth_of_type'] = nthOfType;
25866
25867 return props;
25868 }
25869
25870 function getPropsForDOMEvent(ev, config) {
25871 var allowElementCallback = config.allowElementCallback;
25872 var allowSelectors = config.allowSelectors || [];
25873 var blockAttrs = config.blockAttrs || [];
25874 var blockElementCallback = config.blockElementCallback;
25875 var blockSelectors = config.blockSelectors || [];
25876 var captureTextContent = config.captureTextContent || false;
25877 var captureExtraAttrs = config.captureExtraAttrs || [];
25878 var capturedForHeatMap = config.capturedForHeatMap || false;
25879
25880 // convert array to set every time, as the config may have changed
25881 var blockAttrsSet = {};
25882 _.each(blockAttrs, function(attr) {
25883 blockAttrsSet[attr] = true;
25884 });
25885
25886 var props = null;
25887
25888 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
25889 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
25890 target = target.parentNode;
25891 }
25892
25893 if (
25894 shouldTrackDomEvent(target, ev) &&
25895 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
25896 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
25897 ) {
25898 var targetElementList = [target];
25899 var curEl = target;
25900 while (curEl.parentNode && !isTag(curEl, 'body')) {
25901 targetElementList.push(curEl.parentNode);
25902 curEl = curEl.parentNode;
25903 }
25904
25905 var elementsJson = [];
25906 var href, explicitNoTrack = false;
25907 _.each(targetElementList, function(el) {
25908 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
25909
25910 // if the element or a parent element is an anchor tag
25911 // include the href as a property
25912 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
25913 href = el.getAttribute('href');
25914 href = shouldTrackDetails && shouldTrackValue(href) && href;
25915 }
25916
25917 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
25918 explicitNoTrack = true;
25919 }
25920
25921 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
25922 }, this);
25923
25924 if (!explicitNoTrack) {
25925 var docElement = document$1['documentElement'];
25926 props = {
25927 '$event_type': ev.type,
25928 '$host': win.location.host,
25929 '$pathname': win.location.pathname,
25930 '$elements': elementsJson,
25931 '$el_attr__href': href,
25932 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
25933 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
25934 '$pageHeight': document$1['body']['offsetHeight'] || 0,
25935 '$pageWidth': document$1['body']['offsetWidth'] || 0,
25936 };
25937 _.each(captureExtraAttrs, function(attr) {
25938 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
25939 var attrVal = target.getAttribute(attr);
25940 if (shouldTrackValue(attrVal)) {
25941 props['$el_attr__' + attr] = attrVal;
25942 }
25943 }
25944 });
25945
25946 if (captureTextContent) {
25947 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
25948 if (elementText && elementText.length) {
25949 props['$el_text'] = elementText;
25950 }
25951 }
25952
25953 if (ev.type === EV_CLICK) {
25954 _.each(CLICK_EVENT_PROPS, function(prop) {
25955 if (prop in ev) {
25956 props['$' + prop] = ev[prop];
25957 }
25958 });
25959 if (capturedForHeatMap) {
25960 props['$captured_for_heatmap'] = true;
25961 }
25962 target = guessRealClickTarget(ev);
25963 }
25964 // prioritize text content from "real" click target if different from original target
25965 if (captureTextContent) {
25966 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
25967 if (elementText && elementText.length) {
25968 props['$el_text'] = elementText;
25969 }
25970 }
25971
25972 if (target) {
25973 // target may have been recalculated; check allowlists and blocklists again
25974 if (
25975 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
25976 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
25977 ) {
25978 return null;
25979 }
25980
25981 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
25982 props['$target'] = targetProps;
25983 // pull up more props onto main event props
25984 props['$el_classes'] = targetProps['$classes'];
25985 _.extend(props, _.strip_empty_properties({
25986 '$el_id': targetProps['$id'],
25987 '$el_tag_name': targetProps['$tag_name']
25988 }));
25989 }
25990 }
25991 }
25992
25993 return props;
25994 }
25995
25996
25997 /**
25998 * Get the direct text content of an element, protecting against sensitive data collection.
25999 * Concats textContent of each of the element's text node children; this avoids potential
26000 * collection of sensitive data that could happen if we used element.textContent and the
26001 * element had sensitive child elements, since element.textContent includes child content.
26002 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
26003 * @param {Element} el - element to get the text of
26004 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26005 * @returns {string} the element's direct text content
26006 */
26007 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
26008 var elText = '';
26009
26010 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
26011 _.each(el.childNodes, function(child) {
26012 if (isTextNode(child) && child.textContent) {
26013 elText += _.trim(child.textContent)
26014 // scrub potentially sensitive values
26015 .split(/(\s+)/).filter(shouldTrackValue).join('')
26016 // normalize whitespace
26017 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
26018 // truncate
26019 .substring(0, 255);
26020 }
26021 });
26022 }
26023
26024 return _.trim(elText);
26025 }
26026
26027 function guessRealClickTarget(ev) {
26028 var target = ev.target;
26029 var composedPath = ev['composedPath']();
26030 for (var i = 0; i < composedPath.length; i++) {
26031 var node = composedPath[i];
26032 if (
26033 isTag(node, 'a') ||
26034 isTag(node, 'button') ||
26035 isTag(node, 'input') ||
26036 isTag(node, 'select') ||
26037 (node.getAttribute && node.getAttribute('role') === 'button')
26038 ) {
26039 target = node;
26040 break;
26041 }
26042 if (node === target) {
26043 break;
26044 }
26045 }
26046 return target;
26047 }
26048
26049 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
26050 if (allowElementCallback) {
26051 try {
26052 if (!allowElementCallback(el, ev)) {
26053 return false;
26054 }
26055 } catch (err) {
26056 logger$1.critical('Error while checking element in allowElementCallback', err);
26057 return false;
26058 }
26059 }
26060
26061 if (!allowSelectors.length) {
26062 // no allowlist; all elements are fair game
26063 return true;
26064 }
26065
26066 for (var i = 0; i < allowSelectors.length; i++) {
26067 var sel = allowSelectors[i];
26068 try {
26069 if (el['matches'](sel)) {
26070 return true;
26071 }
26072 } catch (err) {
26073 logger$1.critical('Error while checking selector: ' + sel, err);
26074 }
26075 }
26076 return false;
26077 }
26078
26079 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
26080 var i;
26081
26082 if (blockElementCallback) {
26083 try {
26084 if (blockElementCallback(el, ev)) {
26085 return true;
26086 }
26087 } catch (err) {
26088 logger$1.critical('Error while checking element in blockElementCallback', err);
26089 return true;
26090 }
26091 }
26092
26093 if (blockSelectors && blockSelectors.length) {
26094 // programmatically prevent tracking of elements that match CSS selectors
26095 for (i = 0; i < blockSelectors.length; i++) {
26096 var sel = blockSelectors[i];
26097 try {
26098 if (el['matches'](sel)) {
26099 return true;
26100 }
26101 } catch (err) {
26102 logger$1.critical('Error while checking selector: ' + sel, err);
26103 }
26104 }
26105 }
26106
26107 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
26108 var classes = getClasses(el);
26109 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
26110 if (classes[OPT_OUT_CLASSES[i]]) {
26111 return true;
26112 }
26113 }
26114
26115 return false;
26116 }
26117
26118 /*
26119 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
26120 * @param {Node} node - node to check
26121 * @returns {boolean} whether node is of the correct nodeType
26122 */
26123 function isElementNode(node) {
26124 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
26125 }
26126
26127 /*
26128 * Check whether an element is of a given tag type.
26129 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
26130 * we want to match tagNames instead of specific references because something like
26131 * element === document.body won't always work because element might not be a native
26132 * element.
26133 * @param {Element} el - element to check
26134 * @param {string} tag - tag name (e.g., "div")
26135 * @returns {boolean} whether el is of the given tag type
26136 */
26137 function isTag(el, tag) {
26138 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
26139 }
26140
26141 /*
26142 * Check whether a DOM node is a TEXT_NODE
26143 * @param {Node} node - node to check
26144 * @returns {boolean} whether node is of type Node.TEXT_NODE
26145 */
26146 function isTextNode(node) {
26147 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
26148 }
26149
26150 function minDOMApisSupported() {
26151 try {
26152 var testEl = document$1.createElement('div');
26153 return !!testEl['matches'];
26154 } catch (err) {
26155 return false;
26156 }
26157 }
26158
26159 /*
26160 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
26161 * using a variety of heuristics.
26162 * @param {Element} el - element to check
26163 * @param {Event} ev - event to check
26164 * @returns {boolean} whether the event should be tracked
26165 */
26166 function shouldTrackDomEvent(el, ev) {
26167 if (!el || isTag(el, 'html') || !isElementNode(el)) {
26168 return false;
26169 }
26170 var tag = el.tagName.toLowerCase();
26171 switch (tag) {
26172 case 'form':
26173 return ev.type === EV_SUBMIT;
26174 case 'input':
26175 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
26176 return ev.type === EV_CHANGE;
26177 } else {
26178 return ev.type === EV_CLICK;
26179 }
26180 case 'select':
26181 case 'textarea':
26182 return ev.type === EV_CHANGE;
26183 default:
26184 return ev.type === EV_CLICK;
26185 }
26186 }
26187
26188 /*
26189 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
26190 * using a variety of heuristics.
26191 * @param {Element} el - element to check
26192 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
26193 * @returns {boolean} whether the element should be tracked
26194 */
26195 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
26196 var i;
26197
26198 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
26199 return false;
26200 }
26201
26202 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
26203 var classes = getClasses(curEl);
26204 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
26205 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
26206 return false;
26207 }
26208 }
26209 }
26210
26211 var elClasses = getClasses(el);
26212 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
26213 if (elClasses[OPT_IN_CLASSES[i]]) {
26214 return true;
26215 }
26216 }
26217
26218 // don't send data from inputs or similar elements since there will always be
26219 // a risk of clientside javascript placing sensitive data in attributes
26220 if (
26221 isTag(el, 'input') ||
26222 isTag(el, 'select') ||
26223 isTag(el, 'textarea') ||
26224 el.getAttribute('contenteditable') === 'true'
26225 ) {
26226 return false;
26227 }
26228
26229 // don't include hidden or password fields
26230 var type = el.type || '';
26231 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"]
26232 switch(type.toLowerCase()) {
26233 case 'hidden':
26234 return false;
26235 case 'password':
26236 return false;
26237 }
26238 }
26239
26240 // filter out data from fields that look like sensitive fields
26241 var name = el.name || el.id || '';
26242 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"]
26243 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
26244 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
26245 return false;
26246 }
26247 }
26248
26249 return true;
26250 }
26251
26252
26253 /*
26254 * Check whether a string value should be "tracked" or if it may contain sensitive data
26255 * using a variety of heuristics.
26256 * @param {string} value - string value to check
26257 * @returns {boolean} whether the element should be tracked
26258 */
26259 function shouldTrackValue(value) {
26260 if (value === null || _.isUndefined(value)) {
26261 return false;
26262 }
26263
26264 if (typeof value === 'string') {
26265 value = _.trim(value);
26266
26267 // check to see if input value looks like a credit card number
26268 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
26269 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}))$/;
26270 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
26271 return false;
26272 }
26273
26274 // check to see if input value looks like a social security number
26275 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
26276 if (ssnRegex.test(value)) {
26277 return false;
26278 }
26279 }
26280
26281 return true;
26282 }
26283
26284 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
26285 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
26286
26287 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
26288 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
26289 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
26290
26291 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
26292 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
26293 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
26294 var CONFIG_BLOCK_ATTRS = 'block_attrs';
26295 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
26296 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
26297 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
26298 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
26299 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
26300 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
26301 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
26302 var CONFIG_TRACK_CLICK = 'click';
26303 var CONFIG_TRACK_INPUT = 'input';
26304 var CONFIG_TRACK_PAGEVIEW = 'pageview';
26305 var CONFIG_TRACK_SCROLL = 'scroll';
26306 var CONFIG_TRACK_SUBMIT = 'submit';
26307
26308 var CONFIG_DEFAULTS$1 = {};
26309 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
26310 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
26311 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
26312 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
26313 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
26314 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
26315 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
26316 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
26317 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
26318 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
26319 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
26320 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
26321 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
26322 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
26323 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
26324
26325 var DEFAULT_PROPS = {
26326 '$mp_autocapture': true
26327 };
26328
26329 var MP_EV_CLICK = '$mp_click';
26330 var MP_EV_INPUT = '$mp_input_change';
26331 var MP_EV_SCROLL = '$mp_scroll';
26332 var MP_EV_SUBMIT = '$mp_submit';
26333
26334 /**
26335 * Autocapture: manages automatic event tracking
26336 * @constructor
26337 */
26338 var Autocapture = function(mp) {
26339 this.mp = mp;
26340 };
26341
26342 Autocapture.prototype.init = function() {
26343 if (!minDOMApisSupported()) {
26344 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
26345 return;
26346 }
26347
26348 this.initPageviewTracking();
26349 this.initClickTracking();
26350 this.initInputTracking();
26351 this.initScrollTracking();
26352 this.initSubmitTracking();
26353 };
26354
26355 Autocapture.prototype.getFullConfig = function() {
26356 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
26357 if (!autocaptureConfig) {
26358 // Autocapture is completely off
26359 return {};
26360 } else if (_.isObject(autocaptureConfig)) {
26361 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
26362 } else {
26363 // Autocapture config is non-object truthy value, return default
26364 return CONFIG_DEFAULTS$1;
26365 }
26366 };
26367
26368 Autocapture.prototype.getConfig = function(key) {
26369 return this.getFullConfig()[key];
26370 };
26371
26372 Autocapture.prototype.currentUrlBlocked = function() {
26373 var i;
26374 var currentUrl = _.info.currentUrl();
26375
26376 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
26377 if (allowUrlRegexes.length) {
26378 // we're using an allowlist, only track if current URL matches
26379 var allowed = false;
26380 for (i = 0; i < allowUrlRegexes.length; i++) {
26381 var allowRegex = allowUrlRegexes[i];
26382 try {
26383 if (currentUrl.match(allowRegex)) {
26384 allowed = true;
26385 break;
26386 }
26387 } catch (err) {
26388 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
26389 return true;
26390 }
26391 }
26392 if (!allowed) {
26393 // wasn't allowed by any regex
26394 return true;
26395 }
26396 }
26397
26398 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
26399 if (!blockUrlRegexes || !blockUrlRegexes.length) {
26400 return false;
26401 }
26402
26403 for (i = 0; i < blockUrlRegexes.length; i++) {
26404 try {
26405 if (currentUrl.match(blockUrlRegexes[i])) {
26406 return true;
26407 }
26408 } catch (err) {
26409 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
26410 return true;
26411 }
26412 }
26413 return false;
26414 };
26415
26416 Autocapture.prototype.pageviewTrackingConfig = function() {
26417 // supports both autocapture config and old track_pageview config
26418 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
26419 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
26420 } else {
26421 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
26422 }
26423 };
26424
26425 // helper for event handlers
26426 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
26427 if (this.currentUrlBlocked()) {
26428 return;
26429 }
26430
26431 var props = getPropsForDOMEvent(ev, {
26432 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
26433 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
26434 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
26435 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
26436 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
26437 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
26438 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
26439 capturedForHeatMap: mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK) && this.mp.is_recording_heatmap_data(),
26440 });
26441 if (props) {
26442 _.extend(props, DEFAULT_PROPS);
26443 this.mp.track(mpEventName, props);
26444 }
26445 };
26446
26447 Autocapture.prototype.initClickTracking = function() {
26448 win.removeEventListener(EV_CLICK, this.listenerClick);
26449
26450 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
26451 return;
26452 }
26453 logger$1.log('Initializing click tracking');
26454
26455 this.listenerClick = win.addEventListener(EV_CLICK, function(ev) {
26456 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
26457 return;
26458 }
26459 this.trackDomEvent(ev, MP_EV_CLICK);
26460 }.bind(this));
26461 };
26462
26463 Autocapture.prototype.initInputTracking = function() {
26464 win.removeEventListener(EV_CHANGE, this.listenerChange);
26465
26466 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
26467 return;
26468 }
26469 logger$1.log('Initializing input tracking');
26470
26471 this.listenerChange = win.addEventListener(EV_CHANGE, function(ev) {
26472 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
26473 return;
26474 }
26475 this.trackDomEvent(ev, MP_EV_INPUT);
26476 }.bind(this));
26477 };
26478
26479 Autocapture.prototype.initPageviewTracking = function() {
26480 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
26481 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
26482 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
26483
26484 if (!this.pageviewTrackingConfig()) {
26485 return;
26486 }
26487 logger$1.log('Initializing pageview tracking');
26488
26489 var previousTrackedUrl = '';
26490 var tracked = false;
26491 if (!this.currentUrlBlocked()) {
26492 tracked = this.mp.track_pageview(DEFAULT_PROPS);
26493 }
26494 if (tracked) {
26495 previousTrackedUrl = _.info.currentUrl();
26496 }
26497
26498 this.listenerPopstate = win.addEventListener(EV_POPSTATE, function() {
26499 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
26500 });
26501 this.listenerHashchange = win.addEventListener(EV_HASHCHANGE, function() {
26502 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
26503 });
26504 var nativePushState = win.history.pushState;
26505 if (typeof nativePushState === 'function') {
26506 win.history.pushState = function(state, unused, url) {
26507 nativePushState.call(win.history, state, unused, url);
26508 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
26509 };
26510 }
26511 var nativeReplaceState = win.history.replaceState;
26512 if (typeof nativeReplaceState === 'function') {
26513 win.history.replaceState = function(state, unused, url) {
26514 nativeReplaceState.call(win.history, state, unused, url);
26515 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
26516 };
26517 }
26518 this.listenerLocationchange = win.addEventListener(EV_MP_LOCATION_CHANGE, safewrap(function() {
26519 if (this.currentUrlBlocked()) {
26520 return;
26521 }
26522
26523 var currentUrl = _.info.currentUrl();
26524 var shouldTrack = false;
26525 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
26526 var trackPageviewOption = this.pageviewTrackingConfig();
26527 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
26528 shouldTrack = currentUrl !== previousTrackedUrl;
26529 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
26530 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
26531 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
26532 shouldTrack = didPathChange;
26533 }
26534
26535 if (shouldTrack) {
26536 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
26537 if (tracked) {
26538 previousTrackedUrl = currentUrl;
26539 }
26540 if (didPathChange) {
26541 this.lastScrollCheckpoint = 0;
26542 logger$1.log('Path change: re-initializing scroll depth checkpoints');
26543 }
26544 }
26545 }.bind(this)));
26546 };
26547
26548 Autocapture.prototype.initScrollTracking = function() {
26549 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
26550
26551 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
26552 return;
26553 }
26554 logger$1.log('Initializing scroll tracking');
26555 this.lastScrollCheckpoint = 0;
26556
26557 this.listenerScroll = win.addEventListener(EV_SCROLLEND, safewrap(function() {
26558 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
26559 return;
26560 }
26561 if (this.currentUrlBlocked()) {
26562 return;
26563 }
26564
26565 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
26566 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
26567 .slice()
26568 .sort(function(a, b) { return a - b; });
26569
26570 var scrollTop = win.scrollY;
26571 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
26572 try {
26573 var scrollHeight = document$1.body.scrollHeight;
26574 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
26575 props['$scroll_height'] = scrollHeight;
26576 props['$scroll_percentage'] = scrollPercentage;
26577 if (scrollPercentage > this.lastScrollCheckpoint) {
26578 for (var i = 0; i < scrollCheckpoints.length; i++) {
26579 var checkpoint = scrollCheckpoints[i];
26580 if (
26581 scrollPercentage >= checkpoint &&
26582 this.lastScrollCheckpoint < checkpoint
26583 ) {
26584 props['$scroll_checkpoint'] = checkpoint;
26585 this.lastScrollCheckpoint = checkpoint;
26586 shouldTrack = true;
26587 }
26588 }
26589 }
26590 } catch (err) {
26591 logger$1.critical('Error while calculating scroll percentage', err);
26592 }
26593 if (shouldTrack) {
26594 this.mp.track(MP_EV_SCROLL, props);
26595 }
26596 }.bind(this)));
26597 };
26598
26599 Autocapture.prototype.initSubmitTracking = function() {
26600 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
26601
26602 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
26603 return;
26604 }
26605 logger$1.log('Initializing submit tracking');
26606
26607 this.listenerSubmit = win.addEventListener(EV_SUBMIT, function(ev) {
26608 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
26609 return;
26610 }
26611 this.trackDomEvent(ev, MP_EV_SUBMIT);
26612 }.bind(this));
26613 };
26614
26615 // TODO integrate error_reporter from mixpanel instance
26616 safewrapClass(Autocapture);
26617
26618 var fetch = win['fetch'];
26619 var logger = console_with_prefix('flags');
26620
26621 var FLAGS_CONFIG_KEY = 'flags';
26622
26623 var CONFIG_CONTEXT = 'context';
26624 var CONFIG_DEFAULTS = {};
26625 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
26626
26627 /**
26628 * FeatureFlagManager: support for Mixpanel's feature flagging product
26629 * @constructor
26630 */
26631 var FeatureFlagManager = function(initOptions) {
26632 this.getMpConfig = initOptions.getConfigFunc;
26633 this.getDistinctId = initOptions.getDistinctIdFunc;
26634 this.track = initOptions.trackingFunc;
26635 };
26636
26637 FeatureFlagManager.prototype.init = function() {
26638 if (!minApisSupported()) {
26639 logger.critical('Feature Flags unavailable: missing minimum required APIs');
26640 return;
26641 }
26642
26643 this.flags = null;
26644 this.fetchFlags();
26645
26646 this.trackedFeatures = new Set();
26647 };
26648
26649 FeatureFlagManager.prototype.getFullConfig = function() {
26650 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
26651 if (!ffConfig) {
26652 // flags are completely off
26653 return {};
26654 } else if (_.isObject(ffConfig)) {
26655 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
26656 } else {
26657 // config is non-object truthy value, return default
26658 return CONFIG_DEFAULTS;
26659 }
26660 };
26661
26662 FeatureFlagManager.prototype.getConfig = function(key) {
26663 return this.getFullConfig()[key];
26664 };
26665
26666 FeatureFlagManager.prototype.isSystemEnabled = function() {
26667 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
26668 };
26669
26670 FeatureFlagManager.prototype.areFlagsReady = function() {
26671 if (!this.isSystemEnabled()) {
26672 logger.error('Feature Flags not enabled');
26673 }
26674 return !!this.flags;
26675 };
26676
26677 FeatureFlagManager.prototype.fetchFlags = function() {
26678 if (!this.isSystemEnabled()) {
26679 return;
26680 }
26681
26682 var distinctId = this.getDistinctId();
26683 logger.log('Fetching flags for distinct ID: ' + distinctId);
26684 var reqParams = {
26685 'context': _.extend({'distinct_id': distinctId}, this.getConfig(CONFIG_CONTEXT))
26686 };
26687 this.fetchPromise = win['fetch'](this.getMpConfig('api_host') + '/' + this.getMpConfig('api_routes')['flags'], {
26688 'method': 'POST',
26689 'headers': {
26690 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
26691 'Content-Type': 'application/octet-stream'
26692 },
26693 'body': JSON.stringify(reqParams)
26694 }).then(function(response) {
26695 return response.json().then(function(responseBody) {
26696 var responseFlags = responseBody['flags'];
26697 if (!responseFlags) {
26698 throw new Error('No flags in API response');
26699 }
26700 var flags = new Map();
26701 _.each(responseFlags, function(data, key) {
26702 flags.set(key, {
26703 'key': data['variant_key'],
26704 'value': data['variant_value']
26705 });
26706 });
26707 this.flags = flags;
26708 }.bind(this)).catch(function(error) {
26709 logger.error(error);
26710 });
26711 }.bind(this)).catch(function() {});
26712 };
26713
26714 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
26715 if (!this.fetchPromise) {
26716 return new Promise(function(resolve) {
26717 logger.critical('Feature Flags not initialized');
26718 resolve(fallback);
26719 });
26720 }
26721
26722 return this.fetchPromise.then(function() {
26723 return this.getVariantSync(featureName, fallback);
26724 }.bind(this)).catch(function(error) {
26725 logger.error(error);
26726 return fallback;
26727 });
26728 };
26729
26730 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
26731 if (!this.areFlagsReady()) {
26732 logger.log('Flags not loaded yet');
26733 return fallback;
26734 }
26735 var feature = this.flags.get(featureName);
26736 if (!feature) {
26737 logger.log('No flag found: "' + featureName + '"');
26738 return fallback;
26739 }
26740 this.trackFeatureCheck(featureName, feature);
26741 return feature;
26742 };
26743
26744 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
26745 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
26746 return feature['value'];
26747 }).catch(function(error) {
26748 logger.error(error);
26749 return fallbackValue;
26750 });
26751 };
26752
26753 // TODO remove deprecated method
26754 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
26755 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
26756 return this.getVariantValue(featureName, fallbackValue);
26757 };
26758
26759 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
26760 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
26761 };
26762
26763 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
26764 return this.getVariantValue(featureName).then(function() {
26765 return this.isEnabledSync(featureName, fallbackValue);
26766 }.bind(this)).catch(function(error) {
26767 logger.error(error);
26768 return fallbackValue;
26769 });
26770 };
26771
26772 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
26773 fallbackValue = fallbackValue || false;
26774 var val = this.getVariantValueSync(featureName, fallbackValue);
26775 if (val !== true && val !== false) {
26776 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
26777 val = fallbackValue;
26778 }
26779 return val;
26780 };
26781
26782 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
26783 if (this.trackedFeatures.has(featureName)) {
26784 return;
26785 }
26786 this.trackedFeatures.add(featureName);
26787 this.track('$experiment_started', {
26788 'Experiment name': featureName,
26789 'Variant name': feature['key'],
26790 '$experiment_type': 'feature_flag'
26791 });
26792 };
26793
26794 function minApisSupported() {
26795 return !!fetch &&
26796 typeof Promise !== 'undefined' &&
26797 typeof Map !== 'undefined' &&
26798 typeof Set !== 'undefined';
26799 }
26800
26801 safewrapClass(FeatureFlagManager);
26802
26803 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
26804 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
26805 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
26806 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
26807 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
26808 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
26809 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
26810
26811 // Deprecated method
26812 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
26813
26814 /* eslint camelcase: "off" */
26815
26816
26817 /**
26818 * DomTracker Object
26819 * @constructor
26820 */
26821 var DomTracker = function() {};
26822
26823
26824 // interface
26825 DomTracker.prototype.create_properties = function() {};
26826 DomTracker.prototype.event_handler = function() {};
26827 DomTracker.prototype.after_track_handler = function() {};
26828
26829 DomTracker.prototype.init = function(mixpanel_instance) {
26830 this.mp = mixpanel_instance;
26831 return this;
26832 };
26833
26834 /**
26835 * @param {Object|string} query
26836 * @param {string} event_name
26837 * @param {Object=} properties
26838 * @param {function=} user_callback
26839 */
26840 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
26841 var that = this;
26842 var elements = _.dom_query(query);
26843
26844 if (elements.length === 0) {
26845 console$1.error('The DOM query (' + query + ') returned 0 elements');
26846 return;
26847 }
26848
26849 _.each(elements, function(element) {
26850 _.register_event(element, this.override_event, function(e) {
26851 var options = {};
26852 var props = that.create_properties(properties, this);
26853 var timeout = that.mp.get_config('track_links_timeout');
26854
26855 that.event_handler(e, this, options);
26856
26857 // in case the mixpanel servers don't get back to us in time
26858 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
26859
26860 // fire the tracking event
26861 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
26862 });
26863 }, this);
26864
26865 return true;
26866 };
26867
26868 /**
26869 * @param {function} user_callback
26870 * @param {Object} props
26871 * @param {boolean=} timeout_occured
26872 */
26873 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
26874 timeout_occured = timeout_occured || false;
26875 var that = this;
26876
26877 return function() {
26878 // options is referenced from both callbacks, so we can have
26879 // a 'lock' of sorts to ensure only one fires
26880 if (options.callback_fired) { return; }
26881 options.callback_fired = true;
26882
26883 if (user_callback && user_callback(timeout_occured, props) === false) {
26884 // user can prevent the default functionality by
26885 // returning false from their callback
26886 return;
26887 }
26888
26889 that.after_track_handler(props, options, timeout_occured);
26890 };
26891 };
26892
26893 DomTracker.prototype.create_properties = function(properties, element) {
26894 var props;
26895
26896 if (typeof(properties) === 'function') {
26897 props = properties(element);
26898 } else {
26899 props = _.extend({}, properties);
26900 }
26901
26902 return props;
26903 };
26904
26905 /**
26906 * LinkTracker Object
26907 * @constructor
26908 * @extends DomTracker
26909 */
26910 var LinkTracker = function() {
26911 this.override_event = 'click';
26912 };
26913 _.inherit(LinkTracker, DomTracker);
26914
26915 LinkTracker.prototype.create_properties = function(properties, element) {
26916 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
26917
26918 if (element.href) { props['url'] = element.href; }
26919
26920 return props;
26921 };
26922
26923 LinkTracker.prototype.event_handler = function(evt, element, options) {
26924 options.new_tab = (
26925 evt.which === 2 ||
26926 evt.metaKey ||
26927 evt.ctrlKey ||
26928 element.target === '_blank'
26929 );
26930 options.href = element.href;
26931
26932 if (!options.new_tab) {
26933 evt.preventDefault();
26934 }
26935 };
26936
26937 LinkTracker.prototype.after_track_handler = function(props, options) {
26938 if (options.new_tab) { return; }
26939
26940 setTimeout(function() {
26941 window.location = options.href;
26942 }, 0);
26943 };
26944
26945 /**
26946 * FormTracker Object
26947 * @constructor
26948 * @extends DomTracker
26949 */
26950 var FormTracker = function() {
26951 this.override_event = 'submit';
26952 };
26953 _.inherit(FormTracker, DomTracker);
26954
26955 FormTracker.prototype.event_handler = function(evt, element, options) {
26956 options.element = element;
26957 evt.preventDefault();
26958 };
26959
26960 FormTracker.prototype.after_track_handler = function(props, options) {
26961 setTimeout(function() {
26962 options.element.submit();
26963 }, 0);
26964 };
26965
26966 /* eslint camelcase: "off" */
26967
26968
26969 /** @const */ var SET_ACTION = '$set';
26970 /** @const */ var SET_ONCE_ACTION = '$set_once';
26971 /** @const */ var UNSET_ACTION = '$unset';
26972 /** @const */ var ADD_ACTION = '$add';
26973 /** @const */ var APPEND_ACTION = '$append';
26974 /** @const */ var UNION_ACTION = '$union';
26975 /** @const */ var REMOVE_ACTION = '$remove';
26976 /** @const */ var DELETE_ACTION = '$delete';
26977
26978 // Common internal methods for mixpanel.people and mixpanel.group APIs.
26979 // These methods shouldn't involve network I/O.
26980 var apiActions = {
26981 set_action: function(prop, to) {
26982 var data = {};
26983 var $set = {};
26984 if (_.isObject(prop)) {
26985 _.each(prop, function(v, k) {
26986 if (!this._is_reserved_property(k)) {
26987 $set[k] = v;
26988 }
26989 }, this);
26990 } else {
26991 $set[prop] = to;
26992 }
26993
26994 data[SET_ACTION] = $set;
26995 return data;
26996 },
26997
26998 unset_action: function(prop) {
26999 var data = {};
27000 var $unset = [];
27001 if (!_.isArray(prop)) {
27002 prop = [prop];
27003 }
27004
27005 _.each(prop, function(k) {
27006 if (!this._is_reserved_property(k)) {
27007 $unset.push(k);
27008 }
27009 }, this);
27010
27011 data[UNSET_ACTION] = $unset;
27012 return data;
27013 },
27014
27015 set_once_action: function(prop, to) {
27016 var data = {};
27017 var $set_once = {};
27018 if (_.isObject(prop)) {
27019 _.each(prop, function(v, k) {
27020 if (!this._is_reserved_property(k)) {
27021 $set_once[k] = v;
27022 }
27023 }, this);
27024 } else {
27025 $set_once[prop] = to;
27026 }
27027 data[SET_ONCE_ACTION] = $set_once;
27028 return data;
27029 },
27030
27031 union_action: function(list_name, values) {
27032 var data = {};
27033 var $union = {};
27034 if (_.isObject(list_name)) {
27035 _.each(list_name, function(v, k) {
27036 if (!this._is_reserved_property(k)) {
27037 $union[k] = _.isArray(v) ? v : [v];
27038 }
27039 }, this);
27040 } else {
27041 $union[list_name] = _.isArray(values) ? values : [values];
27042 }
27043 data[UNION_ACTION] = $union;
27044 return data;
27045 },
27046
27047 append_action: function(list_name, value) {
27048 var data = {};
27049 var $append = {};
27050 if (_.isObject(list_name)) {
27051 _.each(list_name, function(v, k) {
27052 if (!this._is_reserved_property(k)) {
27053 $append[k] = v;
27054 }
27055 }, this);
27056 } else {
27057 $append[list_name] = value;
27058 }
27059 data[APPEND_ACTION] = $append;
27060 return data;
27061 },
27062
27063 remove_action: function(list_name, value) {
27064 var data = {};
27065 var $remove = {};
27066 if (_.isObject(list_name)) {
27067 _.each(list_name, function(v, k) {
27068 if (!this._is_reserved_property(k)) {
27069 $remove[k] = v;
27070 }
27071 }, this);
27072 } else {
27073 $remove[list_name] = value;
27074 }
27075 data[REMOVE_ACTION] = $remove;
27076 return data;
27077 },
27078
27079 delete_action: function() {
27080 var data = {};
27081 data[DELETE_ACTION] = '';
27082 return data;
27083 }
27084 };
27085
27086 /* eslint camelcase: "off" */
27087
27088 /**
27089 * Mixpanel Group Object
27090 * @constructor
27091 */
27092 var MixpanelGroup = function() {};
27093
27094 _.extend(MixpanelGroup.prototype, apiActions);
27095
27096 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
27097 this._mixpanel = mixpanel_instance;
27098 this._group_key = group_key;
27099 this._group_id = group_id;
27100 };
27101
27102 /**
27103 * Set properties on a group.
27104 *
27105 * ### Usage:
27106 *
27107 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
27108 *
27109 * // or set multiple properties at once
27110 * mixpanel.get_group('company', 'mixpanel').set({
27111 * 'Location': '405 Howard',
27112 * 'Founded' : 2009,
27113 * });
27114 * // properties can be strings, integers, dates, or lists
27115 *
27116 * @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.
27117 * @param {*} [to] A value to set on the given property name
27118 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27119 */
27120 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
27121 var data = this.set_action(prop, to);
27122 if (_.isObject(prop)) {
27123 callback = to;
27124 }
27125 return this._send_request(data, callback);
27126 });
27127
27128 /**
27129 * Set properties on a group, only if they do not yet exist.
27130 * This will not overwrite previous group property values, unlike
27131 * group.set().
27132 *
27133 * ### Usage:
27134 *
27135 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
27136 *
27137 * // or set multiple properties at once
27138 * mixpanel.get_group('company', 'mixpanel').set_once({
27139 * 'Location': '405 Howard',
27140 * 'Founded' : 2009,
27141 * });
27142 * // properties can be strings, integers, lists or dates
27143 *
27144 * @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.
27145 * @param {*} [to] A value to set on the given property name
27146 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27147 */
27148 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
27149 var data = this.set_once_action(prop, to);
27150 if (_.isObject(prop)) {
27151 callback = to;
27152 }
27153 return this._send_request(data, callback);
27154 });
27155
27156 /**
27157 * Unset properties on a group permanently.
27158 *
27159 * ### Usage:
27160 *
27161 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
27162 *
27163 * @param {String} prop The name of the property.
27164 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27165 */
27166 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
27167 var data = this.unset_action(prop);
27168 return this._send_request(data, callback);
27169 });
27170
27171 /**
27172 * Merge a given list with a list-valued group property, excluding duplicate values.
27173 *
27174 * ### Usage:
27175 *
27176 * // merge a value to a list, creating it if needed
27177 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
27178 *
27179 * @param {String} list_name Name of the property.
27180 * @param {Array} values Values to merge with the given property
27181 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27182 */
27183 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
27184 if (_.isObject(list_name)) {
27185 callback = values;
27186 }
27187 var data = this.union_action(list_name, values);
27188 return this._send_request(data, callback);
27189 });
27190
27191 /**
27192 * Permanently delete a group.
27193 *
27194 * ### Usage:
27195 *
27196 * mixpanel.get_group('company', 'mixpanel').delete();
27197 *
27198 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27199 */
27200 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
27201 // bracket notation above prevents a minification error related to reserved words
27202 var data = this.delete_action();
27203 return this._send_request(data, callback);
27204 });
27205
27206 /**
27207 * Remove a property from a group. The value will be ignored if doesn't exist.
27208 *
27209 * ### Usage:
27210 *
27211 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
27212 *
27213 * @param {String} list_name Name of the property.
27214 * @param {Object} value Value to remove from the given group property
27215 * @param {Function} [callback] If provided, the callback will be called after the tracking event
27216 */
27217 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
27218 var data = this.remove_action(list_name, value);
27219 return this._send_request(data, callback);
27220 });
27221
27222 MixpanelGroup.prototype._send_request = function(data, callback) {
27223 data['$group_key'] = this._group_key;
27224 data['$group_id'] = this._group_id;
27225 data['$token'] = this._get_config('token');
27226
27227 var date_encoded_data = _.encodeDates(data);
27228 return this._mixpanel._track_or_batch({
27229 type: 'groups',
27230 data: date_encoded_data,
27231 endpoint: this._get_config('api_host') + '/' + this._get_config('api_routes')['groups'],
27232 batcher: this._mixpanel.request_batchers.groups
27233 }, callback);
27234 };
27235
27236 MixpanelGroup.prototype._is_reserved_property = function(prop) {
27237 return prop === '$group_key' || prop === '$group_id';
27238 };
27239
27240 MixpanelGroup.prototype._get_config = function(conf) {
27241 return this._mixpanel.get_config(conf);
27242 };
27243
27244 MixpanelGroup.prototype.toString = function() {
27245 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
27246 };
27247
27248 // MixpanelGroup Exports
27249 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
27250 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
27251 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
27252 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
27253 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
27254 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
27255
27256 /* eslint camelcase: "off" */
27257
27258 /**
27259 * Mixpanel People Object
27260 * @constructor
27261 */
27262 var MixpanelPeople = function() {};
27263
27264 _.extend(MixpanelPeople.prototype, apiActions);
27265
27266 MixpanelPeople.prototype._init = function(mixpanel_instance) {
27267 this._mixpanel = mixpanel_instance;
27268 };
27269
27270 /*
27271 * Set properties on a user record.
27272 *
27273 * ### Usage:
27274 *
27275 * mixpanel.people.set('gender', 'm');
27276 *
27277 * // or set multiple properties at once
27278 * mixpanel.people.set({
27279 * 'Company': 'Acme',
27280 * 'Plan': 'Premium',
27281 * 'Upgrade date': new Date()
27282 * });
27283 * // properties can be strings, integers, dates, or lists
27284 *
27285 * @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.
27286 * @param {*} [to] A value to set on the given property name
27287 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27288 */
27289 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
27290 var data = this.set_action(prop, to);
27291 if (_.isObject(prop)) {
27292 callback = to;
27293 }
27294 // make sure that the referrer info has been updated and saved
27295 if (this._get_config('save_referrer')) {
27296 this._mixpanel['persistence'].update_referrer_info(document.referrer);
27297 }
27298
27299 // update $set object with default people properties
27300 data[SET_ACTION] = _.extend(
27301 {},
27302 _.info.people_properties(),
27303 data[SET_ACTION]
27304 );
27305 return this._send_request(data, callback);
27306 });
27307
27308 /*
27309 * Set properties on a user record, only if they do not yet exist.
27310 * This will not overwrite previous people property values, unlike
27311 * people.set().
27312 *
27313 * ### Usage:
27314 *
27315 * mixpanel.people.set_once('First Login Date', new Date());
27316 *
27317 * // or set multiple properties at once
27318 * mixpanel.people.set_once({
27319 * 'First Login Date': new Date(),
27320 * 'Starting Plan': 'Premium'
27321 * });
27322 *
27323 * // properties can be strings, integers or dates
27324 *
27325 * @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.
27326 * @param {*} [to] A value to set on the given property name
27327 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27328 */
27329 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
27330 var data = this.set_once_action(prop, to);
27331 if (_.isObject(prop)) {
27332 callback = to;
27333 }
27334 return this._send_request(data, callback);
27335 });
27336
27337 /*
27338 * Unset properties on a user record (permanently removes the properties and their values from a profile).
27339 *
27340 * ### Usage:
27341 *
27342 * mixpanel.people.unset('gender');
27343 *
27344 * // or unset multiple properties at once
27345 * mixpanel.people.unset(['gender', 'Company']);
27346 *
27347 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
27348 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27349 */
27350 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
27351 var data = this.unset_action(prop);
27352 return this._send_request(data, callback);
27353 });
27354
27355 /*
27356 * Increment/decrement numeric people analytics properties.
27357 *
27358 * ### Usage:
27359 *
27360 * mixpanel.people.increment('page_views', 1);
27361 *
27362 * // or, for convenience, if you're just incrementing a counter by
27363 * // 1, you can simply do
27364 * mixpanel.people.increment('page_views');
27365 *
27366 * // to decrement a counter, pass a negative number
27367 * mixpanel.people.increment('credits_left', -1);
27368 *
27369 * // like mixpanel.people.set(), you can increment multiple
27370 * // properties at once:
27371 * mixpanel.people.increment({
27372 * counter1: 1,
27373 * counter2: 6
27374 * });
27375 *
27376 * @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.
27377 * @param {Number} [by] An amount to increment the given property
27378 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27379 */
27380 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
27381 var data = {};
27382 var $add = {};
27383 if (_.isObject(prop)) {
27384 _.each(prop, function(v, k) {
27385 if (!this._is_reserved_property(k)) {
27386 if (isNaN(parseFloat(v))) {
27387 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
27388 return;
27389 } else {
27390 $add[k] = v;
27391 }
27392 }
27393 }, this);
27394 callback = by;
27395 } else {
27396 // convenience: mixpanel.people.increment('property'); will
27397 // increment 'property' by 1
27398 if (_.isUndefined(by)) {
27399 by = 1;
27400 }
27401 $add[prop] = by;
27402 }
27403 data[ADD_ACTION] = $add;
27404
27405 return this._send_request(data, callback);
27406 });
27407
27408 /*
27409 * Append a value to a list-valued people analytics property.
27410 *
27411 * ### Usage:
27412 *
27413 * // append a value to a list, creating it if needed
27414 * mixpanel.people.append('pages_visited', 'homepage');
27415 *
27416 * // like mixpanel.people.set(), you can append multiple
27417 * // properties at once:
27418 * mixpanel.people.append({
27419 * list1: 'bob',
27420 * list2: 123
27421 * });
27422 *
27423 * @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.
27424 * @param {*} [value] value An item to append to the list
27425 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27426 */
27427 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
27428 if (_.isObject(list_name)) {
27429 callback = value;
27430 }
27431 var data = this.append_action(list_name, value);
27432 return this._send_request(data, callback);
27433 });
27434
27435 /*
27436 * Remove a value from a list-valued people analytics property.
27437 *
27438 * ### Usage:
27439 *
27440 * mixpanel.people.remove('School', 'UCB');
27441 *
27442 * @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.
27443 * @param {*} [value] value Item to remove from the list
27444 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27445 */
27446 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
27447 if (_.isObject(list_name)) {
27448 callback = value;
27449 }
27450 var data = this.remove_action(list_name, value);
27451 return this._send_request(data, callback);
27452 });
27453
27454 /*
27455 * Merge a given list with a list-valued people analytics property,
27456 * excluding duplicate values.
27457 *
27458 * ### Usage:
27459 *
27460 * // merge a value to a list, creating it if needed
27461 * mixpanel.people.union('pages_visited', 'homepage');
27462 *
27463 * // like mixpanel.people.set(), you can append multiple
27464 * // properties at once:
27465 * mixpanel.people.union({
27466 * list1: 'bob',
27467 * list2: 123
27468 * });
27469 *
27470 * // like mixpanel.people.append(), you can append multiple
27471 * // values to the same list:
27472 * mixpanel.people.union({
27473 * list1: ['bob', 'billy']
27474 * });
27475 *
27476 * @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.
27477 * @param {*} [value] Value / values to merge with the given property
27478 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27479 */
27480 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
27481 if (_.isObject(list_name)) {
27482 callback = values;
27483 }
27484 var data = this.union_action(list_name, values);
27485 return this._send_request(data, callback);
27486 });
27487
27488 /*
27489 * Record that you have charged the current user a certain amount
27490 * of money. Charges recorded with track_charge() will appear in the
27491 * Mixpanel revenue report.
27492 *
27493 * ### Usage:
27494 *
27495 * // charge a user $50
27496 * mixpanel.people.track_charge(50);
27497 *
27498 * // charge a user $30.50 on the 2nd of january
27499 * mixpanel.people.track_charge(30.50, {
27500 * '$time': new Date('jan 1 2012')
27501 * });
27502 *
27503 * @param {Number} amount The amount of money charged to the current user
27504 * @param {Object} [properties] An associative array of properties associated with the charge
27505 * @param {Function} [callback] If provided, the callback will be called when the server responds
27506 * @deprecated
27507 */
27508 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
27509 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
27510 });
27511
27512 /*
27513 * Permanently clear all revenue report transactions from the
27514 * current user's people analytics profile.
27515 *
27516 * ### Usage:
27517 *
27518 * mixpanel.people.clear_charges();
27519 *
27520 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
27521 * @deprecated
27522 */
27523 MixpanelPeople.prototype.clear_charges = function(callback) {
27524 return this.set('$transactions', [], callback);
27525 };
27526
27527 /*
27528 * Permanently deletes the current people analytics profile from
27529 * Mixpanel (using the current distinct_id).
27530 *
27531 * ### Usage:
27532 *
27533 * // remove the all data you have stored about the current user
27534 * mixpanel.people.delete_user();
27535 *
27536 */
27537 MixpanelPeople.prototype.delete_user = function() {
27538 if (!this._identify_called()) {
27539 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
27540 return;
27541 }
27542 var data = {'$delete': this._mixpanel.get_distinct_id()};
27543 return this._send_request(data);
27544 };
27545
27546 MixpanelPeople.prototype.toString = function() {
27547 return this._mixpanel.toString() + '.people';
27548 };
27549
27550 MixpanelPeople.prototype._send_request = function(data, callback) {
27551 data['$token'] = this._get_config('token');
27552 data['$distinct_id'] = this._mixpanel.get_distinct_id();
27553 var device_id = this._mixpanel.get_property('$device_id');
27554 var user_id = this._mixpanel.get_property('$user_id');
27555 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
27556 if (device_id) {
27557 data['$device_id'] = device_id;
27558 }
27559 if (user_id) {
27560 data['$user_id'] = user_id;
27561 }
27562 if (had_persisted_distinct_id) {
27563 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
27564 }
27565
27566 var date_encoded_data = _.encodeDates(data);
27567
27568 if (!this._identify_called()) {
27569 this._enqueue(data);
27570 if (!_.isUndefined(callback)) {
27571 if (this._get_config('verbose')) {
27572 callback({status: -1, error: null});
27573 } else {
27574 callback(-1);
27575 }
27576 }
27577 return _.truncate(date_encoded_data, 255);
27578 }
27579
27580 return this._mixpanel._track_or_batch({
27581 type: 'people',
27582 data: date_encoded_data,
27583 endpoint: this._get_config('api_host') + '/' + this._get_config('api_routes')['engage'],
27584 batcher: this._mixpanel.request_batchers.people
27585 }, callback);
27586 };
27587
27588 MixpanelPeople.prototype._get_config = function(conf_var) {
27589 return this._mixpanel.get_config(conf_var);
27590 };
27591
27592 MixpanelPeople.prototype._identify_called = function() {
27593 return this._mixpanel._flags.identify_called === true;
27594 };
27595
27596 // Queue up engage operations if identify hasn't been called yet.
27597 MixpanelPeople.prototype._enqueue = function(data) {
27598 if (SET_ACTION in data) {
27599 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
27600 } else if (SET_ONCE_ACTION in data) {
27601 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
27602 } else if (UNSET_ACTION in data) {
27603 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
27604 } else if (ADD_ACTION in data) {
27605 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
27606 } else if (APPEND_ACTION in data) {
27607 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
27608 } else if (REMOVE_ACTION in data) {
27609 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
27610 } else if (UNION_ACTION in data) {
27611 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
27612 } else {
27613 console$1.error('Invalid call to _enqueue():', data);
27614 }
27615 };
27616
27617 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
27618 var _this = this;
27619 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
27620 var action_params = queued_data;
27621
27622 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
27623 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
27624 _this._mixpanel['persistence'].save();
27625 if (queue_to_params_fn) {
27626 action_params = queue_to_params_fn(queued_data);
27627 }
27628 action_method.call(_this, action_params, function(response, data) {
27629 // on bad response, we want to add it back to the queue
27630 if (response === 0) {
27631 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
27632 }
27633 if (!_.isUndefined(callback)) {
27634 callback(response, data);
27635 }
27636 });
27637 }
27638 };
27639
27640 // Flush queued engage operations - order does not matter,
27641 // and there are network level race conditions anyway
27642 MixpanelPeople.prototype._flush = function(
27643 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
27644 ) {
27645 var _this = this;
27646
27647 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
27648 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
27649 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
27650 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
27651 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
27652
27653 // we have to fire off each $append individually since there is
27654 // no concat method server side
27655 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
27656 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
27657 var $append_item;
27658 var append_callback = function(response, data) {
27659 if (response === 0) {
27660 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
27661 }
27662 if (!_.isUndefined(_append_callback)) {
27663 _append_callback(response, data);
27664 }
27665 };
27666 for (var i = $append_queue.length - 1; i >= 0; i--) {
27667 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
27668 $append_item = $append_queue.pop();
27669 _this._mixpanel['persistence'].save();
27670 if (!_.isEmptyObject($append_item)) {
27671 _this.append($append_item, append_callback);
27672 }
27673 }
27674 }
27675
27676 // same for $remove
27677 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
27678 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
27679 var $remove_item;
27680 var remove_callback = function(response, data) {
27681 if (response === 0) {
27682 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
27683 }
27684 if (!_.isUndefined(_remove_callback)) {
27685 _remove_callback(response, data);
27686 }
27687 };
27688 for (var j = $remove_queue.length - 1; j >= 0; j--) {
27689 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
27690 $remove_item = $remove_queue.pop();
27691 _this._mixpanel['persistence'].save();
27692 if (!_.isEmptyObject($remove_item)) {
27693 _this.remove($remove_item, remove_callback);
27694 }
27695 }
27696 }
27697 };
27698
27699 MixpanelPeople.prototype._is_reserved_property = function(prop) {
27700 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
27701 };
27702
27703 // MixpanelPeople Exports
27704 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
27705 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
27706 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
27707 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
27708 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
27709 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
27710 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
27711 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
27712 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
27713 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
27714 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
27715
27716 /* eslint camelcase: "off" */
27717
27718
27719 /*
27720 * Constants
27721 */
27722 /** @const */ var SET_QUEUE_KEY = '__mps';
27723 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
27724 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
27725 /** @const */ var ADD_QUEUE_KEY = '__mpa';
27726 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
27727 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
27728 /** @const */ var UNION_QUEUE_KEY = '__mpu';
27729 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
27730 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
27731 /** @const */ var ALIAS_ID_KEY = '__alias';
27732 /** @const */ var EVENT_TIMERS_KEY = '__timers';
27733 /** @const */ var RESERVED_PROPERTIES = [
27734 SET_QUEUE_KEY,
27735 SET_ONCE_QUEUE_KEY,
27736 UNSET_QUEUE_KEY,
27737 ADD_QUEUE_KEY,
27738 APPEND_QUEUE_KEY,
27739 REMOVE_QUEUE_KEY,
27740 UNION_QUEUE_KEY,
27741 PEOPLE_DISTINCT_ID_KEY,
27742 ALIAS_ID_KEY,
27743 EVENT_TIMERS_KEY
27744 ];
27745
27746 /**
27747 * Mixpanel Persistence Object
27748 * @constructor
27749 */
27750 var MixpanelPersistence = function(config) {
27751 this['props'] = {};
27752 this.campaign_params_saved = false;
27753
27754 if (config['persistence_name']) {
27755 this.name = 'mp_' + config['persistence_name'];
27756 } else {
27757 this.name = 'mp_' + config['token'] + '_mixpanel';
27758 }
27759
27760 var storage_type = config['persistence'];
27761 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
27762 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
27763 storage_type = config['persistence'] = 'cookie';
27764 }
27765
27766 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
27767 this.storage = _.localStorage;
27768 } else {
27769 this.storage = _.cookie;
27770 }
27771
27772 this.load();
27773 this.update_config(config);
27774 this.upgrade();
27775 this.save();
27776 };
27777
27778 MixpanelPersistence.prototype.properties = function() {
27779 var p = {};
27780
27781 this.load();
27782
27783 // Filter out reserved properties
27784 _.each(this['props'], function(v, k) {
27785 if (!_.include(RESERVED_PROPERTIES, k)) {
27786 p[k] = v;
27787 }
27788 });
27789 return p;
27790 };
27791
27792 MixpanelPersistence.prototype.load = function() {
27793 if (this.disabled) { return; }
27794
27795 var entry = this.storage.parse(this.name);
27796
27797 if (entry) {
27798 this['props'] = _.extend({}, entry);
27799 }
27800 };
27801
27802 MixpanelPersistence.prototype.upgrade = function() {
27803 var old_cookie,
27804 old_localstorage;
27805
27806 // if transferring from cookie to localStorage or vice-versa, copy existing
27807 // super properties over to new storage mode
27808 if (this.storage === _.localStorage) {
27809 old_cookie = _.cookie.parse(this.name);
27810
27811 _.cookie.remove(this.name);
27812 _.cookie.remove(this.name, true);
27813
27814 if (old_cookie) {
27815 this.register_once(old_cookie);
27816 }
27817 } else if (this.storage === _.cookie) {
27818 old_localstorage = _.localStorage.parse(this.name);
27819
27820 _.localStorage.remove(this.name);
27821
27822 if (old_localstorage) {
27823 this.register_once(old_localstorage);
27824 }
27825 }
27826 };
27827
27828 MixpanelPersistence.prototype.save = function() {
27829 if (this.disabled) { return; }
27830
27831 this.storage.set(
27832 this.name,
27833 JSONStringify(this['props']),
27834 this.expire_days,
27835 this.cross_subdomain,
27836 this.secure,
27837 this.cross_site,
27838 this.cookie_domain
27839 );
27840 };
27841
27842 MixpanelPersistence.prototype.load_prop = function(key) {
27843 this.load();
27844 return this['props'][key];
27845 };
27846
27847 MixpanelPersistence.prototype.remove = function() {
27848 // remove both domain and subdomain cookies
27849 this.storage.remove(this.name, false, this.cookie_domain);
27850 this.storage.remove(this.name, true, this.cookie_domain);
27851 };
27852
27853 // removes the storage entry and deletes all loaded data
27854 // forced name for tests
27855 MixpanelPersistence.prototype.clear = function() {
27856 this.remove();
27857 this['props'] = {};
27858 };
27859
27860 /**
27861 * @param {Object} props
27862 * @param {*=} default_value
27863 * @param {number=} days
27864 */
27865 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
27866 if (_.isObject(props)) {
27867 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
27868 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
27869
27870 this.load();
27871
27872 _.each(props, function(val, prop) {
27873 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
27874 this['props'][prop] = val;
27875 }
27876 }, this);
27877
27878 this.save();
27879
27880 return true;
27881 }
27882 return false;
27883 };
27884
27885 /**
27886 * @param {Object} props
27887 * @param {number=} days
27888 */
27889 MixpanelPersistence.prototype.register = function(props, days) {
27890 if (_.isObject(props)) {
27891 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
27892
27893 this.load();
27894 _.extend(this['props'], props);
27895 this.save();
27896
27897 return true;
27898 }
27899 return false;
27900 };
27901
27902 MixpanelPersistence.prototype.unregister = function(prop) {
27903 this.load();
27904 if (prop in this['props']) {
27905 delete this['props'][prop];
27906 this.save();
27907 }
27908 };
27909
27910 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
27911 this.register(_.info.searchInfo(referrer));
27912 };
27913
27914 // EXPORTED METHOD, we test this directly.
27915 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
27916 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
27917 this.register_once({
27918 '$initial_referrer': referrer || '$direct',
27919 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
27920 }, '');
27921 };
27922
27923 MixpanelPersistence.prototype.get_referrer_info = function() {
27924 return _.strip_empty_properties({
27925 '$initial_referrer': this['props']['$initial_referrer'],
27926 '$initial_referring_domain': this['props']['$initial_referring_domain']
27927 });
27928 };
27929
27930 MixpanelPersistence.prototype.update_config = function(config) {
27931 this.default_expiry = this.expire_days = config['cookie_expiration'];
27932 this.set_disabled(config['disable_persistence']);
27933 this.set_cookie_domain(config['cookie_domain']);
27934 this.set_cross_site(config['cross_site_cookie']);
27935 this.set_cross_subdomain(config['cross_subdomain_cookie']);
27936 this.set_secure(config['secure_cookie']);
27937 };
27938
27939 MixpanelPersistence.prototype.set_disabled = function(disabled) {
27940 this.disabled = disabled;
27941 if (this.disabled) {
27942 this.remove();
27943 } else {
27944 this.save();
27945 }
27946 };
27947
27948 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
27949 if (cookie_domain !== this.cookie_domain) {
27950 this.remove();
27951 this.cookie_domain = cookie_domain;
27952 this.save();
27953 }
27954 };
27955
27956 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
27957 if (cross_site !== this.cross_site) {
27958 this.cross_site = cross_site;
27959 this.remove();
27960 this.save();
27961 }
27962 };
27963
27964 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
27965 if (cross_subdomain !== this.cross_subdomain) {
27966 this.cross_subdomain = cross_subdomain;
27967 this.remove();
27968 this.save();
27969 }
27970 };
27971
27972 MixpanelPersistence.prototype.get_cross_subdomain = function() {
27973 return this.cross_subdomain;
27974 };
27975
27976 MixpanelPersistence.prototype.set_secure = function(secure) {
27977 if (secure !== this.secure) {
27978 this.secure = secure ? true : false;
27979 this.remove();
27980 this.save();
27981 }
27982 };
27983
27984 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
27985 var q_key = this._get_queue_key(queue),
27986 q_data = data[queue],
27987 set_q = this._get_or_create_queue(SET_ACTION),
27988 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
27989 unset_q = this._get_or_create_queue(UNSET_ACTION),
27990 add_q = this._get_or_create_queue(ADD_ACTION),
27991 union_q = this._get_or_create_queue(UNION_ACTION),
27992 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
27993 append_q = this._get_or_create_queue(APPEND_ACTION, []);
27994
27995 if (q_key === SET_QUEUE_KEY) {
27996 // Update the set queue - we can override any existing values
27997 _.extend(set_q, q_data);
27998 // if there was a pending increment, override it
27999 // with the set.
28000 this._pop_from_people_queue(ADD_ACTION, q_data);
28001 // if there was a pending union, override it
28002 // with the set.
28003 this._pop_from_people_queue(UNION_ACTION, q_data);
28004 this._pop_from_people_queue(UNSET_ACTION, q_data);
28005 } else if (q_key === SET_ONCE_QUEUE_KEY) {
28006 // only queue the data if there is not already a set_once call for it.
28007 _.each(q_data, function(v, k) {
28008 if (!(k in set_once_q)) {
28009 set_once_q[k] = v;
28010 }
28011 });
28012 this._pop_from_people_queue(UNSET_ACTION, q_data);
28013 } else if (q_key === UNSET_QUEUE_KEY) {
28014 _.each(q_data, function(prop) {
28015
28016 // undo previously-queued actions on this key
28017 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
28018 if (prop in enqueued_obj) {
28019 delete enqueued_obj[prop];
28020 }
28021 });
28022 _.each(append_q, function(append_obj) {
28023 if (prop in append_obj) {
28024 delete append_obj[prop];
28025 }
28026 });
28027
28028 unset_q[prop] = true;
28029
28030 });
28031 } else if (q_key === ADD_QUEUE_KEY) {
28032 _.each(q_data, function(v, k) {
28033 // If it exists in the set queue, increment
28034 // the value
28035 if (k in set_q) {
28036 set_q[k] += v;
28037 } else {
28038 // If it doesn't exist, update the add
28039 // queue
28040 if (!(k in add_q)) {
28041 add_q[k] = 0;
28042 }
28043 add_q[k] += v;
28044 }
28045 }, this);
28046 this._pop_from_people_queue(UNSET_ACTION, q_data);
28047 } else if (q_key === UNION_QUEUE_KEY) {
28048 _.each(q_data, function(v, k) {
28049 if (_.isArray(v)) {
28050 if (!(k in union_q)) {
28051 union_q[k] = [];
28052 }
28053 // Prevent duplicate values
28054 _.each(v, function(item) {
28055 if (!_.include(union_q[k], item)) {
28056 union_q[k].push(item);
28057 }
28058 });
28059 }
28060 });
28061 this._pop_from_people_queue(UNSET_ACTION, q_data);
28062 } else if (q_key === REMOVE_QUEUE_KEY) {
28063 remove_q.push(q_data);
28064 this._pop_from_people_queue(APPEND_ACTION, q_data);
28065 } else if (q_key === APPEND_QUEUE_KEY) {
28066 append_q.push(q_data);
28067 this._pop_from_people_queue(UNSET_ACTION, q_data);
28068 }
28069
28070 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
28071 console$1.log(data);
28072
28073 this.save();
28074 };
28075
28076 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
28077 var q = this['props'][this._get_queue_key(queue)];
28078 if (!_.isUndefined(q)) {
28079 _.each(data, function(v, k) {
28080 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
28081 // list actions: only remove if both k+v match
28082 // e.g. remove should not override append in a case like
28083 // append({foo: 'bar'}); remove({foo: 'qux'})
28084 _.each(q, function(queued_action) {
28085 if (queued_action[k] === v) {
28086 delete queued_action[k];
28087 }
28088 });
28089 } else {
28090 delete q[k];
28091 }
28092 }, this);
28093 }
28094 };
28095
28096 MixpanelPersistence.prototype.load_queue = function(queue) {
28097 return this.load_prop(this._get_queue_key(queue));
28098 };
28099
28100 MixpanelPersistence.prototype._get_queue_key = function(queue) {
28101 if (queue === SET_ACTION) {
28102 return SET_QUEUE_KEY;
28103 } else if (queue === SET_ONCE_ACTION) {
28104 return SET_ONCE_QUEUE_KEY;
28105 } else if (queue === UNSET_ACTION) {
28106 return UNSET_QUEUE_KEY;
28107 } else if (queue === ADD_ACTION) {
28108 return ADD_QUEUE_KEY;
28109 } else if (queue === APPEND_ACTION) {
28110 return APPEND_QUEUE_KEY;
28111 } else if (queue === REMOVE_ACTION) {
28112 return REMOVE_QUEUE_KEY;
28113 } else if (queue === UNION_ACTION) {
28114 return UNION_QUEUE_KEY;
28115 } else {
28116 console$1.error('Invalid queue:', queue);
28117 }
28118 };
28119
28120 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
28121 var key = this._get_queue_key(queue);
28122 default_val = _.isUndefined(default_val) ? {} : default_val;
28123 return this['props'][key] || (this['props'][key] = default_val);
28124 };
28125
28126 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
28127 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
28128 timers[event_name] = timestamp;
28129 this['props'][EVENT_TIMERS_KEY] = timers;
28130 this.save();
28131 };
28132
28133 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
28134 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
28135 var timestamp = timers[event_name];
28136 if (!_.isUndefined(timestamp)) {
28137 delete this['props'][EVENT_TIMERS_KEY][event_name];
28138 this.save();
28139 }
28140 return timestamp;
28141 };
28142
28143 /* eslint camelcase: "off" */
28144
28145 /*
28146 * Mixpanel JS Library
28147 *
28148 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
28149 * http://mixpanel.com/
28150 *
28151 * Includes portions of Underscore.js
28152 * http://documentcloud.github.com/underscore/
28153 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
28154 * Released under the MIT License.
28155 */
28156
28157 /*
28158 SIMPLE STYLE GUIDE:
28159
28160 this.x === public function
28161 this._x === internal - only use within this file
28162 this.__x === private - only use within the class
28163
28164 Globals should be all caps
28165 */
28166
28167 var init_type; // MODULE or SNIPPET loader
28168 // allow bundlers to specify how extra code (recorder bundle) should be loaded
28169 // eslint-disable-next-line no-unused-vars
28170 var load_extra_bundle = function(src, _onload) {
28171 throw new Error(src + ' not available in this build.');
28172 };
28173
28174 var mixpanel_master; // main mixpanel instance / object
28175 var INIT_MODULE = 0;
28176 var INIT_SNIPPET = 1;
28177
28178 var IDENTITY_FUNC = function(x) {return x;};
28179
28180 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
28181 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
28182 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
28183 /** @const */ var DEVICE_ID_PREFIX = '$device:';
28184
28185
28186 /*
28187 * Dynamic... constants? Is that an oxymoron?
28188 */
28189 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
28190 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
28191 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
28192
28193 // IE<10 does not support cross-origin XHR's but script tags
28194 // with defer won't block window.onload; ENQUEUE_REQUESTS
28195 // should only be true for Opera<12
28196 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
28197
28198 // save reference to navigator.sendBeacon so it can be minified
28199 var sendBeacon = null;
28200 if (navigator['sendBeacon']) {
28201 sendBeacon = function() {
28202 // late reference to navigator.sendBeacon to allow patching/spying
28203 return navigator['sendBeacon'].apply(navigator, arguments);
28204 };
28205 }
28206
28207 var DEFAULT_API_ROUTES = {
28208 'track': 'track/',
28209 'engage': 'engage/',
28210 'groups': 'groups/',
28211 'record': 'record/',
28212 'flags': 'flags/'
28213 };
28214
28215 /*
28216 * Module-level globals
28217 */
28218 var DEFAULT_CONFIG = {
28219 'api_host': 'https://api-js.mixpanel.com',
28220 'api_routes': DEFAULT_API_ROUTES,
28221 'api_extra_query_params': {},
28222 'api_method': 'POST',
28223 'api_transport': 'XHR',
28224 'api_payload_format': PAYLOAD_TYPE_BASE64,
28225 'app_host': 'https://mixpanel.com',
28226 'autocapture': false,
28227 'cdn': 'https://cdn.mxpnl.com',
28228 'cross_site_cookie': false,
28229 'cross_subdomain_cookie': true,
28230 'error_reporter': NOOP_FUNC,
28231 'flags': false,
28232 'persistence': 'cookie',
28233 'persistence_name': '',
28234 'cookie_domain': '',
28235 'cookie_name': '',
28236 'loaded': NOOP_FUNC,
28237 'mp_loader': null,
28238 'track_marketing': true,
28239 'track_pageview': false,
28240 'skip_first_touch_marketing': false,
28241 'store_google': true,
28242 'stop_utm_persistence': false,
28243 'save_referrer': true,
28244 'test': false,
28245 'verbose': false,
28246 'img': false,
28247 'debug': false,
28248 'track_links_timeout': 300,
28249 'cookie_expiration': 365,
28250 'upgrade': false,
28251 'disable_persistence': false,
28252 'disable_cookie': false,
28253 'secure_cookie': false,
28254 'ip': true,
28255 'opt_out_tracking_by_default': false,
28256 'opt_out_persistence_by_default': false,
28257 'opt_out_tracking_persistence_type': 'localStorage',
28258 'opt_out_tracking_cookie_prefix': null,
28259 'property_blacklist': [],
28260 'xhr_headers': {}, // { header: value, header2: value }
28261 'ignore_dnt': false,
28262 'batch_requests': true,
28263 'batch_size': 50,
28264 'batch_flush_interval_ms': 5000,
28265 'batch_request_timeout_ms': 90000,
28266 'batch_autostart': true,
28267 'hooks': {},
28268 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
28269 'record_block_selector': 'img, video',
28270 'record_canvas': false,
28271 'record_collect_fonts': false,
28272 'record_heatmap_data': false,
28273 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
28274 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
28275 'record_mask_text_selector': '*',
28276 'record_max_ms': MAX_RECORDING_MS,
28277 'record_min_ms': 0,
28278 'record_sessions_percent': 0,
28279 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
28280 };
28281
28282 var DOM_LOADED = false;
28283
28284 /**
28285 * Mixpanel Library Object
28286 * @constructor
28287 */
28288 var MixpanelLib = function() {};
28289
28290
28291 /**
28292 * create_mplib(token:string, config:object, name:string)
28293 *
28294 * This function is used by the init method of MixpanelLib objects
28295 * as well as the main initializer at the end of the JSLib (that
28296 * initializes document.mixpanel as well as any additional instances
28297 * declared before this file has loaded).
28298 */
28299 var create_mplib = function(token, config, name) {
28300 var instance,
28301 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
28302
28303 if (target && init_type === INIT_MODULE) {
28304 instance = target;
28305 } else {
28306 if (target && !_.isArray(target)) {
28307 console$1.error('You have already initialized ' + name);
28308 return;
28309 }
28310 instance = new MixpanelLib();
28311 }
28312
28313 instance._cached_groups = {}; // cache groups in a pool
28314
28315 instance._init(token, config, name);
28316
28317 instance['people'] = new MixpanelPeople();
28318 instance['people']._init(instance);
28319
28320 if (!instance.get_config('skip_first_touch_marketing')) {
28321 // We need null UTM params in the object because
28322 // UTM parameters act as a tuple. If any UTM param
28323 // is present, then we set all UTM params including
28324 // empty ones together
28325 var utm_params = _.info.campaignParams(null);
28326 var initial_utm_params = {};
28327 var has_utm = false;
28328 _.each(utm_params, function(utm_value, utm_key) {
28329 initial_utm_params['initial_' + utm_key] = utm_value;
28330 if (utm_value) {
28331 has_utm = true;
28332 }
28333 });
28334 if (has_utm) {
28335 instance['people'].set_once(initial_utm_params);
28336 }
28337 }
28338
28339 // if any instance on the page has debug = true, we set the
28340 // global debug to be true
28341 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
28342
28343 // if target is not defined, we called init after the lib already
28344 // loaded, so there won't be an array of things to execute
28345 if (!_.isUndefined(target) && _.isArray(target)) {
28346 // Crunch through the people queue first - we queue this data up &
28347 // flush on identify, so it's better to do all these operations first
28348 instance._execute_array.call(instance['people'], target['people']);
28349 instance._execute_array(target);
28350 }
28351
28352 return instance;
28353 };
28354
28355 // Initialization methods
28356
28357 /**
28358 * This function initializes a new instance of the Mixpanel tracking object.
28359 * All new instances are added to the main mixpanel object as sub properties (such as
28360 * mixpanel.library_name) and also returned by this function. To define a
28361 * second instance on the page, you would call:
28362 *
28363 * mixpanel.init('new token', { your: 'config' }, 'library_name');
28364 *
28365 * and use it like so:
28366 *
28367 * mixpanel.library_name.track(...);
28368 *
28369 * @param {String} token Your Mixpanel API token
28370 * @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>.
28371 * @param {String} [name] The name for the new mixpanel instance that you want created
28372 */
28373 MixpanelLib.prototype.init = function (token, config, name) {
28374 if (_.isUndefined(name)) {
28375 this.report_error('You must name your new library: init(token, config, name)');
28376 return;
28377 }
28378 if (name === PRIMARY_INSTANCE_NAME) {
28379 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
28380 return;
28381 }
28382
28383 var instance = create_mplib(token, config, name);
28384 mixpanel_master[name] = instance;
28385 instance._loaded();
28386
28387 return instance;
28388 };
28389
28390 // mixpanel._init(token:string, config:object, name:string)
28391 //
28392 // This function sets up the current instance of the mixpanel
28393 // library. The difference between this method and the init(...)
28394 // method is this one initializes the actual instance, whereas the
28395 // init(...) method sets up a new library and calls _init on it.
28396 //
28397 MixpanelLib.prototype._init = function(token, config, name) {
28398 config = config || {};
28399
28400 this['__loaded'] = true;
28401 this['config'] = {};
28402
28403 var variable_features = {};
28404
28405 // default to JSON payload for standard mixpanel.com API hosts
28406 if (!('api_payload_format' in config)) {
28407 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
28408 if (api_host.match(/\.mixpanel\.com/)) {
28409 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
28410 }
28411 }
28412
28413 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
28414 'name': name,
28415 'token': token,
28416 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
28417 }));
28418
28419 this['_jsc'] = NOOP_FUNC;
28420
28421 this.__dom_loaded_queue = [];
28422 this.__request_queue = [];
28423 this.__disabled_events = [];
28424 this._flags = {
28425 'disable_all_events': false,
28426 'identify_called': false
28427 };
28428
28429 // set up request queueing/batching
28430 this.request_batchers = {};
28431 this._batch_requests = this.get_config('batch_requests');
28432 if (this._batch_requests) {
28433 if (!_.localStorage.is_supported(true) || !USE_XHR) {
28434 this._batch_requests = false;
28435 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
28436 _.each(this.get_batcher_configs(), function(batcher_config) {
28437 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
28438 _.localStorage.remove(batcher_config.queue_key);
28439 });
28440 } else {
28441 this.init_batchers();
28442 if (sendBeacon && win.addEventListener) {
28443 // Before page closes or hides (user tabs away etc), attempt to flush any events
28444 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
28445 // events will not be removed from the persistent store; if the site is loaded again,
28446 // the events will be flushed again on startup and deduplicated on the Mixpanel server
28447 // side.
28448 // There is no reliable way to capture only page close events, so we lean on the
28449 // visibilitychange and pagehide events as recommended at
28450 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
28451 // These events fire when the user clicks away from the current page/tab, so will occur
28452 // more frequently than page unload, but are the only mechanism currently for capturing
28453 // this scenario somewhat reliably.
28454 var flush_on_unload = _.bind(function() {
28455 if (!this.request_batchers.events.stopped) {
28456 this.request_batchers.events.flush({unloading: true});
28457 }
28458 }, this);
28459 win.addEventListener('pagehide', function(ev) {
28460 if (ev['persisted']) {
28461 flush_on_unload();
28462 }
28463 });
28464 win.addEventListener('visibilitychange', function() {
28465 if (document$1['visibilityState'] === 'hidden') {
28466 flush_on_unload();
28467 }
28468 });
28469 }
28470 }
28471 }
28472
28473 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
28474 this.unpersisted_superprops = {};
28475 this._gdpr_init();
28476
28477 var uuid = _.UUID();
28478 if (!this.get_distinct_id()) {
28479 // There is no need to set the distinct id
28480 // or the device id if something was already stored
28481 // in the persitence
28482 this.register_once({
28483 'distinct_id': DEVICE_ID_PREFIX + uuid,
28484 '$device_id': uuid
28485 }, '');
28486 }
28487
28488 this.flags = new FeatureFlagManager({
28489 getConfigFunc: _.bind(this.get_config, this),
28490 getDistinctIdFunc: _.bind(this.get_distinct_id, this),
28491 trackingFunc: _.bind(this.track, this)
28492 });
28493 this.flags.init();
28494 this['flags'] = this.flags;
28495
28496 this.autocapture = new Autocapture(this);
28497 this.autocapture.init();
28498
28499 this._init_tab_id();
28500 this._check_and_start_session_recording();
28501 };
28502
28503 /**
28504 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
28505 * This is primarily used for session recording, where data must be isolated to the current tab.
28506 */
28507 MixpanelLib.prototype._init_tab_id = function() {
28508 if (_.sessionStorage.is_supported()) {
28509 try {
28510 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
28511 var tab_id_key = 'mp_tab_id_' + key_suffix;
28512
28513 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
28514 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
28515 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
28516 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
28517 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
28518 }
28519
28520 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
28521 this.tab_id = _.sessionStorage.get(tab_id_key);
28522
28523 // 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,
28524 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
28525 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
28526 win.addEventListener('beforeunload', function () {
28527 _.sessionStorage.remove(should_generate_new_tab_id_key);
28528 });
28529 } catch(err) {
28530 this.report_error('Error initializing tab id', err);
28531 }
28532 } else {
28533 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
28534 }
28535 };
28536
28537 MixpanelLib.prototype.get_tab_id = function () {
28538 return this.tab_id || null;
28539 };
28540
28541 MixpanelLib.prototype._should_load_recorder = function () {
28542 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
28543 var tab_id = this.get_tab_id();
28544 return recording_registry_idb.init()
28545 .then(function () {
28546 return recording_registry_idb.getAll();
28547 })
28548 .then(function (recordings) {
28549 for (var i = 0; i < recordings.length; i++) {
28550 // if there are expired recordings in the registry, we should load the recorder to flush them
28551 // if there's a recording for this tab id, we should load the recorder to continue the recording
28552 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
28553 return true;
28554 }
28555 }
28556 return false;
28557 })
28558 .catch(_.bind(function (err) {
28559 this.report_error('Error checking recording registry', err);
28560 }, this));
28561 };
28562
28563 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
28564 if (!win['MutationObserver']) {
28565 console$1.critical('Browser does not support MutationObserver; skipping session recording');
28566 return;
28567 }
28568
28569 var loadRecorder = _.bind(function(startNewIfInactive) {
28570 var handleLoadedRecorder = _.bind(function() {
28571 this._recorder = this._recorder || new win['__mp_recorder'](this);
28572 this._recorder['resumeRecording'](startNewIfInactive);
28573 }, this);
28574
28575 if (_.isUndefined(win['__mp_recorder'])) {
28576 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
28577 } else {
28578 handleLoadedRecorder();
28579 }
28580 }, this);
28581
28582 /**
28583 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
28584 * 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.
28585 */
28586 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
28587 if (force_start || is_sampled) {
28588 loadRecorder(true);
28589 } else {
28590 this._should_load_recorder()
28591 .then(function (shouldLoad) {
28592 if (shouldLoad) {
28593 loadRecorder(false);
28594 }
28595 });
28596 }
28597 });
28598
28599 MixpanelLib.prototype.start_session_recording = function () {
28600 this._check_and_start_session_recording(true);
28601 };
28602
28603 MixpanelLib.prototype.stop_session_recording = function () {
28604 if (this._recorder) {
28605 this._recorder['stopRecording']();
28606 }
28607 };
28608
28609 MixpanelLib.prototype.pause_session_recording = function () {
28610 if (this._recorder) {
28611 this._recorder['pauseRecording']();
28612 }
28613 };
28614
28615 MixpanelLib.prototype.resume_session_recording = function () {
28616 if (this._recorder) {
28617 this._recorder['resumeRecording']();
28618 }
28619 };
28620
28621 MixpanelLib.prototype.is_recording_heatmap_data = function () {
28622 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
28623 };
28624
28625 MixpanelLib.prototype.get_session_recording_properties = function () {
28626 var props = {};
28627 var replay_id = this._get_session_replay_id();
28628 if (replay_id) {
28629 props['$mp_replay_id'] = replay_id;
28630 }
28631 return props;
28632 };
28633
28634 MixpanelLib.prototype.get_session_replay_url = function () {
28635 var replay_url = null;
28636 var replay_id = this._get_session_replay_id();
28637 if (replay_id) {
28638 var query_params = _.HTTPBuildQuery({
28639 'replay_id': replay_id,
28640 'distinct_id': this.get_distinct_id(),
28641 'token': this.get_config('token')
28642 });
28643 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
28644 }
28645 return replay_url;
28646 };
28647
28648 MixpanelLib.prototype._get_session_replay_id = function () {
28649 var replay_id = null;
28650 if (this._recorder) {
28651 replay_id = this._recorder['replayId'];
28652 }
28653 return replay_id || null;
28654 };
28655
28656 // "private" public method to reach into the recorder in test cases
28657 MixpanelLib.prototype.__get_recorder = function () {
28658 return this._recorder;
28659 };
28660
28661 // Private methods
28662
28663 MixpanelLib.prototype._loaded = function() {
28664 this.get_config('loaded')(this);
28665 this._set_default_superprops();
28666 this['people'].set_once(this['persistence'].get_referrer_info());
28667
28668 // `store_google` is now deprecated and previously stored UTM parameters are cleared
28669 // from persistence by default.
28670 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
28671 var utm_params = _.info.campaignParams(null);
28672 _.each(utm_params, function(_utm_value, utm_key) {
28673 // We need to unregister persisted UTM parameters so old values
28674 // are not mixed with the new UTM parameters
28675 this.unregister(utm_key);
28676 }.bind(this));
28677 }
28678 };
28679
28680 // update persistence with info on referrer, UTM params, etc
28681 MixpanelLib.prototype._set_default_superprops = function() {
28682 this['persistence'].update_search_keyword(document$1.referrer);
28683 // Registering super properties for UTM persistence by 'store_google' is deprecated.
28684 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
28685 this.register(_.info.campaignParams());
28686 }
28687 if (this.get_config('save_referrer')) {
28688 this['persistence'].update_referrer_info(document$1.referrer);
28689 }
28690 };
28691
28692 MixpanelLib.prototype._dom_loaded = function() {
28693 _.each(this.__dom_loaded_queue, function(item) {
28694 this._track_dom.apply(this, item);
28695 }, this);
28696
28697 if (!this.has_opted_out_tracking()) {
28698 _.each(this.__request_queue, function(item) {
28699 this._send_request.apply(this, item);
28700 }, this);
28701 }
28702
28703 delete this.__dom_loaded_queue;
28704 delete this.__request_queue;
28705 };
28706
28707 MixpanelLib.prototype._track_dom = function(DomClass, args) {
28708 if (this.get_config('img')) {
28709 this.report_error('You can\'t use DOM tracking functions with img = true.');
28710 return false;
28711 }
28712
28713 if (!DOM_LOADED) {
28714 this.__dom_loaded_queue.push([DomClass, args]);
28715 return false;
28716 }
28717
28718 var dt = new DomClass().init(this);
28719 return dt.track.apply(dt, args);
28720 };
28721
28722 /**
28723 * _prepare_callback() should be called by callers of _send_request for use
28724 * as the callback argument.
28725 *
28726 * If there is no callback, this returns null.
28727 * If we are going to make XHR/XDR requests, this returns a function.
28728 * If we are going to use script tags, this returns a string to use as the
28729 * callback GET param.
28730 */
28731 MixpanelLib.prototype._prepare_callback = function(callback, data) {
28732 if (_.isUndefined(callback)) {
28733 return null;
28734 }
28735
28736 if (USE_XHR) {
28737 var callback_function = function(response) {
28738 callback(response, data);
28739 };
28740 return callback_function;
28741 } else {
28742 // if the user gives us a callback, we store as a random
28743 // property on this instances jsc function and update our
28744 // callback string to reflect that.
28745 var jsc = this['_jsc'];
28746 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
28747 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
28748 jsc[randomized_cb] = function(response) {
28749 delete jsc[randomized_cb];
28750 callback(response, data);
28751 };
28752 return callback_string;
28753 }
28754 };
28755
28756 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
28757 var succeeded = true;
28758
28759 if (ENQUEUE_REQUESTS) {
28760 this.__request_queue.push(arguments);
28761 return succeeded;
28762 }
28763
28764 var DEFAULT_OPTIONS = {
28765 method: this.get_config('api_method'),
28766 transport: this.get_config('api_transport'),
28767 verbose: this.get_config('verbose')
28768 };
28769 var body_data = null;
28770
28771 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
28772 callback = options;
28773 options = null;
28774 }
28775 options = _.extend(DEFAULT_OPTIONS, options || {});
28776 if (!USE_XHR) {
28777 options.method = 'GET';
28778 }
28779 var use_post = options.method === 'POST';
28780 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
28781
28782 // needed to correctly format responses
28783 var verbose_mode = options.verbose;
28784 if (data['verbose']) { verbose_mode = true; }
28785
28786 if (this.get_config('test')) { data['test'] = 1; }
28787 if (verbose_mode) { data['verbose'] = 1; }
28788 if (this.get_config('img')) { data['img'] = 1; }
28789 if (!USE_XHR) {
28790 if (callback) {
28791 data['callback'] = callback;
28792 } else if (verbose_mode || this.get_config('test')) {
28793 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
28794 // which by itself is not valid javascript. Without a callback, this verbose output will
28795 // cause an error when returned via jsonp, so we force a no-op callback param.
28796 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
28797 data['callback'] = '(function(){})';
28798 }
28799 }
28800
28801 data['ip'] = this.get_config('ip')?1:0;
28802 data['_'] = new Date().getTime().toString();
28803
28804 if (use_post) {
28805 body_data = 'data=' + encodeURIComponent(data['data']);
28806 delete data['data'];
28807 }
28808
28809 _.extend(data, this.get_config('api_extra_query_params'));
28810
28811 url += '?' + _.HTTPBuildQuery(data);
28812
28813 var lib = this;
28814 if ('img' in data) {
28815 var img = document$1.createElement('img');
28816 img.src = url;
28817 document$1.body.appendChild(img);
28818 } else if (use_sendBeacon) {
28819 try {
28820 succeeded = sendBeacon(url, body_data);
28821 } catch (e) {
28822 lib.report_error(e);
28823 succeeded = false;
28824 }
28825 try {
28826 if (callback) {
28827 callback(succeeded ? 1 : 0);
28828 }
28829 } catch (e) {
28830 lib.report_error(e);
28831 }
28832 } else if (USE_XHR) {
28833 try {
28834 var req = new XMLHttpRequest();
28835 req.open(options.method, url, true);
28836
28837 var headers = this.get_config('xhr_headers');
28838 if (use_post) {
28839 headers['Content-Type'] = 'application/x-www-form-urlencoded';
28840 }
28841 _.each(headers, function(headerValue, headerName) {
28842 req.setRequestHeader(headerName, headerValue);
28843 });
28844
28845 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
28846 req.timeout = options.timeout_ms;
28847 var start_time = new Date().getTime();
28848 }
28849
28850 // send the mp_optout cookie
28851 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
28852 req.withCredentials = true;
28853 req.onreadystatechange = function () {
28854 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
28855 if (req.status === 200) {
28856 if (callback) {
28857 if (verbose_mode) {
28858 var response;
28859 try {
28860 response = _.JSONDecode(req.responseText);
28861 } catch (e) {
28862 lib.report_error(e);
28863 if (options.ignore_json_errors) {
28864 response = req.responseText;
28865 } else {
28866 return;
28867 }
28868 }
28869 callback(response);
28870 } else {
28871 callback(Number(req.responseText));
28872 }
28873 }
28874 } else {
28875 var error;
28876 if (
28877 req.timeout &&
28878 !req.status &&
28879 new Date().getTime() - start_time >= req.timeout
28880 ) {
28881 error = 'timeout';
28882 } else {
28883 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
28884 }
28885 lib.report_error(error);
28886 if (callback) {
28887 if (verbose_mode) {
28888 var response_headers = req['responseHeaders'] || {};
28889 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
28890 } else {
28891 callback(0);
28892 }
28893 }
28894 }
28895 }
28896 };
28897 req.send(body_data);
28898 } catch (e) {
28899 lib.report_error(e);
28900 succeeded = false;
28901 }
28902 } else {
28903 var script = document$1.createElement('script');
28904 script.type = 'text/javascript';
28905 script.async = true;
28906 script.defer = true;
28907 script.src = url;
28908 var s = document$1.getElementsByTagName('script')[0];
28909 s.parentNode.insertBefore(script, s);
28910 }
28911
28912 return succeeded;
28913 };
28914
28915 /**
28916 * _execute_array() deals with processing any mixpanel function
28917 * calls that were called before the Mixpanel library were loaded
28918 * (and are thus stored in an array so they can be called later)
28919 *
28920 * Note: we fire off all the mixpanel function calls && user defined
28921 * functions BEFORE we fire off mixpanel tracking calls. This is so
28922 * identify/register/set_config calls can properly modify early
28923 * tracking calls.
28924 *
28925 * @param {Array} array
28926 */
28927 MixpanelLib.prototype._execute_array = function(array) {
28928 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
28929 _.each(array, function(item) {
28930 if (item) {
28931 fn_name = item[0];
28932 if (_.isArray(fn_name)) {
28933 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
28934 } else if (typeof(item) === 'function') {
28935 item.call(this);
28936 } else if (_.isArray(item) && fn_name === 'alias') {
28937 alias_calls.push(item);
28938 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
28939 tracking_calls.push(item);
28940 } else {
28941 other_calls.push(item);
28942 }
28943 }
28944 }, this);
28945
28946 var execute = function(calls, context) {
28947 _.each(calls, function(item) {
28948 if (_.isArray(item[0])) {
28949 // chained call
28950 var caller = context;
28951 _.each(item, function(call) {
28952 caller = caller[call[0]].apply(caller, call.slice(1));
28953 });
28954 } else {
28955 this[item[0]].apply(this, item.slice(1));
28956 }
28957 }, context);
28958 };
28959
28960 execute(alias_calls, this);
28961 execute(other_calls, this);
28962 execute(tracking_calls, this);
28963 };
28964
28965 // request queueing utils
28966
28967 MixpanelLib.prototype.are_batchers_initialized = function() {
28968 return !!this.request_batchers.events;
28969 };
28970
28971 MixpanelLib.prototype.get_batcher_configs = function() {
28972 var queue_prefix = '__mpq_' + this.get_config('token');
28973 var api_routes = this.get_config('api_routes');
28974 this._batcher_configs = this._batcher_configs || {
28975 events: {type: 'events', endpoint: '/' + api_routes['track'], queue_key: queue_prefix + '_ev'},
28976 people: {type: 'people', endpoint: '/' + api_routes['engage'], queue_key: queue_prefix + '_pp'},
28977 groups: {type: 'groups', endpoint: '/' + api_routes['groups'], queue_key: queue_prefix + '_gr'}
28978 };
28979 return this._batcher_configs;
28980 };
28981
28982 MixpanelLib.prototype.init_batchers = function() {
28983 if (!this.are_batchers_initialized()) {
28984 var batcher_for = _.bind(function(attrs) {
28985 return new RequestBatcher(
28986 attrs.queue_key,
28987 {
28988 libConfig: this['config'],
28989 errorReporter: this.get_config('error_reporter'),
28990 sendRequestFunc: _.bind(function(data, options, cb) {
28991 this._send_request(
28992 this.get_config('api_host') + attrs.endpoint,
28993 this._encode_data_for_request(data),
28994 options,
28995 this._prepare_callback(cb, data)
28996 );
28997 }, this),
28998 beforeSendHook: _.bind(function(item) {
28999 return this._run_hook('before_send_' + attrs.type, item);
29000 }, this),
29001 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
29002 usePersistence: true,
29003 }
29004 );
29005 }, this);
29006 var batcher_configs = this.get_batcher_configs();
29007 this.request_batchers = {
29008 events: batcher_for(batcher_configs.events),
29009 people: batcher_for(batcher_configs.people),
29010 groups: batcher_for(batcher_configs.groups)
29011 };
29012 }
29013 if (this.get_config('batch_autostart')) {
29014 this.start_batch_senders();
29015 }
29016 };
29017
29018 MixpanelLib.prototype.start_batch_senders = function() {
29019 this._batchers_were_started = true;
29020 if (this.are_batchers_initialized()) {
29021 this._batch_requests = true;
29022 _.each(this.request_batchers, function(batcher) {
29023 batcher.start();
29024 });
29025 }
29026 };
29027
29028 MixpanelLib.prototype.stop_batch_senders = function() {
29029 this._batch_requests = false;
29030 _.each(this.request_batchers, function(batcher) {
29031 batcher.stop();
29032 batcher.clear();
29033 });
29034 };
29035
29036 /**
29037 * push() keeps the standard async-array-push
29038 * behavior around after the lib is loaded.
29039 * This is only useful for external integrations that
29040 * do not wish to rely on our convenience methods
29041 * (created in the snippet).
29042 *
29043 * ### Usage:
29044 * mixpanel.push(['register', { a: 'b' }]);
29045 *
29046 * @param {Array} item A [function_name, args...] array to be executed
29047 */
29048 MixpanelLib.prototype.push = function(item) {
29049 this._execute_array([item]);
29050 };
29051
29052 /**
29053 * Disable events on the Mixpanel object. If passed no arguments,
29054 * this function disables tracking of any event. If passed an
29055 * array of event names, those events will be disabled, but other
29056 * events will continue to be tracked.
29057 *
29058 * Note: this function does not stop other mixpanel functions from
29059 * firing, such as register() or people.set().
29060 *
29061 * @param {Array} [events] An array of event names to disable
29062 */
29063 MixpanelLib.prototype.disable = function(events) {
29064 if (typeof(events) === 'undefined') {
29065 this._flags.disable_all_events = true;
29066 } else {
29067 this.__disabled_events = this.__disabled_events.concat(events);
29068 }
29069 };
29070
29071 MixpanelLib.prototype._encode_data_for_request = function(data) {
29072 var encoded_data = JSONStringify(data);
29073 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
29074 encoded_data = _.base64Encode(encoded_data);
29075 }
29076 return {'data': encoded_data};
29077 };
29078
29079 // internal method for handling track vs batch-enqueue logic
29080 MixpanelLib.prototype._track_or_batch = function(options, callback) {
29081 var truncated_data = _.truncate(options.data, 255);
29082 var endpoint = options.endpoint;
29083 var batcher = options.batcher;
29084 var should_send_immediately = options.should_send_immediately;
29085 var send_request_options = options.send_request_options || {};
29086 callback = callback || NOOP_FUNC;
29087
29088 var request_enqueued_or_initiated = true;
29089 var send_request_immediately = _.bind(function() {
29090 if (!send_request_options.skip_hooks) {
29091 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
29092 }
29093 if (truncated_data) {
29094 console$1.log('MIXPANEL REQUEST:');
29095 console$1.log(truncated_data);
29096 return this._send_request(
29097 endpoint,
29098 this._encode_data_for_request(truncated_data),
29099 send_request_options,
29100 this._prepare_callback(callback, truncated_data)
29101 );
29102 } else {
29103 return null;
29104 }
29105 }, this);
29106
29107 if (this._batch_requests && !should_send_immediately) {
29108 batcher.enqueue(truncated_data).then(function(succeeded) {
29109 if (succeeded) {
29110 callback(1, truncated_data);
29111 } else {
29112 send_request_immediately();
29113 }
29114 });
29115 } else {
29116 request_enqueued_or_initiated = send_request_immediately();
29117 }
29118
29119 return request_enqueued_or_initiated && truncated_data;
29120 };
29121
29122 /**
29123 * Track an event. This is the most important and
29124 * frequently used Mixpanel function.
29125 *
29126 * ### Usage:
29127 *
29128 * // track an event named 'Registered'
29129 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
29130 *
29131 * // track an event using navigator.sendBeacon
29132 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
29133 *
29134 * To track link clicks or form submissions, see track_links() or track_forms().
29135 *
29136 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
29137 * @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.
29138 * @param {Object} [options] Optional configuration for this track request.
29139 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
29140 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
29141 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
29142 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
29143 * with the tracking payload sent to the API server is returned; otherwise false.
29144 */
29145 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
29146 if (!callback && typeof options === 'function') {
29147 callback = options;
29148 options = null;
29149 }
29150 options = options || {};
29151 var transport = options['transport']; // external API, don't minify 'transport' prop
29152 if (transport) {
29153 options.transport = transport; // 'transport' prop name can be minified internally
29154 }
29155 var should_send_immediately = options['send_immediately'];
29156 if (typeof callback !== 'function') {
29157 callback = NOOP_FUNC;
29158 }
29159
29160 if (_.isUndefined(event_name)) {
29161 this.report_error('No event name provided to mixpanel.track');
29162 return;
29163 }
29164
29165 if (this._event_is_disabled(event_name)) {
29166 callback(0);
29167 return;
29168 }
29169
29170 // set defaults
29171 properties = _.extend({}, properties);
29172 properties['token'] = this.get_config('token');
29173
29174 // set $duration if time_event was previously called for this event
29175 var start_timestamp = this['persistence'].remove_event_timer(event_name);
29176 if (!_.isUndefined(start_timestamp)) {
29177 var duration_in_ms = new Date().getTime() - start_timestamp;
29178 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
29179 }
29180
29181 this._set_default_superprops();
29182
29183 var marketing_properties = this.get_config('track_marketing')
29184 ? _.info.marketingParams()
29185 : {};
29186
29187 // note: extend writes to the first object, so lets make sure we
29188 // don't write to the persistence properties object and info
29189 // properties object by passing in a new object
29190
29191 // update properties with pageview info and super-properties
29192 properties = _.extend(
29193 {},
29194 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
29195 marketing_properties,
29196 this['persistence'].properties(),
29197 this.unpersisted_superprops,
29198 this.get_session_recording_properties(),
29199 properties
29200 );
29201
29202 var property_blacklist = this.get_config('property_blacklist');
29203 if (_.isArray(property_blacklist)) {
29204 _.each(property_blacklist, function(blacklisted_prop) {
29205 delete properties[blacklisted_prop];
29206 });
29207 } else {
29208 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
29209 }
29210
29211 var data = {
29212 'event': event_name,
29213 'properties': properties
29214 };
29215 var ret = this._track_or_batch({
29216 type: 'events',
29217 data: data,
29218 endpoint: this.get_config('api_host') + '/' + this.get_config('api_routes')['track'],
29219 batcher: this.request_batchers.events,
29220 should_send_immediately: should_send_immediately,
29221 send_request_options: options
29222 }, callback);
29223
29224 return ret;
29225 });
29226
29227 /**
29228 * Register the current user into one/many groups.
29229 *
29230 * ### Usage:
29231 *
29232 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
29233 * mixpanel.set_group('company', 'mixpanel')
29234 * mixpanel.set_group('company', 128746312)
29235 *
29236 * @param {String} group_key Group key
29237 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
29238 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29239 *
29240 */
29241 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
29242 if (!_.isArray(group_ids)) {
29243 group_ids = [group_ids];
29244 }
29245 var prop = {};
29246 prop[group_key] = group_ids;
29247 this.register(prop);
29248 return this['people'].set(group_key, group_ids, callback);
29249 });
29250
29251 /**
29252 * Add a new group for this user.
29253 *
29254 * ### Usage:
29255 *
29256 * mixpanel.add_group('company', 'mixpanel')
29257 *
29258 * @param {String} group_key Group key
29259 * @param {*} group_id A valid Mixpanel property type
29260 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29261 */
29262 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
29263 var old_values = this.get_property(group_key);
29264 var prop = {};
29265 if (old_values === undefined) {
29266 prop[group_key] = [group_id];
29267 this.register(prop);
29268 } else {
29269 if (old_values.indexOf(group_id) === -1) {
29270 old_values.push(group_id);
29271 prop[group_key] = old_values;
29272 this.register(prop);
29273 }
29274 }
29275 return this['people'].union(group_key, group_id, callback);
29276 });
29277
29278 /**
29279 * Remove a group from this user.
29280 *
29281 * ### Usage:
29282 *
29283 * mixpanel.remove_group('company', 'mixpanel')
29284 *
29285 * @param {String} group_key Group key
29286 * @param {*} group_id A valid Mixpanel property type
29287 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29288 */
29289 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
29290 var old_value = this.get_property(group_key);
29291 // if the value doesn't exist, the persistent store is unchanged
29292 if (old_value !== undefined) {
29293 var idx = old_value.indexOf(group_id);
29294 if (idx > -1) {
29295 old_value.splice(idx, 1);
29296 this.register({group_key: old_value});
29297 }
29298 if (old_value.length === 0) {
29299 this.unregister(group_key);
29300 }
29301 }
29302 return this['people'].remove(group_key, group_id, callback);
29303 });
29304
29305 /**
29306 * Track an event with specific groups.
29307 *
29308 * ### Usage:
29309 *
29310 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
29311 *
29312 * @param {String} event_name The name of the event (see `mixpanel.track()`)
29313 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
29314 * @param {Object=} groups An object mapping group name keys to one or more values
29315 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29316 */
29317 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
29318 var tracking_props = _.extend({}, properties || {});
29319 _.each(groups, function(v, k) {
29320 if (v !== null && v !== undefined) {
29321 tracking_props[k] = v;
29322 }
29323 });
29324 return this.track(event_name, tracking_props, callback);
29325 });
29326
29327 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
29328 return group_key + '_' + JSON.stringify(group_id);
29329 };
29330
29331 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
29332 delete this._cached_groups[this._create_map_key(group_key, group_id)];
29333 };
29334
29335 /**
29336 * Look up reference to a Mixpanel group
29337 *
29338 * ### Usage:
29339 *
29340 * mixpanel.get_group(group_key, group_id)
29341 *
29342 * @param {String} group_key Group key
29343 * @param {Object} group_id A valid Mixpanel property type
29344 * @returns {Object} A MixpanelGroup identifier
29345 */
29346 MixpanelLib.prototype.get_group = function (group_key, group_id) {
29347 var map_key = this._create_map_key(group_key, group_id);
29348 var group = this._cached_groups[map_key];
29349 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
29350 group = new MixpanelGroup();
29351 group._init(this, group_key, group_id);
29352 this._cached_groups[map_key] = group;
29353 }
29354 return group;
29355 };
29356
29357 /**
29358 * Track a default Mixpanel page view event, which includes extra default event properties to
29359 * improve page view data.
29360 *
29361 * ### Usage:
29362 *
29363 * // track a default $mp_web_page_view event
29364 * mixpanel.track_pageview();
29365 *
29366 * // track a page view event with additional event properties
29367 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
29368 *
29369 * // example approach to track page views on different page types as event properties
29370 * mixpanel.track_pageview({'page': 'pricing'});
29371 * mixpanel.track_pageview({'page': 'homepage'});
29372 *
29373 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
29374 * // individual pages on the same site or product. Use cases for custom event_name may be page
29375 * // views on different products or internal applications that are considered completely separate
29376 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
29377 *
29378 * ### Notes:
29379 *
29380 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
29381 * may be turned on for tracking page loads automatically.
29382 *
29383 * // track only page loads
29384 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
29385 *
29386 * // track when the URL changes in any manner
29387 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
29388 *
29389 * // track when the URL changes, ignoring any changes in the hash part
29390 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
29391 *
29392 * // track when the path changes, ignoring any query parameter or hash changes
29393 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
29394 *
29395 * @param {Object} [properties] An optional set of additional properties to send with the page view event
29396 * @param {Object} [options] Page view tracking options
29397 * @param {String} [options.event_name] - Alternate name for the tracking event
29398 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
29399 * with the tracking payload sent to the API server is returned; otherwise false.
29400 */
29401 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
29402 if (typeof properties !== 'object') {
29403 properties = {};
29404 }
29405 options = options || {};
29406 var event_name = options['event_name'] || '$mp_web_page_view';
29407
29408 var default_page_properties = _.extend(
29409 _.info.mpPageViewProperties(),
29410 _.info.campaignParams(),
29411 _.info.clickParams()
29412 );
29413
29414 var event_properties = _.extend(
29415 {},
29416 default_page_properties,
29417 properties
29418 );
29419
29420 return this.track(event_name, event_properties);
29421 });
29422
29423 /**
29424 * Track clicks on a set of document elements. Selector must be a
29425 * valid query. Elements must exist on the page at the time track_links is called.
29426 *
29427 * ### Usage:
29428 *
29429 * // track click for link id #nav
29430 * mixpanel.track_links('#nav', 'Clicked Nav Link');
29431 *
29432 * ### Notes:
29433 *
29434 * This function will wait up to 300 ms for the Mixpanel
29435 * servers to respond. If they have not responded by that time
29436 * it will head to the link without ensuring that your event
29437 * has been tracked. To configure this timeout please see the
29438 * set_config() documentation below.
29439 *
29440 * If you pass a function in as the properties argument, the
29441 * function will receive the DOMElement that triggered the
29442 * event as an argument. You are expected to return an object
29443 * from the function; any properties defined on this object
29444 * will be sent to mixpanel as event properties.
29445 *
29446 * @type {Function}
29447 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
29448 * @param {String} event_name The name of the event to track
29449 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
29450 */
29451 MixpanelLib.prototype.track_links = function() {
29452 return this._track_dom.call(this, LinkTracker, arguments);
29453 };
29454
29455 /**
29456 * Track form submissions. Selector must be a valid query.
29457 *
29458 * ### Usage:
29459 *
29460 * // track submission for form id 'register'
29461 * mixpanel.track_forms('#register', 'Created Account');
29462 *
29463 * ### Notes:
29464 *
29465 * This function will wait up to 300 ms for the mixpanel
29466 * servers to respond, if they have not responded by that time
29467 * it will head to the link without ensuring that your event
29468 * has been tracked. To configure this timeout please see the
29469 * set_config() documentation below.
29470 *
29471 * If you pass a function in as the properties argument, the
29472 * function will receive the DOMElement that triggered the
29473 * event as an argument. You are expected to return an object
29474 * from the function; any properties defined on this object
29475 * will be sent to mixpanel as event properties.
29476 *
29477 * @type {Function}
29478 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
29479 * @param {String} event_name The name of the event to track
29480 * @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
29481 */
29482 MixpanelLib.prototype.track_forms = function() {
29483 return this._track_dom.call(this, FormTracker, arguments);
29484 };
29485
29486 /**
29487 * Time an event by including the time between this call and a
29488 * later 'track' call for the same event in the properties sent
29489 * with the event.
29490 *
29491 * ### Usage:
29492 *
29493 * // time an event named 'Registered'
29494 * mixpanel.time_event('Registered');
29495 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
29496 *
29497 * When called for a particular event name, the next track call for that event
29498 * name will include the elapsed time between the 'time_event' and 'track'
29499 * calls. This value is stored as seconds in the '$duration' property.
29500 *
29501 * @param {String} event_name The name of the event.
29502 */
29503 MixpanelLib.prototype.time_event = function(event_name) {
29504 if (_.isUndefined(event_name)) {
29505 this.report_error('No event name provided to mixpanel.time_event');
29506 return;
29507 }
29508
29509 if (this._event_is_disabled(event_name)) {
29510 return;
29511 }
29512
29513 this['persistence'].set_event_timer(event_name, new Date().getTime());
29514 };
29515
29516 var REGISTER_DEFAULTS = {
29517 'persistent': true
29518 };
29519 /**
29520 * Helper to parse options param for register methods, maintaining
29521 * legacy support for plain "days" param instead of options object
29522 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
29523 * @returns {Object} options object
29524 */
29525 var options_for_register = function(days_or_options) {
29526 var options;
29527 if (_.isObject(days_or_options)) {
29528 options = days_or_options;
29529 } else if (!_.isUndefined(days_or_options)) {
29530 options = {'days': days_or_options};
29531 } else {
29532 options = {};
29533 }
29534 return _.extend({}, REGISTER_DEFAULTS, options);
29535 };
29536
29537 /**
29538 * Register a set of super properties, which are included with all
29539 * events. This will overwrite previous super property values.
29540 *
29541 * ### Usage:
29542 *
29543 * // register 'Gender' as a super property
29544 * mixpanel.register({'Gender': 'Female'});
29545 *
29546 * // register several super properties when a user signs up
29547 * mixpanel.register({
29548 * 'Email': 'jdoe@example.com',
29549 * 'Account Type': 'Free'
29550 * });
29551 *
29552 * // register only for the current pageload
29553 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
29554 *
29555 * @param {Object} properties An associative array of properties to store about the user
29556 * @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)
29557 * @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)
29558 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
29559 */
29560 MixpanelLib.prototype.register = function(props, days_or_options) {
29561 var options = options_for_register(days_or_options);
29562 if (options['persistent']) {
29563 this['persistence'].register(props, options['days']);
29564 } else {
29565 _.extend(this.unpersisted_superprops, props);
29566 }
29567 };
29568
29569 /**
29570 * Register a set of super properties only once. This will not
29571 * overwrite previous super property values, unlike register().
29572 *
29573 * ### Usage:
29574 *
29575 * // register a super property for the first time only
29576 * mixpanel.register_once({
29577 * 'First Login Date': new Date().toISOString()
29578 * });
29579 *
29580 * // register once, only for the current pageload
29581 * mixpanel.register_once({
29582 * 'First interaction time': new Date().toISOString()
29583 * }, 'None', {persistent: false});
29584 *
29585 * ### Notes:
29586 *
29587 * If default_value is specified, current super properties
29588 * with that value will be overwritten.
29589 *
29590 * @param {Object} properties An associative array of properties to store about the user
29591 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
29592 * @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)
29593 * @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)
29594 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
29595 */
29596 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
29597 var options = options_for_register(days_or_options);
29598 if (options['persistent']) {
29599 this['persistence'].register_once(props, default_value, options['days']);
29600 } else {
29601 if (typeof(default_value) === 'undefined') {
29602 default_value = 'None';
29603 }
29604 _.each(props, function(val, prop) {
29605 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
29606 this.unpersisted_superprops[prop] = val;
29607 }
29608 }, this);
29609 }
29610 };
29611
29612 /**
29613 * Delete a super property stored with the current user.
29614 *
29615 * @param {String} property The name of the super property to remove
29616 * @param {Object} [options]
29617 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
29618 */
29619 MixpanelLib.prototype.unregister = function(property, options) {
29620 options = options_for_register(options);
29621 if (options['persistent']) {
29622 this['persistence'].unregister(property);
29623 } else {
29624 delete this.unpersisted_superprops[property];
29625 }
29626 };
29627
29628 MixpanelLib.prototype._register_single = function(prop, value) {
29629 var props = {};
29630 props[prop] = value;
29631 this.register(props);
29632 };
29633
29634 /**
29635 * Identify a user with a unique ID to track user activity across
29636 * devices, tie a user to their events, and create a user profile.
29637 * If you never call this method, unique visitors are tracked using
29638 * a UUID generated the first time they visit the site.
29639 *
29640 * Call identify when you know the identity of the current user,
29641 * typically after login or signup. We recommend against using
29642 * identify for anonymous visitors to your site.
29643 *
29644 * ### Notes:
29645 * If your project has
29646 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
29647 * enabled, the identify method will connect pre- and
29648 * post-authentication events when appropriate.
29649 *
29650 * If your project does not have ID Merge enabled, identify will
29651 * change the user's local distinct_id to the unique ID you pass.
29652 * Events tracked prior to authentication will not be connected
29653 * to the same user identity. If ID Merge is disabled, alias can
29654 * be used to connect pre- and post-registration events.
29655 *
29656 * @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.
29657 */
29658 MixpanelLib.prototype.identify = function(
29659 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
29660 ) {
29661 // Optional Parameters
29662 // _set_callback:function A callback to be run if and when the People set queue is flushed
29663 // _add_callback:function A callback to be run if and when the People add queue is flushed
29664 // _append_callback:function A callback to be run if and when the People append queue is flushed
29665 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
29666 // _union_callback:function A callback to be run if and when the People union queue is flushed
29667 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
29668
29669 var previous_distinct_id = this.get_distinct_id();
29670 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
29671 // we allow the following condition if previous distinct_id is same as new_distinct_id
29672 // so that you can force flush people updates for anonymous profiles.
29673 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
29674 this.report_error('distinct_id cannot have $device: prefix');
29675 return -1;
29676 }
29677 this.register({'$user_id': new_distinct_id});
29678 }
29679
29680 if (!this.get_property('$device_id')) {
29681 // The persisted distinct id might not actually be a device id at all
29682 // it might be a distinct id of the user from before
29683 var device_id = previous_distinct_id;
29684 this.register_once({
29685 '$had_persisted_distinct_id': true,
29686 '$device_id': device_id
29687 }, '');
29688 }
29689
29690 // identify only changes the distinct id if it doesn't match either the existing or the alias;
29691 // if it's new, blow away the alias as well.
29692 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
29693 this.unregister(ALIAS_ID_KEY);
29694 this.register({'distinct_id': new_distinct_id});
29695 }
29696 this._flags.identify_called = true;
29697 // Flush any queued up people requests
29698 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
29699
29700 // send an $identify event any time the distinct_id is changing - logic on the server
29701 // will determine whether or not to do anything with it.
29702 if (new_distinct_id !== previous_distinct_id) {
29703 this.track('$identify', {
29704 'distinct_id': new_distinct_id,
29705 '$anon_distinct_id': previous_distinct_id
29706 }, {skip_hooks: true});
29707 }
29708
29709 // check feature flags again if distinct id has changed
29710 if (new_distinct_id !== previous_distinct_id) {
29711 this.flags.fetchFlags();
29712 }
29713 };
29714
29715 /**
29716 * Clears super properties and generates a new random distinct_id for this instance.
29717 * Useful for clearing data when a user logs out.
29718 */
29719 MixpanelLib.prototype.reset = function() {
29720 this['persistence'].clear();
29721 this._flags.identify_called = false;
29722 var uuid = _.UUID();
29723 this.register_once({
29724 'distinct_id': DEVICE_ID_PREFIX + uuid,
29725 '$device_id': uuid
29726 }, '');
29727 this.stop_session_recording();
29728 this._check_and_start_session_recording();
29729 };
29730
29731 /**
29732 * Returns the current distinct id of the user. This is either the id automatically
29733 * generated by the library or the id that has been passed by a call to identify().
29734 *
29735 * ### Notes:
29736 *
29737 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
29738 * init() has a loaded function available to handle this automatically. For example:
29739 *
29740 * // set distinct_id after the mixpanel library has loaded
29741 * mixpanel.init('YOUR PROJECT TOKEN', {
29742 * loaded: function(mixpanel) {
29743 * distinct_id = mixpanel.get_distinct_id();
29744 * }
29745 * });
29746 */
29747 MixpanelLib.prototype.get_distinct_id = function() {
29748 return this.get_property('distinct_id');
29749 };
29750
29751 /**
29752 * The alias method creates an alias which Mixpanel will use to
29753 * remap one id to another. Multiple aliases can point to the
29754 * same identifier.
29755 *
29756 * The following is a valid use of alias:
29757 *
29758 * mixpanel.alias('new_id', 'existing_id');
29759 * // You can add multiple id aliases to the existing ID
29760 * mixpanel.alias('newer_id', 'existing_id');
29761 *
29762 * Aliases can also be chained - the following is a valid example:
29763 *
29764 * mixpanel.alias('new_id', 'existing_id');
29765 * // chain newer_id - new_id - existing_id
29766 * mixpanel.alias('newer_id', 'new_id');
29767 *
29768 * Aliases cannot point to multiple identifiers - the following
29769 * example will not work:
29770 *
29771 * mixpanel.alias('new_id', 'existing_id');
29772 * // this is invalid as 'new_id' already points to 'existing_id'
29773 * mixpanel.alias('new_id', 'newer_id');
29774 *
29775 * ### Notes:
29776 *
29777 * If your project does not have
29778 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
29779 * enabled, the best practice is to call alias once when a unique
29780 * ID is first created for a user (e.g., when a user first registers
29781 * for an account). Do not use alias multiple times for a single
29782 * user without ID Merge enabled.
29783 *
29784 * @param {String} alias A unique identifier that you want to use for this user in the future.
29785 * @param {String} [original] The current identifier being used for this user.
29786 */
29787 MixpanelLib.prototype.alias = function(alias, original) {
29788 // If the $people_distinct_id key exists in persistence, there has been a previous
29789 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
29790 // this ID, as it will duplicate users.
29791 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
29792 this.report_error('Attempting to create alias for existing People user - aborting.');
29793 return -2;
29794 }
29795
29796 var _this = this;
29797 if (_.isUndefined(original)) {
29798 original = this.get_distinct_id();
29799 }
29800 if (alias !== original) {
29801 this._register_single(ALIAS_ID_KEY, alias);
29802 return this.track('$create_alias', {
29803 'alias': alias,
29804 'distinct_id': original
29805 }, {
29806 skip_hooks: true
29807 }, function() {
29808 // Flush the people queue
29809 _this.identify(alias);
29810 });
29811 } else {
29812 this.report_error('alias matches current distinct_id - skipping api call.');
29813 this.identify(alias);
29814 return -1;
29815 }
29816 };
29817
29818 /**
29819 * Provide a string to recognize the user by. The string passed to
29820 * this method will appear in the Mixpanel Streams product rather
29821 * than an automatically generated name. Name tags do not have to
29822 * be unique.
29823 *
29824 * This value will only be included in Streams data.
29825 *
29826 * @param {String} name_tag A human readable name for the user
29827 * @deprecated
29828 */
29829 MixpanelLib.prototype.name_tag = function(name_tag) {
29830 this._register_single('mp_name_tag', name_tag);
29831 };
29832
29833 /**
29834 * Update the configuration of a mixpanel library instance.
29835 *
29836 * The default config is:
29837 *
29838 * {
29839 * // host for requests (customizable for e.g. a local proxy)
29840 * api_host: 'https://api-js.mixpanel.com',
29841 *
29842 * // endpoints for different types of requests
29843 * api_routes: {
29844 * track: 'track/',
29845 * engage: 'engage/',
29846 * groups: 'groups/',
29847 * }
29848 *
29849 * // HTTP method for tracking requests
29850 * api_method: 'POST'
29851 *
29852 * // transport for sending requests ('XHR' or 'sendBeacon')
29853 * // NB: sendBeacon should only be used for scenarios such as
29854 * // page unload where a "best-effort" attempt to send is
29855 * // acceptable; the sendBeacon API does not support callbacks
29856 * // or any way to know the result of the request. Mixpanel
29857 * // tracking via sendBeacon will not support any event-
29858 * // batching or retry mechanisms.
29859 * api_transport: 'XHR'
29860 *
29861 * // request-batching/queueing/retry
29862 * batch_requests: true,
29863 *
29864 * // maximum number of events/updates to send in a single
29865 * // network request
29866 * batch_size: 50,
29867 *
29868 * // milliseconds to wait between sending batch requests
29869 * batch_flush_interval_ms: 5000,
29870 *
29871 * // milliseconds to wait for network responses to batch requests
29872 * // before they are considered timed-out and retried
29873 * batch_request_timeout_ms: 90000,
29874 *
29875 * // override value for cookie domain, only useful for ensuring
29876 * // correct cross-subdomain cookies on unusual domains like
29877 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
29878 * // set cookies on a different domain than the current origin
29879 * cookie_domain: ''
29880 *
29881 * // super properties cookie expiration (in days)
29882 * cookie_expiration: 365
29883 *
29884 * // if true, cookie will be set with SameSite=None; Secure
29885 * // this is only useful in special situations, like embedded
29886 * // 3rd-party iframes that set up a Mixpanel instance
29887 * cross_site_cookie: false
29888 *
29889 * // super properties span subdomains
29890 * cross_subdomain_cookie: true
29891 *
29892 * // debug mode
29893 * debug: false
29894 *
29895 * // if this is true, the mixpanel cookie or localStorage entry
29896 * // will be deleted, and no user persistence will take place
29897 * disable_persistence: false
29898 *
29899 * // if this is true, Mixpanel will automatically determine
29900 * // City, Region and Country data using the IP address of
29901 * //the client
29902 * ip: true
29903 *
29904 * // opt users out of tracking by this Mixpanel instance by default
29905 * opt_out_tracking_by_default: false
29906 *
29907 * // opt users out of browser data storage by this Mixpanel instance by default
29908 * opt_out_persistence_by_default: false
29909 *
29910 * // persistence mechanism used by opt-in/opt-out methods - cookie
29911 * // or localStorage - falls back to cookie if localStorage is unavailable
29912 * opt_out_tracking_persistence_type: 'localStorage'
29913 *
29914 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
29915 * opt_out_tracking_cookie_prefix: null
29916 *
29917 * // type of persistent store for super properties (cookie/
29918 * // localStorage) if set to 'localStorage', any existing
29919 * // mixpanel cookie value with the same persistence_name
29920 * // will be transferred to localStorage and deleted
29921 * persistence: 'cookie'
29922 *
29923 * // name for super properties persistent store
29924 * persistence_name: ''
29925 *
29926 * // names of properties/superproperties which should never
29927 * // be sent with track() calls
29928 * property_blacklist: []
29929 *
29930 * // if this is true, mixpanel cookies will be marked as
29931 * // secure, meaning they will only be transmitted over https
29932 * secure_cookie: false
29933 *
29934 * // disables enriching user profiles with first touch marketing data
29935 * skip_first_touch_marketing: false
29936 *
29937 * // the amount of time track_links will
29938 * // wait for Mixpanel's servers to respond
29939 * track_links_timeout: 300
29940 *
29941 * // adds any UTM parameters and click IDs present on the page to any events fired
29942 * track_marketing: true
29943 *
29944 * // enables automatic page view tracking using default page view events through
29945 * // the track_pageview() method
29946 * track_pageview: false
29947 *
29948 * // if you set upgrade to be true, the library will check for
29949 * // a cookie from our old js library and import super
29950 * // properties from it, then the old cookie is deleted
29951 * // The upgrade config option only works in the initialization,
29952 * // so make sure you set it when you create the library.
29953 * upgrade: false
29954 *
29955 * // extra HTTP request headers to set for each API request, in
29956 * // the format {'Header-Name': value}
29957 * xhr_headers: {}
29958 *
29959 * // whether to ignore or respect the web browser's Do Not Track setting
29960 * ignore_dnt: false
29961 * }
29962 *
29963 *
29964 * @param {Object} config A dictionary of new configuration values to update
29965 */
29966 MixpanelLib.prototype.set_config = function(config) {
29967 if (_.isObject(config)) {
29968 _.extend(this['config'], config);
29969
29970 var new_batch_size = config['batch_size'];
29971 if (new_batch_size) {
29972 _.each(this.request_batchers, function(batcher) {
29973 batcher.resetBatchSize();
29974 });
29975 }
29976
29977 if (!this.get_config('persistence_name')) {
29978 this['config']['persistence_name'] = this['config']['cookie_name'];
29979 }
29980 if (!this.get_config('disable_persistence')) {
29981 this['config']['disable_persistence'] = this['config']['disable_cookie'];
29982 }
29983
29984 if (this['persistence']) {
29985 this['persistence'].update_config(this['config']);
29986 }
29987 Config.DEBUG = Config.DEBUG || this.get_config('debug');
29988
29989 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
29990 this.autocapture.init();
29991 }
29992 }
29993 };
29994
29995 /**
29996 * returns the current config object for the library.
29997 */
29998 MixpanelLib.prototype.get_config = function(prop_name) {
29999 return this['config'][prop_name];
30000 };
30001
30002 /**
30003 * Fetch a hook function from config, with safe default, and run it
30004 * against the given arguments
30005 * @param {string} hook_name which hook to retrieve
30006 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
30007 */
30008 MixpanelLib.prototype._run_hook = function(hook_name) {
30009 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
30010 if (typeof ret === 'undefined') {
30011 this.report_error(hook_name + ' hook did not return a value');
30012 ret = null;
30013 }
30014 return ret;
30015 };
30016
30017 /**
30018 * Returns the value of the super property named property_name. If no such
30019 * property is set, get_property() will return the undefined value.
30020 *
30021 * ### Notes:
30022 *
30023 * get_property() can only be called after the Mixpanel library has finished loading.
30024 * init() has a loaded function available to handle this automatically. For example:
30025 *
30026 * // grab value for 'user_id' after the mixpanel library has loaded
30027 * mixpanel.init('YOUR PROJECT TOKEN', {
30028 * loaded: function(mixpanel) {
30029 * user_id = mixpanel.get_property('user_id');
30030 * }
30031 * });
30032 *
30033 * @param {String} property_name The name of the super property you want to retrieve
30034 */
30035 MixpanelLib.prototype.get_property = function(property_name) {
30036 return this['persistence'].load_prop([property_name]);
30037 };
30038
30039 MixpanelLib.prototype.toString = function() {
30040 var name = this.get_config('name');
30041 if (name !== PRIMARY_INSTANCE_NAME) {
30042 name = PRIMARY_INSTANCE_NAME + '.' + name;
30043 }
30044 return name;
30045 };
30046
30047 MixpanelLib.prototype._event_is_disabled = function(event_name) {
30048 return _.isBlockedUA(userAgent) ||
30049 this._flags.disable_all_events ||
30050 _.include(this.__disabled_events, event_name);
30051 };
30052
30053 // perform some housekeeping around GDPR opt-in/out state
30054 MixpanelLib.prototype._gdpr_init = function() {
30055 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
30056
30057 // try to convert opt-in/out cookies to localStorage if possible
30058 if (is_localStorage_requested && _.localStorage.is_supported()) {
30059 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
30060 this.opt_in_tracking({'enable_persistence': false});
30061 }
30062 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
30063 this.opt_out_tracking({'clear_persistence': false});
30064 }
30065 this.clear_opt_in_out_tracking({
30066 'persistence_type': 'cookie',
30067 'enable_persistence': false
30068 });
30069 }
30070
30071 // check whether the user has already opted out - if so, clear & disable persistence
30072 if (this.has_opted_out_tracking()) {
30073 this._gdpr_update_persistence({'clear_persistence': true});
30074
30075 // check whether we should opt out by default
30076 // note: we don't clear persistence here by default since opt-out default state is often
30077 // used as an initial state while GDPR information is being collected
30078 } else if (!this.has_opted_in_tracking() && (
30079 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
30080 )) {
30081 _.cookie.remove('mp_optout');
30082 this.opt_out_tracking({
30083 'clear_persistence': this.get_config('opt_out_persistence_by_default')
30084 });
30085 }
30086 };
30087
30088 /**
30089 * Enable or disable persistence based on options
30090 * only enable/disable if persistence is not already in this state
30091 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
30092 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
30093 */
30094 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
30095 var disabled;
30096 if (options && options['clear_persistence']) {
30097 disabled = true;
30098 } else if (options && options['enable_persistence']) {
30099 disabled = false;
30100 } else {
30101 return;
30102 }
30103
30104 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
30105 this['persistence'].set_disabled(disabled);
30106 }
30107
30108 if (disabled) {
30109 this.stop_batch_senders();
30110 this.stop_session_recording();
30111 } else {
30112 // only start batchers after opt-in if they have previously been started
30113 // in order to avoid unintentionally starting up batching for the first time
30114 if (this._batchers_were_started) {
30115 this.start_batch_senders();
30116 }
30117 }
30118 };
30119
30120 // call a base gdpr function after constructing the appropriate token and options args
30121 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
30122 options = _.extend({
30123 'track': _.bind(this.track, this),
30124 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
30125 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
30126 'cookie_expiration': this.get_config('cookie_expiration'),
30127 'cross_site_cookie': this.get_config('cross_site_cookie'),
30128 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
30129 'cookie_domain': this.get_config('cookie_domain'),
30130 'secure_cookie': this.get_config('secure_cookie'),
30131 'ignore_dnt': this.get_config('ignore_dnt')
30132 }, options);
30133
30134 // check if localStorage can be used for recording opt out status, fall back to cookie if not
30135 if (!_.localStorage.is_supported()) {
30136 options['persistence_type'] = 'cookie';
30137 }
30138
30139 return func(this.get_config('token'), {
30140 track: options['track'],
30141 trackEventName: options['track_event_name'],
30142 trackProperties: options['track_properties'],
30143 persistenceType: options['persistence_type'],
30144 persistencePrefix: options['cookie_prefix'],
30145 cookieDomain: options['cookie_domain'],
30146 cookieExpiration: options['cookie_expiration'],
30147 crossSiteCookie: options['cross_site_cookie'],
30148 crossSubdomainCookie: options['cross_subdomain_cookie'],
30149 secureCookie: options['secure_cookie'],
30150 ignoreDnt: options['ignore_dnt']
30151 });
30152 };
30153
30154 /**
30155 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
30156 *
30157 * ### Usage:
30158 *
30159 * // opt user in
30160 * mixpanel.opt_in_tracking();
30161 *
30162 * // opt user in with specific event name, properties, cookie configuration
30163 * mixpanel.opt_in_tracking({
30164 * track_event_name: 'User opted in',
30165 * track_event_properties: {
30166 * 'Email': 'jdoe@example.com'
30167 * },
30168 * cookie_expiration: 30,
30169 * secure_cookie: true
30170 * });
30171 *
30172 * @param {Object} [options] A dictionary of config options to override
30173 * @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)
30174 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
30175 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
30176 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
30177 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
30178 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
30179 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
30180 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
30181 * @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)
30182 * @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)
30183 * @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)
30184 */
30185 MixpanelLib.prototype.opt_in_tracking = function(options) {
30186 options = _.extend({
30187 'enable_persistence': true
30188 }, options);
30189
30190 this._gdpr_call_func(optIn, options);
30191 this._gdpr_update_persistence(options);
30192 };
30193
30194 /**
30195 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
30196 *
30197 * ### Usage:
30198 *
30199 * // opt user out
30200 * mixpanel.opt_out_tracking();
30201 *
30202 * // opt user out with different cookie configuration from Mixpanel instance
30203 * mixpanel.opt_out_tracking({
30204 * cookie_expiration: 30,
30205 * secure_cookie: true
30206 * });
30207 *
30208 * @param {Object} [options] A dictionary of config options to override
30209 * @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
30210 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
30211 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
30212 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
30213 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
30214 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
30215 * @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)
30216 * @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)
30217 * @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)
30218 */
30219 MixpanelLib.prototype.opt_out_tracking = function(options) {
30220 options = _.extend({
30221 'clear_persistence': true,
30222 'delete_user': true
30223 }, options);
30224
30225 // delete user and clear charges since these methods may be disabled by opt-out
30226 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
30227 this['people'].delete_user();
30228 this['people'].clear_charges();
30229 }
30230
30231 this._gdpr_call_func(optOut, options);
30232 this._gdpr_update_persistence(options);
30233 };
30234
30235 /**
30236 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
30237 *
30238 * ### Usage:
30239 *
30240 * var has_opted_in = mixpanel.has_opted_in_tracking();
30241 * // use has_opted_in value
30242 *
30243 * @param {Object} [options] A dictionary of config options to override
30244 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
30245 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
30246 * @returns {boolean} current opt-in status
30247 */
30248 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
30249 return this._gdpr_call_func(hasOptedIn, options);
30250 };
30251
30252 /**
30253 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
30254 *
30255 * ### Usage:
30256 *
30257 * var has_opted_out = mixpanel.has_opted_out_tracking();
30258 * // use has_opted_out value
30259 *
30260 * @param {Object} [options] A dictionary of config options to override
30261 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
30262 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
30263 * @returns {boolean} current opt-out status
30264 */
30265 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
30266 return this._gdpr_call_func(hasOptedOut, options);
30267 };
30268
30269 /**
30270 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
30271 *
30272 * ### Usage:
30273 *
30274 * // clear user's opt-in/out status
30275 * mixpanel.clear_opt_in_out_tracking();
30276 *
30277 * // clear user's opt-in/out status with specific cookie configuration - should match
30278 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
30279 * mixpanel.clear_opt_in_out_tracking({
30280 * cookie_expiration: 30,
30281 * secure_cookie: true
30282 * });
30283 *
30284 * @param {Object} [options] A dictionary of config options to override
30285 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
30286 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
30287 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
30288 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
30289 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
30290 * @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)
30291 * @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)
30292 * @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)
30293 */
30294 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
30295 options = _.extend({
30296 'enable_persistence': true
30297 }, options);
30298
30299 this._gdpr_call_func(clearOptInOut, options);
30300 this._gdpr_update_persistence(options);
30301 };
30302
30303 MixpanelLib.prototype.report_error = function(msg, err) {
30304 console$1.error.apply(console$1.error, arguments);
30305 try {
30306 if (!err && !(msg instanceof Error)) {
30307 msg = new Error(msg);
30308 }
30309 this.get_config('error_reporter')(msg, err);
30310 } catch(err) {
30311 console$1.error(err);
30312 }
30313 };
30314
30315 // EXPORTS (for closure compiler)
30316
30317 // MixpanelLib Exports
30318 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
30319 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
30320 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
30321 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
30322 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
30323 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
30324 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
30325 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
30326 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
30327 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
30328 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
30329 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
30330 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
30331 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
30332 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
30333 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
30334 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
30335 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
30336 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
30337 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
30338 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
30339 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
30340 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
30341 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
30342 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
30343 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
30344 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
30345 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
30346 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
30347 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
30348 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
30349 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
30350 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
30351 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
30352 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
30353 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
30354 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
30355 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
30356 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
30357
30358 // Exports intended only for testing
30359 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
30360
30361 // MixpanelPersistence Exports
30362 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
30363 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
30364 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
30365 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
30366 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
30367
30368
30369 var instances = {};
30370 var extend_mp = function() {
30371 // add all the sub mixpanel instances
30372 _.each(instances, function(instance, name) {
30373 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
30374 });
30375
30376 // add private functions as _
30377 mixpanel_master['_'] = _;
30378 };
30379
30380 var override_mp_init_func = function() {
30381 // we override the snippets init function to handle the case where a
30382 // user initializes the mixpanel library after the script loads & runs
30383 mixpanel_master['init'] = function(token, config, name) {
30384 if (name) {
30385 // initialize a sub library
30386 if (!mixpanel_master[name]) {
30387 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
30388 mixpanel_master[name]._loaded();
30389 }
30390 return mixpanel_master[name];
30391 } else {
30392 var instance = mixpanel_master;
30393
30394 if (instances[PRIMARY_INSTANCE_NAME]) {
30395 // main mixpanel lib already initialized
30396 instance = instances[PRIMARY_INSTANCE_NAME];
30397 } else if (token) {
30398 // intialize the main mixpanel lib
30399 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
30400 instance._loaded();
30401 instances[PRIMARY_INSTANCE_NAME] = instance;
30402 }
30403
30404 mixpanel_master = instance;
30405 if (init_type === INIT_SNIPPET) {
30406 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
30407 }
30408 extend_mp();
30409 }
30410 };
30411 };
30412
30413 var add_dom_loaded_handler = function() {
30414 // Cross browser DOM Loaded support
30415 function dom_loaded_handler() {
30416 // function flag since we only want to execute this once
30417 if (dom_loaded_handler.done) { return; }
30418 dom_loaded_handler.done = true;
30419
30420 DOM_LOADED = true;
30421 ENQUEUE_REQUESTS = false;
30422
30423 _.each(instances, function(inst) {
30424 inst._dom_loaded();
30425 });
30426 }
30427
30428 function do_scroll_check() {
30429 try {
30430 document$1.documentElement.doScroll('left');
30431 } catch(e) {
30432 setTimeout(do_scroll_check, 1);
30433 return;
30434 }
30435
30436 dom_loaded_handler();
30437 }
30438
30439 if (document$1.addEventListener) {
30440 if (document$1.readyState === 'complete') {
30441 // safari 4 can fire the DOMContentLoaded event before loading all
30442 // external JS (including this file). you will see some copypasta
30443 // on the internet that checks for 'complete' and 'loaded', but
30444 // 'loaded' is an IE thing
30445 dom_loaded_handler();
30446 } else {
30447 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
30448 }
30449 } else if (document$1.attachEvent) {
30450 // IE
30451 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
30452
30453 // check to make sure we arn't in a frame
30454 var toplevel = false;
30455 try {
30456 toplevel = win.frameElement === null;
30457 } catch(e) {
30458 // noop
30459 }
30460
30461 if (document$1.documentElement.doScroll && toplevel) {
30462 do_scroll_check();
30463 }
30464 }
30465
30466 // fallback handler, always will work
30467 _.register_event(win, 'load', dom_loaded_handler, true);
30468 };
30469
30470 function init_as_module(bundle_loader) {
30471 load_extra_bundle = bundle_loader;
30472 init_type = INIT_MODULE;
30473 mixpanel_master = new MixpanelLib();
30474
30475 override_mp_init_func();
30476 mixpanel_master['init']();
30477 add_dom_loaded_handler();
30478
30479 return mixpanel_master;
30480 }
30481
30482 // For loading separate bundles asynchronously via script tag
30483 // so that we don't load them until they are needed at runtime.
30484
30485 // For builds that have everything in one bundle, no extra work.
30486 function loadNoop (_src, onload) {
30487 onload();
30488 }
30489
30490 /* eslint camelcase: "off" */
30491
30492 var mixpanel = init_as_module(loadNoop);
30493
30494
30495
30496
30497 /***/ }),
30498
30499 /***/ "../node_modules/redux-thunk/es/index.js":
30500 /*!***********************************************!*\
30501 !*** ../node_modules/redux-thunk/es/index.js ***!
30502 \***********************************************/
30503 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
30504
30505 "use strict";
30506 __webpack_require__.r(__webpack_exports__);
30507 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
30508 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
30509 /* harmony export */ });
30510 /** A function that accepts a potential "extra argument" value to be injected later,
30511 * and returns an instance of the thunk middleware that uses that value
30512 */
30513 function createThunkMiddleware(extraArgument) {
30514 // Standard Redux middleware definition pattern:
30515 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
30516 var middleware = function middleware(_ref) {
30517 var dispatch = _ref.dispatch,
30518 getState = _ref.getState;
30519 return function (next) {
30520 return function (action) {
30521 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
30522 // If this "action" is really a function, call it and return the result.
30523 if (typeof action === 'function') {
30524 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
30525 return action(dispatch, getState, extraArgument);
30526 } // Otherwise, pass the action down the middleware chain as usual
30527
30528
30529 return next(action);
30530 };
30531 };
30532 };
30533
30534 return middleware;
30535 }
30536
30537 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
30538 // with whatever "extra arg" they want to inject into their thunks
30539
30540 thunk.withExtraArgument = createThunkMiddleware;
30541 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
30542
30543 /***/ }),
30544
30545 /***/ "../node_modules/redux/es/redux.js":
30546 /*!*****************************************!*\
30547 !*** ../node_modules/redux/es/redux.js ***!
30548 \*****************************************/
30549 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
30550
30551 "use strict";
30552 __webpack_require__.r(__webpack_exports__);
30553 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
30554 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
30555 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
30556 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
30557 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
30558 /* harmony export */ compose: () => (/* binding */ compose),
30559 /* harmony export */ createStore: () => (/* binding */ createStore),
30560 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
30561 /* harmony export */ });
30562 /* 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");
30563
30564
30565 /**
30566 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
30567 *
30568 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
30569 * during build.
30570 * @param {number} code
30571 */
30572 function formatProdErrorMessage(code) {
30573 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. ';
30574 }
30575
30576 // Inlined version of the `symbol-observable` polyfill
30577 var $$observable = (function () {
30578 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
30579 })();
30580
30581 /**
30582 * These are private action types reserved by Redux.
30583 * For any unknown actions, you must return the current state.
30584 * If the current state is undefined, you must return the initial state.
30585 * Do not reference these action types directly in your code.
30586 */
30587 var randomString = function randomString() {
30588 return Math.random().toString(36).substring(7).split('').join('.');
30589 };
30590
30591 var ActionTypes = {
30592 INIT: "@@redux/INIT" + randomString(),
30593 REPLACE: "@@redux/REPLACE" + randomString(),
30594 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
30595 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
30596 }
30597 };
30598
30599 /**
30600 * @param {any} obj The object to inspect.
30601 * @returns {boolean} True if the argument appears to be a plain object.
30602 */
30603 function isPlainObject(obj) {
30604 if (typeof obj !== 'object' || obj === null) return false;
30605 var proto = obj;
30606
30607 while (Object.getPrototypeOf(proto) !== null) {
30608 proto = Object.getPrototypeOf(proto);
30609 }
30610
30611 return Object.getPrototypeOf(obj) === proto;
30612 }
30613
30614 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
30615 function miniKindOf(val) {
30616 if (val === void 0) return 'undefined';
30617 if (val === null) return 'null';
30618 var type = typeof val;
30619
30620 switch (type) {
30621 case 'boolean':
30622 case 'string':
30623 case 'number':
30624 case 'symbol':
30625 case 'function':
30626 {
30627 return type;
30628 }
30629 }
30630
30631 if (Array.isArray(val)) return 'array';
30632 if (isDate(val)) return 'date';
30633 if (isError(val)) return 'error';
30634 var constructorName = ctorName(val);
30635
30636 switch (constructorName) {
30637 case 'Symbol':
30638 case 'Promise':
30639 case 'WeakMap':
30640 case 'WeakSet':
30641 case 'Map':
30642 case 'Set':
30643 return constructorName;
30644 } // other
30645
30646
30647 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
30648 }
30649
30650 function ctorName(val) {
30651 return typeof val.constructor === 'function' ? val.constructor.name : null;
30652 }
30653
30654 function isError(val) {
30655 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
30656 }
30657
30658 function isDate(val) {
30659 if (val instanceof Date) return true;
30660 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
30661 }
30662
30663 function kindOf(val) {
30664 var typeOfVal = typeof val;
30665
30666 if (true) {
30667 typeOfVal = miniKindOf(val);
30668 }
30669
30670 return typeOfVal;
30671 }
30672
30673 /**
30674 * @deprecated
30675 *
30676 * **We recommend using the `configureStore` method
30677 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
30678 *
30679 * Redux Toolkit is our recommended approach for writing Redux logic today,
30680 * including store setup, reducers, data fetching, and more.
30681 *
30682 * **For more details, please read this Redux docs page:**
30683 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
30684 *
30685 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
30686 * simplifies setup and helps avoid common bugs.
30687 *
30688 * You should not be using the `redux` core package by itself today, except for learning purposes.
30689 * The `createStore` method from the core `redux` package will not be removed, but we encourage
30690 * all users to migrate to using Redux Toolkit for all Redux code.
30691 *
30692 * If you want to use `createStore` without this visual deprecation warning, use
30693 * the `legacy_createStore` import instead:
30694 *
30695 * `import { legacy_createStore as createStore} from 'redux'`
30696 *
30697 */
30698
30699 function createStore(reducer, preloadedState, enhancer) {
30700 var _ref2;
30701
30702 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
30703 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.');
30704 }
30705
30706 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
30707 enhancer = preloadedState;
30708 preloadedState = undefined;
30709 }
30710
30711 if (typeof enhancer !== 'undefined') {
30712 if (typeof enhancer !== 'function') {
30713 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
30714 }
30715
30716 return enhancer(createStore)(reducer, preloadedState);
30717 }
30718
30719 if (typeof reducer !== 'function') {
30720 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
30721 }
30722
30723 var currentReducer = reducer;
30724 var currentState = preloadedState;
30725 var currentListeners = [];
30726 var nextListeners = currentListeners;
30727 var isDispatching = false;
30728 /**
30729 * This makes a shallow copy of currentListeners so we can use
30730 * nextListeners as a temporary list while dispatching.
30731 *
30732 * This prevents any bugs around consumers calling
30733 * subscribe/unsubscribe in the middle of a dispatch.
30734 */
30735
30736 function ensureCanMutateNextListeners() {
30737 if (nextListeners === currentListeners) {
30738 nextListeners = currentListeners.slice();
30739 }
30740 }
30741 /**
30742 * Reads the state tree managed by the store.
30743 *
30744 * @returns {any} The current state tree of your application.
30745 */
30746
30747
30748 function getState() {
30749 if (isDispatching) {
30750 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.');
30751 }
30752
30753 return currentState;
30754 }
30755 /**
30756 * Adds a change listener. It will be called any time an action is dispatched,
30757 * and some part of the state tree may potentially have changed. You may then
30758 * call `getState()` to read the current state tree inside the callback.
30759 *
30760 * You may call `dispatch()` from a change listener, with the following
30761 * caveats:
30762 *
30763 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
30764 * If you subscribe or unsubscribe while the listeners are being invoked, this
30765 * will not have any effect on the `dispatch()` that is currently in progress.
30766 * However, the next `dispatch()` call, whether nested or not, will use a more
30767 * recent snapshot of the subscription list.
30768 *
30769 * 2. The listener should not expect to see all state changes, as the state
30770 * might have been updated multiple times during a nested `dispatch()` before
30771 * the listener is called. It is, however, guaranteed that all subscribers
30772 * registered before the `dispatch()` started will be called with the latest
30773 * state by the time it exits.
30774 *
30775 * @param {Function} listener A callback to be invoked on every dispatch.
30776 * @returns {Function} A function to remove this change listener.
30777 */
30778
30779
30780 function subscribe(listener) {
30781 if (typeof listener !== 'function') {
30782 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
30783 }
30784
30785 if (isDispatching) {
30786 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.');
30787 }
30788
30789 var isSubscribed = true;
30790 ensureCanMutateNextListeners();
30791 nextListeners.push(listener);
30792 return function unsubscribe() {
30793 if (!isSubscribed) {
30794 return;
30795 }
30796
30797 if (isDispatching) {
30798 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.');
30799 }
30800
30801 isSubscribed = false;
30802 ensureCanMutateNextListeners();
30803 var index = nextListeners.indexOf(listener);
30804 nextListeners.splice(index, 1);
30805 currentListeners = null;
30806 };
30807 }
30808 /**
30809 * Dispatches an action. It is the only way to trigger a state change.
30810 *
30811 * The `reducer` function, used to create the store, will be called with the
30812 * current state tree and the given `action`. Its return value will
30813 * be considered the **next** state of the tree, and the change listeners
30814 * will be notified.
30815 *
30816 * The base implementation only supports plain object actions. If you want to
30817 * dispatch a Promise, an Observable, a thunk, or something else, you need to
30818 * wrap your store creating function into the corresponding middleware. For
30819 * example, see the documentation for the `redux-thunk` package. Even the
30820 * middleware will eventually dispatch plain object actions using this method.
30821 *
30822 * @param {Object} action A plain object representing “what changed”. It is
30823 * a good idea to keep actions serializable so you can record and replay user
30824 * sessions, or use the time travelling `redux-devtools`. An action must have
30825 * a `type` property which may not be `undefined`. It is a good idea to use
30826 * string constants for action types.
30827 *
30828 * @returns {Object} For convenience, the same action object you dispatched.
30829 *
30830 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
30831 * return something else (for example, a Promise you can await).
30832 */
30833
30834
30835 function dispatch(action) {
30836 if (!isPlainObject(action)) {
30837 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.");
30838 }
30839
30840 if (typeof action.type === 'undefined') {
30841 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
30842 }
30843
30844 if (isDispatching) {
30845 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
30846 }
30847
30848 try {
30849 isDispatching = true;
30850 currentState = currentReducer(currentState, action);
30851 } finally {
30852 isDispatching = false;
30853 }
30854
30855 var listeners = currentListeners = nextListeners;
30856
30857 for (var i = 0; i < listeners.length; i++) {
30858 var listener = listeners[i];
30859 listener();
30860 }
30861
30862 return action;
30863 }
30864 /**
30865 * Replaces the reducer currently used by the store to calculate the state.
30866 *
30867 * You might need this if your app implements code splitting and you want to
30868 * load some of the reducers dynamically. You might also need this if you
30869 * implement a hot reloading mechanism for Redux.
30870 *
30871 * @param {Function} nextReducer The reducer for the store to use instead.
30872 * @returns {void}
30873 */
30874
30875
30876 function replaceReducer(nextReducer) {
30877 if (typeof nextReducer !== 'function') {
30878 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
30879 }
30880
30881 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
30882 // Any reducers that existed in both the new and old rootReducer
30883 // will receive the previous state. This effectively populates
30884 // the new state tree with any relevant data from the old one.
30885
30886 dispatch({
30887 type: ActionTypes.REPLACE
30888 });
30889 }
30890 /**
30891 * Interoperability point for observable/reactive libraries.
30892 * @returns {observable} A minimal observable of state changes.
30893 * For more information, see the observable proposal:
30894 * https://github.com/tc39/proposal-observable
30895 */
30896
30897
30898 function observable() {
30899 var _ref;
30900
30901 var outerSubscribe = subscribe;
30902 return _ref = {
30903 /**
30904 * The minimal observable subscription method.
30905 * @param {Object} observer Any object that can be used as an observer.
30906 * The observer object should have a `next` method.
30907 * @returns {subscription} An object with an `unsubscribe` method that can
30908 * be used to unsubscribe the observable from the store, and prevent further
30909 * emission of values from the observable.
30910 */
30911 subscribe: function subscribe(observer) {
30912 if (typeof observer !== 'object' || observer === null) {
30913 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
30914 }
30915
30916 function observeState() {
30917 if (observer.next) {
30918 observer.next(getState());
30919 }
30920 }
30921
30922 observeState();
30923 var unsubscribe = outerSubscribe(observeState);
30924 return {
30925 unsubscribe: unsubscribe
30926 };
30927 }
30928 }, _ref[$$observable] = function () {
30929 return this;
30930 }, _ref;
30931 } // When a store is created, an "INIT" action is dispatched so that every
30932 // reducer returns their initial state. This effectively populates
30933 // the initial state tree.
30934
30935
30936 dispatch({
30937 type: ActionTypes.INIT
30938 });
30939 return _ref2 = {
30940 dispatch: dispatch,
30941 subscribe: subscribe,
30942 getState: getState,
30943 replaceReducer: replaceReducer
30944 }, _ref2[$$observable] = observable, _ref2;
30945 }
30946 /**
30947 * Creates a Redux store that holds the state tree.
30948 *
30949 * **We recommend using `configureStore` from the
30950 * `@reduxjs/toolkit` package**, which replaces `createStore`:
30951 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
30952 *
30953 * The only way to change the data in the store is to call `dispatch()` on it.
30954 *
30955 * There should only be a single store in your app. To specify how different
30956 * parts of the state tree respond to actions, you may combine several reducers
30957 * into a single reducer function by using `combineReducers`.
30958 *
30959 * @param {Function} reducer A function that returns the next state tree, given
30960 * the current state tree and the action to handle.
30961 *
30962 * @param {any} [preloadedState] The initial state. You may optionally specify it
30963 * to hydrate the state from the server in universal apps, or to restore a
30964 * previously serialized user session.
30965 * If you use `combineReducers` to produce the root reducer function, this must be
30966 * an object with the same shape as `combineReducers` keys.
30967 *
30968 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
30969 * to enhance the store with third-party capabilities such as middleware,
30970 * time travel, persistence, etc. The only store enhancer that ships with Redux
30971 * is `applyMiddleware()`.
30972 *
30973 * @returns {Store} A Redux store that lets you read the state, dispatch actions
30974 * and subscribe to changes.
30975 */
30976
30977 var legacy_createStore = createStore;
30978
30979 /**
30980 * Prints a warning in the console if it exists.
30981 *
30982 * @param {String} message The warning message.
30983 * @returns {void}
30984 */
30985 function warning(message) {
30986 /* eslint-disable no-console */
30987 if (typeof console !== 'undefined' && typeof console.error === 'function') {
30988 console.error(message);
30989 }
30990 /* eslint-enable no-console */
30991
30992
30993 try {
30994 // This error was thrown as a convenience so that if you enable
30995 // "break on all exceptions" in your console,
30996 // it would pause the execution at this line.
30997 throw new Error(message);
30998 } catch (e) {} // eslint-disable-line no-empty
30999
31000 }
31001
31002 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
31003 var reducerKeys = Object.keys(reducers);
31004 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
31005
31006 if (reducerKeys.length === 0) {
31007 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
31008 }
31009
31010 if (!isPlainObject(inputState)) {
31011 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
31012 }
31013
31014 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
31015 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
31016 });
31017 unexpectedKeys.forEach(function (key) {
31018 unexpectedKeyCache[key] = true;
31019 });
31020 if (action && action.type === ActionTypes.REPLACE) return;
31021
31022 if (unexpectedKeys.length > 0) {
31023 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.");
31024 }
31025 }
31026
31027 function assertReducerShape(reducers) {
31028 Object.keys(reducers).forEach(function (key) {
31029 var reducer = reducers[key];
31030 var initialState = reducer(undefined, {
31031 type: ActionTypes.INIT
31032 });
31033
31034 if (typeof initialState === 'undefined') {
31035 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.");
31036 }
31037
31038 if (typeof reducer(undefined, {
31039 type: ActionTypes.PROBE_UNKNOWN_ACTION()
31040 }) === 'undefined') {
31041 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.");
31042 }
31043 });
31044 }
31045 /**
31046 * Turns an object whose values are different reducer functions, into a single
31047 * reducer function. It will call every child reducer, and gather their results
31048 * into a single state object, whose keys correspond to the keys of the passed
31049 * reducer functions.
31050 *
31051 * @param {Object} reducers An object whose values correspond to different
31052 * reducer functions that need to be combined into one. One handy way to obtain
31053 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
31054 * undefined for any action. Instead, they should return their initial state
31055 * if the state passed to them was undefined, and the current state for any
31056 * unrecognized action.
31057 *
31058 * @returns {Function} A reducer function that invokes every reducer inside the
31059 * passed object, and builds a state object with the same shape.
31060 */
31061
31062
31063 function combineReducers(reducers) {
31064 var reducerKeys = Object.keys(reducers);
31065 var finalReducers = {};
31066
31067 for (var i = 0; i < reducerKeys.length; i++) {
31068 var key = reducerKeys[i];
31069
31070 if (true) {
31071 if (typeof reducers[key] === 'undefined') {
31072 warning("No reducer provided for key \"" + key + "\"");
31073 }
31074 }
31075
31076 if (typeof reducers[key] === 'function') {
31077 finalReducers[key] = reducers[key];
31078 }
31079 }
31080
31081 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
31082 // keys multiple times.
31083
31084 var unexpectedKeyCache;
31085
31086 if (true) {
31087 unexpectedKeyCache = {};
31088 }
31089
31090 var shapeAssertionError;
31091
31092 try {
31093 assertReducerShape(finalReducers);
31094 } catch (e) {
31095 shapeAssertionError = e;
31096 }
31097
31098 return function combination(state, action) {
31099 if (state === void 0) {
31100 state = {};
31101 }
31102
31103 if (shapeAssertionError) {
31104 throw shapeAssertionError;
31105 }
31106
31107 if (true) {
31108 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
31109
31110 if (warningMessage) {
31111 warning(warningMessage);
31112 }
31113 }
31114
31115 var hasChanged = false;
31116 var nextState = {};
31117
31118 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
31119 var _key = finalReducerKeys[_i];
31120 var reducer = finalReducers[_key];
31121 var previousStateForKey = state[_key];
31122 var nextStateForKey = reducer(previousStateForKey, action);
31123
31124 if (typeof nextStateForKey === 'undefined') {
31125 var actionType = action && action.type;
31126 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.");
31127 }
31128
31129 nextState[_key] = nextStateForKey;
31130 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
31131 }
31132
31133 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
31134 return hasChanged ? nextState : state;
31135 };
31136 }
31137
31138 function bindActionCreator(actionCreator, dispatch) {
31139 return function () {
31140 return dispatch(actionCreator.apply(this, arguments));
31141 };
31142 }
31143 /**
31144 * Turns an object whose values are action creators, into an object with the
31145 * same keys, but with every function wrapped into a `dispatch` call so they
31146 * may be invoked directly. This is just a convenience method, as you can call
31147 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
31148 *
31149 * For convenience, you can also pass an action creator as the first argument,
31150 * and get a dispatch wrapped function in return.
31151 *
31152 * @param {Function|Object} actionCreators An object whose values are action
31153 * creator functions. One handy way to obtain it is to use ES6 `import * as`
31154 * syntax. You may also pass a single function.
31155 *
31156 * @param {Function} dispatch The `dispatch` function available on your Redux
31157 * store.
31158 *
31159 * @returns {Function|Object} The object mimicking the original object, but with
31160 * every action creator wrapped into the `dispatch` call. If you passed a
31161 * function as `actionCreators`, the return value will also be a single
31162 * function.
31163 */
31164
31165
31166 function bindActionCreators(actionCreators, dispatch) {
31167 if (typeof actionCreators === 'function') {
31168 return bindActionCreator(actionCreators, dispatch);
31169 }
31170
31171 if (typeof actionCreators !== 'object' || actionCreators === null) {
31172 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\"?");
31173 }
31174
31175 var boundActionCreators = {};
31176
31177 for (var key in actionCreators) {
31178 var actionCreator = actionCreators[key];
31179
31180 if (typeof actionCreator === 'function') {
31181 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
31182 }
31183 }
31184
31185 return boundActionCreators;
31186 }
31187
31188 /**
31189 * Composes single-argument functions from right to left. The rightmost
31190 * function can take multiple arguments as it provides the signature for
31191 * the resulting composite function.
31192 *
31193 * @param {...Function} funcs The functions to compose.
31194 * @returns {Function} A function obtained by composing the argument functions
31195 * from right to left. For example, compose(f, g, h) is identical to doing
31196 * (...args) => f(g(h(...args))).
31197 */
31198 function compose() {
31199 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
31200 funcs[_key] = arguments[_key];
31201 }
31202
31203 if (funcs.length === 0) {
31204 return function (arg) {
31205 return arg;
31206 };
31207 }
31208
31209 if (funcs.length === 1) {
31210 return funcs[0];
31211 }
31212
31213 return funcs.reduce(function (a, b) {
31214 return function () {
31215 return a(b.apply(void 0, arguments));
31216 };
31217 });
31218 }
31219
31220 /**
31221 * Creates a store enhancer that applies middleware to the dispatch method
31222 * of the Redux store. This is handy for a variety of tasks, such as expressing
31223 * asynchronous actions in a concise manner, or logging every action payload.
31224 *
31225 * See `redux-thunk` package as an example of the Redux middleware.
31226 *
31227 * Because middleware is potentially asynchronous, this should be the first
31228 * store enhancer in the composition chain.
31229 *
31230 * Note that each middleware will be given the `dispatch` and `getState` functions
31231 * as named arguments.
31232 *
31233 * @param {...Function} middlewares The middleware chain to be applied.
31234 * @returns {Function} A store enhancer applying the middleware.
31235 */
31236
31237 function applyMiddleware() {
31238 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
31239 middlewares[_key] = arguments[_key];
31240 }
31241
31242 return function (createStore) {
31243 return function () {
31244 var store = createStore.apply(void 0, arguments);
31245
31246 var _dispatch = function dispatch() {
31247 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
31248 };
31249
31250 var middlewareAPI = {
31251 getState: store.getState,
31252 dispatch: function dispatch() {
31253 return _dispatch.apply(void 0, arguments);
31254 }
31255 };
31256 var chain = middlewares.map(function (middleware) {
31257 return middleware(middlewareAPI);
31258 });
31259 _dispatch = compose.apply(void 0, chain)(store.dispatch);
31260 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
31261 dispatch: _dispatch
31262 });
31263 };
31264 };
31265 }
31266
31267
31268
31269
31270 /***/ }),
31271
31272 /***/ "../node_modules/reselect/es/defaultMemoize.js":
31273 /*!*****************************************************!*\
31274 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
31275 \*****************************************************/
31276 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31277
31278 "use strict";
31279 __webpack_require__.r(__webpack_exports__);
31280 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31281 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
31282 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
31283 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
31284 /* harmony export */ });
31285 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
31286 // https://github.com/erikras/lru-memoize
31287 var NOT_FOUND = 'NOT_FOUND';
31288
31289 function createSingletonCache(equals) {
31290 var entry;
31291 return {
31292 get: function get(key) {
31293 if (entry && equals(entry.key, key)) {
31294 return entry.value;
31295 }
31296
31297 return NOT_FOUND;
31298 },
31299 put: function put(key, value) {
31300 entry = {
31301 key: key,
31302 value: value
31303 };
31304 },
31305 getEntries: function getEntries() {
31306 return entry ? [entry] : [];
31307 },
31308 clear: function clear() {
31309 entry = undefined;
31310 }
31311 };
31312 }
31313
31314 function createLruCache(maxSize, equals) {
31315 var entries = [];
31316
31317 function get(key) {
31318 var cacheIndex = entries.findIndex(function (entry) {
31319 return equals(key, entry.key);
31320 }); // We found a cached entry
31321
31322 if (cacheIndex > -1) {
31323 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
31324
31325 if (cacheIndex > 0) {
31326 entries.splice(cacheIndex, 1);
31327 entries.unshift(entry);
31328 }
31329
31330 return entry.value;
31331 } // No entry found in cache, return sentinel
31332
31333
31334 return NOT_FOUND;
31335 }
31336
31337 function put(key, value) {
31338 if (get(key) === NOT_FOUND) {
31339 // TODO Is unshift slow?
31340 entries.unshift({
31341 key: key,
31342 value: value
31343 });
31344
31345 if (entries.length > maxSize) {
31346 entries.pop();
31347 }
31348 }
31349 }
31350
31351 function getEntries() {
31352 return entries;
31353 }
31354
31355 function clear() {
31356 entries = [];
31357 }
31358
31359 return {
31360 get: get,
31361 put: put,
31362 getEntries: getEntries,
31363 clear: clear
31364 };
31365 }
31366
31367 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
31368 return a === b;
31369 };
31370 function createCacheKeyComparator(equalityCheck) {
31371 return function areArgumentsShallowlyEqual(prev, next) {
31372 if (prev === null || next === null || prev.length !== next.length) {
31373 return false;
31374 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
31375
31376
31377 var length = prev.length;
31378
31379 for (var i = 0; i < length; i++) {
31380 if (!equalityCheck(prev[i], next[i])) {
31381 return false;
31382 }
31383 }
31384
31385 return true;
31386 };
31387 }
31388 // defaultMemoize now supports a configurable cache size with LRU behavior,
31389 // and optional comparison of the result value with existing values
31390 function defaultMemoize(func, equalityCheckOrOptions) {
31391 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
31392 equalityCheck: equalityCheckOrOptions
31393 };
31394 var _providedOptions$equa = providedOptions.equalityCheck,
31395 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
31396 _providedOptions$maxS = providedOptions.maxSize,
31397 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
31398 resultEqualityCheck = providedOptions.resultEqualityCheck;
31399 var comparator = createCacheKeyComparator(equalityCheck);
31400 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
31401
31402 function memoized() {
31403 var value = cache.get(arguments);
31404
31405 if (value === NOT_FOUND) {
31406 // @ts-ignore
31407 value = func.apply(null, arguments);
31408
31409 if (resultEqualityCheck) {
31410 var entries = cache.getEntries();
31411 var matchingEntry = entries.find(function (entry) {
31412 return resultEqualityCheck(entry.value, value);
31413 });
31414
31415 if (matchingEntry) {
31416 value = matchingEntry.value;
31417 }
31418 }
31419
31420 cache.put(arguments, value);
31421 }
31422
31423 return value;
31424 }
31425
31426 memoized.clearCache = function () {
31427 return cache.clear();
31428 };
31429
31430 return memoized;
31431 }
31432
31433 /***/ }),
31434
31435 /***/ "../node_modules/reselect/es/index.js":
31436 /*!********************************************!*\
31437 !*** ../node_modules/reselect/es/index.js ***!
31438 \********************************************/
31439 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
31440
31441 "use strict";
31442 __webpack_require__.r(__webpack_exports__);
31443 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31444 /* harmony export */ createSelector: () => (/* binding */ createSelector),
31445 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
31446 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
31447 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
31448 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
31449 /* harmony export */ });
31450 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
31451
31452
31453
31454 function getDependencies(funcs) {
31455 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
31456
31457 if (!dependencies.every(function (dep) {
31458 return typeof dep === 'function';
31459 })) {
31460 var dependencyTypes = dependencies.map(function (dep) {
31461 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
31462 }).join(', ');
31463 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
31464 }
31465
31466 return dependencies;
31467 }
31468
31469 function createSelectorCreator(memoize) {
31470 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
31471 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
31472 }
31473
31474 var createSelector = function createSelector() {
31475 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
31476 funcs[_key2] = arguments[_key2];
31477 }
31478
31479 var _recomputations = 0;
31480
31481 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
31482 // So, start by declaring the default value here.
31483 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
31484
31485
31486 var directlyPassedOptions = {
31487 memoizeOptions: undefined
31488 }; // Normally, the result func or "output selector" is the last arg
31489
31490 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
31491
31492 if (typeof resultFunc === 'object') {
31493 directlyPassedOptions = resultFunc; // and pop the real result func off
31494
31495 resultFunc = funcs.pop();
31496 }
31497
31498 if (typeof resultFunc !== 'function') {
31499 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
31500 } // Determine which set of options we're using. Prefer options passed directly,
31501 // but fall back to options given to createSelectorCreator.
31502
31503
31504 var _directlyPassedOption = directlyPassedOptions,
31505 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
31506 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
31507 // is an array. In most libs I've looked at, it's an equality function or options object.
31508 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
31509 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
31510 // we wrap it in an array so we can apply it.
31511
31512 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
31513 var dependencies = getDependencies(funcs);
31514 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
31515 _recomputations++; // apply arguments instead of spreading for performance.
31516
31517 return resultFunc.apply(null, arguments);
31518 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
31519
31520 var selector = memoize(function dependenciesChecker() {
31521 var params = [];
31522 var length = dependencies.length;
31523
31524 for (var i = 0; i < length; i++) {
31525 // apply arguments instead of spreading and mutate a local list of params for performance.
31526 // @ts-ignore
31527 params.push(dependencies[i].apply(null, arguments));
31528 } // apply arguments instead of spreading for performance.
31529
31530
31531 _lastResult = memoizedResultFunc.apply(null, params);
31532 return _lastResult;
31533 });
31534 Object.assign(selector, {
31535 resultFunc: resultFunc,
31536 memoizedResultFunc: memoizedResultFunc,
31537 dependencies: dependencies,
31538 lastResult: function lastResult() {
31539 return _lastResult;
31540 },
31541 recomputations: function recomputations() {
31542 return _recomputations;
31543 },
31544 resetRecomputations: function resetRecomputations() {
31545 return _recomputations = 0;
31546 }
31547 });
31548 return selector;
31549 }; // @ts-ignore
31550
31551
31552 return createSelector;
31553 }
31554 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
31555 // Manual definition of state and output arguments
31556 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
31557 if (selectorCreator === void 0) {
31558 selectorCreator = createSelector;
31559 }
31560
31561 if (typeof selectors !== 'object') {
31562 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
31563 }
31564
31565 var objectKeys = Object.keys(selectors);
31566 var resultSelector = selectorCreator( // @ts-ignore
31567 objectKeys.map(function (key) {
31568 return selectors[key];
31569 }), function () {
31570 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
31571 values[_key3] = arguments[_key3];
31572 }
31573
31574 return values.reduce(function (composition, value, index) {
31575 composition[objectKeys[index]] = value;
31576 return composition;
31577 }, {});
31578 });
31579 return resultSelector;
31580 };
31581
31582 /***/ }),
31583
31584 /***/ "@wordpress/i18n":
31585 /*!**************************!*\
31586 !*** external "wp.i18n" ***!
31587 \**************************/
31588 /***/ ((module) => {
31589
31590 "use strict";
31591 module.exports = wp.i18n;
31592
31593 /***/ })
31594
31595 /******/ });
31596 /************************************************************************/
31597 /******/ // The module cache
31598 /******/ var __webpack_module_cache__ = {};
31599 /******/
31600 /******/ // The require function
31601 /******/ function __webpack_require__(moduleId) {
31602 /******/ // Check if module is in cache
31603 /******/ var cachedModule = __webpack_module_cache__[moduleId];
31604 /******/ if (cachedModule !== undefined) {
31605 /******/ return cachedModule.exports;
31606 /******/ }
31607 /******/ // Create a new module (and put it into the cache)
31608 /******/ var module = __webpack_module_cache__[moduleId] = {
31609 /******/ // no module.id needed
31610 /******/ // no module.loaded needed
31611 /******/ exports: {}
31612 /******/ };
31613 /******/
31614 /******/ // Execute the module function
31615 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
31616 /******/
31617 /******/ // Return the exports of the module
31618 /******/ return module.exports;
31619 /******/ }
31620 /******/
31621 /************************************************************************/
31622 /******/ /* webpack/runtime/define property getters */
31623 /******/ (() => {
31624 /******/ // define getter functions for harmony exports
31625 /******/ __webpack_require__.d = (exports, definition) => {
31626 /******/ for(var key in definition) {
31627 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
31628 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
31629 /******/ }
31630 /******/ }
31631 /******/ };
31632 /******/ })();
31633 /******/
31634 /******/ /* webpack/runtime/global */
31635 /******/ (() => {
31636 /******/ __webpack_require__.g = (function() {
31637 /******/ if (typeof globalThis === 'object') return globalThis;
31638 /******/ try {
31639 /******/ return this || new Function('return this')();
31640 /******/ } catch (e) {
31641 /******/ if (typeof window === 'object') return window;
31642 /******/ }
31643 /******/ })();
31644 /******/ })();
31645 /******/
31646 /******/ /* webpack/runtime/hasOwnProperty shorthand */
31647 /******/ (() => {
31648 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
31649 /******/ })();
31650 /******/
31651 /******/ /* webpack/runtime/make namespace object */
31652 /******/ (() => {
31653 /******/ // define __esModule on exports
31654 /******/ __webpack_require__.r = (exports) => {
31655 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
31656 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
31657 /******/ }
31658 /******/ Object.defineProperty(exports, '__esModule', { value: true });
31659 /******/ };
31660 /******/ })();
31661 /******/
31662 /************************************************************************/
31663 var __webpack_exports__ = {};
31664 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
31665 (() => {
31666 "use strict";
31667 /*!******************************************!*\
31668 !*** ../core/common/assets/js/common.js ***!
31669 \******************************************/
31670
31671
31672 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
31673 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
31674 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
31675 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
31676 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
31677 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
31678 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
31679 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
31680 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
31681 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
31682 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
31683 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
31684 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
31685 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
31686 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
31687 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
31688 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
31689 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
31690 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)); }
31691 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
31692 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; }
31693 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
31694 function ElementorCommonApp() {
31695 (0, _classCallCheck2.default)(this, ElementorCommonApp);
31696 return _callSuper(this, ElementorCommonApp, arguments);
31697 }
31698 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
31699 return (0, _createClass2.default)(ElementorCommonApp, [{
31700 key: "setMarionetteTemplateCompiler",
31701 value: function setMarionetteTemplateCompiler() {
31702 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
31703 options = {
31704 evaluate: /<#([\s\S]+?)#>/g,
31705 interpolate: /{{{([\s\S]+?)}}}/g,
31706 escape: /{{([^}]+?)}}(?!})/g
31707 };
31708 return _.template(rawTemplate, options);
31709 };
31710 }
31711 }, {
31712 key: "getDefaultElements",
31713 value: function getDefaultElements() {
31714 return {
31715 $window: jQuery(window),
31716 $document: jQuery(document),
31717 $body: jQuery(document.body)
31718 };
31719 }
31720 }, {
31721 key: "initComponents",
31722 value: function initComponents() {
31723 this.events = new _events.default();
31724 this.eventsManager = new _module.default();
31725 this.debug = new _debug.default();
31726 this.helpers = new _helpers.default();
31727 this.storage = new _storage.default();
31728 this.dialogsManager = new DialogsManager.Instance();
31729 this.notifications = new _notifications.default();
31730 this.api = window.$e;
31731 $e.components.register(new _component2.default());
31732 elementorCommon.elements.$window.on('elementor:init-components', function () {
31733 $e.components.register(new _component.default());
31734 });
31735 this.initModules();
31736 }
31737 }, {
31738 key: "initModules",
31739 value: function initModules() {
31740 var _this = this;
31741 var activeModules = this.config.activeModules;
31742 var modules = {
31743 ajax: _ajax.default,
31744 finder: _finder.default,
31745 connect: _connect.default
31746 };
31747 activeModules.forEach(function (name) {
31748 if (modules[name]) {
31749 _this[name] = new modules[name](_this.config[name]);
31750 }
31751 });
31752 }
31753 }, {
31754 key: "compileArrayTemplateArgs",
31755 value: function compileArrayTemplateArgs(template, templateArgs) {
31756 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
31757 if (!number) {
31758 number = 1;
31759 }
31760 number--;
31761 return undefined !== templateArgs[number] ? templateArgs[number] : match;
31762 });
31763 }
31764 }, {
31765 key: "compileObjectTemplateArgs",
31766 value: function compileObjectTemplateArgs(template, templateArgs) {
31767 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
31768 return templateArgs[name] ? templateArgs[name] : match;
31769 });
31770 }
31771 }, {
31772 key: "compileTemplate",
31773 value: function compileTemplate(template, templateArgs) {
31774 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
31775 }
31776 }, {
31777 key: "translate",
31778 value: function translate(stringKey, context, templateArgs, i18nStack) {
31779 if (context) {
31780 i18nStack = this.config[context].i18n;
31781 }
31782 if (!i18nStack) {
31783 i18nStack = this.config.i18n;
31784 }
31785 var string = i18nStack[stringKey];
31786 if (undefined === string) {
31787 string = stringKey;
31788 }
31789 if (templateArgs) {
31790 string = this.compileTemplate(string, templateArgs);
31791 }
31792 return string;
31793 }
31794 }, {
31795 key: "onInit",
31796 value: function onInit() {
31797 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
31798 this.config = elementorCommonConfig;
31799 this.setMarionetteTemplateCompiler();
31800 }
31801 }]);
31802 }(elementorModules.ViewModule);
31803 window.elementorCommon = new ElementorCommonApp();
31804 elementorCommon.initComponents();
31805 })();
31806
31807 /******/ })()
31808 ;
31809 //# sourceMappingURL=common.js.map